@powerhousedao/connect 6.0.0-dev.83 → 6.0.0-dev.88

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.
@@ -43833,6 +43833,11 @@ class CollectionMembershipCache {
43833
43833
  constructor(operationIndex) {
43834
43834
  this.operationIndex = operationIndex;
43835
43835
  }
43836
+ withScopedIndex(operationIndex) {
43837
+ const scoped = new CollectionMembershipCache(operationIndex);
43838
+ scoped.cache = this.cache;
43839
+ return scoped;
43840
+ }
43836
43841
  async getCollectionsForDocuments(documentIds) {
43837
43842
  const result = {};
43838
43843
  const missing = [];
@@ -44120,6 +44125,12 @@ class DocumentMetaCache {
44120
44125
  this.cache = new Map;
44121
44126
  this.lruTracker = new LRUTracker;
44122
44127
  }
44128
+ withScopedStore(operationStore) {
44129
+ const scoped = new DocumentMetaCache(operationStore, this.config);
44130
+ scoped.cache = this.cache;
44131
+ scoped.lruTracker = this.lruTracker;
44132
+ return scoped;
44133
+ }
44123
44134
  async startup() {
44124
44135
  return Promise.resolve();
44125
44136
  }
@@ -44269,9 +44280,18 @@ class KyselyOperationIndexTxn {
44269
44280
 
44270
44281
  class KyselyOperationIndex {
44271
44282
  db;
44283
+ trx;
44272
44284
  constructor(db) {
44273
44285
  this.db = db;
44274
44286
  }
44287
+ get queryExecutor() {
44288
+ return this.trx ?? this.db;
44289
+ }
44290
+ withTransaction(trx) {
44291
+ const instance2 = new KyselyOperationIndex(this.db);
44292
+ instance2.trx = trx;
44293
+ return instance2;
44294
+ }
44275
44295
  start() {
44276
44296
  return new KyselyOperationIndexTxn;
44277
44297
  }
@@ -44280,70 +44300,76 @@ class KyselyOperationIndex {
44280
44300
  throw new Error("Operation aborted");
44281
44301
  }
44282
44302
  const kyselyTxn = txn;
44303
+ if (this.trx) {
44304
+ return this.executeCommit(this.trx, kyselyTxn);
44305
+ }
44306
+ let resultOrdinals = [];
44307
+ await this.db.transaction().execute(async (trx) => {
44308
+ resultOrdinals = await this.executeCommit(trx, kyselyTxn);
44309
+ });
44310
+ return resultOrdinals;
44311
+ }
44312
+ async executeCommit(trx, kyselyTxn) {
44283
44313
  const collections = kyselyTxn.getCollections();
44284
44314
  const memberships = kyselyTxn.getCollectionMembershipRecords();
44285
44315
  const removals = kyselyTxn.getCollectionRemovals();
44286
44316
  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),
44317
+ if (collections.length > 0) {
44318
+ const collectionRows = collections.map((collectionId) => ({
44319
+ documentId: collectionId,
44320
+ collectionId,
44321
+ joinedOrdinal: BigInt(0),
44322
+ leftOrdinal: null
44323
+ }));
44324
+ await trx.insertInto("document_collections").values(collectionRows).onConflict((oc) => oc.doNothing()).execute();
44325
+ }
44326
+ let operationOrdinals = [];
44327
+ if (operations.length > 0) {
44328
+ const operationRows = operations.map((op) => ({
44329
+ opId: op.id || "",
44330
+ documentId: op.documentId,
44331
+ documentType: op.documentType,
44332
+ scope: op.scope,
44333
+ branch: op.branch,
44334
+ timestampUtcMs: op.timestampUtcMs,
44335
+ index: op.index,
44336
+ skip: op.skip,
44337
+ hash: op.hash,
44338
+ action: op.action,
44339
+ sourceRemote: op.sourceRemote
44340
+ }));
44341
+ const insertedOps = await trx.insertInto("operation_index_operations").values(operationRows).returning("ordinal").execute();
44342
+ operationOrdinals = insertedOps.map((row) => row.ordinal);
44343
+ }
44344
+ if (memberships.length > 0) {
44345
+ for (const m2 of memberships) {
44346
+ const ordinal = operationOrdinals[m2.operationIndex];
44347
+ await trx.insertInto("document_collections").values({
44348
+ documentId: m2.documentId,
44349
+ collectionId: m2.collectionId,
44350
+ joinedOrdinal: BigInt(ordinal),
44294
44351
  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
- }
44352
+ }).onConflict((oc) => oc.columns(["documentId", "collectionId"]).doUpdateSet({
44353
+ joinedOrdinal: BigInt(ordinal),
44354
+ leftOrdinal: null
44355
+ })).execute();
44330
44356
  }
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
- }
44357
+ }
44358
+ if (removals.length > 0) {
44359
+ for (const r4 of removals) {
44360
+ const ordinal = operationOrdinals[r4.operationIndex];
44361
+ await trx.updateTable("document_collections").set({
44362
+ leftOrdinal: BigInt(ordinal)
44363
+ }).where("collectionId", "=", r4.collectionId).where("documentId", "=", r4.documentId).where("leftOrdinal", "is", null).execute();
44338
44364
  }
44339
- });
44340
- return resultOrdinals;
44365
+ }
44366
+ return operationOrdinals;
44341
44367
  }
44342
44368
  async find(collectionId, cursor, view, paging, signal) {
44343
44369
  if (signal?.aborted) {
44344
44370
  throw new Error("Operation aborted");
44345
44371
  }
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");
44372
+ 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
44373
  if (cursor !== undefined) {
44348
44374
  query = query.where("oi.ordinal", ">", cursor);
44349
44375
  }
@@ -44385,7 +44411,7 @@ class KyselyOperationIndex {
44385
44411
  if (signal?.aborted) {
44386
44412
  throw new Error("Operation aborted");
44387
44413
  }
44388
- let query = this.db.selectFrom("operation_index_operations").selectAll().where("documentId", "=", documentId).orderBy("ordinal", "asc");
44414
+ let query = this.queryExecutor.selectFrom("operation_index_operations").selectAll().where("documentId", "=", documentId).orderBy("ordinal", "asc");
44389
44415
  if (view?.branch) {
44390
44416
  query = query.where("branch", "=", view.branch);
44391
44417
  }
@@ -44421,7 +44447,7 @@ class KyselyOperationIndex {
44421
44447
  if (signal?.aborted) {
44422
44448
  throw new Error("Operation aborted");
44423
44449
  }
44424
- let query = this.db.selectFrom("operation_index_operations").selectAll().where("ordinal", ">", ordinal).orderBy("ordinal", "asc");
44450
+ let query = this.queryExecutor.selectFrom("operation_index_operations").selectAll().where("ordinal", ">", ordinal).orderBy("ordinal", "asc");
44425
44451
  if (paging?.cursor) {
44426
44452
  const cursorOrdinal = Number.parseInt(paging.cursor, 10);
44427
44453
  query = query.where("ordinal", ">", cursorOrdinal);
@@ -44486,14 +44512,14 @@ class KyselyOperationIndex {
44486
44512
  if (signal?.aborted) {
44487
44513
  throw new Error("Operation aborted");
44488
44514
  }
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();
44515
+ 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
44516
  return result?.timestampUtcMs ?? null;
44491
44517
  }
44492
44518
  async getCollectionsForDocuments(documentIds) {
44493
44519
  if (documentIds.length === 0) {
44494
44520
  return {};
44495
44521
  }
44496
- const rows = await this.db.selectFrom("document_collections").select(["documentId", "collectionId"]).where("documentId", "in", documentIds).where("leftOrdinal", "is", null).execute();
44522
+ const rows = await this.queryExecutor.selectFrom("document_collections").select(["documentId", "collectionId"]).where("documentId", "in", documentIds).where("leftOrdinal", "is", null).execute();
44497
44523
  const result = {};
44498
44524
  for (const row of rows) {
44499
44525
  if (!(row.documentId in result)) {
@@ -44567,6 +44593,12 @@ class KyselyWriteCache {
44567
44593
  this.streams = new Map;
44568
44594
  this.lruTracker = new LRUTracker;
44569
44595
  }
44596
+ withScopedStores(operationStore, keyframeStore) {
44597
+ const scoped = new KyselyWriteCache(keyframeStore, operationStore, this.registry, this.config);
44598
+ scoped.streams = this.streams;
44599
+ scoped.lruTracker = this.lruTracker;
44600
+ return scoped;
44601
+ }
44570
44602
  async startup() {
44571
44603
  return Promise.resolve();
44572
44604
  }
@@ -44875,6 +44907,63 @@ class EventBus {
44875
44907
  }
44876
44908
  }
44877
44909
 
44910
+ class DefaultExecutionScope {
44911
+ operationStore;
44912
+ operationIndex;
44913
+ writeCache;
44914
+ documentMetaCache;
44915
+ collectionMembershipCache;
44916
+ constructor(operationStore, operationIndex, writeCache, documentMetaCache, collectionMembershipCache) {
44917
+ this.operationStore = operationStore;
44918
+ this.operationIndex = operationIndex;
44919
+ this.writeCache = writeCache;
44920
+ this.documentMetaCache = documentMetaCache;
44921
+ this.collectionMembershipCache = collectionMembershipCache;
44922
+ }
44923
+ async run(fn) {
44924
+ return fn({
44925
+ operationStore: this.operationStore,
44926
+ operationIndex: this.operationIndex,
44927
+ writeCache: this.writeCache,
44928
+ documentMetaCache: this.documentMetaCache,
44929
+ collectionMembershipCache: this.collectionMembershipCache
44930
+ });
44931
+ }
44932
+ }
44933
+
44934
+ class KyselyExecutionScope {
44935
+ db;
44936
+ operationStore;
44937
+ operationIndex;
44938
+ keyframeStore;
44939
+ writeCache;
44940
+ documentMetaCache;
44941
+ collectionMembershipCache;
44942
+ constructor(db, operationStore, operationIndex, keyframeStore, writeCache, documentMetaCache, collectionMembershipCache) {
44943
+ this.db = db;
44944
+ this.operationStore = operationStore;
44945
+ this.operationIndex = operationIndex;
44946
+ this.keyframeStore = keyframeStore;
44947
+ this.writeCache = writeCache;
44948
+ this.documentMetaCache = documentMetaCache;
44949
+ this.collectionMembershipCache = collectionMembershipCache;
44950
+ }
44951
+ async run(fn) {
44952
+ return this.db.transaction().execute(async (trx) => {
44953
+ const scopedOperationStore = this.operationStore.withTransaction(trx);
44954
+ const scopedOperationIndex = this.operationIndex.withTransaction(trx);
44955
+ const scopedKeyframeStore = this.keyframeStore.withTransaction(trx);
44956
+ return fn({
44957
+ operationStore: scopedOperationStore,
44958
+ operationIndex: scopedOperationIndex,
44959
+ writeCache: this.writeCache.withScopedStores(scopedOperationStore, scopedKeyframeStore),
44960
+ documentMetaCache: this.documentMetaCache.withScopedStore(scopedOperationStore),
44961
+ collectionMembershipCache: this.collectionMembershipCache.withScopedIndex(scopedOperationIndex)
44962
+ });
44963
+ });
44964
+ }
44965
+ }
44966
+
44878
44967
  class DocumentModelRegistry {
44879
44968
  modules = [];
44880
44969
  manifests = [];
@@ -45334,37 +45423,29 @@ function driveCollectionId(branch, driveId) {
45334
45423
  }
45335
45424
 
45336
45425
  class DocumentActionHandler {
45337
- writeCache;
45338
- operationStore;
45339
- documentMetaCache;
45340
- collectionMembershipCache;
45341
45426
  registry;
45342
45427
  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;
45428
+ constructor(registry, logger4) {
45348
45429
  this.registry = registry;
45349
45430
  this.logger = logger4;
45350
45431
  }
45351
- async execute(job, action, startTime, indexTxn, skip = 0, sourceRemote = "") {
45432
+ async execute(job, action, startTime, indexTxn, stores, skip = 0, sourceRemote = "") {
45352
45433
  switch (action.type) {
45353
45434
  case "CREATE_DOCUMENT":
45354
- return this.executeCreate(job, action, startTime, indexTxn, skip, sourceRemote);
45435
+ return this.executeCreate(job, action, startTime, indexTxn, stores, skip, sourceRemote);
45355
45436
  case "DELETE_DOCUMENT":
45356
- return this.executeDelete(job, action, startTime, indexTxn, sourceRemote);
45437
+ return this.executeDelete(job, action, startTime, indexTxn, stores, sourceRemote);
45357
45438
  case "UPGRADE_DOCUMENT":
45358
- return this.executeUpgrade(job, action, startTime, indexTxn, skip, sourceRemote);
45439
+ return this.executeUpgrade(job, action, startTime, indexTxn, stores, skip, sourceRemote);
45359
45440
  case "ADD_RELATIONSHIP":
45360
- return this.executeAddRelationship(job, action, startTime, indexTxn, sourceRemote);
45441
+ return this.executeAddRelationship(job, action, startTime, indexTxn, stores, sourceRemote);
45361
45442
  case "REMOVE_RELATIONSHIP":
45362
- return this.executeRemoveRelationship(job, action, startTime, indexTxn, sourceRemote);
45443
+ return this.executeRemoveRelationship(job, action, startTime, indexTxn, stores, sourceRemote);
45363
45444
  default:
45364
45445
  return buildErrorResult(job, new Error(`Unknown document action type: ${action.type}`), startTime);
45365
45446
  }
45366
45447
  }
45367
- async executeCreate(job, action, startTime, indexTxn, skip = 0, sourceRemote = "") {
45448
+ async executeCreate(job, action, startTime, indexTxn, stores, skip = 0, sourceRemote = "") {
45368
45449
  if (job.scope !== "document") {
45369
45450
  return {
45370
45451
  job,
@@ -45384,12 +45465,12 @@ class DocumentActionHandler {
45384
45465
  ...document2.state
45385
45466
  };
45386
45467
  const resultingState = JSON.stringify(resultingStateObj);
45387
- const writeError = await this.writeOperationToStore(document2.header.id, document2.header.documentType, job.scope, job.branch, operation, job, startTime);
45468
+ const writeError = await this.writeOperationToStore(document2.header.id, document2.header.documentType, job.scope, job.branch, operation, job, startTime, stores);
45388
45469
  if (writeError !== null) {
45389
45470
  return writeError;
45390
45471
  }
45391
45472
  updateDocumentRevision(document2, job.scope, operation.index);
45392
- this.writeCache.putState(document2.header.id, job.scope, job.branch, operation.index, document2);
45473
+ stores.writeCache.putState(document2.header.id, job.scope, job.branch, operation.index, document2);
45393
45474
  indexTxn.write([
45394
45475
  {
45395
45476
  ...operation,
@@ -45405,14 +45486,14 @@ class DocumentActionHandler {
45405
45486
  indexTxn.createCollection(collectionId);
45406
45487
  indexTxn.addToCollection(collectionId, document2.header.id);
45407
45488
  }
45408
- this.documentMetaCache.putDocumentMeta(document2.header.id, job.branch, {
45489
+ stores.documentMetaCache.putDocumentMeta(document2.header.id, job.branch, {
45409
45490
  state: document2.state.document,
45410
45491
  documentType: document2.header.documentType,
45411
45492
  documentScopeRevision: 1
45412
45493
  });
45413
45494
  return buildSuccessResult(job, operation, document2.header.id, document2.header.documentType, resultingState, startTime);
45414
45495
  }
45415
- async executeDelete(job, action, startTime, indexTxn, sourceRemote = "") {
45496
+ async executeDelete(job, action, startTime, indexTxn, stores, sourceRemote = "") {
45416
45497
  const input = action.input;
45417
45498
  if (!input.documentId) {
45418
45499
  return buildErrorResult(job, new Error("DELETE_DOCUMENT action requires a documentId in input"), startTime);
@@ -45420,7 +45501,7 @@ class DocumentActionHandler {
45420
45501
  const documentId = input.documentId;
45421
45502
  let document2;
45422
45503
  try {
45423
- document2 = await this.writeCache.getState(documentId, job.scope, job.branch);
45504
+ document2 = await stores.writeCache.getState(documentId, job.scope, job.branch);
45424
45505
  } catch (error3) {
45425
45506
  return buildErrorResult(job, new Error(`Failed to fetch document before deletion: ${error3 instanceof Error ? error3.message : String(error3)}`), startTime);
45426
45507
  }
@@ -45440,12 +45521,12 @@ class DocumentActionHandler {
45440
45521
  document: document2.state.document
45441
45522
  };
45442
45523
  const resultingState = JSON.stringify(resultingStateObj);
45443
- const writeError = await this.writeOperationToStore(documentId, document2.header.documentType, job.scope, job.branch, operation, job, startTime);
45524
+ const writeError = await this.writeOperationToStore(documentId, document2.header.documentType, job.scope, job.branch, operation, job, startTime, stores);
45444
45525
  if (writeError !== null) {
45445
45526
  return writeError;
45446
45527
  }
45447
45528
  updateDocumentRevision(document2, job.scope, operation.index);
45448
- this.writeCache.putState(documentId, job.scope, job.branch, operation.index, document2);
45529
+ stores.writeCache.putState(documentId, job.scope, job.branch, operation.index, document2);
45449
45530
  indexTxn.write([
45450
45531
  {
45451
45532
  ...operation,
@@ -45456,14 +45537,14 @@ class DocumentActionHandler {
45456
45537
  sourceRemote
45457
45538
  }
45458
45539
  ]);
45459
- this.documentMetaCache.putDocumentMeta(documentId, job.branch, {
45540
+ stores.documentMetaCache.putDocumentMeta(documentId, job.branch, {
45460
45541
  state: document2.state.document,
45461
45542
  documentType: document2.header.documentType,
45462
45543
  documentScopeRevision: operation.index + 1
45463
45544
  });
45464
45545
  return buildSuccessResult(job, operation, documentId, document2.header.documentType, resultingState, startTime);
45465
45546
  }
45466
- async executeUpgrade(job, action, startTime, indexTxn, skip = 0, sourceRemote = "") {
45547
+ async executeUpgrade(job, action, startTime, indexTxn, stores, skip = 0, sourceRemote = "") {
45467
45548
  const input = action.input;
45468
45549
  if (!input.documentId) {
45469
45550
  return buildErrorResult(job, new Error("UPGRADE_DOCUMENT action requires a documentId in input"), startTime);
@@ -45473,7 +45554,7 @@ class DocumentActionHandler {
45473
45554
  const toVersion = input.toVersion;
45474
45555
  let document2;
45475
45556
  try {
45476
- document2 = await this.writeCache.getState(documentId, job.scope, job.branch);
45557
+ document2 = await stores.writeCache.getState(documentId, job.scope, job.branch);
45477
45558
  } catch (error3) {
45478
45559
  return buildErrorResult(job, new Error(`Failed to fetch document for upgrade: ${error3 instanceof Error ? error3.message : String(error3)}`), startTime);
45479
45560
  }
@@ -45514,12 +45595,12 @@ class DocumentActionHandler {
45514
45595
  ...document2.state
45515
45596
  };
45516
45597
  const resultingState = JSON.stringify(resultingStateObj);
45517
- const writeError = await this.writeOperationToStore(documentId, document2.header.documentType, job.scope, job.branch, operation, job, startTime);
45598
+ const writeError = await this.writeOperationToStore(documentId, document2.header.documentType, job.scope, job.branch, operation, job, startTime, stores);
45518
45599
  if (writeError !== null) {
45519
45600
  return writeError;
45520
45601
  }
45521
45602
  updateDocumentRevision(document2, job.scope, operation.index);
45522
- this.writeCache.putState(documentId, job.scope, job.branch, operation.index, document2);
45603
+ stores.writeCache.putState(documentId, job.scope, job.branch, operation.index, document2);
45523
45604
  indexTxn.write([
45524
45605
  {
45525
45606
  ...operation,
@@ -45530,14 +45611,14 @@ class DocumentActionHandler {
45530
45611
  sourceRemote
45531
45612
  }
45532
45613
  ]);
45533
- this.documentMetaCache.putDocumentMeta(documentId, job.branch, {
45614
+ stores.documentMetaCache.putDocumentMeta(documentId, job.branch, {
45534
45615
  state: document2.state.document,
45535
45616
  documentType: document2.header.documentType,
45536
45617
  documentScopeRevision: operation.index + 1
45537
45618
  });
45538
45619
  return buildSuccessResult(job, operation, documentId, document2.header.documentType, resultingState, startTime);
45539
45620
  }
45540
- async executeAddRelationship(job, action, startTime, indexTxn, sourceRemote = "") {
45621
+ async executeAddRelationship(job, action, startTime, indexTxn, stores, sourceRemote = "") {
45541
45622
  if (job.scope !== "document") {
45542
45623
  return buildErrorResult(job, new Error(`ADD_RELATIONSHIP must be in "document" scope, got "${job.scope}"`), startTime);
45543
45624
  }
@@ -45550,7 +45631,7 @@ class DocumentActionHandler {
45550
45631
  }
45551
45632
  let sourceDoc;
45552
45633
  try {
45553
- sourceDoc = await this.writeCache.getState(input.sourceId, "document", job.branch);
45634
+ sourceDoc = await stores.writeCache.getState(input.sourceId, "document", job.branch);
45554
45635
  } catch (error3) {
45555
45636
  return buildErrorResult(job, new Error(`ADD_RELATIONSHIP: source document ${input.sourceId} not found: ${error3 instanceof Error ? error3.message : String(error3)}`), startTime);
45556
45637
  }
@@ -45560,7 +45641,7 @@ class DocumentActionHandler {
45560
45641
  scope: job.scope,
45561
45642
  branch: job.branch
45562
45643
  });
45563
- const writeError = await this.writeOperationToStore(input.sourceId, sourceDoc.header.documentType, job.scope, job.branch, operation, job, startTime);
45644
+ const writeError = await this.writeOperationToStore(input.sourceId, sourceDoc.header.documentType, job.scope, job.branch, operation, job, startTime, stores);
45564
45645
  if (writeError !== null) {
45565
45646
  return writeError;
45566
45647
  }
@@ -45576,7 +45657,7 @@ class DocumentActionHandler {
45576
45657
  [job.scope]: scopeState === undefined ? {} : structuredClone(scopeState)
45577
45658
  };
45578
45659
  const resultingState = JSON.stringify(resultingStateObj);
45579
- this.writeCache.putState(input.sourceId, job.scope, job.branch, operation.index, sourceDoc);
45660
+ stores.writeCache.putState(input.sourceId, job.scope, job.branch, operation.index, sourceDoc);
45580
45661
  indexTxn.write([
45581
45662
  {
45582
45663
  ...operation,
@@ -45590,16 +45671,16 @@ class DocumentActionHandler {
45590
45671
  if (sourceDoc.header.documentType === "powerhouse/document-drive") {
45591
45672
  const collectionId = driveCollectionId(job.branch, input.sourceId);
45592
45673
  indexTxn.addToCollection(collectionId, input.targetId);
45593
- this.collectionMembershipCache.invalidate(input.targetId);
45674
+ stores.collectionMembershipCache.invalidate(input.targetId);
45594
45675
  }
45595
- this.documentMetaCache.putDocumentMeta(input.sourceId, job.branch, {
45676
+ stores.documentMetaCache.putDocumentMeta(input.sourceId, job.branch, {
45596
45677
  state: sourceDoc.state.document,
45597
45678
  documentType: sourceDoc.header.documentType,
45598
45679
  documentScopeRevision: operation.index + 1
45599
45680
  });
45600
45681
  return buildSuccessResult(job, operation, input.sourceId, sourceDoc.header.documentType, resultingState, startTime);
45601
45682
  }
45602
- async executeRemoveRelationship(job, action, startTime, indexTxn, sourceRemote = "") {
45683
+ async executeRemoveRelationship(job, action, startTime, indexTxn, stores, sourceRemote = "") {
45603
45684
  if (job.scope !== "document") {
45604
45685
  return buildErrorResult(job, new Error(`REMOVE_RELATIONSHIP must be in "document" scope, got "${job.scope}"`), startTime);
45605
45686
  }
@@ -45609,7 +45690,7 @@ class DocumentActionHandler {
45609
45690
  }
45610
45691
  let sourceDoc;
45611
45692
  try {
45612
- sourceDoc = await this.writeCache.getState(input.sourceId, "document", job.branch);
45693
+ sourceDoc = await stores.writeCache.getState(input.sourceId, "document", job.branch);
45613
45694
  } catch (error3) {
45614
45695
  return buildErrorResult(job, new Error(`REMOVE_RELATIONSHIP: source document ${input.sourceId} not found: ${error3 instanceof Error ? error3.message : String(error3)}`), startTime);
45615
45696
  }
@@ -45619,7 +45700,7 @@ class DocumentActionHandler {
45619
45700
  scope: job.scope,
45620
45701
  branch: job.branch
45621
45702
  });
45622
- const writeError = await this.writeOperationToStore(input.sourceId, sourceDoc.header.documentType, job.scope, job.branch, operation, job, startTime);
45703
+ const writeError = await this.writeOperationToStore(input.sourceId, sourceDoc.header.documentType, job.scope, job.branch, operation, job, startTime, stores);
45623
45704
  if (writeError !== null) {
45624
45705
  return writeError;
45625
45706
  }
@@ -45635,7 +45716,7 @@ class DocumentActionHandler {
45635
45716
  [job.scope]: scopeState === undefined ? {} : structuredClone(scopeState)
45636
45717
  };
45637
45718
  const resultingState = JSON.stringify(resultingStateObj);
45638
- this.writeCache.putState(input.sourceId, job.scope, job.branch, operation.index, sourceDoc);
45719
+ stores.writeCache.putState(input.sourceId, job.scope, job.branch, operation.index, sourceDoc);
45639
45720
  indexTxn.write([
45640
45721
  {
45641
45722
  ...operation,
@@ -45649,24 +45730,24 @@ class DocumentActionHandler {
45649
45730
  if (sourceDoc.header.documentType === "powerhouse/document-drive") {
45650
45731
  const collectionId = driveCollectionId(job.branch, input.sourceId);
45651
45732
  indexTxn.removeFromCollection(collectionId, input.targetId);
45652
- this.collectionMembershipCache.invalidate(input.targetId);
45733
+ stores.collectionMembershipCache.invalidate(input.targetId);
45653
45734
  }
45654
- this.documentMetaCache.putDocumentMeta(input.sourceId, job.branch, {
45735
+ stores.documentMetaCache.putDocumentMeta(input.sourceId, job.branch, {
45655
45736
  state: sourceDoc.state.document,
45656
45737
  documentType: sourceDoc.header.documentType,
45657
45738
  documentScopeRevision: operation.index + 1
45658
45739
  });
45659
45740
  return buildSuccessResult(job, operation, input.sourceId, sourceDoc.header.documentType, resultingState, startTime);
45660
45741
  }
45661
- async writeOperationToStore(documentId, documentType, scope, branch, operation, job, startTime) {
45742
+ async writeOperationToStore(documentId, documentType, scope, branch, operation, job, startTime, stores) {
45662
45743
  try {
45663
- await this.operationStore.apply(documentId, documentType, scope, branch, operation.index, (txn) => {
45744
+ await stores.operationStore.apply(documentId, documentType, scope, branch, operation.index, (txn) => {
45664
45745
  txn.addOperations(operation);
45665
45746
  });
45666
45747
  return null;
45667
45748
  } catch (error3) {
45668
45749
  this.logger.error("Error writing @Operation to IOperationStore: @Error", operation, error3);
45669
- this.writeCache.invalidate(documentId, scope, branch);
45750
+ stores.writeCache.invalidate(documentId, scope, branch);
45670
45751
  return {
45671
45752
  job,
45672
45753
  success: false,
@@ -45755,7 +45836,8 @@ class SimpleJobExecutor {
45755
45836
  config;
45756
45837
  signatureVerifierModule;
45757
45838
  documentActionHandler;
45758
- constructor(logger4, registry, operationStore, eventBus, writeCache, operationIndex, documentMetaCache, collectionMembershipCache, config, signatureVerifier) {
45839
+ executionScope;
45840
+ constructor(logger4, registry, operationStore, eventBus, writeCache, operationIndex, documentMetaCache, collectionMembershipCache, config, signatureVerifier, executionScope) {
45759
45841
  this.logger = logger4;
45760
45842
  this.registry = registry;
45761
45843
  this.operationStore = operationStore;
@@ -45772,71 +45854,101 @@ class SimpleJobExecutor {
45772
45854
  retryMaxDelayMs: config.retryMaxDelayMs ?? 5000
45773
45855
  };
45774
45856
  this.signatureVerifierModule = new SignatureVerifier(signatureVerifier);
45775
- this.documentActionHandler = new DocumentActionHandler(writeCache, operationStore, documentMetaCache, collectionMembershipCache, registry, logger4);
45857
+ this.documentActionHandler = new DocumentActionHandler(registry, logger4);
45858
+ this.executionScope = executionScope ?? new DefaultExecutionScope(operationStore, operationIndex, writeCache, documentMetaCache, collectionMembershipCache);
45776
45859
  }
45777
45860
  async executeJob(job) {
45778
45861
  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
45862
+ const touchedCacheEntries = [];
45863
+ let pendingEvent;
45864
+ let result;
45865
+ try {
45866
+ result = await this.executionScope.run(async (stores) => {
45867
+ const indexTxn = stores.operationIndex.start();
45868
+ if (job.kind === "load") {
45869
+ const loadResult = await this.executeLoadJob(job, startTime, indexTxn, stores);
45870
+ if (loadResult.success && loadResult.operationsWithContext) {
45871
+ for (const owc of loadResult.operationsWithContext) {
45872
+ touchedCacheEntries.push({
45873
+ documentId: owc.context.documentId,
45874
+ scope: owc.context.scope,
45875
+ branch: owc.context.branch
45876
+ });
45877
+ }
45878
+ const ordinals2 = await stores.operationIndex.commit(indexTxn);
45879
+ for (let i3 = 0;i3 < loadResult.operationsWithContext.length; i3++) {
45880
+ loadResult.operationsWithContext[i3].context.ordinal = ordinals2[i3];
45881
+ }
45882
+ const collectionMemberships = loadResult.operationsWithContext.length > 0 ? await this.getCollectionMembershipsForOperations(loadResult.operationsWithContext, stores) : {};
45883
+ pendingEvent = {
45884
+ jobId: job.id,
45885
+ operations: loadResult.operationsWithContext,
45886
+ jobMeta: job.meta,
45887
+ collectionMemberships
45888
+ };
45889
+ }
45890
+ return loadResult;
45891
+ }
45892
+ const actionResult = await this.processActions(job, job.actions, startTime, indexTxn, stores);
45893
+ if (!actionResult.success) {
45894
+ return {
45895
+ job,
45896
+ success: false,
45897
+ error: actionResult.error,
45898
+ duration: Date.now() - startTime
45899
+ };
45900
+ }
45901
+ if (actionResult.operationsWithContext.length > 0) {
45902
+ for (const owc of actionResult.operationsWithContext) {
45903
+ touchedCacheEntries.push({
45904
+ documentId: owc.context.documentId,
45905
+ scope: owc.context.scope,
45906
+ branch: owc.context.branch
45907
+ });
45908
+ }
45909
+ }
45910
+ const ordinals = await stores.operationIndex.commit(indexTxn);
45911
+ if (actionResult.operationsWithContext.length > 0) {
45912
+ for (let i3 = 0;i3 < actionResult.operationsWithContext.length; i3++) {
45913
+ actionResult.operationsWithContext[i3].context.ordinal = ordinals[i3];
45914
+ }
45915
+ const collectionMemberships = await this.getCollectionMembershipsForOperations(actionResult.operationsWithContext, stores);
45916
+ pendingEvent = {
45917
+ jobId: job.id,
45918
+ operations: actionResult.operationsWithContext,
45919
+ jobMeta: job.meta,
45920
+ collectionMemberships
45921
+ };
45922
+ }
45923
+ return {
45924
+ job,
45925
+ success: true,
45926
+ operations: actionResult.generatedOperations,
45927
+ operationsWithContext: actionResult.operationsWithContext,
45928
+ duration: Date.now() - startTime
45793
45929
  };
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
- });
45930
+ });
45931
+ } catch (error3) {
45932
+ for (const entry of touchedCacheEntries) {
45933
+ this.writeCache.invalidate(entry.documentId, entry.scope, entry.branch);
45934
+ this.documentMetaCache.invalidate(entry.documentId, entry.branch);
45797
45935
  }
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
- };
45936
+ throw error3;
45808
45937
  }
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);
45938
+ if (pendingEvent) {
45939
+ this.eventBus.emit(ReactorEventTypes.JOB_WRITE_READY, pendingEvent).catch((error3) => {
45940
+ this.logger.error("Failed to emit JOB_WRITE_READY event: @Event : @Error", pendingEvent, error3);
45823
45941
  });
45824
45942
  }
45825
- return {
45826
- job,
45827
- success: true,
45828
- operations: result.generatedOperations,
45829
- operationsWithContext: result.operationsWithContext,
45830
- duration: Date.now() - startTime
45831
- };
45943
+ return result;
45832
45944
  }
45833
- async getCollectionMembershipsForOperations(operations) {
45945
+ async getCollectionMembershipsForOperations(operations, stores) {
45834
45946
  const documentIds = [
45835
45947
  ...new Set(operations.map((op) => op.context.documentId))
45836
45948
  ];
45837
- return this.collectionMembershipCache.getCollectionsForDocuments(documentIds);
45949
+ return stores.collectionMembershipCache.getCollectionsForDocuments(documentIds);
45838
45950
  }
45839
- async processActions(job, actions2, startTime, indexTxn, skipValues, sourceOperations, sourceRemote = "") {
45951
+ async processActions(job, actions2, startTime, indexTxn, stores, skipValues, sourceOperations, sourceRemote = "") {
45840
45952
  const generatedOperations = [];
45841
45953
  const operationsWithContext = [];
45842
45954
  try {
@@ -45854,7 +45966,7 @@ class SimpleJobExecutor {
45854
45966
  const skip = skipValues?.[actionIndex] ?? 0;
45855
45967
  const sourceOperation = sourceOperations?.[actionIndex];
45856
45968
  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);
45969
+ 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
45970
  const error3 = this.accumulateResultOrReturnError(result, generatedOperations, operationsWithContext);
45859
45971
  if (error3 !== null) {
45860
45972
  return {
@@ -45871,10 +45983,10 @@ class SimpleJobExecutor {
45871
45983
  operationsWithContext
45872
45984
  };
45873
45985
  }
45874
- async executeRegularAction(job, action, startTime, indexTxn, skip = 0, sourceOperation, sourceRemote = "") {
45986
+ async executeRegularAction(job, action, startTime, indexTxn, stores, skip = 0, sourceOperation, sourceRemote = "") {
45875
45987
  let docMeta;
45876
45988
  try {
45877
- docMeta = await this.documentMetaCache.getDocumentMeta(job.documentId, job.branch);
45989
+ docMeta = await stores.documentMetaCache.getDocumentMeta(job.documentId, job.branch);
45878
45990
  } catch (error3) {
45879
45991
  return buildErrorResult(job, error3 instanceof Error ? error3 : new Error(String(error3)), startTime);
45880
45992
  }
@@ -45882,11 +45994,11 @@ class SimpleJobExecutor {
45882
45994
  return buildErrorResult(job, new DocumentDeletedError(job.documentId, docMeta.state.deletedAtUtcIso), startTime);
45883
45995
  }
45884
45996
  if (isUndoRedo(action) || action.type === "PRUNE" || action.type === "NOOP" && skip > 0) {
45885
- this.writeCache.invalidate(job.documentId, job.scope, job.branch);
45997
+ stores.writeCache.invalidate(job.documentId, job.scope, job.branch);
45886
45998
  }
45887
45999
  let document2;
45888
46000
  try {
45889
- document2 = await this.writeCache.getState(job.documentId, job.scope, job.branch);
46001
+ document2 = await stores.writeCache.getState(job.documentId, job.scope, job.branch);
45890
46002
  } catch (error3) {
45891
46003
  return buildErrorResult(job, error3 instanceof Error ? error3 : new Error(String(error3)), startTime);
45892
46004
  }
@@ -45937,12 +46049,12 @@ ${error3.stack}`;
45937
46049
  header: updatedDocument.header
45938
46050
  });
45939
46051
  try {
45940
- await this.operationStore.apply(job.documentId, document2.header.documentType, scope, job.branch, newOperation.index, (txn) => {
46052
+ await stores.operationStore.apply(job.documentId, document2.header.documentType, scope, job.branch, newOperation.index, (txn) => {
45941
46053
  txn.addOperations(newOperation);
45942
46054
  });
45943
46055
  } catch (error3) {
45944
46056
  this.logger.error("Error writing @Operation to IOperationStore: @Error", newOperation, error3);
45945
- this.writeCache.invalidate(job.documentId, scope, job.branch);
46057
+ stores.writeCache.invalidate(job.documentId, scope, job.branch);
45946
46058
  return {
45947
46059
  job,
45948
46060
  success: false,
@@ -45954,7 +46066,7 @@ ${error3.stack}`;
45954
46066
  ...updatedDocument.header.revision,
45955
46067
  [scope]: newOperation.index + 1
45956
46068
  };
45957
- this.writeCache.putState(job.documentId, scope, job.branch, newOperation.index, updatedDocument);
46069
+ stores.writeCache.putState(job.documentId, scope, job.branch, newOperation.index, updatedDocument);
45958
46070
  indexTxn.write([
45959
46071
  {
45960
46072
  ...newOperation,
@@ -45985,13 +46097,13 @@ ${error3.stack}`;
45985
46097
  duration: Date.now() - startTime
45986
46098
  };
45987
46099
  }
45988
- async executeLoadJob(job, startTime, indexTxn) {
46100
+ async executeLoadJob(job, startTime, indexTxn, stores) {
45989
46101
  if (job.operations.length === 0) {
45990
46102
  return buildErrorResult(job, new Error("Load job must include at least one operation"), startTime);
45991
46103
  }
45992
46104
  let docMeta;
45993
46105
  try {
45994
- docMeta = await this.documentMetaCache.getDocumentMeta(job.documentId, job.branch);
46106
+ docMeta = await stores.documentMetaCache.getDocumentMeta(job.documentId, job.branch);
45995
46107
  } catch {}
45996
46108
  if (docMeta?.state.isDeleted) {
45997
46109
  return buildErrorResult(job, new DocumentDeletedError(job.documentId, docMeta.state.deletedAtUtcIso), startTime);
@@ -45999,7 +46111,7 @@ ${error3.stack}`;
45999
46111
  const scope = job.scope;
46000
46112
  let latestRevision = 0;
46001
46113
  try {
46002
- const revisions = await this.operationStore.getRevisions(job.documentId, job.branch);
46114
+ const revisions = await stores.operationStore.getRevisions(job.documentId, job.branch);
46003
46115
  latestRevision = revisions.revision[scope] ?? 0;
46004
46116
  } catch {
46005
46117
  latestRevision = 0;
@@ -46015,7 +46127,7 @@ ${error3.stack}`;
46015
46127
  }
46016
46128
  let conflictingOps = [];
46017
46129
  try {
46018
- const conflictingResult = await this.operationStore.getConflicting(job.documentId, scope, job.branch, minIncomingTimestamp);
46130
+ const conflictingResult = await stores.operationStore.getConflicting(job.documentId, scope, job.branch, minIncomingTimestamp);
46019
46131
  conflictingOps = conflictingResult.results;
46020
46132
  } catch {
46021
46133
  conflictingOps = [];
@@ -46024,7 +46136,7 @@ ${error3.stack}`;
46024
46136
  if (conflictingOps.length > 0) {
46025
46137
  const minConflictingIndex = Math.min(...conflictingOps.map((op) => op.index));
46026
46138
  try {
46027
- const allOpsResult = await this.operationStore.getSince(job.documentId, scope, job.branch, minConflictingIndex - 1);
46139
+ const allOpsResult = await stores.operationStore.getSince(job.documentId, scope, job.branch, minConflictingIndex - 1);
46028
46140
  allOpsFromMinConflictingIndex = allOpsResult.results;
46029
46141
  } catch {
46030
46142
  allOpsFromMinConflictingIndex = conflictingOps;
@@ -46085,7 +46197,7 @@ ${error3.stack}`;
46085
46197
  const actions2 = reshuffledOperations.map((operation) => operation.action);
46086
46198
  const skipValues = reshuffledOperations.map((operation) => operation.skip);
46087
46199
  const effectiveSourceRemote = skipCount > 0 ? "" : job.meta.sourceRemote || "";
46088
- const result = await this.processActions(job, actions2, startTime, indexTxn, skipValues, reshuffledOperations, effectiveSourceRemote);
46200
+ const result = await this.processActions(job, actions2, startTime, indexTxn, stores, skipValues, reshuffledOperations, effectiveSourceRemote);
46089
46201
  if (!result.success) {
46090
46202
  return {
46091
46203
  job,
@@ -46094,9 +46206,9 @@ ${error3.stack}`;
46094
46206
  duration: Date.now() - startTime
46095
46207
  };
46096
46208
  }
46097
- this.writeCache.invalidate(job.documentId, scope, job.branch);
46209
+ stores.writeCache.invalidate(job.documentId, scope, job.branch);
46098
46210
  if (scope === "document") {
46099
- this.documentMetaCache.invalidate(job.documentId, job.branch);
46211
+ stores.documentMetaCache.invalidate(job.documentId, job.branch);
46100
46212
  }
46101
46213
  return {
46102
46214
  job,
@@ -47045,14 +47157,23 @@ async function collectAllPages(firstPage, signal) {
47045
47157
 
47046
47158
  class KyselyKeyframeStore {
47047
47159
  db;
47160
+ trx;
47048
47161
  constructor(db) {
47049
47162
  this.db = db;
47050
47163
  }
47164
+ get queryExecutor() {
47165
+ return this.trx ?? this.db;
47166
+ }
47167
+ withTransaction(trx) {
47168
+ const instance2 = new KyselyKeyframeStore(this.db);
47169
+ instance2.trx = trx;
47170
+ return instance2;
47171
+ }
47051
47172
  async putKeyframe(documentId, scope, branch, revision, document2, signal) {
47052
47173
  if (signal?.aborted) {
47053
47174
  throw new Error("Operation aborted");
47054
47175
  }
47055
- await this.db.insertInto("Keyframe").values({
47176
+ await this.queryExecutor.insertInto("Keyframe").values({
47056
47177
  documentId,
47057
47178
  documentType: document2.header.documentType,
47058
47179
  scope,
@@ -47065,7 +47186,7 @@ class KyselyKeyframeStore {
47065
47186
  if (signal?.aborted) {
47066
47187
  throw new Error("Operation aborted");
47067
47188
  }
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();
47189
+ 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
47190
  if (!row) {
47070
47191
  return;
47071
47192
  }
@@ -47078,7 +47199,7 @@ class KyselyKeyframeStore {
47078
47199
  if (signal?.aborted) {
47079
47200
  throw new Error("Operation aborted");
47080
47201
  }
47081
- let query = this.db.deleteFrom("Keyframe").where("documentId", "=", documentId);
47202
+ let query = this.queryExecutor.deleteFrom("Keyframe").where("documentId", "=", documentId);
47082
47203
  if (scope !== undefined && branch !== undefined) {
47083
47204
  query = query.where("scope", "=", scope).where("branch", "=", branch);
47084
47205
  } else if (scope !== undefined) {
@@ -47129,48 +47250,64 @@ class AtomicTransaction {
47129
47250
 
47130
47251
  class KyselyOperationStore {
47131
47252
  db;
47253
+ trx;
47132
47254
  constructor(db) {
47133
47255
  this.db = db;
47134
47256
  }
47257
+ get queryExecutor() {
47258
+ return this.trx ?? this.db;
47259
+ }
47260
+ withTransaction(trx) {
47261
+ const instance2 = new KyselyOperationStore(this.db);
47262
+ instance2.trx = trx;
47263
+ return instance2;
47264
+ }
47135
47265
  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);
47266
+ if (this.trx) {
47267
+ await this.executeApply(this.trx, documentId, documentType, scope, branch, revision, fn, signal);
47268
+ } else {
47269
+ await this.db.transaction().execute(async (trx) => {
47270
+ await this.executeApply(trx, documentId, documentType, scope, branch, revision, fn, signal);
47271
+ });
47272
+ }
47273
+ }
47274
+ async executeApply(trx, documentId, documentType, scope, branch, revision, fn, signal) {
47275
+ if (signal?.aborted) {
47276
+ throw new Error("Operation aborted");
47277
+ }
47278
+ const latestOp = await trx.selectFrom("Operation").selectAll().where("documentId", "=", documentId).where("scope", "=", scope).where("branch", "=", branch).orderBy("index", "desc").limit(1).executeTakeFirst();
47279
+ const currentRevision = latestOp ? latestOp.index : -1;
47280
+ if (currentRevision !== revision - 1) {
47281
+ throw new RevisionMismatchError(currentRevision + 1, revision);
47282
+ }
47283
+ const atomicTxn = new AtomicTransaction(documentId, documentType, scope, branch, revision);
47284
+ await fn(atomicTxn);
47285
+ const operations = atomicTxn.getOperations();
47286
+ if (operations.length > 0) {
47287
+ let prevOpId = latestOp?.opId || "";
47288
+ for (const op of operations) {
47289
+ op.prevOpId = prevOpId;
47290
+ prevOpId = op.opId;
47144
47291
  }
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;
47292
+ try {
47293
+ await trx.insertInto("Operation").values(operations).execute();
47294
+ } catch (error3) {
47295
+ if (error3 instanceof Error) {
47296
+ if (error3.message.includes("unique constraint")) {
47297
+ const op = operations[0];
47298
+ throw new DuplicateOperationError(`${op.opId} at index ${op.index} with skip ${op.skip}`);
47163
47299
  }
47164
47300
  throw error3;
47165
47301
  }
47302
+ throw error3;
47166
47303
  }
47167
- });
47304
+ }
47168
47305
  }
47169
47306
  async getSince(documentId, scope, branch, revision, filter, paging, signal) {
47170
47307
  if (signal?.aborted) {
47171
47308
  throw new Error("Operation aborted");
47172
47309
  }
47173
- let query = this.db.selectFrom("Operation").selectAll().where("documentId", "=", documentId).where("scope", "=", scope).where("branch", "=", branch).where("index", ">", revision).orderBy("index", "asc");
47310
+ let query = this.queryExecutor.selectFrom("Operation").selectAll().where("documentId", "=", documentId).where("scope", "=", scope).where("branch", "=", branch).where("index", ">", revision).orderBy("index", "asc");
47174
47311
  if (filter) {
47175
47312
  if (filter.actionTypes && filter.actionTypes.length > 0) {
47176
47313
  const actionTypesArray = filter.actionTypes.map((t4) => `'${t4.replace(/'/g, "''")}'`).join(",");
@@ -47217,7 +47354,7 @@ class KyselyOperationStore {
47217
47354
  if (signal?.aborted) {
47218
47355
  throw new Error("Operation aborted");
47219
47356
  }
47220
- let query = this.db.selectFrom("Operation").selectAll().where("id", ">", id).orderBy("id", "asc");
47357
+ let query = this.queryExecutor.selectFrom("Operation").selectAll().where("id", ">", id).orderBy("id", "asc");
47221
47358
  if (paging) {
47222
47359
  const cursorValue = Number.parseInt(paging.cursor, 10);
47223
47360
  if (cursorValue > 0) {
@@ -47249,7 +47386,7 @@ class KyselyOperationStore {
47249
47386
  if (signal?.aborted) {
47250
47387
  throw new Error("Operation aborted");
47251
47388
  }
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");
47389
+ 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
47390
  if (paging) {
47254
47391
  const cursorValue = Number.parseInt(paging.cursor, 10);
47255
47392
  if (cursorValue > 0) {
@@ -47281,7 +47418,7 @@ class KyselyOperationStore {
47281
47418
  if (signal?.aborted) {
47282
47419
  throw new Error("Operation aborted");
47283
47420
  }
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();
47421
+ 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
47422
  const revision = {};
47286
47423
  let latestTimestamp = new Date(0).toISOString();
47287
47424
  for (const row of scopeRevisions) {
@@ -51075,9 +51212,10 @@ class ReactorBuilder {
51075
51212
  });
51076
51213
  await documentMetaCache.startup();
51077
51214
  const collectionMembershipCache = new CollectionMembershipCache(operationIndex);
51215
+ const executionScope = new KyselyExecutionScope(database, operationStore, operationIndex, keyframeStore, writeCache, documentMetaCache, collectionMembershipCache);
51078
51216
  let executorManager = this.executorManager;
51079
51217
  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);
51218
+ 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
51219
  }
51082
51220
  await executorManager.start(this.executorConfig.maxConcurrency ?? 1);
51083
51221
  const readModelInstances = Array.from(new Set([...this.readModels]));
@@ -51208,6 +51346,7 @@ class ReactorClientBuilder {
51208
51346
  signatureVerifier;
51209
51347
  subscriptionManager;
51210
51348
  jobAwaiter;
51349
+ documentModelLoader;
51211
51350
  withLogger(logger4) {
51212
51351
  this.logger = logger4;
51213
51352
  return this;
@@ -51246,6 +51385,10 @@ class ReactorClientBuilder {
51246
51385
  this.jobAwaiter = jobAwaiter;
51247
51386
  return this;
51248
51387
  }
51388
+ withDocumentModelLoader(loader) {
51389
+ this.documentModelLoader = loader;
51390
+ return this;
51391
+ }
51249
51392
  async build() {
51250
51393
  const module = await this.buildModule();
51251
51394
  return module.client;
@@ -51263,6 +51406,9 @@ class ReactorClientBuilder {
51263
51406
  if (this.signatureVerifier) {
51264
51407
  this.reactorBuilder.withSignatureVerifier(this.signatureVerifier);
51265
51408
  }
51409
+ if (this.documentModelLoader) {
51410
+ this.reactorBuilder.withDocumentModelLoader(this.documentModelLoader);
51411
+ }
51266
51412
  reactorModule = await this.reactorBuilder.buildModule();
51267
51413
  reactor = reactorModule.reactor;
51268
51414
  eventBus = reactorModule.eventBus;
@@ -56723,6 +56869,7 @@ __export(exports_src, {
56723
56869
  useVetraPackages: () => useVetraPackages,
56724
56870
  useVetraPackageManager: () => useVetraPackageManager,
56725
56871
  useUserPermissions: () => useUserPermissions,
56872
+ useUser: () => useUser,
56726
56873
  useSupportedDocumentTypesInReactor: () => useSupportedDocumentTypesInReactor,
56727
56874
  useSubgraphModules: () => useSubgraphModules,
56728
56875
  useSetPHDriveEditorConfig: () => useSetPHDriveEditorConfig,
@@ -56741,8 +56888,12 @@ __export(exports_src, {
56741
56888
  useSelectedDocumentId: () => useSelectedDocumentId,
56742
56889
  useSelectedDocument: () => useSelectedDocument,
56743
56890
  useRevisionHistoryVisible: () => useRevisionHistoryVisible,
56891
+ useRenownInit: () => useRenownInit,
56892
+ useRenownAuth: () => useRenownAuth,
56893
+ useRenown: () => useRenown,
56744
56894
  useRelationalQuery: () => useRelationalQuery,
56745
56895
  useRelationalDb: () => useRelationalDb,
56896
+ usePendingInstallations: () => usePendingInstallations,
56746
56897
  useParentFolderForSelectedNode: () => useParentFolderForSelectedNode,
56747
56898
  usePHToast: () => usePHToast,
56748
56899
  usePHModal: () => usePHModal,
@@ -56758,6 +56909,8 @@ __export(exports_src, {
56758
56909
  useNodeParentFolderById: () => useNodeParentFolderById,
56759
56910
  useNodeById: () => useNodeById,
56760
56911
  useNodeActions: () => useNodeActions,
56912
+ useLoginStatus: () => useLoginStatus,
56913
+ useLoading: () => useLoading,
56761
56914
  useIsExternalControlsEnabled: () => useIsExternalControlsEnabled,
56762
56915
  useIsDragAndDropEnabled: () => useIsDragAndDropEnabled,
56763
56916
  useInspectorEnabled: () => useInspectorEnabled,
@@ -56793,6 +56946,8 @@ __export(exports_src, {
56793
56946
  useDocumentCache: () => useDocumentCache,
56794
56947
  useDocumentById: () => useDocumentById,
56795
56948
  useDocument: () => useDocument,
56949
+ useDismissedPackages: () => useDismissedPackages,
56950
+ useDid: () => useDid,
56796
56951
  useDefaultDriveEditorModule: () => useDefaultDriveEditorModule,
56797
56952
  useConnectionStates: () => useConnectionStates,
56798
56953
  useConnectionState: () => useConnectionState,
@@ -56817,6 +56972,7 @@ __export(exports_src, {
56817
56972
  setPHDriveEditorConfig: () => setPHDriveEditorConfig,
56818
56973
  setPHDocumentEditorConfigByKey: () => setPHDocumentEditorConfigByKey,
56819
56974
  setPHDocumentEditorConfig: () => setPHDocumentEditorConfig,
56975
+ setLoading: () => setLoading,
56820
56976
  setGlobal: () => setGlobal,
56821
56977
  setFeatures: () => setFeatures,
56822
56978
  setDriveSharingType: () => setDriveSharingType,
@@ -56836,6 +56992,7 @@ __export(exports_src, {
56836
56992
  makeDriveUrlComponent: () => makeDriveUrlComponent,
56837
56993
  logout: () => logout,
56838
56994
  login: () => login,
56995
+ loading: () => loading,
56839
56996
  isInspectorEnabledSync: () => isInspectorEnabledSync,
56840
56997
  isFolderNodeKind: () => isFolderNodeKind,
56841
56998
  isFileNodeKind: () => isFileNodeKind,
@@ -56884,6 +57041,7 @@ __export(exports_src, {
56884
57041
  baseDocumentModelsMap: () => baseDocumentModelsMap,
56885
57042
  baseDocumentModels: () => baseDocumentModels,
56886
57043
  addTrigger: () => addTrigger,
57044
+ addRenownEventHandler: () => addRenownEventHandler,
56887
57045
  addRemoteDrive: () => addRemoteDrive,
56888
57046
  addPromiseState: () => addPromiseState,
56889
57047
  addFolder: () => addFolder,
@@ -56895,10 +57053,10 @@ __export(exports_src, {
56895
57053
  SyncOperationStatus: () => SyncOperationStatus,
56896
57054
  SpinnerIcon: () => SpinnerIcon,
56897
57055
  RenownUserButton: () => RenownUserButton,
56898
- RenownProvider: () => RenownProvider,
56899
57056
  RenownLogo: () => RenownLogo,
56900
57057
  RenownLoginButton: () => RenownLoginButton,
56901
57058
  RenownAuthButton: () => RenownAuthButton,
57059
+ Renown: () => Renown2,
56902
57060
  RemoteDocumentController: () => RemoteDocumentController,
56903
57061
  RemoteClient: () => RemoteClient,
56904
57062
  RelationalDbProcessor: () => RelationalDbProcessor,
@@ -56916,7 +57074,6 @@ __export(exports_src, {
56916
57074
  InMemoryQueue: () => InMemoryQueue,
56917
57075
  ISSUER_TYPE: () => ISSUER_TYPE,
56918
57076
  GqlRequestChannel: () => GqlRequestChannel,
56919
- ExternalLinkIcon: () => ExternalLinkIcon,
56920
57077
  DocumentChangeType: () => DocumentChangeType,
56921
57078
  DocumentCache: () => DocumentCache,
56922
57079
  DisconnectIcon: () => DisconnectIcon,
@@ -56925,6 +57082,7 @@ __export(exports_src, {
56925
57082
  CopyIcon: () => CopyIcon,
56926
57083
  ConsoleLogger: () => ConsoleLogger,
56927
57084
  ConflictError: () => ConflictError,
57085
+ ChevronDownIcon: () => ChevronDownIcon,
56928
57086
  ChannelScheme: () => ChannelScheme,
56929
57087
  CREDENTIAL_TYPES: () => CREDENTIAL_TYPES,
56930
57088
  CREDENTIAL_SUBJECT_TYPE: () => CREDENTIAL_SUBJECT_TYPE,
@@ -56964,17 +57122,20 @@ import {
56964
57122
  setSharingType
56965
57123
  } from "document-drive";
56966
57124
  import { documentModelDocumentModelModule } from "document-model";
57125
+ import { useCallback as useCallback2 } from "react";
57126
+ import { useEffect as useEffect4, useState as useState3, useSyncExternalStore as useSyncExternalStore22 } from "react";
56967
57127
  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
57128
  import { logger as logger5 } from "document-drive";
56971
- import { use as use2, useCallback as useCallback2, useSyncExternalStore as useSyncExternalStore32 } from "react";
57129
+ import { useSyncExternalStore as useSyncExternalStore32 } from "react";
57130
+ import { logger as logger6 } from "document-drive";
57131
+ import { use as use2, useCallback as useCallback22, useSyncExternalStore as useSyncExternalStore4 } from "react";
56972
57132
  import { useEffect as useEffect22, useState as useState22 } from "react";
57133
+ import { useEffect as useEffect32, useRef as useRef3, useState as useState32 } from "react";
56973
57134
  import {
56974
57135
  DocumentModelNotFoundError,
56975
57136
  DocumentNotFoundError as DocumentNotFoundError2
56976
57137
  } from "document-drive";
56977
- import { useCallback as useCallback3, useEffect as useEffect32, useRef as useRef22, useState as useState32 } from "react";
57138
+ import { useCallback as useCallback4, useEffect as useEffect42, useRef as useRef22, useState as useState4 } from "react";
56978
57139
  import { isFileNode as isFileNode2 } from "document-drive";
56979
57140
  import { useMemo as useMemo2 } from "react";
56980
57141
  import {
@@ -56984,20 +57145,24 @@ import {
56984
57145
  } from "document-model";
56985
57146
  import { createState } from "document-model";
56986
57147
  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
57148
  import { useEffect as useEffect5, useState as useState5 } from "react";
56990
57149
  import { createRelationalDbLegacy } from "document-drive";
56991
57150
  import { useMemo as useMemo22 } from "react";
56992
57151
  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";
57152
+ import { useCallback as useCallback5, useMemo as useMemo3, useRef as useRef4 } from "react";
57153
+ import { useCallback as useCallback6, useState as useState7 } from "react";
56995
57154
  import { jsxDEV as jsxDEV2 } from "react/jsx-dev-runtime";
57155
+ import {
57156
+ Children as Children2,
57157
+ cloneElement as cloneElement2,
57158
+ forwardRef,
57159
+ isValidElement as isValidElement3
57160
+ } from "react";
56996
57161
  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";
57162
+ import { useCallback as useCallback7, useEffect as useEffect7, useRef as useRef5, useState as useState8 } from "react";
56998
57163
  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";
57164
+ import { jsxDEV as jsxDEV4, Fragment as Fragment2 } from "react/jsx-dev-runtime";
57165
+ import { useRef as useRef6 } from "react";
57001
57166
  function asUint8Array(buf) {
57002
57167
  if (globalThis.Buffer != null) {
57003
57168
  return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
@@ -60348,38 +60513,61 @@ function makePHEventFunctions(key) {
60348
60513
  const setEventName = `ph:set${capitalCase(key)}`;
60349
60514
  const updateEventName = `ph:${key}Updated`;
60350
60515
  function setValue(value) {
60516
+ if (isServer) {
60517
+ return;
60518
+ }
60351
60519
  const event = new CustomEvent(setEventName, {
60352
60520
  detail: { [key]: value }
60353
60521
  });
60354
60522
  window.dispatchEvent(event);
60355
60523
  }
60356
60524
  function dispatchUpdatedEvent() {
60525
+ if (isServer) {
60526
+ return;
60527
+ }
60357
60528
  const event = new CustomEvent(updateEventName);
60358
60529
  window.dispatchEvent(event);
60359
60530
  }
60360
60531
  function handleSetValueEvent(event) {
60532
+ if (isServer) {
60533
+ return;
60534
+ }
60361
60535
  const value = event.detail[key];
60362
- if (!window.ph)
60363
- throw new Error("ph global store is not defined");
60536
+ if (!window.ph) {
60537
+ window.ph = {};
60538
+ }
60364
60539
  window.ph[key] = value;
60365
60540
  dispatchUpdatedEvent();
60366
60541
  }
60367
60542
  function addEventHandler() {
60543
+ if (isServer) {
60544
+ return;
60545
+ }
60368
60546
  window.addEventListener(setEventName, handleSetValueEvent);
60369
60547
  }
60370
60548
  function subscribeToValue(onStoreChange) {
60549
+ if (isServer)
60550
+ return () => {};
60371
60551
  window.addEventListener(updateEventName, onStoreChange);
60372
60552
  return () => {
60373
60553
  window.removeEventListener(updateEventName, onStoreChange);
60374
60554
  };
60375
60555
  }
60376
60556
  function getSnapshot() {
60377
- if (!window.ph)
60378
- throw new Error("ph global store is not defined");
60557
+ if (isServer) {
60558
+ return;
60559
+ }
60560
+ if (!window.ph) {
60561
+ console.warn(`ph global store is not initialized. Did you call set${capitalCase(key)}?`);
60562
+ return;
60563
+ }
60379
60564
  return window.ph[key];
60380
60565
  }
60566
+ function getServerSnapshot() {
60567
+ return;
60568
+ }
60381
60569
  function useValue() {
60382
- return useSyncExternalStore3(subscribeToValue, getSnapshot);
60570
+ return useSyncExternalStore3(subscribeToValue, getSnapshot, getServerSnapshot);
60383
60571
  }
60384
60572
  return {
60385
60573
  useValue,
@@ -60387,6 +60575,138 @@ function makePHEventFunctions(key) {
60387
60575
  addEventHandler
60388
60576
  };
60389
60577
  }
60578
+ function useDid() {
60579
+ const renown = useRenown();
60580
+ return renown?.did;
60581
+ }
60582
+ function useUser() {
60583
+ const renown = useRenown();
60584
+ const [user, setUser2] = useState3(renown?.user);
60585
+ useEffect4(() => {
60586
+ setUser2(renown?.user);
60587
+ if (!renown)
60588
+ return;
60589
+ return renown.on("user", setUser2);
60590
+ }, [renown]);
60591
+ return user;
60592
+ }
60593
+ function useLoginStatus() {
60594
+ const renown = useRenown();
60595
+ return useSyncExternalStore22((cb) => {
60596
+ if (!renown) {
60597
+ return () => {};
60598
+ }
60599
+ return renown.on("status", cb);
60600
+ }, () => renown === loading ? "loading" : renown?.status, () => {
60601
+ return;
60602
+ });
60603
+ }
60604
+ function openRenown(documentId) {
60605
+ const renown = window.ph?.renown;
60606
+ let renownUrl = renown?.baseUrl;
60607
+ if (!renownUrl) {
60608
+ logger5.warn("Renown instance not found, falling back to: ", RENOWN_URL);
60609
+ renownUrl = RENOWN_URL;
60610
+ }
60611
+ if (documentId) {
60612
+ window.open(`${renownUrl}/profile/${documentId}`, "_blank")?.focus();
60613
+ return;
60614
+ }
60615
+ const url = new URL(renownUrl);
60616
+ url.searchParams.set("app", renown?.did ?? "");
60617
+ url.searchParams.set("connect", renown?.did ?? "");
60618
+ url.searchParams.set("network", RENOWN_NETWORK_ID);
60619
+ url.searchParams.set("chain", RENOWN_CHAIN_ID);
60620
+ const returnUrl = new URL(window.location.pathname, window.location.origin);
60621
+ url.searchParams.set("returnUrl", returnUrl.toJSON());
60622
+ window.open(url, "_self")?.focus();
60623
+ }
60624
+ function consumeDidFromUrl() {
60625
+ if (typeof window === "undefined")
60626
+ return;
60627
+ const urlParams = new URLSearchParams(window.location.search);
60628
+ const userParam = urlParams.get("user");
60629
+ if (!userParam)
60630
+ return;
60631
+ const userDid = decodeURIComponent(userParam);
60632
+ const cleanUrl = new URL(window.location.href);
60633
+ cleanUrl.searchParams.delete("user");
60634
+ window.history.replaceState({}, "", cleanUrl.toString());
60635
+ return userDid;
60636
+ }
60637
+ async function login(userDid, renown) {
60638
+ if (!renown) {
60639
+ return;
60640
+ }
60641
+ const did = userDid ?? consumeDidFromUrl();
60642
+ try {
60643
+ const user = renown.user;
60644
+ if (user?.did && (user.did === did || !did)) {
60645
+ return user;
60646
+ }
60647
+ if (!did) {
60648
+ return;
60649
+ }
60650
+ return await renown.login(did);
60651
+ } catch (error3) {
60652
+ logger5.error(error3 instanceof Error ? error3.message : JSON.stringify(error3));
60653
+ }
60654
+ }
60655
+ async function logout() {
60656
+ const renown = window.ph?.renown;
60657
+ await renown?.logout();
60658
+ const url = new URL(window.location.href);
60659
+ if (url.searchParams.has("user")) {
60660
+ url.searchParams.delete("user");
60661
+ window.history.replaceState(null, "", url.toString());
60662
+ }
60663
+ }
60664
+ function truncateAddress(address) {
60665
+ if (address.length <= 13)
60666
+ return address;
60667
+ return `${address.slice(0, 7)}...${address.slice(-5)}`;
60668
+ }
60669
+ function toRenownAuthStatus(loginStatus, user) {
60670
+ if (loginStatus === "authorized") {
60671
+ return user ? "authorized" : "checking";
60672
+ }
60673
+ return loginStatus;
60674
+ }
60675
+ function useRenownAuth() {
60676
+ const user = useUser();
60677
+ const loginStatus = useLoginStatus();
60678
+ const status = toRenownAuthStatus(loginStatus, user);
60679
+ const address = user?.address;
60680
+ const ensName = user?.ens?.name;
60681
+ const avatarUrl = user?.profile?.userImage ?? user?.ens?.avatarUrl;
60682
+ const profileId = user?.profile?.documentId;
60683
+ const displayName = ensName ?? user?.profile?.username ?? undefined;
60684
+ const displayAddress = address ? truncateAddress(address) : undefined;
60685
+ const login2 = useCallback2(() => {
60686
+ openRenown();
60687
+ }, []);
60688
+ const logout2 = useCallback2(async () => {
60689
+ await logout();
60690
+ }, []);
60691
+ const openProfile = useCallback2(() => {
60692
+ if (profileId) {
60693
+ openRenown(profileId);
60694
+ }
60695
+ }, [profileId]);
60696
+ return {
60697
+ status,
60698
+ user,
60699
+ address,
60700
+ ensName,
60701
+ avatarUrl,
60702
+ profileId,
60703
+ displayName,
60704
+ displayAddress,
60705
+ login: login2,
60706
+ logout: logout2,
60707
+ openProfile
60708
+ };
60709
+ }
60390
60710
  function useAllowedDocumentTypes() {
60391
60711
  const definedAllowedDocumentTypes = allowedDocumentTypesEventFunctions.useValue();
60392
60712
  return definedAllowedDocumentTypes;
@@ -60398,6 +60718,14 @@ function setVetraPackageManager(packageManager) {
60398
60718
  updateReactorClientDocumentModels(packages);
60399
60719
  });
60400
60720
  }
60721
+ function usePendingInstallations() {
60722
+ const pm = useVetraPackageManager();
60723
+ return useSyncExternalStore32((cb) => pm ? pm.subscribePendingChanges(cb) : NOOP_UNSUBSCRIBE, () => pm?.getPendingInstallations() ?? EMPTY_PENDING);
60724
+ }
60725
+ function useDismissedPackages() {
60726
+ const pm = useVetraPackageManager();
60727
+ return useSyncExternalStore32((cb) => pm ? pm.subscribePendingChanges(cb) : NOOP_UNSUBSCRIBE, () => pm?.getDismissedPackages() ?? EMPTY_DISMISSED);
60728
+ }
60401
60729
  function updateReactorClientDocumentModels(packages) {
60402
60730
  const documentModelModules = packages.flatMap((pkg) => pkg.modules.documentModelModules).filter((module) => module !== undefined);
60403
60731
  const registry = window.ph?.reactorClientModule?.reactorModule?.documentModelRegistry;
@@ -60429,52 +60757,6 @@ function useAllowedDocumentModelModules() {
60429
60757
  return documentModelModules;
60430
60758
  return documentModelModules?.filter((module) => allowedDocumentTypes.includes(module.documentModel.global.id));
60431
60759
  }
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
60760
  function sortNodesByName(nodes) {
60479
60761
  return nodes.toSorted((a3, b2) => a3.name.localeCompare(b2.name));
60480
60762
  }
@@ -60490,7 +60772,7 @@ function isFolderNodeKind(node) {
60490
60772
  }
60491
60773
  function useDispatch(document2) {
60492
60774
  function dispatch(actionOrActions, onErrors, onSuccess) {
60493
- dispatchActions(actionOrActions, document2, onErrors, onSuccess).catch(logger5.error);
60775
+ dispatchActions(actionOrActions, document2, onErrors, onSuccess).catch(logger6.error);
60494
60776
  }
60495
60777
  return [document2, dispatch];
60496
60778
  }
@@ -60522,17 +60804,17 @@ function getDocumentQueryState(promise) {
60522
60804
  }
60523
60805
  function useDocument(id) {
60524
60806
  const documentCache = useDocumentCache();
60525
- const document2 = useSyncExternalStore32((cb) => id && documentCache ? documentCache.subscribe(id, cb) : () => {}, () => id ? documentCache?.get(id) : undefined);
60807
+ const document2 = useSyncExternalStore4((cb) => id && documentCache ? documentCache.subscribe(id, cb) : () => {}, () => id ? documentCache?.get(id) : undefined);
60526
60808
  return document2 ? use2(document2) : undefined;
60527
60809
  }
60528
60810
  function useDocuments(ids) {
60529
60811
  const documentCache = useDocumentCache();
60530
- const documents = useSyncExternalStore32((cb) => ids?.length && documentCache ? documentCache.subscribe(ids, cb) : () => {}, () => ids?.length && documentCache ? documentCache.getBatch(ids) : undefined);
60812
+ const documents = useSyncExternalStore4((cb) => ids?.length && documentCache ? documentCache.subscribe(ids, cb) : () => {}, () => ids?.length && documentCache ? documentCache.getBatch(ids) : undefined);
60531
60813
  return documents ? use2(documents) : [];
60532
60814
  }
60533
60815
  function useGetDocument() {
60534
60816
  const documentCache = useDocumentCache();
60535
- return useCallback2((id) => {
60817
+ return useCallback22((id) => {
60536
60818
  if (!documentCache) {
60537
60819
  return Promise.reject(new Error("Document cache not initialized"));
60538
60820
  }
@@ -60541,7 +60823,7 @@ function useGetDocument() {
60541
60823
  }
60542
60824
  function useGetDocuments() {
60543
60825
  const documentCache = useDocumentCache();
60544
- return useCallback2((ids) => {
60826
+ return useCallback22((ids) => {
60545
60827
  if (!documentCache) {
60546
60828
  return Promise.reject(new Error("Document cache not initialized"));
60547
60829
  }
@@ -60868,6 +61150,52 @@ function usePHDocumentEditorConfigByKey(key) {
60868
61150
  const useValueHook = phDocumentEditorConfigHooks[key];
60869
61151
  return useValueHook();
60870
61152
  }
61153
+ function useConnectionStates() {
61154
+ const syncManager = useSync();
61155
+ const [states, setStates] = useState32(() => buildSnapshot(syncManager));
61156
+ const unsubscribesRef = useRef3([]);
61157
+ useEffect32(() => {
61158
+ if (!syncManager)
61159
+ return;
61160
+ function subscribe2() {
61161
+ for (const unsub of unsubscribesRef.current) {
61162
+ unsub();
61163
+ }
61164
+ unsubscribesRef.current = [];
61165
+ const remotes = syncManager.list();
61166
+ for (const remote of remotes) {
61167
+ const unsub = remote.channel.onConnectionStateChange(() => {
61168
+ setStates(buildSnapshot(syncManager));
61169
+ });
61170
+ unsubscribesRef.current.push(unsub);
61171
+ }
61172
+ setStates(buildSnapshot(syncManager));
61173
+ }
61174
+ subscribe2();
61175
+ const interval = setInterval(subscribe2, 5000);
61176
+ return () => {
61177
+ clearInterval(interval);
61178
+ for (const unsub of unsubscribesRef.current) {
61179
+ unsub();
61180
+ }
61181
+ unsubscribesRef.current = [];
61182
+ };
61183
+ }, [syncManager]);
61184
+ return states;
61185
+ }
61186
+ function useConnectionState(remoteName) {
61187
+ const states = useConnectionStates();
61188
+ return states.get(remoteName);
61189
+ }
61190
+ function buildSnapshot(syncManager) {
61191
+ const map = new Map;
61192
+ if (!syncManager)
61193
+ return map;
61194
+ for (const remote of syncManager.list()) {
61195
+ map.set(remote.name, remote.channel.getConnectionState());
61196
+ }
61197
+ return map;
61198
+ }
60871
61199
  function useDocumentOfType(documentId, documentType) {
60872
61200
  const [document2, dispatch] = useDocumentById(documentId);
60873
61201
  const documentModelModule = useDocumentModelModuleById(documentType);
@@ -60887,13 +61215,13 @@ function useDocumentOfType(documentId, documentType) {
60887
61215
  function useDocumentOperations(documentId) {
60888
61216
  const reactorClient = useReactorClient();
60889
61217
  const hasFetchedRef = useRef22(false);
60890
- const [state, setState] = useState32(() => ({
61218
+ const [state, setState] = useState4(() => ({
60891
61219
  globalOperations: [],
60892
61220
  localOperations: [],
60893
61221
  isLoading: !!documentId,
60894
61222
  error: undefined
60895
61223
  }));
60896
- const fetchOperations = useCallback3(async (retryCount = 0) => {
61224
+ const fetchOperations = useCallback4(async (retryCount = 0) => {
60897
61225
  const MAX_RETRIES = 5;
60898
61226
  const RETRY_DELAY_MS = 500;
60899
61227
  if (!documentId || !reactorClient) {
@@ -60939,7 +61267,7 @@ function useDocumentOperations(documentId) {
60939
61267
  });
60940
61268
  hasFetchedRef.current = true;
60941
61269
  }, [documentId, reactorClient]);
60942
- useEffect32(() => {
61270
+ useEffect42(() => {
60943
61271
  if (documentId && reactorClient) {
60944
61272
  fetchOperations();
60945
61273
  } else if (!documentId) {
@@ -60952,7 +61280,7 @@ function useDocumentOperations(documentId) {
60952
61280
  hasFetchedRef.current = false;
60953
61281
  }
60954
61282
  }, [documentId, reactorClient, fetchOperations]);
60955
- const refetch = useCallback3(() => {
61283
+ const refetch = useCallback4(() => {
60956
61284
  fetchOperations(0);
60957
61285
  }, [fetchOperations]);
60958
61286
  return { ...state, refetch };
@@ -61399,81 +61727,6 @@ function makeVetraPackageManifestModulesEntry(modules) {
61399
61727
  return acc;
61400
61728
  }, {});
61401
61729
  }
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
61730
  function useGetSwitchboardLink(document2) {
61478
61731
  const [drive] = useSelectedDrive();
61479
61732
  const remotes = useSyncList();
@@ -61516,6 +61769,47 @@ function useUserPermissions() {
61516
61769
  isAllowedToEditDocuments: allowList.includes(user?.address ?? "")
61517
61770
  };
61518
61771
  }
61772
+ function cdnUrlToApiUrl(cdnUrl) {
61773
+ return cdnUrl.replace(/\/-\/cdn\/?$/, "");
61774
+ }
61775
+ function mapPackageInfo(pkg) {
61776
+ return {
61777
+ name: pkg.name,
61778
+ description: pkg.manifest?.description,
61779
+ version: pkg.manifest?.version,
61780
+ category: pkg.manifest?.category,
61781
+ publisher: pkg.manifest?.publisher?.name,
61782
+ publisherUrl: pkg.manifest?.publisher?.url
61783
+ };
61784
+ }
61785
+
61786
+ class RegistryClient {
61787
+ apiUrl;
61788
+ constructor(cdnUrl) {
61789
+ this.apiUrl = cdnUrlToApiUrl(cdnUrl);
61790
+ }
61791
+ async getPackages() {
61792
+ const res = await fetch(`${this.apiUrl}/packages`);
61793
+ if (!res.ok)
61794
+ throw new Error(`Registry error: HTTP ${res.status}`);
61795
+ const data = await res.json();
61796
+ return data.map(mapPackageInfo);
61797
+ }
61798
+ async getPackagesByDocumentType(documentType) {
61799
+ const encodedType = encodeURIComponent(documentType);
61800
+ const res = await fetch(`${this.apiUrl}/packages/by-document-type?type=${encodedType}`);
61801
+ if (!res.ok)
61802
+ throw new Error(`Registry error: HTTP ${res.status}`);
61803
+ return await res.json();
61804
+ }
61805
+ async searchPackages(query) {
61806
+ const packages = await this.getPackages();
61807
+ if (!query)
61808
+ return packages;
61809
+ const lowerQuery = query.toLowerCase();
61810
+ return packages.filter((pkg) => pkg.name.toLowerCase().includes(lowerQuery) || pkg.description?.toLowerCase().includes(lowerQuery));
61811
+ }
61812
+ }
61519
61813
 
61520
61814
  class BaseStorage {
61521
61815
  #store;
@@ -61537,6 +61831,19 @@ class BaseStorage {
61537
61831
  return this.#store.delete(this.#buildKey(key));
61538
61832
  }
61539
61833
  }
61834
+ function loadDismissedPackages() {
61835
+ try {
61836
+ const raw = localStorage.getItem(DISMISSED_STORAGE_KEY);
61837
+ if (raw)
61838
+ return JSON.parse(raw);
61839
+ } catch {}
61840
+ return [];
61841
+ }
61842
+ function persistDismissedPackages(dismissed) {
61843
+ try {
61844
+ localStorage.setItem(DISMISSED_STORAGE_KEY, JSON.stringify(dismissed));
61845
+ } catch {}
61846
+ }
61540
61847
  function loadCSS(pkg, registryUrl) {
61541
61848
  const head = document.getElementsByTagName("head")[0];
61542
61849
  const existingStyle = head.querySelector(`link[data-package='${pkg}']`);
@@ -61557,10 +61864,13 @@ function removeCSS(pkg) {
61557
61864
  style.remove();
61558
61865
  }
61559
61866
  }
61867
+ async function runtimeImport(url) {
61868
+ return new Function("u", "return import(u)")(url);
61869
+ }
61560
61870
  async function loadExternalPackage(name4, registryUrl) {
61561
61871
  registryUrl = registryUrl.endsWith("/") ? registryUrl : `${registryUrl}/`;
61562
61872
  const url = `${registryUrl}${name4}/index.js`;
61563
- const module = await import(url);
61873
+ const module = await runtimeImport(url);
61564
61874
  loadCSS(name4, registryUrl);
61565
61875
  return convertLegacyLibToVetraPackage(module);
61566
61876
  }
@@ -61571,12 +61881,23 @@ class BrowserPackageManager {
61571
61881
  #localPackageIds = new Set;
61572
61882
  #subscribers = new Set;
61573
61883
  #packagesMemo = [];
61574
- constructor(namespace2) {
61884
+ #registryCdnUrl;
61885
+ #registryClient;
61886
+ #documentModelRegistry;
61887
+ #pending = [];
61888
+ #dismissed = loadDismissedPackages();
61889
+ #deferredActions = new Map;
61890
+ #pendingListeners = new Set;
61891
+ constructor(namespace2, registryCdnUrl) {
61575
61892
  this.#storage = new BrowserLocalStorage(namespace2 + ":PH_PACKAGES");
61576
61893
  const packages = this.#storage.get("packages");
61577
61894
  if (!packages) {
61578
61895
  this.#storage.set("packages", []);
61579
61896
  }
61897
+ if (registryCdnUrl) {
61898
+ this.#registryCdnUrl = registryCdnUrl;
61899
+ this.#registryClient = new RegistryClient(registryCdnUrl);
61900
+ }
61580
61901
  }
61581
61902
  async init() {
61582
61903
  const packages = this.#storage.get("packages");
@@ -61632,6 +61953,99 @@ class BrowserPackageManager {
61632
61953
  handler({ packages });
61633
61954
  });
61634
61955
  }
61956
+ setDocumentModelRegistry(registry) {
61957
+ this.#documentModelRegistry = registry;
61958
+ }
61959
+ async load(documentType) {
61960
+ if (!this.#registryClient || !this.#registryCdnUrl) {
61961
+ throw new Error("Registry CDN URL not configured — cannot discover packages");
61962
+ }
61963
+ const packageNames = await this.#registryClient.getPackagesByDocumentType(documentType);
61964
+ if (packageNames.length === 0) {
61965
+ throw new Error(`No package found containing document type: ${documentType}`);
61966
+ }
61967
+ const packageName = packageNames.sort((a3, b2) => a3.localeCompare(b2))[0];
61968
+ this.#pending = [...this.#pending, { documentType, packageName }];
61969
+ this.#notifyPendingListeners();
61970
+ return new Promise((resolve2, reject) => {
61971
+ this.#deferredActions.set(packageName, { resolve: resolve2, reject });
61972
+ });
61973
+ }
61974
+ async approveInstallation(packageName) {
61975
+ const deferred = this.#deferredActions.get(packageName);
61976
+ if (!deferred)
61977
+ return;
61978
+ try {
61979
+ await this.addPackage(packageName, this.#registryCdnUrl);
61980
+ } catch (error3) {
61981
+ this.#removePending(packageName);
61982
+ this.#deferredActions.delete(packageName);
61983
+ deferred.reject(error3 instanceof Error ? error3 : new Error(`Failed to install package: ${packageName}`));
61984
+ return;
61985
+ }
61986
+ const pendingEntries = this.#pending.filter((p2) => p2.packageName === packageName);
61987
+ this.#removePending(packageName);
61988
+ this.#deferredActions.delete(packageName);
61989
+ if (!this.#documentModelRegistry) {
61990
+ deferred.reject(new Error("Document model registry not available"));
61991
+ return;
61992
+ }
61993
+ for (const entry of pendingEntries) {
61994
+ try {
61995
+ const module = this.#documentModelRegistry.getModule(entry.documentType);
61996
+ deferred.resolve(module);
61997
+ return;
61998
+ } catch {}
61999
+ }
62000
+ deferred.reject(new Error(`Module not found after installing package: ${packageName}`));
62001
+ }
62002
+ rejectInstallation(packageName) {
62003
+ const deferred = this.#deferredActions.get(packageName);
62004
+ if (!deferred)
62005
+ return;
62006
+ const rejectedEntries = this.#pending.filter((p2) => p2.packageName === packageName);
62007
+ const documentTypes = rejectedEntries.map((e4) => e4.documentType);
62008
+ this.#addDismissed(packageName, documentTypes);
62009
+ this.#removePending(packageName);
62010
+ this.#deferredActions.delete(packageName);
62011
+ deferred.reject(new Error(`Installation rejected for package: ${packageName}`));
62012
+ }
62013
+ subscribePendingChanges(listener) {
62014
+ this.#pendingListeners.add(listener);
62015
+ return () => {
62016
+ this.#pendingListeners.delete(listener);
62017
+ };
62018
+ }
62019
+ getPendingInstallations() {
62020
+ return this.#pending;
62021
+ }
62022
+ getDismissedPackages() {
62023
+ return this.#dismissed;
62024
+ }
62025
+ removeDismissed(packageName) {
62026
+ this.#dismissed = this.#dismissed.filter((d2) => d2.packageName !== packageName);
62027
+ persistDismissedPackages(this.#dismissed);
62028
+ this.#notifyPendingListeners();
62029
+ }
62030
+ #addDismissed(packageName, documentTypes) {
62031
+ const existing = this.#dismissed.find((d2) => d2.packageName === packageName);
62032
+ if (existing) {
62033
+ const merged = new Set([...existing.documentTypes, ...documentTypes]);
62034
+ existing.documentTypes = [...merged];
62035
+ } else {
62036
+ this.#dismissed = [...this.#dismissed, { packageName, documentTypes }];
62037
+ }
62038
+ persistDismissedPackages(this.#dismissed);
62039
+ }
62040
+ #removePending(packageName) {
62041
+ this.#pending = this.#pending.filter((p2) => p2.packageName !== packageName);
62042
+ this.#notifyPendingListeners();
62043
+ }
62044
+ #notifyPendingListeners() {
62045
+ for (const listener of this.#pendingListeners) {
62046
+ listener();
62047
+ }
62048
+ }
61635
62049
  }
61636
62050
  async function dropTablesInSchema(pg, schema) {
61637
62051
  await pg.exec(`
@@ -61657,40 +62071,6 @@ async function dropAllReactorStorage(pg) {
61657
62071
  await dropTablesInSchema(pg, REACTOR_SCHEMA);
61658
62072
  await dropTablesInSchema(pg, "public");
61659
62073
  }
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
62074
 
61695
62075
  class ReactorClientDocumentCache {
61696
62076
  client;
@@ -61996,7 +62376,7 @@ function split2(lst, le = false) {
61996
62376
  }
61997
62377
  function add(Ah, Al, Bh, Bl) {
61998
62378
  const l2 = (Al >>> 0) + (Bl >>> 0);
61999
- return { h: Ah + Bh + (l2 / 4294967296 | 0) | 0, l: l2 | 0 };
62379
+ return { h: Ah + Bh + (l2 / 2 ** 32 | 0) | 0, l: l2 | 0 };
62000
62380
  }
62001
62381
  function _abool2(value, title = "") {
62002
62382
  if (typeof value !== "boolean") {
@@ -62807,7 +63187,7 @@ function edwards(params, extraOpts = {}) {
62807
63187
  _abool2(zip215, "zip215");
62808
63188
  const normed = copyBytes(bytes);
62809
63189
  const lastByte = bytes[len - 1];
62810
- normed[len - 1] = lastByte & -129;
63190
+ normed[len - 1] = lastByte & ~128;
62811
63191
  const y2 = bytesToNumberLE(normed);
62812
63192
  const max = zip215 ? MASK : Fp.ORDER;
62813
63193
  aInRange("point.y", y2, _0n4, max);
@@ -64193,7 +64573,7 @@ function ripemd_f(group, x2, y2, z2) {
64193
64573
  return x2 ^ (y2 | ~z2);
64194
64574
  }
64195
64575
  function keccakP(s3, rounds = 24) {
64196
- const B2 = new Uint32Array(10);
64576
+ const B2 = new Uint32Array(5 * 2);
64197
64577
  for (let round = 24 - rounds;round < 24; round++) {
64198
64578
  for (let x2 = 0;x2 < 10; x2++)
64199
64579
  B2[x2] = s3[x2] ^ s3[x2 + 10] ^ s3[x2 + 20] ^ s3[x2 + 30] ^ s3[x2 + 40];
@@ -64582,7 +64962,7 @@ function convertRadix2(data, from3, to, padding2) {
64582
64962
  }
64583
64963
  function radix(num) {
64584
64964
  anumber2(num);
64585
- const _256 = 256;
64965
+ const _256 = 2 ** 8;
64586
64966
  return {
64587
64967
  encode: (bytes) => {
64588
64968
  if (!isBytes2(bytes))
@@ -73199,7 +73579,7 @@ function useStableParams(params) {
73199
73579
  function createProcessorQuery(ProcessorClass) {
73200
73580
  function useQuery(driveId, queryCallback, parameters, options) {
73201
73581
  const stableParams = useStableParams(parameters);
73202
- const memoizedCallback = useCallback4(queryCallback, [stableParams]);
73582
+ const memoizedCallback = useCallback5(queryCallback, [stableParams]);
73203
73583
  return useRelationalQuery(ProcessorClass, driveId, memoizedCallback, stableParams, options);
73204
73584
  }
73205
73585
  return useQuery;
@@ -73733,41 +74113,6 @@ function CopyIcon({ size = 14, color = "#9EA0A1" }) {
73733
74113
  ]
73734
74114
  }, undefined, true, undefined, this);
73735
74115
  }
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
74116
  function DisconnectIcon({ size = 14, color = "#EA4335" }) {
73772
74117
  return /* @__PURE__ */ jsxDEV2("svg", {
73773
74118
  width: size,
@@ -73870,6 +74215,27 @@ function SpinnerIcon({ size = 14, color = "currentColor" }) {
73870
74215
  ]
73871
74216
  }, undefined, true, undefined, this);
73872
74217
  }
74218
+ function ChevronDownIcon({
74219
+ size = 14,
74220
+ color = "currentColor",
74221
+ style
74222
+ }) {
74223
+ return /* @__PURE__ */ jsxDEV2("svg", {
74224
+ width: size,
74225
+ height: size,
74226
+ viewBox: "0 0 16 16",
74227
+ fill: "none",
74228
+ xmlns: "http://www.w3.org/2000/svg",
74229
+ style,
74230
+ children: /* @__PURE__ */ jsxDEV2("path", {
74231
+ d: "M4 6L8 10L12 6",
74232
+ stroke: color,
74233
+ strokeWidth: "1.5",
74234
+ strokeLinecap: "round",
74235
+ strokeLinejoin: "round"
74236
+ }, undefined, false, undefined, this)
74237
+ }, undefined, false, undefined, this);
74238
+ }
73873
74239
  function UserIcon({ size = 24, color = "#6366f1" }) {
73874
74240
  return /* @__PURE__ */ jsxDEV2("svg", {
73875
74241
  width: size,
@@ -73894,134 +74260,80 @@ function UserIcon({ size = 24, color = "#6366f1" }) {
73894
74260
  ]
73895
74261
  }, undefined, true, undefined, this);
73896
74262
  }
74263
+ function mergeProps2(parentProps, childProps) {
74264
+ const merged = { ...parentProps };
74265
+ for (const key of Object.keys(childProps)) {
74266
+ const parentValue = parentProps[key];
74267
+ const childValue = childProps[key];
74268
+ if (key === "style") {
74269
+ merged[key] = { ...parentValue, ...childValue };
74270
+ } else if (key === "className") {
74271
+ merged[key] = [parentValue, childValue].filter(Boolean).join(" ");
74272
+ } else if (typeof parentValue === "function" && typeof childValue === "function") {
74273
+ merged[key] = (...args) => {
74274
+ childValue(...args);
74275
+ parentValue(...args);
74276
+ };
74277
+ } else if (childValue !== undefined) {
74278
+ merged[key] = childValue;
74279
+ }
74280
+ }
74281
+ return merged;
74282
+ }
73897
74283
  function RenownLoginButton({
73898
74284
  onLogin: onLoginProp,
73899
74285
  darkMode = false,
73900
74286
  style,
73901
74287
  className,
73902
- renderTrigger,
73903
- showPopover = false
74288
+ asChild = false,
74289
+ children
73904
74290
  }) {
73905
74291
  const onLogin = onLoginProp ?? (() => openRenown());
73906
- const [isOpen, setIsOpen] = useState7(false);
73907
74292
  const [isLoading, setIsLoading] = useState7(false);
73908
74293
  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) {
74294
+ const handleMouseEnter = useCallback6(() => setIsHovered(true), []);
74295
+ const handleMouseLeave = useCallback6(() => setIsHovered(false), []);
74296
+ const handleClick2 = () => {
74297
+ if (!isLoading) {
73949
74298
  setIsLoading(true);
73950
74299
  onLogin();
73951
74300
  }
73952
74301
  };
74302
+ const themeStyles = darkMode ? darkStyles : lightStyles;
73953
74303
  const triggerStyle = {
73954
74304
  ...styles.trigger,
73955
- cursor: !isLoading ? "pointer" : "wait",
74305
+ ...themeStyles.trigger,
74306
+ ...isHovered && !isLoading ? themeStyles.triggerHover : {},
74307
+ cursor: isLoading ? "wait" : "pointer",
73956
74308
  ...style
73957
74309
  };
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";
74310
+ const triggerElement = asChild ? /* @__PURE__ */ jsxDEV22(Slot, {
74311
+ onClick: handleClick2,
74312
+ "data-renown-state": "login",
74313
+ ...isLoading ? { "data-loading": "" } : {},
74314
+ children
74315
+ }, undefined, false, undefined, this) : /* @__PURE__ */ jsxDEV22("button", {
74316
+ type: "button",
74317
+ style: triggerStyle,
74318
+ "aria-label": "Log in with Renown",
74319
+ onClick: handleClick2,
74320
+ "data-renown-state": "login",
74321
+ ...isLoading ? { "data-loading": "" } : {},
74322
+ children: isLoading ? /* @__PURE__ */ jsxDEV22(SpinnerIcon, {
74323
+ size: 16
74324
+ }, undefined, false, undefined, this) : /* @__PURE__ */ jsxDEV22("span", {
74325
+ children: "Log in"
74326
+ }, undefined, false, undefined, this)
74327
+ }, undefined, false, undefined, this);
73971
74328
  return /* @__PURE__ */ jsxDEV22("div", {
73972
- ref: wrapperRef,
73973
74329
  style: styles.wrapper,
73974
74330
  className,
73975
74331
  onMouseEnter: handleMouseEnter,
73976
74332
  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);
74333
+ children: triggerElement
74334
+ }, undefined, false, undefined, this);
74023
74335
  }
74024
- function truncateAddress(address) {
74336
+ function truncateAddress2(address) {
74025
74337
  if (address.length <= 13)
74026
74338
  return address;
74027
74339
  return `${address.slice(0, 7)}...${address.slice(-5)}`;
@@ -74034,27 +74346,34 @@ function RenownUserButton({
74034
74346
  onDisconnect: onDisconnectProp,
74035
74347
  style,
74036
74348
  className,
74037
- renderTrigger
74349
+ asChild = false,
74350
+ children,
74351
+ menuItems
74038
74352
  }) {
74039
74353
  const user = useUser();
74040
74354
  const address = addressProp ?? user?.address ?? "";
74041
- const username = usernameProp ?? user?.ens?.name;
74042
- const avatarUrl = avatarUrlProp ?? user?.ens?.avatarUrl;
74355
+ const username = usernameProp ?? user?.profile?.username ?? user?.ens?.name;
74356
+ const avatarUrl = avatarUrlProp ?? user?.profile?.userImage ?? user?.ens?.avatarUrl;
74043
74357
  const userId = userIdProp ?? user?.profile?.documentId;
74044
74358
  const onDisconnect = onDisconnectProp ?? (() => void logout());
74359
+ const displayName = username ?? (address ? truncateAddress2(address) : "Account");
74360
+ const profileId = userId ?? address;
74045
74361
  const [isOpen, setIsOpen] = useState8(false);
74362
+ const [isHovered, setIsHovered] = useState8(false);
74046
74363
  const [isCopied, setIsCopied] = useState8(false);
74047
74364
  const [showAbove, setShowAbove] = useState8(true);
74048
- const wrapperRef = useRef6(null);
74049
- const closeTimeoutRef = useRef6(null);
74050
- const calculatePosition = useCallback6(() => {
74365
+ const [hoveredItem, setHoveredItem] = useState8(null);
74366
+ const wrapperRef = useRef5(null);
74367
+ const closeTimeoutRef = useRef5(null);
74368
+ const calculatePosition = useCallback7(() => {
74051
74369
  if (!wrapperRef.current)
74052
74370
  return;
74053
74371
  const rect = wrapperRef.current.getBoundingClientRect();
74054
74372
  const spaceAbove = rect.top;
74055
- setShowAbove(spaceAbove >= POPOVER_HEIGHT2 + POPOVER_GAP2);
74373
+ setShowAbove(spaceAbove >= POPOVER_HEIGHT + POPOVER_GAP);
74056
74374
  }, []);
74057
- const handleMouseEnter = useCallback6(() => {
74375
+ const handleMouseEnter = useCallback7(() => {
74376
+ setIsHovered(true);
74058
74377
  if (closeTimeoutRef.current) {
74059
74378
  clearTimeout(closeTimeoutRef.current);
74060
74379
  closeTimeoutRef.current = null;
@@ -74062,19 +74381,21 @@ function RenownUserButton({
74062
74381
  calculatePosition();
74063
74382
  setIsOpen(true);
74064
74383
  }, [calculatePosition]);
74065
- const handleMouseLeave = useCallback6(() => {
74384
+ const handleMouseLeave = useCallback7(() => {
74066
74385
  closeTimeoutRef.current = setTimeout(() => {
74067
74386
  setIsOpen(false);
74387
+ setIsHovered(false);
74388
+ setHoveredItem(null);
74068
74389
  }, 150);
74069
74390
  }, []);
74070
- useEffect8(() => {
74391
+ useEffect7(() => {
74071
74392
  return () => {
74072
74393
  if (closeTimeoutRef.current) {
74073
74394
  clearTimeout(closeTimeoutRef.current);
74074
74395
  }
74075
74396
  };
74076
74397
  }, []);
74077
- const copyToClipboard = useCallback6(async () => {
74398
+ const copyToClipboard = useCallback7(async () => {
74078
74399
  try {
74079
74400
  await navigator.clipboard.writeText(address);
74080
74401
  setIsCopied(true);
@@ -74083,6 +74404,43 @@ function RenownUserButton({
74083
74404
  console.error("Failed to copy address:", err);
74084
74405
  }
74085
74406
  }, [address]);
74407
+ const triggerElement = asChild ? /* @__PURE__ */ jsxDEV3(Slot, {
74408
+ "data-renown-state": "authenticated",
74409
+ children
74410
+ }, undefined, false, undefined, this) : /* @__PURE__ */ jsxDEV3("button", {
74411
+ type: "button",
74412
+ style: {
74413
+ ...styles2.trigger,
74414
+ ...isHovered ? styles2.triggerHover : {},
74415
+ ...style
74416
+ },
74417
+ "aria-label": "Open account menu",
74418
+ "data-renown-state": "authenticated",
74419
+ children: [
74420
+ avatarUrl ? /* @__PURE__ */ jsxDEV3("img", {
74421
+ src: avatarUrl,
74422
+ alt: "Avatar",
74423
+ style: styles2.avatar
74424
+ }, undefined, false, undefined, this) : /* @__PURE__ */ jsxDEV3("div", {
74425
+ style: styles2.avatarPlaceholder,
74426
+ children: /* @__PURE__ */ jsxDEV3("span", {
74427
+ style: styles2.avatarInitial,
74428
+ children: (displayName || "U")[0].toUpperCase()
74429
+ }, undefined, false, undefined, this)
74430
+ }, undefined, false, undefined, this),
74431
+ /* @__PURE__ */ jsxDEV3("span", {
74432
+ style: styles2.displayName,
74433
+ children: displayName
74434
+ }, undefined, false, undefined, this),
74435
+ /* @__PURE__ */ jsxDEV3(ChevronDownIcon, {
74436
+ size: 14,
74437
+ style: {
74438
+ ...styles2.chevron,
74439
+ ...isOpen ? styles2.chevronOpen : {}
74440
+ }
74441
+ }, undefined, false, undefined, this)
74442
+ ]
74443
+ }, undefined, true, undefined, this);
74086
74444
  return /* @__PURE__ */ jsxDEV3("div", {
74087
74445
  ref: wrapperRef,
74088
74446
  style: styles2.wrapper,
@@ -74090,46 +74448,25 @@ function RenownUserButton({
74090
74448
  onMouseEnter: handleMouseEnter,
74091
74449
  onMouseLeave: handleMouseLeave,
74092
74450
  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),
74451
+ triggerElement,
74115
74452
  isOpen && /* @__PURE__ */ jsxDEV3("div", {
74116
74453
  style: {
74117
74454
  ...styles2.popoverBase,
74118
- ...showAbove ? { bottom: `calc(100% + ${POPOVER_GAP2}px)` } : { top: `calc(100% + ${POPOVER_GAP2}px)` }
74455
+ ...showAbove ? { bottom: `calc(100% + ${POPOVER_GAP}px)` } : { top: `calc(100% + ${POPOVER_GAP}px)` }
74119
74456
  },
74120
74457
  children: [
74121
74458
  /* @__PURE__ */ jsxDEV3("div", {
74122
- style: styles2.section,
74459
+ style: styles2.header,
74123
74460
  children: [
74124
74461
  username && /* @__PURE__ */ jsxDEV3("div", {
74125
- style: styles2.username,
74462
+ style: styles2.headerUsername,
74126
74463
  children: username
74127
74464
  }, undefined, false, undefined, this),
74128
- /* @__PURE__ */ jsxDEV3("div", {
74465
+ address && /* @__PURE__ */ jsxDEV3("div", {
74129
74466
  style: styles2.addressRow,
74130
74467
  children: /* @__PURE__ */ jsxDEV3("button", {
74131
74468
  type: "button",
74132
- onClick: copyToClipboard,
74469
+ onClick: () => void copyToClipboard(),
74133
74470
  style: styles2.addressButton,
74134
74471
  children: /* @__PURE__ */ jsxDEV3("div", {
74135
74472
  style: {
@@ -74141,20 +74478,26 @@ function RenownUserButton({
74141
74478
  },
74142
74479
  children: [
74143
74480
  /* @__PURE__ */ jsxDEV3("div", {
74144
- style: { ...styles2.addressText, opacity: isCopied ? 0 : 1 },
74481
+ style: {
74482
+ ...styles2.addressText,
74483
+ opacity: isCopied ? 0 : 1
74484
+ },
74145
74485
  children: [
74146
74486
  /* @__PURE__ */ jsxDEV3("span", {
74147
- children: truncateAddress(address)
74487
+ children: truncateAddress2(address)
74148
74488
  }, undefined, false, undefined, this),
74149
74489
  /* @__PURE__ */ jsxDEV3(CopyIcon, {
74150
- size: 14,
74151
- color: "#9EA0A1"
74490
+ size: 12,
74491
+ color: "#9ca3af"
74152
74492
  }, undefined, false, undefined, this)
74153
74493
  ]
74154
74494
  }, undefined, true, undefined, this),
74155
74495
  /* @__PURE__ */ jsxDEV3("div", {
74156
- style: { ...styles2.copiedText, opacity: isCopied ? 1 : 0 },
74157
- children: "Copied to clipboard!"
74496
+ style: {
74497
+ ...styles2.copiedText,
74498
+ opacity: isCopied ? 1 : 0
74499
+ },
74500
+ children: "Copied!"
74158
74501
  }, undefined, false, undefined, this)
74159
74502
  ]
74160
74503
  }, undefined, true, undefined, this)
@@ -74162,35 +74505,64 @@ function RenownUserButton({
74162
74505
  }, undefined, false, undefined, this)
74163
74506
  ]
74164
74507
  }, 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)
74508
+ /* @__PURE__ */ jsxDEV3("div", {
74509
+ style: styles2.menuSection,
74510
+ children: [
74511
+ profileId && /* @__PURE__ */ jsxDEV3("button", {
74512
+ type: "button",
74513
+ onClick: () => openRenown(profileId),
74514
+ onMouseEnter: () => setHoveredItem("profile"),
74515
+ onMouseLeave: () => setHoveredItem(null),
74516
+ style: {
74517
+ ...styles2.menuItem,
74518
+ ...hoveredItem === "profile" ? styles2.menuItemHover : {}
74519
+ },
74520
+ children: [
74521
+ /* @__PURE__ */ jsxDEV3(UserIcon, {
74522
+ size: 14,
74523
+ color: "#6b7280"
74524
+ }, undefined, false, undefined, this),
74525
+ "View Profile"
74526
+ ]
74527
+ }, undefined, true, undefined, this),
74528
+ menuItems?.map((item) => /* @__PURE__ */ jsxDEV3("button", {
74529
+ type: "button",
74530
+ onClick: item.onClick,
74531
+ onMouseEnter: () => setHoveredItem(item.label),
74532
+ onMouseLeave: () => setHoveredItem(null),
74533
+ style: {
74534
+ ...styles2.menuItem,
74535
+ ...hoveredItem === item.label ? styles2.menuItemHover : {},
74536
+ ...item.style
74537
+ },
74538
+ children: [
74539
+ item.icon,
74540
+ item.label
74541
+ ]
74542
+ }, item.label, true, undefined, this))
74543
+ ]
74544
+ }, undefined, true, undefined, this),
74545
+ /* @__PURE__ */ jsxDEV3("hr", {
74546
+ style: styles2.separator
74178
74547
  }, undefined, false, undefined, this),
74179
74548
  /* @__PURE__ */ jsxDEV3("div", {
74180
- style: styles2.sectionLast,
74549
+ style: styles2.menuSection,
74181
74550
  children: /* @__PURE__ */ jsxDEV3("button", {
74182
74551
  type: "button",
74183
74552
  onClick: onDisconnect,
74553
+ onMouseEnter: () => setHoveredItem("disconnect"),
74554
+ onMouseLeave: () => setHoveredItem(null),
74184
74555
  style: {
74185
74556
  ...styles2.menuItem,
74186
- ...styles2.disconnectItem
74557
+ ...styles2.disconnectItem,
74558
+ ...hoveredItem === "disconnect" ? styles2.menuItemHover : {}
74187
74559
  },
74188
74560
  children: [
74189
74561
  /* @__PURE__ */ jsxDEV3(DisconnectIcon, {
74190
74562
  size: 14,
74191
- color: "#EA4335"
74563
+ color: "#dc2626"
74192
74564
  }, undefined, false, undefined, this),
74193
- "Disconnect"
74565
+ "Log out"
74194
74566
  ]
74195
74567
  }, undefined, true, undefined, this)
74196
74568
  }, undefined, false, undefined, this)
@@ -74201,23 +74573,23 @@ function RenownUserButton({
74201
74573
  }
74202
74574
  function RenownAuthButton({
74203
74575
  className = "",
74204
- renderAuthenticated,
74205
- renderUnauthenticated,
74206
- renderLoading
74576
+ darkMode,
74577
+ loginContent,
74578
+ userContent,
74579
+ loadingContent,
74580
+ children
74207
74581
  }) {
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) {
74582
+ const auth = useRenownAuth();
74583
+ if (children) {
74584
+ return /* @__PURE__ */ jsxDEV4(Fragment2, {
74585
+ children: children(auth)
74586
+ }, undefined, false, undefined, this);
74587
+ }
74588
+ if (auth.status === "loading" || auth.status === "checking") {
74589
+ if (loadingContent) {
74218
74590
  return /* @__PURE__ */ jsxDEV4("div", {
74219
74591
  className,
74220
- children: renderLoading()
74592
+ children: loadingContent
74221
74593
  }, undefined, false, undefined, this);
74222
74594
  }
74223
74595
  return /* @__PURE__ */ jsxDEV4("div", {
@@ -74225,24 +74597,44 @@ function RenownAuthButton({
74225
74597
  children: [
74226
74598
  /* @__PURE__ */ jsxDEV4("div", {
74227
74599
  style: {
74228
- width: "40px",
74229
- height: "40px",
74230
- borderRadius: "50%",
74231
- backgroundColor: "#e5e7eb",
74600
+ display: "flex",
74601
+ alignItems: "center",
74602
+ gap: "8px",
74603
+ padding: "6px 12px",
74604
+ borderRadius: "8px",
74605
+ border: "1px solid #e5e7eb",
74232
74606
  animation: "pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite"
74233
- }
74234
- }, undefined, false, undefined, this),
74607
+ },
74608
+ children: [
74609
+ /* @__PURE__ */ jsxDEV4("div", {
74610
+ style: {
74611
+ width: "28px",
74612
+ height: "28px",
74613
+ borderRadius: "50%",
74614
+ backgroundColor: "#e5e7eb"
74615
+ }
74616
+ }, undefined, false, undefined, this),
74617
+ /* @__PURE__ */ jsxDEV4("div", {
74618
+ style: {
74619
+ width: "80px",
74620
+ height: "14px",
74621
+ borderRadius: "4px",
74622
+ backgroundColor: "#e5e7eb"
74623
+ }
74624
+ }, undefined, false, undefined, this)
74625
+ ]
74626
+ }, undefined, true, undefined, this),
74235
74627
  /* @__PURE__ */ jsxDEV4("style", {
74236
74628
  children: `@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }`
74237
74629
  }, undefined, false, undefined, this)
74238
74630
  ]
74239
74631
  }, undefined, true, undefined, this);
74240
74632
  }
74241
- if (loginStatus === "authorized" && user) {
74242
- if (renderAuthenticated) {
74633
+ if (auth.status === "authorized") {
74634
+ if (userContent) {
74243
74635
  return /* @__PURE__ */ jsxDEV4("div", {
74244
74636
  className,
74245
- children: renderAuthenticated({ user, logout, openProfile })
74637
+ children: userContent
74246
74638
  }, undefined, false, undefined, this);
74247
74639
  }
74248
74640
  return /* @__PURE__ */ jsxDEV4("div", {
@@ -74250,54 +74642,52 @@ function RenownAuthButton({
74250
74642
  children: /* @__PURE__ */ jsxDEV4(RenownUserButton, {}, undefined, false, undefined, this)
74251
74643
  }, undefined, false, undefined, this);
74252
74644
  }
74253
- if (renderUnauthenticated) {
74645
+ if (loginContent) {
74254
74646
  return /* @__PURE__ */ jsxDEV4("div", {
74255
74647
  className,
74256
- children: renderUnauthenticated({ openRenown: () => openRenown(), isLoading })
74648
+ children: loginContent
74257
74649
  }, undefined, false, undefined, this);
74258
74650
  }
74259
74651
  return /* @__PURE__ */ jsxDEV4("div", {
74260
74652
  className,
74261
- children: /* @__PURE__ */ jsxDEV4(RenownLoginButton, {}, undefined, false, undefined, this)
74653
+ children: /* @__PURE__ */ jsxDEV4(RenownLoginButton, {
74654
+ darkMode
74655
+ }, undefined, false, undefined, this)
74262
74656
  }, undefined, false, undefined, this);
74263
74657
  }
74264
- function RenownProvider({
74658
+ async function initRenown(appName, namespace2, url) {
74659
+ addRenownEventHandler();
74660
+ setRenown(loading);
74661
+ const builder = new RenownBuilder(appName, {
74662
+ basename: namespace2,
74663
+ baseUrl: url
74664
+ });
74665
+ const renown = await builder.build();
74666
+ setRenown(renown);
74667
+ await login(undefined, renown);
74668
+ return renown;
74669
+ }
74670
+ function useRenownInit({
74265
74671
  appName,
74266
- basename: basename2,
74267
- baseUrl,
74268
- children
74672
+ namespace: namespace2,
74673
+ url
74269
74674
  }) {
74270
- const initRef = useRef7(false);
74271
- const initialPropsRef = useRef7({ appName, basename: basename2, baseUrl });
74675
+ const promiseRef = useRef6(Promise.withResolvers());
74676
+ const initRef = useRef6(false);
74677
+ if (typeof window === "undefined") {
74678
+ promiseRef.current.reject(new Error("window is undefined"));
74679
+ return promiseRef.current.promise;
74680
+ }
74272
74681
  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
- }
74682
+ return promiseRef.current.promise;
74283
74683
  }
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;
74684
+ initRef.current = true;
74685
+ initRenown(appName, namespace2, url).then(promiseRef.current.resolve).catch(promiseRef.current.reject);
74686
+ return promiseRef.current.promise;
74687
+ }
74688
+ function Renown2({ onError, ...initOptions }) {
74689
+ useRenownInit(initOptions).catch(onError ?? console.error);
74690
+ return null;
74301
74691
  }
74302
74692
  var __create2, __getProtoOf2, __defProp3, __getOwnPropNames2, __getOwnPropDesc2, __hasOwnProp2, __toESM2 = (mod, isNodeMode, target) => {
74303
74693
  target = mod != null ? __create2(__getProtoOf2(mod)) : {};
@@ -74863,13 +75253,13 @@ ${String(result)}`);
74863
75253
  return t4;
74864
75254
  };
74865
75255
  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 = () => {
75256
+ }, 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
75257
  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 = () => {
75258
+ return useSyncExternalStore32((cb) => packageManager ? packageManager.subscribe(cb) : () => {}, () => packageManager?.packages ?? []);
75259
+ }, 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
75260
  const sync = useSync();
74871
75261
  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) => {
75262
+ }, 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
75263
  const errors2 = [];
74874
75264
  if (document2.header.documentType !== "powerhouse/document-model") {
74875
75265
  return errors2;
@@ -74921,7 +75311,7 @@ ${String(result)}`);
74921
75311
  return operationDate >= startDate && operationDate <= endDate;
74922
75312
  });
74923
75313
  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) => {
75314
+ }, lzString, useOnDropFile = (documentTypesOverride) => {
74925
75315
  const selectedDriveId = useSelectedDriveId();
74926
75316
  const selectedFolder = useSelectedFolder();
74927
75317
  const documentTypes = useDocumentTypes();
@@ -74935,7 +75325,7 @@ ${String(result)}`);
74935
75325
  return await addFileWithProgress(file, selectedDriveId, fileName, targetNodeId, onProgress, documentTypesOverride ?? documentTypes, resolveConflict);
74936
75326
  };
74937
75327
  return onDropFile;
74938
- }, store, BrowserLocalStorage, PGLITE_UPDATE_EVENT = "ph:pglite-update", defaultPGliteState, usePGliteDB = () => {
75328
+ }, store, BrowserLocalStorage, DISMISSED_STORAGE_KEY = "ph-connect-dismissed-packages", PGLITE_UPDATE_EVENT = "ph:pglite-update", defaultPGliteState, usePGliteDB = () => {
74939
75329
  const [state, setState] = useState5(() => window.powerhouse?.pglite ?? defaultPGliteState);
74940
75330
  useEffect5(() => {
74941
75331
  const handlePgliteUpdate = () => setState(window.powerhouse?.pglite ?? defaultPGliteState);
@@ -74961,7 +75351,7 @@ ${String(result)}`);
74961
75351
  const pglite = usePGliteDB();
74962
75352
  const setPGlite = useSetPGliteDB();
74963
75353
  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 = () => {
75354
+ }, 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
75355
  throw new Error("not implemented");
74966
75356
  }, _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
75357
  astr("base64", s3);
@@ -75736,7 +76126,7 @@ ${String(result)}`);
75736
76126
  }, MAX_RETRIES = 5, RETRY_DELAY = 200, isRelationNotExistError = (error3) => {
75737
76127
  const errorMessage = error3 instanceof Error ? error3.message : typeof error3 === "string" ? error3 : String(error3);
75738
76128
  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,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", POPOVER_GAP = 8, POPOVER_HEIGHT = 120, styles, POPOVER_GAP2 = 8, POPOVER_HEIGHT2 = 150, styles2;
76129
+ }, import_lodash, ConflictError, Slot, lightStyles, darkStyles, styles, POPOVER_GAP = 4, POPOVER_HEIGHT = 150, styles2;
75740
76130
  var init_src2 = __esm(() => {
75741
76131
  init_src();
75742
76132
  init_src();
@@ -80093,6 +80483,52 @@ spurious results.`);
80093
80483
  SPLIT_UPPER_UPPER_RE = /(\p{Lu})([\p{Lu}][\p{Ll}])/gu;
80094
80484
  SPLIT_SEPARATE_NUMBER_RE = /(\d)\p{Ll}|(\p{L})\d/u;
80095
80485
  DEFAULT_STRIP_REGEXP = /[^\p{L}\d]+/giu;
80486
+ isServer = typeof window === "undefined";
80487
+ ({
80488
+ useValue: useLoading,
80489
+ setValue: setLoading,
80490
+ addEventHandler: addLoadingEventHandler
80491
+ } = makePHEventFunctions("loading"));
80492
+ renownEventFunctions = makePHEventFunctions("renown");
80493
+ addRenownEventHandler = renownEventFunctions.addEventHandler;
80494
+ useRenown = renownEventFunctions.useValue;
80495
+ setRenown = renownEventFunctions.setValue;
80496
+ DOMAIN_TYPE = [
80497
+ { name: "name", type: "string" },
80498
+ { name: "version", type: "string" },
80499
+ { name: "chainId", type: "uint256" },
80500
+ { name: "verifyingContract", type: "address" }
80501
+ ];
80502
+ VERIFIABLE_CREDENTIAL_EIP712_TYPE = [
80503
+ { name: "@context", type: "string[]" },
80504
+ { name: "type", type: "string[]" },
80505
+ { name: "id", type: "string" },
80506
+ { name: "issuer", type: "Issuer" },
80507
+ { name: "credentialSubject", type: "CredentialSubject" },
80508
+ { name: "credentialSchema", type: "CredentialSchema" },
80509
+ { name: "issuanceDate", type: "string" },
80510
+ { name: "expirationDate", type: "string" }
80511
+ ];
80512
+ CREDENTIAL_SCHEMA_EIP712_TYPE = [
80513
+ { name: "id", type: "string" },
80514
+ { name: "type", type: "string" }
80515
+ ];
80516
+ CREDENTIAL_SUBJECT_TYPE = [
80517
+ { name: "app", type: "string" },
80518
+ { name: "id", type: "string" },
80519
+ { name: "name", type: "string" }
80520
+ ];
80521
+ ISSUER_TYPE = [
80522
+ { name: "id", type: "string" },
80523
+ { name: "ethereumAddress", type: "string" }
80524
+ ];
80525
+ CREDENTIAL_TYPES = {
80526
+ EIP712Domain: DOMAIN_TYPE,
80527
+ VerifiableCredential: VERIFIABLE_CREDENTIAL_EIP712_TYPE,
80528
+ CredentialSchema: CREDENTIAL_SCHEMA_EIP712_TYPE,
80529
+ CredentialSubject: CREDENTIAL_SUBJECT_TYPE,
80530
+ Issuer: ISSUER_TYPE
80531
+ };
80096
80532
  isExternalControlsEnabledEventFunctions = makePHEventFunctions("isExternalControlsEnabled");
80097
80533
  setIsExternalControlsEnabled = isExternalControlsEnabledEventFunctions.setValue;
80098
80534
  useIsExternalControlsEnabled = isExternalControlsEnabledEventFunctions.useValue;
@@ -80121,14 +80557,8 @@ spurious results.`);
80121
80557
  vetraPackageManagerFunctions = makePHEventFunctions("vetraPackageManager");
80122
80558
  useVetraPackageManager = vetraPackageManagerFunctions.useValue;
80123
80559
  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;
80560
+ EMPTY_PENDING = [];
80561
+ EMPTY_DISMISSED = [];
80132
80562
  documentEventFunctions = makePHEventFunctions("documentCache");
80133
80563
  useDocumentCache = documentEventFunctions.useValue;
80134
80564
  setDocumentCache = documentEventFunctions.setValue;
@@ -81176,6 +81606,14 @@ spurious results.`);
81176
81606
  ...phDocumentEditorConfigHooks,
81177
81607
  ...nonUserConfigHooks
81178
81608
  };
81609
+ reactorClientModuleEventFunctions = makePHEventFunctions("reactorClientModule");
81610
+ reactorClientEventFunctions = makePHEventFunctions("reactorClient");
81611
+ useReactorClientModule = reactorClientModuleEventFunctions.useValue;
81612
+ setReactorClientModule = reactorClientModuleEventFunctions.setValue;
81613
+ addReactorClientModuleEventHandler = reactorClientModuleEventFunctions.addEventHandler;
81614
+ useReactorClient = reactorClientEventFunctions.useValue;
81615
+ setReactorClient = reactorClientEventFunctions.setValue;
81616
+ addReactorClientEventHandler = reactorClientEventFunctions.addEventHandler;
81179
81617
  featuresEventFunctions = makePHEventFunctions("features");
81180
81618
  useFeatures = featuresEventFunctions.useValue;
81181
81619
  setFeatures = featuresEventFunctions.setValue;
@@ -81208,51 +81646,6 @@ spurious results.`);
81208
81646
  [SyncStatus.Error]: "ERROR"
81209
81647
  };
81210
81648
  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
81649
  store = {
81257
81650
  get: function(key) {
81258
81651
  const value = localStorage.getItem(key);
@@ -81425,7 +81818,7 @@ spurious results.`);
81425
81818
  1541459225,
81426
81819
  327033209
81427
81820
  ]);
81428
- U32_MASK64 = /* @__PURE__ */ BigInt(4294967295);
81821
+ U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
81429
81822
  _32n = /* @__PURE__ */ BigInt(32);
81430
81823
  SHA256_K = /* @__PURE__ */ Uint32Array.from([
81431
81824
  1116352408,
@@ -81975,7 +82368,7 @@ spurious results.`);
81975
82368
  this.iHash.update(pad);
81976
82369
  this.oHash = hash.create();
81977
82370
  for (let i3 = 0;i3 < pad.length; i3++)
81978
- pad[i3] ^= 106;
82371
+ pad[i3] ^= 54 ^ 92;
81979
82372
  this.oHash.update(pad);
81980
82373
  clean(pad);
81981
82374
  }
@@ -82240,11 +82633,11 @@ spurious results.`);
82240
82633
  RIPEMD160 = class RIPEMD160 extends HashMD {
82241
82634
  constructor() {
82242
82635
  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;
82636
+ this.h0 = 1732584193 | 0;
82637
+ this.h1 = 4023233417 | 0;
82638
+ this.h2 = 2562383102 | 0;
82639
+ this.h3 = 271733878 | 0;
82640
+ this.h4 = 3285377520 | 0;
82248
82641
  }
82249
82642
  get() {
82250
82643
  const { h0, h1, h2, h3, h4 } = this;
@@ -82422,7 +82815,7 @@ spurious results.`);
82422
82815
  return to;
82423
82816
  }
82424
82817
  };
82425
- keccak_256 = /* @__PURE__ */ (() => gen(1, 136, 32))();
82818
+ keccak_256 = /* @__PURE__ */ (() => gen(1, 136, 256 / 8))();
82426
82819
  import_canonicalize = __toESM2(require_canonicalize(), 1);
82427
82820
  ID_CHAR = `(?:[a-zA-Z0-9._-]|${PCT_ENCODED})`;
82428
82821
  METHOD_ID = `((?:${ID_CHAR}*:)*(${ID_CHAR}+))`;
@@ -87273,72 +87666,63 @@ spurious results.`);
87273
87666
  this.name = "ConflictError";
87274
87667
  }
87275
87668
  };
87276
- styles = {
87669
+ Slot = forwardRef(({ children, ...props }, ref) => {
87670
+ const child = Children2.only(children);
87671
+ if (!isValidElement3(child)) {
87672
+ return null;
87673
+ }
87674
+ const childElement = child;
87675
+ const mergedProps = mergeProps2(props, childElement.props);
87676
+ if (ref) {
87677
+ mergedProps.ref = ref;
87678
+ }
87679
+ return cloneElement2(childElement, mergedProps);
87680
+ });
87681
+ Slot.displayName = "Slot";
87682
+ lightStyles = {
87277
87683
  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)"
87684
+ backgroundColor: "#ffffff",
87685
+ borderWidth: "1px",
87686
+ borderStyle: "solid",
87687
+ borderColor: "#d1d5db",
87688
+ color: "#111827"
87296
87689
  },
87297
- popoverDark: {
87690
+ triggerHover: {
87691
+ backgroundColor: "#ecf3f8",
87692
+ borderColor: "#9ca3af"
87693
+ }
87694
+ };
87695
+ darkStyles = {
87696
+ trigger: {
87298
87697
  backgroundColor: "#1f2937",
87299
- boxShadow: "0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2)"
87698
+ borderWidth: "1px",
87699
+ borderStyle: "solid",
87700
+ borderColor: "#4b5563",
87701
+ color: "#ecf3f8"
87300
87702
  },
87301
- popoverContent: {
87302
- padding: "16px"
87303
- },
87304
- logoContainer: {
87305
- display: "flex",
87306
- justifyContent: "center",
87307
- height: "22px",
87308
- width: "83px",
87309
- margin: "0 auto 16px",
87310
- overflow: "hidden"
87703
+ triggerHover: {
87704
+ backgroundColor: "#374151",
87705
+ borderColor: "#6b7280"
87706
+ }
87707
+ };
87708
+ styles = {
87709
+ wrapper: {
87710
+ position: "relative",
87711
+ display: "inline-block"
87311
87712
  },
87312
- connectButtonBase: {
87713
+ trigger: {
87313
87714
  display: "flex",
87314
87715
  alignItems: "center",
87315
87716
  justifyContent: "center",
87316
- width: "100%",
87317
- height: "28px",
87717
+ gap: "8px",
87718
+ padding: "8px 32px",
87318
87719
  borderRadius: "8px",
87319
- backgroundColor: "transparent",
87320
- fontSize: "14px",
87321
87720
  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)"
87721
+ fontSize: "14px",
87722
+ fontWeight: 500,
87723
+ fontFamily: "inherit",
87724
+ lineHeight: "20px",
87725
+ transition: "background-color 150ms, border-color 150ms"
87342
87726
  }
87343
87727
  };
87344
87728
  styles2 = {
@@ -87349,56 +87733,89 @@ spurious results.`);
87349
87733
  trigger: {
87350
87734
  display: "flex",
87351
87735
  alignItems: "center",
87352
- justifyContent: "center",
87353
- padding: 0,
87354
- border: "none",
87355
- background: "transparent",
87736
+ gap: "8px",
87737
+ padding: "6px 12px",
87738
+ borderWidth: "1px",
87739
+ borderStyle: "solid",
87740
+ borderColor: "#e5e7eb",
87741
+ backgroundColor: "#ffffff",
87356
87742
  cursor: "pointer",
87357
- borderRadius: "50%",
87358
- overflow: "hidden"
87743
+ borderRadius: "8px",
87744
+ fontSize: "12px",
87745
+ fontWeight: 500,
87746
+ fontFamily: "inherit",
87747
+ color: "#111827",
87748
+ transition: "background-color 150ms, border-color 150ms"
87749
+ },
87750
+ triggerHover: {
87751
+ backgroundColor: "#f9fafb",
87752
+ borderColor: "#9ca3af"
87359
87753
  },
87360
87754
  avatar: {
87361
- width: "40px",
87362
- height: "40px",
87755
+ width: "28px",
87756
+ height: "28px",
87363
87757
  borderRadius: "50%",
87364
- objectFit: "cover"
87758
+ objectFit: "cover",
87759
+ flexShrink: 0
87365
87760
  },
87366
87761
  avatarPlaceholder: {
87367
- width: "40px",
87368
- height: "40px",
87762
+ width: "28px",
87763
+ height: "28px",
87369
87764
  borderRadius: "50%",
87370
- backgroundColor: "#e5e7eb",
87765
+ background: "linear-gradient(135deg, #8b5cf6, #3b82f6)",
87371
87766
  display: "flex",
87372
87767
  alignItems: "center",
87373
- justifyContent: "center"
87768
+ justifyContent: "center",
87769
+ flexShrink: 0
87770
+ },
87771
+ avatarInitial: {
87772
+ fontSize: "12px",
87773
+ fontWeight: 700,
87774
+ color: "#ffffff",
87775
+ lineHeight: 1
87776
+ },
87777
+ displayName: {
87778
+ maxWidth: "120px",
87779
+ overflow: "hidden",
87780
+ textOverflow: "ellipsis",
87781
+ whiteSpace: "nowrap"
87782
+ },
87783
+ chevron: {
87784
+ flexShrink: 0,
87785
+ transition: "transform 150ms",
87786
+ color: "#6b7280"
87787
+ },
87788
+ chevronOpen: {
87789
+ transform: "rotate(180deg)"
87374
87790
  },
87375
87791
  popoverBase: {
87376
87792
  position: "absolute",
87377
- left: 0,
87378
- backgroundColor: "white",
87793
+ right: 0,
87794
+ backgroundColor: "#ffffff",
87379
87795
  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",
87796
+ boxShadow: "0 4px 12px rgba(0, 0, 0, 0.12), 0 1px 3px rgba(0, 0, 0, 0.08)",
87797
+ width: "100%",
87382
87798
  zIndex: 1000,
87383
- color: "#111827"
87799
+ color: "#111827",
87800
+ borderWidth: "1px",
87801
+ borderStyle: "solid",
87802
+ borderColor: "#e5e7eb",
87803
+ overflow: "hidden"
87384
87804
  },
87385
- section: {
87386
- padding: "8px 12px",
87805
+ header: {
87806
+ padding: "12px 16px",
87387
87807
  borderBottom: "1px solid #e5e7eb"
87388
87808
  },
87389
- sectionLast: {
87390
- padding: "8px 12px",
87391
- borderBottom: "none"
87392
- },
87393
- username: {
87809
+ headerUsername: {
87394
87810
  fontSize: "14px",
87395
- fontWeight: 500,
87396
- color: "#111827"
87811
+ fontWeight: 600,
87812
+ color: "#111827",
87813
+ margin: 0
87397
87814
  },
87398
87815
  addressRow: {
87399
87816
  display: "flex",
87400
87817
  alignItems: "center",
87401
- gap: "8px",
87818
+ gap: "4px",
87402
87819
  marginTop: "4px"
87403
87820
  },
87404
87821
  addressButton: {
@@ -87407,19 +87824,21 @@ spurious results.`);
87407
87824
  gap: "4px",
87408
87825
  padding: 0,
87409
87826
  border: "none",
87410
- background: "transparent",
87827
+ backgroundColor: "transparent",
87411
87828
  cursor: "pointer",
87412
87829
  fontSize: "12px",
87413
- color: "#111827",
87830
+ color: "#6b7280",
87831
+ fontFamily: "inherit",
87414
87832
  position: "relative",
87415
87833
  width: "100%"
87416
87834
  },
87417
87835
  copiedText: {
87418
87836
  fontSize: "12px",
87419
- color: "#111827",
87837
+ color: "#059669",
87420
87838
  position: "absolute",
87421
87839
  left: 0,
87422
- transition: "opacity 150ms"
87840
+ transition: "opacity 150ms",
87841
+ fontWeight: 500
87423
87842
  },
87424
87843
  addressText: {
87425
87844
  display: "flex",
@@ -87427,34 +87846,48 @@ spurious results.`);
87427
87846
  gap: "4px",
87428
87847
  transition: "opacity 150ms"
87429
87848
  },
87849
+ menuSection: {
87850
+ padding: "4px 0"
87851
+ },
87430
87852
  menuItem: {
87431
87853
  display: "flex",
87432
87854
  alignItems: "center",
87433
87855
  gap: "8px",
87434
87856
  width: "100%",
87435
- padding: 0,
87857
+ padding: "8px 16px",
87436
87858
  border: "none",
87437
- background: "transparent",
87859
+ backgroundColor: "transparent",
87438
87860
  cursor: "pointer",
87439
87861
  fontSize: "14px",
87440
- color: "#111827",
87441
- textDecoration: "none"
87862
+ color: "#374151",
87863
+ textDecoration: "none",
87864
+ fontFamily: "inherit",
87865
+ transition: "background-color 150ms"
87866
+ },
87867
+ menuItemHover: {
87868
+ backgroundColor: "#f3f4f6"
87442
87869
  },
87443
87870
  disconnectItem: {
87444
- color: "#7f1d1d"
87871
+ color: "#dc2626"
87872
+ },
87873
+ separator: {
87874
+ height: "1px",
87875
+ backgroundColor: "#e5e7eb",
87876
+ margin: 0,
87877
+ border: "none"
87445
87878
  }
87446
87879
  };
87447
87880
  });
87448
87881
 
87449
87882
  // src/hooks/useClientErrorHandler.ts
87450
87883
  import { logger as logger7 } from "document-drive";
87451
- import { useCallback as useCallback7, useMemo as useMemo4, useRef as useRef8, useState as useState9 } from "react";
87884
+ import { useCallback as useCallback3, useMemo as useMemo4, useRef as useRef7, useState as useState9 } from "react";
87452
87885
  var DELAY_LIMIT = 1e5, useClientErrorHandler = () => {
87453
87886
  const [handlingInProgress, setHandlingInProgress] = useState9([]);
87454
87887
  const [pullResponderTriggerMap, setPullResponderTriggerMap] = useState9(new Map);
87455
87888
  const drives = useDrives();
87456
- const pullResponderRegisterDelay = useRef8(new Map);
87457
- const handleStrands400 = useCallback7(async (driveId, trigger, handlerCode) => {
87889
+ const pullResponderRegisterDelay = useRef7(new Map);
87890
+ const handleStrands400 = useCallback3(async (driveId, trigger, handlerCode) => {
87458
87891
  setHandlingInProgress((state) => [...state, handlerCode]);
87459
87892
  const triggerData = trigger.data;
87460
87893
  if (!triggerData)
@@ -87487,7 +87920,7 @@ var DELAY_LIMIT = 1e5, useClientErrorHandler = () => {
87487
87920
  pullResponderRegisterDelay,
87488
87921
  registerNewPullResponderTrigger
87489
87922
  ]);
87490
- const handleDriveNotFound = useCallback7(async (driveId, trigger, handlerCode) => {
87923
+ const handleDriveNotFound = useCallback3(async (driveId, trigger, handlerCode) => {
87491
87924
  setHandlingInProgress((state) => [...state, handlerCode]);
87492
87925
  try {
87493
87926
  const drive = drives?.find((drive2) => drive2.header.id === driveId);
@@ -87523,7 +87956,7 @@ var DELAY_LIMIT = 1e5, useClientErrorHandler = () => {
87523
87956
  getDriveIdBySlug,
87524
87957
  addRemoteDrive
87525
87958
  ]);
87526
- const strandsErrorHandler = useCallback7(async (driveId, trigger, status, errorMessage) => {}, [handleDriveNotFound, handleStrands400, handlingInProgress]);
87959
+ const strandsErrorHandler = useCallback3(async (driveId, trigger, status, errorMessage) => {}, [handleDriveNotFound, handleStrands400, handlingInProgress]);
87527
87960
  return useMemo4(() => ({ strandsErrorHandler }), [strandsErrorHandler]);
87528
87961
  };
87529
87962
  var init_useClientErrorHandler = __esm(() => {
@@ -87531,7 +87964,7 @@ var init_useClientErrorHandler = __esm(() => {
87531
87964
  });
87532
87965
 
87533
87966
  // src/hooks/useCookieBanner.ts
87534
- import { useSyncExternalStore as useSyncExternalStore4 } from "react";
87967
+ import { useSyncExternalStore as useSyncExternalStore5 } from "react";
87535
87968
  function getInitial2() {
87536
87969
  try {
87537
87970
  const value = localStorage.getItem(COOKIE_BANNER_KEY_STORAGE);
@@ -87553,7 +87986,7 @@ function subscribe2(fn) {
87553
87986
  return () => listeners2.delete(fn);
87554
87987
  }
87555
87988
  var namespace2, COOKIE_BANNER_KEY_STORAGE, listeners2, bannerShown, useCookieBanner = () => {
87556
- const cookieBannerShown = useSyncExternalStore4(subscribe2, getCookieBannerState, getCookieBannerState);
87989
+ const cookieBannerShown = useSyncExternalStore5(subscribe2, getCookieBannerState, getCookieBannerState);
87557
87990
  return [cookieBannerShown, setCookieBannerState];
87558
87991
  };
87559
87992
  var init_useCookieBanner = __esm(() => {
@@ -88199,7 +88632,7 @@ function isRouteErrorResponse(error3) {
88199
88632
  function createRouter(init4) {
88200
88633
  const routerWindow = init4.window ? init4.window : typeof window !== "undefined" ? window : undefined;
88201
88634
  const isBrowser2 = typeof routerWindow !== "undefined" && typeof routerWindow.document !== "undefined" && typeof routerWindow.document.createElement !== "undefined";
88202
- const isServer = !isBrowser2;
88635
+ const isServer2 = !isBrowser2;
88203
88636
  invariant2(init4.routes.length > 0, "You must provide a non-empty routes array to createRouter");
88204
88637
  let mapRouteProperties;
88205
88638
  if (init4.mapRouteProperties) {
@@ -88963,7 +89396,7 @@ function createRouter(init4) {
88963
89396
  return new Map(state.fetchers);
88964
89397
  }
88965
89398
  function fetch3(key, routeId, href, opts) {
88966
- if (isServer) {
89399
+ if (isServer2) {
88967
89400
  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
89401
  }
88969
89402
  abortFetcher(key);
@@ -92520,7 +92953,7 @@ var init_dist2 = __esm(() => {
92520
92953
 
92521
92954
  // src/hooks/useInitSentry.ts
92522
92955
  import { childLogger } from "document-drive";
92523
- import React8, { useEffect as useEffect13 } from "react";
92956
+ import React8, { useEffect as useEffect11 } from "react";
92524
92957
  async function getSentry() {
92525
92958
  return await Promise.resolve().then(() => (init_esm6(), exports_esm));
92526
92959
  }
@@ -92577,7 +93010,7 @@ async function closeClient() {
92577
93010
  function useInitSentry() {
92578
93011
  const [acceptedCookies] = useAcceptedCookies();
92579
93012
  const { analytics } = acceptedCookies;
92580
- useEffect13(() => {
93013
+ useEffect11(() => {
92581
93014
  if (!analytics) {
92582
93015
  closeClient().catch((error3) => logger9.error("@error", error3));
92583
93016
  return;
@@ -92635,7 +93068,7 @@ var init_useNodeActions = __esm(() => {
92635
93068
  });
92636
93069
 
92637
93070
  // ../../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";
93071
+ 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
93072
  import { jsx } from "react/jsx-runtime";
92640
93073
  function _extends4() {
92641
93074
  return _extends4 = Object.assign ? Object.assign.bind() : function(n5) {
@@ -92769,7 +93202,7 @@ function deepEqual(x2, y2) {
92769
93202
  }, true) : x2 === y2;
92770
93203
  }
92771
93204
  function useDeepEqualMemo(value) {
92772
- var ref = useRef12(undefined);
93205
+ var ref = useRef11(undefined);
92773
93206
  if (!deepEqual(ref.current, value)) {
92774
93207
  ref.current = value;
92775
93208
  }
@@ -92777,12 +93210,12 @@ function useDeepEqualMemo(value) {
92777
93210
  }
92778
93211
  function useHotkeys(keys2, callback, options, dependencies) {
92779
93212
  var _useState = useState13(null), ref = _useState[0], setRef = _useState[1];
92780
- var hasTriggeredRef = useRef12(false);
93213
+ var hasTriggeredRef = useRef11(false);
92781
93214
  var _options = !(options instanceof Array) ? options : !(dependencies instanceof Array) ? dependencies : undefined;
92782
93215
  var _keys = isReadonlyArray3(keys2) ? keys2.join(_options == null ? undefined : _options.splitKey) : keys2;
92783
93216
  var _deps = options instanceof Array ? options : dependencies instanceof Array ? dependencies : undefined;
92784
93217
  var memoisedCB = useCallback12(callback, _deps != null ? _deps : []);
92785
- var cbRef = useRef12(memoisedCB);
93218
+ var cbRef = useRef11(memoisedCB);
92786
93219
  if (_deps) {
92787
93220
  cbRef.current = memoisedCB;
92788
93221
  } else {
@@ -92975,7 +93408,7 @@ var init_react_hotkeys_hook_esm = __esm(() => {
92975
93408
  enableScope: function enableScope() {},
92976
93409
  disableScope: function disableScope() {}
92977
93410
  });
92978
- useSafeLayoutEffect = typeof window !== "undefined" ? useLayoutEffect3 : useEffect14;
93411
+ useSafeLayoutEffect = typeof window !== "undefined" ? useLayoutEffect3 : useEffect12;
92979
93412
  });
92980
93413
 
92981
93414
  // src/hooks/useUndoRedoShortcuts.ts
@@ -93006,13 +93439,13 @@ var init_useUndoRedoShortcuts = __esm(() => {
93006
93439
  });
93007
93440
 
93008
93441
  // src/hooks/useWindowSize.ts
93009
- import { useEffect as useEffect15, useState as useState14 } from "react";
93442
+ import { useEffect as useEffect13, useState as useState14 } from "react";
93010
93443
  var useWindowSize = () => {
93011
93444
  const [windowSize, setWindowSize] = useState14({
93012
93445
  innerWidth: window.innerWidth,
93013
93446
  innerHeight: window.innerHeight
93014
93447
  });
93015
- useEffect15(() => {
93448
+ useEffect13(() => {
93016
93449
  const windowSizeHandler = () => {
93017
93450
  setWindowSize({
93018
93451
  innerWidth: window.innerWidth,
@@ -93034,7 +93467,7 @@ var init_package = __esm(() => {
93034
93467
  package_default = {
93035
93468
  name: "@powerhousedao/connect",
93036
93469
  productName: "Powerhouse-Connect",
93037
- version: "6.0.0-dev.82",
93470
+ version: "6.0.0-dev.87",
93038
93471
  description: "Powerhouse Connect",
93039
93472
  main: "dist/index.html",
93040
93473
  type: "module",