fetchium 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. package/CHANGELOG.md +6 -5
  2. package/dist/cjs/development/QueryClient-CLi3ONNM.js +2 -0
  3. package/dist/cjs/development/QueryClient-CLi3ONNM.js.map +1 -0
  4. package/dist/cjs/development/QueryController-BQA49OYU.js +2 -0
  5. package/dist/cjs/development/QueryController-BQA49OYU.js.map +1 -0
  6. package/dist/cjs/development/index.js +1 -1
  7. package/dist/cjs/development/index.js.map +1 -1
  8. package/dist/cjs/development/mutation-CikIl_6k.js +2 -0
  9. package/dist/cjs/development/mutation-CikIl_6k.js.map +1 -0
  10. package/dist/cjs/development/react/index.js +1 -1
  11. package/dist/cjs/development/rest/index.js +2 -0
  12. package/dist/cjs/development/rest/index.js.map +1 -0
  13. package/dist/cjs/development/topic/index.js +2 -0
  14. package/dist/cjs/development/topic/index.js.map +1 -0
  15. package/dist/cjs/production/QueryClient-N0MJmuHW.js +2 -0
  16. package/dist/cjs/production/QueryClient-N0MJmuHW.js.map +1 -0
  17. package/dist/cjs/production/QueryController-BQA49OYU.js +2 -0
  18. package/dist/cjs/production/QueryController-BQA49OYU.js.map +1 -0
  19. package/dist/cjs/production/index.js +1 -1
  20. package/dist/cjs/production/index.js.map +1 -1
  21. package/dist/cjs/production/mutation-P_Yb4LI9.js +2 -0
  22. package/dist/cjs/production/mutation-P_Yb4LI9.js.map +1 -0
  23. package/dist/cjs/production/react/index.js +1 -1
  24. package/dist/cjs/production/rest/index.js +2 -0
  25. package/dist/cjs/production/rest/index.js.map +1 -0
  26. package/dist/cjs/production/topic/index.js +2 -0
  27. package/dist/cjs/production/topic/index.js.map +1 -0
  28. package/dist/esm/MutationResult.d.ts +0 -1
  29. package/dist/esm/MutationResult.d.ts.map +1 -1
  30. package/dist/esm/QueryClient.d.ts +26 -4
  31. package/dist/esm/QueryClient.d.ts.map +1 -1
  32. package/dist/esm/QueryController.d.ts +49 -0
  33. package/dist/esm/QueryController.d.ts.map +1 -0
  34. package/dist/esm/QueryResult.d.ts +10 -10
  35. package/dist/esm/QueryResult.d.ts.map +1 -1
  36. package/dist/esm/development/QueryClient-Dtde3pss.js +2572 -0
  37. package/dist/esm/development/QueryClient-Dtde3pss.js.map +1 -0
  38. package/dist/esm/development/QueryController-Ch_ncxiI.js +14 -0
  39. package/dist/esm/development/QueryController-Ch_ncxiI.js.map +1 -0
  40. package/dist/esm/development/index.js +29 -100
  41. package/dist/esm/development/index.js.map +1 -1
  42. package/dist/esm/development/mutation-UZshUQAf.js +58 -0
  43. package/dist/esm/development/mutation-UZshUQAf.js.map +1 -0
  44. package/dist/esm/development/react/index.js +1 -1
  45. package/dist/esm/development/rest/index.js +142 -0
  46. package/dist/esm/development/rest/index.js.map +1 -0
  47. package/dist/esm/development/{shared-Dq2yW78d.js → shared-DcuVH8Pf.js} +5 -5
  48. package/dist/esm/development/{shared-Dq2yW78d.js.map → shared-DcuVH8Pf.js.map} +1 -1
  49. package/dist/esm/development/stores/async.js +6 -6
  50. package/dist/esm/development/stores/sync.js +5 -5
  51. package/dist/esm/development/topic/index.js +86 -0
  52. package/dist/esm/development/topic/index.js.map +1 -0
  53. package/dist/esm/index.d.ts +5 -4
  54. package/dist/esm/index.d.ts.map +1 -1
  55. package/dist/esm/mutation.d.ts +6 -19
  56. package/dist/esm/mutation.d.ts.map +1 -1
  57. package/dist/esm/production/{QueryClient-BP0Z1rQV.js → QueryClient-YqnBxFy1.js} +972 -968
  58. package/dist/esm/production/QueryClient-YqnBxFy1.js.map +1 -0
  59. package/dist/esm/production/QueryController-Ch_ncxiI.js +14 -0
  60. package/dist/esm/production/QueryController-Ch_ncxiI.js.map +1 -0
  61. package/dist/esm/production/index.js +29 -100
  62. package/dist/esm/production/index.js.map +1 -1
  63. package/dist/esm/production/mutation-pgFl1uIY.js +58 -0
  64. package/dist/esm/production/mutation-pgFl1uIY.js.map +1 -0
  65. package/dist/esm/production/react/index.js +1 -1
  66. package/dist/esm/production/rest/index.js +142 -0
  67. package/dist/esm/production/rest/index.js.map +1 -0
  68. package/dist/esm/production/{shared-Dq2yW78d.js → shared-DcuVH8Pf.js} +5 -5
  69. package/dist/esm/production/{shared-Dq2yW78d.js.map → shared-DcuVH8Pf.js.map} +1 -1
  70. package/dist/esm/production/stores/async.js +6 -6
  71. package/dist/esm/production/stores/sync.js +5 -5
  72. package/dist/esm/production/topic/index.js +86 -0
  73. package/dist/esm/production/topic/index.js.map +1 -0
  74. package/dist/esm/query-types.d.ts +2 -4
  75. package/dist/esm/query-types.d.ts.map +1 -1
  76. package/dist/esm/query.d.ts +17 -39
  77. package/dist/esm/query.d.ts.map +1 -1
  78. package/dist/esm/rest/RESTMutation.d.ts +18 -0
  79. package/dist/esm/rest/RESTMutation.d.ts.map +1 -0
  80. package/dist/esm/rest/RESTQuery.d.ts +24 -0
  81. package/dist/esm/rest/RESTQuery.d.ts.map +1 -0
  82. package/dist/esm/rest/RESTQueryController.d.ts +34 -0
  83. package/dist/esm/rest/RESTQueryController.d.ts.map +1 -0
  84. package/dist/esm/rest/index.d.ts +5 -0
  85. package/dist/esm/rest/index.d.ts.map +1 -0
  86. package/dist/esm/stores/shared.d.ts.map +1 -1
  87. package/dist/esm/testing/MockClient.d.ts +64 -0
  88. package/dist/esm/testing/MockClient.d.ts.map +1 -0
  89. package/dist/esm/testing/auto-generate.d.ts +20 -0
  90. package/dist/esm/testing/auto-generate.d.ts.map +1 -0
  91. package/dist/esm/testing/entity-factory.d.ts +13 -0
  92. package/dist/esm/testing/entity-factory.d.ts.map +1 -0
  93. package/dist/esm/testing/index.d.ts +6 -0
  94. package/dist/esm/testing/index.d.ts.map +1 -0
  95. package/dist/esm/testing/types.d.ts +37 -0
  96. package/dist/esm/testing/types.d.ts.map +1 -0
  97. package/dist/esm/topic/TopicQuery.d.ts +10 -0
  98. package/dist/esm/topic/TopicQuery.d.ts.map +1 -0
  99. package/dist/esm/topic/TopicQueryController.d.ts +43 -0
  100. package/dist/esm/topic/TopicQueryController.d.ts.map +1 -0
  101. package/dist/esm/topic/index.d.ts +3 -0
  102. package/dist/esm/topic/index.d.ts.map +1 -0
  103. package/dist/esm/typeDefs.d.ts +1 -1
  104. package/dist/esm/types.d.ts +9 -4
  105. package/dist/esm/types.d.ts.map +1 -1
  106. package/package.json +51 -4
  107. package/plugin/.claude-plugin/plugin.json +10 -0
  108. package/plugin/agents/fetchium.md +168 -0
  109. package/plugin/docs/api/fetchium-react.md +135 -0
  110. package/plugin/docs/api/fetchium.md +674 -0
  111. package/plugin/docs/api/stores-async.md +219 -0
  112. package/plugin/docs/api/stores-sync.md +133 -0
  113. package/plugin/docs/core/entities.md +351 -0
  114. package/plugin/docs/core/queries.md +600 -0
  115. package/plugin/docs/core/streaming.md +550 -0
  116. package/plugin/docs/core/types.md +374 -0
  117. package/plugin/docs/data/caching.md +298 -0
  118. package/plugin/docs/data/live-data.md +435 -0
  119. package/plugin/docs/data/mutations.md +465 -0
  120. package/plugin/docs/guides/auth.md +318 -0
  121. package/plugin/docs/guides/error-handling.md +351 -0
  122. package/plugin/docs/guides/offline.md +270 -0
  123. package/plugin/docs/guides/testing.md +301 -0
  124. package/plugin/docs/quickstart.md +170 -0
  125. package/plugin/docs/reference/pagination.md +519 -0
  126. package/plugin/docs/reference/rest-queries.md +107 -0
  127. package/plugin/docs/reference/why-signalium.md +364 -0
  128. package/plugin/docs/setup/project-setup.md +319 -0
  129. package/plugin/install.mjs +88 -0
  130. package/plugin/skills/design/SKILL.md +140 -0
  131. package/plugin/skills/teach/SKILL.md +105 -0
  132. package/dist/cjs/development/QueryClient-CpmwggOn.js +0 -2
  133. package/dist/cjs/development/QueryClient-CpmwggOn.js.map +0 -1
  134. package/dist/cjs/production/QueryClient-qi3bR0eD.js +0 -2
  135. package/dist/cjs/production/QueryClient-qi3bR0eD.js.map +0 -1
  136. package/dist/esm/development/QueryClient-DRZtPKFD.js +0 -2568
  137. package/dist/esm/development/QueryClient-DRZtPKFD.js.map +0 -1
  138. package/dist/esm/production/QueryClient-BP0Z1rQV.js.map +0 -1
@@ -1,10 +1,11 @@
1
- import { notifier as at, relay as It, setScopeOwner as pe, reactiveMethod as ge, signal as Mt, context as Tt, getContext as ve, task as _e, reactiveSignal as me, isSignal as Ee } from "signalium";
2
- import { registerCustomHash as we, hashValue as A } from "signalium/utils";
3
- import { D as Ft } from "./shared-Dq2yW78d.js";
4
- var q = /* @__PURE__ */ ((i) => (i.Always = "always", i.Online = "online", i.OfflineFirst = "offlineFirst", i))(q || {}), u = /* @__PURE__ */ ((i) => (i[i.UNDEFINED = 1] = "UNDEFINED", i[i.NULL = 2] = "NULL", i[i.NUMBER = 4] = "NUMBER", i[i.STRING = 8] = "STRING", i[i.BOOLEAN = 16] = "BOOLEAN", i[i.OBJECT = 32] = "OBJECT", i[i.ARRAY = 64] = "ARRAY", i[i.ID = 128] = "ID", i[i.RECORD = 256] = "RECORD", i[i.UNION = 512] = "UNION", i[i.ENTITY = 1024] = "ENTITY", i[i.HAS_FORMAT = 4096] = "HAS_FORMAT", i[i.IS_EAGER_FORMAT = 8192] = "IS_EAGER_FORMAT", i[i.PARSE_RESULT = 16384] = "PARSE_RESULT", i[i.LIVE = 32768] = "LIVE", i))(u || {});
5
- const B = /* @__PURE__ */ Symbol("array"), Q = /* @__PURE__ */ Symbol("record"), kt = /* @__PURE__ */ Symbol("QUERY_ID");
6
- var ct = /* @__PURE__ */ ((i) => (i[i.Array = 0] = "Array", i[i.Value = 1] = "Value", i))(ct || {});
7
- class U {
1
+ import { notifier as at, relay as It, setScopeOwner as ye, reactiveMethod as pe, signal as Nt, context as Mt, getContext as ge, task as ve, reactiveSignal as _e, isSignal as me, watcher as we } from "signalium";
2
+ import { registerCustomHash as Ee, hashValue as D } from "signalium/utils";
3
+ import { d as kt } from "./shared-DcuVH8Pf.js";
4
+ import { SyncQueryStore as Ce, MemoryPersistentStore as be } from "./stores/sync.js";
5
+ var L = /* @__PURE__ */ ((n) => (n.Always = "always", n.Online = "online", n.OfflineFirst = "offlineFirst", n))(L || {}), l = /* @__PURE__ */ ((n) => (n[n.UNDEFINED = 1] = "UNDEFINED", n[n.NULL = 2] = "NULL", n[n.NUMBER = 4] = "NUMBER", n[n.STRING = 8] = "STRING", n[n.BOOLEAN = 16] = "BOOLEAN", n[n.OBJECT = 32] = "OBJECT", n[n.ARRAY = 64] = "ARRAY", n[n.ID = 128] = "ID", n[n.RECORD = 256] = "RECORD", n[n.UNION = 512] = "UNION", n[n.ENTITY = 1024] = "ENTITY", n[n.HAS_FORMAT = 4096] = "HAS_FORMAT", n[n.IS_EAGER_FORMAT = 8192] = "IS_EAGER_FORMAT", n[n.PARSE_RESULT = 16384] = "PARSE_RESULT", n[n.LIVE = 32768] = "LIVE", n))(l || {});
6
+ const Q = /* @__PURE__ */ Symbol("array"), B = /* @__PURE__ */ Symbol("record"), Ft = /* @__PURE__ */ Symbol("QUERY_ID");
7
+ var ct = /* @__PURE__ */ ((n) => (n[n.Array = 0] = "Array", n[n.Value = 1] = "Value", n))(ct || {});
8
+ class j {
8
9
  type;
9
10
  entityDefs;
10
11
  constraintFieldRefs;
@@ -13,42 +14,42 @@ class U {
13
14
  onCreate;
14
15
  onUpdate;
15
16
  onDelete;
16
- constructor(t, e, n, s, r, o, a, c) {
17
- this.type = t, this.entityDefs = e, this.constraintFieldRefs = n, this.sort = s, this.valueType = r, this.onCreate = o, this.onUpdate = a, this.onDelete = c;
17
+ constructor(t, e, i, s, r, o, a, c) {
18
+ this.type = t, this.entityDefs = e, this.constraintFieldRefs = i, this.sort = s, this.valueType = r, this.onCreate = o, this.onUpdate = a, this.onDelete = c;
18
19
  }
19
- static array(t, e, n) {
20
- return new U(
20
+ static array(t, e, i) {
21
+ return new j(
21
22
  0,
22
23
  t,
23
24
  e,
24
- n,
25
+ i,
25
26
  void 0,
26
27
  void 0,
27
28
  void 0,
28
29
  void 0
29
30
  );
30
31
  }
31
- static value(t, e, n, s, r, o) {
32
- return new U(
32
+ static value(t, e, i, s, r, o) {
33
+ return new j(
33
34
  1,
34
35
  t,
35
36
  e,
36
37
  void 0,
37
- n,
38
+ i,
38
39
  s,
39
40
  r,
40
41
  o
41
42
  );
42
43
  }
43
44
  }
44
- const O = /* @__PURE__ */ new WeakMap();
45
- function F(i) {
46
- return O.get(i);
45
+ const x = /* @__PURE__ */ new WeakMap();
46
+ function k(n) {
47
+ return x.get(n);
47
48
  }
48
- var W = /* @__PURE__ */ ((i) => (i[i.Query = 0] = "Query", i[i.Entity = 1] = "Entity", i))(W || {});
49
- class be {
50
- constructor(t, e, n) {
51
- this._onEvict = e, this._intervalId = setInterval(this._tick, t * 6e4 * n);
49
+ var z = /* @__PURE__ */ ((n) => (n[n.Query = 0] = "Query", n[n.Entity = 1] = "Entity", n))(z || {});
50
+ class xe {
51
+ constructor(t, e, i) {
52
+ this._onEvict = e, this._intervalId = setInterval(this._tick, t * 6e4 * i);
52
53
  }
53
54
  _currentFlush = /* @__PURE__ */ new Map();
54
55
  _nextFlush = /* @__PURE__ */ new Map();
@@ -60,16 +61,16 @@ class be {
60
61
  this._currentFlush.delete(t), this._nextFlush.delete(t);
61
62
  }
62
63
  _tick = () => {
63
- const { _currentFlush: t, _nextFlush: e, _onEvict: n } = this;
64
+ const { _currentFlush: t, _nextFlush: e, _onEvict: i } = this;
64
65
  for (const [s, r] of t)
65
- n(s, r);
66
+ i(s, r);
66
67
  this._currentFlush = e, this._nextFlush = /* @__PURE__ */ new Map();
67
68
  };
68
69
  destroy() {
69
70
  clearInterval(this._intervalId);
70
71
  }
71
72
  }
72
- class Ce {
73
+ class Oe {
73
74
  _buckets = /* @__PURE__ */ new Map();
74
75
  _nextTickEntries = /* @__PURE__ */ new Map();
75
76
  _nextTickScheduled = !1;
@@ -78,16 +79,16 @@ class Ce {
78
79
  constructor(t, e = 1) {
79
80
  this._onEvict = t, this._multiplier = e;
80
81
  }
81
- schedule(t, e, n) {
82
+ schedule(t, e, i) {
82
83
  if (e === 1 / 0) return;
83
84
  if (e === 0) {
84
85
  const { _nextTickEntries: o } = this;
85
- o.set(t, n), this._nextTickScheduled || (this._nextTickScheduled = !0, setTimeout(this._flushNextTick, 0));
86
+ o.set(t, i), this._nextTickScheduled || (this._nextTickScheduled = !0, setTimeout(this._flushNextTick, 0));
86
87
  return;
87
88
  }
88
89
  const { _buckets: s } = this;
89
90
  let r = s.get(e);
90
- r || (r = new be(e, this._onEvict, this._multiplier), s.set(e, r)), r.schedule(t, n);
91
+ r || (r = new xe(e, this._onEvict, this._multiplier), s.set(e, r)), r.schedule(t, i);
91
92
  }
92
93
  cancel(t, e) {
93
94
  if (e !== 1 / 0) {
@@ -101,155 +102,155 @@ class Ce {
101
102
  _flushNextTick = () => {
102
103
  const { _nextTickEntries: t, _onEvict: e } = this;
103
104
  this._nextTickScheduled = !1;
104
- for (const [n, s] of t)
105
- e(n, s);
105
+ for (const [i, s] of t)
106
+ e(i, s);
106
107
  t.clear();
107
108
  };
108
109
  destroy() {
109
110
  const { _buckets: t, _nextTickEntries: e } = this;
110
- for (const n of t.values())
111
- n.destroy();
111
+ for (const i of t.values())
112
+ i.destroy();
112
113
  t.clear(), e.clear();
113
114
  }
114
115
  }
115
- class xe {
116
- schedule(t, e, n) {
116
+ class Re {
117
+ schedule(t, e, i) {
117
118
  }
118
119
  cancel(t, e) {
119
120
  }
120
121
  destroy() {
121
122
  }
122
123
  }
123
- const Y = /* @__PURE__ */ Symbol("fieldRef"), M = /* @__PURE__ */ Symbol("fieldRefPath"), ft = /* @__PURE__ */ Symbol("DEFINITION_TARGET"), G = /* @__PURE__ */ Symbol("CANCEL_PROXY"), Re = /\[([^\]]+)\]/g;
124
- function Pt(i) {
124
+ const Y = /* @__PURE__ */ Symbol("fieldRef"), N = /* @__PURE__ */ Symbol("fieldRefPath"), ft = /* @__PURE__ */ Symbol("DEFINITION_TARGET"), G = /* @__PURE__ */ Symbol("CANCEL_PROXY"), Se = /\[([^\]]+)\]/g;
125
+ function Tt(n) {
125
126
  const t = {
126
127
  [Y]: !0,
127
- [M]: i
128
+ [N]: n
128
129
  };
129
- return new Proxy(t, Oe);
130
+ return new Proxy(t, Ae);
130
131
  }
131
- const Oe = {
132
- get(i, t) {
132
+ const Ae = {
133
+ get(n, t) {
133
134
  if (t === Y) return !0;
134
- if (t === M) return i[M];
135
+ if (t === N) return n[N];
135
136
  if (t === Symbol.toPrimitive || t === "toString" || t === "valueOf") {
136
- const n = i[M];
137
- return () => `[${n.join(".")}]`;
137
+ const i = n[N];
138
+ return () => `[${i.join(".")}]`;
138
139
  }
139
140
  if (typeof t == "symbol") return;
140
- const e = i[M];
141
- return Pt([...e, t]);
141
+ const e = n[N];
142
+ return Tt([...e, t]);
142
143
  },
143
- has(i, t) {
144
- return t === Y || t === M;
144
+ has(n, t) {
145
+ return t === Y || t === N;
145
146
  }
146
147
  };
147
- function Lt(i) {
148
- return typeof i == "object" && i !== null && i[Y] === !0;
148
+ function Pt(n) {
149
+ return typeof n == "object" && n !== null && n[Y] === !0;
149
150
  }
150
- function jt(i) {
151
- return i[M];
151
+ function Lt(n) {
152
+ return n[N];
152
153
  }
153
- function qt(i) {
154
- return new Proxy(i, {
155
- set(t, e, n) {
156
- return t[e] = n, !0;
154
+ function jt(n) {
155
+ return new Proxy(n, {
156
+ set(t, e, i) {
157
+ return t[e] = i, !0;
157
158
  },
158
159
  get(t, e) {
159
160
  return e === ft ? t : e === G ? () => {
160
- } : typeof e == "symbol" ? t[e] : Pt([e]);
161
+ } : typeof e == "symbol" ? t[e] : Tt([e]);
161
162
  }
162
163
  });
163
164
  }
164
- function Se(i) {
165
- const t = i[ft];
166
- i[G]();
165
+ function De(n) {
166
+ const t = n[ft];
167
+ n[G]();
167
168
  const e = {};
168
169
  for (const r of Object.getOwnPropertyNames(t))
169
170
  e[r] = t[r];
170
- const n = {};
171
+ const i = {};
171
172
  let s = Object.getPrototypeOf(t);
172
173
  for (; s && s !== Object.prototype; ) {
173
174
  for (const r of Object.getOwnPropertyNames(s)) {
174
175
  if (r === "constructor") continue;
175
176
  const o = Object.getOwnPropertyDescriptor(s, r);
176
- typeof o.value == "function" && !(r in n) && (n[r] = o.value);
177
+ typeof o.value == "function" && !(r in i) && (i[r] = o.value);
177
178
  }
178
179
  s = Object.getPrototypeOf(s);
179
180
  }
180
- return { fields: e, methods: n };
181
+ return { fields: e, methods: i };
181
182
  }
182
- function ut(i, t) {
183
+ function ut(n, t) {
183
184
  let e = t;
184
- for (const n of i) {
185
+ for (const i of n) {
185
186
  if (e == null) return;
186
- e = e[n];
187
+ e = e[i];
187
188
  }
188
189
  return e;
189
190
  }
190
- function Ne(i, t) {
191
- return i.replace(Re, (e, n) => {
192
- const s = n.split("."), r = ut(s, t);
191
+ function Ie(n, t) {
192
+ return n.replace(Se, (e, i) => {
193
+ const s = i.split("."), r = ut(s, t);
193
194
  return r != null ? encodeURIComponent(String(r)) : "";
194
195
  });
195
196
  }
196
- function P(i, t) {
197
- if (Lt(i))
198
- return ut(jt(i), t);
199
- if (typeof i == "string")
200
- return Ne(i, t);
201
- if (Array.isArray(i))
202
- return i.map((e) => P(e, t));
203
- if (typeof i == "object" && i !== null && Object.getPrototypeOf(i) === Object.prototype) {
197
+ function W(n, t) {
198
+ if (Pt(n))
199
+ return ut(Lt(n), t);
200
+ if (typeof n == "string")
201
+ return Ie(n, t);
202
+ if (Array.isArray(n))
203
+ return n.map((e) => W(e, t));
204
+ if (typeof n == "object" && n !== null && Object.getPrototypeOf(n) === Object.prototype) {
204
205
  const e = {};
205
- for (const n of Object.keys(i))
206
- e[n] = P(i[n], t);
206
+ for (const i of Object.keys(n))
207
+ e[i] = W(n[i], t);
207
208
  return e;
208
209
  }
209
- return i;
210
+ return n;
210
211
  }
211
- function et(i, t, e) {
212
- const n = i.fields, s = i.methods, r = { params: t }, o = {};
213
- for (const [a, c] of Object.entries(n))
214
- o[a] = P(c, r);
212
+ function et(n, t, e) {
213
+ const i = n.fields, s = n.methods, r = { params: t }, o = {};
214
+ for (const [a, c] of Object.entries(i))
215
+ o[a] = W(c, r);
215
216
  o.params = t, o.context = e;
216
217
  for (const [a, c] of Object.entries(s))
217
218
  o[a] = c.bind(o);
218
219
  return o;
219
220
  }
220
- class Ut {
221
+ class qt {
221
222
  static cache;
222
223
  constructor() {
223
- return qt(this);
224
+ return jt(this);
224
225
  }
225
226
  }
226
- const Vt = Object.entries, it = Object.keys;
227
- function Et(i) {
228
- return typeof i == "number" ? i | u.UNDEFINED : i instanceof _ ? (i.mask & u.UNDEFINED) !== 0 ? i : _.cloneWith(i, u.UNDEFINED) : i;
227
+ const Ut = Object.entries, nt = Object.keys;
228
+ function wt(n) {
229
+ return typeof n == "number" ? n | l.UNDEFINED : n instanceof _ ? (n.mask & l.UNDEFINED) !== 0 ? n : _.cloneWith(n, l.UNDEFINED) : n;
229
230
  }
230
- function De(i) {
231
- return i instanceof _ && (i.mask & u.OBJECT) !== 0 && (i.mask & (u.ENTITY | u.ARRAY | u.UNION | u.RECORD | u.LIVE)) === 0;
231
+ function Ne(n) {
232
+ return n instanceof _ && (n.mask & l.OBJECT) !== 0 && (n.mask & (l.ENTITY | l.ARRAY | l.UNION | l.RECORD | l.LIVE)) === 0;
232
233
  }
233
- function Kt(i, t, e) {
234
- const n = /* @__PURE__ */ new Set();
235
- for (const r of i)
234
+ function Vt(n, t, e) {
235
+ const i = /* @__PURE__ */ new Set();
236
+ for (const r of n)
236
237
  if (r !== void 0)
237
238
  for (const o of Object.keys(r))
238
- n.add(o);
239
+ i.add(o);
239
240
  const s = {};
240
- for (const r of n) {
241
+ for (const r of i) {
241
242
  let o = 0, a;
242
243
  const c = [];
243
244
  let f = !0;
244
- for (const l of i) {
245
- const d = l?.[r];
246
- d !== void 0 ? (o++, a === void 0 && (a = d), De(d) ? c.push(d.shape) : (f = !1, c.push(void 0))) : (f = !1, c.push(void 0));
245
+ for (const d of n) {
246
+ const u = d?.[r];
247
+ u !== void 0 ? (o++, a === void 0 && (a = u), Ne(u) ? c.push(u.shape) : (f = !1, c.push(void 0))) : (f = !1, c.push(void 0));
247
248
  }
248
249
  if (f && o > 0) {
249
- const l = Kt(c, t), d = new _(u.OBJECT, l);
250
- s[r] = o < t ? Et(d) : d;
250
+ const d = Vt(c, t), u = new _(l.OBJECT, d);
251
+ s[r] = o < t ? wt(u) : u;
251
252
  } else
252
- s[r] = o < t ? Et(a) : a;
253
+ s[r] = o < t ? wt(a) : a;
253
254
  }
254
255
  return s;
255
256
  }
@@ -279,17 +280,17 @@ class _ {
279
280
  */
280
281
  _entityCache = void 0;
281
282
  /**
282
- * Live collection configuration (shared by LiveArray and LiveValue).
283
+ * Live data configuration (shared by LiveArray and LiveValue).
283
284
  */
284
285
  _liveConfig = void 0;
285
- constructor(t, e, n, s, r, o) {
286
- this.mask = t, this.shape = e, this.values = n, this.typenameField = s, this.typenameValue = r, this.idField = o;
286
+ constructor(t, e, i, s, r, o) {
287
+ this.mask = t, this.shape = e, this.values = i, this.typenameField = s, this.typenameValue = r, this.idField = o;
287
288
  }
288
289
  static merge(t) {
289
290
  if (t.length === 1) return t[0];
290
- const e = t.length, n = t.map((c) => c.shape);
291
+ const e = t.length, i = t.map((c) => c.shape);
291
292
  t[0].typenameValue;
292
- const s = Kt(n, e);
293
+ const s = Vt(i, e);
293
294
  let r, o, a;
294
295
  for (const c of t) {
295
296
  if (r === void 0 && c.idField !== void 0)
@@ -301,7 +302,7 @@ class _ {
301
302
  o === void 0 && (o = c.typenameField), a === void 0 && (a = c.typenameValue);
302
303
  }
303
304
  return new _(
304
- u.ENTITY | u.OBJECT,
305
+ l.ENTITY | l.OBJECT,
305
306
  s,
306
307
  void 0,
307
308
  o,
@@ -310,7 +311,7 @@ class _ {
310
311
  );
311
312
  }
312
313
  static cloneWith(t, e) {
313
- const n = new _(
314
+ const i = new _(
314
315
  e | t.mask,
315
316
  t.shape,
316
317
  t.values,
@@ -318,7 +319,7 @@ class _ {
318
319
  t.typenameValue,
319
320
  t.idField
320
321
  );
321
- return n._methods = t._methods, n._entityConfig = t._entityConfig, n._entityClass = t._entityClass, n._entityCache = t._entityCache, n._liveConfig = t._liveConfig, n;
322
+ return i._methods = t._methods, i._entityConfig = t._entityConfig, i._entityClass = t._entityClass, i._entityCache = t._entityCache, i._liveConfig = t._liveConfig, i;
322
323
  }
323
324
  }
324
325
  class H extends Set {
@@ -328,12 +329,12 @@ class H extends Set {
328
329
  super(t), this.lowercaseMap = /* @__PURE__ */ new Map();
329
330
  for (const e of t)
330
331
  if (typeof e == "string") {
331
- const n = e.toLowerCase(), s = this.lowercaseMap.get(n);
332
+ const i = e.toLowerCase(), s = this.lowercaseMap.get(i);
332
333
  if (s !== void 0)
333
334
  throw new Error(
334
- `Case-insensitive enum cannot have multiple values with the same lowercase form: '${s}' and '${e}' both become '${n}'`
335
+ `Case-insensitive enum cannot have multiple values with the same lowercase form: '${s}' and '${e}' both become '${i}'`
335
336
  );
336
- this.lowercaseMap.set(n, e);
337
+ this.lowercaseMap.set(i, e);
337
338
  }
338
339
  }
339
340
  /**
@@ -356,34 +357,34 @@ class H extends Set {
356
357
  return t;
357
358
  }
358
359
  }
359
- const Ae = 1128875347;
360
- we(H, (i) => {
361
- let t = Ae;
362
- for (const e of i)
363
- t += A(e);
360
+ const Me = 1128875347;
361
+ Ee(H, (n) => {
362
+ let t = Me;
363
+ for (const e of n)
364
+ t += D(e);
364
365
  return t >>> 0;
365
366
  });
366
- function dt(i, t) {
367
- return new _(i, t);
367
+ function lt(n, t) {
368
+ return new _(n, t);
368
369
  }
369
- function Ie(i) {
370
- return dt(u.ARRAY, i);
370
+ function ke(n) {
371
+ return lt(l.ARRAY, n);
371
372
  }
372
- function Me(i) {
373
- return dt(u.RECORD | u.OBJECT, i);
373
+ function Fe(n) {
374
+ return lt(l.RECORD | l.OBJECT, n);
374
375
  }
375
- function Te(i) {
376
- return dt(u.PARSE_RESULT, i);
376
+ function Te(n) {
377
+ return lt(l.PARSE_RESULT, n);
377
378
  }
378
- function $t(i, t) {
379
- let e = i, n, s, r;
380
- for (const [o, a] of Vt(t))
379
+ function Kt(n, t) {
380
+ let e = n, i, s, r;
381
+ for (const [o, a] of Ut(t))
381
382
  switch (typeof a) {
382
383
  case "number":
383
- if ((a & u.ID) !== 0) {
384
- if (n !== void 0)
384
+ if ((a & l.ID) !== 0) {
385
+ if (i !== void 0)
385
386
  throw new Error(`Duplicate id field: ${o}`);
386
- n = o;
387
+ i = o;
387
388
  }
388
389
  break;
389
390
  case "string":
@@ -394,18 +395,18 @@ function $t(i, t) {
394
395
  case "object":
395
396
  if (a instanceof H || a instanceof Set)
396
397
  break;
397
- a.mask & u.LIVE && (e |= u.LIVE);
398
+ a.mask & l.LIVE && (e |= l.LIVE);
398
399
  break;
399
400
  }
400
- return new _(e, t, void 0, s, r, n);
401
+ return new _(e, t, void 0, s, r, i);
401
402
  }
402
- function Fe(i) {
403
- return $t(u.OBJECT, i);
403
+ function Pe(n) {
404
+ return Kt(l.OBJECT, n);
404
405
  }
405
- function wt(i, t, e) {
406
- const n = i.mask;
407
- if ((n & u.UNION) !== 0) {
408
- const s = i;
406
+ function Et(n, t, e) {
407
+ const i = n.mask;
408
+ if ((i & l.UNION) !== 0) {
409
+ const s = n;
409
410
  if (s.typenameField !== void 0) {
410
411
  if (e !== void 0 && e !== s.typenameField)
411
412
  throw new Error(
@@ -415,7 +416,7 @@ function wt(i, t, e) {
415
416
  }
416
417
  const r = s.shape;
417
418
  if (r !== void 0)
418
- for (const o of [...it(r), B, Q]) {
419
+ for (const o of [...nt(r), Q, B]) {
419
420
  const a = r[o];
420
421
  if (t[o] !== void 0 && t[o] !== a)
421
422
  throw new Error(
@@ -423,494 +424,494 @@ function wt(i, t, e) {
423
424
  );
424
425
  t[o] = a;
425
426
  }
426
- } else if ((n & u.ARRAY) !== 0) {
427
- if (t[B] !== void 0)
428
- throw new Error("Array shape already defined");
429
- t[B] = i.shape;
430
- } else if ((n & u.RECORD) !== 0) {
427
+ } else if ((i & l.ARRAY) !== 0) {
431
428
  if (t[Q] !== void 0)
429
+ throw new Error("Array shape already defined");
430
+ t[Q] = n.shape;
431
+ } else if ((i & l.RECORD) !== 0) {
432
+ if (t[B] !== void 0)
432
433
  throw new Error("Record shape already defined");
433
- t[Q] = i.shape;
434
+ t[B] = n.shape;
434
435
  } else {
435
- const s = i.typenameField, r = i.typenameValue;
436
+ const s = n.typenameField, r = n.typenameValue;
436
437
  if (r === void 0)
437
438
  throw new Error(
438
439
  "Object definitions must have a typename to be in a union with other objects, records, or arrays"
439
440
  );
440
441
  if (e !== void 0 && s !== e)
441
442
  throw new Error("Object definitions must have the same typename field to be in the same union");
442
- e = s, t[r] = i;
443
+ e = s, t[r] = n;
443
444
  }
444
445
  return e;
445
446
  }
446
- function lt(...i) {
447
- const t = i;
448
- let e = 0, n = 0, s, r, o, a, c = 0;
449
- for (const l of t) {
450
- if (typeof l == "number") {
451
- e |= l;
447
+ function dt(...n) {
448
+ const t = n;
449
+ let e = 0, i = 0, s, r, o, a, c = 0;
450
+ for (const d of t) {
451
+ if (typeof d == "number") {
452
+ e |= d;
452
453
  continue;
453
454
  }
454
- if (l instanceof Set) {
455
+ if (d instanceof Set) {
455
456
  if (r === void 0)
456
- r = new Set(l);
457
+ r = new Set(d);
457
458
  else
458
- for (const d of l)
459
- r.add(d);
459
+ for (const u of d)
460
+ r.add(u);
460
461
  continue;
461
462
  }
462
- if (n++, c |= l.mask, n === 1) {
463
- s = l;
463
+ if (i++, c |= d.mask, i === 1) {
464
+ s = d;
464
465
  continue;
465
466
  }
466
- n === 2 && (o = /* @__PURE__ */ Object.create(null), a = wt(s, o, a)), a = wt(l, o, a);
467
+ i === 2 && (o = /* @__PURE__ */ Object.create(null), a = Et(s, o, a)), a = Et(d, o, a);
467
468
  }
468
- if (n === 0)
469
- return r === void 0 ? e : e === 0 ? r : new _(e | u.UNION, void 0, r);
470
- if (n === 1)
469
+ if (i === 0)
470
+ return r === void 0 ? e : e === 0 ? r : new _(e | l.UNION, void 0, r);
471
+ if (i === 1)
471
472
  return _.cloneWith(s, e);
472
- const f = e | c | u.UNION;
473
+ const f = e | c | l.UNION;
473
474
  return new _(f, o, r, a);
474
475
  }
475
- function ht(i, t, e) {
476
- const n = i;
477
- if (typeof n == "number")
478
- return n | t;
479
- if (n instanceof Set)
480
- return lt(i, t);
481
- let s = e.get(n);
482
- return s === void 0 && (s = _.cloneWith(n, t), e.set(n, s)), s;
476
+ function ht(n, t, e) {
477
+ const i = n;
478
+ if (typeof i == "number")
479
+ return i | t;
480
+ if (i instanceof Set)
481
+ return dt(n, t);
482
+ let s = e.get(i);
483
+ return s === void 0 && (s = _.cloneWith(i, t), e.set(i, s)), s;
483
484
  }
484
- const ke = /* @__PURE__ */ new WeakMap(), Pe = /* @__PURE__ */ new WeakMap(), Le = /* @__PURE__ */ new WeakMap();
485
- function je(i) {
486
- return ht(i, u.UNDEFINED | u.NULL, Le);
485
+ const Le = /* @__PURE__ */ new WeakMap(), je = /* @__PURE__ */ new WeakMap(), qe = /* @__PURE__ */ new WeakMap();
486
+ function Ue(n) {
487
+ return ht(n, l.UNDEFINED | l.NULL, qe);
487
488
  }
488
- function qe(i) {
489
- return ht(i, u.UNDEFINED, ke);
489
+ function Ve(n) {
490
+ return ht(n, l.UNDEFINED, Le);
490
491
  }
491
- function Ue(i) {
492
- return ht(i, u.NULL, Pe);
492
+ function Ke(n) {
493
+ return ht(n, l.NULL, je);
493
494
  }
494
- function Ve(i) {
495
- return i;
495
+ function $e(n) {
496
+ return n;
496
497
  }
497
- function Ke(i) {
498
- return /* @__PURE__ */ new Set([i]);
498
+ function Qe(n) {
499
+ return /* @__PURE__ */ new Set([n]);
499
500
  }
500
- const Bt = ((...i) => new Set(i));
501
- Bt.caseInsensitive = (...i) => new H(i);
501
+ const $t = ((...n) => new Set(n));
502
+ $t.caseInsensitive = (...n) => new H(n);
502
503
  const Qt = 16;
503
- let $e = 0;
504
- const nt = [], Yt = [], Gt = /* @__PURE__ */ new Map(), z = /* @__PURE__ */ new WeakSet();
505
- class V {
504
+ let Be = 0;
505
+ const it = [], Bt = [], Yt = /* @__PURE__ */ new Map(), J = /* @__PURE__ */ new WeakSet();
506
+ class q {
506
507
  _raw;
507
508
  _formatted;
508
509
  _parsed;
509
510
  _formatId;
510
- constructor(t, e, n) {
511
- this._raw = t, this._formatId = e, n ? (this._formatted = nt[e](t), this._parsed = !0) : this._parsed = !1, z.add(this);
511
+ constructor(t, e, i) {
512
+ this._raw = t, this._formatId = e, i ? (this._formatted = it[e](t), this._parsed = !0) : this._parsed = !1, J.add(this);
512
513
  }
513
514
  getValue() {
514
- return this._parsed || (this._formatted = nt[this._formatId](this._raw), this._parsed = !0), this._formatted;
515
+ return this._parsed || (this._formatted = it[this._formatId](this._raw), this._parsed = !0), this._formatted;
515
516
  }
516
517
  toJSON() {
517
- return this._parsed ? Yt[this._formatId](this._formatted) : this._raw;
518
+ return this._parsed ? Bt[this._formatId](this._formatted) : this._raw;
518
519
  }
519
520
  }
520
- function Be(i) {
521
- const t = Gt.get(i);
521
+ function Ye(n) {
522
+ const t = Yt.get(n);
522
523
  if (t === void 0)
523
- throw new Error(`Format ${i} not registered`);
524
+ throw new Error(`Format ${n} not registered`);
524
525
  return t;
525
526
  }
526
- function Wt(i, t, e, n, s) {
527
- const r = $e++;
528
- nt[r] = e, Yt[r] = n;
529
- const o = s?.eager ?? !0, c = r << Qt | t | u.HAS_FORMAT | (o ? u.IS_EAGER_FORMAT : 0);
530
- Gt.set(i, c);
527
+ function Gt(n, t, e, i, s) {
528
+ const r = Be++;
529
+ it[r] = e, Bt[r] = i;
530
+ const o = s?.eager ?? !0, c = r << Qt | t | l.HAS_FORMAT | (o ? l.IS_EAGER_FORMAT : 0);
531
+ Yt.set(n, c);
531
532
  }
532
- Wt(
533
+ Gt(
533
534
  "date",
534
- u.STRING,
535
- (i) => {
536
- const t = i.match(/^(\d{4})-(\d{2})-(\d{2})$/);
535
+ l.STRING,
536
+ (n) => {
537
+ const t = n.match(/^(\d{4})-(\d{2})-(\d{2})$/);
537
538
  if (!t)
538
- throw new Error(`Invalid date string: ${i}. Expected YYYY-MM-DD format.`);
539
- const [, e, n, s] = t, r = new Date(Date.UTC(parseInt(e, 10), parseInt(n, 10) - 1, parseInt(s, 10)));
539
+ throw new Error(`Invalid date string: ${n}. Expected YYYY-MM-DD format.`);
540
+ const [, e, i, s] = t, r = new Date(Date.UTC(parseInt(e, 10), parseInt(i, 10) - 1, parseInt(s, 10)));
540
541
  if (isNaN(r.getTime()))
541
- throw new Error(`Invalid date string: ${i}`);
542
+ throw new Error(`Invalid date string: ${n}`);
542
543
  return r;
543
544
  },
544
- (i) => {
545
- const t = i.getUTCFullYear(), e = String(i.getUTCMonth() + 1).padStart(2, "0"), n = String(i.getUTCDate()).padStart(2, "0");
546
- return `${t}-${e}-${n}`;
545
+ (n) => {
546
+ const t = n.getUTCFullYear(), e = String(n.getUTCMonth() + 1).padStart(2, "0"), i = String(n.getUTCDate()).padStart(2, "0");
547
+ return `${t}-${e}-${i}`;
547
548
  }
548
549
  );
549
- Wt(
550
+ Gt(
550
551
  "date-time",
551
- u.STRING,
552
- (i) => {
553
- const t = new Date(i);
552
+ l.STRING,
553
+ (n) => {
554
+ const t = new Date(n);
554
555
  if (isNaN(t.getTime()))
555
- throw new Error(`Invalid date-time string: ${i}`);
556
+ throw new Error(`Invalid date-time string: ${n}`);
556
557
  return t;
557
558
  },
558
- (i) => i.toISOString()
559
+ (n) => n.toISOString()
559
560
  );
560
- const bt = /* @__PURE__ */ new WeakMap();
561
- function L(i) {
562
- let t = bt.get(i);
561
+ const Ct = /* @__PURE__ */ new WeakMap();
562
+ function T(n) {
563
+ let t = Ct.get(n);
563
564
  if (t === void 0) {
564
- const e = new i(), n = e[ft] ?? e;
565
+ const e = new n(), i = e[ft] ?? e;
565
566
  e[G] && e[G]();
566
567
  const s = {};
567
- for (const [f, l] of Vt(n))
568
- s[f] = l;
569
- const r = Object.getPrototypeOf(i.prototype);
568
+ for (const [f, d] of Ut(i))
569
+ s[f] = d;
570
+ const r = Object.getPrototypeOf(n.prototype);
570
571
  if (r != null) {
571
572
  const f = r.constructor;
572
- if (f !== Ut && typeof f == "function") {
573
- const d = L(f).shape;
574
- for (const y of it(d))
575
- if (y in s && s[y] !== d[y])
573
+ if (f !== qt && typeof f == "function") {
574
+ const u = T(f).shape;
575
+ for (const y of nt(u))
576
+ if (y in s && s[y] !== u[y])
576
577
  throw new Error(`Cannot extend: field '${y}' already exists in type definition`);
577
578
  }
578
579
  }
579
- const o = {}, a = i.prototype;
580
+ const o = {}, a = n.prototype;
580
581
  for (const f of Object.getOwnPropertyNames(a))
581
582
  f !== "constructor" && typeof a[f] == "function" && (o[f] = a[f]);
582
- t = $t(u.ENTITY | u.OBJECT, s), t._entityClass = i, it(o).length > 0 && (t._methods = o), typeof o.__subscribe == "function" && (t._entityConfig = { hasSubscribe: !0 });
583
- const c = i;
584
- c.cache && (t._entityCache = c.cache), bt.set(i, t);
583
+ t = Kt(l.ENTITY | l.OBJECT, s), t._entityClass = n, nt(o).length > 0 && (t._methods = o), typeof o.__subscribe == "function" && (t._entityConfig = { hasSubscribe: !0 });
584
+ const c = n;
585
+ c.cache && (t._entityCache = c.cache), Ct.set(n, t);
585
586
  }
586
587
  return t;
587
588
  }
588
- function Qe(i) {
589
- return L(i);
589
+ function Ge(n) {
590
+ return T(n);
590
591
  }
591
- function Ht(i, t) {
592
+ function Wt(n, t) {
592
593
  if (t == null) return;
593
594
  const e = /* @__PURE__ */ new Map();
594
595
  if (Array.isArray(t))
595
- for (const n of t) {
596
- const [s, r] = n, a = L(s).typenameValue;
596
+ for (const i of t) {
597
+ const [s, r] = i, a = T(s).typenameValue;
597
598
  if (a === void 0) continue;
598
599
  const c = [];
599
- for (const [f, l] of Object.entries(r))
600
- c.push([f, l]);
600
+ for (const [f, d] of Object.entries(r))
601
+ c.push([f, d]);
601
602
  c.length > 0 && e.set(a, c);
602
603
  }
603
604
  else {
604
605
  const s = Object.entries(t);
605
606
  if (s.length === 0) return;
606
607
  const r = s.map(([o, a]) => [o, a]);
607
- for (const o of i) {
608
+ for (const o of n) {
608
609
  const a = o.typenameValue;
609
610
  a !== void 0 && e.set(a, r);
610
611
  }
611
612
  }
612
613
  return e.size > 0 ? e : void 0;
613
614
  }
614
- function zt(i) {
615
- return Array.isArray(i) ? i.map((t) => L(t)) : [L(i)];
615
+ function zt(n) {
616
+ return Array.isArray(n) ? n.map((t) => T(t)) : [T(n)];
616
617
  }
617
- function Ye(i, t) {
618
- const e = zt(i), n = e.length === 1 ? e[0] : lt(...e.map((o) => o)), s = u.ARRAY | u.LIVE, r = new _(s, n);
619
- return r._liveConfig = U.array(
618
+ function We(n, t) {
619
+ const e = zt(n), i = e.length === 1 ? e[0] : dt(...e.map((o) => o)), s = l.ARRAY | l.LIVE, r = new _(s, i);
620
+ return r._liveConfig = j.array(
620
621
  e,
621
- Ht(e, t?.constraints),
622
+ Wt(e, t?.constraints),
622
623
  t?.sort
623
624
  ), r;
624
625
  }
625
- function Ge(i, t, e) {
626
- const n = zt(t), s = i, r = u.LIVE, o = new _(r, void 0);
627
- return o._liveConfig = U.value(
628
- n,
629
- Ht(n, e?.constraints),
626
+ function ze(n, t, e) {
627
+ const i = zt(t), s = n, r = l.LIVE, o = new _(r, void 0);
628
+ return o._liveConfig = j.value(
629
+ i,
630
+ Wt(i, e?.constraints),
630
631
  s,
631
632
  e.onCreate,
632
633
  e.onUpdate,
633
634
  e.onDelete
634
635
  ), o;
635
636
  }
636
- const We = {
637
- format: Be,
638
- typename: Ve,
639
- const: Ke,
640
- enum: Bt,
641
- id: u.ID | u.STRING | u.NUMBER,
642
- string: u.STRING,
643
- number: u.NUMBER,
644
- boolean: u.BOOLEAN,
645
- null: u.NULL,
646
- undefined: u.UNDEFINED,
647
- array: Ie,
648
- object: Fe,
649
- record: Me,
650
- union: lt,
651
- nullish: je,
652
- optional: qe,
653
- nullable: Ue,
637
+ const He = {
638
+ format: Ye,
639
+ typename: $e,
640
+ const: Qe,
641
+ enum: $t,
642
+ id: l.ID | l.STRING | l.NUMBER,
643
+ string: l.STRING,
644
+ number: l.NUMBER,
645
+ boolean: l.BOOLEAN,
646
+ null: l.NULL,
647
+ undefined: l.UNDEFINED,
648
+ array: ke,
649
+ object: Pe,
650
+ record: Fe,
651
+ union: dt,
652
+ nullish: Ue,
653
+ optional: Ve,
654
+ nullable: Ke,
654
655
  result: Te,
655
- entity: Qe,
656
- liveArray: Ye,
657
- liveValue: Ge
656
+ entity: Ge,
657
+ liveArray: We,
658
+ liveValue: ze
658
659
  };
659
- function j(i, t, e) {
660
- return new TypeError(`Validation error at ${i}`);
660
+ function P(n, t, e) {
661
+ return new TypeError(`Validation error at ${n}`);
661
662
  }
662
- const Jt = Array.isArray;
663
- function Ct(i) {
664
- if (i === null) return u.NULL;
665
- switch (typeof i) {
663
+ const Ht = Array.isArray;
664
+ function bt(n) {
665
+ if (n === null) return l.NULL;
666
+ switch (typeof n) {
666
667
  case "number":
667
- return u.NUMBER;
668
+ return l.NUMBER;
668
669
  case "string":
669
- return u.STRING;
670
+ return l.STRING;
670
671
  case "boolean":
671
- return u.BOOLEAN;
672
+ return l.BOOLEAN;
672
673
  case "undefined":
673
- return u.UNDEFINED;
674
+ return l.UNDEFINED;
674
675
  case "object":
675
- return Jt(i) ? u.ARRAY : u.OBJECT;
676
+ return Ht(n) ? l.ARRAY : l.OBJECT;
676
677
  default:
677
- throw new Error(`Invalid type: ${typeof i}`);
678
+ throw new Error(`Invalid type: ${typeof n}`);
678
679
  }
679
680
  }
680
- function Ri(i) {
681
- return k(i);
681
+ function Dn(n) {
682
+ return F(n);
682
683
  }
683
- function k(i) {
684
- if (i === null || typeof i != "object")
685
- return i;
686
- if (Jt(i))
687
- return i.map((e) => k(e));
688
- if (i instanceof Date)
689
- return new Date(i.getTime());
690
- if (i instanceof Map) {
684
+ function F(n) {
685
+ if (n === null || typeof n != "object")
686
+ return n;
687
+ if (Ht(n))
688
+ return n.map((e) => F(e));
689
+ if (n instanceof Date)
690
+ return new Date(n.getTime());
691
+ if (n instanceof Map) {
691
692
  const e = /* @__PURE__ */ new Map();
692
- for (const [n, s] of i)
693
- e.set(k(n), k(s));
693
+ for (const [i, s] of n)
694
+ e.set(F(i), F(s));
694
695
  return e;
695
696
  }
696
- if (i instanceof Set) {
697
+ if (n instanceof Set) {
697
698
  const e = /* @__PURE__ */ new Set();
698
- for (const n of i)
699
- e.add(k(n));
699
+ for (const i of n)
700
+ e.add(F(i));
700
701
  return e;
701
702
  }
702
703
  const t = {};
703
- for (const e of Object.keys(i))
704
- t[e] = k(i[e]);
704
+ for (const e of Object.keys(n))
705
+ t[e] = F(n[e]);
705
706
  return t;
706
707
  }
707
- const yt = Object.entries, He = () => {
708
+ const yt = Object.entries, Je = () => {
708
709
  };
709
710
  class st {
710
711
  queryClient = void 0;
711
712
  preloadedEntities = void 0;
712
- warn = He;
713
+ warn = Je;
713
714
  /** When true, missing optional fields on existing entities are set to
714
715
  * undefined. False for mutation events (truly partial payloads). */
715
716
  isPartialEvent = !1;
716
717
  seen = void 0;
717
718
  seenByKey = void 0;
718
- reset(t, e, n, s = !1) {
719
- this.queryClient = t, this.preloadedEntities = e, this.warn = n, this.isPartialEvent = s, t !== void 0 && (this.seen === void 0 ? (this.seen = /* @__PURE__ */ new Map(), this.seenByKey = /* @__PURE__ */ new Map()) : (this.seen.clear(), this.seenByKey.clear()));
719
+ reset(t, e, i, s = !1) {
720
+ this.queryClient = t, this.preloadedEntities = e, this.warn = i, this.isPartialEvent = s, t !== void 0 && (this.seen === void 0 ? (this.seen = /* @__PURE__ */ new Map(), this.seenByKey = /* @__PURE__ */ new Map()) : (this.seen.clear(), this.seenByKey.clear()));
720
721
  }
721
722
  }
722
- function Xt(i, t, e) {
723
- return T(i, t, e, "");
723
+ function Jt(n, t, e) {
724
+ return M(n, t, e, "");
724
725
  }
725
- function ze(i, t, e) {
726
- return pt(i, t, e);
726
+ function Xe(n, t, e) {
727
+ return pt(n, t, e);
727
728
  }
728
- function xt(i, t, e, n) {
729
- const s = i >> Qt;
730
- if ((i & u.IS_EAGER_FORMAT) !== 0)
729
+ function xt(n, t, e, i) {
730
+ const s = n >> Qt;
731
+ if ((n & l.IS_EAGER_FORMAT) !== 0)
731
732
  try {
732
- return new V(t, s, !0);
733
+ return new q(t, s, !0);
733
734
  } catch (o) {
734
- if ((i & u.UNDEFINED) !== 0) {
735
+ if ((n & l.UNDEFINED) !== 0) {
735
736
  e.warn("Invalid formatted value for optional type, defaulting to undefined", {
736
737
  value: t,
737
- path: n,
738
+ path: i,
738
739
  error: o instanceof Error ? o.message : String(o)
739
740
  });
740
741
  return;
741
742
  }
742
743
  throw o;
743
744
  }
744
- return new V(t, s, !1);
745
+ return new q(t, s, !1);
745
746
  }
746
- function T(i, t, e, n) {
747
+ function M(n, t, e, i) {
747
748
  const s = t;
748
749
  if (s instanceof H) {
749
- const c = s.get(i);
750
- if (c === void 0) throw j(n);
750
+ const c = s.get(n);
751
+ if (c === void 0) throw P(i);
751
752
  return c;
752
753
  }
753
754
  if (s instanceof Set) {
754
- if (!s.has(i)) throw j(n);
755
- return i;
755
+ if (!s.has(n)) throw P(i);
756
+ return n;
756
757
  }
757
758
  if (typeof s == "string") {
758
- if (i == null) return s;
759
- if (i !== s) throw j(n);
760
- return i;
759
+ if (n == null) return s;
760
+ if (n !== s) throw P(i);
761
+ return n;
761
762
  }
762
763
  if (typeof s == "number") {
763
- const c = Ct(i);
764
+ const c = bt(n);
764
765
  if ((s & c) === 0) {
765
- if ((s & u.UNDEFINED) !== 0) {
766
- e.warn("Invalid value for optional type, defaulting to undefined", { value: i, path: n });
766
+ if ((s & l.UNDEFINED) !== 0) {
767
+ e.warn("Invalid value for optional type, defaulting to undefined", { value: n, path: i });
767
768
  return;
768
769
  }
769
- throw j(n);
770
+ throw P(i);
770
771
  }
771
- return (s & u.HAS_FORMAT) !== 0 && i !== null && i !== void 0 ? xt(s, i, e, n) : i;
772
+ return (s & l.HAS_FORMAT) !== 0 && n !== null && n !== void 0 ? xt(s, n, e, i) : n;
772
773
  }
773
774
  const r = s.mask, o = s._liveConfig;
774
775
  if (o !== void 0 && o.type === ct.Value)
775
- return o.valueType !== void 0 ? T(i, o.valueType, e, n) : i;
776
- if ((r & u.PARSE_RESULT) !== 0)
776
+ return o.valueType !== void 0 ? M(n, o.valueType, e, i) : n;
777
+ if ((r & l.PARSE_RESULT) !== 0)
777
778
  try {
778
- return { success: !0, value: T(i, s.shape, e, n) };
779
+ return { success: !0, value: M(n, s.shape, e, i) };
779
780
  } catch (c) {
780
781
  return { success: !1, error: c instanceof Error ? c : new Error(String(c)) };
781
782
  }
782
- const a = Ct(i);
783
- if ((r & a) === 0 && !s.values?.has(i)) {
784
- if ((r & u.UNDEFINED) !== 0) {
785
- e.warn("Invalid value for optional type, defaulting to undefined", { value: i, path: n });
783
+ const a = bt(n);
784
+ if ((r & a) === 0 && !s.values?.has(n)) {
785
+ if ((r & l.UNDEFINED) !== 0) {
786
+ e.warn("Invalid value for optional type, defaulting to undefined", { value: n, path: i });
786
787
  return;
787
788
  }
788
- throw j(n);
789
+ throw P(i);
789
790
  }
790
- return a < u.OBJECT ? (r & u.HAS_FORMAT) !== 0 && i !== null && i !== void 0 ? xt(r, i, e, n) : i : (r & u.UNION) !== 0 ? Je(a, i, s, e, n) : a === u.ARRAY ? Zt(i, s.shape, e, n) : (r & u.RECORD) !== 0 ? te(i, s.shape, e, n) : (r & u.ENTITY) !== 0 && e.queryClient !== void 0 ? pt(i, s, e) : ee(i, s, e, n);
791
+ return a < l.OBJECT ? (r & l.HAS_FORMAT) !== 0 && n !== null && n !== void 0 ? xt(r, n, e, i) : n : (r & l.UNION) !== 0 ? Ze(a, n, s, e, i) : a === l.ARRAY ? Xt(n, s.shape, e, i) : (r & l.RECORD) !== 0 ? Zt(n, s.shape, e, i) : (r & l.ENTITY) !== 0 && e.queryClient !== void 0 ? pt(n, s, e) : te(n, s, e, i);
791
792
  }
792
- function Je(i, t, e, n, s) {
793
- if (i === u.ARRAY) {
794
- const r = e.shape[B];
795
- return r === void 0 || typeof r == "number" ? t : Zt(t, r, n, s);
793
+ function Ze(n, t, e, i, s) {
794
+ if (n === l.ARRAY) {
795
+ const r = e.shape[Q];
796
+ return r === void 0 || typeof r == "number" ? t : Xt(t, r, i, s);
796
797
  } else {
797
798
  const r = e.typenameField, o = r ? t[r] : void 0;
798
799
  if (o === void 0 || typeof o != "string") {
799
- const c = e.shape[Q];
800
+ const c = e.shape[B];
800
801
  if (c === void 0)
801
802
  throw new Error(
802
803
  `Typename field '${r}' is required for union discrimination but was not found in the data`
803
804
  );
804
- return te(t, c, n, s);
805
+ return Zt(t, c, i, s);
805
806
  }
806
807
  const a = e.shape[o];
807
808
  if (a === void 0 || typeof a == "number")
808
809
  throw new Error(`Unknown typename '${o}' in union`);
809
- return a.mask & u.ENTITY && n.queryClient !== void 0 ? pt(t, a, n) : ee(t, a, n, s);
810
+ return a.mask & l.ENTITY && i.queryClient !== void 0 ? pt(t, a, i) : te(t, a, i, s);
810
811
  }
811
812
  }
812
- function Zt(i, t, e, n) {
813
+ function Xt(n, t, e, i) {
813
814
  const s = [];
814
- for (let r = 0; r < i.length; r++)
815
+ for (let r = 0; r < n.length; r++)
815
816
  try {
816
- s.push(T(i[r], t, e, `${n}[${r}]`));
817
+ s.push(M(n[r], t, e, `${i}[${r}]`));
817
818
  } catch (o) {
818
819
  e.warn("Failed to parse array item, filtering out", {
819
820
  index: r,
820
- value: i[r],
821
+ value: n[r],
821
822
  error: o instanceof Error ? o.message : String(o)
822
823
  });
823
824
  }
824
825
  return s;
825
826
  }
826
- function te(i, t, e, n) {
827
- for (const [s, r] of yt(i))
828
- i[s] = T(r, t, e, `${n}["${s}"]`);
829
- return i;
827
+ function Zt(n, t, e, i) {
828
+ for (const [s, r] of yt(n))
829
+ n[s] = M(r, t, e, `${i}["${s}"]`);
830
+ return n;
830
831
  }
831
- function ee(i, t, e, n) {
832
- if (O.has(i))
833
- return i;
832
+ function te(n, t, e, i) {
833
+ if (x.has(n))
834
+ return n;
834
835
  const s = t.shape;
835
836
  for (const [r, o] of yt(s))
836
- i[r] = T(i[r], o, e, `${n}.${r}`);
837
- return i;
837
+ n[r] = M(n[r], o, e, `${i}.${r}`);
838
+ return n;
838
839
  }
839
- function pt(i, t, e) {
840
- const n = e.queryClient, s = e.preloadedEntities;
840
+ function pt(n, t, e) {
841
+ const i = e.queryClient, s = e.preloadedEntities;
841
842
  let r, o;
842
843
  if (s !== void 0)
843
- r = i.__entityRef, o = r;
844
+ r = n.__entityRef, o = r;
844
845
  else {
845
- const p = i[t.idField];
846
+ const p = n[t.idField];
846
847
  if (p == null || typeof p != "string" && typeof p != "number")
847
848
  throw new Error(`Entity id must be a string or number: ${t.typenameValue} (got ${typeof p})`);
848
- o = p, r = A([t.typenameValue, o]);
849
+ o = p, r = D([t.typenameValue, o]);
849
850
  }
850
851
  const a = e.seenByKey.get(r);
851
852
  if (a !== void 0)
852
853
  return a.data;
853
854
  if (s !== void 0) {
854
- const g = n.entityMap.getEntity(r)?.data ?? s.get(r);
855
+ const g = i.entityMap.getEntity(r)?.data ?? s.get(r);
855
856
  if (g === void 0)
856
857
  throw new Error(`Cached entity ${r} not found in preloaded map`);
857
- i = g;
858
+ n = g;
858
859
  }
859
860
  const c = {};
860
861
  typeof t.idField == "symbol" && (c[t.idField] = o);
861
- const f = n.entityMap.getEntity(r), l = e.isPartialEvent && f !== void 0, d = {
862
+ const f = i.entityMap.getEntity(r), d = e.isPartialEvent && f !== void 0, u = {
862
863
  key: r,
863
864
  shape: t,
864
865
  data: c,
865
- rawKeys: l ? new Set(Object.keys(i)) : void 0
866
+ rawKeys: d ? new Set(Object.keys(n)) : void 0
866
867
  };
867
- e.seen.set(c, d), e.seenByKey.set(r, d);
868
+ e.seen.set(c, u), e.seenByKey.set(r, u);
868
869
  const y = `[[${t.typenameValue}:${o}]]`, v = t.shape;
869
870
  for (const [p, g] of yt(v))
870
- l && !(p in i) || (c[p] = T(i[p], g, e, `${y}.${p}`));
871
+ d && !(p in n) || (c[p] = M(n[p], g, e, `${y}.${p}`));
871
872
  return c;
872
873
  }
873
- function Xe(i, t) {
874
- return Ze(i, t.shape, t.typenameField);
874
+ function tn(n, t) {
875
+ return en(n, t.shape, t.typenameField);
875
876
  }
876
- function Ze(i, t, e) {
877
+ function en(n, t, e) {
877
878
  if (t === void 0) return !0;
878
- for (const n of Object.keys(t)) {
879
- if (n === e) continue;
880
- const s = t[n];
879
+ for (const i of Object.keys(t)) {
880
+ if (i === e) continue;
881
+ const s = t[i];
881
882
  if (s instanceof _) {
882
- if ((s.mask & u.UNDEFINED) !== 0) continue;
883
- if (!(n in i) || i[n] === void 0) return !1;
883
+ if ((s.mask & l.UNDEFINED) !== 0) continue;
884
+ if (!(i in n) || n[i] === void 0) return !1;
884
885
  } else if (typeof s == "number") {
885
- if ((s & u.UNDEFINED) !== 0) continue;
886
- if (!(n in i) || i[n] === void 0) return !1;
887
- } else if (!(n in i) || i[n] === void 0) return !1;
886
+ if ((s & l.UNDEFINED) !== 0) continue;
887
+ if (!(i in n) || n[i] === void 0) return !1;
888
+ } else if (!(i in n) || n[i] === void 0) return !1;
888
889
  }
889
890
  return !0;
890
891
  }
891
- const ti = Object.prototype, $ = /* @__PURE__ */ new WeakMap();
892
- function D(i) {
893
- if (typeof i != "object" || i === null) return i;
894
- if (z.has(i)) return D(i.getValue());
895
- if (O.has(i)) return i;
896
- if (Array.isArray(i)) {
897
- let t = $.get(i);
898
- return t === void 0 && (t = new Proxy(i, ei), $.set(i, t)), t;
892
+ const nn = Object.prototype, $ = /* @__PURE__ */ new WeakMap();
893
+ function A(n) {
894
+ if (typeof n != "object" || n === null) return n;
895
+ if (J.has(n)) return A(n.getValue());
896
+ if (x.has(n)) return n;
897
+ if (Array.isArray(n)) {
898
+ let t = $.get(n);
899
+ return t === void 0 && (t = new Proxy(n, sn), $.set(n, t)), t;
899
900
  }
900
- if (Object.getPrototypeOf(i) === ti) {
901
- let t = $.get(i);
902
- return t === void 0 && (t = new Proxy(i, ii), $.set(i, t)), t;
901
+ if (Object.getPrototypeOf(n) === nn) {
902
+ let t = $.get(n);
903
+ return t === void 0 && (t = new Proxy(n, rn), $.set(n, t)), t;
903
904
  }
904
- return i;
905
+ return n;
905
906
  }
906
- const ei = {
907
- get(i, t, e) {
907
+ const sn = {
908
+ get(n, t, e) {
908
909
  if (typeof t == "string") {
909
- const n = Number(t);
910
- if (Number.isInteger(n) && n >= 0 && n < i.length)
911
- return D(i[n]);
910
+ const i = Number(t);
911
+ if (Number.isInteger(i) && i >= 0 && i < n.length)
912
+ return A(n[i]);
912
913
  }
913
- return Reflect.get(i, t, e);
914
+ return Reflect.get(n, t, e);
914
915
  },
915
916
  set() {
916
917
  return !1;
@@ -918,9 +919,9 @@ const ei = {
918
919
  deleteProperty() {
919
920
  return !1;
920
921
  }
921
- }, ii = {
922
- get(i, t, e) {
923
- return typeof t == "string" ? D(i[t]) : Reflect.get(i, t, e);
922
+ }, rn = {
923
+ get(n, t, e) {
924
+ return typeof t == "string" ? A(n[t]) : Reflect.get(n, t, e);
924
925
  },
925
926
  set() {
926
927
  return !1;
@@ -928,17 +929,17 @@ const ei = {
928
929
  deleteProperty() {
929
930
  return !1;
930
931
  },
931
- has(i, t) {
932
- return t in i;
932
+ has(n, t) {
933
+ return t in n;
933
934
  },
934
- ownKeys(i) {
935
- return Reflect.ownKeys(i);
935
+ ownKeys(n) {
936
+ return Reflect.ownKeys(n);
936
937
  },
937
- getOwnPropertyDescriptor(i, t) {
938
- return Object.getOwnPropertyDescriptor(i, t);
938
+ getOwnPropertyDescriptor(n, t) {
939
+ return Object.getOwnPropertyDescriptor(n, t);
939
940
  }
940
941
  };
941
- class ni {
942
+ class on {
942
943
  _notifier;
943
944
  _queryClient;
944
945
  _proxies = /* @__PURE__ */ new Map();
@@ -955,8 +956,8 @@ class ni {
955
956
  _entityCache;
956
957
  _extraMethods;
957
958
  _extraGetters;
958
- constructor(t, e, n, s, r, o) {
959
- this._notifier = at(), this._queryClient = o, this.key = t, this.typename = e, this.id = n, this.idField = s, this.data = r, this.entityRefs = void 0;
959
+ constructor(t, e, i, s, r, o) {
960
+ this._notifier = at(), this._queryClient = o, this.key = t, this.typename = e, this.id = i, this.idField = s, this.data = r, this.entityRefs = void 0;
960
961
  }
961
962
  retain() {
962
963
  this.refCount++;
@@ -967,24 +968,24 @@ class ni {
967
968
  if (--this.refCount > 0 || this.refCount < 0)
968
969
  return;
969
970
  const t = this._entityCache?.gcTime;
970
- t !== void 0 ? this._queryClient.gcManager.schedule(this.key, t, W.Entity) : this.evict();
971
+ t !== void 0 ? this._queryClient.gcManager.schedule(this.key, t, z.Entity) : this.evict();
971
972
  }
972
973
  evict() {
973
974
  const t = this.liveCollections.slice();
974
975
  this.liveCollections.length = 0;
975
- for (const n of t) n.destroy();
976
+ for (const i of t) i.destroy();
976
977
  this._queryClient.entityMap.remove(this.key);
977
978
  const e = this.entityRefs;
978
979
  if (this.entityRefs = void 0, e)
979
- for (const n of e.keys()) n.release();
980
+ for (const i of e.keys()) i.release();
980
981
  }
981
982
  setChildRefs(t, e) {
982
- const n = this.entityRefs;
983
+ const i = this.entityRefs;
983
984
  if (t !== void 0 && t.size > 0)
984
985
  for (const s of t.keys())
985
- (n === void 0 || !n.has(s)) && s.retain();
986
- if (n !== void 0 && n.size > 0)
987
- for (const s of n.keys())
986
+ (i === void 0 || !i.has(s)) && s.retain();
987
+ if (i !== void 0 && i.size > 0)
988
+ for (const s of i.keys())
988
989
  (t === void 0 || !t.has(s)) && s.release();
989
990
  this.entityRefs = t, e && this.save();
990
991
  }
@@ -1000,14 +1001,14 @@ class ni {
1000
1001
  }
1001
1002
  getProxy(t) {
1002
1003
  const e = t;
1003
- let n = this._proxies.get(e);
1004
- return n === void 0 && (n = ri(this, this.key, t, this._notifier, this._queryClient), this._proxies.set(e, n)), n;
1004
+ let i = this._proxies.get(e);
1005
+ return i === void 0 && (i = cn(this, this.key, t, this._notifier, this._queryClient), this._proxies.set(e, i)), i;
1005
1006
  }
1006
1007
  get proxy() {
1007
1008
  return this._proxies.values().next().value;
1008
1009
  }
1009
1010
  satisfiesDef(t) {
1010
- return this.satisfiedDefs.has(t) ? !0 : Xe(this.data, t) ? (this.satisfiedDefs.add(t), !0) : !1;
1011
+ return this.satisfiedDefs.has(t) ? !0 : tn(this.data, t) ? (this.satisfiedDefs.add(t), !0) : !1;
1011
1012
  }
1012
1013
  save() {
1013
1014
  this._queryClient.entityMap.save(this);
@@ -1019,131 +1020,131 @@ class ni {
1019
1020
  this._notifier.consume();
1020
1021
  }
1021
1022
  }
1022
- function si(i, t, e) {
1023
- const n = [];
1024
- for (const s of i) {
1023
+ function an(n, t, e) {
1024
+ const i = [];
1025
+ for (const s of n) {
1025
1026
  if (typeof s != "object" || s === null) continue;
1026
- const r = O.get(s);
1027
+ const r = x.get(s);
1027
1028
  if (r === void 0) continue;
1028
1029
  const o = e.entityMap.getEntity(r);
1029
- o !== void 0 && o.satisfiesDef(t) && n.push(s);
1030
+ o !== void 0 && o.satisfiesDef(t) && i.push(s);
1030
1031
  }
1031
- return n;
1032
+ return i;
1032
1033
  }
1033
- function ri(i, t, e, n, s) {
1034
- const r = e.shape ?? {}, o = e, a = o._methods, c = o._entityClass, f = o._entityConfig, l = c ? c.prototype : Ut.prototype;
1034
+ function cn(n, t, e, i, s) {
1035
+ const r = e.shape ?? {}, o = e, a = o._methods, c = o._entityClass, f = o._entityConfig, d = c ? c.prototype : qt.prototype;
1035
1036
  e.typenameField;
1036
- const d = /* @__PURE__ */ new Map(), y = /* @__PURE__ */ new Map(), v = () => ({ __entityRef: t });
1037
+ const u = /* @__PURE__ */ new Map(), y = /* @__PURE__ */ new Map(), v = () => ({ __entityRef: t });
1037
1038
  let p;
1038
- f?.hasSubscribe && a && "__subscribe" in a && (p = It((w) => {
1039
- const h = (b) => {
1040
- b.__eventSource = t, s.applyMutationEvent(b);
1039
+ f?.hasSubscribe && a && "__subscribe" in a && (p = It((E) => {
1040
+ const h = (C) => {
1041
+ C.__eventSource = t, s.applyMutationEvent(C);
1041
1042
  }, m = a.__subscribe.call(g, h);
1042
- return w.value = g, m;
1043
+ return E.value = g, m;
1043
1044
  }));
1044
1045
  let g;
1045
- const E = Object.keys(r);
1046
- if (E.includes("__typename") || E.push("__typename"), a)
1047
- for (const w of Object.keys(a))
1048
- E.includes(w) || E.push(w);
1049
- let S, C = E;
1050
- function I() {
1051
- const w = i._extraMethods;
1052
- if (w !== S) {
1053
- if (S = w, C = E.slice(), w !== void 0)
1054
- for (const m of Object.keys(w))
1055
- C.includes(m) || C.push(m);
1056
- const h = i._extraGetters;
1046
+ const w = Object.keys(r);
1047
+ if (w.includes("__typename") || w.push("__typename"), a)
1048
+ for (const E of Object.keys(a))
1049
+ w.includes(E) || w.push(E);
1050
+ let I, O = w;
1051
+ function K() {
1052
+ const E = n._extraMethods;
1053
+ if (E !== I) {
1054
+ if (I = E, O = w.slice(), E !== void 0)
1055
+ for (const m of Object.keys(E))
1056
+ O.includes(m) || O.push(m);
1057
+ const h = n._extraGetters;
1057
1058
  if (h !== void 0)
1058
1059
  for (const m of Object.keys(h))
1059
- C.includes(m) || C.push(m);
1060
+ O.includes(m) || O.push(m);
1060
1061
  }
1061
- return C;
1062
+ return O;
1062
1063
  }
1063
- const x = {
1064
+ const R = {
1064
1065
  getPrototypeOf() {
1065
- return l;
1066
+ return d;
1066
1067
  },
1067
- get(w, h) {
1068
+ get(E, h) {
1068
1069
  if (typeof h == "symbol") return;
1069
1070
  if (h === "toJSON") return v;
1070
1071
  if (h === "__context") return s.getContext();
1071
- if (h === "__typename") return i.typename;
1072
- if (p?.value, n.consume(), typeof h == "string") {
1073
- const b = i._extraGetters;
1074
- if (b !== void 0 && h in b)
1075
- return b[h]();
1076
- const N = i._extraMethods;
1077
- if (N !== void 0 && h in N) {
1078
- let R = d.get(h);
1079
- return R || (R = N[h].bind(g), d.set(h, R)), R;
1072
+ if (h === "__typename") return n.typename;
1073
+ if (p?.value, i.consume(), typeof h == "string") {
1074
+ const C = n._extraGetters;
1075
+ if (C !== void 0 && h in C)
1076
+ return C[h]();
1077
+ const S = n._extraMethods;
1078
+ if (S !== void 0 && h in S) {
1079
+ let b = u.get(h);
1080
+ return b || (b = S[h].bind(g), u.set(h, b)), b;
1080
1081
  }
1081
1082
  if (a && h in a) {
1082
- let R = d.get(h);
1083
- return R || (R = ge(g, a[h].bind(g)), d.set(h, R)), R;
1083
+ let b = u.get(h);
1084
+ return b || (b = pe(g, a[h].bind(g)), u.set(h, b)), b;
1084
1085
  }
1085
1086
  }
1086
- const m = i.data[h];
1087
- if (typeof m == "object" && m !== null && z.has(m))
1088
- return D(m.getValue());
1087
+ const m = n.data[h];
1088
+ if (typeof m == "object" && m !== null && J.has(m))
1089
+ return A(m.getValue());
1089
1090
  if (Array.isArray(m) && typeof h == "string") {
1090
- const b = r[h];
1091
- if (b instanceof _ && (b.mask & u.ARRAY) !== 0) {
1092
- const N = b.shape;
1093
- if (N instanceof _ && (N.mask & u.ENTITY) !== 0) {
1094
- const R = N.typenameValue;
1095
- if (R !== void 0) {
1096
- const _t = s.getEntityDefsForTypename(R);
1091
+ const C = r[h];
1092
+ if (C instanceof _ && (C.mask & l.ARRAY) !== 0) {
1093
+ const S = C.shape;
1094
+ if (S instanceof _ && (S.mask & l.ENTITY) !== 0) {
1095
+ const b = S.typenameValue;
1096
+ if (b !== void 0) {
1097
+ const _t = s.getEntityDefsForTypename(b);
1097
1098
  if (_t !== void 0 && _t.length > 1) {
1098
1099
  const X = y.get(h);
1099
1100
  if (X !== void 0 && X.source === m)
1100
- return D(X.filtered);
1101
- const mt = si(m, N, s);
1102
- return y.set(h, { source: m, filtered: mt }), D(mt);
1101
+ return A(X.filtered);
1102
+ const mt = an(m, S, s);
1103
+ return y.set(h, { source: m, filtered: mt }), A(mt);
1103
1104
  }
1104
1105
  }
1105
1106
  }
1106
1107
  }
1107
- return D(m);
1108
+ return A(m);
1108
1109
  }
1109
- return D(m);
1110
+ return A(m);
1110
1111
  },
1111
1112
  set() {
1112
1113
  return !1;
1113
1114
  },
1114
- has(w, h) {
1115
+ has(E, h) {
1115
1116
  if (h === "__typename") return !0;
1116
1117
  if (typeof h == "string") {
1117
- const m = i._extraGetters;
1118
+ const m = n._extraGetters;
1118
1119
  if (m && h in m) return !0;
1119
- const b = i._extraMethods;
1120
- if (b && h in b || a && h in a) return !0;
1120
+ const C = n._extraMethods;
1121
+ if (C && h in C || a && h in a) return !0;
1121
1122
  }
1122
1123
  return h in r;
1123
1124
  },
1124
1125
  ownKeys() {
1125
- return I();
1126
+ return K();
1126
1127
  },
1127
- getOwnPropertyDescriptor(w, h) {
1128
+ getOwnPropertyDescriptor(E, h) {
1128
1129
  if (h === "__typename")
1129
- return { enumerable: !0, configurable: !0, value: i.typename, writable: !1 };
1130
+ return { enumerable: !0, configurable: !0, value: n.typename, writable: !1 };
1130
1131
  if (h in r)
1131
- return { enumerable: !0, configurable: !0, value: x.get(w, h, g), writable: !1 };
1132
+ return { enumerable: !0, configurable: !0, value: R.get(E, h, g), writable: !1 };
1132
1133
  if (typeof h == "string") {
1133
- const m = i._extraGetters;
1134
+ const m = n._extraGetters;
1134
1135
  if (m && h in m)
1135
- return { enumerable: !0, configurable: !0, value: x.get(w, h, g), writable: !1 };
1136
- const b = i._extraMethods;
1137
- if (b && h in b)
1138
- return { enumerable: !0, configurable: !0, value: x.get(w, h, g), writable: !1 };
1136
+ return { enumerable: !0, configurable: !0, value: R.get(E, h, g), writable: !1 };
1137
+ const C = n._extraMethods;
1138
+ if (C && h in C)
1139
+ return { enumerable: !0, configurable: !0, value: R.get(E, h, g), writable: !1 };
1139
1140
  if (a && h in a)
1140
- return { enumerable: !1, configurable: !0, value: x.get(w, h, g), writable: !1 };
1141
+ return { enumerable: !1, configurable: !0, value: R.get(E, h, g), writable: !1 };
1141
1142
  }
1142
1143
  }
1143
1144
  };
1144
- return g = new Proxy({}, x), O.set(g, t), pe(g, s), g;
1145
+ return g = new Proxy({}, R), x.set(g, t), ye(g, s), g;
1145
1146
  }
1146
- class oi {
1147
+ class fn {
1147
1148
  instances = /* @__PURE__ */ new Map();
1148
1149
  persistEntity;
1149
1150
  constructor(t) {
@@ -1155,17 +1156,17 @@ class oi {
1155
1156
  getEntity(t) {
1156
1157
  return this.instances.get(t);
1157
1158
  }
1158
- getOrCreateEntity(t, e, n, s) {
1159
+ getOrCreateEntity(t, e, i, s) {
1159
1160
  let r = this.instances.get(t);
1160
1161
  if (r === void 0) {
1161
- const o = n.idField;
1162
+ const o = i.idField;
1162
1163
  if (o === void 0)
1163
- throw new Error(`Entity id field is required ${n.typenameValue}`);
1164
+ throw new Error(`Entity id field is required ${i.typenameValue}`);
1164
1165
  const a = e[o];
1165
1166
  if (typeof a != "string" && typeof a != "number")
1166
- throw new Error(`Entity id must be string or number: ${n.typenameValue}`);
1167
- const c = n;
1168
- r = new ni(t, n.typenameValue, a, o, e, s), r._entityCache = c._entityCache, this.instances.set(t, r);
1167
+ throw new Error(`Entity id must be string or number: ${i.typenameValue}`);
1168
+ const c = i;
1169
+ r = new on(t, i.typenameValue, a, o, e, s), r._entityCache = c._entityCache, this.instances.set(t, r);
1169
1170
  }
1170
1171
  return r.parseId = s.currentParseId, r;
1171
1172
  }
@@ -1176,18 +1177,18 @@ class oi {
1176
1177
  let e;
1177
1178
  if (t.entityRefs) {
1178
1179
  e = /* @__PURE__ */ new Set();
1179
- for (const n of t.entityRefs.keys()) e.add(n.key);
1180
+ for (const i of t.entityRefs.keys()) e.add(i.key);
1180
1181
  }
1181
1182
  this.persistEntity(t.key, t.data, e);
1182
1183
  }
1183
1184
  }
1184
- class ie {
1185
+ class ee {
1185
1186
  onlineSignal;
1186
1187
  manualOverride = void 0;
1187
1188
  eventListenersAttached = !1;
1188
1189
  constructor(t) {
1189
1190
  const e = t ?? this.detectOnlineStatus();
1190
- this.onlineSignal = Mt(e), this.canAttachListeners() && this.attachEventListeners();
1191
+ this.onlineSignal = Nt(e), this.canAttachListeners() && this.attachEventListeners();
1191
1192
  }
1192
1193
  /**
1193
1194
  * Returns true if the network is currently online
@@ -1246,7 +1247,7 @@ class ie {
1246
1247
  }
1247
1248
  }
1248
1249
  class ne {
1249
- static onlineSignal = Mt(!0);
1250
+ static onlineSignal = Nt(!0);
1250
1251
  get isOnline() {
1251
1252
  return !0;
1252
1253
  }
@@ -1260,97 +1261,28 @@ class ne {
1260
1261
  destroy() {
1261
1262
  }
1262
1263
  }
1263
- const ai = new ie(), Oi = Tt(ai);
1264
- function gt(i, t = typeof window > "u") {
1264
+ const un = new ee(), In = Mt(un);
1265
+ function gt(n, t = typeof window > "u") {
1265
1266
  let e;
1266
- i === !1 ? e = 0 : i === void 0 || i === !0 ? e = t ? 0 : 3 : typeof i == "number" ? e = i : e = i.retries;
1267
- const n = typeof i == "object" && i.retryDelay ? i.retryDelay : (s) => 1e3 * Math.pow(2, s);
1268
- return { retries: e, retryDelay: n };
1267
+ n === !1 ? e = 0 : n === void 0 || n === !0 ? e = t ? 0 : 3 : typeof n == "number" ? e = n : e = n.retries;
1268
+ const i = typeof n == "object" && n.retryDelay ? n.retryDelay : (s) => 1e3 * Math.pow(2, s);
1269
+ return { retries: e, retryDelay: i };
1269
1270
  }
1270
- class ci {
1271
+ class Nn {
1271
1272
  static cache;
1273
+ /**
1274
+ * The controller class responsible for sending requests for this query type.
1275
+ * Must be set on each concrete Query subclass (or inherited from a base like RESTQuery).
1276
+ */
1277
+ static controller;
1272
1278
  params;
1273
1279
  config;
1274
1280
  constructor() {
1275
- return qt(this);
1276
- }
1277
- }
1278
- class Si extends ci {
1279
- method = "GET";
1280
- path;
1281
- searchParams;
1282
- body;
1283
- headers;
1284
- requestOptions;
1285
- loadNext;
1286
- getStorageKey() {
1287
- return `${this.method ?? "GET"}:${this.path ?? ""}`;
1288
- }
1289
- async send() {
1290
- return this.executeRequest();
1291
- }
1292
- resolveLoadNext() {
1293
- const e = (this.getLoadNext ? this.getLoadNext() : void 0) ?? this.rawLoadNext;
1294
- if (e === void 0) return;
1295
- const n = {
1296
- params: this.params ?? {},
1297
- result: this.resultData
1298
- };
1299
- return {
1300
- url: e.url !== void 0 ? P(e.url, n) : void 0,
1301
- searchParams: e.searchParams !== void 0 ? P(e.searchParams, n) : void 0
1302
- };
1303
- }
1304
- hasNext() {
1305
- const t = this.resolveLoadNext();
1306
- if (t === void 0) return !1;
1307
- if (t.url !== void 0 && t.url !== null)
1308
- return !0;
1309
- if (t.searchParams !== void 0) {
1310
- const e = Object.keys(t.searchParams);
1311
- if (e.length === 0) return !1;
1312
- for (const n of e)
1313
- if (t.searchParams[n] === void 0 || t.searchParams[n] === null)
1314
- return !1;
1315
- return !0;
1316
- }
1317
- return !1;
1318
- }
1319
- async sendNext() {
1320
- const t = this.resolveLoadNext();
1321
- if (t === void 0)
1322
- throw new Error("loadNext is not configured for this query");
1323
- return this.executeRequest(t);
1324
- }
1325
- async executeRequest(t) {
1326
- const e = t?.url ?? (this.getPath ? this.getPath() : this.path), n = this.getMethod ? this.getMethod() : this.method, s = this.getSearchParams ? this.getSearchParams() : this.searchParams, r = t?.searchParams ? { ...s, ...t.searchParams } : s, o = this.getBody ? this.getBody() : this.body, a = this.getRequestOptions ? this.getRequestOptions() : this.requestOptions;
1327
- if (!e)
1328
- throw new Error("RESTQuery requires a path. Define `path` as a field or override `getPath()`.");
1329
- let c = e;
1330
- if (r) {
1331
- const S = new URLSearchParams();
1332
- for (const I in r) {
1333
- const x = r[I];
1334
- x != null && S.append(I, String(x));
1335
- }
1336
- const C = S.toString();
1337
- C && (c += "?" + C);
1338
- }
1339
- const f = Dt(a?.baseUrl) ?? Dt(this.context.baseUrl), l = f ? `${f}${c}` : c, { baseUrl: d, signal: y, ...v } = a ?? {}, g = o || this.headers ? {
1340
- ...o ? { "Content-Type": "application/json" } : void 0,
1341
- ...this.headers
1342
- } : void 0, E = await this.context.fetch(l, {
1343
- method: n,
1344
- headers: g,
1345
- body: o ? JSON.stringify(o) : void 0,
1346
- signal: this.signal,
1347
- ...v
1348
- });
1349
- return this.response = E, E.json();
1281
+ return jt(this);
1350
1282
  }
1351
1283
  }
1352
- const Rt = /* @__PURE__ */ new WeakMap();
1353
- class J {
1284
+ const Ot = /* @__PURE__ */ new WeakMap();
1285
+ class V {
1354
1286
  constructor(t, e) {
1355
1287
  this.captured = e, this.statics = t;
1356
1288
  }
@@ -1359,71 +1291,76 @@ class J {
1359
1291
  return et(this.captured, t, e);
1360
1292
  }
1361
1293
  resolveOptions(t) {
1362
- const { methods: e } = this.captured, n = e.getConfig ? e.getConfig.call(t) : t.config, s = gt(n?.retry);
1363
- return { config: n, retryConfig: s };
1294
+ const { methods: e } = this.captured, i = e.getConfig ? e.getConfig.call(t) : t.config, s = gt(i?.retry);
1295
+ return { config: i, retryConfig: s };
1364
1296
  }
1365
1297
  static for(t) {
1366
- let e = Rt.get(t);
1298
+ let e = Ot.get(t);
1367
1299
  if (e !== void 0)
1368
1300
  return e;
1369
- const n = new t(), s = Se(n), r = String(s.methods.getStorageKey.call(s.fields)), o = s.fields.result, a = o instanceof _ ? o : We.object(o), c = (a.mask & u.ENTITY) !== 0, f = t.cache, l = s.fields.loadNext, d = typeof s.methods.sendNext == "function", y = c ? a : new _(
1370
- u.ENTITY | u.OBJECT,
1301
+ const i = new t(), s = De(i), r = String(s.methods.getIdentityKey.call(s.fields)), o = s.fields.result, a = o instanceof _ ? o : He.object(o), c = (a.mask & l.ENTITY) !== 0, f = t.cache, d = s.fields.fetchNext, u = t.controller;
1302
+ if (!u)
1303
+ throw new Error(
1304
+ `Query class "${t.name}" must define a static \`controller\` property. Extend RESTQuery (from fetchium/rest) or set \`static controller = MyController\` on your query class.`
1305
+ );
1306
+ const y = typeof u.prototype.sendNext == "function", v = c ? a : new _(
1307
+ l.ENTITY | l.OBJECT,
1371
1308
  a.shape,
1372
1309
  void 0,
1373
1310
  void 0,
1374
1311
  r,
1375
1312
  // typenameValue — unique per query class
1376
- kt
1313
+ Ft
1377
1314
  // idField — symbol, injected onto payload before parse
1378
1315
  );
1379
- return e = new J(
1380
- { id: r, shape: y, cache: f, rawLoadNext: l, hasSendNext: d, isEntityResult: c },
1316
+ return e = new V(
1317
+ { id: r, shape: v, cache: f, rawFetchNext: d, hasSendNext: y, isEntityResult: c, controllerClass: u },
1381
1318
  s
1382
- ), Rt.set(t, e), e;
1319
+ ), Ot.set(t, e), e;
1383
1320
  }
1384
1321
  }
1385
- const Ni = (i, t) => {
1386
- const e = J.for(i);
1322
+ const Mn = (n, t) => {
1323
+ const e = V.for(n);
1387
1324
  return vt(e, t);
1388
1325
  };
1389
- function Di(i, ...t) {
1390
- const e = J.for(i), n = ve(wi);
1391
- if (n === void 0)
1326
+ function kn(n, ...t) {
1327
+ const e = V.for(n), i = ge(bn);
1328
+ if (i === void 0)
1392
1329
  throw new Error("QueryClient not found");
1393
1330
  const s = t[0];
1394
- return n.getQuery(e, s);
1331
+ return i.getQuery(e, s);
1395
1332
  }
1396
- function se(i, t) {
1397
- return new Promise((e, n) => {
1333
+ function ie(n, t) {
1334
+ return new Promise((e, i) => {
1398
1335
  if (t?.aborted) {
1399
- n(t.reason);
1336
+ i(t.reason);
1400
1337
  return;
1401
1338
  }
1402
- const s = setTimeout(e, i);
1339
+ const s = setTimeout(e, n);
1403
1340
  t?.addEventListener(
1404
1341
  "abort",
1405
1342
  () => {
1406
- clearTimeout(s), n(t.reason);
1343
+ clearTimeout(s), i(t.reason);
1407
1344
  },
1408
1345
  { once: !0 }
1409
1346
  );
1410
1347
  });
1411
1348
  }
1412
- async function rt(i, t, e) {
1413
- const n = Math.max(0, t.retries);
1349
+ async function rt(n, t, e) {
1350
+ const i = Math.max(0, t.retries);
1414
1351
  let s;
1415
- for (let r = 0; r <= n; r++) {
1352
+ for (let r = 0; r <= i; r++) {
1416
1353
  e?.throwIfAborted();
1417
1354
  try {
1418
- return await i();
1355
+ return await n();
1419
1356
  } catch (o) {
1420
- if (s = o, r >= n) throw o;
1421
- await se(t.retryDelay(r), e);
1357
+ if (s = o, r >= i) throw o;
1358
+ await ie(t.retryDelay(r), e);
1422
1359
  }
1423
1360
  }
1424
1361
  throw s;
1425
1362
  }
1426
- class fi {
1363
+ class ln {
1427
1364
  def;
1428
1365
  queryKey;
1429
1366
  storageKey = -1;
@@ -1441,8 +1378,6 @@ class fi {
1441
1378
  /** Resolved per-instance options (depend on actual params). */
1442
1379
  config = void 0;
1443
1380
  retryConfig = gt(void 0);
1444
- /** The raw fetch Response from the most recent successful fetch. */
1445
- _lastResponse = void 0;
1446
1381
  /** Controller for aborting in-flight fetches and retry waits. */
1447
1382
  _abortController = void 0;
1448
1383
  /** Cached execution context, recreated only when storageKey (params) changes. */
@@ -1451,7 +1386,7 @@ class fi {
1451
1386
  /** Root entity that holds parsed data, proxy, child refs, and bindings.
1452
1387
  * For entity results, this is undefined until the first apply discovers it. */
1453
1388
  rootEntity;
1454
- /** Extra methods (__refetch, __loadNext) attached to the root entity proxy. */
1389
+ /** Extra methods (__refetch, __fetchNext) attached to the root entity proxy. */
1455
1390
  _extraMethods = {};
1456
1391
  /** Query id injected as QUERY_ID on non-entity payloads. */
1457
1392
  _queryId = 0;
@@ -1461,24 +1396,24 @@ class fi {
1461
1396
  get relayState() {
1462
1397
  return this._relayState;
1463
1398
  }
1464
- constructor(t, e, n, s) {
1465
- this.def = t, this.queryClient = e, this.queryKey = n, this.params = s, this._extraMethods = { __refetch: this.refetch }, t.statics.hasSendNext && (this._extraMethods.__loadNext = this.loadNext);
1466
- const r = At(s);
1467
- this._queryId = r !== void 0 ? A(r) : 0, this.relay = It(
1399
+ constructor(t, e, i, s) {
1400
+ this.def = t, this.queryClient = e, this.queryKey = i, this.params = s, this._extraMethods = { __refetch: this.refetch }, t.statics.hasSendNext && (this._extraMethods.__fetchNext = this.fetchNext);
1401
+ const r = Dt(s);
1402
+ this._queryId = r !== void 0 ? D(r) : 0, this.relay = It(
1468
1403
  (o) => {
1469
1404
  this._relayState = o;
1470
1405
  const a = () => {
1471
- clearTimeout(this.debounceTimer), this.debounceTimer = void 0, this._abortController?.abort(), this._abortController = void 0, this._loadNextAbort?.abort(), this._loadNextAbort = void 0, this._loadNextPromise = void 0, this.unsubscribe?.(), this.unsubscribe = void 0;
1472
- const f = this.config?.gcTime ?? Ft;
1473
- this.queryClient.gcManager.schedule(this.queryKey, f, W.Query);
1406
+ clearTimeout(this.debounceTimer), this.debounceTimer = void 0, this._abortController?.abort(), this._abortController = void 0, this._fetchNextAbort?.abort(), this._fetchNextAbort = void 0, this._fetchNextPromise = void 0, this.unsubscribe?.(), this.unsubscribe = void 0;
1407
+ const f = this.config?.gcTime ?? kt;
1408
+ this.queryClient.gcManager.schedule(this.queryKey, f, z.Query);
1474
1409
  }, c = (f = !1) => {
1475
- const { wasPaused: l, isPaused: d, initialized: y } = this;
1476
- if (this.wasPaused = d, d && !l && y) {
1410
+ const { wasPaused: d, isPaused: u, initialized: y } = this;
1411
+ if (this.wasPaused = u, u && !d && y) {
1477
1412
  a();
1478
1413
  return;
1479
1414
  }
1480
- const v = At(this.params), p = vt(this.def, v), g = p !== this.storageKey;
1481
- g && (this.currentParams = v, this.storageKey = p), this.getOrCreateExecutionContext(), this.initialized ? l || f ? (this.queryClient.activateQuery(this), f && this.updatedAt !== void 0 && this.setupSubscription(), (this.config?.refreshStaleOnReconnect ?? !0) && this.isStale && this.runDebounced()) : g && (this.setupSubscription(), this.runDebounced()) : (this.queryClient.activateQuery(this), this.initialize());
1415
+ const v = Dt(this.params), p = vt(this.def, v), g = p !== this.storageKey;
1416
+ g && (this.currentParams = v, this.storageKey = p), this.getOrCreateExecutionContext(), this.initialized ? d || f ? (this.queryClient.activateQuery(this), f && this.updatedAt !== void 0 && this.setupSubscription(), (this.config?.refreshStaleOnReconnect ?? !0) && this.isStale && this.runDebounced()) : g && (this.setupSubscription(), this.runDebounced()) : (this.queryClient.activateQuery(this), this.initialize());
1482
1417
  };
1483
1418
  return c(!0), {
1484
1419
  update: c,
@@ -1489,18 +1424,18 @@ class fi {
1489
1424
  );
1490
1425
  }
1491
1426
  /** Apply raw data (fresh or cached) to the root entity and return the proxy. */
1492
- applyData(t, e, n = !1, s) {
1427
+ applyData(t, e, i = !1, s) {
1493
1428
  const r = this.def;
1494
1429
  return this.rootEntity = this.queryClient.parseAndApplyRootEntity(
1495
1430
  t,
1496
1431
  this._queryId,
1497
1432
  r.statics.shape,
1498
1433
  e,
1499
- n,
1434
+ i,
1500
1435
  s
1501
1436
  ), this.rootEntity._extraMethods === void 0 && (this.rootEntity._extraMethods = this._extraMethods, this.rootEntity._extraGetters = {
1502
1437
  __hasNext: () => this.hasNext,
1503
- __isLoadingNext: () => this._loadNextPromise !== void 0
1438
+ __isFetchingNext: () => this._fetchNextPromise !== void 0
1504
1439
  }), this.rootEntity.getProxy(r.statics.shape);
1505
1440
  }
1506
1441
  /** Save query metadata (the __entityRef pointer, updatedAt, ref set). */
@@ -1518,16 +1453,16 @@ class fi {
1518
1453
  async initialize() {
1519
1454
  const t = this.queryClient, e = this.relayState;
1520
1455
  this.initialized = !0;
1521
- let n;
1456
+ let i;
1522
1457
  try {
1523
- n = await t.loadCachedQuery(this.def, this.storageKey), n !== void 0 && (this.updatedAt = n.updatedAt, e.value = this.applyData(n.value, !1, !1, n.preloadedEntities));
1458
+ i = await t.loadCachedQuery(this.def, this.storageKey), i !== void 0 && (this.updatedAt = i.updatedAt, e.value = this.applyData(i.value, !1, !1, i.preloadedEntities));
1524
1459
  } catch (s) {
1525
1460
  t.store.deleteQuery(this.storageKey), t.getContext().log?.warn?.("Failed to initialize query, the query cache may be corrupted or invalid", s);
1526
1461
  }
1527
1462
  if (!this.isPaused)
1528
1463
  try {
1529
- if (n !== void 0 && this.setupSubscription(), n === void 0 || this.isStale) {
1530
- if (await se(0), this.isPaused) return;
1464
+ if (i !== void 0 && this.setupSubscription(), i === void 0 || this.isStale) {
1465
+ if (await ie(0), this.isPaused) return;
1531
1466
  this.runQueryImmediately();
1532
1467
  }
1533
1468
  } catch (s) {
@@ -1539,15 +1474,15 @@ class fi {
1539
1474
  const t = this.config?.subscribe;
1540
1475
  if (!t) return;
1541
1476
  const e = this._executionCtx;
1542
- this.unsubscribe = t.call(e, (n) => {
1543
- n.__eventSource = this.queryKey, this.queryClient.applyMutationEvent(n);
1477
+ this.unsubscribe = t.call(e, (i) => {
1478
+ i.__eventSource = this.queryKey, this.queryClient.applyMutationEvent(i);
1544
1479
  });
1545
1480
  }
1546
1481
  getOrCreateExecutionContext() {
1547
1482
  return (this._executionCtx === void 0 || this._executionCtxKey !== this.storageKey) && (this._executionCtxKey = this.storageKey, this._executionCtx = this.def.createExecutionContext(
1548
1483
  this.currentParams ?? {},
1549
1484
  this.queryClient.getContext()
1550
- ), this._executionCtx.refetch = () => this.refetch(), this._executionCtx.rawLoadNext = this.def.statics.rawLoadNext), this._executionCtx.response = this._lastResponse, this.resolveAndApplyOptions(), this._executionCtx;
1485
+ ), this._executionCtx.refetch = () => this.refetch(), this._executionCtx.rawFetchNext = this.def.statics.rawFetchNext), this.resolveAndApplyOptions(), this._executionCtx;
1551
1486
  }
1552
1487
  resolveAndApplyOptions() {
1553
1488
  const t = this.def.resolveOptions(this._executionCtx);
@@ -1557,11 +1492,11 @@ class fi {
1557
1492
  const t = this.def;
1558
1493
  if (this.isPaused)
1559
1494
  throw new Error("Query is paused due to network status");
1560
- const e = this.getOrCreateExecutionContext(), { send: n } = t.captured.methods, s = this._abortController?.signal;
1561
- return e.signal = s, rt(
1495
+ const e = this.getOrCreateExecutionContext(), i = this.queryClient.getController(t.statics.controllerClass), s = this._abortController?.signal ?? new AbortController().signal;
1496
+ return rt(
1562
1497
  async () => {
1563
- const r = await n.call(e);
1564
- this._lastResponse = e.response, this._executionCtx.response = this._lastResponse, this.resolveAndApplyOptions(), this.updatedAt = Date.now();
1498
+ const r = await i.send(e, s);
1499
+ this.updatedAt = Date.now();
1565
1500
  const o = this.applyData(r, !0);
1566
1501
  return this.saveQueryMetadata(), this.unsubscribe === void 0 && this.setupSubscription(), o;
1567
1502
  },
@@ -1570,7 +1505,7 @@ class fi {
1570
1505
  );
1571
1506
  }
1572
1507
  runQueryImmediately() {
1573
- this._abortController?.abort(), this._abortController = new AbortController(), this._loadNextAbort?.abort(), this._loadNextAbort = void 0, this._loadNextPromise = void 0, this.relayState.setPromise(this.runQuery());
1508
+ this._abortController?.abort(), this._abortController = new AbortController(), this._fetchNextAbort?.abort(), this._fetchNextAbort = void 0, this._fetchNextPromise = void 0, this.relayState.setPromise(this.runQuery());
1574
1509
  }
1575
1510
  runDebounced() {
1576
1511
  if (this.relayState.isPending) return;
@@ -1583,35 +1518,41 @@ class fi {
1583
1518
  // Public methods
1584
1519
  // ======================================================
1585
1520
  refetch = () => this.relayState.isPending ? this.relay : (this.runQueryImmediately(), this.relay);
1586
- /** In-flight loadNext promise for deduplication. */
1587
- _loadNextPromise = void 0;
1588
- /** Controller for aborting in-flight loadNext requests. */
1589
- _loadNextAbort = void 0;
1590
- loadNext = () => {
1521
+ markStale() {
1522
+ this.updatedAt = 0;
1523
+ }
1524
+ get resolvedParams() {
1525
+ return this.currentParams;
1526
+ }
1527
+ /** In-flight fetchNext promise for deduplication. */
1528
+ _fetchNextPromise = void 0;
1529
+ /** Controller for aborting in-flight fetchNext requests. */
1530
+ _fetchNextAbort = void 0;
1531
+ fetchNext = () => {
1591
1532
  if (this.updatedAt === void 0)
1592
- throw new Error("Cannot call __loadNext before initial data has loaded");
1593
- return this._loadNextPromise !== void 0 ? this._loadNextPromise : (queueMicrotask(() => this.rootEntity?.notify()), this._loadNextPromise = this.runLoadNext().then(
1594
- (t) => (this._loadNextPromise = void 0, this.rootEntity?.notify(), t),
1533
+ throw new Error("Cannot call __fetchNext before initial data has loaded");
1534
+ return this._fetchNextPromise !== void 0 ? this._fetchNextPromise : (queueMicrotask(() => this.rootEntity?.notify()), this._fetchNextPromise = this.runFetchNext().then(
1535
+ (t) => (this._fetchNextPromise = void 0, this.rootEntity?.notify(), t),
1595
1536
  (t) => {
1596
- throw this._loadNextPromise = void 0, this.rootEntity?.notify(), t;
1537
+ throw this._fetchNextPromise = void 0, this.rootEntity?.notify(), t;
1597
1538
  }
1598
- ), this._loadNextPromise);
1539
+ ), this._fetchNextPromise);
1599
1540
  };
1600
1541
  get hasNext() {
1601
1542
  if (this.rootEntity === void 0 || !this._executionCtx) return !1;
1602
- const t = this.def.captured.methods.hasNext;
1603
- return t ? (this._executionCtx.resultData = this.rootEntity.data, t.call(this._executionCtx)) : !1;
1543
+ const t = this.queryClient.getController(this.def.statics.controllerClass);
1544
+ return t.hasNext ? (this._executionCtx.resultData = this.rootEntity.data, t.hasNext(this._executionCtx)) : !1;
1604
1545
  }
1605
- async runLoadNext() {
1546
+ async runFetchNext() {
1606
1547
  const t = this.def;
1607
- this._loadNextAbort = new AbortController();
1608
- const e = this._loadNextAbort.signal, n = this.getOrCreateExecutionContext();
1609
- n.signal = e, n.resultData = this.rootEntity.data;
1610
- const s = t.captured.methods.sendNext;
1548
+ this._fetchNextAbort = new AbortController();
1549
+ const e = this._fetchNextAbort.signal, i = this.getOrCreateExecutionContext();
1550
+ i.resultData = this.rootEntity.data;
1551
+ const s = this.queryClient.getController(t.statics.controllerClass);
1611
1552
  return rt(
1612
1553
  async () => {
1613
- const r = await s.call(n);
1614
- this._lastResponse = n.response, this._executionCtx.response = this._lastResponse, this.resolveAndApplyOptions(), this.updatedAt = Date.now();
1554
+ const r = await s.sendNext(i, e);
1555
+ this.updatedAt = Date.now();
1615
1556
  const o = this.applyData(r, !0, !0);
1616
1557
  return this.saveQueryMetadata(), o;
1617
1558
  },
@@ -1629,38 +1570,37 @@ class fi {
1629
1570
  return Date.now() - this.updatedAt >= t;
1630
1571
  }
1631
1572
  get isPaused() {
1632
- const t = this.config?.networkMode ?? q.Online;
1633
- if (t === q.Always)
1573
+ const t = this.config?.networkMode ?? L.Online;
1574
+ if (t === L.Always)
1634
1575
  return !1;
1635
1576
  const e = this.queryClient.networkManager.getOnlineSignal().value;
1636
1577
  switch (t) {
1637
- case q.Online:
1578
+ case L.Online:
1638
1579
  return !e;
1639
- case q.OfflineFirst:
1580
+ case L.OfflineFirst:
1640
1581
  return !e && this.updatedAt === void 0;
1641
1582
  default:
1642
1583
  return !1;
1643
1584
  }
1644
1585
  }
1645
1586
  }
1646
- class ui {
1587
+ class dn {
1647
1588
  def;
1648
1589
  queryClient;
1649
- _lastResponse;
1650
1590
  _inFlight = !1;
1651
1591
  task;
1652
1592
  constructor(t, e) {
1653
1593
  this.def = t, this.queryClient = e, this.task = this.createTask();
1654
1594
  }
1655
1595
  createTask() {
1656
- return _e(
1596
+ return ve(
1657
1597
  async (t) => {
1658
1598
  if (this._inFlight)
1659
1599
  throw new Error("A mutation is already in progress. Await the previous call before starting a new one.");
1660
1600
  this._inFlight = !0;
1661
1601
  try {
1662
- const e = await this.executeWithRetry(t), n = this.validateResponse(e);
1663
- return this.processEffects(t, n), n;
1602
+ const e = await this.executeWithRetry(t), i = this.validateResponse(e);
1603
+ return this.processEffects(t, i), i;
1664
1604
  } finally {
1665
1605
  this._inFlight = !1;
1666
1606
  }
@@ -1672,122 +1612,126 @@ class ui {
1672
1612
  const e = this.def.responseShape;
1673
1613
  if (!(e instanceof _))
1674
1614
  return t;
1675
- const n = this.queryClient.getContext().log?.warn ?? (() => {
1615
+ const i = this.queryClient.getContext().log?.warn ?? (() => {
1676
1616
  }), s = new st();
1677
- return s.reset(void 0, void 0, n), Xt(t, e, s);
1617
+ return s.reset(void 0, void 0, i), Jt(t, e, s);
1678
1618
  }
1679
1619
  // ======================================================
1680
1620
  // Effects processing
1681
1621
  // ======================================================
1682
1622
  processEffects(t, e) {
1683
- let n;
1623
+ let i;
1684
1624
  if (this.def.hasGetEffects) {
1685
1625
  const r = et(
1686
1626
  this.def.captured,
1687
1627
  t ?? {},
1688
1628
  this.queryClient.getContext()
1689
1629
  );
1690
- r.result = e, r.response = this._lastResponse, n = r.getEffects();
1630
+ r.result = e, i = r.getEffects();
1691
1631
  } else if (this.def.effects !== void 0) {
1692
1632
  const r = { params: t, result: e };
1693
- n = P(this.def.effects, r);
1633
+ i = W(this.def.effects, r);
1694
1634
  }
1695
- if (n === void 0) return;
1635
+ if (i === void 0) return;
1696
1636
  const s = this.queryClient;
1697
- Z(n.creates, "create", s), Z(n.updates, "update", s), Z(n.deletes, "delete", s);
1637
+ Z(i.creates, "create", s), Z(i.updates, "update", s), Z(i.deletes, "delete", s), i.invalidates && s.invalidateQueries(i.invalidates);
1698
1638
  }
1699
1639
  // ======================================================
1700
1640
  // Retry logic
1701
1641
  // ======================================================
1702
1642
  executeWithRetry(t) {
1703
- const e = gt(this.def.config?.retry, !0);
1643
+ const e = gt(this.def.config?.retry, !0), i = this.queryClient.getController(this.def.controllerClass);
1644
+ if (!i.sendMutation)
1645
+ throw new Error(
1646
+ `Controller "${this.def.controllerClass.name}" does not implement sendMutation(). Add a sendMutation() method to handle mutations.`
1647
+ );
1704
1648
  return rt(async () => {
1705
- const n = et(
1649
+ const s = new AbortController(), r = et(
1706
1650
  this.def.captured,
1707
1651
  t ?? {},
1708
1652
  this.queryClient.getContext()
1709
- ), s = await this.def.captured.methods.send.call(n);
1710
- return this._lastResponse = n.response, s;
1653
+ );
1654
+ return await i.sendMutation(r, s.signal);
1711
1655
  }, e);
1712
1656
  }
1713
1657
  }
1714
- function di(i) {
1715
- return typeof i == "string" ? i : L(i).typenameValue;
1658
+ function hn(n) {
1659
+ return typeof n == "string" ? n : T(n).typenameValue;
1716
1660
  }
1717
- function Z(i, t, e) {
1718
- if (i)
1719
- for (const [n, s] of i) {
1720
- const r = di(n);
1661
+ function Z(n, t, e) {
1662
+ if (n)
1663
+ for (const [i, s] of n) {
1664
+ const r = hn(i);
1721
1665
  r !== void 0 && e.applyMutationEvent({ type: t, typename: r, data: s });
1722
1666
  }
1723
1667
  }
1724
- const re = "__eventSource";
1725
- function oe(i) {
1726
- return { field: i, segments: i.indexOf(".") !== -1 ? i.split(".") : void 0 };
1668
+ const se = "__eventSource";
1669
+ function re(n) {
1670
+ return { field: n, segments: n.indexOf(".") !== -1 ? n.split(".") : void 0 };
1727
1671
  }
1728
- function li(i) {
1729
- return i.map(oe);
1672
+ function yn(n) {
1673
+ return n.map(re);
1730
1674
  }
1731
- function hi(i, t) {
1732
- if (t.segments === void 0) return i[t.field];
1733
- let e = i;
1734
- for (const n of t.segments) {
1675
+ function pn(n, t) {
1676
+ if (t.segments === void 0) return n[t.field];
1677
+ let e = n;
1678
+ for (const i of t.segments) {
1735
1679
  if (e == null) return;
1736
- e = e[n];
1680
+ e = e[i];
1737
1681
  }
1738
1682
  return e;
1739
1683
  }
1740
- function ae(i, t) {
1684
+ function oe(n, t) {
1741
1685
  const e = [];
1742
- for (let n = 0; n < t.length; n++) {
1743
- const s = t[n], r = hi(i, s);
1686
+ for (let i = 0; i < t.length; i++) {
1687
+ const s = t[i], r = pn(n, s);
1744
1688
  if (r === void 0) return;
1745
1689
  e.push(s.field, r);
1746
1690
  }
1747
- return A(e);
1691
+ return D(e);
1748
1692
  }
1749
- function yi(i, t) {
1750
- if (i === void 0) return;
1693
+ function gn(n, t) {
1694
+ if (n === void 0) return;
1751
1695
  const e = /* @__PURE__ */ new Map();
1752
- for (const [n, s] of i) {
1696
+ for (const [i, s] of n) {
1753
1697
  const r = s.slice().sort((c, f) => c[0] < f[0] ? -1 : c[0] > f[0] ? 1 : 0), o = [];
1754
1698
  let a = !0;
1755
1699
  for (const [c, f] of r) {
1756
- let l;
1757
- if (Lt(f)) {
1758
- const d = jt(f);
1759
- l = ut(d, t);
1700
+ let d;
1701
+ if (Pt(f)) {
1702
+ const u = Lt(f);
1703
+ d = ut(u, t);
1760
1704
  } else
1761
- l = f;
1762
- if (l === void 0) {
1705
+ d = f;
1706
+ if (d === void 0) {
1763
1707
  a = !1;
1764
1708
  break;
1765
1709
  }
1766
- o.push(c, l);
1710
+ o.push(c, d);
1767
1711
  }
1768
- a && e.set(n, A(o));
1712
+ a && e.set(i, D(o));
1769
1713
  }
1770
1714
  return e.size > 0 ? e : void 0;
1771
1715
  }
1772
- function Ot(i, t) {
1773
- const e = i.get(t);
1716
+ function Rt(n, t) {
1717
+ const e = n.get(t);
1774
1718
  if (e !== void 0)
1775
- return e.map(([n]) => n).sort();
1719
+ return e.map(([i]) => i).sort();
1776
1720
  }
1777
- class pi {
1721
+ class vn {
1778
1722
  fields;
1779
1723
  fieldPaths;
1780
1724
  _bindings = /* @__PURE__ */ new Map();
1781
1725
  constructor(t) {
1782
- this.fields = t, this.fieldPaths = t.map(oe);
1726
+ this.fields = t, this.fieldPaths = t.map(re);
1783
1727
  }
1784
1728
  register(t, e) {
1785
- let n = this._bindings.get(t);
1786
- n === void 0 && (n = /* @__PURE__ */ new Set(), this._bindings.set(t, n)), n.add(e);
1729
+ let i = this._bindings.get(t);
1730
+ i === void 0 && (i = /* @__PURE__ */ new Set(), this._bindings.set(t, i)), i.add(e);
1787
1731
  }
1788
1732
  unregister(t, e) {
1789
- const n = this._bindings.get(t);
1790
- n !== void 0 && (n.delete(e), n.size === 0 && this._bindings.delete(t));
1733
+ const i = this._bindings.get(t);
1734
+ i !== void 0 && (i.delete(e), i.size === 0 && this._bindings.delete(t));
1791
1735
  }
1792
1736
  getMatching(t) {
1793
1737
  return this._bindings.get(t);
@@ -1796,67 +1740,67 @@ class pi {
1796
1740
  return this._bindings.size === 0;
1797
1741
  }
1798
1742
  }
1799
- function St(i) {
1800
- return A(i);
1743
+ function St(n) {
1744
+ return D(n);
1801
1745
  }
1802
- class gi {
1746
+ class _n {
1803
1747
  _groups = /* @__PURE__ */ new Map();
1804
1748
  getOrCreateGroup(t) {
1805
1749
  const e = St(t);
1806
- let n = this._groups.get(e);
1807
- return n === void 0 && (n = new pi(t), this._groups.set(e, n)), n;
1750
+ let i = this._groups.get(e);
1751
+ return i === void 0 && (i = new vn(t), this._groups.set(e, i)), i;
1808
1752
  }
1809
- register(t, e, n) {
1810
- this.getOrCreateGroup(e).register(t, n);
1753
+ register(t, e, i) {
1754
+ this.getOrCreateGroup(e).register(t, i);
1811
1755
  }
1812
- unregister(t, e, n) {
1756
+ unregister(t, e, i) {
1813
1757
  const s = St(e), r = this._groups.get(s);
1814
- r !== void 0 && (r.unregister(t, n), r.isEmpty && this._groups.delete(s));
1758
+ r !== void 0 && (r.unregister(t, i), r.isEmpty && this._groups.delete(s));
1815
1759
  }
1816
1760
  registerBinding(t, e) {
1817
- const n = t._constraintHashes.get(e);
1818
- if (n === void 0) return;
1819
- const s = Ot(t._constraintFieldRefs, e);
1820
- s !== void 0 && this.register(n, s, t);
1761
+ const i = t._constraintHashes.get(e);
1762
+ if (i === void 0) return;
1763
+ const s = Rt(t._constraintFieldRefs, e);
1764
+ s !== void 0 && this.register(i, s, t);
1821
1765
  }
1822
1766
  unregisterBinding(t, e) {
1823
- const n = t._constraintHashes.get(e);
1824
- if (n === void 0) return;
1825
- const s = Ot(t._constraintFieldRefs, e);
1826
- s !== void 0 && this.unregister(n, s, t);
1767
+ const i = t._constraintHashes.get(e);
1768
+ if (i === void 0) return;
1769
+ const s = Rt(t._constraintFieldRefs, e);
1770
+ s !== void 0 && this.unregister(i, s, t);
1827
1771
  }
1828
- routeEvent(t, e, n, s, r, o) {
1772
+ routeEvent(t, e, i, s, r, o) {
1829
1773
  for (const a of this._groups.values()) {
1830
- const c = ae(e, a.fieldPaths);
1774
+ const c = oe(e, a.fieldPaths);
1831
1775
  if (c === void 0) continue;
1832
1776
  const f = a.getMatching(c);
1833
1777
  if (f !== void 0)
1834
- for (const l of f)
1835
- l.onEvent(t, n, s, r, o);
1778
+ for (const d of f)
1779
+ d.onEvent(t, i, s, r, o);
1836
1780
  }
1837
1781
  }
1838
1782
  }
1839
- function Nt(i) {
1783
+ function At(n) {
1840
1784
  const t = /* @__PURE__ */ new Set();
1841
- for (const e of i)
1785
+ for (const e of n)
1842
1786
  if (typeof e == "object" && e !== null) {
1843
- const n = F(e);
1844
- n !== void 0 && t.add(n);
1787
+ const i = k(e);
1788
+ i !== void 0 && t.add(i);
1845
1789
  }
1846
1790
  return t;
1847
1791
  }
1848
- class ce {
1792
+ class ae {
1849
1793
  _queryClient;
1850
1794
  _parent;
1851
1795
  _constraintHashes;
1852
1796
  _entityDefsByTypename;
1853
1797
  _constraintFieldRefs;
1854
1798
  instance;
1855
- constructor(t, e, n, s, r, o) {
1856
- this._queryClient = n, this._parent = s, this._constraintHashes = r, this._constraintFieldRefs = e, this.instance = o, this._entityDefsByTypename = /* @__PURE__ */ new Map();
1799
+ constructor(t, e, i, s, r, o) {
1800
+ this._queryClient = i, this._parent = s, this._constraintHashes = r, this._constraintFieldRefs = e, this.instance = o, this._entityDefsByTypename = /* @__PURE__ */ new Map();
1857
1801
  for (const a of t)
1858
1802
  a.typenameValue !== void 0 && this._entityDefsByTypename.set(a.typenameValue, a);
1859
- z.add(this);
1803
+ J.add(this);
1860
1804
  }
1861
1805
  getValue() {
1862
1806
  return this.instance.getValue();
@@ -1875,11 +1819,11 @@ class ce {
1875
1819
  * root level by applyMutationEvent. The binding just checks if the entity's
1876
1820
  * current data satisfies this binding's shape and forwards to the instance.
1877
1821
  */
1878
- onEvent(t, e, n, s, r) {
1822
+ onEvent(t, e, i, s, r) {
1879
1823
  const o = this._entityDefsByTypename.get(t);
1880
1824
  if (o === void 0) return;
1881
1825
  const a = this._queryClient.entityMap.getEntity(e);
1882
- if (n === "delete") {
1826
+ if (i === "delete") {
1883
1827
  const f = a !== void 0 ? a.getProxy(o) : r;
1884
1828
  f !== void 0 && (this.instance.onEvent(e, f, r ?? a?.data ?? {}, "delete"), s?.());
1885
1829
  return;
@@ -1887,7 +1831,7 @@ class ce {
1887
1831
  if (a === void 0 || !a.satisfiesDef(o)) return;
1888
1832
  s?.();
1889
1833
  const c = a.getProxy(o);
1890
- this.instance.onEvent(e, c, a.data, n);
1834
+ this.instance.onEvent(e, c, a.data, i);
1891
1835
  }
1892
1836
  destroy() {
1893
1837
  this._queryClient.unregisterLiveCollection(this);
@@ -1895,44 +1839,44 @@ class ce {
1895
1839
  e !== -1 && t.splice(e, 1);
1896
1840
  }
1897
1841
  }
1898
- class vi {
1842
+ class mn {
1899
1843
  _notifier;
1900
1844
  _items;
1901
1845
  _keys;
1902
1846
  _outputSignal;
1903
1847
  _queryClient;
1904
1848
  _parent;
1905
- constructor(t, e, n, s, r, o) {
1906
- this._notifier = at(), this._items = n, this._keys = Nt(n), this._queryClient = t, this._parent = e;
1849
+ constructor(t, e, i, s, r, o) {
1850
+ this._notifier = at(), this._items = i, this._keys = At(i), this._queryClient = t, this._parent = e;
1907
1851
  const a = s !== void 0 && r !== void 0, c = o !== void 0;
1908
- (a || c) && (this._outputSignal = me(() => {
1852
+ (a || c) && (this._outputSignal = _e(() => {
1909
1853
  this._notifier.consume();
1910
1854
  let f = this._items;
1911
1855
  if (a) {
1912
- const l = [];
1913
- for (const d of f) {
1914
- if (typeof d != "object" || d === null) {
1915
- l.push(d);
1856
+ const d = [];
1857
+ for (const u of f) {
1858
+ if (typeof u != "object" || u === null) {
1859
+ d.push(u);
1916
1860
  continue;
1917
1861
  }
1918
- const y = F(d);
1862
+ const y = k(u);
1919
1863
  if (y === void 0) {
1920
- l.push(d);
1864
+ d.push(u);
1921
1865
  continue;
1922
1866
  }
1923
1867
  const v = t.entityMap.getEntity(y);
1924
1868
  if (v === void 0) {
1925
- l.push(d);
1869
+ d.push(u);
1926
1870
  continue;
1927
1871
  }
1928
- v.consume(), ae(v.data, s) === r && l.push(d);
1872
+ v.consume(), oe(v.data, s) === r && d.push(u);
1929
1873
  }
1930
- f = l;
1874
+ f = d;
1931
1875
  }
1932
1876
  return c && (f = (f === this._items ? f.slice() : f).sort(o)), f;
1933
1877
  }));
1934
1878
  }
1935
- onEvent(t, e, n, s) {
1879
+ onEvent(t, e, i, s) {
1936
1880
  switch (s) {
1937
1881
  case "create":
1938
1882
  this.add(t, e);
@@ -1954,26 +1898,26 @@ class vi {
1954
1898
  add(t, e) {
1955
1899
  if (this._keys.has(t)) return !1;
1956
1900
  this._keys.add(t), this._items.push(e);
1957
- const n = this._queryClient.entityMap.getEntity(t);
1958
- return n !== void 0 && (this._parent.addChildRef(n), n.save()), this._notifier.notify(), !0;
1901
+ const i = this._queryClient.entityMap.getEntity(t);
1902
+ return i !== void 0 && (this._parent.addChildRef(i), i.save()), this._notifier.notify(), !0;
1959
1903
  }
1960
1904
  remove(t) {
1961
1905
  if (!this._keys.has(t)) return !1;
1962
1906
  this._keys.delete(t);
1963
1907
  const e = this._findIndex(t);
1964
1908
  e !== -1 && this._items.splice(e, 1);
1965
- const n = this._queryClient.entityMap.getEntity(t);
1966
- return n !== void 0 && this._parent.removeChildRef(n), this._notifier.notify(), !0;
1909
+ const i = this._queryClient.entityMap.getEntity(t);
1910
+ return i !== void 0 && this._parent.removeChildRef(i), this._notifier.notify(), !0;
1967
1911
  }
1968
1912
  has(t) {
1969
1913
  return this._keys.has(t);
1970
1914
  }
1971
1915
  reset(t) {
1972
- const e = this._items, n = Array.isArray(t) ? t : [];
1973
- this._items = n, this._keys = Nt(n);
1974
- for (const s of n)
1916
+ const e = this._items, i = Array.isArray(t) ? t : [];
1917
+ this._items = i, this._keys = At(i);
1918
+ for (const s of i)
1975
1919
  if (typeof s == "object" && s !== null) {
1976
- const r = F(s);
1920
+ const r = k(s);
1977
1921
  if (r !== void 0) {
1978
1922
  const o = this._queryClient.entityMap.getEntity(r);
1979
1923
  o !== void 0 && this._parent.addChildRef(o);
@@ -1981,7 +1925,7 @@ class vi {
1981
1925
  }
1982
1926
  for (const s of e)
1983
1927
  if (typeof s == "object" && s !== null) {
1984
- const r = F(s);
1928
+ const r = k(s);
1985
1929
  if (r !== void 0) {
1986
1930
  const o = this._queryClient.entityMap.getEntity(r);
1987
1931
  o !== void 0 && this._parent.removeChildRef(o);
@@ -1993,20 +1937,20 @@ class vi {
1993
1937
  if (Array.isArray(t))
1994
1938
  for (const e of t) {
1995
1939
  if (typeof e != "object" || e === null) continue;
1996
- const n = F(e);
1997
- n !== void 0 && this.add(n, e);
1940
+ const i = k(e);
1941
+ i !== void 0 && this.add(i, e);
1998
1942
  }
1999
1943
  }
2000
1944
  _findIndex(t) {
2001
1945
  for (let e = 0; e < this._items.length; e++) {
2002
- const n = this._items[e];
2003
- if (typeof n == "object" && n !== null && F(n) === t)
1946
+ const i = this._items[e];
1947
+ if (typeof i == "object" && i !== null && k(i) === t)
2004
1948
  return e;
2005
1949
  }
2006
1950
  return -1;
2007
1951
  }
2008
1952
  }
2009
- class _i {
1953
+ class wn {
2010
1954
  _notifier;
2011
1955
  _value;
2012
1956
  _createdKeys;
@@ -2016,21 +1960,21 @@ class _i {
2016
1960
  _onCreate;
2017
1961
  _onUpdate;
2018
1962
  _onDelete;
2019
- constructor(t, e, n, s, r, o) {
2020
- this._notifier = at(), this._value = n, this._createdKeys = /* @__PURE__ */ new Set(), this._deletedKeys = /* @__PURE__ */ new Set(), this._queryClient = t, this._parent = e, this._onCreate = s, this._onUpdate = r, this._onDelete = o;
1963
+ constructor(t, e, i, s, r, o) {
1964
+ this._notifier = at(), this._value = i, this._createdKeys = /* @__PURE__ */ new Set(), this._deletedKeys = /* @__PURE__ */ new Set(), this._queryClient = t, this._parent = e, this._onCreate = s, this._onUpdate = r, this._onDelete = o;
2021
1965
  }
2022
- onEvent(t, e, n, s) {
1966
+ onEvent(t, e, i, s) {
2023
1967
  switch (s) {
2024
1968
  case "create":
2025
1969
  if (this._createdKeys.has(t)) return;
2026
1970
  this._createdKeys.add(t), this._value = this._onCreate(this._value, e);
2027
1971
  break;
2028
1972
  case "update":
2029
- this._value = this._onUpdate(this._value, e ?? n);
1973
+ this._value = this._onUpdate(this._value, e ?? i);
2030
1974
  break;
2031
1975
  case "delete":
2032
1976
  if (this._deletedKeys.has(t)) return;
2033
- this._deletedKeys.add(t), this._value = this._onDelete(this._value, e ?? n);
1977
+ this._deletedKeys.add(t), this._value = this._onDelete(this._value, e ?? i);
2034
1978
  break;
2035
1979
  }
2036
1980
  this._notifier.notify();
@@ -2047,48 +1991,48 @@ class _i {
2047
1991
  append(t) {
2048
1992
  }
2049
1993
  }
2050
- function fe(i, t, e, n, s) {
2051
- let r = i.constraintFieldRefs;
1994
+ function ce(n, t, e, i, s) {
1995
+ let r = n.constraintFieldRefs;
2052
1996
  if (r === void 0) {
2053
1997
  r = /* @__PURE__ */ new Map();
2054
- for (const f of i.entityDefs) {
2055
- const l = f.typenameValue;
2056
- l !== void 0 && r.set(l, [[re, e.key]]);
1998
+ for (const f of n.entityDefs) {
1999
+ const d = f.typenameValue;
2000
+ d !== void 0 && r.set(d, [[se, e.key]]);
2057
2001
  }
2058
2002
  }
2059
- const o = yi(r, n) ?? /* @__PURE__ */ new Map();
2003
+ const o = gn(r, i) ?? /* @__PURE__ */ new Map();
2060
2004
  let a;
2061
- if (i.type === ct.Array) {
2062
- let f, l;
2063
- if (i.constraintFieldRefs !== void 0 && o.size > 0 && o.size === 1)
2064
- for (const [d] of i.constraintFieldRefs) {
2065
- const y = o.get(d);
2005
+ if (n.type === ct.Array) {
2006
+ let f, d;
2007
+ if (n.constraintFieldRefs !== void 0 && o.size > 0 && o.size === 1)
2008
+ for (const [u] of n.constraintFieldRefs) {
2009
+ const y = o.get(u);
2066
2010
  if (y !== void 0) {
2067
- l = y;
2068
- const v = i.constraintFieldRefs.get(d);
2069
- v !== void 0 && (f = li(v.map(([p]) => p)));
2011
+ d = y;
2012
+ const v = n.constraintFieldRefs.get(u);
2013
+ v !== void 0 && (f = yn(v.map(([p]) => p)));
2070
2014
  break;
2071
2015
  }
2072
2016
  }
2073
- a = new vi(
2017
+ a = new mn(
2074
2018
  s,
2075
2019
  e,
2076
2020
  Array.isArray(t) ? t : [],
2077
2021
  f,
2078
- l,
2079
- i.sort
2022
+ d,
2023
+ n.sort
2080
2024
  );
2081
2025
  } else
2082
- a = new _i(
2026
+ a = new wn(
2083
2027
  s,
2084
2028
  e,
2085
2029
  t,
2086
- i.onCreate,
2087
- i.onUpdate,
2088
- i.onDelete
2030
+ n.onCreate,
2031
+ n.onUpdate,
2032
+ n.onDelete
2089
2033
  );
2090
- const c = new ce(
2091
- i.entityDefs,
2034
+ const c = new ae(
2035
+ n.entityDefs,
2092
2036
  r,
2093
2037
  s,
2094
2038
  e,
@@ -2097,85 +2041,85 @@ function fe(i, t, e, n, s) {
2097
2041
  );
2098
2042
  return e.liveCollections.push(c), s.registerLiveCollection(c), c;
2099
2043
  }
2100
- const ue = Object.entries, de = Object.prototype;
2101
- function tt(i, t, e, n = !1) {
2102
- const s = i.queryClient;
2044
+ const fe = Object.entries, ue = Object.prototype;
2045
+ function tt(n, t, e, i = !1) {
2046
+ const s = n.queryClient;
2103
2047
  s.currentParseId++;
2104
- const r = i.seen, o = /* @__PURE__ */ new Map();
2105
- return { data: K(t, r, s, e, o, n), entityRefs: o };
2048
+ const r = n.seen, o = /* @__PURE__ */ new Map();
2049
+ return { data: U(t, r, s, e, o, i), entityRefs: o };
2106
2050
  }
2107
- function K(i, t, e, n, s, r) {
2108
- if (typeof i != "object" || i === null) return i;
2109
- const o = t.get(i);
2051
+ function U(n, t, e, i, s, r) {
2052
+ if (typeof n != "object" || n === null) return n;
2053
+ const o = t.get(n);
2110
2054
  if (o !== void 0)
2111
- return mi(o, t, e, n, s, r);
2112
- if (Array.isArray(i)) {
2113
- for (let a = 0; a < i.length; a++) {
2114
- const c = i[a];
2115
- typeof c == "object" && c !== null && !(c instanceof V) && !O.has(c) && (i[a] = K(c, t, e, n, s, r));
2055
+ return En(o, t, e, i, s, r);
2056
+ if (Array.isArray(n)) {
2057
+ for (let a = 0; a < n.length; a++) {
2058
+ const c = n[a];
2059
+ typeof c == "object" && c !== null && !(c instanceof q) && !x.has(c) && (n[a] = U(c, t, e, i, s, r));
2116
2060
  }
2117
- return i;
2061
+ return n;
2118
2062
  }
2119
- if (Object.getPrototypeOf(i) === de && !O.has(i)) {
2120
- const a = i;
2063
+ if (Object.getPrototypeOf(n) === ue && !x.has(n)) {
2064
+ const a = n;
2121
2065
  for (const c of Object.keys(a)) {
2122
2066
  const f = a[c];
2123
- typeof f == "object" && f !== null && !(f instanceof V) && !O.has(f) && (a[c] = K(f, t, e, n, s, r));
2067
+ typeof f == "object" && f !== null && !(f instanceof q) && !x.has(f) && (a[c] = U(f, t, e, i, s, r));
2124
2068
  }
2125
2069
  }
2126
- return i;
2070
+ return n;
2127
2071
  }
2128
- function le(i) {
2129
- return typeof i == "object" && i !== null && !(i instanceof V) && !O.has(i);
2072
+ function le(n) {
2073
+ return typeof n == "object" && n !== null && !(n instanceof q) && !x.has(n);
2130
2074
  }
2131
- function mi(i, t, e, n, s, r) {
2132
- const { key: o, data: a, shape: c, rawKeys: f } = i, l = c.shape, d = e.prepareEntity(o, a, c), y = d.data, v = y !== a, p = v && f !== void 0 && d.entityRefs !== void 0 ? new Map(d.entityRefs) : /* @__PURE__ */ new Map();
2133
- if (v ? (he(
2134
- l,
2075
+ function En(n, t, e, i, s, r) {
2076
+ const { key: o, data: a, shape: c, rawKeys: f } = n, d = c.shape, u = e.prepareEntity(o, a, c), y = u.data, v = y !== a, p = v && f !== void 0 && u.entityRefs !== void 0 ? new Map(u.entityRefs) : /* @__PURE__ */ new Map();
2077
+ if (v ? (de(
2078
+ d,
2135
2079
  a,
2136
2080
  y,
2137
2081
  f,
2138
- d,
2082
+ u,
2139
2083
  y,
2140
2084
  t,
2141
2085
  e,
2142
- n,
2086
+ i,
2143
2087
  p,
2144
2088
  r
2145
- ), d.notify()) : ye(l, a, d, a, t, e, n, p, r), r && d.liveCollections.length > 0)
2146
- for (const E of d.liveCollections) {
2147
- const S = E.instance.getRawValue();
2148
- if (Array.isArray(S))
2149
- for (const C of S) {
2150
- if (typeof C != "object" || C === null) continue;
2151
- const I = O.get(C);
2152
- if (I === void 0) continue;
2153
- const x = e.entityMap.getEntity(I);
2154
- x !== void 0 && p.set(x, (p.get(x) ?? 0) + 1);
2089
+ ), u.notify()) : he(d, a, u, a, t, e, i, p, r), r && u.liveCollections.length > 0)
2090
+ for (const w of u.liveCollections) {
2091
+ const I = w.instance.getRawValue();
2092
+ if (Array.isArray(I))
2093
+ for (const O of I) {
2094
+ if (typeof O != "object" || O === null) continue;
2095
+ const K = x.get(O);
2096
+ if (K === void 0) continue;
2097
+ const R = e.entityMap.getEntity(K);
2098
+ R !== void 0 && p.set(R, (p.get(R) ?? 0) + 1);
2155
2099
  }
2156
2100
  }
2157
- d.setChildRefs(p.size > 0 ? p : void 0, n);
2158
- const g = d.getProxy(c);
2159
- return s.set(d, (s.get(d) ?? 0) + 1), g;
2160
- }
2161
- function he(i, t, e, n, s, r, o, a, c, f, l) {
2162
- for (const [d, y] of ue(i))
2163
- if (!(n !== void 0 && !n.has(d)))
2164
- if (le(t[d]) && (t[d] = K(t[d], o, a, c, f, l)), y instanceof _ && y._liveConfig !== void 0) {
2165
- const v = e[d];
2166
- v instanceof ce ? l ? v.append(t[d]) : v.reset(t[d]) : e[d] = fe(
2101
+ u.setChildRefs(p.size > 0 ? p : void 0, i);
2102
+ const g = u.getProxy(c);
2103
+ return s.set(u, (s.get(u) ?? 0) + 1), g;
2104
+ }
2105
+ function de(n, t, e, i, s, r, o, a, c, f, d) {
2106
+ for (const [u, y] of fe(n))
2107
+ if (!(i !== void 0 && !i.has(u)))
2108
+ if (le(t[u]) && (t[u] = U(t[u], o, a, c, f, d)), y instanceof _ && y._liveConfig !== void 0) {
2109
+ const v = e[u];
2110
+ v instanceof ae ? d ? v.append(t[u]) : v.reset(t[u]) : e[u] = ce(
2167
2111
  y._liveConfig,
2168
- t[d],
2112
+ t[u],
2169
2113
  s,
2170
2114
  r,
2171
2115
  a
2172
2116
  );
2173
2117
  } else {
2174
- const v = t[d], p = e[d];
2118
+ const v = t[u], p = e[u];
2175
2119
  if (ot(v) && ot(p)) {
2176
2120
  const g = y instanceof _ && y.shape !== void 0 ? y.shape : void 0;
2177
2121
  if (g !== void 0)
2178
- he(
2122
+ de(
2179
2123
  g,
2180
2124
  v,
2181
2125
  p,
@@ -2186,58 +2130,55 @@ function he(i, t, e, n, s, r, o, a, c, f, l) {
2186
2130
  a,
2187
2131
  c,
2188
2132
  f,
2189
- l
2133
+ d
2190
2134
  );
2191
2135
  else
2192
- for (const E of Object.keys(v))
2193
- p[E] = v[E];
2194
- e[d] = p;
2136
+ for (const w of Object.keys(v))
2137
+ p[w] = v[w];
2138
+ e[u] = p;
2195
2139
  } else
2196
- e[d] = v;
2140
+ e[u] = v;
2197
2141
  }
2198
2142
  }
2199
- function ye(i, t, e, n, s, r, o, a, c) {
2200
- for (const [f, l] of ue(i))
2143
+ function he(n, t, e, i, s, r, o, a, c) {
2144
+ for (const [f, d] of fe(n))
2201
2145
  if (f in t)
2202
- if (le(t[f]) && (t[f] = K(t[f], s, r, o, a, c)), l instanceof _ && l._liveConfig !== void 0)
2203
- t[f] = fe(
2204
- l._liveConfig,
2146
+ if (le(t[f]) && (t[f] = U(t[f], s, r, o, a, c)), d instanceof _ && d._liveConfig !== void 0)
2147
+ t[f] = ce(
2148
+ d._liveConfig,
2205
2149
  t[f],
2206
2150
  e,
2207
- n,
2151
+ i,
2208
2152
  r
2209
2153
  );
2210
2154
  else {
2211
- const d = t[f];
2212
- if (ot(d)) {
2213
- const y = l instanceof _ && l.shape !== void 0 ? l.shape : void 0;
2214
- y !== void 0 && ye(y, d, e, n, s, r, o, a, c);
2155
+ const u = t[f];
2156
+ if (ot(u)) {
2157
+ const y = d instanceof _ && d.shape !== void 0 ? d.shape : void 0;
2158
+ y !== void 0 && he(y, u, e, i, s, r, o, a, c);
2215
2159
  }
2216
2160
  }
2217
2161
  }
2218
- function ot(i) {
2219
- return typeof i == "object" && i !== null && !Array.isArray(i) && Object.getPrototypeOf(i) === de && !O.has(i);
2162
+ function ot(n) {
2163
+ return typeof n == "object" && n !== null && !Array.isArray(n) && Object.getPrototypeOf(n) === ue && !x.has(n);
2220
2164
  }
2221
- function Dt(i) {
2222
- if (i !== void 0)
2223
- return typeof i == "string" ? i : typeof i == "function" ? i() : i.value;
2165
+ function Fn(n) {
2166
+ if (n !== void 0)
2167
+ return typeof n == "string" ? n : typeof n == "function" ? n() : n.value;
2224
2168
  }
2225
- function Ei(i) {
2226
- return Ee(i);
2169
+ function Cn(n) {
2170
+ return me(n);
2227
2171
  }
2228
- function At(i) {
2229
- if (i === void 0)
2172
+ function Dt(n) {
2173
+ if (n === void 0)
2230
2174
  return;
2231
2175
  const t = {};
2232
- for (const [e, n] of Object.entries(i))
2233
- Ei(n) ? t[e] = n.value : t[e] = n;
2176
+ for (const [e, i] of Object.entries(n))
2177
+ Cn(i) ? t[e] = i.value : t[e] = i;
2234
2178
  return t;
2235
2179
  }
2236
- const vt = (i, t) => A([i.statics.id, t]);
2237
- class Ai {
2238
- constructor(t, e = { fetch, log: console }, n, s) {
2239
- this.context = e, this.isServer = typeof window > "u", this.store = t, this.gcManager = s ?? (this.isServer ? new xe() : new Ce(this.handleEviction, this.context.evictionMultiplier)), this.networkManager = n ?? new ie(), this.entityMap = new oi((r, o, a) => this.store.saveEntity(r, o, a)), this.store.purgeStaleQueries?.();
2240
- }
2180
+ const vt = (n, t) => D([n.statics.id, t]);
2181
+ class Tn {
2241
2182
  entityMap;
2242
2183
  queryInstances = /* @__PURE__ */ new Map();
2243
2184
  mutationInstances = /* @__PURE__ */ new Map();
@@ -2246,9 +2187,53 @@ class Ai {
2246
2187
  isServer;
2247
2188
  store;
2248
2189
  currentParseId = 0;
2190
+ context;
2249
2191
  typenameRegistry = /* @__PURE__ */ new Map();
2250
2192
  constraintRegistry = /* @__PURE__ */ new Map();
2251
2193
  mergedDefCache = /* @__PURE__ */ new Map();
2194
+ controllers = /* @__PURE__ */ new Map();
2195
+ networkUnsubscribe;
2196
+ constructor(t = {}) {
2197
+ const {
2198
+ store: e = new Ce(new be()),
2199
+ log: i,
2200
+ evictionMultiplier: s,
2201
+ controllers: r,
2202
+ networkManager: o,
2203
+ gcManager: a,
2204
+ ...c
2205
+ } = t;
2206
+ this.isServer = typeof window > "u", this.store = e, this.context = { ...c, log: i ?? console, evictionMultiplier: s }, this.gcManager = t.gcManager ?? (this.isServer ? new Re() : new Oe(this.handleEviction, s)), this.networkManager = t.networkManager ?? new ee(), this.entityMap = new fn((u, y, v) => this.store.saveEntity(u, y, v));
2207
+ for (const u of t.controllers ?? [])
2208
+ this.controllers.set(u.constructor, u), u.register(this);
2209
+ const f = this.networkManager.getOnlineSignal(), d = we(() => f.value);
2210
+ this.networkUnsubscribe = d.addListener(
2211
+ () => {
2212
+ const u = f.value;
2213
+ for (const y of this.controllers.values())
2214
+ y.onNetworkStatusChange?.(u);
2215
+ },
2216
+ { skipInitial: !0 }
2217
+ ), this.store.purgeStaleQueries?.();
2218
+ }
2219
+ /**
2220
+ * Returns the registered controller instance for the given controller class.
2221
+ * Throws if no controller of that class has been registered.
2222
+ */
2223
+ getController(t) {
2224
+ let e = this.controllers.get(t);
2225
+ if (!e) {
2226
+ try {
2227
+ e = new t();
2228
+ } catch {
2229
+ throw new Error(
2230
+ `No controller registered for ${t.name} and auto-instantiation failed. Pass an instance via QueryClient config: new QueryClient({ store, controllers: [new ${t.name}(...)] })`
2231
+ );
2232
+ }
2233
+ this.controllers.set(t, e), e.register(this);
2234
+ }
2235
+ return e;
2236
+ }
2252
2237
  getContext() {
2253
2238
  return this.context;
2254
2239
  }
@@ -2258,10 +2243,10 @@ class Ai {
2258
2243
  registerEntityDef(t) {
2259
2244
  const e = t.typenameValue;
2260
2245
  if (e === void 0 || t._entityClass === void 0) return;
2261
- const n = this.typenameRegistry.get(e);
2262
- if (n !== void 0) {
2263
- if (n.indexOf(t) !== -1) return;
2264
- n.push(t), this.mergedDefCache.delete(e), this.getMergedDef(e);
2246
+ const i = this.typenameRegistry.get(e);
2247
+ if (i !== void 0) {
2248
+ if (i.indexOf(t) !== -1) return;
2249
+ i.push(t), this.mergedDefCache.delete(e), this.getMergedDef(e);
2265
2250
  } else
2266
2251
  this.typenameRegistry.set(e, [t]);
2267
2252
  }
@@ -2271,19 +2256,19 @@ class Ai {
2271
2256
  getMergedDef(t) {
2272
2257
  let e = this.mergedDefCache.get(t);
2273
2258
  if (e !== void 0) return e;
2274
- const n = this.typenameRegistry.get(t);
2275
- if (n !== void 0)
2276
- return e = _.merge(n), this.mergedDefCache.set(t, e), e;
2259
+ const i = this.typenameRegistry.get(t);
2260
+ if (i !== void 0)
2261
+ return e = _.merge(i), this.mergedDefCache.set(t, e), e;
2277
2262
  }
2278
- saveQueryData(t, e, n, s, r) {
2263
+ saveQueryData(t, e, i, s, r) {
2279
2264
  const o = r !== void 0 && r.size > 0 ? new Set([...r.keys()].map((a) => a.key)) : void 0;
2280
- this.store.saveQuery(t, e, n, s, o);
2265
+ this.store.saveQuery(t, e, i, s, o);
2281
2266
  }
2282
2267
  activateQuery(t) {
2283
- const { def: e, queryKey: n, storageKey: s, config: r } = t;
2268
+ const { def: e, queryKey: i, storageKey: s, config: r } = t;
2284
2269
  this.store.activateQuery(e, s);
2285
- const o = r?.gcTime ?? Ft;
2286
- this.gcManager.cancel(n, o);
2270
+ const o = r?.gcTime ?? kt;
2271
+ this.gcManager.cancel(i, o);
2287
2272
  }
2288
2273
  loadCachedQuery(t, e) {
2289
2274
  return this.store.loadQuery(t, e);
@@ -2293,9 +2278,9 @@ class Ai {
2293
2278
  * that triggers fetches and prepopulates with cached data
2294
2279
  */
2295
2280
  getQuery(t, e) {
2296
- const n = vt(t, e);
2297
- let s = this.queryInstances.get(n);
2298
- return s === void 0 && (s = new fi(t, this, n, e), this.queryInstances.set(n, s)), s.relay;
2281
+ const i = vt(t, e);
2282
+ let s = this.queryInstances.get(i);
2283
+ return s === void 0 && (s = new ln(t, this, i, e), this.queryInstances.set(i, s)), s.relay;
2299
2284
  }
2300
2285
  /**
2301
2286
  * Gets or creates a MutationResult for the given mutation definition.
@@ -2303,151 +2288,170 @@ class Ai {
2303
2288
  */
2304
2289
  getMutation(t) {
2305
2290
  const e = t.id;
2306
- let n = this.mutationInstances.get(e);
2307
- return n === void 0 && (n = new ui(t, this), this.mutationInstances.set(e, n)), n.task;
2291
+ let i = this.mutationInstances.get(e);
2292
+ return i === void 0 && (i = new dn(t, this), this.mutationInstances.set(e, i)), i.task;
2308
2293
  }
2309
2294
  /**
2310
2295
  * Parse data: validates, formats, produces parsed entity data objects.
2311
2296
  * Does NOT touch the entity store. Call applyRefs() after to commit entities.
2312
2297
  */
2313
- parseData(t, e, n) {
2298
+ parseData(t, e, i) {
2314
2299
  const s = this.context.log?.warn ?? (() => {
2315
2300
  }), r = new st();
2316
- return r.reset(this, n, s), { data: Xt(t, e, r), ctx: r };
2301
+ return r.reset(this, i, s), { data: Jt(t, e, r), ctx: r };
2317
2302
  }
2318
2303
  /**
2319
2304
  * Apply entities from parseData() via a single depth-first walk: creates/
2320
2305
  * updates EntityInstances, replaces parsed data with proxies, counts child
2321
2306
  * refs. Returns the reified data and root-level entity refs.
2322
2307
  */
2323
- applyRefs(t, e = !0, n = !1) {
2324
- return tt(t.ctx, t.data, e, n);
2308
+ applyRefs(t, e = !0, i = !1) {
2309
+ return tt(t.ctx, t.data, e, i);
2325
2310
  }
2326
2311
  /**
2327
2312
  * Parse and apply data as a root entity. For non-entity results, injects
2328
2313
  * QUERY_ID onto the payload. Returns the root EntityInstance (created or
2329
2314
  * found in the store by the standard entity pipeline).
2330
2315
  */
2331
- parseAndApplyRootEntity(t, e, n, s, r = !1, o) {
2332
- typeof n.idField == "symbol" && typeof t == "object" && t !== null && !("__entityRef" in t) && (t[kt] = e);
2333
- const a = this.parseData(t, n, o), c = tt(a.ctx, a.data, s, r), f = O.get(c.data);
2316
+ parseAndApplyRootEntity(t, e, i, s, r = !1, o) {
2317
+ typeof i.idField == "symbol" && typeof t == "object" && t !== null && !("__entityRef" in t) && (t[Ft] = e);
2318
+ const a = this.parseData(t, i, o), c = tt(a.ctx, a.data, s, r), f = x.get(c.data);
2334
2319
  return this.entityMap.getEntity(f);
2335
2320
  }
2336
- prepareEntity(t, e, n) {
2337
- return this.registerEntityDef(n), this.entityMap.getOrCreateEntity(t, e, n, this);
2321
+ prepareEntity(t, e, i) {
2322
+ return this.registerEntityDef(i), this.entityMap.getOrCreateEntity(t, e, i, this);
2338
2323
  }
2339
2324
  // ======================================================
2340
2325
  // Mutation Events
2341
2326
  // ======================================================
2342
2327
  applyMutationEvent(t) {
2343
- const { type: e, typename: n } = t, s = this.getMergedDef(n);
2328
+ const { type: e, typename: i } = t, s = this.getMergedDef(i);
2344
2329
  if (s === void 0) return;
2345
2330
  const r = s.idField;
2346
2331
  if (r === void 0 || typeof r == "symbol") return;
2347
2332
  const o = t.data, a = t.id !== void 0 ? t.id : e === "delete" && (typeof o == "string" || typeof o == "number") ? o : o[r];
2348
2333
  if (a === void 0) return;
2349
- const c = A([n, a]), f = t.__eventSource, l = typeof o == "object" && o !== null ? o : {}, d = this.entityMap.getEntity(c);
2334
+ const c = D([i, a]), f = t.__eventSource, d = typeof o == "object" && o !== null ? o : {}, u = this.entityMap.getEntity(c);
2350
2335
  if (e === "delete") {
2351
- const g = d !== void 0 ? d.data : l;
2352
- this.routeEvent(n, g, c, e, f, void 0, g);
2336
+ const g = u !== void 0 ? u.data : d;
2337
+ this.routeEvent(i, g, c, e, f, void 0, g);
2353
2338
  return;
2354
2339
  }
2355
2340
  try {
2356
2341
  const g = this.context.log?.warn ?? (() => {
2357
- }), E = new st();
2358
- E.reset(
2342
+ }), w = new st();
2343
+ w.reset(
2359
2344
  this,
2360
2345
  void 0,
2361
2346
  g,
2362
2347
  /* isPartialEvent */
2363
2348
  !0
2364
2349
  );
2365
- const S = ze(l, s, E);
2366
- tt(E, S, !0);
2350
+ const I = Xe(d, s, w);
2351
+ tt(w, I, !0);
2367
2352
  } catch (g) {
2368
- if (this.context.log?.warn?.("Failed to apply mutation event", g), d === void 0) {
2369
- const E = this.entityMap.getEntity(c);
2370
- E !== void 0 && E.evict();
2353
+ if (this.context.log?.warn?.("Failed to apply mutation event", g), u === void 0) {
2354
+ const w = this.entityMap.getEntity(c);
2355
+ w !== void 0 && w.evict();
2371
2356
  }
2372
2357
  return;
2373
2358
  }
2374
2359
  const y = this.entityMap.getEntity(c);
2375
2360
  if (y === void 0) return;
2376
2361
  this.entityMap.save(y);
2377
- const v = d === void 0;
2362
+ const v = u === void 0;
2378
2363
  let p = !1;
2379
- this.routeEvent(n, y.data, c, e, f, () => {
2364
+ this.routeEvent(i, y.data, c, e, f, () => {
2380
2365
  p = !0;
2381
2366
  }), v && !p && y.evict();
2382
2367
  }
2383
2368
  // ======================================================
2369
+ // Query Invalidation
2370
+ // ======================================================
2371
+ invalidateQueries(t) {
2372
+ for (const e of t) {
2373
+ const i = Array.isArray(e), s = i ? e[0] : e, r = i ? e[1] : void 0, a = V.for(s).statics.id;
2374
+ for (const [, c] of this.queryInstances)
2375
+ c.def.statics.id === a && (r === void 0 || xn(c.resolvedParams, r)) && c.markStale();
2376
+ }
2377
+ }
2378
+ // ======================================================
2384
2379
  // In-Memory GC
2385
2380
  // ======================================================
2386
2381
  handleEviction = (t, e) => {
2387
- if (e === W.Query) {
2382
+ if (e === z.Query) {
2388
2383
  const s = this.queryInstances.get(t);
2389
2384
  if (s === void 0) return;
2390
2385
  s.rootEntity?.evict(), this.queryInstances.delete(t);
2391
2386
  return;
2392
2387
  }
2393
- const n = this.entityMap.getEntity(t);
2394
- n !== void 0 && n.evict();
2388
+ const i = this.entityMap.getEntity(t);
2389
+ i !== void 0 && i.evict();
2395
2390
  };
2396
2391
  // ======================================================
2397
- // Constraint Registry (Live Collections)
2392
+ // Constraint Registry (Live Data)
2398
2393
  // ======================================================
2399
2394
  getOrCreateMatcher(t) {
2400
2395
  let e = this.constraintRegistry.get(t);
2401
- return e === void 0 && (e = new gi(), this.constraintRegistry.set(t, e)), e;
2396
+ return e === void 0 && (e = new _n(), this.constraintRegistry.set(t, e)), e;
2402
2397
  }
2403
2398
  registerLiveCollection(t) {
2404
- for (const [e, n] of t._entityDefsByTypename)
2405
- this.registerEntityDef(n), this.getOrCreateMatcher(e).registerBinding(t, e);
2399
+ for (const [e, i] of t._entityDefsByTypename)
2400
+ this.registerEntityDef(i), this.getOrCreateMatcher(e).registerBinding(t, e);
2406
2401
  }
2407
2402
  unregisterLiveCollection(t) {
2408
2403
  for (const e of t._entityDefsByTypename.keys()) {
2409
- const n = this.constraintRegistry.get(e);
2410
- n !== void 0 && n.unregisterBinding(t, e);
2404
+ const i = this.constraintRegistry.get(e);
2405
+ i !== void 0 && i.unregisterBinding(t, e);
2411
2406
  }
2412
2407
  }
2413
- routeEvent(t, e, n, s, r, o, a) {
2408
+ routeEvent(t, e, i, s, r, o, a) {
2414
2409
  const c = this.constraintRegistry.get(t);
2415
2410
  if (c === void 0) return;
2416
- const f = r !== void 0 ? { ...e, [re]: r } : e;
2417
- c.routeEvent(t, f, n, s, o, a);
2411
+ const f = r !== void 0 ? { ...e, [se]: r } : e;
2412
+ c.routeEvent(t, f, i, s, o, a);
2418
2413
  }
2419
2414
  destroy() {
2420
- this.gcManager.destroy(), this.networkManager.destroy(), this.queryInstances.clear(), this.mutationInstances.clear(), this.constraintRegistry.clear(), this.typenameRegistry.clear(), this.mergedDefCache.clear();
2415
+ this.networkUnsubscribe?.(), this.gcManager.destroy(), this.networkManager.destroy();
2416
+ for (const t of this.controllers.values())
2417
+ t.destroy?.();
2418
+ this.controllers.clear(), this.queryInstances.clear(), this.mutationInstances.clear(), this.constraintRegistry.clear(), this.typenameRegistry.clear(), this.mergedDefCache.clear();
2421
2419
  }
2422
2420
  }
2423
- const wi = Tt(void 0);
2421
+ const bn = Mt(void 0);
2422
+ function xn(n, t) {
2423
+ if (n === void 0) return !1;
2424
+ for (const e in t)
2425
+ if (n[e] !== t[e]) return !1;
2426
+ return !0;
2427
+ }
2424
2428
  export {
2425
- B as A,
2426
- Ut as E,
2427
- Ce as G,
2428
- ct as L,
2429
- u as M,
2430
- ie as N,
2431
- wi as Q,
2432
- Si as R,
2429
+ Q as A,
2430
+ qt as E,
2431
+ Oe as G,
2432
+ j as L,
2433
+ l as M,
2434
+ ee as N,
2435
+ Ft as Q,
2436
+ B as R,
2433
2437
  _ as V,
2434
- Ai as a,
2435
- Wt as b,
2436
- qt as c,
2437
- ci as d,
2438
- Se as e,
2439
- Di as f,
2440
- Ri as g,
2441
- ne as h,
2442
- ai as i,
2443
- Oi as j,
2444
- xe as k,
2445
- q as l,
2446
- Q as m,
2447
- kt as n,
2448
- U as o,
2449
- Ni as q,
2450
- Dt as r,
2451
- We as t
2438
+ ct as a,
2439
+ In as b,
2440
+ L as c,
2441
+ Re as d,
2442
+ ne as e,
2443
+ Nn as f,
2444
+ Tn as g,
2445
+ bn as h,
2446
+ un as i,
2447
+ Dn as j,
2448
+ kn as k,
2449
+ jt as l,
2450
+ De as m,
2451
+ W as n,
2452
+ Fn as o,
2453
+ Mn as q,
2454
+ Gt as r,
2455
+ He as t
2452
2456
  };
2453
- //# sourceMappingURL=QueryClient-BP0Z1rQV.js.map
2457
+ //# sourceMappingURL=QueryClient-YqnBxFy1.js.map