@nivaro/react 0.3.136 → 0.3.138

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 (50) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +95 -4
  4. package/dist/index.js +748 -743
  5. package/dist/shared/components/CollectionBrowserView.js +392 -389
  6. package/dist/shared/components/DelegateCoverLine.js +80 -87
  7. package/dist/shared/components/ItemEditForm.js +589 -588
  8. package/dist/shared/components/MyWorkView.js +284 -286
  9. package/dist/shared/components/NotificationBell.js +251 -205
  10. package/dist/shared/components/ai/AiAnalyticsView.js +878 -417
  11. package/dist/shared/components/ai/AiPlanCard.js +164 -122
  12. package/dist/shared/components/ai/AiPlanUndo.js +291 -0
  13. package/dist/shared/components/ai/call-log/CallDrawer.js +357 -0
  14. package/dist/shared/components/ai/call-log/RawJson.js +126 -0
  15. package/dist/shared/components/ai/call-log/ThreadView.js +223 -0
  16. package/dist/shared/components/ai/call-log/TranscriptView.js +227 -0
  17. package/dist/shared/components/ai/call-log/controls.js +364 -0
  18. package/dist/shared/components/ai/call-log/format.js +46 -0
  19. package/dist/shared/components/ai/call-log/url.js +105 -0
  20. package/dist/shared/components/chat/ChatPanel.js +86 -86
  21. package/dist/shared/components/chat/chat-core.js +422 -346
  22. package/dist/shared/components/integrations/IntegrationObligationsView.js +98 -98
  23. package/dist/shared/components/integrations/RecordIntegrationPreview.js +102 -93
  24. package/dist/shared/components/integrations/console/api.js +11 -1
  25. package/dist/shared/components/item-edit/HeaderRollupExplainer.js +5 -1
  26. package/dist/shared/components/item-edit/RecordLiveSync.js +241 -229
  27. package/dist/shared/components/item-edit/RecordRecapChanges.js +166 -0
  28. package/dist/shared/components/item-edit/RecordRecapStrip.js +254 -84
  29. package/dist/shared/components/item-edit/live-related.js +34 -18
  30. package/dist/shared/components/panels/RevisionsPanel.js +735 -683
  31. package/dist/shared/components/queue/QueueWorklist.js +323 -316
  32. package/dist/shared/components/support/SupportRequestDialog.js +198 -181
  33. package/dist/shared/components/trackers/use-tracker-link.js +74 -65
  34. package/dist/shared/lib/config-update-refresh.js +34 -0
  35. package/dist/shared/lib/config-watch.js +17 -17
  36. package/dist/shared/lib/gap-refresh.js +49 -0
  37. package/dist/shared/lib/integration-dots.js +8 -8
  38. package/dist/shared/lib/live-ops.js +26 -23
  39. package/dist/shared/lib/live-pickers.js +1 -1
  40. package/dist/shared/lib/live-queries.js +223 -195
  41. package/dist/shared/lib/live.js +56 -51
  42. package/dist/shared/lib/obligation-banner.js +11 -10
  43. package/dist/shared/lib/obligation-filters.js +22 -18
  44. package/dist/shared/lib/obligation-reason-text.js +18 -8
  45. package/dist/shared/lib/presence-hooks.js +133 -132
  46. package/dist/shared/lib/reconnect-resync.js +90 -0
  47. package/dist/shared/lib/record-room-holds.js +43 -0
  48. package/dist/shared/lib/socket-realtime.js +116 -105
  49. package/dist/shared/lib/user-sync.js +1 -6
  50. package/package.json +1 -1
@@ -1,15 +1,16 @@
1
- import { useQueryClient as ce } from "@tanstack/react-query";
2
- import { useSyncExternalStore as he, useRef as pe, useEffect as ie } from "react";
3
- import { expandCoalesced as ge } from "./live.js";
4
- import { getLiveMode as me } from "./live-preference.js";
5
- import { LIVE_WIDGET_SAFETY_MS as we } from "./live-widgets.js";
6
- import { isOwnWrite as ye } from "./own-writes.js";
7
- import { useOptionalRealtime as le, useRealtimeStatus as Me } from "./realtime.js";
8
- import { setScreenRefreshClient as be } from "./screen-refresh.js";
9
- function xe(n) {
10
- return { live: n };
1
+ import { useQueryClient as ae } from "@tanstack/react-query";
2
+ import { useSyncExternalStore as ye, useRef as me, useEffect as ce } from "react";
3
+ import { expandCoalesced as be } from "./live.js";
4
+ import { getLiveMode as le } from "./live-preference.js";
5
+ import { LIVE_WIDGET_SAFETY_MS as Me } from "./live-widgets.js";
6
+ import { isOwnWrite as Se } from "./own-writes.js";
7
+ import { useOptionalRealtime as fe, useRealtimeStatus as Oe } from "./realtime.js";
8
+ import { onResync as Re } from "./reconnect-resync.js";
9
+ import { setScreenRefreshClient as Ee } from "./screen-refresh.js";
10
+ function Be(t) {
11
+ return { live: t };
11
12
  }
12
- const Oe = [
13
+ const Ce = [
13
14
  "item",
14
15
  "rrv-record",
15
16
  "revisions",
@@ -46,269 +47,296 @@ const Oe = [
46
47
  "live-record",
47
48
  "live-list",
48
49
  // Realtime round 2 (rt2-record): the record page's SLA clock re-reads after a reconnect too.
49
- "sla-breach"
50
- ], m = (n) => {
51
- var i;
52
- const s = (i = n.meta) == null ? void 0 : i.live;
50
+ "sla-breach",
51
+ // rt-fix C: record panels kept live by RecordLiveSync (proposals, obligation lines, external
52
+ // ids, dynamic attributes) re-read after a reconnect too.
53
+ "change-proposals",
54
+ "integration-obligations",
55
+ "record-external-ids",
56
+ "attribute-values"
57
+ ], Le = [
58
+ "notification-count",
59
+ "notifications",
60
+ "nvr-chat",
61
+ "nvr-chat-rooms",
62
+ "nvr-chat-thread",
63
+ "pipeline-all-owners",
64
+ "pipeline-instance-owners",
65
+ "pipeline-owners-resolved",
66
+ "cbv-owners",
67
+ "approval-brief",
68
+ "my-work",
69
+ "my-work-count"
70
+ ], w = (t) => {
71
+ var o;
72
+ const s = (o = t.meta) == null ? void 0 : o.live;
53
73
  return s && typeof s == "object" ? s : null;
54
74
  };
55
- function Se(n) {
56
- var i;
57
- if (!n || n.reconcileOnly) return [];
75
+ function Te(t) {
76
+ var o;
77
+ if (!t || t.reconcileOnly) return [];
58
78
  const s = /* @__PURE__ */ new Set();
59
- for (const f of n.reads ?? []) f && s.add(f);
60
- return (i = n.record) != null && i.collection && s.add(n.record.collection), [...s];
79
+ for (const a of t.reads ?? []) a && s.add(a);
80
+ return (o = t.record) != null && o.collection && s.add(t.record.collection), [...s];
61
81
  }
62
- function Ce(n, s, i) {
82
+ function ke(t, s, o) {
63
83
  var k;
64
- if (n.reconcileOnly) return !1;
65
- const f = n.record, v = !!f && f.collection === s;
66
- if (!v && !(n.reads ?? []).includes(s)) return !1;
67
- const C = n.includeOwn ?? !v, L = v ? String(f == null ? void 0 : f.id) : null;
68
- for (const p of i) {
69
- if (p.own && !C || L !== null && String(p.item) !== L && p.item !== "*") continue;
70
- if (p.action === "create" || p.action === "delete") return !0;
71
- const a = p.changed_fields;
72
- if (!a || a.length === 0) return !0;
73
- const E = a.filter((u) => !u.startsWith("$"));
74
- if (E.length > 0 && (!n.fields || E.some((u) => {
75
- var w;
76
- return (w = n.fields) == null ? void 0 : w.includes(u);
77
- })) || (k = n.aspects) != null && k.length && a.some((u) => {
78
- var w;
79
- return (w = n.aspects) == null ? void 0 : w.includes(u);
84
+ if (t.reconcileOnly) return !1;
85
+ const a = t.record, v = !!a && a.collection === s;
86
+ if (!v && !(t.reads ?? []).includes(s)) return !1;
87
+ const R = t.includeOwn ?? !v, T = v ? String(a == null ? void 0 : a.id) : null;
88
+ for (const g of o) {
89
+ if (g.own && !R || T !== null && String(g.item) !== T && g.item !== "*") continue;
90
+ if (g.action === "create" || g.action === "delete") return !0;
91
+ const d = g.changed_fields;
92
+ if (!d || d.length === 0) return !0;
93
+ const E = d.filter((u) => !u.startsWith("$"));
94
+ if (E.length > 0 && (!t.fields || E.some((u) => {
95
+ var y;
96
+ return (y = t.fields) == null ? void 0 : y.includes(u);
97
+ })) || (k = t.aspects) != null && k.length && d.some((u) => {
98
+ var y;
99
+ return (y = t.aspects) == null ? void 0 : y.includes(u);
80
100
  })) return !0;
81
101
  }
82
102
  return !1;
83
103
  }
84
- const x = /* @__PURE__ */ new Map(), V = /* @__PURE__ */ new Set(), re = (n, s) => {
85
- const i = (x.get(n) ?? 0) + s;
86
- i > 0 ? x.set(n, i) : x.delete(n);
87
- for (const f of V) f();
104
+ const q = /* @__PURE__ */ new Map(), F = /* @__PURE__ */ new Set(), ue = (t, s) => {
105
+ const o = (q.get(t) ?? 0) + s;
106
+ o > 0 ? q.set(t, o) : q.delete(t);
107
+ for (const a of F) a();
88
108
  };
89
- function Ee(n, s, i = {}) {
90
- var $, J;
91
- const f = i.windowMs ?? 300, v = i.readsGapMs ?? 1e4, C = i.hiddenReconcileMs ?? 5 * 6e4, L = i.lingerMs ?? 3e4, k = i.jitterMs ?? 1500, p = i.isOwn ?? ((t, e) => ye(t, e)), a = i.now ?? (() => Date.now()), E = i.random ?? Math.random, u = i.doc === void 0 ? typeof document > "u" ? null : document : i.doc, w = i.win === void 0 ? typeof window > "u" ? null : window : i.win, Q = n.getQueryCache(), R = { events: 0, refetches: 0, reconciles: 0, deferred: 0 };
92
- let g = !1;
93
- const h = /* @__PURE__ */ new Map(), M = /* @__PURE__ */ new Map(), A = /* @__PURE__ */ new Map(), j = /* @__PURE__ */ new Map(), ue = 500, fe = (t) => {
94
- if (g || !(t != null && t.collection)) return;
95
- const e = String(t.collection);
96
- if (!h.has(e)) return;
97
- R.events++;
98
- const o = A.get(e) ?? [];
99
- for (const c of ge(t)) {
100
- if (o.length >= ue) {
101
- o.length = 0, o.push({ collection: e, item: "*", own: !1 });
109
+ function Qe(t, s, o = {}) {
110
+ var Z, ee;
111
+ const a = o.windowMs ?? 300, v = o.readsGapMs ?? 1e4, R = o.hiddenReconcileMs ?? 5 * 6e4, T = o.lingerMs ?? 3e4, k = o.jitterMs ?? 1500, g = o.isOwn ?? ((e, n) => Se(e, n)), d = o.now ?? (() => Date.now()), E = o.random ?? Math.random, u = o.doc === void 0 ? typeof document > "u" ? null : document : o.doc, y = o.win === void 0 ? typeof window > "u" ? null : window : o.win, Q = t.getQueryCache(), C = { events: 0, refetches: 0, reconciles: 0, deferred: 0 };
112
+ let h = !1;
113
+ const p = /* @__PURE__ */ new Map(), b = /* @__PURE__ */ new Map(), A = /* @__PURE__ */ new Map(), _ = /* @__PURE__ */ new Map(), de = 500, ve = (e) => {
114
+ if (h || !(e != null && e.collection)) return;
115
+ const n = String(e.collection);
116
+ if (!p.has(n)) return;
117
+ C.events++;
118
+ const i = A.get(n) ?? [];
119
+ for (const c of be(e)) {
120
+ if (i.length >= de) {
121
+ i.length = 0, i.push({ collection: n, item: "*", own: !1 });
102
122
  break;
103
123
  }
104
- o.push({ ...c, own: c.item != null && c.item !== "*" && p(e, c.item) });
124
+ i.push({ ...c, own: c.item != null && c.item !== "*" && g(n, c.item) });
105
125
  }
106
- A.set(e, o), j.has(e) || j.set(
107
- e,
108
- setTimeout(() => ae(e), f)
126
+ A.set(n, i), _.has(n) || _.set(
127
+ n,
128
+ setTimeout(() => pe(n), a)
109
129
  );
110
- }, U = () => {
111
- if (g) return;
112
- const t = /* @__PURE__ */ new Set();
113
- for (const e of Q.getAll()) {
114
- if (e.getObserversCount() === 0) continue;
115
- const o = m(e);
116
- if (!(o != null && o.staleOnly && !e.state.dataUpdatedAt))
117
- for (const c of Se(o)) t.add(c);
130
+ }, K = () => {
131
+ if (h) return;
132
+ const e = /* @__PURE__ */ new Set();
133
+ for (const n of Q.getAll()) {
134
+ if (n.getObserversCount() === 0) continue;
135
+ const i = w(n);
136
+ if (!(i != null && i.staleOnly && !n.state.dataUpdatedAt))
137
+ for (const c of Te(i)) e.add(c);
118
138
  }
119
- for (const e of t) {
120
- const o = M.get(e);
121
- o && (clearTimeout(o), M.delete(e)), h.has(e) || h.set(e, s.subscribeCollections([e], fe));
139
+ for (const n of e) {
140
+ const i = b.get(n);
141
+ i && (clearTimeout(i), b.delete(n)), p.has(n) || p.set(n, s.subscribeCollections([n], ve));
122
142
  }
123
- for (const e of h.keys())
124
- t.has(e) || M.has(e) || M.set(
125
- e,
143
+ for (const n of p.keys())
144
+ e.has(n) || b.has(n) || b.set(
145
+ n,
126
146
  setTimeout(() => {
127
- var o;
128
- M.delete(e), (o = h.get(e)) == null || o(), h.delete(e);
129
- }, L)
147
+ var i;
148
+ b.delete(n), (i = p.get(n)) == null || i(), p.delete(n);
149
+ }, T)
130
150
  );
131
151
  };
132
- let G = !1;
133
- const W = () => {
134
- G || (G = !0, queueMicrotask(() => {
135
- G = !1, U();
152
+ let D = !1;
153
+ const U = () => {
154
+ D || (D = !0, queueMicrotask(() => {
155
+ D = !1, K();
136
156
  }));
137
- }, z = /* @__PURE__ */ new WeakSet(), de = Q.subscribe((t) => {
138
- var e, o;
139
- if (t.type === "added" || t.type === "removed" || t.type === "observerAdded" || t.type === "observerRemoved" || t.type === "observerOptionsUpdated")
140
- W();
141
- else if (t.type === "updated" && ((e = t.action) == null ? void 0 : e.type) === "success") {
142
- const c = t.query;
143
- (o = m(c)) != null && o.staleOnly && !z.has(c) && (z.add(c), W());
157
+ }, W = /* @__PURE__ */ new WeakSet(), he = Q.subscribe((e) => {
158
+ var n, i;
159
+ if (e.type === "added" || e.type === "removed" || e.type === "observerAdded" || e.type === "observerRemoved" || e.type === "observerOptionsUpdated")
160
+ U();
161
+ else if (e.type === "updated" && ((n = e.action) == null ? void 0 : n.type) === "success") {
162
+ const c = e.query;
163
+ (i = w(c)) != null && i.staleOnly && !W.has(c) && (W.add(c), U());
144
164
  }
145
- }), D = /* @__PURE__ */ new WeakMap(), b = /* @__PURE__ */ new Map(), I = /* @__PURE__ */ new Map(), _ = /* @__PURE__ */ new Set(), H = (t, e) => {
146
- if (t.length === 0) return;
147
- const o = new Set(t), c = a();
148
- for (const l of t) D.set(l, c);
149
- R.refetches += t.filter((l) => l.getObserversCount() > 0).length, n.invalidateQueries(
150
- { predicate: (l) => o.has(l) },
151
- { cancelRefetch: e }
165
+ }), G = /* @__PURE__ */ new WeakMap(), M = /* @__PURE__ */ new Map(), I = /* @__PURE__ */ new Map(), j = /* @__PURE__ */ new Set(), Y = (e, n) => {
166
+ if (e.length === 0) return;
167
+ const i = new Set(e), c = d();
168
+ for (const l of e) G.set(l, c);
169
+ C.refetches += e.filter((l) => l.getObserversCount() > 0).length, t.invalidateQueries(
170
+ { predicate: (l) => i.has(l) },
171
+ { cancelRefetch: n }
152
172
  );
153
- }, N = (t, e = !0) => {
154
- var ee, te, ne;
155
- const o = [], c = [];
156
- for (const r of t)
157
- r.getObserversCount() === 0 || (ee = m(r)) != null && ee.staleOnly ? c.push(r) : u != null && u.hidden ? (c.push(r), _.add(r)) : o.push(r);
173
+ }, N = (e, n = !0) => {
174
+ var te, se, oe;
175
+ const i = [], c = [];
176
+ for (const r of e)
177
+ r.getObserversCount() === 0 || (te = w(r)) != null && te.staleOnly ? c.push(r) : u != null && u.hidden ? (c.push(r), j.add(r)) : i.push(r);
158
178
  if (c.length) {
159
179
  const r = new Set(c);
160
- R.deferred += c.length, n.invalidateQueries({ predicate: (d) => r.has(d), refetchType: "none" });
180
+ C.deferred += c.length, t.invalidateQueries({ predicate: (f) => r.has(f), refetchType: "none" });
161
181
  }
162
- const l = a(), y = [];
163
- for (const r of o) {
164
- const d = m(r), S = (d == null ? void 0 : d.minGapMs) ?? (d != null && d.record ? 0 : v), se = D.get(r) ?? 0;
165
- if (S <= 0 || l - se >= S) {
166
- const oe = b.get(r);
167
- oe && (clearTimeout(oe), b.delete(r)), y.push(r);
168
- } else b.has(r) || b.set(
182
+ const l = d(), m = [];
183
+ for (const r of i) {
184
+ const f = w(r), O = (f == null ? void 0 : f.minGapMs) ?? (f != null && f.record ? 0 : v), ie = G.get(r) ?? 0;
185
+ if (O <= 0 || l - ie >= O) {
186
+ const re = M.get(r);
187
+ re && (clearTimeout(re), M.delete(r)), m.push(r);
188
+ } else M.has(r) || M.set(
169
189
  r,
170
190
  setTimeout(
171
191
  () => {
172
- b.delete(r), g || N([r]);
192
+ M.delete(r), h || N([r]);
173
193
  },
174
- se + S - l
194
+ ie + O - l
175
195
  )
176
196
  );
177
197
  }
178
- const Z = [];
179
- for (const r of y) {
180
- const d = ((te = m(r)) == null ? void 0 : te.jitterMs) ?? 0, S = ((ne = m(r)) == null ? void 0 : ne.delayMs) ?? 0;
181
- if (d <= 0 && S <= 0) {
182
- Z.push(r);
198
+ const ne = [];
199
+ for (const r of m) {
200
+ const f = ((se = w(r)) == null ? void 0 : se.jitterMs) ?? 0, O = ((oe = w(r)) == null ? void 0 : oe.delayMs) ?? 0;
201
+ if (f <= 0 && O <= 0) {
202
+ ne.push(r);
183
203
  continue;
184
204
  }
185
- I.has(r) || (D.set(r, l), I.set(
205
+ I.has(r) || (G.set(r, l), I.set(
186
206
  r,
187
207
  setTimeout(
188
208
  () => {
189
- I.delete(r), g || H([r], e);
209
+ I.delete(r), h || Y([r], n);
190
210
  },
191
- S + Math.floor(E() * Math.max(0, d))
211
+ O + Math.floor(E() * Math.max(0, f))
192
212
  )
193
213
  ));
194
214
  }
195
- H(Z, e);
196
- }, ae = (t) => {
197
- j.delete(t);
198
- const e = A.get(t) ?? [];
199
- if (A.delete(t), g || e.length === 0) return;
200
- const o = [];
215
+ Y(ne, n);
216
+ }, pe = (e) => {
217
+ _.delete(e);
218
+ const n = A.get(e) ?? [];
219
+ if (A.delete(e), h || n.length === 0) return;
220
+ const i = [];
201
221
  for (const c of Q.getAll()) {
202
- const l = m(c);
203
- l && Ce(l, t, e) && o.push(c);
222
+ const l = w(c);
223
+ l && ke(l, e, n) && i.push(c);
204
224
  }
205
- N(o);
206
- }, ve = new Set(Oe), B = (t) => {
207
- if (g || me() === "off") return;
208
- R.reconciles++;
209
- const e = [], o = /* @__PURE__ */ new Set();
225
+ N(i);
226
+ }, ge = new Set(Ce), H = (e) => {
227
+ if (h || le() === "off") return;
228
+ C.reconciles++;
229
+ const n = [], i = /* @__PURE__ */ new Set();
210
230
  for (const l of Q.getAll()) {
211
- const y = m(l);
212
- y != null && y.staleOnly ? o.add(l) : y && e.push(l);
231
+ const m = w(l);
232
+ m != null && m.staleOnly ? i.add(l) : m && n.push(l);
213
233
  }
214
- _.clear(), o.size > 0 && n.invalidateQueries({
215
- predicate: (l) => o.has(l),
234
+ j.clear(), i.size > 0 && t.invalidateQueries({
235
+ predicate: (l) => i.has(l),
216
236
  refetchType: "none"
217
237
  });
218
- const c = new Set(e);
219
- n.invalidateQueries(
238
+ const c = new Set(n);
239
+ t.invalidateQueries(
220
240
  {
221
- predicate: (l) => c.has(l) || l.getObserversCount() > 0 && ve.has(String(l.queryKey[0]))
241
+ predicate: (l) => c.has(l) || l.getObserversCount() > 0 && ge.has(String(l.queryKey[0]))
222
242
  },
223
243
  { cancelRefetch: !1 }
224
244
  );
225
245
  };
226
- let T = null;
227
- const K = (t) => {
228
- T || (T = setTimeout(
246
+ let L = null;
247
+ const z = (e) => {
248
+ L || (L = setTimeout(
229
249
  () => {
230
- T = null, B();
250
+ L = null, H();
231
251
  },
232
252
  Math.floor(E() * k)
233
253
  ));
234
254
  };
235
- let P = (($ = s.status) == null ? void 0 : $.call(s).state) !== "reconnecting";
236
- const F = (J = s.onStatus) == null ? void 0 : J.call(s, (t) => {
237
- const e = t.state === "live";
238
- e && !P && (t.resumed === "unverified" || t.resumed === void 0) && K(), P = e;
239
- }), X = () => K(), O = i.reconcileOnCatchupFull === !1 ? null : w;
240
- O == null || O.addEventListener("nvr:catchup-full", X);
241
- let q = u != null && u.hidden ? a() : null;
242
- const Y = () => {
255
+ let P = ((Z = s.status) == null ? void 0 : Z.call(s).state) !== "reconnecting";
256
+ const V = (ee = s.onStatus) == null ? void 0 : ee.call(s, (e) => {
257
+ const n = e.state === "live";
258
+ n && !P && (e.resumed === "unverified" || e.resumed === void 0) && z(), P = n;
259
+ }), we = /* @__PURE__ */ new Set([...Le, ...o.resyncHeads ?? []]), X = () => {
260
+ h || le() === "off" || t.invalidateQueries(
261
+ {
262
+ predicate: (e) => e.getObserversCount() > 0 && we.has(String(e.queryKey[0]))
263
+ },
264
+ { cancelRefetch: !1 }
265
+ );
266
+ }, B = o.onResync === null ? void 0 : o.onResync ? o.onResync(X) : Re(s, X), $ = () => z(), S = o.reconcileOnCatchupFull === !1 ? null : y;
267
+ S == null || S.addEventListener("nvr:catchup-full", $);
268
+ let x = u != null && u.hidden ? d() : null;
269
+ const J = () => {
243
270
  if (!u) return;
244
271
  if (u.hidden) {
245
- q ?? (q = a());
272
+ x ?? (x = d());
246
273
  return;
247
274
  }
248
- const t = q == null ? 0 : a() - q;
249
- if (q = null, t >= C) {
250
- B();
275
+ const e = x == null ? 0 : d() - x;
276
+ if (x = null, e >= R) {
277
+ H();
251
278
  return;
252
279
  }
253
- const e = [..._].filter((o) => o.getObserversCount() > 0);
254
- _.clear(), N(e, !1);
280
+ const n = [...j].filter((i) => i.getObserversCount() > 0);
281
+ j.clear(), N(n, !1);
255
282
  };
256
- return u == null || u.addEventListener("visibilitychange", Y), re(n, 1), U(), {
257
- reconcile: B,
258
- collections: () => [...h.keys()],
259
- stats: () => ({ ...R }),
283
+ return u == null || u.addEventListener("visibilitychange", J), ue(t, 1), K(), {
284
+ reconcile: H,
285
+ collections: () => [...p.keys()],
286
+ stats: () => ({ ...C }),
260
287
  dispose() {
261
- if (!g) {
262
- g = !0, de(), F == null || F(), O == null || O.removeEventListener("nvr:catchup-full", X), u == null || u.removeEventListener("visibilitychange", Y);
263
- for (const t of [
264
- ...j.values(),
265
- ...M.values(),
288
+ if (!h) {
289
+ h = !0, he(), V == null || V(), B == null || B(), S == null || S.removeEventListener("nvr:catchup-full", $), u == null || u.removeEventListener("visibilitychange", J);
290
+ for (const e of [
291
+ ..._.values(),
266
292
  ...b.values(),
293
+ ...M.values(),
267
294
  ...I.values()
268
295
  ])
269
- clearTimeout(t);
270
- T && clearTimeout(T);
271
- for (const t of h.values()) t();
272
- h.clear(), re(n, -1);
296
+ clearTimeout(e);
297
+ L && clearTimeout(L);
298
+ for (const e of p.values()) e();
299
+ p.clear(), ue(t, -1);
273
300
  }
274
301
  }
275
302
  };
276
303
  }
277
- function Ge(n) {
278
- const s = ce(), i = le(), f = pe(n);
279
- ie(() => {
280
- be(s);
281
- }, [s]), ie(() => {
282
- if (!i) return;
283
- const v = Ee(s, i, f.current);
304
+ function Fe(t) {
305
+ const s = ae(), o = fe(), a = me(t);
306
+ ce(() => {
307
+ Ee(s);
308
+ }, [s]), ce(() => {
309
+ if (!o) return;
310
+ const v = Qe(s, o, a.current);
284
311
  return () => v.dispose();
285
- }, [s, i]);
312
+ }, [s, o]);
286
313
  }
287
- function Re() {
288
- const n = ce();
289
- return he(
290
- (s) => (V.add(s), () => {
291
- V.delete(s);
314
+ function Ae() {
315
+ const t = ae();
316
+ return ye(
317
+ (s) => (F.add(s), () => {
318
+ F.delete(s);
292
319
  }),
293
- () => x.has(n),
320
+ () => q.has(t),
294
321
  () => !1
295
322
  );
296
323
  }
297
- function De(n, s = {}) {
298
- const i = le(), f = Me(), v = Re(), C = s.enabled !== !1 && !!i && (f == null ? void 0 : f.state) !== "reconnecting" && (!s.requireBridge || v);
299
- return Te(C, n, s.safetyMs);
324
+ function Ke(t, s = {}) {
325
+ const o = fe(), a = Oe(), v = Ae(), R = s.enabled !== !1 && !!o && (a == null ? void 0 : a.state) !== "reconnecting" && (!s.requireBridge || v);
326
+ return _e(R, t, s.safetyMs);
300
327
  }
301
- function Te(n, s, i = we) {
302
- return !n || s == null || s === !1 ? s : Math.max(s, i);
328
+ function _e(t, s, o = Me) {
329
+ return !t || s == null || s === !1 ? s : Math.max(s, o);
303
330
  }
304
331
  export {
305
- Oe as LIVE_RECONCILE_HEADS,
306
- Ee as createLiveQueryBridge,
307
- Se as liveCollectionsOf,
308
- Ce as liveEventsMatch,
309
- xe as liveQueryMeta,
310
- Te as liveRefetchInterval,
311
- Re as useLiveQueriesOn,
312
- Ge as useLiveQueryBridge,
313
- De as useLiveRefetchInterval
332
+ Ce as LIVE_RECONCILE_HEADS,
333
+ Le as LIVE_RESYNC_HEADS,
334
+ Qe as createLiveQueryBridge,
335
+ Te as liveCollectionsOf,
336
+ ke as liveEventsMatch,
337
+ Be as liveQueryMeta,
338
+ _e as liveRefetchInterval,
339
+ Ae as useLiveQueriesOn,
340
+ Fe as useLiveQueryBridge,
341
+ Ke as useLiveRefetchInterval
314
342
  };