@nivaro/react 0.2.54 → 0.2.56

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.
Files changed (151) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +99 -98
  3. package/dist/index.d.ts +367 -2
  4. package/dist/index.js +645 -616
  5. package/dist/layout-editor.d.ts +4 -0
  6. package/dist/shared/components/BackgroundRunOffer.js +117 -0
  7. package/dist/shared/components/BroadcastView.js +214 -213
  8. package/dist/shared/components/CollectionBrowserView.js +2592 -2695
  9. package/dist/shared/components/ItemEditForm.js +4066 -3832
  10. package/dist/shared/components/JobsTray.js +100 -55
  11. package/dist/shared/components/MyWorkView.js +91 -89
  12. package/dist/shared/components/NotificationBell.js +80 -79
  13. package/dist/shared/components/ProfileView.js +568 -520
  14. package/dist/shared/components/RecordCompare.js +254 -0
  15. package/dist/shared/components/RecordReadView.js +599 -552
  16. package/dist/shared/components/ReportView.js +578 -543
  17. package/dist/shared/components/RowPresence.js +91 -0
  18. package/dist/shared/components/WidgetSlot.js +474 -458
  19. package/dist/shared/components/ai/AiAnalyticsView.js +16 -6
  20. package/dist/shared/components/ai/AskPanel.js +139 -119
  21. package/dist/shared/components/ai/FirstWeekCard.js +126 -0
  22. package/dist/shared/components/bulk/BulkFieldUpdate.js +289 -0
  23. package/dist/shared/components/bulk/bulk-field-options.js +45 -0
  24. package/dist/shared/components/charts/CumulativeFlowChart.js +176 -0
  25. package/dist/shared/components/chat/ChannelArchive.js +326 -0
  26. package/dist/shared/components/chat/ChannelExtras.js +141 -121
  27. package/dist/shared/components/chat/ChatAnalyticsView.js +112 -110
  28. package/dist/shared/components/chat/ChatPanel.js +1695 -1733
  29. package/dist/shared/components/chat/Composer.js +357 -303
  30. package/dist/shared/components/chat/MessageActions.js +92 -0
  31. package/dist/shared/components/chat/MessageFormat.js +290 -264
  32. package/dist/shared/components/chat/OutboxBubbles.js +146 -0
  33. package/dist/shared/components/chat/RequestIdCard.js +135 -0
  34. package/dist/shared/components/chat/RoomHeaderMenu.js +202 -0
  35. package/dist/shared/components/chat/RoomParts.js +213 -274
  36. package/dist/shared/components/chat/ScreenClip.js +184 -0
  37. package/dist/shared/components/chat/chat-core.js +402 -483
  38. package/dist/shared/components/chat/chat-drafts.js +59 -0
  39. package/dist/shared/components/chat/chat-emoji.js +348 -0
  40. package/dist/shared/components/chat/chat-local-time.js +41 -0
  41. package/dist/shared/components/chat/chat-outbox.js +303 -0
  42. package/dist/shared/components/chat/chat-window.js +163 -0
  43. package/dist/shared/components/chat/huddle/HuddleControls.js +143 -0
  44. package/dist/shared/components/chat/huddle/HuddleStage.js +164 -0
  45. package/dist/shared/components/chat/huddle/huddle-store.js +342 -0
  46. package/dist/shared/components/chat/huddle/useHuddle.js +58 -0
  47. package/dist/shared/components/help-videos/api.js +76 -73
  48. package/dist/shared/components/item-edit/CatalogPickerField.js +113 -112
  49. package/dist/shared/components/item-edit/ChangeReasonDialog.js +13 -13
  50. package/dist/shared/components/item-edit/FieldAffordances.js +2 -2
  51. package/dist/shared/components/item-edit/FieldRenderer.js +248 -245
  52. package/dist/shared/components/item-edit/FieldRow.js +292 -279
  53. package/dist/shared/components/item-edit/GroupSection.js +698 -574
  54. package/dist/shared/components/item-edit/InlineTableField.js +3 -1
  55. package/dist/shared/components/item-edit/RelationCombobox.js +186 -176
  56. package/dist/shared/components/item-edit/entry/EntryStrip.js +54 -0
  57. package/dist/shared/components/item-edit/entry/entry-keys.js +27 -0
  58. package/dist/shared/components/item-edit/entry/useEntryKeyboard.js +70 -0
  59. package/dist/shared/components/item-edit/entry/useEntryMode.js +59 -0
  60. package/dist/shared/components/item-edit/form-structure-ui.js +105 -0
  61. package/dist/shared/components/item-edit/lazy-sections.js +36 -0
  62. package/dist/shared/components/item-edit/lock-why.js +39 -32
  63. package/dist/shared/components/item-edit/picker-miss.js +26 -0
  64. package/dist/shared/components/item-edit/placement-behaviour.js +196 -0
  65. package/dist/shared/components/item-edit/useFormUsageBeacon.js +51 -45
  66. package/dist/shared/components/layout-editor/AddPanel.js +134 -117
  67. package/dist/shared/components/layout-editor/ChangeNote.js +25 -24
  68. package/dist/shared/components/layout-editor/CollabParts.js +80 -75
  69. package/dist/shared/components/layout-editor/DesignNode.js +126 -120
  70. package/dist/shared/components/layout-editor/EditorCanvas.js +30 -27
  71. package/dist/shared/components/layout-editor/EditorTopBar.js +203 -192
  72. package/dist/shared/components/layout-editor/HistoryPanel.js +120 -104
  73. package/dist/shared/components/layout-editor/LayoutEditor.js +768 -671
  74. package/dist/shared/components/layout-editor/RestorePiece.js +143 -0
  75. package/dist/shared/components/layout-editor/StagedChip.js +22 -0
  76. package/dist/shared/components/layout-editor/StructureMenu.js +237 -186
  77. package/dist/shared/components/layout-editor/collab/FormFollowShare.js +149 -103
  78. package/dist/shared/components/layout-editor/collab/collab-api.js +29 -26
  79. package/dist/shared/components/layout-editor/dnd/LayoutDndProvider.js +81 -80
  80. package/dist/shared/components/layout-editor/dnd/node.js +69 -57
  81. package/dist/shared/components/layout-editor/draft-recovery.js +113 -43
  82. package/dist/shared/components/layout-editor/entry/PlacementPresets.js +149 -0
  83. package/dist/shared/components/layout-editor/entry/entry-editor-context.js +10 -0
  84. package/dist/shared/components/layout-editor/entry/presets.js +71 -0
  85. package/dist/shared/components/layout-editor/entry/tab-order.js +110 -0
  86. package/dist/shared/components/layout-editor/entry/theme-preview.js +37 -0
  87. package/dist/shared/components/layout-editor/grid-guides.js +142 -0
  88. package/dist/shared/components/layout-editor/inspector/BehaviourSettings.js +402 -0
  89. package/dist/shared/components/layout-editor/inspector/BulkInspector.js +61 -57
  90. package/dist/shared/components/layout-editor/inspector/GroupInspector.js +247 -151
  91. package/dist/shared/components/layout-editor/inspector/Inspector.js +176 -155
  92. package/dist/shared/components/layout-editor/inspector/LookTab.js +167 -116
  93. package/dist/shared/components/layout-editor/inspector/PickerMisses.js +129 -0
  94. package/dist/shared/components/layout-editor/inspector/PickerTab.js +84 -82
  95. package/dist/shared/components/layout-editor/inspector/RulesTab.js +66 -62
  96. package/dist/shared/components/layout-editor/inspector/kit.js +69 -68
  97. package/dist/shared/components/layout-editor/outputs/OutputsButton.js +254 -0
  98. package/dist/shared/components/layout-editor/outputs/help-sheet.js +154 -0
  99. package/dist/shared/components/layout-editor/outputs/output-api.js +61 -0
  100. package/dist/shared/components/layout-editor/overview/describe-conditions.js +6 -0
  101. package/dist/shared/components/layout-editor/overview/purpose.js +15 -13
  102. package/dist/shared/components/layout-editor/parity-keys.json.js +1 -1
  103. package/dist/shared/components/layout-editor/restore-piece.js +192 -0
  104. package/dist/shared/components/layout-editor/section-structure.js +241 -0
  105. package/dist/shared/components/layout-editor/settings/EntrySection.js +296 -0
  106. package/dist/shared/components/layout-editor/settings/FormSettings.js +41 -39
  107. package/dist/shared/components/layout-editor/settings/ResolveSettings.js +255 -0
  108. package/dist/shared/components/layout-editor/settings/ToolsSection.js +147 -111
  109. package/dist/shared/components/layout-editor/settings/WhoSection.js +29 -26
  110. package/dist/shared/components/layout-editor/settings/settings-registry.js +114 -17
  111. package/dist/shared/components/layout-editor/staged-api.js +64 -0
  112. package/dist/shared/components/layout-editor/structure-ops.js +81 -77
  113. package/dist/shared/components/layout-editor/testing/TestingPanels.js +65 -60
  114. package/dist/shared/components/layout-editor/testing/testing-model.js +198 -185
  115. package/dist/shared/components/layout-editor/toolbar-kit.js +11 -11
  116. package/dist/shared/components/layout-editor/usage/AbTestSection.js +355 -0
  117. package/dist/shared/components/layout-editor/usage/UsagePanel.js +144 -70
  118. package/dist/shared/components/layout-editor/usage/ab-api.js +86 -0
  119. package/dist/shared/components/layout-editor/usage/suggest-collapse.js +32 -0
  120. package/dist/shared/components/layout-editor/useLayoutDraft.js +25 -24
  121. package/dist/shared/components/notifications/NotificationAnalyticsView.js +148 -77
  122. package/dist/shared/components/panels/ErpFailureBanner.js +18 -17
  123. package/dist/shared/components/panels/ExternalRequestsChip.js +63 -62
  124. package/dist/shared/components/pipeline/PipelineEditorView.js +106 -104
  125. package/dist/shared/components/profile/AgentsPanel.js +479 -0
  126. package/dist/shared/components/queue/QueueWorklist.js +1026 -1040
  127. package/dist/shared/components/support/SupportAnalytics.js +171 -0
  128. package/dist/shared/components/support/SupportView.js +75 -73
  129. package/dist/shared/lib/background-runs.js +150 -0
  130. package/dist/shared/lib/delivery-ack.js +9 -0
  131. package/dist/shared/lib/entry-badge-style.js +13 -0
  132. package/dist/shared/lib/entry-config.js +71 -0
  133. package/dist/shared/lib/form-sections.js +64 -0
  134. package/dist/shared/lib/form-structure.js +99 -0
  135. package/dist/shared/lib/form-usage-beacon.js +101 -52
  136. package/dist/shared/lib/jobs-tray.js +25 -23
  137. package/dist/shared/lib/keyset-pager.js +37 -0
  138. package/dist/shared/lib/layout-ops.js +84 -82
  139. package/dist/shared/lib/layout-resolve.js +113 -0
  140. package/dist/shared/lib/placement-behaviour.js +144 -0
  141. package/dist/shared/lib/prefetch.js +149 -0
  142. package/dist/shared/lib/presence-hooks.js +199 -0
  143. package/dist/shared/lib/record-outbox.js +82 -81
  144. package/dist/shared/lib/replay-socket.js +93 -0
  145. package/dist/shared/lib/request-gate.js +51 -50
  146. package/dist/shared/lib/room-gaps.js +96 -0
  147. package/dist/shared/lib/search-log.js +27 -0
  148. package/dist/shared/lib/socket-realtime.js +101 -80
  149. package/dist/shared/lib/stale-chunk.js +60 -0
  150. package/dist/shared/lib/worker-socket.js +200 -0
  151. package/package.json +1 -1
@@ -1,8 +1,8 @@
1
1
  import { useSyncExternalStore as k } from "react";
2
2
  const u = "nvr:jobs-tray:v1", a = "nvr:jobs-tray:dismissed:v1", m = 20, w = 1440 * 60 * 1e3;
3
3
  let s = [], o = /* @__PURE__ */ new Set(), y = !1, S = 0;
4
- const c = /* @__PURE__ */ new Set();
5
- function i(t, n) {
4
+ const d = /* @__PURE__ */ new Set();
5
+ function r(t, n) {
6
6
  try {
7
7
  const e = localStorage.getItem(t);
8
8
  return e ? JSON.parse(e) : n;
@@ -18,24 +18,24 @@ function f() {
18
18
  }
19
19
  function l() {
20
20
  S++;
21
- for (const t of c) t();
21
+ for (const t of d) t();
22
22
  }
23
23
  function g() {
24
24
  const t = Date.now() - w;
25
25
  s = s.filter((n) => n.status === "queued" || n.status === "running" || n.at >= t).sort((n, e) => e.at - n.at).slice(0, m);
26
26
  }
27
- function r() {
28
- y || typeof window > "u" || (y = !0, s = i(u, []), o = new Set(i(a, [])), g(), window.addEventListener("storage", (t) => {
29
- t.key !== u && t.key !== a || (s = i(u, []), o = new Set(i(a, [])), l());
27
+ function i() {
28
+ y || typeof window > "u" || (y = !0, s = r(u, []), o = new Set(r(a, [])), g(), window.addEventListener("storage", (t) => {
29
+ t.key !== u && t.key !== a || (s = r(u, []), o = new Set(r(a, [])), l());
30
30
  }));
31
31
  }
32
- function b(t, n) {
32
+ function _(t, n) {
33
33
  return o.has(t) && (n === "completed" || n === "error" || n === "canceled");
34
34
  }
35
- function _(t, n = Date.now()) {
36
- if (r(), !(t != null && t.key) || !t.status) return;
37
- const e = s.find((d) => d.key === t.key);
38
- if (e && (e.status === "completed" || e.status === "error" || e.status === "canceled") && t.status === "running" || (t.status === "queued" && o.delete(t.key), b(t.key, t.status))) return;
35
+ function b(t, n = Date.now()) {
36
+ if (i(), !(t != null && t.key) || !t.status) return;
37
+ const e = s.find((c) => c.key === t.key);
38
+ if (e && (e.status === "completed" || e.status === "error" || e.status === "canceled") && t.status === "running" || (t.status === "queued" && o.delete(t.key), _(t.key, t.status))) return;
39
39
  s = [{
40
40
  key: t.key,
41
41
  kind: t.kind ?? (e == null ? void 0 : e.kind) ?? "job",
@@ -46,35 +46,37 @@ function _(t, n = Date.now()) {
46
46
  error: t.error ?? null,
47
47
  href: t.href ?? (e == null ? void 0 : e.href) ?? null,
48
48
  file_id: t.file_id ?? (e == null ? void 0 : e.file_id) ?? null,
49
+ // Only a running job can be cancelled; a progress tick without it keeps the earlier one.
50
+ cancel_path: t.status === "running" || t.status === "queued" ? t.cancel_path ?? (e == null ? void 0 : e.cancel_path) ?? null : null,
49
51
  position: t.position ?? null,
50
52
  eta_seconds: t.eta_seconds ?? null,
51
53
  at: n
52
- }, ...s.filter((d) => d.key !== t.key)], g(), f(), l();
54
+ }, ...s.filter((c) => c.key !== t.key)], g(), f(), l();
53
55
  }
54
- function h(t) {
55
- r();
56
- for (const n of t) _(n, n.at ? new Date(n.at).getTime() : Date.now());
56
+ function D(t) {
57
+ i();
58
+ for (const n of t) b(n, n.at ? new Date(n.at).getTime() : Date.now());
57
59
  }
58
60
  function E(t) {
59
- r(), o.add(t), s = s.filter((n) => n.key !== t), f(), l();
61
+ i(), o.add(t), s = s.filter((n) => n.key !== t), f(), l();
60
62
  }
61
63
  function I() {
62
- r();
64
+ i();
63
65
  for (const t of s)
64
66
  t.status !== "queued" && t.status !== "running" && o.add(t.key);
65
67
  s = s.filter((t) => t.status === "queued" || t.status === "running"), f(), l();
66
68
  }
67
- function O() {
68
- return r(), k(
69
- (t) => (c.add(t), () => c.delete(t)),
69
+ function q() {
70
+ return i(), k(
71
+ (t) => (d.add(t), () => d.delete(t)),
70
72
  () => S,
71
73
  () => 0
72
74
  ), s;
73
75
  }
74
76
  export {
75
- _ as applyJobUpdate,
77
+ b as applyJobUpdate,
76
78
  I as dismissFinishedJobs,
77
79
  E as dismissJob,
78
- h as seedJobs,
79
- O as useTrayJobs
80
+ D as seedJobs,
81
+ q as useTrayJobs
80
82
  };
@@ -0,0 +1,37 @@
1
+ const u = "start";
2
+ function c() {
3
+ return { key: "", cursors: /* @__PURE__ */ new Map(), off: !1 };
4
+ }
5
+ function n(r, t) {
6
+ r.key !== t && (r.key = t, r.cursors.clear(), r.off = !1);
7
+ }
8
+ function o(r, t, e, s) {
9
+ if (n(r, t), /[.$]/.test(s) && (r.off = !0), r.off) return { page: e, sort: s };
10
+ if (e <= 1) return { after: u, sort: s };
11
+ const f = r.cursors.get(e);
12
+ return f ? { after: f, sort: s } : { page: e, sort: i(s) };
13
+ }
14
+ function a(r, t, e, s) {
15
+ n(r, t), !r.off && (typeof s == "string" && s ? r.cursors.set(e + 1, s) : r.cursors.delete(e + 1));
16
+ }
17
+ function l(r, t) {
18
+ n(r, t), r.off = !0, r.cursors.clear();
19
+ }
20
+ function C(r) {
21
+ var e;
22
+ const t = r;
23
+ return (t == null ? void 0 : t.status) === 400 && /^CURSOR_/.test(String(((e = t.response) == null ? void 0 : e.code) ?? ""));
24
+ }
25
+ function i(r) {
26
+ const t = r.split(",").map((e) => e.trim()).filter(Boolean);
27
+ return t.some((e) => e.replace(/^-/, "").toLowerCase() === "id") ? t.join(",") : [...t, "id"].join(",");
28
+ }
29
+ export {
30
+ u as CURSOR_START,
31
+ c as createCursorBook,
32
+ C as isCursorRefusal,
33
+ a as noteNextCursor,
34
+ o as pageRequest,
35
+ l as stopCursors,
36
+ i as withIdTieBreak
37
+ };
@@ -1,6 +1,6 @@
1
1
  var j = Object.defineProperty;
2
- var I = (t, e, r) => e in t ? j(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
3
- var x = (t, e, r) => I(t, typeof e != "symbol" ? e + "" : e, r);
2
+ var I = (t, e, s) => e in t ? j(t, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[e] = s;
3
+ var x = (t, e, s) => I(t, typeof e != "symbol" ? e + "" : e, s);
4
4
  const R = [
5
5
  "label_override",
6
6
  "is_visible",
@@ -82,7 +82,9 @@ const R = [
82
82
  "sheet_width",
83
83
  "header_fields",
84
84
  "hide_empty",
85
- "change_note"
85
+ "change_note",
86
+ "entry_config",
87
+ "email_summary_group"
86
88
  ], m = ["section", "tab", "metadata", "container", "content"], d = "__ungrouped__", z = "__header__", C = [
87
89
  "__apply_values__",
88
90
  "__create_with_defaults__"
@@ -105,10 +107,10 @@ const R = [
105
107
  ["__related_records__", 9]
106
108
  ]), P = (t) => F.get(t) ?? (G.test(t) ? 8 : 0);
107
109
  class N extends Error {
108
- constructor(r, s) {
109
- super(r);
110
+ constructor(s, o) {
111
+ super(s);
110
112
  x(this, "op_index");
111
- this.name = "LayoutOpError", this.op_index = s;
113
+ this.name = "LayoutOpError", this.op_index = o;
112
114
  }
113
115
  }
114
116
  function f(t) {
@@ -132,12 +134,12 @@ function X(t, e) {
132
134
  show_approval_chain: !1
133
135
  };
134
136
  }
135
- function H(t, e, r, s) {
137
+ function H(t, e, s, o) {
136
138
  return {
137
139
  key: t,
138
140
  label: e,
139
- type: r,
140
- parent_key: s,
141
+ type: s,
142
+ parent_key: o,
141
143
  sort: 0,
142
144
  icon: null,
143
145
  is_collapsed: !1,
@@ -161,105 +163,105 @@ function K(t) {
161
163
  return {
162
164
  ...t,
163
165
  groups: [...t.groups].sort(
164
- (e, r) => g(e.parent_key ?? "", r.parent_key ?? "") || e.sort - r.sort || h(e, r) || g(e.key, r.key)
166
+ (e, s) => g(e.parent_key ?? "", s.parent_key ?? "") || e.sort - s.sort || h(e, s) || g(e.key, s.key)
165
167
  ),
166
168
  placements: [...t.placements].sort(
167
- (e, r) => g(e.group_key ?? "", r.group_key ?? "") || e.sort - r.sort || h(e, r) || g(e.field, r.field)
169
+ (e, s) => g(e.group_key ?? "", s.group_key ?? "") || e.sort - s.sort || h(e, s) || g(e.field, s.field)
168
170
  )
169
171
  };
170
172
  }
171
173
  function p(t, e) {
172
- return t.placements.map((r, s) => ({ p: r, i: s })).filter(({ p: r }) => r.group_key === e && !f(r)).sort((r, s) => r.p.sort - s.p.sort || h(r.p, s.p) || r.i - s.i).map(({ p: r }) => r);
174
+ return t.placements.map((s, o) => ({ p: s, i: o })).filter(({ p: s }) => s.group_key === e && !f(s)).sort((s, o) => s.p.sort - o.p.sort || h(s.p, o.p) || s.i - o.i).map(({ p: s }) => s);
173
175
  }
174
176
  function u(t, e) {
175
- const r = [];
176
- return t.groups.forEach((s, l) => {
177
- s.parent_key === e && r.push({ m: s, tie: P(s.key), i: l });
178
- }), e === null && t.placements.forEach((s, l) => {
179
- f(s) && r.push({ m: s, tie: P(s.field), i: t.groups.length + l });
180
- }), r.sort((s, l) => s.m.sort - l.m.sort || s.tie - l.tie || h(s.m, l.m) || s.i - l.i).map((s) => s.m);
177
+ const s = [];
178
+ return t.groups.forEach((o, l) => {
179
+ o.parent_key === e && s.push({ m: o, tie: P(o.key), i: l });
180
+ }), e === null && t.placements.forEach((o, l) => {
181
+ f(o) && s.push({ m: o, tie: P(o.field), i: t.groups.length + l });
182
+ }), s.sort((o, l) => o.m.sort - l.m.sort || o.tie - l.tie || h(o.m, l.m) || o.i - l.i).map((o) => o.m);
181
183
  }
182
184
  function c(t) {
183
- t.forEach((e, r) => {
184
- e.sort = r;
185
+ t.forEach((e, s) => {
186
+ e.sort = s;
185
187
  });
186
188
  }
187
189
  function V(t) {
188
190
  const e = /* @__PURE__ */ new Set();
189
- for (const s of t.placements) f(s) || e.add(s.group_key);
190
- for (const s of e) c(p(t, s));
191
- const r = /* @__PURE__ */ new Set([null]);
192
- for (const s of t.groups) r.add(s.parent_key);
193
- for (const s of r) c(u(t, s));
191
+ for (const o of t.placements) f(o) || e.add(o.group_key);
192
+ for (const o of e) c(p(t, o));
193
+ const s = /* @__PURE__ */ new Set([null]);
194
+ for (const o of t.groups) s.add(o.parent_key);
195
+ for (const o of s) c(u(t, o));
194
196
  }
195
197
  function J(t, e) {
196
- const r = {
198
+ const s = {
197
199
  layout: { ...t.layout },
198
- groups: t.groups.map((s) => ({ ...s })),
199
- placements: t.placements.map((s) => ({ ...s }))
200
+ groups: t.groups.map((o) => ({ ...o })),
201
+ placements: t.placements.map((o) => ({ ...o }))
200
202
  };
201
203
  if (!Array.isArray(e)) throw new N("ops must be an array", 0);
202
- return e.forEach((s, l) => {
203
- B(r, s, l), V(r);
204
- }), K({ ...r, rev: t.rev });
204
+ return e.forEach((o, l) => {
205
+ B(s, o, l), V(s);
206
+ }), K({ ...s, rev: t.rev });
205
207
  }
206
- function B(t, e, r) {
207
- const s = (n) => {
208
- throw new N(n, r);
208
+ function B(t, e, s) {
209
+ const o = (n) => {
210
+ throw new N(n, s);
209
211
  };
210
- (!e || typeof e != "object") && s("Each op must be an object");
211
- const l = (n, o, i) => {
212
- (typeof i != "number" || !Number.isFinite(i)) && s("index must be a number");
212
+ (!e || typeof e != "object") && o("Each op must be an object");
213
+ const l = (n, r, i) => {
214
+ (typeof i != "number" || !Number.isFinite(i)) && o("index must be a number");
213
215
  const _ = Math.max(0, Math.min(n.length, Math.floor(i)));
214
- return [...n.slice(0, _), o, ...n.slice(_)];
215
- }, y = (n, o) => {
216
+ return [...n.slice(0, _), r, ...n.slice(_)];
217
+ }, y = (n, r) => {
216
218
  if (n == null) return {};
217
- (typeof n != "object" || Array.isArray(n)) && s("patch must be an object");
219
+ (typeof n != "object" || Array.isArray(n)) && o("patch must be an object");
218
220
  for (const i of Object.keys(n))
219
- o.includes(i) || s(`Unknown setting "${i}"`);
221
+ r.includes(i) || o(`Unknown setting "${i}"`);
220
222
  return n;
221
223
  }, A = (n) => {
222
- const o = y(n, L);
223
- return o.type !== void 0 && !m.includes(o.type) && s(`Group type must be one of ${m.join(", ")}`), o.read_width != null && !["full", "half", "third"].includes(o.read_width) && s("read_width must be 'full', 'half', 'third' or null"), o.editor_note != null && (typeof o.editor_note != "string" || o.editor_note.length > 4e3) && s("A note must be text of at most 4000 characters"), o;
224
+ const r = y(n, L);
225
+ return r.type !== void 0 && !m.includes(r.type) && o(`Group type must be one of ${m.join(", ")}`), r.read_width != null && !["full", "half", "third"].includes(r.read_width) && o("read_width must be 'full', 'half', 'third' or null"), r.editor_note != null && (typeof r.editor_note != "string" || r.editor_note.length > 4e3) && o("A note must be text of at most 4000 characters"), r;
224
226
  }, k = (n) => {
225
- (!n || typeof n.field != "string") && s("A placement needs a field");
226
- const o = n;
227
- M.includes(o.field) && s(`"${o.field}" is a reserved name`);
227
+ (!n || typeof n.field != "string") && o("A placement needs a field");
228
+ const r = n;
229
+ M.includes(r.field) && o(`"${r.field}" is a reserved name`);
228
230
  const i = t.placements.find(
229
- (_) => _.field === o.field && _.group_key === (o.group_key ?? null)
231
+ (_) => _.field === r.field && _.group_key === (r.group_key ?? null)
230
232
  );
231
- return i || s(`"${o.field}" is not placed in ${o.group_key ?? "Ungrouped"}`), i;
233
+ return i || o(`"${r.field}" is not placed in ${r.group_key ?? "Ungrouped"}`), i;
232
234
  }, b = (n) => {
233
- n === d && s("The Ungrouped zone can only be moved");
234
- const o = t.groups.find((i) => i.key === n);
235
- return o || s(`No group "${String(n)}"`), o;
235
+ n === d && o("The Ungrouped zone can only be moved");
236
+ const r = t.groups.find((i) => i.key === n);
237
+ return r || o(`No group "${String(n)}"`), r;
236
238
  }, O = (n) => {
237
239
  if (n === null || n === z || t.layout.layout_type === "table" && C.includes(n)) return;
238
- const o = t.groups.find((i) => i.key === n);
239
- (!o || o.key === d) && s(`No group "${n}"`), o.type === "container" && s("Fields go in the tabs of a container"), o.type === "content" && s("A text block holds text, not fields");
240
- }, T = (n, o) => {
240
+ const r = t.groups.find((i) => i.key === n);
241
+ (!r || r.key === d) && o(`No group "${n}"`), r.type === "container" && o("Fields go in the tabs of a container"), r.type === "content" && o("A text block holds text, not fields");
242
+ }, T = (n, r) => {
241
243
  if (n === null) return;
242
244
  const i = t.groups.find((_) => _.key === n);
243
- (i == null ? void 0 : i.type) !== "container" && s(`"${n}" is not a container`), o !== "tab" && s("Only tabs go inside a container");
244
- }, S = (n, o) => {
245
+ (i == null ? void 0 : i.type) !== "container" && o(`"${n}" is not a container`), r !== "tab" && o("Only tabs go inside a container");
246
+ }, S = (n, r) => {
245
247
  const i = f(n) ? u(t, null).filter((_) => _ !== n) : p(t, n.group_key).filter((_) => _ !== n);
246
- c(l(i, n, o));
248
+ c(l(i, n, r));
247
249
  };
248
250
  switch (e.op) {
249
251
  case "place": {
250
- (typeof e.field != "string" || !e.field) && s("place needs a field"), M.includes(e.field) && s(`"${e.field}" is a reserved name`);
252
+ (typeof e.field != "string" || !e.field) && o("place needs a field"), M.includes(e.field) && o(`"${e.field}" is a reserved name`);
251
253
  const n = e.group_key ?? null;
252
- O(n), t.placements.some((i) => i.field === e.field && i.group_key === n) && s(`"${e.field}" is already in ${n ?? "Ungrouped"}`);
253
- const o = {
254
+ O(n), t.placements.some((i) => i.field === e.field && i.group_key === n) && o(`"${e.field}" is already in ${n ?? "Ungrouped"}`);
255
+ const r = {
254
256
  ...X(e.field, n),
255
257
  ...y(e.patch, R)
256
258
  };
257
- t.placements.push(o), S(o, e.index);
259
+ t.placements.push(r), S(r, e.index);
258
260
  return;
259
261
  }
260
262
  case "move": {
261
- const n = k(e.from), o = e.to_group_key ?? null;
262
- o !== n.group_key && (O(o), t.placements.some((i) => i.field === n.field && i.group_key === o) && s(`"${n.field}" is already in ${o ?? "Ungrouped"}`), n.group_key = o), S(n, e.index);
263
+ const n = k(e.from), r = e.to_group_key ?? null;
264
+ r !== n.group_key && (O(r), t.placements.some((i) => i.field === n.field && i.group_key === r) && o(`"${n.field}" is already in ${r ?? "Ungrouped"}`), n.group_key = r), S(n, e.index);
263
265
  return;
264
266
  }
265
267
  case "update_placement": {
@@ -269,39 +271,39 @@ function B(t, e, r) {
269
271
  }
270
272
  case "remove": {
271
273
  const n = k(e.at);
272
- t.placements = t.placements.filter((o) => o !== n);
274
+ t.placements = t.placements.filter((r) => r !== n);
273
275
  return;
274
276
  }
275
277
  case "group_create": {
276
- (typeof e.key != "string" || !e.key.trim()) && s("A group needs a key"), e.key.startsWith("__") && s("Group keys starting with __ are reserved"), t.groups.some((v) => v.key === e.key) && s(`A group "${e.key}" already exists`), typeof e.label != "string" && s("A group needs a label");
277
- const n = A(e.patch), o = n.type ?? e.group_type;
278
- m.includes(o) || s(`Group type must be one of ${m.join(", ")}`);
278
+ (typeof e.key != "string" || !e.key.trim()) && o("A group needs a key"), e.key.startsWith("__") && o("Group keys starting with __ are reserved"), t.groups.some((v) => v.key === e.key) && o(`A group "${e.key}" already exists`), typeof e.label != "string" && o("A group needs a label");
279
+ const n = A(e.patch), r = n.type ?? e.group_type;
280
+ m.includes(r) || o(`Group type must be one of ${m.join(", ")}`);
279
281
  const i = e.parent_key ?? null;
280
- T(i, o);
281
- const _ = { ...H(e.key, e.label, o, i), ...n }, w = u(t, i);
282
+ T(i, r);
283
+ const _ = { ...H(e.key, e.label, r, i), ...n }, w = u(t, i);
282
284
  t.groups.push(_), c(l(w, _, e.index));
283
285
  return;
284
286
  }
285
287
  case "group_update": {
286
- const n = b(e.key), o = A(e.patch);
287
- o.type !== void 0 && o.type !== n.type && (n.parent_key !== null && o.type !== "tab" && s("Only tabs go inside a container"), n.type === "container" && t.groups.some((i) => i.parent_key === n.key) && s("Move the tabs out of this container first"), (o.type === "container" || o.type === "content") && p(t, n.key).length && s("Move the fields out of this section first")), Object.assign(n, o);
288
+ const n = b(e.key), r = A(e.patch);
289
+ r.type !== void 0 && r.type !== n.type && (n.parent_key !== null && r.type !== "tab" && o("Only tabs go inside a container"), n.type === "container" && t.groups.some((i) => i.parent_key === n.key) && o("Move the tabs out of this container first"), (r.type === "container" || r.type === "content") && p(t, n.key).length && o("Move the fields out of this section first")), Object.assign(n, r);
288
290
  return;
289
291
  }
290
292
  case "group_move": {
291
293
  const n = e.parent_key ?? null;
292
- let o;
294
+ let r;
293
295
  if (e.key === d || f({ field: e.key, group_key: null })) {
294
- n !== null && s("This stays at the top level of the form");
296
+ n !== null && o("This stays at the top level of the form");
295
297
  const i = e.key === d ? t.groups.find((_) => _.key === d) : t.placements.find((_) => _.field === e.key && _.group_key === null);
296
- i || s(`"${e.key}" is not on this form`), o = i;
298
+ i || o(`"${e.key}" is not on this form`), r = i;
297
299
  } else {
298
300
  const i = b(e.key);
299
- T(n, i.type), i.parent_key = n, o = i;
301
+ T(n, i.type), i.parent_key = n, r = i;
300
302
  }
301
303
  c(
302
304
  l(
303
- u(t, n).filter((i) => i !== o),
304
- o,
305
+ u(t, n).filter((i) => i !== r),
306
+ r,
305
307
  e.index
306
308
  )
307
309
  );
@@ -309,11 +311,11 @@ function B(t, e, r) {
309
311
  }
310
312
  case "group_remove": {
311
313
  const n = b(e.key);
312
- e.placements !== "ungroup" && e.placements !== "delete" && s("placements must be 'ungroup' or 'delete'");
313
- const o = u(t, n.parent_key), i = u(t, n.key);
314
+ e.placements !== "ungroup" && e.placements !== "delete" && o("placements must be 'ungroup' or 'delete'");
315
+ const r = u(t, n.parent_key), i = u(t, n.key);
314
316
  for (const a of i) a.parent_key = n.parent_key;
315
- const _ = o.indexOf(n);
316
- c([...o.slice(0, _), ...i, ...o.slice(_ + 1)]), t.groups = t.groups.filter((a) => a !== n);
317
+ const _ = r.indexOf(n);
318
+ c([...r.slice(0, _), ...i, ...r.slice(_ + 1)]), t.groups = t.groups.filter((a) => a !== n);
317
319
  const w = p(t, n.key);
318
320
  if (t.placements = t.placements.filter((a) => a.group_key !== n.key), e.placements === "delete") return;
319
321
  const v = p(t, null), U = u(t, null), E = w.filter(
@@ -329,7 +331,7 @@ function B(t, e, r) {
329
331
  return;
330
332
  }
331
333
  default:
332
- s(`Unknown op "${String(e.op)}"`);
334
+ o(`Unknown op "${String(e.op)}"`);
333
335
  }
334
336
  }
335
337
  export {
@@ -0,0 +1,113 @@
1
+ const s = /^\d{4}-\d{2}-\d{2}$/, c = (t) => typeof t == "string" && s.test(t);
2
+ function o(t) {
3
+ let n = t;
4
+ if (typeof n == "string")
5
+ try {
6
+ n = JSON.parse(n);
7
+ } catch {
8
+ return null;
9
+ }
10
+ return n && typeof n == "object" && !Array.isArray(n) ? n : null;
11
+ }
12
+ function l(t, n, e) {
13
+ const r = { ...o(t) ?? {} };
14
+ return e == null ? delete r[n] : r[n] = e, Object.keys(r).length > 0 ? r : null;
15
+ }
16
+ function a(t = /* @__PURE__ */ new Date()) {
17
+ const n = (e) => String(e).padStart(2, "0");
18
+ return `${t.getFullYear()}-${n(t.getMonth() + 1)}-${n(t.getDate())}`;
19
+ }
20
+ function p(t) {
21
+ var u;
22
+ const n = o((u = o(t)) == null ? void 0 : u.active_window);
23
+ if (!n) return null;
24
+ const e = c(n.from) ? n.from : null, r = c(n.until) ? n.until : null;
25
+ return e || r ? { from: e, until: r } : null;
26
+ }
27
+ function h(t, n) {
28
+ return t ? t.from && n < t.from ? "before" : t.until && n > t.until ? "after" : "open" : null;
29
+ }
30
+ function i(t) {
31
+ return (/* @__PURE__ */ new Date(`${t}T00:00:00Z`)).toLocaleDateString(void 0, {
32
+ day: "numeric",
33
+ month: "short",
34
+ year: "numeric",
35
+ timeZone: "UTC"
36
+ });
37
+ }
38
+ function g(t) {
39
+ return t.from && t.until ? `${i(t.from)} – ${i(t.until)}` : t.from ? `from ${i(t.from)}` : `until ${i(t.until)}`;
40
+ }
41
+ function b(t, n) {
42
+ const e = n.from || null, r = n.until || null;
43
+ return {
44
+ conditions: l(
45
+ t,
46
+ "active_window",
47
+ e || r ? { ...e ? { from: e } : {}, ...r ? { until: r } : {} } : null
48
+ )
49
+ };
50
+ }
51
+ function _(t) {
52
+ var e;
53
+ const n = Number((e = o(t)) == null ? void 0 : e.phone_of);
54
+ return Number.isInteger(n) && n > 0 ? n : null;
55
+ }
56
+ function w(t, n) {
57
+ return { conditions: l(t, "phone_of", n) };
58
+ }
59
+ function y(t) {
60
+ var e;
61
+ const n = o((e = o(t)) == null ? void 0 : e.freeze);
62
+ return !n || !c(n.until) ? null : {
63
+ until: n.until,
64
+ reason: typeof n.reason == "string" ? n.reason : "",
65
+ by: typeof n.by == "string" ? n.by : null,
66
+ by_name: typeof n.by_name == "string" ? n.by_name : null,
67
+ at: typeof n.at == "string" ? n.at : null
68
+ };
69
+ }
70
+ function z(t, n = a()) {
71
+ const e = y(t);
72
+ return e && n < e.until ? e : null;
73
+ }
74
+ function O(t, n) {
75
+ return { conditions: l(t, "freeze", n) };
76
+ }
77
+ function d(t) {
78
+ var e;
79
+ const n = (e = o(t)) == null ? void 0 : e.lazy_sections;
80
+ return Array.isArray(n) ? [...new Set(n.filter((r) => typeof r == "string"))] : [];
81
+ }
82
+ function $(t, n, e) {
83
+ const r = d(t).filter((f) => f !== n), u = e ? [...r, n] : r;
84
+ return { conditions: l(t, "lazy_sections", u.length ? u : null) };
85
+ }
86
+ const m = "(max-width: 639px)";
87
+ function S() {
88
+ var t;
89
+ try {
90
+ return typeof window < "u" && ((t = window.matchMedia) != null && t.call(window, m).matches) ? "phone" : null;
91
+ } catch {
92
+ return null;
93
+ }
94
+ }
95
+ export {
96
+ m as PHONE_QUERY,
97
+ z as activeFreeze,
98
+ p as activeWindowOf,
99
+ b as activeWindowPatch,
100
+ o as conditionsObject,
101
+ l as conditionsWithKey,
102
+ S as currentViewport,
103
+ i as dayWords,
104
+ y as freezeOf,
105
+ O as freezePatch,
106
+ $ as lazySectionPatch,
107
+ d as lazySectionsOf,
108
+ a as localDay,
109
+ _ as phoneOf,
110
+ w as phoneOfPatch,
111
+ h as windowState,
112
+ g as windowWords
113
+ };