@nivaro/react 0.3.123 → 0.3.125

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,6 +5,11 @@ function M(e) {
5
5
  const o = (e.changes ?? []).filter((s) => s && i(s.label)).map((s) => `${i(s.label)} ${i(s.from) || "—"} → ${i(s.to) || "—"}`);
6
6
  return o.length ? `changed ${r}: ${o.join(", ")}` : `changed ${r}`;
7
7
  }
8
+ function Ce(e) {
9
+ return (e.totals ?? []).filter((n) => n && i(n.label) && Number.isFinite(n.delta) && n.delta !== 0).map(
10
+ (n) => `${i(n.label)} ${n.delta > 0 ? "+" : "−"}${Math.abs(n.delta).toLocaleString("en-US", { maximumFractionDigits: 2 })}`
11
+ ).join(", ");
12
+ }
8
13
  const k = "a record you can't see", z = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i, W = {
9
14
  ai: "AI",
10
15
  api: "API",
@@ -49,7 +54,7 @@ function q(e) {
49
54
  function Q(e) {
50
55
  return /ies$/i.test(e) ? e.replace(/ies$/i, (n) => n === "IES" ? "Y" : "y") : /(ss|us|is)$/i.test(e) ? e : /(x|ch|sh|ss|us)es$/i.test(e) ? e.replace(/es$/i, "") : /s$/i.test(e) && e.length > 1 ? e.slice(0, -1) : e;
51
56
  }
52
- function E(e) {
57
+ function D(e) {
53
58
  return /[^aeiou]y$/i.test(e) ? e.replace(/y$/i, (n) => n === "Y" ? "IES" : "ies") : /(s|x|z|ch|sh)$/i.test(e) && !/^[A-Z0-9]+$/.test(e) ? `${e}es` : `${e}s`;
54
59
  }
55
60
  function g(e) {
@@ -122,39 +127,39 @@ const se = {
122
127
  nivaro_workflow_templates: "Pipeline",
123
128
  nivaro_workflow_transitions: "Pipeline move"
124
129
  }, ae = /^(nivaro|directus)_/i;
125
- function N(e) {
130
+ function C(e) {
126
131
  const n = g(e);
127
132
  return `${/^[aeiou]/i.test(n) ? "an" : "a"} ${n}`;
128
133
  }
129
- function C(e, n) {
134
+ function N(e, n) {
130
135
  var l;
131
136
  const t = i(e);
132
137
  if (!t) return { singular: "Record", plural: "Records" };
133
138
  const r = (l = n == null ? void 0 : n.collections) == null ? void 0 : l[t], o = typeof r == "string" ? { plural: r } : r ?? {}, s = i(o.plural), a = i(o.singular);
134
139
  if (a || s) {
135
- const f = a || A(s, Q), $ = s && s !== f ? s : A(f, E);
140
+ const f = a || y(s, Q), $ = s && s !== f ? s : y(f, D);
136
141
  return { singular: f, plural: $ };
137
142
  }
138
143
  const c = se[t];
139
- if (c) return { singular: c, plural: c === "Settings" ? c : A(c, E) };
140
- const u = q(t.replace(/^(nivaro|directus)_/, "")) || "Record", d = A(u, Q);
141
- return { singular: d, plural: A(d, E) };
144
+ if (c) return { singular: c, plural: c === "Settings" ? c : y(c, D) };
145
+ const u = q(t.replace(/^(nivaro|directus)_/, "")) || "Record", d = y(u, Q);
146
+ return { singular: d, plural: y(d, D) };
142
147
  }
143
- function A(e, n) {
148
+ function y(e, n) {
144
149
  const t = e.split(" ");
145
150
  return t[t.length - 1] = n(t[t.length - 1] ?? ""), t.join(" ");
146
151
  }
147
152
  function L(e, n, t) {
148
- const { singular: r, plural: o } = C(n, t);
153
+ const { singular: r, plural: o } = N(n, t);
149
154
  return `${e} ${g(e === 1 ? r : o)}`;
150
155
  }
151
156
  function ce(e, n) {
152
- const t = e.user ?? e.user_id ?? null, r = t ? P(t, n) : null;
157
+ const t = e.user ?? e.user_id ?? null, r = t ? T(t, n) : null;
153
158
  if (r) return r;
154
159
  const o = [i(e.first_name), i(e.last_name)].filter(Boolean).join(" ");
155
160
  return o || (i(e.user_email) ? i(e.user_email) : null);
156
161
  }
157
- function P(e, n) {
162
+ function T(e, n) {
158
163
  if (!e || !(n != null && n.users)) return null;
159
164
  const t = n.users;
160
165
  return i(t[e] ?? t[ie(e)] ?? t[i(e).toLowerCase()]) || null;
@@ -220,12 +225,12 @@ function Y(e) {
220
225
  };
221
226
  }
222
227
  function H(e, n) {
223
- const t = Y(e), r = ce(e, n), o = P(t.on_behalf_of, n) ?? r;
228
+ const t = Y(e), r = ce(e, n), o = T(t.on_behalf_of, n) ?? r;
224
229
  switch (t.kind) {
225
230
  case "person":
226
231
  return r ?? "Someone";
227
232
  case "view_as":
228
- return `${(P(t.id, n) ?? i(t.name) ?? "") || "An administrator"} as ${o ?? "someone"}`;
233
+ return `${(T(t.id, n) ?? i(t.name) ?? "") || "An administrator"} as ${o ?? "someone"}`;
229
234
  case "api_key":
230
235
  return `API key “${i(t.name) || (t.id ? `#${t.id}` : "unnamed")}”`;
231
236
  case "mcp": {
@@ -245,21 +250,21 @@ function H(e, n) {
245
250
  function I(e, n, t) {
246
251
  const r = i(n);
247
252
  if (!r || !i(e)) return null;
248
- const o = `${e}:${r}`, s = t == null ? void 0 : t.records, { singular: a } = C(e, t), c = ae.test(i(e));
253
+ const o = `${e}:${r}`, s = t == null ? void 0 : t.records, { singular: a } = N(e, t), c = ae.test(i(e));
249
254
  if (s && o in s) {
250
255
  const u = s[o];
251
- if (u == null) return c ? N(a) : k;
256
+ if (u == null) return c ? C(a) : k;
252
257
  const d = i(u);
253
- return d ? c && (d === r || z.test(d)) ? N(a) : d.toLowerCase().startsWith(a.toLowerCase()) ? d : `${a} ${d}` : c ? N(a) : a;
258
+ return d ? c && (d === r || z.test(d)) ? C(a) : d.toLowerCase().startsWith(a.toLowerCase()) ? d : `${a} ${d}` : c ? C(a) : a;
254
259
  }
255
- return c || z.test(r) ? N(a) : `${a} ${r}`;
260
+ return c || z.test(r) ? C(a) : `${a} ${r}`;
256
261
  }
257
262
  function Z(e, n, t) {
258
263
  var o;
259
264
  const r = (o = t == null ? void 0 : t.fields) == null ? void 0 : o[`${e ?? ""}.${n}`];
260
265
  return i(r) || q(n);
261
266
  }
262
- function T(e, n, t) {
267
+ function P(e, n, t) {
263
268
  const r = [...new Set(n)].map((o) => Z(e, o, t));
264
269
  return r.length === 0 ? "" : r.length === 1 ? r[0] : r.length <= 3 ? `${r.slice(0, -1).join(", ")} and ${r[r.length - 1]}` : `${r.slice(0, 2).join(", ")} and ${r.length - 2} other fields`;
265
270
  }
@@ -332,7 +337,7 @@ function J(e) {
332
337
  }
333
338
  return n;
334
339
  }
335
- const b = {
340
+ const x = {
336
341
  ack: "acknowledged",
337
342
  acknowledge: "acknowledged",
338
343
  acquire: "took",
@@ -473,12 +478,12 @@ function ee(e) {
473
478
  if (n.length === 0) return { verb: null, past: null, noun: "" };
474
479
  const t = n[n.length - 1];
475
480
  let r = -1;
476
- if (b[t]) r = n.length - 1;
477
- else if (b[n[0]]) r = 0;
478
- else for (let a = n.length - 1; a >= 0; a--) b[n[a]] && (r = a);
481
+ if (x[t]) r = n.length - 1;
482
+ else if (x[n[0]]) r = 0;
483
+ else for (let a = n.length - 1; a >= 0; a--) x[n[a]] && (r = a);
479
484
  if (r < 0) return { verb: null, past: null, noun: n.map(U).join(" ") };
480
485
  const o = n[r], s = [...n.slice(0, r), ...n.slice(r + 1)];
481
- return { verb: o, past: b[o], noun: s.map(U).join(" ") };
486
+ return { verb: o, past: x[o], noun: s.map(U).join(" ") };
482
487
  }
483
488
  function he(e, n) {
484
489
  return n ? /s$/.test(n) && !/ss$/.test(n) ? n : e && ve.has(e) ? `${/^[aeiou]/i.test(n) ? "an" : "a"} ${n}` : `the ${n}` : "";
@@ -499,18 +504,18 @@ function ne(e) {
499
504
  return `${/^[aeiou]/i.test(e) ? "an" : "a"} ${e}`;
500
505
  }
501
506
  function te(e, n) {
502
- const t = g(C(e.parent_collection, n).singular), r = `${/^[aeiou]/i.test(t) ? "an" : "a"} ${t} record`;
507
+ const t = g(N(e.parent_collection, n).singular), r = `${/^[aeiou]/i.test(t) ? "an" : "a"} ${t} record`;
503
508
  if (!i(e.parent_id)) return r;
504
509
  const o = I(e.parent_collection, e.parent_id, n);
505
510
  return !o || o === k ? r : o;
506
511
  }
507
- function D(e) {
512
+ function E(e) {
508
513
  const n = i(e.value);
509
514
  return n ? `${e.noun} ${n}` : ne(e.noun);
510
515
  }
511
516
  function re(e, n, t) {
512
517
  const r = te(n, t);
513
- return e === "create" ? `added ${D(n)} to ${r}` : e === "delete" ? `removed ${D(n)} from ${r}` : `updated ${D(n)} on ${r}`;
518
+ return e === "create" ? `added ${E(n)} to ${r}` : e === "delete" ? `removed ${E(n)} from ${r}` : `updated ${E(n)} on ${r}`;
514
519
  }
515
520
  function ke(e, n) {
516
521
  var l;
@@ -553,13 +558,13 @@ function Se(e, n) {
553
558
  return `changed ${r}: ${[...o.map(we), ...s].join("; ")}`;
554
559
  }
555
560
  const K = /* @__PURE__ */ new Set(["transition", "pipeline-transition"]);
556
- function Ne(e) {
561
+ function je(e) {
557
562
  const n = i(e).toLowerCase();
558
563
  return /approv/.test(n) ? "Approved" : /reject/.test(n) ? "Rejected" : /declin/.test(n) ? "Declined" : /send.?back|return/.test(n) ? "Sent back" : /submit/.test(n) ? "Submitted" : /cancel/.test(n) ? "Cancelled" : "Moved";
559
564
  }
560
- function ye(e, n) {
561
- var $, _, h, v, y;
562
- const t = i(e.action), r = e.collection ?? null, o = I(r, e.item, n), s = C(r, n), a = `${/^[aeiou]/i.test(s.singular) ? "an" : "a"} ${g(s.singular)}`, c = i(e.comment), u = o ? ` on ${o}` : "", d = S(e, n);
565
+ function be(e, n) {
566
+ var $, _, h, v, b;
567
+ const t = i(e.action), r = e.collection ?? null, o = I(r, e.item, n), s = N(r, n), a = `${/^[aeiou]/i.test(s.singular) ? "an" : "a"} ${g(s.singular)}`, c = i(e.comment), u = o ? ` on ${o}` : "", d = S(e, n);
563
568
  if (d && (t === "create" || t === "delete" || t === "update"))
564
569
  return re(t, d, n);
565
570
  if ((($ = e.event) == null ? void 0 : $.kind) === "start") {
@@ -584,14 +589,14 @@ function ye(e, n) {
584
589
  return e.o2m ? `${M(e.o2m)}${u}` : `changed related rows${u}`;
585
590
  const p = B(e);
586
591
  if (r === "nivaro_settings")
587
- return p.length ? `changed the ${T(r, p, n)} setting${p.length === 1 ? "" : "s"}` : "changed the settings";
592
+ return p.length ? `changed the ${P(r, p, n)} setting${p.length === 1 ? "" : "s"}` : "changed the settings";
588
593
  if (r === "nivaro_approval_instances" && ((v = e.why) != null && v.approval)) {
589
594
  const m = e.why.approval, w = I(m.collection, m.item, n);
590
- return `${(b[i(m.decision).toLowerCase()] ?? i(m.decision).toLowerCase()) || "decided on"} ${w ?? o ?? "an approval"}${m.chain ? ` (${m.chain})` : ""}`;
595
+ return `${(x[i(m.decision).toLowerCase()] ?? i(m.decision).toLowerCase()) || "decided on"} ${w ?? o ?? "an approval"}${m.chain ? ` (${m.chain})` : ""}`;
591
596
  }
592
597
  if (p.length) {
593
- const m = ((y = e.changes) == null ? void 0 : y.length) === 1 ? e.changes[0] : null;
594
- return m && "value" in m && X(r, m.field, m.value, n) ? `set ${Z(r, m.field, n)} to ${V(r, m.field, m.value, n)}${u}` : `changed ${T(r, p, n)}${u}`;
598
+ const m = ((b = e.changes) == null ? void 0 : b.length) === 1 ? e.changes[0] : null;
599
+ return m && "value" in m && X(r, m.field, m.value, n) ? `set ${Z(r, m.field, n)} to ${V(r, m.field, m.value, n)}${u}` : `changed ${P(r, p, n)}${u}`;
595
600
  }
596
601
  return `updated ${o ?? a}`;
597
602
  }
@@ -617,13 +622,13 @@ function ye(e, n) {
617
622
  return `exported ${p.rows != null ? L(p.rows, r, n) : g(s.plural)}${p.format ? ` to ${p.format}` : ""}`;
618
623
  }
619
624
  case "masquerade-start":
620
- return `started viewing as ${x(e, n, c)}`;
625
+ return `started viewing as ${A(e, n, c)}`;
621
626
  case "masquerade-stop":
622
- return `stopped viewing as ${x(e, n, c)}`;
627
+ return `stopped viewing as ${A(e, n, c)}`;
623
628
  case "token.generate":
624
- return `generated a static token for ${x(e, n, "")}`;
629
+ return `generated a static token for ${A(e, n, "")}`;
625
630
  case "token.revoke":
626
- return `revoked the static token of ${x(e, n, "")}`;
631
+ return `revoked the static token of ${A(e, n, "")}`;
627
632
  case "api_key_created":
628
633
  return `created ${o && o !== k ? o : "an API key"}`;
629
634
  case "api_key_revoked":
@@ -633,7 +638,7 @@ function ye(e, n) {
633
638
  case "api_key_simulate":
634
639
  return `tested requests as ${o && o !== k ? o : "an API key"}`;
635
640
  case "set_role":
636
- return `changed the role of ${x(e, n, "")}`;
641
+ return `changed the role of ${A(e, n, "")}`;
637
642
  case "bulk-write":
638
643
  case "bulk-action-execute": {
639
644
  const p = /(\d+)\s+(?:item|row)/i.exec(c), m = p ? L(Number(p[1]), r, n) : g(s.plural), w = t === "bulk-action-execute" ? /^(.+?)\s*\([^)]*\)\s+on\s/.exec(c) : null;
@@ -685,14 +690,14 @@ function ye(e, n) {
685
690
  const l = ee(t);
686
691
  return /settings$/.test(l.noun) && !l.verb ? `changed the ${l.noun}` : l.past ? o && l.noun && g(s.singular).toLowerCase().includes(l.noun.toLowerCase()) ? `${l.past} ${o}` : l.noun ? `${l.past} ${he(l.verb, l.noun)}${u}` : `${l.past} ${o ?? "something"}` : `recorded “${G(t)}”${u}`;
687
692
  }
688
- function x(e, n, t) {
689
- const r = i(e.item), o = P(r, n) ?? (t || null);
693
+ function A(e, n, t) {
694
+ const r = i(e.item), o = T(r, n) ?? (t || null);
690
695
  if (o) return o;
691
696
  const s = e.collection === "nivaro_users" ? I(e.collection, e.item, n) : null;
692
697
  return s && !z.test(r) ? s : "someone";
693
698
  }
694
- function Ae(e, n) {
695
- return `${H(e, n)} ${ye(e, n)}`;
699
+ function ye(e, n) {
700
+ return `${H(e, n)} ${be(e, n)}`;
696
701
  }
697
702
  function Re(e) {
698
703
  var c, u, d, l;
@@ -702,11 +707,11 @@ function Re(e) {
702
707
  const s = (l = e.why) == null ? void 0 : l.approval, a = s ? `${q(i(s.decision)) || "Decided"}${s.chain ? ` · ${s.chain}` : ""}${s.step != null && s.step !== "" ? ` · step ${s.step}` : ""}${i(s.comment) ? ` — “${i(s.comment)}”` : ""}` : null;
703
708
  return { reason: r, note: o, approval: a };
704
709
  }
705
- const xe = 6e4, be = 5e3;
706
- function R(e) {
710
+ const Ae = 6e4, xe = 5e3;
711
+ function j(e) {
707
712
  return e.timestamp ? new Date(e.timestamp).getTime() : Number.NaN;
708
713
  }
709
- function j(e) {
714
+ function R(e) {
710
715
  const n = Y(e);
711
716
  return `${n.kind}|${i(n.id)}|${i(e.user ?? e.user_id).toUpperCase()}`;
712
717
  }
@@ -714,13 +719,13 @@ function Ie(e) {
714
719
  const n = i(e.action);
715
720
  return !i(e.item) && (n.startsWith("bulk-") || n === "import-complete");
716
721
  }
717
- function je(e, n = {}) {
718
- const t = n.windowMs ?? xe, r = [], o = (s, a) => s.parent_collection === a.parent_collection && (!i(s.parent_id) || !i(a.parent_id) || i(s.parent_id) === i(a.parent_id));
722
+ function Le(e, n = {}) {
723
+ const t = n.windowMs ?? Ae, r = [], o = (s, a) => s.parent_collection === a.parent_collection && (!i(s.parent_id) || !i(a.parent_id) || i(s.parent_id) === i(a.parent_id));
719
724
  for (const s of e) {
720
725
  const a = r[r.length - 1], c = a == null ? void 0 : a.entries[a.entries.length - 1], u = i(s.group_key);
721
726
  if (a && c && n.labels) {
722
727
  const d = S(s, n.labels), l = S(c, n.labels);
723
- if (d && l && a.entries.every((f) => S(f, n.labels)) && o(d, l) && j(s) === j(c) && Math.abs(R(c) - R(s)) <= be) {
728
+ if (d && l && a.entries.every((f) => S(f, n.labels)) && o(d, l) && R(s) === R(c) && Math.abs(j(c) - j(s)) <= xe) {
724
729
  a.entries.push(s), a.by !== "group_key" && (a.by = "time");
725
730
  continue;
726
731
  }
@@ -731,7 +736,7 @@ function je(e, n = {}) {
731
736
  a.entries.push(s), a.by = "group_key";
732
737
  continue;
733
738
  }
734
- if (!u && !d && a.by !== "group_key" && i(s.action) === i(c.action) && i(s.collection) === i(c.collection) && i(s.collection) !== "" && j(s) === j(c) && Math.abs(R(c) - R(s)) <= t) {
739
+ if (!u && !d && a.by !== "group_key" && i(s.action) === i(c.action) && i(s.collection) === i(c.collection) && i(s.collection) !== "" && R(s) === R(c) && Math.abs(j(c) - j(s)) <= t) {
735
740
  a.entries.push(s), a.by = "time";
736
741
  continue;
737
742
  }
@@ -740,10 +745,10 @@ function je(e, n = {}) {
740
745
  }
741
746
  return r;
742
747
  }
743
- function Le(e, n) {
748
+ function Te(e, n) {
744
749
  if (e.length === 0) return "";
745
750
  const t = e.filter((v) => !Ie(v)), r = t[0] ?? e[0];
746
- if (t.length <= 1) return Ae(r, n);
751
+ if (t.length <= 1) return ye(r, n);
747
752
  const o = H(r, n), s = Se(t, n);
748
753
  if (s) return `${o} ${s}`;
749
754
  const c = new Set(t.map((v) => i(v.collection))).size === 1 ? r.collection ?? null : null, u = new Set(t.map((v) => i(v.item))), d = u.size > 1 ? u.size : t.length, l = c ? u.size === 1 && i(r.item) ? I(c, r.item, n) ?? L(d, c, n) : L(d, c, n) : `${d} records`, f = u.size === 1 && t.length > 1 ? ` ${t.length} times` : "", $ = new Set(
@@ -757,11 +762,11 @@ function Le(e, n) {
757
762
  var m;
758
763
  return i(((m = p.event) == null ? void 0 : m.to_label) ?? J(p.comment).to);
759
764
  })
760
- ), y = v.size === 1 ? [...v][0] : "";
761
- return `${o} moved ${l}${y ? ` to ${y}` : ""}${f}`;
765
+ ), b = v.size === 1 ? [...v][0] : "";
766
+ return `${o} moved ${l}${b ? ` to ${b}` : ""}${f}`;
762
767
  }
763
768
  if (_ === "update") {
764
- const v = Ce(t, c, n);
769
+ const v = Ne(t, c, n);
765
770
  return `${o} updated ${l}${f}${v ? `: ${v}` : ""}`;
766
771
  }
767
772
  if (_ === "create") return `${o} created ${l}`;
@@ -769,14 +774,14 @@ function Le(e, n) {
769
774
  if (_ === "picker-exclude") return `${o} hid ${l} from pickers${f}`;
770
775
  if (_ === "picker-include") return `${o} showed ${l} in pickers again${f}`;
771
776
  const h = ee(_);
772
- return h.past ? `${o} ${h.past} ${l}${h.noun && !g(C(c, n).plural).toLowerCase().includes(h.noun) ? ` (${h.noun})` : ""}${f}` : `${o} recorded “${G(_)}” on ${l}`;
777
+ return h.past ? `${o} ${h.past} ${l}${h.noun && !g(N(c, n).plural).toLowerCase().includes(h.noun) ? ` (${h.noun})` : ""}${f}` : `${o} recorded “${G(_)}” on ${l}`;
773
778
  }
774
- function Ce(e, n, t) {
779
+ function Ne(e, n, t) {
775
780
  var c;
776
781
  const r = ((c = e[0]) == null ? void 0 : c.changes) ?? null;
777
782
  if (!(r != null && r.length)) {
778
783
  const u = e.map((d) => B(d).sort().join(","));
779
- return u[0] && u.every((d) => d === u[0]) ? T(n, u[0].split(","), t) : "";
784
+ return u[0] && u.every((d) => d === u[0]) ? P(n, u[0].split(","), t) : "";
780
785
  }
781
786
  const o = (u) => JSON.stringify((u.changes ?? []).map((d) => [d.field, d.value ?? null]).sort());
782
787
  if (e.every((u) => o(u) === o(e[0])) && r.length <= 2 && r.every((u) => X(n, u.field, u.value, t)))
@@ -784,7 +789,7 @@ function Ce(e, n, t) {
784
789
  (u) => `${Z(n, u.field, t)} → ${V(n, u.field, u.value, t)}`
785
790
  ).join(", ");
786
791
  const a = new Set(e.flatMap((u) => (u.changes ?? []).map((d) => d.field)));
787
- return T(n, [...a], t);
792
+ return P(n, [...a], t);
788
793
  }
789
794
  function Pe(e) {
790
795
  var a;
@@ -810,33 +815,34 @@ function Pe(e) {
810
815
  };
811
816
  }
812
817
  export {
813
- xe as BURST_WINDOW_MS,
818
+ Ae as BURST_WINDOW_MS,
814
819
  k as HIDDEN_RECORD,
815
- be as LINK_WRITE_WINDOW_MS,
820
+ xe as LINK_WRITE_WINDOW_MS,
816
821
  ee as actionParts,
817
822
  Pe as activityLabelRefs,
818
- ye as activityPredicate,
823
+ be as activityPredicate,
819
824
  Re as activityWhy,
820
825
  H as actorName,
821
826
  Y as actorOf,
822
827
  le as choiceText,
823
- C as collectionNouns,
828
+ N as collectionNouns,
824
829
  L as countNoun,
825
830
  Z as fieldLabel,
826
- T as fieldList,
827
- je as groupActivity,
831
+ P as fieldList,
832
+ Le as groupActivity,
828
833
  S as junctionOf,
829
834
  ke as linkChanges,
830
835
  Se as linkGroupPredicate,
831
836
  we as linkPairText,
832
837
  M as o2mSentence,
838
+ Ce as o2mTotalsText,
833
839
  de as parseActor,
834
840
  J as parseTransitionComment,
835
841
  G as readableTitle,
836
842
  I as recordPhrase,
837
- Le as renderActivityGroupSentence,
838
- Ae as renderActivitySentence,
839
- Ne as transitionVerb,
843
+ Te as renderActivityGroupSentence,
844
+ ye as renderActivitySentence,
845
+ je as transitionVerb,
840
846
  X as valueShowable,
841
847
  V as valueText
842
848
  };
@@ -0,0 +1,68 @@
1
+ function a(t) {
2
+ return t.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
3
+ }
4
+ function i(t) {
5
+ if (t && typeof t == "object" && !Array.isArray(t))
6
+ return Array.isArray(t.blocks) ? t : null;
7
+ if (typeof t != "string") return null;
8
+ const r = t.trimStart();
9
+ if (!r.startsWith("{") || !r.includes('"blocks"')) return null;
10
+ try {
11
+ const e = JSON.parse(r);
12
+ return Array.isArray(e == null ? void 0 : e.blocks) ? e : null;
13
+ } catch {
14
+ return null;
15
+ }
16
+ }
17
+ const d = (t) => i(t) !== null;
18
+ function y(t) {
19
+ const r = i(t);
20
+ return r ? (r.blocks ?? []).map((e) => {
21
+ const o = e.data ?? {}, n = a(String(o.text ?? "")), c = Math.max(1, Math.min(6, Number(o.level ?? 2)));
22
+ switch (e.type) {
23
+ case "paragraph":
24
+ return `<p>${n}</p>`;
25
+ case "header":
26
+ return `<h${c}>${n}</h${c}>`;
27
+ case "list": {
28
+ const s = (o.items ?? []).map((l) => `<li>${a(f(l))}</li>`).join("");
29
+ return o.style === "ordered" ? `<ol>${s}</ol>` : `<ul>${s}</ul>`;
30
+ }
31
+ case "quote":
32
+ return `<blockquote><p>${n}</p></blockquote>`;
33
+ default:
34
+ return n ? `<p>${n}</p>` : "";
35
+ }
36
+ }).join("") : typeof t == "string" && t ? `<p>${a(t)}</p>` : "";
37
+ }
38
+ function f(t) {
39
+ return typeof t == "string" ? t : t && typeof t == "object" && "content" in t ? String(t.content) : "";
40
+ }
41
+ const p = (t) => t.replace(/<br\s*\/?>/gi, `
42
+ `).replace(/<[^>]*>/g, "").replace(/&nbsp;/g, " ").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&#39;/g, "'").replace(/&amp;/g, "&").trim();
43
+ function m(t) {
44
+ const r = i(t);
45
+ if (!r) return "";
46
+ const e = [];
47
+ for (const o of r.blocks ?? []) {
48
+ const n = o.data ?? {};
49
+ if (o.type === "list") {
50
+ const s = n.style === "ordered";
51
+ (n.items ?? []).forEach((l, g) => {
52
+ const u = p(f(l));
53
+ u && e.push(`${s ? `${g + 1}.` : "•"} ${u}`);
54
+ });
55
+ continue;
56
+ }
57
+ const c = p(String(n.text ?? ""));
58
+ c && e.push(c);
59
+ }
60
+ return e.join(`
61
+ `);
62
+ }
63
+ export {
64
+ i as editorJsDoc,
65
+ y as editorJsToHtml,
66
+ m as editorJsToText,
67
+ d as isEditorJsValue
68
+ };
@@ -0,0 +1,81 @@
1
+ import { useQueryClient as m, useQuery as c } from "@tanstack/react-query";
2
+ import { useOptionalNivaroClient as f } from "../context.js";
3
+ import { get as _, patch as p, put as A } from "./commands.js";
4
+ const v = ["nvr-profile-prefs"];
5
+ function q(e, t) {
6
+ const i = e == null ? void 0 : e.revision_personal_sets;
7
+ if (!i || typeof i != "object" || Array.isArray(i)) return [];
8
+ const r = i[t];
9
+ return Array.isArray(r) ? r.filter(
10
+ (o) => o && typeof o.name == "string" && Array.isArray(o.fields)
11
+ ) : [];
12
+ }
13
+ function h(e) {
14
+ const t = f(), i = m(), r = ["revision-column-sets", e], { data: o } = c({
15
+ queryKey: r,
16
+ queryFn: () => t.request(_(`/revision-column-sets/${e}`)).then((l) => l.data),
17
+ enabled: !!t && !!e,
18
+ staleTime: 6e4,
19
+ retry: !1
20
+ });
21
+ return {
22
+ sets: (o == null ? void 0 : o.sets) ?? [],
23
+ roleDefault: (o == null ? void 0 : o.role_default) ?? null,
24
+ /** Admins: replace the collection's shared sets. */
25
+ save: async (l) => {
26
+ t && (await t.request(A(`/revision-column-sets/${e}`, { sets: l })), await i.invalidateQueries({ queryKey: r }));
27
+ }
28
+ };
29
+ }
30
+ function b(e, t) {
31
+ const i = e == null ? void 0 : e.revision_table_columns;
32
+ if (!i || typeof i != "object" || Array.isArray(i)) return null;
33
+ const r = i[t];
34
+ return Array.isArray(r) ? r.filter((o) => typeof o == "string") : null;
35
+ }
36
+ function K(e) {
37
+ const t = f(), i = m(), { data: r, isSuccess: o } = c({
38
+ queryKey: v,
39
+ queryFn: () => t.request(_("/users/me")).then((s) => {
40
+ var n;
41
+ return ((n = s.data) == null ? void 0 : n.preferences) ?? {};
42
+ }),
43
+ enabled: !!t,
44
+ staleTime: 6e4,
45
+ retry: !1
46
+ }), l = (r == null ? void 0 : r.revision_view) === "table" || (r == null ? void 0 : r.revision_view) === "timeline" ? r.revision_view : null, y = (s, n) => {
47
+ i.setQueryData(v, (u) => n({ ...u ?? {} })), t && t.request(p("/users/me/preferences", s)).catch(() => {
48
+ i.invalidateQueries({ queryKey: v });
49
+ });
50
+ };
51
+ return {
52
+ /** True once the person's stored choices have been read (or there is no client). */
53
+ loaded: o || !t,
54
+ view: l,
55
+ /** This collection's picked columns in order; null = never picked (use the default). */
56
+ columns: b(r, e),
57
+ /** The person's own named sets for this collection. */
58
+ personalSets: q(r, e),
59
+ setPersonalSets: (s) => y(
60
+ {
61
+ revision_personal_sets: {
62
+ collection: e,
63
+ sets: (s == null ? void 0 : s.map((n) => ({ name: n.name, fields: n.fields }))) ?? null
64
+ }
65
+ },
66
+ (n) => {
67
+ const u = n.revision_personal_sets, a = u && typeof u == "object" && !Array.isArray(u) ? { ...u } : {};
68
+ return s === null ? delete a[e] : a[e] = s, { ...n, revision_personal_sets: a };
69
+ }
70
+ ),
71
+ setView: (s) => y({ revision_view: s }, (n) => ({ ...n, revision_view: s })),
72
+ setColumns: (s) => y({ revision_table_columns: { collection: e, fields: s } }, (n) => {
73
+ const u = n.revision_table_columns, a = u && typeof u == "object" && !Array.isArray(u) ? { ...u } : {};
74
+ return s === null ? delete a[e] : a[e] = s, { ...n, revision_table_columns: a };
75
+ })
76
+ };
77
+ }
78
+ export {
79
+ K as useRevisionPrefs,
80
+ h as useSharedColumnSets
81
+ };
@@ -0,0 +1,125 @@
1
+ const y = {
2
+ plain: 0,
3
+ header: 1,
4
+ changed: 2,
5
+ recalculated: 3,
6
+ muted: 4
7
+ }, g = (e) => e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g, "");
8
+ function x(e) {
9
+ let t = e + 1, n = "";
10
+ for (; t > 0; ) {
11
+ const o = (t - 1) % 26;
12
+ n = String.fromCharCode(65 + o) + n, t = Math.floor((t - 1) / 26);
13
+ }
14
+ return n;
15
+ }
16
+ function w(e) {
17
+ var p;
18
+ const t = e.freezeColumns ?? 0, n = `<pane ${t ? `xSplit="${t}" ` : ""}ySplit="1" topLeftCell="${x(t)}2" activePane="bottomRight" state="frozen"/>`, o = (p = e.widths) != null && p.length ? `<cols>${e.widths.map(
19
+ (a, i) => `<col min="${i + 1}" max="${i + 1}" width="${Math.max(6, Math.min(80, a))}" customWidth="1"/>`
20
+ ).join("")}</cols>` : "", r = e.rows.map((a, i) => {
21
+ const h = a.map((m, l) => {
22
+ const s = `${x(l)}${i + 1}`, d = y[m.style ?? "plain"];
23
+ return m.v === null || m.v === void 0 || m.v === "" ? d ? `<c r="${s}" s="${d}"/>` : "" : typeof m.v == "number" && Number.isFinite(m.v) ? `<c r="${s}" s="${d}"><v>${m.v}</v></c>` : `<c r="${s}" s="${d}" t="inlineStr"><is><t xml:space="preserve">${g(String(m.v))}</t></is></c>`;
24
+ }).join("");
25
+ return `<row r="${i + 1}">${h}</row>`;
26
+ }).join("");
27
+ return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
28
+ <worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><sheetViews><sheetView workbookViewId="0">${n}</sheetView></sheetViews>${o}<sheetData>${r}</sheetData></worksheet>`;
29
+ }
30
+ const F = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
31
+ <styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
32
+ <fonts count="3"><font><sz val="11"/><name val="Calibri"/></font><font><b/><sz val="11"/><name val="Calibri"/></font><font><sz val="11"/><color rgb="FF64748B"/><name val="Calibri"/></font></fonts>
33
+ <fills count="5"><fill><patternFill patternType="none"/></fill><fill><patternFill patternType="gray125"/></fill><fill><patternFill patternType="solid"><fgColor rgb="FFF1F5F9"/><bgColor indexed="64"/></patternFill></fill><fill><patternFill patternType="solid"><fgColor rgb="FFFEF3C7"/><bgColor indexed="64"/></patternFill></fill><fill><patternFill patternType="solid"><fgColor rgb="FFFDE68A"/><bgColor indexed="64"/></patternFill></fill></fills>
34
+ <borders count="1"><border><left/><right/><top/><bottom/><diagonal/></border></borders>
35
+ <cellStyleXfs count="1"><xf numFmtId="0" fontId="0" fillId="0" borderId="0"/></cellStyleXfs>
36
+ <cellXfs count="5"><xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0" applyAlignment="1"><alignment vertical="top" wrapText="1"/></xf><xf numFmtId="0" fontId="1" fillId="2" borderId="0" xfId="0" applyFont="1" applyFill="1" applyAlignment="1"><alignment vertical="top" wrapText="1"/></xf><xf numFmtId="0" fontId="1" fillId="3" borderId="0" xfId="0" applyFont="1" applyFill="1" applyAlignment="1"><alignment vertical="top" wrapText="1"/></xf><xf numFmtId="0" fontId="1" fillId="4" borderId="0" xfId="0" applyFont="1" applyFill="1" applyAlignment="1"><alignment vertical="top" wrapText="1"/></xf><xf numFmtId="0" fontId="2" fillId="0" borderId="0" xfId="0" applyFont="1" applyAlignment="1"><alignment vertical="top" wrapText="1"/></xf></cellXfs>
37
+ </styleSheet>`;
38
+ function b(e) {
39
+ return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
40
+ <workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"><sheets>${e.map((t, n) => `<sheet name="${g(t)}" sheetId="${n + 1}" r:id="rId${n + 1}"/>`).join("")}</sheets></workbook>`;
41
+ }
42
+ function I(e) {
43
+ return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
44
+ <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">${Array.from(
45
+ { length: e },
46
+ (n, o) => `<Relationship Id="rId${o + 1}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet${o + 1}.xml"/>`
47
+ ).join("")}<Relationship Id="rId${e + 1}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/></Relationships>`;
48
+ }
49
+ function v(e) {
50
+ return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
51
+ <Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/><Override PartName="/xl/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"/>${Array.from(
52
+ { length: e },
53
+ (n, o) => `<Override PartName="/xl/worksheets/sheet${o + 1}.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/>`
54
+ ).join("")}</Types>`;
55
+ }
56
+ const T = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
57
+ <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/></Relationships>`;
58
+ let u = null;
59
+ function $(e) {
60
+ if (!u) {
61
+ u = new Uint32Array(256);
62
+ for (let n = 0; n < 256; n++) {
63
+ let o = n;
64
+ for (let r = 0; r < 8; r++) o = o & 1 ? 3988292384 ^ o >>> 1 : o >>> 1;
65
+ u[n] = o >>> 0;
66
+ }
67
+ }
68
+ let t = 4294967295;
69
+ for (const n of e) t = (u[(t ^ n) & 255] ^ t >>> 8) >>> 0;
70
+ return (t ^ 4294967295) >>> 0;
71
+ }
72
+ function k(e) {
73
+ const t = new TextEncoder(), n = [], o = [];
74
+ let r = 0;
75
+ for (const l of e) {
76
+ const s = t.encode(l.name), d = $(l.data), f = new DataView(new ArrayBuffer(30));
77
+ f.setUint32(0, 67324752, !0), f.setUint16(4, 20, !0), f.setUint16(8, 0, !0), f.setUint32(14, d, !0), f.setUint32(18, l.data.length, !0), f.setUint32(22, l.data.length, !0), f.setUint16(26, s.length, !0), n.push(new Uint8Array(f.buffer), s, l.data);
78
+ const c = new DataView(new ArrayBuffer(46));
79
+ c.setUint32(0, 33639248, !0), c.setUint16(4, 20, !0), c.setUint16(6, 20, !0), c.setUint32(16, d, !0), c.setUint32(20, l.data.length, !0), c.setUint32(24, l.data.length, !0), c.setUint16(28, s.length, !0), c.setUint32(42, r, !0), o.push(new Uint8Array(c.buffer), s), r += 30 + s.length + l.data.length;
80
+ }
81
+ const p = o.reduce((l, s) => l + s.length, 0), a = new DataView(new ArrayBuffer(22));
82
+ a.setUint32(0, 101010256, !0), a.setUint16(8, e.length, !0), a.setUint16(10, e.length, !0), a.setUint32(12, p, !0), a.setUint32(16, r, !0);
83
+ const i = [...n, ...o, new Uint8Array(a.buffer)], h = new Uint8Array(i.reduce((l, s) => l + s.length, 0));
84
+ let m = 0;
85
+ for (const l of i)
86
+ h.set(l, m), m += l.length;
87
+ return h;
88
+ }
89
+ function U(e) {
90
+ const t = /* @__PURE__ */ new Set();
91
+ return e.map((n, o) => {
92
+ let r = n.replace(/[:\\/?*[\]]/g, " ").trim().slice(0, 31) || `Sheet${o + 1}`, p = r, a = 2;
93
+ for (; t.has(p.toLowerCase()); ) {
94
+ const i = ` (${a++})`;
95
+ r = r.slice(0, 31 - i.length), p = `${r}${i}`;
96
+ }
97
+ return t.add(p.toLowerCase()), p;
98
+ });
99
+ }
100
+ function C(e) {
101
+ const t = new TextEncoder(), n = U(e.map((o) => o.name));
102
+ return k([
103
+ { name: "[Content_Types].xml", data: t.encode(v(e.length)) },
104
+ { name: "_rels/.rels", data: t.encode(T) },
105
+ { name: "xl/workbook.xml", data: t.encode(b(n)) },
106
+ { name: "xl/_rels/workbook.xml.rels", data: t.encode(I(e.length)) },
107
+ { name: "xl/styles.xml", data: t.encode(F) },
108
+ ...e.map((o, r) => ({
109
+ name: `xl/worksheets/sheet${r + 1}.xml`,
110
+ data: t.encode(w(o))
111
+ }))
112
+ ]);
113
+ }
114
+ function S(e) {
115
+ return new Blob([C(e)], {
116
+ type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
117
+ });
118
+ }
119
+ export {
120
+ x as columnName,
121
+ $ as crc32,
122
+ S as xlsxBlob,
123
+ C as xlsxBytes,
124
+ k as zipStored
125
+ };