@coasys/ad4m-connect 0.13.1-staging.5 → 0.13.1-staging.7

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.
package/dist/core.js CHANGED
@@ -39,7 +39,7 @@ var __async = (__this, __arguments, generator) => {
39
39
  };
40
40
 
41
41
  // ../package.json
42
- var version = "0.13.1-staging.5";
42
+ var version = "0.13.1-staging.7";
43
43
 
44
44
  // src/utils.ts
45
45
  function isEmbedded() {
@@ -281,6 +281,12 @@ var READ_METHODS = /* @__PURE__ */ new Set([
281
281
  "hosting.info",
282
282
  "hosting.wallet",
283
283
  "hosting.walletHistory",
284
+ "identity.devices",
285
+ "identity.joinStatus",
286
+ "identity.log",
287
+ "identity.offers",
288
+ "identity.resolve",
289
+ "identity.status",
284
290
  "language.all",
285
291
  "language.get",
286
292
  "language.meta",
@@ -368,6 +374,19 @@ var INITIAL_RECONNECT_DELAY_MS = 500;
368
374
  var MAX_RECONNECT_DELAY_MS = 3e4;
369
375
  var WATCH_RETRY_DELAY_MS = 1e3;
370
376
  var MAX_WATCH_RETRIES = 5;
377
+ var PING_INTERVAL_MS = 1e4;
378
+ var SLOWEST_LINK_BYTES_PER_MS = 16;
379
+ var PONG_RETURN_MS = 5e3;
380
+ var CHECK_CONNECTION_DEADLINE_MS = 2e3;
381
+ function utf8Length(text) {
382
+ let bytes = text.length;
383
+ for (let i = 0; i < text.length; i++) {
384
+ const unit = text.charCodeAt(i);
385
+ if (unit >= 128)
386
+ bytes += unit < 2048 || unit >= 55296 && unit <= 57343 ? 1 : 2;
387
+ }
388
+ return bytes;
389
+ }
371
390
  var _idCounter2 = 0;
372
391
  function nextId() {
373
392
  return String(++_idCounter2);
@@ -389,12 +408,26 @@ var ApiClient = class {
389
408
  this._wsReconnectTimer = null;
390
409
  this._wsReconnectDelay = INITIAL_RECONNECT_DELAY_MS;
391
410
  this._wsPingTimer = null;
411
+ this._wsPingedAt = null;
412
+ this._wsPingArrivesBy = 0;
413
+ this._wsSentBy = 0;
414
+ this._wsProbeTimer = null;
392
415
  this._watching = "{}";
393
416
  this._watchScheduled = false;
394
417
  this._watchDone = Promise.resolve();
395
418
  this._watchSent = Promise.resolve();
396
419
  this._watchRetries = 0;
397
420
  this._watchRetryTimer = null;
421
+ this._networkCallbacks = /* @__PURE__ */ new Set();
422
+ this._unlistenNetwork = null;
423
+ this._networkChanged = false;
424
+ this._networkDial = null;
425
+ this._wakeListening = false;
426
+ this._onWake = (event) => {
427
+ if (event.type === "visibilitychange" && typeof document !== "undefined" && document.visibilityState !== "visible")
428
+ return;
429
+ this.reconnectNow();
430
+ };
398
431
  this.baseUrl = baseUrl;
399
432
  this.token = token;
400
433
  this._webSocketImpl = webSocketImpl;
@@ -419,6 +452,8 @@ var ApiClient = class {
419
452
  return;
420
453
  if (this._authFailed !== null)
421
454
  throw new RpcError(401, this._authFailed);
455
+ this._listenForNetworkChanges();
456
+ this._cancelReconnect();
422
457
  const WsImpl = this._webSocketImpl ?? globalThis.WebSocket;
423
458
  const ws = new WsImpl(this._getWsUrl());
424
459
  this._ws = ws;
@@ -439,6 +474,10 @@ var ApiClient = class {
439
474
  this._wsOpen.catch(() => {
440
475
  });
441
476
  ws.onmessage = (event) => {
477
+ if (this._ws === ws) {
478
+ this._wsPingedAt = null;
479
+ this._endProbe();
480
+ }
442
481
  let parsed;
443
482
  try {
444
483
  parsed = JSON.parse(event.data);
@@ -461,7 +500,7 @@ var ApiClient = class {
461
500
  this._failAuth(rpcError.body);
462
501
  return;
463
502
  }
464
- if (parsed.type === "pong")
503
+ if (parsed.type === "pong" || this._ws !== ws)
465
504
  return;
466
505
  const perspective = parsed.perspectiveUuid;
467
506
  const regs = this._handlers.get(parsed.type);
@@ -481,13 +520,13 @@ var ApiClient = class {
481
520
  if (this._ws !== ws)
482
521
  return;
483
522
  this._wsReconnectDelay = INITIAL_RECONNECT_DELAY_MS;
484
- this._startPing();
523
+ this._startPing(ws);
485
524
  this._watching = "{}";
486
525
  this._watchRetries = 0;
487
526
  this._flushWatch();
488
527
  for (const pending of this._pendingCalls.values()) {
489
528
  if (!pending.sent) {
490
- ws.send(pending.message);
529
+ this._send(ws, pending.message);
491
530
  pending.sent = true;
492
531
  }
493
532
  }
@@ -501,6 +540,56 @@ var ApiClient = class {
501
540
  }
502
541
  }
503
542
  this._hasConnectedOnce = true;
543
+ if (this._networkChanged) {
544
+ this._networkChanged = false;
545
+ this._notifyNetworkChange();
546
+ }
547
+ }
548
+ _listenForNetworkChanges() {
549
+ if (this._unlistenNetwork)
550
+ return;
551
+ const handler = () => this._onNetworkChange();
552
+ const removers = [];
553
+ const target = globalThis;
554
+ if (typeof target.addEventListener === "function") {
555
+ target.addEventListener("online", handler);
556
+ removers.push(() => target.removeEventListener?.("online", handler));
557
+ }
558
+ const connection = globalThis.navigator?.connection;
559
+ if (typeof connection?.addEventListener === "function") {
560
+ const probe = () => this.checkConnection();
561
+ connection.addEventListener("change", probe);
562
+ removers.push(() => connection.removeEventListener?.("change", probe));
563
+ }
564
+ this._unlistenNetwork = () => {
565
+ for (const remove of removers)
566
+ remove();
567
+ };
568
+ }
569
+ _onNetworkChange() {
570
+ if (this._authFailed !== null)
571
+ return;
572
+ const ws = this._ws;
573
+ if (ws && ws === this._networkDial && ws.readyState === 0)
574
+ return;
575
+ if (ws) {
576
+ console.info("Network changed; reconnecting the WebSocket");
577
+ this._onClose(ws);
578
+ ws.close();
579
+ }
580
+ this._cancelReconnect();
581
+ this._wsReconnectDelay = INITIAL_RECONNECT_DELAY_MS;
582
+ if (this._handlers.size === 0 && this._pendingCalls.size === 0) {
583
+ this._notifyNetworkChange();
584
+ return;
585
+ }
586
+ this._networkChanged = true;
587
+ this._ensureWs();
588
+ this._networkDial = this._ws;
589
+ }
590
+ _notifyNetworkChange() {
591
+ for (const cb of [...this._networkCallbacks])
592
+ callSafely(cb, "Error in network-change callback:");
504
593
  }
505
594
  _onClose(ws, reason) {
506
595
  if (this._ws !== ws)
@@ -532,19 +621,51 @@ var ApiClient = class {
532
621
  for (const cb of [...this._authFailedCallbacks])
533
622
  callSafely(cb, "Error in auth-failed callback:", reason);
534
623
  }
535
- _startPing() {
624
+ _startPing(ws) {
536
625
  this._stopPing();
626
+ this._wsPingedAt = null;
627
+ this._wsSentBy = 0;
537
628
  this._wsPingTimer = setInterval(() => {
538
- if (this._ws?.readyState === 1) {
539
- this._ws.send(JSON.stringify({ type: "ping" }));
629
+ if (this._ws !== ws)
630
+ return;
631
+ if (this._wsProbeTimer)
632
+ return;
633
+ const ping = JSON.stringify({ type: "ping" });
634
+ if (this._wsPingedAt === null) {
635
+ this._wsPingedAt = performance.now();
636
+ this._send(ws, ping);
637
+ this._wsPingArrivesBy = this._wsSentBy;
638
+ return;
540
639
  }
541
- }, 3e4);
640
+ if (performance.now() >= Math.max(this._wsPingedAt + PING_INTERVAL_MS, this._wsPingArrivesBy + PONG_RETURN_MS)) {
641
+ this._dropSilentSocket(ws);
642
+ return;
643
+ }
644
+ this._send(ws, ping);
645
+ }, PING_INTERVAL_MS);
646
+ }
647
+ _send(ws, text) {
648
+ if (this._ws === ws)
649
+ this._wsSentBy = Math.max(this._wsSentBy, performance.now()) + utf8Length(text) / SLOWEST_LINK_BYTES_PER_MS;
650
+ ws.send(text);
651
+ }
652
+ _dropSilentSocket(ws) {
653
+ console.warn(`WebSocket silent for ${performance.now() - (this._wsPingedAt ?? performance.now())} ms after a ping; reconnecting`);
654
+ this._onClose(ws);
655
+ ws.close();
542
656
  }
543
657
  _stopPing() {
544
658
  if (this._wsPingTimer) {
545
659
  clearInterval(this._wsPingTimer);
546
660
  this._wsPingTimer = null;
547
661
  }
662
+ this._endProbe();
663
+ }
664
+ _endProbe() {
665
+ if (this._wsProbeTimer) {
666
+ clearTimeout(this._wsProbeTimer);
667
+ this._wsProbeTimer = null;
668
+ }
548
669
  }
549
670
  _scheduleReconnect() {
550
671
  if (this._wsReconnectTimer || this._authFailed !== null)
@@ -553,8 +674,40 @@ var ApiClient = class {
553
674
  this._wsReconnectDelay = Math.min(this._wsReconnectDelay * 2, MAX_RECONNECT_DELAY_MS);
554
675
  this._wsReconnectTimer = setTimeout(() => {
555
676
  this._wsReconnectTimer = null;
677
+ this._listenForWake(false);
556
678
  this._ensureWs();
557
679
  }, delay);
680
+ this._listenForWake(true);
681
+ }
682
+ _cancelReconnect() {
683
+ if (this._wsReconnectTimer) {
684
+ clearTimeout(this._wsReconnectTimer);
685
+ this._wsReconnectTimer = null;
686
+ }
687
+ this._listenForWake(false);
688
+ }
689
+ reconnectNow() {
690
+ if (!this._wsReconnectTimer || this._ws || this._authFailed !== null)
691
+ return;
692
+ this._cancelReconnect();
693
+ this._wsReconnectDelay = INITIAL_RECONNECT_DELAY_MS;
694
+ this._ensureWs();
695
+ }
696
+ _listenForWake(on) {
697
+ if (on === this._wakeListening)
698
+ return;
699
+ const win = typeof window !== "undefined" ? window : void 0;
700
+ if (typeof win?.addEventListener !== "function")
701
+ return;
702
+ const doc = typeof document !== "undefined" && typeof document.addEventListener === "function" ? document : void 0;
703
+ this._wakeListening = on;
704
+ if (on) {
705
+ win.addEventListener("online", this._onWake);
706
+ doc?.addEventListener("visibilitychange", this._onWake);
707
+ } else {
708
+ win.removeEventListener("online", this._onWake);
709
+ doc?.removeEventListener("visibilitychange", this._onWake);
710
+ }
558
711
  }
559
712
  call(method, params, options) {
560
713
  this._flushWatch();
@@ -586,7 +739,7 @@ var ApiClient = class {
586
739
  }, timeoutMs);
587
740
  const onAbort = () => {
588
741
  if (pending.sent && this._ws?.readyState === 1) {
589
- this._ws.send(JSON.stringify({ id: nextId(), type: "request.cancel", params: { targetId: id } }));
742
+ this._send(this._ws, JSON.stringify({ id: nextId(), type: "request.cancel", params: { targetId: id } }));
590
743
  }
591
744
  settle(() => reject(new DOMException("Aborted", "AbortError")));
592
745
  };
@@ -608,7 +761,7 @@ var ApiClient = class {
608
761
  return;
609
762
  }
610
763
  if (this._ws.readyState === 1) {
611
- this._ws.send(message);
764
+ this._send(this._ws, message);
612
765
  pending.sent = true;
613
766
  }
614
767
  });
@@ -708,10 +861,7 @@ var ApiClient = class {
708
861
  clearTimeout(this._watchRetryTimer);
709
862
  this._watchRetryTimer = null;
710
863
  }
711
- if (this._wsReconnectTimer) {
712
- clearTimeout(this._wsReconnectTimer);
713
- this._wsReconnectTimer = null;
714
- }
864
+ this._cancelReconnect();
715
865
  const ws = this._ws;
716
866
  this._ws = null;
717
867
  this._wsOpen = null;
@@ -723,6 +873,32 @@ var ApiClient = class {
723
873
  this._reconnectCallbacks.delete(callback);
724
874
  };
725
875
  }
876
+ onNetworkChange(callback) {
877
+ this._networkCallbacks.add(callback);
878
+ this._listenForNetworkChanges();
879
+ return () => {
880
+ this._networkCallbacks.delete(callback);
881
+ };
882
+ }
883
+ checkConnection(deadlineMs = CHECK_CONNECTION_DEADLINE_MS) {
884
+ const ws = this._ws;
885
+ if (!ws || ws.readyState !== 1 || this._wsProbeTimer)
886
+ return;
887
+ const first = this._wsPingedAt === null;
888
+ if (first)
889
+ this._wsPingedAt = performance.now();
890
+ this._send(ws, JSON.stringify({ type: "ping" }));
891
+ if (first)
892
+ this._wsPingArrivesBy = this._wsSentBy;
893
+ const wait = Math.max(deadlineMs, this._wsSentBy - performance.now() + deadlineMs / 2);
894
+ this._wsProbeTimer = setTimeout(() => {
895
+ this._wsProbeTimer = null;
896
+ if (this._ws !== ws)
897
+ return;
898
+ console.warn(`WebSocket silent for ${wait} ms after a check; reconnecting`);
899
+ this._onNetworkChange();
900
+ }, wait);
901
+ }
726
902
  onAuthFailed(callback) {
727
903
  this._authFailedCallbacks.add(callback);
728
904
  return () => {
@@ -737,6 +913,11 @@ var ApiClient = class {
737
913
  this._handlers.clear();
738
914
  this._reconnectCallbacks.clear();
739
915
  this._authFailedCallbacks.clear();
916
+ this._networkCallbacks.clear();
917
+ this._unlistenNetwork?.();
918
+ this._unlistenNetwork = null;
919
+ this._networkChanged = false;
920
+ this._networkDial = null;
740
921
  this._hasConnectedOnce = false;
741
922
  }
742
923
  };
@@ -899,6 +1080,9 @@ var Agent = class {
899
1080
  static fromWire(wire) {
900
1081
  const agent = new Agent(wire.did, Perspective.fromWire(wire.perspective));
901
1082
  agent.directMessageLanguage = wire.directMessageLanguage;
1083
+ if ("identity" in wire && wire.identity) {
1084
+ agent.identity = wire.identity;
1085
+ }
902
1086
  return agent;
903
1087
  }
904
1088
  };
@@ -926,13 +1110,14 @@ var AgentStatus = class {
926
1110
  this.did = obj.did;
927
1111
  this.didDocument = obj.didDocument;
928
1112
  this.error = obj.error;
1113
+ this.identity = obj.identity ?? null;
929
1114
  } else {
930
1115
  this.isInitialized = false;
931
1116
  this.isUnlocked = false;
932
1117
  }
933
1118
  }
934
1119
  };
935
- var __classPrivateFieldSet$d = function(receiver, state, value, kind, f) {
1120
+ var __classPrivateFieldSet$e = function(receiver, state, value, kind, f) {
936
1121
  if (kind === "m")
937
1122
  throw new TypeError("Private method is not writable");
938
1123
  if (kind === "a" && !f)
@@ -941,7 +1126,7 @@ var __classPrivateFieldSet$d = function(receiver, state, value, kind, f) {
941
1126
  throw new TypeError("Cannot write private member to an object whose class did not declare it");
942
1127
  return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
943
1128
  };
944
- var __classPrivateFieldGet$d = function(receiver, state, kind, f) {
1129
+ var __classPrivateFieldGet$e = function(receiver, state, kind, f) {
945
1130
  if (kind === "a" && !f)
946
1131
  throw new TypeError("Private accessor was defined without a getter");
947
1132
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
@@ -961,15 +1146,15 @@ var IDBCache = class {
961
1146
  _IDBCache_storeName.set(this, void 0);
962
1147
  _IDBCache_dbPromise.set(this, null);
963
1148
  _IDBCache_version.set(this, 1);
964
- __classPrivateFieldSet$d(this, _IDBCache_dbName, dbName, "f");
965
- __classPrivateFieldSet$d(this, _IDBCache_storeName, storeName, "f");
1149
+ __classPrivateFieldSet$e(this, _IDBCache_dbName, dbName, "f");
1150
+ __classPrivateFieldSet$e(this, _IDBCache_storeName, storeName, "f");
966
1151
  }
967
1152
  async get(key) {
968
1153
  try {
969
- const db = await __classPrivateFieldGet$d(this, _IDBCache_instances, "m", _IDBCache_open).call(this);
1154
+ const db = await __classPrivateFieldGet$e(this, _IDBCache_instances, "m", _IDBCache_open).call(this);
970
1155
  return new Promise((resolve) => {
971
- const tx = db.transaction(__classPrivateFieldGet$d(this, _IDBCache_storeName, "f"), "readonly");
972
- const store = tx.objectStore(__classPrivateFieldGet$d(this, _IDBCache_storeName, "f"));
1156
+ const tx = db.transaction(__classPrivateFieldGet$e(this, _IDBCache_storeName, "f"), "readonly");
1157
+ const store = tx.objectStore(__classPrivateFieldGet$e(this, _IDBCache_storeName, "f"));
973
1158
  const req = store.get(key);
974
1159
  req.onsuccess = () => resolve(req.result ?? void 0);
975
1160
  req.onerror = () => resolve(void 0);
@@ -980,10 +1165,10 @@ var IDBCache = class {
980
1165
  }
981
1166
  async put(key, value) {
982
1167
  try {
983
- const db = await __classPrivateFieldGet$d(this, _IDBCache_instances, "m", _IDBCache_open).call(this);
1168
+ const db = await __classPrivateFieldGet$e(this, _IDBCache_instances, "m", _IDBCache_open).call(this);
984
1169
  return new Promise((resolve) => {
985
- const tx = db.transaction(__classPrivateFieldGet$d(this, _IDBCache_storeName, "f"), "readwrite");
986
- const store = tx.objectStore(__classPrivateFieldGet$d(this, _IDBCache_storeName, "f"));
1170
+ const tx = db.transaction(__classPrivateFieldGet$e(this, _IDBCache_storeName, "f"), "readwrite");
1171
+ const store = tx.objectStore(__classPrivateFieldGet$e(this, _IDBCache_storeName, "f"));
987
1172
  store.put(value, key);
988
1173
  tx.oncomplete = () => resolve();
989
1174
  tx.onerror = () => resolve();
@@ -993,10 +1178,10 @@ var IDBCache = class {
993
1178
  }
994
1179
  async delete(key) {
995
1180
  try {
996
- const db = await __classPrivateFieldGet$d(this, _IDBCache_instances, "m", _IDBCache_open).call(this);
1181
+ const db = await __classPrivateFieldGet$e(this, _IDBCache_instances, "m", _IDBCache_open).call(this);
997
1182
  return new Promise((resolve) => {
998
- const tx = db.transaction(__classPrivateFieldGet$d(this, _IDBCache_storeName, "f"), "readwrite");
999
- const store = tx.objectStore(__classPrivateFieldGet$d(this, _IDBCache_storeName, "f"));
1183
+ const tx = db.transaction(__classPrivateFieldGet$e(this, _IDBCache_storeName, "f"), "readwrite");
1184
+ const store = tx.objectStore(__classPrivateFieldGet$e(this, _IDBCache_storeName, "f"));
1000
1185
  store.delete(key);
1001
1186
  tx.oncomplete = () => resolve();
1002
1187
  tx.onerror = () => resolve();
@@ -1006,10 +1191,10 @@ var IDBCache = class {
1006
1191
  }
1007
1192
  async clear() {
1008
1193
  try {
1009
- const db = await __classPrivateFieldGet$d(this, _IDBCache_instances, "m", _IDBCache_open).call(this);
1194
+ const db = await __classPrivateFieldGet$e(this, _IDBCache_instances, "m", _IDBCache_open).call(this);
1010
1195
  return new Promise((resolve) => {
1011
- const tx = db.transaction(__classPrivateFieldGet$d(this, _IDBCache_storeName, "f"), "readwrite");
1012
- const store = tx.objectStore(__classPrivateFieldGet$d(this, _IDBCache_storeName, "f"));
1196
+ const tx = db.transaction(__classPrivateFieldGet$e(this, _IDBCache_storeName, "f"), "readwrite");
1197
+ const store = tx.objectStore(__classPrivateFieldGet$e(this, _IDBCache_storeName, "f"));
1013
1198
  store.clear();
1014
1199
  tx.oncomplete = () => resolve();
1015
1200
  tx.onerror = () => resolve();
@@ -1019,10 +1204,10 @@ var IDBCache = class {
1019
1204
  }
1020
1205
  };
1021
1206
  _IDBCache_dbName = /* @__PURE__ */ new WeakMap(), _IDBCache_storeName = /* @__PURE__ */ new WeakMap(), _IDBCache_dbPromise = /* @__PURE__ */ new WeakMap(), _IDBCache_version = /* @__PURE__ */ new WeakMap(), _IDBCache_instances = /* @__PURE__ */ new WeakSet(), _IDBCache_open = function _IDBCache_open2() {
1022
- if (!__classPrivateFieldGet$d(this, _IDBCache_dbPromise, "f")) {
1023
- __classPrivateFieldSet$d(this, _IDBCache_dbPromise, new Promise((resolve, reject) => {
1024
- const storeName = __classPrivateFieldGet$d(this, _IDBCache_storeName, "f");
1025
- const req = indexedDB.open(__classPrivateFieldGet$d(this, _IDBCache_dbName, "f"), __classPrivateFieldGet$d(this, _IDBCache_version, "f"));
1207
+ if (!__classPrivateFieldGet$e(this, _IDBCache_dbPromise, "f")) {
1208
+ __classPrivateFieldSet$e(this, _IDBCache_dbPromise, new Promise((resolve, reject) => {
1209
+ const storeName = __classPrivateFieldGet$e(this, _IDBCache_storeName, "f");
1210
+ const req = indexedDB.open(__classPrivateFieldGet$e(this, _IDBCache_dbName, "f"), __classPrivateFieldGet$e(this, _IDBCache_version, "f"));
1026
1211
  req.onupgradeneeded = () => {
1027
1212
  const db = req.result;
1028
1213
  if (!db.objectStoreNames.contains(storeName)) {
@@ -1033,7 +1218,7 @@ _IDBCache_dbName = /* @__PURE__ */ new WeakMap(), _IDBCache_storeName = /* @__PU
1033
1218
  req.onerror = () => reject(req.error);
1034
1219
  }), "f");
1035
1220
  }
1036
- return __classPrivateFieldGet$d(this, _IDBCache_dbPromise, "f");
1221
+ return __classPrivateFieldGet$e(this, _IDBCache_dbPromise, "f");
1037
1222
  };
1038
1223
  var NullCache = class {
1039
1224
  async get(_key) {
@@ -1055,7 +1240,7 @@ function createPersistentCache(dbName, storeName) {
1055
1240
  }
1056
1241
  return new NullCache();
1057
1242
  }
1058
- var __classPrivateFieldSet$c = function(receiver, state, value, kind, f) {
1243
+ var __classPrivateFieldSet$d = function(receiver, state, value, kind, f) {
1059
1244
  if (kind === "m")
1060
1245
  throw new TypeError("Private method is not writable");
1061
1246
  if (kind === "a" && !f)
@@ -1064,7 +1249,7 @@ var __classPrivateFieldSet$c = function(receiver, state, value, kind, f) {
1064
1249
  throw new TypeError("Cannot write private member to an object whose class did not declare it");
1065
1250
  return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
1066
1251
  };
1067
- var __classPrivateFieldGet$c = function(receiver, state, kind, f) {
1252
+ var __classPrivateFieldGet$d = function(receiver, state, kind, f) {
1068
1253
  if (kind === "a" && !f)
1069
1254
  throw new TypeError("Private accessor was defined without a getter");
1070
1255
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
@@ -1091,74 +1276,74 @@ var AgentClient = class {
1091
1276
  _AgentClient_persistent.set(this, void 0);
1092
1277
  _AgentClient_selfDid.set(this, null);
1093
1278
  _AgentClient_onAgentUpdated.set(this, (event) => {
1094
- __classPrivateFieldGet$c(this, _AgentClient_instances, "m", _AgentClient_cacheAgent).call(this, Agent.fromWire(event.agent));
1279
+ __classPrivateFieldGet$d(this, _AgentClient_instances, "m", _AgentClient_cacheAgent).call(this, Agent.fromWire(event.agent));
1095
1280
  });
1096
- __classPrivateFieldSet$c(this, _AgentClient_apiClient, sharedApiClient || new ApiClient(baseUrl, token), "f");
1097
- __classPrivateFieldSet$c(this, _AgentClient_persistent, createPersistentCache("ad4m-agent-cache", "agents"), "f");
1281
+ __classPrivateFieldSet$d(this, _AgentClient_apiClient, sharedApiClient || new ApiClient(baseUrl, token), "f");
1282
+ __classPrivateFieldSet$d(this, _AgentClient_persistent, createPersistentCache("ad4m-agent-cache", "agents"), "f");
1098
1283
  }
1099
1284
  async me() {
1100
- const agentObject = toAgent(await __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call("agent.get", {}));
1101
- if (agentObject.did && !__classPrivateFieldGet$c(this, _AgentClient_selfDid, "f")) {
1102
- __classPrivateFieldSet$c(this, _AgentClient_selfDid, agentObject.did, "f");
1285
+ const agentObject = toAgent(await __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call("agent.get", {}));
1286
+ if (agentObject.did && !__classPrivateFieldGet$d(this, _AgentClient_selfDid, "f")) {
1287
+ __classPrivateFieldSet$d(this, _AgentClient_selfDid, agentObject.did, "f");
1103
1288
  }
1104
1289
  return agentObject;
1105
1290
  }
1106
1291
  async status() {
1107
- const agentStatus = await __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call("agent.status", {});
1292
+ const agentStatus = await __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call("agent.status", {});
1108
1293
  return new AgentStatus(agentStatus);
1109
1294
  }
1110
1295
  async generate(passphrase, options) {
1111
- const result = await __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call("agent.generate", { passphrase }, options);
1296
+ const result = await __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call("agent.generate", { passphrase }, options);
1112
1297
  return new AgentStatus(result);
1113
1298
  }
1114
1299
  async import(args) {
1115
- const result = await __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call("agent.import", { ...args });
1300
+ const result = await __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call("agent.import", { ...args });
1116
1301
  return new AgentStatus(result);
1117
1302
  }
1118
1303
  async lock(passphrase) {
1119
- const result = await __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call("agent.lock", { passphrase });
1304
+ const result = await __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call("agent.lock", { passphrase });
1120
1305
  return new AgentStatus(result);
1121
1306
  }
1122
1307
  async unlock(passphrase, holochain = true, options) {
1123
- const result = await __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call("agent.unlock", { passphrase, holochain }, options);
1308
+ const result = await __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call("agent.unlock", { passphrase, holochain }, options);
1124
1309
  return new AgentStatus(result);
1125
1310
  }
1126
1311
  async byDID(did) {
1127
- __classPrivateFieldGet$c(this, _AgentClient_instances, "m", _AgentClient_listen).call(this);
1312
+ __classPrivateFieldGet$d(this, _AgentClient_instances, "m", _AgentClient_listen).call(this);
1128
1313
  const now = Date.now();
1129
- const cached = __classPrivateFieldGet$c(this, _AgentClient_memCache, "f").get(did);
1314
+ const cached = __classPrivateFieldGet$d(this, _AgentClient_memCache, "f").get(did);
1130
1315
  if (cached) {
1131
- const isSelf = did === __classPrivateFieldGet$c(this, _AgentClient_selfDid, "f");
1316
+ const isSelf = did === __classPrivateFieldGet$d(this, _AgentClient_selfDid, "f");
1132
1317
  if (isSelf || now - cached.ts < AgentClient.REMOTE_AGENT_TTL_MS) {
1133
1318
  return cached.promise;
1134
1319
  }
1135
1320
  }
1136
1321
  const promise = (async () => {
1137
- const entry = await __classPrivateFieldGet$c(this, _AgentClient_persistent, "f").get(did);
1322
+ const entry = await __classPrivateFieldGet$d(this, _AgentClient_persistent, "f").get(did);
1138
1323
  if (entry?.agent && now - (entry.ts ?? 0) < AgentClient.REMOTE_AGENT_TTL_L2_MS) {
1139
1324
  return entry.agent;
1140
1325
  }
1141
- const result = toAgent(await __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call("agent.byDid", { did }));
1142
- __classPrivateFieldGet$c(this, _AgentClient_persistent, "f").put(did, { agent: result, ts: Date.now() });
1326
+ const result = toAgent(await __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call("agent.byDid", { did }));
1327
+ __classPrivateFieldGet$d(this, _AgentClient_persistent, "f").put(did, { agent: result, ts: Date.now() });
1143
1328
  return result;
1144
1329
  })();
1145
- __classPrivateFieldGet$c(this, _AgentClient_memCache, "f").set(did, { promise, ts: now });
1330
+ __classPrivateFieldGet$d(this, _AgentClient_memCache, "f").set(did, { promise, ts: now });
1146
1331
  promise.catch(() => {
1147
- if (__classPrivateFieldGet$c(this, _AgentClient_memCache, "f").get(did)?.promise === promise) {
1148
- __classPrivateFieldGet$c(this, _AgentClient_memCache, "f").delete(did);
1332
+ if (__classPrivateFieldGet$d(this, _AgentClient_memCache, "f").get(did)?.promise === promise) {
1333
+ __classPrivateFieldGet$d(this, _AgentClient_memCache, "f").delete(did);
1149
1334
  }
1150
1335
  });
1151
1336
  return promise;
1152
1337
  }
1153
1338
  setSelfDid(did) {
1154
- __classPrivateFieldSet$c(this, _AgentClient_selfDid, did, "f");
1339
+ __classPrivateFieldSet$d(this, _AgentClient_selfDid, did, "f");
1155
1340
  }
1156
1341
  invalidateByDid(did) {
1157
- __classPrivateFieldGet$c(this, _AgentClient_memCache, "f").delete(did);
1158
- __classPrivateFieldGet$c(this, _AgentClient_persistent, "f").delete(did);
1342
+ __classPrivateFieldGet$d(this, _AgentClient_memCache, "f").delete(did);
1343
+ __classPrivateFieldGet$d(this, _AgentClient_persistent, "f").delete(did);
1159
1344
  }
1160
1345
  clearByDidCache() {
1161
- __classPrivateFieldGet$c(this, _AgentClient_memCache, "f").clear();
1346
+ __classPrivateFieldGet$d(this, _AgentClient_memCache, "f").clear();
1162
1347
  }
1163
1348
  async updatePublicPerspective(perspective) {
1164
1349
  const publicPerspective = {
@@ -1169,77 +1354,77 @@ var AgentClient = class {
1169
1354
  proof: { key: proof.key, signature: proof.signature, valid: proof.valid, invalid: proof.invalid }
1170
1355
  }))
1171
1356
  };
1172
- const agent = toAgent(await __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call("agent.updateProfile", { publicPerspective }));
1173
- __classPrivateFieldGet$c(this, _AgentClient_instances, "m", _AgentClient_cacheAgent).call(this, agent);
1357
+ const agent = toAgent(await __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call("agent.updateProfile", { publicPerspective }));
1358
+ __classPrivateFieldGet$d(this, _AgentClient_instances, "m", _AgentClient_cacheAgent).call(this, agent);
1174
1359
  return agent;
1175
1360
  }
1176
1361
  async mutatePublicPerspective({ additions, removals }) {
1177
- const added = additions.length > 0 ? await __classPrivateFieldGet$c(this, _AgentClient_instances, "m", _AgentClient_signLinks).call(this, additions) : [];
1362
+ const added = additions.length > 0 ? await __classPrivateFieldGet$d(this, _AgentClient_instances, "m", _AgentClient_signLinks).call(this, additions) : [];
1178
1363
  const { perspective } = await this.me();
1179
1364
  const kept = (perspective?.links ?? []).filter((link) => !removals.some((r) => linkEqual(link, r)));
1180
1365
  return this.updatePublicPerspective({ links: [...kept, ...added] });
1181
1366
  }
1182
1367
  async updateDirectMessageLanguage(directMessageLanguage) {
1183
- const agent = toAgent(await __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call("agent.updateProfile", { dmLanguage: directMessageLanguage }));
1184
- __classPrivateFieldGet$c(this, _AgentClient_instances, "m", _AgentClient_cacheAgent).call(this, agent);
1368
+ const agent = toAgent(await __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call("agent.updateProfile", { dmLanguage: directMessageLanguage }));
1369
+ __classPrivateFieldGet$d(this, _AgentClient_instances, "m", _AgentClient_cacheAgent).call(this, agent);
1185
1370
  return agent;
1186
1371
  }
1187
1372
  async addEntanglementProofs(proofs) {
1188
- return __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call("agent.addEntanglementProofs", { proofs });
1373
+ return __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call("agent.addEntanglementProofs", { proofs });
1189
1374
  }
1190
1375
  async deleteEntanglementProofs(proofs) {
1191
- return __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call("agent.deleteEntanglementProofs", { proofs });
1376
+ return __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call("agent.deleteEntanglementProofs", { proofs });
1192
1377
  }
1193
1378
  async getEntanglementProofs() {
1194
- return __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call("agent.getEntanglementProofs", {});
1379
+ return __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call("agent.getEntanglementProofs", {});
1195
1380
  }
1196
1381
  async entanglementProofPreFlight(deviceKey, deviceKeyType) {
1197
- return __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call("agent.entanglementProofPreflight", { deviceKey, deviceKeyType });
1382
+ return __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call("agent.entanglementProofPreflight", { deviceKey, deviceKeyType });
1198
1383
  }
1199
1384
  async requestCapability(authInfo, agent) {
1200
- return __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call("agent.requestCapability", agent === void 0 ? { authInfo } : { authInfo, agent });
1385
+ return __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call("agent.requestCapability", agent === void 0 ? { authInfo } : { authInfo, agent });
1201
1386
  }
1202
1387
  async permitCapability(auth) {
1203
- return __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call("agent.permitCapability", { auth });
1388
+ return __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call("agent.permitCapability", { auth });
1204
1389
  }
1205
1390
  async generateJwt(requestId, rand) {
1206
- return __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call("agent.generateJwt", { requestId, rand });
1391
+ return __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call("agent.generateJwt", { requestId, rand });
1207
1392
  }
1208
1393
  async getApps() {
1209
- return __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call("agent.getApps", {});
1394
+ return __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call("agent.getApps", {});
1210
1395
  }
1211
1396
  async removeApp(requestId) {
1212
- return __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call("agent.removeApp", { id: requestId });
1397
+ return __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call("agent.removeApp", { id: requestId });
1213
1398
  }
1214
1399
  async revokeToken(requestId) {
1215
- return __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call("agent.revokeToken", { token: requestId });
1400
+ return __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call("agent.revokeToken", { token: requestId });
1216
1401
  }
1217
1402
  async isLocked() {
1218
- return __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call("agent.isLocked", {});
1403
+ return __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call("agent.isLocked", {});
1219
1404
  }
1220
1405
  async signMessage(message) {
1221
- return __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call("agent.sign", { message });
1406
+ return __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call("agent.sign", { message });
1222
1407
  }
1223
1408
  async createUser(email, password) {
1224
- return __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call("user.create", { email, password });
1409
+ return __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call("user.create", { email, password });
1225
1410
  }
1226
1411
  async loginUser(email, password) {
1227
- return __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call("user.login", { email, password });
1412
+ return __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call("user.login", { email, password });
1228
1413
  }
1229
1414
  async requestLoginVerification(email, appInfo) {
1230
- return __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call("user.requestVerification", { email, appInfo });
1415
+ return __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call("user.requestVerification", { email, appInfo });
1231
1416
  }
1232
1417
  async verifyEmailCode(email, code2, verificationType) {
1233
- return __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call("user.verifyEmail", { email, code: code2, verificationType });
1418
+ return __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call("user.verifyEmail", { email, code: code2, verificationType });
1234
1419
  }
1235
1420
  async logout() {
1236
- return __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call("user.logout", {});
1421
+ return __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call("user.logout", {});
1237
1422
  }
1238
1423
  async revokeAllSessions(email) {
1239
- return __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call("user.revokeAllSessions", email === void 0 ? {} : { email });
1424
+ return __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call("user.revokeAllSessions", email === void 0 ? {} : { email });
1240
1425
  }
1241
1426
  async hostingUserInfo() {
1242
- const info = (await __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call("hosting.info", {})).userInfo ?? {
1427
+ const info = (await __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call("hosting.info", {})).userInfo ?? {
1243
1428
  email: "",
1244
1429
  credits: null,
1245
1430
  hotWalletAddress: null,
@@ -1248,34 +1433,34 @@ var AgentClient = class {
1248
1433
  return new HostingUserInfo(info.email, info.freeAccess ? "unlimited" : String(info.credits ?? 0), info.hotWalletAddress || void 0, !!info.freeAccess);
1249
1434
  }
1250
1435
  async computeLog(since, limit, userEmail) {
1251
- return __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call("runtime.computeLog", { since, limit, userEmail });
1436
+ return __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call("runtime.computeLog", { since, limit, userEmail });
1252
1437
  }
1253
1438
  async setHotWalletAddress(address) {
1254
- return __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call("hosting.setHotWallet", { address });
1439
+ return __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call("hosting.setHotWallet", { address });
1255
1440
  }
1256
1441
  async requestPayment(amountHOT) {
1257
- return __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call("hosting.requestPayment", { amountHOT });
1442
+ return __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call("hosting.requestPayment", { amountHOT });
1258
1443
  }
1259
1444
  };
1260
1445
  _AgentClient_apiClient = /* @__PURE__ */ new WeakMap(), _AgentClient_memCache = /* @__PURE__ */ new WeakMap(), _AgentClient_persistent = /* @__PURE__ */ new WeakMap(), _AgentClient_selfDid = /* @__PURE__ */ new WeakMap(), _AgentClient_onAgentUpdated = /* @__PURE__ */ new WeakMap(), _AgentClient_instances = /* @__PURE__ */ new WeakSet(), _AgentClient_cacheAgent = function _AgentClient_cacheAgent2(agent) {
1261
1446
  if (!agent.did)
1262
1447
  return;
1263
- __classPrivateFieldGet$c(this, _AgentClient_memCache, "f").set(agent.did, { promise: Promise.resolve(agent), ts: Date.now() });
1264
- __classPrivateFieldGet$c(this, _AgentClient_persistent, "f").put(agent.did, { agent, ts: Date.now() });
1265
- __classPrivateFieldGet$c(this, _AgentClient_instances, "m", _AgentClient_listen).call(this);
1448
+ __classPrivateFieldGet$d(this, _AgentClient_memCache, "f").set(agent.did, { promise: Promise.resolve(agent), ts: Date.now() });
1449
+ __classPrivateFieldGet$d(this, _AgentClient_persistent, "f").put(agent.did, { agent, ts: Date.now() });
1450
+ __classPrivateFieldGet$d(this, _AgentClient_instances, "m", _AgentClient_listen).call(this);
1266
1451
  }, _AgentClient_signLinks = async function _AgentClient_signLinks2(links) {
1267
- const { uuid } = await __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call("perspective.create", { name: "Agent Perspective Proxy" });
1452
+ const { uuid } = await __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call("perspective.create", { name: "Agent Perspective Proxy" });
1268
1453
  try {
1269
- return (await __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call("perspective.addLinks", { uuid, links, status: "SHARED" })).map(LinkExpression.fromWire);
1454
+ return (await __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call("perspective.addLinks", { uuid, links, status: "SHARED" })).map(LinkExpression.fromWire);
1270
1455
  } finally {
1271
- await __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call("perspective.remove", { uuid });
1456
+ await __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call("perspective.remove", { uuid });
1272
1457
  }
1273
1458
  }, _AgentClient_listen = function _AgentClient_listen2() {
1274
- __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").on("agent-updated", __classPrivateFieldGet$c(this, _AgentClient_onAgentUpdated, "f"));
1459
+ __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").on("agent-updated", __classPrivateFieldGet$d(this, _AgentClient_onAgentUpdated, "f"));
1275
1460
  };
1276
1461
  AgentClient.REMOTE_AGENT_TTL_MS = 5 * 6e4;
1277
1462
  AgentClient.REMOTE_AGENT_TTL_L2_MS = 5 * 6e4;
1278
- var __classPrivateFieldSet$b = function(receiver, state, value, kind, f) {
1463
+ var __classPrivateFieldSet$c = function(receiver, state, value, kind, f) {
1279
1464
  if (kind === "m")
1280
1465
  throw new TypeError("Private method is not writable");
1281
1466
  if (kind === "a" && !f)
@@ -1284,7 +1469,7 @@ var __classPrivateFieldSet$b = function(receiver, state, value, kind, f) {
1284
1469
  throw new TypeError("Cannot write private member to an object whose class did not declare it");
1285
1470
  return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
1286
1471
  };
1287
- var __classPrivateFieldGet$b = function(receiver, state, kind, f) {
1472
+ var __classPrivateFieldGet$c = function(receiver, state, kind, f) {
1288
1473
  if (kind === "a" && !f)
1289
1474
  throw new TypeError("Private accessor was defined without a getter");
1290
1475
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
@@ -1295,34 +1480,34 @@ var _LanguageClient_apiClient;
1295
1480
  var LanguageClient = class {
1296
1481
  constructor(baseUrl, token, sharedApiClient) {
1297
1482
  _LanguageClient_apiClient.set(this, void 0);
1298
- __classPrivateFieldSet$b(this, _LanguageClient_apiClient, sharedApiClient || new ApiClient(baseUrl, token), "f");
1483
+ __classPrivateFieldSet$c(this, _LanguageClient_apiClient, sharedApiClient || new ApiClient(baseUrl, token), "f");
1299
1484
  }
1300
1485
  async byAddress(address) {
1301
- return __classPrivateFieldGet$b(this, _LanguageClient_apiClient, "f").call("language.get", { address });
1486
+ return __classPrivateFieldGet$c(this, _LanguageClient_apiClient, "f").call("language.get", { address });
1302
1487
  }
1303
1488
  async byFilter(filter) {
1304
- return __classPrivateFieldGet$b(this, _LanguageClient_apiClient, "f").call("language.all", { filter });
1489
+ return __classPrivateFieldGet$c(this, _LanguageClient_apiClient, "f").call("language.all", { filter });
1305
1490
  }
1306
1491
  async all() {
1307
- return __classPrivateFieldGet$b(this, _LanguageClient_apiClient, "f").call("language.all", {});
1492
+ return __classPrivateFieldGet$c(this, _LanguageClient_apiClient, "f").call("language.all", {});
1308
1493
  }
1309
1494
  async writeSettings(languageAddress, settings) {
1310
- return __classPrivateFieldGet$b(this, _LanguageClient_apiClient, "f").call("language.writeSettings", { address: languageAddress, settings });
1495
+ return __classPrivateFieldGet$c(this, _LanguageClient_apiClient, "f").call("language.writeSettings", { address: languageAddress, settings });
1311
1496
  }
1312
1497
  async applyTemplateAndPublish(sourceLanguageHash, templateData, options) {
1313
- return __classPrivateFieldGet$b(this, _LanguageClient_apiClient, "f").call("language.applyTemplate", { sourceLanguageHash, templateData }, options);
1498
+ return __classPrivateFieldGet$c(this, _LanguageClient_apiClient, "f").call("language.applyTemplate", { sourceLanguageHash, templateData }, options);
1314
1499
  }
1315
1500
  async publish(languagePath, languageMeta, options) {
1316
- return __classPrivateFieldGet$b(this, _LanguageClient_apiClient, "f").call("language.publish", { languagePath, languageMeta }, options);
1501
+ return __classPrivateFieldGet$c(this, _LanguageClient_apiClient, "f").call("language.publish", { languagePath, languageMeta }, options);
1317
1502
  }
1318
1503
  async meta(address) {
1319
- return __classPrivateFieldGet$b(this, _LanguageClient_apiClient, "f").call("language.meta", { address });
1504
+ return __classPrivateFieldGet$c(this, _LanguageClient_apiClient, "f").call("language.meta", { address });
1320
1505
  }
1321
1506
  async source(address) {
1322
- return __classPrivateFieldGet$b(this, _LanguageClient_apiClient, "f").call("language.source", { address });
1507
+ return __classPrivateFieldGet$c(this, _LanguageClient_apiClient, "f").call("language.source", { address });
1323
1508
  }
1324
1509
  async remove(address) {
1325
- return __classPrivateFieldGet$b(this, _LanguageClient_apiClient, "f").call("language.remove", { address });
1510
+ return __classPrivateFieldGet$c(this, _LanguageClient_apiClient, "f").call("language.remove", { address });
1326
1511
  }
1327
1512
  };
1328
1513
  _LanguageClient_apiClient = /* @__PURE__ */ new WeakMap();
@@ -1364,7 +1549,7 @@ function neighbourhoodExpressionFromWire(wire) {
1364
1549
  const meta = new Perspective(wire.data.meta.links.map(LinkExpression.fromWire));
1365
1550
  return new NeighbourhoodExpression(wire.author, wire.timestamp, new Neighbourhood(wire.data.linkLanguage, meta), wire.proof);
1366
1551
  }
1367
- var __classPrivateFieldSet$a = function(receiver, state, value, kind, f) {
1552
+ var __classPrivateFieldSet$b = function(receiver, state, value, kind, f) {
1368
1553
  if (kind === "m")
1369
1554
  throw new TypeError("Private method is not writable");
1370
1555
  if (kind === "a" && !f)
@@ -1373,7 +1558,7 @@ var __classPrivateFieldSet$a = function(receiver, state, value, kind, f) {
1373
1558
  throw new TypeError("Cannot write private member to an object whose class did not declare it");
1374
1559
  return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
1375
1560
  };
1376
- var __classPrivateFieldGet$a = function(receiver, state, kind, f) {
1561
+ var __classPrivateFieldGet$b = function(receiver, state, kind, f) {
1377
1562
  if (kind === "a" && !f)
1378
1563
  throw new TypeError("Private accessor was defined without a getter");
1379
1564
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
@@ -1388,47 +1573,47 @@ var NeighbourhoodClient = class {
1388
1573
  _NeighbourhoodClient_apiClient.set(this, void 0);
1389
1574
  _NeighbourhoodClient_signalHandlers.set(this, /* @__PURE__ */ new Map());
1390
1575
  _NeighbourhoodClient_signalUnsubscribers.set(this, /* @__PURE__ */ new Map());
1391
- __classPrivateFieldSet$a(this, _NeighbourhoodClient_apiClient, sharedApiClient || new ApiClient(baseUrl, token), "f");
1576
+ __classPrivateFieldSet$b(this, _NeighbourhoodClient_apiClient, sharedApiClient || new ApiClient(baseUrl, token), "f");
1392
1577
  }
1393
1578
  async publishFromPerspective(perspectiveUUID, linkLanguage, meta, options) {
1394
- return __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").call("neighbourhood.publish", {
1579
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("neighbourhood.publish", {
1395
1580
  perspectiveUuid: perspectiveUUID,
1396
1581
  linkLanguage,
1397
1582
  meta: Perspective.toWire(meta)
1398
1583
  }, options);
1399
1584
  }
1400
1585
  async joinFromUrl(url, options) {
1401
- return PerspectiveHandle.fromWire(await __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").call("neighbourhood.join", { url }, options));
1586
+ return PerspectiveHandle.fromWire(await __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("neighbourhood.join", { url }, options));
1402
1587
  }
1403
1588
  async otherAgents(perspectiveUUID) {
1404
- return __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").call("neighbourhood.otherAgents", { uuid: perspectiveUUID });
1589
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("neighbourhood.otherAgents", { uuid: perspectiveUUID });
1405
1590
  }
1406
1591
  async hasTelepresenceAdapter(perspectiveUUID) {
1407
- return __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").call("neighbourhood.hasTelepresence", { uuid: perspectiveUUID });
1592
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("neighbourhood.hasTelepresence", { uuid: perspectiveUUID });
1408
1593
  }
1409
1594
  async onlineAgents(perspectiveUUID) {
1410
- const agents = await __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").call("neighbourhood.onlineAgents", { uuid: perspectiveUUID });
1595
+ const agents = await __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("neighbourhood.onlineAgents", { uuid: perspectiveUUID });
1411
1596
  return agents.map(({ did, status }) => ({ did, status: PerspectiveExpression.fromWire(status) }));
1412
1597
  }
1413
1598
  async ownOnlineStatus(perspectiveUUID) {
1414
- const status = await __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").call("neighbourhood.ownOnlineStatus", { uuid: perspectiveUUID });
1599
+ const status = await __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("neighbourhood.ownOnlineStatus", { uuid: perspectiveUUID });
1415
1600
  return status ? PerspectiveExpression.fromWire(status) : null;
1416
1601
  }
1417
1602
  async setOnlineStatus(perspectiveUUID, status) {
1418
- return __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").call("neighbourhood.setOnlineStatus", { uuid: perspectiveUUID, status: Perspective.toWire(status) });
1603
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("neighbourhood.setOnlineStatus", { uuid: perspectiveUUID, status: Perspective.toWire(status) });
1419
1604
  }
1420
1605
  async setOnlineStatusU(perspectiveUUID, status) {
1421
- return __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").call("neighbourhood.setOnlineStatus", { uuid: perspectiveUUID, status, signed: false });
1606
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("neighbourhood.setOnlineStatus", { uuid: perspectiveUUID, status, signed: false });
1422
1607
  }
1423
1608
  async sendSignal(perspectiveUUID, remoteAgentDid, payload) {
1424
- return __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").call("neighbourhood.sendSignal", {
1609
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("neighbourhood.sendSignal", {
1425
1610
  uuid: perspectiveUUID,
1426
1611
  remoteAgentDid,
1427
1612
  payload: Perspective.toWire(payload)
1428
1613
  });
1429
1614
  }
1430
1615
  async sendSignalU(perspectiveUUID, remoteAgentDid, payload) {
1431
- return __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").call("neighbourhood.sendSignal", {
1616
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("neighbourhood.sendSignal", {
1432
1617
  uuid: perspectiveUUID,
1433
1618
  remoteAgentDid,
1434
1619
  payload,
@@ -1436,14 +1621,14 @@ var NeighbourhoodClient = class {
1436
1621
  });
1437
1622
  }
1438
1623
  async sendBroadcast(perspectiveUUID, payload, loopback = false) {
1439
- return __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").call("neighbourhood.sendBroadcast", {
1624
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("neighbourhood.sendBroadcast", {
1440
1625
  uuid: perspectiveUUID,
1441
1626
  payload: Perspective.toWire(payload),
1442
1627
  loopback
1443
1628
  });
1444
1629
  }
1445
1630
  async sendBroadcastU(perspectiveUUID, payload, loopback = false) {
1446
- return __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").call("neighbourhood.sendBroadcast", {
1631
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("neighbourhood.sendBroadcast", {
1447
1632
  uuid: perspectiveUUID,
1448
1633
  payload,
1449
1634
  loopback,
@@ -1451,7 +1636,7 @@ var NeighbourhoodClient = class {
1451
1636
  });
1452
1637
  }
1453
1638
  dispatchSignal(perspectiveUUID, signal) {
1454
- const handlers = __classPrivateFieldGet$a(this, _NeighbourhoodClient_signalHandlers, "f").get(perspectiveUUID);
1639
+ const handlers = __classPrivateFieldGet$b(this, _NeighbourhoodClient_signalHandlers, "f").get(perspectiveUUID);
1455
1640
  if (handlers) {
1456
1641
  for (const handler of handlers) {
1457
1642
  try {
@@ -1463,15 +1648,15 @@ var NeighbourhoodClient = class {
1463
1648
  }
1464
1649
  }
1465
1650
  async subscribeToSignals(perspectiveUUID) {
1466
- const unsub = __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").on("signal", (event) => this.dispatchSignal(perspectiveUUID, PerspectiveExpression.fromWire(event.signal)), { perspective: perspectiveUUID });
1467
- __classPrivateFieldGet$a(this, _NeighbourhoodClient_signalUnsubscribers, "f").set(perspectiveUUID, unsub);
1468
- await __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").watchApplied();
1651
+ const unsub = __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").on("signal", (event) => this.dispatchSignal(perspectiveUUID, PerspectiveExpression.fromWire(event.signal)), { perspective: perspectiveUUID });
1652
+ __classPrivateFieldGet$b(this, _NeighbourhoodClient_signalUnsubscribers, "f").set(perspectiveUUID, unsub);
1653
+ await __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").watchApplied();
1469
1654
  }
1470
1655
  async addSignalHandler(perspectiveUUID, handler) {
1471
- let handlersForPerspective = __classPrivateFieldGet$a(this, _NeighbourhoodClient_signalHandlers, "f").get(perspectiveUUID);
1656
+ let handlersForPerspective = __classPrivateFieldGet$b(this, _NeighbourhoodClient_signalHandlers, "f").get(perspectiveUUID);
1472
1657
  if (!handlersForPerspective) {
1473
1658
  handlersForPerspective = [];
1474
- __classPrivateFieldGet$a(this, _NeighbourhoodClient_signalHandlers, "f").set(perspectiveUUID, handlersForPerspective);
1659
+ __classPrivateFieldGet$b(this, _NeighbourhoodClient_signalHandlers, "f").set(perspectiveUUID, handlersForPerspective);
1475
1660
  handlersForPerspective.push(handler);
1476
1661
  await this.subscribeToSignals(perspectiveUUID);
1477
1662
  } else {
@@ -1479,76 +1664,85 @@ var NeighbourhoodClient = class {
1479
1664
  }
1480
1665
  }
1481
1666
  removeSignalHandler(perspectiveUUID, handler) {
1482
- const handlersForPerspective = __classPrivateFieldGet$a(this, _NeighbourhoodClient_signalHandlers, "f").get(perspectiveUUID);
1667
+ const handlersForPerspective = __classPrivateFieldGet$b(this, _NeighbourhoodClient_signalHandlers, "f").get(perspectiveUUID);
1483
1668
  if (handlersForPerspective) {
1484
1669
  const index = handlersForPerspective.indexOf(handler);
1485
1670
  if (index > -1) {
1486
1671
  handlersForPerspective.splice(index, 1);
1487
1672
  }
1488
1673
  if (handlersForPerspective.length === 0) {
1489
- __classPrivateFieldGet$a(this, _NeighbourhoodClient_signalHandlers, "f").delete(perspectiveUUID);
1490
- const unsub = __classPrivateFieldGet$a(this, _NeighbourhoodClient_signalUnsubscribers, "f").get(perspectiveUUID);
1674
+ __classPrivateFieldGet$b(this, _NeighbourhoodClient_signalHandlers, "f").delete(perspectiveUUID);
1675
+ const unsub = __classPrivateFieldGet$b(this, _NeighbourhoodClient_signalUnsubscribers, "f").get(perspectiveUUID);
1491
1676
  if (unsub) {
1492
1677
  unsub();
1493
- __classPrivateFieldGet$a(this, _NeighbourhoodClient_signalUnsubscribers, "f").delete(perspectiveUUID);
1678
+ __classPrivateFieldGet$b(this, _NeighbourhoodClient_signalUnsubscribers, "f").delete(perspectiveUUID);
1494
1679
  }
1495
1680
  }
1496
1681
  }
1497
1682
  }
1498
1683
  async sfuStartRoom(neighbourhoodUrl, roomName) {
1499
- return __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").call("sfu.startRoom", { neighbourhoodUrl, roomName });
1684
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("sfu.startRoom", { neighbourhoodUrl, roomName });
1500
1685
  }
1501
1686
  async sfuStopRoom(neighbourhoodUrl, roomName) {
1502
- return __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").call("sfu.stopRoom", { neighbourhoodUrl, roomName });
1687
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("sfu.stopRoom", { neighbourhoodUrl, roomName });
1503
1688
  }
1504
1689
  async sfuListRooms() {
1505
- return __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").call("sfu.listRooms", {});
1690
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("sfu.listRooms", {});
1506
1691
  }
1507
1692
  async sfuCallJoin(neighbourhoodUrl, roomName, sdpOffer) {
1508
- return __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").call("sfu.callJoin", {
1693
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("sfu.callJoin", {
1509
1694
  neighbourhoodUrl,
1510
1695
  roomName,
1511
1696
  sdpOffer
1512
1697
  });
1513
1698
  }
1514
1699
  async sfuCallLeave(neighbourhoodUrl, roomName) {
1515
- return __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").call("sfu.callLeave", { neighbourhoodUrl, roomName });
1700
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("sfu.callLeave", { neighbourhoodUrl, roomName });
1516
1701
  }
1517
1702
  async sfuCallSetQualityPreference(neighbourhoodUrl, roomName, preference) {
1518
- return __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").call("sfu.callSetQualityPreference", {
1703
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("sfu.callSetQualityPreference", {
1519
1704
  neighbourhoodUrl,
1520
1705
  roomName,
1521
1706
  preference
1522
1707
  });
1523
1708
  }
1524
1709
  async sfuCallAnswerServerOffer(neighbourhoodUrl, roomName, sdpAnswer) {
1525
- return __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").call("sfu.callAnswerServerOffer", {
1710
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("sfu.callAnswerServerOffer", {
1526
1711
  neighbourhoodUrl,
1527
1712
  roomName,
1528
1713
  sdpAnswer
1529
1714
  });
1530
1715
  }
1716
+ async sfuCallRestartIce(neighbourhoodUrl, roomName) {
1717
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("sfu.callRestartIce", { neighbourhoodUrl, roomName });
1718
+ }
1719
+ onNetworkChange(callback) {
1720
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").onNetworkChange(callback);
1721
+ }
1722
+ checkConnection() {
1723
+ __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").checkConnection();
1724
+ }
1531
1725
  async sfuGetConfig(neighbourhoodUrl) {
1532
- return __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").call("sfu.getConfig", { neighbourhoodUrl });
1726
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("sfu.getConfig", { neighbourhoodUrl });
1533
1727
  }
1534
1728
  async sfuSetConfig(neighbourhoodUrl, config) {
1535
- return __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").call("sfu.setConfig", { neighbourhoodUrl, config });
1729
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("sfu.setConfig", { neighbourhoodUrl, config });
1536
1730
  }
1537
1731
  async sfuPeerForNeighbourhood(neighbourhoodUrl) {
1538
- return __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").call("sfu.sfuPeerForNeighbourhood", { neighbourhoodUrl });
1732
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("sfu.sfuPeerForNeighbourhood", { neighbourhoodUrl });
1539
1733
  }
1540
1734
  async sfuPeersForNeighbourhood(neighbourhoodUrl) {
1541
- return __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").call("sfu.sfuPeersForNeighbourhood", { neighbourhoodUrl });
1735
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("sfu.sfuPeersForNeighbourhood", { neighbourhoodUrl });
1542
1736
  }
1543
1737
  async sfuAddIceCandidate(neighbourhoodUrl, roomName, candidate) {
1544
- return __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").call("sfu.addIceCandidate", {
1738
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("sfu.addIceCandidate", {
1545
1739
  neighbourhoodUrl,
1546
1740
  roomName,
1547
1741
  candidate
1548
1742
  });
1549
1743
  }
1550
1744
  async sfuSendData(neighbourhoodUrl, roomName, channelLabel, data, binary = false) {
1551
- return __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").call("sfu.sendData", {
1745
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("sfu.sendData", {
1552
1746
  neighbourhoodUrl,
1553
1747
  roomName,
1554
1748
  channelLabel,
@@ -1557,13 +1751,13 @@ var NeighbourhoodClient = class {
1557
1751
  });
1558
1752
  }
1559
1753
  subscribeSfuDataChannel(callback) {
1560
- return __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").on("sfu-data", (message) => callback(message));
1754
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").on("sfu-data", (message) => callback(message));
1561
1755
  }
1562
1756
  subscribeSfuRoomRoster(callback) {
1563
- return __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").on("sfu-room-roster", (roster) => callback(roster));
1757
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").on("sfu-room-roster", (roster) => callback(roster));
1564
1758
  }
1565
1759
  subscribeSfuCallRenegotiationOffer(targetDid, callback) {
1566
- return __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").on("sfu-call-renegotiation-offer", (event) => {
1760
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").on("sfu-call-renegotiation-offer", (event) => {
1567
1761
  if (event.targetDid !== targetDid)
1568
1762
  return;
1569
1763
  callback({
@@ -1576,7 +1770,7 @@ var NeighbourhoodClient = class {
1576
1770
  });
1577
1771
  }
1578
1772
  subscribeSfuMigrateEvent(targetDid, callback) {
1579
- return __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").on("sfu-migrate", (event) => {
1773
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").on("sfu-migrate", (event) => {
1580
1774
  if (event.targetDid !== targetDid)
1581
1775
  return;
1582
1776
  callback({
@@ -1588,22 +1782,22 @@ var NeighbourhoodClient = class {
1588
1782
  });
1589
1783
  }
1590
1784
  async sfuServesAllMembers(perspectiveId) {
1591
- return __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").call("sfu.servesAllMembers", { uuid: perspectiveId });
1785
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("sfu.servesAllMembers", { uuid: perspectiveId });
1592
1786
  }
1593
1787
  async callerDid() {
1594
- return (await __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").call("agent.status", {})).did;
1788
+ return (await __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("agent.status", {})).did;
1595
1789
  }
1596
1790
  async sfuStatus() {
1597
- return __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").call("sfu.status", {});
1791
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("sfu.status", {});
1598
1792
  }
1599
1793
  async sfuCascadeStatus() {
1600
- return __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").call("sfu.cascadeStatus", {});
1794
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("sfu.cascadeStatus", {});
1601
1795
  }
1602
1796
  async sfuQualityPreferences() {
1603
- return __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").call("sfu.qualityPreferences", {});
1797
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("sfu.qualityPreferences", {});
1604
1798
  }
1605
1799
  async sfuEnsureMembership(neighbourhoodUrl, did) {
1606
- return __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").call("sfu.ensureMembership", {
1800
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("sfu.ensureMembership", {
1607
1801
  neighbourhoodUrl,
1608
1802
  did
1609
1803
  });
@@ -1625,10 +1819,12 @@ var SfuManager = class {
1625
1819
  this.replacedTracks = /* @__PURE__ */ new Map();
1626
1820
  this.qualityPreference = null;
1627
1821
  this.offerQueue = Promise.resolve();
1822
+ this.answeredOffer = null;
1628
1823
  this.renegotiationUnsubscribe = null;
1629
1824
  this.rosterUnsubscribe = null;
1630
1825
  this.dataChannelUnsubscribe = null;
1631
- this.disconnectedTimer = null;
1826
+ this.restartTimer = null;
1827
+ this.networkUnsubscribe = null;
1632
1828
  this.unlistedTimer = null;
1633
1829
  this.neighbourhood = neighbourhood;
1634
1830
  this.neighbourhoodUrl = neighbourhoodUrl || "";
@@ -1666,6 +1862,7 @@ var SfuManager = class {
1666
1862
  }
1667
1863
  console.info(`SFU: connection failed, reconnecting (${this.reconnectAttempts}/${SfuManager.MAX_RECONNECTS})`);
1668
1864
  this.reconnecting = true;
1865
+ this.endRestart();
1669
1866
  try {
1670
1867
  const deadline = Date.now() + SfuManager.REJOIN_WINDOW_MS;
1671
1868
  for (let delay = 1e3; ; delay = Math.min(delay * 2, 1e4)) {
@@ -1704,6 +1901,28 @@ var SfuManager = class {
1704
1901
  this.reconnecting = false;
1705
1902
  }
1706
1903
  }
1904
+ restartIce(pc) {
1905
+ if (this.restartTimer || this.reconnecting || this.state.peerConnection !== pc)
1906
+ return;
1907
+ console.info("SFU: restarting ICE");
1908
+ this.restartTimer = setTimeout(() => {
1909
+ this.restartTimer = null;
1910
+ if (this.state.peerConnection !== pc)
1911
+ return;
1912
+ if (pc.iceConnectionState === "connected" || pc.iceConnectionState === "completed")
1913
+ return;
1914
+ void this.reconnect();
1915
+ }, SfuManager.RESTART_TIMEOUT_MS);
1916
+ this.neighbourhood.sfuCallRestartIce(this.neighbourhoodUrl, this.roomId).catch((err2) => {
1917
+ console.warn("SFU: ICE restart refused:", err2);
1918
+ });
1919
+ }
1920
+ endRestart() {
1921
+ if (this.restartTimer) {
1922
+ clearTimeout(this.restartTimer);
1923
+ this.restartTimer = null;
1924
+ }
1925
+ }
1707
1926
  on(event, callback) {
1708
1927
  if (!this.callbacks.has(event)) {
1709
1928
  this.callbacks.set(event, []);
@@ -1744,30 +1963,25 @@ var SfuManager = class {
1744
1963
  if (this.state.peerConnection !== pc)
1745
1964
  return;
1746
1965
  if (pc.iceConnectionState === "failed") {
1747
- if (this.disconnectedTimer) {
1748
- clearTimeout(this.disconnectedTimer);
1749
- this.disconnectedTimer = null;
1750
- }
1751
- this.reconnect();
1966
+ this.endRestart();
1967
+ void this.reconnect();
1752
1968
  } else if (pc.iceConnectionState === "disconnected") {
1753
- if (!this.disconnectedTimer) {
1754
- this.disconnectedTimer = setTimeout(() => {
1755
- this.disconnectedTimer = null;
1756
- if (this.state.peerConnection === pc && pc.iceConnectionState === "disconnected") {
1757
- this.reconnect();
1758
- }
1759
- }, SfuManager.DISCONNECT_GRACE_MS);
1760
- }
1761
- } else {
1762
- if (pc.iceConnectionState === "connected" || pc.iceConnectionState === "completed") {
1763
- this.reconnectAttempts = 0;
1764
- }
1765
- if (this.disconnectedTimer) {
1766
- clearTimeout(this.disconnectedTimer);
1767
- this.disconnectedTimer = null;
1768
- }
1969
+ this.neighbourhood.checkConnection();
1970
+ this.restartIce(pc);
1971
+ } else if (pc.iceConnectionState === "connected" || pc.iceConnectionState === "completed") {
1972
+ this.reconnectAttempts = 0;
1973
+ this.endRestart();
1769
1974
  }
1770
1975
  };
1976
+ if (!this.networkUnsubscribe) {
1977
+ this.networkUnsubscribe = this.neighbourhood.onNetworkChange(() => {
1978
+ const current = this.state.peerConnection;
1979
+ if (!current || this.reconnecting)
1980
+ return;
1981
+ this.endRestart();
1982
+ this.restartIce(current);
1983
+ });
1984
+ }
1771
1985
  this.senders.clear();
1772
1986
  for (const kind of ["audio", "video"]) {
1773
1987
  const track = this.replacedTracks.has(kind) ? this.replacedTracks.get(kind) : localStream.getTracks().find((t) => t.kind === kind);
@@ -1904,7 +2118,7 @@ var SfuManager = class {
1904
2118
  unsubscribe?.();
1905
2119
  }
1906
2120
  async applyServerOffer(pc, event) {
1907
- if (this.state.peerConnection !== pc)
2121
+ if (this.state.peerConnection !== pc || event.sdpOffer === this.answeredOffer)
1908
2122
  return;
1909
2123
  for (const entry of event.trackMapping ?? []) {
1910
2124
  this.midToParticipant.set(entry.mid, entry.agentDid);
@@ -1913,6 +2127,7 @@ var SfuManager = class {
1913
2127
  await pc.setRemoteDescription(new RTCSessionDescription(JSON.parse(event.sdpOffer)));
1914
2128
  await pc.setLocalDescription(await pc.createAnswer());
1915
2129
  await this.neighbourhood.sfuCallAnswerServerOffer(this.neighbourhoodUrl, event.roomName, JSON.stringify(pc.localDescription));
2130
+ this.answeredOffer = event.sdpOffer;
1916
2131
  } catch (err2) {
1917
2132
  if (this.state.peerConnection !== pc)
1918
2133
  return;
@@ -1962,10 +2177,9 @@ var SfuManager = class {
1962
2177
  async leave() {
1963
2178
  this.generation++;
1964
2179
  this.releaseServerEvents();
1965
- if (this.disconnectedTimer) {
1966
- clearTimeout(this.disconnectedTimer);
1967
- this.disconnectedTimer = null;
1968
- }
2180
+ this.endRestart();
2181
+ this.networkUnsubscribe?.();
2182
+ this.networkUnsubscribe = null;
1969
2183
  this.senders.clear();
1970
2184
  this.replacedTracks.clear();
1971
2185
  this.qualityPreference = null;
@@ -2062,7 +2276,7 @@ var SfuManager = class {
2062
2276
  };
2063
2277
  SfuManager.MAX_RECONNECTS = 3;
2064
2278
  SfuManager.REJOIN_WINDOW_MS = 12e4;
2065
- SfuManager.DISCONNECT_GRACE_MS = 1e4;
2279
+ SfuManager.RESTART_TIMEOUT_MS = 5e3;
2066
2280
  SfuManager.UNLISTED_GRACE_MS = 3e3;
2067
2281
  var CALL_PROTOCOL_VERSION = 1;
2068
2282
  function parseCallMessage(payload) {
@@ -2213,6 +2427,7 @@ var MeshManager = class {
2213
2427
  this.outstanding = 0;
2214
2428
  this.lastRepairAt = 0;
2215
2429
  this.renegotiationRepairs = /* @__PURE__ */ new Map();
2430
+ this.unwatchNetwork = null;
2216
2431
  this.channel = options.channel;
2217
2432
  this.callId = options.callId;
2218
2433
  this.selfId = options.selfId;
@@ -2223,6 +2438,8 @@ var MeshManager = class {
2223
2438
  this.createPeerConnection = options.createPeerConnection ?? ((configuration) => new RTCPeerConnection(configuration));
2224
2439
  this.now = options.now ?? (() => Date.now());
2225
2440
  this.sweepMs = options.sweepMs ?? SWEEP_INTERVAL_MS;
2441
+ this.onNetworkChange = options.onNetworkChange;
2442
+ this.checkConnection = options.checkConnection;
2226
2443
  }
2227
2444
  on(event, callback) {
2228
2445
  if (!this.callbacks.has(event))
@@ -2307,6 +2524,7 @@ var MeshManager = class {
2307
2524
  this.publish({ v: CALL_PROTOCOL_VERSION, call: this.callId, warm: true });
2308
2525
  if (this.sweepMs > 0)
2309
2526
  this.sweep = setInterval(() => this.tick(), this.sweepMs);
2527
+ this.unwatchNetwork = this.onNetworkChange?.(() => this.restartAll()) ?? null;
2310
2528
  }
2311
2529
  async leave() {
2312
2530
  this.closed = true;
@@ -2314,6 +2532,8 @@ var MeshManager = class {
2314
2532
  clearInterval(this.sweep);
2315
2533
  this.sweep = null;
2316
2534
  }
2535
+ this.unwatchNetwork?.();
2536
+ this.unwatchNetwork = null;
2317
2537
  this.unwatchPublish?.();
2318
2538
  this.unwatchPublish = null;
2319
2539
  if (this.channelUnsubscribe) {
@@ -2547,8 +2767,10 @@ var MeshManager = class {
2547
2767
  if (slot.offerDeferred && pc.signalingState === "stable")
2548
2768
  void negotiate();
2549
2769
  }
2550
- if (state === "disconnected" && !slot.disconnectedAt)
2770
+ if (state === "disconnected" && !slot.disconnectedAt) {
2551
2771
  slot.disconnectedAt = this.now();
2772
+ this.checkConnection?.();
2773
+ }
2552
2774
  if (state === "connected" || state === "failed")
2553
2775
  slot.disconnectedAt = 0;
2554
2776
  this.emit("peer-state", peerId, state);
@@ -2777,6 +2999,23 @@ var MeshManager = class {
2777
2999
  slot.attempts = attempts - 1;
2778
3000
  this.rebuild(peerId, { announce: true, rung: "rebuild" });
2779
3001
  }
3002
+ restartAll() {
3003
+ if (this.closed)
3004
+ return;
3005
+ const at = this.now();
3006
+ for (const [peerId, slot] of this.slots) {
3007
+ if (!slot.remoteReady || typeof slot.pc.restartIce !== "function")
3008
+ continue;
3009
+ slot.lastAttempt = at;
3010
+ try {
3011
+ slot.pc.restartIce();
3012
+ this.emit("peer-recovery", peerId, { rung: "ice-restart", attempts: slot.attempts });
3013
+ } catch (error) {
3014
+ this.fail(`restarting ice with ${peerId}`, error);
3015
+ }
3016
+ }
3017
+ this.lastRepairAt = at;
3018
+ }
2780
3019
  dueForRepair(peerId, slot, at) {
2781
3020
  const state = slot.pc.connectionState;
2782
3021
  if (slot.attempts >= MAX_RECOVERY_ATTEMPTS)
@@ -2998,7 +3237,9 @@ function createSession(config) {
2998
3237
  channel,
2999
3238
  callId: roomId,
3000
3239
  selfId: agentDid,
3001
- ...meshIce.length > 0 ? { iceServers: meshIce } : {}
3240
+ ...meshIce.length > 0 ? { iceServers: meshIce } : {},
3241
+ onNetworkChange: (cb) => api.onNetworkChange(cb),
3242
+ checkConnection: () => api.checkConnection()
3002
3243
  });
3003
3244
  meshManager = mesh;
3004
3245
  wireMeshEvents(mesh);
@@ -3161,7 +3402,7 @@ function createSession(config) {
3161
3402
  };
3162
3403
  return session;
3163
3404
  }
3164
- var __classPrivateFieldSet$9 = function(receiver, state, value, kind, f) {
3405
+ var __classPrivateFieldSet$a = function(receiver, state, value, kind, f) {
3165
3406
  if (kind === "m")
3166
3407
  throw new TypeError("Private method is not writable");
3167
3408
  if (kind === "a" && !f)
@@ -3170,7 +3411,7 @@ var __classPrivateFieldSet$9 = function(receiver, state, value, kind, f) {
3170
3411
  throw new TypeError("Cannot write private member to an object whose class did not declare it");
3171
3412
  return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
3172
3413
  };
3173
- var __classPrivateFieldGet$9 = function(receiver, state, kind, f) {
3414
+ var __classPrivateFieldGet$a = function(receiver, state, kind, f) {
3174
3415
  if (kind === "a" && !f)
3175
3416
  throw new TypeError("Private accessor was defined without a getter");
3176
3417
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
@@ -3192,144 +3433,144 @@ var NeighbourhoodProxy = class {
3192
3433
  []
3193
3434
  );
3194
3435
  _NeighbourhoodProxy_sfuStatusCache.set(this, null);
3195
- __classPrivateFieldSet$9(this, _NeighbourhoodProxy_client, client, "f");
3196
- __classPrivateFieldSet$9(this, _NeighbourhoodProxy_pID, pID, "f");
3197
- __classPrivateFieldSet$9(this, _NeighbourhoodProxy_agentDid, agentDid, "f");
3436
+ __classPrivateFieldSet$a(this, _NeighbourhoodProxy_client, client, "f");
3437
+ __classPrivateFieldSet$a(this, _NeighbourhoodProxy_pID, pID, "f");
3438
+ __classPrivateFieldSet$a(this, _NeighbourhoodProxy_agentDid, agentDid, "f");
3198
3439
  }
3199
3440
  async otherAgents() {
3200
- return await __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").otherAgents(__classPrivateFieldGet$9(this, _NeighbourhoodProxy_pID, "f"));
3441
+ return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").otherAgents(__classPrivateFieldGet$a(this, _NeighbourhoodProxy_pID, "f"));
3201
3442
  }
3202
3443
  async hasTelepresenceAdapter() {
3203
- return await __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").hasTelepresenceAdapter(__classPrivateFieldGet$9(this, _NeighbourhoodProxy_pID, "f"));
3444
+ return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").hasTelepresenceAdapter(__classPrivateFieldGet$a(this, _NeighbourhoodProxy_pID, "f"));
3204
3445
  }
3205
3446
  async onlineAgents() {
3206
- return await __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").onlineAgents(__classPrivateFieldGet$9(this, _NeighbourhoodProxy_pID, "f"));
3447
+ return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").onlineAgents(__classPrivateFieldGet$a(this, _NeighbourhoodProxy_pID, "f"));
3207
3448
  }
3208
3449
  async ownOnlineStatus() {
3209
- return await __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").ownOnlineStatus(__classPrivateFieldGet$9(this, _NeighbourhoodProxy_pID, "f"));
3450
+ return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").ownOnlineStatus(__classPrivateFieldGet$a(this, _NeighbourhoodProxy_pID, "f"));
3210
3451
  }
3211
3452
  async setOnlineStatus(status) {
3212
- return await __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").setOnlineStatus(__classPrivateFieldGet$9(this, _NeighbourhoodProxy_pID, "f"), status);
3453
+ return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").setOnlineStatus(__classPrivateFieldGet$a(this, _NeighbourhoodProxy_pID, "f"), status);
3213
3454
  }
3214
3455
  async setOnlineStatusU(status) {
3215
- return await __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").setOnlineStatusU(__classPrivateFieldGet$9(this, _NeighbourhoodProxy_pID, "f"), status);
3456
+ return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").setOnlineStatusU(__classPrivateFieldGet$a(this, _NeighbourhoodProxy_pID, "f"), status);
3216
3457
  }
3217
3458
  async sendSignal(remoteAgentDid, payload) {
3218
- return await __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").sendSignal(__classPrivateFieldGet$9(this, _NeighbourhoodProxy_pID, "f"), remoteAgentDid, payload);
3459
+ return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").sendSignal(__classPrivateFieldGet$a(this, _NeighbourhoodProxy_pID, "f"), remoteAgentDid, payload);
3219
3460
  }
3220
3461
  async sendSignalU(remoteAgentDid, payload) {
3221
- return await __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").sendSignalU(__classPrivateFieldGet$9(this, _NeighbourhoodProxy_pID, "f"), remoteAgentDid, payload);
3462
+ return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").sendSignalU(__classPrivateFieldGet$a(this, _NeighbourhoodProxy_pID, "f"), remoteAgentDid, payload);
3222
3463
  }
3223
3464
  async sendBroadcast(payload, loopback = false) {
3224
- return await __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").sendBroadcast(__classPrivateFieldGet$9(this, _NeighbourhoodProxy_pID, "f"), payload, loopback);
3465
+ return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").sendBroadcast(__classPrivateFieldGet$a(this, _NeighbourhoodProxy_pID, "f"), payload, loopback);
3225
3466
  }
3226
3467
  async sendBroadcastU(payload, loopback = false) {
3227
- return await __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").sendBroadcastU(__classPrivateFieldGet$9(this, _NeighbourhoodProxy_pID, "f"), payload, loopback);
3468
+ return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").sendBroadcastU(__classPrivateFieldGet$a(this, _NeighbourhoodProxy_pID, "f"), payload, loopback);
3228
3469
  }
3229
3470
  async addSignalHandler(handler) {
3230
- await __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").addSignalHandler(__classPrivateFieldGet$9(this, _NeighbourhoodProxy_pID, "f"), handler);
3471
+ await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").addSignalHandler(__classPrivateFieldGet$a(this, _NeighbourhoodProxy_pID, "f"), handler);
3231
3472
  }
3232
3473
  removeSignalHandler(handler) {
3233
- __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").removeSignalHandler(__classPrivateFieldGet$9(this, _NeighbourhoodProxy_pID, "f"), handler);
3474
+ __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").removeSignalHandler(__classPrivateFieldGet$a(this, _NeighbourhoodProxy_pID, "f"), handler);
3234
3475
  }
3235
3476
  get sessions() {
3236
- return __classPrivateFieldGet$9(this, _NeighbourhoodProxy_sessions, "f");
3477
+ return __classPrivateFieldGet$a(this, _NeighbourhoodProxy_sessions, "f");
3237
3478
  }
3238
3479
  async createSession(roomName, options) {
3239
- if (!__classPrivateFieldGet$9(this, _NeighbourhoodProxy_agentDid, "f")) {
3240
- __classPrivateFieldSet$9(this, _NeighbourhoodProxy_agentDid, await __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").callerDid() ?? "", "f");
3480
+ if (!__classPrivateFieldGet$a(this, _NeighbourhoodProxy_agentDid, "f")) {
3481
+ __classPrivateFieldSet$a(this, _NeighbourhoodProxy_agentDid, await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").callerDid() ?? "", "f");
3241
3482
  }
3242
- if (!__classPrivateFieldGet$9(this, _NeighbourhoodProxy_agentDid, "f")) {
3483
+ if (!__classPrivateFieldGet$a(this, _NeighbourhoodProxy_agentDid, "f")) {
3243
3484
  throw new Error("Cannot create a call session: the executor reports no agent DID");
3244
3485
  }
3245
- if (!__classPrivateFieldGet$9(this, _NeighbourhoodProxy_sfuStatusCache, "f")) {
3486
+ if (!__classPrivateFieldGet$a(this, _NeighbourhoodProxy_sfuStatusCache, "f")) {
3246
3487
  try {
3247
- __classPrivateFieldSet$9(this, _NeighbourhoodProxy_sfuStatusCache, await __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").sfuStatus(), "f");
3488
+ __classPrivateFieldSet$a(this, _NeighbourhoodProxy_sfuStatusCache, await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").sfuStatus(), "f");
3248
3489
  } catch {
3249
3490
  }
3250
3491
  }
3251
3492
  const proxy = this;
3252
3493
  const session = createSession({
3253
- api: __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f"),
3494
+ api: __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f"),
3254
3495
  roomId: roomName,
3255
- agentDid: __classPrivateFieldGet$9(this, _NeighbourhoodProxy_agentDid, "f"),
3496
+ agentDid: __classPrivateFieldGet$a(this, _NeighbourhoodProxy_agentDid, "f"),
3256
3497
  neighbourhoodUrl: options?.neighbourhoodUrl ?? "",
3257
3498
  topology: options?.topology ?? "auto",
3258
3499
  sfuConfig: options?.sfuConfig,
3259
3500
  iceServers: options?.iceServers,
3260
- localSfuStatus: __classPrivateFieldGet$9(this, _NeighbourhoodProxy_sfuStatusCache, "f") ?? void 0,
3261
- sfuServesAllMembers: () => __classPrivateFieldGet$9(proxy, _NeighbourhoodProxy_client, "f").sfuServesAllMembers(__classPrivateFieldGet$9(proxy, _NeighbourhoodProxy_pID, "f")),
3262
- channel: createTelepresenceChannel(proxy, __classPrivateFieldGet$9(proxy, _NeighbourhoodProxy_agentDid, "f")),
3501
+ localSfuStatus: __classPrivateFieldGet$a(this, _NeighbourhoodProxy_sfuStatusCache, "f") ?? void 0,
3502
+ sfuServesAllMembers: () => __classPrivateFieldGet$a(proxy, _NeighbourhoodProxy_client, "f").sfuServesAllMembers(__classPrivateFieldGet$a(proxy, _NeighbourhoodProxy_pID, "f")),
3503
+ channel: createTelepresenceChannel(proxy, __classPrivateFieldGet$a(proxy, _NeighbourhoodProxy_agentDid, "f")),
3263
3504
  ownOnlineStatus: () => proxy.ownOnlineStatus(),
3264
3505
  setOnlineStatus: (status) => proxy.setOnlineStatusU(status),
3265
3506
  onlineAgents: () => proxy.onlineAgents()
3266
3507
  });
3267
- __classPrivateFieldGet$9(this, _NeighbourhoodProxy_sessions, "f").push(session);
3508
+ __classPrivateFieldGet$a(this, _NeighbourhoodProxy_sessions, "f").push(session);
3268
3509
  session.on("state-changed", (state) => {
3269
3510
  if (state === "closed") {
3270
- const idx = __classPrivateFieldGet$9(this, _NeighbourhoodProxy_sessions, "f").indexOf(session);
3511
+ const idx = __classPrivateFieldGet$a(this, _NeighbourhoodProxy_sessions, "f").indexOf(session);
3271
3512
  if (idx !== -1)
3272
- __classPrivateFieldGet$9(this, _NeighbourhoodProxy_sessions, "f").splice(idx, 1);
3513
+ __classPrivateFieldGet$a(this, _NeighbourhoodProxy_sessions, "f").splice(idx, 1);
3273
3514
  }
3274
3515
  });
3275
3516
  return session;
3276
3517
  }
3277
3518
  async sfuConfig(neighbourhoodUrl) {
3278
- return await __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").sfuGetConfig(neighbourhoodUrl);
3519
+ return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").sfuGetConfig(neighbourhoodUrl);
3279
3520
  }
3280
3521
  async setSfuConfig(neighbourhoodUrl, config) {
3281
- return await __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").sfuSetConfig(neighbourhoodUrl, config);
3522
+ return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").sfuSetConfig(neighbourhoodUrl, config);
3282
3523
  }
3283
3524
  async sfuPeer(neighbourhoodUrl) {
3284
- return await __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").sfuPeerForNeighbourhood(neighbourhoodUrl);
3525
+ return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").sfuPeerForNeighbourhood(neighbourhoodUrl);
3285
3526
  }
3286
3527
  async sfuPeers(neighbourhoodUrl) {
3287
- return await __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").sfuPeersForNeighbourhood(neighbourhoodUrl);
3528
+ return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").sfuPeersForNeighbourhood(neighbourhoodUrl);
3288
3529
  }
3289
3530
  async sfuStartRoom(neighbourhoodUrl, roomName) {
3290
- return await __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").sfuStartRoom(neighbourhoodUrl, roomName);
3531
+ return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").sfuStartRoom(neighbourhoodUrl, roomName);
3291
3532
  }
3292
3533
  async sfuStopRoom(neighbourhoodUrl, roomName) {
3293
- return await __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").sfuStopRoom(neighbourhoodUrl, roomName);
3534
+ return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").sfuStopRoom(neighbourhoodUrl, roomName);
3294
3535
  }
3295
3536
  async sfuListRooms() {
3296
- return await __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").sfuListRooms();
3537
+ return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").sfuListRooms();
3297
3538
  }
3298
3539
  async callJoin(neighbourhoodUrl, roomName, sdpOffer) {
3299
- return await __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").sfuCallJoin(neighbourhoodUrl, roomName, sdpOffer);
3540
+ return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").sfuCallJoin(neighbourhoodUrl, roomName, sdpOffer);
3300
3541
  }
3301
3542
  async callLeave(neighbourhoodUrl, roomName) {
3302
- return await __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").sfuCallLeave(neighbourhoodUrl, roomName);
3543
+ return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").sfuCallLeave(neighbourhoodUrl, roomName);
3303
3544
  }
3304
3545
  async callSetQualityPreference(neighbourhoodUrl, roomName, preference) {
3305
- return await __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").sfuCallSetQualityPreference(neighbourhoodUrl, roomName, preference);
3546
+ return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").sfuCallSetQualityPreference(neighbourhoodUrl, roomName, preference);
3306
3547
  }
3307
3548
  async callAnswerServerOffer(neighbourhoodUrl, roomName, sdpAnswer) {
3308
- return await __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").sfuCallAnswerServerOffer(neighbourhoodUrl, roomName, sdpAnswer);
3549
+ return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").sfuCallAnswerServerOffer(neighbourhoodUrl, roomName, sdpAnswer);
3309
3550
  }
3310
3551
  subscribeCallRenegotiationOffer(targetDid, callback) {
3311
- return __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").subscribeSfuCallRenegotiationOffer(targetDid, callback);
3552
+ return __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").subscribeSfuCallRenegotiationOffer(targetDid, callback);
3312
3553
  }
3313
3554
  subscribeMigrateEvent(targetDid, callback) {
3314
- return __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").subscribeSfuMigrateEvent(targetDid, callback);
3555
+ return __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").subscribeSfuMigrateEvent(targetDid, callback);
3315
3556
  }
3316
3557
  async addIceCandidate(neighbourhoodUrl, roomName, candidate) {
3317
- return await __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").sfuAddIceCandidate(neighbourhoodUrl, roomName, candidate);
3558
+ return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").sfuAddIceCandidate(neighbourhoodUrl, roomName, candidate);
3318
3559
  }
3319
3560
  async sendData(neighbourhoodUrl, roomName, channelLabel, data, binary = false) {
3320
- return await __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").sfuSendData(neighbourhoodUrl, roomName, channelLabel, data, binary);
3561
+ return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").sfuSendData(neighbourhoodUrl, roomName, channelLabel, data, binary);
3321
3562
  }
3322
3563
  subscribeDataChannel(callback) {
3323
- return __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").subscribeSfuDataChannel(callback);
3564
+ return __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").subscribeSfuDataChannel(callback);
3324
3565
  }
3325
3566
  async sfuCascadeStatus() {
3326
- return await __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").sfuCascadeStatus();
3567
+ return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").sfuCascadeStatus();
3327
3568
  }
3328
3569
  async sfuQualityPreferences() {
3329
- return await __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").sfuQualityPreferences();
3570
+ return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").sfuQualityPreferences();
3330
3571
  }
3331
3572
  async sfuEnsureMembership(neighbourhoodUrl, did) {
3332
- return await __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").sfuEnsureMembership(neighbourhoodUrl, did);
3573
+ return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").sfuEnsureMembership(neighbourhoodUrl, did);
3333
3574
  }
3334
3575
  };
3335
3576
  _NeighbourhoodProxy_client = /* @__PURE__ */ new WeakMap(), _NeighbourhoodProxy_pID = /* @__PURE__ */ new WeakMap(), _NeighbourhoodProxy_agentDid = /* @__PURE__ */ new WeakMap(), _NeighbourhoodProxy_sessions = /* @__PURE__ */ new WeakMap(), _NeighbourhoodProxy_sfuStatusCache = /* @__PURE__ */ new WeakMap();
@@ -3366,7 +3607,7 @@ var LinkQuery = class {
3366
3607
  return true;
3367
3608
  }
3368
3609
  };
3369
- var __classPrivateFieldSet$8 = function(receiver, state, value, kind, f) {
3610
+ var __classPrivateFieldSet$9 = function(receiver, state, value, kind, f) {
3370
3611
  if (kind === "m")
3371
3612
  throw new TypeError("Private method is not writable");
3372
3613
  if (kind === "a" && !f)
@@ -3375,7 +3616,7 @@ var __classPrivateFieldSet$8 = function(receiver, state, value, kind, f) {
3375
3616
  throw new TypeError("Cannot write private member to an object whose class did not declare it");
3376
3617
  return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
3377
3618
  };
3378
- var __classPrivateFieldGet$8 = function(receiver, state, kind, f) {
3619
+ var __classPrivateFieldGet$9 = function(receiver, state, kind, f) {
3379
3620
  if (kind === "a" && !f)
3380
3621
  throw new TypeError("Private accessor was defined without a getter");
3381
3622
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
@@ -3398,44 +3639,44 @@ var Literal = class {
3398
3639
  if (url.startsWith("literal://"))
3399
3640
  throw new Error("literal:// format is no longer supported. Use literal: instead.");
3400
3641
  const l = new Literal();
3401
- __classPrivateFieldSet$8(l, _Literal_url, url, "f");
3642
+ __classPrivateFieldSet$9(l, _Literal_url, url, "f");
3402
3643
  return l;
3403
3644
  }
3404
3645
  static from(literal2) {
3405
3646
  const l = new Literal();
3406
- __classPrivateFieldSet$8(l, _Literal_literal, literal2, "f");
3647
+ __classPrivateFieldSet$9(l, _Literal_literal, literal2, "f");
3407
3648
  return l;
3408
3649
  }
3409
3650
  toUrl() {
3410
- if (__classPrivateFieldGet$8(this, _Literal_url, "f") && __classPrivateFieldGet$8(this, _Literal_literal, "f") === void 0)
3411
- return __classPrivateFieldGet$8(this, _Literal_url, "f");
3412
- if (__classPrivateFieldGet$8(this, _Literal_literal, "f") === void 0)
3651
+ if (__classPrivateFieldGet$9(this, _Literal_url, "f") && __classPrivateFieldGet$9(this, _Literal_literal, "f") === void 0)
3652
+ return __classPrivateFieldGet$9(this, _Literal_url, "f");
3653
+ if (__classPrivateFieldGet$9(this, _Literal_literal, "f") === void 0)
3413
3654
  throw new Error("Can't turn empty Literal into URL");
3414
3655
  let encoded;
3415
- switch (typeof __classPrivateFieldGet$8(this, _Literal_literal, "f")) {
3656
+ switch (typeof __classPrivateFieldGet$9(this, _Literal_literal, "f")) {
3416
3657
  case "string":
3417
- encoded = `string:${encodeRFC3986URIComponent(__classPrivateFieldGet$8(this, _Literal_literal, "f"))}`;
3658
+ encoded = `string:${encodeRFC3986URIComponent(__classPrivateFieldGet$9(this, _Literal_literal, "f"))}`;
3418
3659
  break;
3419
3660
  case "number":
3420
- encoded = `number:${encodeRFC3986URIComponent(__classPrivateFieldGet$8(this, _Literal_literal, "f"))}`;
3661
+ encoded = `number:${encodeRFC3986URIComponent(__classPrivateFieldGet$9(this, _Literal_literal, "f"))}`;
3421
3662
  break;
3422
3663
  case "boolean":
3423
- encoded = `boolean:${encodeRFC3986URIComponent(__classPrivateFieldGet$8(this, _Literal_literal, "f"))}`;
3664
+ encoded = `boolean:${encodeRFC3986URIComponent(__classPrivateFieldGet$9(this, _Literal_literal, "f"))}`;
3424
3665
  break;
3425
3666
  case "object":
3426
- encoded = `json:${encodeRFC3986URIComponent(JSON.stringify(__classPrivateFieldGet$8(this, _Literal_literal, "f")))}`;
3667
+ encoded = `json:${encodeRFC3986URIComponent(JSON.stringify(__classPrivateFieldGet$9(this, _Literal_literal, "f")))}`;
3427
3668
  break;
3428
3669
  }
3429
3670
  return `literal:${encoded}`;
3430
3671
  }
3431
3672
  get() {
3432
- if (__classPrivateFieldGet$8(this, _Literal_literal, "f") !== void 0)
3433
- return __classPrivateFieldGet$8(this, _Literal_literal, "f");
3434
- if (!__classPrivateFieldGet$8(this, _Literal_url, "f"))
3673
+ if (__classPrivateFieldGet$9(this, _Literal_literal, "f") !== void 0)
3674
+ return __classPrivateFieldGet$9(this, _Literal_literal, "f");
3675
+ if (!__classPrivateFieldGet$9(this, _Literal_url, "f"))
3435
3676
  throw new Error("Can't render empty Literal");
3436
- if (!__classPrivateFieldGet$8(this, _Literal_url, "f").startsWith("literal:"))
3677
+ if (!__classPrivateFieldGet$9(this, _Literal_url, "f").startsWith("literal:"))
3437
3678
  throw new Error("Can't render Literal from non-literal URL");
3438
- const body = __classPrivateFieldGet$8(this, _Literal_url, "f").substring(8);
3679
+ const body = __classPrivateFieldGet$9(this, _Literal_url, "f").substring(8);
3439
3680
  if (body.startsWith("string:")) {
3440
3681
  return decodeURIComponent(body.substring(7));
3441
3682
  }
@@ -4818,7 +5059,7 @@ function invalidatePerspectiveCache(perspectiveUUID) {
4818
5059
  }
4819
5060
  }
4820
5061
  }
4821
- var __classPrivateFieldSet$7 = function(receiver, state, value, kind, f) {
5062
+ var __classPrivateFieldSet$8 = function(receiver, state, value, kind, f) {
4822
5063
  if (kind === "m")
4823
5064
  throw new TypeError("Private method is not writable");
4824
5065
  if (kind === "a" && !f)
@@ -4827,7 +5068,7 @@ var __classPrivateFieldSet$7 = function(receiver, state, value, kind, f) {
4827
5068
  throw new TypeError("Cannot write private member to an object whose class did not declare it");
4828
5069
  return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
4829
5070
  };
4830
- var __classPrivateFieldGet$7 = function(receiver, state, kind, f) {
5071
+ var __classPrivateFieldGet$8 = function(receiver, state, kind, f) {
4831
5072
  if (kind === "a" && !f)
4832
5073
  throw new TypeError("Private accessor was defined without a getter");
4833
5074
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
@@ -4849,10 +5090,23 @@ var _LiveQuery_latest;
4849
5090
  var _LiveQuery_buffer;
4850
5091
  var _LiveQuery_unlisten;
4851
5092
  var _LiveQuery_unreconnect;
5093
+ var _LiveQuery_opening;
5094
+ var _LiveQuery_retryTimer;
5095
+ var _LiveQuery_reopening;
5096
+ var _LiveQuery_statusListeners;
4852
5097
  var _LiveQuery_start;
5098
+ var _LiveQuery_reopen;
5099
+ var _LiveQuery_clearRetry;
5100
+ var _LiveQuery_emit;
4853
5101
  var _LiveQuery_replace;
4854
5102
  var _LiveQuery_receive;
4855
5103
  var _LiveQuery_resync;
5104
+ var REOPEN_BASE_DELAY_MS = 1e3;
5105
+ var REOPEN_MAX_DELAY_MS = 6e4;
5106
+ function reopenDelay(failures, random = Math.random) {
5107
+ const ceiling = Math.min(REOPEN_BASE_DELAY_MS * 2 ** Math.max(0, failures - 1), REOPEN_MAX_DELAY_MS);
5108
+ return ceiling / 2 + random() * ceiling / 2;
5109
+ }
4856
5110
  function applyUpdate(result, update) {
4857
5111
  if ("result" in update)
4858
5112
  return update.result;
@@ -4899,106 +5153,196 @@ var LiveQuery = class {
4899
5153
  _LiveQuery_buffer.set(this, null);
4900
5154
  _LiveQuery_unlisten.set(this, void 0);
4901
5155
  _LiveQuery_unreconnect.set(this, void 0);
4902
- __classPrivateFieldSet$7(this, _LiveQuery_client, client, "f");
4903
- __classPrivateFieldSet$7(this, _LiveQuery_uuid, uuid, "f");
4904
- __classPrivateFieldSet$7(this, _LiveQuery_open, open, "f");
4905
- __classPrivateFieldSet$7(this, _LiveQuery_onResult, onResult, "f");
4906
- __classPrivateFieldSet$7(this, _LiveQuery_unlisten, client.onQueryUpdate((update) => __classPrivateFieldGet$7(this, _LiveQuery_instances, "m", _LiveQuery_receive).call(this, update)), "f");
4907
- __classPrivateFieldSet$7(this, _LiveQuery_unreconnect, client.onReconnect(() => {
4908
- this.start().catch((e) => console.error("Error re-opening live query after reconnect:", e));
4909
- }), "f");
5156
+ _LiveQuery_opening.set(this, void 0);
5157
+ _LiveQuery_retryTimer.set(this, void 0);
5158
+ _LiveQuery_reopening.set(this, false);
5159
+ _LiveQuery_statusListeners.set(
5160
+ this,
5161
+ /* @__PURE__ */ new Set()
5162
+ );
5163
+ __classPrivateFieldSet$8(this, _LiveQuery_client, client, "f");
5164
+ __classPrivateFieldSet$8(this, _LiveQuery_uuid, uuid, "f");
5165
+ __classPrivateFieldSet$8(this, _LiveQuery_open, open, "f");
5166
+ __classPrivateFieldSet$8(this, _LiveQuery_onResult, onResult, "f");
5167
+ __classPrivateFieldSet$8(this, _LiveQuery_unlisten, client.onQueryUpdate((update) => __classPrivateFieldGet$8(this, _LiveQuery_instances, "m", _LiveQuery_receive).call(this, update)), "f");
5168
+ __classPrivateFieldSet$8(this, _LiveQuery_unreconnect, client.onReconnect(() => __classPrivateFieldGet$8(this, _LiveQuery_instances, "m", _LiveQuery_reopen).call(this)), "f");
4910
5169
  }
4911
5170
  get id() {
4912
- return __classPrivateFieldGet$7(this, _LiveQuery_id, "f");
5171
+ return __classPrivateFieldGet$8(this, _LiveQuery_id, "f");
4913
5172
  }
4914
5173
  get result() {
4915
- return __classPrivateFieldGet$7(this, _LiveQuery_result, "f");
5174
+ return __classPrivateFieldGet$8(this, _LiveQuery_result, "f");
5175
+ }
5176
+ get reopening() {
5177
+ return __classPrivateFieldGet$8(this, _LiveQuery_reopening, "f");
5178
+ }
5179
+ onStatus(listener) {
5180
+ __classPrivateFieldGet$8(this, _LiveQuery_statusListeners, "f").add(listener);
5181
+ return () => __classPrivateFieldGet$8(this, _LiveQuery_statusListeners, "f").delete(listener);
4916
5182
  }
4917
5183
  start() {
4918
5184
  var _a;
4919
- __classPrivateFieldSet$7(this, _LiveQuery_latest, __classPrivateFieldGet$7(this, _LiveQuery_instances, "m", _LiveQuery_start).call(this, __classPrivateFieldSet$7(this, _LiveQuery_generation, (_a = __classPrivateFieldGet$7(this, _LiveQuery_generation, "f"), ++_a), "f")), "f");
4920
- return __classPrivateFieldGet$7(this, _LiveQuery_latest, "f");
5185
+ __classPrivateFieldGet$8(this, _LiveQuery_instances, "m", _LiveQuery_clearRetry).call(this);
5186
+ __classPrivateFieldSet$8(this, _LiveQuery_latest, __classPrivateFieldGet$8(this, _LiveQuery_instances, "m", _LiveQuery_start).call(this, __classPrivateFieldSet$8(this, _LiveQuery_generation, (_a = __classPrivateFieldGet$8(this, _LiveQuery_generation, "f"), ++_a), "f")), "f");
5187
+ return __classPrivateFieldGet$8(this, _LiveQuery_latest, "f");
4921
5188
  }
4922
- dispose() {
5189
+ dispose(options = {}) {
4923
5190
  var _a;
4924
- __classPrivateFieldSet$7(this, _LiveQuery_disposed, true, "f");
4925
- __classPrivateFieldSet$7(this, _LiveQuery_generation, (_a = __classPrivateFieldGet$7(this, _LiveQuery_generation, "f"), _a++, _a), "f");
4926
- __classPrivateFieldGet$7(this, _LiveQuery_unlisten, "f").call(this);
4927
- __classPrivateFieldGet$7(this, _LiveQuery_unreconnect, "f").call(this);
4928
- if (__classPrivateFieldGet$7(this, _LiveQuery_id, "f"))
4929
- __classPrivateFieldGet$7(this, _LiveQuery_client, "f").disposeQuerySubscription(__classPrivateFieldGet$7(this, _LiveQuery_uuid, "f"), __classPrivateFieldGet$7(this, _LiveQuery_id, "f")).catch(() => {
5191
+ __classPrivateFieldSet$8(this, _LiveQuery_disposed, true, "f");
5192
+ __classPrivateFieldSet$8(this, _LiveQuery_generation, (_a = __classPrivateFieldGet$8(this, _LiveQuery_generation, "f"), _a++, _a), "f");
5193
+ __classPrivateFieldGet$8(this, _LiveQuery_instances, "m", _LiveQuery_clearRetry).call(this);
5194
+ __classPrivateFieldGet$8(this, _LiveQuery_statusListeners, "f").clear();
5195
+ __classPrivateFieldGet$8(this, _LiveQuery_unlisten, "f").call(this);
5196
+ __classPrivateFieldGet$8(this, _LiveQuery_unreconnect, "f").call(this);
5197
+ if (options.cancelOpening)
5198
+ __classPrivateFieldGet$8(this, _LiveQuery_opening, "f")?.abort();
5199
+ if (__classPrivateFieldGet$8(this, _LiveQuery_id, "f"))
5200
+ __classPrivateFieldGet$8(this, _LiveQuery_client, "f").disposeQuerySubscription(__classPrivateFieldGet$8(this, _LiveQuery_uuid, "f"), __classPrivateFieldGet$8(this, _LiveQuery_id, "f")).catch(() => {
4930
5201
  });
4931
5202
  }
4932
5203
  };
4933
- _LiveQuery_client = /* @__PURE__ */ new WeakMap(), _LiveQuery_uuid = /* @__PURE__ */ new WeakMap(), _LiveQuery_open = /* @__PURE__ */ new WeakMap(), _LiveQuery_onResult = /* @__PURE__ */ new WeakMap(), _LiveQuery_id = /* @__PURE__ */ new WeakMap(), _LiveQuery_revision = /* @__PURE__ */ new WeakMap(), _LiveQuery_result = /* @__PURE__ */ new WeakMap(), _LiveQuery_started = /* @__PURE__ */ new WeakMap(), _LiveQuery_disposed = /* @__PURE__ */ new WeakMap(), _LiveQuery_generation = /* @__PURE__ */ new WeakMap(), _LiveQuery_latest = /* @__PURE__ */ new WeakMap(), _LiveQuery_buffer = /* @__PURE__ */ new WeakMap(), _LiveQuery_unlisten = /* @__PURE__ */ new WeakMap(), _LiveQuery_unreconnect = /* @__PURE__ */ new WeakMap(), _LiveQuery_instances = /* @__PURE__ */ new WeakSet(), _LiveQuery_start = async function _LiveQuery_start2(generation) {
4934
- __classPrivateFieldSet$7(this, _LiveQuery_buffer, [], "f");
5204
+ _LiveQuery_client = /* @__PURE__ */ new WeakMap(), _LiveQuery_uuid = /* @__PURE__ */ new WeakMap(), _LiveQuery_open = /* @__PURE__ */ new WeakMap(), _LiveQuery_onResult = /* @__PURE__ */ new WeakMap(), _LiveQuery_id = /* @__PURE__ */ new WeakMap(), _LiveQuery_revision = /* @__PURE__ */ new WeakMap(), _LiveQuery_result = /* @__PURE__ */ new WeakMap(), _LiveQuery_started = /* @__PURE__ */ new WeakMap(), _LiveQuery_disposed = /* @__PURE__ */ new WeakMap(), _LiveQuery_generation = /* @__PURE__ */ new WeakMap(), _LiveQuery_latest = /* @__PURE__ */ new WeakMap(), _LiveQuery_buffer = /* @__PURE__ */ new WeakMap(), _LiveQuery_unlisten = /* @__PURE__ */ new WeakMap(), _LiveQuery_unreconnect = /* @__PURE__ */ new WeakMap(), _LiveQuery_opening = /* @__PURE__ */ new WeakMap(), _LiveQuery_retryTimer = /* @__PURE__ */ new WeakMap(), _LiveQuery_reopening = /* @__PURE__ */ new WeakMap(), _LiveQuery_statusListeners = /* @__PURE__ */ new WeakMap(), _LiveQuery_instances = /* @__PURE__ */ new WeakSet(), _LiveQuery_start = async function _LiveQuery_start2(generation) {
5205
+ __classPrivateFieldSet$8(this, _LiveQuery_buffer, [], "f");
5206
+ const opening = new AbortController();
5207
+ __classPrivateFieldSet$8(this, _LiveQuery_opening, opening, "f");
4935
5208
  let subscribed;
4936
5209
  try {
4937
- subscribed = await __classPrivateFieldGet$7(this, _LiveQuery_open, "f").call(this);
5210
+ subscribed = await __classPrivateFieldGet$8(this, _LiveQuery_open, "f").call(this, opening.signal);
4938
5211
  } catch (e) {
4939
- if (generation === __classPrivateFieldGet$7(this, _LiveQuery_generation, "f"))
4940
- __classPrivateFieldSet$7(this, _LiveQuery_buffer, null, "f");
5212
+ if (generation === __classPrivateFieldGet$8(this, _LiveQuery_generation, "f"))
5213
+ __classPrivateFieldSet$8(this, _LiveQuery_buffer, null, "f");
4941
5214
  throw e;
5215
+ } finally {
5216
+ if (__classPrivateFieldGet$8(this, _LiveQuery_opening, "f") === opening)
5217
+ __classPrivateFieldSet$8(this, _LiveQuery_opening, void 0, "f");
4942
5218
  }
4943
- if (__classPrivateFieldGet$7(this, _LiveQuery_disposed, "f") || generation !== __classPrivateFieldGet$7(this, _LiveQuery_generation, "f")) {
4944
- __classPrivateFieldGet$7(this, _LiveQuery_client, "f").disposeQuerySubscription(__classPrivateFieldGet$7(this, _LiveQuery_uuid, "f"), subscribed.subscriptionId).catch(() => {
5219
+ if (__classPrivateFieldGet$8(this, _LiveQuery_disposed, "f") || generation !== __classPrivateFieldGet$8(this, _LiveQuery_generation, "f")) {
5220
+ __classPrivateFieldGet$8(this, _LiveQuery_client, "f").disposeQuerySubscription(__classPrivateFieldGet$8(this, _LiveQuery_uuid, "f"), subscribed.subscriptionId).catch(() => {
4945
5221
  });
4946
- return __classPrivateFieldGet$7(this, _LiveQuery_disposed, "f") ? __classPrivateFieldGet$7(this, _LiveQuery_result, "f") ?? subscribed.result : __classPrivateFieldGet$7(this, _LiveQuery_latest, "f");
5222
+ return __classPrivateFieldGet$8(this, _LiveQuery_disposed, "f") ? __classPrivateFieldGet$8(this, _LiveQuery_result, "f") ?? subscribed.result : __classPrivateFieldGet$8(this, _LiveQuery_latest, "f");
5223
+ }
5224
+ __classPrivateFieldSet$8(this, _LiveQuery_id, subscribed.subscriptionId, "f");
5225
+ __classPrivateFieldGet$8(this, _LiveQuery_instances, "m", _LiveQuery_replace).call(this, subscribed.revision, subscribed.result);
5226
+ return __classPrivateFieldGet$8(this, _LiveQuery_result, "f");
5227
+ }, _LiveQuery_reopen = function _LiveQuery_reopen2(failures = 0) {
5228
+ if (__classPrivateFieldGet$8(this, _LiveQuery_disposed, "f"))
5229
+ return;
5230
+ const reopened = this.start();
5231
+ const generation = __classPrivateFieldGet$8(this, _LiveQuery_generation, "f");
5232
+ reopened.then(() => {
5233
+ if (__classPrivateFieldGet$8(this, _LiveQuery_disposed, "f") || generation !== __classPrivateFieldGet$8(this, _LiveQuery_generation, "f") || !__classPrivateFieldGet$8(this, _LiveQuery_reopening, "f"))
5234
+ return;
5235
+ __classPrivateFieldSet$8(this, _LiveQuery_reopening, false, "f");
5236
+ __classPrivateFieldGet$8(this, _LiveQuery_instances, "m", _LiveQuery_emit).call(this, { state: "open" });
5237
+ }, (error) => {
5238
+ if (__classPrivateFieldGet$8(this, _LiveQuery_disposed, "f") || generation !== __classPrivateFieldGet$8(this, _LiveQuery_generation, "f"))
5239
+ return;
5240
+ const retryInMs = reopenDelay(failures + 1);
5241
+ console.error(`Error re-opening live query (attempt ${failures + 1}), retrying in ${Math.round(retryInMs)}ms:`, error);
5242
+ __classPrivateFieldSet$8(this, _LiveQuery_reopening, true, "f");
5243
+ __classPrivateFieldGet$8(this, _LiveQuery_instances, "m", _LiveQuery_emit).call(this, { state: "reopening", error, retryInMs });
5244
+ const timer = setTimeout(() => {
5245
+ __classPrivateFieldSet$8(this, _LiveQuery_retryTimer, void 0, "f");
5246
+ __classPrivateFieldGet$8(this, _LiveQuery_instances, "m", _LiveQuery_reopen2).call(this, failures + 1);
5247
+ }, retryInMs);
5248
+ if (typeof timer?.unref === "function")
5249
+ timer.unref();
5250
+ __classPrivateFieldSet$8(this, _LiveQuery_retryTimer, timer, "f");
5251
+ });
5252
+ }, _LiveQuery_clearRetry = function _LiveQuery_clearRetry2() {
5253
+ if (__classPrivateFieldGet$8(this, _LiveQuery_retryTimer, "f") === void 0)
5254
+ return;
5255
+ clearTimeout(__classPrivateFieldGet$8(this, _LiveQuery_retryTimer, "f"));
5256
+ __classPrivateFieldSet$8(this, _LiveQuery_retryTimer, void 0, "f");
5257
+ }, _LiveQuery_emit = function _LiveQuery_emit2(status) {
5258
+ for (const listener of [...__classPrivateFieldGet$8(this, _LiveQuery_statusListeners, "f")]) {
5259
+ try {
5260
+ listener(status);
5261
+ } catch (e) {
5262
+ console.error("Error in live query status listener:", e);
5263
+ }
4947
5264
  }
4948
- __classPrivateFieldSet$7(this, _LiveQuery_id, subscribed.subscriptionId, "f");
4949
- __classPrivateFieldGet$7(this, _LiveQuery_instances, "m", _LiveQuery_replace).call(this, subscribed.revision, subscribed.result);
4950
- return __classPrivateFieldGet$7(this, _LiveQuery_result, "f");
4951
5265
  }, _LiveQuery_replace = function _LiveQuery_replace2(revision, result) {
4952
- __classPrivateFieldSet$7(this, _LiveQuery_revision, revision, "f");
4953
- __classPrivateFieldSet$7(this, _LiveQuery_result, result, "f");
4954
- const buffered = __classPrivateFieldGet$7(this, _LiveQuery_buffer, "f") ?? [];
4955
- __classPrivateFieldSet$7(this, _LiveQuery_buffer, null, "f");
4956
- if (__classPrivateFieldGet$7(this, _LiveQuery_started, "f"))
4957
- __classPrivateFieldGet$7(this, _LiveQuery_onResult, "f").call(this, result);
4958
- __classPrivateFieldSet$7(this, _LiveQuery_started, true, "f");
5266
+ __classPrivateFieldSet$8(this, _LiveQuery_revision, revision, "f");
5267
+ __classPrivateFieldSet$8(this, _LiveQuery_result, result, "f");
5268
+ const buffered = __classPrivateFieldGet$8(this, _LiveQuery_buffer, "f") ?? [];
5269
+ __classPrivateFieldSet$8(this, _LiveQuery_buffer, null, "f");
5270
+ if (__classPrivateFieldGet$8(this, _LiveQuery_started, "f"))
5271
+ __classPrivateFieldGet$8(this, _LiveQuery_onResult, "f").call(this, result);
5272
+ __classPrivateFieldSet$8(this, _LiveQuery_started, true, "f");
4959
5273
  for (const update of buffered)
4960
- __classPrivateFieldGet$7(this, _LiveQuery_instances, "m", _LiveQuery_receive).call(this, update);
5274
+ __classPrivateFieldGet$8(this, _LiveQuery_instances, "m", _LiveQuery_receive).call(this, update);
4961
5275
  }, _LiveQuery_receive = function _LiveQuery_receive2(update) {
4962
- if (__classPrivateFieldGet$7(this, _LiveQuery_buffer, "f")) {
4963
- __classPrivateFieldGet$7(this, _LiveQuery_buffer, "f").push(update);
5276
+ if (__classPrivateFieldGet$8(this, _LiveQuery_buffer, "f")) {
5277
+ __classPrivateFieldGet$8(this, _LiveQuery_buffer, "f").push(update);
4964
5278
  return;
4965
5279
  }
4966
5280
  if ("lagged" in update) {
4967
- if (__classPrivateFieldGet$7(this, _LiveQuery_id, "f"))
4968
- __classPrivateFieldGet$7(this, _LiveQuery_instances, "m", _LiveQuery_resync).call(this);
5281
+ if (__classPrivateFieldGet$8(this, _LiveQuery_id, "f"))
5282
+ __classPrivateFieldGet$8(this, _LiveQuery_instances, "m", _LiveQuery_resync).call(this);
4969
5283
  return;
4970
5284
  }
4971
- if (update.subscriptionId !== __classPrivateFieldGet$7(this, _LiveQuery_id, "f") || update.revision <= __classPrivateFieldGet$7(this, _LiveQuery_revision, "f"))
5285
+ if (update.subscriptionId !== __classPrivateFieldGet$8(this, _LiveQuery_id, "f") || update.revision <= __classPrivateFieldGet$8(this, _LiveQuery_revision, "f"))
4972
5286
  return;
4973
- if (update.revision !== __classPrivateFieldGet$7(this, _LiveQuery_revision, "f") + 1) {
4974
- __classPrivateFieldGet$7(this, _LiveQuery_instances, "m", _LiveQuery_resync).call(this);
5287
+ if (update.revision !== __classPrivateFieldGet$8(this, _LiveQuery_revision, "f") + 1) {
5288
+ __classPrivateFieldGet$8(this, _LiveQuery_instances, "m", _LiveQuery_resync).call(this);
4975
5289
  return;
4976
5290
  }
4977
5291
  let result;
4978
5292
  try {
4979
- result = applyUpdate(__classPrivateFieldGet$7(this, _LiveQuery_result, "f"), update);
5293
+ result = applyUpdate(__classPrivateFieldGet$8(this, _LiveQuery_result, "f"), update);
4980
5294
  } catch {
4981
- __classPrivateFieldGet$7(this, _LiveQuery_instances, "m", _LiveQuery_resync).call(this);
5295
+ __classPrivateFieldGet$8(this, _LiveQuery_instances, "m", _LiveQuery_resync).call(this);
4982
5296
  return;
4983
5297
  }
4984
- __classPrivateFieldSet$7(this, _LiveQuery_revision, update.revision, "f");
4985
- __classPrivateFieldSet$7(this, _LiveQuery_result, result, "f");
4986
- __classPrivateFieldGet$7(this, _LiveQuery_onResult, "f").call(this, __classPrivateFieldGet$7(this, _LiveQuery_result, "f"));
5298
+ __classPrivateFieldSet$8(this, _LiveQuery_revision, update.revision, "f");
5299
+ __classPrivateFieldSet$8(this, _LiveQuery_result, result, "f");
5300
+ __classPrivateFieldGet$8(this, _LiveQuery_onResult, "f").call(this, __classPrivateFieldGet$8(this, _LiveQuery_result, "f"));
4987
5301
  }, _LiveQuery_resync = function _LiveQuery_resync2() {
4988
- const generation = __classPrivateFieldGet$7(this, _LiveQuery_generation, "f");
4989
- const id = __classPrivateFieldGet$7(this, _LiveQuery_id, "f");
4990
- __classPrivateFieldSet$7(this, _LiveQuery_buffer, [], "f");
4991
- __classPrivateFieldGet$7(this, _LiveQuery_client, "f").resyncSubscription(__classPrivateFieldGet$7(this, _LiveQuery_uuid, "f"), id).then(({ revision, result }) => {
4992
- if (!__classPrivateFieldGet$7(this, _LiveQuery_disposed, "f") && generation === __classPrivateFieldGet$7(this, _LiveQuery_generation, "f"))
4993
- __classPrivateFieldGet$7(this, _LiveQuery_instances, "m", _LiveQuery_replace).call(this, revision, result);
5302
+ const generation = __classPrivateFieldGet$8(this, _LiveQuery_generation, "f");
5303
+ const id = __classPrivateFieldGet$8(this, _LiveQuery_id, "f");
5304
+ __classPrivateFieldSet$8(this, _LiveQuery_buffer, [], "f");
5305
+ __classPrivateFieldGet$8(this, _LiveQuery_client, "f").resyncSubscription(__classPrivateFieldGet$8(this, _LiveQuery_uuid, "f"), id).then(({ revision, result }) => {
5306
+ if (!__classPrivateFieldGet$8(this, _LiveQuery_disposed, "f") && generation === __classPrivateFieldGet$8(this, _LiveQuery_generation, "f"))
5307
+ __classPrivateFieldGet$8(this, _LiveQuery_instances, "m", _LiveQuery_replace).call(this, revision, result);
4994
5308
  }, () => {
4995
- if (!__classPrivateFieldGet$7(this, _LiveQuery_disposed, "f") && generation === __classPrivateFieldGet$7(this, _LiveQuery_generation, "f")) {
4996
- __classPrivateFieldGet$7(this, _LiveQuery_client, "f").disposeQuerySubscription(__classPrivateFieldGet$7(this, _LiveQuery_uuid, "f"), id).catch(() => {
5309
+ if (!__classPrivateFieldGet$8(this, _LiveQuery_disposed, "f") && generation === __classPrivateFieldGet$8(this, _LiveQuery_generation, "f")) {
5310
+ __classPrivateFieldGet$8(this, _LiveQuery_client, "f").disposeQuerySubscription(__classPrivateFieldGet$8(this, _LiveQuery_uuid, "f"), id).catch(() => {
4997
5311
  });
4998
- this.start().catch((e) => console.error("Error re-opening live query:", e));
5312
+ __classPrivateFieldGet$8(this, _LiveQuery_instances, "m", _LiveQuery_reopen).call(this);
4999
5313
  }
5000
5314
  });
5001
5315
  };
5316
+ function compareCodePoints(a, b) {
5317
+ const as = Array.from(a);
5318
+ const bs = Array.from(b);
5319
+ const n = Math.min(as.length, bs.length);
5320
+ for (let i = 0; i < n; i++) {
5321
+ const d = as[i].codePointAt(0) - bs[i].codePointAt(0);
5322
+ if (d !== 0)
5323
+ return d;
5324
+ }
5325
+ return as.length - bs.length;
5326
+ }
5327
+ var STATE_VALUE_DECIMAL = /^[+-]?(?:[0-9]+(?:\.[0-9]*)?|\.[0-9]+)(?:[eE][+-]?[0-9]+)?$/;
5328
+ var STATE_VALUE_INFINITE = /^[+-]?[iI][nN][fF](?:[iI][nN][iI][tT][yY])?$/;
5329
+ function decodeStateValue(target) {
5330
+ const payload = target.startsWith("literal:number:") ? target.slice("literal:number:".length) : void 0;
5331
+ if (payload === void 0)
5332
+ return NaN;
5333
+ let decoded;
5334
+ try {
5335
+ decoded = decodeURIComponent(payload);
5336
+ } catch {
5337
+ return NaN;
5338
+ }
5339
+ if (STATE_VALUE_DECIMAL.test(decoded))
5340
+ return Number(decoded);
5341
+ if (STATE_VALUE_INFINITE.test(decoded)) {
5342
+ return decoded.startsWith("-") ? -Infinity : Infinity;
5343
+ }
5344
+ return NaN;
5345
+ }
5002
5346
  function isModelQueryShape(v) {
5003
5347
  if (typeof v !== "object" || v === null || typeof v.className !== "string" || v.className.length === 0) {
5004
5348
  return false;
@@ -5278,7 +5622,7 @@ var SHACLFlow = class {
5278
5622
  const stateName = nameLink ? Literal.fromUrl(nameLink.target).get() : "";
5279
5623
  stateUriToName.set(stateUri, stateName);
5280
5624
  const valueLink = links.find((l) => l.source === stateUri && l.predicate === "ad4m://stateValue");
5281
- const stateValue = valueLink ? Literal.fromUrl(valueLink.target).get() : 0;
5625
+ const stateValue = valueLink ? decodeStateValue(valueLink.target) : 0;
5282
5626
  const hintLink = links.find((l) => l.source === stateUri && l.predicate === "ad4m://interpretationHint");
5283
5627
  let interpretationHint;
5284
5628
  if (hintLink) {
@@ -5334,7 +5678,18 @@ var SHACLFlow = class {
5334
5678
  ...consensusRule !== void 0 ? { consensusRule } : {}
5335
5679
  });
5336
5680
  }
5337
- flow._states.sort((a, b) => a.value - b.value);
5681
+ flow._states.sort((a, b) => {
5682
+ const aNaN = Number.isNaN(a.value);
5683
+ const bNaN = Number.isNaN(b.value);
5684
+ if (aNaN !== bNaN)
5685
+ return aNaN ? 1 : -1;
5686
+ if (!aNaN && a.value !== b.value)
5687
+ return a.value < b.value ? -1 : 1;
5688
+ return compareCodePoints(a.name, b.name);
5689
+ });
5690
+ if (flow._states.length > 1 && !Number.isNaN(flow._states[0].value) && flow._states[0].value === flow._states[1].value) {
5691
+ console.warn(`flow \`${flowUri}\`: states \`${flow._states[0].name}\` and \`${flow._states[1].name}\` tie on the lowest value ${flow._states[0].value}; \`${flow._states[0].name}\` is the initial state by name order (#1202)`);
5692
+ }
5338
5693
  const transitionLinks = links.filter((l) => l.source === flowUri && l.predicate === "ad4m://hasTransition");
5339
5694
  for (const transitionLink of transitionLinks) {
5340
5695
  const transitionUri = transitionLink.target;
@@ -5453,14 +5808,14 @@ SHACLFlow.STATE_AND_TRANSITION_PREDICATES = [
5453
5808
  "ad4m://toState",
5454
5809
  "ad4m://transitionActions"
5455
5810
  ];
5456
- var __classPrivateFieldGet$6 = function(receiver, state, kind, f) {
5811
+ var __classPrivateFieldGet$7 = function(receiver, state, kind, f) {
5457
5812
  if (kind === "a" && !f)
5458
5813
  throw new TypeError("Private accessor was defined without a getter");
5459
5814
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
5460
5815
  throw new TypeError("Cannot read private member from an object whose class did not declare it");
5461
5816
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5462
5817
  };
5463
- var __classPrivateFieldSet$6 = function(receiver, state, value, kind, f) {
5818
+ var __classPrivateFieldSet$7 = function(receiver, state, value, kind, f) {
5464
5819
  if (kind === "m")
5465
5820
  throw new TypeError("Private method is not writable");
5466
5821
  if (kind === "a" && !f)
@@ -5501,46 +5856,52 @@ var QuerySubscriptionProxy = class {
5501
5856
  _QuerySubscriptionProxy_initialized.set(this, void 0);
5502
5857
  _QuerySubscriptionProxy_initResolve.set(this, void 0);
5503
5858
  _QuerySubscriptionProxy_initReject.set(this, void 0);
5504
- const open = className === void 0 ? () => client.subscribeQuery(uuid, query) : () => client.modelSubscribe(uuid, className, query);
5505
- __classPrivateFieldSet$6(this, _QuerySubscriptionProxy_live, new LiveQuery(client, uuid, open, (result) => __classPrivateFieldGet$6(this, _QuerySubscriptionProxy_instances, "m", _QuerySubscriptionProxy_deliver).call(this, result)), "f");
5506
- __classPrivateFieldSet$6(this, _QuerySubscriptionProxy_initialized, new Promise((resolve, reject) => {
5507
- __classPrivateFieldSet$6(this, _QuerySubscriptionProxy_initResolve, resolve, "f");
5508
- __classPrivateFieldSet$6(this, _QuerySubscriptionProxy_initReject, reject, "f");
5859
+ const open = className === void 0 ? (signal) => client.subscribeQuery(uuid, query, { signal }) : (signal) => client.modelSubscribe(uuid, className, query, { signal });
5860
+ __classPrivateFieldSet$7(this, _QuerySubscriptionProxy_live, new LiveQuery(client, uuid, open, (result) => __classPrivateFieldGet$7(this, _QuerySubscriptionProxy_instances, "m", _QuerySubscriptionProxy_deliver).call(this, result)), "f");
5861
+ __classPrivateFieldSet$7(this, _QuerySubscriptionProxy_initialized, new Promise((resolve, reject) => {
5862
+ __classPrivateFieldSet$7(this, _QuerySubscriptionProxy_initResolve, resolve, "f");
5863
+ __classPrivateFieldSet$7(this, _QuerySubscriptionProxy_initReject, reject, "f");
5509
5864
  }), "f");
5510
- __classPrivateFieldGet$6(this, _QuerySubscriptionProxy_initialized, "f").catch(() => {
5865
+ __classPrivateFieldGet$7(this, _QuerySubscriptionProxy_initialized, "f").catch(() => {
5511
5866
  });
5512
5867
  }
5513
5868
  async subscribe() {
5514
5869
  try {
5515
- __classPrivateFieldGet$6(this, _QuerySubscriptionProxy_instances, "m", _QuerySubscriptionProxy_deliver).call(this, await __classPrivateFieldGet$6(this, _QuerySubscriptionProxy_live, "f").start());
5870
+ __classPrivateFieldGet$7(this, _QuerySubscriptionProxy_instances, "m", _QuerySubscriptionProxy_deliver).call(this, await __classPrivateFieldGet$7(this, _QuerySubscriptionProxy_live, "f").start());
5516
5871
  } catch (error) {
5517
- __classPrivateFieldGet$6(this, _QuerySubscriptionProxy_initReject, "f")?.call(this, error);
5518
- __classPrivateFieldSet$6(this, _QuerySubscriptionProxy_initResolve, __classPrivateFieldSet$6(this, _QuerySubscriptionProxy_initReject, void 0, "f"), "f");
5872
+ __classPrivateFieldGet$7(this, _QuerySubscriptionProxy_initReject, "f")?.call(this, error);
5873
+ __classPrivateFieldSet$7(this, _QuerySubscriptionProxy_initResolve, __classPrivateFieldSet$7(this, _QuerySubscriptionProxy_initReject, void 0, "f"), "f");
5519
5874
  throw error;
5520
5875
  }
5521
5876
  }
5522
5877
  get id() {
5523
- return __classPrivateFieldGet$6(this, _QuerySubscriptionProxy_live, "f").id;
5878
+ return __classPrivateFieldGet$7(this, _QuerySubscriptionProxy_live, "f").id;
5524
5879
  }
5525
5880
  get initialized() {
5526
- return __classPrivateFieldGet$6(this, _QuerySubscriptionProxy_initialized, "f");
5881
+ return __classPrivateFieldGet$7(this, _QuerySubscriptionProxy_initialized, "f");
5527
5882
  }
5528
5883
  get result() {
5529
- return __classPrivateFieldGet$6(this, _QuerySubscriptionProxy_live, "f").result;
5884
+ return __classPrivateFieldGet$7(this, _QuerySubscriptionProxy_live, "f").result;
5530
5885
  }
5531
5886
  onResult(callback) {
5532
- __classPrivateFieldGet$6(this, _QuerySubscriptionProxy_callbacks, "f").add(callback);
5533
- return () => __classPrivateFieldGet$6(this, _QuerySubscriptionProxy_callbacks, "f").delete(callback);
5887
+ __classPrivateFieldGet$7(this, _QuerySubscriptionProxy_callbacks, "f").add(callback);
5888
+ return () => __classPrivateFieldGet$7(this, _QuerySubscriptionProxy_callbacks, "f").delete(callback);
5534
5889
  }
5535
- dispose() {
5536
- __classPrivateFieldGet$6(this, _QuerySubscriptionProxy_live, "f").dispose();
5537
- __classPrivateFieldGet$6(this, _QuerySubscriptionProxy_callbacks, "f").clear();
5890
+ get reopening() {
5891
+ return __classPrivateFieldGet$7(this, _QuerySubscriptionProxy_live, "f").reopening;
5892
+ }
5893
+ onStatus(listener) {
5894
+ return __classPrivateFieldGet$7(this, _QuerySubscriptionProxy_live, "f").onStatus(listener);
5895
+ }
5896
+ dispose(options = {}) {
5897
+ __classPrivateFieldGet$7(this, _QuerySubscriptionProxy_live, "f").dispose(options);
5898
+ __classPrivateFieldGet$7(this, _QuerySubscriptionProxy_callbacks, "f").clear();
5538
5899
  }
5539
5900
  };
5540
5901
  _QuerySubscriptionProxy_live = /* @__PURE__ */ new WeakMap(), _QuerySubscriptionProxy_callbacks = /* @__PURE__ */ new WeakMap(), _QuerySubscriptionProxy_initialized = /* @__PURE__ */ new WeakMap(), _QuerySubscriptionProxy_initResolve = /* @__PURE__ */ new WeakMap(), _QuerySubscriptionProxy_initReject = /* @__PURE__ */ new WeakMap(), _QuerySubscriptionProxy_instances = /* @__PURE__ */ new WeakSet(), _QuerySubscriptionProxy_deliver = function _QuerySubscriptionProxy_deliver2(result) {
5541
- __classPrivateFieldGet$6(this, _QuerySubscriptionProxy_initResolve, "f")?.call(this, true);
5542
- __classPrivateFieldSet$6(this, _QuerySubscriptionProxy_initResolve, __classPrivateFieldSet$6(this, _QuerySubscriptionProxy_initReject, void 0, "f"), "f");
5543
- for (const callback of __classPrivateFieldGet$6(this, _QuerySubscriptionProxy_callbacks, "f")) {
5902
+ __classPrivateFieldGet$7(this, _QuerySubscriptionProxy_initResolve, "f")?.call(this, true);
5903
+ __classPrivateFieldSet$7(this, _QuerySubscriptionProxy_initResolve, __classPrivateFieldSet$7(this, _QuerySubscriptionProxy_initReject, void 0, "f"), "f");
5904
+ for (const callback of __classPrivateFieldGet$7(this, _QuerySubscriptionProxy_callbacks, "f")) {
5544
5905
  try {
5545
5906
  callback(result);
5546
5907
  } catch (e) {
@@ -5550,7 +5911,7 @@ _QuerySubscriptionProxy_live = /* @__PURE__ */ new WeakMap(), _QuerySubscription
5550
5911
  };
5551
5912
  var PerspectiveProxy = class {
5552
5913
  get client() {
5553
- return __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f");
5914
+ return __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f");
5554
5915
  }
5555
5916
  constructor(handle, ad4m) {
5556
5917
  _PerspectiveProxy_handle.set(this, void 0);
@@ -5564,20 +5925,20 @@ var PerspectiveProxy = class {
5564
5925
  this,
5565
5926
  null
5566
5927
  );
5567
- __classPrivateFieldSet$6(this, _PerspectiveProxy_handle, handle, "f");
5568
- __classPrivateFieldSet$6(this, _PerspectiveProxy_client, ad4m, "f");
5569
- this.uuid = __classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid;
5570
- this.name = __classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").name;
5571
- this.owners = __classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").owners;
5572
- this.sharedUrl = __classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").sharedUrl;
5573
- this.neighbourhood = __classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").neighbourhood;
5574
- this.state = __classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").state;
5928
+ __classPrivateFieldSet$7(this, _PerspectiveProxy_handle, handle, "f");
5929
+ __classPrivateFieldSet$7(this, _PerspectiveProxy_client, ad4m, "f");
5930
+ this.uuid = __classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid;
5931
+ this.name = __classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").name;
5932
+ this.owners = __classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").owners;
5933
+ this.sharedUrl = __classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").sharedUrl;
5934
+ this.neighbourhood = __classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").neighbourhood;
5935
+ this.state = __classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").state;
5575
5936
  }
5576
5937
  updateHandle(handle) {
5577
- if (handle.uuid !== __classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid) {
5578
- throw new Error(`PerspectiveProxy.updateHandle: UUID mismatch \u2014 proxy is bound to "${__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid}" but received handle with UUID "${handle.uuid}". This would silently diverge from listeners registered under the original UUID.`);
5938
+ if (handle.uuid !== __classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid) {
5939
+ throw new Error(`PerspectiveProxy.updateHandle: UUID mismatch \u2014 proxy is bound to "${__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid}" but received handle with UUID "${handle.uuid}". This would silently diverge from listeners registered under the original UUID.`);
5579
5940
  }
5580
- __classPrivateFieldSet$6(this, _PerspectiveProxy_handle, handle, "f");
5941
+ __classPrivateFieldSet$7(this, _PerspectiveProxy_handle, handle, "f");
5581
5942
  this.uuid = handle.uuid;
5582
5943
  this.name = handle.name;
5583
5944
  this.owners = handle.owners;
@@ -5589,135 +5950,135 @@ var PerspectiveProxy = class {
5589
5950
  return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
5590
5951
  }
5591
5952
  async executeAction(actions, expression, parameters, batchId) {
5592
- const result = await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").executeCommands(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, JSON.stringify(actions), expression, JSON.stringify(parameters), batchId);
5593
- invalidatePerspectiveCache(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid);
5953
+ const result = await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").executeCommands(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, JSON.stringify(actions), expression, JSON.stringify(parameters), batchId);
5954
+ invalidatePerspectiveCache(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid);
5594
5955
  return result;
5595
5956
  }
5596
5957
  async get(query, options) {
5597
- return await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").queryLinks(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, query, options);
5958
+ return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").queryLinks(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, query, options);
5598
5959
  }
5599
5960
  async runInterpretation(transcript, basePrefix, classes, options) {
5600
5961
  const { existingScope, mintScope, observe, ...callOptions } = options ?? {};
5601
- return await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").runInterpretation(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, transcript, basePrefix, classes, existingScope, mintScope, observe, callOptions);
5962
+ return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").runInterpretation(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, transcript, basePrefix, classes, existingScope, mintScope, observe, callOptions);
5602
5963
  }
5603
5964
  async runInterpretationWithHarness(transcript, basePrefix, maxToolCalls, classes, modelOverride, observationId, emitDebugEvents, options) {
5604
- return await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").runInterpretationWithHarness(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, transcript, basePrefix, maxToolCalls, classes, modelOverride, void 0, observationId, emitDebugEvents, options);
5965
+ return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").runInterpretationWithHarness(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, transcript, basePrefix, maxToolCalls, classes, modelOverride, void 0, observationId, emitDebugEvents, options);
5605
5966
  }
5606
5967
  async runAgent(messages2, settings, options) {
5607
- return await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").runAgent(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, messages2, settings, options);
5968
+ return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").runAgent(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, messages2, settings, options);
5608
5969
  }
5609
5970
  async addAutoProcessor(config) {
5610
- return await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").addAutoProcessor(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, config);
5971
+ return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").addAutoProcessor(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, config);
5611
5972
  }
5612
5973
  async removeAutoProcessor(processorId) {
5613
- return await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").removeAutoProcessor(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, processorId);
5974
+ return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").removeAutoProcessor(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, processorId);
5614
5975
  }
5615
5976
  async interpretationOverlays() {
5616
- if (__classPrivateFieldGet$6(this, _PerspectiveProxy_overlaysInFlight, "f")) {
5617
- return [...await __classPrivateFieldGet$6(this, _PerspectiveProxy_overlaysInFlight, "f")];
5977
+ if (__classPrivateFieldGet$7(this, _PerspectiveProxy_overlaysInFlight, "f")) {
5978
+ return [...await __classPrivateFieldGet$7(this, _PerspectiveProxy_overlaysInFlight, "f")];
5618
5979
  }
5619
- const pending = __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").interpretationOverlays(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid);
5620
- __classPrivateFieldSet$6(this, _PerspectiveProxy_overlaysInFlight, pending, "f");
5980
+ const pending = __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").interpretationOverlays(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid);
5981
+ __classPrivateFieldSet$7(this, _PerspectiveProxy_overlaysInFlight, pending, "f");
5621
5982
  try {
5622
5983
  return [...await pending];
5623
5984
  } finally {
5624
- if (__classPrivateFieldGet$6(this, _PerspectiveProxy_overlaysInFlight, "f") === pending) {
5625
- __classPrivateFieldSet$6(this, _PerspectiveProxy_overlaysInFlight, null, "f");
5985
+ if (__classPrivateFieldGet$7(this, _PerspectiveProxy_overlaysInFlight, "f") === pending) {
5986
+ __classPrivateFieldSet$7(this, _PerspectiveProxy_overlaysInFlight, null, "f");
5626
5987
  }
5627
5988
  }
5628
5989
  }
5629
5990
  async acceptInterpretation(base, property) {
5630
5991
  try {
5631
- return await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").acceptInterpretation(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, base, property);
5992
+ return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").acceptInterpretation(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, base, property);
5632
5993
  } finally {
5633
- __classPrivateFieldSet$6(this, _PerspectiveProxy_overlaysInFlight, null, "f");
5994
+ __classPrivateFieldSet$7(this, _PerspectiveProxy_overlaysInFlight, null, "f");
5634
5995
  }
5635
5996
  }
5636
5997
  async rejectInterpretation(base, property) {
5637
5998
  try {
5638
- return await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").rejectInterpretation(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, base, property);
5999
+ return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").rejectInterpretation(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, base, property);
5639
6000
  } finally {
5640
- __classPrivateFieldSet$6(this, _PerspectiveProxy_overlaysInFlight, null, "f");
6001
+ __classPrivateFieldSet$7(this, _PerspectiveProxy_overlaysInFlight, null, "f");
5641
6002
  }
5642
6003
  }
5643
6004
  async proposeFlowTransition(instanceUri, toState, rationale, outputs) {
5644
- return await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").proposeFlowTransition(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, instanceUri, toState, rationale, outputs);
6005
+ return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").proposeFlowTransition(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, instanceUri, toState, rationale, outputs);
5645
6006
  }
5646
6007
  async acceptFlowProposal(proposalUri) {
5647
- return await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").acceptFlowProposal(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, proposalUri);
6008
+ return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").acceptFlowProposal(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, proposalUri);
5648
6009
  }
5649
6010
  async rejectFlowProposal(proposalUri) {
5650
- return await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").rejectFlowProposal(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, proposalUri);
6011
+ return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").rejectFlowProposal(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, proposalUri);
5651
6012
  }
5652
6013
  async verifyFlowReceipt(receipt) {
5653
- return await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").verifyFlowReceipt(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, receipt);
6014
+ return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").verifyFlowReceipt(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, receipt);
5654
6015
  }
5655
6016
  async flowValidOutputs(flow, state) {
5656
- return await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").flowValidOutputs(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, flow, state);
6017
+ return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").flowValidOutputs(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, flow, state);
5657
6018
  }
5658
6019
  async flowStates(instances) {
5659
- return await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").flowStates(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, instances);
6020
+ return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").flowStates(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, instances);
5660
6021
  }
5661
6022
  async flowFired(instance) {
5662
- return await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").flowFired(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, instance);
6023
+ return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").flowFired(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, instance);
5663
6024
  }
5664
6025
  onFlowStateChanged(handler) {
5665
6026
  return this.on("flow-state-changed", handler);
5666
6027
  }
5667
6028
  async mintFlowReceipt(instanceUri) {
5668
- return await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").mintFlowReceipt(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, instanceUri);
6029
+ return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").mintFlowReceipt(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, instanceUri);
5669
6030
  }
5670
6031
  async infer(query, options) {
5671
- return await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").queryProlog(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, query, options);
6032
+ return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").queryProlog(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, query, options);
5672
6033
  }
5673
6034
  async querySparql(query, options) {
5674
- const cached = getCachedResult(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, query);
6035
+ const cached = getCachedResult(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, query);
5675
6036
  if (cached !== void 0)
5676
6037
  return cached;
5677
- const result = await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").querySparql(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, query, options);
5678
- setCachedResult(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, query, result);
6038
+ const result = await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").querySparql(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, query, options);
6039
+ setCachedResult(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, query, result);
5679
6040
  return result;
5680
6041
  }
5681
6042
  async modelQuery(className, queryJson, options) {
5682
- return await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").modelQuery(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, className, queryJson, options);
6043
+ return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").modelQuery(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, className, queryJson, options);
5683
6044
  }
5684
6045
  async subjectClassesOf(uris) {
5685
6046
  if (uris.length === 0)
5686
6047
  return {};
5687
- return await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").subjectClassesOf(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, uris);
6048
+ return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").subjectClassesOf(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, uris);
5688
6049
  }
5689
6050
  async evaluateGetters(className, instanceIds, propertyNames) {
5690
- return await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").evaluateGetters(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, className, instanceIds, propertyNames);
6051
+ return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").evaluateGetters(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, className, instanceIds, propertyNames);
5691
6052
  }
5692
6053
  async modelSubscribe(className, queryJson) {
5693
- return await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").modelSubscribe(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, className, queryJson);
6054
+ return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").modelSubscribe(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, className, queryJson);
5694
6055
  }
5695
6056
  async add(link, status = "shared", batchId) {
5696
- const result = await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").addLink(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, link, status, batchId);
5697
- invalidatePerspectiveCache(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid);
6057
+ const result = await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").addLink(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, link, status, batchId);
6058
+ invalidatePerspectiveCache(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid);
5698
6059
  return result;
5699
6060
  }
5700
6061
  async addLinks(links, status = "shared", batchId) {
5701
- const result = await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").addLinks(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, links, status, batchId);
5702
- invalidatePerspectiveCache(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid);
6062
+ const result = await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").addLinks(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, links, status, batchId);
6063
+ invalidatePerspectiveCache(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid);
5703
6064
  return result;
5704
6065
  }
5705
6066
  async removeLinks(links, batchId) {
5706
- const result = await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").removeLinks(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, links, batchId);
5707
- invalidatePerspectiveCache(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid);
6067
+ const result = await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").removeLinks(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, links, batchId);
6068
+ invalidatePerspectiveCache(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid);
5708
6069
  return result;
5709
6070
  }
5710
6071
  async linkMutations(mutations, status = "shared") {
5711
- const result = await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").linkMutations(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, mutations, status);
5712
- invalidatePerspectiveCache(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid);
6072
+ const result = await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").linkMutations(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, mutations, status);
6073
+ invalidatePerspectiveCache(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid);
5713
6074
  return result;
5714
6075
  }
5715
6076
  async addLinkExpression(link, status = "shared", batchId) {
5716
- return await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").addLinkExpression(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, link, status, batchId);
6077
+ return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").addLinkExpression(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, link, status, batchId);
5717
6078
  }
5718
6079
  async update(oldLink, newLink, batchId) {
5719
- const result = await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").updateLink(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, oldLink, newLink, batchId);
5720
- invalidatePerspectiveCache(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid);
6080
+ const result = await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").updateLink(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, oldLink, newLink, batchId);
6081
+ invalidatePerspectiveCache(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid);
5721
6082
  return result;
5722
6083
  }
5723
6084
  async remove(link, batchId) {
@@ -5738,39 +6099,39 @@ var PerspectiveProxy = class {
5738
6099
  } else {
5739
6100
  resolvedLink = link;
5740
6101
  }
5741
- const result = await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").removeLink(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, resolvedLink, batchId);
5742
- invalidatePerspectiveCache(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid);
6102
+ const result = await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").removeLink(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, resolvedLink, batchId);
6103
+ invalidatePerspectiveCache(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid);
5743
6104
  return result;
5744
6105
  }
5745
6106
  async createBatch() {
5746
- return await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").createBatch(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid);
6107
+ return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").createBatch(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid);
5747
6108
  }
5748
6109
  async commitBatch(batchId) {
5749
- const result = await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").commitBatch(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, batchId);
5750
- invalidatePerspectiveCache(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid);
6110
+ const result = await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").commitBatch(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, batchId);
6111
+ invalidatePerspectiveCache(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid);
5751
6112
  return result;
5752
6113
  }
5753
6114
  async getExpression(expressionURI) {
5754
- return await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").getExpression(expressionURI);
6115
+ return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").getExpression(expressionURI);
5755
6116
  }
5756
6117
  async createExpression(content, languageAddress) {
5757
- return await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").createExpression(content, languageAddress);
6118
+ return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").createExpression(content, languageAddress);
5758
6119
  }
5759
6120
  on(type, handler) {
5760
- const release = __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").on(type, (event) => handler(event), { perspective: __classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid });
6121
+ const release = __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").on(type, (event) => handler(event), { perspective: __classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid });
5761
6122
  const releaseOnce = () => {
5762
- if (__classPrivateFieldGet$6(this, _PerspectiveProxy_releases, "f").delete(releaseOnce))
6123
+ if (__classPrivateFieldGet$7(this, _PerspectiveProxy_releases, "f").delete(releaseOnce))
5763
6124
  release();
5764
6125
  };
5765
- __classPrivateFieldGet$6(this, _PerspectiveProxy_releases, "f").add(releaseOnce);
6126
+ __classPrivateFieldGet$7(this, _PerspectiveProxy_releases, "f").add(releaseOnce);
5766
6127
  return releaseOnce;
5767
6128
  }
5768
6129
  dispose() {
5769
- for (const release of [...__classPrivateFieldGet$6(this, _PerspectiveProxy_releases, "f")])
6130
+ for (const release of [...__classPrivateFieldGet$7(this, _PerspectiveProxy_releases, "f")])
5770
6131
  release();
5771
6132
  }
5772
6133
  async snapshot() {
5773
- return __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").snapshotByUUID(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid);
6134
+ return __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").snapshotByUUID(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid);
5774
6135
  }
5775
6136
  async loadSnapshot(snapshot) {
5776
6137
  const cleanedSnapshot = JSON.parse(JSON.stringify(snapshot));
@@ -5878,10 +6239,10 @@ var PerspectiveProxy = class {
5878
6239
  return typeof code2 === "string" ? code2 : null;
5879
6240
  }
5880
6241
  async addSdna(name, sdnaCode, sdnaType, shaclJson) {
5881
- return __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").addSdna(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, name, sdnaCode, sdnaType, shaclJson);
6242
+ return __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").addSdna(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, name, sdnaCode, sdnaType, shaclJson);
5882
6243
  }
5883
6244
  async addSdnaAll(entries) {
5884
- return __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").addSdnaBatch(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, entries);
6245
+ return __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").addSdnaBatch(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, entries);
5885
6246
  }
5886
6247
  async ensureSubjectClasses(jsClasses) {
5887
6248
  const entries = [];
@@ -5889,7 +6250,7 @@ var PerspectiveProxy = class {
5889
6250
  if (Object.prototype.hasOwnProperty.call(jsClass, "builtinUri"))
5890
6251
  continue;
5891
6252
  const className = jsClass.className || jsClass.prototype?.className || jsClass.name;
5892
- if (__classPrivateFieldGet$6(this, _PerspectiveProxy_ensuredSubjectClasses, "f").has(className))
6253
+ if (__classPrivateFieldGet$7(this, _PerspectiveProxy_ensuredSubjectClasses, "f").has(className))
5893
6254
  continue;
5894
6255
  if (!jsClass.generateSHACL) {
5895
6256
  throw new Error(`Class ${jsClass.name} must have generateSHACL(). Use @Model decorator.`);
@@ -5905,26 +6266,26 @@ var PerspectiveProxy = class {
5905
6266
  return;
5906
6267
  await this.addSdnaAll(entries);
5907
6268
  for (const entry of entries) {
5908
- __classPrivateFieldGet$6(this, _PerspectiveProxy_ensuredSubjectClasses, "f").add(entry.name);
6269
+ __classPrivateFieldGet$7(this, _PerspectiveProxy_ensuredSubjectClasses, "f").add(entry.name);
5909
6270
  }
5910
6271
  }
5911
6272
  async addShacl(name, shape) {
5912
6273
  await this.addSdna(name, "", "subject_class", JSON.stringify(shape.toJSON()));
5913
6274
  }
5914
6275
  async getShacl(name) {
5915
- const result = await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").getShacl(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, name);
6276
+ const result = await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").getShacl(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, name);
5916
6277
  if (!result)
5917
6278
  return null;
5918
6279
  return SHACLShape.fromLinks(result.links, result.shapeUri);
5919
6280
  }
5920
6281
  async getShaclNames() {
5921
- return __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").getShaclNames(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid);
6282
+ return __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").getShaclNames(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid);
5922
6283
  }
5923
6284
  async getShaclTargetClass(name) {
5924
- return __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").getShaclTargetClass(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, name);
6285
+ return __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").getShaclTargetClass(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, name);
5925
6286
  }
5926
6287
  async getAllShacl() {
5927
- const entries = await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").getAllShacl(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid);
6288
+ const entries = await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").getAllShacl(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid);
5928
6289
  const shapes = [];
5929
6290
  for (const { name, shapeUri, links } of entries) {
5930
6291
  try {
@@ -6006,20 +6367,14 @@ var PerspectiveProxy = class {
6006
6367
  async stringOrTemplateObjectToSubjectClassName(subjectClass) {
6007
6368
  if (typeof subjectClass === "string")
6008
6369
  return subjectClass;
6009
- else {
6010
- let subjectClasses = await this.subjectClassesByTemplate(subjectClass);
6011
- if (subjectClasses[0]) {
6012
- return subjectClasses[0];
6013
- } else {
6014
- return subjectClass.className;
6015
- }
6016
- }
6370
+ const obj = subjectClass;
6371
+ return obj.className || obj.constructor?.className || obj.constructor?.prototype?.className || (await this.subjectClassesByTemplate(obj))[0];
6017
6372
  }
6018
6373
  async createSubject(subjectClass, exprAddr, initialValues, batchId) {
6019
6374
  let className;
6020
6375
  if (typeof subjectClass === "string") {
6021
6376
  className = subjectClass;
6022
- await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").createSubject(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, JSON.stringify({
6377
+ await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").createSubject(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, JSON.stringify({
6023
6378
  className,
6024
6379
  initialValues
6025
6380
  }), exprAddr, initialValues ? JSON.stringify(initialValues) : void 0, batchId);
@@ -6029,7 +6384,7 @@ var PerspectiveProxy = class {
6029
6384
  if (!resolvedClassName) {
6030
6385
  throw new Error("Could not resolve subject class name from object. Use a decorated class or pass a className string.");
6031
6386
  }
6032
- await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").createSubject(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, JSON.stringify({
6387
+ await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").createSubject(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, JSON.stringify({
6033
6388
  className: resolvedClassName,
6034
6389
  initialValues
6035
6390
  }), exprAddr, initialValues ? JSON.stringify(initialValues) : void 0, batchId);
@@ -6040,19 +6395,19 @@ var PerspectiveProxy = class {
6040
6395
  return exprAddr;
6041
6396
  }
6042
6397
  async updateSubject(className, exprAddr, values, batchId) {
6043
- await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").updateSubject(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, className, exprAddr, JSON.stringify(values), batchId);
6044
- invalidatePerspectiveCache(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid);
6398
+ await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").updateSubject(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, className, exprAddr, JSON.stringify(values), batchId);
6399
+ invalidatePerspectiveCache(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid);
6045
6400
  }
6046
6401
  async getSubjectData(subjectClass, exprAddr) {
6047
6402
  if (typeof subjectClass === "string") {
6048
- return JSON.parse(await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").getSubjectData(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, JSON.stringify({ className: subjectClass }), exprAddr));
6403
+ return JSON.parse(await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").getSubjectData(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, JSON.stringify({ className: subjectClass }), exprAddr));
6049
6404
  }
6050
6405
  const obj = subjectClass;
6051
6406
  const resolvedClassName = obj.className || obj.constructor?.className || obj.constructor?.prototype?.className || await this.findClassByProperties(obj);
6052
6407
  if (!resolvedClassName) {
6053
6408
  throw new Error("Could not resolve subject class name from object. Use a decorated class or pass a className string.");
6054
6409
  }
6055
- return JSON.parse(await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").getSubjectData(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, JSON.stringify({ className: resolvedClassName }), exprAddr));
6410
+ return JSON.parse(await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").getSubjectData(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, JSON.stringify({ className: resolvedClassName }), exprAddr));
6056
6411
  }
6057
6412
  async getActionsFromSHACL(className, predicate) {
6058
6413
  const escaped = this.escapeRegExp(className);
@@ -6082,16 +6437,16 @@ var PerspectiveProxy = class {
6082
6437
  async removeSubject(subjectClass, exprAddr, batchId) {
6083
6438
  const ctor = subjectClass?.constructor;
6084
6439
  if (typeof subjectClass === "object" && ctor && Object.prototype.hasOwnProperty.call(ctor, "builtinUri")) {
6085
- await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").removeSubject(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, ctor.builtinUri, exprAddr, batchId);
6086
- invalidatePerspectiveCache(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid);
6440
+ await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").removeSubject(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, ctor.builtinUri, exprAddr, batchId);
6441
+ invalidatePerspectiveCache(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid);
6087
6442
  return;
6088
6443
  }
6089
6444
  let className = await this.stringOrTemplateObjectToSubjectClassName(subjectClass);
6090
6445
  const shapePattern = new RegExp(`[/:#]${this.escapeRegExp(className)}Shape$`);
6091
6446
  const markers = await this.get(new LinkQuery({ predicate: "ad4m://abstract" }));
6092
6447
  if (markers.some((link) => shapePattern.test(link.data.source))) {
6093
- await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").removeSubject(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, className, exprAddr, batchId);
6094
- invalidatePerspectiveCache(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid);
6448
+ await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").removeSubject(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, className, exprAddr, batchId);
6449
+ invalidatePerspectiveCache(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid);
6095
6450
  return;
6096
6451
  }
6097
6452
  let actions = await this.getActionsFromSHACL(className, "ad4m://destructor");
@@ -6316,7 +6671,7 @@ var PerspectiveProxy = class {
6316
6671
  if (Object.prototype.hasOwnProperty.call(jsClass, "builtinUri"))
6317
6672
  return;
6318
6673
  const className = jsClass.className || jsClass.prototype?.className || jsClass.name;
6319
- if (__classPrivateFieldGet$6(this, _PerspectiveProxy_ensuredSubjectClasses, "f").has(className))
6674
+ if (__classPrivateFieldGet$7(this, _PerspectiveProxy_ensuredSubjectClasses, "f").has(className))
6320
6675
  return;
6321
6676
  if (!jsClass.generateSHACL) {
6322
6677
  throw new Error(`Class ${jsClass.name} must have generateSHACL(). Use @Model decorator.`);
@@ -6324,10 +6679,10 @@ var PerspectiveProxy = class {
6324
6679
  const { shape } = jsClass.generateSHACL();
6325
6680
  const shaclJson = JSON.stringify(shape.toJSON());
6326
6681
  await this.addSdna(className, "", "subject_class", shaclJson);
6327
- __classPrivateFieldGet$6(this, _PerspectiveProxy_ensuredSubjectClasses, "f").add(className);
6682
+ __classPrivateFieldGet$7(this, _PerspectiveProxy_ensuredSubjectClasses, "f").add(className);
6328
6683
  }
6329
6684
  clearEnsuredSubjectClasses() {
6330
- __classPrivateFieldGet$6(this, _PerspectiveProxy_ensuredSubjectClasses, "f").clear();
6685
+ __classPrivateFieldGet$7(this, _PerspectiveProxy_ensuredSubjectClasses, "f").clear();
6331
6686
  }
6332
6687
  async listRegisteredClasses() {
6333
6688
  const results = await this.querySparql(`SELECT DISTINCT ?class WHERE { ?class <rdf://type> <ad4m://SubjectClass> . }`);
@@ -6455,19 +6810,24 @@ var PerspectiveProxy = class {
6455
6810
  }));
6456
6811
  }
6457
6812
  getNeighbourhoodProxy() {
6458
- return __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").getNeighbourhoodProxy(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid);
6813
+ return __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").getNeighbourhoodProxy(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid);
6459
6814
  }
6460
6815
  get ai() {
6461
- return __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").aiClient;
6816
+ return __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").aiClient;
6462
6817
  }
6463
6818
  async subscribeQuery(query) {
6464
- const subscription = new QuerySubscriptionProxy(this.uuid, query, __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f"));
6465
- await subscription.subscribe();
6819
+ const subscription = new QuerySubscriptionProxy(this.uuid, query, __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f"));
6820
+ try {
6821
+ await subscription.subscribe();
6822
+ } catch (e) {
6823
+ subscription.dispose({ cancelOpening: true });
6824
+ throw e;
6825
+ }
6466
6826
  return subscription;
6467
6827
  }
6468
6828
  };
6469
6829
  _PerspectiveProxy_handle = /* @__PURE__ */ new WeakMap(), _PerspectiveProxy_client = /* @__PURE__ */ new WeakMap(), _PerspectiveProxy_releases = /* @__PURE__ */ new WeakMap(), _PerspectiveProxy_ensuredSubjectClasses = /* @__PURE__ */ new WeakMap(), _PerspectiveProxy_overlaysInFlight = /* @__PURE__ */ new WeakMap();
6470
- var __classPrivateFieldSet$5 = function(receiver, state, value, kind, f) {
6830
+ var __classPrivateFieldSet$6 = function(receiver, state, value, kind, f) {
6471
6831
  if (kind === "m")
6472
6832
  throw new TypeError("Private method is not writable");
6473
6833
  if (kind === "a" && !f)
@@ -6476,7 +6836,7 @@ var __classPrivateFieldSet$5 = function(receiver, state, value, kind, f) {
6476
6836
  throw new TypeError("Cannot write private member to an object whose class did not declare it");
6477
6837
  return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
6478
6838
  };
6479
- var __classPrivateFieldGet$5 = function(receiver, state, kind, f) {
6839
+ var __classPrivateFieldGet$6 = function(receiver, state, kind, f) {
6480
6840
  if (kind === "a" && !f)
6481
6841
  throw new TypeError("Private accessor was defined without a getter");
6482
6842
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
@@ -6496,27 +6856,27 @@ var PerspectiveClient = class {
6496
6856
  _PerspectiveClient_expressionClient.set(this, void 0);
6497
6857
  _PerspectiveClient_neighbourhoodClient.set(this, void 0);
6498
6858
  _PerspectiveClient_aiClient.set(this, void 0);
6499
- __classPrivateFieldSet$5(this, _PerspectiveClient_apiClient, sharedApiClient || new ApiClient(baseUrl, token), "f");
6859
+ __classPrivateFieldSet$6(this, _PerspectiveClient_apiClient, sharedApiClient || new ApiClient(baseUrl, token), "f");
6500
6860
  }
6501
6861
  setExpressionClient(client) {
6502
- __classPrivateFieldSet$5(this, _PerspectiveClient_expressionClient, client, "f");
6862
+ __classPrivateFieldSet$6(this, _PerspectiveClient_expressionClient, client, "f");
6503
6863
  }
6504
6864
  setNeighbourhoodClient(client) {
6505
- __classPrivateFieldSet$5(this, _PerspectiveClient_neighbourhoodClient, client, "f");
6865
+ __classPrivateFieldSet$6(this, _PerspectiveClient_neighbourhoodClient, client, "f");
6506
6866
  }
6507
6867
  setAIClient(client) {
6508
- __classPrivateFieldSet$5(this, _PerspectiveClient_aiClient, client, "f");
6868
+ __classPrivateFieldSet$6(this, _PerspectiveClient_aiClient, client, "f");
6509
6869
  }
6510
6870
  get aiClient() {
6511
- return __classPrivateFieldGet$5(this, _PerspectiveClient_aiClient, "f");
6871
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_aiClient, "f");
6512
6872
  }
6513
6873
  async all() {
6514
- const perspectives = await __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call("perspective.all", {});
6874
+ const perspectives = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call("perspective.all", {});
6515
6875
  return perspectives.map((handle) => new PerspectiveProxy(PerspectiveHandle.fromWire(handle), this));
6516
6876
  }
6517
6877
  async byUUID(uuid) {
6518
6878
  try {
6519
- const perspective = await __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call("perspective.get", { uuid });
6879
+ const perspective = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call("perspective.get", { uuid });
6520
6880
  if (!perspective)
6521
6881
  return null;
6522
6882
  return new PerspectiveProxy(PerspectiveHandle.fromWire(perspective), this);
@@ -6527,11 +6887,11 @@ var PerspectiveClient = class {
6527
6887
  }
6528
6888
  }
6529
6889
  async snapshotByUUID(uuid) {
6530
- const snapshot = await __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call("perspective.snapshot", { uuid });
6890
+ const snapshot = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call("perspective.snapshot", { uuid });
6531
6891
  return snapshot ? new Perspective(snapshot.links.map(LinkExpression.fromWire)) : null;
6532
6892
  }
6533
6893
  async publishSnapshotByUUID(uuid) {
6534
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call("perspective.publishSnapshot", { uuid });
6894
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call("perspective.publishSnapshot", { uuid });
6535
6895
  }
6536
6896
  async queryLinks(uuid, query, options) {
6537
6897
  const params = { uuid };
@@ -6547,38 +6907,38 @@ var PerspectiveClient = class {
6547
6907
  params.untilDate = query.untilDate instanceof Date ? query.untilDate.toISOString() : String(query.untilDate);
6548
6908
  if (query.limit !== void 0)
6549
6909
  params.limit = query.limit;
6550
- const links = await __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call("perspective.queryLinks", params, options);
6910
+ const links = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call("perspective.queryLinks", params, options);
6551
6911
  return links.map(LinkExpression.fromWire);
6552
6912
  }
6553
6913
  async queryProlog(uuid, query, options) {
6554
- const result = await __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call("perspective.queryProlog", { uuid, query }, options);
6914
+ const result = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call("perspective.queryProlog", { uuid, query }, options);
6555
6915
  return JSON.parse(result);
6556
6916
  }
6557
6917
  async querySparql(uuid, query, options) {
6558
- const result = await __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call("perspective.querySparql", { uuid, engine: "sparql", query }, options);
6918
+ const result = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call("perspective.querySparql", { uuid, engine: "sparql", query }, options);
6559
6919
  return JSON.parse(result);
6560
6920
  }
6561
- async subscribeQuery(uuid, query) {
6562
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call("perspective.subscribeQuery", { uuid, query });
6921
+ async subscribeQuery(uuid, query, options) {
6922
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call("perspective.subscribeQuery", { uuid, query }, options);
6563
6923
  }
6564
6924
  onQueryUpdate(cb) {
6565
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").on("query-subscription-update", cb);
6925
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").on("query-subscription-update", cb);
6566
6926
  }
6567
6927
  async resyncSubscription(uuid, subscriptionId) {
6568
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call("perspective.resyncSubscription", { uuid, subscriptionId });
6928
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call("perspective.resyncSubscription", { uuid, subscriptionId });
6569
6929
  }
6570
6930
  async disposeQuerySubscription(uuid, subscriptionId) {
6571
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call("perspective.disposeQuery", { uuid, subscriptionId });
6931
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call("perspective.disposeQuery", { uuid, subscriptionId });
6572
6932
  }
6573
6933
  async modelQuery(uuid, className, queryJson, options) {
6574
- const resultJson = await __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call("perspective.modelQuery", { uuid, ...classParams(className), query_json: queryJson }, options);
6934
+ const resultJson = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call("perspective.modelQuery", { uuid, ...classParams(className), query_json: queryJson }, options);
6575
6935
  return JSON.parse(resultJson);
6576
6936
  }
6577
6937
  async subjectClassesOf(uuid, uris) {
6578
- return await __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call("perspective.subjectClassesOf", { uuid, uris });
6938
+ return await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call("perspective.subjectClassesOf", { uuid, uris });
6579
6939
  }
6580
6940
  async evaluateGetters(uuid, className, instanceIds, propertyNames) {
6581
- const resultJson = await __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call("perspective.evaluateGetters", {
6941
+ const resultJson = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call("perspective.evaluateGetters", {
6582
6942
  uuid,
6583
6943
  class_name: className,
6584
6944
  instance_ids: instanceIds,
@@ -6586,39 +6946,39 @@ var PerspectiveClient = class {
6586
6946
  });
6587
6947
  return JSON.parse(resultJson);
6588
6948
  }
6589
- async modelSubscribe(uuid, className, queryJson) {
6590
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call("perspective.modelSubscribe", { uuid, ...classParams(className), query_json: queryJson });
6949
+ async modelSubscribe(uuid, className, queryJson, options) {
6950
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call("perspective.modelSubscribe", { uuid, ...classParams(className), query_json: queryJson }, options);
6591
6951
  }
6592
6952
  async add(name) {
6593
- const handle = await __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call("perspective.create", { name });
6953
+ const handle = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call("perspective.create", { name });
6594
6954
  return new PerspectiveProxy(PerspectiveHandle.fromWire(handle), this);
6595
6955
  }
6596
6956
  async update(uuid, name) {
6597
- const handle = await __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call("perspective.update", { uuid, name });
6957
+ const handle = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call("perspective.update", { uuid, name });
6598
6958
  return new PerspectiveProxy(PerspectiveHandle.fromWire(handle), this);
6599
6959
  }
6600
6960
  async remove(uuid) {
6601
- const result = await __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call("perspective.remove", { uuid });
6961
+ const result = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call("perspective.remove", { uuid });
6602
6962
  return { perspectiveRemove: result };
6603
6963
  }
6604
6964
  async addLink(uuid, link, status = "shared", batchId) {
6605
- const added = await __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call("perspective.addLink", { uuid, link, status, batchId });
6965
+ const added = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call("perspective.addLink", { uuid, link, status, batchId });
6606
6966
  return LinkExpression.fromWire(added);
6607
6967
  }
6608
6968
  async addLinks(uuid, links, status = "shared", batchId) {
6609
- const added = await __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call("perspective.addLinks", { uuid, links, status, batchId });
6969
+ const added = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call("perspective.addLinks", { uuid, links, status, batchId });
6610
6970
  return added.map(LinkExpression.fromWire);
6611
6971
  }
6612
6972
  async removeLinks(uuid, links, batchId) {
6613
- const removed = await __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call("perspective.removeLinks", { uuid, links: links.map(linkExpressionInputToWire), batchId });
6973
+ const removed = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call("perspective.removeLinks", { uuid, links: links.map(linkExpressionInputToWire), batchId });
6614
6974
  return removed.map(LinkExpression.fromWire);
6615
6975
  }
6616
6976
  async linkMutations(uuid, mutations, status) {
6617
- const diff = await __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call("perspective.linkMutations", { uuid, mutations: linkMutationsToWire(mutations), status });
6977
+ const diff = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call("perspective.linkMutations", { uuid, mutations: linkMutationsToWire(mutations), status });
6618
6978
  return LinkExpressionMutations.fromWire(diff);
6619
6979
  }
6620
6980
  async runInterpretation(uuid, transcript, basePrefix, classes, existingScope, mintScope, observe, options) {
6621
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call("perspective.runInterpretation", {
6981
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call("perspective.runInterpretation", {
6622
6982
  uuid,
6623
6983
  transcript,
6624
6984
  basePrefix,
@@ -6630,7 +6990,7 @@ var PerspectiveClient = class {
6630
6990
  }, options);
6631
6991
  }
6632
6992
  async runInterpretationWithHarness(uuid, transcript, basePrefix, maxToolCalls, classes, modelOverride, existingScope, observationId, emitDebugEvents, options) {
6633
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call("perspective.runInterpretationWithHarness", {
6993
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call("perspective.runInterpretationWithHarness", {
6634
6994
  uuid,
6635
6995
  transcript,
6636
6996
  basePrefix,
@@ -6643,16 +7003,16 @@ var PerspectiveClient = class {
6643
7003
  }, options);
6644
7004
  }
6645
7005
  async runAgent(uuid, messages2, settings, options) {
6646
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call("perspective.runAgent", { uuid, messages: messages2, ...settings }, options);
7006
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call("perspective.runAgent", { uuid, messages: messages2, ...settings }, options);
6647
7007
  }
6648
7008
  async addAutoProcessor(uuid, config) {
6649
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call("perspective.addAutoProcessor", { ...config, uuid });
7009
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call("perspective.addAutoProcessor", { ...config, uuid });
6650
7010
  }
6651
7011
  async removeAutoProcessor(uuid, processorId) {
6652
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call("perspective.removeAutoProcessor", { uuid, processorId });
7012
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call("perspective.removeAutoProcessor", { uuid, processorId });
6653
7013
  }
6654
7014
  async interpretationOverlays(uuid) {
6655
- const overlays = await __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call("perspective.interpretationOverlays", { uuid });
7015
+ const overlays = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call("perspective.interpretationOverlays", { uuid });
6656
7016
  return overlays.map(({ base, kind, run, inferred }) => ({
6657
7017
  base,
6658
7018
  run,
@@ -6661,109 +7021,109 @@ var PerspectiveClient = class {
6661
7021
  }));
6662
7022
  }
6663
7023
  async acceptInterpretation(uuid, base, property) {
6664
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call("perspective.acceptInterpretation", { uuid, base, property });
7024
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call("perspective.acceptInterpretation", { uuid, base, property });
6665
7025
  }
6666
7026
  async rejectInterpretation(uuid, base, property) {
6667
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call("perspective.rejectInterpretation", { uuid, base, property });
7027
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call("perspective.rejectInterpretation", { uuid, base, property });
6668
7028
  }
6669
7029
  async proposeFlowTransition(uuid, instanceUri, toState, rationale, outputs) {
6670
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call("perspective.proposeFlowTransition", { uuid, instanceUri, toState, rationale, outputs });
7030
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call("perspective.proposeFlowTransition", { uuid, instanceUri, toState, rationale, outputs });
6671
7031
  }
6672
7032
  async acceptFlowProposal(uuid, proposalUri) {
6673
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call("perspective.acceptFlowProposal", { uuid, proposalUri });
7033
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call("perspective.acceptFlowProposal", { uuid, proposalUri });
6674
7034
  }
6675
7035
  async rejectFlowProposal(uuid, proposalUri) {
6676
- const result = await __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call("perspective.rejectFlowProposal", { uuid, proposalUri });
7036
+ const result = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call("perspective.rejectFlowProposal", { uuid, proposalUri });
6677
7037
  return result.retractedLinks;
6678
7038
  }
6679
7039
  async verifyFlowReceipt(uuid, receipt) {
6680
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call("perspective.verifyFlowReceipt", { uuid, receipt });
7040
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call("perspective.verifyFlowReceipt", { uuid, receipt });
6681
7041
  }
6682
7042
  async flowValidOutputs(uuid, flow, state) {
6683
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call("perspective.flowValidOutputs", { uuid, flow, state });
7043
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call("perspective.flowValidOutputs", { uuid, flow, state });
6684
7044
  }
6685
7045
  async flowStates(uuid, instances) {
6686
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call("perspective.flowStates", { uuid, instances });
7046
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call("perspective.flowStates", { uuid, instances });
6687
7047
  }
6688
7048
  async flowFired(uuid, instance) {
6689
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call("perspective.flowFired", { uuid, instance });
7049
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call("perspective.flowFired", { uuid, instance });
6690
7050
  }
6691
7051
  async mintFlowReceipt(uuid, instanceUri) {
6692
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call("perspective.mintFlowReceipt", { uuid, instanceUri });
7052
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call("perspective.mintFlowReceipt", { uuid, instanceUri });
6693
7053
  }
6694
7054
  async addLinkExpression(uuid, link, status = "shared", batchId) {
6695
- const added = await __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call("perspective.addLinkExpression", { uuid, link: linkExpressionToWire(link), status, batchId });
7055
+ const added = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call("perspective.addLinkExpression", { uuid, link: linkExpressionToWire(link), status, batchId });
6696
7056
  return LinkExpression.fromWire(added);
6697
7057
  }
6698
7058
  async updateLink(uuid, oldLink, newLink, batchId) {
6699
- const updated = await __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call("perspective.updateLink", { uuid, oldLink: linkExpressionInputToWire(oldLink), newLink, batchId });
7059
+ const updated = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call("perspective.updateLink", { uuid, oldLink: linkExpressionInputToWire(oldLink), newLink, batchId });
6700
7060
  return LinkExpression.fromWire(updated);
6701
7061
  }
6702
7062
  async removeLink(uuid, link, batchId) {
6703
7063
  const { status, ...wire } = linkExpressionInputToWire(link);
6704
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call("perspective.removeLink", { uuid, link: wire, batchId });
7064
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call("perspective.removeLink", { uuid, link: wire, batchId });
6705
7065
  }
6706
7066
  async addSdna(uuid, name, sdnaCode, sdnaType, shaclJson) {
6707
- const result = await __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call("perspective.addSdna", { uuid, name, sdnaCode: sdnaCode || "", sdnaType, shaclJson });
7067
+ const result = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call("perspective.addSdna", { uuid, name, sdnaCode: sdnaCode || "", sdnaType, shaclJson });
6708
7068
  return typeof result === "boolean" ? result : result.every(Boolean);
6709
7069
  }
6710
7070
  async addSdnaBatch(uuid, entries) {
6711
- const result = await __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call("perspective.addSdna", { uuid, entries: entries.map((e) => ({ ...e, sdnaCode: e.sdnaCode || "" })) });
7071
+ const result = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call("perspective.addSdna", { uuid, entries: entries.map((e) => ({ ...e, sdnaCode: e.sdnaCode || "" })) });
6712
7072
  return typeof result === "boolean" ? [result] : result;
6713
7073
  }
6714
7074
  async executeCommands(uuid, commands, expression, parameters, batchId) {
6715
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call("perspective.executeCommands", { uuid, commands, expression, parameters, batchId });
7075
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call("perspective.executeCommands", { uuid, commands, expression, parameters, batchId });
6716
7076
  }
6717
7077
  async createSubject(uuid, subjectClass, expressionAddress, initialValues, batchId) {
6718
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call("perspective.createSubject", { uuid, subjectClass, expressionAddress, initialValues, batchId });
7078
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call("perspective.createSubject", { uuid, subjectClass, expressionAddress, initialValues, batchId });
6719
7079
  }
6720
7080
  async updateSubject(uuid, subjectClass, expressionAddress, values, batchId) {
6721
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call("perspective.updateSubject", { uuid, subjectClass, expressionAddress, values, batchId });
7081
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call("perspective.updateSubject", { uuid, subjectClass, expressionAddress, values, batchId });
6722
7082
  }
6723
7083
  async removeSubject(uuid, subjectClass, expressionAddress, batchId) {
6724
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call("perspective.removeSubject", { uuid, subjectClass, expressionAddress, batchId });
7084
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call("perspective.removeSubject", { uuid, subjectClass, expressionAddress, batchId });
6725
7085
  }
6726
7086
  async getSubjectData(uuid, subjectClass, expressionAddress) {
6727
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call("perspective.getSubjectData", { uuid, subjectClass, expressionAddress });
7087
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call("perspective.getSubjectData", { uuid, subjectClass, expressionAddress });
6728
7088
  }
6729
7089
  async getShaclNames(uuid) {
6730
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call("perspective.getShaclNames", { uuid });
7090
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call("perspective.getShaclNames", { uuid });
6731
7091
  }
6732
7092
  async getShaclTargetClass(uuid, name) {
6733
- const result = await __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call("perspective.getShaclTargetClass", { uuid, name });
7093
+ const result = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call("perspective.getShaclTargetClass", { uuid, name });
6734
7094
  return result ?? void 0;
6735
7095
  }
6736
7096
  async getShacl(uuid, name) {
6737
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call("perspective.getShacl", { uuid, name });
7097
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call("perspective.getShacl", { uuid, name });
6738
7098
  }
6739
7099
  async getAllShacl(uuid) {
6740
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call("perspective.getAllShacl", { uuid });
7100
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call("perspective.getAllShacl", { uuid });
6741
7101
  }
6742
7102
  async getExpression(expressionURI) {
6743
- return await __classPrivateFieldGet$5(this, _PerspectiveClient_expressionClient, "f").get(expressionURI);
7103
+ return await __classPrivateFieldGet$6(this, _PerspectiveClient_expressionClient, "f").get(expressionURI);
6744
7104
  }
6745
7105
  async createExpression(content, languageAddress) {
6746
- return await __classPrivateFieldGet$5(this, _PerspectiveClient_expressionClient, "f").create(content, languageAddress);
7106
+ return await __classPrivateFieldGet$6(this, _PerspectiveClient_expressionClient, "f").create(content, languageAddress);
6747
7107
  }
6748
7108
  on(type, handler, filter) {
6749
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").on(type, handler, filter);
7109
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").on(type, handler, filter);
6750
7110
  }
6751
7111
  getNeighbourhoodProxy(uuid) {
6752
- return new NeighbourhoodProxy(__classPrivateFieldGet$5(this, _PerspectiveClient_neighbourhoodClient, "f"), uuid);
7112
+ return new NeighbourhoodProxy(__classPrivateFieldGet$6(this, _PerspectiveClient_neighbourhoodClient, "f"), uuid);
6753
7113
  }
6754
7114
  async createBatch(uuid) {
6755
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call("perspective.createBatch", { uuid });
7115
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call("perspective.createBatch", { uuid });
6756
7116
  }
6757
7117
  async commitBatch(uuid, batchId) {
6758
- const diff = await __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call("perspective.commitBatch", { uuid, batchId });
7118
+ const diff = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call("perspective.commitBatch", { uuid, batchId });
6759
7119
  return LinkExpressionMutations.fromWire(diff);
6760
7120
  }
6761
7121
  onReconnect(callback) {
6762
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").onReconnect(callback);
7122
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").onReconnect(callback);
6763
7123
  }
6764
7124
  };
6765
7125
  _PerspectiveClient_apiClient = /* @__PURE__ */ new WeakMap(), _PerspectiveClient_expressionClient = /* @__PURE__ */ new WeakMap(), _PerspectiveClient_neighbourhoodClient = /* @__PURE__ */ new WeakMap(), _PerspectiveClient_aiClient = /* @__PURE__ */ new WeakMap();
6766
- var __classPrivateFieldSet$4 = function(receiver, state, value, kind, f) {
7126
+ var __classPrivateFieldSet$5 = function(receiver, state, value, kind, f) {
6767
7127
  if (kind === "m")
6768
7128
  throw new TypeError("Private method is not writable");
6769
7129
  if (kind === "a" && !f)
@@ -6772,7 +7132,7 @@ var __classPrivateFieldSet$4 = function(receiver, state, value, kind, f) {
6772
7132
  throw new TypeError("Cannot write private member to an object whose class did not declare it");
6773
7133
  return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
6774
7134
  };
6775
- var __classPrivateFieldGet$4 = function(receiver, state, kind, f) {
7135
+ var __classPrivateFieldGet$5 = function(receiver, state, kind, f) {
6776
7136
  if (kind === "a" && !f)
6777
7137
  throw new TypeError("Private accessor was defined without a getter");
6778
7138
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
@@ -6783,183 +7143,183 @@ var _RuntimeClient_apiClient;
6783
7143
  var RuntimeClient = class {
6784
7144
  constructor(baseUrl, token, sharedApiClient) {
6785
7145
  _RuntimeClient_apiClient.set(this, void 0);
6786
- __classPrivateFieldSet$4(this, _RuntimeClient_apiClient, sharedApiClient || new ApiClient(baseUrl, token), "f");
7146
+ __classPrivateFieldSet$5(this, _RuntimeClient_apiClient, sharedApiClient || new ApiClient(baseUrl, token), "f");
6787
7147
  }
6788
7148
  async info() {
6789
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call("runtime.info", {});
7149
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call("runtime.info", {});
6790
7150
  }
6791
7151
  async tlsDomain() {
6792
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call("runtime.tlsDomain", {});
7152
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call("runtime.tlsDomain", {});
6793
7153
  }
6794
7154
  async quit() {
6795
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call("runtime.quit", {});
7155
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call("runtime.quit", {});
6796
7156
  }
6797
7157
  async openLink(url) {
6798
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call("runtime.openLink", { url });
7158
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call("runtime.openLink", { url });
6799
7159
  }
6800
7160
  async addTrustedAgents(agents) {
6801
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call("agent.addTrustedAgents", { agents });
7161
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call("agent.addTrustedAgents", { agents });
6802
7162
  }
6803
7163
  async deleteTrustedAgents(agents) {
6804
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call("agent.deleteTrustedAgents", { agents });
7164
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call("agent.deleteTrustedAgents", { agents });
6805
7165
  }
6806
7166
  async getTrustedAgents() {
6807
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call("agent.getTrustedAgents", {});
7167
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call("agent.getTrustedAgents", {});
6808
7168
  }
6809
7169
  async addKnownLinkLanguageTemplates(addresses) {
6810
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call("runtime.addLinkLanguageTemplates", { addresses });
7170
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call("runtime.addLinkLanguageTemplates", { addresses });
6811
7171
  }
6812
7172
  async removeKnownLinkLanguageTemplates(addresses) {
6813
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call("runtime.removeLinkLanguageTemplates", { addresses });
7173
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call("runtime.removeLinkLanguageTemplates", { addresses });
6814
7174
  }
6815
7175
  async knownLinkLanguageTemplates() {
6816
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call("runtime.linkLanguageTemplates", {});
7176
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call("runtime.linkLanguageTemplates", {});
6817
7177
  }
6818
7178
  async addFriends(dids) {
6819
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call("runtime.addFriends", { dids });
7179
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call("runtime.addFriends", { dids });
6820
7180
  }
6821
7181
  async removeFriends(dids) {
6822
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call("runtime.removeFriends", { dids });
7182
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call("runtime.removeFriends", { dids });
6823
7183
  }
6824
7184
  async friends() {
6825
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call("runtime.friends", {});
7185
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call("runtime.friends", {});
6826
7186
  }
6827
7187
  async hcAgentInfos() {
6828
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call("runtime.hcAgentInfos", {});
7188
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call("runtime.hcAgentInfos", {});
6829
7189
  }
6830
7190
  async getNetworkMetrics() {
6831
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call("runtime.networkMetrics", {});
7191
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call("runtime.networkMetrics", {});
6832
7192
  }
6833
7193
  async restartHolochain(options) {
6834
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call("runtime.restartHolochain", {}, options);
7194
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call("runtime.restartHolochain", {}, options);
6835
7195
  }
6836
7196
  async hcAddAgentInfos(agentInfos) {
6837
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call("runtime.addHcAgentInfos", { agentInfos });
7197
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call("runtime.addHcAgentInfos", { agentInfos });
6838
7198
  }
6839
7199
  async verifyStringSignedByDid(did, didSigningKeyId, data, signedData) {
6840
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call("runtime.verifySignature", { did, data, signedData });
7200
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call("runtime.verifySignature", { did, data, signedData });
6841
7201
  }
6842
7202
  async setStatus(perspective) {
6843
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call("runtime.setStatus", { status: Perspective.toWire(perspective) });
7203
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call("runtime.setStatus", { status: Perspective.toWire(perspective) });
6844
7204
  }
6845
7205
  async friendStatus(did) {
6846
- const status = await __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call("runtime.friendStatus", { did });
7206
+ const status = await __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call("runtime.friendStatus", { did });
6847
7207
  return status ? PerspectiveExpression.fromWire(status) : null;
6848
7208
  }
6849
7209
  async friendSendMessage(did, message) {
6850
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call("runtime.sendFriendMessage", { did, message: Perspective.toWire(message) });
7210
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call("runtime.sendFriendMessage", { did, message: Perspective.toWire(message) });
6851
7211
  }
6852
7212
  async messageInbox() {
6853
- return (await __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call("runtime.inbox", {})).map(PerspectiveExpression.fromWire);
7213
+ return (await __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call("runtime.inbox", {})).map(PerspectiveExpression.fromWire);
6854
7214
  }
6855
7215
  async messageOutbox() {
6856
- const sent = await __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call("runtime.outbox", {});
7216
+ const sent = await __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call("runtime.outbox", {});
6857
7217
  return sent.map(({ recipient, message }) => ({ recipient, message: PerspectiveExpression.fromWire(message) }));
6858
7218
  }
6859
7219
  async requestInstallNotification(notification) {
6860
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call("runtime.createNotification", { ...notification });
7220
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call("runtime.createNotification", { ...notification });
6861
7221
  }
6862
7222
  async grantNotification(id) {
6863
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call("runtime.grantNotification", { id, granted: true });
7223
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call("runtime.grantNotification", { id, granted: true });
6864
7224
  }
6865
7225
  async exportDb(filePath) {
6866
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call("runtime.exportData", { type: "db", filePath });
7226
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call("runtime.exportData", { type: "db", filePath });
6867
7227
  }
6868
7228
  async importDb(filePath) {
6869
- const result = await __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call("runtime.importData", { type: "db", filePath });
7229
+ const result = await __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call("runtime.importData", { type: "db", filePath });
6870
7230
  if ("success" in result)
6871
7231
  throw new Error('runtime.importData answered a perspective import for type "db"');
6872
7232
  return result;
6873
7233
  }
6874
7234
  async notifications() {
6875
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call("runtime.notifications", {});
7235
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call("runtime.notifications", {});
6876
7236
  }
6877
7237
  async updateNotification(id, notification) {
6878
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call("runtime.updateNotification", { ...notification, id });
7238
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call("runtime.updateNotification", { ...notification, id });
6879
7239
  }
6880
7240
  async removeNotification(id) {
6881
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call("runtime.deleteNotification", { id });
7241
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call("runtime.deleteNotification", { id });
6882
7242
  }
6883
7243
  async exportPerspective(uuid, filePath) {
6884
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call("runtime.exportData", { type: "perspective", perspectiveUuid: uuid, filePath });
7244
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call("runtime.exportData", { type: "perspective", perspectiveUuid: uuid, filePath });
6885
7245
  }
6886
7246
  async importPerspective(filePath) {
6887
- const result = await __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call("runtime.importData", { type: "perspective", filePath });
7247
+ const result = await __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call("runtime.importData", { type: "perspective", filePath });
6888
7248
  return "success" in result && result.success;
6889
7249
  }
6890
7250
  async multiUserEnabled() {
6891
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call("user.multiUserEnabled", {});
7251
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call("user.multiUserEnabled", {});
6892
7252
  }
6893
7253
  async setMultiUserEnabled(enabled) {
6894
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call("user.setMultiUserEnabled", { enabled });
7254
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call("user.setMultiUserEnabled", { enabled });
6895
7255
  }
6896
7256
  async freeHostingEnabled() {
6897
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call("runtime.freeHostingEnabled", {});
7257
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call("runtime.freeHostingEnabled", {});
6898
7258
  }
6899
7259
  async setFreeHostingEnabled(enabled) {
6900
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call("runtime.setFreeHostingEnabled", { enabled });
7260
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call("runtime.setFreeHostingEnabled", { enabled });
6901
7261
  }
6902
7262
  async listUsers() {
6903
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call("user.list", {});
7263
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call("user.list", {});
6904
7264
  }
6905
7265
  async userWalletAddress(email) {
6906
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call("user.wallet", { email });
7266
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call("user.wallet", { email });
6907
7267
  }
6908
7268
  async emailTestModeEnable() {
6909
- return await __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call("user.emailTest", { action: "enable" }) === true;
7269
+ return await __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call("user.emailTest", { action: "enable" }) === true;
6910
7270
  }
6911
7271
  async emailTestModeDisable() {
6912
- return await __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call("user.emailTest", { action: "disable" }) === true;
7272
+ return await __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call("user.emailTest", { action: "disable" }) === true;
6913
7273
  }
6914
7274
  async emailTestGetCode(email) {
6915
- const code2 = await __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call("user.emailTest", { action: "get-code", email });
7275
+ const code2 = await __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call("user.emailTest", { action: "get-code", email });
6916
7276
  return typeof code2 === "string" ? code2 : null;
6917
7277
  }
6918
7278
  async emailTestClearCodes() {
6919
- return await __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call("user.emailTest", { action: "clear-codes" }) === true;
7279
+ return await __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call("user.emailTest", { action: "clear-codes" }) === true;
6920
7280
  }
6921
7281
  async emailTestSetExpiry(email, verificationType, expiresAt) {
6922
- return await __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call("user.emailTest", { action: "set-expiry", email, verificationType, expiresAt }) === true;
7282
+ return await __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call("user.emailTest", { action: "set-expiry", email, verificationType, expiresAt }) === true;
6923
7283
  }
6924
7284
  async unytAgentKey() {
6925
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call("runtime.unytAgentKey", {});
7285
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call("runtime.unytAgentKey", {});
6926
7286
  }
6927
7287
  async unytHotAgentPubkey() {
6928
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call("runtime.unytHotAgentPubkey", {});
7288
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call("runtime.unytHotAgentPubkey", {});
6929
7289
  }
6930
7290
  async unytWalletBalance() {
6931
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call("runtime.unytWalletBalance", {});
7291
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call("runtime.unytWalletBalance", {});
6932
7292
  }
6933
7293
  async unytWalletHistory(page, perPage) {
6934
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call("runtime.unytWalletHistory", { page, perPage });
7294
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call("runtime.unytWalletHistory", { page, perPage });
6935
7295
  }
6936
7296
  async unytVersionInfo() {
6937
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call("runtime.unytVersionInfo", {});
7297
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call("runtime.unytVersionInfo", {});
6938
7298
  }
6939
7299
  async setUnytMembraneProof(proof) {
6940
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call("runtime.setUnytMembraneProof", { proof });
7300
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call("runtime.setUnytMembraneProof", { proof });
6941
7301
  }
6942
7302
  async unytReinstallDna() {
6943
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call("runtime.unytReinstallDna", {});
7303
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call("runtime.unytReinstallDna", {});
6944
7304
  }
6945
7305
  async unytSendHot(recipient, amount) {
6946
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call("runtime.unytSendHot", { recipient, amount });
7306
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call("runtime.unytSendHot", { recipient, amount });
6947
7307
  }
6948
7308
  async setUserCredits(email, amount) {
6949
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call("user.credits", { email, amount });
7309
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call("user.credits", { email, amount });
6950
7310
  }
6951
7311
  async setUserFreeAccess(email, enabled) {
6952
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call("user.freeAccess", { email, enabled });
7312
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call("user.freeAccess", { email, enabled });
6953
7313
  }
6954
7314
  async setHostRates(rates) {
6955
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call("runtime.setHostRates", { rates });
7315
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call("runtime.setHostRates", { rates });
6956
7316
  }
6957
7317
  async hostRates() {
6958
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call("runtime.hostRates", {});
7318
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call("runtime.hostRates", {});
6959
7319
  }
6960
7320
  };
6961
7321
  _RuntimeClient_apiClient = /* @__PURE__ */ new WeakMap();
6962
- var __classPrivateFieldSet$3 = function(receiver, state, value, kind, f) {
7322
+ var __classPrivateFieldSet$4 = function(receiver, state, value, kind, f) {
6963
7323
  if (kind === "m")
6964
7324
  throw new TypeError("Private method is not writable");
6965
7325
  if (kind === "a" && !f)
@@ -6968,7 +7328,7 @@ var __classPrivateFieldSet$3 = function(receiver, state, value, kind, f) {
6968
7328
  throw new TypeError("Cannot write private member to an object whose class did not declare it");
6969
7329
  return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
6970
7330
  };
6971
- var __classPrivateFieldGet$3 = function(receiver, state, kind, f) {
7331
+ var __classPrivateFieldGet$4 = function(receiver, state, kind, f) {
6972
7332
  if (kind === "a" && !f)
6973
7333
  throw new TypeError("Private accessor was defined without a getter");
6974
7334
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
@@ -6990,8 +7350,8 @@ var ExpressionClient = class {
6990
7350
  _ExpressionClient_inflight.set(this, /* @__PURE__ */ new Map());
6991
7351
  _ExpressionClient_totalMemBytes.set(this, 0);
6992
7352
  _ExpressionClient_persistent.set(this, void 0);
6993
- __classPrivateFieldSet$3(this, _ExpressionClient_apiClient, sharedApiClient || new ApiClient(baseUrl, token), "f");
6994
- __classPrivateFieldSet$3(this, _ExpressionClient_persistent, createPersistentCache("ad4m-expression-cache", "expressions"), "f");
7353
+ __classPrivateFieldSet$4(this, _ExpressionClient_apiClient, sharedApiClient || new ApiClient(baseUrl, token), "f");
7354
+ __classPrivateFieldSet$4(this, _ExpressionClient_persistent, createPersistentCache("ad4m-expression-cache", "expressions"), "f");
6995
7355
  }
6996
7356
  async get(url, alwaysGet = false) {
6997
7357
  if (!alwaysGet) {
@@ -7006,47 +7366,47 @@ var ExpressionClient = class {
7006
7366
  }
7007
7367
  }
7008
7368
  if (!alwaysGet) {
7009
- const memHit = __classPrivateFieldGet$3(this, _ExpressionClient_memCache, "f").get(url);
7369
+ const memHit = __classPrivateFieldGet$4(this, _ExpressionClient_memCache, "f").get(url);
7010
7370
  if (memHit)
7011
7371
  return memHit.data;
7012
7372
  }
7013
7373
  if (!alwaysGet) {
7014
- const existing = __classPrivateFieldGet$3(this, _ExpressionClient_inflight, "f").get(url);
7374
+ const existing = __classPrivateFieldGet$4(this, _ExpressionClient_inflight, "f").get(url);
7015
7375
  if (existing)
7016
7376
  return existing;
7017
7377
  }
7018
7378
  const promise = (async () => {
7019
7379
  if (!alwaysGet) {
7020
- const persisted = await __classPrivateFieldGet$3(this, _ExpressionClient_persistent, "f").get(url);
7380
+ const persisted = await __classPrivateFieldGet$4(this, _ExpressionClient_persistent, "f").get(url);
7021
7381
  if (persisted) {
7022
- __classPrivateFieldGet$3(this, _ExpressionClient_instances, "m", _ExpressionClient_memCacheResult).call(this, url, persisted);
7382
+ __classPrivateFieldGet$4(this, _ExpressionClient_instances, "m", _ExpressionClient_memCacheResult).call(this, url, persisted);
7023
7383
  return persisted;
7024
7384
  }
7025
7385
  }
7026
- const result = await __classPrivateFieldGet$3(this, _ExpressionClient_apiClient, "f").call("expression.get", { url });
7027
- __classPrivateFieldGet$3(this, _ExpressionClient_instances, "m", _ExpressionClient_memCacheResult).call(this, url, result);
7028
- __classPrivateFieldGet$3(this, _ExpressionClient_persistent, "f").put(url, result);
7386
+ const result = await __classPrivateFieldGet$4(this, _ExpressionClient_apiClient, "f").call("expression.get", { url });
7387
+ __classPrivateFieldGet$4(this, _ExpressionClient_instances, "m", _ExpressionClient_memCacheResult).call(this, url, result);
7388
+ __classPrivateFieldGet$4(this, _ExpressionClient_persistent, "f").put(url, result);
7029
7389
  return result;
7030
7390
  })();
7031
- __classPrivateFieldGet$3(this, _ExpressionClient_inflight, "f").set(url, promise);
7391
+ __classPrivateFieldGet$4(this, _ExpressionClient_inflight, "f").set(url, promise);
7032
7392
  try {
7033
7393
  return await promise;
7034
7394
  } finally {
7035
- __classPrivateFieldGet$3(this, _ExpressionClient_inflight, "f").delete(url);
7395
+ __classPrivateFieldGet$4(this, _ExpressionClient_inflight, "f").delete(url);
7036
7396
  }
7037
7397
  }
7038
7398
  async getMany(urls) {
7039
- const results = urls.map((u) => __classPrivateFieldGet$3(this, _ExpressionClient_memCache, "f").get(u)?.data ?? null);
7399
+ const results = urls.map((u) => __classPrivateFieldGet$4(this, _ExpressionClient_memCache, "f").get(u)?.data ?? null);
7040
7400
  let uncachedIndices = results.map((r, i) => r === null ? i : -1).filter((i) => i >= 0);
7041
7401
  if (uncachedIndices.length === 0)
7042
7402
  return results;
7043
- const l2Results = await Promise.all(uncachedIndices.map((i) => __classPrivateFieldGet$3(this, _ExpressionClient_persistent, "f").get(urls[i])));
7403
+ const l2Results = await Promise.all(uncachedIndices.map((i) => __classPrivateFieldGet$4(this, _ExpressionClient_persistent, "f").get(urls[i])));
7044
7404
  const stillMissing = [];
7045
7405
  for (let j = 0; j < uncachedIndices.length; j++) {
7046
7406
  const idx = uncachedIndices[j];
7047
7407
  if (l2Results[j]) {
7048
7408
  results[idx] = l2Results[j];
7049
- __classPrivateFieldGet$3(this, _ExpressionClient_instances, "m", _ExpressionClient_memCacheResult).call(this, urls[idx], l2Results[j]);
7409
+ __classPrivateFieldGet$4(this, _ExpressionClient_instances, "m", _ExpressionClient_memCacheResult).call(this, urls[idx], l2Results[j]);
7050
7410
  } else {
7051
7411
  stillMissing.push(idx);
7052
7412
  }
@@ -7054,53 +7414,53 @@ var ExpressionClient = class {
7054
7414
  if (stillMissing.length === 0)
7055
7415
  return results;
7056
7416
  const uncachedUrls = stillMissing.map((i) => urls[i]);
7057
- const fetched = await __classPrivateFieldGet$3(this, _ExpressionClient_apiClient, "f").call("expression.getMany", { urls: uncachedUrls });
7417
+ const fetched = await __classPrivateFieldGet$4(this, _ExpressionClient_apiClient, "f").call("expression.getMany", { urls: uncachedUrls });
7058
7418
  for (let i = 0; i < stillMissing.length; i++) {
7059
7419
  const idx = stillMissing[i];
7060
7420
  results[idx] = fetched[i];
7061
7421
  if (fetched[i]) {
7062
- __classPrivateFieldGet$3(this, _ExpressionClient_instances, "m", _ExpressionClient_memCacheResult).call(this, uncachedUrls[i], fetched[i]);
7063
- __classPrivateFieldGet$3(this, _ExpressionClient_persistent, "f").put(uncachedUrls[i], fetched[i]);
7422
+ __classPrivateFieldGet$4(this, _ExpressionClient_instances, "m", _ExpressionClient_memCacheResult).call(this, uncachedUrls[i], fetched[i]);
7423
+ __classPrivateFieldGet$4(this, _ExpressionClient_persistent, "f").put(uncachedUrls[i], fetched[i]);
7064
7424
  }
7065
7425
  }
7066
7426
  return results;
7067
7427
  }
7068
7428
  clearCache() {
7069
- __classPrivateFieldGet$3(this, _ExpressionClient_memCache, "f").clear();
7070
- __classPrivateFieldGet$3(this, _ExpressionClient_inflight, "f").clear();
7071
- __classPrivateFieldSet$3(this, _ExpressionClient_totalMemBytes, 0, "f");
7072
- __classPrivateFieldGet$3(this, _ExpressionClient_persistent, "f").clear();
7429
+ __classPrivateFieldGet$4(this, _ExpressionClient_memCache, "f").clear();
7430
+ __classPrivateFieldGet$4(this, _ExpressionClient_inflight, "f").clear();
7431
+ __classPrivateFieldSet$4(this, _ExpressionClient_totalMemBytes, 0, "f");
7432
+ __classPrivateFieldGet$4(this, _ExpressionClient_persistent, "f").clear();
7073
7433
  }
7074
7434
  async getRaw(url) {
7075
- return __classPrivateFieldGet$3(this, _ExpressionClient_apiClient, "f").call("expression.getRaw", { url });
7435
+ return __classPrivateFieldGet$4(this, _ExpressionClient_apiClient, "f").call("expression.getRaw", { url });
7076
7436
  }
7077
7437
  async create(content, languageAddress) {
7078
7438
  const serialized = JSON.stringify(content);
7079
- return __classPrivateFieldGet$3(this, _ExpressionClient_apiClient, "f").call("expression.create", { content: serialized, languageAddress });
7439
+ return __classPrivateFieldGet$4(this, _ExpressionClient_apiClient, "f").call("expression.create", { content: serialized, languageAddress });
7080
7440
  }
7081
7441
  async interactions(url) {
7082
- return __classPrivateFieldGet$3(this, _ExpressionClient_apiClient, "f").call("expression.interactions", { url });
7442
+ return __classPrivateFieldGet$4(this, _ExpressionClient_apiClient, "f").call("expression.interactions", { url });
7083
7443
  }
7084
7444
  async interact(url, interactionCall) {
7085
- const result = await __classPrivateFieldGet$3(this, _ExpressionClient_apiClient, "f").call("expression.interact", { url, interactionCall });
7086
- __classPrivateFieldGet$3(this, _ExpressionClient_memCache, "f").delete(url);
7087
- __classPrivateFieldGet$3(this, _ExpressionClient_inflight, "f").delete(url);
7088
- __classPrivateFieldGet$3(this, _ExpressionClient_persistent, "f").delete(url);
7445
+ const result = await __classPrivateFieldGet$4(this, _ExpressionClient_apiClient, "f").call("expression.interact", { url, interactionCall });
7446
+ __classPrivateFieldGet$4(this, _ExpressionClient_memCache, "f").delete(url);
7447
+ __classPrivateFieldGet$4(this, _ExpressionClient_inflight, "f").delete(url);
7448
+ __classPrivateFieldGet$4(this, _ExpressionClient_persistent, "f").delete(url);
7089
7449
  return result;
7090
7450
  }
7091
7451
  };
7092
7452
  _ExpressionClient_apiClient = /* @__PURE__ */ new WeakMap(), _ExpressionClient_memCache = /* @__PURE__ */ new WeakMap(), _ExpressionClient_inflight = /* @__PURE__ */ new WeakMap(), _ExpressionClient_totalMemBytes = /* @__PURE__ */ new WeakMap(), _ExpressionClient_persistent = /* @__PURE__ */ new WeakMap(), _ExpressionClient_instances = /* @__PURE__ */ new WeakSet(), _ExpressionClient_memCacheResult = function _ExpressionClient_memCacheResult2(url, data) {
7093
7453
  const size = JSON.stringify(data).length;
7094
- while (__classPrivateFieldGet$3(this, _ExpressionClient_memCache, "f").size >= ExpressionClient.MAX_MEM_ENTRIES || __classPrivateFieldGet$3(this, _ExpressionClient_totalMemBytes, "f") + size > ExpressionClient.MAX_MEM_BYTES) {
7095
- const oldest = __classPrivateFieldGet$3(this, _ExpressionClient_memCache, "f").keys().next().value;
7454
+ while (__classPrivateFieldGet$4(this, _ExpressionClient_memCache, "f").size >= ExpressionClient.MAX_MEM_ENTRIES || __classPrivateFieldGet$4(this, _ExpressionClient_totalMemBytes, "f") + size > ExpressionClient.MAX_MEM_BYTES) {
7455
+ const oldest = __classPrivateFieldGet$4(this, _ExpressionClient_memCache, "f").keys().next().value;
7096
7456
  if (!oldest)
7097
7457
  break;
7098
- const entry = __classPrivateFieldGet$3(this, _ExpressionClient_memCache, "f").get(oldest);
7099
- __classPrivateFieldSet$3(this, _ExpressionClient_totalMemBytes, __classPrivateFieldGet$3(this, _ExpressionClient_totalMemBytes, "f") - entry.size, "f");
7100
- __classPrivateFieldGet$3(this, _ExpressionClient_memCache, "f").delete(oldest);
7458
+ const entry = __classPrivateFieldGet$4(this, _ExpressionClient_memCache, "f").get(oldest);
7459
+ __classPrivateFieldSet$4(this, _ExpressionClient_totalMemBytes, __classPrivateFieldGet$4(this, _ExpressionClient_totalMemBytes, "f") - entry.size, "f");
7460
+ __classPrivateFieldGet$4(this, _ExpressionClient_memCache, "f").delete(oldest);
7101
7461
  }
7102
- __classPrivateFieldGet$3(this, _ExpressionClient_memCache, "f").set(url, { data, size });
7103
- __classPrivateFieldSet$3(this, _ExpressionClient_totalMemBytes, __classPrivateFieldGet$3(this, _ExpressionClient_totalMemBytes, "f") + size, "f");
7462
+ __classPrivateFieldGet$4(this, _ExpressionClient_memCache, "f").set(url, { data, size });
7463
+ __classPrivateFieldSet$4(this, _ExpressionClient_totalMemBytes, __classPrivateFieldGet$4(this, _ExpressionClient_totalMemBytes, "f") + size, "f");
7104
7464
  };
7105
7465
  ExpressionClient.MAX_MEM_ENTRIES = 200;
7106
7466
  ExpressionClient.MAX_MEM_BYTES = 5 * 1024 * 1024;
@@ -11300,7 +11660,7 @@ var AITaskInput = class {
11300
11660
  this.metaData = metaData;
11301
11661
  }
11302
11662
  };
11303
- var __classPrivateFieldSet$2 = function(receiver, state, value, kind, f) {
11663
+ var __classPrivateFieldSet$3 = function(receiver, state, value, kind, f) {
11304
11664
  if (kind === "m")
11305
11665
  throw new TypeError("Private method is not writable");
11306
11666
  if (kind === "a" && !f)
@@ -11309,7 +11669,7 @@ var __classPrivateFieldSet$2 = function(receiver, state, value, kind, f) {
11309
11669
  throw new TypeError("Cannot write private member to an object whose class did not declare it");
11310
11670
  return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
11311
11671
  };
11312
- var __classPrivateFieldGet$2 = function(receiver, state, kind, f) {
11672
+ var __classPrivateFieldGet$3 = function(receiver, state, kind, f) {
11313
11673
  if (kind === "a" && !f)
11314
11674
  throw new TypeError("Private accessor was defined without a getter");
11315
11675
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
@@ -11324,44 +11684,44 @@ var AIClient = class {
11324
11684
  _AIClient_apiClient.set(this, void 0);
11325
11685
  _AIClient_transcriptionUnsubscribers.set(this, /* @__PURE__ */ new Map());
11326
11686
  _AIClient_pendingStreamIds.set(this, /* @__PURE__ */ new Set());
11327
- __classPrivateFieldSet$2(this, _AIClient_apiClient, sharedApiClient || new ApiClient(baseUrl, token), "f");
11687
+ __classPrivateFieldSet$3(this, _AIClient_apiClient, sharedApiClient || new ApiClient(baseUrl, token), "f");
11328
11688
  }
11329
11689
  serializeModelInput({ modelType, ...model }) {
11330
11690
  return { ...model, type: modelType };
11331
11691
  }
11332
11692
  async getModels() {
11333
- return __classPrivateFieldGet$2(this, _AIClient_apiClient, "f").call("ai.models", {});
11693
+ return __classPrivateFieldGet$3(this, _AIClient_apiClient, "f").call("ai.models", {});
11334
11694
  }
11335
11695
  async discoverModels(baseUrl, apiKey, apiType) {
11336
- return __classPrivateFieldGet$2(this, _AIClient_apiClient, "f").call("ai.discoverModels", { baseUrl, apiKey, apiType });
11696
+ return __classPrivateFieldGet$3(this, _AIClient_apiClient, "f").call("ai.discoverModels", { baseUrl, apiKey, apiType });
11337
11697
  }
11338
11698
  async addModel(model, options) {
11339
- return __classPrivateFieldGet$2(this, _AIClient_apiClient, "f").call("ai.addModel", { model: this.serializeModelInput(model) }, options);
11699
+ return __classPrivateFieldGet$3(this, _AIClient_apiClient, "f").call("ai.addModel", { model: this.serializeModelInput(model) }, options);
11340
11700
  }
11341
11701
  async updateModel(modelId, model) {
11342
- return __classPrivateFieldGet$2(this, _AIClient_apiClient, "f").call("ai.updateModel", { id: modelId, model: this.serializeModelInput(model) });
11702
+ return __classPrivateFieldGet$3(this, _AIClient_apiClient, "f").call("ai.updateModel", { id: modelId, model: this.serializeModelInput(model) });
11343
11703
  }
11344
11704
  async removeModel(modelId) {
11345
- return __classPrivateFieldGet$2(this, _AIClient_apiClient, "f").call("ai.removeModel", { id: modelId });
11705
+ return __classPrivateFieldGet$3(this, _AIClient_apiClient, "f").call("ai.removeModel", { id: modelId });
11346
11706
  }
11347
11707
  async setDefaultModel(modelType, modelId) {
11348
- return __classPrivateFieldGet$2(this, _AIClient_apiClient, "f").call("ai.setDefaultModel", { id: modelId, modelType });
11708
+ return __classPrivateFieldGet$3(this, _AIClient_apiClient, "f").call("ai.setDefaultModel", { id: modelId, modelType });
11349
11709
  }
11350
11710
  async getDefaultModel(modelType) {
11351
- return __classPrivateFieldGet$2(this, _AIClient_apiClient, "f").call("ai.getDefaultModel", { modelType });
11711
+ return __classPrivateFieldGet$3(this, _AIClient_apiClient, "f").call("ai.getDefaultModel", { modelType });
11352
11712
  }
11353
11713
  async tasks() {
11354
- return __classPrivateFieldGet$2(this, _AIClient_apiClient, "f").call("ai.tasks", {});
11714
+ return __classPrivateFieldGet$3(this, _AIClient_apiClient, "f").call("ai.tasks", {});
11355
11715
  }
11356
11716
  async addTask(name, modelId, systemPrompt, promptExamples, metaData) {
11357
11717
  const task = new AITaskInput(name, modelId, systemPrompt, promptExamples, metaData);
11358
- return __classPrivateFieldGet$2(this, _AIClient_apiClient, "f").call("ai.addTask", { task });
11718
+ return __classPrivateFieldGet$3(this, _AIClient_apiClient, "f").call("ai.addTask", { task });
11359
11719
  }
11360
11720
  async removeTask(taskId) {
11361
- return __classPrivateFieldGet$2(this, _AIClient_apiClient, "f").call("ai.removeTask", { id: taskId });
11721
+ return __classPrivateFieldGet$3(this, _AIClient_apiClient, "f").call("ai.removeTask", { id: taskId });
11362
11722
  }
11363
11723
  async updateTask(taskId, task) {
11364
- return __classPrivateFieldGet$2(this, _AIClient_apiClient, "f").call("ai.updateTask", {
11724
+ return __classPrivateFieldGet$3(this, _AIClient_apiClient, "f").call("ai.updateTask", {
11365
11725
  task: {
11366
11726
  taskId,
11367
11727
  name: task.name,
@@ -11375,34 +11735,34 @@ var AIClient = class {
11375
11735
  });
11376
11736
  }
11377
11737
  async modelLoadingStatus(model) {
11378
- return __classPrivateFieldGet$2(this, _AIClient_apiClient, "f").call("ai.modelLoadingStatus", { model });
11738
+ return __classPrivateFieldGet$3(this, _AIClient_apiClient, "f").call("ai.modelLoadingStatus", { model });
11379
11739
  }
11380
11740
  async prompt(taskId, prompt, options) {
11381
- return __classPrivateFieldGet$2(this, _AIClient_apiClient, "f").call("ai.prompt", { taskId, prompt }, options);
11741
+ return __classPrivateFieldGet$3(this, _AIClient_apiClient, "f").call("ai.prompt", { taskId, prompt }, options);
11382
11742
  }
11383
11743
  async embed(modelId, text, options) {
11384
- const aiEmbed = await __classPrivateFieldGet$2(this, _AIClient_apiClient, "f").call("ai.embed", { modelId, text }, options);
11744
+ const aiEmbed = await __classPrivateFieldGet$3(this, _AIClient_apiClient, "f").call("ai.embed", { modelId, text }, options);
11385
11745
  const compressed = base64Js.toByteArray(aiEmbed);
11386
11746
  const inflated = pako.inflate(compressed);
11387
11747
  const decompressed = JSON.parse(new TextDecoder("utf-8").decode(inflated));
11388
11748
  return decompressed;
11389
11749
  }
11390
11750
  async openTranscriptionStream(modelId, streamCallback, params) {
11391
- const streamId = await __classPrivateFieldGet$2(this, _AIClient_apiClient, "f").call("ai.transcriptionOpen", { modelId, params });
11392
- const unsub = __classPrivateFieldGet$2(this, _AIClient_apiClient, "f").on("transcription-text", (event) => {
11751
+ const streamId = await __classPrivateFieldGet$3(this, _AIClient_apiClient, "f").call("ai.transcriptionOpen", { modelId, params });
11752
+ const unsub = __classPrivateFieldGet$3(this, _AIClient_apiClient, "f").on("transcription-text", (event) => {
11393
11753
  if (event.streamId === streamId && event.text)
11394
11754
  streamCallback(event.text);
11395
11755
  });
11396
- __classPrivateFieldGet$2(this, _AIClient_transcriptionUnsubscribers, "f").set(streamId, unsub);
11756
+ __classPrivateFieldGet$3(this, _AIClient_transcriptionUnsubscribers, "f").set(streamId, unsub);
11397
11757
  return streamId;
11398
11758
  }
11399
11759
  async closeTranscriptionStream(streamId) {
11400
- __classPrivateFieldGet$2(this, _AIClient_pendingStreamIds, "f").delete(streamId);
11760
+ __classPrivateFieldGet$3(this, _AIClient_pendingStreamIds, "f").delete(streamId);
11401
11761
  try {
11402
- await __classPrivateFieldGet$2(this, _AIClient_apiClient, "f").call("ai.transcriptionClose", { streamId });
11762
+ await __classPrivateFieldGet$3(this, _AIClient_apiClient, "f").call("ai.transcriptionClose", { streamId });
11403
11763
  } finally {
11404
- __classPrivateFieldGet$2(this, _AIClient_transcriptionUnsubscribers, "f").get(streamId)?.();
11405
- __classPrivateFieldGet$2(this, _AIClient_transcriptionUnsubscribers, "f").delete(streamId);
11764
+ __classPrivateFieldGet$3(this, _AIClient_transcriptionUnsubscribers, "f").get(streamId)?.();
11765
+ __classPrivateFieldGet$3(this, _AIClient_transcriptionUnsubscribers, "f").delete(streamId);
11406
11766
  }
11407
11767
  }
11408
11768
  async feedTranscriptionStream(streamIds, audio) {
@@ -11411,10 +11771,10 @@ var AIClient = class {
11411
11771
  if (ids.length === 0 || typedAudio.length === 0) {
11412
11772
  return;
11413
11773
  }
11414
- const baseUrl = __classPrivateFieldGet$2(this, _AIClient_apiClient, "f").getBaseUrl();
11415
- const token = __classPrivateFieldGet$2(this, _AIClient_apiClient, "f").getToken();
11774
+ const baseUrl = __classPrivateFieldGet$3(this, _AIClient_apiClient, "f").getBaseUrl();
11775
+ const token = __classPrivateFieldGet$3(this, _AIClient_apiClient, "f").getToken();
11416
11776
  const bodyBuffer = typedAudio.buffer.slice(typedAudio.byteOffset, typedAudio.byteOffset + typedAudio.byteLength);
11417
- const response = await __classPrivateFieldGet$2(this, _AIClient_apiClient, "f").doFetch(`${baseUrl}/api/v1/ai/transcription/feed`, {
11777
+ const response = await __classPrivateFieldGet$3(this, _AIClient_apiClient, "f").doFetch(`${baseUrl}/api/v1/ai/transcription/feed`, {
11418
11778
  method: "POST",
11419
11779
  headers: {
11420
11780
  "Content-Type": "application/octet-stream",
@@ -11430,6 +11790,67 @@ var AIClient = class {
11430
11790
  }
11431
11791
  };
11432
11792
  _AIClient_apiClient = /* @__PURE__ */ new WeakMap(), _AIClient_transcriptionUnsubscribers = /* @__PURE__ */ new WeakMap(), _AIClient_pendingStreamIds = /* @__PURE__ */ new WeakMap();
11793
+ var __classPrivateFieldSet$2 = function(receiver, state, value, kind, f) {
11794
+ if (kind === "m")
11795
+ throw new TypeError("Private method is not writable");
11796
+ if (kind === "a" && !f)
11797
+ throw new TypeError("Private accessor was defined without a setter");
11798
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
11799
+ throw new TypeError("Cannot write private member to an object whose class did not declare it");
11800
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
11801
+ };
11802
+ var __classPrivateFieldGet$2 = function(receiver, state, kind, f) {
11803
+ if (kind === "a" && !f)
11804
+ throw new TypeError("Private accessor was defined without a getter");
11805
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
11806
+ throw new TypeError("Cannot read private member from an object whose class did not declare it");
11807
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11808
+ };
11809
+ var _IdentityClient_apiClient;
11810
+ var IdentityClient = class {
11811
+ constructor(baseUrl, token, sharedApiClient) {
11812
+ _IdentityClient_apiClient.set(this, void 0);
11813
+ __classPrivateFieldSet$2(this, _IdentityClient_apiClient, sharedApiClient || new ApiClient(baseUrl, token), "f");
11814
+ }
11815
+ async status() {
11816
+ return __classPrivateFieldGet$2(this, _IdentityClient_apiClient, "f").call("identity.status", {});
11817
+ }
11818
+ async log(did, from, fresh) {
11819
+ return __classPrivateFieldGet$2(this, _IdentityClient_apiClient, "f").call("identity.log", { did, from, fresh });
11820
+ }
11821
+ async resolve(didUrl, options = {}) {
11822
+ return __classPrivateFieldGet$2(this, _IdentityClient_apiClient, "f").call("identity.resolve", {
11823
+ didUrl,
11824
+ fresh: options.fresh,
11825
+ accept: options.accept
11826
+ });
11827
+ }
11828
+ async resetLog(did) {
11829
+ return __classPrivateFieldGet$2(this, _IdentityClient_apiClient, "f").call("identity.resetLog", { did });
11830
+ }
11831
+ async cosignIncept(event) {
11832
+ return __classPrivateFieldGet$2(this, _IdentityClient_apiClient, "f").call("identity.cosignIncept", { event });
11833
+ }
11834
+ async publish(events) {
11835
+ return __classPrivateFieldGet$2(this, _IdentityClient_apiClient, "f").call("identity.publish", { events });
11836
+ }
11837
+ async openOffer(signedOffer) {
11838
+ return __classPrivateFieldGet$2(this, _IdentityClient_apiClient, "f").call("identity.openOffer", { signedOffer });
11839
+ }
11840
+ async offers(request, wait) {
11841
+ return __classPrivateFieldGet$2(this, _IdentityClient_apiClient, "f").call("identity.offers", { request, wait });
11842
+ }
11843
+ async claimOffer(offer, hint) {
11844
+ return __classPrivateFieldGet$2(this, _IdentityClient_apiClient, "f").call("identity.claimOffer", { offer, hint });
11845
+ }
11846
+ async joinStatus(offerId) {
11847
+ return __classPrivateFieldGet$2(this, _IdentityClient_apiClient, "f").call("identity.joinStatus", { offerId });
11848
+ }
11849
+ async devices() {
11850
+ return __classPrivateFieldGet$2(this, _IdentityClient_apiClient, "f").call("identity.devices", {});
11851
+ }
11852
+ };
11853
+ _IdentityClient_apiClient = /* @__PURE__ */ new WeakMap();
11433
11854
  function isContainmentTraversal(scope) {
11434
11855
  return isTraverseScope(scope) && !("predicate" in scope && scope.predicate) && !("model" in scope && scope.model);
11435
11856
  }
@@ -12063,6 +12484,7 @@ function buildSPARQLWhereFilters(metadata, _allRelationsMetadata, where) {
12063
12484
  }
12064
12485
  return { joins, filters };
12065
12486
  }
12487
+ var fingerprint = (value) => JSON.stringify(value, (_, v) => typeof v === "function" ? void 0 : v);
12066
12488
  var ModelQueryBuilder = class {
12067
12489
  constructor(perspective, ctor, query, unionClasses) {
12068
12490
  this.queryParams = {};
@@ -12094,6 +12516,9 @@ var ModelQueryBuilder = class {
12094
12516
  }
12095
12517
  return this.ctor.parseModelResult(this.perspective, raw, include, properties);
12096
12518
  }
12519
+ takeSnapshots(instances) {
12520
+ this.ctor.takeSnapshots(instances, this.queryParams.include);
12521
+ }
12097
12522
  dispose() {
12098
12523
  if (this.currentSubscription) {
12099
12524
  this.currentSubscription.dispose();
@@ -12199,7 +12624,6 @@ var ModelQueryBuilder = class {
12199
12624
  async subscribe(callback) {
12200
12625
  this.dispose();
12201
12626
  const parseResults = (raw) => this.parse(raw);
12202
- const fingerprint = (results) => JSON.stringify(results, (_, v) => typeof v === "function" ? void 0 : v);
12203
12627
  let lastFingerprint = null;
12204
12628
  const { initial } = await this.live(this.queryParams, (raw) => {
12205
12629
  try {
@@ -12248,53 +12672,33 @@ var ModelQueryBuilder = class {
12248
12672
  }
12249
12673
  async paginateSubscribe(pageSize, pageNumber, callback) {
12250
12674
  this.dispose();
12251
- const subscriptionParams = { ...this.queryParams || {} };
12252
- delete subscriptionParams.limit;
12253
- delete subscriptionParams.offset;
12254
12675
  const paginatedQuery = {
12255
12676
  ...this.queryParams || {},
12256
12677
  limit: pageSize,
12257
12678
  offset: pageSize * (pageNumber - 1),
12258
12679
  count: true
12259
12680
  };
12260
- let disposed = false;
12261
- let fetching = false;
12262
- let pending = false;
12263
- const processResults = async () => {
12264
- if (disposed)
12265
- return;
12266
- if (fetching) {
12267
- pending = true;
12268
- return;
12269
- }
12270
- fetching = true;
12681
+ let lastFingerprint = null;
12682
+ const toPage = (raw) => {
12683
+ const results = this.parse(raw);
12684
+ const fp2 = fingerprint([results, raw?.totalCount]);
12685
+ this.takeSnapshots(results);
12686
+ return { page: { results, totalCount: raw?.totalCount, pageSize, pageNumber }, fp: fp2 };
12687
+ };
12688
+ const { initial } = await this.live(paginatedQuery, (raw) => {
12271
12689
  try {
12272
- const { results: results2, totalCount: totalCount2 } = await this.execute(paginatedQuery);
12273
- if (!disposed)
12274
- callback({ results: results2, totalCount: totalCount2, pageSize, pageNumber });
12275
- } finally {
12276
- fetching = false;
12277
- if (pending) {
12278
- pending = false;
12279
- processResults().catch((e) => console.error("Paginate subscription error:", e));
12280
- }
12690
+ const { page: page2, fp: fp2 } = toPage(raw);
12691
+ if (fp2 === lastFingerprint)
12692
+ return;
12693
+ lastFingerprint = fp2;
12694
+ callback(page2);
12695
+ } catch (e) {
12696
+ console.error("Paginate subscription error:", e);
12281
12697
  }
12282
- };
12283
- const { live } = await this.live(subscriptionParams, () => {
12284
- processResults().catch((e) => console.error("Paginate subscription error:", e));
12285
12698
  });
12286
- if (this.currentSubscription === live) {
12287
- this.currentSubscription = {
12288
- dispose: () => {
12289
- disposed = true;
12290
- live.dispose();
12291
- }
12292
- };
12293
- } else {
12294
- disposed = true;
12295
- }
12296
- const { results, totalCount } = await this.execute(paginatedQuery);
12297
- return { results, totalCount, pageSize, pageNumber };
12699
+ const { page, fp } = toPage(initial);
12700
+ lastFingerprint = fp;
12701
+ return page;
12298
12702
  }
12299
12703
  async paginateSubscribeSparql(pageSize, pageNumber, callback) {
12300
12704
  return await this.paginateSubscribe(pageSize, pageNumber, callback);
@@ -12619,7 +13023,10 @@ var Ad4mModel = class {
12619
13023
  }
12620
13024
  constructor(perspective, baseExpression) {
12621
13025
  this._snapshot = null;
13026
+ this._idMinted = false;
13027
+ this._relationsWritten = /* @__PURE__ */ new Set();
12622
13028
  this._baseExpression = baseExpression ? baseExpression : `ad4m://obj/${makeRandomId(24)}`;
13029
+ this._idMinted = !baseExpression;
12623
13030
  this._perspective = perspective;
12624
13031
  }
12625
13032
  get id() {
@@ -12891,6 +13298,12 @@ var Ad4mModel = class {
12891
13298
  return [];
12892
13299
  return arr.map((json) => jsonToModelInstance(this, perspective, json, include, properties));
12893
13300
  }
13301
+ static takeSnapshots(instances, include) {
13302
+ const relations = include ? Object.fromEntries(Object.entries(include).filter(([k]) => !k.startsWith("$"))) : void 0;
13303
+ const snapshot = relations && Object.keys(relations).length > 0 ? relations : void 0;
13304
+ for (const inst of instances)
13305
+ inst.takeSnapshot?.(snapshot);
13306
+ }
12894
13307
  static prepareUnionQueryParams(classes, query = {}) {
12895
13308
  if (!classes.length)
12896
13309
  throw new Error("A query over several classes needs at least one class");
@@ -12963,10 +13376,7 @@ var Ad4mModel = class {
12963
13376
  const { classNames, queryJson } = Ad4mModel.prepareUnionQueryParams(classes, query);
12964
13377
  const result = await perspective.modelQuery(classNames, queryJson, options);
12965
13378
  const results = Ad4mModel.parseUnionResult(classes, perspective, result, query.include, query.properties);
12966
- const snapshotRelations = query.include ? Object.fromEntries(Object.entries(query.include).filter(([k]) => !k.startsWith("$"))) : void 0;
12967
- for (const inst of results) {
12968
- inst.takeSnapshot?.(snapshotRelations && Object.keys(snapshotRelations).length > 0 ? snapshotRelations : void 0);
12969
- }
13379
+ Ad4mModel.takeSnapshots(results, query.include);
12970
13380
  return { results, totalCount: result.totalCount };
12971
13381
  }
12972
13382
  static async findAllOf(perspective, classes, query, options) {
@@ -12982,10 +13392,7 @@ var Ad4mModel = class {
12982
13392
  const instances = result.instances.map((json) => {
12983
13393
  return jsonToModelInstance(this, perspective, json, query.include, query.properties);
12984
13394
  });
12985
- const snapshotRelations = query.include ? Object.fromEntries(Object.entries(query.include).filter(([k]) => !k.startsWith("$"))) : void 0;
12986
- for (const inst of instances) {
12987
- inst.takeSnapshot(snapshotRelations && Object.keys(snapshotRelations).length > 0 ? snapshotRelations : void 0);
12988
- }
13395
+ Ad4mModel.takeSnapshots(instances, query.include);
12989
13396
  return {
12990
13397
  results: instances,
12991
13398
  totalCount: result.totalCount
@@ -13054,6 +13461,7 @@ var Ad4mModel = class {
13054
13461
  console.warn(`Relation "${key}" has no metadata, skipping`);
13055
13462
  return;
13056
13463
  }
13464
+ this._relationsWritten.add(metadata.predicate);
13057
13465
  const abstractName = this.abstractName();
13058
13466
  if (abstractName) {
13059
13467
  if (value != null)
@@ -13075,6 +13483,7 @@ var Ad4mModel = class {
13075
13483
  console.warn(`Relation "${key}" has no metadata, skipping`);
13076
13484
  return;
13077
13485
  }
13486
+ this._relationsWritten.add(metadata.predicate);
13078
13487
  const abstractName = this.abstractName();
13079
13488
  if (abstractName) {
13080
13489
  if (value != null)
@@ -13244,6 +13653,8 @@ var Ad4mModel = class {
13244
13653
  break;
13245
13654
  }
13246
13655
  } else if (Array.isArray(value)) {
13656
+ if (value.length === 0 && !this._snapshot && this._idMinted && !this._relationsWritten.has(this.getRelationOptions(key)?.predicate ?? key))
13657
+ continue;
13247
13658
  await this.setRelationValues(key, value, batchId);
13248
13659
  } else if (value !== void 0 && value !== null && value !== "") {
13249
13660
  const relationMeta = this.getRelationOptions(key);
@@ -13477,6 +13888,7 @@ var _Ad4mClient_neighbourhoodClient;
13477
13888
  var _Ad4mClient_perspectiveClient;
13478
13889
  var _Ad4mClient_runtimeClient;
13479
13890
  var _Ad4mClient_aiClient;
13891
+ var _Ad4mClient_identityClient;
13480
13892
  var Ad4mClient = class {
13481
13893
  constructor(baseUrl, token, options) {
13482
13894
  _Ad4mClient_baseUrl.set(this, void 0);
@@ -13489,6 +13901,7 @@ var Ad4mClient = class {
13489
13901
  _Ad4mClient_perspectiveClient.set(this, void 0);
13490
13902
  _Ad4mClient_runtimeClient.set(this, void 0);
13491
13903
  _Ad4mClient_aiClient.set(this, void 0);
13904
+ _Ad4mClient_identityClient.set(this, void 0);
13492
13905
  __classPrivateFieldSet$1(this, _Ad4mClient_baseUrl, baseUrl, "f");
13493
13906
  __classPrivateFieldSet$1(this, _Ad4mClient_token, token, "f");
13494
13907
  __classPrivateFieldSet$1(this, _Ad4mClient_apiClient, new ApiClient(baseUrl, token, options?.webSocketImpl, options?.fetchImpl), "f");
@@ -13502,6 +13915,7 @@ var Ad4mClient = class {
13502
13915
  __classPrivateFieldGet$1(this, _Ad4mClient_perspectiveClient, "f").setNeighbourhoodClient(__classPrivateFieldGet$1(this, _Ad4mClient_neighbourhoodClient, "f"));
13503
13916
  __classPrivateFieldGet$1(this, _Ad4mClient_perspectiveClient, "f").setAIClient(__classPrivateFieldGet$1(this, _Ad4mClient_aiClient, "f"));
13504
13917
  __classPrivateFieldSet$1(this, _Ad4mClient_runtimeClient, new RuntimeClient(baseUrl, token, __classPrivateFieldGet$1(this, _Ad4mClient_apiClient, "f")), "f");
13918
+ __classPrivateFieldSet$1(this, _Ad4mClient_identityClient, new IdentityClient(baseUrl, token, __classPrivateFieldGet$1(this, _Ad4mClient_apiClient, "f")), "f");
13505
13919
  try {
13506
13920
  const dt = globalThis.__AD4M_DEVTOOLS__;
13507
13921
  if (dt) {
@@ -13532,18 +13946,24 @@ var Ad4mClient = class {
13532
13946
  get ai() {
13533
13947
  return __classPrivateFieldGet$1(this, _Ad4mClient_aiClient, "f");
13534
13948
  }
13949
+ get identity() {
13950
+ return __classPrivateFieldGet$1(this, _Ad4mClient_identityClient, "f");
13951
+ }
13535
13952
  on(type, handler, filter) {
13536
13953
  return __classPrivateFieldGet$1(this, _Ad4mClient_apiClient, "f").on(type, handler, filter);
13537
13954
  }
13538
13955
  onAuthFailed(callback) {
13539
13956
  return __classPrivateFieldGet$1(this, _Ad4mClient_apiClient, "f").onAuthFailed(callback);
13540
13957
  }
13958
+ reconnectNow() {
13959
+ __classPrivateFieldGet$1(this, _Ad4mClient_apiClient, "f").reconnectNow();
13960
+ }
13541
13961
  close() {
13542
13962
  __classPrivateFieldGet$1(this, _Ad4mClient_agentClient, "f").clearByDidCache();
13543
13963
  __classPrivateFieldGet$1(this, _Ad4mClient_apiClient, "f").closeAll();
13544
13964
  }
13545
13965
  };
13546
- _Ad4mClient_baseUrl = /* @__PURE__ */ new WeakMap(), _Ad4mClient_token = /* @__PURE__ */ new WeakMap(), _Ad4mClient_apiClient = /* @__PURE__ */ new WeakMap(), _Ad4mClient_agentClient = /* @__PURE__ */ new WeakMap(), _Ad4mClient_expressionClient = /* @__PURE__ */ new WeakMap(), _Ad4mClient_languageClient = /* @__PURE__ */ new WeakMap(), _Ad4mClient_neighbourhoodClient = /* @__PURE__ */ new WeakMap(), _Ad4mClient_perspectiveClient = /* @__PURE__ */ new WeakMap(), _Ad4mClient_runtimeClient = /* @__PURE__ */ new WeakMap(), _Ad4mClient_aiClient = /* @__PURE__ */ new WeakMap();
13966
+ _Ad4mClient_baseUrl = /* @__PURE__ */ new WeakMap(), _Ad4mClient_token = /* @__PURE__ */ new WeakMap(), _Ad4mClient_apiClient = /* @__PURE__ */ new WeakMap(), _Ad4mClient_agentClient = /* @__PURE__ */ new WeakMap(), _Ad4mClient_expressionClient = /* @__PURE__ */ new WeakMap(), _Ad4mClient_languageClient = /* @__PURE__ */ new WeakMap(), _Ad4mClient_neighbourhoodClient = /* @__PURE__ */ new WeakMap(), _Ad4mClient_perspectiveClient = /* @__PURE__ */ new WeakMap(), _Ad4mClient_runtimeClient = /* @__PURE__ */ new WeakMap(), _Ad4mClient_aiClient = /* @__PURE__ */ new WeakMap(), _Ad4mClient_identityClient = /* @__PURE__ */ new WeakMap();
13547
13967
  var ExceptionType;
13548
13968
  (function(ExceptionType2) {
13549
13969
  ExceptionType2["LanguageIsNotLoaded"] = "LANGUAGE_IS_NOT_LOADED";