@powerhousedao/connect 6.0.0-dev.84 → 6.0.0-dev.89

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.
@@ -37279,6 +37279,7 @@ import { isUndoRedo } from "document-model/core";
37279
37279
  import { deriveOperationId as deriveOperationId2 } from "document-model/core";
37280
37280
  import { ConsoleLogger } from "document-model/core";
37281
37281
  import { AbortError } from "document-drive/utils/errors";
37282
+ import { hashDocumentStateForScope } from "document-model/core";
37282
37283
  function createDocumentAction(input) {
37283
37284
  return {
37284
37285
  id: generateId(),
@@ -43833,6 +43834,11 @@ class CollectionMembershipCache {
43833
43834
  constructor(operationIndex) {
43834
43835
  this.operationIndex = operationIndex;
43835
43836
  }
43837
+ withScopedIndex(operationIndex) {
43838
+ const scoped = new CollectionMembershipCache(operationIndex);
43839
+ scoped.cache = this.cache;
43840
+ return scoped;
43841
+ }
43836
43842
  async getCollectionsForDocuments(documentIds) {
43837
43843
  const result = {};
43838
43844
  const missing = [];
@@ -44120,6 +44126,12 @@ class DocumentMetaCache {
44120
44126
  this.cache = new Map;
44121
44127
  this.lruTracker = new LRUTracker;
44122
44128
  }
44129
+ withScopedStore(operationStore) {
44130
+ const scoped = new DocumentMetaCache(operationStore, this.config);
44131
+ scoped.cache = this.cache;
44132
+ scoped.lruTracker = this.lruTracker;
44133
+ return scoped;
44134
+ }
44123
44135
  async startup() {
44124
44136
  return Promise.resolve();
44125
44137
  }
@@ -44269,9 +44281,18 @@ class KyselyOperationIndexTxn {
44269
44281
 
44270
44282
  class KyselyOperationIndex {
44271
44283
  db;
44284
+ trx;
44272
44285
  constructor(db) {
44273
44286
  this.db = db;
44274
44287
  }
44288
+ get queryExecutor() {
44289
+ return this.trx ?? this.db;
44290
+ }
44291
+ withTransaction(trx) {
44292
+ const instance2 = new KyselyOperationIndex(this.db);
44293
+ instance2.trx = trx;
44294
+ return instance2;
44295
+ }
44275
44296
  start() {
44276
44297
  return new KyselyOperationIndexTxn;
44277
44298
  }
@@ -44280,70 +44301,76 @@ class KyselyOperationIndex {
44280
44301
  throw new Error("Operation aborted");
44281
44302
  }
44282
44303
  const kyselyTxn = txn;
44304
+ if (this.trx) {
44305
+ return this.executeCommit(this.trx, kyselyTxn);
44306
+ }
44307
+ let resultOrdinals = [];
44308
+ await this.db.transaction().execute(async (trx) => {
44309
+ resultOrdinals = await this.executeCommit(trx, kyselyTxn);
44310
+ });
44311
+ return resultOrdinals;
44312
+ }
44313
+ async executeCommit(trx, kyselyTxn) {
44283
44314
  const collections = kyselyTxn.getCollections();
44284
44315
  const memberships = kyselyTxn.getCollectionMembershipRecords();
44285
44316
  const removals = kyselyTxn.getCollectionRemovals();
44286
44317
  const operations = kyselyTxn.getOperations();
44287
- let resultOrdinals = [];
44288
- await this.db.transaction().execute(async (trx) => {
44289
- if (collections.length > 0) {
44290
- const collectionRows = collections.map((collectionId) => ({
44291
- documentId: collectionId,
44292
- collectionId,
44293
- joinedOrdinal: BigInt(0),
44318
+ if (collections.length > 0) {
44319
+ const collectionRows = collections.map((collectionId) => ({
44320
+ documentId: collectionId,
44321
+ collectionId,
44322
+ joinedOrdinal: BigInt(0),
44323
+ leftOrdinal: null
44324
+ }));
44325
+ await trx.insertInto("document_collections").values(collectionRows).onConflict((oc) => oc.doNothing()).execute();
44326
+ }
44327
+ let operationOrdinals = [];
44328
+ if (operations.length > 0) {
44329
+ const operationRows = operations.map((op) => ({
44330
+ opId: op.id || "",
44331
+ documentId: op.documentId,
44332
+ documentType: op.documentType,
44333
+ scope: op.scope,
44334
+ branch: op.branch,
44335
+ timestampUtcMs: op.timestampUtcMs,
44336
+ index: op.index,
44337
+ skip: op.skip,
44338
+ hash: op.hash,
44339
+ action: op.action,
44340
+ sourceRemote: op.sourceRemote
44341
+ }));
44342
+ const insertedOps = await trx.insertInto("operation_index_operations").values(operationRows).returning("ordinal").execute();
44343
+ operationOrdinals = insertedOps.map((row) => row.ordinal);
44344
+ }
44345
+ if (memberships.length > 0) {
44346
+ for (const m2 of memberships) {
44347
+ const ordinal = operationOrdinals[m2.operationIndex];
44348
+ await trx.insertInto("document_collections").values({
44349
+ documentId: m2.documentId,
44350
+ collectionId: m2.collectionId,
44351
+ joinedOrdinal: BigInt(ordinal),
44294
44352
  leftOrdinal: null
44295
- }));
44296
- await trx.insertInto("document_collections").values(collectionRows).onConflict((oc) => oc.doNothing()).execute();
44297
- }
44298
- let operationOrdinals = [];
44299
- if (operations.length > 0) {
44300
- const operationRows = operations.map((op) => ({
44301
- opId: op.id || "",
44302
- documentId: op.documentId,
44303
- documentType: op.documentType,
44304
- scope: op.scope,
44305
- branch: op.branch,
44306
- timestampUtcMs: op.timestampUtcMs,
44307
- index: op.index,
44308
- skip: op.skip,
44309
- hash: op.hash,
44310
- action: op.action,
44311
- sourceRemote: op.sourceRemote
44312
- }));
44313
- const insertedOps = await trx.insertInto("operation_index_operations").values(operationRows).returning("ordinal").execute();
44314
- operationOrdinals = insertedOps.map((row) => row.ordinal);
44315
- resultOrdinals = operationOrdinals;
44316
- }
44317
- if (memberships.length > 0) {
44318
- for (const m2 of memberships) {
44319
- const ordinal = operationOrdinals[m2.operationIndex];
44320
- await trx.insertInto("document_collections").values({
44321
- documentId: m2.documentId,
44322
- collectionId: m2.collectionId,
44323
- joinedOrdinal: BigInt(ordinal),
44324
- leftOrdinal: null
44325
- }).onConflict((oc) => oc.columns(["documentId", "collectionId"]).doUpdateSet({
44326
- joinedOrdinal: BigInt(ordinal),
44327
- leftOrdinal: null
44328
- })).execute();
44329
- }
44353
+ }).onConflict((oc) => oc.columns(["documentId", "collectionId"]).doUpdateSet({
44354
+ joinedOrdinal: BigInt(ordinal),
44355
+ leftOrdinal: null
44356
+ })).execute();
44330
44357
  }
44331
- if (removals.length > 0) {
44332
- for (const r4 of removals) {
44333
- const ordinal = operationOrdinals[r4.operationIndex];
44334
- await trx.updateTable("document_collections").set({
44335
- leftOrdinal: BigInt(ordinal)
44336
- }).where("collectionId", "=", r4.collectionId).where("documentId", "=", r4.documentId).where("leftOrdinal", "is", null).execute();
44337
- }
44358
+ }
44359
+ if (removals.length > 0) {
44360
+ for (const r4 of removals) {
44361
+ const ordinal = operationOrdinals[r4.operationIndex];
44362
+ await trx.updateTable("document_collections").set({
44363
+ leftOrdinal: BigInt(ordinal)
44364
+ }).where("collectionId", "=", r4.collectionId).where("documentId", "=", r4.documentId).where("leftOrdinal", "is", null).execute();
44338
44365
  }
44339
- });
44340
- return resultOrdinals;
44366
+ }
44367
+ return operationOrdinals;
44341
44368
  }
44342
44369
  async find(collectionId, cursor, view, paging, signal) {
44343
44370
  if (signal?.aborted) {
44344
44371
  throw new Error("Operation aborted");
44345
44372
  }
44346
- let query = this.db.selectFrom("operation_index_operations as oi").innerJoin("document_collections as dc", "oi.documentId", "dc.documentId").selectAll("oi").select(["dc.documentId", "dc.collectionId"]).where("dc.collectionId", "=", collectionId).where(sql`(dc."leftOrdinal" IS NULL OR oi.ordinal < dc."leftOrdinal")`).orderBy("oi.ordinal", "asc");
44373
+ let query = this.queryExecutor.selectFrom("operation_index_operations as oi").innerJoin("document_collections as dc", "oi.documentId", "dc.documentId").selectAll("oi").select(["dc.documentId", "dc.collectionId"]).where("dc.collectionId", "=", collectionId).where(sql`(dc."leftOrdinal" IS NULL OR oi.ordinal < dc."leftOrdinal")`).orderBy("oi.ordinal", "asc");
44347
44374
  if (cursor !== undefined) {
44348
44375
  query = query.where("oi.ordinal", ">", cursor);
44349
44376
  }
@@ -44385,7 +44412,7 @@ class KyselyOperationIndex {
44385
44412
  if (signal?.aborted) {
44386
44413
  throw new Error("Operation aborted");
44387
44414
  }
44388
- let query = this.db.selectFrom("operation_index_operations").selectAll().where("documentId", "=", documentId).orderBy("ordinal", "asc");
44415
+ let query = this.queryExecutor.selectFrom("operation_index_operations").selectAll().where("documentId", "=", documentId).orderBy("ordinal", "asc");
44389
44416
  if (view?.branch) {
44390
44417
  query = query.where("branch", "=", view.branch);
44391
44418
  }
@@ -44421,7 +44448,7 @@ class KyselyOperationIndex {
44421
44448
  if (signal?.aborted) {
44422
44449
  throw new Error("Operation aborted");
44423
44450
  }
44424
- let query = this.db.selectFrom("operation_index_operations").selectAll().where("ordinal", ">", ordinal).orderBy("ordinal", "asc");
44451
+ let query = this.queryExecutor.selectFrom("operation_index_operations").selectAll().where("ordinal", ">", ordinal).orderBy("ordinal", "asc");
44425
44452
  if (paging?.cursor) {
44426
44453
  const cursorOrdinal = Number.parseInt(paging.cursor, 10);
44427
44454
  query = query.where("ordinal", ">", cursorOrdinal);
@@ -44486,14 +44513,14 @@ class KyselyOperationIndex {
44486
44513
  if (signal?.aborted) {
44487
44514
  throw new Error("Operation aborted");
44488
44515
  }
44489
- const result = await this.db.selectFrom("operation_index_operations as oi").innerJoin("document_collections as dc", "oi.documentId", "dc.documentId").select("oi.timestampUtcMs").where("dc.collectionId", "=", collectionId).where(sql`(dc."leftOrdinal" IS NULL OR oi.ordinal < dc."leftOrdinal")`).orderBy("oi.ordinal", "desc").limit(1).executeTakeFirst();
44516
+ const result = await this.queryExecutor.selectFrom("operation_index_operations as oi").innerJoin("document_collections as dc", "oi.documentId", "dc.documentId").select("oi.timestampUtcMs").where("dc.collectionId", "=", collectionId).where(sql`(dc."leftOrdinal" IS NULL OR oi.ordinal < dc."leftOrdinal")`).orderBy("oi.ordinal", "desc").limit(1).executeTakeFirst();
44490
44517
  return result?.timestampUtcMs ?? null;
44491
44518
  }
44492
44519
  async getCollectionsForDocuments(documentIds) {
44493
44520
  if (documentIds.length === 0) {
44494
44521
  return {};
44495
44522
  }
44496
- const rows = await this.db.selectFrom("document_collections").select(["documentId", "collectionId"]).where("documentId", "in", documentIds).where("leftOrdinal", "is", null).execute();
44523
+ const rows = await this.queryExecutor.selectFrom("document_collections").select(["documentId", "collectionId"]).where("documentId", "in", documentIds).where("leftOrdinal", "is", null).execute();
44497
44524
  const result = {};
44498
44525
  for (const row of rows) {
44499
44526
  if (!(row.documentId in result)) {
@@ -44547,6 +44574,10 @@ class RingBuffer {
44547
44574
  return this.size;
44548
44575
  }
44549
44576
  }
44577
+ function extractModuleVersion(doc) {
44578
+ const v2 = doc.state.document.version;
44579
+ return v2 === 0 ? undefined : v2;
44580
+ }
44550
44581
 
44551
44582
  class KyselyWriteCache {
44552
44583
  streams;
@@ -44567,6 +44598,12 @@ class KyselyWriteCache {
44567
44598
  this.streams = new Map;
44568
44599
  this.lruTracker = new LRUTracker;
44569
44600
  }
44601
+ withScopedStores(operationStore, keyframeStore) {
44602
+ const scoped = new KyselyWriteCache(keyframeStore, operationStore, this.registry, this.config);
44603
+ scoped.streams = this.streams;
44604
+ scoped.lruTracker = this.lruTracker;
44605
+ return scoped;
44606
+ }
44570
44607
  async startup() {
44571
44608
  return Promise.resolve();
44572
44609
  }
@@ -44705,7 +44742,7 @@ class KyselyWriteCache {
44705
44742
  throw new Error(`Failed to rebuild document ${documentId}: CREATE_DOCUMENT action missing model in input`);
44706
44743
  }
44707
44744
  document2 = createDocumentFromAction(documentCreateAction);
44708
- const docModule = this.registry.getModule(documentType);
44745
+ let docModule = this.registry.getModule(documentType, extractModuleVersion(document2));
44709
44746
  const docScopeOps = await this.operationStore.getSince(documentId, "document", branch, 0, undefined, undefined, signal);
44710
44747
  for (const operation of docScopeOps.results) {
44711
44748
  if (operation.index === 0) {
@@ -44714,6 +44751,7 @@ class KyselyWriteCache {
44714
44751
  if (operation.action.type === "UPGRADE_DOCUMENT") {
44715
44752
  const upgradeAction = operation.action;
44716
44753
  document2 = applyUpgradeDocumentAction(document2, upgradeAction);
44754
+ docModule = this.registry.getModule(documentType, extractModuleVersion(document2));
44717
44755
  } else if (operation.action.type === "DELETE_DOCUMENT") {
44718
44756
  applyDeleteDocumentAction(document2, operation.action);
44719
44757
  } else {
@@ -44725,7 +44763,7 @@ class KyselyWriteCache {
44725
44763
  }
44726
44764
  }
44727
44765
  }
44728
- const module = this.registry.getModule(documentType);
44766
+ const module = this.registry.getModule(documentType, extractModuleVersion(document2));
44729
44767
  let cursor = undefined;
44730
44768
  const pageSize = 100;
44731
44769
  let hasMorePages;
@@ -44875,6 +44913,63 @@ class EventBus {
44875
44913
  }
44876
44914
  }
44877
44915
 
44916
+ class DefaultExecutionScope {
44917
+ operationStore;
44918
+ operationIndex;
44919
+ writeCache;
44920
+ documentMetaCache;
44921
+ collectionMembershipCache;
44922
+ constructor(operationStore, operationIndex, writeCache, documentMetaCache, collectionMembershipCache) {
44923
+ this.operationStore = operationStore;
44924
+ this.operationIndex = operationIndex;
44925
+ this.writeCache = writeCache;
44926
+ this.documentMetaCache = documentMetaCache;
44927
+ this.collectionMembershipCache = collectionMembershipCache;
44928
+ }
44929
+ async run(fn) {
44930
+ return fn({
44931
+ operationStore: this.operationStore,
44932
+ operationIndex: this.operationIndex,
44933
+ writeCache: this.writeCache,
44934
+ documentMetaCache: this.documentMetaCache,
44935
+ collectionMembershipCache: this.collectionMembershipCache
44936
+ });
44937
+ }
44938
+ }
44939
+
44940
+ class KyselyExecutionScope {
44941
+ db;
44942
+ operationStore;
44943
+ operationIndex;
44944
+ keyframeStore;
44945
+ writeCache;
44946
+ documentMetaCache;
44947
+ collectionMembershipCache;
44948
+ constructor(db, operationStore, operationIndex, keyframeStore, writeCache, documentMetaCache, collectionMembershipCache) {
44949
+ this.db = db;
44950
+ this.operationStore = operationStore;
44951
+ this.operationIndex = operationIndex;
44952
+ this.keyframeStore = keyframeStore;
44953
+ this.writeCache = writeCache;
44954
+ this.documentMetaCache = documentMetaCache;
44955
+ this.collectionMembershipCache = collectionMembershipCache;
44956
+ }
44957
+ async run(fn) {
44958
+ return this.db.transaction().execute(async (trx) => {
44959
+ const scopedOperationStore = this.operationStore.withTransaction(trx);
44960
+ const scopedOperationIndex = this.operationIndex.withTransaction(trx);
44961
+ const scopedKeyframeStore = this.keyframeStore.withTransaction(trx);
44962
+ return fn({
44963
+ operationStore: scopedOperationStore,
44964
+ operationIndex: scopedOperationIndex,
44965
+ writeCache: this.writeCache.withScopedStores(scopedOperationStore, scopedKeyframeStore),
44966
+ documentMetaCache: this.documentMetaCache.withScopedStore(scopedOperationStore),
44967
+ collectionMembershipCache: this.collectionMembershipCache.withScopedIndex(scopedOperationIndex)
44968
+ });
44969
+ });
44970
+ }
44971
+ }
44972
+
44878
44973
  class DocumentModelRegistry {
44879
44974
  modules = [];
44880
44975
  manifests = [];
@@ -45334,37 +45429,29 @@ function driveCollectionId(branch, driveId) {
45334
45429
  }
45335
45430
 
45336
45431
  class DocumentActionHandler {
45337
- writeCache;
45338
- operationStore;
45339
- documentMetaCache;
45340
- collectionMembershipCache;
45341
45432
  registry;
45342
45433
  logger;
45343
- constructor(writeCache, operationStore, documentMetaCache, collectionMembershipCache, registry, logger4) {
45344
- this.writeCache = writeCache;
45345
- this.operationStore = operationStore;
45346
- this.documentMetaCache = documentMetaCache;
45347
- this.collectionMembershipCache = collectionMembershipCache;
45434
+ constructor(registry, logger4) {
45348
45435
  this.registry = registry;
45349
45436
  this.logger = logger4;
45350
45437
  }
45351
- async execute(job, action, startTime, indexTxn, skip = 0, sourceRemote = "") {
45438
+ async execute(job, action, startTime, indexTxn, stores, skip = 0, sourceRemote = "") {
45352
45439
  switch (action.type) {
45353
45440
  case "CREATE_DOCUMENT":
45354
- return this.executeCreate(job, action, startTime, indexTxn, skip, sourceRemote);
45441
+ return this.executeCreate(job, action, startTime, indexTxn, stores, skip, sourceRemote);
45355
45442
  case "DELETE_DOCUMENT":
45356
- return this.executeDelete(job, action, startTime, indexTxn, sourceRemote);
45443
+ return this.executeDelete(job, action, startTime, indexTxn, stores, sourceRemote);
45357
45444
  case "UPGRADE_DOCUMENT":
45358
- return this.executeUpgrade(job, action, startTime, indexTxn, skip, sourceRemote);
45445
+ return this.executeUpgrade(job, action, startTime, indexTxn, stores, skip, sourceRemote);
45359
45446
  case "ADD_RELATIONSHIP":
45360
- return this.executeAddRelationship(job, action, startTime, indexTxn, sourceRemote);
45447
+ return this.executeAddRelationship(job, action, startTime, indexTxn, stores, sourceRemote);
45361
45448
  case "REMOVE_RELATIONSHIP":
45362
- return this.executeRemoveRelationship(job, action, startTime, indexTxn, sourceRemote);
45449
+ return this.executeRemoveRelationship(job, action, startTime, indexTxn, stores, sourceRemote);
45363
45450
  default:
45364
45451
  return buildErrorResult(job, new Error(`Unknown document action type: ${action.type}`), startTime);
45365
45452
  }
45366
45453
  }
45367
- async executeCreate(job, action, startTime, indexTxn, skip = 0, sourceRemote = "") {
45454
+ async executeCreate(job, action, startTime, indexTxn, stores, skip = 0, sourceRemote = "") {
45368
45455
  if (job.scope !== "document") {
45369
45456
  return {
45370
45457
  job,
@@ -45384,12 +45471,12 @@ class DocumentActionHandler {
45384
45471
  ...document2.state
45385
45472
  };
45386
45473
  const resultingState = JSON.stringify(resultingStateObj);
45387
- const writeError = await this.writeOperationToStore(document2.header.id, document2.header.documentType, job.scope, job.branch, operation, job, startTime);
45474
+ const writeError = await this.writeOperationToStore(document2.header.id, document2.header.documentType, job.scope, job.branch, operation, job, startTime, stores);
45388
45475
  if (writeError !== null) {
45389
45476
  return writeError;
45390
45477
  }
45391
45478
  updateDocumentRevision(document2, job.scope, operation.index);
45392
- this.writeCache.putState(document2.header.id, job.scope, job.branch, operation.index, document2);
45479
+ stores.writeCache.putState(document2.header.id, job.scope, job.branch, operation.index, document2);
45393
45480
  indexTxn.write([
45394
45481
  {
45395
45482
  ...operation,
@@ -45405,14 +45492,14 @@ class DocumentActionHandler {
45405
45492
  indexTxn.createCollection(collectionId);
45406
45493
  indexTxn.addToCollection(collectionId, document2.header.id);
45407
45494
  }
45408
- this.documentMetaCache.putDocumentMeta(document2.header.id, job.branch, {
45495
+ stores.documentMetaCache.putDocumentMeta(document2.header.id, job.branch, {
45409
45496
  state: document2.state.document,
45410
45497
  documentType: document2.header.documentType,
45411
45498
  documentScopeRevision: 1
45412
45499
  });
45413
45500
  return buildSuccessResult(job, operation, document2.header.id, document2.header.documentType, resultingState, startTime);
45414
45501
  }
45415
- async executeDelete(job, action, startTime, indexTxn, sourceRemote = "") {
45502
+ async executeDelete(job, action, startTime, indexTxn, stores, sourceRemote = "") {
45416
45503
  const input = action.input;
45417
45504
  if (!input.documentId) {
45418
45505
  return buildErrorResult(job, new Error("DELETE_DOCUMENT action requires a documentId in input"), startTime);
@@ -45420,7 +45507,7 @@ class DocumentActionHandler {
45420
45507
  const documentId = input.documentId;
45421
45508
  let document2;
45422
45509
  try {
45423
- document2 = await this.writeCache.getState(documentId, job.scope, job.branch);
45510
+ document2 = await stores.writeCache.getState(documentId, job.scope, job.branch);
45424
45511
  } catch (error3) {
45425
45512
  return buildErrorResult(job, new Error(`Failed to fetch document before deletion: ${error3 instanceof Error ? error3.message : String(error3)}`), startTime);
45426
45513
  }
@@ -45440,12 +45527,12 @@ class DocumentActionHandler {
45440
45527
  document: document2.state.document
45441
45528
  };
45442
45529
  const resultingState = JSON.stringify(resultingStateObj);
45443
- const writeError = await this.writeOperationToStore(documentId, document2.header.documentType, job.scope, job.branch, operation, job, startTime);
45530
+ const writeError = await this.writeOperationToStore(documentId, document2.header.documentType, job.scope, job.branch, operation, job, startTime, stores);
45444
45531
  if (writeError !== null) {
45445
45532
  return writeError;
45446
45533
  }
45447
45534
  updateDocumentRevision(document2, job.scope, operation.index);
45448
- this.writeCache.putState(documentId, job.scope, job.branch, operation.index, document2);
45535
+ stores.writeCache.putState(documentId, job.scope, job.branch, operation.index, document2);
45449
45536
  indexTxn.write([
45450
45537
  {
45451
45538
  ...operation,
@@ -45456,14 +45543,14 @@ class DocumentActionHandler {
45456
45543
  sourceRemote
45457
45544
  }
45458
45545
  ]);
45459
- this.documentMetaCache.putDocumentMeta(documentId, job.branch, {
45546
+ stores.documentMetaCache.putDocumentMeta(documentId, job.branch, {
45460
45547
  state: document2.state.document,
45461
45548
  documentType: document2.header.documentType,
45462
45549
  documentScopeRevision: operation.index + 1
45463
45550
  });
45464
45551
  return buildSuccessResult(job, operation, documentId, document2.header.documentType, resultingState, startTime);
45465
45552
  }
45466
- async executeUpgrade(job, action, startTime, indexTxn, skip = 0, sourceRemote = "") {
45553
+ async executeUpgrade(job, action, startTime, indexTxn, stores, skip = 0, sourceRemote = "") {
45467
45554
  const input = action.input;
45468
45555
  if (!input.documentId) {
45469
45556
  return buildErrorResult(job, new Error("UPGRADE_DOCUMENT action requires a documentId in input"), startTime);
@@ -45473,7 +45560,7 @@ class DocumentActionHandler {
45473
45560
  const toVersion = input.toVersion;
45474
45561
  let document2;
45475
45562
  try {
45476
- document2 = await this.writeCache.getState(documentId, job.scope, job.branch);
45563
+ document2 = await stores.writeCache.getState(documentId, job.scope, job.branch);
45477
45564
  } catch (error3) {
45478
45565
  return buildErrorResult(job, new Error(`Failed to fetch document for upgrade: ${error3 instanceof Error ? error3.message : String(error3)}`), startTime);
45479
45566
  }
@@ -45514,12 +45601,12 @@ class DocumentActionHandler {
45514
45601
  ...document2.state
45515
45602
  };
45516
45603
  const resultingState = JSON.stringify(resultingStateObj);
45517
- const writeError = await this.writeOperationToStore(documentId, document2.header.documentType, job.scope, job.branch, operation, job, startTime);
45604
+ const writeError = await this.writeOperationToStore(documentId, document2.header.documentType, job.scope, job.branch, operation, job, startTime, stores);
45518
45605
  if (writeError !== null) {
45519
45606
  return writeError;
45520
45607
  }
45521
45608
  updateDocumentRevision(document2, job.scope, operation.index);
45522
- this.writeCache.putState(documentId, job.scope, job.branch, operation.index, document2);
45609
+ stores.writeCache.putState(documentId, job.scope, job.branch, operation.index, document2);
45523
45610
  indexTxn.write([
45524
45611
  {
45525
45612
  ...operation,
@@ -45530,14 +45617,14 @@ class DocumentActionHandler {
45530
45617
  sourceRemote
45531
45618
  }
45532
45619
  ]);
45533
- this.documentMetaCache.putDocumentMeta(documentId, job.branch, {
45620
+ stores.documentMetaCache.putDocumentMeta(documentId, job.branch, {
45534
45621
  state: document2.state.document,
45535
45622
  documentType: document2.header.documentType,
45536
45623
  documentScopeRevision: operation.index + 1
45537
45624
  });
45538
45625
  return buildSuccessResult(job, operation, documentId, document2.header.documentType, resultingState, startTime);
45539
45626
  }
45540
- async executeAddRelationship(job, action, startTime, indexTxn, sourceRemote = "") {
45627
+ async executeAddRelationship(job, action, startTime, indexTxn, stores, sourceRemote = "") {
45541
45628
  if (job.scope !== "document") {
45542
45629
  return buildErrorResult(job, new Error(`ADD_RELATIONSHIP must be in "document" scope, got "${job.scope}"`), startTime);
45543
45630
  }
@@ -45550,7 +45637,7 @@ class DocumentActionHandler {
45550
45637
  }
45551
45638
  let sourceDoc;
45552
45639
  try {
45553
- sourceDoc = await this.writeCache.getState(input.sourceId, "document", job.branch);
45640
+ sourceDoc = await stores.writeCache.getState(input.sourceId, "document", job.branch);
45554
45641
  } catch (error3) {
45555
45642
  return buildErrorResult(job, new Error(`ADD_RELATIONSHIP: source document ${input.sourceId} not found: ${error3 instanceof Error ? error3.message : String(error3)}`), startTime);
45556
45643
  }
@@ -45560,7 +45647,7 @@ class DocumentActionHandler {
45560
45647
  scope: job.scope,
45561
45648
  branch: job.branch
45562
45649
  });
45563
- const writeError = await this.writeOperationToStore(input.sourceId, sourceDoc.header.documentType, job.scope, job.branch, operation, job, startTime);
45650
+ const writeError = await this.writeOperationToStore(input.sourceId, sourceDoc.header.documentType, job.scope, job.branch, operation, job, startTime, stores);
45564
45651
  if (writeError !== null) {
45565
45652
  return writeError;
45566
45653
  }
@@ -45576,7 +45663,7 @@ class DocumentActionHandler {
45576
45663
  [job.scope]: scopeState === undefined ? {} : structuredClone(scopeState)
45577
45664
  };
45578
45665
  const resultingState = JSON.stringify(resultingStateObj);
45579
- this.writeCache.putState(input.sourceId, job.scope, job.branch, operation.index, sourceDoc);
45666
+ stores.writeCache.putState(input.sourceId, job.scope, job.branch, operation.index, sourceDoc);
45580
45667
  indexTxn.write([
45581
45668
  {
45582
45669
  ...operation,
@@ -45590,16 +45677,16 @@ class DocumentActionHandler {
45590
45677
  if (sourceDoc.header.documentType === "powerhouse/document-drive") {
45591
45678
  const collectionId = driveCollectionId(job.branch, input.sourceId);
45592
45679
  indexTxn.addToCollection(collectionId, input.targetId);
45593
- this.collectionMembershipCache.invalidate(input.targetId);
45680
+ stores.collectionMembershipCache.invalidate(input.targetId);
45594
45681
  }
45595
- this.documentMetaCache.putDocumentMeta(input.sourceId, job.branch, {
45682
+ stores.documentMetaCache.putDocumentMeta(input.sourceId, job.branch, {
45596
45683
  state: sourceDoc.state.document,
45597
45684
  documentType: sourceDoc.header.documentType,
45598
45685
  documentScopeRevision: operation.index + 1
45599
45686
  });
45600
45687
  return buildSuccessResult(job, operation, input.sourceId, sourceDoc.header.documentType, resultingState, startTime);
45601
45688
  }
45602
- async executeRemoveRelationship(job, action, startTime, indexTxn, sourceRemote = "") {
45689
+ async executeRemoveRelationship(job, action, startTime, indexTxn, stores, sourceRemote = "") {
45603
45690
  if (job.scope !== "document") {
45604
45691
  return buildErrorResult(job, new Error(`REMOVE_RELATIONSHIP must be in "document" scope, got "${job.scope}"`), startTime);
45605
45692
  }
@@ -45609,7 +45696,7 @@ class DocumentActionHandler {
45609
45696
  }
45610
45697
  let sourceDoc;
45611
45698
  try {
45612
- sourceDoc = await this.writeCache.getState(input.sourceId, "document", job.branch);
45699
+ sourceDoc = await stores.writeCache.getState(input.sourceId, "document", job.branch);
45613
45700
  } catch (error3) {
45614
45701
  return buildErrorResult(job, new Error(`REMOVE_RELATIONSHIP: source document ${input.sourceId} not found: ${error3 instanceof Error ? error3.message : String(error3)}`), startTime);
45615
45702
  }
@@ -45619,7 +45706,7 @@ class DocumentActionHandler {
45619
45706
  scope: job.scope,
45620
45707
  branch: job.branch
45621
45708
  });
45622
- const writeError = await this.writeOperationToStore(input.sourceId, sourceDoc.header.documentType, job.scope, job.branch, operation, job, startTime);
45709
+ const writeError = await this.writeOperationToStore(input.sourceId, sourceDoc.header.documentType, job.scope, job.branch, operation, job, startTime, stores);
45623
45710
  if (writeError !== null) {
45624
45711
  return writeError;
45625
45712
  }
@@ -45635,7 +45722,7 @@ class DocumentActionHandler {
45635
45722
  [job.scope]: scopeState === undefined ? {} : structuredClone(scopeState)
45636
45723
  };
45637
45724
  const resultingState = JSON.stringify(resultingStateObj);
45638
- this.writeCache.putState(input.sourceId, job.scope, job.branch, operation.index, sourceDoc);
45725
+ stores.writeCache.putState(input.sourceId, job.scope, job.branch, operation.index, sourceDoc);
45639
45726
  indexTxn.write([
45640
45727
  {
45641
45728
  ...operation,
@@ -45649,24 +45736,24 @@ class DocumentActionHandler {
45649
45736
  if (sourceDoc.header.documentType === "powerhouse/document-drive") {
45650
45737
  const collectionId = driveCollectionId(job.branch, input.sourceId);
45651
45738
  indexTxn.removeFromCollection(collectionId, input.targetId);
45652
- this.collectionMembershipCache.invalidate(input.targetId);
45739
+ stores.collectionMembershipCache.invalidate(input.targetId);
45653
45740
  }
45654
- this.documentMetaCache.putDocumentMeta(input.sourceId, job.branch, {
45741
+ stores.documentMetaCache.putDocumentMeta(input.sourceId, job.branch, {
45655
45742
  state: sourceDoc.state.document,
45656
45743
  documentType: sourceDoc.header.documentType,
45657
45744
  documentScopeRevision: operation.index + 1
45658
45745
  });
45659
45746
  return buildSuccessResult(job, operation, input.sourceId, sourceDoc.header.documentType, resultingState, startTime);
45660
45747
  }
45661
- async writeOperationToStore(documentId, documentType, scope, branch, operation, job, startTime) {
45748
+ async writeOperationToStore(documentId, documentType, scope, branch, operation, job, startTime, stores) {
45662
45749
  try {
45663
- await this.operationStore.apply(documentId, documentType, scope, branch, operation.index, (txn) => {
45750
+ await stores.operationStore.apply(documentId, documentType, scope, branch, operation.index, (txn) => {
45664
45751
  txn.addOperations(operation);
45665
45752
  });
45666
45753
  return null;
45667
45754
  } catch (error3) {
45668
45755
  this.logger.error("Error writing @Operation to IOperationStore: @Error", operation, error3);
45669
- this.writeCache.invalidate(documentId, scope, branch);
45756
+ stores.writeCache.invalidate(documentId, scope, branch);
45670
45757
  return {
45671
45758
  job,
45672
45759
  success: false,
@@ -45755,7 +45842,8 @@ class SimpleJobExecutor {
45755
45842
  config;
45756
45843
  signatureVerifierModule;
45757
45844
  documentActionHandler;
45758
- constructor(logger4, registry, operationStore, eventBus, writeCache, operationIndex, documentMetaCache, collectionMembershipCache, config, signatureVerifier) {
45845
+ executionScope;
45846
+ constructor(logger4, registry, operationStore, eventBus, writeCache, operationIndex, documentMetaCache, collectionMembershipCache, config, signatureVerifier, executionScope) {
45759
45847
  this.logger = logger4;
45760
45848
  this.registry = registry;
45761
45849
  this.operationStore = operationStore;
@@ -45772,71 +45860,101 @@ class SimpleJobExecutor {
45772
45860
  retryMaxDelayMs: config.retryMaxDelayMs ?? 5000
45773
45861
  };
45774
45862
  this.signatureVerifierModule = new SignatureVerifier(signatureVerifier);
45775
- this.documentActionHandler = new DocumentActionHandler(writeCache, operationStore, documentMetaCache, collectionMembershipCache, registry, logger4);
45863
+ this.documentActionHandler = new DocumentActionHandler(registry, logger4);
45864
+ this.executionScope = executionScope ?? new DefaultExecutionScope(operationStore, operationIndex, writeCache, documentMetaCache, collectionMembershipCache);
45776
45865
  }
45777
45866
  async executeJob(job) {
45778
45867
  const startTime = Date.now();
45779
- const indexTxn = this.operationIndex.start();
45780
- if (job.kind === "load") {
45781
- const result2 = await this.executeLoadJob(job, startTime, indexTxn);
45782
- if (result2.success && result2.operationsWithContext) {
45783
- const ordinals2 = await this.operationIndex.commit(indexTxn);
45784
- for (let i3 = 0;i3 < result2.operationsWithContext.length; i3++) {
45785
- result2.operationsWithContext[i3].context.ordinal = ordinals2[i3];
45786
- }
45787
- const collectionMemberships = result2.operationsWithContext.length > 0 ? await this.getCollectionMembershipsForOperations(result2.operationsWithContext) : {};
45788
- const event = {
45789
- jobId: job.id,
45790
- operations: result2.operationsWithContext,
45791
- jobMeta: job.meta,
45792
- collectionMemberships
45868
+ const touchedCacheEntries = [];
45869
+ let pendingEvent;
45870
+ let result;
45871
+ try {
45872
+ result = await this.executionScope.run(async (stores) => {
45873
+ const indexTxn = stores.operationIndex.start();
45874
+ if (job.kind === "load") {
45875
+ const loadResult = await this.executeLoadJob(job, startTime, indexTxn, stores);
45876
+ if (loadResult.success && loadResult.operationsWithContext) {
45877
+ for (const owc of loadResult.operationsWithContext) {
45878
+ touchedCacheEntries.push({
45879
+ documentId: owc.context.documentId,
45880
+ scope: owc.context.scope,
45881
+ branch: owc.context.branch
45882
+ });
45883
+ }
45884
+ const ordinals2 = await stores.operationIndex.commit(indexTxn);
45885
+ for (let i3 = 0;i3 < loadResult.operationsWithContext.length; i3++) {
45886
+ loadResult.operationsWithContext[i3].context.ordinal = ordinals2[i3];
45887
+ }
45888
+ const collectionMemberships = loadResult.operationsWithContext.length > 0 ? await this.getCollectionMembershipsForOperations(loadResult.operationsWithContext, stores) : {};
45889
+ pendingEvent = {
45890
+ jobId: job.id,
45891
+ operations: loadResult.operationsWithContext,
45892
+ jobMeta: job.meta,
45893
+ collectionMemberships
45894
+ };
45895
+ }
45896
+ return loadResult;
45897
+ }
45898
+ const actionResult = await this.processActions(job, job.actions, startTime, indexTxn, stores);
45899
+ if (!actionResult.success) {
45900
+ return {
45901
+ job,
45902
+ success: false,
45903
+ error: actionResult.error,
45904
+ duration: Date.now() - startTime
45905
+ };
45906
+ }
45907
+ if (actionResult.operationsWithContext.length > 0) {
45908
+ for (const owc of actionResult.operationsWithContext) {
45909
+ touchedCacheEntries.push({
45910
+ documentId: owc.context.documentId,
45911
+ scope: owc.context.scope,
45912
+ branch: owc.context.branch
45913
+ });
45914
+ }
45915
+ }
45916
+ const ordinals = await stores.operationIndex.commit(indexTxn);
45917
+ if (actionResult.operationsWithContext.length > 0) {
45918
+ for (let i3 = 0;i3 < actionResult.operationsWithContext.length; i3++) {
45919
+ actionResult.operationsWithContext[i3].context.ordinal = ordinals[i3];
45920
+ }
45921
+ const collectionMemberships = await this.getCollectionMembershipsForOperations(actionResult.operationsWithContext, stores);
45922
+ pendingEvent = {
45923
+ jobId: job.id,
45924
+ operations: actionResult.operationsWithContext,
45925
+ jobMeta: job.meta,
45926
+ collectionMemberships
45927
+ };
45928
+ }
45929
+ return {
45930
+ job,
45931
+ success: true,
45932
+ operations: actionResult.generatedOperations,
45933
+ operationsWithContext: actionResult.operationsWithContext,
45934
+ duration: Date.now() - startTime
45793
45935
  };
45794
- this.eventBus.emit(ReactorEventTypes.JOB_WRITE_READY, event).catch((error3) => {
45795
- this.logger.error("Failed to emit JOB_WRITE_READY event: @Event : @Error", event, error3);
45796
- });
45936
+ });
45937
+ } catch (error3) {
45938
+ for (const entry of touchedCacheEntries) {
45939
+ this.writeCache.invalidate(entry.documentId, entry.scope, entry.branch);
45940
+ this.documentMetaCache.invalidate(entry.documentId, entry.branch);
45797
45941
  }
45798
- return result2;
45799
- }
45800
- const result = await this.processActions(job, job.actions, startTime, indexTxn);
45801
- if (!result.success) {
45802
- return {
45803
- job,
45804
- success: false,
45805
- error: result.error,
45806
- duration: Date.now() - startTime
45807
- };
45942
+ throw error3;
45808
45943
  }
45809
- const ordinals = await this.operationIndex.commit(indexTxn);
45810
- if (result.operationsWithContext.length > 0) {
45811
- for (let i3 = 0;i3 < result.operationsWithContext.length; i3++) {
45812
- result.operationsWithContext[i3].context.ordinal = ordinals[i3];
45813
- }
45814
- const collectionMemberships = await this.getCollectionMembershipsForOperations(result.operationsWithContext);
45815
- const event = {
45816
- jobId: job.id,
45817
- operations: result.operationsWithContext,
45818
- jobMeta: job.meta,
45819
- collectionMemberships
45820
- };
45821
- this.eventBus.emit(ReactorEventTypes.JOB_WRITE_READY, event).catch((error3) => {
45822
- this.logger.error("Failed to emit JOB_WRITE_READY event: @Event : @Error", event, error3);
45944
+ if (pendingEvent) {
45945
+ this.eventBus.emit(ReactorEventTypes.JOB_WRITE_READY, pendingEvent).catch((error3) => {
45946
+ this.logger.error("Failed to emit JOB_WRITE_READY event: @Event : @Error", pendingEvent, error3);
45823
45947
  });
45824
45948
  }
45825
- return {
45826
- job,
45827
- success: true,
45828
- operations: result.generatedOperations,
45829
- operationsWithContext: result.operationsWithContext,
45830
- duration: Date.now() - startTime
45831
- };
45949
+ return result;
45832
45950
  }
45833
- async getCollectionMembershipsForOperations(operations) {
45951
+ async getCollectionMembershipsForOperations(operations, stores) {
45834
45952
  const documentIds = [
45835
45953
  ...new Set(operations.map((op) => op.context.documentId))
45836
45954
  ];
45837
- return this.collectionMembershipCache.getCollectionsForDocuments(documentIds);
45955
+ return stores.collectionMembershipCache.getCollectionsForDocuments(documentIds);
45838
45956
  }
45839
- async processActions(job, actions2, startTime, indexTxn, skipValues, sourceOperations, sourceRemote = "") {
45957
+ async processActions(job, actions2, startTime, indexTxn, stores, skipValues, sourceOperations, sourceRemote = "") {
45840
45958
  const generatedOperations = [];
45841
45959
  const operationsWithContext = [];
45842
45960
  try {
@@ -45854,7 +45972,7 @@ class SimpleJobExecutor {
45854
45972
  const skip = skipValues?.[actionIndex] ?? 0;
45855
45973
  const sourceOperation = sourceOperations?.[actionIndex];
45856
45974
  const isDocumentAction = documentScopeActions.includes(action.type);
45857
- const result = isDocumentAction ? await this.documentActionHandler.execute(job, action, startTime, indexTxn, skip, sourceRemote) : await this.executeRegularAction(job, action, startTime, indexTxn, skip, sourceOperation, sourceRemote);
45975
+ const result = isDocumentAction ? await this.documentActionHandler.execute(job, action, startTime, indexTxn, stores, skip, sourceRemote) : await this.executeRegularAction(job, action, startTime, indexTxn, stores, skip, sourceOperation, sourceRemote);
45858
45976
  const error3 = this.accumulateResultOrReturnError(result, generatedOperations, operationsWithContext);
45859
45977
  if (error3 !== null) {
45860
45978
  return {
@@ -45871,10 +45989,10 @@ class SimpleJobExecutor {
45871
45989
  operationsWithContext
45872
45990
  };
45873
45991
  }
45874
- async executeRegularAction(job, action, startTime, indexTxn, skip = 0, sourceOperation, sourceRemote = "") {
45992
+ async executeRegularAction(job, action, startTime, indexTxn, stores, skip = 0, sourceOperation, sourceRemote = "") {
45875
45993
  let docMeta;
45876
45994
  try {
45877
- docMeta = await this.documentMetaCache.getDocumentMeta(job.documentId, job.branch);
45995
+ docMeta = await stores.documentMetaCache.getDocumentMeta(job.documentId, job.branch);
45878
45996
  } catch (error3) {
45879
45997
  return buildErrorResult(job, error3 instanceof Error ? error3 : new Error(String(error3)), startTime);
45880
45998
  }
@@ -45882,11 +46000,11 @@ class SimpleJobExecutor {
45882
46000
  return buildErrorResult(job, new DocumentDeletedError(job.documentId, docMeta.state.deletedAtUtcIso), startTime);
45883
46001
  }
45884
46002
  if (isUndoRedo(action) || action.type === "PRUNE" || action.type === "NOOP" && skip > 0) {
45885
- this.writeCache.invalidate(job.documentId, job.scope, job.branch);
46003
+ stores.writeCache.invalidate(job.documentId, job.scope, job.branch);
45886
46004
  }
45887
46005
  let document2;
45888
46006
  try {
45889
- document2 = await this.writeCache.getState(job.documentId, job.scope, job.branch);
46007
+ document2 = await stores.writeCache.getState(job.documentId, job.scope, job.branch);
45890
46008
  } catch (error3) {
45891
46009
  return buildErrorResult(job, error3 instanceof Error ? error3 : new Error(String(error3)), startTime);
45892
46010
  }
@@ -45937,12 +46055,12 @@ ${error3.stack}`;
45937
46055
  header: updatedDocument.header
45938
46056
  });
45939
46057
  try {
45940
- await this.operationStore.apply(job.documentId, document2.header.documentType, scope, job.branch, newOperation.index, (txn) => {
46058
+ await stores.operationStore.apply(job.documentId, document2.header.documentType, scope, job.branch, newOperation.index, (txn) => {
45941
46059
  txn.addOperations(newOperation);
45942
46060
  });
45943
46061
  } catch (error3) {
45944
46062
  this.logger.error("Error writing @Operation to IOperationStore: @Error", newOperation, error3);
45945
- this.writeCache.invalidate(job.documentId, scope, job.branch);
46063
+ stores.writeCache.invalidate(job.documentId, scope, job.branch);
45946
46064
  return {
45947
46065
  job,
45948
46066
  success: false,
@@ -45954,7 +46072,7 @@ ${error3.stack}`;
45954
46072
  ...updatedDocument.header.revision,
45955
46073
  [scope]: newOperation.index + 1
45956
46074
  };
45957
- this.writeCache.putState(job.documentId, scope, job.branch, newOperation.index, updatedDocument);
46075
+ stores.writeCache.putState(job.documentId, scope, job.branch, newOperation.index, updatedDocument);
45958
46076
  indexTxn.write([
45959
46077
  {
45960
46078
  ...newOperation,
@@ -45985,13 +46103,13 @@ ${error3.stack}`;
45985
46103
  duration: Date.now() - startTime
45986
46104
  };
45987
46105
  }
45988
- async executeLoadJob(job, startTime, indexTxn) {
46106
+ async executeLoadJob(job, startTime, indexTxn, stores) {
45989
46107
  if (job.operations.length === 0) {
45990
46108
  return buildErrorResult(job, new Error("Load job must include at least one operation"), startTime);
45991
46109
  }
45992
46110
  let docMeta;
45993
46111
  try {
45994
- docMeta = await this.documentMetaCache.getDocumentMeta(job.documentId, job.branch);
46112
+ docMeta = await stores.documentMetaCache.getDocumentMeta(job.documentId, job.branch);
45995
46113
  } catch {}
45996
46114
  if (docMeta?.state.isDeleted) {
45997
46115
  return buildErrorResult(job, new DocumentDeletedError(job.documentId, docMeta.state.deletedAtUtcIso), startTime);
@@ -45999,7 +46117,7 @@ ${error3.stack}`;
45999
46117
  const scope = job.scope;
46000
46118
  let latestRevision = 0;
46001
46119
  try {
46002
- const revisions = await this.operationStore.getRevisions(job.documentId, job.branch);
46120
+ const revisions = await stores.operationStore.getRevisions(job.documentId, job.branch);
46003
46121
  latestRevision = revisions.revision[scope] ?? 0;
46004
46122
  } catch {
46005
46123
  latestRevision = 0;
@@ -46015,7 +46133,7 @@ ${error3.stack}`;
46015
46133
  }
46016
46134
  let conflictingOps = [];
46017
46135
  try {
46018
- const conflictingResult = await this.operationStore.getConflicting(job.documentId, scope, job.branch, minIncomingTimestamp);
46136
+ const conflictingResult = await stores.operationStore.getConflicting(job.documentId, scope, job.branch, minIncomingTimestamp);
46019
46137
  conflictingOps = conflictingResult.results;
46020
46138
  } catch {
46021
46139
  conflictingOps = [];
@@ -46024,7 +46142,7 @@ ${error3.stack}`;
46024
46142
  if (conflictingOps.length > 0) {
46025
46143
  const minConflictingIndex = Math.min(...conflictingOps.map((op) => op.index));
46026
46144
  try {
46027
- const allOpsResult = await this.operationStore.getSince(job.documentId, scope, job.branch, minConflictingIndex - 1);
46145
+ const allOpsResult = await stores.operationStore.getSince(job.documentId, scope, job.branch, minConflictingIndex - 1);
46028
46146
  allOpsFromMinConflictingIndex = allOpsResult.results;
46029
46147
  } catch {
46030
46148
  allOpsFromMinConflictingIndex = conflictingOps;
@@ -46085,7 +46203,7 @@ ${error3.stack}`;
46085
46203
  const actions2 = reshuffledOperations.map((operation) => operation.action);
46086
46204
  const skipValues = reshuffledOperations.map((operation) => operation.skip);
46087
46205
  const effectiveSourceRemote = skipCount > 0 ? "" : job.meta.sourceRemote || "";
46088
- const result = await this.processActions(job, actions2, startTime, indexTxn, skipValues, reshuffledOperations, effectiveSourceRemote);
46206
+ const result = await this.processActions(job, actions2, startTime, indexTxn, stores, skipValues, reshuffledOperations, effectiveSourceRemote);
46089
46207
  if (!result.success) {
46090
46208
  return {
46091
46209
  job,
@@ -46094,9 +46212,9 @@ ${error3.stack}`;
46094
46212
  duration: Date.now() - startTime
46095
46213
  };
46096
46214
  }
46097
- this.writeCache.invalidate(job.documentId, scope, job.branch);
46215
+ stores.writeCache.invalidate(job.documentId, scope, job.branch);
46098
46216
  if (scope === "document") {
46099
- this.documentMetaCache.invalidate(job.documentId, job.branch);
46217
+ stores.documentMetaCache.invalidate(job.documentId, job.branch);
46100
46218
  }
46101
46219
  return {
46102
46220
  job,
@@ -47045,14 +47163,23 @@ async function collectAllPages(firstPage, signal) {
47045
47163
 
47046
47164
  class KyselyKeyframeStore {
47047
47165
  db;
47166
+ trx;
47048
47167
  constructor(db) {
47049
47168
  this.db = db;
47050
47169
  }
47170
+ get queryExecutor() {
47171
+ return this.trx ?? this.db;
47172
+ }
47173
+ withTransaction(trx) {
47174
+ const instance2 = new KyselyKeyframeStore(this.db);
47175
+ instance2.trx = trx;
47176
+ return instance2;
47177
+ }
47051
47178
  async putKeyframe(documentId, scope, branch, revision, document2, signal) {
47052
47179
  if (signal?.aborted) {
47053
47180
  throw new Error("Operation aborted");
47054
47181
  }
47055
- await this.db.insertInto("Keyframe").values({
47182
+ await this.queryExecutor.insertInto("Keyframe").values({
47056
47183
  documentId,
47057
47184
  documentType: document2.header.documentType,
47058
47185
  scope,
@@ -47065,7 +47192,7 @@ class KyselyKeyframeStore {
47065
47192
  if (signal?.aborted) {
47066
47193
  throw new Error("Operation aborted");
47067
47194
  }
47068
- const row = await this.db.selectFrom("Keyframe").selectAll().where("documentId", "=", documentId).where("scope", "=", scope).where("branch", "=", branch).where("revision", "<=", targetRevision).orderBy("revision", "desc").limit(1).executeTakeFirst();
47195
+ const row = await this.queryExecutor.selectFrom("Keyframe").selectAll().where("documentId", "=", documentId).where("scope", "=", scope).where("branch", "=", branch).where("revision", "<=", targetRevision).orderBy("revision", "desc").limit(1).executeTakeFirst();
47069
47196
  if (!row) {
47070
47197
  return;
47071
47198
  }
@@ -47074,11 +47201,30 @@ class KyselyKeyframeStore {
47074
47201
  document: row.document
47075
47202
  };
47076
47203
  }
47204
+ async listKeyframes(documentId, scope, branch, signal) {
47205
+ if (signal?.aborted) {
47206
+ throw new Error("Operation aborted");
47207
+ }
47208
+ let query = this.queryExecutor.selectFrom("Keyframe").selectAll().where("documentId", "=", documentId).orderBy("revision", "asc");
47209
+ if (scope !== undefined) {
47210
+ query = query.where("scope", "=", scope);
47211
+ }
47212
+ if (branch !== undefined) {
47213
+ query = query.where("branch", "=", branch);
47214
+ }
47215
+ const rows = await query.execute();
47216
+ return rows.map((row) => ({
47217
+ scope: row.scope,
47218
+ branch: row.branch,
47219
+ revision: row.revision,
47220
+ document: row.document
47221
+ }));
47222
+ }
47077
47223
  async deleteKeyframes(documentId, scope, branch, signal) {
47078
47224
  if (signal?.aborted) {
47079
47225
  throw new Error("Operation aborted");
47080
47226
  }
47081
- let query = this.db.deleteFrom("Keyframe").where("documentId", "=", documentId);
47227
+ let query = this.queryExecutor.deleteFrom("Keyframe").where("documentId", "=", documentId);
47082
47228
  if (scope !== undefined && branch !== undefined) {
47083
47229
  query = query.where("scope", "=", scope).where("branch", "=", branch);
47084
47230
  } else if (scope !== undefined) {
@@ -47129,48 +47275,64 @@ class AtomicTransaction {
47129
47275
 
47130
47276
  class KyselyOperationStore {
47131
47277
  db;
47278
+ trx;
47132
47279
  constructor(db) {
47133
47280
  this.db = db;
47134
47281
  }
47282
+ get queryExecutor() {
47283
+ return this.trx ?? this.db;
47284
+ }
47285
+ withTransaction(trx) {
47286
+ const instance2 = new KyselyOperationStore(this.db);
47287
+ instance2.trx = trx;
47288
+ return instance2;
47289
+ }
47135
47290
  async apply(documentId, documentType, scope, branch, revision, fn, signal) {
47136
- await this.db.transaction().execute(async (trx) => {
47137
- if (signal?.aborted) {
47138
- throw new Error("Operation aborted");
47139
- }
47140
- const latestOp = await trx.selectFrom("Operation").selectAll().where("documentId", "=", documentId).where("scope", "=", scope).where("branch", "=", branch).orderBy("index", "desc").limit(1).executeTakeFirst();
47141
- const currentRevision = latestOp ? latestOp.index : -1;
47142
- if (currentRevision !== revision - 1) {
47143
- throw new RevisionMismatchError(currentRevision + 1, revision);
47291
+ if (this.trx) {
47292
+ await this.executeApply(this.trx, documentId, documentType, scope, branch, revision, fn, signal);
47293
+ } else {
47294
+ await this.db.transaction().execute(async (trx) => {
47295
+ await this.executeApply(trx, documentId, documentType, scope, branch, revision, fn, signal);
47296
+ });
47297
+ }
47298
+ }
47299
+ async executeApply(trx, documentId, documentType, scope, branch, revision, fn, signal) {
47300
+ if (signal?.aborted) {
47301
+ throw new Error("Operation aborted");
47302
+ }
47303
+ const latestOp = await trx.selectFrom("Operation").selectAll().where("documentId", "=", documentId).where("scope", "=", scope).where("branch", "=", branch).orderBy("index", "desc").limit(1).executeTakeFirst();
47304
+ const currentRevision = latestOp ? latestOp.index : -1;
47305
+ if (currentRevision !== revision - 1) {
47306
+ throw new RevisionMismatchError(currentRevision + 1, revision);
47307
+ }
47308
+ const atomicTxn = new AtomicTransaction(documentId, documentType, scope, branch, revision);
47309
+ await fn(atomicTxn);
47310
+ const operations = atomicTxn.getOperations();
47311
+ if (operations.length > 0) {
47312
+ let prevOpId = latestOp?.opId || "";
47313
+ for (const op of operations) {
47314
+ op.prevOpId = prevOpId;
47315
+ prevOpId = op.opId;
47144
47316
  }
47145
- const atomicTxn = new AtomicTransaction(documentId, documentType, scope, branch, revision);
47146
- await fn(atomicTxn);
47147
- const operations = atomicTxn.getOperations();
47148
- if (operations.length > 0) {
47149
- let prevOpId = latestOp?.opId || "";
47150
- for (const op of operations) {
47151
- op.prevOpId = prevOpId;
47152
- prevOpId = op.opId;
47153
- }
47154
- try {
47155
- await trx.insertInto("Operation").values(operations).execute();
47156
- } catch (error3) {
47157
- if (error3 instanceof Error) {
47158
- if (error3.message.includes("unique constraint")) {
47159
- const op = operations[0];
47160
- throw new DuplicateOperationError(`${op.opId} at index ${op.index} with skip ${op.skip}`);
47161
- }
47162
- throw error3;
47317
+ try {
47318
+ await trx.insertInto("Operation").values(operations).execute();
47319
+ } catch (error3) {
47320
+ if (error3 instanceof Error) {
47321
+ if (error3.message.includes("unique constraint")) {
47322
+ const op = operations[0];
47323
+ throw new DuplicateOperationError(`${op.opId} at index ${op.index} with skip ${op.skip}`);
47163
47324
  }
47164
47325
  throw error3;
47165
47326
  }
47327
+ throw error3;
47166
47328
  }
47167
- });
47329
+ }
47168
47330
  }
47169
47331
  async getSince(documentId, scope, branch, revision, filter, paging, signal) {
47170
47332
  if (signal?.aborted) {
47171
47333
  throw new Error("Operation aborted");
47172
47334
  }
47173
- let query = this.db.selectFrom("Operation").selectAll().where("documentId", "=", documentId).where("scope", "=", scope).where("branch", "=", branch).where("index", ">", revision).orderBy("index", "asc");
47335
+ let query = this.queryExecutor.selectFrom("Operation").selectAll().where("documentId", "=", documentId).where("scope", "=", scope).where("branch", "=", branch).where("index", ">", revision).orderBy("index", "asc");
47174
47336
  if (filter) {
47175
47337
  if (filter.actionTypes && filter.actionTypes.length > 0) {
47176
47338
  const actionTypesArray = filter.actionTypes.map((t4) => `'${t4.replace(/'/g, "''")}'`).join(",");
@@ -47217,7 +47379,7 @@ class KyselyOperationStore {
47217
47379
  if (signal?.aborted) {
47218
47380
  throw new Error("Operation aborted");
47219
47381
  }
47220
- let query = this.db.selectFrom("Operation").selectAll().where("id", ">", id).orderBy("id", "asc");
47382
+ let query = this.queryExecutor.selectFrom("Operation").selectAll().where("id", ">", id).orderBy("id", "asc");
47221
47383
  if (paging) {
47222
47384
  const cursorValue = Number.parseInt(paging.cursor, 10);
47223
47385
  if (cursorValue > 0) {
@@ -47249,7 +47411,7 @@ class KyselyOperationStore {
47249
47411
  if (signal?.aborted) {
47250
47412
  throw new Error("Operation aborted");
47251
47413
  }
47252
- let query = this.db.selectFrom("Operation").selectAll().where("documentId", "=", documentId).where("scope", "=", scope).where("branch", "=", branch).where("timestampUtcMs", ">=", new Date(minTimestamp)).orderBy("index", "asc");
47414
+ let query = this.queryExecutor.selectFrom("Operation").selectAll().where("documentId", "=", documentId).where("scope", "=", scope).where("branch", "=", branch).where("timestampUtcMs", ">=", new Date(minTimestamp)).orderBy("index", "asc");
47253
47415
  if (paging) {
47254
47416
  const cursorValue = Number.parseInt(paging.cursor, 10);
47255
47417
  if (cursorValue > 0) {
@@ -47281,7 +47443,7 @@ class KyselyOperationStore {
47281
47443
  if (signal?.aborted) {
47282
47444
  throw new Error("Operation aborted");
47283
47445
  }
47284
- const scopeRevisions = await this.db.selectFrom("Operation as o1").select(["o1.scope", "o1.index", "o1.timestampUtcMs"]).where("o1.documentId", "=", documentId).where("o1.branch", "=", branch).where((eb) => eb("o1.index", "=", eb.selectFrom("Operation as o2").select((eb2) => eb2.fn.max("o2.index").as("maxIndex")).where("o2.documentId", "=", eb.ref("o1.documentId")).where("o2.branch", "=", eb.ref("o1.branch")).where("o2.scope", "=", eb.ref("o1.scope")))).execute();
47446
+ const scopeRevisions = await this.queryExecutor.selectFrom("Operation as o1").select(["o1.scope", "o1.index", "o1.timestampUtcMs"]).where("o1.documentId", "=", documentId).where("o1.branch", "=", branch).where((eb) => eb("o1.index", "=", eb.selectFrom("Operation as o2").select((eb2) => eb2.fn.max("o2.index").as("maxIndex")).where("o2.documentId", "=", eb.ref("o1.documentId")).where("o2.branch", "=", eb.ref("o1.branch")).where("o2.scope", "=", eb.ref("o1.scope")))).execute();
47285
47447
  const revision = {};
47286
47448
  let latestTimestamp = new Date(0).toISOString();
47287
47449
  for (const row of scopeRevisions) {
@@ -51075,9 +51237,10 @@ class ReactorBuilder {
51075
51237
  });
51076
51238
  await documentMetaCache.startup();
51077
51239
  const collectionMembershipCache = new CollectionMembershipCache(operationIndex);
51240
+ const executionScope = new KyselyExecutionScope(database, operationStore, operationIndex, keyframeStore, writeCache, documentMetaCache, collectionMembershipCache);
51078
51241
  let executorManager = this.executorManager;
51079
51242
  if (!executorManager) {
51080
- executorManager = new SimpleJobExecutorManager(() => new SimpleJobExecutor(this.logger, documentModelRegistry, operationStore, eventBus, writeCache, operationIndex, documentMetaCache, collectionMembershipCache, this.executorConfig, this.signatureVerifier), eventBus, queue, jobTracker, this.logger, resolver);
51243
+ executorManager = new SimpleJobExecutorManager(() => new SimpleJobExecutor(this.logger, documentModelRegistry, operationStore, eventBus, writeCache, operationIndex, documentMetaCache, collectionMembershipCache, this.executorConfig, this.signatureVerifier, executionScope), eventBus, queue, jobTracker, this.logger, resolver);
51081
51244
  }
51082
51245
  await executorManager.start(this.executorConfig.maxConcurrency ?? 1);
51083
51246
  const readModelInstances = Array.from(new Set([...this.readModels]));
@@ -51208,6 +51371,7 @@ class ReactorClientBuilder {
51208
51371
  signatureVerifier;
51209
51372
  subscriptionManager;
51210
51373
  jobAwaiter;
51374
+ documentModelLoader;
51211
51375
  withLogger(logger4) {
51212
51376
  this.logger = logger4;
51213
51377
  return this;
@@ -51246,6 +51410,10 @@ class ReactorClientBuilder {
51246
51410
  this.jobAwaiter = jobAwaiter;
51247
51411
  return this;
51248
51412
  }
51413
+ withDocumentModelLoader(loader) {
51414
+ this.documentModelLoader = loader;
51415
+ return this;
51416
+ }
51249
51417
  async build() {
51250
51418
  const module = await this.buildModule();
51251
51419
  return module.client;
@@ -51263,6 +51431,9 @@ class ReactorClientBuilder {
51263
51431
  if (this.signatureVerifier) {
51264
51432
  this.reactorBuilder.withSignatureVerifier(this.signatureVerifier);
51265
51433
  }
51434
+ if (this.documentModelLoader) {
51435
+ this.reactorBuilder.withDocumentModelLoader(this.documentModelLoader);
51436
+ }
51266
51437
  reactorModule = await this.reactorBuilder.buildModule();
51267
51438
  reactor = reactorModule.reactor;
51268
51439
  eventBus = reactorModule.eventBus;
@@ -51312,6 +51483,118 @@ function relationalDbToQueryBuilder(query) {
51312
51483
  withSchema: (schema) => relationalDbToQueryBuilder(query.withSchema(schema))
51313
51484
  };
51314
51485
  }
51486
+
51487
+ class DocumentIntegrityService {
51488
+ keyframeStore;
51489
+ operationStore;
51490
+ writeCache;
51491
+ documentView;
51492
+ documentModelRegistry;
51493
+ constructor(keyframeStore, operationStore, writeCache, documentView, documentModelRegistry) {
51494
+ this.keyframeStore = keyframeStore;
51495
+ this.operationStore = operationStore;
51496
+ this.writeCache = writeCache;
51497
+ this.documentView = documentView;
51498
+ this.documentModelRegistry = documentModelRegistry;
51499
+ }
51500
+ async validateDocument(documentId, branch = "main", signal) {
51501
+ const keyframeIssues = [];
51502
+ const snapshotIssues = [];
51503
+ const replayCache = new KyselyWriteCache(nullKeyframeStore, this.operationStore, this.documentModelRegistry, {
51504
+ maxDocuments: 1,
51505
+ ringBufferSize: 1,
51506
+ keyframeInterval: Number.MAX_SAFE_INTEGER
51507
+ });
51508
+ const keyframes = await this.keyframeStore.listKeyframes(documentId, undefined, branch, signal);
51509
+ for (const keyframe of keyframes) {
51510
+ if (signal?.aborted) {
51511
+ throw new Error("Operation aborted");
51512
+ }
51513
+ replayCache.invalidate(documentId, keyframe.scope, branch);
51514
+ const replayedDoc = await replayCache.getState(documentId, keyframe.scope, branch, keyframe.revision, signal);
51515
+ const kfHash = hashDocumentStateForScope(keyframe.document, keyframe.scope);
51516
+ const replayHash = hashDocumentStateForScope(replayedDoc, keyframe.scope);
51517
+ if (kfHash !== replayHash) {
51518
+ keyframeIssues.push({
51519
+ scope: keyframe.scope,
51520
+ branch,
51521
+ revision: keyframe.revision,
51522
+ keyframeHash: kfHash,
51523
+ replayedHash: replayHash
51524
+ });
51525
+ }
51526
+ }
51527
+ let currentDoc;
51528
+ try {
51529
+ currentDoc = await this.documentView.get(documentId);
51530
+ } catch {
51531
+ return {
51532
+ documentId,
51533
+ isConsistent: keyframeIssues.length === 0,
51534
+ keyframeIssues,
51535
+ snapshotIssues
51536
+ };
51537
+ }
51538
+ const revisions = await this.operationStore.getRevisions(documentId, branch, signal);
51539
+ const allScopes = Object.keys(revisions.revision);
51540
+ for (const scope of allScopes) {
51541
+ if (scope === "document")
51542
+ continue;
51543
+ replayCache.invalidate(documentId, scope, branch);
51544
+ let replayedDoc;
51545
+ try {
51546
+ replayedDoc = await replayCache.getState(documentId, scope, branch, undefined, signal);
51547
+ } catch {
51548
+ if (signal?.aborted) {
51549
+ throw new Error("Operation aborted");
51550
+ }
51551
+ continue;
51552
+ }
51553
+ const snapshotHash = hashDocumentStateForScope(currentDoc, scope);
51554
+ const replayHash = hashDocumentStateForScope(replayedDoc, scope);
51555
+ if (snapshotHash !== replayHash) {
51556
+ snapshotIssues.push({
51557
+ scope,
51558
+ branch,
51559
+ snapshotHash,
51560
+ replayedHash: replayHash
51561
+ });
51562
+ }
51563
+ }
51564
+ return {
51565
+ documentId,
51566
+ isConsistent: keyframeIssues.length === 0 && snapshotIssues.length === 0,
51567
+ keyframeIssues,
51568
+ snapshotIssues
51569
+ };
51570
+ }
51571
+ async rebuildKeyframes(documentId, branch = "main", signal) {
51572
+ const deleted = await this.keyframeStore.deleteKeyframes(documentId, undefined, branch, signal);
51573
+ return {
51574
+ documentId,
51575
+ keyframesDeleted: deleted,
51576
+ scopesInvalidated: 0
51577
+ };
51578
+ }
51579
+ async rebuildSnapshots(documentId, branch = "main", signal) {
51580
+ const scopes = await this.discoverScopes(documentId, branch, signal);
51581
+ for (const scope of scopes) {
51582
+ if (signal?.aborted) {
51583
+ throw new Error("Operation aborted");
51584
+ }
51585
+ this.writeCache.invalidate(documentId, scope, branch);
51586
+ }
51587
+ return {
51588
+ documentId,
51589
+ keyframesDeleted: 0,
51590
+ scopesInvalidated: scopes.length
51591
+ };
51592
+ }
51593
+ async discoverScopes(documentId, branch, signal) {
51594
+ const revisions = await this.operationStore.getRevisions(documentId, branch, signal);
51595
+ return Object.keys(revisions.revision);
51596
+ }
51597
+ }
51315
51598
  var __defProp2, __export2 = (target, all) => {
51316
51599
  for (var name in all)
51317
51600
  __defProp2(target, name, {
@@ -51454,7 +51737,7 @@ var __defProp2, __export2 = (target, all) => {
51454
51737
  }
51455
51738
  }
51456
51739
  return maxOrdinal;
51457
- }, SyncStatus, cachedEncoder, LOG2_26, IS_RELATIONAL_DB_PROCESSOR, RelationalDbProcessor;
51740
+ }, SyncStatus, cachedEncoder, LOG2_26, IS_RELATIONAL_DB_PROCESSOR, RelationalDbProcessor, nullKeyframeStore;
51458
51741
  var init_src = __esm(() => {
51459
51742
  __defProp2 = Object.defineProperty;
51460
51743
  byteToHex = [];
@@ -56714,6 +56997,12 @@ var init_src = __esm(() => {
56714
56997
  return relationalDbToQueryBuilder(this.relationalDb);
56715
56998
  }
56716
56999
  };
57000
+ nullKeyframeStore = {
57001
+ putKeyframe: () => Promise.resolve(),
57002
+ findNearestKeyframe: () => Promise.resolve(undefined),
57003
+ listKeyframes: () => Promise.resolve([]),
57004
+ deleteKeyframes: () => Promise.resolve(0)
57005
+ };
56717
57006
  });
56718
57007
 
56719
57008
  // ../../packages/reactor-browser/dist/src/index.js
@@ -56723,6 +57012,7 @@ __export(exports_src, {
56723
57012
  useVetraPackages: () => useVetraPackages,
56724
57013
  useVetraPackageManager: () => useVetraPackageManager,
56725
57014
  useUserPermissions: () => useUserPermissions,
57015
+ useUser: () => useUser,
56726
57016
  useSupportedDocumentTypesInReactor: () => useSupportedDocumentTypesInReactor,
56727
57017
  useSubgraphModules: () => useSubgraphModules,
56728
57018
  useSetPHDriveEditorConfig: () => useSetPHDriveEditorConfig,
@@ -56741,8 +57031,12 @@ __export(exports_src, {
56741
57031
  useSelectedDocumentId: () => useSelectedDocumentId,
56742
57032
  useSelectedDocument: () => useSelectedDocument,
56743
57033
  useRevisionHistoryVisible: () => useRevisionHistoryVisible,
57034
+ useRenownInit: () => useRenownInit,
57035
+ useRenownAuth: () => useRenownAuth,
57036
+ useRenown: () => useRenown,
56744
57037
  useRelationalQuery: () => useRelationalQuery,
56745
57038
  useRelationalDb: () => useRelationalDb,
57039
+ usePendingInstallations: () => usePendingInstallations,
56746
57040
  useParentFolderForSelectedNode: () => useParentFolderForSelectedNode,
56747
57041
  usePHToast: () => usePHToast,
56748
57042
  usePHModal: () => usePHModal,
@@ -56758,6 +57052,8 @@ __export(exports_src, {
56758
57052
  useNodeParentFolderById: () => useNodeParentFolderById,
56759
57053
  useNodeById: () => useNodeById,
56760
57054
  useNodeActions: () => useNodeActions,
57055
+ useLoginStatus: () => useLoginStatus,
57056
+ useLoading: () => useLoading,
56761
57057
  useIsExternalControlsEnabled: () => useIsExternalControlsEnabled,
56762
57058
  useIsDragAndDropEnabled: () => useIsDragAndDropEnabled,
56763
57059
  useInspectorEnabled: () => useInspectorEnabled,
@@ -56793,6 +57089,8 @@ __export(exports_src, {
56793
57089
  useDocumentCache: () => useDocumentCache,
56794
57090
  useDocumentById: () => useDocumentById,
56795
57091
  useDocument: () => useDocument,
57092
+ useDismissedPackages: () => useDismissedPackages,
57093
+ useDid: () => useDid,
56796
57094
  useDefaultDriveEditorModule: () => useDefaultDriveEditorModule,
56797
57095
  useConnectionStates: () => useConnectionStates,
56798
57096
  useConnectionState: () => useConnectionState,
@@ -56817,6 +57115,7 @@ __export(exports_src, {
56817
57115
  setPHDriveEditorConfig: () => setPHDriveEditorConfig,
56818
57116
  setPHDocumentEditorConfigByKey: () => setPHDocumentEditorConfigByKey,
56819
57117
  setPHDocumentEditorConfig: () => setPHDocumentEditorConfig,
57118
+ setLoading: () => setLoading,
56820
57119
  setGlobal: () => setGlobal,
56821
57120
  setFeatures: () => setFeatures,
56822
57121
  setDriveSharingType: () => setDriveSharingType,
@@ -56836,6 +57135,7 @@ __export(exports_src, {
56836
57135
  makeDriveUrlComponent: () => makeDriveUrlComponent,
56837
57136
  logout: () => logout,
56838
57137
  login: () => login,
57138
+ loading: () => loading,
56839
57139
  isInspectorEnabledSync: () => isInspectorEnabledSync,
56840
57140
  isFolderNodeKind: () => isFolderNodeKind,
56841
57141
  isFileNodeKind: () => isFileNodeKind,
@@ -56884,6 +57184,7 @@ __export(exports_src, {
56884
57184
  baseDocumentModelsMap: () => baseDocumentModelsMap,
56885
57185
  baseDocumentModels: () => baseDocumentModels,
56886
57186
  addTrigger: () => addTrigger,
57187
+ addRenownEventHandler: () => addRenownEventHandler,
56887
57188
  addRemoteDrive: () => addRemoteDrive,
56888
57189
  addPromiseState: () => addPromiseState,
56889
57190
  addFolder: () => addFolder,
@@ -56895,10 +57196,10 @@ __export(exports_src, {
56895
57196
  SyncOperationStatus: () => SyncOperationStatus,
56896
57197
  SpinnerIcon: () => SpinnerIcon,
56897
57198
  RenownUserButton: () => RenownUserButton,
56898
- RenownProvider: () => RenownProvider,
56899
57199
  RenownLogo: () => RenownLogo,
56900
57200
  RenownLoginButton: () => RenownLoginButton,
56901
57201
  RenownAuthButton: () => RenownAuthButton,
57202
+ Renown: () => Renown2,
56902
57203
  RemoteDocumentController: () => RemoteDocumentController,
56903
57204
  RemoteClient: () => RemoteClient,
56904
57205
  RelationalDbProcessor: () => RelationalDbProcessor,
@@ -56916,7 +57217,7 @@ __export(exports_src, {
56916
57217
  InMemoryQueue: () => InMemoryQueue,
56917
57218
  ISSUER_TYPE: () => ISSUER_TYPE,
56918
57219
  GqlRequestChannel: () => GqlRequestChannel,
56919
- ExternalLinkIcon: () => ExternalLinkIcon,
57220
+ DocumentIntegrityService: () => DocumentIntegrityService,
56920
57221
  DocumentChangeType: () => DocumentChangeType,
56921
57222
  DocumentCache: () => DocumentCache,
56922
57223
  DisconnectIcon: () => DisconnectIcon,
@@ -56925,6 +57226,7 @@ __export(exports_src, {
56925
57226
  CopyIcon: () => CopyIcon,
56926
57227
  ConsoleLogger: () => ConsoleLogger,
56927
57228
  ConflictError: () => ConflictError,
57229
+ ChevronDownIcon: () => ChevronDownIcon,
56928
57230
  ChannelScheme: () => ChannelScheme,
56929
57231
  CREDENTIAL_TYPES: () => CREDENTIAL_TYPES,
56930
57232
  CREDENTIAL_SUBJECT_TYPE: () => CREDENTIAL_SUBJECT_TYPE,
@@ -56964,17 +57266,20 @@ import {
56964
57266
  setSharingType
56965
57267
  } from "document-drive";
56966
57268
  import { documentModelDocumentModelModule } from "document-model";
57269
+ import { useCallback as useCallback2 } from "react";
57270
+ import { useEffect as useEffect4, useState as useState3, useSyncExternalStore as useSyncExternalStore22 } from "react";
56967
57271
  import { useSyncExternalStore as useSyncExternalStore3 } from "react";
56968
- import { useSyncExternalStore as useSyncExternalStore22 } from "react";
56969
- import { useEffect as useEffect4, useRef as useRef3, useState as useState3 } from "react";
56970
57272
  import { logger as logger5 } from "document-drive";
56971
- import { use as use2, useCallback as useCallback2, useSyncExternalStore as useSyncExternalStore32 } from "react";
57273
+ import { useSyncExternalStore as useSyncExternalStore32 } from "react";
57274
+ import { logger as logger6 } from "document-drive";
57275
+ import { use as use2, useCallback as useCallback22, useSyncExternalStore as useSyncExternalStore4 } from "react";
56972
57276
  import { useEffect as useEffect22, useState as useState22 } from "react";
57277
+ import { useEffect as useEffect32, useRef as useRef3, useState as useState32 } from "react";
56973
57278
  import {
56974
57279
  DocumentModelNotFoundError,
56975
57280
  DocumentNotFoundError as DocumentNotFoundError2
56976
57281
  } from "document-drive";
56977
- import { useCallback as useCallback3, useEffect as useEffect32, useRef as useRef22, useState as useState32 } from "react";
57282
+ import { useCallback as useCallback4, useEffect as useEffect42, useRef as useRef22, useState as useState4 } from "react";
56978
57283
  import { isFileNode as isFileNode2 } from "document-drive";
56979
57284
  import { useMemo as useMemo2 } from "react";
56980
57285
  import {
@@ -56984,20 +57289,24 @@ import {
56984
57289
  } from "document-model";
56985
57290
  import { createState } from "document-model";
56986
57291
  import { defaultBaseState as defaultBaseState2, generateId as generateId22 } from "document-model/core";
56987
- import { logger as logger6 } from "document-drive";
56988
- import { useEffect as useEffect42, useState as useState4 } from "react";
56989
57292
  import { useEffect as useEffect5, useState as useState5 } from "react";
56990
57293
  import { createRelationalDbLegacy } from "document-drive";
56991
57294
  import { useMemo as useMemo22 } from "react";
56992
57295
  import { useEffect as useEffect6, useRef as useRef32, useState as useState6 } from "react";
56993
- import { useCallback as useCallback4, useMemo as useMemo3, useRef as useRef4 } from "react";
56994
- import { useCallback as useCallback5, useEffect as useEffect7, useRef as useRef5, useState as useState7 } from "react";
57296
+ import { useCallback as useCallback5, useMemo as useMemo3, useRef as useRef4 } from "react";
57297
+ import { useCallback as useCallback6, useState as useState7 } from "react";
56995
57298
  import { jsxDEV as jsxDEV2 } from "react/jsx-dev-runtime";
57299
+ import {
57300
+ Children as Children2,
57301
+ cloneElement as cloneElement2,
57302
+ forwardRef,
57303
+ isValidElement as isValidElement3
57304
+ } from "react";
56996
57305
  import { jsxDEV as jsxDEV22 } from "react/jsx-dev-runtime";
56997
- import { useCallback as useCallback6, useEffect as useEffect8, useRef as useRef6, useState as useState8 } from "react";
57306
+ import { useCallback as useCallback7, useEffect as useEffect7, useRef as useRef5, useState as useState8 } from "react";
56998
57307
  import { jsxDEV as jsxDEV3 } from "react/jsx-dev-runtime";
56999
- import { jsxDEV as jsxDEV4 } from "react/jsx-dev-runtime";
57000
- import { useEffect as useEffect9, useRef as useRef7 } from "react";
57308
+ import { jsxDEV as jsxDEV4, Fragment as Fragment2 } from "react/jsx-dev-runtime";
57309
+ import { useRef as useRef6 } from "react";
57001
57310
  function asUint8Array(buf) {
57002
57311
  if (globalThis.Buffer != null) {
57003
57312
  return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
@@ -60348,38 +60657,61 @@ function makePHEventFunctions(key) {
60348
60657
  const setEventName = `ph:set${capitalCase(key)}`;
60349
60658
  const updateEventName = `ph:${key}Updated`;
60350
60659
  function setValue(value) {
60660
+ if (isServer) {
60661
+ return;
60662
+ }
60351
60663
  const event = new CustomEvent(setEventName, {
60352
60664
  detail: { [key]: value }
60353
60665
  });
60354
60666
  window.dispatchEvent(event);
60355
60667
  }
60356
60668
  function dispatchUpdatedEvent() {
60669
+ if (isServer) {
60670
+ return;
60671
+ }
60357
60672
  const event = new CustomEvent(updateEventName);
60358
60673
  window.dispatchEvent(event);
60359
60674
  }
60360
60675
  function handleSetValueEvent(event) {
60676
+ if (isServer) {
60677
+ return;
60678
+ }
60361
60679
  const value = event.detail[key];
60362
- if (!window.ph)
60363
- throw new Error("ph global store is not defined");
60680
+ if (!window.ph) {
60681
+ window.ph = {};
60682
+ }
60364
60683
  window.ph[key] = value;
60365
60684
  dispatchUpdatedEvent();
60366
60685
  }
60367
60686
  function addEventHandler() {
60687
+ if (isServer) {
60688
+ return;
60689
+ }
60368
60690
  window.addEventListener(setEventName, handleSetValueEvent);
60369
60691
  }
60370
60692
  function subscribeToValue(onStoreChange) {
60693
+ if (isServer)
60694
+ return () => {};
60371
60695
  window.addEventListener(updateEventName, onStoreChange);
60372
60696
  return () => {
60373
60697
  window.removeEventListener(updateEventName, onStoreChange);
60374
60698
  };
60375
60699
  }
60376
60700
  function getSnapshot() {
60377
- if (!window.ph)
60378
- throw new Error("ph global store is not defined");
60701
+ if (isServer) {
60702
+ return;
60703
+ }
60704
+ if (!window.ph) {
60705
+ console.warn(`ph global store is not initialized. Did you call set${capitalCase(key)}?`);
60706
+ return;
60707
+ }
60379
60708
  return window.ph[key];
60380
60709
  }
60710
+ function getServerSnapshot() {
60711
+ return;
60712
+ }
60381
60713
  function useValue() {
60382
- return useSyncExternalStore3(subscribeToValue, getSnapshot);
60714
+ return useSyncExternalStore3(subscribeToValue, getSnapshot, getServerSnapshot);
60383
60715
  }
60384
60716
  return {
60385
60717
  useValue,
@@ -60387,6 +60719,138 @@ function makePHEventFunctions(key) {
60387
60719
  addEventHandler
60388
60720
  };
60389
60721
  }
60722
+ function useDid() {
60723
+ const renown = useRenown();
60724
+ return renown?.did;
60725
+ }
60726
+ function useUser() {
60727
+ const renown = useRenown();
60728
+ const [user, setUser2] = useState3(renown?.user);
60729
+ useEffect4(() => {
60730
+ setUser2(renown?.user);
60731
+ if (!renown)
60732
+ return;
60733
+ return renown.on("user", setUser2);
60734
+ }, [renown]);
60735
+ return user;
60736
+ }
60737
+ function useLoginStatus() {
60738
+ const renown = useRenown();
60739
+ return useSyncExternalStore22((cb) => {
60740
+ if (!renown) {
60741
+ return () => {};
60742
+ }
60743
+ return renown.on("status", cb);
60744
+ }, () => renown === loading ? "loading" : renown?.status, () => {
60745
+ return;
60746
+ });
60747
+ }
60748
+ function openRenown(documentId) {
60749
+ const renown = window.ph?.renown;
60750
+ let renownUrl = renown?.baseUrl;
60751
+ if (!renownUrl) {
60752
+ logger5.warn("Renown instance not found, falling back to: ", RENOWN_URL);
60753
+ renownUrl = RENOWN_URL;
60754
+ }
60755
+ if (documentId) {
60756
+ window.open(`${renownUrl}/profile/${documentId}`, "_blank")?.focus();
60757
+ return;
60758
+ }
60759
+ const url = new URL(renownUrl);
60760
+ url.searchParams.set("app", renown?.did ?? "");
60761
+ url.searchParams.set("connect", renown?.did ?? "");
60762
+ url.searchParams.set("network", RENOWN_NETWORK_ID);
60763
+ url.searchParams.set("chain", RENOWN_CHAIN_ID);
60764
+ const returnUrl = new URL(window.location.pathname, window.location.origin);
60765
+ url.searchParams.set("returnUrl", returnUrl.toJSON());
60766
+ window.open(url, "_self")?.focus();
60767
+ }
60768
+ function consumeDidFromUrl() {
60769
+ if (typeof window === "undefined")
60770
+ return;
60771
+ const urlParams = new URLSearchParams(window.location.search);
60772
+ const userParam = urlParams.get("user");
60773
+ if (!userParam)
60774
+ return;
60775
+ const userDid = decodeURIComponent(userParam);
60776
+ const cleanUrl = new URL(window.location.href);
60777
+ cleanUrl.searchParams.delete("user");
60778
+ window.history.replaceState({}, "", cleanUrl.toString());
60779
+ return userDid;
60780
+ }
60781
+ async function login(userDid, renown) {
60782
+ if (!renown) {
60783
+ return;
60784
+ }
60785
+ const did = userDid ?? consumeDidFromUrl();
60786
+ try {
60787
+ const user = renown.user;
60788
+ if (user?.did && (user.did === did || !did)) {
60789
+ return user;
60790
+ }
60791
+ if (!did) {
60792
+ return;
60793
+ }
60794
+ return await renown.login(did);
60795
+ } catch (error3) {
60796
+ logger5.error(error3 instanceof Error ? error3.message : JSON.stringify(error3));
60797
+ }
60798
+ }
60799
+ async function logout() {
60800
+ const renown = window.ph?.renown;
60801
+ await renown?.logout();
60802
+ const url = new URL(window.location.href);
60803
+ if (url.searchParams.has("user")) {
60804
+ url.searchParams.delete("user");
60805
+ window.history.replaceState(null, "", url.toString());
60806
+ }
60807
+ }
60808
+ function truncateAddress(address) {
60809
+ if (address.length <= 13)
60810
+ return address;
60811
+ return `${address.slice(0, 7)}...${address.slice(-5)}`;
60812
+ }
60813
+ function toRenownAuthStatus(loginStatus, user) {
60814
+ if (loginStatus === "authorized") {
60815
+ return user ? "authorized" : "checking";
60816
+ }
60817
+ return loginStatus;
60818
+ }
60819
+ function useRenownAuth() {
60820
+ const user = useUser();
60821
+ const loginStatus = useLoginStatus();
60822
+ const status = toRenownAuthStatus(loginStatus, user);
60823
+ const address = user?.address;
60824
+ const ensName = user?.ens?.name;
60825
+ const avatarUrl = user?.profile?.userImage ?? user?.ens?.avatarUrl;
60826
+ const profileId = user?.profile?.documentId;
60827
+ const displayName = ensName ?? user?.profile?.username ?? undefined;
60828
+ const displayAddress = address ? truncateAddress(address) : undefined;
60829
+ const login2 = useCallback2(() => {
60830
+ openRenown();
60831
+ }, []);
60832
+ const logout2 = useCallback2(async () => {
60833
+ await logout();
60834
+ }, []);
60835
+ const openProfile = useCallback2(() => {
60836
+ if (profileId) {
60837
+ openRenown(profileId);
60838
+ }
60839
+ }, [profileId]);
60840
+ return {
60841
+ status,
60842
+ user,
60843
+ address,
60844
+ ensName,
60845
+ avatarUrl,
60846
+ profileId,
60847
+ displayName,
60848
+ displayAddress,
60849
+ login: login2,
60850
+ logout: logout2,
60851
+ openProfile
60852
+ };
60853
+ }
60390
60854
  function useAllowedDocumentTypes() {
60391
60855
  const definedAllowedDocumentTypes = allowedDocumentTypesEventFunctions.useValue();
60392
60856
  return definedAllowedDocumentTypes;
@@ -60398,6 +60862,14 @@ function setVetraPackageManager(packageManager) {
60398
60862
  updateReactorClientDocumentModels(packages);
60399
60863
  });
60400
60864
  }
60865
+ function usePendingInstallations() {
60866
+ const pm = useVetraPackageManager();
60867
+ return useSyncExternalStore32((cb) => pm ? pm.subscribePendingChanges(cb) : NOOP_UNSUBSCRIBE, () => pm?.getPendingInstallations() ?? EMPTY_PENDING);
60868
+ }
60869
+ function useDismissedPackages() {
60870
+ const pm = useVetraPackageManager();
60871
+ return useSyncExternalStore32((cb) => pm ? pm.subscribePendingChanges(cb) : NOOP_UNSUBSCRIBE, () => pm?.getDismissedPackages() ?? EMPTY_DISMISSED);
60872
+ }
60401
60873
  function updateReactorClientDocumentModels(packages) {
60402
60874
  const documentModelModules = packages.flatMap((pkg) => pkg.modules.documentModelModules).filter((module) => module !== undefined);
60403
60875
  const registry = window.ph?.reactorClientModule?.reactorModule?.documentModelRegistry;
@@ -60429,52 +60901,6 @@ function useAllowedDocumentModelModules() {
60429
60901
  return documentModelModules;
60430
60902
  return documentModelModules?.filter((module) => allowedDocumentTypes.includes(module.documentModel.global.id));
60431
60903
  }
60432
- function useConnectionStates() {
60433
- const syncManager = useSync();
60434
- const [states, setStates] = useState3(() => buildSnapshot(syncManager));
60435
- const unsubscribesRef = useRef3([]);
60436
- useEffect4(() => {
60437
- if (!syncManager)
60438
- return;
60439
- function subscribe2() {
60440
- for (const unsub of unsubscribesRef.current) {
60441
- unsub();
60442
- }
60443
- unsubscribesRef.current = [];
60444
- const remotes = syncManager.list();
60445
- for (const remote of remotes) {
60446
- const unsub = remote.channel.onConnectionStateChange(() => {
60447
- setStates(buildSnapshot(syncManager));
60448
- });
60449
- unsubscribesRef.current.push(unsub);
60450
- }
60451
- setStates(buildSnapshot(syncManager));
60452
- }
60453
- subscribe2();
60454
- const interval = setInterval(subscribe2, 5000);
60455
- return () => {
60456
- clearInterval(interval);
60457
- for (const unsub of unsubscribesRef.current) {
60458
- unsub();
60459
- }
60460
- unsubscribesRef.current = [];
60461
- };
60462
- }, [syncManager]);
60463
- return states;
60464
- }
60465
- function useConnectionState(remoteName) {
60466
- const states = useConnectionStates();
60467
- return states.get(remoteName);
60468
- }
60469
- function buildSnapshot(syncManager) {
60470
- const map = new Map;
60471
- if (!syncManager)
60472
- return map;
60473
- for (const remote of syncManager.list()) {
60474
- map.set(remote.name, remote.channel.getConnectionState());
60475
- }
60476
- return map;
60477
- }
60478
60904
  function sortNodesByName(nodes) {
60479
60905
  return nodes.toSorted((a3, b2) => a3.name.localeCompare(b2.name));
60480
60906
  }
@@ -60490,7 +60916,7 @@ function isFolderNodeKind(node) {
60490
60916
  }
60491
60917
  function useDispatch(document2) {
60492
60918
  function dispatch(actionOrActions, onErrors, onSuccess) {
60493
- dispatchActions(actionOrActions, document2, onErrors, onSuccess).catch(logger5.error);
60919
+ dispatchActions(actionOrActions, document2, onErrors, onSuccess).catch(logger6.error);
60494
60920
  }
60495
60921
  return [document2, dispatch];
60496
60922
  }
@@ -60522,17 +60948,17 @@ function getDocumentQueryState(promise) {
60522
60948
  }
60523
60949
  function useDocument(id) {
60524
60950
  const documentCache = useDocumentCache();
60525
- const document2 = useSyncExternalStore32((cb) => id && documentCache ? documentCache.subscribe(id, cb) : () => {}, () => id ? documentCache?.get(id) : undefined);
60951
+ const document2 = useSyncExternalStore4((cb) => id && documentCache ? documentCache.subscribe(id, cb) : () => {}, () => id ? documentCache?.get(id) : undefined);
60526
60952
  return document2 ? use2(document2) : undefined;
60527
60953
  }
60528
60954
  function useDocuments(ids) {
60529
60955
  const documentCache = useDocumentCache();
60530
- const documents = useSyncExternalStore32((cb) => ids?.length && documentCache ? documentCache.subscribe(ids, cb) : () => {}, () => ids?.length && documentCache ? documentCache.getBatch(ids) : undefined);
60956
+ const documents = useSyncExternalStore4((cb) => ids?.length && documentCache ? documentCache.subscribe(ids, cb) : () => {}, () => ids?.length && documentCache ? documentCache.getBatch(ids) : undefined);
60531
60957
  return documents ? use2(documents) : [];
60532
60958
  }
60533
60959
  function useGetDocument() {
60534
60960
  const documentCache = useDocumentCache();
60535
- return useCallback2((id) => {
60961
+ return useCallback22((id) => {
60536
60962
  if (!documentCache) {
60537
60963
  return Promise.reject(new Error("Document cache not initialized"));
60538
60964
  }
@@ -60541,7 +60967,7 @@ function useGetDocument() {
60541
60967
  }
60542
60968
  function useGetDocuments() {
60543
60969
  const documentCache = useDocumentCache();
60544
- return useCallback2((ids) => {
60970
+ return useCallback22((ids) => {
60545
60971
  if (!documentCache) {
60546
60972
  return Promise.reject(new Error("Document cache not initialized"));
60547
60973
  }
@@ -60868,6 +61294,52 @@ function usePHDocumentEditorConfigByKey(key) {
60868
61294
  const useValueHook = phDocumentEditorConfigHooks[key];
60869
61295
  return useValueHook();
60870
61296
  }
61297
+ function useConnectionStates() {
61298
+ const syncManager = useSync();
61299
+ const [states, setStates] = useState32(() => buildSnapshot(syncManager));
61300
+ const unsubscribesRef = useRef3([]);
61301
+ useEffect32(() => {
61302
+ if (!syncManager)
61303
+ return;
61304
+ function subscribe2() {
61305
+ for (const unsub of unsubscribesRef.current) {
61306
+ unsub();
61307
+ }
61308
+ unsubscribesRef.current = [];
61309
+ const remotes = syncManager.list();
61310
+ for (const remote of remotes) {
61311
+ const unsub = remote.channel.onConnectionStateChange(() => {
61312
+ setStates(buildSnapshot(syncManager));
61313
+ });
61314
+ unsubscribesRef.current.push(unsub);
61315
+ }
61316
+ setStates(buildSnapshot(syncManager));
61317
+ }
61318
+ subscribe2();
61319
+ const interval = setInterval(subscribe2, 5000);
61320
+ return () => {
61321
+ clearInterval(interval);
61322
+ for (const unsub of unsubscribesRef.current) {
61323
+ unsub();
61324
+ }
61325
+ unsubscribesRef.current = [];
61326
+ };
61327
+ }, [syncManager]);
61328
+ return states;
61329
+ }
61330
+ function useConnectionState(remoteName) {
61331
+ const states = useConnectionStates();
61332
+ return states.get(remoteName);
61333
+ }
61334
+ function buildSnapshot(syncManager) {
61335
+ const map = new Map;
61336
+ if (!syncManager)
61337
+ return map;
61338
+ for (const remote of syncManager.list()) {
61339
+ map.set(remote.name, remote.channel.getConnectionState());
61340
+ }
61341
+ return map;
61342
+ }
60871
61343
  function useDocumentOfType(documentId, documentType) {
60872
61344
  const [document2, dispatch] = useDocumentById(documentId);
60873
61345
  const documentModelModule = useDocumentModelModuleById(documentType);
@@ -60887,13 +61359,13 @@ function useDocumentOfType(documentId, documentType) {
60887
61359
  function useDocumentOperations(documentId) {
60888
61360
  const reactorClient = useReactorClient();
60889
61361
  const hasFetchedRef = useRef22(false);
60890
- const [state, setState] = useState32(() => ({
61362
+ const [state, setState] = useState4(() => ({
60891
61363
  globalOperations: [],
60892
61364
  localOperations: [],
60893
61365
  isLoading: !!documentId,
60894
61366
  error: undefined
60895
61367
  }));
60896
- const fetchOperations = useCallback3(async (retryCount = 0) => {
61368
+ const fetchOperations = useCallback4(async (retryCount = 0) => {
60897
61369
  const MAX_RETRIES = 5;
60898
61370
  const RETRY_DELAY_MS = 500;
60899
61371
  if (!documentId || !reactorClient) {
@@ -60939,7 +61411,7 @@ function useDocumentOperations(documentId) {
60939
61411
  });
60940
61412
  hasFetchedRef.current = true;
60941
61413
  }, [documentId, reactorClient]);
60942
- useEffect32(() => {
61414
+ useEffect42(() => {
60943
61415
  if (documentId && reactorClient) {
60944
61416
  fetchOperations();
60945
61417
  } else if (!documentId) {
@@ -60952,7 +61424,7 @@ function useDocumentOperations(documentId) {
60952
61424
  hasFetchedRef.current = false;
60953
61425
  }
60954
61426
  }, [documentId, reactorClient, fetchOperations]);
60955
- const refetch = useCallback3(() => {
61427
+ const refetch = useCallback4(() => {
60956
61428
  fetchOperations(0);
60957
61429
  }, [fetchOperations]);
60958
61430
  return { ...state, refetch };
@@ -61399,81 +61871,6 @@ function makeVetraPackageManifestModulesEntry(modules) {
61399
61871
  return acc;
61400
61872
  }, {});
61401
61873
  }
61402
- function openRenown(documentId) {
61403
- if (documentId) {
61404
- window.open(`${RENOWN_URL}/profile/${documentId}`, "_blank")?.focus();
61405
- return;
61406
- }
61407
- const url = new URL(RENOWN_URL);
61408
- url.searchParams.set("connect", window.ph?.renown?.did ?? "");
61409
- url.searchParams.set("network", RENOWN_NETWORK_ID);
61410
- url.searchParams.set("chain", RENOWN_CHAIN_ID);
61411
- const returnUrl = new URL(window.location.pathname, window.location.origin);
61412
- url.searchParams.set("returnUrl", returnUrl.toJSON());
61413
- window.open(url, "_self")?.focus();
61414
- }
61415
- function consumeDidFromUrl() {
61416
- if (typeof window === "undefined")
61417
- return;
61418
- const urlParams = new URLSearchParams(window.location.search);
61419
- const userParam = urlParams.get("user");
61420
- if (!userParam)
61421
- return;
61422
- const userDid = decodeURIComponent(userParam);
61423
- const cleanUrl = new URL(window.location.href);
61424
- cleanUrl.searchParams.delete("user");
61425
- window.history.replaceState({}, "", cleanUrl.toString());
61426
- return userDid;
61427
- }
61428
- async function login(userDid, renown) {
61429
- if (!renown) {
61430
- return;
61431
- }
61432
- const did = userDid ?? consumeDidFromUrl();
61433
- try {
61434
- const user = renown.user;
61435
- if (user?.did && (user.did === did || !did)) {
61436
- return user;
61437
- }
61438
- if (!did) {
61439
- return;
61440
- }
61441
- return await renown.login(did);
61442
- } catch (error3) {
61443
- logger6.error("@error", error3);
61444
- }
61445
- }
61446
- async function logout() {
61447
- const renown = window.ph?.renown;
61448
- await renown?.logout();
61449
- const url = new URL(window.location.href);
61450
- if (url.searchParams.has("user")) {
61451
- url.searchParams.delete("user");
61452
- window.history.replaceState(null, "", url.toString());
61453
- }
61454
- }
61455
- function useUser() {
61456
- const renown = useRenown();
61457
- const [user, setUser2] = useState4(() => renown?.user);
61458
- useEffect42(() => {
61459
- setUser2(renown?.user);
61460
- if (!renown)
61461
- return;
61462
- return renown.on("user", setUser2);
61463
- }, [renown]);
61464
- return user;
61465
- }
61466
- function useLoginStatus() {
61467
- const renown = useRenown();
61468
- const [status, setStatus] = useState4(() => renown ? renown.status : "initializing");
61469
- useEffect42(() => {
61470
- setStatus(renown ? renown.status : "initializing");
61471
- if (!renown)
61472
- return;
61473
- return renown.on("status", setStatus);
61474
- }, [renown]);
61475
- return status;
61476
- }
61477
61874
  function useGetSwitchboardLink(document2) {
61478
61875
  const [drive] = useSelectedDrive();
61479
61876
  const remotes = useSyncList();
@@ -61516,6 +61913,47 @@ function useUserPermissions() {
61516
61913
  isAllowedToEditDocuments: allowList.includes(user?.address ?? "")
61517
61914
  };
61518
61915
  }
61916
+ function cdnUrlToApiUrl(cdnUrl) {
61917
+ return cdnUrl.replace(/\/-\/cdn\/?$/, "");
61918
+ }
61919
+ function mapPackageInfo(pkg) {
61920
+ return {
61921
+ name: pkg.name,
61922
+ description: pkg.manifest?.description,
61923
+ version: pkg.manifest?.version,
61924
+ category: pkg.manifest?.category,
61925
+ publisher: pkg.manifest?.publisher?.name,
61926
+ publisherUrl: pkg.manifest?.publisher?.url
61927
+ };
61928
+ }
61929
+
61930
+ class RegistryClient {
61931
+ apiUrl;
61932
+ constructor(cdnUrl) {
61933
+ this.apiUrl = cdnUrlToApiUrl(cdnUrl);
61934
+ }
61935
+ async getPackages() {
61936
+ const res = await fetch(`${this.apiUrl}/packages`);
61937
+ if (!res.ok)
61938
+ throw new Error(`Registry error: HTTP ${res.status}`);
61939
+ const data = await res.json();
61940
+ return data.map(mapPackageInfo);
61941
+ }
61942
+ async getPackagesByDocumentType(documentType) {
61943
+ const encodedType = encodeURIComponent(documentType);
61944
+ const res = await fetch(`${this.apiUrl}/packages/by-document-type?type=${encodedType}`);
61945
+ if (!res.ok)
61946
+ throw new Error(`Registry error: HTTP ${res.status}`);
61947
+ return await res.json();
61948
+ }
61949
+ async searchPackages(query) {
61950
+ const packages = await this.getPackages();
61951
+ if (!query)
61952
+ return packages;
61953
+ const lowerQuery = query.toLowerCase();
61954
+ return packages.filter((pkg) => pkg.name.toLowerCase().includes(lowerQuery) || pkg.description?.toLowerCase().includes(lowerQuery));
61955
+ }
61956
+ }
61519
61957
 
61520
61958
  class BaseStorage {
61521
61959
  #store;
@@ -61537,6 +61975,19 @@ class BaseStorage {
61537
61975
  return this.#store.delete(this.#buildKey(key));
61538
61976
  }
61539
61977
  }
61978
+ function loadDismissedPackages() {
61979
+ try {
61980
+ const raw = localStorage.getItem(DISMISSED_STORAGE_KEY);
61981
+ if (raw)
61982
+ return JSON.parse(raw);
61983
+ } catch {}
61984
+ return [];
61985
+ }
61986
+ function persistDismissedPackages(dismissed) {
61987
+ try {
61988
+ localStorage.setItem(DISMISSED_STORAGE_KEY, JSON.stringify(dismissed));
61989
+ } catch {}
61990
+ }
61540
61991
  function loadCSS(pkg, registryUrl) {
61541
61992
  const head = document.getElementsByTagName("head")[0];
61542
61993
  const existingStyle = head.querySelector(`link[data-package='${pkg}']`);
@@ -61557,10 +62008,13 @@ function removeCSS(pkg) {
61557
62008
  style.remove();
61558
62009
  }
61559
62010
  }
62011
+ async function runtimeImport(url) {
62012
+ return new Function("u", "return import(u)")(url);
62013
+ }
61560
62014
  async function loadExternalPackage(name4, registryUrl) {
61561
62015
  registryUrl = registryUrl.endsWith("/") ? registryUrl : `${registryUrl}/`;
61562
62016
  const url = `${registryUrl}${name4}/index.js`;
61563
- const module = await import(url);
62017
+ const module = await runtimeImport(url);
61564
62018
  loadCSS(name4, registryUrl);
61565
62019
  return convertLegacyLibToVetraPackage(module);
61566
62020
  }
@@ -61571,12 +62025,23 @@ class BrowserPackageManager {
61571
62025
  #localPackageIds = new Set;
61572
62026
  #subscribers = new Set;
61573
62027
  #packagesMemo = [];
61574
- constructor(namespace2) {
62028
+ #registryCdnUrl;
62029
+ #registryClient;
62030
+ #documentModelRegistry;
62031
+ #pending = [];
62032
+ #dismissed = loadDismissedPackages();
62033
+ #deferredActions = new Map;
62034
+ #pendingListeners = new Set;
62035
+ constructor(namespace2, registryCdnUrl) {
61575
62036
  this.#storage = new BrowserLocalStorage(namespace2 + ":PH_PACKAGES");
61576
62037
  const packages = this.#storage.get("packages");
61577
62038
  if (!packages) {
61578
62039
  this.#storage.set("packages", []);
61579
62040
  }
62041
+ if (registryCdnUrl) {
62042
+ this.#registryCdnUrl = registryCdnUrl;
62043
+ this.#registryClient = new RegistryClient(registryCdnUrl);
62044
+ }
61580
62045
  }
61581
62046
  async init() {
61582
62047
  const packages = this.#storage.get("packages");
@@ -61632,6 +62097,99 @@ class BrowserPackageManager {
61632
62097
  handler({ packages });
61633
62098
  });
61634
62099
  }
62100
+ setDocumentModelRegistry(registry) {
62101
+ this.#documentModelRegistry = registry;
62102
+ }
62103
+ async load(documentType) {
62104
+ if (!this.#registryClient || !this.#registryCdnUrl) {
62105
+ throw new Error("Registry CDN URL not configured — cannot discover packages");
62106
+ }
62107
+ const packageNames = await this.#registryClient.getPackagesByDocumentType(documentType);
62108
+ if (packageNames.length === 0) {
62109
+ throw new Error(`No package found containing document type: ${documentType}`);
62110
+ }
62111
+ const packageName = packageNames.sort((a3, b2) => a3.localeCompare(b2))[0];
62112
+ this.#pending = [...this.#pending, { documentType, packageName }];
62113
+ this.#notifyPendingListeners();
62114
+ return new Promise((resolve2, reject) => {
62115
+ this.#deferredActions.set(packageName, { resolve: resolve2, reject });
62116
+ });
62117
+ }
62118
+ async approveInstallation(packageName) {
62119
+ const deferred = this.#deferredActions.get(packageName);
62120
+ if (!deferred)
62121
+ return;
62122
+ try {
62123
+ await this.addPackage(packageName, this.#registryCdnUrl);
62124
+ } catch (error3) {
62125
+ this.#removePending(packageName);
62126
+ this.#deferredActions.delete(packageName);
62127
+ deferred.reject(error3 instanceof Error ? error3 : new Error(`Failed to install package: ${packageName}`));
62128
+ return;
62129
+ }
62130
+ const pendingEntries = this.#pending.filter((p2) => p2.packageName === packageName);
62131
+ this.#removePending(packageName);
62132
+ this.#deferredActions.delete(packageName);
62133
+ if (!this.#documentModelRegistry) {
62134
+ deferred.reject(new Error("Document model registry not available"));
62135
+ return;
62136
+ }
62137
+ for (const entry of pendingEntries) {
62138
+ try {
62139
+ const module = this.#documentModelRegistry.getModule(entry.documentType);
62140
+ deferred.resolve(module);
62141
+ return;
62142
+ } catch {}
62143
+ }
62144
+ deferred.reject(new Error(`Module not found after installing package: ${packageName}`));
62145
+ }
62146
+ rejectInstallation(packageName) {
62147
+ const deferred = this.#deferredActions.get(packageName);
62148
+ if (!deferred)
62149
+ return;
62150
+ const rejectedEntries = this.#pending.filter((p2) => p2.packageName === packageName);
62151
+ const documentTypes = rejectedEntries.map((e4) => e4.documentType);
62152
+ this.#addDismissed(packageName, documentTypes);
62153
+ this.#removePending(packageName);
62154
+ this.#deferredActions.delete(packageName);
62155
+ deferred.reject(new Error(`Installation rejected for package: ${packageName}`));
62156
+ }
62157
+ subscribePendingChanges(listener) {
62158
+ this.#pendingListeners.add(listener);
62159
+ return () => {
62160
+ this.#pendingListeners.delete(listener);
62161
+ };
62162
+ }
62163
+ getPendingInstallations() {
62164
+ return this.#pending;
62165
+ }
62166
+ getDismissedPackages() {
62167
+ return this.#dismissed;
62168
+ }
62169
+ removeDismissed(packageName) {
62170
+ this.#dismissed = this.#dismissed.filter((d2) => d2.packageName !== packageName);
62171
+ persistDismissedPackages(this.#dismissed);
62172
+ this.#notifyPendingListeners();
62173
+ }
62174
+ #addDismissed(packageName, documentTypes) {
62175
+ const existing = this.#dismissed.find((d2) => d2.packageName === packageName);
62176
+ if (existing) {
62177
+ const merged = new Set([...existing.documentTypes, ...documentTypes]);
62178
+ existing.documentTypes = [...merged];
62179
+ } else {
62180
+ this.#dismissed = [...this.#dismissed, { packageName, documentTypes }];
62181
+ }
62182
+ persistDismissedPackages(this.#dismissed);
62183
+ }
62184
+ #removePending(packageName) {
62185
+ this.#pending = this.#pending.filter((p2) => p2.packageName !== packageName);
62186
+ this.#notifyPendingListeners();
62187
+ }
62188
+ #notifyPendingListeners() {
62189
+ for (const listener of this.#pendingListeners) {
62190
+ listener();
62191
+ }
62192
+ }
61635
62193
  }
61636
62194
  async function dropTablesInSchema(pg, schema) {
61637
62195
  await pg.exec(`
@@ -61657,40 +62215,6 @@ async function dropAllReactorStorage(pg) {
61657
62215
  await dropTablesInSchema(pg, REACTOR_SCHEMA);
61658
62216
  await dropTablesInSchema(pg, "public");
61659
62217
  }
61660
- function cdnUrlToApiUrl(cdnUrl) {
61661
- return cdnUrl.replace(/\/-\/cdn\/?$/, "");
61662
- }
61663
- function mapPackageInfo(pkg) {
61664
- return {
61665
- name: pkg.name,
61666
- description: pkg.manifest?.description,
61667
- version: pkg.manifest?.version,
61668
- category: pkg.manifest?.category,
61669
- publisher: pkg.manifest?.publisher?.name,
61670
- publisherUrl: pkg.manifest?.publisher?.url
61671
- };
61672
- }
61673
-
61674
- class RegistryClient {
61675
- apiUrl;
61676
- constructor(cdnUrl) {
61677
- this.apiUrl = cdnUrlToApiUrl(cdnUrl);
61678
- }
61679
- async getPackages() {
61680
- const res = await fetch(`${this.apiUrl}/packages`);
61681
- if (!res.ok)
61682
- throw new Error(`Registry error: HTTP ${res.status}`);
61683
- const data = await res.json();
61684
- return data.map(mapPackageInfo);
61685
- }
61686
- async searchPackages(query) {
61687
- const packages = await this.getPackages();
61688
- if (!query)
61689
- return packages;
61690
- const lowerQuery = query.toLowerCase();
61691
- return packages.filter((pkg) => pkg.name.toLowerCase().includes(lowerQuery) || pkg.description?.toLowerCase().includes(lowerQuery));
61692
- }
61693
- }
61694
62218
 
61695
62219
  class ReactorClientDocumentCache {
61696
62220
  client;
@@ -61996,7 +62520,7 @@ function split2(lst, le = false) {
61996
62520
  }
61997
62521
  function add(Ah, Al, Bh, Bl) {
61998
62522
  const l2 = (Al >>> 0) + (Bl >>> 0);
61999
- return { h: Ah + Bh + (l2 / 4294967296 | 0) | 0, l: l2 | 0 };
62523
+ return { h: Ah + Bh + (l2 / 2 ** 32 | 0) | 0, l: l2 | 0 };
62000
62524
  }
62001
62525
  function _abool2(value, title = "") {
62002
62526
  if (typeof value !== "boolean") {
@@ -62807,7 +63331,7 @@ function edwards(params, extraOpts = {}) {
62807
63331
  _abool2(zip215, "zip215");
62808
63332
  const normed = copyBytes(bytes);
62809
63333
  const lastByte = bytes[len - 1];
62810
- normed[len - 1] = lastByte & -129;
63334
+ normed[len - 1] = lastByte & ~128;
62811
63335
  const y2 = bytesToNumberLE(normed);
62812
63336
  const max = zip215 ? MASK : Fp.ORDER;
62813
63337
  aInRange("point.y", y2, _0n4, max);
@@ -64193,7 +64717,7 @@ function ripemd_f(group, x2, y2, z2) {
64193
64717
  return x2 ^ (y2 | ~z2);
64194
64718
  }
64195
64719
  function keccakP(s3, rounds = 24) {
64196
- const B2 = new Uint32Array(10);
64720
+ const B2 = new Uint32Array(5 * 2);
64197
64721
  for (let round = 24 - rounds;round < 24; round++) {
64198
64722
  for (let x2 = 0;x2 < 10; x2++)
64199
64723
  B2[x2] = s3[x2] ^ s3[x2 + 10] ^ s3[x2 + 20] ^ s3[x2 + 30] ^ s3[x2 + 40];
@@ -64582,7 +65106,7 @@ function convertRadix2(data, from3, to, padding2) {
64582
65106
  }
64583
65107
  function radix(num) {
64584
65108
  anumber2(num);
64585
- const _256 = 256;
65109
+ const _256 = 2 ** 8;
64586
65110
  return {
64587
65111
  encode: (bytes) => {
64588
65112
  if (!isBytes2(bytes))
@@ -73199,7 +73723,7 @@ function useStableParams(params) {
73199
73723
  function createProcessorQuery(ProcessorClass) {
73200
73724
  function useQuery(driveId, queryCallback, parameters, options) {
73201
73725
  const stableParams = useStableParams(parameters);
73202
- const memoizedCallback = useCallback4(queryCallback, [stableParams]);
73726
+ const memoizedCallback = useCallback5(queryCallback, [stableParams]);
73203
73727
  return useRelationalQuery(ProcessorClass, driveId, memoizedCallback, stableParams, options);
73204
73728
  }
73205
73729
  return useQuery;
@@ -73733,41 +74257,6 @@ function CopyIcon({ size = 14, color = "#9EA0A1" }) {
73733
74257
  ]
73734
74258
  }, undefined, true, undefined, this);
73735
74259
  }
73736
- function ExternalLinkIcon({
73737
- size = 14,
73738
- color = "currentColor"
73739
- }) {
73740
- return /* @__PURE__ */ jsxDEV2("svg", {
73741
- width: size,
73742
- height: size,
73743
- viewBox: "0 0 16 16",
73744
- fill: "none",
73745
- xmlns: "http://www.w3.org/2000/svg",
73746
- children: [
73747
- /* @__PURE__ */ jsxDEV2("path", {
73748
- d: "M12 8.66667V12.6667C12 13.0203 11.8595 13.3594 11.6095 13.6095C11.3594 13.8595 11.0203 14 10.6667 14H3.33333C2.97971 14 2.64057 13.8595 2.39052 13.6095C2.14048 13.3594 2 13.0203 2 12.6667V5.33333C2 4.97971 2.14048 4.64057 2.39052 4.39052C2.64057 4.14048 2.97971 4 3.33333 4H7.33333",
73749
- stroke: color,
73750
- strokeWidth: "1.5",
73751
- strokeLinecap: "round",
73752
- strokeLinejoin: "round"
73753
- }, undefined, false, undefined, this),
73754
- /* @__PURE__ */ jsxDEV2("path", {
73755
- d: "M10 2H14V6",
73756
- stroke: color,
73757
- strokeWidth: "1.5",
73758
- strokeLinecap: "round",
73759
- strokeLinejoin: "round"
73760
- }, undefined, false, undefined, this),
73761
- /* @__PURE__ */ jsxDEV2("path", {
73762
- d: "M6.66669 9.33333L14 2",
73763
- stroke: color,
73764
- strokeWidth: "1.5",
73765
- strokeLinecap: "round",
73766
- strokeLinejoin: "round"
73767
- }, undefined, false, undefined, this)
73768
- ]
73769
- }, undefined, true, undefined, this);
73770
- }
73771
74260
  function DisconnectIcon({ size = 14, color = "#EA4335" }) {
73772
74261
  return /* @__PURE__ */ jsxDEV2("svg", {
73773
74262
  width: size,
@@ -73870,6 +74359,27 @@ function SpinnerIcon({ size = 14, color = "currentColor" }) {
73870
74359
  ]
73871
74360
  }, undefined, true, undefined, this);
73872
74361
  }
74362
+ function ChevronDownIcon({
74363
+ size = 14,
74364
+ color = "currentColor",
74365
+ style
74366
+ }) {
74367
+ return /* @__PURE__ */ jsxDEV2("svg", {
74368
+ width: size,
74369
+ height: size,
74370
+ viewBox: "0 0 16 16",
74371
+ fill: "none",
74372
+ xmlns: "http://www.w3.org/2000/svg",
74373
+ style,
74374
+ children: /* @__PURE__ */ jsxDEV2("path", {
74375
+ d: "M4 6L8 10L12 6",
74376
+ stroke: color,
74377
+ strokeWidth: "1.5",
74378
+ strokeLinecap: "round",
74379
+ strokeLinejoin: "round"
74380
+ }, undefined, false, undefined, this)
74381
+ }, undefined, false, undefined, this);
74382
+ }
73873
74383
  function UserIcon({ size = 24, color = "#6366f1" }) {
73874
74384
  return /* @__PURE__ */ jsxDEV2("svg", {
73875
74385
  width: size,
@@ -73894,134 +74404,80 @@ function UserIcon({ size = 24, color = "#6366f1" }) {
73894
74404
  ]
73895
74405
  }, undefined, true, undefined, this);
73896
74406
  }
74407
+ function mergeProps2(parentProps, childProps) {
74408
+ const merged = { ...parentProps };
74409
+ for (const key of Object.keys(childProps)) {
74410
+ const parentValue = parentProps[key];
74411
+ const childValue = childProps[key];
74412
+ if (key === "style") {
74413
+ merged[key] = { ...parentValue, ...childValue };
74414
+ } else if (key === "className") {
74415
+ merged[key] = [parentValue, childValue].filter(Boolean).join(" ");
74416
+ } else if (typeof parentValue === "function" && typeof childValue === "function") {
74417
+ merged[key] = (...args) => {
74418
+ childValue(...args);
74419
+ parentValue(...args);
74420
+ };
74421
+ } else if (childValue !== undefined) {
74422
+ merged[key] = childValue;
74423
+ }
74424
+ }
74425
+ return merged;
74426
+ }
73897
74427
  function RenownLoginButton({
73898
74428
  onLogin: onLoginProp,
73899
74429
  darkMode = false,
73900
74430
  style,
73901
74431
  className,
73902
- renderTrigger,
73903
- showPopover = false
74432
+ asChild = false,
74433
+ children
73904
74434
  }) {
73905
74435
  const onLogin = onLoginProp ?? (() => openRenown());
73906
- const [isOpen, setIsOpen] = useState7(false);
73907
74436
  const [isLoading, setIsLoading] = useState7(false);
73908
74437
  const [isHovered, setIsHovered] = useState7(false);
73909
- const [showAbove, setShowAbove] = useState7(true);
73910
- const wrapperRef = useRef5(null);
73911
- const closeTimeoutRef = useRef5(null);
73912
- const calculatePosition = useCallback5(() => {
73913
- if (!wrapperRef.current)
73914
- return;
73915
- const rect = wrapperRef.current.getBoundingClientRect();
73916
- const spaceAbove = rect.top;
73917
- setShowAbove(spaceAbove >= POPOVER_HEIGHT + POPOVER_GAP);
73918
- }, []);
73919
- const handleMouseEnter = useCallback5(() => {
73920
- setIsHovered(true);
73921
- if (!showPopover)
73922
- return;
73923
- if (closeTimeoutRef.current) {
73924
- clearTimeout(closeTimeoutRef.current);
73925
- closeTimeoutRef.current = null;
73926
- }
73927
- calculatePosition();
73928
- setIsOpen(true);
73929
- }, [calculatePosition, showPopover]);
73930
- const handleMouseLeave = useCallback5(() => {
73931
- closeTimeoutRef.current = setTimeout(() => {
73932
- setIsOpen(false);
73933
- setIsHovered(false);
73934
- }, 150);
73935
- }, []);
73936
- useEffect7(() => {
73937
- return () => {
73938
- if (closeTimeoutRef.current) {
73939
- clearTimeout(closeTimeoutRef.current);
73940
- }
73941
- };
73942
- }, []);
73943
- const handleConnect = () => {
73944
- setIsLoading(true);
73945
- onLogin();
73946
- };
73947
- const handleDirectClick = () => {
73948
- if (!showPopover && !isLoading) {
74438
+ const handleMouseEnter = useCallback6(() => setIsHovered(true), []);
74439
+ const handleMouseLeave = useCallback6(() => setIsHovered(false), []);
74440
+ const handleClick2 = () => {
74441
+ if (!isLoading) {
73949
74442
  setIsLoading(true);
73950
74443
  onLogin();
73951
74444
  }
73952
74445
  };
74446
+ const themeStyles = darkMode ? darkStyles : lightStyles;
73953
74447
  const triggerStyle = {
73954
74448
  ...styles.trigger,
73955
- cursor: !isLoading ? "pointer" : "wait",
74449
+ ...themeStyles.trigger,
74450
+ ...isHovered && !isLoading ? themeStyles.triggerHover : {},
74451
+ cursor: isLoading ? "wait" : "pointer",
73956
74452
  ...style
73957
74453
  };
73958
- const allowLogin = !isLoading && !!onLogin;
73959
- const connectButtonStyle = {
73960
- ...styles.connectButtonBase,
73961
- ...darkMode ? styles.connectButtonDark : styles.connectButtonLight,
73962
- cursor: allowLogin ? "pointer" : "wait"
73963
- };
73964
- const popoverStyle = {
73965
- ...styles.popoverBase,
73966
- ...darkMode ? styles.popoverDark : styles.popoverLight,
73967
- ...showAbove ? { bottom: `calc(100% + ${POPOVER_GAP}px)` } : { top: `calc(100% + ${POPOVER_GAP}px)` }
73968
- };
73969
- const triggerImageStyle = darkMode ? styles.triggerImageDark : styles.triggerImageLight;
73970
- const logoColor = darkMode ? "#f9fafb" : "#374151";
74454
+ const triggerElement = asChild ? /* @__PURE__ */ jsxDEV22(Slot, {
74455
+ onClick: handleClick2,
74456
+ "data-renown-state": "login",
74457
+ ...isLoading ? { "data-loading": "" } : {},
74458
+ children
74459
+ }, undefined, false, undefined, this) : /* @__PURE__ */ jsxDEV22("button", {
74460
+ type: "button",
74461
+ style: triggerStyle,
74462
+ "aria-label": "Log in with Renown",
74463
+ onClick: handleClick2,
74464
+ "data-renown-state": "login",
74465
+ ...isLoading ? { "data-loading": "" } : {},
74466
+ children: isLoading ? /* @__PURE__ */ jsxDEV22(SpinnerIcon, {
74467
+ size: 16
74468
+ }, undefined, false, undefined, this) : /* @__PURE__ */ jsxDEV22("span", {
74469
+ children: "Log in"
74470
+ }, undefined, false, undefined, this)
74471
+ }, undefined, false, undefined, this);
73971
74472
  return /* @__PURE__ */ jsxDEV22("div", {
73972
- ref: wrapperRef,
73973
74473
  style: styles.wrapper,
73974
74474
  className,
73975
74475
  onMouseEnter: handleMouseEnter,
73976
74476
  onMouseLeave: handleMouseLeave,
73977
- children: [
73978
- renderTrigger ? renderTrigger({
73979
- onMouseEnter: handleMouseEnter,
73980
- onMouseLeave: handleMouseLeave,
73981
- isLoading
73982
- }) : /* @__PURE__ */ jsxDEV22("button", {
73983
- type: "button",
73984
- style: triggerStyle,
73985
- "aria-label": showPopover ? "Open Renown Login" : "Login with Renown",
73986
- onClick: showPopover ? undefined : handleDirectClick,
73987
- children: isLoading ? /* @__PURE__ */ jsxDEV22(SpinnerIcon, {
73988
- size: 42
73989
- }, undefined, false, undefined, this) : /* @__PURE__ */ jsxDEV22("img", {
73990
- width: 42,
73991
- height: 42,
73992
- src: isHovered ? renownShortHoverDataUrl : renownShortDataUrl,
73993
- alt: "Renown Login",
73994
- style: triggerImageStyle
73995
- }, undefined, false, undefined, this)
73996
- }, undefined, false, undefined, this),
73997
- isOpen && showPopover && /* @__PURE__ */ jsxDEV22("div", {
73998
- style: popoverStyle,
73999
- children: /* @__PURE__ */ jsxDEV22("div", {
74000
- style: styles.popoverContent,
74001
- children: [
74002
- /* @__PURE__ */ jsxDEV22("div", {
74003
- style: styles.logoContainer,
74004
- children: /* @__PURE__ */ jsxDEV22(RenownLogo, {
74005
- width: 83,
74006
- height: 22,
74007
- color: logoColor
74008
- }, undefined, false, undefined, this)
74009
- }, undefined, false, undefined, this),
74010
- /* @__PURE__ */ jsxDEV22("button", {
74011
- type: "button",
74012
- onClick: allowLogin ? handleConnect : undefined,
74013
- style: connectButtonStyle,
74014
- children: isLoading ? /* @__PURE__ */ jsxDEV22(SpinnerIcon, {
74015
- size: 14
74016
- }, undefined, false, undefined, this) : "Connect"
74017
- }, undefined, false, undefined, this)
74018
- ]
74019
- }, undefined, true, undefined, this)
74020
- }, undefined, false, undefined, this)
74021
- ]
74022
- }, undefined, true, undefined, this);
74477
+ children: triggerElement
74478
+ }, undefined, false, undefined, this);
74023
74479
  }
74024
- function truncateAddress(address) {
74480
+ function truncateAddress2(address) {
74025
74481
  if (address.length <= 13)
74026
74482
  return address;
74027
74483
  return `${address.slice(0, 7)}...${address.slice(-5)}`;
@@ -74034,27 +74490,34 @@ function RenownUserButton({
74034
74490
  onDisconnect: onDisconnectProp,
74035
74491
  style,
74036
74492
  className,
74037
- renderTrigger
74493
+ asChild = false,
74494
+ children,
74495
+ menuItems
74038
74496
  }) {
74039
74497
  const user = useUser();
74040
74498
  const address = addressProp ?? user?.address ?? "";
74041
- const username = usernameProp ?? user?.ens?.name;
74042
- const avatarUrl = avatarUrlProp ?? user?.ens?.avatarUrl;
74499
+ const username = usernameProp ?? user?.profile?.username ?? user?.ens?.name;
74500
+ const avatarUrl = avatarUrlProp ?? user?.profile?.userImage ?? user?.ens?.avatarUrl;
74043
74501
  const userId = userIdProp ?? user?.profile?.documentId;
74044
74502
  const onDisconnect = onDisconnectProp ?? (() => void logout());
74503
+ const displayName = username ?? (address ? truncateAddress2(address) : "Account");
74504
+ const profileId = userId ?? address;
74045
74505
  const [isOpen, setIsOpen] = useState8(false);
74506
+ const [isHovered, setIsHovered] = useState8(false);
74046
74507
  const [isCopied, setIsCopied] = useState8(false);
74047
74508
  const [showAbove, setShowAbove] = useState8(true);
74048
- const wrapperRef = useRef6(null);
74049
- const closeTimeoutRef = useRef6(null);
74050
- const calculatePosition = useCallback6(() => {
74509
+ const [hoveredItem, setHoveredItem] = useState8(null);
74510
+ const wrapperRef = useRef5(null);
74511
+ const closeTimeoutRef = useRef5(null);
74512
+ const calculatePosition = useCallback7(() => {
74051
74513
  if (!wrapperRef.current)
74052
74514
  return;
74053
74515
  const rect = wrapperRef.current.getBoundingClientRect();
74054
74516
  const spaceAbove = rect.top;
74055
- setShowAbove(spaceAbove >= POPOVER_HEIGHT2 + POPOVER_GAP2);
74517
+ setShowAbove(spaceAbove >= POPOVER_HEIGHT + POPOVER_GAP);
74056
74518
  }, []);
74057
- const handleMouseEnter = useCallback6(() => {
74519
+ const handleMouseEnter = useCallback7(() => {
74520
+ setIsHovered(true);
74058
74521
  if (closeTimeoutRef.current) {
74059
74522
  clearTimeout(closeTimeoutRef.current);
74060
74523
  closeTimeoutRef.current = null;
@@ -74062,19 +74525,21 @@ function RenownUserButton({
74062
74525
  calculatePosition();
74063
74526
  setIsOpen(true);
74064
74527
  }, [calculatePosition]);
74065
- const handleMouseLeave = useCallback6(() => {
74528
+ const handleMouseLeave = useCallback7(() => {
74066
74529
  closeTimeoutRef.current = setTimeout(() => {
74067
74530
  setIsOpen(false);
74531
+ setIsHovered(false);
74532
+ setHoveredItem(null);
74068
74533
  }, 150);
74069
74534
  }, []);
74070
- useEffect8(() => {
74535
+ useEffect7(() => {
74071
74536
  return () => {
74072
74537
  if (closeTimeoutRef.current) {
74073
74538
  clearTimeout(closeTimeoutRef.current);
74074
74539
  }
74075
74540
  };
74076
74541
  }, []);
74077
- const copyToClipboard = useCallback6(async () => {
74542
+ const copyToClipboard = useCallback7(async () => {
74078
74543
  try {
74079
74544
  await navigator.clipboard.writeText(address);
74080
74545
  setIsCopied(true);
@@ -74083,6 +74548,43 @@ function RenownUserButton({
74083
74548
  console.error("Failed to copy address:", err);
74084
74549
  }
74085
74550
  }, [address]);
74551
+ const triggerElement = asChild ? /* @__PURE__ */ jsxDEV3(Slot, {
74552
+ "data-renown-state": "authenticated",
74553
+ children
74554
+ }, undefined, false, undefined, this) : /* @__PURE__ */ jsxDEV3("button", {
74555
+ type: "button",
74556
+ style: {
74557
+ ...styles2.trigger,
74558
+ ...isHovered ? styles2.triggerHover : {},
74559
+ ...style
74560
+ },
74561
+ "aria-label": "Open account menu",
74562
+ "data-renown-state": "authenticated",
74563
+ children: [
74564
+ avatarUrl ? /* @__PURE__ */ jsxDEV3("img", {
74565
+ src: avatarUrl,
74566
+ alt: "Avatar",
74567
+ style: styles2.avatar
74568
+ }, undefined, false, undefined, this) : /* @__PURE__ */ jsxDEV3("div", {
74569
+ style: styles2.avatarPlaceholder,
74570
+ children: /* @__PURE__ */ jsxDEV3("span", {
74571
+ style: styles2.avatarInitial,
74572
+ children: (displayName || "U")[0].toUpperCase()
74573
+ }, undefined, false, undefined, this)
74574
+ }, undefined, false, undefined, this),
74575
+ /* @__PURE__ */ jsxDEV3("span", {
74576
+ style: styles2.displayName,
74577
+ children: displayName
74578
+ }, undefined, false, undefined, this),
74579
+ /* @__PURE__ */ jsxDEV3(ChevronDownIcon, {
74580
+ size: 14,
74581
+ style: {
74582
+ ...styles2.chevron,
74583
+ ...isOpen ? styles2.chevronOpen : {}
74584
+ }
74585
+ }, undefined, false, undefined, this)
74586
+ ]
74587
+ }, undefined, true, undefined, this);
74086
74588
  return /* @__PURE__ */ jsxDEV3("div", {
74087
74589
  ref: wrapperRef,
74088
74590
  style: styles2.wrapper,
@@ -74090,46 +74592,25 @@ function RenownUserButton({
74090
74592
  onMouseEnter: handleMouseEnter,
74091
74593
  onMouseLeave: handleMouseLeave,
74092
74594
  children: [
74093
- renderTrigger ? renderTrigger({
74094
- onMouseEnter: handleMouseEnter,
74095
- onMouseLeave: handleMouseLeave,
74096
- address,
74097
- username,
74098
- avatarUrl
74099
- }) : /* @__PURE__ */ jsxDEV3("button", {
74100
- type: "button",
74101
- style: { ...styles2.trigger, ...style },
74102
- "aria-label": "Open account menu",
74103
- children: avatarUrl ? /* @__PURE__ */ jsxDEV3("img", {
74104
- src: avatarUrl,
74105
- alt: "Avatar",
74106
- style: styles2.avatar
74107
- }, undefined, false, undefined, this) : /* @__PURE__ */ jsxDEV3("div", {
74108
- style: styles2.avatarPlaceholder,
74109
- children: /* @__PURE__ */ jsxDEV3(UserIcon, {
74110
- size: 24,
74111
- color: "#9ca3af"
74112
- }, undefined, false, undefined, this)
74113
- }, undefined, false, undefined, this)
74114
- }, undefined, false, undefined, this),
74595
+ triggerElement,
74115
74596
  isOpen && /* @__PURE__ */ jsxDEV3("div", {
74116
74597
  style: {
74117
74598
  ...styles2.popoverBase,
74118
- ...showAbove ? { bottom: `calc(100% + ${POPOVER_GAP2}px)` } : { top: `calc(100% + ${POPOVER_GAP2}px)` }
74599
+ ...showAbove ? { bottom: `calc(100% + ${POPOVER_GAP}px)` } : { top: `calc(100% + ${POPOVER_GAP}px)` }
74119
74600
  },
74120
74601
  children: [
74121
74602
  /* @__PURE__ */ jsxDEV3("div", {
74122
- style: styles2.section,
74603
+ style: styles2.header,
74123
74604
  children: [
74124
74605
  username && /* @__PURE__ */ jsxDEV3("div", {
74125
- style: styles2.username,
74606
+ style: styles2.headerUsername,
74126
74607
  children: username
74127
74608
  }, undefined, false, undefined, this),
74128
- /* @__PURE__ */ jsxDEV3("div", {
74609
+ address && /* @__PURE__ */ jsxDEV3("div", {
74129
74610
  style: styles2.addressRow,
74130
74611
  children: /* @__PURE__ */ jsxDEV3("button", {
74131
74612
  type: "button",
74132
- onClick: copyToClipboard,
74613
+ onClick: () => void copyToClipboard(),
74133
74614
  style: styles2.addressButton,
74134
74615
  children: /* @__PURE__ */ jsxDEV3("div", {
74135
74616
  style: {
@@ -74141,20 +74622,26 @@ function RenownUserButton({
74141
74622
  },
74142
74623
  children: [
74143
74624
  /* @__PURE__ */ jsxDEV3("div", {
74144
- style: { ...styles2.addressText, opacity: isCopied ? 0 : 1 },
74625
+ style: {
74626
+ ...styles2.addressText,
74627
+ opacity: isCopied ? 0 : 1
74628
+ },
74145
74629
  children: [
74146
74630
  /* @__PURE__ */ jsxDEV3("span", {
74147
- children: truncateAddress(address)
74631
+ children: truncateAddress2(address)
74148
74632
  }, undefined, false, undefined, this),
74149
74633
  /* @__PURE__ */ jsxDEV3(CopyIcon, {
74150
- size: 14,
74151
- color: "#9EA0A1"
74634
+ size: 12,
74635
+ color: "#9ca3af"
74152
74636
  }, undefined, false, undefined, this)
74153
74637
  ]
74154
74638
  }, undefined, true, undefined, this),
74155
74639
  /* @__PURE__ */ jsxDEV3("div", {
74156
- style: { ...styles2.copiedText, opacity: isCopied ? 1 : 0 },
74157
- children: "Copied to clipboard!"
74640
+ style: {
74641
+ ...styles2.copiedText,
74642
+ opacity: isCopied ? 1 : 0
74643
+ },
74644
+ children: "Copied!"
74158
74645
  }, undefined, false, undefined, this)
74159
74646
  ]
74160
74647
  }, undefined, true, undefined, this)
@@ -74162,35 +74649,64 @@ function RenownUserButton({
74162
74649
  }, undefined, false, undefined, this)
74163
74650
  ]
74164
74651
  }, undefined, true, undefined, this),
74165
- userId && /* @__PURE__ */ jsxDEV3("div", {
74166
- style: styles2.section,
74167
- children: /* @__PURE__ */ jsxDEV3("button", {
74168
- type: "button",
74169
- onClick: () => openRenown(userId),
74170
- style: styles2.menuItem,
74171
- children: [
74172
- /* @__PURE__ */ jsxDEV3(ExternalLinkIcon, {
74173
- size: 14
74174
- }, undefined, false, undefined, this),
74175
- "View on Renown"
74176
- ]
74177
- }, undefined, true, undefined, this)
74652
+ /* @__PURE__ */ jsxDEV3("div", {
74653
+ style: styles2.menuSection,
74654
+ children: [
74655
+ profileId && /* @__PURE__ */ jsxDEV3("button", {
74656
+ type: "button",
74657
+ onClick: () => openRenown(profileId),
74658
+ onMouseEnter: () => setHoveredItem("profile"),
74659
+ onMouseLeave: () => setHoveredItem(null),
74660
+ style: {
74661
+ ...styles2.menuItem,
74662
+ ...hoveredItem === "profile" ? styles2.menuItemHover : {}
74663
+ },
74664
+ children: [
74665
+ /* @__PURE__ */ jsxDEV3(UserIcon, {
74666
+ size: 14,
74667
+ color: "#6b7280"
74668
+ }, undefined, false, undefined, this),
74669
+ "View Profile"
74670
+ ]
74671
+ }, undefined, true, undefined, this),
74672
+ menuItems?.map((item) => /* @__PURE__ */ jsxDEV3("button", {
74673
+ type: "button",
74674
+ onClick: item.onClick,
74675
+ onMouseEnter: () => setHoveredItem(item.label),
74676
+ onMouseLeave: () => setHoveredItem(null),
74677
+ style: {
74678
+ ...styles2.menuItem,
74679
+ ...hoveredItem === item.label ? styles2.menuItemHover : {},
74680
+ ...item.style
74681
+ },
74682
+ children: [
74683
+ item.icon,
74684
+ item.label
74685
+ ]
74686
+ }, item.label, true, undefined, this))
74687
+ ]
74688
+ }, undefined, true, undefined, this),
74689
+ /* @__PURE__ */ jsxDEV3("hr", {
74690
+ style: styles2.separator
74178
74691
  }, undefined, false, undefined, this),
74179
74692
  /* @__PURE__ */ jsxDEV3("div", {
74180
- style: styles2.sectionLast,
74693
+ style: styles2.menuSection,
74181
74694
  children: /* @__PURE__ */ jsxDEV3("button", {
74182
74695
  type: "button",
74183
74696
  onClick: onDisconnect,
74697
+ onMouseEnter: () => setHoveredItem("disconnect"),
74698
+ onMouseLeave: () => setHoveredItem(null),
74184
74699
  style: {
74185
74700
  ...styles2.menuItem,
74186
- ...styles2.disconnectItem
74701
+ ...styles2.disconnectItem,
74702
+ ...hoveredItem === "disconnect" ? styles2.menuItemHover : {}
74187
74703
  },
74188
74704
  children: [
74189
74705
  /* @__PURE__ */ jsxDEV3(DisconnectIcon, {
74190
74706
  size: 14,
74191
- color: "#EA4335"
74707
+ color: "#dc2626"
74192
74708
  }, undefined, false, undefined, this),
74193
- "Disconnect"
74709
+ "Log out"
74194
74710
  ]
74195
74711
  }, undefined, true, undefined, this)
74196
74712
  }, undefined, false, undefined, this)
@@ -74201,23 +74717,23 @@ function RenownUserButton({
74201
74717
  }
74202
74718
  function RenownAuthButton({
74203
74719
  className = "",
74204
- renderAuthenticated,
74205
- renderUnauthenticated,
74206
- renderLoading
74720
+ darkMode,
74721
+ loginContent,
74722
+ userContent,
74723
+ loadingContent,
74724
+ children
74207
74725
  }) {
74208
- const user = useUser();
74209
- const loginStatus = useLoginStatus();
74210
- const isLoading = loginStatus === "checking";
74211
- const openProfile = () => {
74212
- if (!user)
74213
- return;
74214
- openRenown(user.profile?.documentId);
74215
- };
74216
- if (isLoading) {
74217
- if (renderLoading) {
74726
+ const auth = useRenownAuth();
74727
+ if (children) {
74728
+ return /* @__PURE__ */ jsxDEV4(Fragment2, {
74729
+ children: children(auth)
74730
+ }, undefined, false, undefined, this);
74731
+ }
74732
+ if (auth.status === "loading" || auth.status === "checking") {
74733
+ if (loadingContent) {
74218
74734
  return /* @__PURE__ */ jsxDEV4("div", {
74219
74735
  className,
74220
- children: renderLoading()
74736
+ children: loadingContent
74221
74737
  }, undefined, false, undefined, this);
74222
74738
  }
74223
74739
  return /* @__PURE__ */ jsxDEV4("div", {
@@ -74225,24 +74741,44 @@ function RenownAuthButton({
74225
74741
  children: [
74226
74742
  /* @__PURE__ */ jsxDEV4("div", {
74227
74743
  style: {
74228
- width: "40px",
74229
- height: "40px",
74230
- borderRadius: "50%",
74231
- backgroundColor: "#e5e7eb",
74744
+ display: "flex",
74745
+ alignItems: "center",
74746
+ gap: "8px",
74747
+ padding: "6px 12px",
74748
+ borderRadius: "8px",
74749
+ border: "1px solid #e5e7eb",
74232
74750
  animation: "pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite"
74233
- }
74234
- }, undefined, false, undefined, this),
74751
+ },
74752
+ children: [
74753
+ /* @__PURE__ */ jsxDEV4("div", {
74754
+ style: {
74755
+ width: "28px",
74756
+ height: "28px",
74757
+ borderRadius: "50%",
74758
+ backgroundColor: "#e5e7eb"
74759
+ }
74760
+ }, undefined, false, undefined, this),
74761
+ /* @__PURE__ */ jsxDEV4("div", {
74762
+ style: {
74763
+ width: "80px",
74764
+ height: "14px",
74765
+ borderRadius: "4px",
74766
+ backgroundColor: "#e5e7eb"
74767
+ }
74768
+ }, undefined, false, undefined, this)
74769
+ ]
74770
+ }, undefined, true, undefined, this),
74235
74771
  /* @__PURE__ */ jsxDEV4("style", {
74236
74772
  children: `@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }`
74237
74773
  }, undefined, false, undefined, this)
74238
74774
  ]
74239
74775
  }, undefined, true, undefined, this);
74240
74776
  }
74241
- if (loginStatus === "authorized" && user) {
74242
- if (renderAuthenticated) {
74777
+ if (auth.status === "authorized") {
74778
+ if (userContent) {
74243
74779
  return /* @__PURE__ */ jsxDEV4("div", {
74244
74780
  className,
74245
- children: renderAuthenticated({ user, logout, openProfile })
74781
+ children: userContent
74246
74782
  }, undefined, false, undefined, this);
74247
74783
  }
74248
74784
  return /* @__PURE__ */ jsxDEV4("div", {
@@ -74250,54 +74786,52 @@ function RenownAuthButton({
74250
74786
  children: /* @__PURE__ */ jsxDEV4(RenownUserButton, {}, undefined, false, undefined, this)
74251
74787
  }, undefined, false, undefined, this);
74252
74788
  }
74253
- if (renderUnauthenticated) {
74789
+ if (loginContent) {
74254
74790
  return /* @__PURE__ */ jsxDEV4("div", {
74255
74791
  className,
74256
- children: renderUnauthenticated({ openRenown: () => openRenown(), isLoading })
74792
+ children: loginContent
74257
74793
  }, undefined, false, undefined, this);
74258
74794
  }
74259
74795
  return /* @__PURE__ */ jsxDEV4("div", {
74260
74796
  className,
74261
- children: /* @__PURE__ */ jsxDEV4(RenownLoginButton, {}, undefined, false, undefined, this)
74797
+ children: /* @__PURE__ */ jsxDEV4(RenownLoginButton, {
74798
+ darkMode
74799
+ }, undefined, false, undefined, this)
74262
74800
  }, undefined, false, undefined, this);
74263
74801
  }
74264
- function RenownProvider({
74802
+ async function initRenown(appName, namespace2, url) {
74803
+ addRenownEventHandler();
74804
+ setRenown(loading);
74805
+ const builder = new RenownBuilder(appName, {
74806
+ basename: namespace2,
74807
+ baseUrl: url
74808
+ });
74809
+ const renown = await builder.build();
74810
+ setRenown(renown);
74811
+ await login(undefined, renown);
74812
+ return renown;
74813
+ }
74814
+ function useRenownInit({
74265
74815
  appName,
74266
- basename: basename2,
74267
- baseUrl,
74268
- children
74816
+ namespace: namespace2,
74817
+ url
74269
74818
  }) {
74270
- const initRef = useRef7(false);
74271
- const initialPropsRef = useRef7({ appName, basename: basename2, baseUrl });
74819
+ const promiseRef = useRef6(Promise.withResolvers());
74820
+ const initRef = useRef6(false);
74821
+ if (typeof window === "undefined") {
74822
+ promiseRef.current.reject(new Error("window is undefined"));
74823
+ return promiseRef.current.promise;
74824
+ }
74272
74825
  if (initRef.current) {
74273
- const initial = initialPropsRef.current;
74274
- if (appName !== initial.appName) {
74275
- console.warn("RenownProvider: 'appName' changed after mount. This prop is only read once during initialization.");
74276
- }
74277
- if (basename2 !== initial.basename) {
74278
- console.warn("RenownProvider: 'basename' changed after mount. This prop is only read once during initialization.");
74279
- }
74280
- if (baseUrl !== initial.baseUrl) {
74281
- console.warn("RenownProvider: 'baseUrl' changed after mount. This prop is only read once during initialization.");
74282
- }
74826
+ return promiseRef.current.promise;
74283
74827
  }
74284
- useEffect9(() => {
74285
- if (initRef.current)
74286
- return;
74287
- initRef.current = true;
74288
- if (!window.ph) {
74289
- window.ph = {};
74290
- }
74291
- addRenownEventHandler();
74292
- const init4 = async () => {
74293
- const builder = new RenownBuilder(appName, { basename: basename2, baseUrl });
74294
- const instance2 = await builder.build();
74295
- setRenown(instance2);
74296
- await login(undefined, instance2);
74297
- };
74298
- init4().catch(console.error);
74299
- }, []);
74300
- return children;
74828
+ initRef.current = true;
74829
+ initRenown(appName, namespace2, url).then(promiseRef.current.resolve).catch(promiseRef.current.reject);
74830
+ return promiseRef.current.promise;
74831
+ }
74832
+ function Renown2({ onError, ...initOptions }) {
74833
+ useRenownInit(initOptions).catch(onError ?? console.error);
74834
+ return null;
74301
74835
  }
74302
74836
  var __create2, __getProtoOf2, __defProp3, __getOwnPropNames2, __getOwnPropDesc2, __hasOwnProp2, __toESM2 = (mod, isNodeMode, target) => {
74303
74837
  target = mod != null ? __create2(__getProtoOf2(mod)) : {};
@@ -74863,13 +75397,13 @@ ${String(result)}`);
74863
75397
  return t4;
74864
75398
  };
74865
75399
  return __assign.apply(this, arguments);
74866
- }, docCache, fragmentSourceMap, printFragmentWarnings = true, experimentalFragmentVariables = false, extras, PropagationMode2, PhDocumentFieldsFragmentDoc, GetDocumentModelsDocument, GetDocumentDocument, GetDocumentChildrenDocument, GetDocumentParentsDocument, FindDocumentsDocument, GetDocumentOperationsDocument, GetJobStatusDocument, CreateDocumentDocument, CreateEmptyDocumentDocument, MutateDocumentDocument, MutateDocumentAsyncDocument, RenameDocumentDocument, AddChildrenDocument, RemoveChildrenDocument, MoveChildrenDocument, DeleteDocumentDocument, DeleteDocumentsDocument, DocumentChangesDocument, JobChangesDocument, PollSyncEnvelopesDocument, TouchChannelDocument, PushSyncEnvelopesDocument, defaultWrapper = (action, _operationName, _operationType, _variables) => action(), SPLIT_LOWER_UPPER_RE, SPLIT_UPPER_UPPER_RE, SPLIT_SEPARATE_NUMBER_RE, DEFAULT_STRIP_REGEXP, SPLIT_REPLACE_VALUE = "$1\x00$2", DEFAULT_PREFIX_SUFFIX_CHARACTERS = "", isExternalControlsEnabledEventFunctions, setIsExternalControlsEnabled, useIsExternalControlsEnabled, addIsExternalControlsEnabledEventHandler, isDragAndDropEnabledEventFunctions, setIsDragAndDropEnabled, useIsDragAndDropEnabled, addIsDragAndDropEnabledEventHandler, allowedDocumentTypesEventFunctions, setAllowedDocumentTypes, addAllowedDocumentTypesEventHandler, phDriveEditorConfigSetters, phDocumentEditorConfigSetters, phDriveEditorConfigHooks, phDocumentEditorConfigHooks, vetraPackageManagerFunctions, useVetraPackageManager, useVetraPackages = () => {
75400
+ }, docCache, fragmentSourceMap, printFragmentWarnings = true, experimentalFragmentVariables = false, extras, PropagationMode2, PhDocumentFieldsFragmentDoc, GetDocumentModelsDocument, GetDocumentDocument, GetDocumentChildrenDocument, GetDocumentParentsDocument, FindDocumentsDocument, GetDocumentOperationsDocument, GetJobStatusDocument, CreateDocumentDocument, CreateEmptyDocumentDocument, MutateDocumentDocument, MutateDocumentAsyncDocument, RenameDocumentDocument, AddChildrenDocument, RemoveChildrenDocument, MoveChildrenDocument, DeleteDocumentDocument, DeleteDocumentsDocument, DocumentChangesDocument, JobChangesDocument, PollSyncEnvelopesDocument, TouchChannelDocument, PushSyncEnvelopesDocument, defaultWrapper = (action, _operationName, _operationType, _variables) => action(), SPLIT_LOWER_UPPER_RE, SPLIT_UPPER_UPPER_RE, SPLIT_SEPARATE_NUMBER_RE, DEFAULT_STRIP_REGEXP, SPLIT_REPLACE_VALUE = "$1\x00$2", DEFAULT_PREFIX_SUFFIX_CHARACTERS = "", isServer, useLoading, setLoading, addLoadingEventHandler, loading = null, renownEventFunctions, addRenownEventHandler, useRenown, setRenown, RENOWN_URL = "https://www.renown.id", RENOWN_NETWORK_ID = "eip155", RENOWN_CHAIN_ID = "1", DOMAIN_TYPE, VERIFIABLE_CREDENTIAL_EIP712_TYPE, CREDENTIAL_SCHEMA_EIP712_TYPE, CREDENTIAL_SUBJECT_TYPE, ISSUER_TYPE, CREDENTIAL_TYPES, isExternalControlsEnabledEventFunctions, setIsExternalControlsEnabled, useIsExternalControlsEnabled, addIsExternalControlsEnabledEventHandler, isDragAndDropEnabledEventFunctions, setIsDragAndDropEnabled, useIsDragAndDropEnabled, addIsDragAndDropEnabledEventHandler, allowedDocumentTypesEventFunctions, setAllowedDocumentTypes, addAllowedDocumentTypesEventHandler, phDriveEditorConfigSetters, phDocumentEditorConfigSetters, phDriveEditorConfigHooks, phDocumentEditorConfigHooks, vetraPackageManagerFunctions, useVetraPackageManager, useVetraPackages = () => {
74867
75401
  const packageManager = useVetraPackageManager();
74868
- return useSyncExternalStore22((cb) => packageManager ? packageManager.subscribe(cb) : () => {}, () => packageManager?.packages ?? []);
74869
- }, addVetraPackageManagerEventHandler, reactorClientModuleEventFunctions, reactorClientEventFunctions, useReactorClientModule, setReactorClientModule, addReactorClientModuleEventHandler, useReactorClient, setReactorClient, addReactorClientEventHandler, useSync = () => useReactorClientModule()?.reactorModule?.syncModule?.syncManager, useSyncList = () => {
75402
+ return useSyncExternalStore32((cb) => packageManager ? packageManager.subscribe(cb) : () => {}, () => packageManager?.packages ?? []);
75403
+ }, addVetraPackageManagerEventHandler, EMPTY_PENDING, EMPTY_DISMISSED, NOOP_UNSUBSCRIBE = () => {}, documentEventFunctions, useDocumentCache, setDocumentCache, addDocumentCacheEventHandler, base64, locales, defaultLocale, initialMulticharmap, initialCharmap, slug_default, drivesEventFunctions, useDrives, setDrives, addDrivesEventHandler, selectedDriveIdEventFunctions, useSelectedDriveId, setSelectedDriveId, addSelectedDriveIdEventHandler, selectedNodeIdEventFunctions, useSelectedNodeId, setSelectedNodeId, addSelectedNodeIdEventHandler, useRouterBasename, setRouterBasename, addRouterBasenameEventHandler, useVersion, setVersion, addVersionEventHandler, useRequiresHardRefresh, setRequiresHardRefresh, addRequiresHardRefreshEventHandler, useWarnOutdatedApp, setWarnOutdatedApp, addWarnOutdatedAppEventHandler, useStudioMode, setStudioMode, addStudioModeEventHandler, useBasePath, setBasePath, addBasePathEventHandler, useVersionCheckInterval, setVersionCheckInterval, addVersionCheckIntervalEventHandler, useCliVersion, setCliVersion, addCliVersionEventHandler, useFileUploadOperationsChunkSize, setFileUploadOperationsChunkSize, addFileUploadOperationsChunkSizeEventHandler, useIsDocumentModelSelectionSettingsEnabled, setIsDocumentModelSelectionSettingsEnabled, addIsDocumentModelSelectionSettingsEnabledEventHandler, useGaTrackingId, setGaTrackingId, addGaTrackingIdEventHandler, useDefaultDrivesUrl, setDefaultDrivesUrl, addDefaultDrivesUrlEventHandler, useDrivesPreserveStrategy, setDrivesPreserveStrategy, addDrivesPreserveStrategyEventHandler, useIsLocalDrivesEnabled, setIsLocalDrivesEnabled, addIsLocalDrivesEnabledEventHandler, useIsAddDriveEnabled, setIsAddDriveEnabled, addIsAddDriveEnabledEventHandler, useIsPublicDrivesEnabled, setIsPublicDrivesEnabled, addIsPublicDrivesEnabledEventHandler, useIsAddPublicDrivesEnabled, setIsAddPublicDrivesEnabled, addIsAddPublicDrivesEnabledEventHandler, useIsDeletePublicDrivesEnabled, setIsDeletePublicDrivesEnabled, addIsDeletePublicDrivesEnabledEventHandler, useIsCloudDrivesEnabled, setIsCloudDrivesEnabled, addIsCloudDrivesEnabledEventHandler, useIsAddCloudDrivesEnabled, setIsAddCloudDrivesEnabled, addIsAddCloudDrivesEnabledEventHandler, useIsDeleteCloudDrivesEnabled, setIsDeleteCloudDrivesEnabled, addIsDeleteCloudDrivesEnabledEventHandler, useLocalDrivesEnabled, setLocalDrivesEnabled, addLocalDrivesEnabledEventHandler, useIsAddLocalDrivesEnabled, setIsAddLocalDrivesEnabled, addIsAddLocalDrivesEnabledEventHandler, useIsDeleteLocalDrivesEnabled, setIsDeleteLocalDrivesEnabled, addIsDeleteLocalDrivesEnabledEventHandler, useIsEditorDebugModeEnabled, setIsEditorDebugModeEnabled, addIsEditorDebugModeEnabledEventHandler, useIsEditorReadModeEnabled, setIsEditorReadModeEnabled, addIsEditorReadModeEnabledEventHandler, useIsAnalyticsDatabaseWorkerEnabled, setIsAnalyticsDatabaseWorkerEnabled, addIsAnalyticsDatabaseWorkerEnabledEventHandler, useIsDiffAnalyticsEnabled, setIsDiffAnalyticsEnabled, addIsDiffAnalyticsEnabledEventHandler, useIsDriveAnalyticsEnabled, setIsDriveAnalyticsEnabled, addIsDriveAnalyticsEnabledEventHandler, useRenownUrl, setRenownUrl, addRenownUrlEventHandler, useRenownNetworkId, setRenownNetworkId, addRenownNetworkIdEventHandler, useRenownChainId, setRenownChainId, addRenownChainIdEventHandler, useSentryRelease, setSentryRelease, addSentryReleaseEventHandler, useSentryDsn, setSentryDsn, addSentryDsnEventHandler, useSentryEnv, setSentryEnv, addSentryEnvEventHandler, useIsSentryTracingEnabled, setIsSentryTracingEnabled, addIsSentryTracingEnabledEventHandler, useIsExternalProcessorsEnabled, setIsExternalProcessorsEnabled, addIsExternalProcessorsEnabledEventHandler, useIsExternalPackagesEnabled, setIsExternalPackagesEnabled, addIsExternalPackagesEnabledEventHandler, enabledEditorsEventFunctions, setEnabledEditors, useEnabledEditors, addEnabledEditorsEventHandler, disabledEditorsEventFunctions, setDisabledEditors, useDisabledEditors, addDisabledEditorsEventHandler, isRelationalProcessorsEnabled, setIsRelationalProcessorsEnabled, useIsRelationalProcessorsEnabled, addIsRelationalProcessorsEnabledEventHandler, isExternalRelationalProcessorsEnabled, setIsExternalRelationalProcessorsEnabled, useIsExternalRelationalProcessorsEnabled, addIsExternalRelationalProcessorsEnabledEventHandler, isAnalyticsEnabledEventFunctions, setIsAnalyticsEnabled, useIsAnalyticsEnabled, addIsAnalyticsEnabledEventHandler, isAnalyticsExternalProcessorsEnabled, setIsAnalyticsExternalProcessorsEnabled, useIsAnalyticsExternalProcessorsEnabled, addIsAnalyticsExternalProcessorsEnabledEventHandler, analyticsDatabaseNameEventFunctions, setAnalyticsDatabaseName, useAnalyticsDatabaseName, addAnalyticsDatabaseNameEventHandler, logLevelEventFunctions, setLogLevel2, useLogLevel, addLogLevelEventHandler, allowListEventFunctions, setAllowList, useAllowList, addAllowListEventHandler, nonUserConfigSetters, phGlobalConfigSetters, nonUserConfigHooks, phGlobalConfigHooks, reactorClientModuleEventFunctions, reactorClientEventFunctions, useReactorClientModule, setReactorClientModule, addReactorClientModuleEventHandler, useReactorClient, setReactorClient, addReactorClientEventHandler, useSync = () => useReactorClientModule()?.reactorModule?.syncModule?.syncManager, useSyncList = () => {
74870
75404
  const sync = useSync();
74871
75405
  return sync?.list() ?? [];
74872
- }, documentEventFunctions, useDocumentCache, setDocumentCache, addDocumentCacheEventHandler, base64, locales, defaultLocale, initialMulticharmap, initialCharmap, slug_default, drivesEventFunctions, useDrives, setDrives, addDrivesEventHandler, selectedDriveIdEventFunctions, useSelectedDriveId, setSelectedDriveId, addSelectedDriveIdEventHandler, selectedNodeIdEventFunctions, useSelectedNodeId, setSelectedNodeId, addSelectedNodeIdEventHandler, useRouterBasename, setRouterBasename, addRouterBasenameEventHandler, useVersion, setVersion, addVersionEventHandler, useRequiresHardRefresh, setRequiresHardRefresh, addRequiresHardRefreshEventHandler, useWarnOutdatedApp, setWarnOutdatedApp, addWarnOutdatedAppEventHandler, useStudioMode, setStudioMode, addStudioModeEventHandler, useBasePath, setBasePath, addBasePathEventHandler, useVersionCheckInterval, setVersionCheckInterval, addVersionCheckIntervalEventHandler, useCliVersion, setCliVersion, addCliVersionEventHandler, useFileUploadOperationsChunkSize, setFileUploadOperationsChunkSize, addFileUploadOperationsChunkSizeEventHandler, useIsDocumentModelSelectionSettingsEnabled, setIsDocumentModelSelectionSettingsEnabled, addIsDocumentModelSelectionSettingsEnabledEventHandler, useGaTrackingId, setGaTrackingId, addGaTrackingIdEventHandler, useDefaultDrivesUrl, setDefaultDrivesUrl, addDefaultDrivesUrlEventHandler, useDrivesPreserveStrategy, setDrivesPreserveStrategy, addDrivesPreserveStrategyEventHandler, useIsLocalDrivesEnabled, setIsLocalDrivesEnabled, addIsLocalDrivesEnabledEventHandler, useIsAddDriveEnabled, setIsAddDriveEnabled, addIsAddDriveEnabledEventHandler, useIsPublicDrivesEnabled, setIsPublicDrivesEnabled, addIsPublicDrivesEnabledEventHandler, useIsAddPublicDrivesEnabled, setIsAddPublicDrivesEnabled, addIsAddPublicDrivesEnabledEventHandler, useIsDeletePublicDrivesEnabled, setIsDeletePublicDrivesEnabled, addIsDeletePublicDrivesEnabledEventHandler, useIsCloudDrivesEnabled, setIsCloudDrivesEnabled, addIsCloudDrivesEnabledEventHandler, useIsAddCloudDrivesEnabled, setIsAddCloudDrivesEnabled, addIsAddCloudDrivesEnabledEventHandler, useIsDeleteCloudDrivesEnabled, setIsDeleteCloudDrivesEnabled, addIsDeleteCloudDrivesEnabledEventHandler, useLocalDrivesEnabled, setLocalDrivesEnabled, addLocalDrivesEnabledEventHandler, useIsAddLocalDrivesEnabled, setIsAddLocalDrivesEnabled, addIsAddLocalDrivesEnabledEventHandler, useIsDeleteLocalDrivesEnabled, setIsDeleteLocalDrivesEnabled, addIsDeleteLocalDrivesEnabledEventHandler, useIsEditorDebugModeEnabled, setIsEditorDebugModeEnabled, addIsEditorDebugModeEnabledEventHandler, useIsEditorReadModeEnabled, setIsEditorReadModeEnabled, addIsEditorReadModeEnabledEventHandler, useIsAnalyticsDatabaseWorkerEnabled, setIsAnalyticsDatabaseWorkerEnabled, addIsAnalyticsDatabaseWorkerEnabledEventHandler, useIsDiffAnalyticsEnabled, setIsDiffAnalyticsEnabled, addIsDiffAnalyticsEnabledEventHandler, useIsDriveAnalyticsEnabled, setIsDriveAnalyticsEnabled, addIsDriveAnalyticsEnabledEventHandler, useRenownUrl, setRenownUrl, addRenownUrlEventHandler, useRenownNetworkId, setRenownNetworkId, addRenownNetworkIdEventHandler, useRenownChainId, setRenownChainId, addRenownChainIdEventHandler, useSentryRelease, setSentryRelease, addSentryReleaseEventHandler, useSentryDsn, setSentryDsn, addSentryDsnEventHandler, useSentryEnv, setSentryEnv, addSentryEnvEventHandler, useIsSentryTracingEnabled, setIsSentryTracingEnabled, addIsSentryTracingEnabledEventHandler, useIsExternalProcessorsEnabled, setIsExternalProcessorsEnabled, addIsExternalProcessorsEnabledEventHandler, useIsExternalPackagesEnabled, setIsExternalPackagesEnabled, addIsExternalPackagesEnabledEventHandler, enabledEditorsEventFunctions, setEnabledEditors, useEnabledEditors, addEnabledEditorsEventHandler, disabledEditorsEventFunctions, setDisabledEditors, useDisabledEditors, addDisabledEditorsEventHandler, isRelationalProcessorsEnabled, setIsRelationalProcessorsEnabled, useIsRelationalProcessorsEnabled, addIsRelationalProcessorsEnabledEventHandler, isExternalRelationalProcessorsEnabled, setIsExternalRelationalProcessorsEnabled, useIsExternalRelationalProcessorsEnabled, addIsExternalRelationalProcessorsEnabledEventHandler, isAnalyticsEnabledEventFunctions, setIsAnalyticsEnabled, useIsAnalyticsEnabled, addIsAnalyticsEnabledEventHandler, isAnalyticsExternalProcessorsEnabled, setIsAnalyticsExternalProcessorsEnabled, useIsAnalyticsExternalProcessorsEnabled, addIsAnalyticsExternalProcessorsEnabledEventHandler, analyticsDatabaseNameEventFunctions, setAnalyticsDatabaseName, useAnalyticsDatabaseName, addAnalyticsDatabaseNameEventHandler, logLevelEventFunctions, setLogLevel2, useLogLevel, addLogLevelEventHandler, allowListEventFunctions, setAllowList, useAllowList, addAllowListEventHandler, nonUserConfigSetters, phGlobalConfigSetters, nonUserConfigHooks, phGlobalConfigHooks, featuresEventFunctions, useFeatures, setFeatures, addFeaturesEventHandler, modalEventFunctions, usePHModal, setPHModal, addModalEventHandler, revisionHistoryEventFunctions, useRevisionHistoryVisible, setRevisionHistoryVisible, addRevisionHistoryVisibleEventHandler, selectedTimelineItemEventFunctions, useSelectedTimelineItem, setSelectedTimelineItem, addSelectedTimelineItemEventHandler, selectedTimelineRevisionEventFunctions, useSelectedTimelineRevision, setSelectedTimelineRevision, addSelectedTimelineRevisionEventHandler, toastEventFunctions, usePHToast, setPHToast, addToastEventHandler, FEATURE_INSPECTOR_ENABLED = "FEATURE_INSPECTOR_ENABLED", FEATURE_INSPECTOR_ENABLED_DEFAULT = false, syncStatusToUI, validateDocument = (document2) => {
75406
+ }, featuresEventFunctions, useFeatures, setFeatures, addFeaturesEventHandler, modalEventFunctions, usePHModal, setPHModal, addModalEventHandler, revisionHistoryEventFunctions, useRevisionHistoryVisible, setRevisionHistoryVisible, addRevisionHistoryVisibleEventHandler, selectedTimelineItemEventFunctions, useSelectedTimelineItem, setSelectedTimelineItem, addSelectedTimelineItemEventHandler, selectedTimelineRevisionEventFunctions, useSelectedTimelineRevision, setSelectedTimelineRevision, addSelectedTimelineRevisionEventHandler, toastEventFunctions, usePHToast, setPHToast, addToastEventHandler, FEATURE_INSPECTOR_ENABLED = "FEATURE_INSPECTOR_ENABLED", FEATURE_INSPECTOR_ENABLED_DEFAULT = false, syncStatusToUI, validateDocument = (document2) => {
74873
75407
  const errors2 = [];
74874
75408
  if (document2.header.documentType !== "powerhouse/document-model") {
74875
75409
  return errors2;
@@ -74921,7 +75455,7 @@ ${String(result)}`);
74921
75455
  return operationDate >= startDate && operationDate <= endDate;
74922
75456
  });
74923
75457
  return operation ? operation.index : 0;
74924
- }, lzString, RENOWN_URL = "https://www.renown.id", RENOWN_NETWORK_ID = "eip155", RENOWN_CHAIN_ID = "1", DOMAIN_TYPE, VERIFIABLE_CREDENTIAL_EIP712_TYPE, CREDENTIAL_SCHEMA_EIP712_TYPE, CREDENTIAL_SUBJECT_TYPE, ISSUER_TYPE, CREDENTIAL_TYPES, useLoading, setLoading, addLoadingEventHandler, renownEventFunctions, useRenown, setRenown, addRenownEventHandler, useOnDropFile = (documentTypesOverride) => {
75458
+ }, lzString, useOnDropFile = (documentTypesOverride) => {
74925
75459
  const selectedDriveId = useSelectedDriveId();
74926
75460
  const selectedFolder = useSelectedFolder();
74927
75461
  const documentTypes = useDocumentTypes();
@@ -74935,7 +75469,7 @@ ${String(result)}`);
74935
75469
  return await addFileWithProgress(file, selectedDriveId, fileName, targetNodeId, onProgress, documentTypesOverride ?? documentTypes, resolveConflict);
74936
75470
  };
74937
75471
  return onDropFile;
74938
- }, store, BrowserLocalStorage, PGLITE_UPDATE_EVENT = "ph:pglite-update", defaultPGliteState, usePGliteDB = () => {
75472
+ }, store, BrowserLocalStorage, DISMISSED_STORAGE_KEY = "ph-connect-dismissed-packages", PGLITE_UPDATE_EVENT = "ph:pglite-update", defaultPGliteState, usePGliteDB = () => {
74939
75473
  const [state, setState] = useState5(() => window.powerhouse?.pglite ?? defaultPGliteState);
74940
75474
  useEffect5(() => {
74941
75475
  const handlePgliteUpdate = () => setState(window.powerhouse?.pglite ?? defaultPGliteState);
@@ -74961,7 +75495,7 @@ ${String(result)}`);
74961
75495
  const pglite = usePGliteDB();
74962
75496
  const setPGlite = useSetPGliteDB();
74963
75497
  return [pglite, setPGlite];
74964
- }, DEFAULT_RENOWN_URL = "https://www.renown.id", crypto2, isLE, swap32IfBE, hasHexBuiltin, hexes, asciis, HashMD, SHA256_IV, SHA384_IV, SHA512_IV, U32_MASK64, _32n, shrSH = (h2, _l, s3) => h2 >>> s3, shrSL = (h2, l2, s3) => h2 << 32 - s3 | l2 >>> s3, rotrSH = (h2, l2, s3) => h2 >>> s3 | l2 << 32 - s3, rotrSL = (h2, l2, s3) => h2 << 32 - s3 | l2 >>> s3, rotrBH = (h2, l2, s3) => h2 << 64 - s3 | l2 >>> s3 - 32, rotrBL = (h2, l2, s3) => h2 >>> s3 - 32 | l2 << 64 - s3, rotlSH = (h2, l2, s3) => h2 << s3 | l2 >>> 32 - s3, rotlSL = (h2, l2, s3) => l2 << s3 | h2 >>> 32 - s3, rotlBH = (h2, l2, s3) => l2 << s3 - 32 | h2 >>> 64 - s3, rotlBL = (h2, l2, s3) => h2 << s3 - 32 | l2 >>> 64 - s3, add3L = (Al, Bl, Cl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0), add3H = (low, Ah, Bh, Ch) => Ah + Bh + Ch + (low / 4294967296 | 0) | 0, add4L = (Al, Bl, Cl, Dl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0), add4H = (low, Ah, Bh, Ch, Dh) => Ah + Bh + Ch + Dh + (low / 4294967296 | 0) | 0, add5L = (Al, Bl, Cl, Dl, El) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0), add5H = (low, Ah, Bh, Ch, Dh, Eh) => Ah + Bh + Ch + Dh + Eh + (low / 4294967296 | 0) | 0, SHA256_K, SHA256_W, SHA256, K512, SHA512_Kh, SHA512_Kl, SHA512_W_H, SHA512_W_L, SHA512, SHA384, sha2562, sha5122, sha384, _0n, _1n, isPosBig = (n5) => typeof n5 === "bigint" && _0n <= n5, bitMask = (n5) => (_1n << BigInt(n5)) - _1n, notImplemented = () => {
75498
+ }, DEFAULT_RENOWN_URL = "https://www.renown.id", crypto2, isLE, swap32IfBE, hasHexBuiltin, hexes, asciis, HashMD, SHA256_IV, SHA384_IV, SHA512_IV, U32_MASK64, _32n, shrSH = (h2, _l, s3) => h2 >>> s3, shrSL = (h2, l2, s3) => h2 << 32 - s3 | l2 >>> s3, rotrSH = (h2, l2, s3) => h2 >>> s3 | l2 << 32 - s3, rotrSL = (h2, l2, s3) => h2 << 32 - s3 | l2 >>> s3, rotrBH = (h2, l2, s3) => h2 << 64 - s3 | l2 >>> s3 - 32, rotrBL = (h2, l2, s3) => h2 >>> s3 - 32 | l2 << 64 - s3, rotlSH = (h2, l2, s3) => h2 << s3 | l2 >>> 32 - s3, rotlSL = (h2, l2, s3) => l2 << s3 | h2 >>> 32 - s3, rotlBH = (h2, l2, s3) => l2 << s3 - 32 | h2 >>> 64 - s3, rotlBL = (h2, l2, s3) => h2 << s3 - 32 | l2 >>> 64 - s3, add3L = (Al, Bl, Cl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0), add3H = (low, Ah, Bh, Ch) => Ah + Bh + Ch + (low / 2 ** 32 | 0) | 0, add4L = (Al, Bl, Cl, Dl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0), add4H = (low, Ah, Bh, Ch, Dh) => Ah + Bh + Ch + Dh + (low / 2 ** 32 | 0) | 0, add5L = (Al, Bl, Cl, Dl, El) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0), add5H = (low, Ah, Bh, Ch, Dh, Eh) => Ah + Bh + Ch + Dh + Eh + (low / 2 ** 32 | 0) | 0, SHA256_K, SHA256_W, SHA256, K512, SHA512_Kh, SHA512_Kl, SHA512_W_H, SHA512_W_L, SHA512, SHA384, sha2562, sha5122, sha384, _0n, _1n, isPosBig = (n5) => typeof n5 === "bigint" && _0n <= n5, bitMask = (n5) => (_1n << BigInt(n5)) - _1n, notImplemented = () => {
74965
75499
  throw new Error("not implemented");
74966
75500
  }, _0n2, _1n2, _2n, _3n, _4n, _5n, _7n, _8n, _9n, _16n, isNegativeLE = (num, modulo) => (mod(num, modulo) & _1n2) === _1n2, FIELD_FIELDS, _0n3, _1n3, pointPrecomputes, pointWindowSizes, _0n4, _1n4, _2n2, _8n2, _0n5, _1n5, _2n3, _3n2, _5n2, _8n3, ed25519_CURVE_p, ed25519_CURVE, ED25519_SQRT_M1, Fp, Fn, ed25519Defaults, ed25519, SQRT_M1, SQRT_AD_MINUS_ONE, INVSQRT_A_MINUS_D, ONE_MINUS_D_SQ, D_MINUS_ONE_SQ, invertSqrt = (number) => uvRatio(_1n5, number), MAX_255B, bytes255ToNumberLE = (bytes) => ed25519.Point.Fp.create(bytesToNumberLE(bytes) & MAX_255B), _RistrettoPoint, import_multibase, HMAC, hmac = (hash, key, message) => new HMAC(hash, key).update(message).digest(), divNearest = (num, den) => (num + (num >= 0 ? den : -den) / _2n4) / den, DERErr, DER, _0n6, _1n6, _2n4, _3n3, _4n2, secp256k1_CURVE, secp256k1_ENDO, _2n5, Fpk1, secp256k1, p256_CURVE, p384_CURVE, p521_CURVE, Fp256, Fp384, Fp521, p256, p384, p521, p2562, sha2563, Rho160, Id160, Pi160, idxLR, idxL, idxR, shifts160, shiftsL160, shiftsR160, Kl160, Kr160, BUF_160, RIPEMD160, ripemd160, ripemd1602, _0n7, _1n7, _2n6, _7n2, _256n, _0x71n, SHA3_PI, SHA3_ROTL, _SHA3_IOTA, IOTAS, SHA3_IOTA_H, SHA3_IOTA_L, rotlH = (h2, l2, s3) => s3 > 32 ? rotlBH(h2, l2, s3) : rotlSH(h2, l2, s3), rotlL = (h2, l2, s3) => s3 > 32 ? rotlBL(h2, l2, s3) : rotlSL(h2, l2, s3), Keccak, gen = (suffix, blockLen, outputLen) => createHasher(() => new Keccak(blockLen, suffix, outputLen)), keccak_256, import_canonicalize, PCT_ENCODED = "(?:%[0-9a-fA-F]{2})", ID_CHAR, METHOD = "([a-z0-9]+)", METHOD_ID, PARAM_CHAR = "[a-zA-Z0-9_.:%-]", PARAM, PARAMS, PATH = `(/[^#?]*)?`, QUERY = `([?][^#]*)?`, FRAGMENT = `(#.*)?`, DID_MATCHER, EMPTY_RESULT, gcd = (a3, b2) => b2 === 0 ? a3 : gcd(b2, a3 % b2), radix2carry = (from3, to) => from3 + (to - gcd(from3, to)), powers, base162, base322, base32nopad, base32hex2, base32hexnopad, base32crockford, hasBase64Builtin, decodeBase64Builtin = (s3, isUrl) => {
74967
75501
  astr("base64", s3);
@@ -75736,7 +76270,7 @@ ${String(result)}`);
75736
76270
  }, MAX_RETRIES = 5, RETRY_DELAY = 200, isRelationNotExistError = (error3) => {
75737
76271
  const errorMessage = error3 instanceof Error ? error3.message : typeof error3 === "string" ? error3 : String(error3);
75738
76272
  return errorMessage.toLowerCase().includes("relation") && errorMessage.toLowerCase().includes("does not exist");
75739
- }, import_lodash, ConflictError, renownShortDataUrl = "data:image/png;base64,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", renownShortHoverDataUrl = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJAAAACQCAYAAADnRuK4AAAACXBIWXMAACxLAAAsSwGlPZapAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAA+WSURBVHgB7Z1rkBTVFYDP7ZnZZdg3oIIPWDQoahTUSCUaRGOq1JiQ5UfEKEqsWCZRK5r4I5HEAsqKoNFiLZ9J+SQPE/0BpmLKIqlSUxoNJgoFCSCmBFYWsqDM7uzuzM709/We24/p7unZnefuTvf5rKZnem7PWttfnXPuo3sZVAHOeXtyKN2lKGwBB+gU7xcycQwYawdiUiCuyz7GxAZsm67z7bEIvB6Px/dBhTAoE5RmMJ2+Q/yfXSo3og5h28R1fLgSmUoWyBZH43dShAkOQoTnIgqsLVWkkgRKplKrSZyAo8Calnh8bbHNixIolUp1ajrbxIEvLNRG1D+A/0WExor5rYyVnSGJKiKyhtzrYqfruthzsecF24urtk9cxsuKiUZjXuHBVGYl19Ruv6iDfkSViJCGkSx1BjclymoacF+XWIIDu6m1qXHzaN8z6lVPDo2sFs6uyTsJxYlExKYAUf9oml5YpDFSWkGBCsmD0uBGESdYYETKqjpoIsXlMYpEvhYMDI10MdA3eY/HohR1go6qGtHIC1Mi32mONzyfd9x7AAtmVePvO2seDDYN0agslIngg9FoJKt6UhpLRBV+nrewzgsnIh2+5i2YG2MkT5jA8gQDhhveroqeuLetSyCse3AqwnkM0xbVO+EDA0ZMdJTc8IXJoaE1ziO2GTJ16fCR88OIokBDLAJEeMHCWnXVRCyhZhrndnSwBL6zI5BIXaudJ2LQiUWpYA470agC7gTE26MNw3da7+RHftGHelyERX7PLBeFpCFZzT2bbgwUkjyEwWhRSFoiiuQ7XCdEqO4h3EQUjxNMWSJ3fulrSkOUel6ECxwSSo9kXcfUzJQOxZu+5Kw6yUN4QCO8Y4GxWLpLHHIv0VBIHqIAXjdweY+ogdgCVyOFimfCH68bnEGngv+4GlEAIgrgdUP0zRbgsU73YTKIKEBeCmPtyhhtCMImXw3eTgXPOHGd+h4sUd+CXTwJQYIEGgf+qh2Fd9QE9Ggj8Iz2MQSJKBA1Z4t6VER7UXKK0bi/wdFA/dYpAtWYAa7CluynALoYcRNbv6rBP7UEBAUSqMZsyX4CA3jHg2oIhFt3Zj8EBRKoxjyT7jXEESkMoxBu72T7ZWQKAiRQDXlbiPKfTEoIpJgpTJEioVDPjByEIEAC1ZDuQdHjsuTRcAO5x2PPpg8HIgqRQDXipeGj8HZ60CWNtWEESmgqdKd6oN4hgWrEhoFehzi5Ahoc29NDh2Q9VM+QQDVgQ+IQHBjJmMUzs2sgK/pwTTHqIfF6w2B9DyySQFWmRx2Bh44dMoTBnpdmSmPJ44pCCrw9kpSRqF4hgarIgK7Btz7+0CUKx2cVmHuZ0kyhwBGV1g4cECINQD1CAlWRO3t7ROpSpSQyXalW+lLMYyxXD2kOycTruxIfybmyeoMEqhIPHemDVweStiB2CjMFweV7UirukAjfa0a7nkwGlh/ZXXddexKoCjz4/z548PARs2A2hNFdBbN4rzkjjymOZoxQG701BgcyWbimb4+QSIN6gQSqkAcPHRXbJ7nBQt2KNka9Y0UecKQru0fGDYmcUWtnOgXXHN4j66l6gCWHUq6nwMQbY0AUxz09ffDrvk+NVZy4VsPcy5V7ivlrlcd5ro38DP8Rx6y9dM5sA0b7U2IN8OLM0+GUaCNMJlKee8NIoDIYUHVYubcX3koOi4vuEMcpife4KQwH47jzPNlcCmd9ZgiFEr00a96kkogEqpC3+lPww//1QQ/+Ipl/9PCKY0UcSw5ndMpJ5/jcKZfY7uqYBT8W22SABCoTjDr37z8Gv+rtt6OHLY8tiRFZuJ3GwJbDEAdkW26nNeaQJ9cGnFEKjOh0VmMcnj7hVBmVJhISqAye7BmAB/YlYEDT3VGjQNSxxJISOCJQvnBWHQR2tJEvFff3Mkc0uqZ1moxGEyUSCVQk/VkOLxwahCcPJEW6MsZmMBJwcNc6Vl3jvMiWWMyvNlIKFNSuVGaK441GZptTYjH40tTmCRGJBBqDNz8Zgb/0peGF3mEhkeaOJo49/tLyC2hwRRLfaKW4o1LeuY7eWd53y/NMcc3PrmhuheWt0+GKpjYYD0igAhwY1uDr//gUetJq3sXmnp6UxFPoWhfZ1d5uA+6imrlrHPlzmDu65RfnZkRy1lSO/4dWJQLdM2fXXCSvQHRbj8mOfhUODOnmVTILXM7lOCBeLaN2YcYfLrGlsCKB8bkhHZM7Lj9jDsmMZ+yAfRy/29gz3frM/B67uDZmQ/AkmT41cP1s44cbP3NAzNa+Otg/bpHIggQy+fKMBrh4WgO8eTQjLzB3XiSzx8SdkYA7JLCEkxfZEMDojUHuYgPYUYp7BOSmZ9wll3ECk395gBuj1nbkYnZalQipW6NR+G7bcTDeUArzgKnszSMZWL97GPan1NyzAvzSil2PcFekYc5C2lPrcCtFgU968/0Z3rQIdhpri0VgeUc7XNnaAhc1NcF4QDVQCbxyaASe+HBYRKWsKUvuInKfYjdX1xTupvuNVjOHdIYoOTG5TyHdFmVwywnT4JbjpkPrOD8MlQQqg9/vT8O6XUNwIKX5CJCTxB5E9Ba+wH2Fy4tcfgOSjqiD4nxvZoeUp3WCnqJLAlXA+l3DUiRvL4g5I4ctF7gjjs/4kGtIQHF8l2dcCV9fNW0qPHLaTFHrTOwCChKoQrBGuvqNhNjrkDdSnDd243gP7vfeWsk7lWFJiVHnF6fNgGuPb4HJAAlUJX66fQge35vK1TyWSL7LOAB8U5c9Qw929Mr1yjjMnhqBlxeI0eYpk6ezTONAVWL9giYZHdb9NwW2CJzb3Xt7fAhyXW97PMg5NKBZx3Lt8VmWF02bAr855zjxMyb3mj8SqALuPnsq4NVft3NYvjciifGPazSae8aErLEcR1c+JxiDa2dOhUfPngb1wIQLdLC39vdEnXRi7dbS3H12XP5lv/U704Cjftyuh3JCMJdQzE5lRvHMbMGw3bdPjgt5OqBemPAa6MxzvwjjCcp00kmzoKWlBeafMQ8WfeF8WHTh+VAp9+0QXf2dZjrzFNCuea+8mfZc+3PaovD3xeM/mlwKk66IHm+BCoESdS29GpZ982ool5/8KwWP70mDe4Q5N2EKPpOlVv00e6oCf754miycJzMk0BhghEKJbvvBzVAq/RkOV20ZhB0JHZxjP97lG66uv9kb23Hl9EkvD+IVaHKX+BMA1mSPPvEUfPXKZbDp5VdKOretgcELlzbJwT77HjDNfQOh92kdeHzdOS11IY8fJFABUKRV99wLjwmZSmFOswKrzm20739n3H1PWO6+eON258UzGuDWeXGoV0igMcBohCKVwm1nNcAlx8fckcbxdA4rIuHrJxY1Qz1DAhUBprJSJVq1sMH1EAXnU8rkkzrEsbs/H4fZTfV9CUigIkGJNv72j0W3XzwrAotPiNoRB8x74K1tjuh1XX/qxN6iUw1IoBJY98AG2LV7b9HtV50fczxkExwPl1LgutMaZb1U75BAJbL+lxuKbnvJiSIKzYx4npVo1EIrPheMSWsSqES2vvue3IrlZxdE8x6yifLMaWYQBOp2MhWnI3DkuBh279krtg/g4MHqzLs99uRTYuT68aLaLpihQFtMkYOM1iTritODM4ddvwKJEePbSxwtxkIYL36lImEdlEwm5XzaWLQ1AtxwRgQe2a7JUec5rUyktuAE/lClMJyi2PTixormuxCUZ+u77xfd/hunGo/1xYdJYV0UJEJXA2HUuO/eeyqegd/67r+LbnvJyQyWzlXg3OkK/HxRsH7loS2iUaLW1vLXGR88dLik9i8tVWDriohMYUEitAJhDdW19GtQLrt3fwBEyLvxl1+2BMplPFZS1gOhFujM+fOAqIxQC1RMN5wYHRqJJioi1ALheA5RGaEWqJSZdS+1vFWongi1QJv/VNqaZyc4F0eEWCCcDytlVt3L/NOpB4eEVqCNv/tDRWM5iy68AIiQCoR3WpSyPNWPRReeB0TIHq6AKQuXc1SSupAuMZtPY0gGdSuQdQNgMfT2GvVOtaYfli2tbDlIkKBbm0sEl4E8/3RxqxGDCN3aXCG4DITIQQKVAD5wgQYQ3ZBARYKp6/YyntgRdEigIpg/fx482n0/EPmQQGNw+VeWwEZRNFO33R96yGYBcL30bd+/GW5csRyIwpBAPtx4/XK4/dabKeoUAaUwH1pE9CF5ioME8gHnyWixWXHUbQoba0QYpzlKfTydBcrzvJCIuu1jE9gItFIUv5XcOEhRqDgCKxDWMDdcX34PyopCxOgEugaiKFR7Ai0QRaHaE/heGEWh2hJ4gTAKVfIQBYpCoxOKcaAbV1wLlUBRqDChEAjX8FTyQCmKQoUJzUg0ToxWAkUhf0IjEEYgikLVJ1RzYRSFqk+oBKIoVH1CNxtPUai6hE4gikLVJZTrgboqvLOUolCOUAqET6qv5Pk+FIVyhHZFIkWh6hBagSqdZKUoZBBagSpd6oFQFAr5onqKQpUz4Y93IeoLn8e78ITzAOdAEL74qaFwYImxmxEE/tVptxsMYJ/CGNvmPKiTP0QBvGpwJgQCXd/vPKjpOhCEH7rXDZ1vxxTmikCciiCiALrHDXRH0bLpza5GIoeRQ4QXDCy6p77RIvC60tHRkRAqve78QNU1IAgnel4Bzbd1xOP7jIFEDm84P9RUqoMIN1nN7YTO2cO4lwKparrbOR6ErqkaRSHCQBPyeGtjTF+4lwLJNKYbRlmoqk61ECHF8UYfBspzmL6M1ybHjh1rjzY0fiQOtVvHolEFYpEIEOElo2oyAjlRFZhrCWRPphaKQpTKwosqxPHKI6qftZY8CPOelBxKvy8C10LnscZYFBSFAREeMHWlM6rrGBMjz81T43Odx/KWc6gKX+adYM1kVRpgDBGa6LKPZL2ZhyeyDC7zts0TCMMT5+xHrlPFhjZSOgs+mLb8AgaHyE3O1GXhu6CstTn+HOiw1ns8K2oiLKooGgUP2dsS1xa3fPS1rU2Nm/3OG7WwSSZTa4Riq/NOEskwGlHkRtQ/GHVUn7EeA31tS1PTmkLnjlkZDwwMdbEIe9bZvbdPNkWKiAIbXxP1A8qi6tjL4gXE4QkmSplmzEajUNRVP5ZKdcY4vCZ+TmehNthLU5ghEr7GLyapJgeWIFgc44y638SoE1wjlmV8mV/Nk9cWSqBQSiOCApdjgS0t8TXFnlFyiMBoFNH0NYwpK4EICIY4avOU7g7mXeI8OmXnGEMkuFSEuzu8A49EncDEhKgGb5QjTu4rqoAtkxSJLeAMOsUXdwIxSeAJvHkC1/CIAZ39uJJQa5qyuVxpnHwGk1vpUB2et44AAAAASUVORK5CYII=", POPOVER_GAP = 8, POPOVER_HEIGHT = 120, styles, POPOVER_GAP2 = 8, POPOVER_HEIGHT2 = 150, styles2;
76273
+ }, import_lodash, ConflictError, Slot, lightStyles, darkStyles, styles, POPOVER_GAP = 4, POPOVER_HEIGHT = 150, styles2;
75740
76274
  var init_src2 = __esm(() => {
75741
76275
  init_src();
75742
76276
  init_src();
@@ -80093,6 +80627,52 @@ spurious results.`);
80093
80627
  SPLIT_UPPER_UPPER_RE = /(\p{Lu})([\p{Lu}][\p{Ll}])/gu;
80094
80628
  SPLIT_SEPARATE_NUMBER_RE = /(\d)\p{Ll}|(\p{L})\d/u;
80095
80629
  DEFAULT_STRIP_REGEXP = /[^\p{L}\d]+/giu;
80630
+ isServer = typeof window === "undefined";
80631
+ ({
80632
+ useValue: useLoading,
80633
+ setValue: setLoading,
80634
+ addEventHandler: addLoadingEventHandler
80635
+ } = makePHEventFunctions("loading"));
80636
+ renownEventFunctions = makePHEventFunctions("renown");
80637
+ addRenownEventHandler = renownEventFunctions.addEventHandler;
80638
+ useRenown = renownEventFunctions.useValue;
80639
+ setRenown = renownEventFunctions.setValue;
80640
+ DOMAIN_TYPE = [
80641
+ { name: "name", type: "string" },
80642
+ { name: "version", type: "string" },
80643
+ { name: "chainId", type: "uint256" },
80644
+ { name: "verifyingContract", type: "address" }
80645
+ ];
80646
+ VERIFIABLE_CREDENTIAL_EIP712_TYPE = [
80647
+ { name: "@context", type: "string[]" },
80648
+ { name: "type", type: "string[]" },
80649
+ { name: "id", type: "string" },
80650
+ { name: "issuer", type: "Issuer" },
80651
+ { name: "credentialSubject", type: "CredentialSubject" },
80652
+ { name: "credentialSchema", type: "CredentialSchema" },
80653
+ { name: "issuanceDate", type: "string" },
80654
+ { name: "expirationDate", type: "string" }
80655
+ ];
80656
+ CREDENTIAL_SCHEMA_EIP712_TYPE = [
80657
+ { name: "id", type: "string" },
80658
+ { name: "type", type: "string" }
80659
+ ];
80660
+ CREDENTIAL_SUBJECT_TYPE = [
80661
+ { name: "app", type: "string" },
80662
+ { name: "id", type: "string" },
80663
+ { name: "name", type: "string" }
80664
+ ];
80665
+ ISSUER_TYPE = [
80666
+ { name: "id", type: "string" },
80667
+ { name: "ethereumAddress", type: "string" }
80668
+ ];
80669
+ CREDENTIAL_TYPES = {
80670
+ EIP712Domain: DOMAIN_TYPE,
80671
+ VerifiableCredential: VERIFIABLE_CREDENTIAL_EIP712_TYPE,
80672
+ CredentialSchema: CREDENTIAL_SCHEMA_EIP712_TYPE,
80673
+ CredentialSubject: CREDENTIAL_SUBJECT_TYPE,
80674
+ Issuer: ISSUER_TYPE
80675
+ };
80096
80676
  isExternalControlsEnabledEventFunctions = makePHEventFunctions("isExternalControlsEnabled");
80097
80677
  setIsExternalControlsEnabled = isExternalControlsEnabledEventFunctions.setValue;
80098
80678
  useIsExternalControlsEnabled = isExternalControlsEnabledEventFunctions.useValue;
@@ -80121,14 +80701,8 @@ spurious results.`);
80121
80701
  vetraPackageManagerFunctions = makePHEventFunctions("vetraPackageManager");
80122
80702
  useVetraPackageManager = vetraPackageManagerFunctions.useValue;
80123
80703
  addVetraPackageManagerEventHandler = vetraPackageManagerFunctions.addEventHandler;
80124
- reactorClientModuleEventFunctions = makePHEventFunctions("reactorClientModule");
80125
- reactorClientEventFunctions = makePHEventFunctions("reactorClient");
80126
- useReactorClientModule = reactorClientModuleEventFunctions.useValue;
80127
- setReactorClientModule = reactorClientModuleEventFunctions.setValue;
80128
- addReactorClientModuleEventHandler = reactorClientModuleEventFunctions.addEventHandler;
80129
- useReactorClient = reactorClientEventFunctions.useValue;
80130
- setReactorClient = reactorClientEventFunctions.setValue;
80131
- addReactorClientEventHandler = reactorClientEventFunctions.addEventHandler;
80704
+ EMPTY_PENDING = [];
80705
+ EMPTY_DISMISSED = [];
80132
80706
  documentEventFunctions = makePHEventFunctions("documentCache");
80133
80707
  useDocumentCache = documentEventFunctions.useValue;
80134
80708
  setDocumentCache = documentEventFunctions.setValue;
@@ -81176,6 +81750,14 @@ spurious results.`);
81176
81750
  ...phDocumentEditorConfigHooks,
81177
81751
  ...nonUserConfigHooks
81178
81752
  };
81753
+ reactorClientModuleEventFunctions = makePHEventFunctions("reactorClientModule");
81754
+ reactorClientEventFunctions = makePHEventFunctions("reactorClient");
81755
+ useReactorClientModule = reactorClientModuleEventFunctions.useValue;
81756
+ setReactorClientModule = reactorClientModuleEventFunctions.setValue;
81757
+ addReactorClientModuleEventHandler = reactorClientModuleEventFunctions.addEventHandler;
81758
+ useReactorClient = reactorClientEventFunctions.useValue;
81759
+ setReactorClient = reactorClientEventFunctions.setValue;
81760
+ addReactorClientEventHandler = reactorClientEventFunctions.addEventHandler;
81179
81761
  featuresEventFunctions = makePHEventFunctions("features");
81180
81762
  useFeatures = featuresEventFunctions.useValue;
81181
81763
  setFeatures = featuresEventFunctions.setValue;
@@ -81208,51 +81790,6 @@ spurious results.`);
81208
81790
  [SyncStatus.Error]: "ERROR"
81209
81791
  };
81210
81792
  lzString = __toESM2(require_lz_string(), 1);
81211
- DOMAIN_TYPE = [
81212
- { name: "name", type: "string" },
81213
- { name: "version", type: "string" },
81214
- { name: "chainId", type: "uint256" },
81215
- { name: "verifyingContract", type: "address" }
81216
- ];
81217
- VERIFIABLE_CREDENTIAL_EIP712_TYPE = [
81218
- { name: "@context", type: "string[]" },
81219
- { name: "type", type: "string[]" },
81220
- { name: "id", type: "string" },
81221
- { name: "issuer", type: "Issuer" },
81222
- { name: "credentialSubject", type: "CredentialSubject" },
81223
- { name: "credentialSchema", type: "CredentialSchema" },
81224
- { name: "issuanceDate", type: "string" },
81225
- { name: "expirationDate", type: "string" }
81226
- ];
81227
- CREDENTIAL_SCHEMA_EIP712_TYPE = [
81228
- { name: "id", type: "string" },
81229
- { name: "type", type: "string" }
81230
- ];
81231
- CREDENTIAL_SUBJECT_TYPE = [
81232
- { name: "app", type: "string" },
81233
- { name: "id", type: "string" },
81234
- { name: "name", type: "string" }
81235
- ];
81236
- ISSUER_TYPE = [
81237
- { name: "id", type: "string" },
81238
- { name: "ethereumAddress", type: "string" }
81239
- ];
81240
- CREDENTIAL_TYPES = {
81241
- EIP712Domain: DOMAIN_TYPE,
81242
- VerifiableCredential: VERIFIABLE_CREDENTIAL_EIP712_TYPE,
81243
- CredentialSchema: CREDENTIAL_SCHEMA_EIP712_TYPE,
81244
- CredentialSubject: CREDENTIAL_SUBJECT_TYPE,
81245
- Issuer: ISSUER_TYPE
81246
- };
81247
- ({
81248
- useValue: useLoading,
81249
- setValue: setLoading,
81250
- addEventHandler: addLoadingEventHandler
81251
- } = makePHEventFunctions("loading"));
81252
- renownEventFunctions = makePHEventFunctions("renown");
81253
- useRenown = renownEventFunctions.useValue;
81254
- setRenown = renownEventFunctions.setValue;
81255
- addRenownEventHandler = renownEventFunctions.addEventHandler;
81256
81793
  store = {
81257
81794
  get: function(key) {
81258
81795
  const value = localStorage.getItem(key);
@@ -81425,7 +81962,7 @@ spurious results.`);
81425
81962
  1541459225,
81426
81963
  327033209
81427
81964
  ]);
81428
- U32_MASK64 = /* @__PURE__ */ BigInt(4294967295);
81965
+ U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
81429
81966
  _32n = /* @__PURE__ */ BigInt(32);
81430
81967
  SHA256_K = /* @__PURE__ */ Uint32Array.from([
81431
81968
  1116352408,
@@ -81975,7 +82512,7 @@ spurious results.`);
81975
82512
  this.iHash.update(pad);
81976
82513
  this.oHash = hash.create();
81977
82514
  for (let i3 = 0;i3 < pad.length; i3++)
81978
- pad[i3] ^= 106;
82515
+ pad[i3] ^= 54 ^ 92;
81979
82516
  this.oHash.update(pad);
81980
82517
  clean(pad);
81981
82518
  }
@@ -82240,11 +82777,11 @@ spurious results.`);
82240
82777
  RIPEMD160 = class RIPEMD160 extends HashMD {
82241
82778
  constructor() {
82242
82779
  super(64, 20, 8, true);
82243
- this.h0 = 1732584193;
82244
- this.h1 = -271733879;
82245
- this.h2 = -1732584194;
82246
- this.h3 = 271733878;
82247
- this.h4 = -1009589776;
82780
+ this.h0 = 1732584193 | 0;
82781
+ this.h1 = 4023233417 | 0;
82782
+ this.h2 = 2562383102 | 0;
82783
+ this.h3 = 271733878 | 0;
82784
+ this.h4 = 3285377520 | 0;
82248
82785
  }
82249
82786
  get() {
82250
82787
  const { h0, h1, h2, h3, h4 } = this;
@@ -82422,7 +82959,7 @@ spurious results.`);
82422
82959
  return to;
82423
82960
  }
82424
82961
  };
82425
- keccak_256 = /* @__PURE__ */ (() => gen(1, 136, 32))();
82962
+ keccak_256 = /* @__PURE__ */ (() => gen(1, 136, 256 / 8))();
82426
82963
  import_canonicalize = __toESM2(require_canonicalize(), 1);
82427
82964
  ID_CHAR = `(?:[a-zA-Z0-9._-]|${PCT_ENCODED})`;
82428
82965
  METHOD_ID = `((?:${ID_CHAR}*:)*(${ID_CHAR}+))`;
@@ -87273,72 +87810,63 @@ spurious results.`);
87273
87810
  this.name = "ConflictError";
87274
87811
  }
87275
87812
  };
87276
- styles = {
87813
+ Slot = forwardRef(({ children, ...props }, ref) => {
87814
+ const child = Children2.only(children);
87815
+ if (!isValidElement3(child)) {
87816
+ return null;
87817
+ }
87818
+ const childElement = child;
87819
+ const mergedProps = mergeProps2(props, childElement.props);
87820
+ if (ref) {
87821
+ mergedProps.ref = ref;
87822
+ }
87823
+ return cloneElement2(childElement, mergedProps);
87824
+ });
87825
+ Slot.displayName = "Slot";
87826
+ lightStyles = {
87277
87827
  trigger: {
87278
- display: "flex",
87279
- alignItems: "center",
87280
- justifyContent: "center",
87281
- padding: 0,
87282
- border: "none",
87283
- background: "transparent",
87284
- cursor: "pointer"
87285
- },
87286
- popoverBase: {
87287
- position: "absolute",
87288
- left: 0,
87289
- borderRadius: "8px",
87290
- width: "208px",
87291
- zIndex: 1000
87292
- },
87293
- popoverLight: {
87294
- backgroundColor: "white",
87295
- boxShadow: "0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)"
87828
+ backgroundColor: "#ffffff",
87829
+ borderWidth: "1px",
87830
+ borderStyle: "solid",
87831
+ borderColor: "#d1d5db",
87832
+ color: "#111827"
87296
87833
  },
87297
- popoverDark: {
87834
+ triggerHover: {
87835
+ backgroundColor: "#ecf3f8",
87836
+ borderColor: "#9ca3af"
87837
+ }
87838
+ };
87839
+ darkStyles = {
87840
+ trigger: {
87298
87841
  backgroundColor: "#1f2937",
87299
- boxShadow: "0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2)"
87300
- },
87301
- popoverContent: {
87302
- padding: "16px"
87842
+ borderWidth: "1px",
87843
+ borderStyle: "solid",
87844
+ borderColor: "#4b5563",
87845
+ color: "#ecf3f8"
87303
87846
  },
87304
- logoContainer: {
87305
- display: "flex",
87306
- justifyContent: "center",
87307
- height: "22px",
87308
- width: "83px",
87309
- margin: "0 auto 16px",
87310
- overflow: "hidden"
87847
+ triggerHover: {
87848
+ backgroundColor: "#374151",
87849
+ borderColor: "#6b7280"
87850
+ }
87851
+ };
87852
+ styles = {
87853
+ wrapper: {
87854
+ position: "relative",
87855
+ display: "inline-block"
87311
87856
  },
87312
- connectButtonBase: {
87857
+ trigger: {
87313
87858
  display: "flex",
87314
87859
  alignItems: "center",
87315
87860
  justifyContent: "center",
87316
- width: "100%",
87317
- height: "28px",
87861
+ gap: "8px",
87862
+ padding: "8px 32px",
87318
87863
  borderRadius: "8px",
87319
- backgroundColor: "transparent",
87320
- fontSize: "14px",
87321
87864
  cursor: "pointer",
87322
- marginTop: "16px"
87323
- },
87324
- connectButtonLight: {
87325
- border: "1px solid #d1d5db",
87326
- color: "#111827"
87327
- },
87328
- connectButtonDark: {
87329
- border: "1px solid #4b5563",
87330
- color: "#f9fafb"
87331
- },
87332
- wrapper: {
87333
- position: "relative",
87334
- display: "inline-block"
87335
- },
87336
- triggerImageLight: {
87337
- display: "block"
87338
- },
87339
- triggerImageDark: {
87340
- display: "block",
87341
- filter: "invert(1)"
87865
+ fontSize: "14px",
87866
+ fontWeight: 500,
87867
+ fontFamily: "inherit",
87868
+ lineHeight: "20px",
87869
+ transition: "background-color 150ms, border-color 150ms"
87342
87870
  }
87343
87871
  };
87344
87872
  styles2 = {
@@ -87349,56 +87877,89 @@ spurious results.`);
87349
87877
  trigger: {
87350
87878
  display: "flex",
87351
87879
  alignItems: "center",
87352
- justifyContent: "center",
87353
- padding: 0,
87354
- border: "none",
87355
- background: "transparent",
87880
+ gap: "8px",
87881
+ padding: "6px 12px",
87882
+ borderWidth: "1px",
87883
+ borderStyle: "solid",
87884
+ borderColor: "#e5e7eb",
87885
+ backgroundColor: "#ffffff",
87356
87886
  cursor: "pointer",
87357
- borderRadius: "50%",
87358
- overflow: "hidden"
87887
+ borderRadius: "8px",
87888
+ fontSize: "12px",
87889
+ fontWeight: 500,
87890
+ fontFamily: "inherit",
87891
+ color: "#111827",
87892
+ transition: "background-color 150ms, border-color 150ms"
87893
+ },
87894
+ triggerHover: {
87895
+ backgroundColor: "#f9fafb",
87896
+ borderColor: "#9ca3af"
87359
87897
  },
87360
87898
  avatar: {
87361
- width: "40px",
87362
- height: "40px",
87899
+ width: "28px",
87900
+ height: "28px",
87363
87901
  borderRadius: "50%",
87364
- objectFit: "cover"
87902
+ objectFit: "cover",
87903
+ flexShrink: 0
87365
87904
  },
87366
87905
  avatarPlaceholder: {
87367
- width: "40px",
87368
- height: "40px",
87906
+ width: "28px",
87907
+ height: "28px",
87369
87908
  borderRadius: "50%",
87370
- backgroundColor: "#e5e7eb",
87909
+ background: "linear-gradient(135deg, #8b5cf6, #3b82f6)",
87371
87910
  display: "flex",
87372
87911
  alignItems: "center",
87373
- justifyContent: "center"
87912
+ justifyContent: "center",
87913
+ flexShrink: 0
87914
+ },
87915
+ avatarInitial: {
87916
+ fontSize: "12px",
87917
+ fontWeight: 700,
87918
+ color: "#ffffff",
87919
+ lineHeight: 1
87920
+ },
87921
+ displayName: {
87922
+ maxWidth: "120px",
87923
+ overflow: "hidden",
87924
+ textOverflow: "ellipsis",
87925
+ whiteSpace: "nowrap"
87926
+ },
87927
+ chevron: {
87928
+ flexShrink: 0,
87929
+ transition: "transform 150ms",
87930
+ color: "#6b7280"
87931
+ },
87932
+ chevronOpen: {
87933
+ transform: "rotate(180deg)"
87374
87934
  },
87375
87935
  popoverBase: {
87376
87936
  position: "absolute",
87377
- left: 0,
87378
- backgroundColor: "white",
87937
+ right: 0,
87938
+ backgroundColor: "#ffffff",
87379
87939
  borderRadius: "8px",
87380
- boxShadow: "0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)",
87381
- width: "208px",
87940
+ boxShadow: "0 4px 12px rgba(0, 0, 0, 0.12), 0 1px 3px rgba(0, 0, 0, 0.08)",
87941
+ width: "100%",
87382
87942
  zIndex: 1000,
87383
- color: "#111827"
87943
+ color: "#111827",
87944
+ borderWidth: "1px",
87945
+ borderStyle: "solid",
87946
+ borderColor: "#e5e7eb",
87947
+ overflow: "hidden"
87384
87948
  },
87385
- section: {
87386
- padding: "8px 12px",
87949
+ header: {
87950
+ padding: "12px 16px",
87387
87951
  borderBottom: "1px solid #e5e7eb"
87388
87952
  },
87389
- sectionLast: {
87390
- padding: "8px 12px",
87391
- borderBottom: "none"
87392
- },
87393
- username: {
87953
+ headerUsername: {
87394
87954
  fontSize: "14px",
87395
- fontWeight: 500,
87396
- color: "#111827"
87955
+ fontWeight: 600,
87956
+ color: "#111827",
87957
+ margin: 0
87397
87958
  },
87398
87959
  addressRow: {
87399
87960
  display: "flex",
87400
87961
  alignItems: "center",
87401
- gap: "8px",
87962
+ gap: "4px",
87402
87963
  marginTop: "4px"
87403
87964
  },
87404
87965
  addressButton: {
@@ -87407,19 +87968,21 @@ spurious results.`);
87407
87968
  gap: "4px",
87408
87969
  padding: 0,
87409
87970
  border: "none",
87410
- background: "transparent",
87971
+ backgroundColor: "transparent",
87411
87972
  cursor: "pointer",
87412
87973
  fontSize: "12px",
87413
- color: "#111827",
87974
+ color: "#6b7280",
87975
+ fontFamily: "inherit",
87414
87976
  position: "relative",
87415
87977
  width: "100%"
87416
87978
  },
87417
87979
  copiedText: {
87418
87980
  fontSize: "12px",
87419
- color: "#111827",
87981
+ color: "#059669",
87420
87982
  position: "absolute",
87421
87983
  left: 0,
87422
- transition: "opacity 150ms"
87984
+ transition: "opacity 150ms",
87985
+ fontWeight: 500
87423
87986
  },
87424
87987
  addressText: {
87425
87988
  display: "flex",
@@ -87427,34 +87990,48 @@ spurious results.`);
87427
87990
  gap: "4px",
87428
87991
  transition: "opacity 150ms"
87429
87992
  },
87993
+ menuSection: {
87994
+ padding: "4px 0"
87995
+ },
87430
87996
  menuItem: {
87431
87997
  display: "flex",
87432
87998
  alignItems: "center",
87433
87999
  gap: "8px",
87434
88000
  width: "100%",
87435
- padding: 0,
88001
+ padding: "8px 16px",
87436
88002
  border: "none",
87437
- background: "transparent",
88003
+ backgroundColor: "transparent",
87438
88004
  cursor: "pointer",
87439
88005
  fontSize: "14px",
87440
- color: "#111827",
87441
- textDecoration: "none"
88006
+ color: "#374151",
88007
+ textDecoration: "none",
88008
+ fontFamily: "inherit",
88009
+ transition: "background-color 150ms"
88010
+ },
88011
+ menuItemHover: {
88012
+ backgroundColor: "#f3f4f6"
87442
88013
  },
87443
88014
  disconnectItem: {
87444
- color: "#7f1d1d"
88015
+ color: "#dc2626"
88016
+ },
88017
+ separator: {
88018
+ height: "1px",
88019
+ backgroundColor: "#e5e7eb",
88020
+ margin: 0,
88021
+ border: "none"
87445
88022
  }
87446
88023
  };
87447
88024
  });
87448
88025
 
87449
88026
  // src/hooks/useClientErrorHandler.ts
87450
88027
  import { logger as logger7 } from "document-drive";
87451
- import { useCallback as useCallback7, useMemo as useMemo4, useRef as useRef8, useState as useState9 } from "react";
88028
+ import { useCallback as useCallback3, useMemo as useMemo4, useRef as useRef7, useState as useState9 } from "react";
87452
88029
  var DELAY_LIMIT = 1e5, useClientErrorHandler = () => {
87453
88030
  const [handlingInProgress, setHandlingInProgress] = useState9([]);
87454
88031
  const [pullResponderTriggerMap, setPullResponderTriggerMap] = useState9(new Map);
87455
88032
  const drives = useDrives();
87456
- const pullResponderRegisterDelay = useRef8(new Map);
87457
- const handleStrands400 = useCallback7(async (driveId, trigger, handlerCode) => {
88033
+ const pullResponderRegisterDelay = useRef7(new Map);
88034
+ const handleStrands400 = useCallback3(async (driveId, trigger, handlerCode) => {
87458
88035
  setHandlingInProgress((state) => [...state, handlerCode]);
87459
88036
  const triggerData = trigger.data;
87460
88037
  if (!triggerData)
@@ -87487,7 +88064,7 @@ var DELAY_LIMIT = 1e5, useClientErrorHandler = () => {
87487
88064
  pullResponderRegisterDelay,
87488
88065
  registerNewPullResponderTrigger
87489
88066
  ]);
87490
- const handleDriveNotFound = useCallback7(async (driveId, trigger, handlerCode) => {
88067
+ const handleDriveNotFound = useCallback3(async (driveId, trigger, handlerCode) => {
87491
88068
  setHandlingInProgress((state) => [...state, handlerCode]);
87492
88069
  try {
87493
88070
  const drive = drives?.find((drive2) => drive2.header.id === driveId);
@@ -87523,7 +88100,7 @@ var DELAY_LIMIT = 1e5, useClientErrorHandler = () => {
87523
88100
  getDriveIdBySlug,
87524
88101
  addRemoteDrive
87525
88102
  ]);
87526
- const strandsErrorHandler = useCallback7(async (driveId, trigger, status, errorMessage) => {}, [handleDriveNotFound, handleStrands400, handlingInProgress]);
88103
+ const strandsErrorHandler = useCallback3(async (driveId, trigger, status, errorMessage) => {}, [handleDriveNotFound, handleStrands400, handlingInProgress]);
87527
88104
  return useMemo4(() => ({ strandsErrorHandler }), [strandsErrorHandler]);
87528
88105
  };
87529
88106
  var init_useClientErrorHandler = __esm(() => {
@@ -87531,7 +88108,7 @@ var init_useClientErrorHandler = __esm(() => {
87531
88108
  });
87532
88109
 
87533
88110
  // src/hooks/useCookieBanner.ts
87534
- import { useSyncExternalStore as useSyncExternalStore4 } from "react";
88111
+ import { useSyncExternalStore as useSyncExternalStore5 } from "react";
87535
88112
  function getInitial2() {
87536
88113
  try {
87537
88114
  const value = localStorage.getItem(COOKIE_BANNER_KEY_STORAGE);
@@ -87553,7 +88130,7 @@ function subscribe2(fn) {
87553
88130
  return () => listeners2.delete(fn);
87554
88131
  }
87555
88132
  var namespace2, COOKIE_BANNER_KEY_STORAGE, listeners2, bannerShown, useCookieBanner = () => {
87556
- const cookieBannerShown = useSyncExternalStore4(subscribe2, getCookieBannerState, getCookieBannerState);
88133
+ const cookieBannerShown = useSyncExternalStore5(subscribe2, getCookieBannerState, getCookieBannerState);
87557
88134
  return [cookieBannerShown, setCookieBannerState];
87558
88135
  };
87559
88136
  var init_useCookieBanner = __esm(() => {
@@ -88199,7 +88776,7 @@ function isRouteErrorResponse(error3) {
88199
88776
  function createRouter(init4) {
88200
88777
  const routerWindow = init4.window ? init4.window : typeof window !== "undefined" ? window : undefined;
88201
88778
  const isBrowser2 = typeof routerWindow !== "undefined" && typeof routerWindow.document !== "undefined" && typeof routerWindow.document.createElement !== "undefined";
88202
- const isServer = !isBrowser2;
88779
+ const isServer2 = !isBrowser2;
88203
88780
  invariant2(init4.routes.length > 0, "You must provide a non-empty routes array to createRouter");
88204
88781
  let mapRouteProperties;
88205
88782
  if (init4.mapRouteProperties) {
@@ -88963,7 +89540,7 @@ function createRouter(init4) {
88963
89540
  return new Map(state.fetchers);
88964
89541
  }
88965
89542
  function fetch3(key, routeId, href, opts) {
88966
- if (isServer) {
89543
+ if (isServer2) {
88967
89544
  throw new Error("router.fetch() was called during the server render, but it shouldn't be. " + "You are likely calling a useFetcher() method in the body of your component. " + "Try moving it to a useEffect or a callback.");
88968
89545
  }
88969
89546
  abortFetcher(key);
@@ -92520,7 +93097,7 @@ var init_dist2 = __esm(() => {
92520
93097
 
92521
93098
  // src/hooks/useInitSentry.ts
92522
93099
  import { childLogger } from "document-drive";
92523
- import React8, { useEffect as useEffect13 } from "react";
93100
+ import React8, { useEffect as useEffect11 } from "react";
92524
93101
  async function getSentry() {
92525
93102
  return await Promise.resolve().then(() => (init_esm6(), exports_esm));
92526
93103
  }
@@ -92577,7 +93154,7 @@ async function closeClient() {
92577
93154
  function useInitSentry() {
92578
93155
  const [acceptedCookies] = useAcceptedCookies();
92579
93156
  const { analytics } = acceptedCookies;
92580
- useEffect13(() => {
93157
+ useEffect11(() => {
92581
93158
  if (!analytics) {
92582
93159
  closeClient().catch((error3) => logger9.error("@error", error3));
92583
93160
  return;
@@ -92635,7 +93212,7 @@ var init_useNodeActions = __esm(() => {
92635
93212
  });
92636
93213
 
92637
93214
  // ../../node_modules/.pnpm/react-hotkeys-hook@4.6.2_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/react-hotkeys-hook/dist/react-hotkeys-hook.esm.js
92638
- import { useContext as useContext5, createContext as createContext4, useState as useState13, useCallback as useCallback12, useRef as useRef12, useLayoutEffect as useLayoutEffect3, useEffect as useEffect14 } from "react";
93215
+ import { useContext as useContext5, createContext as createContext4, useState as useState13, useCallback as useCallback12, useRef as useRef11, useLayoutEffect as useLayoutEffect3, useEffect as useEffect12 } from "react";
92639
93216
  import { jsx } from "react/jsx-runtime";
92640
93217
  function _extends4() {
92641
93218
  return _extends4 = Object.assign ? Object.assign.bind() : function(n5) {
@@ -92769,7 +93346,7 @@ function deepEqual(x2, y2) {
92769
93346
  }, true) : x2 === y2;
92770
93347
  }
92771
93348
  function useDeepEqualMemo(value) {
92772
- var ref = useRef12(undefined);
93349
+ var ref = useRef11(undefined);
92773
93350
  if (!deepEqual(ref.current, value)) {
92774
93351
  ref.current = value;
92775
93352
  }
@@ -92777,12 +93354,12 @@ function useDeepEqualMemo(value) {
92777
93354
  }
92778
93355
  function useHotkeys(keys2, callback, options, dependencies) {
92779
93356
  var _useState = useState13(null), ref = _useState[0], setRef = _useState[1];
92780
- var hasTriggeredRef = useRef12(false);
93357
+ var hasTriggeredRef = useRef11(false);
92781
93358
  var _options = !(options instanceof Array) ? options : !(dependencies instanceof Array) ? dependencies : undefined;
92782
93359
  var _keys = isReadonlyArray3(keys2) ? keys2.join(_options == null ? undefined : _options.splitKey) : keys2;
92783
93360
  var _deps = options instanceof Array ? options : dependencies instanceof Array ? dependencies : undefined;
92784
93361
  var memoisedCB = useCallback12(callback, _deps != null ? _deps : []);
92785
- var cbRef = useRef12(memoisedCB);
93362
+ var cbRef = useRef11(memoisedCB);
92786
93363
  if (_deps) {
92787
93364
  cbRef.current = memoisedCB;
92788
93365
  } else {
@@ -92975,7 +93552,7 @@ var init_react_hotkeys_hook_esm = __esm(() => {
92975
93552
  enableScope: function enableScope() {},
92976
93553
  disableScope: function disableScope() {}
92977
93554
  });
92978
- useSafeLayoutEffect = typeof window !== "undefined" ? useLayoutEffect3 : useEffect14;
93555
+ useSafeLayoutEffect = typeof window !== "undefined" ? useLayoutEffect3 : useEffect12;
92979
93556
  });
92980
93557
 
92981
93558
  // src/hooks/useUndoRedoShortcuts.ts
@@ -93006,13 +93583,13 @@ var init_useUndoRedoShortcuts = __esm(() => {
93006
93583
  });
93007
93584
 
93008
93585
  // src/hooks/useWindowSize.ts
93009
- import { useEffect as useEffect15, useState as useState14 } from "react";
93586
+ import { useEffect as useEffect13, useState as useState14 } from "react";
93010
93587
  var useWindowSize = () => {
93011
93588
  const [windowSize, setWindowSize] = useState14({
93012
93589
  innerWidth: window.innerWidth,
93013
93590
  innerHeight: window.innerHeight
93014
93591
  });
93015
- useEffect15(() => {
93592
+ useEffect13(() => {
93016
93593
  const windowSizeHandler = () => {
93017
93594
  setWindowSize({
93018
93595
  innerWidth: window.innerWidth,
@@ -93034,7 +93611,7 @@ var init_package = __esm(() => {
93034
93611
  package_default = {
93035
93612
  name: "@powerhousedao/connect",
93036
93613
  productName: "Powerhouse-Connect",
93037
- version: "6.0.0-dev.83",
93614
+ version: "6.0.0-dev.88",
93038
93615
  description: "Powerhouse Connect",
93039
93616
  main: "dist/index.html",
93040
93617
  type: "module",