@statezero/core 0.2.52 → 0.2.54

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,31 +1,31 @@
1
- import { ref as J, computed as R, onMounted as hs, onBeforeUnmount as fs, watch as it, createElementBlock as $, openBlock as A, createElementVNode as h, createVNode as Tt, toDisplayString as S, createCommentVNode as V, Fragment as W, renderList as ce, normalizeClass as Mt, normalizeStyle as at, withDirectives as Qe, createTextVNode as Ve, vModelCheckbox as $t, vModelSelect as At, Transition as Ot, withCtx as Pt } from "vue";
2
- import { v7 as G } from "uuid";
3
- import { isNil as E, isEmpty as ve, trim as dt, isEqual as qe } from "lodash-es";
4
- import Ae from "mitt";
5
- import It from "handlebars";
6
- import Ft from "superjson";
1
+ import { ref as J, computed as I, onMounted as hs, onBeforeUnmount as fs, watch as ot, createElementBlock as M, openBlock as A, createElementVNode as f, createVNode as St, toDisplayString as S, createCommentVNode as L, Fragment as W, renderList as ce, normalizeClass as Tt, normalizeStyle as it, withDirectives as Ue, createTextVNode as Qe, vModelCheckbox as Mt, vModelSelect as At, Transition as Ot, withCtx as $t } from "vue";
2
+ import { v7 as B } from "uuid";
3
+ import { isNil as b, isEmpty as ve, trim as dt, isEqual as He } from "lodash-es";
4
+ import Oe from "mitt";
5
+ import Ft from "handlebars";
6
+ import Pt from "superjson";
7
7
  import ps from "p-queue";
8
8
  import ms from "axios";
9
- import { z as P } from "zod";
9
+ import { z as $ } from "zod";
10
10
  import ys from "pusher-js";
11
- import Zt, { createEqualsOperation as ee } from "sift";
11
+ import Wt, { createEqualsOperation as ee } from "sift";
12
12
  import { DateTime as _e } from "luxon";
13
13
  import { parse as gs, format as _s } from "date-fns";
14
14
  import { Graph as Dt } from "graphlib";
15
15
  import Le from "object-hash";
16
- import * as Yt from "mathjs";
16
+ import * as Zt from "mathjs";
17
17
  import ws from "rfdc";
18
18
  const se = /* @__PURE__ */ new Map(), ut = /* @__PURE__ */ new Set();
19
19
  function Cs(n) {
20
20
  return ut.add(n), () => ut.delete(n);
21
21
  }
22
- function Je(n) {
22
+ function qe(n) {
23
23
  return typeof n == "string" && /\{\{\s*TempPK_[^}\s]+\s*\}\}/.test(n);
24
24
  }
25
25
  function zt(n) {
26
26
  return `{{TempPK_${n}}}`;
27
27
  }
28
- function Kt(n, e) {
28
+ function Rt(n, e) {
29
29
  const t = `{{TempPK_${n}}}`, s = `"TempPK_${n}"`, r = typeof e == "string" ? `"${e}"` : String(e);
30
30
  se.set(s, r);
31
31
  for (const o of ut)
@@ -36,26 +36,26 @@ function Kt(n, e) {
36
36
  }
37
37
  }
38
38
  function vs(n) {
39
- if (!Je(String(n))) return n;
39
+ if (!qe(String(n))) return n;
40
40
  const e = String(n).match(/\{\{\s*TempPK_([^}\s]+)\s*\}\}/);
41
41
  if (!e) return n;
42
42
  const t = `"TempPK_${e[1]}"`, s = se.get(t);
43
43
  return s ? s.startsWith('"') && s.endsWith('"') ? s.slice(1, -1) : parseInt(s, 10) : n;
44
44
  }
45
- function We(n) {
45
+ function Je(n) {
46
46
  if (se.size === 0) return n;
47
47
  const e = Object.fromEntries(se);
48
48
  try {
49
49
  if (typeof n == "string")
50
- return It.compile(n, { noEscape: !0 })(e);
51
- const t = Ft.stringify(n), r = It.compile(t, { noEscape: !0 })(e);
52
- return Ft.parse(r);
50
+ return Ft.compile(n, { noEscape: !0 })(e);
51
+ const t = Pt.stringify(n), r = Ft.compile(t, { noEscape: !0 })(e);
52
+ return Pt.parse(r);
53
53
  } catch {
54
54
  return n;
55
55
  }
56
56
  }
57
- const Es = Ae(), bs = Ae(), Rt = Ae();
58
- class ks {
57
+ const ks = Oe(), bs = Oe(), Kt = Oe(), at = /* @__PURE__ */ new Map();
58
+ class Es {
59
59
  constructor(e, t = {}) {
60
60
  this.dbName = e, this.storeName = t.storeName || "keyval-store", this.batchDelay = t.batchDelay || 50, this.version = t.version || 5, this.resetOnErrors = t.resetOnErrors || [
61
61
  "VersionError",
@@ -236,9 +236,9 @@ class ks {
236
236
  }
237
237
  }
238
238
  }
239
- class vt {
239
+ class Ct {
240
240
  constructor(e, t = {}, s = null) {
241
- this.store = new ks(e, t), this.localMap = /* @__PURE__ */ new Map(), this.hydrate().then((r) => {
241
+ at.has(e) ? this.store = at.get(e) : (this.store = new Es(e, t), at.set(e, this.store)), this.localMap = /* @__PURE__ */ new Map(), this.hydrate().then((r) => {
242
242
  typeof s == "function" && s(r);
243
243
  }).catch((r) => {
244
244
  console.error(`Cache hydration failed for "${e}":`, r);
@@ -288,13 +288,13 @@ class vt {
288
288
  const ge = (n, e) => {
289
289
  if (!e || !e.pks || e.pks.length === 0) return;
290
290
  const t = e.pks.map((r) => n._lastRenderedData.get(r) ?? null), s = n.render(e.pks, !0, !1);
291
- if (!qe(s, t)) {
291
+ if (!He(s, t)) {
292
292
  const r = n.pkField;
293
293
  for (const o of s)
294
294
  o && o[r] != null && n._lastRenderedData.set(o[r], o);
295
295
  for (const o of e.pks)
296
296
  s.some((i) => i && i[r] === o) || n._lastRenderedData.set(o, null);
297
- Es.emit(
297
+ ks.emit(
298
298
  `${n.modelClass.configKey}::${n.modelClass.modelName}::render`,
299
299
  e
300
300
  ), n.renderCallbacks.forEach((o) => {
@@ -347,7 +347,7 @@ class Ss {
347
347
  operationsMap;
348
348
  isSyncing;
349
349
  constructor(e, t, s = null, r = null, o = {}) {
350
- this.modelClass = e, this.fetchFn = t, this.isSyncing = !1, this.pruneThreshold = o.pruneThreshold || 10, this.groundTruthArray = s || [], this.operationsMap = /* @__PURE__ */ new Map(), r && r.length > 0 && this._loadOperations(r), this.modelCache = new vt("model-cache", {}, this.onHydrated.bind(this)), this._lastRenderedData = /* @__PURE__ */ new Map(), this.renderCallbacks = /* @__PURE__ */ new Set(), this._unsubscribeTempPk = Cs((i, l) => {
350
+ this.modelClass = e, this.fetchFn = t, this.isSyncing = !1, this.pruneThreshold = o.pruneThreshold || 10, this.groundTruthArray = s || [], this.operationsMap = /* @__PURE__ */ new Map(), r && r.length > 0 && this._loadOperations(r), this.modelCache = new Ct("model-cache", {}, this.onHydrated.bind(this)), this._lastRenderedData = /* @__PURE__ */ new Map(), this.renderCallbacks = /* @__PURE__ */ new Set(), this._unsubscribeTempPk = Cs((i, l) => {
351
351
  if (this._lastRenderedData.has(i)) {
352
352
  const a = this._lastRenderedData.get(i);
353
353
  a && typeof a == "object" && (a[this.pkField] = l), this._lastRenderedData.set(l, a), this._lastRenderedData.delete(i);
@@ -363,7 +363,7 @@ class Ss {
363
363
  */
364
364
  _loadOperations(e) {
365
365
  e.forEach((t) => {
366
- const s = Pe.get(t.operationId);
366
+ const s = Fe.get(t.operationId);
367
367
  s ? this.operationsMap.set(s.operationId, s) : this.operationsMap.set(t.operationId, new q(t, !0));
368
368
  });
369
369
  }
@@ -374,7 +374,7 @@ class Ss {
374
374
  onHydrated() {
375
375
  if (this.groundTruthArray.length === 0 && this.operationsMap.size === 0) {
376
376
  let e = this.modelCache.get(this.cacheKey);
377
- !E(e) && !ve(e) && this.setGroundTruth(e);
377
+ !b(e) && !ve(e) && this.setGroundTruth(e);
378
378
  }
379
379
  }
380
380
  setCache(e) {
@@ -382,7 +382,7 @@ class Ss {
382
382
  let s = [];
383
383
  e.forEach((r) => {
384
384
  let o = r[t];
385
- if (!(typeof o == "string" && Je(o) && (o = We(r[t]), E(o) || ve(dt(o)))))
385
+ if (!(typeof o == "string" && qe(o) && (o = Je(r[t]), b(o) || ve(dt(o)))))
386
386
  if (r && typeof r.serialize == "function") {
387
387
  const i = r.serialize(!0);
388
388
  i[t] = o, s.push(i);
@@ -397,14 +397,14 @@ class Ss {
397
397
  const s = this.pkField;
398
398
  let r = [];
399
399
  if (e.forEach((c) => {
400
- let f = c[s];
401
- typeof f == "string" && Je(f) && (f = We(c[s]), E(f) || ve(dt(f))) || (c[s] = f, r.push(c));
400
+ let h = c[s];
401
+ typeof h == "string" && qe(h) && (h = Je(c[s]), b(h) || ve(dt(h))) || (c[s] = h, r.push(c));
402
402
  }), t === null) {
403
403
  this.setCache(r);
404
404
  return;
405
405
  }
406
406
  const i = (this.modelCache.get(this.cacheKey) || []).filter(
407
- (c) => c && typeof c == "object" && s in c && (!t.has(c[s]) || r.some((f) => f[s] === c[s]))
407
+ (c) => c && typeof c == "object" && s in c && (!t.has(c[s]) || r.some((h) => h[s] === c[s]))
408
408
  ), l = new Map(
409
409
  i.map((c) => [c[s], c])
410
410
  );
@@ -478,18 +478,28 @@ class Ss {
478
478
  r.push(l);
479
479
  }
480
480
  if (r.push(...Array.from(s.values())), this.groundTruthArray = r, i.length > 0) {
481
- const l = new q({
482
- operationId: `checkpoint_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
483
- type: M.CHECKPOINT,
484
- instances: i,
485
- status: C.CONFIRMED,
486
- timestamp: Date.now(),
487
- queryset: this.modelClass.objects.all()
488
- });
489
- this.operationsMap.set(
490
- l.operationId,
491
- l
481
+ const l = /* @__PURE__ */ new Set();
482
+ for (const c of this.operations)
483
+ if ((c.type === P.UPDATE || c.type === P.UPDATE_INSTANCE) && c.status !== C.CONFIRMED && c.status !== C.REJECTED)
484
+ for (const h of c.instances)
485
+ h && h[t] != null && l.add(h[t]);
486
+ const a = i.filter(
487
+ (c) => !l.has(c[t])
492
488
  );
489
+ if (a.length > 0) {
490
+ const c = new q({
491
+ operationId: `checkpoint_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
492
+ type: P.CHECKPOINT,
493
+ instances: a,
494
+ status: C.CONFIRMED,
495
+ timestamp: Date.now(),
496
+ queryset: this.modelClass.objects.all()
497
+ });
498
+ this.operationsMap.set(
499
+ c.operationId,
500
+ c
501
+ );
502
+ }
493
503
  }
494
504
  ge(
495
505
  this,
@@ -543,21 +553,21 @@ class Ss {
543
553
  }
544
554
  let o = r[s];
545
555
  switch (e.type) {
546
- case M.CREATE:
547
- case M.BULK_CREATE:
556
+ case P.CREATE:
557
+ case P.BULK_CREATE:
548
558
  t.has(o) || t.set(o, r);
549
559
  break;
550
- case M.CHECKPOINT:
551
- case M.UPDATE_INSTANCE:
552
- case M.UPDATE: {
560
+ case P.CHECKPOINT:
561
+ case P.UPDATE_INSTANCE:
562
+ case P.UPDATE: {
553
563
  const i = t.get(o);
554
564
  i ? t.set(o, { ...i, ...r }) : this.operations.some(
555
- (a) => a.type === M.DELETE && a.status !== C.REJECTED && a.instances.some((c) => c && c[s] === o)
565
+ (a) => a.type === P.DELETE && a.status !== C.REJECTED && a.instances.some((c) => c && c[s] === o)
556
566
  ) || t.set(o, r);
557
567
  break;
558
568
  }
559
- case M.DELETE_INSTANCE:
560
- case M.DELETE:
569
+ case P.DELETE_INSTANCE:
570
+ case P.DELETE:
561
571
  t.delete(o);
562
572
  break;
563
573
  default:
@@ -593,7 +603,7 @@ class Ss {
593
603
  pruneUnreferencedInstances(e) {
594
604
  const t = this.pkField, s = this.modelClass.modelName, r = /* @__PURE__ */ new Set();
595
605
  for (const [l, a] of e._stores.entries())
596
- a.modelClass.modelName === s && a.groundTruthPks.forEach((c) => r.add(c)), a.includedPks.has(s) && a.includedPks.get(s).forEach((f) => r.add(f));
606
+ a.modelClass.modelName === s && a.groundTruthPks.forEach((c) => r.add(c)), a.includedPks.has(s) && a.includedPks.get(s).forEach((h) => r.add(h));
597
607
  const o = this.groundTruthArray.filter((l) => !l || typeof l != "object" || !(t in l) ? !1 : r.has(l[t]));
598
608
  this.groundTruthArray.length - o.length > 0 && (this.groundTruthArray = o, this.setCache(o));
599
609
  }
@@ -607,10 +617,10 @@ class Ss {
607
617
  return this._renderFromCache(o);
608
618
  const l = this.pkField;
609
619
  if (i.length < o.length) {
610
- const a = o.filter((p) => this._lastRenderedData.has(p)), c = this._renderFromCache(a), f = this._renderFresh(i, t);
611
- for (const p of f)
620
+ const a = o.filter((p) => this._lastRenderedData.has(p)), c = this._renderFromCache(a), h = this._renderFresh(i, t);
621
+ for (const p of h)
612
622
  p && p[l] != null && this._lastRenderedData.set(p[l], p);
613
- return [...c, ...f];
623
+ return [...c, ...h];
614
624
  } else {
615
625
  const a = this._renderFresh(o, t);
616
626
  for (const c of a)
@@ -634,7 +644,7 @@ class Ss {
634
644
  for (const l of o)
635
645
  l.status !== C.REJECTED && (t || l.status === C.CONFIRMED) && this.applyOperation(l, r);
636
646
  let i = Array.from(r.values());
637
- return e && this.updateCache(i, s), E(e) && this.setCache(i), i;
647
+ return e && this.updateCache(i, s), b(e) && this.setCache(i), i;
638
648
  }
639
649
  async sync(e = null) {
640
650
  const t = this.modelClass.modelName;
@@ -669,7 +679,7 @@ class Ss {
669
679
  }
670
680
  }
671
681
  }
672
- class Ge {
682
+ class Ve {
673
683
  constructor() {
674
684
  this._stores = /* @__PURE__ */ new Map(), this.syncManager = () => {
675
685
  console.warn("SyncManager not set for ModelStoreRegistry");
@@ -694,35 +704,37 @@ class Ge {
694
704
  }
695
705
  // Get a single entity from the store
696
706
  getEntity(e, t) {
697
- if (E(e) || E(t)) return;
707
+ if (b(e) || b(t)) return;
698
708
  if (t[e.primaryKeyField]) throw new Error("getEntity should be called with a pk not an object");
699
709
  return this.getStore(e).render([t])[0] || null;
700
710
  }
701
711
  // Add or update an entity ground truth in the store, not for operations!
702
712
  setEntity(e, t, s) {
703
- if (E(e) || E(t)) return;
713
+ if (b(e) || b(t)) return;
704
714
  if (t[e.primaryKeyField]) throw new Error("getEntity should be called with a pk not an object");
705
715
  return this.getStore(e).addToGroundTruth([s]), s;
706
716
  }
707
717
  // Batch add or update entities in the store ground truth
708
718
  setEntities(e, t) {
709
- if (E(e) || !t?.length) return;
719
+ if (b(e) || !t?.length) return;
710
720
  this.getStore(e).addToGroundTruth(t);
711
721
  }
712
722
  }
713
- const Q = new Ge(), ie = Ae(), C = {
723
+ const j = new Ve(), ie = Oe(), C = {
714
724
  CREATED: "operation:created",
715
725
  CONFIRMED: "operation:confirmed",
716
726
  REJECTED: "operation:rejected",
717
727
  CLEAR: "clear:all",
718
728
  MUTATED: "operation:mutated"
719
- }, M = {
729
+ }, P = {
720
730
  CREATE: "create",
721
731
  BULK_CREATE: "bulk_create",
722
732
  UPDATE: "update",
723
733
  DELETE: "delete",
724
734
  UPDATE_INSTANCE: "update_instance",
725
735
  DELETE_INSTANCE: "delete_instance",
736
+ GET_OR_CREATE: "get_or_create",
737
+ UPDATE_OR_CREATE: "update_or_create",
726
738
  CHECKPOINT: "checkpoint"
727
739
  };
728
740
  class q {
@@ -743,15 +755,15 @@ class q {
743
755
  throw new Error("Operation data must include a 'type'.");
744
756
  if (!e.instances)
745
757
  throw new Error("Operation data must include 'instances'.");
746
- this.operationId = e.operationId || `op_${G()}`, this.type = e.type, this.status = e.status || C.CREATED, this.queryset = e.queryset, this.args = e.args, this.doNotPropagate = e.doNotPropagate || !1, this.localOnly = e.localOnly || !1;
758
+ this.operationId = e.operationId || `op_${B()}`, this.type = e.type, this.status = e.status || C.CREATED, this.queryset = e.queryset, this.args = e.args, this.doNotPropagate = e.doNotPropagate || !1, this.localOnly = e.localOnly || !1;
747
759
  let s = this.queryset.ModelClass, r = e.instances;
748
- E(r) || (r = Array.isArray(e.instances) ? e.instances : [e.instances]);
760
+ b(r) || (r = Array.isArray(e.instances) ? e.instances : [e.instances]);
749
761
  let o = s.primaryKeyField;
750
- if (r.some((a) => E(a) || typeof a != "object" || !(o in a)))
762
+ if (r.some((a) => b(a) || typeof a != "object" || !(o in a)))
751
763
  throw new Error(`All operation instances must be objects with the '${o}' field`);
752
764
  this.#e = r;
753
765
  const i = r.map((a) => a[o]);
754
- Q.getStore(s).render(i, !0, !1), this.#t = r.map((a) => s.fromPk(a[o]).serialize()), this.timestamp = e.timestamp || Date.now(), !t && (Pe.register(this), ie.emit(C.CREATED, this));
766
+ j.getStore(s).render(i, !0, !1), this.#t = r.map((a) => s.fromPk(a[o]).serialize()), this.timestamp = e.timestamp || Date.now(), !t && (Fe.register(this), ie.emit(C.CREATED, this));
755
767
  }
756
768
  /**
757
769
  * Getter for instances that replaces any temporary PKs with real PKs
@@ -903,8 +915,8 @@ class Ts {
903
915
  return t.length > 0 ? t[t.length - 1] : void 0;
904
916
  }
905
917
  }
906
- const Pe = new Ts(), Ms = Ae();
907
- function $s(n) {
918
+ const Fe = new Ts(), Ms = Oe();
919
+ function As(n) {
908
920
  Ms.emit("error", n);
909
921
  }
910
922
  class fe extends Error {
@@ -917,7 +929,7 @@ class fe extends Error {
917
929
  * @param {number} status - The HTTP status code.
918
930
  */
919
931
  constructor(e, t, s, r) {
920
- super(e), this.name = "StateZeroError", this.code = t, this.detail = s, this.status = r, Object.setPrototypeOf(this, new.target.prototype), $s(this);
932
+ super(e), this.name = "StateZeroError", this.code = t, this.detail = s, this.status = r, Object.setPrototypeOf(this, new.target.prototype), As(this);
921
933
  }
922
934
  /**
923
935
  * Returns a full error message including the detail.
@@ -939,7 +951,7 @@ class fe extends Error {
939
951
  return this.message;
940
952
  }
941
953
  }
942
- class Oe extends fe {
954
+ class $e extends fe {
943
955
  /**
944
956
  * Creates a new ValidationError.
945
957
  *
@@ -950,7 +962,7 @@ class Oe extends fe {
950
962
  super("Validation error", "validation_error", e, t), this.name = "ValidationError";
951
963
  }
952
964
  }
953
- class Nt extends fe {
965
+ class It extends fe {
954
966
  /**
955
967
  * Creates a new DoesNotExist error.
956
968
  *
@@ -972,7 +984,7 @@ class lt extends fe {
972
984
  super("Permission denied", "permission_denied", e, t), this.name = "PermissionDenied";
973
985
  }
974
986
  }
975
- class As extends fe {
987
+ class Os extends fe {
976
988
  /**
977
989
  * Creates a new MultipleObjectsReturned error.
978
990
  *
@@ -983,7 +995,7 @@ class As extends fe {
983
995
  super("Multiple objects returned", "multiple_objects_returned", e, t), this.name = "MultipleObjectsReturned";
984
996
  }
985
997
  }
986
- class xt extends fe {
998
+ class Nt extends fe {
987
999
  /**
988
1000
  * Creates a new ConflictError.
989
1001
  *
@@ -994,7 +1006,7 @@ class xt extends fe {
994
1006
  super("Conflict", "conflict", e, t), this.name = "ConflictError";
995
1007
  }
996
1008
  }
997
- class Os extends fe {
1009
+ class $s extends fe {
998
1010
  /**
999
1011
  * Creates a new ASTValidationError.
1000
1012
  *
@@ -1005,7 +1017,7 @@ class Os extends fe {
1005
1017
  super("Query syntax error", "ast_validation_error", e, t), this.name = "ASTValidationError";
1006
1018
  }
1007
1019
  }
1008
- class x extends fe {
1020
+ class U extends fe {
1009
1021
  /**
1010
1022
  * Creates a new ConfigError.
1011
1023
  *
@@ -1016,36 +1028,36 @@ class x extends fe {
1016
1028
  super("Configuration error", "config_error", e, t), this.name = "ConfigError";
1017
1029
  }
1018
1030
  }
1019
- function Ps(n) {
1031
+ function Fs(n) {
1020
1032
  const { status: e, type: t, detail: s } = n;
1021
1033
  if (t === void 0 && s === "Invalid token.")
1022
1034
  return new lt(s, 403);
1023
1035
  switch (t) {
1024
1036
  // Direct mappings
1025
1037
  case "ValidationError":
1026
- return new Oe(s, e);
1038
+ return new $e(s, e);
1027
1039
  case "NotFound":
1028
- return new Nt(s, e);
1040
+ return new It(s, e);
1029
1041
  case "MultipleObjectsReturned":
1030
- return new As(s, e);
1042
+ return new Os(s, e);
1031
1043
  case "PermissionDenied":
1032
1044
  return new lt(s, e);
1033
1045
  case "ConflictError":
1034
- return new xt(s, e);
1046
+ return new Nt(s, e);
1035
1047
  case "ASTValidationError":
1036
- return new Os(s, e);
1048
+ return new $s(s, e);
1037
1049
  case "ConfigError":
1038
- return new x(s, e);
1050
+ return new U(s, e);
1039
1051
  // Django error types that map to our error classes
1040
1052
  case "FieldError":
1041
- return new Oe(s, e);
1053
+ return new $e(s, e);
1042
1054
  case "ValueError":
1043
- return new Oe(s, e);
1055
+ return new $e(s, e);
1044
1056
  default:
1045
- return e === 400 ? new Oe(s, e) : e === 403 ? new lt(s, e) : e === 404 ? new Nt(s, e) : e === 409 ? new xt(s, e) : new fe("Unknown error", "unknown", s, e);
1057
+ return e === 400 ? new $e(s, e) : e === 403 ? new lt(s, e) : e === 404 ? new It(s, e) : e === 409 ? new Nt(s, e) : new fe("Unknown error", "unknown", s, e);
1046
1058
  }
1047
1059
  }
1048
- const jt = {
1060
+ const xt = {
1049
1061
  CREATE: "create",
1050
1062
  UPDATE: "update",
1051
1063
  DELETE: "delete",
@@ -1053,7 +1065,7 @@ const jt = {
1053
1065
  BULK_UPDATE: "bulk_update",
1054
1066
  BULK_DELETE: "bulk_delete"
1055
1067
  };
1056
- class Is {
1068
+ class Ps {
1057
1069
  /**
1058
1070
  * @param {PusherReceiverOptions} options
1059
1071
  * @param {string} configKey - The backend configuration key
@@ -1143,7 +1155,7 @@ Common causes:
1143
1155
  `%cAuthentication failed for channel ${t}. Check your authEndpoint and server-side permissions.`,
1144
1156
  "color: orange; font-weight: bold;"
1145
1157
  );
1146
- }), Object.values(jt).forEach((r) => {
1158
+ }), Object.values(xt).forEach((r) => {
1147
1159
  s.bind(r, (o) => {
1148
1160
  const i = {
1149
1161
  ...o,
@@ -1158,7 +1170,7 @@ Common causes:
1158
1170
  unsubscribe(e) {
1159
1171
  const t = this.channels.get(e);
1160
1172
  if (!t) return;
1161
- Object.values(jt).forEach((r) => {
1173
+ Object.values(xt).forEach((r) => {
1162
1174
  t.unbind(r);
1163
1175
  });
1164
1176
  const s = e.startsWith("private-") ? e : this.formatChannelName(e);
@@ -1200,67 +1212,67 @@ Common causes:
1200
1212
  return this.namespaceResolver(e);
1201
1213
  }
1202
1214
  }
1203
- const Ze = /* @__PURE__ */ new Map();
1204
- function Fs(n, e) {
1205
- const t = Ze.get(n);
1206
- t && t.disconnect(), Ze.set(n, e), e.connect();
1215
+ const We = /* @__PURE__ */ new Map();
1216
+ function Ds(n, e) {
1217
+ const t = We.get(n);
1218
+ t && t.disconnect(), We.set(n, e), e.connect();
1207
1219
  }
1208
- function Ut(n = "default") {
1209
- return Ze.get(n);
1220
+ function jt(n = "default") {
1221
+ return We.get(n);
1210
1222
  }
1211
- function Ds() {
1212
- return Ze;
1223
+ function zs() {
1224
+ return We;
1213
1225
  }
1214
- let Qt = {
1226
+ let Ut = {
1215
1227
  backendConfigs: {}
1216
1228
  };
1217
- const zs = P.object({
1218
- clientOptions: P.object({
1219
- appKey: P.string({ required_error: "Pusher appKey is required" }),
1220
- cluster: P.string({ required_error: "Pusher cluster is required" }),
1221
- forceTLS: P.boolean().optional(),
1222
- authEndpoint: P.string().url("Pusher authentication endpoint URL is required"),
1223
- getAuthHeaders: P.function().optional().refine(
1229
+ const Rs = $.object({
1230
+ clientOptions: $.object({
1231
+ appKey: $.string({ required_error: "Pusher appKey is required" }),
1232
+ cluster: $.string({ required_error: "Pusher cluster is required" }),
1233
+ forceTLS: $.boolean().optional(),
1234
+ authEndpoint: $.string().url("Pusher authentication endpoint URL is required"),
1235
+ getAuthHeaders: $.function().optional().refine(
1224
1236
  (n) => n === void 0 || typeof n == "function",
1225
1237
  "getAuthHeaders must be a function if provided"
1226
1238
  )
1227
1239
  })
1228
- }), Ks = P.object({
1229
- type: P.enum(["websocket", "pusher", "none"]),
1230
- websocketUrl: P.string().url().optional(),
1231
- pusher: zs.optional(),
1232
- hotpaths: P.array(P.string()).default(["default"])
1240
+ }), Ks = $.object({
1241
+ type: $.enum(["websocket", "pusher", "none"]),
1242
+ websocketUrl: $.string().url().optional(),
1243
+ pusher: Rs.optional(),
1244
+ hotpaths: $.array($.string()).default(["default"])
1233
1245
  }).superRefine((n, e) => {
1234
1246
  n.type === "websocket" && (n.websocketUrl || e.addIssue({
1235
- code: P.ZodIssueCode.custom,
1247
+ code: $.ZodIssueCode.custom,
1236
1248
  path: ["websocketUrl"],
1237
1249
  message: "WebSocket URL is required for WebSocket event receiver"
1238
1250
  })), n.type === "pusher" && (n.pusher || e.addIssue({
1239
- code: P.ZodIssueCode.custom,
1251
+ code: $.ZodIssueCode.custom,
1240
1252
  path: ["pusher"],
1241
1253
  message: "Pusher configuration is required for Pusher event receiver"
1242
1254
  }));
1243
- }), Be = P.object({
1244
- API_URL: P.string().url("API_URL must be a valid URL"),
1245
- GENERATED_TYPES_DIR: P.string({
1255
+ }), Be = $.object({
1256
+ API_URL: $.string().url("API_URL must be a valid URL"),
1257
+ GENERATED_TYPES_DIR: $.string({
1246
1258
  required_error: "GENERATED_TYPES_DIR is required"
1247
1259
  }),
1248
- GENERATED_ACTIONS_DIR: P.string().optional(),
1249
- BACKEND_TZ: P.string().optional(),
1250
- SYNC_TOKEN: P.string().optional(),
1251
- fileRootURL: P.string().url("fileRootURL must be a valid URL").optional(),
1252
- fileUploadMode: P.enum(["server", "s3"]).default("server"),
1253
- getAuthHeaders: P.function().optional().refine(
1260
+ GENERATED_ACTIONS_DIR: $.string().optional(),
1261
+ BACKEND_TZ: $.string().optional(),
1262
+ SYNC_TOKEN: $.string().optional(),
1263
+ fileRootURL: $.string().url("fileRootURL must be a valid URL").optional(),
1264
+ fileUploadMode: $.enum(["server", "s3"]).default("server"),
1265
+ getAuthHeaders: $.function().optional().refine(
1254
1266
  (n) => n === void 0 || typeof n == "function",
1255
1267
  "getAuthHeaders must be a function if provided"
1256
1268
  ),
1257
- eventInterceptor: P.function().optional().refine(
1269
+ eventInterceptor: $.function().optional().refine(
1258
1270
  (n) => n === void 0 || typeof n == "function",
1259
1271
  "eventInterceptor must be a function if provided"
1260
1272
  ),
1261
- events: P.lazy(() => Ks.optional())
1262
- }), Rs = P.object({
1263
- backendConfigs: P.record(P.string(), Be).refine(
1273
+ events: $.lazy(() => Ks.optional())
1274
+ }), Is = $.object({
1275
+ backendConfigs: $.record($.string(), Be).refine(
1264
1276
  (n) => {
1265
1277
  for (const [e, t] of Object.entries(n))
1266
1278
  if (!Be.safeParse(t).success)
@@ -1279,43 +1291,43 @@ const zs = P.object({
1279
1291
  return { message: e.join("; ") };
1280
1292
  }
1281
1293
  ),
1282
- periodicSyncIntervalSeconds: P.number().min(5).nullable().optional().default(null)
1294
+ periodicSyncIntervalSeconds: $.number().min(5).nullable().optional().default(null)
1283
1295
  });
1284
1296
  let ht = null;
1285
1297
  function Ns(n) {
1286
- Qt = n;
1287
- const e = Rs.safeParse(Qt);
1298
+ Ut = n;
1299
+ const e = Is.safeParse(Ut);
1288
1300
  if (!e.success) {
1289
1301
  const t = e.error.errors.map((s) => s.message);
1290
- throw new x(`Error setting configuration: ${t.join(", ")}`);
1302
+ throw new U(`Error setting configuration: ${t.join(", ")}`);
1291
1303
  }
1292
1304
  ht = e.data;
1293
1305
  }
1294
1306
  function he() {
1295
1307
  if (!ht)
1296
- throw new x("Configuration not set. Please call setConfig() with a valid configuration.");
1308
+ throw new U("Configuration not set. Please call setConfig() with a valid configuration.");
1297
1309
  return ht;
1298
1310
  }
1299
1311
  function xs(n, e) {
1300
1312
  try {
1301
1313
  const t = he();
1302
1314
  if (!t.backendConfigs[n])
1303
- throw new x(`Backend "${n}" not found in configuration.`);
1315
+ throw new U(`Backend "${n}" not found in configuration.`);
1304
1316
  const s = { ...t.backendConfigs[n], ...e }, r = Be.safeParse(s);
1305
1317
  if (!r.success) {
1306
1318
  const o = r.error.errors.map((i) => i.message);
1307
- throw new x(`Invalid backend configuration: ${o.join(", ")}`);
1319
+ throw new U(`Invalid backend configuration: ${o.join(", ")}`);
1308
1320
  }
1309
1321
  t.backendConfigs[n] = r.data;
1310
1322
  } catch (t) {
1311
- throw t instanceof x ? t : new x(t.message || "Invalid backend configuration");
1323
+ throw t instanceof U ? t : new U(t.message || "Invalid backend configuration");
1312
1324
  }
1313
1325
  }
1314
- function Xt(n = "default") {
1326
+ function Yt(n = "default") {
1315
1327
  try {
1316
1328
  const e = he();
1317
1329
  if (!e.backendConfigs[n])
1318
- throw new x(`Backend "${n}" not found in configuration.`);
1330
+ throw new U(`Backend "${n}" not found in configuration.`);
1319
1331
  const t = e.backendConfigs[n];
1320
1332
  if (!t.events)
1321
1333
  return null;
@@ -1323,9 +1335,9 @@ function Xt(n = "default") {
1323
1335
  switch (t.events.type) {
1324
1336
  case "pusher":
1325
1337
  if (!t.events.pusher || !t.events.pusher.clientOptions)
1326
- throw new x("Pusher client options are required for Pusher event receiver.");
1338
+ throw new U("Pusher client options are required for Pusher event receiver.");
1327
1339
  if (!t.events.pusher.clientOptions.authEndpoint)
1328
- throw new x("Pusher auth endpoint is required for Pusher event receiver.");
1340
+ throw new U("Pusher auth endpoint is required for Pusher event receiver.");
1329
1341
  const r = t.events.pusher.clientOptions.getAuthHeaders || t.getAuthHeaders, o = t.SYNC_TOKEN, i = () => {
1330
1342
  const a = r ? r() : {};
1331
1343
  return o ? { ...a, "X-StateZero-Sync-Token": o } : a;
@@ -1333,16 +1345,16 @@ function Xt(n = "default") {
1333
1345
  ...t.events.pusher.clientOptions,
1334
1346
  getAuthHeaders: i
1335
1347
  };
1336
- s = new Is({ clientOptions: l }, n);
1348
+ s = new Ps({ clientOptions: l }, n);
1337
1349
  break;
1338
1350
  case "none":
1339
1351
  return null;
1340
1352
  default:
1341
- throw new x(`Unknown event receiver type: ${t.events.type}`);
1353
+ throw new U(`Unknown event receiver type: ${t.events.type}`);
1342
1354
  }
1343
- return s && Fs(n, s), s;
1355
+ return s && Ds(n, s), s;
1344
1356
  } catch (e) {
1345
- throw e instanceof x ? e : new x(`Failed to initialize event receiver: ${e.message}`);
1357
+ throw e instanceof U ? e : new U(`Failed to initialize event receiver: ${e.message}`);
1346
1358
  }
1347
1359
  }
1348
1360
  function js() {
@@ -1350,19 +1362,19 @@ function js() {
1350
1362
  const n = he(), e = {};
1351
1363
  return Object.keys(n.backendConfigs).forEach((t) => {
1352
1364
  try {
1353
- e[t] = Xt(t);
1365
+ e[t] = Yt(t);
1354
1366
  } catch (s) {
1355
1367
  console.warn(`Failed to initialize event receiver for backend "${t}": ${s.message}`);
1356
1368
  }
1357
1369
  }), e;
1358
1370
  } catch (n) {
1359
- throw new x(`Failed to initialize event receivers: ${n.message}`);
1371
+ throw new U(`Failed to initialize event receivers: ${n.message}`);
1360
1372
  }
1361
1373
  }
1362
1374
  let ft = null;
1363
1375
  function Us(n) {
1364
1376
  if (typeof n != "function")
1365
- throw new x("Provided model getter must be a function.");
1377
+ throw new U("Provided model getter must be a function.");
1366
1378
  ft = n;
1367
1379
  }
1368
1380
  function Qs(n, e = "default") {
@@ -1370,31 +1382,31 @@ function Qs(n, e = "default") {
1370
1382
  return n;
1371
1383
  const s = he().backendConfigs[e];
1372
1384
  if (!s)
1373
- throw new x(`Backend "${e}" not found in configuration.`);
1385
+ throw new U(`Backend "${e}" not found in configuration.`);
1374
1386
  return s.fileRootURL ? s.fileRootURL.replace(/\/$/, "") + n : n;
1375
1387
  }
1376
- function es(n, e) {
1388
+ function Xt(n, e) {
1377
1389
  if (!ft)
1378
- throw new x("Model registry not registered. Please call registerModelGetter() with the function from model-registry.js during app initialization.");
1390
+ throw new U("Model registry not registered. Please call registerModelGetter() with the function from model-registry.js during app initialization.");
1379
1391
  return ft(n, e);
1380
1392
  }
1381
- const Fe = {
1393
+ const De = {
1382
1394
  setConfig: Ns,
1383
1395
  getConfig: he,
1384
1396
  setBackendConfig: xs,
1385
- initializeEventReceiver: Xt,
1397
+ initializeEventReceiver: Yt,
1386
1398
  registerModelGetter: Us,
1387
- getModelClass: es,
1399
+ getModelClass: Xt,
1388
1400
  buildFileUrl: Qs
1389
- }, ts = "__STATEZERO_DEBUG__", X = globalThis[ts] || {
1390
- emitter: Ae(),
1401
+ }, es = "__STATEZERO_DEBUG__", X = globalThis[es] || {
1402
+ emitter: Oe(),
1391
1403
  buffer: [],
1392
1404
  enabled: !0,
1393
1405
  started: !1,
1394
1406
  maxEntries: 500,
1395
1407
  nextId: 1
1396
1408
  };
1397
- globalThis[ts] = X;
1409
+ globalThis[es] = X;
1398
1410
  const Me = X.emitter, ue = X.buffer;
1399
1411
  function Te(n) {
1400
1412
  if (!X.enabled) return;
@@ -1405,26 +1417,26 @@ function Te(n) {
1405
1417
  };
1406
1418
  ue.push(e), ue.length > X.maxEntries && ue.shift(), Me.emit("record", e);
1407
1419
  }
1408
- function B(n) {
1420
+ function G(n) {
1409
1421
  Te(n);
1410
1422
  }
1411
- function Vs(n) {
1423
+ function Ls(n) {
1412
1424
  return Me.on("record", n), () => Me.off("record", n);
1413
1425
  }
1414
- function Ls(n) {
1426
+ function Vs(n) {
1415
1427
  return Me.on("clear", n), () => Me.off("clear", n);
1416
1428
  }
1417
- function Vt() {
1429
+ function Qt() {
1418
1430
  return ue.slice();
1419
1431
  }
1420
- function Gs() {
1432
+ function Bs() {
1421
1433
  ue.length = 0, Me.emit("clear");
1422
1434
  }
1423
1435
  function Lt(n) {
1424
1436
  const e = Number(n);
1425
1437
  !Number.isFinite(e) || e <= 0 || (X.maxEntries = Math.floor(e), ue.length > X.maxEntries && ue.splice(0, ue.length - X.maxEntries));
1426
1438
  }
1427
- function Bs() {
1439
+ function Gs() {
1428
1440
  X.started || (X.started = !0, ie.on(C.CREATED, (n) => {
1429
1441
  Te({
1430
1442
  type: "operation",
@@ -1493,19 +1505,19 @@ function we(n, e, t, s = null) {
1493
1505
  if (!e) return;
1494
1506
  const r = t.configKey;
1495
1507
  let o = null;
1496
- s && (o = j.getStore(s));
1508
+ s && (o = x.getStore(s));
1497
1509
  try {
1498
1510
  for (const [i, l] of Object.entries(e)) {
1499
- const a = Fe.getModelClass(i, r);
1511
+ const a = De.getModelClass(i, r);
1500
1512
  if (!a)
1501
1513
  throw console.error(
1502
1514
  `Model class not found for ${i} in config ${r}`
1503
1515
  ), new Error(`Model class not found for ${i}`);
1504
1516
  if (o) {
1505
1517
  o.includedPks.has(i) || o.includedPks.set(i, /* @__PURE__ */ new Set());
1506
- const f = o.includedPks.get(i);
1518
+ const h = o.includedPks.get(i);
1507
1519
  for (const p of Object.keys(l))
1508
- f.add(Number(p));
1520
+ h.add(Number(p));
1509
1521
  }
1510
1522
  const c = Object.values(l);
1511
1523
  n.setEntities(a, c);
@@ -1517,8 +1529,8 @@ function we(n, e, t, s = null) {
1517
1529
  ), new Error(`Failed to process included entities: ${i.message}`);
1518
1530
  }
1519
1531
  }
1520
- async function L(n, e, t = {}, s, r = null, o = null, i = {}) {
1521
- const { namespace: l = "default", timeout: a } = i, c = n.ModelClass, p = Fe.getConfig().backendConfigs[c.configKey];
1532
+ async function V(n, e, t = {}, s, r = null, o = null, i = {}) {
1533
+ const { namespace: l = "default", timeout: a } = i, c = n.ModelClass, p = De.getConfig().backendConfigs[c.configKey];
1522
1534
  if (!p)
1523
1535
  throw new Error(
1524
1536
  `No backend configuration found for key: ${c.configKey}`
@@ -1539,7 +1551,7 @@ async function L(n, e, t = {}, s, r = null, o = null, i = {}) {
1539
1551
  }
1540
1552
  }, v = w?.ast?.serializerOptions?.limit, O = w?.ast?.serializerOptions?.overfetch || 10;
1541
1553
  v && O && (w.ast.serializerOptions.limit = v + O);
1542
- const b = [
1554
+ const k = [
1543
1555
  "create",
1544
1556
  "bulk_create",
1545
1557
  "update",
@@ -1548,79 +1560,79 @@ async function L(n, e, t = {}, s, r = null, o = null, i = {}) {
1548
1560
  "delete_instance",
1549
1561
  "get_or_create",
1550
1562
  "update_or_create"
1551
- ].includes(e), U = `${p.API_URL.replace(/\/+$/, "")}/${c.modelName}/`, N = p.getAuthHeaders ? p.getAuthHeaders() : {}, I = n.semanticKey;
1563
+ ].includes(e), Q = `${p.API_URL.replace(/\/+$/, "")}/${c.modelName}/`, N = p.getAuthHeaders ? p.getAuthHeaders() : {}, F = n.semanticKey;
1552
1564
  s && (N["X-Operation-ID"] = s), o && (N["X-Canonical-ID"] = o);
1553
1565
  const re = async () => {
1554
1566
  try {
1555
- B({
1567
+ G({
1556
1568
  type: "request",
1557
1569
  modelName: c.modelName,
1558
1570
  configKey: c.configKey,
1559
- semanticKey: I,
1571
+ semanticKey: F,
1560
1572
  operationType: e,
1561
1573
  operationId: s,
1562
1574
  canonicalId: o,
1563
- url: U,
1575
+ url: Q,
1564
1576
  payload: w,
1565
1577
  namespace: l
1566
1578
  });
1567
- let D = await ms.post(U, We(w), { headers: N });
1568
- typeof r == "function" && D?.data && await r(D.data);
1569
- const F = D?.data?.data, K = D?.data?.included, me = Array.isArray(F) ? F.length : F != null ? 1 : 0, Ye = K ? Object.keys(K).length : 0, ye = 100, Ke = Array.isArray(F) && F.length > ye ? F.slice(0, ye) : F, Xe = Array.isArray(F) && F.length > ye;
1570
- let Re = K, Ee = !1;
1579
+ let z = await ms.post(Q, Je(w), { headers: N });
1580
+ typeof r == "function" && z?.data && await r(z.data);
1581
+ const D = z?.data?.data, K = z?.data?.included, me = Array.isArray(D) ? D.length : D != null ? 1 : 0, Ze = K ? Object.keys(K).length : 0, ye = 100, Re = Array.isArray(D) && D.length > ye ? D.slice(0, ye) : D, Ye = Array.isArray(D) && D.length > ye;
1582
+ let Ke = K, ke = !1;
1571
1583
  if (K && typeof K == "object") {
1572
- const Ne = {};
1584
+ const Ie = {};
1573
1585
  let ne = 0;
1574
- for (const [xe, je] of Object.entries(K))
1575
- if (Ne[xe] = je, ne += 1, ne >= ye) {
1576
- Ee = !0;
1586
+ for (const [Ne, xe] of Object.entries(K))
1587
+ if (Ie[Ne] = xe, ne += 1, ne >= ye) {
1588
+ ke = !0;
1577
1589
  break;
1578
1590
  }
1579
- Re = Ee ? Ne : K;
1591
+ Ke = ke ? Ie : K;
1580
1592
  }
1581
- return B({
1593
+ return G({
1582
1594
  type: "response",
1583
1595
  modelName: c.modelName,
1584
1596
  configKey: c.configKey,
1585
- semanticKey: I,
1597
+ semanticKey: F,
1586
1598
  operationType: e,
1587
1599
  operationId: s,
1588
1600
  canonicalId: o,
1589
- url: U,
1590
- status: D.status,
1601
+ url: Q,
1602
+ status: z.status,
1591
1603
  dataCount: me,
1592
- includedCount: Ye,
1593
- data: Ke,
1594
- included: Re,
1595
- dataTruncated: Xe,
1596
- includedTruncated: Ee
1597
- }), D.data;
1598
- } catch (D) {
1599
- if (B({
1604
+ includedCount: Ze,
1605
+ data: Re,
1606
+ included: Ke,
1607
+ dataTruncated: Ye,
1608
+ includedTruncated: ke
1609
+ }), z.data;
1610
+ } catch (z) {
1611
+ if (G({
1600
1612
  type: "error",
1601
1613
  modelName: c.modelName,
1602
1614
  configKey: c.configKey,
1603
- semanticKey: I,
1615
+ semanticKey: F,
1604
1616
  operationType: e,
1605
1617
  operationId: s,
1606
1618
  canonicalId: o,
1607
- url: U,
1608
- status: D?.response?.status,
1609
- message: D?.message
1610
- }), D?.code === "ECONNREFUSED") {
1611
- const F = "Connection refused. If you're running tests, start the test server with `python manage.py statezero_testserver`.";
1612
- throw new Error(`${F} (${U})`);
1619
+ url: Q,
1620
+ status: z?.response?.status,
1621
+ message: z?.message
1622
+ }), z?.code === "ECONNREFUSED") {
1623
+ const D = "Connection refused. If you're running tests, start the test server with `python manage.py statezero_testserver`.";
1624
+ throw new Error(`${D} (${Q})`);
1613
1625
  }
1614
- if (D.response && D.response.data) {
1615
- const F = Ps(D.response.data);
1616
- throw Error.captureStackTrace && Error.captureStackTrace(F, L), F;
1626
+ if (z.response && z.response.data) {
1627
+ const D = Fs(z.response.data);
1628
+ throw Error.captureStackTrace && Error.captureStackTrace(D, V), D;
1617
1629
  }
1618
- throw new Error(`API call failed: ${D.message}`);
1630
+ throw new Error(`API call failed: ${z.message}`);
1619
1631
  }
1620
- }, pe = Hs(l), ae = b ? pe.add(re) : re();
1632
+ }, pe = Hs(l), ae = k ? pe.add(re) : re();
1621
1633
  return a ? qs(ae, a) : ae;
1622
1634
  }
1623
- class Gt {
1635
+ class Vt {
1624
1636
  // Supported Django strftime formats and their date-fns equivalents
1625
1637
  static SUPPORTED_FORMATS = {
1626
1638
  "iso-8601": null,
@@ -1715,7 +1727,7 @@ class Gt {
1715
1727
  function Js(n) {
1716
1728
  if (!n || !n.configKey)
1717
1729
  return "UTC";
1718
- const e = Fe.getConfig();
1730
+ const e = De.getConfig();
1719
1731
  return (e.backendConfigs[n.configKey] || e.backendConfigs.default).BACKEND_TZ || "UTC";
1720
1732
  }
1721
1733
  const Bt = {
@@ -1723,7 +1735,7 @@ const Bt = {
1723
1735
  toInternal: (n, e = {}) => {
1724
1736
  if (typeof n == "string")
1725
1737
  throw new Error("File field expects a file object, not a string path");
1726
- if (E(n))
1738
+ if (b(n))
1727
1739
  return null;
1728
1740
  if (typeof n != "object" || Array.isArray(n))
1729
1741
  throw new Error(`expected file object, got ${Array.isArray(n) ? "array" : typeof n}`);
@@ -1738,7 +1750,7 @@ const Bt = {
1738
1750
  // Return object with both formats for maximum compatibility
1739
1751
  toLive: (n, e = {}) => {
1740
1752
  if (!n || typeof n != "object") return n;
1741
- const t = e.model?.constructor?.configKey || "default", s = n.file_url ? Fe.buildFileUrl(n.file_url, t) : null;
1753
+ const t = e.model?.constructor?.configKey || "default", s = n.file_url ? De.buildFileUrl(n.file_url, t) : null;
1742
1754
  return {
1743
1755
  // snake_case (backend format)
1744
1756
  file_path: n.file_path,
@@ -1755,23 +1767,23 @@ const Bt = {
1755
1767
  mimeType: n.mime_type
1756
1768
  };
1757
1769
  }
1758
- }, Ht = {
1770
+ }, Gt = {
1759
1771
  toInternal: (n, e = {}) => {
1760
- if (E(n) || typeof n == "string") return n;
1772
+ if (b(n) || typeof n == "string") return n;
1761
1773
  if (n instanceof Date) {
1762
1774
  const { model: t, field: s, fieldSchema: r } = e, o = t?.schema || r?.format && {
1763
1775
  properties: { [s]: { format: r.format } }
1764
1776
  };
1765
- return o ? Gt.serializeDate(n, s, o) : n.toISOString();
1777
+ return o ? Vt.serializeDate(n, s, o) : n.toISOString();
1766
1778
  }
1767
1779
  throw new Error(`expected string or Date, got ${typeof n}`);
1768
1780
  },
1769
1781
  toLive: (n, e = {}) => {
1770
- if (E(n) || typeof n != "string") return n;
1782
+ if (b(n) || typeof n != "string") return n;
1771
1783
  const { model: t, field: s } = e;
1772
1784
  if (t?.schema) {
1773
1785
  const r = Js(t);
1774
- return Gt.parseDate(n, s, t.schema, r);
1786
+ return Vt.parseDate(n, s, t.schema, r);
1775
1787
  }
1776
1788
  try {
1777
1789
  return new Date(n);
@@ -1779,9 +1791,9 @@ const Bt = {
1779
1791
  return console.warn(`Failed to parse date: ${n}`), n;
1780
1792
  }
1781
1793
  }
1782
- }, ke = {
1794
+ }, Ee = {
1783
1795
  toInternal: (n, e = {}) => {
1784
- if (E(n)) return n;
1796
+ if (b(n)) return n;
1785
1797
  const t = n.pk || n;
1786
1798
  if (typeof t != "string" && typeof t != "number")
1787
1799
  throw new Error(
@@ -1790,13 +1802,13 @@ const Bt = {
1790
1802
  return t;
1791
1803
  },
1792
1804
  toLive: (n, e = {}) => {
1793
- if (E(n)) return n;
1805
+ if (b(n)) return n;
1794
1806
  const { model: t, field: s } = e;
1795
1807
  return t.relationshipFields.has(s) && n ? t.relationshipFields.get(s).ModelClass().fromPk(n) : n;
1796
1808
  }
1797
1809
  }, Ws = {
1798
1810
  toInternal: (n, e = {}) => {
1799
- if (E(n)) return n;
1811
+ if (b(n)) return n;
1800
1812
  if (!Array.isArray(n)) throw new Error(`expected array, got ${typeof n}`);
1801
1813
  return n.map((t) => {
1802
1814
  const s = t.pk || t;
@@ -1808,7 +1820,7 @@ const Bt = {
1808
1820
  });
1809
1821
  },
1810
1822
  toLive: (n, e = {}) => {
1811
- if (E(n)) return n;
1823
+ if (b(n)) return n;
1812
1824
  const { model: t, field: s } = e;
1813
1825
  if (t.relationshipFields.has(s) && n) {
1814
1826
  const r = t.relationshipFields.get(s);
@@ -1824,25 +1836,25 @@ const Bt = {
1824
1836
  string: {
1825
1837
  "file-path": Bt,
1826
1838
  "image-path": Bt,
1827
- date: Ht,
1828
- "date-time": Ht,
1829
- "foreign-key": ke,
1830
- "one-to-one": ke
1839
+ date: Gt,
1840
+ "date-time": Gt,
1841
+ "foreign-key": Ee,
1842
+ "one-to-one": Ee
1831
1843
  },
1832
1844
  integer: {
1833
- "foreign-key": ke,
1834
- "one-to-one": ke
1845
+ "foreign-key": Ee,
1846
+ "one-to-one": Ee
1835
1847
  },
1836
1848
  // Add other PK types as needed
1837
1849
  uuid: {
1838
- "foreign-key": ke,
1839
- "one-to-one": ke
1850
+ "foreign-key": Ee,
1851
+ "one-to-one": Ee
1840
1852
  },
1841
1853
  array: {
1842
1854
  "many-to-many": Ws
1843
1855
  }
1844
1856
  };
1845
- class ss {
1857
+ class ts {
1846
1858
  constructor(e) {
1847
1859
  this.modelClass = e;
1848
1860
  }
@@ -1900,15 +1912,15 @@ class ss {
1900
1912
  function Zs(n) {
1901
1913
  if (!n || !n.configKey)
1902
1914
  return "UTC";
1903
- const e = Fe.getConfig();
1915
+ const e = De.getConfig();
1904
1916
  return (e.backendConfigs[n.configKey] || e.backendConfigs.default).BACKEND_TZ || "UTC";
1905
1917
  }
1906
1918
  function Ys(n, e, t) {
1907
1919
  if (!t?.schema || !n) return e;
1908
- const s = new ss(t);
1920
+ const s = new ts(t);
1909
1921
  return Array.isArray(e) ? e.map((r) => s.toLiveField(n, r)) : s.toLiveField(n, e);
1910
1922
  }
1911
- function De(n, e, t, s = {}) {
1923
+ function ze(n, e, t, s = {}) {
1912
1924
  const r = n.split("__"), o = [
1913
1925
  "exact",
1914
1926
  "iexact",
@@ -1936,64 +1948,64 @@ function De(n, e, t, s = {}) {
1936
1948
  ], i = ["year", "month", "day", "week_day", "hour", "minute", "second", "date", "time"], l = ["gt", "gte", "lt", "lte", "exact"];
1937
1949
  let a = [], c = [...r];
1938
1950
  if (r.length >= 3) {
1939
- const b = r[r.length - 2], k = r[r.length - 1];
1940
- i.includes(b) && l.includes(k) && (a = [b, k], c = r.slice(0, -2));
1951
+ const k = r[r.length - 2], E = r[r.length - 1];
1952
+ i.includes(k) && l.includes(E) && (a = [k, E], c = r.slice(0, -2));
1941
1953
  }
1942
- let f = null;
1943
- a.length === 0 && r.length > 1 && o.includes(r[r.length - 1]) && (f = r[r.length - 1], c = r.slice(0, -1));
1954
+ let h = null;
1955
+ a.length === 0 && r.length > 1 && o.includes(r[r.length - 1]) && (h = r[r.length - 1], c = r.slice(0, -1));
1944
1956
  let p = t, m = [], y = !1, _ = !1, w = null;
1945
- for (let b = 0; b < c.length; b++) {
1946
- let k = c[b];
1947
- k === "pk" && p && (k = p.primaryKeyField);
1948
- const U = b === c.length - 1;
1949
- if (p && p.relationshipFields && p.relationshipFields instanceof Map && p.relationshipFields.has(k)) {
1950
- const N = p.relationshipFields.get(k), I = N.ModelClass(), re = N.relationshipType;
1951
- if (!U && re === "many-to-many") {
1952
- let ae = c.slice(b + 1).join("__");
1953
- a.length > 0 ? ae += "__" + a.join("__") : f && (ae += "__" + f);
1954
- const D = De(ae, e, I, s), F = m.length > 0 ? m.join(".") + "." + k : k, K = D.requiredPath || D.field, me = `${F}.${K}`;
1957
+ for (let k = 0; k < c.length; k++) {
1958
+ let E = c[k];
1959
+ E === "pk" && p && (E = p.primaryKeyField);
1960
+ const Q = k === c.length - 1;
1961
+ if (p && p.relationshipFields && p.relationshipFields instanceof Map && p.relationshipFields.has(E)) {
1962
+ const N = p.relationshipFields.get(E), F = N.ModelClass(), re = N.relationshipType;
1963
+ if (!Q && re === "many-to-many") {
1964
+ let ae = c.slice(k + 1).join("__");
1965
+ a.length > 0 ? ae += "__" + a.join("__") : h && (ae += "__" + h);
1966
+ const z = ze(ae, e, F, s), D = m.length > 0 ? m.join(".") + "." + E : E, K = z.requiredPath || z.field, me = `${D}.${K}`;
1955
1967
  return {
1956
- field: F,
1957
- operator: { $elemMatch: { [D.field]: D.operator } },
1968
+ field: D,
1969
+ operator: { $elemMatch: { [z.field]: z.operator } },
1958
1970
  isM2M: !0,
1959
1971
  requiredPath: me
1960
1972
  // Full path for data picking
1961
1973
  };
1962
1974
  }
1963
- if (m.push(k), !U)
1964
- p = I;
1975
+ if (m.push(E), !Q)
1976
+ p = F;
1965
1977
  else {
1966
1978
  if (y = !0, re === "many-to-many")
1967
- _ = !0, w = k;
1979
+ _ = !0, w = E;
1968
1980
  else {
1969
- const pe = I.primaryKeyField || "id";
1981
+ const pe = F.primaryKeyField || "id";
1970
1982
  m.push(pe), w = pe;
1971
1983
  }
1972
- p = I;
1984
+ p = F;
1973
1985
  }
1974
- } else if (p && p.fields && p.fields.includes(k)) {
1975
- if (m.push(k), w = k, U)
1986
+ } else if (p && p.fields && p.fields.includes(E)) {
1987
+ if (m.push(E), w = E, Q)
1976
1988
  break;
1977
- const N = p.schema?.properties?.[k];
1989
+ const N = p.schema?.properties?.[E];
1978
1990
  if (N && N.format === "json") {
1979
- const I = c.slice(b + 1);
1980
- m.push(...I);
1991
+ const F = c.slice(k + 1);
1992
+ m.push(...F);
1981
1993
  break;
1982
1994
  }
1983
- throw new Error(`Field '${k}' in '${n}' is not a relationship field and cannot be traversed.`);
1995
+ throw new Error(`Field '${E}' in '${n}' is not a relationship field and cannot be traversed.`);
1984
1996
  } else
1985
- throw new Error(`Field '${k}' in '${n}' not found in model ${p.modelName}.`);
1997
+ throw new Error(`Field '${E}' in '${n}' not found in model ${p.modelName}.`);
1986
1998
  }
1987
- const v = m.join("."), T = i.includes(f) || a.length === 2 && i.includes(a[0]) ? e : Ys(w, e, p);
1999
+ const v = m.join("."), T = i.includes(h) || a.length === 2 && i.includes(a[0]) ? e : Ys(w, e, p);
1988
2000
  if (a.length === 2) {
1989
- const [b, k] = a;
1990
- return Xs(v, b, k, T, y);
2001
+ const [k, E] = a;
2002
+ return Xs(v, k, E, T, y);
1991
2003
  }
1992
- if (f)
1993
- return er(v, f, T, y, p, w, _);
2004
+ if (h)
2005
+ return er(v, h, T, y, p, w, _);
1994
2006
  if (y) {
1995
- let b = T;
1996
- return T && typeof T == "object" && "pk" in T && (b = T.pk), _ ? { field: v, operator: { $elemMatch: { pk: { $eq: b } } }, isM2M: !0 } : { field: v, operator: { $eq: b } };
2007
+ let k = T;
2008
+ return T && typeof T == "object" && "pk" in T && (k = T.pk), _ ? { field: v, operator: { $elemMatch: { pk: { $eq: k } } }, isM2M: !0 } : { field: v, operator: { $eq: k } };
1997
2009
  }
1998
2010
  return { field: v, operator: { $eq: T } };
1999
2011
  }
@@ -2016,8 +2028,8 @@ function er(n, e, t, s, r, o, i = !1) {
2016
2028
  // document-level operator
2017
2029
  requiredPath: n,
2018
2030
  // need the M2M field itself for data picking
2019
- operator: function(f) {
2020
- const p = f[a], m = p === null || Array.isArray(p) && p.length === 0;
2031
+ operator: function(h) {
2032
+ const p = h[a], m = p === null || Array.isArray(p) && p.length === 0;
2021
2033
  return c ? m : !m;
2022
2034
  }
2023
2035
  };
@@ -2059,15 +2071,15 @@ function er(n, e, t, s, r, o, i = !1) {
2059
2071
  } : e === "in" ? { field: n, operator: { $in: t } } : e === "gt" ? { field: n, operator: { $nin: [null, void 0], $gt: t } } : e === "gte" ? { field: n, operator: { $nin: [null, void 0], $gte: t } } : e === "lt" ? { field: n, operator: { $nin: [null, void 0], $lt: t } } : e === "lte" ? { field: n, operator: { $nin: [null, void 0], $lte: t } } : { field: n, operator: { $eq: t } };
2060
2072
  }
2061
2073
  function tr(n = "UTC", e = null) {
2062
- const t = e ? new ss(e) : null, s = (a, c = null) => a ? a instanceof Date ? a : t && c && typeof a == "string" ? t.toLiveField(c, a) : (console.warn("Date conversion without serializer context:", a), null) : null, r = (a, c, f = null) => {
2063
- const p = s(a, f);
2074
+ const t = e ? new ts(e) : null, s = (a, c = null) => a ? a instanceof Date ? a : t && c && typeof a == "string" ? t.toLiveField(c, a) : (console.warn("Date conversion without serializer context:", a), null) : null, r = (a, c, h = null) => {
2075
+ const p = s(a, h);
2064
2076
  if (!p || !(p instanceof Date) || isNaN(p.getTime()))
2065
2077
  return null;
2066
2078
  const m = _e.fromJSDate(p).setZone(n);
2067
2079
  return c(m);
2068
2080
  }, o = {
2069
2081
  // Year - same in both
2070
- $year(a, c, f) {
2082
+ $year(a, c, h) {
2071
2083
  const p = typeof a == "string" ? Number(a) : a;
2072
2084
  return ee(
2073
2085
  (m) => {
@@ -2075,11 +2087,11 @@ function tr(n = "UTC", e = null) {
2075
2087
  return y !== null && y === p;
2076
2088
  },
2077
2089
  c,
2078
- f
2090
+ h
2079
2091
  );
2080
2092
  },
2081
2093
  // Month - Luxon is 1-indexed like Django
2082
- $month(a, c, f) {
2094
+ $month(a, c, h) {
2083
2095
  const p = typeof a == "string" ? Number(a) : a;
2084
2096
  return ee(
2085
2097
  (m) => {
@@ -2087,11 +2099,11 @@ function tr(n = "UTC", e = null) {
2087
2099
  return y !== null && y === p;
2088
2100
  },
2089
2101
  c,
2090
- f
2102
+ h
2091
2103
  );
2092
2104
  },
2093
2105
  // Day of month - same in both
2094
- $day(a, c, f) {
2106
+ $day(a, c, h) {
2095
2107
  const p = typeof a == "string" ? Number(a) : a;
2096
2108
  return ee(
2097
2109
  (m) => {
@@ -2099,11 +2111,11 @@ function tr(n = "UTC", e = null) {
2099
2111
  return y !== null && y === p;
2100
2112
  },
2101
2113
  c,
2102
- f
2114
+ h
2103
2115
  );
2104
2116
  },
2105
2117
  // Day of week - convert to Django's 1=Sunday format
2106
- $week_day(a, c, f) {
2118
+ $week_day(a, c, h) {
2107
2119
  const p = typeof a == "string" ? Number(a) : a;
2108
2120
  return ee(
2109
2121
  (m) => {
@@ -2111,11 +2123,11 @@ function tr(n = "UTC", e = null) {
2111
2123
  return y !== null && y === p;
2112
2124
  },
2113
2125
  c,
2114
- f
2126
+ h
2115
2127
  );
2116
2128
  },
2117
2129
  // Hour - same in both
2118
- $hour(a, c, f) {
2130
+ $hour(a, c, h) {
2119
2131
  const p = typeof a == "string" ? Number(a) : a;
2120
2132
  return ee(
2121
2133
  (m) => {
@@ -2123,11 +2135,11 @@ function tr(n = "UTC", e = null) {
2123
2135
  return y !== null && y === p;
2124
2136
  },
2125
2137
  c,
2126
- f
2138
+ h
2127
2139
  );
2128
2140
  },
2129
2141
  // Minute - same in both
2130
- $minute(a, c, f) {
2142
+ $minute(a, c, h) {
2131
2143
  const p = typeof a == "string" ? Number(a) : a;
2132
2144
  return ee(
2133
2145
  (m) => {
@@ -2135,11 +2147,11 @@ function tr(n = "UTC", e = null) {
2135
2147
  return y !== null && y === p;
2136
2148
  },
2137
2149
  c,
2138
- f
2150
+ h
2139
2151
  );
2140
2152
  },
2141
2153
  // Second - same in both
2142
- $second(a, c, f) {
2154
+ $second(a, c, h) {
2143
2155
  const p = typeof a == "string" ? Number(a) : a;
2144
2156
  return ee(
2145
2157
  (m) => {
@@ -2147,11 +2159,11 @@ function tr(n = "UTC", e = null) {
2147
2159
  return y !== null && y === p;
2148
2160
  },
2149
2161
  c,
2150
- f
2162
+ h
2151
2163
  );
2152
2164
  },
2153
2165
  // Date - extract date portion (ignore time)
2154
- $date(a, c, f) {
2166
+ $date(a, c, h) {
2155
2167
  return ee(
2156
2168
  (p, m) => {
2157
2169
  const y = s(p, m);
@@ -2163,11 +2175,11 @@ function tr(n = "UTC", e = null) {
2163
2175
  return w.year === v.year && w.month === v.month && w.day === v.day;
2164
2176
  },
2165
2177
  c,
2166
- f
2178
+ h
2167
2179
  );
2168
2180
  },
2169
2181
  // Time - extract time portion (ignore date)
2170
- $time(a, c, f) {
2182
+ $time(a, c, h) {
2171
2183
  return ee(
2172
2184
  (p, m) => {
2173
2185
  const y = s(p, m);
@@ -2181,13 +2193,13 @@ function tr(n = "UTC", e = null) {
2181
2193
  } else {
2182
2194
  const T = s(a, m);
2183
2195
  if (!T) return !1;
2184
- const b = _e.fromJSDate(T).setZone(n);
2185
- w = b.hour, v = b.minute, O = b.second;
2196
+ const k = _e.fromJSDate(T).setZone(n);
2197
+ w = k.hour, v = k.minute, O = k.second;
2186
2198
  }
2187
2199
  return _.hour === w && _.minute === v && _.second === O;
2188
2200
  },
2189
2201
  c,
2190
- f
2202
+ h
2191
2203
  );
2192
2204
  }
2193
2205
  }, i = {
@@ -2205,24 +2217,24 @@ function tr(n = "UTC", e = null) {
2205
2217
  }, l = ["gt", "gte", "lt", "lte", "exact"];
2206
2218
  return Object.keys(i).forEach((a) => {
2207
2219
  const c = i[a];
2208
- l.forEach((f) => {
2209
- o[`$${a}_${f}`] = (p, m, y) => ee(
2220
+ l.forEach((h) => {
2221
+ o[`$${a}_${h}`] = (p, m, y) => ee(
2210
2222
  (_, w) => {
2211
2223
  const v = s(_, w);
2212
2224
  if (!v || !(v instanceof Date) || isNaN(v.getTime()))
2213
2225
  return !1;
2214
- const O = _e.fromJSDate(v).setZone(n), T = c(O), b = a === "date" ? p : typeof p == "string" ? Number(p) : p;
2215
- switch (f) {
2226
+ const O = _e.fromJSDate(v).setZone(n), T = c(O), k = a === "date" ? p : typeof p == "string" ? Number(p) : p;
2227
+ switch (h) {
2216
2228
  case "gt":
2217
- return T > b;
2229
+ return T > k;
2218
2230
  case "gte":
2219
- return T >= b;
2231
+ return T >= k;
2220
2232
  case "lt":
2221
- return T < b;
2233
+ return T < k;
2222
2234
  case "lte":
2223
- return T <= b;
2235
+ return T <= k;
2224
2236
  case "exact":
2225
- return T === b;
2237
+ return T === k;
2226
2238
  default:
2227
2239
  return !1;
2228
2240
  }
@@ -2235,7 +2247,7 @@ function tr(n = "UTC", e = null) {
2235
2247
  }
2236
2248
  function sr(n, e) {
2237
2249
  const t = Zs(e);
2238
- return Zt(n, {
2250
+ return Wt(n, {
2239
2251
  operations: tr(t, e)
2240
2252
  });
2241
2253
  }
@@ -2243,10 +2255,10 @@ function pt(n, e) {
2243
2255
  const t = {}, s = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
2244
2256
  for (const [o, i] of Object.entries(n))
2245
2257
  try {
2246
- const l = De(o, i, e), { field: a, operator: c, isDatePart: f, isM2M: p } = l;
2247
- f ? (s.has(a) || s.set(a, []), s.get(a).push({ [a]: c })) : p && c.$elemMatch ? (r.has(a) || r.set(a, []), r.get(a).push(c.$elemMatch)) : t[a] ? t[a] = { ...t[a], ...c } : t[a] = c;
2258
+ const l = ze(o, i, e), { field: a, operator: c, isDatePart: h, isM2M: p } = l;
2259
+ h ? (s.has(a) || s.set(a, []), s.get(a).push({ [a]: c })) : p && c.$elemMatch ? (r.has(a) || r.set(a, []), r.get(a).push(c.$elemMatch)) : t[a] ? t[a] = { ...t[a], ...c } : t[a] = c;
2248
2260
  } catch (l) {
2249
- throw new Oe(`Failed to process field '${o}': ${l.message}`);
2261
+ throw new $e(`Failed to process field '${o}': ${l.message}`);
2250
2262
  }
2251
2263
  for (const [o, i] of r.entries())
2252
2264
  i.length === 1 ? t[o] = { $elemMatch: i[0] } : t[o] = { $elemMatch: { $and: i } };
@@ -2272,7 +2284,7 @@ function rr(n, e) {
2272
2284
  $or: n.map((t) => "operator" in t && "conditions" in t ? { [t.operator === "AND" ? "$and" : "$or"]: t.conditions.map((r) => pt(r, e)) } : pt(t, e))
2273
2285
  };
2274
2286
  }
2275
- function He(n, e) {
2287
+ function Ge(n, e) {
2276
2288
  if (!n) return null;
2277
2289
  if (n.type === "filter") {
2278
2290
  const { conditions: t, Q: s } = n;
@@ -2285,15 +2297,15 @@ function He(n, e) {
2285
2297
  return r;
2286
2298
  }
2287
2299
  if (n.type === "and" && n.children) {
2288
- const t = n.children.map((s) => He(s, e)).filter((s) => s != null);
2300
+ const t = n.children.map((s) => Ge(s, e)).filter((s) => s != null);
2289
2301
  return t.length === 0 ? null : t.length === 1 ? t[0] : { $and: t };
2290
2302
  }
2291
2303
  if (n.type === "or" && n.children) {
2292
- const t = n.children.map((s) => He(s, e)).filter((s) => s != null);
2304
+ const t = n.children.map((s) => Ge(s, e)).filter((s) => s != null);
2293
2305
  return t.length === 0 ? null : t.length === 1 ? t[0] : { $or: t };
2294
2306
  }
2295
2307
  if (n.type === "exclude" && n.child) {
2296
- const t = He(n.child, e);
2308
+ const t = Ge(n.child, e);
2297
2309
  return t ? { $not: t } : null;
2298
2310
  }
2299
2311
  return null;
@@ -2307,7 +2319,7 @@ function nr(n, e, t) {
2307
2319
  }
2308
2320
  const o = s.map((i) => {
2309
2321
  try {
2310
- const { field: l } = De(i, "", t);
2322
+ const { field: l } = ze(i, "", t);
2311
2323
  return {
2312
2324
  [l]: {
2313
2325
  $regex: new RegExp(r(e.searchQuery), "i")
@@ -2321,9 +2333,9 @@ function nr(n, e, t) {
2321
2333
  };
2322
2334
  }
2323
2335
  });
2324
- return n.filter(Zt({ $or: o }));
2336
+ return n.filter(Wt({ $or: o }));
2325
2337
  }
2326
- function qt(n, e) {
2338
+ function Ht(n, e) {
2327
2339
  const t = e.split(".");
2328
2340
  let s = n;
2329
2341
  for (const r of t) {
@@ -2337,7 +2349,7 @@ function or(n, e) {
2337
2349
  return n.map((t) => {
2338
2350
  const s = t.startsWith("-"), r = s ? t.substring(1) : t;
2339
2351
  try {
2340
- const { field: o } = De(r, "", e);
2352
+ const { field: o } = ze(r, "", e);
2341
2353
  return {
2342
2354
  field: o,
2343
2355
  desc: s
@@ -2355,7 +2367,7 @@ function ir(n, e, t) {
2355
2367
  const s = or(e, t);
2356
2368
  return [...n].sort((r, o) => {
2357
2369
  for (const { field: i, desc: l } of s) {
2358
- const a = qt(r, i), c = qt(o, i);
2370
+ const a = Ht(r, i), c = Ht(o, i);
2359
2371
  if (a !== c) {
2360
2372
  if (a === null && c !== null) return l ? -1 : 1;
2361
2373
  if (a !== null && c === null) return l ? 1 : -1;
@@ -2376,7 +2388,7 @@ function mt(n, e, t) {
2376
2388
  const s = t.primaryKeyField;
2377
2389
  let r = [...n];
2378
2390
  if (e.filter) {
2379
- const o = He(e.filter, t);
2391
+ const o = Ge(e.filter, t);
2380
2392
  o && Object.keys(o).length && (r = r.filter(sr(o, t)));
2381
2393
  }
2382
2394
  return e.search && e.search.searchQuery && (r = nr(r, e.search, t)), Array.isArray(e.orderBy) && e.orderBy.length && (r = ir(r, e.orderBy, t)), r.map((o) => o[s]);
@@ -2386,9 +2398,9 @@ function yt(n, e) {
2386
2398
  t.add(s);
2387
2399
  function r(i) {
2388
2400
  try {
2389
- const { field: l, isM2M: a, requiredPath: c } = De(i, null, e);
2390
- let f;
2391
- c ? f = c : a ? f = `${l}.pk` : f = l, t.add(f);
2401
+ const { field: l, isM2M: a, requiredPath: c } = ze(i, null, e);
2402
+ let h;
2403
+ c ? h = c : a ? h = `${l}.pk` : h = l, t.add(h);
2392
2404
  } catch (l) {
2393
2405
  console.warn(`getRequiredFields: couldn't process "${i}": ${l.message}`);
2394
2406
  }
@@ -2429,7 +2441,7 @@ function _t(n, e) {
2429
2441
  gt(t, e, r);
2430
2442
  }), t;
2431
2443
  }
2432
- function wt(n, e, t, s = !1) {
2444
+ function ss(n, e, t, s = !1) {
2433
2445
  if (!Array.isArray(n) || n.length === 0)
2434
2446
  return [];
2435
2447
  if (!t)
@@ -2452,13 +2464,13 @@ class ar {
2452
2464
  groundTruthPks;
2453
2465
  isSyncing;
2454
2466
  constructor(e, t, s, r = null, o = null, i = {}) {
2455
- if (this.modelClass = e, this.fetchFn = t, this.queryset = s, this.isSyncing = !1, this.lastSync = null, this.isTemp = i.isTemp || !1, this.pruneThreshold = i.pruneThreshold || 10, this.groundTruthPks = r || [], this.operationsMap = /* @__PURE__ */ new Map(), this.includedPks = /* @__PURE__ */ new Map(), Array.isArray(o))
2467
+ if (this.modelClass = e, this.fetchFn = t, this.queryset = s, this.isSyncing = !1, this.lastSync = null, this._createdAt = Date.now(), this.isTemp = i.isTemp || !1, this.pruneThreshold = i.pruneThreshold || 10, this.groundTruthPks = r || [], this.operationsMap = /* @__PURE__ */ new Map(), this.includedPks = /* @__PURE__ */ new Map(), Array.isArray(o))
2456
2468
  for (const l of o) {
2457
- const c = Pe.get(l.operationId) || new q(l, !0);
2469
+ const c = Fe.get(l.operationId) || new q(l, !0);
2458
2470
  this.operationsMap.set(c.operationId, c);
2459
2471
  }
2460
- if (this.qsCache = new vt("queryset-cache", {}, this.onHydrated.bind(this)), this._lastRenderedPks = null, this.renderCallbacks = /* @__PURE__ */ new Set(), !this.isTemp) {
2461
- const l = Q.getStore(this.modelClass);
2472
+ if (this.qsCache = new Ct("queryset-cache", {}, this.onHydrated.bind(this)), this._lastRenderedPks = null, this.renderCallbacks = /* @__PURE__ */ new Set(), !this.isTemp) {
2473
+ const l = j.getStore(this.modelClass);
2462
2474
  this._modelStoreUnregister = l.registerRenderCallback(() => {
2463
2475
  this._emitRenderEvent();
2464
2476
  });
@@ -2469,15 +2481,14 @@ class ar {
2469
2481
  return this.queryset.semanticKey;
2470
2482
  }
2471
2483
  onHydrated(e) {
2472
- if (this.groundTruthPks.length === 0 && this.operationsMap.size === 0) {
2473
- const t = this.qsCache.get(this.cacheKey);
2474
- !E(t) && !ve(t) && this.setGroundTruth(t);
2475
- }
2484
+ if (this.lastSync !== null || this.groundTruthPks.length > 0 || this.operationsMap.size > 0) return;
2485
+ const t = this.qsCache.get(this.cacheKey);
2486
+ !b(t) && !ve(t) && (this.groundTruthPks = Array.isArray(t) ? t : [], this._emitRenderEvent());
2476
2487
  }
2477
2488
  setCache(e) {
2478
2489
  let t = [];
2479
2490
  e.forEach((s) => {
2480
- typeof s == "string" && Je(s) && (s = We(s), E(s) || ve(dt(s))) || t.push(s);
2491
+ typeof s == "string" && qe(s) && (s = Je(s), b(s) || ve(dt(s))) || t.push(s);
2481
2492
  }), this.qsCache.set(this.cacheKey, t);
2482
2493
  }
2483
2494
  clearCache() {
@@ -2501,7 +2512,7 @@ class ar {
2501
2512
  } catch (s) {
2502
2513
  console.warn("Error in render callback:", s);
2503
2514
  }
2504
- }), qe(e, this._lastRenderedPks) || (this._lastRenderedPks = e, bs.emit(
2515
+ }), He(e, this._lastRenderedPks) || (this._lastRenderedPks = e, bs.emit(
2505
2516
  `${this.modelClass.configKey}::${this.modelClass.modelName}::queryset::render`,
2506
2517
  { ast: this.queryset.build(), ModelClass: this.modelClass }
2507
2518
  ));
@@ -2556,7 +2567,7 @@ class ar {
2556
2567
  */
2557
2568
  registerWithModelStore() {
2558
2569
  if (this._modelStoreUnregister) return;
2559
- const e = Q.getStore(this.modelClass);
2570
+ const e = j.getStore(this.modelClass);
2560
2571
  this._modelStoreUnregister = e.registerRenderCallback(() => {
2561
2572
  this._emitRenderEvent();
2562
2573
  });
@@ -2568,15 +2579,39 @@ class ar {
2568
2579
  */
2569
2580
  _getValidatedAndFilteredPks(e) {
2570
2581
  const t = Array.from(e).map((o) => this.modelClass.fromPk(o, this.queryset)).filter(
2571
- (o) => Q.getEntity(this.modelClass, o.pk) !== null
2582
+ (o) => j.getEntity(this.modelClass, o.pk) !== null
2572
2583
  ), s = this.queryset.build();
2573
- return wt(t, s, this.modelClass, !1);
2584
+ return ss(t, s, this.modelClass, !1);
2585
+ }
2586
+ /**
2587
+ * For offset pages that aren't full, expand with creates from the model store
2588
+ * that sort after the first item on the page (direction-adjusted).
2589
+ */
2590
+ _fillOffsetPage(e, t) {
2591
+ const s = j.getStore(this.modelClass);
2592
+ if (!s) return null;
2593
+ const r = this.queryset._orderBy;
2594
+ if (!r || r.length === 0) return null;
2595
+ const o = r[0].replace(/^-/, ""), i = r[0].startsWith("-"), l = this.modelClass.fromPk(e[0], this.queryset);
2596
+ if (!l) return null;
2597
+ const a = l[o];
2598
+ if (a == null) return null;
2599
+ const c = this.pkField, h = new Set(e), p = new Set(e);
2600
+ for (const m of s.operations)
2601
+ if (m.status !== C.REJECTED && !(!t && m.status !== C.CONFIRMED) && !(m.type !== P.CREATE && m.type !== P.BULK_CREATE && m.type !== P.GET_OR_CREATE && m.type !== P.UPDATE_OR_CREATE))
2602
+ for (const y of m.instances) {
2603
+ if (!y || y[c] == null || h.has(y[c])) continue;
2604
+ const _ = y[o];
2605
+ if (_ == null) continue;
2606
+ (i ? _ <= a : _ >= a) && p.add(y[c]);
2607
+ }
2608
+ return p.size === h.size ? null : this._getValidatedAndFilteredPks(Array.from(p));
2574
2609
  }
2575
2610
  render(e = !0, t = !1) {
2576
2611
  if (t) {
2577
- const l = this.qsCache.get(this.cacheKey);
2578
- if (Array.isArray(l))
2579
- return B({
2612
+ const a = this.qsCache.get(this.cacheKey);
2613
+ if (Array.isArray(a))
2614
+ return G({
2580
2615
  type: "render",
2581
2616
  source: "cache",
2582
2617
  semanticKey: this.queryset.semanticKey,
@@ -2585,15 +2620,19 @@ class ar {
2585
2620
  optimistic: e,
2586
2621
  groundTruthCount: this.groundTruthPks.length,
2587
2622
  operationsCount: this.operationsMap.size,
2588
- resultCount: l.length
2589
- }), l;
2623
+ resultCount: a.length
2624
+ }), a;
2590
2625
  }
2591
- const s = this.groundTruthPks.length === 0 && this.lastSync === null ? this.renderFromModelStore() : this.renderFromData(e);
2626
+ const s = this.renderFromData(e);
2592
2627
  let r = this._getValidatedAndFilteredPks(s);
2593
2628
  const o = r.length, i = this.queryset.build().serializerOptions?.limit;
2594
- return i && (r = r.slice(0, i)), this.setCache(r), B({
2629
+ if ((this.queryset._serializerOptions?.offset ?? 0) > 0 && i && r.length > 0 && r.length < i) {
2630
+ const a = this._fillOffsetPage(r, e);
2631
+ a && (r = a);
2632
+ }
2633
+ return i && (r = r.slice(0, i)), this.setCache(r), G({
2595
2634
  type: "render",
2596
- source: this.groundTruthPks.length === 0 && this.lastSync === null ? "modelStore" : "groundTruth",
2635
+ source: "groundTruth",
2597
2636
  semanticKey: this.queryset.semanticKey,
2598
2637
  modelName: this.modelClass.modelName,
2599
2638
  configKey: this.modelClass.configKey,
@@ -2607,18 +2646,44 @@ class ar {
2607
2646
  }), r;
2608
2647
  }
2609
2648
  renderFromData(e = !0) {
2610
- const t = this.groundTruthSet;
2611
- for (const r of this.operations)
2612
- r.status !== C.REJECTED && (e || r.status === C.CONFIRMED) && this.applyOperation(r, t);
2613
- return Array.from(t);
2649
+ const t = j.getStore(this.modelClass);
2650
+ if (this.isTemp && this.lastSync === null && t) {
2651
+ const i = this.pkField;
2652
+ return t.render().map((l) => l[i]).filter((l) => l != null);
2653
+ }
2654
+ if (!this.isTemp && this.lastSync === null && t) {
2655
+ if (!((this.queryset._serializerOptions?.offset ?? 0) > 0)) {
2656
+ const c = this.pkField;
2657
+ return t.render().map((h) => h[c]).filter((h) => h != null);
2658
+ }
2659
+ const { root: l } = x.querysetStoreGraph.findRoot(this.queryset), a = l ? x._stores.get(l) : null;
2660
+ if (a && a !== this && a.lastSync !== null)
2661
+ return a.render();
2662
+ }
2663
+ if ((this.queryset._serializerOptions?.offset ?? 0) > 0)
2664
+ return Array.from(this.groundTruthSet);
2665
+ if (!t || !this._hasRecentOps(t))
2666
+ return Array.from(this.groundTruthSet);
2667
+ const r = this._buildFreshPks(t, e), o = this.groundTruthSet;
2668
+ for (const i of r) o.add(i);
2669
+ return Array.from(o);
2670
+ }
2671
+ /** Are there any inflight or recent confirmed ops in the model store? */
2672
+ _hasRecentOps(e) {
2673
+ const t = e.operations, s = this.lastSync ?? this._createdAt;
2674
+ for (let r = t.length - 1; r >= 0; r--)
2675
+ if (t[r].status !== C.REJECTED)
2676
+ return t[r].status !== C.CONFIRMED ? !0 : t[r].timestamp >= s;
2677
+ return !1;
2614
2678
  }
2615
- /**
2616
- * Render by getting all instances from the model store and filtering locally.
2617
- * Used when a queryset has no ground truth (temp stores, newly created stores, etc.)
2618
- */
2619
- renderFromModelStore() {
2620
- const s = Q.getStore(this.modelClass).groundTruthPks.map((o) => this.modelClass.fromPk(o, this.queryset)), r = this.queryset.build();
2621
- return wt(s, r, this.modelClass, !1);
2679
+ /** Build set of PKs from ops newer than lastSync. Only used for no-offset querysets. */
2680
+ _buildFreshPks(e, t) {
2681
+ const s = /* @__PURE__ */ new Set(), r = this.pkField, o = this.lastSync ?? this._createdAt;
2682
+ for (const i of e.operations)
2683
+ if (i.status !== C.REJECTED && !(!t && i.status !== C.CONFIRMED) && !(i.status === C.CONFIRMED && i.timestamp < o))
2684
+ for (const l of i.instances)
2685
+ l && l[r] != null && s.add(l[r]);
2686
+ return s;
2622
2687
  }
2623
2688
  applyOperation(e, t) {
2624
2689
  const s = this.pkField;
@@ -2630,26 +2695,7 @@ class ar {
2630
2695
  continue;
2631
2696
  }
2632
2697
  let o = r[s];
2633
- switch (e.type) {
2634
- case M.CREATE:
2635
- case M.BULK_CREATE:
2636
- t.add(o);
2637
- break;
2638
- case M.CHECKPOINT:
2639
- break;
2640
- case M.UPDATE:
2641
- case M.UPDATE_INSTANCE:
2642
- t.add(o);
2643
- break;
2644
- case M.DELETE:
2645
- case M.DELETE_INSTANCE:
2646
- t.delete(o);
2647
- break;
2648
- default:
2649
- console.error(
2650
- `[QuerysetStore ${this.modelClass.modelName}] Unknown operation type: ${e.type}`
2651
- );
2652
- }
2698
+ CREATE_TYPES.has(e.type) && t.add(o);
2653
2699
  }
2654
2700
  return t;
2655
2701
  }
@@ -2663,7 +2709,7 @@ class ar {
2663
2709
  console.warn(`[QuerysetStore ${t}] Already syncing, request ignored.`);
2664
2710
  return;
2665
2711
  }
2666
- this.isSyncing = !0, B({
2712
+ this.isSyncing = !0, G({
2667
2713
  type: "sync",
2668
2714
  phase: "start",
2669
2715
  semanticKey: this.queryset.semanticKey,
@@ -2677,7 +2723,7 @@ class ar {
2677
2723
  modelClass: this.modelClass,
2678
2724
  canonical_id: e
2679
2725
  }), { data: r, included: o } = s;
2680
- E(r) || (this.includedPks.clear(), we(Q, o, this.modelClass, this.queryset), this.setGroundTruth(r)), this.setOperations(this.getInflightOperations()), this.lastSync = Date.now(), B({
2726
+ b(r) || (this.includedPks.clear(), we(j, o, this.modelClass, this.queryset), this.setGroundTruth(r)), this.setOperations(this.getInflightOperations()), this.lastSync = Date.now(), G({
2681
2727
  type: "sync",
2682
2728
  phase: "success",
2683
2729
  semanticKey: this.queryset.semanticKey,
@@ -2688,7 +2734,7 @@ class ar {
2688
2734
  includedCount: o ? Object.keys(o).length : 0
2689
2735
  });
2690
2736
  } catch (s) {
2691
- console.error(`[${t}] Failed to sync ground truth:`, s), B({
2737
+ console.error(`[${t}] Failed to sync ground truth:`, s), G({
2692
2738
  type: "sync",
2693
2739
  phase: "error",
2694
2740
  semanticKey: this.queryset.semanticKey,
@@ -2796,10 +2842,10 @@ class lr {
2796
2842
  class cr {
2797
2843
  #e;
2798
2844
  #t;
2799
- #s;
2800
- #r = [];
2845
+ #r;
2846
+ #s = [];
2801
2847
  constructor(e) {
2802
- return this.#e = e, this.#t = e.ModelClass, this.#r.queryset = e, this.#r.ModelClass = e.ModelClass, this.#s = new Proxy(this.#r, {
2848
+ return this.#e = e, this.#t = e.ModelClass, this.#s.queryset = e, this.#s.ModelClass = e.ModelClass, this.#r = new Proxy(this.#s, {
2803
2849
  get: (t, s, r) => s === "touch" ? () => this.touch() : s === "serialize" ? () => this.serialize() : s === Symbol.iterator ? () => this.getCurrentItems()[Symbol.iterator]() : typeof s == "string" && [
2804
2850
  "forEach",
2805
2851
  "map",
@@ -2809,20 +2855,20 @@ class cr {
2809
2855
  "every",
2810
2856
  "find"
2811
2857
  ].includes(s) ? (...o) => this.getCurrentItems()[s](...o) : s === "length" ? this.getCurrentItems().length : typeof s == "string" && !isNaN(parseInt(s)) ? this.getCurrentItems()[s] : t[s]
2812
- }), this.#s;
2858
+ }), this.#r;
2813
2859
  }
2814
2860
  /**
2815
2861
  * Serializes the lqs as a simple array of objects, for freezing e.g in the metric stores
2816
2862
  */
2817
2863
  serialize() {
2818
- return j.getStore(this.#e).render().map((s) => (this.#t.primaryKeyField, this.#t.fromPk(s, this.#e).serialize()));
2864
+ return x.getStore(this.#e).render().map((s) => (this.#t.primaryKeyField, this.#t.fromPk(s, this.#e).serialize()));
2819
2865
  }
2820
2866
  /**
2821
2867
  * Refresh the queryset data from the database
2822
2868
  * Delegates to the underlying store's sync method
2823
2869
  */
2824
2870
  refreshFromDb() {
2825
- return j.getStore(this.#e).sync(!0);
2871
+ return x.getStore(this.#e).sync(!0);
2826
2872
  }
2827
2873
  /**
2828
2874
  * Get the current items from the store
@@ -2830,7 +2876,7 @@ class cr {
2830
2876
  * @returns {Array} The current items in the queryset
2831
2877
  */
2832
2878
  getCurrentItems() {
2833
- return j.getStore(this.#e).render().map((r) => (this.#t.primaryKeyField, this.#t.fromPk(r, this.#e)));
2879
+ return x.getStore(this.#e).render().map((r) => (this.#t.primaryKeyField, this.#t.fromPk(r, this.#e)));
2834
2880
  }
2835
2881
  }
2836
2882
  class Ce {
@@ -2854,7 +2900,7 @@ class Ce {
2854
2900
  this.followingQuerysets.has(e) || this.followingQuerysets.set(e, /* @__PURE__ */ new Set()), this.followingQuerysets.get(e).add(t);
2855
2901
  }
2856
2902
  getStore(e) {
2857
- if (E(e) || E(e.ModelClass))
2903
+ if (b(e) || b(e.ModelClass))
2858
2904
  throw new Error("QuerysetStoreRegistry.getStore requires a valid queryset");
2859
2905
  if (this.querysetStoreGraph.addQueryset(e), this._tempStores.has(e))
2860
2906
  return this._tempStores.get(e);
@@ -2872,7 +2918,7 @@ class Ce {
2872
2918
  ...i,
2873
2919
  type: "list"
2874
2920
  };
2875
- return (await L(
2921
+ return (await V(
2876
2922
  e,
2877
2923
  "list",
2878
2924
  c,
@@ -2904,7 +2950,7 @@ class Ce {
2904
2950
  * @returns {LiveQueryset} - A live view of the queryset
2905
2951
  */
2906
2952
  getEntity(e, t = !1) {
2907
- if (E(e)) throw new Error("qsStoreRegistry: getEntity cannot be called without a queryset");
2953
+ if (b(e)) throw new Error("qsStoreRegistry: getEntity cannot be called without a queryset");
2908
2954
  const s = e.semanticKey;
2909
2955
  this.addFollowingQueryset(s, e);
2910
2956
  let r;
@@ -2919,7 +2965,7 @@ class Ce {
2919
2965
  * @returns {Array} - The set instances
2920
2966
  */
2921
2967
  setEntity(e, t) {
2922
- if (E(e) || E(t)) return [];
2968
+ if (b(e) || b(t)) return [];
2923
2969
  const s = e.semanticKey;
2924
2970
  this.addFollowingQueryset(s, e);
2925
2971
  let r;
@@ -2946,20 +2992,20 @@ class Ce {
2946
2992
  * @param {Set} dbSyncedKeys - Set of semanticKeys that are dbSynced (followedQuerysets)
2947
2993
  */
2948
2994
  async groupSync(e, t, s, r = null) {
2949
- if (E(e)) return;
2995
+ if (b(e)) return;
2950
2996
  const o = e.semanticKey, i = e.ModelClass, l = /* @__PURE__ */ new Set();
2951
2997
  for (const y of s) {
2952
2998
  const _ = typeof y == "string" ? y : y?.semanticKey;
2953
2999
  _ && this._stores.has(_) && l.add(_);
2954
3000
  }
2955
- const { isRoot: a, root: c } = this.querysetStoreGraph.findRoot(e, l), f = a || c === o;
2956
- if (B({
3001
+ const { isRoot: a, root: c } = this.querysetStoreGraph.findRoot(e, l), h = a || c === o;
3002
+ if (G({
2957
3003
  type: "groupSync",
2958
3004
  phase: "start",
2959
3005
  operationId: t,
2960
3006
  semanticKey: o,
2961
3007
  rootKey: c,
2962
- iAmRoot: f,
3008
+ iAmRoot: h,
2963
3009
  modelName: i?.modelName,
2964
3010
  configKey: i?.configKey
2965
3011
  }), !this._groupSyncCache.has(t)) {
@@ -2974,8 +3020,8 @@ class Ce {
2974
3020
  console.warn(`[groupSync] No store found for queryset: ${o}`);
2975
3021
  return;
2976
3022
  }
2977
- if (f)
2978
- await m.sync(r), p.pks = m.groundTruthPks, p.resolve(), B({
3023
+ if (h)
3024
+ await m.sync(r), p.pks = m.groundTruthPks, p.resolve(), G({
2979
3025
  type: "groupSync",
2980
3026
  phase: "rootSynced",
2981
3027
  operationId: t,
@@ -2988,12 +3034,12 @@ class Ce {
2988
3034
  else {
2989
3035
  let y = 3e4;
2990
3036
  try {
2991
- const b = he();
2992
- b.periodicSyncIntervalSeconds && (y = b.periodicSyncIntervalSeconds * 2e3);
3037
+ const k = he();
3038
+ k.periodicSyncIntervalSeconds && (y = k.periodicSyncIntervalSeconds * 2e3);
2993
3039
  } catch {
2994
3040
  }
2995
- const _ = new Promise((b, k) => {
2996
- setTimeout(() => k(new Error("timeout")), y);
3041
+ const _ = new Promise((k, E) => {
3042
+ setTimeout(() => E(new Error("timeout")), y);
2997
3043
  });
2998
3044
  let w = !1;
2999
3045
  try {
@@ -3002,7 +3048,7 @@ class Ce {
3002
3048
  w = !0;
3003
3049
  }
3004
3050
  if (w || !p.pks) {
3005
- console.warn(`[groupSync] Falling back to direct sync for: ${o.substring(0, 60)}`), await m.sync(r), B({
3051
+ console.warn(`[groupSync] Falling back to direct sync for: ${o.substring(0, 60)}`), await m.sync(r), G({
3006
3052
  type: "groupSync",
3007
3053
  phase: "fallbackSync",
3008
3054
  operationId: t,
@@ -3013,8 +3059,8 @@ class Ce {
3013
3059
  });
3014
3060
  return;
3015
3061
  }
3016
- const v = p.pks.map((b) => i.fromPk(b, e)), O = e.build(), T = wt(v, O, i, !1);
3017
- m.setGroundTruth(T), m.setOperations(m.getInflightOperations()), m.lastSync = Date.now(), B({
3062
+ const v = p.pks.map((k) => i.fromPk(k, e)), O = e.build(), T = ss(v, O, i, !1);
3063
+ m.setGroundTruth(T), m.setOperations(m.getInflightOperations()), m.lastSync = Date.now(), G({
3018
3064
  type: "groupSync",
3019
3065
  phase: "filteredFromRoot",
3020
3066
  operationId: t,
@@ -3027,248 +3073,63 @@ class Ce {
3027
3073
  }
3028
3074
  }
3029
3075
  }
3030
- const j = new Ce();
3031
- class ze {
3032
- /**
3033
- * Calculate metric based on ground truth and operations
3034
- */
3035
- calculateWithOperations(e, t, s, r) {
3036
- let o = e === null ? this.getInitialValue() : e;
3037
- for (const i of t)
3038
- i.status !== C.REJECTED && i.frozenInstances.forEach((l, a) => {
3039
- l[r.primaryKeyField];
3040
- const c = i.instances[a] || null, f = {
3041
- originalData: l,
3042
- // Pre-operation state
3043
- updatedData: c,
3044
- // Post-operation state (for updates)
3045
- type: i.type,
3046
- status: i.status
3047
- };
3048
- o = this.reduceOperation(o, f, s);
3049
- });
3050
- return o;
3051
- }
3052
- /**
3053
- * Get initial value for the metric type
3054
- * Override in subclasses if needed
3055
- */
3056
- getInitialValue() {
3057
- return 0;
3058
- }
3059
- /**
3060
- * Process a single operation - implement in subclasses
3061
- */
3062
- reduceOperation(e, t, s) {
3063
- throw new Error("reduceOperation must be implemented by subclass");
3064
- }
3065
- /**
3066
- * Safely get a numeric value from an object
3067
- */
3068
- safeGetValue(e, t) {
3069
- if (!e || !t) return 0;
3070
- const s = e[t];
3071
- if (E(s)) return 0;
3072
- const r = parseFloat(s);
3073
- return isNaN(r) ? 0 : r;
3074
- }
3075
- }
3076
- class dr extends ze {
3077
- reduceOperation(e, t, s) {
3078
- if (t.status === C.REJECTED)
3079
- return e;
3080
- const { type: r } = t;
3081
- return r === M.CREATE ? e + 1 : [M.DELETE, M.DELETE_INSTANCE].includes(r) ? Math.max(0, e - 1) : e;
3082
- }
3083
- }
3084
- class ur extends ze {
3085
- reduceOperation(e, t, s) {
3086
- if (t.status === C.REJECTED)
3087
- return e;
3088
- if (!s)
3089
- throw new Error("SumStrategy requires a field parameter");
3090
- const { type: r, originalData: o, updatedData: i } = t;
3091
- switch (r) {
3092
- case M.CREATE:
3093
- return e + this.safeGetValue(o, s);
3094
- case M.CHECKPOINT:
3095
- case M.UPDATE:
3096
- if (i) {
3097
- const l = this.safeGetValue(o, s), a = this.safeGetValue(i, s);
3098
- return e - l + a;
3099
- }
3100
- return e;
3101
- case M.DELETE:
3102
- case M.DELETE_INSTANCE:
3103
- return e - this.safeGetValue(o, s);
3104
- default:
3105
- return e;
3106
- }
3107
- }
3108
- }
3109
- class hr extends ze {
3110
- getInitialValue() {
3111
- return 1 / 0;
3112
- }
3113
- reduceOperation(e, t, s) {
3114
- if (t.status === C.REJECTED)
3115
- return e;
3116
- if (!s)
3117
- throw new Error("MinStrategy requires a field parameter");
3118
- const { type: r, originalData: o, updatedData: i } = t;
3119
- if (r === M.CREATE) {
3120
- const l = this.safeGetValue(o, s);
3121
- return Math.min(e, l);
3122
- } else if ((r === M.UPDATE || r.CHECKPOINT) && i) {
3123
- const l = this.safeGetValue(o, s), a = this.safeGetValue(i, s);
3124
- if (l === e)
3125
- return a <= l, a;
3126
- if (a < e)
3127
- return a;
3128
- }
3129
- return e;
3130
- }
3131
- }
3132
- class fr extends ze {
3133
- getInitialValue() {
3134
- return -1 / 0;
3135
- }
3136
- reduceOperation(e, t, s) {
3137
- if (t.status === C.REJECTED)
3138
- return e;
3139
- if (!s)
3140
- throw new Error("MaxStrategy requires a field parameter");
3141
- const { type: r, originalData: o, updatedData: i } = t;
3142
- if (r === M.CREATE) {
3143
- const l = this.safeGetValue(o, s);
3144
- return Math.max(e, l);
3145
- } else if ((r === M.UPDATE || r === M.CHECKPOINT) && i) {
3146
- const l = this.safeGetValue(o, s), a = this.safeGetValue(i, s);
3147
- if (l === e)
3148
- return a >= l, a;
3149
- if (a > e)
3150
- return a;
3151
- }
3152
- return e;
3153
- }
3154
- }
3155
- class pr {
3156
- // Collection of custom strategy overrides
3157
- static #e = /* @__PURE__ */ new Map();
3158
- // Default strategy map
3159
- static #t = /* @__PURE__ */ new Map([
3160
- ["count", () => new dr()],
3161
- ["sum", () => new ur()],
3162
- ["min", () => new hr()],
3163
- ["max", () => new fr()]
3164
- ]);
3165
- /**
3166
- * Clear all custom strategy overrides
3167
- */
3168
- static clearCustomStrategies() {
3169
- this.#e.clear();
3170
- }
3171
- /**
3172
- * Generate a unique key for the strategy map
3173
- * @private
3174
- * @param {string} metricType - The type of metric (count, sum, min, max)
3175
- * @param {Function} ModelClass - The model class
3176
- * @returns {string} A unique key
3177
- */
3178
- static #s(e, t) {
3179
- return `${e}::${t.configKey}::${t.modelName}`;
3180
- }
3181
- /**
3182
- * Override a strategy for a specific metric type and model class
3183
- * @param {string} metricType - The type of metric (count, sum, min, max)
3184
- * @param {Function|null} ModelClass - The model class or null for a generic override
3185
- * @param {MetricCalculationStrategy} strategy - The strategy to use
3186
- */
3187
- static overrideStrategy(e, t, s) {
3188
- if (!e || !s)
3189
- throw new Error("overrideStrategy requires metricType and strategy");
3190
- if (!(s instanceof ze))
3191
- throw new Error("strategy must be an instance of MetricCalculationStrategy");
3192
- let r;
3193
- t ? r = this.#s(e, t) : r = `${e}::*::*`, this.#e.set(r, s);
3194
- }
3195
- /**
3196
- * Get the appropriate strategy for a model class and metric type
3197
- * @param {string} metricType - The type of metric (count, sum, min, max)
3198
- * @param {Function} ModelClass - The model class
3199
- * @returns {MetricCalculationStrategy} The appropriate strategy
3200
- */
3201
- static getStrategy(e, t) {
3202
- const s = e.toLowerCase(), r = this.#s(s, t);
3203
- if (this.#e.has(r))
3204
- return this.#e.get(r);
3205
- const o = `${s}::*::*`;
3206
- return this.#e.has(o) ? this.#e.get(o) : (this.#t.get(s) || this.#t.get("count"))();
3207
- }
3208
- }
3209
- class mr {
3076
+ const x = new Ce();
3077
+ class dr {
3210
3078
  constructor(e, t, s, r = null, o = null, i) {
3211
- this.metricType = e, this.modelClass = t, this.queryset = s, this.field = r, this.ast = o, this.fetchFn = i, this.groundTruthValue = null, this.isSyncing = !1, this.strategy = pr.getStrategy(e, t), this.operations = [], this.confirmedOps = /* @__PURE__ */ new Set(), this.metricCache = new vt(
3079
+ this.metricType = e, this.modelClass = t, this.queryset = s, this.field = r, this.ast = o, this.fetchFn = i, this.groundTruthValue = null, this.isSyncing = !1, this.deltas = /* @__PURE__ */ new Map(), this.metricCache = new Ct(
3212
3080
  "metric-store-cache",
3213
3081
  {},
3214
3082
  this.onHydrated.bind(this)
3215
3083
  ), this._lastCalculatedValue = null;
3216
3084
  }
3217
3085
  reset() {
3218
- this.groundTruthValue = null, this._lastCalculatedValue = null, this.operations = [], this.confirmedOps = /* @__PURE__ */ new Set(), this.isSyncing = !1, this.clearCache();
3086
+ this.groundTruthValue = null, this._lastCalculatedValue = null, this.deltas = /* @__PURE__ */ new Map(), this.isSyncing = !1, this.clearCache();
3219
3087
  }
3220
3088
  get cacheKey() {
3221
3089
  return `${this.modelClass.configKey}::${this.modelClass.modelName}::metric::${this.metricType}::${this.field || "null"}::${this.ast ? Le(this.ast) : "global"}`;
3222
3090
  }
3223
3091
  /**
3224
- * Add an operation to this metric store
3225
- * @param {Operation} operation - The operation to add
3092
+ * Add a delta for an operation
3226
3093
  */
3227
- addOperation(e) {
3228
- if (e.queryset.ModelClass !== this.modelClass)
3229
- return;
3230
- const t = this.operations.findIndex(
3231
- (s) => s.operationId === e.operationId
3232
- );
3233
- t !== -1 ? this.operations[t] = e : this.operations.push(e), E(this.groundTruthValue) || this.render();
3094
+ addDelta(e, t) {
3095
+ this.deltas.set(e, { delta: t, confirmed: !1 }), this.render();
3234
3096
  }
3235
3097
  /**
3236
- * Update an operation in this metric store
3237
- * @param {Operation} operation - The operation to update
3098
+ * Mark a delta as confirmed
3238
3099
  */
3239
- updateOperation(e) {
3240
- if (e.queryset.ModelClass !== this.modelClass)
3241
- return;
3242
- const t = this.operations.findIndex(
3243
- (s) => s.operationId === e.operationId
3244
- );
3245
- t !== -1 ? this.operations[t] = e : this.operations.push(e), E(this.groundTruthValue) || this.render();
3100
+ confirmDelta(e) {
3101
+ const t = this.deltas.get(e);
3102
+ t && (t.confirmed = !0, this.render());
3246
3103
  }
3247
3104
  /**
3248
- * Confirm an operation in this metric store
3249
- * @param {Operation} operation - The operation to confirm
3105
+ * Remove a rejected delta
3250
3106
  */
3251
- confirm(e) {
3252
- if (e.queryset.ModelClass !== this.modelClass)
3253
- return;
3254
- const t = this.operations.findIndex(
3255
- (s) => s.operationId === e.operationId
3256
- );
3257
- t !== -1 && (this.operations[t] = e, this.confirmedOps.add(e.operationId)), this.render();
3107
+ rejectDelta(e) {
3108
+ this.deltas.delete(e) && this.render();
3258
3109
  }
3259
3110
  /**
3260
- * Reject an operation in this metric store
3261
- * @param {Operation} operation - The operation to reject
3111
+ * Update a delta (e.g., when operation is mutated)
3262
3112
  */
3113
+ updateDelta(e, t) {
3114
+ const s = this.deltas.get(e);
3115
+ s ? (s.delta = t, this.render()) : this.addDelta(e, t);
3116
+ }
3117
+ // Legacy API — kept for backward compatibility with existing callers.
3118
+ // processMetricStores in operationEventHandlers still calls these.
3119
+ addOperation(e) {
3120
+ }
3121
+ updateOperation(e) {
3122
+ }
3123
+ confirm(e) {
3124
+ this.confirmDelta(e.operationId);
3125
+ }
3263
3126
  reject(e) {
3264
- e.queryset.ModelClass === this.modelClass && (this.operations = this.operations.filter(
3265
- (t) => t.operationId !== e.operationId
3266
- ), this.confirmedOps.delete(e.operationId), E(this.groundTruthValue) || this.render());
3127
+ this.rejectDelta(e.operationId);
3267
3128
  }
3268
3129
  onHydrated() {
3269
3130
  if (this.groundTruthValue === null) {
3270
3131
  const e = this.metricCache.get(this.cacheKey);
3271
- !E(e) && !ve(e) && this.setGroundTruth(e?.value);
3132
+ !b(e) && !ve(e) && this.setGroundTruth(e?.value);
3272
3133
  }
3273
3134
  }
3274
3135
  setCache() {
@@ -3281,8 +3142,8 @@ class mr {
3281
3142
  this.metricCache.delete(this.cacheKey);
3282
3143
  }
3283
3144
  setGroundTruth(e) {
3284
- const t = !qe(this.groundTruthValue, e);
3285
- this.groundTruthValue = e, this.setCache(), t && Rt.emit("metric::render", {
3145
+ const t = !He(this.groundTruthValue, e);
3146
+ this.groundTruthValue = e, this.setCache(), t && Kt.emit("metric::render", {
3286
3147
  metricType: this.metricType,
3287
3148
  ModelClass: this.modelClass,
3288
3149
  field: this.field,
@@ -3291,19 +3152,15 @@ class mr {
3291
3152
  });
3292
3153
  }
3293
3154
  /**
3294
- * Render the metric with current operations
3295
- * @returns {any} Calculated metric value
3155
+ * Render: groundTruthValue + sum of all deltas
3296
3156
  */
3297
3157
  render() {
3298
- if (E(this.groundTruthValue))
3158
+ if (b(this.groundTruthValue))
3299
3159
  return null;
3300
- const e = this.strategy.calculateWithOperations(
3301
- this.groundTruthValue,
3302
- this.operations,
3303
- this.field,
3304
- this.modelClass
3305
- );
3306
- return qe(this._lastCalculatedValue, e) || (this._lastCalculatedValue = e, Rt.emit("metric::render", {
3160
+ let e = this.groundTruthValue;
3161
+ for (const { delta: t } of this.deltas.values())
3162
+ e += t;
3163
+ return He(this._lastCalculatedValue, e) || (this._lastCalculatedValue = e, Kt.emit("metric::render", {
3307
3164
  metricType: this.metricType,
3308
3165
  ModelClass: this.modelClass,
3309
3166
  field: this.field,
@@ -3329,9 +3186,9 @@ class mr {
3329
3186
  field: this.field,
3330
3187
  ast: this.ast
3331
3188
  });
3332
- return this.confirmedOps.size > 0 && (this.operations = this.operations.filter(
3333
- (t) => !this.confirmedOps.has(t.operationId)
3334
- ), this.confirmedOps.clear()), this.setGroundTruth(e), e;
3189
+ for (const [t, s] of this.deltas)
3190
+ s.confirmed && this.deltas.delete(t);
3191
+ return this.setGroundTruth(e), e;
3335
3192
  } catch (e) {
3336
3193
  return console.error(
3337
3194
  `[MetricStore] Failed to sync ${this.metricType} metric:`,
@@ -3349,12 +3206,12 @@ function Z(n) {
3349
3206
  return delete n.isOptimistic, delete n.then, delete n.catch, n;
3350
3207
  }
3351
3208
  ws();
3352
- Yt.create();
3353
- function yr(n, e) {
3209
+ Zt.create();
3210
+ function ur(n, e) {
3354
3211
  if (!n || !n.__f_expr)
3355
3212
  return n;
3356
3213
  try {
3357
- return Yt.evaluate(n.original_expr, e);
3214
+ return Zt.evaluate(n.original_expr, e);
3358
3215
  } catch (t) {
3359
3216
  return console.warn(`Error evaluating F expression: ${t.message}`), null;
3360
3217
  }
@@ -3368,10 +3225,10 @@ class de {
3368
3225
  * @returns {Operation} The created operation
3369
3226
  */
3370
3227
  static createCreateOperation(e, t = {}, s = null) {
3371
- const o = e.ModelClass.primaryKeyField, i = s || `${G()}`, l = zt(i);
3228
+ const o = e.ModelClass.primaryKeyField, i = s || `${B()}`, l = zt(i);
3372
3229
  return new q({
3373
3230
  operationId: i,
3374
- type: M.CREATE,
3231
+ type: P.CREATE,
3375
3232
  instances: [{ ...t, [o]: l }],
3376
3233
  queryset: e,
3377
3234
  args: { data: t },
@@ -3386,13 +3243,13 @@ class de {
3386
3243
  * @returns {Operation} The created operation
3387
3244
  */
3388
3245
  static createBulkCreateOperation(e, t = [], s = null) {
3389
- const o = e.ModelClass.primaryKeyField, i = s || `${G()}`, l = t.map((a, c) => {
3390
- const f = zt(`${i}_${c}`);
3391
- return { ...a, [o]: f };
3246
+ const o = e.ModelClass.primaryKeyField, i = s || `${B()}`, l = t.map((a, c) => {
3247
+ const h = zt(`${i}_${c}`);
3248
+ return { ...a, [o]: h };
3392
3249
  });
3393
3250
  return new q({
3394
3251
  operationId: i,
3395
- type: M.BULK_CREATE,
3252
+ type: P.BULK_CREATE,
3396
3253
  instances: l,
3397
3254
  queryset: e,
3398
3255
  args: { data: t },
@@ -3408,12 +3265,12 @@ class de {
3408
3265
  * @returns {Operation} The created operation
3409
3266
  */
3410
3267
  static createUpdateOperation(e, t = {}, s = null, r = null) {
3411
- const o = e.ModelClass, i = o.primaryKeyField, a = j.getStore(e).render(), c = r || `${G()}`, f = a.map((p) => {
3412
- const m = Q.getEntity(o, p), y = { ...m };
3268
+ const o = e.ModelClass, i = o.primaryKeyField, a = x.getStore(e).render(), c = r || `${B()}`, h = a.map((p) => {
3269
+ const m = j.getEntity(o, p), y = { ...m };
3413
3270
  y[i] = p;
3414
3271
  for (const [_, w] of Object.entries(t))
3415
3272
  if (w && typeof w == "object" && w.__f_expr) {
3416
- const v = yr(w, m);
3273
+ const v = ur(w, m);
3417
3274
  v !== null ? y[_] = v : y[_] = m[_];
3418
3275
  } else
3419
3276
  y[_] = w;
@@ -3421,8 +3278,8 @@ class de {
3421
3278
  });
3422
3279
  return new q({
3423
3280
  operationId: c,
3424
- type: M.UPDATE,
3425
- instances: f,
3281
+ type: P.UPDATE,
3282
+ instances: h,
3426
3283
  queryset: e,
3427
3284
  args: { filter: s, data: t },
3428
3285
  localOnly: e._optimisticOnly || !1
@@ -3435,10 +3292,10 @@ class de {
3435
3292
  * @returns {Operation} The created operation
3436
3293
  */
3437
3294
  static createDeleteOperation(e, t = null) {
3438
- const r = e.ModelClass.primaryKeyField, i = j.getStore(e).render(), l = t || `${G()}`, a = i.map((c) => ({ [r]: c }));
3295
+ const r = e.ModelClass.primaryKeyField, i = x.getStore(e).render(), l = t || `${B()}`, a = i.map((c) => ({ [r]: c }));
3439
3296
  return new q({
3440
3297
  operationId: l,
3441
- type: M.DELETE,
3298
+ type: P.DELETE,
3442
3299
  instances: a,
3443
3300
  queryset: e,
3444
3301
  args: {},
@@ -3453,10 +3310,10 @@ class de {
3453
3310
  * @returns {Operation} The created operation
3454
3311
  */
3455
3312
  static createUpdateInstanceOperation(e, t = {}, s = null) {
3456
- const o = e.ModelClass.primaryKeyField, l = j.getStore(e).render(), a = s || `${G()}`, c = l.map((f) => ({ ...t, [o]: f }));
3313
+ const o = e.ModelClass.primaryKeyField, l = x.getStore(e).render(), a = s || `${B()}`, c = l.map((h) => ({ ...t, [o]: h }));
3457
3314
  return new q({
3458
3315
  operationId: a,
3459
- type: M.UPDATE_INSTANCE,
3316
+ type: P.UPDATE_INSTANCE,
3460
3317
  instances: c,
3461
3318
  queryset: e,
3462
3319
  args: { data: t },
@@ -3471,10 +3328,10 @@ class de {
3471
3328
  * @returns {Operation} The created operation
3472
3329
  */
3473
3330
  static createDeleteInstanceOperation(e, t, s = null) {
3474
- const r = s || `${G()}`;
3331
+ const r = s || `${B()}`;
3475
3332
  return new q({
3476
3333
  operationId: r,
3477
- type: M.DELETE_INSTANCE,
3334
+ type: P.DELETE_INSTANCE,
3478
3335
  instances: [t],
3479
3336
  queryset: e,
3480
3337
  args: t,
@@ -3490,15 +3347,15 @@ class de {
3490
3347
  * @returns {Operation} The created operation
3491
3348
  */
3492
3349
  static createGetOrCreateOperation(e, t = {}, s = {}, r = null) {
3493
- const o = e.ModelClass, i = o.primaryKeyField, l = r || `${G()}`, c = Q.getStore(o).render(), f = { ...t }, m = new e.constructor(o).filter(f).build(), y = yt(m, o), _ = c.map(
3494
- (k) => _t(y, o.fromPk(k[i], e))
3350
+ const o = e.ModelClass, i = o.primaryKeyField, l = r || `${B()}`, c = j.getStore(o).render(), h = { ...t }, m = new e.constructor(o).filter(h).build(), y = yt(m, o), _ = c.map(
3351
+ (E) => _t(y, o.fromPk(E[i], e))
3495
3352
  ), w = mt(_, m, o), v = c.filter(
3496
- (k) => w.includes(k[i])
3497
- ), O = v.length === 0, T = O ? M.CREATE : M.UPDATE, b = O ? { ...t, ...s, [i]: l } : v[0];
3353
+ (E) => w.includes(E[i])
3354
+ ), O = v.length === 0, T = O ? P.CREATE : P.UPDATE, k = O ? { ...t, ...s, [i]: l } : v[0];
3498
3355
  return new q({
3499
3356
  operationId: l,
3500
3357
  type: T,
3501
- instances: [b],
3358
+ instances: [k],
3502
3359
  queryset: e,
3503
3360
  args: { lookup: t, defaults: s },
3504
3361
  localOnly: e._optimisticOnly || !1
@@ -3513,22 +3370,22 @@ class de {
3513
3370
  * @returns {Operation} The created operation
3514
3371
  */
3515
3372
  static createUpdateOrCreateOperation(e, t = {}, s = {}, r = null) {
3516
- const o = e.ModelClass, i = o.primaryKeyField, l = r || `${G()}`, c = Q.getStore(o).render(), f = { ...t }, m = new e.constructor(o).filter(f).build(), y = yt(m, o), _ = c.map(
3517
- (k) => _t(y, o.fromPk(k[i], e))
3373
+ const o = e.ModelClass, i = o.primaryKeyField, l = r || `${B()}`, c = j.getStore(o).render(), h = { ...t }, m = new e.constructor(o).filter(h).build(), y = yt(m, o), _ = c.map(
3374
+ (E) => _t(y, o.fromPk(E[i], e))
3518
3375
  ), w = mt(_, m, o), v = c.filter(
3519
- (k) => w.includes(k[i])
3520
- ), O = v.length === 0, T = O ? M.CREATE : M.UPDATE, b = O ? { ...t, ...s, [i]: l } : { ...v[0], ...s };
3376
+ (E) => w.includes(E[i])
3377
+ ), O = v.length === 0, T = O ? P.CREATE : P.UPDATE, k = O ? { ...t, ...s, [i]: l } : { ...v[0], ...s };
3521
3378
  return new q({
3522
3379
  operationId: l,
3523
3380
  type: T,
3524
- instances: [b],
3381
+ instances: [k],
3525
3382
  queryset: e,
3526
3383
  args: { lookup: t, defaults: s },
3527
3384
  localOnly: e._optimisticOnly || !1
3528
3385
  });
3529
3386
  }
3530
3387
  }
3531
- class Jt extends Array {
3388
+ class qt extends Array {
3532
3389
  /**
3533
3390
  * Creates a new ResultTuple.
3534
3391
  *
@@ -3539,7 +3396,7 @@ class Jt extends Array {
3539
3396
  super(2), this[0] = e, this[1] = t, this.instance = e, this.created = t;
3540
3397
  }
3541
3398
  }
3542
- class gr {
3399
+ class hr {
3543
3400
  /**
3544
3401
  * Executes a get operation (get, first, last) with the QuerySet.
3545
3402
  *
@@ -3549,12 +3406,12 @@ class gr {
3549
3406
  * @returns {Promise<Object>} The model instance.
3550
3407
  */
3551
3408
  static executeGet(e, t, s = {}) {
3552
- const r = e.ModelClass, i = j.getStore(e).render(), l = Array.isArray(i) && i.length === 1 ? i[0] : null, a = r.fromPk(l, e), c = L(e, t, s).then(
3553
- (f) => {
3554
- const { data: p, included: m, model_name: y } = f.data;
3555
- if (E(p) || Array.isArray(p) && p.length === 0)
3409
+ const r = e.ModelClass, i = x.getStore(e).render(), l = Array.isArray(i) && i.length === 1 ? i[0] : null, a = r.fromPk(l, e), c = V(e, t, s).then(
3410
+ (h) => {
3411
+ const { data: p, included: m, model_name: y } = h.data;
3412
+ if (b(p) || Array.isArray(p) && p.length === 0)
3556
3413
  return null;
3557
- we(Q, m, r, e);
3414
+ we(j, m, r, e);
3558
3415
  const _ = Array.isArray(p) ? p[0] : p;
3559
3416
  return a.pk = _, Z(a), a;
3560
3417
  }
@@ -3577,11 +3434,11 @@ class gr {
3577
3434
  * synchronized with the in‑memory store.
3578
3435
  */
3579
3436
  static executeList(e, t = "list", s = {}) {
3580
- const r = j.getEntity(e), o = L(e, t, s).then((i) => {
3437
+ const r = x.getEntity(e), o = V(e, t, s).then((i) => {
3581
3438
  const { data: l, included: a } = i.data;
3582
- we(Q, a, e.ModelClass, e);
3439
+ we(j, a, e.ModelClass, e);
3583
3440
  const c = Array.isArray(l) ? l : [];
3584
- return j.setEntity(e, c), Z(r), r;
3441
+ return x.setEntity(e, c), Z(r), r;
3585
3442
  });
3586
3443
  return te(r, o);
3587
3444
  }
@@ -3598,28 +3455,28 @@ class gr {
3598
3455
  lookup: s.lookup || {},
3599
3456
  defaults: s.defaults || {}
3600
3457
  }, l = t === "get_or_create" ? de.createGetOrCreateOperation(e, i.lookup, i.defaults) : de.createUpdateOrCreateOperation(e, i.lookup, i.defaults), a = l.type === "create", c = r.fromPk(l.instances[0][o], e);
3601
- let f = new Jt(c, a);
3458
+ let h = new qt(c, a);
3602
3459
  if (l.localOnly)
3603
- return l.updateStatus(C.CONFIRMED, l.instances), f;
3604
- const p = L(
3460
+ return l.updateStatus(C.CONFIRMED, l.instances), h;
3461
+ const p = V(
3605
3462
  e,
3606
3463
  t,
3607
3464
  i,
3608
3465
  l.operationId
3609
3466
  ).then((m) => {
3610
3467
  const { data: y, included: _, model_name: w } = m.data, v = m.metadata.created;
3611
- we(Q, _, r, e);
3468
+ we(j, _, r, e);
3612
3469
  const O = Array.isArray(y) ? y[0] : y;
3613
3470
  a && (c.pk = O);
3614
- const b = (_[w] || {})[O];
3615
- return b && l.mutate({
3616
- instances: [b],
3471
+ const k = (_[w] || {})[O];
3472
+ return k && l.mutate({
3473
+ instances: [k],
3617
3474
  status: C.CONFIRMED
3618
- }), f = new Jt(c, v), Z(f), f;
3475
+ }), h = new qt(c, v), Z(h), h;
3619
3476
  }).catch((m) => {
3620
3477
  throw l.updateStatus(C.REJECTED), m;
3621
3478
  });
3622
- return te(f, p);
3479
+ return te(h, p);
3623
3480
  }
3624
3481
  /**
3625
3482
  * Executes an aggregation operation with the QuerySet.
@@ -3635,15 +3492,15 @@ class gr {
3635
3492
  throw new Error(
3636
3493
  `Field parameter is required for ${t} operation`
3637
3494
  );
3638
- const i = Ie.getEntity(t, e, o), l = {};
3495
+ const i = Pe.getEntity(t, e, o), l = {};
3639
3496
  t !== "exists" && (l.field = o);
3640
- const a = L(
3497
+ const a = V(
3641
3498
  e,
3642
3499
  t,
3643
3500
  l
3644
3501
  ).then((c) => {
3645
- const f = c.data, p = j.getEntity(e);
3646
- return Ie.setEntity(t, e, o, f, p), Z(i), f;
3502
+ const h = c.data, p = x.getEntity(e);
3503
+ return Pe.setEntity(t, e, o, h, p), Z(i), h;
3647
3504
  });
3648
3505
  return te(i, a);
3649
3506
  }
@@ -3656,7 +3513,7 @@ class gr {
3656
3513
  * @returns {Promise<boolean>} Whether records exist.
3657
3514
  */
3658
3515
  static async executeExists(e, t = "exists", s = {}) {
3659
- return (await L(
3516
+ return (await V(
3660
3517
  e,
3661
3518
  t,
3662
3519
  {}
@@ -3681,7 +3538,7 @@ class gr {
3681
3538
  let c = [a, { [o]: a }, l.instances];
3682
3539
  if (l.localOnly)
3683
3540
  return l.updateStatus(C.CONFIRMED, l.instances), c;
3684
- const f = L(
3541
+ const h = V(
3685
3542
  e,
3686
3543
  t,
3687
3544
  i,
@@ -3694,7 +3551,7 @@ class gr {
3694
3551
  }).catch((p) => {
3695
3552
  throw l.updateStatus(C.REJECTED), p;
3696
3553
  });
3697
- return te(c, f);
3554
+ return te(c, h);
3698
3555
  }
3699
3556
  /**
3700
3557
  * Executes a delete operation with the QuerySet.
@@ -3709,16 +3566,16 @@ class gr {
3709
3566
  let a = [l, { [o]: l }, i.instances];
3710
3567
  if (i.localOnly)
3711
3568
  return i.updateStatus(C.CONFIRMED, i.instances), a;
3712
- const c = L(
3569
+ const c = V(
3713
3570
  e,
3714
3571
  t,
3715
3572
  {},
3716
3573
  i.operationId
3717
- ).then((f) => {
3718
- const p = f.metadata.deleted_count, m = f.metadata.rows_deleted;
3574
+ ).then((h) => {
3575
+ const p = h.metadata.deleted_count, m = h.metadata.rows_deleted;
3719
3576
  return i.updateStatus(C.CONFIRMED, m), a = [p, { [o]: p }, m || []], Z(a), a;
3720
- }).catch((f) => {
3721
- throw i.updateStatus(C.REJECTED), f;
3577
+ }).catch((h) => {
3578
+ throw i.updateStatus(C.REJECTED), h;
3722
3579
  });
3723
3580
  return te(a, c);
3724
3581
  }
@@ -3731,25 +3588,25 @@ class gr {
3731
3588
  * @returns {LiveThenable<Object>} The live Model instance which resolves to the created model.
3732
3589
  */
3733
3590
  static executeCreate(e, t = "create", s = {}) {
3734
- const r = e.ModelClass, o = `${G()}`, i = {
3591
+ const r = e.ModelClass, o = `${B()}`, i = {
3735
3592
  data: s.data || {}
3736
3593
  };
3737
- E(s.data) && (console.warn("executeCreate was called with null data"), s.data = {});
3594
+ b(s.data) && (console.warn("executeCreate was called with null data"), s.data = {});
3738
3595
  const l = de.createCreateOperation(e, i.data, o), a = l.instances[0][r.primaryKeyField], c = r.fromPk(a, e);
3739
3596
  if (l.localOnly)
3740
3597
  return l.updateStatus(C.CONFIRMED, l.instances), c;
3741
- const f = L(
3598
+ const h = V(
3742
3599
  e,
3743
3600
  t,
3744
3601
  i,
3745
3602
  o,
3746
3603
  async (p) => {
3747
3604
  const { data: m } = p.data, y = Array.isArray(m) ? m[0] : m;
3748
- Kt(o, y);
3605
+ Rt(o, y);
3749
3606
  }
3750
3607
  ).then((p) => {
3751
3608
  const { data: m, included: y, model_name: _ } = p.data;
3752
- we(Q, y, r, e);
3609
+ we(j, y, r, e);
3753
3610
  const w = Array.isArray(m) ? m[0] : m;
3754
3611
  c.pk = w;
3755
3612
  const O = (y[_] || {})[w];
@@ -3764,7 +3621,7 @@ class gr {
3764
3621
  }).catch((p) => {
3765
3622
  throw l.updateStatus(C.REJECTED), p;
3766
3623
  });
3767
- return te(c, f);
3624
+ return te(c, h);
3768
3625
  }
3769
3626
  /**
3770
3627
  * Executes a bulk_create operation with the QuerySet.
@@ -3775,10 +3632,10 @@ class gr {
3775
3632
  * @returns {LiveThenable<Array>} Array of live Model instances.
3776
3633
  */
3777
3634
  static executeBulkCreate(e, t = "bulk_create", s = {}) {
3778
- const r = e.ModelClass, o = `${G()}`, i = r.primaryKeyField, l = {
3635
+ const r = e.ModelClass, o = `${B()}`, i = r.primaryKeyField, l = {
3779
3636
  data: s.data || []
3780
3637
  };
3781
- if (E(s.data) || !Array.isArray(s.data))
3638
+ if (b(s.data) || !Array.isArray(s.data))
3782
3639
  return console.warn("executeBulkCreate was called with invalid data"), Promise.resolve([]);
3783
3640
  const a = de.createBulkCreateOperation(e, l.data, o), c = a.instances.map((p) => {
3784
3641
  const m = p[i];
@@ -3786,7 +3643,7 @@ class gr {
3786
3643
  });
3787
3644
  if (a.localOnly)
3788
3645
  return a.updateStatus(C.CONFIRMED, a.instances), c;
3789
- const f = L(
3646
+ const h = V(
3790
3647
  e,
3791
3648
  t,
3792
3649
  l,
@@ -3795,15 +3652,15 @@ class gr {
3795
3652
  const { data: m } = p.data;
3796
3653
  (Array.isArray(m) ? m : []).forEach((_, w) => {
3797
3654
  const v = `${o}_${w}`;
3798
- Kt(v, _);
3655
+ Rt(v, _);
3799
3656
  });
3800
3657
  }
3801
3658
  ).then((p) => {
3802
3659
  const { data: m, included: y, model_name: _ } = p.data;
3803
- we(Q, y, r, e);
3660
+ we(j, y, r, e);
3804
3661
  const w = Array.isArray(m) ? m : [];
3805
- w.forEach((T, b) => {
3806
- c[b] && (c[b].pk = T);
3662
+ w.forEach((T, k) => {
3663
+ c[k] && (c[k].pk = T);
3807
3664
  });
3808
3665
  const v = y[_] || {}, O = w.map((T) => v[T]).filter(Boolean);
3809
3666
  return a.mutate({
@@ -3813,7 +3670,7 @@ class gr {
3813
3670
  }).catch((p) => {
3814
3671
  throw a.updateStatus(C.REJECTED), p;
3815
3672
  });
3816
- return te(c, f);
3673
+ return te(c, h);
3817
3674
  }
3818
3675
  /**
3819
3676
  * Executes an update_instance operation with the QuerySet.
@@ -3826,29 +3683,29 @@ class gr {
3826
3683
  static executeUpdateInstance(e, t = "update_instance", s = {}) {
3827
3684
  const r = e.ModelClass;
3828
3685
  r.primaryKeyField;
3829
- const i = j.getStore(e).render(), l = s.data || {}, a = de.createUpdateInstanceOperation(e, l), c = Array.isArray(i) ? i[0] : null, f = r.fromPk(c, e);
3686
+ const i = x.getStore(e).render(), l = s.data || {}, a = de.createUpdateInstanceOperation(e, l), c = Array.isArray(i) ? i[0] : null, h = r.fromPk(c, e);
3830
3687
  if (a.localOnly)
3831
- return a.updateStatus(C.CONFIRMED, a.instances), f;
3832
- const p = L(
3688
+ return a.updateStatus(C.CONFIRMED, a.instances), h;
3689
+ const p = V(
3833
3690
  e,
3834
3691
  t,
3835
3692
  { data: l },
3836
3693
  a.operationId
3837
3694
  ).then((m) => {
3838
3695
  const { data: y, included: _, model_name: w } = m.data;
3839
- we(Q, _, r, e);
3696
+ we(j, _, r, e);
3840
3697
  const v = Array.isArray(y) ? y[0] : y;
3841
- f.pk = v;
3698
+ h.pk = v;
3842
3699
  const T = (_[w] || {})[v];
3843
3700
  if (!T)
3844
3701
  throw new Error(
3845
3702
  `Entity data not found for ${w} with pk ${v}`
3846
3703
  );
3847
- return a.updateStatus(C.CONFIRMED, [T]), Z(f), f;
3704
+ return a.updateStatus(C.CONFIRMED, [T]), Z(h), h;
3848
3705
  }).catch((m) => {
3849
3706
  throw a.updateStatus(C.REJECTED), m;
3850
3707
  });
3851
- return te(f, p);
3708
+ return te(h, p);
3852
3709
  }
3853
3710
  /**
3854
3711
  * Executes a delete_instance operation with the QuerySet.
@@ -3866,18 +3723,18 @@ class gr {
3866
3723
  let a = [1, { [o]: 1 }, l.instances];
3867
3724
  if (l.localOnly)
3868
3725
  return l.updateStatus(C.CONFIRMED, l.instances), a;
3869
- const c = L(
3726
+ const c = V(
3870
3727
  e,
3871
3728
  t,
3872
3729
  s,
3873
3730
  l.operationId
3874
- ).then((f) => {
3731
+ ).then((h) => {
3875
3732
  let p = 1;
3876
- typeof f.data == "number" && (p = f.data);
3877
- const m = f.metadata?.rows_deleted || [s];
3733
+ typeof h.data == "number" && (p = h.data);
3734
+ const m = h.metadata?.rows_deleted || [s];
3878
3735
  return l.updateStatus(C.CONFIRMED, [s]), a = [p, { [o]: p }, m], Z(a), a;
3879
- }).catch((f) => {
3880
- throw l.updateStatus(C.REJECTED), f;
3736
+ }).catch((h) => {
3737
+ throw l.updateStatus(C.REJECTED), h;
3881
3738
  });
3882
3739
  return te(a, c);
3883
3740
  }
@@ -3934,47 +3791,64 @@ class gr {
3934
3791
  * @returns {Promise<any>} The raw API response data.
3935
3792
  */
3936
3793
  static executeRemote(e, t = "list", s = {}) {
3937
- return L(e, t, s);
3794
+ return V(e, t, s);
3938
3795
  }
3939
3796
  }
3940
- class _r {
3797
+ class fr {
3941
3798
  constructor(e, t, s = null) {
3942
3799
  this.queryset = e, this.metricType = t, this.field = s;
3943
3800
  }
3944
3801
  get lqs() {
3945
- return j.getEntity(this.queryset);
3802
+ return x.getEntity(this.queryset);
3946
3803
  }
3947
3804
  /**
3948
3805
  * Refresh the metric data from the database
3949
3806
  * Delegates to the underlying store's sync method
3950
3807
  */
3951
3808
  refreshFromDb() {
3952
- return Ie.getStore(
3809
+ return Pe.getStore(
3953
3810
  this.metricType,
3954
3811
  this.queryset,
3955
3812
  this.field
3956
3813
  ).sync(!0);
3957
3814
  }
3958
3815
  /**
3959
- * Getter that always returns the current value from the store
3816
+ * Returns the current metric value from the store.
3817
+ * Called implicitly by JS when coercing to a primitive (arithmetic, template literals, etc.)
3960
3818
  */
3961
- get value() {
3962
- const e = Ie.getStore(
3819
+ valueOf() {
3820
+ const e = Pe.getStore(
3963
3821
  this.metricType,
3964
3822
  this.queryset,
3965
3823
  this.field
3966
3824
  );
3967
3825
  return e ? e.render() : null;
3968
3826
  }
3827
+ toString() {
3828
+ const e = this.valueOf();
3829
+ return e === null ? "" : String(e);
3830
+ }
3831
+ /** @deprecated Use valueOf() coercion instead (e.g. +metric, `${metric}`, metric + 0) */
3832
+ get value() {
3833
+ return this.valueOf();
3834
+ }
3969
3835
  }
3970
- class Ct {
3836
+ class wt {
3971
3837
  constructor() {
3972
- this._stores = /* @__PURE__ */ new Map(), this.syncManager = null;
3838
+ this._stores = /* @__PURE__ */ new Map(), this.followedMetrics = /* @__PURE__ */ new Set(), this.syncManager = null;
3973
3839
  }
3974
3840
  clear() {
3975
3841
  for (const e of this._stores.values())
3976
3842
  this.syncManager.unfollowModel(this, e.store.modelClass);
3977
- this._stores = /* @__PURE__ */ new Map();
3843
+ this._stores = /* @__PURE__ */ new Map(), this.followedMetrics = /* @__PURE__ */ new Set();
3844
+ }
3845
+ followMetric(e, t, s = null) {
3846
+ const r = this._makeKey(e, t, s);
3847
+ this.followedMetrics.add(r);
3848
+ }
3849
+ unfollowMetric(e, t, s = null) {
3850
+ const r = this._makeKey(e, t, s);
3851
+ this.followedMetrics.delete(r);
3978
3852
  }
3979
3853
  setSyncManager(e) {
3980
3854
  this.syncManager = e;
@@ -3985,7 +3859,7 @@ class Ct {
3985
3859
  * @returns {Array} Array of metric stores
3986
3860
  */
3987
3861
  getAllStoresForQueryset(e) {
3988
- if (E(e) || E(e.ModelClass))
3862
+ if (b(e) || b(e.ModelClass))
3989
3863
  return [];
3990
3864
  const t = [], s = e.ModelClass;
3991
3865
  for (const [r, o] of this._stores.entries()) {
@@ -4002,14 +3876,14 @@ class Ct {
4002
3876
  * Get a metric store for a specific queryset and metric type
4003
3877
  */
4004
3878
  getStore(e, t, s = null) {
4005
- if (E(e) || E(t) || E(t.ModelClass))
3879
+ if (b(e) || b(t) || b(t.ModelClass))
4006
3880
  return null;
4007
3881
  const r = t.ModelClass, o = t.build(), i = this._makeKey(e, t, s);
4008
3882
  if (!this._stores.has(i)) {
4009
- const l = async ({ metricType: c, modelClass: f, field: p, ast: m }) => {
3883
+ const l = async ({ metricType: c, modelClass: h, field: p, ast: m }) => {
4010
3884
  const y = t.clone();
4011
- return await gr.executeAgg(y, c, { field: p });
4012
- }, a = new mr(
3885
+ return await hr.executeAgg(y, c, { field: p });
3886
+ }, a = new dr(
4013
3887
  e,
4014
3888
  r,
4015
3889
  t,
@@ -4029,20 +3903,20 @@ class Ct {
4029
3903
  * Get a metric value for a specific queryset
4030
3904
  */
4031
3905
  getEntity(e, t, s = null) {
4032
- if (E(e) || E(t) || E(t.ModelClass))
3906
+ if (b(e) || b(t) || b(t.ModelClass))
4033
3907
  return null;
4034
3908
  this.getStore(e, t, s);
4035
- const r = new _r(t, e, s);
3909
+ const r = new fr(t, e, s);
4036
3910
  return r;
4037
3911
  }
4038
3912
  /**
4039
3913
  * Set metric ground truth value
4040
3914
  */
4041
3915
  setEntity(e, t, s, r) {
4042
- if (E(e) || E(t) || E(t.ModelClass))
3916
+ if (b(e) || b(t) || b(t.ModelClass))
4043
3917
  return null;
4044
3918
  const o = this.getStore(e, t, s);
4045
- return o ? ((!E(o.groundTruthValue) || !ve(o.operations)) && o.reset(), o.setGroundTruth(r), r) : null;
3919
+ return o ? ((!b(o.groundTruthValue) || !ve(o.operations)) && o.reset(), o.setGroundTruth(r), r) : null;
4046
3920
  }
4047
3921
  /**
4048
3922
  * Sync a specific metric with the server
@@ -4059,8 +3933,8 @@ class Ct {
4059
3933
  return this._stores.has(e) ? this._stores.get(e).queryset : null;
4060
3934
  }
4061
3935
  }
4062
- const Ie = new Ct();
4063
- class wr {
3936
+ const Pe = new wt();
3937
+ class pr {
4064
3938
  constructor(e) {
4065
3939
  this.event = e.event, this.model = e.model, this.operation_id = e.operation_id, this.pk_field_name = e.pk_field_name, this.configKey = e.configKey, this.canonical_id = e.canonical_id || null, this.server_ts_ms = e.server_ts_ms || null, this.instances = e.instances?.map((t) => t && this.pk_field_name && t[this.pk_field_name] != null ? {
4066
3940
  ...t,
@@ -4068,21 +3942,21 @@ class wr {
4068
3942
  } : t) || e.instances, this._cachedInstances = null;
4069
3943
  }
4070
3944
  get modelClass() {
4071
- return es(this.model, this.configKey);
3945
+ return Xt(this.model, this.configKey);
4072
3946
  }
4073
3947
  async getFullInstances() {
4074
3948
  if (this.event === "delete")
4075
3949
  throw new Error(
4076
3950
  "Cannot fetch full instances for delete operation bozo..."
4077
3951
  );
4078
- return E(this._cachedInstances) && (this._cachedInstances = await this.modelClass.objects.filter({
3952
+ return b(this._cachedInstances) && (this._cachedInstances = await this.modelClass.objects.filter({
4079
3953
  [`${this.modelClass.primaryKeyField}__in`]: this.instances.map(
4080
3954
  (e) => e[this.modelClass.primaryKeyField]
4081
3955
  )
4082
3956
  }).fetch()), this._cachedInstances;
4083
3957
  }
4084
3958
  }
4085
- class Cr {
3959
+ class mr {
4086
3960
  constructor() {
4087
3961
  this.registries = /* @__PURE__ */ new Map(), this.followedModels = /* @__PURE__ */ new Map(), this.followAllQuerysets = !0, this.followedQuerysets = /* @__PURE__ */ new Map(), this.periodicSyncTimer = null, this.eventBatch = /* @__PURE__ */ new Map(), this.debounceTimer = null, this.maxWaitTimer = null, this.debounceMs = 100, this.maxWaitMs = 2e3, this.batchStartTime = null;
4088
3962
  }
@@ -4105,7 +3979,7 @@ class Cr {
4105
3979
  * Initialize event handlers for all event receivers
4106
3980
  */
4107
3981
  initialize() {
4108
- js(), Ds().forEach((t, s) => {
3982
+ js(), zs().forEach((t, s) => {
4109
3983
  t && t.addModelEventHandler(this.handleEvent.bind(this));
4110
3984
  }), this.startPeriodicSync();
4111
3985
  }
@@ -4125,7 +3999,7 @@ class Cr {
4125
3999
  async syncStaleQuerysets() {
4126
4000
  const e = this.registries.get(Ce);
4127
4001
  if (!e) return;
4128
- const t = `periodic-sync-${G()}`, s = new Set(
4002
+ const t = `periodic-sync-${B()}`, s = new Set(
4129
4003
  [...this.followedQuerysets].map((o) => o.semanticKey).filter((o) => e._stores.has(o))
4130
4004
  ), r = [];
4131
4005
  for (const [o, i] of e._stores.entries()) {
@@ -4139,7 +4013,7 @@ class Cr {
4139
4013
  ), this.pruneUnreferencedModels();
4140
4014
  }
4141
4015
  pruneUnreferencedModels() {
4142
- const e = this.registries.get(Ge), t = this.registries.get(Ce);
4016
+ const e = this.registries.get(Ve), t = this.registries.get(Ce);
4143
4017
  if (!(!e || !t))
4144
4018
  for (const [s, r] of e._stores.entries())
4145
4019
  r.pruneUnreferencedInstances(t);
@@ -4157,7 +4031,7 @@ class Cr {
4157
4031
  const r = [...this.followedModels.values()].some(
4158
4032
  (o) => o.has(t)
4159
4033
  );
4160
- s.add(t), r || Ut(t.configKey)?.subscribe(
4034
+ s.add(t), r || jt(t.configKey)?.subscribe(
4161
4035
  t.modelName,
4162
4036
  this.handleEvent
4163
4037
  );
@@ -4167,7 +4041,7 @@ class Cr {
4167
4041
  if (!s) return;
4168
4042
  s.delete(t), [...this.followedModels.values()].some(
4169
4043
  (o) => o.has(t)
4170
- ) || Ut(t.configKey)?.unsubscribe(
4044
+ ) || jt(t.configKey)?.unsubscribe(
4171
4045
  t.modelName,
4172
4046
  this.handleEvent
4173
4047
  );
@@ -4184,7 +4058,7 @@ class Cr {
4184
4058
  * Checks the `verify` flag on membership state to determine which querysets need syncing.
4185
4059
  */
4186
4060
  syncQuerysetsNeedingVerification(e) {
4187
- const t = Pe.getQuerysetStates(e);
4061
+ const t = Fe.getQuerysetStates(e);
4188
4062
  if (!t) return;
4189
4063
  const s = this.registries.get(Ce);
4190
4064
  if (!s) return;
@@ -4195,7 +4069,7 @@ class Cr {
4195
4069
  c && r.push(c);
4196
4070
  }
4197
4071
  if (r.length === 0) return;
4198
- const o = `maybe-sync-${G()}`, i = new Set(
4072
+ const o = `maybe-sync-${B()}`, i = new Set(
4199
4073
  [...this.followedQuerysets].map((l) => l.semanticKey).filter((l) => s._stores.has(l))
4200
4074
  );
4201
4075
  Promise.all(
@@ -4205,7 +4079,7 @@ class Cr {
4205
4079
  );
4206
4080
  }
4207
4081
  handleEvent = (e) => {
4208
- B({
4082
+ G({
4209
4083
  type: "event",
4210
4084
  modelName: e.model,
4211
4085
  configKey: e.configKey,
@@ -4215,8 +4089,8 @@ class Cr {
4215
4089
  operationId: e.operation_id,
4216
4090
  socketId: e.socket_id
4217
4091
  });
4218
- let t = new wr(e), s = Pe.has(t.operation_id);
4219
- if (this.registries.has(Ct) && this.processMetrics(t), s) {
4092
+ let t = new pr(e), s = Fe.has(t.operation_id);
4093
+ if (this.registries.has(wt) && this.processMetrics(t), s) {
4220
4094
  this.syncQuerysetsNeedingVerification(t.operation_id);
4221
4095
  return;
4222
4096
  }
@@ -4243,7 +4117,7 @@ class Cr {
4243
4117
  s.has(o) || s.set(o, []), s.get(o).push(r);
4244
4118
  }), s.forEach((r, o) => {
4245
4119
  const i = r[0];
4246
- this.registries.has(Ce) && this.processQuerysetsBatch(i, r), this.registries.has(Ge) && this.processModels(i);
4120
+ this.registries.has(Ce) && this.processQuerysetsBatch(i, r), this.registries.has(Ve) && this.processModels(i);
4247
4121
  });
4248
4122
  }
4249
4123
  isQuerysetFollowed(e) {
@@ -4260,20 +4134,20 @@ class Cr {
4260
4134
  }
4261
4135
  processQuerysetsBatch(e, t) {
4262
4136
  const s = this.registries.get(Ce), r = [];
4263
- for (const [c, f] of s._stores.entries())
4264
- if (f.modelClass.modelName === e.model && f.modelClass.configKey === e.configKey) {
4137
+ for (const [c, h] of s._stores.entries())
4138
+ if (h.modelClass.modelName === e.model && h.modelClass.configKey === e.configKey) {
4265
4139
  if (this.followAllQuerysets) {
4266
- r.push(f);
4140
+ r.push(h);
4267
4141
  continue;
4268
4142
  }
4269
4143
  const p = s.followingQuerysets.get(c);
4270
- p && [...p].some((y) => this.isQuerysetFollowed(y)) && r.push(f);
4144
+ p && [...p].some((y) => this.isQuerysetFollowed(y)) && r.push(h);
4271
4145
  }
4272
4146
  if (r.length === 0) return;
4273
4147
  const i = t.reduce(
4274
- (c, f) => (f.server_ts_ms || 0) > (c.server_ts_ms || 0) ? f : c,
4148
+ (c, h) => (h.server_ts_ms || 0) > (c.server_ts_ms || 0) ? h : c,
4275
4149
  t[0]
4276
- ).canonical_id, l = `remote-event-${G()}`, a = new Set(
4150
+ ).canonical_id, l = `remote-event-${B()}`, a = new Set(
4277
4151
  [...this.followedQuerysets].map((c) => c.semanticKey).filter((c) => s._stores.has(c))
4278
4152
  );
4279
4153
  Promise.all(
@@ -4283,18 +4157,18 @@ class Cr {
4283
4157
  );
4284
4158
  }
4285
4159
  processMetrics(e) {
4286
- const t = this.registries.get(Ct);
4160
+ const t = this.registries.get(wt);
4287
4161
  for (const [s, r] of t._stores.entries())
4288
4162
  if (r.queryset && r.queryset.modelClass.modelName === e.model && r.queryset.modelClass.configKey === e.configKey) {
4289
4163
  if (this.followAllQuerysets) {
4290
4164
  r.store.sync();
4291
4165
  continue;
4292
4166
  }
4293
- this.isQuerysetFollowed(r.queryset) && r.store.sync();
4167
+ (t.followedMetrics.has(s) || this.isQuerysetFollowed(r.queryset)) && r.store.sync();
4294
4168
  }
4295
4169
  }
4296
4170
  processModels(e) {
4297
- const t = this.registries.get(Ge);
4171
+ const t = this.registries.get(Ve);
4298
4172
  if (!t) return;
4299
4173
  const s = t.getStore(e.modelClass);
4300
4174
  if (!s) return;
@@ -4304,105 +4178,105 @@ class Cr {
4304
4178
  if (r.size === 0) return;
4305
4179
  const o = new Set(s.groundTruthPks), i = this.registries.get(Ce), l = /* @__PURE__ */ new Set();
4306
4180
  if (i)
4307
- for (const [c, f] of i._stores.entries())
4308
- f.modelClass.modelName === e.model && f.modelClass.configKey === e.configKey && f.groundTruthPks.forEach((p) => l.add(p));
4181
+ for (const [c, h] of i._stores.entries())
4182
+ h.modelClass.modelName === e.model && h.modelClass.configKey === e.configKey && h.groundTruthPks.forEach((p) => l.add(p));
4309
4183
  const a = [];
4310
4184
  r.forEach((c) => {
4311
4185
  o.has(c) && !l.has(c) && a.push(c);
4312
4186
  }), a.length > 0 && s.sync(a);
4313
4187
  }
4314
4188
  }
4315
- const $e = new Cr();
4316
- $e.manageRegistry(j);
4317
- $e.manageRegistry(Q);
4318
- $e.manageRegistry(Ie);
4319
- const vr = /* @__PURE__ */ new Set();
4320
- function Er(n) {
4321
- typeof n == "function" && vr.add(n);
4189
+ const Ae = new mr();
4190
+ Ae.manageRegistry(x);
4191
+ Ae.manageRegistry(j);
4192
+ Ae.manageRegistry(Pe);
4193
+ const yr = /* @__PURE__ */ new Set();
4194
+ function gr(n) {
4195
+ typeof n == "function" && yr.add(n);
4322
4196
  }
4323
- $e.followAllQuerysets = !1;
4197
+ Ae.followAllQuerysets = !1;
4324
4198
  const rs = /* @__PURE__ */ new Map();
4325
- Er(() => {
4326
- rs.clear(), $e.followAllQuerysets = !0, $e.followedQuerysets.clear();
4199
+ gr(() => {
4200
+ rs.clear(), Ae.followAllQuerysets = !0, Ae.followedQuerysets.clear();
4327
4201
  });
4328
- const br = (n, e) => {
4202
+ const _r = (n, e) => {
4329
4203
  const t = n.__vccOpts || n;
4330
4204
  for (const [s, r] of e)
4331
4205
  t[s] = r;
4332
4206
  return t;
4333
- }, kr = { class: "szd" }, Sr = { class: "szd-header" }, Tr = { class: "szd-header__top" }, Mr = { class: "szd-header__left" }, $r = {
4207
+ }, wr = { class: "szd" }, Cr = { class: "szd-header" }, vr = { class: "szd-header__top" }, kr = { class: "szd-header__left" }, br = {
4334
4208
  key: 0,
4335
4209
  class: "szd-header__model"
4336
- }, Ar = {
4210
+ }, Er = {
4337
4211
  key: 1,
4338
4212
  class: "szd-header__model szd-header__model--empty"
4339
- }, Or = { class: "szd-header__right" }, Pr = {
4213
+ }, Sr = { class: "szd-header__right" }, Tr = {
4340
4214
  key: 0,
4341
4215
  class: "szd-header__badge szd-header__badge--syncing"
4342
- }, Ir = {
4216
+ }, Mr = {
4343
4217
  key: 1,
4344
4218
  class: "szd-header__badge"
4345
- }, Fr = { class: "szd-header__badge" }, Dr = { class: "szd-tabs" }, zr = ["onClick"], Kr = { class: "szd-content" }, Rr = {
4219
+ }, Ar = { class: "szd-header__badge" }, Or = { class: "szd-tabs" }, $r = ["onClick"], Fr = { class: "szd-content" }, Pr = {
4346
4220
  key: 0,
4347
4221
  class: "szd-panel"
4348
- }, Nr = { class: "szd-panel__section" }, xr = { class: "szd-kv" }, jr = { class: "szd-kv__row" }, Ur = { class: "szd-kv__value" }, Qr = { class: "szd-kv__row" }, Vr = { class: "szd-kv__value" }, Lr = { class: "szd-kv__row" }, Gr = { class: "szd-kv__value" }, Br = { class: "szd-kv__row" }, Hr = { class: "szd-kv__value" }, qr = { class: "szd-panel__section" }, Jr = { class: "szd-stats" }, Wr = { class: "szd-stat" }, Zr = { class: "szd-stat__value" }, Yr = { class: "szd-stat" }, Xr = { class: "szd-stat__value" }, en = { class: "szd-stat" }, tn = { class: "szd-stat__value" }, sn = { class: "szd-stat" }, rn = { class: "szd-stat__value" }, nn = {
4222
+ }, Dr = { class: "szd-panel__section" }, zr = { class: "szd-kv" }, Rr = { class: "szd-kv__row" }, Kr = { class: "szd-kv__value" }, Ir = { class: "szd-kv__row" }, Nr = { class: "szd-kv__value" }, xr = { class: "szd-kv__row" }, jr = { class: "szd-kv__value" }, Ur = { class: "szd-kv__row" }, Qr = { class: "szd-kv__value" }, Lr = { class: "szd-panel__section" }, Vr = { class: "szd-stats" }, Br = { class: "szd-stat" }, Gr = { class: "szd-stat__value" }, Hr = { class: "szd-stat" }, qr = { class: "szd-stat__value" }, Jr = { class: "szd-stat" }, Wr = { class: "szd-stat__value" }, Zr = { class: "szd-stat" }, Yr = { class: "szd-stat__value" }, Xr = {
4349
4223
  class: "szd-kv",
4350
4224
  style: { "margin-top": "12px" }
4351
- }, on = { class: "szd-kv__row" }, an = { class: "szd-kv__value" }, ln = {
4225
+ }, en = { class: "szd-kv__row" }, tn = { class: "szd-kv__value" }, sn = {
4352
4226
  key: 0,
4353
4227
  class: "szd-panel__section"
4354
- }, cn = { class: "szd-event-preview__text" }, dn = { class: "szd-event-preview__time" }, un = {
4228
+ }, rn = { class: "szd-event-preview__text" }, nn = { class: "szd-event-preview__time" }, on = {
4355
4229
  key: 1,
4356
4230
  class: "szd-panel"
4357
- }, hn = { class: "szd-timeline-filters" }, fn = ["onUpdate:modelValue"], pn = { class: "szd-timeline" }, mn = ["onClick"], yn = { class: "szd-timeline__time" }, gn = { class: "szd-timeline__text" }, _n = {
4231
+ }, an = { class: "szd-timeline-filters" }, ln = ["onUpdate:modelValue"], cn = { class: "szd-timeline" }, dn = ["onClick"], un = { class: "szd-timeline__time" }, hn = { class: "szd-timeline__text" }, fn = {
4358
4232
  key: 0,
4359
4233
  class: "szd-empty"
4360
- }, wn = {
4234
+ }, pn = {
4361
4235
  key: 2,
4362
4236
  class: "szd-panel"
4363
- }, Cn = { class: "szd-pipeline" }, vn = ["onClick"], En = { class: "szd-pipeline__label" }, bn = { class: "szd-pipeline__count" }, kn = {
4237
+ }, mn = { class: "szd-pipeline" }, yn = ["onClick"], gn = { class: "szd-pipeline__label" }, _n = { class: "szd-pipeline__count" }, wn = {
4364
4238
  key: 0,
4365
4239
  class: "szd-pipeline__arrow"
4366
- }, Sn = {
4240
+ }, Cn = {
4367
4241
  class: "szd-panel__section",
4368
4242
  style: { "margin-top": "20px" }
4369
- }, Tn = { class: "szd-preview-header" }, Mn = ["value"], $n = {
4243
+ }, vn = { class: "szd-preview-header" }, kn = ["value"], bn = {
4370
4244
  key: 0,
4371
4245
  class: "szd-data-grid"
4372
- }, An = { class: "szd-data-card__header" }, On = {
4246
+ }, En = { class: "szd-data-card__header" }, Sn = {
4373
4247
  key: 0,
4374
4248
  class: "szd-data-card__badge"
4375
- }, Pn = {
4249
+ }, Tn = {
4376
4250
  key: 1,
4377
4251
  class: "szd-data-card__badge szd-data-card__badge--absent"
4378
- }, In = { class: "szd-data-card__content" }, Fn = {
4252
+ }, Mn = { class: "szd-data-card__content" }, An = {
4379
4253
  key: 1,
4380
4254
  class: "szd-empty"
4381
- }, Dn = {
4255
+ }, On = {
4382
4256
  key: 3,
4383
4257
  class: "szd-panel"
4384
- }, zn = {
4258
+ }, $n = {
4385
4259
  class: "szd-kv",
4386
4260
  style: { "margin-bottom": "16px" }
4387
- }, Kn = { class: "szd-kv__row" }, Rn = { class: "szd-kv__value szd-kv__value--mono" }, Nn = { class: "szd-ast" }, xn = {
4261
+ }, Fn = { class: "szd-kv__row" }, Pn = { class: "szd-kv__value szd-kv__value--mono" }, Dn = { class: "szd-ast" }, zn = {
4388
4262
  key: 0,
4389
4263
  class: "szd-detail"
4390
- }, jn = { class: "szd-detail__panel szd-detail__panel--sm" }, Un = { class: "szd-detail__header" }, Qn = { class: "szd-detail__body" }, Vn = { class: "szd-settings-section" }, Ln = ["value"], Gn = {
4264
+ }, Rn = { class: "szd-detail__panel szd-detail__panel--sm" }, Kn = { class: "szd-detail__header" }, In = { class: "szd-detail__body" }, Nn = { class: "szd-settings-section" }, xn = ["value"], jn = {
4391
4265
  key: 0,
4392
4266
  class: "szd-settings-section"
4393
- }, Bn = { class: "szd-settings-row" }, Hn = { class: "szd-settings-code" }, qn = { class: "szd-settings-section" }, Jn = { class: "szd-settings-actions" }, Wn = ["disabled"], Zn = { class: "szd-settings-section" }, Yn = { class: "szd-toggle" }, Xn = {
4267
+ }, Un = { class: "szd-settings-row" }, Qn = { class: "szd-settings-code" }, Ln = { class: "szd-settings-section" }, Vn = { class: "szd-settings-actions" }, Bn = ["disabled"], Gn = { class: "szd-settings-section" }, Hn = { class: "szd-toggle" }, qn = {
4394
4268
  key: 1,
4395
4269
  class: "szd-settings-section"
4396
- }, eo = { class: "szd-kv" }, to = { class: "szd-kv__row" }, so = { class: "szd-kv__value" }, ro = { class: "szd-kv__row" }, no = { class: "szd-kv__value" }, oo = { class: "szd-kv__row" }, io = { class: "szd-kv__value" }, ao = { class: "szd-kv__row" }, lo = { class: "szd-kv__value" }, co = { class: "szd-kv__row" }, uo = { class: "szd-kv__value" }, ho = {
4270
+ }, Jn = { class: "szd-kv" }, Wn = { class: "szd-kv__row" }, Zn = { class: "szd-kv__value" }, Yn = { class: "szd-kv__row" }, Xn = { class: "szd-kv__value" }, eo = { class: "szd-kv__row" }, to = { class: "szd-kv__value" }, so = { class: "szd-kv__row" }, ro = { class: "szd-kv__value" }, no = { class: "szd-kv__row" }, oo = { class: "szd-kv__value" }, io = {
4397
4271
  key: 0,
4398
4272
  class: "szd-detail"
4399
- }, fo = { class: "szd-detail__panel" }, po = { class: "szd-detail__header" }, mo = { class: "szd-detail__title" }, yo = { class: "szd-detail__body" }, go = { class: "szd-kv" }, _o = { class: "szd-kv__key" }, wo = { class: "szd-kv__value" }, Co = { class: "szd-ast" }, vo = {
4273
+ }, ao = { class: "szd-detail__panel" }, lo = { class: "szd-detail__header" }, co = { class: "szd-detail__title" }, uo = { class: "szd-detail__body" }, ho = { class: "szd-kv" }, fo = { class: "szd-kv__key" }, po = { class: "szd-kv__value" }, mo = { class: "szd-ast" }, yo = {
4400
4274
  class: "szd-kv",
4401
4275
  style: { "margin-bottom": "16px" }
4402
- }, Eo = { class: "szd-kv__row" }, bo = { class: "szd-kv__value" }, ko = { class: "szd-kv__row" }, So = { class: "szd-kv__value" }, To = {
4276
+ }, go = { class: "szd-kv__row" }, _o = { class: "szd-kv__value" }, wo = { class: "szd-kv__row" }, Co = { class: "szd-kv__value" }, vo = {
4403
4277
  key: 0,
4404
4278
  class: "szd-kv__note"
4405
- }, Mo = { class: "szd-ast" }, Wt = 100, $o = {
4279
+ }, ko = { class: "szd-ast" }, Jt = 100, bo = {
4406
4280
  __name: "StateZeroDebugPanel",
4407
4281
  props: {
4408
4282
  queryset: { type: [Object, String], default: null },
@@ -4416,7 +4290,7 @@ const br = (n, e) => {
4416
4290
  { id: "timeline", label: "Timeline" },
4417
4291
  { id: "data", label: "Data" },
4418
4292
  { id: "ast", label: "AST" }
4419
- ], r = J(""), o = J(e.useQueryset), i = J(!0), l = J(Vt()), a = J(0), c = J(!1), f = J(null), p = J(!1), m = J(null), y = J({
4293
+ ], r = J(""), o = J(e.useQueryset), i = J(!0), l = J(Qt()), a = J(0), c = J(!1), h = J(null), p = J(!1), m = J(null), y = J({
4420
4294
  request: !0,
4421
4295
  response: !0,
4422
4296
  render: !0,
@@ -4432,9 +4306,9 @@ const br = (n, e) => {
4432
4306
  let g = u;
4433
4307
  return d && g && typeof g == "object" && "value" in g && (g = g.value), g?.original?.queryset ? g.original.queryset : g?.queryset ? g.queryset : g?.semanticKey ? g : null;
4434
4308
  }
4435
- const w = R(
4309
+ const w = I(
4436
4310
  () => _(e.queryset, o.value)
4437
- ), v = R(() => {
4311
+ ), v = I(() => {
4438
4312
  a.value;
4439
4313
  const u = [];
4440
4314
  return rs.forEach((d) => {
@@ -4445,50 +4319,50 @@ const br = (n, e) => {
4445
4319
  queryset: d
4446
4320
  });
4447
4321
  }), u;
4448
- }), O = R(() => (a.value, Array.from(j._stores.entries()).map(
4322
+ }), O = I(() => (a.value, Array.from(x._stores.entries()).map(
4449
4323
  ([u, d]) => ({
4450
4324
  semanticKey: u,
4451
4325
  modelName: d?.modelClass?.modelName,
4452
4326
  configKey: d?.modelClass?.configKey,
4453
4327
  store: d
4454
4328
  })
4455
- ))), T = R(() => {
4329
+ ))), T = I(() => {
4456
4330
  const u = /* @__PURE__ */ new Map();
4457
4331
  return v.value.forEach((d) => {
4458
4332
  u.set(d.semanticKey, d.queryset);
4459
4333
  }), u;
4460
- }), b = R(() => {
4334
+ }), k = I(() => {
4461
4335
  const u = /* @__PURE__ */ new Map();
4462
4336
  return v.value.forEach((d) => {
4463
4337
  u.set(d.semanticKey, d);
4464
4338
  }), O.value.forEach((d) => {
4465
4339
  u.has(d.semanticKey) || u.set(d.semanticKey, d);
4466
4340
  }), Array.from(u.values());
4467
- }), k = R(() => w.value?.semanticKey ? w.value.semanticKey : r.value ? r.value : ""), U = R(() => w.value ? w.value : r.value && T.value.get(r.value) || null), N = R(() => {
4468
- if (U.value)
4341
+ }), E = I(() => w.value?.semanticKey ? w.value.semanticKey : r.value ? r.value : ""), Q = I(() => w.value ? w.value : r.value && T.value.get(r.value) || null), N = I(() => {
4342
+ if (Q.value)
4469
4343
  try {
4470
- return j.getStore(U.value);
4344
+ return x.getStore(Q.value);
4471
4345
  } catch {
4472
4346
  return null;
4473
4347
  }
4474
- return k.value && j._stores.get(k.value) || null;
4475
- }), I = R(() => {
4348
+ return E.value && x._stores.get(E.value) || null;
4349
+ }), F = I(() => {
4476
4350
  a.value;
4477
- const u = N.value, d = U.value, g = u?.modelClass?.modelName || d?.ModelClass?.modelName, z = u?.modelClass?.configKey || d?.ModelClass?.configKey, H = u?.groundTruthPks?.length ?? 0, oe = u?.operationsMap?.size ?? 0, le = u?.getInflightOperations?.() || [], be = u?.isSyncing ?? !1, Ue = u?.lastSync ? new Date(u.lastSync).toLocaleString() : "—", ot = u && Array.isArray(u._lastRenderedPks) ? u._lastRenderedPks.length : null, cs = u?.groundTruthPks?.length ?? 0, ds = u ? u.lastSync === null ? "model store" : "ground truth" : "—", us = be ? "Sync in progress — results may change." : oe > 0 ? "Optimistic operations are applied to results." : u?.lastSync === null ? "No ground truth yet — rendering from model store." : "Using ground truth + local filters.";
4351
+ const u = N.value, d = Q.value, g = u?.modelClass?.modelName || d?.ModelClass?.modelName, R = u?.modelClass?.configKey || d?.ModelClass?.configKey, H = u?.groundTruthPks?.length ?? 0, oe = u?.operationsMap?.size ?? 0, le = u?.getInflightOperations?.() || [], be = u?.isSyncing ?? !1, je = u?.lastSync ? new Date(u.lastSync).toLocaleString() : "—", nt = u && Array.isArray(u._lastRenderedPks) ? u._lastRenderedPks.length : null, cs = u?.groundTruthPks?.length ?? 0, ds = u ? u.lastSync === null ? "model store" : "ground truth" : "—", us = be ? "Sync in progress — results may change." : oe > 0 ? "Optimistic operations are applied to results." : u?.lastSync === null ? "No ground truth yet — rendering from model store." : "Using ground truth + local filters.";
4478
4352
  return {
4479
4353
  modelName: g,
4480
- configKey: z,
4354
+ configKey: R,
4481
4355
  groundTruthCount: H,
4482
4356
  opsCount: oe,
4483
4357
  inFlightCount: le.length,
4484
4358
  isSyncing: be,
4485
- lastSync: Ue,
4486
- optimisticCount: ot,
4359
+ lastSync: je,
4360
+ optimisticCount: nt,
4487
4361
  confirmedCount: cs,
4488
4362
  source: ds,
4489
4363
  reason: us
4490
4364
  };
4491
- }), re = R(() => {
4365
+ }), re = I(() => {
4492
4366
  a.value;
4493
4367
  try {
4494
4368
  return N.value?.queryset?.build?.() || null;
@@ -4499,13 +4373,13 @@ const br = (n, e) => {
4499
4373
  function pe(u) {
4500
4374
  if (!u?.filter?.conditions) return "—";
4501
4375
  const d = u.filter.conditions;
4502
- return typeof d != "object" ? String(d) : Object.entries(d).map(([z, H]) => H === null ? `${z}: null` : typeof H == "object" ? `${z}: ${JSON.stringify(H)}` : `${z}: ${H}`).join(", ");
4376
+ return typeof d != "object" ? String(d) : Object.entries(d).map(([R, H]) => H === null ? `${R}: null` : typeof H == "object" ? `${R}: ${JSON.stringify(H)}` : `${R}: ${H}`).join(", ");
4503
4377
  }
4504
4378
  function ae(u) {
4505
4379
  const d = u?.orderBy;
4506
4380
  return !d || Array.isArray(d) && d.length === 0 ? "—" : Array.isArray(d) ? d.join(", ") : String(d);
4507
4381
  }
4508
- const D = R(() => {
4382
+ const z = I(() => {
4509
4383
  const u = re.value;
4510
4384
  return {
4511
4385
  filter: pe(u),
@@ -4513,10 +4387,10 @@ const br = (n, e) => {
4513
4387
  limit: u?.serializerOptions?.limit ?? "—"
4514
4388
  };
4515
4389
  });
4516
- function F(u, d, g, z) {
4390
+ function D(u, d, g, R) {
4517
4391
  if (!u || !Array.isArray(g)) return [];
4518
4392
  const H = [];
4519
- for (const oe of g.slice(0, z))
4393
+ for (const oe of g.slice(0, R))
4520
4394
  try {
4521
4395
  const le = u.fromPk(oe, d);
4522
4396
  le && H.push(le.serialize());
@@ -4524,9 +4398,9 @@ const br = (n, e) => {
4524
4398
  }
4525
4399
  return H;
4526
4400
  }
4527
- const K = R(() => {
4401
+ const K = I(() => {
4528
4402
  a.value;
4529
- const u = N.value, d = U.value;
4403
+ const u = N.value, d = Q.value;
4530
4404
  if (!u || !d)
4531
4405
  return {
4532
4406
  modelStoreFiltered: [],
@@ -4541,7 +4415,7 @@ const br = (n, e) => {
4541
4415
  finalSample: [],
4542
4416
  limit: null
4543
4417
  };
4544
- const g = Array.isArray(u.groundTruthPks) ? [...u.groundTruthPks] : [], z = u.renderFromData(!0), H = u.renderFromData(!1), oe = u._getValidatedAndFilteredPks(z), le = u.lastSync === null ? u.renderFromModelStore() : [], be = d.build()?.serializerOptions?.limit ?? null, Ue = be ? oe.slice(0, be) : oe, ot = le.length > 0 ? F(
4418
+ const g = Array.isArray(u.groundTruthPks) ? [...u.groundTruthPks] : [], R = u.renderFromData(!0), H = u.renderFromData(!1), oe = u._getValidatedAndFilteredPks(R), le = [], be = d.build()?.serializerOptions?.limit ?? null, je = be ? oe.slice(0, be) : oe, nt = le.length > 0 ? D(
4545
4419
  u.modelClass,
4546
4420
  d,
4547
4421
  le,
@@ -4550,66 +4424,66 @@ const br = (n, e) => {
4550
4424
  return {
4551
4425
  modelStoreFiltered: le,
4552
4426
  groundTruth: g,
4553
- optimistic: z,
4427
+ optimistic: R,
4554
4428
  filtered: oe,
4555
- final: Ue,
4556
- modelStoreSample: ot,
4557
- groundTruthSample: F(
4429
+ final: je,
4430
+ modelStoreSample: nt,
4431
+ groundTruthSample: D(
4558
4432
  u.modelClass,
4559
4433
  d,
4560
4434
  g,
4561
4435
  e.sampleSize
4562
4436
  ),
4563
- optimisticSample: F(
4437
+ optimisticSample: D(
4564
4438
  u.modelClass,
4565
4439
  d,
4566
- z,
4440
+ R,
4567
4441
  e.sampleSize
4568
4442
  ),
4569
- filteredSample: F(
4443
+ filteredSample: D(
4570
4444
  u.modelClass,
4571
4445
  d,
4572
4446
  oe,
4573
4447
  e.sampleSize
4574
4448
  ),
4575
- finalSample: F(
4449
+ finalSample: D(
4576
4450
  u.modelClass,
4577
4451
  d,
4578
- Ue,
4452
+ je,
4579
4453
  e.sampleSize
4580
4454
  ),
4581
4455
  limit: be,
4582
4456
  confirmed: H
4583
4457
  };
4584
- }), me = R(() => [
4458
+ }), me = I(() => [
4585
4459
  { id: "model-store", label: "Model Store", count: K.value.modelStoreFiltered.length, pks: K.value.modelStoreFiltered },
4586
4460
  { id: "ground-truth", label: "Ground Truth", count: K.value.groundTruth.length, pks: K.value.groundTruth },
4587
4461
  { id: "optimistic", label: "Optimistic", count: K.value.optimistic.length, pks: K.value.optimistic },
4588
4462
  { id: "filtered", label: "Filtered", count: K.value.filtered.length, pks: K.value.filtered },
4589
4463
  { id: "final", label: "Final", count: K.value.final.length, pks: K.value.final }
4590
- ]), Ye = R(() => K.value.final || []);
4464
+ ]), Ze = I(() => K.value.final || []);
4591
4465
  function ye(u) {
4592
- const d = N.value, g = U.value;
4466
+ const d = N.value, g = Q.value;
4593
4467
  if (!d || !g || u == null) return null;
4594
4468
  try {
4595
- const z = d.modelClass.fromPk(u, g);
4596
- return z ? z.serialize() : null;
4469
+ const R = d.modelClass.fromPk(u, g);
4470
+ return R ? R.serialize() : null;
4597
4471
  } catch {
4598
4472
  return null;
4599
4473
  }
4600
4474
  }
4601
- R(() => m.value == null ? null : ye(m.value));
4602
- const Ke = R(() => {
4603
- if (!f.value || f.value.type !== "snapshot") return [];
4604
- const u = f.value.data, d = N.value, g = U.value;
4605
- return !d || !g || !u.pks ? [] : F(d.modelClass, g, u.pks, Wt);
4606
- }), Xe = R(() => !f.value || f.value.type !== "snapshot" ? !1 : f.value.data.count > Wt), Re = R(() => {
4607
- if (!k.value) return l.value;
4475
+ I(() => m.value == null ? null : ye(m.value));
4476
+ const Re = I(() => {
4477
+ if (!h.value || h.value.type !== "snapshot") return [];
4478
+ const u = h.value.data, d = N.value, g = Q.value;
4479
+ return !d || !g || !u.pks ? [] : D(d.modelClass, g, u.pks, Jt);
4480
+ }), Ye = I(() => !h.value || h.value.type !== "snapshot" ? !1 : h.value.data.count > Jt), Ke = I(() => {
4481
+ if (!E.value) return l.value;
4608
4482
  const u = N.value;
4609
- return l.value.filter((d) => d.semanticKey === k.value ? !0 : u ? d.modelName === u.modelClass?.modelName && d.configKey === u.modelClass?.configKey : !1);
4610
- }), Ee = R(() => Re.value.filter((u) => y.value[u.type])), Ne = R(() => l.value.length), ne = R(
4483
+ return l.value.filter((d) => d.semanticKey === E.value ? !0 : u ? d.modelName === u.modelClass?.modelName && d.configKey === u.modelClass?.configKey : !1);
4484
+ }), ke = I(() => Ke.value.filter((u) => y.value[u.type])), Ie = I(() => l.value.length), ne = I(
4611
4485
  () => l.value.length ? l.value[l.value.length - 1] : null
4612
- ), xe = [
4486
+ ), Ne = [
4613
4487
  { id: "request", label: "Requests", color: "#3b82f6" },
4614
4488
  { id: "response", label: "Responses", color: "#22c55e" },
4615
4489
  { id: "render", label: "Renders", color: "#a855f7" },
@@ -4620,10 +4494,10 @@ const br = (n, e) => {
4620
4494
  { id: "groupSync", label: "Group Sync", color: "#8b5cf6" },
4621
4495
  { id: "error", label: "Errors", color: "#ef4444" }
4622
4496
  ];
4623
- function je(u) {
4624
- return xe.find((d) => d.id === u)?.color || "#6b7280";
4497
+ function xe(u) {
4498
+ return Ne.find((d) => d.id === u)?.color || "#6b7280";
4625
4499
  }
4626
- function et(u) {
4500
+ function Xe(u) {
4627
4501
  if (!u) return "";
4628
4502
  try {
4629
4503
  return new Date(u).toLocaleTimeString();
@@ -4631,7 +4505,7 @@ const br = (n, e) => {
4631
4505
  return "";
4632
4506
  }
4633
4507
  }
4634
- function Et(u) {
4508
+ function vt(u) {
4635
4509
  if (!u) return "";
4636
4510
  switch (u.type) {
4637
4511
  case "request":
@@ -4660,7 +4534,7 @@ const br = (n, e) => {
4660
4534
  if (!u) return null;
4661
4535
  const d = {
4662
4536
  type: u.type,
4663
- time: et(u.ts),
4537
+ time: Xe(u.ts),
4664
4538
  model: u.modelName,
4665
4539
  config: u.configKey,
4666
4540
  semanticKey: u.semanticKey
@@ -4689,10 +4563,10 @@ const br = (n, e) => {
4689
4563
  }
4690
4564
  }
4691
4565
  function os() {
4692
- Gs(), l.value = [];
4566
+ Bs(), l.value = [];
4693
4567
  }
4694
4568
  function is() {
4695
- !k.value || !navigator?.clipboard || navigator.clipboard.writeText(k.value);
4569
+ !E.value || !navigator?.clipboard || navigator.clipboard.writeText(E.value);
4696
4570
  }
4697
4571
  async function as() {
4698
4572
  if (!(!N.value || c.value)) {
@@ -4705,60 +4579,60 @@ const br = (n, e) => {
4705
4579
  }
4706
4580
  }
4707
4581
  }
4708
- function bt(u) {
4709
- f.value = { type: "entry", data: u };
4582
+ function kt(u) {
4583
+ h.value = { type: "entry", data: u };
4710
4584
  }
4711
4585
  function ls(u) {
4712
- f.value = { type: "snapshot", data: u };
4586
+ h.value = { type: "snapshot", data: u };
4713
4587
  }
4714
- function kt() {
4715
- f.value = null;
4588
+ function bt() {
4589
+ h.value = null;
4716
4590
  }
4717
- function St(u) {
4591
+ function Et(u) {
4718
4592
  Object.keys(y.value).forEach((d) => {
4719
4593
  y.value[d] = u;
4720
4594
  });
4721
4595
  }
4722
- let tt = null, st = null, rt = null, nt = null;
4596
+ let et = null, tt = null, st = null, rt = null;
4723
4597
  return hs(() => {
4724
- Bs(), Lt(e.maxEntries), tt = Vs((u) => {
4598
+ Gs(), Lt(e.maxEntries), et = Ls((u) => {
4725
4599
  i.value && (l.value = [...l.value, u], l.value.length > e.maxEntries && (l.value = l.value.slice(-e.maxEntries)));
4726
- }), st = Ls(() => {
4600
+ }), tt = Vs(() => {
4727
4601
  l.value = [];
4728
- }), rt = setInterval(() => {
4602
+ }), st = setInterval(() => {
4729
4603
  a.value += 1;
4730
- }, 2e3), nt = setInterval(() => {
4731
- l.value = Vt();
4604
+ }, 2e3), rt = setInterval(() => {
4605
+ l.value = Qt();
4732
4606
  }, 1e3);
4733
4607
  }), fs(() => {
4734
- tt && tt(), st && st(), rt && clearInterval(rt), nt && clearInterval(nt);
4735
- }), it(
4608
+ et && et(), tt && tt(), st && clearInterval(st), rt && clearInterval(rt);
4609
+ }), ot(
4736
4610
  () => e.maxEntries,
4737
4611
  (u) => Lt(u)
4738
- ), it(
4612
+ ), ot(
4739
4613
  () => e.useQueryset,
4740
4614
  (u) => {
4741
4615
  o.value = u;
4742
4616
  }
4743
- ), it(k, () => {
4617
+ ), ot(E, () => {
4744
4618
  m.value = null;
4745
- }), (u, d) => (A(), $("section", kr, [
4746
- h("header", Sr, [
4747
- h("div", Tr, [
4748
- h("div", Mr, [
4749
- d[9] || (d[9] = h("div", { class: "szd-header__title" }, "StateZero", -1)),
4750
- k.value ? (A(), $("span", $r, S(I.value.modelName || "?"), 1)) : (A(), $("span", Ar, "No queryset"))
4619
+ }), (u, d) => (A(), M("section", wr, [
4620
+ f("header", Cr, [
4621
+ f("div", vr, [
4622
+ f("div", kr, [
4623
+ d[9] || (d[9] = f("div", { class: "szd-header__title" }, "StateZero", -1)),
4624
+ E.value ? (A(), M("span", br, S(F.value.modelName || "?"), 1)) : (A(), M("span", Er, "No queryset"))
4751
4625
  ]),
4752
- h("div", Or, [
4753
- I.value.isSyncing ? (A(), $("span", Pr, "Syncing")) : V("", !0),
4754
- I.value.opsCount > 0 ? (A(), $("span", Ir, S(I.value.opsCount) + " ops", 1)) : V("", !0),
4755
- h("span", Fr, S(Ne.value) + " events", 1),
4756
- h("button", {
4626
+ f("div", Sr, [
4627
+ F.value.isSyncing ? (A(), M("span", Tr, "Syncing")) : L("", !0),
4628
+ F.value.opsCount > 0 ? (A(), M("span", Mr, S(F.value.opsCount) + " ops", 1)) : L("", !0),
4629
+ f("span", Ar, S(Ie.value) + " events", 1),
4630
+ f("button", {
4757
4631
  class: "szd-btn szd-btn--icon",
4758
4632
  onClick: d[0] || (d[0] = (g) => p.value = !0),
4759
4633
  title: "Settings"
4760
4634
  }, [...d[10] || (d[10] = [
4761
- h("svg", {
4635
+ f("svg", {
4762
4636
  width: "16",
4763
4637
  height: "16",
4764
4638
  viewBox: "0 0 24 24",
@@ -4766,339 +4640,339 @@ const br = (n, e) => {
4766
4640
  stroke: "currentColor",
4767
4641
  "stroke-width": "2"
4768
4642
  }, [
4769
- h("circle", {
4643
+ f("circle", {
4770
4644
  cx: "12",
4771
4645
  cy: "12",
4772
4646
  r: "3"
4773
4647
  }),
4774
- h("path", { d: "M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z" })
4648
+ f("path", { d: "M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z" })
4775
4649
  ], -1)
4776
4650
  ])])
4777
4651
  ])
4778
4652
  ]),
4779
- h("nav", Dr, [
4780
- (A(), $(W, null, ce(s, (g) => h("button", {
4653
+ f("nav", Or, [
4654
+ (A(), M(W, null, ce(s, (g) => f("button", {
4781
4655
  key: g.id,
4782
- class: Mt(["szd-tabs__tab", { "szd-tabs__tab--active": t.value === g.id }]),
4783
- onClick: (z) => t.value = g.id
4784
- }, S(g.label), 11, zr)), 64))
4656
+ class: Tt(["szd-tabs__tab", { "szd-tabs__tab--active": t.value === g.id }]),
4657
+ onClick: (R) => t.value = g.id
4658
+ }, S(g.label), 11, $r)), 64))
4785
4659
  ])
4786
4660
  ]),
4787
- h("main", Kr, [
4788
- t.value === "overview" ? (A(), $("div", Rr, [
4789
- h("div", Nr, [
4790
- d[15] || (d[15] = h("h3", { class: "szd-panel__heading" }, "Why This View?", -1)),
4791
- h("div", xr, [
4792
- h("div", jr, [
4793
- d[11] || (d[11] = h("span", { class: "szd-kv__key" }, "Filter:", -1)),
4794
- h("span", Ur, S(D.value.filter), 1)
4661
+ f("main", Fr, [
4662
+ t.value === "overview" ? (A(), M("div", Pr, [
4663
+ f("div", Dr, [
4664
+ d[15] || (d[15] = f("h3", { class: "szd-panel__heading" }, "Why This View?", -1)),
4665
+ f("div", zr, [
4666
+ f("div", Rr, [
4667
+ d[11] || (d[11] = f("span", { class: "szd-kv__key" }, "Filter:", -1)),
4668
+ f("span", Kr, S(z.value.filter), 1)
4795
4669
  ]),
4796
- h("div", Qr, [
4797
- d[12] || (d[12] = h("span", { class: "szd-kv__key" }, "Order:", -1)),
4798
- h("span", Vr, S(D.value.orderBy), 1)
4670
+ f("div", Ir, [
4671
+ d[12] || (d[12] = f("span", { class: "szd-kv__key" }, "Order:", -1)),
4672
+ f("span", Nr, S(z.value.orderBy), 1)
4799
4673
  ]),
4800
- h("div", Lr, [
4801
- d[13] || (d[13] = h("span", { class: "szd-kv__key" }, "Limit:", -1)),
4802
- h("span", Gr, S(D.value.limit), 1)
4674
+ f("div", xr, [
4675
+ d[13] || (d[13] = f("span", { class: "szd-kv__key" }, "Limit:", -1)),
4676
+ f("span", jr, S(z.value.limit), 1)
4803
4677
  ]),
4804
- h("div", Br, [
4805
- d[14] || (d[14] = h("span", { class: "szd-kv__key" }, "Reason:", -1)),
4806
- h("span", Hr, S(I.value.reason), 1)
4678
+ f("div", Ur, [
4679
+ d[14] || (d[14] = f("span", { class: "szd-kv__key" }, "Reason:", -1)),
4680
+ f("span", Qr, S(F.value.reason), 1)
4807
4681
  ])
4808
4682
  ])
4809
4683
  ]),
4810
- h("div", qr, [
4811
- d[21] || (d[21] = h("h3", { class: "szd-panel__heading" }, "Current State", -1)),
4812
- h("div", Jr, [
4813
- h("div", Wr, [
4814
- h("div", Zr, S(I.value.optimisticCount ?? "—"), 1),
4815
- d[16] || (d[16] = h("div", { class: "szd-stat__label" }, "Optimistic", -1))
4684
+ f("div", Lr, [
4685
+ d[21] || (d[21] = f("h3", { class: "szd-panel__heading" }, "Current State", -1)),
4686
+ f("div", Vr, [
4687
+ f("div", Br, [
4688
+ f("div", Gr, S(F.value.optimisticCount ?? "—"), 1),
4689
+ d[16] || (d[16] = f("div", { class: "szd-stat__label" }, "Optimistic", -1))
4816
4690
  ]),
4817
- h("div", Yr, [
4818
- h("div", Xr, S(I.value.confirmedCount), 1),
4819
- d[17] || (d[17] = h("div", { class: "szd-stat__label" }, "Confirmed", -1))
4691
+ f("div", Hr, [
4692
+ f("div", qr, S(F.value.confirmedCount), 1),
4693
+ d[17] || (d[17] = f("div", { class: "szd-stat__label" }, "Confirmed", -1))
4820
4694
  ]),
4821
- h("div", en, [
4822
- h("div", tn, S(I.value.groundTruthCount), 1),
4823
- d[18] || (d[18] = h("div", { class: "szd-stat__label" }, "Ground Truth", -1))
4695
+ f("div", Jr, [
4696
+ f("div", Wr, S(F.value.groundTruthCount), 1),
4697
+ d[18] || (d[18] = f("div", { class: "szd-stat__label" }, "Ground Truth", -1))
4824
4698
  ]),
4825
- h("div", sn, [
4826
- h("div", rn, S(I.value.inFlightCount), 1),
4827
- d[19] || (d[19] = h("div", { class: "szd-stat__label" }, "In-Flight", -1))
4699
+ f("div", Zr, [
4700
+ f("div", Yr, S(F.value.inFlightCount), 1),
4701
+ d[19] || (d[19] = f("div", { class: "szd-stat__label" }, "In-Flight", -1))
4828
4702
  ])
4829
4703
  ]),
4830
- h("div", nn, [
4831
- h("div", on, [
4832
- d[20] || (d[20] = h("span", { class: "szd-kv__key" }, "Last Sync:", -1)),
4833
- h("span", an, S(I.value.lastSync), 1)
4704
+ f("div", Xr, [
4705
+ f("div", en, [
4706
+ d[20] || (d[20] = f("span", { class: "szd-kv__key" }, "Last Sync:", -1)),
4707
+ f("span", tn, S(F.value.lastSync), 1)
4834
4708
  ])
4835
4709
  ])
4836
4710
  ]),
4837
- ne.value ? (A(), $("div", ln, [
4838
- d[22] || (d[22] = h("h3", { class: "szd-panel__heading" }, "Last Event", -1)),
4839
- h("button", {
4711
+ ne.value ? (A(), M("div", sn, [
4712
+ d[22] || (d[22] = f("h3", { class: "szd-panel__heading" }, "Last Event", -1)),
4713
+ f("button", {
4840
4714
  class: "szd-event-preview",
4841
- onClick: d[1] || (d[1] = (g) => bt(ne.value))
4715
+ onClick: d[1] || (d[1] = (g) => kt(ne.value))
4842
4716
  }, [
4843
- h("span", {
4717
+ f("span", {
4844
4718
  class: "szd-event-preview__badge",
4845
- style: at({ background: je(ne.value.type) })
4719
+ style: it({ background: xe(ne.value.type) })
4846
4720
  }, S(ne.value.type), 5),
4847
- h("span", cn, S(Et(ne.value)), 1),
4848
- h("span", dn, S(et(ne.value.ts)), 1)
4721
+ f("span", rn, S(vt(ne.value)), 1),
4722
+ f("span", nn, S(Xe(ne.value.ts)), 1)
4849
4723
  ])
4850
- ])) : V("", !0)
4851
- ])) : V("", !0),
4852
- t.value === "timeline" ? (A(), $("div", un, [
4853
- h("div", hn, [
4854
- h("button", {
4724
+ ])) : L("", !0)
4725
+ ])) : L("", !0),
4726
+ t.value === "timeline" ? (A(), M("div", on, [
4727
+ f("div", an, [
4728
+ f("button", {
4855
4729
  class: "szd-btn szd-btn--sm",
4856
- onClick: d[2] || (d[2] = (g) => St(!0))
4730
+ onClick: d[2] || (d[2] = (g) => Et(!0))
4857
4731
  }, "All"),
4858
- h("button", {
4732
+ f("button", {
4859
4733
  class: "szd-btn szd-btn--sm",
4860
- onClick: d[3] || (d[3] = (g) => St(!1))
4734
+ onClick: d[3] || (d[3] = (g) => Et(!1))
4861
4735
  }, "None"),
4862
- (A(), $(W, null, ce(xe, (g) => h("label", {
4736
+ (A(), M(W, null, ce(Ne, (g) => f("label", {
4863
4737
  key: g.id,
4864
- class: Mt(["szd-filter-chip", { "szd-filter-chip--active": y.value[g.id] }]),
4865
- style: at(y.value[g.id] ? { background: g.color, borderColor: g.color } : {})
4738
+ class: Tt(["szd-filter-chip", { "szd-filter-chip--active": y.value[g.id] }]),
4739
+ style: it(y.value[g.id] ? { background: g.color, borderColor: g.color } : {})
4866
4740
  }, [
4867
- Qe(h("input", {
4741
+ Ue(f("input", {
4868
4742
  type: "checkbox",
4869
- "onUpdate:modelValue": (z) => y.value[g.id] = z,
4743
+ "onUpdate:modelValue": (R) => y.value[g.id] = R,
4870
4744
  class: "szd-filter-chip__input"
4871
- }, null, 8, fn), [
4872
- [$t, y.value[g.id]]
4745
+ }, null, 8, ln), [
4746
+ [Mt, y.value[g.id]]
4873
4747
  ]),
4874
- Ve(" " + S(g.label), 1)
4748
+ Qe(" " + S(g.label), 1)
4875
4749
  ], 6)), 64))
4876
4750
  ]),
4877
- h("div", pn, [
4878
- (A(!0), $(W, null, ce(Ee.value, (g) => (A(), $("div", {
4751
+ f("div", cn, [
4752
+ (A(!0), M(W, null, ce(ke.value, (g) => (A(), M("div", {
4879
4753
  key: g.id,
4880
4754
  class: "szd-timeline__item",
4881
- onClick: (z) => bt(g)
4755
+ onClick: (R) => kt(g)
4882
4756
  }, [
4883
- h("span", yn, S(et(g.ts)), 1),
4884
- h("span", {
4757
+ f("span", un, S(Xe(g.ts)), 1),
4758
+ f("span", {
4885
4759
  class: "szd-timeline__badge",
4886
- style: at({ background: je(g.type) })
4760
+ style: it({ background: xe(g.type) })
4887
4761
  }, S(g.type), 5),
4888
- h("span", gn, S(Et(g)), 1)
4889
- ], 8, mn))), 128)),
4890
- Ee.value.length ? V("", !0) : (A(), $("div", _n, " No events match current filters "))
4762
+ f("span", hn, S(vt(g)), 1)
4763
+ ], 8, dn))), 128)),
4764
+ ke.value.length ? L("", !0) : (A(), M("div", fn, " No events match current filters "))
4891
4765
  ])
4892
- ])) : V("", !0),
4893
- t.value === "data" ? (A(), $("div", wn, [
4894
- d[25] || (d[25] = h("h3", { class: "szd-panel__heading" }, "Data Pipeline", -1)),
4895
- h("div", Cn, [
4896
- (A(!0), $(W, null, ce(me.value, (g, z) => (A(), $(W, {
4766
+ ])) : L("", !0),
4767
+ t.value === "data" ? (A(), M("div", pn, [
4768
+ d[25] || (d[25] = f("h3", { class: "szd-panel__heading" }, "Data Pipeline", -1)),
4769
+ f("div", mn, [
4770
+ (A(!0), M(W, null, ce(me.value, (g, R) => (A(), M(W, {
4897
4771
  key: g.id
4898
4772
  }, [
4899
- h("div", {
4773
+ f("div", {
4900
4774
  class: "szd-pipeline__stage",
4901
4775
  onClick: (H) => ls(g)
4902
4776
  }, [
4903
- h("div", En, S(g.label), 1),
4904
- h("div", bn, S(g.count), 1)
4905
- ], 8, vn),
4906
- z < me.value.length - 1 ? (A(), $("div", kn, "→")) : V("", !0)
4777
+ f("div", gn, S(g.label), 1),
4778
+ f("div", _n, S(g.count), 1)
4779
+ ], 8, yn),
4780
+ R < me.value.length - 1 ? (A(), M("div", wn, "→")) : L("", !0)
4907
4781
  ], 64))), 128))
4908
4782
  ]),
4909
- h("div", Sn, [
4910
- h("div", Tn, [
4911
- d[24] || (d[24] = h("h3", { class: "szd-panel__heading" }, "Instance Preview", -1)),
4912
- Qe(h("select", {
4783
+ f("div", Cn, [
4784
+ f("div", vn, [
4785
+ d[24] || (d[24] = f("h3", { class: "szd-panel__heading" }, "Instance Preview", -1)),
4786
+ Ue(f("select", {
4913
4787
  "onUpdate:modelValue": d[4] || (d[4] = (g) => m.value = g),
4914
4788
  class: "szd-select"
4915
4789
  }, [
4916
- d[23] || (d[23] = h("option", { value: null }, "Select instance...", -1)),
4917
- (A(!0), $(W, null, ce(Ye.value, (g) => (A(), $("option", {
4790
+ d[23] || (d[23] = f("option", { value: null }, "Select instance...", -1)),
4791
+ (A(!0), M(W, null, ce(Ze.value, (g) => (A(), M("option", {
4918
4792
  key: g,
4919
4793
  value: g
4920
- }, S(g), 9, Mn))), 128))
4794
+ }, S(g), 9, kn))), 128))
4921
4795
  ], 512), [
4922
4796
  [At, m.value]
4923
4797
  ])
4924
4798
  ]),
4925
- m.value != null ? (A(), $("div", $n, [
4926
- (A(!0), $(W, null, ce(me.value, (g) => (A(), $("div", {
4799
+ m.value != null ? (A(), M("div", bn, [
4800
+ (A(!0), M(W, null, ce(me.value, (g) => (A(), M("div", {
4927
4801
  key: g.id,
4928
4802
  class: "szd-data-card"
4929
4803
  }, [
4930
- h("div", An, [
4931
- Ve(S(g.label) + " ", 1),
4932
- g.pks.includes(m.value) ? (A(), $("span", On, "Present")) : (A(), $("span", Pn, "Absent"))
4804
+ f("div", En, [
4805
+ Qe(S(g.label) + " ", 1),
4806
+ g.pks.includes(m.value) ? (A(), M("span", Sn, "Present")) : (A(), M("span", Tn, "Absent"))
4933
4807
  ]),
4934
- h("pre", In, S(g.pks.includes(m.value) ? JSON.stringify(ye(m.value), null, 2) : "—"), 1)
4808
+ f("pre", Mn, S(g.pks.includes(m.value) ? JSON.stringify(ye(m.value), null, 2) : "—"), 1)
4935
4809
  ]))), 128))
4936
- ])) : (A(), $("div", Fn, "Select an instance to preview"))
4810
+ ])) : (A(), M("div", An, "Select an instance to preview"))
4937
4811
  ])
4938
- ])) : V("", !0),
4939
- t.value === "ast" ? (A(), $("div", Dn, [
4940
- d[27] || (d[27] = h("h3", { class: "szd-panel__heading" }, "Query AST", -1)),
4941
- h("div", zn, [
4942
- h("div", Kn, [
4943
- d[26] || (d[26] = h("span", { class: "szd-kv__key" }, "Semantic Key:", -1)),
4944
- h("code", Rn, S(k.value || "—"), 1)
4812
+ ])) : L("", !0),
4813
+ t.value === "ast" ? (A(), M("div", On, [
4814
+ d[27] || (d[27] = f("h3", { class: "szd-panel__heading" }, "Query AST", -1)),
4815
+ f("div", $n, [
4816
+ f("div", Fn, [
4817
+ d[26] || (d[26] = f("span", { class: "szd-kv__key" }, "Semantic Key:", -1)),
4818
+ f("code", Pn, S(E.value || "—"), 1)
4945
4819
  ])
4946
4820
  ]),
4947
- h("pre", Nn, S(re.value ? JSON.stringify(re.value, null, 2) : "Select a queryset to view AST"), 1)
4948
- ])) : V("", !0)
4821
+ f("pre", Dn, S(re.value ? JSON.stringify(re.value, null, 2) : "Select a queryset to view AST"), 1)
4822
+ ])) : L("", !0)
4949
4823
  ]),
4950
- Tt(Ot, { name: "szd-slide" }, {
4951
- default: Pt(() => [
4952
- p.value ? (A(), $("div", xn, [
4953
- h("div", {
4824
+ St(Ot, { name: "szd-slide" }, {
4825
+ default: $t(() => [
4826
+ p.value ? (A(), M("div", zn, [
4827
+ f("div", {
4954
4828
  class: "szd-detail__backdrop",
4955
4829
  onClick: d[5] || (d[5] = (g) => p.value = !1)
4956
4830
  }),
4957
- h("div", jn, [
4958
- h("div", Un, [
4959
- d[28] || (d[28] = h("h3", { class: "szd-detail__title" }, "Debug Settings", -1)),
4960
- h("button", {
4831
+ f("div", Rn, [
4832
+ f("div", Kn, [
4833
+ d[28] || (d[28] = f("h3", { class: "szd-detail__title" }, "Debug Settings", -1)),
4834
+ f("button", {
4961
4835
  class: "szd-btn",
4962
4836
  onClick: d[6] || (d[6] = (g) => p.value = !1)
4963
4837
  }, "Close")
4964
4838
  ]),
4965
- h("div", Qn, [
4966
- h("div", Vn, [
4967
- d[30] || (d[30] = h("label", { class: "szd-settings-label" }, "Queryset", -1)),
4968
- Qe(h("select", {
4839
+ f("div", In, [
4840
+ f("div", Nn, [
4841
+ d[30] || (d[30] = f("label", { class: "szd-settings-label" }, "Queryset", -1)),
4842
+ Ue(f("select", {
4969
4843
  "onUpdate:modelValue": d[7] || (d[7] = (g) => r.value = g),
4970
4844
  class: "szd-select szd-select--full"
4971
4845
  }, [
4972
- d[29] || (d[29] = h("option", { value: "" }, "Select queryset...", -1)),
4973
- (A(!0), $(W, null, ce(b.value, (g) => (A(), $("option", {
4846
+ d[29] || (d[29] = f("option", { value: "" }, "Select queryset...", -1)),
4847
+ (A(!0), M(W, null, ce(k.value, (g) => (A(), M("option", {
4974
4848
  key: g.semanticKey,
4975
4849
  value: g.semanticKey
4976
- }, S(g.modelName || "?") + " · " + S(g.semanticKey), 9, Ln))), 128))
4850
+ }, S(g.modelName || "?") + " · " + S(g.semanticKey), 9, xn))), 128))
4977
4851
  ], 512), [
4978
4852
  [At, r.value]
4979
4853
  ])
4980
4854
  ]),
4981
- k.value ? (A(), $("div", Gn, [
4982
- d[31] || (d[31] = h("label", { class: "szd-settings-label" }, "Semantic Key", -1)),
4983
- h("div", Bn, [
4984
- h("code", Hn, S(k.value), 1),
4985
- h("button", {
4855
+ E.value ? (A(), M("div", jn, [
4856
+ d[31] || (d[31] = f("label", { class: "szd-settings-label" }, "Semantic Key", -1)),
4857
+ f("div", Un, [
4858
+ f("code", Qn, S(E.value), 1),
4859
+ f("button", {
4986
4860
  class: "szd-btn szd-btn--sm",
4987
4861
  onClick: is
4988
4862
  }, "Copy")
4989
4863
  ])
4990
- ])) : V("", !0),
4991
- h("div", qn, [
4992
- d[32] || (d[32] = h("label", { class: "szd-settings-label" }, "Actions", -1)),
4993
- h("div", Jn, [
4994
- h("button", {
4864
+ ])) : L("", !0),
4865
+ f("div", Ln, [
4866
+ d[32] || (d[32] = f("label", { class: "szd-settings-label" }, "Actions", -1)),
4867
+ f("div", Vn, [
4868
+ f("button", {
4995
4869
  class: "szd-btn",
4996
4870
  onClick: as,
4997
4871
  disabled: !N.value || c.value
4998
- }, S(c.value ? "Syncing..." : "Sync Now"), 9, Wn),
4999
- h("button", {
4872
+ }, S(c.value ? "Syncing..." : "Sync Now"), 9, Bn),
4873
+ f("button", {
5000
4874
  class: "szd-btn",
5001
4875
  onClick: os
5002
4876
  }, "Clear Events")
5003
4877
  ])
5004
4878
  ]),
5005
- h("div", Zn, [
5006
- d[34] || (d[34] = h("label", { class: "szd-settings-label" }, "Options", -1)),
5007
- h("label", Yn, [
5008
- Qe(h("input", {
4879
+ f("div", Gn, [
4880
+ d[34] || (d[34] = f("label", { class: "szd-settings-label" }, "Options", -1)),
4881
+ f("label", Hn, [
4882
+ Ue(f("input", {
5009
4883
  type: "checkbox",
5010
4884
  "onUpdate:modelValue": d[8] || (d[8] = (g) => i.value = g)
5011
4885
  }, null, 512), [
5012
- [$t, i.value]
4886
+ [Mt, i.value]
5013
4887
  ]),
5014
- d[33] || (d[33] = Ve(" Live updates ", -1))
4888
+ d[33] || (d[33] = Qe(" Live updates ", -1))
5015
4889
  ])
5016
4890
  ]),
5017
- k.value ? (A(), $("div", Xn, [
5018
- d[40] || (d[40] = h("label", { class: "szd-settings-label" }, "Current State", -1)),
5019
- h("div", eo, [
5020
- h("div", to, [
5021
- d[35] || (d[35] = h("span", { class: "szd-kv__key" }, "Model:", -1)),
5022
- h("span", so, S(I.value.modelName || "—"), 1)
4891
+ E.value ? (A(), M("div", qn, [
4892
+ d[40] || (d[40] = f("label", { class: "szd-settings-label" }, "Current State", -1)),
4893
+ f("div", Jn, [
4894
+ f("div", Wn, [
4895
+ d[35] || (d[35] = f("span", { class: "szd-kv__key" }, "Model:", -1)),
4896
+ f("span", Zn, S(F.value.modelName || "—"), 1)
5023
4897
  ]),
5024
- h("div", ro, [
5025
- d[36] || (d[36] = h("span", { class: "szd-kv__key" }, "Source:", -1)),
5026
- h("span", no, S(I.value.source), 1)
4898
+ f("div", Yn, [
4899
+ d[36] || (d[36] = f("span", { class: "szd-kv__key" }, "Source:", -1)),
4900
+ f("span", Xn, S(F.value.source), 1)
5027
4901
  ]),
5028
- h("div", oo, [
5029
- d[37] || (d[37] = h("span", { class: "szd-kv__key" }, "Syncing:", -1)),
5030
- h("span", io, S(I.value.isSyncing ? "Yes" : "No"), 1)
4902
+ f("div", eo, [
4903
+ d[37] || (d[37] = f("span", { class: "szd-kv__key" }, "Syncing:", -1)),
4904
+ f("span", to, S(F.value.isSyncing ? "Yes" : "No"), 1)
5031
4905
  ]),
5032
- h("div", ao, [
5033
- d[38] || (d[38] = h("span", { class: "szd-kv__key" }, "Operations:", -1)),
5034
- h("span", lo, S(I.value.opsCount), 1)
4906
+ f("div", so, [
4907
+ d[38] || (d[38] = f("span", { class: "szd-kv__key" }, "Operations:", -1)),
4908
+ f("span", ro, S(F.value.opsCount), 1)
5035
4909
  ]),
5036
- h("div", co, [
5037
- d[39] || (d[39] = h("span", { class: "szd-kv__key" }, "Last Sync:", -1)),
5038
- h("span", uo, S(I.value.lastSync), 1)
4910
+ f("div", no, [
4911
+ d[39] || (d[39] = f("span", { class: "szd-kv__key" }, "Last Sync:", -1)),
4912
+ f("span", oo, S(F.value.lastSync), 1)
5039
4913
  ])
5040
4914
  ])
5041
- ])) : V("", !0)
4915
+ ])) : L("", !0)
5042
4916
  ])
5043
4917
  ])
5044
- ])) : V("", !0)
4918
+ ])) : L("", !0)
5045
4919
  ]),
5046
4920
  _: 1
5047
4921
  }),
5048
- Tt(Ot, { name: "szd-slide" }, {
5049
- default: Pt(() => [
5050
- f.value ? (A(), $("div", ho, [
5051
- h("div", {
4922
+ St(Ot, { name: "szd-slide" }, {
4923
+ default: $t(() => [
4924
+ h.value ? (A(), M("div", io, [
4925
+ f("div", {
5052
4926
  class: "szd-detail__backdrop",
5053
- onClick: kt
4927
+ onClick: bt
5054
4928
  }),
5055
- h("div", fo, [
5056
- h("div", po, [
5057
- h("h3", mo, S(f.value.type === "entry" ? "Event Detail" : "Snapshot: " + f.value.data.label), 1),
5058
- h("button", {
4929
+ f("div", ao, [
4930
+ f("div", lo, [
4931
+ f("h3", co, S(h.value.type === "entry" ? "Event Detail" : "Snapshot: " + h.value.data.label), 1),
4932
+ f("button", {
5059
4933
  class: "szd-btn",
5060
- onClick: kt
4934
+ onClick: bt
5061
4935
  }, "Close")
5062
4936
  ]),
5063
- h("div", yo, [
5064
- f.value.type === "entry" ? (A(), $(W, { key: 0 }, [
5065
- h("div", go, [
5066
- (A(!0), $(W, null, ce(ns(f.value.data), (g, z) => (A(), $("div", {
5067
- key: z,
4937
+ f("div", uo, [
4938
+ h.value.type === "entry" ? (A(), M(W, { key: 0 }, [
4939
+ f("div", ho, [
4940
+ (A(!0), M(W, null, ce(ns(h.value.data), (g, R) => (A(), M("div", {
4941
+ key: R,
5068
4942
  class: "szd-kv__row"
5069
4943
  }, [
5070
- h("span", _o, S(z) + ":", 1),
5071
- h("span", wo, S(g ?? "—"), 1)
4944
+ f("span", fo, S(R) + ":", 1),
4945
+ f("span", po, S(g ?? "—"), 1)
5072
4946
  ]))), 128))
5073
4947
  ]),
5074
- d[41] || (d[41] = h("h4", { style: { margin: "16px 0 8px" } }, "Raw JSON", -1)),
5075
- h("pre", Co, S(JSON.stringify(f.value.data, null, 2)), 1)
5076
- ], 64)) : (A(), $(W, { key: 1 }, [
5077
- h("div", vo, [
5078
- h("div", Eo, [
5079
- d[42] || (d[42] = h("span", { class: "szd-kv__key" }, "Total Count:", -1)),
5080
- h("span", bo, S(f.value.data.count), 1)
4948
+ d[41] || (d[41] = f("h4", { style: { margin: "16px 0 8px" } }, "Raw JSON", -1)),
4949
+ f("pre", mo, S(JSON.stringify(h.value.data, null, 2)), 1)
4950
+ ], 64)) : (A(), M(W, { key: 1 }, [
4951
+ f("div", yo, [
4952
+ f("div", go, [
4953
+ d[42] || (d[42] = f("span", { class: "szd-kv__key" }, "Total Count:", -1)),
4954
+ f("span", _o, S(h.value.data.count), 1)
5081
4955
  ]),
5082
- h("div", ko, [
5083
- d[43] || (d[43] = h("span", { class: "szd-kv__key" }, "Showing:", -1)),
5084
- h("span", So, [
5085
- Ve(S(Ke.value.length) + " items ", 1),
5086
- Xe.value ? (A(), $("span", To, "(limited to first 100)")) : V("", !0)
4956
+ f("div", wo, [
4957
+ d[43] || (d[43] = f("span", { class: "szd-kv__key" }, "Showing:", -1)),
4958
+ f("span", Co, [
4959
+ Qe(S(Re.value.length) + " items ", 1),
4960
+ Ye.value ? (A(), M("span", vo, "(limited to first 100)")) : L("", !0)
5087
4961
  ])
5088
4962
  ])
5089
4963
  ]),
5090
- d[44] || (d[44] = h("h4", { style: { margin: "0 0 8px" } }, "Data", -1)),
5091
- h("pre", Mo, S(JSON.stringify(Ke.value, null, 2)), 1)
4964
+ d[44] || (d[44] = f("h4", { style: { margin: "0 0 8px" } }, "Data", -1)),
4965
+ f("pre", ko, S(JSON.stringify(Re.value, null, 2)), 1)
5092
4966
  ], 64))
5093
4967
  ])
5094
4968
  ])
5095
- ])) : V("", !0)
4969
+ ])) : L("", !0)
5096
4970
  ]),
5097
4971
  _: 1
5098
4972
  })
5099
4973
  ]));
5100
4974
  }
5101
- }, Go = /* @__PURE__ */ br($o, [["__scopeId", "data-v-6d80920c"]]);
4975
+ }, jo = /* @__PURE__ */ _r(bo, [["__scopeId", "data-v-cf94aafd"]]);
5102
4976
  export {
5103
- Go as default
4977
+ jo as default
5104
4978
  };