@statezero/core 0.2.53 → 0.2.55

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,61 +1,61 @@
1
- import { ref as J, computed as R, onMounted as fs, onBeforeUnmount as ps, watch as it, createElementBlock as $, openBlock as A, createElementVNode as h, createVNode as Mt, toDisplayString as S, createCommentVNode as V, Fragment as W, renderList as ce, normalizeClass as $t, normalizeStyle as at, withDirectives as Qe, createTextVNode as Ve, vModelCheckbox as At, vModelSelect as Ot, Transition as Pt, withCtx as Ft } from "vue";
2
- import { v7 as G } from "uuid";
3
- import { isNil as E, isEmpty as ve, trim as ut, isEqual as qe } from "lodash-es";
4
- import Ae from "mitt";
5
- import It from "handlebars";
6
- import Dt from "superjson";
7
- import ms from "p-queue";
8
- import ys from "axios";
9
- import { z as P } from "zod";
10
- import gs from "pusher-js";
11
- import Yt, { createEqualsOperation as ee } from "sift";
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 Te, 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
+ import ps from "p-queue";
8
+ import ms from "axios";
9
+ import { z as $ } from "zod";
10
+ import ys from "pusher-js";
11
+ import Wt, { createEqualsOperation as ee } from "sift";
12
12
  import { DateTime as _e } from "luxon";
13
- import { parse as _s, format as ws } from "date-fns";
14
- import { Graph as zt } from "graphlib";
13
+ import { parse as gs, format as _s } from "date-fns";
14
+ import { Graph as Dt } from "graphlib";
15
15
  import Le from "object-hash";
16
- import * as Xt from "mathjs";
17
- import Cs from "rfdc";
18
- const se = /* @__PURE__ */ new Map(), ht = /* @__PURE__ */ new Set();
19
- function vs(n) {
20
- return ht.add(n), () => ht.delete(n);
16
+ import * as Zt from "mathjs";
17
+ import ws from "rfdc";
18
+ const se = /* @__PURE__ */ new Map(), ut = /* @__PURE__ */ new Set();
19
+ function Cs(n) {
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
- function Kt(n) {
25
+ function zt(n) {
26
26
  return `{{TempPK_${n}}}`;
27
27
  }
28
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
- for (const o of ht)
31
+ for (const o of ut)
32
32
  try {
33
33
  o(t, e);
34
34
  } catch (i) {
35
35
  console.warn("[tempPk] onResolve callback error:", i);
36
36
  }
37
37
  }
38
- function Es(n) {
39
- if (!Je(String(n))) return n;
38
+ function vs(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 = Dt.stringify(n), r = It.compile(t, { noEscape: !0 })(e);
52
- return Dt.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 bs = Ae(), ks = Ae(), Nt = Ae(), lt = /* @__PURE__ */ new Map();
58
- class Ss {
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 Ss {
236
236
  }
237
237
  }
238
238
  }
239
- class Et {
239
+ class Ct {
240
240
  constructor(e, t = {}, s = null) {
241
- lt.has(e) ? this.store = lt.get(e) : (this.store = new Ss(e, t), lt.set(e, this.store)), 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 Et {
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
- bs.emit(
297
+ ks.emit(
298
298
  `${n.modelClass.configKey}::${n.modelClass.modelName}::render`,
299
299
  e
300
300
  ), n.renderCallbacks.forEach((o) => {
@@ -340,14 +340,14 @@ class Y {
340
340
  return r.size > 0 ? new Y(t, Array.from(r)) : null;
341
341
  }
342
342
  }
343
- class Ts {
343
+ class Ss {
344
344
  modelClass;
345
345
  fetchFn;
346
346
  groundTruthArray;
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 Et("model-cache", {}, this.onHydrated.bind(this)), this._lastRenderedData = /* @__PURE__ */ new Map(), this.renderCallbacks = /* @__PURE__ */ new Set(), this._unsubscribeTempPk = vs((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 Ts {
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 Ts {
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) && !Te(e) && this.setGroundTruth(e);
378
378
  }
379
379
  }
380
380
  setCache(e) {
@@ -382,7 +382,7 @@ class Ts {
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(ut(o)))))
385
+ if (!(typeof o == "string" && qe(o) && (o = Je(r[t]), b(o) || Te(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 Ts {
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(ut(f))) || (c[s] = f, r.push(c));
400
+ let h = c[s];
401
+ typeof h == "string" && qe(h) && (h = Je(c[s]), b(h) || Te(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 Ts {
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 Ts {
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,24 +603,24 @@ class Ts {
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
  }
600
610
  // Render methods
601
611
  render(e = null, t = !0, s = !0) {
602
612
  if (s && e !== null) {
603
- const o = (Array.isArray(e) ? e : [e]).map((a) => Es(a)), i = [];
613
+ const o = (Array.isArray(e) ? e : [e]).map((a) => vs(a)), i = [];
604
614
  for (const a of o)
605
615
  this._lastRenderedData.has(a) || i.push(a);
606
616
  if (i.length === 0)
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 Ts {
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 Ts {
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");
@@ -688,41 +698,43 @@ class Ge {
688
698
  const t = async ({ pks: s, modelClass: r }) => await r.objects.filter({
689
699
  [`${r.primaryKeyField}__in`]: s
690
700
  }).fetch().serialize();
691
- this._stores.set(e, new Ts(e, t, null, null)), this.syncManager.followModel(this, e);
701
+ this._stores.set(e, new Ss(e, t, null, null)), this.syncManager.followModel(this, e);
692
702
  }
693
703
  return this._stores.get(e);
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
@@ -818,7 +830,7 @@ class q {
818
830
  return e.instances && !Array.isArray(e.instances) && (e.instances = [e.instances]), Object.assign(this, e), this.timestamp = Date.now(), ie.emit(C.MUTATED, this), this;
819
831
  }
820
832
  }
821
- class Ms {
833
+ class Ts {
822
834
  constructor() {
823
835
  this._operations = /* @__PURE__ */ new Map(), this._querysetStates = /* @__PURE__ */ new Map();
824
836
  }
@@ -903,9 +915,9 @@ class Ms {
903
915
  return t.length > 0 ? t[t.length - 1] : void 0;
904
916
  }
905
917
  }
906
- const Pe = new Ms(), $s = Ae();
918
+ const Fe = new Ts(), Ms = Oe();
907
919
  function As(n) {
908
- $s.emit("error", n);
920
+ Ms.emit("error", n);
909
921
  }
910
922
  class fe extends Error {
911
923
  /**
@@ -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 xt extends fe {
965
+ class It extends fe {
954
966
  /**
955
967
  * Creates a new DoesNotExist error.
956
968
  *
@@ -961,7 +973,7 @@ class xt extends fe {
961
973
  super("DoesNotExist", "does_not_exist", e, t), this.name = "DoesNotExist";
962
974
  }
963
975
  }
964
- class ct extends fe {
976
+ class lt extends fe {
965
977
  /**
966
978
  * Creates a new PermissionDenied error.
967
979
  *
@@ -983,7 +995,7 @@ class Os extends fe {
983
995
  super("Multiple objects returned", "multiple_objects_returned", e, t), this.name = "MultipleObjectsReturned";
984
996
  }
985
997
  }
986
- class jt extends fe {
998
+ class Nt extends fe {
987
999
  /**
988
1000
  * Creates a new ConflictError.
989
1001
  *
@@ -994,7 +1006,7 @@ class jt extends fe {
994
1006
  super("Conflict", "conflict", e, t), this.name = "ConflictError";
995
1007
  }
996
1008
  }
997
- class Ps extends fe {
1009
+ class $s extends fe {
998
1010
  /**
999
1011
  * Creates a new ASTValidationError.
1000
1012
  *
@@ -1005,7 +1017,7 @@ class Ps 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
  *
@@ -1019,33 +1031,33 @@ class x extends fe {
1019
1031
  function Fs(n) {
1020
1032
  const { status: e, type: t, detail: s } = n;
1021
1033
  if (t === void 0 && s === "Invalid token.")
1022
- return new ct(s, 403);
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 xt(s, e);
1040
+ return new It(s, e);
1029
1041
  case "MultipleObjectsReturned":
1030
1042
  return new Os(s, e);
1031
1043
  case "PermissionDenied":
1032
- return new ct(s, e);
1044
+ return new lt(s, e);
1033
1045
  case "ConflictError":
1034
- return new jt(s, e);
1046
+ return new Nt(s, e);
1035
1047
  case "ASTValidationError":
1036
- return new Ps(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 ct(s, e) : e === 404 ? new xt(s, e) : e === 409 ? new jt(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 Ut = {
1060
+ const xt = {
1049
1061
  CREATE: "create",
1050
1062
  UPDATE: "update",
1051
1063
  DELETE: "delete",
@@ -1053,7 +1065,7 @@ const Ut = {
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
@@ -1063,7 +1075,7 @@ class Is {
1063
1075
  this.configKey = t, this.connectionTimeoutId = null, s.appKey && /^\d+$/.test(s.appKey) && s.appKey.length < 15 && console.warn(
1064
1076
  `%c[Pusher Warning] The provided appKey ("${s.appKey}") looks like a numeric app_id. Pusher requires the alphanumeric key, not the ID. Please verify your configuration for backend: "${this.configKey}".`,
1065
1077
  "color: orange; font-weight: bold; font-size: 14px;"
1066
- ), this.pusherClient = new gs(s.appKey, {
1078
+ ), this.pusherClient = new ys(s.appKey, {
1067
1079
  cluster: s.cluster,
1068
1080
  forceTLS: s.forceTLS ?? !0,
1069
1081
  authEndpoint: s.authEndpoint,
@@ -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(Ut).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(Ut).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();
1215
+ const We = /* @__PURE__ */ new Map();
1204
1216
  function Ds(n, e) {
1205
- const t = Ze.get(n);
1206
- t && t.disconnect(), Ze.set(n, e), e.connect();
1217
+ const t = We.get(n);
1218
+ t && t.disconnect(), We.set(n, e), e.connect();
1207
1219
  }
1208
- function Qt(n = "default") {
1209
- return Ze.get(n);
1220
+ function jt(n = "default") {
1221
+ return We.get(n);
1210
1222
  }
1211
1223
  function zs() {
1212
- return Ze;
1224
+ return We;
1213
1225
  }
1214
- let Vt = {
1226
+ let Ut = {
1215
1227
  backendConfigs: {}
1216
1228
  };
1217
- const Ks = 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
- }), Rs = P.object({
1229
- type: P.enum(["websocket", "pusher", "none"]),
1230
- websocketUrl: P.string().url().optional(),
1231
- pusher: Ks.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(() => Rs.optional())
1262
- }), Ns = 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 Ks = 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
- let ft = null;
1285
- function xs(n) {
1286
- Vt = n;
1287
- const e = Ns.safeParse(Vt);
1296
+ let ht = null;
1297
+ function Ns(n) {
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
- ft = e.data;
1304
+ ht = e.data;
1293
1305
  }
1294
1306
  function he() {
1295
- if (!ft)
1296
- throw new x("Configuration not set. Please call setConfig() with a valid configuration.");
1297
- return ft;
1307
+ if (!ht)
1308
+ throw new U("Configuration not set. Please call setConfig() with a valid configuration.");
1309
+ return ht;
1298
1310
  }
1299
- function js(n, e) {
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 es(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 es(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,70 +1345,70 @@ function es(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
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
- function Us() {
1360
+ function js() {
1349
1361
  try {
1350
1362
  const n = he(), e = {};
1351
1363
  return Object.keys(n.backendConfigs).forEach((t) => {
1352
1364
  try {
1353
- e[t] = es(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
- let pt = null;
1363
- function Qs(n) {
1374
+ let ft = null;
1375
+ function Us(n) {
1364
1376
  if (typeof n != "function")
1365
- throw new x("Provided model getter must be a function.");
1366
- pt = n;
1377
+ throw new U("Provided model getter must be a function.");
1378
+ ft = n;
1367
1379
  }
1368
- function Vs(n, e = "default") {
1380
+ function Qs(n, e = "default") {
1369
1381
  if (n && n.startsWith("http"))
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 ts(n, e) {
1377
- if (!pt)
1378
- throw new x("Model registry not registered. Please call registerModelGetter() with the function from model-registry.js during app initialization.");
1379
- return pt(n, e);
1388
+ function Xt(n, e) {
1389
+ if (!ft)
1390
+ throw new U("Model registry not registered. Please call registerModelGetter() with the function from model-registry.js during app initialization.");
1391
+ return ft(n, e);
1380
1392
  }
1381
- const Ie = {
1382
- setConfig: xs,
1393
+ const De = {
1394
+ setConfig: Ns,
1383
1395
  getConfig: he,
1384
- setBackendConfig: js,
1385
- initializeEventReceiver: es,
1386
- registerModelGetter: Qs,
1387
- getModelClass: ts,
1388
- buildFileUrl: Vs
1389
- }, ss = "__STATEZERO_DEBUG__", X = globalThis[ss] || {
1390
- emitter: Ae(),
1396
+ setBackendConfig: xs,
1397
+ initializeEventReceiver: Yt,
1398
+ registerModelGetter: Us,
1399
+ getModelClass: Xt,
1400
+ buildFileUrl: Qs
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[ss] = X;
1409
+ globalThis[es] = X;
1398
1410
  const Me = X.emitter, ue = X.buffer;
1399
- function Te(n) {
1411
+ function Se(n) {
1400
1412
  if (!X.enabled) return;
1401
1413
  const e = {
1402
1414
  id: X.nextId++,
@@ -1405,28 +1417,28 @@ 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) {
1409
- Te(n);
1420
+ function G(n) {
1421
+ Se(n);
1410
1422
  }
1411
1423
  function Ls(n) {
1412
1424
  return Me.on("record", n), () => Me.off("record", n);
1413
1425
  }
1414
- function Gs(n) {
1426
+ function Vs(n) {
1415
1427
  return Me.on("clear", n), () => Me.off("clear", n);
1416
1428
  }
1417
- function Lt() {
1429
+ function Qt() {
1418
1430
  return ue.slice();
1419
1431
  }
1420
1432
  function Bs() {
1421
1433
  ue.length = 0, Me.emit("clear");
1422
1434
  }
1423
- function Gt(n) {
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 Hs() {
1439
+ function Gs() {
1428
1440
  X.started || (X.started = !0, ie.on(C.CREATED, (n) => {
1429
- Te({
1441
+ Se({
1430
1442
  type: "operation",
1431
1443
  subtype: C.CREATED,
1432
1444
  operationId: n.operationId,
@@ -1438,7 +1450,7 @@ function Hs() {
1438
1450
  instanceCount: n.instances?.length ?? 0
1439
1451
  });
1440
1452
  }), ie.on(C.MUTATED, (n) => {
1441
- Te({
1453
+ Se({
1442
1454
  type: "operation",
1443
1455
  subtype: C.MUTATED,
1444
1456
  operationId: n.operationId,
@@ -1450,7 +1462,7 @@ function Hs() {
1450
1462
  instanceCount: n.instances?.length ?? 0
1451
1463
  });
1452
1464
  }), ie.on(C.CONFIRMED, (n) => {
1453
- Te({
1465
+ Se({
1454
1466
  type: "operation",
1455
1467
  subtype: C.CONFIRMED,
1456
1468
  operationId: n.operationId,
@@ -1462,7 +1474,7 @@ function Hs() {
1462
1474
  instanceCount: n.instances?.length ?? 0
1463
1475
  });
1464
1476
  }), ie.on(C.REJECTED, (n) => {
1465
- Te({
1477
+ Se({
1466
1478
  type: "operation",
1467
1479
  subtype: C.REJECTED,
1468
1480
  operationId: n.operationId,
@@ -1474,14 +1486,14 @@ function Hs() {
1474
1486
  instanceCount: n.instances?.length ?? 0
1475
1487
  });
1476
1488
  }), ie.on(C.CLEAR, () => {
1477
- Te({ type: "operation", subtype: C.CLEAR });
1489
+ Se({ type: "operation", subtype: C.CLEAR });
1478
1490
  }));
1479
1491
  }
1480
- const dt = /* @__PURE__ */ new Map();
1481
- function qs(n = "default") {
1482
- return dt.has(n) || dt.set(n, new ms({ concurrency: 1 })), dt.get(n);
1492
+ const ct = /* @__PURE__ */ new Map();
1493
+ function Hs(n = "default") {
1494
+ return ct.has(n) || ct.set(n, new ps({ concurrency: 1 })), ct.get(n);
1483
1495
  }
1484
- function Js(n, e = 3e4) {
1496
+ function qs(n, e = 3e4) {
1485
1497
  return Promise.race([
1486
1498
  n,
1487
1499
  new Promise(
@@ -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 = Ie.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 = Ie.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,11 +1560,11 @@ 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() : {}, F = 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,
@@ -1560,25 +1572,25 @@ async function L(n, e, t = {}, s, r = null, o = null, i = {}) {
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 ys.post(U, We(w), { headers: N });
1568
- typeof r == "function" && D?.data && await r(D.data);
1569
- const I = D?.data?.data, K = D?.data?.included, me = Array.isArray(I) ? I.length : I != null ? 1 : 0, Ye = K ? Object.keys(K).length : 0, ye = 100, Ke = Array.isArray(I) && I.length > ye ? I.slice(0, ye) : I, Xe = Array.isArray(I) && I.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, ve = !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
+ ve = !0;
1577
1589
  break;
1578
1590
  }
1579
- Re = Ee ? Ne : K;
1591
+ Ke = ve ? Ie : K;
1580
1592
  }
1581
- return B({
1593
+ return G({
1582
1594
  type: "response",
1583
1595
  modelName: c.modelName,
1584
1596
  configKey: c.configKey,
@@ -1586,17 +1598,17 @@ async function L(n, e, t = {}, s, r = null, o = null, i = {}) {
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: ve
1609
+ }), z.data;
1610
+ } catch (z) {
1611
+ if (G({
1600
1612
  type: "error",
1601
1613
  modelName: c.modelName,
1602
1614
  configKey: c.configKey,
@@ -1604,23 +1616,23 @@ async function L(n, e, t = {}, s, r = null, o = null, i = {}) {
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 I = "Connection refused. If you're running tests, start the test server with `python manage.py statezero_testserver`.";
1612
- throw new Error(`${I} (${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 I = Fs(D.response.data);
1616
- throw Error.captureStackTrace && Error.captureStackTrace(I, L), I;
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 = qs(l), ae = b ? pe.add(re) : re();
1621
- return a ? Js(ae, a) : ae;
1632
+ }, pe = Hs(l), ae = k ? pe.add(re) : re();
1633
+ return a ? qs(ae, a) : ae;
1622
1634
  }
1623
- class Bt {
1635
+ class Vt {
1624
1636
  // Supported Django strftime formats and their date-fns equivalents
1625
1637
  static SUPPORTED_FORMATS = {
1626
1638
  "iso-8601": null,
@@ -1674,7 +1686,7 @@ class Bt {
1674
1686
  return c.isValid ? c.toJSDate() : (console.error(`Failed to parse ISO date "${e}":`, c.invalidReason), null);
1675
1687
  }
1676
1688
  const a = this.SUPPORTED_FORMATS[l];
1677
- return _s(e, a, /* @__PURE__ */ new Date());
1689
+ return gs(e, a, /* @__PURE__ */ new Date());
1678
1690
  } catch (a) {
1679
1691
  return console.error(`Failed to parse date "${e}" with format "${l}"`, a), null;
1680
1692
  }
@@ -1706,24 +1718,24 @@ class Bt {
1706
1718
  if (!i || i === "iso-8601")
1707
1719
  return r === "date" ? e.toISOString().slice(0, 10) : e.toISOString();
1708
1720
  const l = this.SUPPORTED_FORMATS[i];
1709
- return ws(e, l);
1721
+ return _s(e, l);
1710
1722
  } catch (l) {
1711
1723
  return console.error(`Failed to format date with format "${i}"`, l), e.toISOString();
1712
1724
  }
1713
1725
  }
1714
1726
  }
1715
- function Ws(n) {
1727
+ function Js(n) {
1716
1728
  if (!n || !n.configKey)
1717
1729
  return "UTC";
1718
- const e = Ie.getConfig();
1730
+ const e = De.getConfig();
1719
1731
  return (e.backendConfigs[n.configKey] || e.backendConfigs.default).BACKEND_TZ || "UTC";
1720
1732
  }
1721
- const Ht = {
1733
+ const Bt = {
1722
1734
  // Store backend snake_case format internally for consistency with API
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 Ht = {
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 ? Ie.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 Ht = {
1755
1767
  mimeType: n.mime_type
1756
1768
  };
1757
1769
  }
1758
- }, qt = {
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 ? Bt.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
- const r = Ws(t);
1774
- return Bt.parseDate(n, s, t.schema, r);
1785
+ const r = Js(t);
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 Ht = {
1779
1791
  return console.warn(`Failed to parse date: ${n}`), n;
1780
1792
  }
1781
1793
  }
1782
- }, ke = {
1794
+ }, be = {
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 Ht = {
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
- }, Zs = {
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 Ht = {
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);
@@ -1820,35 +1832,35 @@ const Ht = {
1820
1832
  }
1821
1833
  return n;
1822
1834
  }
1823
- }, Se = {
1835
+ }, Ee = {
1824
1836
  string: {
1825
- "file-path": Ht,
1826
- "image-path": Ht,
1827
- date: qt,
1828
- "date-time": qt,
1829
- "foreign-key": ke,
1830
- "one-to-one": ke
1837
+ "file-path": Bt,
1838
+ "image-path": Bt,
1839
+ date: Gt,
1840
+ "date-time": Gt,
1841
+ "foreign-key": be,
1842
+ "one-to-one": be
1831
1843
  },
1832
1844
  integer: {
1833
- "foreign-key": ke,
1834
- "one-to-one": ke
1845
+ "foreign-key": be,
1846
+ "one-to-one": be
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": be,
1851
+ "one-to-one": be
1840
1852
  },
1841
1853
  array: {
1842
- "many-to-many": Zs
1854
+ "many-to-many": Ws
1843
1855
  }
1844
1856
  };
1845
- class rs {
1857
+ class ts {
1846
1858
  constructor(e) {
1847
1859
  this.modelClass = e;
1848
1860
  }
1849
1861
  toInternalField(e, t, s = {}) {
1850
1862
  const r = this.modelClass.schema?.properties[e]?.type, o = this.modelClass.schema?.properties[e]?.format;
1851
- return Se[r] && Se[r][o] ? Se[r][o].toInternal(t, {
1863
+ return Ee[r] && Ee[r][o] ? Ee[r][o].toInternal(t, {
1852
1864
  model: this.modelClass,
1853
1865
  field: e,
1854
1866
  ...s
@@ -1862,8 +1874,8 @@ class rs {
1862
1874
  }
1863
1875
  toLiveField(e, t, s = {}) {
1864
1876
  const r = this.modelClass.schema?.properties[e]?.type, o = this.modelClass.schema?.properties[e]?.format;
1865
- if (Se[r] && Se[r][o])
1866
- return Se[r][o].toLive(t, {
1877
+ if (Ee[r] && Ee[r][o])
1878
+ return Ee[r][o].toLive(t, {
1867
1879
  model: this.modelClass,
1868
1880
  field: e,
1869
1881
  ...s
@@ -1897,18 +1909,18 @@ class rs {
1897
1909
  return t;
1898
1910
  }
1899
1911
  }
1900
- function Ys(n) {
1912
+ function Zs(n) {
1901
1913
  if (!n || !n.configKey)
1902
1914
  return "UTC";
1903
- const e = Ie.getConfig();
1915
+ const e = De.getConfig();
1904
1916
  return (e.backendConfigs[n.configKey] || e.backendConfigs.default).BACKEND_TZ || "UTC";
1905
1917
  }
1906
- function Xs(n, e, t) {
1918
+ function Ys(n, e, t) {
1907
1919
  if (!t?.schema || !n) return e;
1908
- const s = new rs(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,74 +1948,74 @@ 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), F = 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, F, s), I = m.length > 0 ? m.join(".") + "." + k : k, K = D.requiredPath || D.field, me = `${I}.${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: I,
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)
1975
+ if (m.push(E), !Q)
1964
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
1981
  const pe = F.primaryKeyField || "id";
1970
1982
  m.push(pe), w = pe;
1971
1983
  }
1972
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 F = c.slice(b + 1);
1991
+ const F = c.slice(k + 1);
1980
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 : Xs(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 er(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 tr(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
  }
2000
- function er(n, e, t, s, r) {
2012
+ function Xs(n, e, t, s, r) {
2001
2013
  return r ? (console.warn(`Date part comparison on relationship fields may not work as expected: ${n}`), { field: n, operator: { $eq: s } }) : {
2002
2014
  field: n,
2003
2015
  operator: { [`$${e}_${t}`]: s }
2004
2016
  };
2005
2017
  }
2006
- function tr(n, e, t, s, r, o, i = !1) {
2018
+ function er(n, e, t, s, r, o, i = !1) {
2007
2019
  function l(a) {
2008
2020
  return a.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2009
2021
  }
@@ -2016,8 +2028,8 @@ function tr(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
  };
@@ -2058,16 +2070,16 @@ function tr(n, e, t, s, r, o, i = !1) {
2058
2070
  operator: { $regex: new RegExp(`${l(t)}$`, "i") }
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
- function sr(n = "UTC", e = null) {
2062
- const t = e ? new rs(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);
2073
+ function tr(n = "UTC", e = null) {
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 sr(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 sr(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 sr(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 sr(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 sr(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 sr(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 sr(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 sr(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 sr(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 sr(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
  }
@@ -2233,20 +2245,20 @@ function sr(n = "UTC", e = null) {
2233
2245
  });
2234
2246
  }), o;
2235
2247
  }
2236
- function rr(n, e) {
2237
- const t = Ys(e);
2238
- return Yt(n, {
2239
- operations: sr(t, e)
2248
+ function sr(n, e) {
2249
+ const t = Zs(e);
2250
+ return Wt(n, {
2251
+ operations: tr(t, e)
2240
2252
  });
2241
2253
  }
2242
- function mt(n, e) {
2254
+ 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 } };
@@ -2267,38 +2279,38 @@ function mt(n, e) {
2267
2279
  }
2268
2280
  return t;
2269
2281
  }
2270
- function nr(n, e) {
2282
+ function rr(n, e) {
2271
2283
  return !n || !n.length ? null : {
2272
- $or: n.map((t) => "operator" in t && "conditions" in t ? { [t.operator === "AND" ? "$and" : "$or"]: t.conditions.map((r) => mt(r, e)) } : mt(t, e))
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;
2279
2291
  let r = {};
2280
- if (t && Object.keys(t).length > 0 && (r = mt(t, e)), s && s.length > 0) {
2281
- const o = nr(s, e);
2292
+ if (t && Object.keys(t).length > 0 && (r = pt(t, e)), s && s.length > 0) {
2293
+ const o = rr(s, e);
2282
2294
  if (o)
2283
2295
  return Object.keys(r).length > 0 ? { $and: [r, o] } : o;
2284
2296
  }
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;
2300
2312
  }
2301
- function or(n, e, t) {
2313
+ function nr(n, e, t) {
2302
2314
  if (!e || !e.searchQuery) return n;
2303
2315
  const s = e.searchFields || (n[0] ? Object.keys(n[0]).filter((i) => typeof n[0][i] == "string") : []);
2304
2316
  if (!s.length) return n;
@@ -2307,7 +2319,7 @@ function or(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 or(n, e, t) {
2321
2333
  };
2322
2334
  }
2323
2335
  });
2324
- return n.filter(Yt({ $or: o }));
2336
+ return n.filter(Wt({ $or: o }));
2325
2337
  }
2326
- function Jt(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) {
@@ -2333,11 +2345,11 @@ function Jt(n, e) {
2333
2345
  }
2334
2346
  return s;
2335
2347
  }
2336
- function ir(n, e) {
2348
+ 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
@@ -2350,12 +2362,12 @@ function ir(n, e) {
2350
2362
  }
2351
2363
  });
2352
2364
  }
2353
- function ar(n, e, t) {
2365
+ function ir(n, e, t) {
2354
2366
  if (!e || !e.length) return [...n];
2355
- const s = ir(e, t);
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 = Jt(r, i), c = Jt(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;
@@ -2368,7 +2380,7 @@ function ar(n, e, t) {
2368
2380
  return 0;
2369
2381
  });
2370
2382
  }
2371
- function yt(n, e, t) {
2383
+ function mt(n, e, t) {
2372
2384
  if (!Array.isArray(n) || n.length === 0)
2373
2385
  return [];
2374
2386
  if (!t)
@@ -2376,19 +2388,19 @@ function yt(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);
2380
- o && Object.keys(o).length && (r = r.filter(rr(o, t)));
2391
+ const o = Ge(e.filter, t);
2392
+ o && Object.keys(o).length && (r = r.filter(sr(o, t)));
2381
2393
  }
2382
- return e.search && e.search.searchQuery && (r = or(r, e.search, t)), Array.isArray(e.orderBy) && e.orderBy.length && (r = ar(r, e.orderBy, t)), r.map((o) => o[s]);
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]);
2383
2395
  }
2384
- function gt(n, e) {
2396
+ function yt(n, e) {
2385
2397
  const t = /* @__PURE__ */ new Set(), s = e.primaryKeyField;
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
  }
@@ -2414,36 +2426,36 @@ function gt(n, e) {
2414
2426
  r(i.replace(/^-/, ""));
2415
2427
  }), Array.from(t);
2416
2428
  }
2417
- function _t(n, e, t) {
2429
+ function gt(n, e, t) {
2418
2430
  if (e == null || t.length === 0)
2419
2431
  return;
2420
2432
  const [s, ...r] = t, o = e[s];
2421
2433
  o !== void 0 && (r.length === 0 ? n[s] = o : Array.isArray(o) ? (s in n || (n[s] = []), o.forEach((i, l) => {
2422
- n[s][l] === void 0 && (n[s][l] = {}), _t(n[s][l], i, r);
2423
- })) : typeof o == "object" && (s in n || (n[s] = {}), _t(n[s], o, r)));
2434
+ n[s][l] === void 0 && (n[s][l] = {}), gt(n[s][l], i, r);
2435
+ })) : typeof o == "object" && (s in n || (n[s] = {}), gt(n[s], o, r)));
2424
2436
  }
2425
- function wt(n, e) {
2437
+ function _t(n, e) {
2426
2438
  const t = {};
2427
2439
  return n.forEach((s) => {
2428
2440
  const r = s.split(".");
2429
- _t(t, e, r);
2441
+ gt(t, e, r);
2430
2442
  }), t;
2431
2443
  }
2432
- function Ct(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)
2436
2448
  throw new Error("ModelClass is required for proper relationship traversal");
2437
2449
  const r = t.primaryKeyField || "id";
2438
- let o = gt(e, t), i = n.map((a) => wt(o, a));
2439
- const l = yt(i, e, t);
2450
+ let o = yt(e, t), i = n.map((a) => _t(o, a));
2451
+ const l = mt(i, e, t);
2440
2452
  if (s) {
2441
2453
  const a = new Map(n.map((c) => [c[r], c]));
2442
2454
  return l.map((c) => a.get(c));
2443
2455
  }
2444
2456
  return l;
2445
2457
  }
2446
- class lr {
2458
+ class ar {
2447
2459
  modelClass;
2448
2460
  fetchFn;
2449
2461
  queryset;
@@ -2452,13 +2464,13 @@ class lr {
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.lastHydrated = 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 Et("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
  });
@@ -2471,12 +2483,13 @@ class lr {
2471
2483
  onHydrated(e) {
2472
2484
  if (this.lastSync !== null || this.groundTruthPks.length > 0 || this.operationsMap.size > 0) return;
2473
2485
  const t = this.qsCache.get(this.cacheKey);
2474
- !E(t) && !ve(t) && (this.groundTruthPks = Array.isArray(t) ? t : [], this._emitRenderEvent());
2486
+ b(t) || (this.groundTruthPks = Array.isArray(t) ? t : [], this.lastHydrated = Date.now(), t.length > 0 && this._emitRenderEvent());
2475
2487
  }
2476
2488
  setCache(e) {
2489
+ if (this.lastSync === null) return;
2477
2490
  let t = [];
2478
2491
  e.forEach((s) => {
2479
- typeof s == "string" && Je(s) && (s = We(s), E(s) || ve(ut(s))) || t.push(s);
2492
+ typeof s == "string" && qe(s) && (s = Je(s), b(s) || Te(dt(s))) || t.push(s);
2480
2493
  }), this.qsCache.set(this.cacheKey, t);
2481
2494
  }
2482
2495
  clearCache() {
@@ -2500,7 +2513,7 @@ class lr {
2500
2513
  } catch (s) {
2501
2514
  console.warn("Error in render callback:", s);
2502
2515
  }
2503
- }), qe(e, this._lastRenderedPks) || (this._lastRenderedPks = e, ks.emit(
2516
+ }), He(e, this._lastRenderedPks) || (this._lastRenderedPks = e, bs.emit(
2504
2517
  `${this.modelClass.configKey}::${this.modelClass.modelName}::queryset::render`,
2505
2518
  { ast: this.queryset.build(), ModelClass: this.modelClass }
2506
2519
  ));
@@ -2555,7 +2568,7 @@ class lr {
2555
2568
  */
2556
2569
  registerWithModelStore() {
2557
2570
  if (this._modelStoreUnregister) return;
2558
- const e = Q.getStore(this.modelClass);
2571
+ const e = j.getStore(this.modelClass);
2559
2572
  this._modelStoreUnregister = e.registerRenderCallback(() => {
2560
2573
  this._emitRenderEvent();
2561
2574
  });
@@ -2567,15 +2580,39 @@ class lr {
2567
2580
  */
2568
2581
  _getValidatedAndFilteredPks(e) {
2569
2582
  const t = Array.from(e).map((o) => this.modelClass.fromPk(o, this.queryset)).filter(
2570
- (o) => Q.getEntity(this.modelClass, o.pk) !== null
2583
+ (o) => j.getEntity(this.modelClass, o.pk) !== null
2571
2584
  ), s = this.queryset.build();
2572
- return Ct(t, s, this.modelClass, !1);
2585
+ return ss(t, s, this.modelClass, !1);
2586
+ }
2587
+ /**
2588
+ * For offset pages that aren't full, expand with creates from the model store
2589
+ * that sort after the first item on the page (direction-adjusted).
2590
+ */
2591
+ _fillOffsetPage(e, t) {
2592
+ const s = j.getStore(this.modelClass);
2593
+ if (!s) return null;
2594
+ const r = this.queryset._orderBy;
2595
+ if (!r || r.length === 0) return null;
2596
+ const o = r[0].replace(/^-/, ""), i = r[0].startsWith("-"), l = this.modelClass.fromPk(e[0], this.queryset);
2597
+ if (!l) return null;
2598
+ const a = l[o];
2599
+ if (a == null) return null;
2600
+ const c = this.pkField, h = new Set(e), p = new Set(e);
2601
+ for (const m of s.operations)
2602
+ 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))
2603
+ for (const y of m.instances) {
2604
+ if (!y || y[c] == null || h.has(y[c])) continue;
2605
+ const _ = y[o];
2606
+ if (_ == null) continue;
2607
+ (i ? _ <= a : _ >= a) && p.add(y[c]);
2608
+ }
2609
+ return p.size === h.size ? null : this._getValidatedAndFilteredPks(Array.from(p));
2573
2610
  }
2574
2611
  render(e = !0, t = !1) {
2575
2612
  if (t) {
2576
- const c = this.qsCache.get(this.cacheKey);
2577
- if (Array.isArray(c))
2578
- return B({
2613
+ const a = this.qsCache.get(this.cacheKey);
2614
+ if (Array.isArray(a))
2615
+ return G({
2579
2616
  type: "render",
2580
2617
  source: "cache",
2581
2618
  semanticKey: this.queryset.semanticKey,
@@ -2584,40 +2621,70 @@ class lr {
2584
2621
  optimistic: e,
2585
2622
  groundTruthCount: this.groundTruthPks.length,
2586
2623
  operationsCount: this.operationsMap.size,
2587
- resultCount: c.length
2588
- }), c;
2624
+ resultCount: a.length
2625
+ }), a;
2589
2626
  }
2590
- const s = this.queryset.build().serializerOptions?.offset, o = this.groundTruthPks.length === 0 && this.lastSync === null && !(s != null && s > 0) ? this.renderFromModelStore() : this.renderFromData(e);
2591
- let i = this._getValidatedAndFilteredPks(o);
2592
- const l = i.length, a = this.queryset.build().serializerOptions?.limit;
2593
- return a && (i = i.slice(0, a)), this.setCache(i), B({
2627
+ const s = this.renderFromData(e);
2628
+ let r = this._getValidatedAndFilteredPks(s);
2629
+ const o = r.length, i = this.queryset.build().serializerOptions?.limit;
2630
+ if ((this.queryset._serializerOptions?.offset ?? 0) > 0 && i && r.length > 0 && r.length < i) {
2631
+ const a = this._fillOffsetPage(r, e);
2632
+ a && (r = a);
2633
+ }
2634
+ return i && (r = r.slice(0, i)), this.setCache(r), G({
2594
2635
  type: "render",
2595
- source: this.groundTruthPks.length === 0 && this.lastSync === null ? "modelStore" : "groundTruth",
2636
+ source: "groundTruth",
2596
2637
  semanticKey: this.queryset.semanticKey,
2597
2638
  modelName: this.modelClass.modelName,
2598
2639
  configKey: this.modelClass.configKey,
2599
2640
  optimistic: e,
2600
2641
  groundTruthCount: this.groundTruthPks.length,
2601
2642
  operationsCount: this.operationsMap.size,
2602
- rawCount: Array.isArray(o) ? o.length : 0,
2603
- filteredCount: l,
2604
- resultCount: i.length,
2605
- limit: a
2606
- }), i;
2643
+ rawCount: Array.isArray(s) ? s.length : 0,
2644
+ filteredCount: o,
2645
+ resultCount: r.length,
2646
+ limit: i
2647
+ }), r;
2607
2648
  }
2608
2649
  renderFromData(e = !0) {
2609
- const t = this.groundTruthSet;
2610
- for (const r of this.operations)
2611
- r.status !== C.REJECTED && (e || r.status === C.CONFIRMED) && this.applyOperation(r, t);
2612
- return Array.from(t);
2650
+ const t = j.getStore(this.modelClass);
2651
+ if (this.isTemp && this.lastSync === null && t) {
2652
+ const i = this.pkField;
2653
+ return t.render().map((l) => l[i]).filter((l) => l != null);
2654
+ }
2655
+ if (!this.isTemp && this.lastSync === null && this.lastHydrated === null && t) {
2656
+ if (!((this.queryset._serializerOptions?.offset ?? 0) > 0)) {
2657
+ const c = this.pkField;
2658
+ return t.render().map((h) => h[c]).filter((h) => h != null);
2659
+ }
2660
+ const { root: l } = x.querysetStoreGraph.findRoot(this.queryset), a = l ? x._stores.get(l) : null;
2661
+ if (a && a !== this && a.lastSync !== null)
2662
+ return a.render();
2663
+ }
2664
+ if ((this.queryset._serializerOptions?.offset ?? 0) > 0)
2665
+ return Array.from(this.groundTruthSet);
2666
+ if (!t || !this._hasRecentOps(t))
2667
+ return Array.from(this.groundTruthSet);
2668
+ const r = this._buildFreshPks(t, e), o = this.groundTruthSet;
2669
+ for (const i of r) o.add(i);
2670
+ return Array.from(o);
2671
+ }
2672
+ /** Are there any inflight or recent confirmed ops in the model store? */
2673
+ _hasRecentOps(e) {
2674
+ const t = e.operations, s = this.lastSync ?? this._createdAt;
2675
+ for (let r = t.length - 1; r >= 0; r--)
2676
+ if (t[r].status !== C.REJECTED)
2677
+ return t[r].status !== C.CONFIRMED ? !0 : t[r].timestamp >= s;
2678
+ return !1;
2613
2679
  }
2614
- /**
2615
- * Render by getting all instances from the model store and filtering locally.
2616
- * Used when a queryset has no ground truth (temp stores, newly created stores, etc.)
2617
- */
2618
- renderFromModelStore() {
2619
- const s = Q.getStore(this.modelClass).groundTruthPks.map((o) => this.modelClass.fromPk(o, this.queryset)), r = this.queryset.build();
2620
- return Ct(s, r, this.modelClass, !1);
2680
+ /** Build set of PKs from ops newer than lastSync. Only used for no-offset querysets. */
2681
+ _buildFreshPks(e, t) {
2682
+ const s = /* @__PURE__ */ new Set(), r = this.pkField, o = this.lastSync ?? this._createdAt;
2683
+ for (const i of e.operations)
2684
+ if (i.status !== C.REJECTED && !(!t && i.status !== C.CONFIRMED) && !(i.status === C.CONFIRMED && i.timestamp < o))
2685
+ for (const l of i.instances)
2686
+ l && l[r] != null && s.add(l[r]);
2687
+ return s;
2621
2688
  }
2622
2689
  applyOperation(e, t) {
2623
2690
  const s = this.pkField;
@@ -2629,26 +2696,7 @@ class lr {
2629
2696
  continue;
2630
2697
  }
2631
2698
  let o = r[s];
2632
- switch (e.type) {
2633
- case M.CREATE:
2634
- case M.BULK_CREATE:
2635
- t.add(o);
2636
- break;
2637
- case M.CHECKPOINT:
2638
- break;
2639
- case M.UPDATE:
2640
- case M.UPDATE_INSTANCE:
2641
- t.add(o);
2642
- break;
2643
- case M.DELETE:
2644
- case M.DELETE_INSTANCE:
2645
- t.delete(o);
2646
- break;
2647
- default:
2648
- console.error(
2649
- `[QuerysetStore ${this.modelClass.modelName}] Unknown operation type: ${e.type}`
2650
- );
2651
- }
2699
+ CREATE_TYPES.has(e.type) && t.add(o);
2652
2700
  }
2653
2701
  return t;
2654
2702
  }
@@ -2662,7 +2710,7 @@ class lr {
2662
2710
  console.warn(`[QuerysetStore ${t}] Already syncing, request ignored.`);
2663
2711
  return;
2664
2712
  }
2665
- this.isSyncing = !0, B({
2713
+ this.isSyncing = !0, G({
2666
2714
  type: "sync",
2667
2715
  phase: "start",
2668
2716
  semanticKey: this.queryset.semanticKey,
@@ -2676,7 +2724,7 @@ class lr {
2676
2724
  modelClass: this.modelClass,
2677
2725
  canonical_id: e
2678
2726
  }), { data: r, included: o } = s;
2679
- E(r) || (this.includedPks.clear(), we(Q, o, this.modelClass, this.queryset), this.setGroundTruth(r)), this.setOperations(this.getInflightOperations()), this.lastSync = Date.now(), B({
2727
+ b(r) || (this.includedPks.clear(), we(j, o, this.modelClass, this.queryset), this.setGroundTruth(r)), this.setOperations(this.getInflightOperations()), this.lastSync = Date.now(), G({
2680
2728
  type: "sync",
2681
2729
  phase: "success",
2682
2730
  semanticKey: this.queryset.semanticKey,
@@ -2687,7 +2735,7 @@ class lr {
2687
2735
  includedCount: o ? Object.keys(o).length : 0
2688
2736
  });
2689
2737
  } catch (s) {
2690
- console.error(`[${t}] Failed to sync ground truth:`, s), B({
2738
+ console.error(`[${t}] Failed to sync ground truth:`, s), G({
2691
2739
  type: "sync",
2692
2740
  phase: "error",
2693
2741
  semanticKey: this.queryset.semanticKey,
@@ -2701,9 +2749,9 @@ class lr {
2701
2749
  }
2702
2750
  }
2703
2751
  }
2704
- class cr {
2752
+ class lr {
2705
2753
  constructor() {
2706
- this.graph = new zt({ directed: !0 }), this.processedQuerysets = /* @__PURE__ */ new Set();
2754
+ this.graph = new Dt({ directed: !0 }), this.processedQuerysets = /* @__PURE__ */ new Set();
2707
2755
  }
2708
2756
  /**
2709
2757
  * Add a queryset and its parent relationship to the graph
@@ -2789,16 +2837,16 @@ class cr {
2789
2837
  return !e && !t ? !0 : !e || !t || e.length !== t.length ? !1 : e.every((s, r) => s === t[r]);
2790
2838
  }
2791
2839
  clear() {
2792
- this.graph = new zt({ directed: !0 }), this.processedQuerysets = /* @__PURE__ */ new Set();
2840
+ this.graph = new Dt({ directed: !0 }), this.processedQuerysets = /* @__PURE__ */ new Set();
2793
2841
  }
2794
2842
  }
2795
- class dr {
2843
+ class cr {
2796
2844
  #e;
2797
2845
  #t;
2798
- #s;
2799
- #r = [];
2846
+ #r;
2847
+ #s = [];
2800
2848
  constructor(e) {
2801
- return this.#e = e, this.#t = e.ModelClass, this.#r.queryset = e, this.#r.ModelClass = e.ModelClass, this.#s = new Proxy(this.#r, {
2849
+ return this.#e = e, this.#t = e.ModelClass, this.#s.queryset = e, this.#s.ModelClass = e.ModelClass, this.#r = new Proxy(this.#s, {
2802
2850
  get: (t, s, r) => s === "touch" ? () => this.touch() : s === "serialize" ? () => this.serialize() : s === Symbol.iterator ? () => this.getCurrentItems()[Symbol.iterator]() : typeof s == "string" && [
2803
2851
  "forEach",
2804
2852
  "map",
@@ -2808,20 +2856,20 @@ class dr {
2808
2856
  "every",
2809
2857
  "find"
2810
2858
  ].includes(s) ? (...o) => this.getCurrentItems()[s](...o) : s === "length" ? this.getCurrentItems().length : typeof s == "string" && !isNaN(parseInt(s)) ? this.getCurrentItems()[s] : t[s]
2811
- }), this.#s;
2859
+ }), this.#r;
2812
2860
  }
2813
2861
  /**
2814
2862
  * Serializes the lqs as a simple array of objects, for freezing e.g in the metric stores
2815
2863
  */
2816
2864
  serialize() {
2817
- return j.getStore(this.#e).render().map((s) => (this.#t.primaryKeyField, this.#t.fromPk(s, this.#e).serialize()));
2865
+ return x.getStore(this.#e).render().map((s) => (this.#t.primaryKeyField, this.#t.fromPk(s, this.#e).serialize()));
2818
2866
  }
2819
2867
  /**
2820
2868
  * Refresh the queryset data from the database
2821
2869
  * Delegates to the underlying store's sync method
2822
2870
  */
2823
2871
  refreshFromDb() {
2824
- return j.getStore(this.#e).sync(!0);
2872
+ return x.getStore(this.#e).sync(!0);
2825
2873
  }
2826
2874
  /**
2827
2875
  * Get the current items from the store
@@ -2829,14 +2877,14 @@ class dr {
2829
2877
  * @returns {Array} The current items in the queryset
2830
2878
  */
2831
2879
  getCurrentItems() {
2832
- return j.getStore(this.#e).render().map((r) => (this.#t.primaryKeyField, this.#t.fromPk(r, this.#e)));
2880
+ return x.getStore(this.#e).render().map((r) => (this.#t.primaryKeyField, this.#t.fromPk(r, this.#e)));
2833
2881
  }
2834
2882
  }
2835
2883
  class Ce {
2836
2884
  constructor() {
2837
2885
  this._stores = /* @__PURE__ */ new Map(), this._tempStores = /* @__PURE__ */ new WeakMap(), this.followingQuerysets = /* @__PURE__ */ new Map(), this.syncManager = () => {
2838
2886
  console.warn("SyncManager not set for QuerysetStoreRegistry");
2839
- }, this.querysetStoreGraph = new cr(), this._groupSyncCache = /* @__PURE__ */ new Map();
2887
+ }, this.querysetStoreGraph = new lr(), this._groupSyncCache = /* @__PURE__ */ new Map();
2840
2888
  }
2841
2889
  clear() {
2842
2890
  this._stores.forEach((e) => {
@@ -2853,7 +2901,7 @@ class Ce {
2853
2901
  this.followingQuerysets.has(e) || this.followingQuerysets.set(e, /* @__PURE__ */ new Set()), this.followingQuerysets.get(e).add(t);
2854
2902
  }
2855
2903
  getStore(e) {
2856
- if (E(e) || E(e.ModelClass))
2904
+ if (b(e) || b(e.ModelClass))
2857
2905
  throw new Error("QuerysetStoreRegistry.getStore requires a valid queryset");
2858
2906
  if (this.querysetStoreGraph.addQueryset(e), this._tempStores.has(e))
2859
2907
  return this._tempStores.get(e);
@@ -2871,7 +2919,7 @@ class Ce {
2871
2919
  ...i,
2872
2920
  type: "list"
2873
2921
  };
2874
- return (await L(
2922
+ return (await V(
2875
2923
  e,
2876
2924
  "list",
2877
2925
  c,
@@ -2884,7 +2932,7 @@ class Ce {
2884
2932
  { namespace: "sync", timeout: 3e4 }
2885
2933
  // Sync ops on separate queue
2886
2934
  )).data;
2887
- }, o = new lr(
2935
+ }, o = new ar(
2888
2936
  e.ModelClass,
2889
2937
  r,
2890
2938
  e,
@@ -2903,12 +2951,12 @@ class Ce {
2903
2951
  * @returns {LiveQueryset} - A live view of the queryset
2904
2952
  */
2905
2953
  getEntity(e, t = !1) {
2906
- if (E(e)) throw new Error("qsStoreRegistry: getEntity cannot be called without a queryset");
2954
+ if (b(e)) throw new Error("qsStoreRegistry: getEntity cannot be called without a queryset");
2907
2955
  const s = e.semanticKey;
2908
2956
  this.addFollowingQueryset(s, e);
2909
2957
  let r;
2910
2958
  this._tempStores.has(e) ? (r = this._tempStores.get(e), r.isTemp = !1, r.registerWithModelStore(), this._stores.set(s, r), this.syncManager.followModel(this, e.ModelClass)) : this._stores.has(s) ? r = this._stores.get(s) : (r = this.getStore(e), r.isTemp = !1, r.registerWithModelStore(), this._stores.set(s, r), this.syncManager.followModel(this, e.ModelClass));
2911
- const o = new dr(e);
2959
+ const o = new cr(e);
2912
2960
  return t && r.sync(), o;
2913
2961
  }
2914
2962
  /**
@@ -2918,7 +2966,7 @@ class Ce {
2918
2966
  * @returns {Array} - The set instances
2919
2967
  */
2920
2968
  setEntity(e, t) {
2921
- if (E(e) || E(t)) return [];
2969
+ if (b(e) || b(t)) return [];
2922
2970
  const s = e.semanticKey;
2923
2971
  this.addFollowingQueryset(s, e);
2924
2972
  let r;
@@ -2945,20 +2993,20 @@ class Ce {
2945
2993
  * @param {Set} dbSyncedKeys - Set of semanticKeys that are dbSynced (followedQuerysets)
2946
2994
  */
2947
2995
  async groupSync(e, t, s, r = null) {
2948
- if (E(e)) return;
2996
+ if (b(e)) return;
2949
2997
  const o = e.semanticKey, i = e.ModelClass, l = /* @__PURE__ */ new Set();
2950
2998
  for (const y of s) {
2951
2999
  const _ = typeof y == "string" ? y : y?.semanticKey;
2952
3000
  _ && this._stores.has(_) && l.add(_);
2953
3001
  }
2954
- const { isRoot: a, root: c } = this.querysetStoreGraph.findRoot(e, l), f = a || c === o;
2955
- if (B({
3002
+ const { isRoot: a, root: c } = this.querysetStoreGraph.findRoot(e, l), h = a || c === o;
3003
+ if (G({
2956
3004
  type: "groupSync",
2957
3005
  phase: "start",
2958
3006
  operationId: t,
2959
3007
  semanticKey: o,
2960
3008
  rootKey: c,
2961
- iAmRoot: f,
3009
+ iAmRoot: h,
2962
3010
  modelName: i?.modelName,
2963
3011
  configKey: i?.configKey
2964
3012
  }), !this._groupSyncCache.has(t)) {
@@ -2973,8 +3021,8 @@ class Ce {
2973
3021
  console.warn(`[groupSync] No store found for queryset: ${o}`);
2974
3022
  return;
2975
3023
  }
2976
- if (f)
2977
- await m.sync(r), p.pks = m.groundTruthPks, p.resolve(), B({
3024
+ if (h)
3025
+ await m.sync(r), p.pks = m.groundTruthPks, p.resolve(), G({
2978
3026
  type: "groupSync",
2979
3027
  phase: "rootSynced",
2980
3028
  operationId: t,
@@ -2987,12 +3035,12 @@ class Ce {
2987
3035
  else {
2988
3036
  let y = 3e4;
2989
3037
  try {
2990
- const b = he();
2991
- b.periodicSyncIntervalSeconds && (y = b.periodicSyncIntervalSeconds * 2e3);
3038
+ const k = he();
3039
+ k.periodicSyncIntervalSeconds && (y = k.periodicSyncIntervalSeconds * 2e3);
2992
3040
  } catch {
2993
3041
  }
2994
- const _ = new Promise((b, k) => {
2995
- setTimeout(() => k(new Error("timeout")), y);
3042
+ const _ = new Promise((k, E) => {
3043
+ setTimeout(() => E(new Error("timeout")), y);
2996
3044
  });
2997
3045
  let w = !1;
2998
3046
  try {
@@ -3001,7 +3049,7 @@ class Ce {
3001
3049
  w = !0;
3002
3050
  }
3003
3051
  if (w || !p.pks) {
3004
- console.warn(`[groupSync] Falling back to direct sync for: ${o.substring(0, 60)}`), await m.sync(r), B({
3052
+ console.warn(`[groupSync] Falling back to direct sync for: ${o.substring(0, 60)}`), await m.sync(r), G({
3005
3053
  type: "groupSync",
3006
3054
  phase: "fallbackSync",
3007
3055
  operationId: t,
@@ -3012,8 +3060,8 @@ class Ce {
3012
3060
  });
3013
3061
  return;
3014
3062
  }
3015
- const v = p.pks.map((b) => i.fromPk(b, e)), O = e.build(), T = Ct(v, O, i, !1);
3016
- m.setGroundTruth(T), m.setOperations(m.getInflightOperations()), m.lastSync = Date.now(), B({
3063
+ const v = p.pks.map((k) => i.fromPk(k, e)), O = e.build(), T = ss(v, O, i, !1);
3064
+ m.setGroundTruth(T), m.setOperations(m.getInflightOperations()), m.lastSync = Date.now(), G({
3017
3065
  type: "groupSync",
3018
3066
  phase: "filteredFromRoot",
3019
3067
  operationId: t,
@@ -3026,248 +3074,63 @@ class Ce {
3026
3074
  }
3027
3075
  }
3028
3076
  }
3029
- const j = new Ce();
3030
- class ze {
3031
- /**
3032
- * Calculate metric based on ground truth and operations
3033
- */
3034
- calculateWithOperations(e, t, s, r) {
3035
- let o = e === null ? this.getInitialValue() : e;
3036
- for (const i of t)
3037
- i.status !== C.REJECTED && i.frozenInstances.forEach((l, a) => {
3038
- l[r.primaryKeyField];
3039
- const c = i.instances[a] || null, f = {
3040
- originalData: l,
3041
- // Pre-operation state
3042
- updatedData: c,
3043
- // Post-operation state (for updates)
3044
- type: i.type,
3045
- status: i.status
3046
- };
3047
- o = this.reduceOperation(o, f, s);
3048
- });
3049
- return o;
3050
- }
3051
- /**
3052
- * Get initial value for the metric type
3053
- * Override in subclasses if needed
3054
- */
3055
- getInitialValue() {
3056
- return 0;
3057
- }
3058
- /**
3059
- * Process a single operation - implement in subclasses
3060
- */
3061
- reduceOperation(e, t, s) {
3062
- throw new Error("reduceOperation must be implemented by subclass");
3063
- }
3064
- /**
3065
- * Safely get a numeric value from an object
3066
- */
3067
- safeGetValue(e, t) {
3068
- if (!e || !t) return 0;
3069
- const s = e[t];
3070
- if (E(s)) return 0;
3071
- const r = parseFloat(s);
3072
- return isNaN(r) ? 0 : r;
3073
- }
3074
- }
3075
- class ur extends ze {
3076
- reduceOperation(e, t, s) {
3077
- if (t.status === C.REJECTED)
3078
- return e;
3079
- const { type: r } = t;
3080
- return r === M.CREATE ? e + 1 : [M.DELETE, M.DELETE_INSTANCE].includes(r) ? Math.max(0, e - 1) : e;
3081
- }
3082
- }
3083
- class hr extends ze {
3084
- reduceOperation(e, t, s) {
3085
- if (t.status === C.REJECTED)
3086
- return e;
3087
- if (!s)
3088
- throw new Error("SumStrategy requires a field parameter");
3089
- const { type: r, originalData: o, updatedData: i } = t;
3090
- switch (r) {
3091
- case M.CREATE:
3092
- return e + this.safeGetValue(o, s);
3093
- case M.CHECKPOINT:
3094
- case M.UPDATE:
3095
- if (i) {
3096
- const l = this.safeGetValue(o, s), a = this.safeGetValue(i, s);
3097
- return e - l + a;
3098
- }
3099
- return e;
3100
- case M.DELETE:
3101
- case M.DELETE_INSTANCE:
3102
- return e - this.safeGetValue(o, s);
3103
- default:
3104
- return e;
3105
- }
3106
- }
3107
- }
3108
- class fr extends ze {
3109
- getInitialValue() {
3110
- return 1 / 0;
3111
- }
3112
- reduceOperation(e, t, s) {
3113
- if (t.status === C.REJECTED)
3114
- return e;
3115
- if (!s)
3116
- throw new Error("MinStrategy requires a field parameter");
3117
- const { type: r, originalData: o, updatedData: i } = t;
3118
- if (r === M.CREATE) {
3119
- const l = this.safeGetValue(o, s);
3120
- return Math.min(e, l);
3121
- } else if ((r === M.UPDATE || r.CHECKPOINT) && i) {
3122
- const l = this.safeGetValue(o, s), a = this.safeGetValue(i, s);
3123
- if (l === e)
3124
- return a <= l, a;
3125
- if (a < e)
3126
- return a;
3127
- }
3128
- return e;
3129
- }
3130
- }
3131
- class pr extends ze {
3132
- getInitialValue() {
3133
- return -1 / 0;
3134
- }
3135
- reduceOperation(e, t, s) {
3136
- if (t.status === C.REJECTED)
3137
- return e;
3138
- if (!s)
3139
- throw new Error("MaxStrategy requires a field parameter");
3140
- const { type: r, originalData: o, updatedData: i } = t;
3141
- if (r === M.CREATE) {
3142
- const l = this.safeGetValue(o, s);
3143
- return Math.max(e, l);
3144
- } else if ((r === M.UPDATE || r === M.CHECKPOINT) && i) {
3145
- const l = this.safeGetValue(o, s), a = this.safeGetValue(i, s);
3146
- if (l === e)
3147
- return a >= l, a;
3148
- if (a > e)
3149
- return a;
3150
- }
3151
- return e;
3152
- }
3153
- }
3154
- class mr {
3155
- // Collection of custom strategy overrides
3156
- static #e = /* @__PURE__ */ new Map();
3157
- // Default strategy map
3158
- static #t = /* @__PURE__ */ new Map([
3159
- ["count", () => new ur()],
3160
- ["sum", () => new hr()],
3161
- ["min", () => new fr()],
3162
- ["max", () => new pr()]
3163
- ]);
3164
- /**
3165
- * Clear all custom strategy overrides
3166
- */
3167
- static clearCustomStrategies() {
3168
- this.#e.clear();
3169
- }
3170
- /**
3171
- * Generate a unique key for the strategy map
3172
- * @private
3173
- * @param {string} metricType - The type of metric (count, sum, min, max)
3174
- * @param {Function} ModelClass - The model class
3175
- * @returns {string} A unique key
3176
- */
3177
- static #s(e, t) {
3178
- return `${e}::${t.configKey}::${t.modelName}`;
3179
- }
3180
- /**
3181
- * Override a strategy for a specific metric type and model class
3182
- * @param {string} metricType - The type of metric (count, sum, min, max)
3183
- * @param {Function|null} ModelClass - The model class or null for a generic override
3184
- * @param {MetricCalculationStrategy} strategy - The strategy to use
3185
- */
3186
- static overrideStrategy(e, t, s) {
3187
- if (!e || !s)
3188
- throw new Error("overrideStrategy requires metricType and strategy");
3189
- if (!(s instanceof ze))
3190
- throw new Error("strategy must be an instance of MetricCalculationStrategy");
3191
- let r;
3192
- t ? r = this.#s(e, t) : r = `${e}::*::*`, this.#e.set(r, s);
3193
- }
3194
- /**
3195
- * Get the appropriate strategy for a model class and metric type
3196
- * @param {string} metricType - The type of metric (count, sum, min, max)
3197
- * @param {Function} ModelClass - The model class
3198
- * @returns {MetricCalculationStrategy} The appropriate strategy
3199
- */
3200
- static getStrategy(e, t) {
3201
- const s = e.toLowerCase(), r = this.#s(s, t);
3202
- if (this.#e.has(r))
3203
- return this.#e.get(r);
3204
- const o = `${s}::*::*`;
3205
- return this.#e.has(o) ? this.#e.get(o) : (this.#t.get(s) || this.#t.get("count"))();
3206
- }
3207
- }
3208
- class yr {
3077
+ const x = new Ce();
3078
+ class dr {
3209
3079
  constructor(e, t, s, r = null, o = null, i) {
3210
- 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 = mr.getStrategy(e, t), this.operations = [], this.confirmedOps = /* @__PURE__ */ new Set(), this.metricCache = new Et(
3080
+ 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(
3211
3081
  "metric-store-cache",
3212
3082
  {},
3213
3083
  this.onHydrated.bind(this)
3214
3084
  ), this._lastCalculatedValue = null;
3215
3085
  }
3216
3086
  reset() {
3217
- this.groundTruthValue = null, this._lastCalculatedValue = null, this.operations = [], this.confirmedOps = /* @__PURE__ */ new Set(), this.isSyncing = !1, this.clearCache();
3087
+ this.groundTruthValue = null, this._lastCalculatedValue = null, this.deltas = /* @__PURE__ */ new Map(), this.isSyncing = !1, this.clearCache();
3218
3088
  }
3219
3089
  get cacheKey() {
3220
3090
  return `${this.modelClass.configKey}::${this.modelClass.modelName}::metric::${this.metricType}::${this.field || "null"}::${this.ast ? Le(this.ast) : "global"}`;
3221
3091
  }
3222
3092
  /**
3223
- * Add an operation to this metric store
3224
- * @param {Operation} operation - The operation to add
3093
+ * Add a delta for an operation
3225
3094
  */
3226
- addOperation(e) {
3227
- if (e.queryset.ModelClass !== this.modelClass)
3228
- return;
3229
- const t = this.operations.findIndex(
3230
- (s) => s.operationId === e.operationId
3231
- );
3232
- t !== -1 ? this.operations[t] = e : this.operations.push(e), E(this.groundTruthValue) || this.render();
3095
+ addDelta(e, t) {
3096
+ this.deltas.set(e, { delta: t, confirmed: !1 }), this.render();
3233
3097
  }
3234
3098
  /**
3235
- * Update an operation in this metric store
3236
- * @param {Operation} operation - The operation to update
3099
+ * Mark a delta as confirmed
3237
3100
  */
3238
- updateOperation(e) {
3239
- if (e.queryset.ModelClass !== this.modelClass)
3240
- return;
3241
- const t = this.operations.findIndex(
3242
- (s) => s.operationId === e.operationId
3243
- );
3244
- t !== -1 ? this.operations[t] = e : this.operations.push(e), E(this.groundTruthValue) || this.render();
3101
+ confirmDelta(e) {
3102
+ const t = this.deltas.get(e);
3103
+ t && (t.confirmed = !0, this.render());
3245
3104
  }
3246
3105
  /**
3247
- * Confirm an operation in this metric store
3248
- * @param {Operation} operation - The operation to confirm
3106
+ * Remove a rejected delta
3249
3107
  */
3250
- confirm(e) {
3251
- if (e.queryset.ModelClass !== this.modelClass)
3252
- return;
3253
- const t = this.operations.findIndex(
3254
- (s) => s.operationId === e.operationId
3255
- );
3256
- t !== -1 && (this.operations[t] = e, this.confirmedOps.add(e.operationId)), this.render();
3108
+ rejectDelta(e) {
3109
+ this.deltas.delete(e) && this.render();
3257
3110
  }
3258
3111
  /**
3259
- * Reject an operation in this metric store
3260
- * @param {Operation} operation - The operation to reject
3112
+ * Update a delta (e.g., when operation is mutated)
3261
3113
  */
3114
+ updateDelta(e, t) {
3115
+ const s = this.deltas.get(e);
3116
+ s ? (s.delta = t, this.render()) : this.addDelta(e, t);
3117
+ }
3118
+ // Legacy API — kept for backward compatibility with existing callers.
3119
+ // processMetricStores in operationEventHandlers still calls these.
3120
+ addOperation(e) {
3121
+ }
3122
+ updateOperation(e) {
3123
+ }
3124
+ confirm(e) {
3125
+ this.confirmDelta(e.operationId);
3126
+ }
3262
3127
  reject(e) {
3263
- e.queryset.ModelClass === this.modelClass && (this.operations = this.operations.filter(
3264
- (t) => t.operationId !== e.operationId
3265
- ), this.confirmedOps.delete(e.operationId), E(this.groundTruthValue) || this.render());
3128
+ this.rejectDelta(e.operationId);
3266
3129
  }
3267
3130
  onHydrated() {
3268
3131
  if (this.groundTruthValue === null) {
3269
3132
  const e = this.metricCache.get(this.cacheKey);
3270
- !E(e) && !ve(e) && this.setGroundTruth(e?.value);
3133
+ !b(e) && !Te(e) && this.setGroundTruth(e?.value);
3271
3134
  }
3272
3135
  }
3273
3136
  setCache() {
@@ -3280,8 +3143,8 @@ class yr {
3280
3143
  this.metricCache.delete(this.cacheKey);
3281
3144
  }
3282
3145
  setGroundTruth(e) {
3283
- const t = !qe(this.groundTruthValue, e);
3284
- this.groundTruthValue = e, this.setCache(), t && Nt.emit("metric::render", {
3146
+ const t = !He(this.groundTruthValue, e);
3147
+ this.groundTruthValue = e, this.setCache(), t && Kt.emit("metric::render", {
3285
3148
  metricType: this.metricType,
3286
3149
  ModelClass: this.modelClass,
3287
3150
  field: this.field,
@@ -3290,19 +3153,15 @@ class yr {
3290
3153
  });
3291
3154
  }
3292
3155
  /**
3293
- * Render the metric with current operations
3294
- * @returns {any} Calculated metric value
3156
+ * Render: groundTruthValue + sum of all deltas
3295
3157
  */
3296
3158
  render() {
3297
- if (E(this.groundTruthValue))
3159
+ if (b(this.groundTruthValue))
3298
3160
  return null;
3299
- const e = this.strategy.calculateWithOperations(
3300
- this.groundTruthValue,
3301
- this.operations,
3302
- this.field,
3303
- this.modelClass
3304
- );
3305
- return qe(this._lastCalculatedValue, e) || (this._lastCalculatedValue = e, Nt.emit("metric::render", {
3161
+ let e = this.groundTruthValue;
3162
+ for (const { delta: t } of this.deltas.values())
3163
+ e += t;
3164
+ return He(this._lastCalculatedValue, e) || (this._lastCalculatedValue = e, Kt.emit("metric::render", {
3306
3165
  metricType: this.metricType,
3307
3166
  ModelClass: this.modelClass,
3308
3167
  field: this.field,
@@ -3328,9 +3187,9 @@ class yr {
3328
3187
  field: this.field,
3329
3188
  ast: this.ast
3330
3189
  });
3331
- return this.confirmedOps.size > 0 && (this.operations = this.operations.filter(
3332
- (t) => !this.confirmedOps.has(t.operationId)
3333
- ), this.confirmedOps.clear()), this.setGroundTruth(e), e;
3190
+ for (const [t, s] of this.deltas)
3191
+ s.confirmed && this.deltas.delete(t);
3192
+ return this.setGroundTruth(e), e;
3334
3193
  } catch (e) {
3335
3194
  return console.error(
3336
3195
  `[MetricStore] Failed to sync ${this.metricType} metric:`,
@@ -3347,13 +3206,13 @@ function te(n, e) {
3347
3206
  function Z(n) {
3348
3207
  return delete n.isOptimistic, delete n.then, delete n.catch, n;
3349
3208
  }
3350
- Cs();
3351
- Xt.create();
3352
- function gr(n, e) {
3209
+ ws();
3210
+ Zt.create();
3211
+ function ur(n, e) {
3353
3212
  if (!n || !n.__f_expr)
3354
3213
  return n;
3355
3214
  try {
3356
- return Xt.evaluate(n.original_expr, e);
3215
+ return Zt.evaluate(n.original_expr, e);
3357
3216
  } catch (t) {
3358
3217
  return console.warn(`Error evaluating F expression: ${t.message}`), null;
3359
3218
  }
@@ -3367,10 +3226,10 @@ class de {
3367
3226
  * @returns {Operation} The created operation
3368
3227
  */
3369
3228
  static createCreateOperation(e, t = {}, s = null) {
3370
- const o = e.ModelClass.primaryKeyField, i = s || `${G()}`, l = Kt(i);
3229
+ const o = e.ModelClass.primaryKeyField, i = s || `${B()}`, l = zt(i);
3371
3230
  return new q({
3372
3231
  operationId: i,
3373
- type: M.CREATE,
3232
+ type: P.CREATE,
3374
3233
  instances: [{ ...t, [o]: l }],
3375
3234
  queryset: e,
3376
3235
  args: { data: t },
@@ -3385,13 +3244,13 @@ class de {
3385
3244
  * @returns {Operation} The created operation
3386
3245
  */
3387
3246
  static createBulkCreateOperation(e, t = [], s = null) {
3388
- const o = e.ModelClass.primaryKeyField, i = s || `${G()}`, l = t.map((a, c) => {
3389
- const f = Kt(`${i}_${c}`);
3390
- return { ...a, [o]: f };
3247
+ const o = e.ModelClass.primaryKeyField, i = s || `${B()}`, l = t.map((a, c) => {
3248
+ const h = zt(`${i}_${c}`);
3249
+ return { ...a, [o]: h };
3391
3250
  });
3392
3251
  return new q({
3393
3252
  operationId: i,
3394
- type: M.BULK_CREATE,
3253
+ type: P.BULK_CREATE,
3395
3254
  instances: l,
3396
3255
  queryset: e,
3397
3256
  args: { data: t },
@@ -3407,12 +3266,12 @@ class de {
3407
3266
  * @returns {Operation} The created operation
3408
3267
  */
3409
3268
  static createUpdateOperation(e, t = {}, s = null, r = null) {
3410
- const o = e.ModelClass, i = o.primaryKeyField, a = j.getStore(e).render(), c = r || `${G()}`, f = a.map((p) => {
3411
- const m = Q.getEntity(o, p), y = { ...m };
3269
+ const o = e.ModelClass, i = o.primaryKeyField, a = x.getStore(e).render(), c = r || `${B()}`, h = a.map((p) => {
3270
+ const m = j.getEntity(o, p), y = { ...m };
3412
3271
  y[i] = p;
3413
3272
  for (const [_, w] of Object.entries(t))
3414
3273
  if (w && typeof w == "object" && w.__f_expr) {
3415
- const v = gr(w, m);
3274
+ const v = ur(w, m);
3416
3275
  v !== null ? y[_] = v : y[_] = m[_];
3417
3276
  } else
3418
3277
  y[_] = w;
@@ -3420,8 +3279,8 @@ class de {
3420
3279
  });
3421
3280
  return new q({
3422
3281
  operationId: c,
3423
- type: M.UPDATE,
3424
- instances: f,
3282
+ type: P.UPDATE,
3283
+ instances: h,
3425
3284
  queryset: e,
3426
3285
  args: { filter: s, data: t },
3427
3286
  localOnly: e._optimisticOnly || !1
@@ -3434,10 +3293,10 @@ class de {
3434
3293
  * @returns {Operation} The created operation
3435
3294
  */
3436
3295
  static createDeleteOperation(e, t = null) {
3437
- const r = e.ModelClass.primaryKeyField, i = j.getStore(e).render(), l = t || `${G()}`, a = i.map((c) => ({ [r]: c }));
3296
+ const r = e.ModelClass.primaryKeyField, i = x.getStore(e).render(), l = t || `${B()}`, a = i.map((c) => ({ [r]: c }));
3438
3297
  return new q({
3439
3298
  operationId: l,
3440
- type: M.DELETE,
3299
+ type: P.DELETE,
3441
3300
  instances: a,
3442
3301
  queryset: e,
3443
3302
  args: {},
@@ -3452,10 +3311,10 @@ class de {
3452
3311
  * @returns {Operation} The created operation
3453
3312
  */
3454
3313
  static createUpdateInstanceOperation(e, t = {}, s = null) {
3455
- const o = e.ModelClass.primaryKeyField, l = j.getStore(e).render(), a = s || `${G()}`, c = l.map((f) => ({ ...t, [o]: f }));
3314
+ const o = e.ModelClass.primaryKeyField, l = x.getStore(e).render(), a = s || `${B()}`, c = l.map((h) => ({ ...t, [o]: h }));
3456
3315
  return new q({
3457
3316
  operationId: a,
3458
- type: M.UPDATE_INSTANCE,
3317
+ type: P.UPDATE_INSTANCE,
3459
3318
  instances: c,
3460
3319
  queryset: e,
3461
3320
  args: { data: t },
@@ -3470,10 +3329,10 @@ class de {
3470
3329
  * @returns {Operation} The created operation
3471
3330
  */
3472
3331
  static createDeleteInstanceOperation(e, t, s = null) {
3473
- const r = s || `${G()}`;
3332
+ const r = s || `${B()}`;
3474
3333
  return new q({
3475
3334
  operationId: r,
3476
- type: M.DELETE_INSTANCE,
3335
+ type: P.DELETE_INSTANCE,
3477
3336
  instances: [t],
3478
3337
  queryset: e,
3479
3338
  args: t,
@@ -3489,15 +3348,15 @@ class de {
3489
3348
  * @returns {Operation} The created operation
3490
3349
  */
3491
3350
  static createGetOrCreateOperation(e, t = {}, s = {}, r = null) {
3492
- 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 = gt(m, o), _ = c.map(
3493
- (k) => wt(y, o.fromPk(k[i], e))
3494
- ), w = yt(_, m, o), v = c.filter(
3495
- (k) => w.includes(k[i])
3496
- ), O = v.length === 0, T = O ? M.CREATE : M.UPDATE, b = O ? { ...t, ...s, [i]: l } : v[0];
3351
+ 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(
3352
+ (E) => _t(y, o.fromPk(E[i], e))
3353
+ ), w = mt(_, m, o), v = c.filter(
3354
+ (E) => w.includes(E[i])
3355
+ ), O = v.length === 0, T = O ? P.CREATE : P.UPDATE, k = O ? { ...t, ...s, [i]: l } : v[0];
3497
3356
  return new q({
3498
3357
  operationId: l,
3499
3358
  type: T,
3500
- instances: [b],
3359
+ instances: [k],
3501
3360
  queryset: e,
3502
3361
  args: { lookup: t, defaults: s },
3503
3362
  localOnly: e._optimisticOnly || !1
@@ -3512,22 +3371,22 @@ class de {
3512
3371
  * @returns {Operation} The created operation
3513
3372
  */
3514
3373
  static createUpdateOrCreateOperation(e, t = {}, s = {}, r = null) {
3515
- 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 = gt(m, o), _ = c.map(
3516
- (k) => wt(y, o.fromPk(k[i], e))
3517
- ), w = yt(_, m, o), v = c.filter(
3518
- (k) => w.includes(k[i])
3519
- ), O = v.length === 0, T = O ? M.CREATE : M.UPDATE, b = O ? { ...t, ...s, [i]: l } : { ...v[0], ...s };
3374
+ 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(
3375
+ (E) => _t(y, o.fromPk(E[i], e))
3376
+ ), w = mt(_, m, o), v = c.filter(
3377
+ (E) => w.includes(E[i])
3378
+ ), O = v.length === 0, T = O ? P.CREATE : P.UPDATE, k = O ? { ...t, ...s, [i]: l } : { ...v[0], ...s };
3520
3379
  return new q({
3521
3380
  operationId: l,
3522
3381
  type: T,
3523
- instances: [b],
3382
+ instances: [k],
3524
3383
  queryset: e,
3525
3384
  args: { lookup: t, defaults: s },
3526
3385
  localOnly: e._optimisticOnly || !1
3527
3386
  });
3528
3387
  }
3529
3388
  }
3530
- class Wt extends Array {
3389
+ class qt extends Array {
3531
3390
  /**
3532
3391
  * Creates a new ResultTuple.
3533
3392
  *
@@ -3538,7 +3397,7 @@ class Wt extends Array {
3538
3397
  super(2), this[0] = e, this[1] = t, this.instance = e, this.created = t;
3539
3398
  }
3540
3399
  }
3541
- class _r {
3400
+ class hr {
3542
3401
  /**
3543
3402
  * Executes a get operation (get, first, last) with the QuerySet.
3544
3403
  *
@@ -3548,12 +3407,12 @@ class _r {
3548
3407
  * @returns {Promise<Object>} The model instance.
3549
3408
  */
3550
3409
  static executeGet(e, t, s = {}) {
3551
- 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(
3552
- (f) => {
3553
- const { data: p, included: m, model_name: y } = f.data;
3554
- if (E(p) || Array.isArray(p) && p.length === 0)
3410
+ 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(
3411
+ (h) => {
3412
+ const { data: p, included: m, model_name: y } = h.data;
3413
+ if (b(p) || Array.isArray(p) && p.length === 0)
3555
3414
  return null;
3556
- we(Q, m, r, e);
3415
+ we(j, m, r, e);
3557
3416
  const _ = Array.isArray(p) ? p[0] : p;
3558
3417
  return a.pk = _, Z(a), a;
3559
3418
  }
@@ -3576,11 +3435,11 @@ class _r {
3576
3435
  * synchronized with the in‑memory store.
3577
3436
  */
3578
3437
  static executeList(e, t = "list", s = {}) {
3579
- const r = j.getEntity(e), o = L(e, t, s).then((i) => {
3438
+ const r = x.getEntity(e), o = V(e, t, s).then((i) => {
3580
3439
  const { data: l, included: a } = i.data;
3581
- we(Q, a, e.ModelClass, e);
3440
+ we(j, a, e.ModelClass, e);
3582
3441
  const c = Array.isArray(l) ? l : [];
3583
- return j.setEntity(e, c), Z(r), r;
3442
+ return x.setEntity(e, c), Z(r), r;
3584
3443
  });
3585
3444
  return te(r, o);
3586
3445
  }
@@ -3597,28 +3456,28 @@ class _r {
3597
3456
  lookup: s.lookup || {},
3598
3457
  defaults: s.defaults || {}
3599
3458
  }, 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);
3600
- let f = new Wt(c, a);
3459
+ let h = new qt(c, a);
3601
3460
  if (l.localOnly)
3602
- return l.updateStatus(C.CONFIRMED, l.instances), f;
3603
- const p = L(
3461
+ return l.updateStatus(C.CONFIRMED, l.instances), h;
3462
+ const p = V(
3604
3463
  e,
3605
3464
  t,
3606
3465
  i,
3607
3466
  l.operationId
3608
3467
  ).then((m) => {
3609
3468
  const { data: y, included: _, model_name: w } = m.data, v = m.metadata.created;
3610
- we(Q, _, r, e);
3469
+ we(j, _, r, e);
3611
3470
  const O = Array.isArray(y) ? y[0] : y;
3612
3471
  a && (c.pk = O);
3613
- const b = (_[w] || {})[O];
3614
- return b && l.mutate({
3615
- instances: [b],
3472
+ const k = (_[w] || {})[O];
3473
+ return k && l.mutate({
3474
+ instances: [k],
3616
3475
  status: C.CONFIRMED
3617
- }), f = new Wt(c, v), Z(f), f;
3476
+ }), h = new qt(c, v), Z(h), h;
3618
3477
  }).catch((m) => {
3619
3478
  throw l.updateStatus(C.REJECTED), m;
3620
3479
  });
3621
- return te(f, p);
3480
+ return te(h, p);
3622
3481
  }
3623
3482
  /**
3624
3483
  * Executes an aggregation operation with the QuerySet.
@@ -3634,15 +3493,15 @@ class _r {
3634
3493
  throw new Error(
3635
3494
  `Field parameter is required for ${t} operation`
3636
3495
  );
3637
- const i = Fe.getEntity(t, e, o), l = {};
3496
+ const i = Pe.getEntity(t, e, o), l = {};
3638
3497
  t !== "exists" && (l.field = o);
3639
- const a = L(
3498
+ const a = V(
3640
3499
  e,
3641
3500
  t,
3642
3501
  l
3643
3502
  ).then((c) => {
3644
- const f = c.data, p = j.getEntity(e);
3645
- return Fe.setEntity(t, e, o, f, p), Z(i), f;
3503
+ const h = c.data, p = x.getEntity(e);
3504
+ return Pe.setEntity(t, e, o, h, p), Z(i), h;
3646
3505
  });
3647
3506
  return te(i, a);
3648
3507
  }
@@ -3655,7 +3514,7 @@ class _r {
3655
3514
  * @returns {Promise<boolean>} Whether records exist.
3656
3515
  */
3657
3516
  static async executeExists(e, t = "exists", s = {}) {
3658
- return (await L(
3517
+ return (await V(
3659
3518
  e,
3660
3519
  t,
3661
3520
  {}
@@ -3680,7 +3539,7 @@ class _r {
3680
3539
  let c = [a, { [o]: a }, l.instances];
3681
3540
  if (l.localOnly)
3682
3541
  return l.updateStatus(C.CONFIRMED, l.instances), c;
3683
- const f = L(
3542
+ const h = V(
3684
3543
  e,
3685
3544
  t,
3686
3545
  i,
@@ -3693,7 +3552,7 @@ class _r {
3693
3552
  }).catch((p) => {
3694
3553
  throw l.updateStatus(C.REJECTED), p;
3695
3554
  });
3696
- return te(c, f);
3555
+ return te(c, h);
3697
3556
  }
3698
3557
  /**
3699
3558
  * Executes a delete operation with the QuerySet.
@@ -3708,16 +3567,16 @@ class _r {
3708
3567
  let a = [l, { [o]: l }, i.instances];
3709
3568
  if (i.localOnly)
3710
3569
  return i.updateStatus(C.CONFIRMED, i.instances), a;
3711
- const c = L(
3570
+ const c = V(
3712
3571
  e,
3713
3572
  t,
3714
3573
  {},
3715
3574
  i.operationId
3716
- ).then((f) => {
3717
- const p = f.metadata.deleted_count, m = f.metadata.rows_deleted;
3575
+ ).then((h) => {
3576
+ const p = h.metadata.deleted_count, m = h.metadata.rows_deleted;
3718
3577
  return i.updateStatus(C.CONFIRMED, m), a = [p, { [o]: p }, m || []], Z(a), a;
3719
- }).catch((f) => {
3720
- throw i.updateStatus(C.REJECTED), f;
3578
+ }).catch((h) => {
3579
+ throw i.updateStatus(C.REJECTED), h;
3721
3580
  });
3722
3581
  return te(a, c);
3723
3582
  }
@@ -3730,14 +3589,14 @@ class _r {
3730
3589
  * @returns {LiveThenable<Object>} The live Model instance which resolves to the created model.
3731
3590
  */
3732
3591
  static executeCreate(e, t = "create", s = {}) {
3733
- const r = e.ModelClass, o = `${G()}`, i = {
3592
+ const r = e.ModelClass, o = `${B()}`, i = {
3734
3593
  data: s.data || {}
3735
3594
  };
3736
- E(s.data) && (console.warn("executeCreate was called with null data"), s.data = {});
3595
+ b(s.data) && (console.warn("executeCreate was called with null data"), s.data = {});
3737
3596
  const l = de.createCreateOperation(e, i.data, o), a = l.instances[0][r.primaryKeyField], c = r.fromPk(a, e);
3738
3597
  if (l.localOnly)
3739
3598
  return l.updateStatus(C.CONFIRMED, l.instances), c;
3740
- const f = L(
3599
+ const h = V(
3741
3600
  e,
3742
3601
  t,
3743
3602
  i,
@@ -3748,7 +3607,7 @@ class _r {
3748
3607
  }
3749
3608
  ).then((p) => {
3750
3609
  const { data: m, included: y, model_name: _ } = p.data;
3751
- we(Q, y, r, e);
3610
+ we(j, y, r, e);
3752
3611
  const w = Array.isArray(m) ? m[0] : m;
3753
3612
  c.pk = w;
3754
3613
  const O = (y[_] || {})[w];
@@ -3763,7 +3622,7 @@ class _r {
3763
3622
  }).catch((p) => {
3764
3623
  throw l.updateStatus(C.REJECTED), p;
3765
3624
  });
3766
- return te(c, f);
3625
+ return te(c, h);
3767
3626
  }
3768
3627
  /**
3769
3628
  * Executes a bulk_create operation with the QuerySet.
@@ -3774,10 +3633,10 @@ class _r {
3774
3633
  * @returns {LiveThenable<Array>} Array of live Model instances.
3775
3634
  */
3776
3635
  static executeBulkCreate(e, t = "bulk_create", s = {}) {
3777
- const r = e.ModelClass, o = `${G()}`, i = r.primaryKeyField, l = {
3636
+ const r = e.ModelClass, o = `${B()}`, i = r.primaryKeyField, l = {
3778
3637
  data: s.data || []
3779
3638
  };
3780
- if (E(s.data) || !Array.isArray(s.data))
3639
+ if (b(s.data) || !Array.isArray(s.data))
3781
3640
  return console.warn("executeBulkCreate was called with invalid data"), Promise.resolve([]);
3782
3641
  const a = de.createBulkCreateOperation(e, l.data, o), c = a.instances.map((p) => {
3783
3642
  const m = p[i];
@@ -3785,7 +3644,7 @@ class _r {
3785
3644
  });
3786
3645
  if (a.localOnly)
3787
3646
  return a.updateStatus(C.CONFIRMED, a.instances), c;
3788
- const f = L(
3647
+ const h = V(
3789
3648
  e,
3790
3649
  t,
3791
3650
  l,
@@ -3799,10 +3658,10 @@ class _r {
3799
3658
  }
3800
3659
  ).then((p) => {
3801
3660
  const { data: m, included: y, model_name: _ } = p.data;
3802
- we(Q, y, r, e);
3661
+ we(j, y, r, e);
3803
3662
  const w = Array.isArray(m) ? m : [];
3804
- w.forEach((T, b) => {
3805
- c[b] && (c[b].pk = T);
3663
+ w.forEach((T, k) => {
3664
+ c[k] && (c[k].pk = T);
3806
3665
  });
3807
3666
  const v = y[_] || {}, O = w.map((T) => v[T]).filter(Boolean);
3808
3667
  return a.mutate({
@@ -3812,7 +3671,7 @@ class _r {
3812
3671
  }).catch((p) => {
3813
3672
  throw a.updateStatus(C.REJECTED), p;
3814
3673
  });
3815
- return te(c, f);
3674
+ return te(c, h);
3816
3675
  }
3817
3676
  /**
3818
3677
  * Executes an update_instance operation with the QuerySet.
@@ -3825,29 +3684,29 @@ class _r {
3825
3684
  static executeUpdateInstance(e, t = "update_instance", s = {}) {
3826
3685
  const r = e.ModelClass;
3827
3686
  r.primaryKeyField;
3828
- 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);
3687
+ 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);
3829
3688
  if (a.localOnly)
3830
- return a.updateStatus(C.CONFIRMED, a.instances), f;
3831
- const p = L(
3689
+ return a.updateStatus(C.CONFIRMED, a.instances), h;
3690
+ const p = V(
3832
3691
  e,
3833
3692
  t,
3834
3693
  { data: l },
3835
3694
  a.operationId
3836
3695
  ).then((m) => {
3837
3696
  const { data: y, included: _, model_name: w } = m.data;
3838
- we(Q, _, r, e);
3697
+ we(j, _, r, e);
3839
3698
  const v = Array.isArray(y) ? y[0] : y;
3840
- f.pk = v;
3699
+ h.pk = v;
3841
3700
  const T = (_[w] || {})[v];
3842
3701
  if (!T)
3843
3702
  throw new Error(
3844
3703
  `Entity data not found for ${w} with pk ${v}`
3845
3704
  );
3846
- return a.updateStatus(C.CONFIRMED, [T]), Z(f), f;
3705
+ return a.updateStatus(C.CONFIRMED, [T]), Z(h), h;
3847
3706
  }).catch((m) => {
3848
3707
  throw a.updateStatus(C.REJECTED), m;
3849
3708
  });
3850
- return te(f, p);
3709
+ return te(h, p);
3851
3710
  }
3852
3711
  /**
3853
3712
  * Executes a delete_instance operation with the QuerySet.
@@ -3865,18 +3724,18 @@ class _r {
3865
3724
  let a = [1, { [o]: 1 }, l.instances];
3866
3725
  if (l.localOnly)
3867
3726
  return l.updateStatus(C.CONFIRMED, l.instances), a;
3868
- const c = L(
3727
+ const c = V(
3869
3728
  e,
3870
3729
  t,
3871
3730
  s,
3872
3731
  l.operationId
3873
- ).then((f) => {
3732
+ ).then((h) => {
3874
3733
  let p = 1;
3875
- typeof f.data == "number" && (p = f.data);
3876
- const m = f.metadata?.rows_deleted || [s];
3734
+ typeof h.data == "number" && (p = h.data);
3735
+ const m = h.metadata?.rows_deleted || [s];
3877
3736
  return l.updateStatus(C.CONFIRMED, [s]), a = [p, { [o]: p }, m], Z(a), a;
3878
- }).catch((f) => {
3879
- throw l.updateStatus(C.REJECTED), f;
3737
+ }).catch((h) => {
3738
+ throw l.updateStatus(C.REJECTED), h;
3880
3739
  });
3881
3740
  return te(a, c);
3882
3741
  }
@@ -3933,22 +3792,22 @@ class _r {
3933
3792
  * @returns {Promise<any>} The raw API response data.
3934
3793
  */
3935
3794
  static executeRemote(e, t = "list", s = {}) {
3936
- return L(e, t, s);
3795
+ return V(e, t, s);
3937
3796
  }
3938
3797
  }
3939
- class wr {
3798
+ class fr {
3940
3799
  constructor(e, t, s = null) {
3941
3800
  this.queryset = e, this.metricType = t, this.field = s;
3942
3801
  }
3943
3802
  get lqs() {
3944
- return j.getEntity(this.queryset);
3803
+ return x.getEntity(this.queryset);
3945
3804
  }
3946
3805
  /**
3947
3806
  * Refresh the metric data from the database
3948
3807
  * Delegates to the underlying store's sync method
3949
3808
  */
3950
3809
  refreshFromDb() {
3951
- return Fe.getStore(
3810
+ return Pe.getStore(
3952
3811
  this.metricType,
3953
3812
  this.queryset,
3954
3813
  this.field
@@ -3959,7 +3818,7 @@ class wr {
3959
3818
  * Called implicitly by JS when coercing to a primitive (arithmetic, template literals, etc.)
3960
3819
  */
3961
3820
  valueOf() {
3962
- const e = Fe.getStore(
3821
+ const e = Pe.getStore(
3963
3822
  this.metricType,
3964
3823
  this.queryset,
3965
3824
  this.field
@@ -3975,14 +3834,22 @@ class wr {
3975
3834
  return this.valueOf();
3976
3835
  }
3977
3836
  }
3978
- class vt {
3837
+ class wt {
3979
3838
  constructor() {
3980
- this._stores = /* @__PURE__ */ new Map(), this.syncManager = null;
3839
+ this._stores = /* @__PURE__ */ new Map(), this.followedMetrics = /* @__PURE__ */ new Set(), this.syncManager = null;
3981
3840
  }
3982
3841
  clear() {
3983
3842
  for (const e of this._stores.values())
3984
3843
  this.syncManager.unfollowModel(this, e.store.modelClass);
3985
- this._stores = /* @__PURE__ */ new Map();
3844
+ this._stores = /* @__PURE__ */ new Map(), this.followedMetrics = /* @__PURE__ */ new Set();
3845
+ }
3846
+ followMetric(e, t, s = null) {
3847
+ const r = this._makeKey(e, t, s);
3848
+ this.followedMetrics.add(r);
3849
+ }
3850
+ unfollowMetric(e, t, s = null) {
3851
+ const r = this._makeKey(e, t, s);
3852
+ this.followedMetrics.delete(r);
3986
3853
  }
3987
3854
  setSyncManager(e) {
3988
3855
  this.syncManager = e;
@@ -3993,7 +3860,7 @@ class vt {
3993
3860
  * @returns {Array} Array of metric stores
3994
3861
  */
3995
3862
  getAllStoresForQueryset(e) {
3996
- if (E(e) || E(e.ModelClass))
3863
+ if (b(e) || b(e.ModelClass))
3997
3864
  return [];
3998
3865
  const t = [], s = e.ModelClass;
3999
3866
  for (const [r, o] of this._stores.entries()) {
@@ -4010,14 +3877,14 @@ class vt {
4010
3877
  * Get a metric store for a specific queryset and metric type
4011
3878
  */
4012
3879
  getStore(e, t, s = null) {
4013
- if (E(e) || E(t) || E(t.ModelClass))
3880
+ if (b(e) || b(t) || b(t.ModelClass))
4014
3881
  return null;
4015
3882
  const r = t.ModelClass, o = t.build(), i = this._makeKey(e, t, s);
4016
3883
  if (!this._stores.has(i)) {
4017
- const l = async ({ metricType: c, modelClass: f, field: p, ast: m }) => {
3884
+ const l = async ({ metricType: c, modelClass: h, field: p, ast: m }) => {
4018
3885
  const y = t.clone();
4019
- return await _r.executeAgg(y, c, { field: p });
4020
- }, a = new yr(
3886
+ return await hr.executeAgg(y, c, { field: p });
3887
+ }, a = new dr(
4021
3888
  e,
4022
3889
  r,
4023
3890
  t,
@@ -4037,20 +3904,20 @@ class vt {
4037
3904
  * Get a metric value for a specific queryset
4038
3905
  */
4039
3906
  getEntity(e, t, s = null) {
4040
- if (E(e) || E(t) || E(t.ModelClass))
3907
+ if (b(e) || b(t) || b(t.ModelClass))
4041
3908
  return null;
4042
3909
  this.getStore(e, t, s);
4043
- const r = new wr(t, e, s);
3910
+ const r = new fr(t, e, s);
4044
3911
  return r;
4045
3912
  }
4046
3913
  /**
4047
3914
  * Set metric ground truth value
4048
3915
  */
4049
3916
  setEntity(e, t, s, r) {
4050
- if (E(e) || E(t) || E(t.ModelClass))
3917
+ if (b(e) || b(t) || b(t.ModelClass))
4051
3918
  return null;
4052
3919
  const o = this.getStore(e, t, s);
4053
- return o ? ((!E(o.groundTruthValue) || !ve(o.operations)) && o.reset(), o.setGroundTruth(r), r) : null;
3920
+ return o ? ((!b(o.groundTruthValue) || !Te(o.operations)) && o.reset(), o.setGroundTruth(r), r) : null;
4054
3921
  }
4055
3922
  /**
4056
3923
  * Sync a specific metric with the server
@@ -4067,8 +3934,8 @@ class vt {
4067
3934
  return this._stores.has(e) ? this._stores.get(e).queryset : null;
4068
3935
  }
4069
3936
  }
4070
- const Fe = new vt();
4071
- class Cr {
3937
+ const Pe = new wt();
3938
+ class pr {
4072
3939
  constructor(e) {
4073
3940
  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 ? {
4074
3941
  ...t,
@@ -4076,21 +3943,21 @@ class Cr {
4076
3943
  } : t) || e.instances, this._cachedInstances = null;
4077
3944
  }
4078
3945
  get modelClass() {
4079
- return ts(this.model, this.configKey);
3946
+ return Xt(this.model, this.configKey);
4080
3947
  }
4081
3948
  async getFullInstances() {
4082
3949
  if (this.event === "delete")
4083
3950
  throw new Error(
4084
3951
  "Cannot fetch full instances for delete operation bozo..."
4085
3952
  );
4086
- return E(this._cachedInstances) && (this._cachedInstances = await this.modelClass.objects.filter({
3953
+ return b(this._cachedInstances) && (this._cachedInstances = await this.modelClass.objects.filter({
4087
3954
  [`${this.modelClass.primaryKeyField}__in`]: this.instances.map(
4088
3955
  (e) => e[this.modelClass.primaryKeyField]
4089
3956
  )
4090
3957
  }).fetch()), this._cachedInstances;
4091
3958
  }
4092
3959
  }
4093
- class vr {
3960
+ class mr {
4094
3961
  constructor() {
4095
3962
  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;
4096
3963
  }
@@ -4113,7 +3980,7 @@ class vr {
4113
3980
  * Initialize event handlers for all event receivers
4114
3981
  */
4115
3982
  initialize() {
4116
- Us(), zs().forEach((t, s) => {
3983
+ js(), zs().forEach((t, s) => {
4117
3984
  t && t.addModelEventHandler(this.handleEvent.bind(this));
4118
3985
  }), this.startPeriodicSync();
4119
3986
  }
@@ -4133,7 +4000,7 @@ class vr {
4133
4000
  async syncStaleQuerysets() {
4134
4001
  const e = this.registries.get(Ce);
4135
4002
  if (!e) return;
4136
- const t = `periodic-sync-${G()}`, s = new Set(
4003
+ const t = `periodic-sync-${B()}`, s = new Set(
4137
4004
  [...this.followedQuerysets].map((o) => o.semanticKey).filter((o) => e._stores.has(o))
4138
4005
  ), r = [];
4139
4006
  for (const [o, i] of e._stores.entries()) {
@@ -4147,7 +4014,7 @@ class vr {
4147
4014
  ), this.pruneUnreferencedModels();
4148
4015
  }
4149
4016
  pruneUnreferencedModels() {
4150
- const e = this.registries.get(Ge), t = this.registries.get(Ce);
4017
+ const e = this.registries.get(Ve), t = this.registries.get(Ce);
4151
4018
  if (!(!e || !t))
4152
4019
  for (const [s, r] of e._stores.entries())
4153
4020
  r.pruneUnreferencedInstances(t);
@@ -4165,7 +4032,7 @@ class vr {
4165
4032
  const r = [...this.followedModels.values()].some(
4166
4033
  (o) => o.has(t)
4167
4034
  );
4168
- s.add(t), r || Qt(t.configKey)?.subscribe(
4035
+ s.add(t), r || jt(t.configKey)?.subscribe(
4169
4036
  t.modelName,
4170
4037
  this.handleEvent
4171
4038
  );
@@ -4175,7 +4042,7 @@ class vr {
4175
4042
  if (!s) return;
4176
4043
  s.delete(t), [...this.followedModels.values()].some(
4177
4044
  (o) => o.has(t)
4178
- ) || Qt(t.configKey)?.unsubscribe(
4045
+ ) || jt(t.configKey)?.unsubscribe(
4179
4046
  t.modelName,
4180
4047
  this.handleEvent
4181
4048
  );
@@ -4192,7 +4059,7 @@ class vr {
4192
4059
  * Checks the `verify` flag on membership state to determine which querysets need syncing.
4193
4060
  */
4194
4061
  syncQuerysetsNeedingVerification(e) {
4195
- const t = Pe.getQuerysetStates(e);
4062
+ const t = Fe.getQuerysetStates(e);
4196
4063
  if (!t) return;
4197
4064
  const s = this.registries.get(Ce);
4198
4065
  if (!s) return;
@@ -4203,7 +4070,7 @@ class vr {
4203
4070
  c && r.push(c);
4204
4071
  }
4205
4072
  if (r.length === 0) return;
4206
- const o = `maybe-sync-${G()}`, i = new Set(
4073
+ const o = `maybe-sync-${B()}`, i = new Set(
4207
4074
  [...this.followedQuerysets].map((l) => l.semanticKey).filter((l) => s._stores.has(l))
4208
4075
  );
4209
4076
  Promise.all(
@@ -4213,7 +4080,7 @@ class vr {
4213
4080
  );
4214
4081
  }
4215
4082
  handleEvent = (e) => {
4216
- B({
4083
+ G({
4217
4084
  type: "event",
4218
4085
  modelName: e.model,
4219
4086
  configKey: e.configKey,
@@ -4223,8 +4090,8 @@ class vr {
4223
4090
  operationId: e.operation_id,
4224
4091
  socketId: e.socket_id
4225
4092
  });
4226
- let t = new Cr(e), s = Pe.has(t.operation_id);
4227
- if (this.registries.has(vt) && this.processMetrics(t), s) {
4093
+ let t = new pr(e), s = Fe.has(t.operation_id);
4094
+ if (this.registries.has(wt) && this.processMetrics(t), s) {
4228
4095
  this.syncQuerysetsNeedingVerification(t.operation_id);
4229
4096
  return;
4230
4097
  }
@@ -4251,7 +4118,7 @@ class vr {
4251
4118
  s.has(o) || s.set(o, []), s.get(o).push(r);
4252
4119
  }), s.forEach((r, o) => {
4253
4120
  const i = r[0];
4254
- this.registries.has(Ce) && this.processQuerysetsBatch(i, r), this.registries.has(Ge) && this.processModels(i);
4121
+ this.registries.has(Ce) && this.processQuerysetsBatch(i, r), this.registries.has(Ve) && this.processModels(i);
4255
4122
  });
4256
4123
  }
4257
4124
  isQuerysetFollowed(e) {
@@ -4268,20 +4135,20 @@ class vr {
4268
4135
  }
4269
4136
  processQuerysetsBatch(e, t) {
4270
4137
  const s = this.registries.get(Ce), r = [];
4271
- for (const [c, f] of s._stores.entries())
4272
- if (f.modelClass.modelName === e.model && f.modelClass.configKey === e.configKey) {
4138
+ for (const [c, h] of s._stores.entries())
4139
+ if (h.modelClass.modelName === e.model && h.modelClass.configKey === e.configKey) {
4273
4140
  if (this.followAllQuerysets) {
4274
- r.push(f);
4141
+ r.push(h);
4275
4142
  continue;
4276
4143
  }
4277
4144
  const p = s.followingQuerysets.get(c);
4278
- p && [...p].some((y) => this.isQuerysetFollowed(y)) && r.push(f);
4145
+ p && [...p].some((y) => this.isQuerysetFollowed(y)) && r.push(h);
4279
4146
  }
4280
4147
  if (r.length === 0) return;
4281
4148
  const i = t.reduce(
4282
- (c, f) => (f.server_ts_ms || 0) > (c.server_ts_ms || 0) ? f : c,
4149
+ (c, h) => (h.server_ts_ms || 0) > (c.server_ts_ms || 0) ? h : c,
4283
4150
  t[0]
4284
- ).canonical_id, l = `remote-event-${G()}`, a = new Set(
4151
+ ).canonical_id, l = `remote-event-${B()}`, a = new Set(
4285
4152
  [...this.followedQuerysets].map((c) => c.semanticKey).filter((c) => s._stores.has(c))
4286
4153
  );
4287
4154
  Promise.all(
@@ -4291,18 +4158,18 @@ class vr {
4291
4158
  );
4292
4159
  }
4293
4160
  processMetrics(e) {
4294
- const t = this.registries.get(vt);
4161
+ const t = this.registries.get(wt);
4295
4162
  for (const [s, r] of t._stores.entries())
4296
4163
  if (r.queryset && r.queryset.modelClass.modelName === e.model && r.queryset.modelClass.configKey === e.configKey) {
4297
4164
  if (this.followAllQuerysets) {
4298
4165
  r.store.sync();
4299
4166
  continue;
4300
4167
  }
4301
- this.isQuerysetFollowed(r.queryset) && r.store.sync();
4168
+ (t.followedMetrics.has(s) || this.isQuerysetFollowed(r.queryset)) && r.store.sync();
4302
4169
  }
4303
4170
  }
4304
4171
  processModels(e) {
4305
- const t = this.registries.get(Ge);
4172
+ const t = this.registries.get(Ve);
4306
4173
  if (!t) return;
4307
4174
  const s = t.getStore(e.modelClass);
4308
4175
  if (!s) return;
@@ -4312,105 +4179,105 @@ class vr {
4312
4179
  if (r.size === 0) return;
4313
4180
  const o = new Set(s.groundTruthPks), i = this.registries.get(Ce), l = /* @__PURE__ */ new Set();
4314
4181
  if (i)
4315
- for (const [c, f] of i._stores.entries())
4316
- f.modelClass.modelName === e.model && f.modelClass.configKey === e.configKey && f.groundTruthPks.forEach((p) => l.add(p));
4182
+ for (const [c, h] of i._stores.entries())
4183
+ h.modelClass.modelName === e.model && h.modelClass.configKey === e.configKey && h.groundTruthPks.forEach((p) => l.add(p));
4317
4184
  const a = [];
4318
4185
  r.forEach((c) => {
4319
4186
  o.has(c) && !l.has(c) && a.push(c);
4320
4187
  }), a.length > 0 && s.sync(a);
4321
4188
  }
4322
4189
  }
4323
- const $e = new vr();
4324
- $e.manageRegistry(j);
4325
- $e.manageRegistry(Q);
4326
- $e.manageRegistry(Fe);
4327
- const Er = /* @__PURE__ */ new Set();
4328
- function br(n) {
4329
- typeof n == "function" && Er.add(n);
4190
+ const Ae = new mr();
4191
+ Ae.manageRegistry(x);
4192
+ Ae.manageRegistry(j);
4193
+ Ae.manageRegistry(Pe);
4194
+ const yr = /* @__PURE__ */ new Set();
4195
+ function gr(n) {
4196
+ typeof n == "function" && yr.add(n);
4330
4197
  }
4331
- $e.followAllQuerysets = !1;
4332
- const ns = /* @__PURE__ */ new Map();
4333
- br(() => {
4334
- ns.clear(), $e.followAllQuerysets = !0, $e.followedQuerysets.clear();
4198
+ Ae.followAllQuerysets = !1;
4199
+ const rs = /* @__PURE__ */ new Map();
4200
+ gr(() => {
4201
+ rs.clear(), Ae.followAllQuerysets = !0, Ae.followedQuerysets.clear();
4335
4202
  });
4336
- const kr = (n, e) => {
4203
+ const _r = (n, e) => {
4337
4204
  const t = n.__vccOpts || n;
4338
4205
  for (const [s, r] of e)
4339
4206
  t[s] = r;
4340
4207
  return t;
4341
- }, Sr = { class: "szd" }, Tr = { class: "szd-header" }, Mr = { class: "szd-header__top" }, $r = { class: "szd-header__left" }, Ar = {
4208
+ }, wr = { class: "szd" }, Cr = { class: "szd-header" }, vr = { class: "szd-header__top" }, kr = { class: "szd-header__left" }, br = {
4342
4209
  key: 0,
4343
4210
  class: "szd-header__model"
4344
- }, Or = {
4211
+ }, Er = {
4345
4212
  key: 1,
4346
4213
  class: "szd-header__model szd-header__model--empty"
4347
- }, Pr = { class: "szd-header__right" }, Fr = {
4214
+ }, Sr = { class: "szd-header__right" }, Tr = {
4348
4215
  key: 0,
4349
4216
  class: "szd-header__badge szd-header__badge--syncing"
4350
- }, Ir = {
4217
+ }, Mr = {
4351
4218
  key: 1,
4352
4219
  class: "szd-header__badge"
4353
- }, Dr = { class: "szd-header__badge" }, zr = { class: "szd-tabs" }, Kr = ["onClick"], Rr = { class: "szd-content" }, Nr = {
4220
+ }, Ar = { class: "szd-header__badge" }, Or = { class: "szd-tabs" }, $r = ["onClick"], Fr = { class: "szd-content" }, Pr = {
4354
4221
  key: 0,
4355
4222
  class: "szd-panel"
4356
- }, xr = { class: "szd-panel__section" }, jr = { class: "szd-kv" }, Ur = { class: "szd-kv__row" }, Qr = { class: "szd-kv__value" }, Vr = { class: "szd-kv__row" }, Lr = { class: "szd-kv__value" }, Gr = { class: "szd-kv__row" }, Br = { class: "szd-kv__value" }, Hr = { class: "szd-kv__row" }, qr = { class: "szd-kv__value" }, Jr = { class: "szd-panel__section" }, Wr = { class: "szd-stats" }, Zr = { class: "szd-stat" }, Yr = { class: "szd-stat__value" }, Xr = { class: "szd-stat" }, en = { class: "szd-stat__value" }, tn = { class: "szd-stat" }, sn = { class: "szd-stat__value" }, rn = { class: "szd-stat" }, nn = { class: "szd-stat__value" }, on = {
4223
+ }, 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 = {
4357
4224
  class: "szd-kv",
4358
4225
  style: { "margin-top": "12px" }
4359
- }, an = { class: "szd-kv__row" }, ln = { class: "szd-kv__value" }, cn = {
4226
+ }, en = { class: "szd-kv__row" }, tn = { class: "szd-kv__value" }, sn = {
4360
4227
  key: 0,
4361
4228
  class: "szd-panel__section"
4362
- }, dn = { class: "szd-event-preview__text" }, un = { class: "szd-event-preview__time" }, hn = {
4229
+ }, rn = { class: "szd-event-preview__text" }, nn = { class: "szd-event-preview__time" }, on = {
4363
4230
  key: 1,
4364
4231
  class: "szd-panel"
4365
- }, fn = { class: "szd-timeline-filters" }, pn = ["onUpdate:modelValue"], mn = { class: "szd-timeline" }, yn = ["onClick"], gn = { class: "szd-timeline__time" }, _n = { class: "szd-timeline__text" }, wn = {
4232
+ }, 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 = {
4366
4233
  key: 0,
4367
4234
  class: "szd-empty"
4368
- }, Cn = {
4235
+ }, pn = {
4369
4236
  key: 2,
4370
4237
  class: "szd-panel"
4371
- }, vn = { class: "szd-pipeline" }, En = ["onClick"], bn = { class: "szd-pipeline__label" }, kn = { class: "szd-pipeline__count" }, Sn = {
4238
+ }, mn = { class: "szd-pipeline" }, yn = ["onClick"], gn = { class: "szd-pipeline__label" }, _n = { class: "szd-pipeline__count" }, wn = {
4372
4239
  key: 0,
4373
4240
  class: "szd-pipeline__arrow"
4374
- }, Tn = {
4241
+ }, Cn = {
4375
4242
  class: "szd-panel__section",
4376
4243
  style: { "margin-top": "20px" }
4377
- }, Mn = { class: "szd-preview-header" }, $n = ["value"], An = {
4244
+ }, vn = { class: "szd-preview-header" }, kn = ["value"], bn = {
4378
4245
  key: 0,
4379
4246
  class: "szd-data-grid"
4380
- }, On = { class: "szd-data-card__header" }, Pn = {
4247
+ }, En = { class: "szd-data-card__header" }, Sn = {
4381
4248
  key: 0,
4382
4249
  class: "szd-data-card__badge"
4383
- }, Fn = {
4250
+ }, Tn = {
4384
4251
  key: 1,
4385
4252
  class: "szd-data-card__badge szd-data-card__badge--absent"
4386
- }, In = { class: "szd-data-card__content" }, Dn = {
4253
+ }, Mn = { class: "szd-data-card__content" }, An = {
4387
4254
  key: 1,
4388
4255
  class: "szd-empty"
4389
- }, zn = {
4256
+ }, On = {
4390
4257
  key: 3,
4391
4258
  class: "szd-panel"
4392
- }, Kn = {
4259
+ }, $n = {
4393
4260
  class: "szd-kv",
4394
4261
  style: { "margin-bottom": "16px" }
4395
- }, Rn = { class: "szd-kv__row" }, Nn = { class: "szd-kv__value szd-kv__value--mono" }, xn = { class: "szd-ast" }, jn = {
4262
+ }, Fn = { class: "szd-kv__row" }, Pn = { class: "szd-kv__value szd-kv__value--mono" }, Dn = { class: "szd-ast" }, zn = {
4396
4263
  key: 0,
4397
4264
  class: "szd-detail"
4398
- }, Un = { class: "szd-detail__panel szd-detail__panel--sm" }, Qn = { class: "szd-detail__header" }, Vn = { class: "szd-detail__body" }, Ln = { class: "szd-settings-section" }, Gn = ["value"], Bn = {
4265
+ }, 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 = {
4399
4266
  key: 0,
4400
4267
  class: "szd-settings-section"
4401
- }, Hn = { class: "szd-settings-row" }, qn = { class: "szd-settings-code" }, Jn = { class: "szd-settings-section" }, Wn = { class: "szd-settings-actions" }, Zn = ["disabled"], Yn = { class: "szd-settings-section" }, Xn = { class: "szd-toggle" }, eo = {
4268
+ }, 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 = {
4402
4269
  key: 1,
4403
4270
  class: "szd-settings-section"
4404
- }, to = { class: "szd-kv" }, so = { class: "szd-kv__row" }, ro = { class: "szd-kv__value" }, no = { class: "szd-kv__row" }, oo = { class: "szd-kv__value" }, io = { class: "szd-kv__row" }, ao = { class: "szd-kv__value" }, lo = { class: "szd-kv__row" }, co = { class: "szd-kv__value" }, uo = { class: "szd-kv__row" }, ho = { class: "szd-kv__value" }, fo = {
4271
+ }, 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 = {
4405
4272
  key: 0,
4406
4273
  class: "szd-detail"
4407
- }, po = { class: "szd-detail__panel" }, mo = { class: "szd-detail__header" }, yo = { class: "szd-detail__title" }, go = { class: "szd-detail__body" }, _o = { class: "szd-kv" }, wo = { class: "szd-kv__key" }, Co = { class: "szd-kv__value" }, vo = { class: "szd-ast" }, Eo = {
4274
+ }, 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 = {
4408
4275
  class: "szd-kv",
4409
4276
  style: { "margin-bottom": "16px" }
4410
- }, bo = { class: "szd-kv__row" }, ko = { class: "szd-kv__value" }, So = { class: "szd-kv__row" }, To = { class: "szd-kv__value" }, Mo = {
4277
+ }, go = { class: "szd-kv__row" }, _o = { class: "szd-kv__value" }, wo = { class: "szd-kv__row" }, Co = { class: "szd-kv__value" }, vo = {
4411
4278
  key: 0,
4412
4279
  class: "szd-kv__note"
4413
- }, $o = { class: "szd-ast" }, Zt = 100, Ao = {
4280
+ }, ko = { class: "szd-ast" }, Jt = 100, bo = {
4414
4281
  __name: "StateZeroDebugPanel",
4415
4282
  props: {
4416
4283
  queryset: { type: [Object, String], default: null },
@@ -4424,7 +4291,7 @@ const kr = (n, e) => {
4424
4291
  { id: "timeline", label: "Timeline" },
4425
4292
  { id: "data", label: "Data" },
4426
4293
  { id: "ast", label: "AST" }
4427
- ], r = J(""), o = J(e.useQueryset), i = J(!0), l = J(Lt()), a = J(0), c = J(!1), f = J(null), p = J(!1), m = J(null), y = J({
4294
+ ], 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({
4428
4295
  request: !0,
4429
4296
  response: !0,
4430
4297
  render: !0,
@@ -4440,12 +4307,12 @@ const kr = (n, e) => {
4440
4307
  let g = u;
4441
4308
  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;
4442
4309
  }
4443
- const w = R(
4310
+ const w = I(
4444
4311
  () => _(e.queryset, o.value)
4445
- ), v = R(() => {
4312
+ ), v = I(() => {
4446
4313
  a.value;
4447
4314
  const u = [];
4448
- return ns.forEach((d) => {
4315
+ return rs.forEach((d) => {
4449
4316
  d?.semanticKey && u.push({
4450
4317
  semanticKey: d.semanticKey,
4451
4318
  modelName: d.ModelClass?.modelName,
@@ -4453,50 +4320,50 @@ const kr = (n, e) => {
4453
4320
  queryset: d
4454
4321
  });
4455
4322
  }), u;
4456
- }), O = R(() => (a.value, Array.from(j._stores.entries()).map(
4323
+ }), O = I(() => (a.value, Array.from(x._stores.entries()).map(
4457
4324
  ([u, d]) => ({
4458
4325
  semanticKey: u,
4459
4326
  modelName: d?.modelClass?.modelName,
4460
4327
  configKey: d?.modelClass?.configKey,
4461
4328
  store: d
4462
4329
  })
4463
- ))), T = R(() => {
4330
+ ))), T = I(() => {
4464
4331
  const u = /* @__PURE__ */ new Map();
4465
4332
  return v.value.forEach((d) => {
4466
4333
  u.set(d.semanticKey, d.queryset);
4467
4334
  }), u;
4468
- }), b = R(() => {
4335
+ }), k = I(() => {
4469
4336
  const u = /* @__PURE__ */ new Map();
4470
4337
  return v.value.forEach((d) => {
4471
4338
  u.set(d.semanticKey, d);
4472
4339
  }), O.value.forEach((d) => {
4473
4340
  u.has(d.semanticKey) || u.set(d.semanticKey, d);
4474
4341
  }), Array.from(u.values());
4475
- }), 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(() => {
4476
- if (U.value)
4342
+ }), 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(() => {
4343
+ if (Q.value)
4477
4344
  try {
4478
- return j.getStore(U.value);
4345
+ return x.getStore(Q.value);
4479
4346
  } catch {
4480
4347
  return null;
4481
4348
  }
4482
- return k.value && j._stores.get(k.value) || null;
4483
- }), F = R(() => {
4349
+ return E.value && x._stores.get(E.value) || null;
4350
+ }), F = I(() => {
4484
4351
  a.value;
4485
- 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, ds = u?.groundTruthPks?.length ?? 0, us = u ? u.lastSync === null ? "model store" : "ground truth" : "—", hs = 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.";
4352
+ 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?.() || [], ke = 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 = ke ? "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.";
4486
4353
  return {
4487
4354
  modelName: g,
4488
- configKey: z,
4355
+ configKey: R,
4489
4356
  groundTruthCount: H,
4490
4357
  opsCount: oe,
4491
4358
  inFlightCount: le.length,
4492
- isSyncing: be,
4493
- lastSync: Ue,
4494
- optimisticCount: ot,
4495
- confirmedCount: ds,
4496
- source: us,
4497
- reason: hs
4359
+ isSyncing: ke,
4360
+ lastSync: je,
4361
+ optimisticCount: nt,
4362
+ confirmedCount: cs,
4363
+ source: ds,
4364
+ reason: us
4498
4365
  };
4499
- }), re = R(() => {
4366
+ }), re = I(() => {
4500
4367
  a.value;
4501
4368
  try {
4502
4369
  return N.value?.queryset?.build?.() || null;
@@ -4507,13 +4374,13 @@ const kr = (n, e) => {
4507
4374
  function pe(u) {
4508
4375
  if (!u?.filter?.conditions) return "—";
4509
4376
  const d = u.filter.conditions;
4510
- 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(", ");
4377
+ 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(", ");
4511
4378
  }
4512
4379
  function ae(u) {
4513
4380
  const d = u?.orderBy;
4514
4381
  return !d || Array.isArray(d) && d.length === 0 ? "—" : Array.isArray(d) ? d.join(", ") : String(d);
4515
4382
  }
4516
- const D = R(() => {
4383
+ const z = I(() => {
4517
4384
  const u = re.value;
4518
4385
  return {
4519
4386
  filter: pe(u),
@@ -4521,10 +4388,10 @@ const kr = (n, e) => {
4521
4388
  limit: u?.serializerOptions?.limit ?? "—"
4522
4389
  };
4523
4390
  });
4524
- function I(u, d, g, z) {
4391
+ function D(u, d, g, R) {
4525
4392
  if (!u || !Array.isArray(g)) return [];
4526
4393
  const H = [];
4527
- for (const oe of g.slice(0, z))
4394
+ for (const oe of g.slice(0, R))
4528
4395
  try {
4529
4396
  const le = u.fromPk(oe, d);
4530
4397
  le && H.push(le.serialize());
@@ -4532,9 +4399,9 @@ const kr = (n, e) => {
4532
4399
  }
4533
4400
  return H;
4534
4401
  }
4535
- const K = R(() => {
4402
+ const K = I(() => {
4536
4403
  a.value;
4537
- const u = N.value, d = U.value;
4404
+ const u = N.value, d = Q.value;
4538
4405
  if (!u || !d)
4539
4406
  return {
4540
4407
  modelStoreFiltered: [],
@@ -4549,7 +4416,7 @@ const kr = (n, e) => {
4549
4416
  finalSample: [],
4550
4417
  limit: null
4551
4418
  };
4552
- 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 ? I(
4419
+ const g = Array.isArray(u.groundTruthPks) ? [...u.groundTruthPks] : [], R = u.renderFromData(!0), H = u.renderFromData(!1), oe = u._getValidatedAndFilteredPks(R), le = [], ke = d.build()?.serializerOptions?.limit ?? null, je = ke ? oe.slice(0, ke) : oe, nt = le.length > 0 ? D(
4553
4420
  u.modelClass,
4554
4421
  d,
4555
4422
  le,
@@ -4558,66 +4425,66 @@ const kr = (n, e) => {
4558
4425
  return {
4559
4426
  modelStoreFiltered: le,
4560
4427
  groundTruth: g,
4561
- optimistic: z,
4428
+ optimistic: R,
4562
4429
  filtered: oe,
4563
- final: Ue,
4564
- modelStoreSample: ot,
4565
- groundTruthSample: I(
4430
+ final: je,
4431
+ modelStoreSample: nt,
4432
+ groundTruthSample: D(
4566
4433
  u.modelClass,
4567
4434
  d,
4568
4435
  g,
4569
4436
  e.sampleSize
4570
4437
  ),
4571
- optimisticSample: I(
4438
+ optimisticSample: D(
4572
4439
  u.modelClass,
4573
4440
  d,
4574
- z,
4441
+ R,
4575
4442
  e.sampleSize
4576
4443
  ),
4577
- filteredSample: I(
4444
+ filteredSample: D(
4578
4445
  u.modelClass,
4579
4446
  d,
4580
4447
  oe,
4581
4448
  e.sampleSize
4582
4449
  ),
4583
- finalSample: I(
4450
+ finalSample: D(
4584
4451
  u.modelClass,
4585
4452
  d,
4586
- Ue,
4453
+ je,
4587
4454
  e.sampleSize
4588
4455
  ),
4589
- limit: be,
4456
+ limit: ke,
4590
4457
  confirmed: H
4591
4458
  };
4592
- }), me = R(() => [
4459
+ }), me = I(() => [
4593
4460
  { id: "model-store", label: "Model Store", count: K.value.modelStoreFiltered.length, pks: K.value.modelStoreFiltered },
4594
4461
  { id: "ground-truth", label: "Ground Truth", count: K.value.groundTruth.length, pks: K.value.groundTruth },
4595
4462
  { id: "optimistic", label: "Optimistic", count: K.value.optimistic.length, pks: K.value.optimistic },
4596
4463
  { id: "filtered", label: "Filtered", count: K.value.filtered.length, pks: K.value.filtered },
4597
4464
  { id: "final", label: "Final", count: K.value.final.length, pks: K.value.final }
4598
- ]), Ye = R(() => K.value.final || []);
4465
+ ]), Ze = I(() => K.value.final || []);
4599
4466
  function ye(u) {
4600
- const d = N.value, g = U.value;
4467
+ const d = N.value, g = Q.value;
4601
4468
  if (!d || !g || u == null) return null;
4602
4469
  try {
4603
- const z = d.modelClass.fromPk(u, g);
4604
- return z ? z.serialize() : null;
4470
+ const R = d.modelClass.fromPk(u, g);
4471
+ return R ? R.serialize() : null;
4605
4472
  } catch {
4606
4473
  return null;
4607
4474
  }
4608
4475
  }
4609
- R(() => m.value == null ? null : ye(m.value));
4610
- const Ke = R(() => {
4611
- if (!f.value || f.value.type !== "snapshot") return [];
4612
- const u = f.value.data, d = N.value, g = U.value;
4613
- return !d || !g || !u.pks ? [] : I(d.modelClass, g, u.pks, Zt);
4614
- }), Xe = R(() => !f.value || f.value.type !== "snapshot" ? !1 : f.value.data.count > Zt), Re = R(() => {
4615
- if (!k.value) return l.value;
4476
+ I(() => m.value == null ? null : ye(m.value));
4477
+ const Re = I(() => {
4478
+ if (!h.value || h.value.type !== "snapshot") return [];
4479
+ const u = h.value.data, d = N.value, g = Q.value;
4480
+ return !d || !g || !u.pks ? [] : D(d.modelClass, g, u.pks, Jt);
4481
+ }), Ye = I(() => !h.value || h.value.type !== "snapshot" ? !1 : h.value.data.count > Jt), Ke = I(() => {
4482
+ if (!E.value) return l.value;
4616
4483
  const u = N.value;
4617
- return l.value.filter((d) => d.semanticKey === k.value ? !0 : u ? d.modelName === u.modelClass?.modelName && d.configKey === u.modelClass?.configKey : !1);
4618
- }), Ee = R(() => Re.value.filter((u) => y.value[u.type])), Ne = R(() => l.value.length), ne = R(
4484
+ return l.value.filter((d) => d.semanticKey === E.value ? !0 : u ? d.modelName === u.modelClass?.modelName && d.configKey === u.modelClass?.configKey : !1);
4485
+ }), ve = I(() => Ke.value.filter((u) => y.value[u.type])), Ie = I(() => l.value.length), ne = I(
4619
4486
  () => l.value.length ? l.value[l.value.length - 1] : null
4620
- ), xe = [
4487
+ ), Ne = [
4621
4488
  { id: "request", label: "Requests", color: "#3b82f6" },
4622
4489
  { id: "response", label: "Responses", color: "#22c55e" },
4623
4490
  { id: "render", label: "Renders", color: "#a855f7" },
@@ -4628,10 +4495,10 @@ const kr = (n, e) => {
4628
4495
  { id: "groupSync", label: "Group Sync", color: "#8b5cf6" },
4629
4496
  { id: "error", label: "Errors", color: "#ef4444" }
4630
4497
  ];
4631
- function je(u) {
4632
- return xe.find((d) => d.id === u)?.color || "#6b7280";
4498
+ function xe(u) {
4499
+ return Ne.find((d) => d.id === u)?.color || "#6b7280";
4633
4500
  }
4634
- function et(u) {
4501
+ function Xe(u) {
4635
4502
  if (!u) return "";
4636
4503
  try {
4637
4504
  return new Date(u).toLocaleTimeString();
@@ -4639,7 +4506,7 @@ const kr = (n, e) => {
4639
4506
  return "";
4640
4507
  }
4641
4508
  }
4642
- function bt(u) {
4509
+ function vt(u) {
4643
4510
  if (!u) return "";
4644
4511
  switch (u.type) {
4645
4512
  case "request":
@@ -4664,11 +4531,11 @@ const kr = (n, e) => {
4664
4531
  return u.type;
4665
4532
  }
4666
4533
  }
4667
- function os(u) {
4534
+ function ns(u) {
4668
4535
  if (!u) return null;
4669
4536
  const d = {
4670
4537
  type: u.type,
4671
- time: et(u.ts),
4538
+ time: Xe(u.ts),
4672
4539
  model: u.modelName,
4673
4540
  config: u.configKey,
4674
4541
  semanticKey: u.semanticKey
@@ -4696,13 +4563,13 @@ const kr = (n, e) => {
4696
4563
  return d;
4697
4564
  }
4698
4565
  }
4699
- function is() {
4566
+ function os() {
4700
4567
  Bs(), l.value = [];
4701
4568
  }
4702
- function as() {
4703
- !k.value || !navigator?.clipboard || navigator.clipboard.writeText(k.value);
4569
+ function is() {
4570
+ !E.value || !navigator?.clipboard || navigator.clipboard.writeText(E.value);
4704
4571
  }
4705
- async function ls() {
4572
+ async function as() {
4706
4573
  if (!(!N.value || c.value)) {
4707
4574
  c.value = !0;
4708
4575
  try {
@@ -4714,59 +4581,59 @@ const kr = (n, e) => {
4714
4581
  }
4715
4582
  }
4716
4583
  function kt(u) {
4717
- f.value = { type: "entry", data: u };
4584
+ h.value = { type: "entry", data: u };
4718
4585
  }
4719
- function cs(u) {
4720
- f.value = { type: "snapshot", data: u };
4586
+ function ls(u) {
4587
+ h.value = { type: "snapshot", data: u };
4721
4588
  }
4722
- function St() {
4723
- f.value = null;
4589
+ function bt() {
4590
+ h.value = null;
4724
4591
  }
4725
- function Tt(u) {
4592
+ function Et(u) {
4726
4593
  Object.keys(y.value).forEach((d) => {
4727
4594
  y.value[d] = u;
4728
4595
  });
4729
4596
  }
4730
- let tt = null, st = null, rt = null, nt = null;
4731
- return fs(() => {
4732
- Hs(), Gt(e.maxEntries), tt = Ls((u) => {
4597
+ let et = null, tt = null, st = null, rt = null;
4598
+ return hs(() => {
4599
+ Gs(), Lt(e.maxEntries), et = Ls((u) => {
4733
4600
  i.value && (l.value = [...l.value, u], l.value.length > e.maxEntries && (l.value = l.value.slice(-e.maxEntries)));
4734
- }), st = Gs(() => {
4601
+ }), tt = Vs(() => {
4735
4602
  l.value = [];
4736
- }), rt = setInterval(() => {
4603
+ }), st = setInterval(() => {
4737
4604
  a.value += 1;
4738
- }, 2e3), nt = setInterval(() => {
4739
- l.value = Lt();
4605
+ }, 2e3), rt = setInterval(() => {
4606
+ l.value = Qt();
4740
4607
  }, 1e3);
4741
- }), ps(() => {
4742
- tt && tt(), st && st(), rt && clearInterval(rt), nt && clearInterval(nt);
4743
- }), it(
4608
+ }), fs(() => {
4609
+ et && et(), tt && tt(), st && clearInterval(st), rt && clearInterval(rt);
4610
+ }), ot(
4744
4611
  () => e.maxEntries,
4745
- (u) => Gt(u)
4746
- ), it(
4612
+ (u) => Lt(u)
4613
+ ), ot(
4747
4614
  () => e.useQueryset,
4748
4615
  (u) => {
4749
4616
  o.value = u;
4750
4617
  }
4751
- ), it(k, () => {
4618
+ ), ot(E, () => {
4752
4619
  m.value = null;
4753
- }), (u, d) => (A(), $("section", Sr, [
4754
- h("header", Tr, [
4755
- h("div", Mr, [
4756
- h("div", $r, [
4757
- d[9] || (d[9] = h("div", { class: "szd-header__title" }, "StateZero", -1)),
4758
- k.value ? (A(), $("span", Ar, S(F.value.modelName || "?"), 1)) : (A(), $("span", Or, "No queryset"))
4620
+ }), (u, d) => (A(), M("section", wr, [
4621
+ f("header", Cr, [
4622
+ f("div", vr, [
4623
+ f("div", kr, [
4624
+ d[9] || (d[9] = f("div", { class: "szd-header__title" }, "StateZero", -1)),
4625
+ E.value ? (A(), M("span", br, S(F.value.modelName || "?"), 1)) : (A(), M("span", Er, "No queryset"))
4759
4626
  ]),
4760
- h("div", Pr, [
4761
- F.value.isSyncing ? (A(), $("span", Fr, "Syncing")) : V("", !0),
4762
- F.value.opsCount > 0 ? (A(), $("span", Ir, S(F.value.opsCount) + " ops", 1)) : V("", !0),
4763
- h("span", Dr, S(Ne.value) + " events", 1),
4764
- h("button", {
4627
+ f("div", Sr, [
4628
+ F.value.isSyncing ? (A(), M("span", Tr, "Syncing")) : L("", !0),
4629
+ F.value.opsCount > 0 ? (A(), M("span", Mr, S(F.value.opsCount) + " ops", 1)) : L("", !0),
4630
+ f("span", Ar, S(Ie.value) + " events", 1),
4631
+ f("button", {
4765
4632
  class: "szd-btn szd-btn--icon",
4766
4633
  onClick: d[0] || (d[0] = (g) => p.value = !0),
4767
4634
  title: "Settings"
4768
4635
  }, [...d[10] || (d[10] = [
4769
- h("svg", {
4636
+ f("svg", {
4770
4637
  width: "16",
4771
4638
  height: "16",
4772
4639
  viewBox: "0 0 24 24",
@@ -4774,339 +4641,339 @@ const kr = (n, e) => {
4774
4641
  stroke: "currentColor",
4775
4642
  "stroke-width": "2"
4776
4643
  }, [
4777
- h("circle", {
4644
+ f("circle", {
4778
4645
  cx: "12",
4779
4646
  cy: "12",
4780
4647
  r: "3"
4781
4648
  }),
4782
- 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" })
4649
+ 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" })
4783
4650
  ], -1)
4784
4651
  ])])
4785
4652
  ])
4786
4653
  ]),
4787
- h("nav", zr, [
4788
- (A(), $(W, null, ce(s, (g) => h("button", {
4654
+ f("nav", Or, [
4655
+ (A(), M(W, null, ce(s, (g) => f("button", {
4789
4656
  key: g.id,
4790
- class: $t(["szd-tabs__tab", { "szd-tabs__tab--active": t.value === g.id }]),
4791
- onClick: (z) => t.value = g.id
4792
- }, S(g.label), 11, Kr)), 64))
4657
+ class: Tt(["szd-tabs__tab", { "szd-tabs__tab--active": t.value === g.id }]),
4658
+ onClick: (R) => t.value = g.id
4659
+ }, S(g.label), 11, $r)), 64))
4793
4660
  ])
4794
4661
  ]),
4795
- h("main", Rr, [
4796
- t.value === "overview" ? (A(), $("div", Nr, [
4797
- h("div", xr, [
4798
- d[15] || (d[15] = h("h3", { class: "szd-panel__heading" }, "Why This View?", -1)),
4799
- h("div", jr, [
4800
- h("div", Ur, [
4801
- d[11] || (d[11] = h("span", { class: "szd-kv__key" }, "Filter:", -1)),
4802
- h("span", Qr, S(D.value.filter), 1)
4662
+ f("main", Fr, [
4663
+ t.value === "overview" ? (A(), M("div", Pr, [
4664
+ f("div", Dr, [
4665
+ d[15] || (d[15] = f("h3", { class: "szd-panel__heading" }, "Why This View?", -1)),
4666
+ f("div", zr, [
4667
+ f("div", Rr, [
4668
+ d[11] || (d[11] = f("span", { class: "szd-kv__key" }, "Filter:", -1)),
4669
+ f("span", Kr, S(z.value.filter), 1)
4803
4670
  ]),
4804
- h("div", Vr, [
4805
- d[12] || (d[12] = h("span", { class: "szd-kv__key" }, "Order:", -1)),
4806
- h("span", Lr, S(D.value.orderBy), 1)
4671
+ f("div", Ir, [
4672
+ d[12] || (d[12] = f("span", { class: "szd-kv__key" }, "Order:", -1)),
4673
+ f("span", Nr, S(z.value.orderBy), 1)
4807
4674
  ]),
4808
- h("div", Gr, [
4809
- d[13] || (d[13] = h("span", { class: "szd-kv__key" }, "Limit:", -1)),
4810
- h("span", Br, S(D.value.limit), 1)
4675
+ f("div", xr, [
4676
+ d[13] || (d[13] = f("span", { class: "szd-kv__key" }, "Limit:", -1)),
4677
+ f("span", jr, S(z.value.limit), 1)
4811
4678
  ]),
4812
- h("div", Hr, [
4813
- d[14] || (d[14] = h("span", { class: "szd-kv__key" }, "Reason:", -1)),
4814
- h("span", qr, S(F.value.reason), 1)
4679
+ f("div", Ur, [
4680
+ d[14] || (d[14] = f("span", { class: "szd-kv__key" }, "Reason:", -1)),
4681
+ f("span", Qr, S(F.value.reason), 1)
4815
4682
  ])
4816
4683
  ])
4817
4684
  ]),
4818
- h("div", Jr, [
4819
- d[21] || (d[21] = h("h3", { class: "szd-panel__heading" }, "Current State", -1)),
4820
- h("div", Wr, [
4821
- h("div", Zr, [
4822
- h("div", Yr, S(F.value.optimisticCount ?? "—"), 1),
4823
- d[16] || (d[16] = h("div", { class: "szd-stat__label" }, "Optimistic", -1))
4685
+ f("div", Lr, [
4686
+ d[21] || (d[21] = f("h3", { class: "szd-panel__heading" }, "Current State", -1)),
4687
+ f("div", Vr, [
4688
+ f("div", Br, [
4689
+ f("div", Gr, S(F.value.optimisticCount ?? "—"), 1),
4690
+ d[16] || (d[16] = f("div", { class: "szd-stat__label" }, "Optimistic", -1))
4824
4691
  ]),
4825
- h("div", Xr, [
4826
- h("div", en, S(F.value.confirmedCount), 1),
4827
- d[17] || (d[17] = h("div", { class: "szd-stat__label" }, "Confirmed", -1))
4692
+ f("div", Hr, [
4693
+ f("div", qr, S(F.value.confirmedCount), 1),
4694
+ d[17] || (d[17] = f("div", { class: "szd-stat__label" }, "Confirmed", -1))
4828
4695
  ]),
4829
- h("div", tn, [
4830
- h("div", sn, S(F.value.groundTruthCount), 1),
4831
- d[18] || (d[18] = h("div", { class: "szd-stat__label" }, "Ground Truth", -1))
4696
+ f("div", Jr, [
4697
+ f("div", Wr, S(F.value.groundTruthCount), 1),
4698
+ d[18] || (d[18] = f("div", { class: "szd-stat__label" }, "Ground Truth", -1))
4832
4699
  ]),
4833
- h("div", rn, [
4834
- h("div", nn, S(F.value.inFlightCount), 1),
4835
- d[19] || (d[19] = h("div", { class: "szd-stat__label" }, "In-Flight", -1))
4700
+ f("div", Zr, [
4701
+ f("div", Yr, S(F.value.inFlightCount), 1),
4702
+ d[19] || (d[19] = f("div", { class: "szd-stat__label" }, "In-Flight", -1))
4836
4703
  ])
4837
4704
  ]),
4838
- h("div", on, [
4839
- h("div", an, [
4840
- d[20] || (d[20] = h("span", { class: "szd-kv__key" }, "Last Sync:", -1)),
4841
- h("span", ln, S(F.value.lastSync), 1)
4705
+ f("div", Xr, [
4706
+ f("div", en, [
4707
+ d[20] || (d[20] = f("span", { class: "szd-kv__key" }, "Last Sync:", -1)),
4708
+ f("span", tn, S(F.value.lastSync), 1)
4842
4709
  ])
4843
4710
  ])
4844
4711
  ]),
4845
- ne.value ? (A(), $("div", cn, [
4846
- d[22] || (d[22] = h("h3", { class: "szd-panel__heading" }, "Last Event", -1)),
4847
- h("button", {
4712
+ ne.value ? (A(), M("div", sn, [
4713
+ d[22] || (d[22] = f("h3", { class: "szd-panel__heading" }, "Last Event", -1)),
4714
+ f("button", {
4848
4715
  class: "szd-event-preview",
4849
4716
  onClick: d[1] || (d[1] = (g) => kt(ne.value))
4850
4717
  }, [
4851
- h("span", {
4718
+ f("span", {
4852
4719
  class: "szd-event-preview__badge",
4853
- style: at({ background: je(ne.value.type) })
4720
+ style: it({ background: xe(ne.value.type) })
4854
4721
  }, S(ne.value.type), 5),
4855
- h("span", dn, S(bt(ne.value)), 1),
4856
- h("span", un, S(et(ne.value.ts)), 1)
4722
+ f("span", rn, S(vt(ne.value)), 1),
4723
+ f("span", nn, S(Xe(ne.value.ts)), 1)
4857
4724
  ])
4858
- ])) : V("", !0)
4859
- ])) : V("", !0),
4860
- t.value === "timeline" ? (A(), $("div", hn, [
4861
- h("div", fn, [
4862
- h("button", {
4725
+ ])) : L("", !0)
4726
+ ])) : L("", !0),
4727
+ t.value === "timeline" ? (A(), M("div", on, [
4728
+ f("div", an, [
4729
+ f("button", {
4863
4730
  class: "szd-btn szd-btn--sm",
4864
- onClick: d[2] || (d[2] = (g) => Tt(!0))
4731
+ onClick: d[2] || (d[2] = (g) => Et(!0))
4865
4732
  }, "All"),
4866
- h("button", {
4733
+ f("button", {
4867
4734
  class: "szd-btn szd-btn--sm",
4868
- onClick: d[3] || (d[3] = (g) => Tt(!1))
4735
+ onClick: d[3] || (d[3] = (g) => Et(!1))
4869
4736
  }, "None"),
4870
- (A(), $(W, null, ce(xe, (g) => h("label", {
4737
+ (A(), M(W, null, ce(Ne, (g) => f("label", {
4871
4738
  key: g.id,
4872
- class: $t(["szd-filter-chip", { "szd-filter-chip--active": y.value[g.id] }]),
4873
- style: at(y.value[g.id] ? { background: g.color, borderColor: g.color } : {})
4739
+ class: Tt(["szd-filter-chip", { "szd-filter-chip--active": y.value[g.id] }]),
4740
+ style: it(y.value[g.id] ? { background: g.color, borderColor: g.color } : {})
4874
4741
  }, [
4875
- Qe(h("input", {
4742
+ Ue(f("input", {
4876
4743
  type: "checkbox",
4877
- "onUpdate:modelValue": (z) => y.value[g.id] = z,
4744
+ "onUpdate:modelValue": (R) => y.value[g.id] = R,
4878
4745
  class: "szd-filter-chip__input"
4879
- }, null, 8, pn), [
4880
- [At, y.value[g.id]]
4746
+ }, null, 8, ln), [
4747
+ [Mt, y.value[g.id]]
4881
4748
  ]),
4882
- Ve(" " + S(g.label), 1)
4749
+ Qe(" " + S(g.label), 1)
4883
4750
  ], 6)), 64))
4884
4751
  ]),
4885
- h("div", mn, [
4886
- (A(!0), $(W, null, ce(Ee.value, (g) => (A(), $("div", {
4752
+ f("div", cn, [
4753
+ (A(!0), M(W, null, ce(ve.value, (g) => (A(), M("div", {
4887
4754
  key: g.id,
4888
4755
  class: "szd-timeline__item",
4889
- onClick: (z) => kt(g)
4756
+ onClick: (R) => kt(g)
4890
4757
  }, [
4891
- h("span", gn, S(et(g.ts)), 1),
4892
- h("span", {
4758
+ f("span", un, S(Xe(g.ts)), 1),
4759
+ f("span", {
4893
4760
  class: "szd-timeline__badge",
4894
- style: at({ background: je(g.type) })
4761
+ style: it({ background: xe(g.type) })
4895
4762
  }, S(g.type), 5),
4896
- h("span", _n, S(bt(g)), 1)
4897
- ], 8, yn))), 128)),
4898
- Ee.value.length ? V("", !0) : (A(), $("div", wn, " No events match current filters "))
4763
+ f("span", hn, S(vt(g)), 1)
4764
+ ], 8, dn))), 128)),
4765
+ ve.value.length ? L("", !0) : (A(), M("div", fn, " No events match current filters "))
4899
4766
  ])
4900
- ])) : V("", !0),
4901
- t.value === "data" ? (A(), $("div", Cn, [
4902
- d[25] || (d[25] = h("h3", { class: "szd-panel__heading" }, "Data Pipeline", -1)),
4903
- h("div", vn, [
4904
- (A(!0), $(W, null, ce(me.value, (g, z) => (A(), $(W, {
4767
+ ])) : L("", !0),
4768
+ t.value === "data" ? (A(), M("div", pn, [
4769
+ d[25] || (d[25] = f("h3", { class: "szd-panel__heading" }, "Data Pipeline", -1)),
4770
+ f("div", mn, [
4771
+ (A(!0), M(W, null, ce(me.value, (g, R) => (A(), M(W, {
4905
4772
  key: g.id
4906
4773
  }, [
4907
- h("div", {
4774
+ f("div", {
4908
4775
  class: "szd-pipeline__stage",
4909
- onClick: (H) => cs(g)
4776
+ onClick: (H) => ls(g)
4910
4777
  }, [
4911
- h("div", bn, S(g.label), 1),
4912
- h("div", kn, S(g.count), 1)
4913
- ], 8, En),
4914
- z < me.value.length - 1 ? (A(), $("div", Sn, "→")) : V("", !0)
4778
+ f("div", gn, S(g.label), 1),
4779
+ f("div", _n, S(g.count), 1)
4780
+ ], 8, yn),
4781
+ R < me.value.length - 1 ? (A(), M("div", wn, "→")) : L("", !0)
4915
4782
  ], 64))), 128))
4916
4783
  ]),
4917
- h("div", Tn, [
4918
- h("div", Mn, [
4919
- d[24] || (d[24] = h("h3", { class: "szd-panel__heading" }, "Instance Preview", -1)),
4920
- Qe(h("select", {
4784
+ f("div", Cn, [
4785
+ f("div", vn, [
4786
+ d[24] || (d[24] = f("h3", { class: "szd-panel__heading" }, "Instance Preview", -1)),
4787
+ Ue(f("select", {
4921
4788
  "onUpdate:modelValue": d[4] || (d[4] = (g) => m.value = g),
4922
4789
  class: "szd-select"
4923
4790
  }, [
4924
- d[23] || (d[23] = h("option", { value: null }, "Select instance...", -1)),
4925
- (A(!0), $(W, null, ce(Ye.value, (g) => (A(), $("option", {
4791
+ d[23] || (d[23] = f("option", { value: null }, "Select instance...", -1)),
4792
+ (A(!0), M(W, null, ce(Ze.value, (g) => (A(), M("option", {
4926
4793
  key: g,
4927
4794
  value: g
4928
- }, S(g), 9, $n))), 128))
4795
+ }, S(g), 9, kn))), 128))
4929
4796
  ], 512), [
4930
- [Ot, m.value]
4797
+ [At, m.value]
4931
4798
  ])
4932
4799
  ]),
4933
- m.value != null ? (A(), $("div", An, [
4934
- (A(!0), $(W, null, ce(me.value, (g) => (A(), $("div", {
4800
+ m.value != null ? (A(), M("div", bn, [
4801
+ (A(!0), M(W, null, ce(me.value, (g) => (A(), M("div", {
4935
4802
  key: g.id,
4936
4803
  class: "szd-data-card"
4937
4804
  }, [
4938
- h("div", On, [
4939
- Ve(S(g.label) + " ", 1),
4940
- g.pks.includes(m.value) ? (A(), $("span", Pn, "Present")) : (A(), $("span", Fn, "Absent"))
4805
+ f("div", En, [
4806
+ Qe(S(g.label) + " ", 1),
4807
+ g.pks.includes(m.value) ? (A(), M("span", Sn, "Present")) : (A(), M("span", Tn, "Absent"))
4941
4808
  ]),
4942
- h("pre", In, S(g.pks.includes(m.value) ? JSON.stringify(ye(m.value), null, 2) : "—"), 1)
4809
+ f("pre", Mn, S(g.pks.includes(m.value) ? JSON.stringify(ye(m.value), null, 2) : "—"), 1)
4943
4810
  ]))), 128))
4944
- ])) : (A(), $("div", Dn, "Select an instance to preview"))
4811
+ ])) : (A(), M("div", An, "Select an instance to preview"))
4945
4812
  ])
4946
- ])) : V("", !0),
4947
- t.value === "ast" ? (A(), $("div", zn, [
4948
- d[27] || (d[27] = h("h3", { class: "szd-panel__heading" }, "Query AST", -1)),
4949
- h("div", Kn, [
4950
- h("div", Rn, [
4951
- d[26] || (d[26] = h("span", { class: "szd-kv__key" }, "Semantic Key:", -1)),
4952
- h("code", Nn, S(k.value || "—"), 1)
4813
+ ])) : L("", !0),
4814
+ t.value === "ast" ? (A(), M("div", On, [
4815
+ d[27] || (d[27] = f("h3", { class: "szd-panel__heading" }, "Query AST", -1)),
4816
+ f("div", $n, [
4817
+ f("div", Fn, [
4818
+ d[26] || (d[26] = f("span", { class: "szd-kv__key" }, "Semantic Key:", -1)),
4819
+ f("code", Pn, S(E.value || "—"), 1)
4953
4820
  ])
4954
4821
  ]),
4955
- h("pre", xn, S(re.value ? JSON.stringify(re.value, null, 2) : "Select a queryset to view AST"), 1)
4956
- ])) : V("", !0)
4822
+ f("pre", Dn, S(re.value ? JSON.stringify(re.value, null, 2) : "Select a queryset to view AST"), 1)
4823
+ ])) : L("", !0)
4957
4824
  ]),
4958
- Mt(Pt, { name: "szd-slide" }, {
4959
- default: Ft(() => [
4960
- p.value ? (A(), $("div", jn, [
4961
- h("div", {
4825
+ St(Ot, { name: "szd-slide" }, {
4826
+ default: $t(() => [
4827
+ p.value ? (A(), M("div", zn, [
4828
+ f("div", {
4962
4829
  class: "szd-detail__backdrop",
4963
4830
  onClick: d[5] || (d[5] = (g) => p.value = !1)
4964
4831
  }),
4965
- h("div", Un, [
4966
- h("div", Qn, [
4967
- d[28] || (d[28] = h("h3", { class: "szd-detail__title" }, "Debug Settings", -1)),
4968
- h("button", {
4832
+ f("div", Rn, [
4833
+ f("div", Kn, [
4834
+ d[28] || (d[28] = f("h3", { class: "szd-detail__title" }, "Debug Settings", -1)),
4835
+ f("button", {
4969
4836
  class: "szd-btn",
4970
4837
  onClick: d[6] || (d[6] = (g) => p.value = !1)
4971
4838
  }, "Close")
4972
4839
  ]),
4973
- h("div", Vn, [
4974
- h("div", Ln, [
4975
- d[30] || (d[30] = h("label", { class: "szd-settings-label" }, "Queryset", -1)),
4976
- Qe(h("select", {
4840
+ f("div", In, [
4841
+ f("div", Nn, [
4842
+ d[30] || (d[30] = f("label", { class: "szd-settings-label" }, "Queryset", -1)),
4843
+ Ue(f("select", {
4977
4844
  "onUpdate:modelValue": d[7] || (d[7] = (g) => r.value = g),
4978
4845
  class: "szd-select szd-select--full"
4979
4846
  }, [
4980
- d[29] || (d[29] = h("option", { value: "" }, "Select queryset...", -1)),
4981
- (A(!0), $(W, null, ce(b.value, (g) => (A(), $("option", {
4847
+ d[29] || (d[29] = f("option", { value: "" }, "Select queryset...", -1)),
4848
+ (A(!0), M(W, null, ce(k.value, (g) => (A(), M("option", {
4982
4849
  key: g.semanticKey,
4983
4850
  value: g.semanticKey
4984
- }, S(g.modelName || "?") + " · " + S(g.semanticKey), 9, Gn))), 128))
4851
+ }, S(g.modelName || "?") + " · " + S(g.semanticKey), 9, xn))), 128))
4985
4852
  ], 512), [
4986
- [Ot, r.value]
4853
+ [At, r.value]
4987
4854
  ])
4988
4855
  ]),
4989
- k.value ? (A(), $("div", Bn, [
4990
- d[31] || (d[31] = h("label", { class: "szd-settings-label" }, "Semantic Key", -1)),
4991
- h("div", Hn, [
4992
- h("code", qn, S(k.value), 1),
4993
- h("button", {
4856
+ E.value ? (A(), M("div", jn, [
4857
+ d[31] || (d[31] = f("label", { class: "szd-settings-label" }, "Semantic Key", -1)),
4858
+ f("div", Un, [
4859
+ f("code", Qn, S(E.value), 1),
4860
+ f("button", {
4994
4861
  class: "szd-btn szd-btn--sm",
4995
- onClick: as
4862
+ onClick: is
4996
4863
  }, "Copy")
4997
4864
  ])
4998
- ])) : V("", !0),
4999
- h("div", Jn, [
5000
- d[32] || (d[32] = h("label", { class: "szd-settings-label" }, "Actions", -1)),
5001
- h("div", Wn, [
5002
- h("button", {
4865
+ ])) : L("", !0),
4866
+ f("div", Ln, [
4867
+ d[32] || (d[32] = f("label", { class: "szd-settings-label" }, "Actions", -1)),
4868
+ f("div", Vn, [
4869
+ f("button", {
5003
4870
  class: "szd-btn",
5004
- onClick: ls,
4871
+ onClick: as,
5005
4872
  disabled: !N.value || c.value
5006
- }, S(c.value ? "Syncing..." : "Sync Now"), 9, Zn),
5007
- h("button", {
4873
+ }, S(c.value ? "Syncing..." : "Sync Now"), 9, Bn),
4874
+ f("button", {
5008
4875
  class: "szd-btn",
5009
- onClick: is
4876
+ onClick: os
5010
4877
  }, "Clear Events")
5011
4878
  ])
5012
4879
  ]),
5013
- h("div", Yn, [
5014
- d[34] || (d[34] = h("label", { class: "szd-settings-label" }, "Options", -1)),
5015
- h("label", Xn, [
5016
- Qe(h("input", {
4880
+ f("div", Gn, [
4881
+ d[34] || (d[34] = f("label", { class: "szd-settings-label" }, "Options", -1)),
4882
+ f("label", Hn, [
4883
+ Ue(f("input", {
5017
4884
  type: "checkbox",
5018
4885
  "onUpdate:modelValue": d[8] || (d[8] = (g) => i.value = g)
5019
4886
  }, null, 512), [
5020
- [At, i.value]
4887
+ [Mt, i.value]
5021
4888
  ]),
5022
- d[33] || (d[33] = Ve(" Live updates ", -1))
4889
+ d[33] || (d[33] = Qe(" Live updates ", -1))
5023
4890
  ])
5024
4891
  ]),
5025
- k.value ? (A(), $("div", eo, [
5026
- d[40] || (d[40] = h("label", { class: "szd-settings-label" }, "Current State", -1)),
5027
- h("div", to, [
5028
- h("div", so, [
5029
- d[35] || (d[35] = h("span", { class: "szd-kv__key" }, "Model:", -1)),
5030
- h("span", ro, S(F.value.modelName || "—"), 1)
4892
+ E.value ? (A(), M("div", qn, [
4893
+ d[40] || (d[40] = f("label", { class: "szd-settings-label" }, "Current State", -1)),
4894
+ f("div", Jn, [
4895
+ f("div", Wn, [
4896
+ d[35] || (d[35] = f("span", { class: "szd-kv__key" }, "Model:", -1)),
4897
+ f("span", Zn, S(F.value.modelName || "—"), 1)
5031
4898
  ]),
5032
- h("div", no, [
5033
- d[36] || (d[36] = h("span", { class: "szd-kv__key" }, "Source:", -1)),
5034
- h("span", oo, S(F.value.source), 1)
4899
+ f("div", Yn, [
4900
+ d[36] || (d[36] = f("span", { class: "szd-kv__key" }, "Source:", -1)),
4901
+ f("span", Xn, S(F.value.source), 1)
5035
4902
  ]),
5036
- h("div", io, [
5037
- d[37] || (d[37] = h("span", { class: "szd-kv__key" }, "Syncing:", -1)),
5038
- h("span", ao, S(F.value.isSyncing ? "Yes" : "No"), 1)
4903
+ f("div", eo, [
4904
+ d[37] || (d[37] = f("span", { class: "szd-kv__key" }, "Syncing:", -1)),
4905
+ f("span", to, S(F.value.isSyncing ? "Yes" : "No"), 1)
5039
4906
  ]),
5040
- h("div", lo, [
5041
- d[38] || (d[38] = h("span", { class: "szd-kv__key" }, "Operations:", -1)),
5042
- h("span", co, S(F.value.opsCount), 1)
4907
+ f("div", so, [
4908
+ d[38] || (d[38] = f("span", { class: "szd-kv__key" }, "Operations:", -1)),
4909
+ f("span", ro, S(F.value.opsCount), 1)
5043
4910
  ]),
5044
- h("div", uo, [
5045
- d[39] || (d[39] = h("span", { class: "szd-kv__key" }, "Last Sync:", -1)),
5046
- h("span", ho, S(F.value.lastSync), 1)
4911
+ f("div", no, [
4912
+ d[39] || (d[39] = f("span", { class: "szd-kv__key" }, "Last Sync:", -1)),
4913
+ f("span", oo, S(F.value.lastSync), 1)
5047
4914
  ])
5048
4915
  ])
5049
- ])) : V("", !0)
4916
+ ])) : L("", !0)
5050
4917
  ])
5051
4918
  ])
5052
- ])) : V("", !0)
4919
+ ])) : L("", !0)
5053
4920
  ]),
5054
4921
  _: 1
5055
4922
  }),
5056
- Mt(Pt, { name: "szd-slide" }, {
5057
- default: Ft(() => [
5058
- f.value ? (A(), $("div", fo, [
5059
- h("div", {
4923
+ St(Ot, { name: "szd-slide" }, {
4924
+ default: $t(() => [
4925
+ h.value ? (A(), M("div", io, [
4926
+ f("div", {
5060
4927
  class: "szd-detail__backdrop",
5061
- onClick: St
4928
+ onClick: bt
5062
4929
  }),
5063
- h("div", po, [
5064
- h("div", mo, [
5065
- h("h3", yo, S(f.value.type === "entry" ? "Event Detail" : "Snapshot: " + f.value.data.label), 1),
5066
- h("button", {
4930
+ f("div", ao, [
4931
+ f("div", lo, [
4932
+ f("h3", co, S(h.value.type === "entry" ? "Event Detail" : "Snapshot: " + h.value.data.label), 1),
4933
+ f("button", {
5067
4934
  class: "szd-btn",
5068
- onClick: St
4935
+ onClick: bt
5069
4936
  }, "Close")
5070
4937
  ]),
5071
- h("div", go, [
5072
- f.value.type === "entry" ? (A(), $(W, { key: 0 }, [
5073
- h("div", _o, [
5074
- (A(!0), $(W, null, ce(os(f.value.data), (g, z) => (A(), $("div", {
5075
- key: z,
4938
+ f("div", uo, [
4939
+ h.value.type === "entry" ? (A(), M(W, { key: 0 }, [
4940
+ f("div", ho, [
4941
+ (A(!0), M(W, null, ce(ns(h.value.data), (g, R) => (A(), M("div", {
4942
+ key: R,
5076
4943
  class: "szd-kv__row"
5077
4944
  }, [
5078
- h("span", wo, S(z) + ":", 1),
5079
- h("span", Co, S(g ?? "—"), 1)
4945
+ f("span", fo, S(R) + ":", 1),
4946
+ f("span", po, S(g ?? "—"), 1)
5080
4947
  ]))), 128))
5081
4948
  ]),
5082
- d[41] || (d[41] = h("h4", { style: { margin: "16px 0 8px" } }, "Raw JSON", -1)),
5083
- h("pre", vo, S(JSON.stringify(f.value.data, null, 2)), 1)
5084
- ], 64)) : (A(), $(W, { key: 1 }, [
5085
- h("div", Eo, [
5086
- h("div", bo, [
5087
- d[42] || (d[42] = h("span", { class: "szd-kv__key" }, "Total Count:", -1)),
5088
- h("span", ko, S(f.value.data.count), 1)
4949
+ d[41] || (d[41] = f("h4", { style: { margin: "16px 0 8px" } }, "Raw JSON", -1)),
4950
+ f("pre", mo, S(JSON.stringify(h.value.data, null, 2)), 1)
4951
+ ], 64)) : (A(), M(W, { key: 1 }, [
4952
+ f("div", yo, [
4953
+ f("div", go, [
4954
+ d[42] || (d[42] = f("span", { class: "szd-kv__key" }, "Total Count:", -1)),
4955
+ f("span", _o, S(h.value.data.count), 1)
5089
4956
  ]),
5090
- h("div", So, [
5091
- d[43] || (d[43] = h("span", { class: "szd-kv__key" }, "Showing:", -1)),
5092
- h("span", To, [
5093
- Ve(S(Ke.value.length) + " items ", 1),
5094
- Xe.value ? (A(), $("span", Mo, "(limited to first 100)")) : V("", !0)
4957
+ f("div", wo, [
4958
+ d[43] || (d[43] = f("span", { class: "szd-kv__key" }, "Showing:", -1)),
4959
+ f("span", Co, [
4960
+ Qe(S(Re.value.length) + " items ", 1),
4961
+ Ye.value ? (A(), M("span", vo, "(limited to first 100)")) : L("", !0)
5095
4962
  ])
5096
4963
  ])
5097
4964
  ]),
5098
- d[44] || (d[44] = h("h4", { style: { margin: "0 0 8px" } }, "Data", -1)),
5099
- h("pre", $o, S(JSON.stringify(Ke.value, null, 2)), 1)
4965
+ d[44] || (d[44] = f("h4", { style: { margin: "0 0 8px" } }, "Data", -1)),
4966
+ f("pre", ko, S(JSON.stringify(Re.value, null, 2)), 1)
5100
4967
  ], 64))
5101
4968
  ])
5102
4969
  ])
5103
- ])) : V("", !0)
4970
+ ])) : L("", !0)
5104
4971
  ]),
5105
4972
  _: 1
5106
4973
  })
5107
4974
  ]));
5108
4975
  }
5109
- }, Bo = /* @__PURE__ */ kr(Ao, [["__scopeId", "data-v-6d80920c"]]);
4976
+ }, jo = /* @__PURE__ */ _r(bo, [["__scopeId", "data-v-cf94aafd"]]);
5110
4977
  export {
5111
- Bo as default
4978
+ jo as default
5112
4979
  };