@codemem/core 0.46.0-alpha.2 → 0.46.0-beta.2

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.
Files changed (81) hide show
  1. package/dist/api-types.d.ts +1 -0
  2. package/dist/api-types.d.ts.map +1 -1
  3. package/dist/{coordinator-api-BToPmSNg.js → coordinator-api-CdUQtf5l.js} +565 -541
  4. package/dist/coordinator-api-CdUQtf5l.js.map +1 -0
  5. package/dist/coordinator-enrollment-reconciler.d.ts.map +1 -1
  6. package/dist/coordinator-runtime.d.ts.map +1 -1
  7. package/dist/database-runtime-primitives.d.ts +1 -1
  8. package/dist/db.d.ts.map +1 -1
  9. package/dist/device-identity-binding.d.ts +2 -0
  10. package/dist/device-identity-binding.d.ts.map +1 -1
  11. package/dist/device-identity-inventory.d.ts.map +1 -1
  12. package/dist/index.d.ts +8 -6
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +11930 -10072
  15. package/dist/index.js.map +1 -1
  16. package/dist/internal/cloudflare-coordinator.js +1 -1
  17. package/dist/legacy-recipient-policy-projection.d.ts.map +1 -1
  18. package/dist/legacy-team-candidate.d.ts.map +1 -1
  19. package/dist/legacy-team-setup-activation.d.ts +0 -4
  20. package/dist/legacy-team-setup-activation.d.ts.map +1 -1
  21. package/dist/legacy-team-setup-completion-manifest.d.ts.map +1 -1
  22. package/dist/memory-ownership-recovery-schema.d.ts +3 -0
  23. package/dist/memory-ownership-recovery-schema.d.ts.map +1 -0
  24. package/dist/memory-ownership-recovery.d.ts +77 -0
  25. package/dist/memory-ownership-recovery.d.ts.map +1 -0
  26. package/dist/memory-retirement-delivery-schema.d.ts +3 -0
  27. package/dist/memory-retirement-delivery-schema.d.ts.map +1 -0
  28. package/dist/memory-retirement-delivery.d.ts +70 -0
  29. package/dist/memory-retirement-delivery.d.ts.map +1 -0
  30. package/dist/memory-retirement-reset.d.ts +48 -0
  31. package/dist/memory-retirement-reset.d.ts.map +1 -0
  32. package/dist/memory-retirement-snapshot-guard.d.ts +4 -0
  33. package/dist/memory-retirement-snapshot-guard.d.ts.map +1 -0
  34. package/dist/memory-retirement-trust.d.ts +13 -0
  35. package/dist/memory-retirement-trust.d.ts.map +1 -0
  36. package/dist/memory-scope-retirement.d.ts +24 -0
  37. package/dist/memory-scope-retirement.d.ts.map +1 -0
  38. package/dist/memory-source-identity.d.ts +26 -0
  39. package/dist/memory-source-identity.d.ts.map +1 -0
  40. package/dist/observer-client.d.ts +6 -2
  41. package/dist/observer-client.d.ts.map +1 -1
  42. package/dist/observer-config.d.ts +3 -1
  43. package/dist/observer-config.d.ts.map +1 -1
  44. package/dist/project-scope-settings.d.ts +28 -3
  45. package/dist/project-scope-settings.d.ts.map +1 -1
  46. package/dist/project.d.ts +1 -0
  47. package/dist/project.d.ts.map +1 -1
  48. package/dist/recipient-policy-edges.d.ts.map +1 -1
  49. package/dist/recipient-policy-intent.d.ts.map +1 -1
  50. package/dist/recipient-policy-migration.d.ts.map +1 -1
  51. package/dist/recipient-policy-onboarding.d.ts.map +1 -1
  52. package/dist/recipient-policy-reconciler.d.ts.map +1 -1
  53. package/dist/recipient-policy-reconciliation.d.ts.map +1 -1
  54. package/dist/recipient-policy-review.d.ts.map +1 -1
  55. package/dist/repository-discovery-cache.d.ts +10 -0
  56. package/dist/repository-discovery-cache.d.ts.map +1 -0
  57. package/dist/repository-discovery-index.d.ts +14 -0
  58. package/dist/repository-discovery-index.d.ts.map +1 -0
  59. package/dist/repository-mapping-aliases.d.ts +48 -0
  60. package/dist/repository-mapping-aliases.d.ts.map +1 -0
  61. package/dist/schema-bootstrap.d.ts.map +1 -1
  62. package/dist/schema.d.ts +34 -0
  63. package/dist/schema.d.ts.map +1 -1
  64. package/dist/scope-resolution.d.ts +5 -1
  65. package/dist/scope-resolution.d.ts.map +1 -1
  66. package/dist/scope-stamping.d.ts.map +1 -1
  67. package/dist/share-operation.d.ts.map +1 -1
  68. package/dist/share-provisioning.d.ts +1 -0
  69. package/dist/share-provisioning.d.ts.map +1 -1
  70. package/dist/store.d.ts +2 -1
  71. package/dist/store.d.ts.map +1 -1
  72. package/dist/sync-bootstrap.d.ts +6 -1
  73. package/dist/sync-bootstrap.d.ts.map +1 -1
  74. package/dist/sync-capability.d.ts +1 -1
  75. package/dist/sync-capability.d.ts.map +1 -1
  76. package/dist/sync-replication.d.ts +2 -18
  77. package/dist/sync-replication.d.ts.map +1 -1
  78. package/dist/test-schema.generated.d.ts +1 -1
  79. package/dist/test-schema.generated.d.ts.map +1 -1
  80. package/package.json +3 -3
  81. package/dist/coordinator-api-BToPmSNg.js.map +0 -1
@@ -42,31 +42,40 @@ function f(e) {
42
42
  return !n && r.some(i) && (o = JSON.stringify(r)), `unmapped:${t("sha256").update(o, "utf8").digest("hex")}`;
43
43
  }
44
44
  function p(e) {
45
- let t = a(e.gitRemote), n = a(e.gitBranch), r = a(e.cwd), i = a(e.workspaceId), o = a(e.project);
45
+ let t = a(e.gitRemote), n = a(e.gitBranch), r = a(e.repositoryIdentity), i = a(e.cwd), o = a(e.workspaceId), s = a(e.project);
46
+ if (r && !e.branchScoped) return {
47
+ value: l(r),
48
+ source: "git_repository",
49
+ displayProject: s
50
+ };
46
51
  if (t) {
47
52
  let r = l(t);
48
53
  return e.branchScoped && n ? {
49
54
  value: `${r}:${n}`,
50
55
  source: "git_remote_branch",
51
- displayProject: o
56
+ displayProject: s
52
57
  } : {
53
58
  value: r,
54
59
  source: "git_remote",
55
- displayProject: o
60
+ displayProject: s
56
61
  };
57
62
  }
58
63
  return r ? {
59
- value: u(r),
60
- source: "cwd",
61
- displayProject: o
64
+ value: l(r),
65
+ source: "git_repository",
66
+ displayProject: s
62
67
  } : i ? {
63
- value: l(i),
68
+ value: u(i),
69
+ source: "cwd",
70
+ displayProject: s
71
+ } : o ? {
72
+ value: l(o),
64
73
  source: "workspace_id",
65
- displayProject: o
74
+ displayProject: s
66
75
  } : {
67
76
  value: f(e),
68
77
  source: "unmapped",
69
- displayProject: o
78
+ displayProject: s
70
79
  };
71
80
  }
72
81
  function m(e) {
@@ -99,11 +108,17 @@ function b(e) {
99
108
  }
100
109
  function x(e, t) {
101
110
  let n = [t.value];
102
- if (t.source !== "git_remote" && t.source !== "git_remote_branch") return n;
111
+ if (e.allowRepositoryCwdFallback === !1 || t.source !== "git_repository" && t.source !== "git_remote" && t.source !== "git_remote_branch") return n;
103
112
  let r = a(e.cwd);
104
113
  return r && n.push(u(r)), n;
105
114
  }
106
115
  function S(e, t) {
116
+ let n = [t.value];
117
+ if (e.allowRepositoryCwdFallback === !1 || t.source !== "git_repository" && t.source !== "git_remote" && t.source !== "git_remote_branch") return n;
118
+ let r = a(e.cwd);
119
+ return r && n.push(u(r)), n;
120
+ }
121
+ function C(e, t) {
107
122
  for (let n of t) {
108
123
  let t = b(e.filter((e) => d(e.workspace_identity) === n).map((e) => ({
109
124
  mapping: e,
@@ -114,7 +129,7 @@ function S(e, t) {
114
129
  }
115
130
  return null;
116
131
  }
117
- function te(e, t) {
132
+ function w(e, t) {
118
133
  return b(t.flatMap((t) => e.flatMap((e) => {
119
134
  if (c(e.workspace_identity)) return [];
120
135
  let n = c(e.project_pattern);
@@ -125,7 +140,16 @@ function te(e, t) {
125
140
  }];
126
141
  })));
127
142
  }
128
- function C(e) {
143
+ function T(e, t) {
144
+ let n = [...t].map(l), r = /* @__PURE__ */ new Set();
145
+ for (let t of e) {
146
+ if (c(t.workspace_identity)) continue;
147
+ let e = c(t.project_pattern);
148
+ !e || !n.some((t) => _(t, e)) || r.add(t.scope_id);
149
+ }
150
+ return r;
151
+ }
152
+ function E(e) {
129
153
  let t = p(e), n = c(e.explicitScopeId);
130
154
  if (n) return {
131
155
  scopeId: n,
@@ -141,21 +165,21 @@ function C(e) {
141
165
  mapping: null,
142
166
  matchedPattern: null
143
167
  };
144
- let r = e.mappings ?? [], i = x(e, t), a = S(r, i);
145
- if (a) return {
146
- scopeId: a.mapping.scope_id,
168
+ let r = e.mappings ?? [], i = C(r, x(e, t));
169
+ if (i) return {
170
+ scopeId: i.mapping.scope_id,
147
171
  reason: "exact_mapping",
148
172
  workspaceIdentity: t,
149
- mapping: a.mapping,
173
+ mapping: i.mapping,
150
174
  matchedPattern: null
151
175
  };
152
- let o = te(r, i);
153
- return o ? {
154
- scopeId: o.mapping.scope_id,
176
+ let a = w(r, S(e, t));
177
+ return a ? {
178
+ scopeId: a.mapping.scope_id,
155
179
  reason: "pattern_mapping",
156
180
  workspaceIdentity: t,
157
- mapping: o.mapping,
158
- matchedPattern: o.matchedPattern
181
+ mapping: a.mapping,
182
+ matchedPattern: a.matchedPattern
159
183
  } : {
160
184
  scopeId: e.localDefaultScopeId ?? "local-default",
161
185
  reason: "local_default",
@@ -164,7 +188,7 @@ function C(e) {
164
188
  matchedPattern: null
165
189
  };
166
190
  }
167
- function w(e, t) {
191
+ function te(e, t) {
168
192
  let n = /* @__PURE__ */ new Set([
169
193
  "",
170
194
  o,
@@ -175,18 +199,18 @@ function w(e, t) {
175
199
  for (let e of i) e.scope_id != null && n.add(e.scope_id);
176
200
  return [...n];
177
201
  }
178
- function T(e) {
202
+ function ne(e) {
179
203
  if (e.devices.length > 500 || e.projects.length > 500 || e.devices.length * e.projects.length > 1e4) throw Error("legacy_team_setup_roster_too_large");
180
204
  }
181
- function ne(e) {
205
+ function re(e) {
182
206
  if (e.projectIdentities.size * e.deviceCount > 1e4) throw Error("legacy_team_setup_roster_too_large");
183
207
  }
184
- function re(e, t, n) {
208
+ function ie(e, t, n) {
185
209
  if (n.length === 0) return;
186
210
  let r = [...new Set(t.map((e) => e.deviceId))], i = r.length > 0 ? `WHERE device_id NOT IN (${r.map(() => "?").join(", ")})` : "", a = Number(e.prepare(`SELECT COUNT(*) FROM identity_devices ${i}`).pluck().get(...r) ?? 0);
187
211
  if ((r.length + a) * n.length > 1e4) throw Error("legacy_team_setup_roster_too_large");
188
212
  }
189
- function ie(e, t, n, r) {
213
+ function ae(e, t, n, r) {
190
214
  if (!r) return;
191
215
  let i = [...new Set(t.map((e) => e.deviceId))], a = i.map(() => "?").join(", "), o = a ? `AND device_id NOT IN (${a})` : "", s = Number(e.prepare(`SELECT COUNT(*) FROM legacy_team_setup_draft_devices
192
216
  WHERE attempt_id = ? ${o}`).pluck().get(r, ...i) ?? 0), c = t.length + s;
@@ -194,31 +218,31 @@ function ie(e, t, n, r) {
194
218
  }
195
219
  //#endregion
196
220
  //#region src/recipient-policy-identifiers.ts
197
- function E(e, t) {
221
+ function oe(e, t) {
198
222
  return e < t ? -1 : +(e > t);
199
223
  }
200
- var ae = /[\p{Cc}\p{Cf}]/u;
201
- function oe(e, t) {
202
- return typeof e == "string" && e.length > 0 && e === e.trim() && e.length <= t && !ae.test(e);
224
+ var se = /[\p{Cc}\p{Cf}]/u;
225
+ function ce(e, t) {
226
+ return typeof e == "string" && e.length > 0 && e === e.trim() && e.length <= t && !se.test(e);
203
227
  }
204
- function se(e) {
205
- return oe(e, 256);
228
+ function le(e) {
229
+ return ce(e, 256);
206
230
  }
207
- function ce(e) {
208
- return oe(e, 2048);
231
+ function ue(e) {
232
+ return ce(e, 2048);
209
233
  }
210
- var le = "Recipient policy value must be strict JSON data";
234
+ var de = "Recipient policy value must be strict JSON data";
211
235
  function D() {
212
- throw TypeError(le);
236
+ throw TypeError(de);
213
237
  }
214
- function ue(e) {
238
+ function fe(e) {
215
239
  let t = JSON.stringify(e);
216
240
  return t === void 0 ? D() : t;
217
241
  }
218
- function de(e, t) {
242
+ function pe(e, t) {
219
243
  if (e === null) return "null";
220
244
  if (typeof e == "boolean") return e ? "true" : "false";
221
- if (typeof e == "string") return ue(e);
245
+ if (typeof e == "string") return fe(e);
222
246
  if (typeof e == "number") return !Number.isFinite(e) || Object.is(e, -0) ? D() : String(e);
223
247
  if (typeof e != "object" || t.has(e)) return D();
224
248
  t.add(e);
@@ -231,7 +255,7 @@ function de(e, t) {
231
255
  for (let n = 0; n < e.length; n += 1) {
232
256
  let i = Object.getOwnPropertyDescriptor(e, String(n));
233
257
  if (!i?.enumerable || !("value" in i)) return D();
234
- r.push(de(i.value, t));
258
+ r.push(pe(i.value, t));
235
259
  }
236
260
  return `[${r.join(",")}]`;
237
261
  }
@@ -240,51 +264,51 @@ function de(e, t) {
240
264
  if (typeof t != "string") return D();
241
265
  let n = Object.getOwnPropertyDescriptor(e, t);
242
266
  return !n?.enumerable || !("value" in n) ? D() : [t, n.value];
243
- }).toSorted(([e], [t]) => E(e, t)).map(([e, n]) => `${ue(e)}:${de(n, t)}`).join(",")}}`;
267
+ }).toSorted(([e], [t]) => oe(e, t)).map(([e, n]) => `${fe(e)}:${pe(n, t)}`).join(",")}}`;
244
268
  } finally {
245
269
  t.delete(e);
246
270
  }
247
271
  }
248
- function fe(e) {
249
- return de(e, /* @__PURE__ */ new WeakSet());
272
+ function me(e) {
273
+ return pe(e, /* @__PURE__ */ new WeakSet());
250
274
  }
251
275
  function O(e, n) {
252
276
  if (e.includes("\0") || !e.isWellFormed()) throw TypeError("Recipient policy digest prefix must be well-formed without NUL");
253
- return `${e}:${t("sha256").update(e, "utf8").update("\0", "utf8").update(fe(n), "utf8").digest("hex")}`;
277
+ return `${e}:${t("sha256").update(e, "utf8").update("\0", "utf8").update(me(n), "utf8").digest("hex")}`;
254
278
  }
255
- function pe(e, n) {
256
- return `${e}:${t("sha256").update(fe(n), "utf8").digest("hex")}`;
257
- }
258
- var me = ["team_invite", "coordinator_invite"];
259
279
  function he(e, n) {
280
+ return `${e}:${t("sha256").update(me(n), "utf8").digest("hex")}`;
281
+ }
282
+ var ge = ["team_invite", "coordinator_invite"];
283
+ function _e(e, n) {
260
284
  return `legacy-team-candidate:${t("sha256").update(JSON.stringify([e, n])).digest("hex").slice(0, 32)}`;
261
285
  }
262
- function ge(e, t) {
286
+ function ve(e, t) {
263
287
  return O("legacy-team-project-ref-v1", [e, t]);
264
288
  }
265
- function _e(e, t) {
289
+ function ye(e, t) {
266
290
  return O("legacy-team-canonical-project-ref-v1", [e, t]);
267
291
  }
268
- function ve(e, t) {
292
+ function be(e, t) {
269
293
  return O("legacy-team-device-ref-v1", [e, t]);
270
294
  }
271
- function ye(e) {
272
- return pe("policy-team-v1", e);
295
+ function xe(e) {
296
+ return he("policy-team-v1", e);
273
297
  }
274
- function be(e) {
298
+ function Se(e) {
275
299
  return O("legacy-team-roster-v1", e.map((e) => ({
276
300
  deviceId: e.deviceId,
277
301
  fingerprint: e.fingerprint,
278
302
  enabled: e.enabled,
279
303
  identityId: e.identityId
280
- })).toSorted((e, t) => E(e.deviceId, t.deviceId)));
304
+ })).toSorted((e, t) => oe(e.deviceId, t.deviceId)));
281
305
  }
282
306
  //#endregion
283
307
  //#region src/coordinator-legacy-team-completion.ts
284
- var xe = 1, Se = 50, Ce = 500, we = 15e5, Te = 25 * we, Ee = 256, De = 37661024, Oe = "completion_conflict", ke = class extends Error {
285
- code = Oe;
308
+ var Ce = 1, we = 50, Te = 500, Ee = 15e5, De = 25 * Ee, Oe = 256, ke = 37661024, Ae = "completion_conflict", je = class extends Error {
309
+ code = Ae;
286
310
  constructor() {
287
- super(Oe), this.name = "CoordinatorLegacyTeamCompletionConflictError";
311
+ super(Ae), this.name = "CoordinatorLegacyTeamCompletionConflictError";
288
312
  }
289
313
  };
290
314
  function k() {
@@ -297,41 +321,41 @@ function j(e, t) {
297
321
  let n = new Set(t);
298
322
  Object.keys(e).some((e) => !n.has(e)) && k();
299
323
  }
300
- function Ae(e) {
324
+ function Me(e) {
301
325
  return /^(?:[\\/]{2}|\.{1,2}[\\/]|\/|~[\\/]|[a-z]:[\\/]|file:)/iu.test(e);
302
326
  }
303
327
  function M(e) {
304
- return (typeof e != "string" || !e || e !== e.trim() || e.length > Ee || /[\p{Cc}\p{Cf}]/u.test(e) || Ae(e)) && k(), e;
328
+ return (typeof e != "string" || !e || e !== e.trim() || e.length > Oe || /[\p{Cc}\p{Cf}]/u.test(e) || Me(e)) && k(), e;
305
329
  }
306
330
  function N(e) {
307
331
  let t = M(e);
308
332
  return /^[a-f0-9]{64}$/u.test(t) || k(), t;
309
333
  }
310
- function je(e) {
334
+ function Ne(e) {
311
335
  typeof e != "string" && k();
312
336
  let t = e.normalize("NFC").trim();
313
- return (!t || [...t].length > 120 || /[\p{Cc}\p{Cf}]/u.test(t) || Ae(t)) && k(), t;
337
+ return (!t || [...t].length > 120 || /[\p{Cc}\p{Cf}]/u.test(t) || Me(t)) && k(), t;
314
338
  }
315
- function Me(e) {
339
+ function Pe(e) {
316
340
  (typeof e != "string" || !e) && k();
317
341
  let t = new Date(e);
318
342
  return (Number.isNaN(t.getTime()) || t.toISOString() !== e) && k(), e;
319
343
  }
320
- function Ne(e, t) {
344
+ function Fe(e, t) {
321
345
  return (!Array.isArray(e) || e.length > t) && k(), e;
322
346
  }
323
- function P(e, t) {
324
- let n = e.toSorted((e, n) => E(t(e), t(n)));
347
+ function Ie(e, t) {
348
+ let n = e.toSorted((e, n) => oe(t(e), t(n)));
325
349
  return n.some((e, r) => r > 0 && t(n[r - 1]) === t(e)) && k(), n;
326
350
  }
327
- function Pe(e) {
328
- return P(Ne(e, 50).map(M), (e) => e);
351
+ function Le(e) {
352
+ return Ie(Fe(e, 50).map(M), (e) => e);
329
353
  }
330
- function Fe(e) {
354
+ function Re(e) {
331
355
  let t = M(e);
332
356
  return /^legacy-team-candidate:[a-f0-9]{32}$/u.test(t) || k(), t;
333
357
  }
334
- function Ie(e) {
358
+ function ze(e) {
335
359
  let t = A(e);
336
360
  j(t, [
337
361
  "version",
@@ -356,13 +380,13 @@ function Ie(e) {
356
380
  "policy_revision",
357
381
  "device_eligibility_mode"
358
382
  ]), n.device_eligibility_mode !== "reviewed_allowlist" && k();
359
- let r = M(t.team_id), i = P(Ne(t.memberships, 500).map((e) => {
383
+ let r = M(t.team_id), i = Ie(Fe(t.memberships, 500).map((e) => {
360
384
  let t = A(e);
361
385
  return j(t, ["identity_id", "role"]), t.role !== "member" && k(), {
362
386
  identity_id: M(t.identity_id),
363
387
  role: "member"
364
388
  };
365
- }), (e) => e.identity_id), a = P(Ne(t.device_decisions, 500).map((e) => {
389
+ }), (e) => e.identity_id), a = Ie(Fe(t.device_decisions, 500).map((e) => {
366
390
  let t = A(e);
367
391
  j(t, [
368
392
  "device_id",
@@ -385,7 +409,7 @@ function Ie(e) {
385
409
  a.length === 0 && k();
386
410
  let o = new Set(i.map((e) => e.identity_id)), s = new Set(a.flatMap((e) => e.identity_id ? [e.identity_id] : []));
387
411
  (o.size !== s.size || [...s].some((e) => !o.has(e))) && k();
388
- let c = P(Ne(t.project_mappings, 500).map((e) => {
412
+ let c = Ie(Fe(t.project_mappings, 500).map((e) => {
389
413
  let t = A(e);
390
414
  j(t, [
391
415
  "project_ref",
@@ -403,7 +427,7 @@ function Ie(e) {
403
427
  let t = l.get(e.resolved_project_ref);
404
428
  t && t !== e.scope_id && k(), l.set(e.resolved_project_ref, e.scope_id);
405
429
  }
406
- let u = P(Ne(t.project_recipients, 500).map((e) => {
430
+ let u = Ie(Fe(t.project_recipients, 500).map((e) => {
407
431
  let t = A(e);
408
432
  j(t, ["resolved_project_ref", "team_id"]);
409
433
  let n = M(t.team_id);
@@ -413,12 +437,12 @@ function Ie(e) {
413
437
  resolved_project_ref: i,
414
438
  team_id: n
415
439
  };
416
- }), (e) => e.resolved_project_ref), d = [...new Set(c.map((e) => e.resolved_project_ref))].toSorted(E), f = u.map((e) => e.resolved_project_ref);
440
+ }), (e) => e.resolved_project_ref), d = [...new Set(c.map((e) => e.resolved_project_ref))].toSorted(oe), f = u.map((e) => e.resolved_project_ref);
417
441
  JSON.stringify(f) !== JSON.stringify(d) && k();
418
442
  let p = {
419
443
  version: 1,
420
444
  coordinator_id: M(t.coordinator_id),
421
- candidate_ref: Fe(t.candidate_ref),
445
+ candidate_ref: Re(t.candidate_ref),
422
446
  candidate_digest: N(t.candidate_digest),
423
447
  team_id: r,
424
448
  team_digest: N(t.team_digest),
@@ -426,7 +450,7 @@ function Ie(e) {
426
450
  finish_digest: N(t.finish_digest),
427
451
  access_delta_digest: N(t.access_delta_digest),
428
452
  team: {
429
- display_name: je(n.display_name),
453
+ display_name: Ne(n.display_name),
430
454
  policy_revision: N(n.policy_revision),
431
455
  device_eligibility_mode: "reviewed_allowlist"
432
456
  },
@@ -434,21 +458,21 @@ function Ie(e) {
434
458
  device_decisions: a,
435
459
  project_mappings: c,
436
460
  project_recipients: u,
437
- completed_at: Me(t.completed_at)
461
+ completed_at: Pe(t.completed_at)
438
462
  };
439
463
  return new TextEncoder().encode(JSON.stringify(p)).byteLength > 15e5 && k(), p;
440
464
  }
441
- function Le(e) {
442
- return JSON.stringify(Ie(e));
465
+ function Be(e) {
466
+ return JSON.stringify(ze(e));
443
467
  }
444
- function Re(e) {
445
- e.team_id !== ye(e.candidate_ref) && k();
468
+ function Ve(e) {
469
+ e.team_id !== xe(e.candidate_ref) && k();
446
470
  }
447
- function ze(e, t) {
448
- he(e.coordinator_id, t) !== e.candidate_ref && k();
471
+ function He(e, t) {
472
+ _e(e.coordinator_id, t) !== e.candidate_ref && k();
449
473
  }
450
- function Be(e, t, n) {
451
- ze(e, t);
474
+ function Ue(e, t, n) {
475
+ He(e, t);
452
476
  let r = new Set(e.project_mappings.map((e) => e.scope_id));
453
477
  n.length !== r.size && k();
454
478
  let i = e.coordinator_id;
@@ -457,57 +481,57 @@ function Be(e, t, n) {
457
481
  }
458
482
  //#endregion
459
483
  //#region src/coordinator-membership-effects.ts
460
- var Ve = "scope_membership_effect_conflict", He = {
484
+ var We = "scope_membership_effect_conflict", Ge = {
461
485
  device_not_enrolled: "device must be enrolled and enabled in the scope group.",
462
486
  scope_group_mismatch: "membership groupId must match the scope groupId.",
463
487
  scope_inactive: "scope is not active.",
464
488
  scope_not_found: "scopeId must reference an existing scope."
465
- }, F = class extends Error {
489
+ }, P = class extends Error {
466
490
  code;
467
491
  constructor(e) {
468
- super(He[e]), this.name = "CoordinatorMembershipError", this.code = e;
492
+ super(Ge[e]), this.name = "CoordinatorMembershipError", this.code = e;
469
493
  }
470
494
  };
471
- function I(e) {
495
+ function F(e) {
472
496
  return e?.trim() || null;
473
497
  }
474
- function Ue(e) {
475
- let t = I(e);
498
+ function Ke(e) {
499
+ let t = F(e);
476
500
  if (!t) throw Error("effectId is required.");
477
501
  if (t.length > 512 || /[\p{Cc}\p{Cf}]/u.test(t)) throw Error("effectId is invalid.");
478
502
  return t;
479
503
  }
480
- function We(e) {
504
+ function qe(e) {
481
505
  return JSON.stringify({
482
- scopeId: I(e.scopeId),
483
- deviceId: I(e.deviceId),
484
- role: I(e.role),
506
+ scopeId: F(e.scopeId),
507
+ deviceId: F(e.deviceId),
508
+ role: F(e.role),
485
509
  membershipEpoch: e.membershipEpoch ?? null,
486
- coordinatorId: I(e.coordinatorId),
487
- groupId: I(e.groupId),
488
- manifestIssuerDeviceId: I(e.manifestIssuerDeviceId),
489
- manifestHash: I(e.manifestHash),
490
- signedManifestJson: I(e.signedManifestJson),
491
- actorType: I(e.actorType),
492
- actorId: I(e.actorId)
510
+ coordinatorId: F(e.coordinatorId),
511
+ groupId: F(e.groupId),
512
+ manifestIssuerDeviceId: F(e.manifestIssuerDeviceId),
513
+ manifestHash: F(e.manifestHash),
514
+ signedManifestJson: F(e.signedManifestJson),
515
+ actorType: F(e.actorType),
516
+ actorId: F(e.actorId)
493
517
  });
494
518
  }
495
- function Ge(e) {
519
+ function Je(e) {
496
520
  return JSON.stringify({
497
- scopeId: I(e.scopeId),
498
- deviceId: I(e.deviceId),
499
- groupId: I(e.groupId),
521
+ scopeId: F(e.scopeId),
522
+ deviceId: F(e.deviceId),
523
+ groupId: F(e.groupId),
500
524
  membershipEpoch: e.membershipEpoch ?? null,
501
- manifestHash: I(e.manifestHash),
502
- signedManifestJson: I(e.signedManifestJson),
503
- actorType: I(e.actorType),
504
- actorId: I(e.actorId)
525
+ manifestHash: F(e.manifestHash),
526
+ signedManifestJson: F(e.signedManifestJson),
527
+ actorType: F(e.actorType),
528
+ actorId: F(e.actorId)
505
529
  });
506
530
  }
507
- function Ke(e, t, n) {
508
- if (e.action !== t || e.request_json !== n) throw Error(Ve);
531
+ function Ye(e, t, n) {
532
+ if (e.action !== t || e.request_json !== n) throw Error(We);
509
533
  }
510
- function qe(e) {
534
+ function Xe(e) {
511
535
  if (e.action !== "grant" || e.outcome_applied !== 1 || e.role == null || e.status == null || e.membership_epoch == null || e.updated_at == null) throw Error("scope_membership_effect_receipt_invalid");
512
536
  return {
513
537
  scope_id: e.scope_id,
@@ -525,254 +549,254 @@ function qe(e) {
525
549
  }
526
550
  //#endregion
527
551
  //#region src/coordinator-store-contract.ts
528
- function Je(e) {
552
+ function Ze(e) {
529
553
  let t = e.trim(), n = new Date(t);
530
554
  if (!t || Number.isNaN(n.getTime())) throw Error("expiresAt must be a valid date.");
531
555
  return n.toISOString();
532
556
  }
533
- var Ye = /^identity:[A-Za-z0-9_-]{18,24}$/u;
534
- function Xe(e) {
535
- return typeof e == "string" && e === e.trim() && Ye.test(e);
557
+ var Qe = /^identity:[A-Za-z0-9_-]{18,24}$/u;
558
+ function $e(e) {
559
+ return typeof e == "string" && e === e.trim() && Qe.test(e);
536
560
  }
537
- function Ze(e) {
561
+ function et(e) {
538
562
  return String(e.kind === "team_member" ? e.assigned_identity_id ?? "" : e.target_identity_id ?? "").trim();
539
563
  }
540
- var Qe = "reciprocal_approval_request_changed", $e = class extends Error {
541
- code = Qe;
564
+ var tt = "reciprocal_approval_request_changed", nt = class extends Error {
565
+ code = tt;
542
566
  constructor() {
543
- super(Qe), this.name = "CoordinatorReciprocalApprovalRequestChangedError";
567
+ super(tt), this.name = "CoordinatorReciprocalApprovalRequestChangedError";
544
568
  }
545
- }, et = 120, tt = /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/iu, nt = /^(?:actor|device|identity|local):\S+$/iu, rt = /^(?:actor|device|identity)[_-][a-z0-9][a-z0-9._:-]{4,}$/iu, it = /^pending[_-]\S+$/iu, at = /^[a-f0-9]{12,64}$/iu, ot = /^(?=.{1,253}$)(?:(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.){2,}[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?|[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.local)$/iu;
546
- function L(e, t) {
569
+ }, rt = 120, it = /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/iu, at = /^(?:actor|device|identity|local):\S+$/iu, ot = /^(?:actor|device|identity)[_-][a-z0-9][a-z0-9._:-]{4,}$/iu, st = /^pending[_-]\S+$/iu, ct = /^[a-f0-9]{12,64}$/iu, lt = /^(?=.{1,253}$)(?:(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.){2,}[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?|[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.local)$/iu;
570
+ function I(e, t) {
547
571
  if ([...e].some((e) => /[\p{Cc}\p{Cf}]/u.test(e))) throw Error(`${t}_invalid`);
548
572
  let n = e.replace(/\s+/gu, " ").trim();
549
573
  if (!n) throw Error(`${t}_required`);
550
- if ([...n].length > et) throw Error(`${t}_too_long`);
574
+ if ([...n].length > rt) throw Error(`${t}_too_long`);
551
575
  return n;
552
576
  }
553
- function R(e) {
577
+ function L(e) {
554
578
  if (typeof e != "string") return !1;
555
579
  let t;
556
580
  try {
557
- t = L(e, "display_name");
581
+ t = I(e, "display_name");
558
582
  } catch {
559
583
  return !1;
560
584
  }
561
585
  return ![
562
- tt,
563
- nt,
564
- rt,
565
586
  it,
566
- at
587
+ at,
588
+ ot,
589
+ st,
590
+ ct
567
591
  ].some((e) => e.test(t));
568
592
  }
569
- function z(e, t) {
570
- let n = L(e, t);
571
- if (!R(n)) throw Error(`${t}_invalid`);
593
+ function R(e, t) {
594
+ let n = I(e, t);
595
+ if (!L(n)) throw Error(`${t}_invalid`);
572
596
  return n;
573
597
  }
574
- function st(e, t) {
575
- let n = L(e, t);
576
- if (!ot.test(n) && !R(n)) throw Error(`${t}_invalid`);
598
+ function ut(e, t) {
599
+ let n = I(e, t);
600
+ if (!lt.test(n) && !L(n)) throw Error(`${t}_invalid`);
577
601
  return n;
578
602
  }
579
- function ct(e) {
603
+ function dt(e) {
580
604
  let t = String(e ?? "").trim(), n = t.replace(/\.local$/iu, "");
581
- return n ? st(ot.test(t) ? n : n.replace(/[-_]+/gu, " "), "device_display_name") : null;
605
+ return n ? ut(lt.test(t) ? n : n.replace(/[-_]+/gu, " "), "device_display_name") : null;
582
606
  }
583
- function lt(e) {
607
+ function ft(e) {
584
608
  for (let t of [
585
609
  e.explicitName,
586
610
  e.osName,
587
611
  e.coordinatorName
588
612
  ]) {
589
613
  let e = String(t ?? "").trim(), n = e.replace(/\.local$/iu, "");
590
- if (ot.test(e)) {
614
+ if (lt.test(e)) {
591
615
  try {
592
- let t = ct(e);
616
+ let t = dt(e);
593
617
  if (t) return t;
594
618
  } catch {}
595
619
  continue;
596
620
  }
597
- if (!(!n || !R(n))) try {
598
- let e = ct(t);
599
- if (e && R(e)) return e;
621
+ if (!(!n || !L(n))) try {
622
+ let e = dt(t);
623
+ if (e && L(e)) return e;
600
624
  } catch {}
601
625
  }
602
626
  let t = String(e.fallbackSeed ?? "").replace(/[^a-z0-9]/giu, "").slice(0, 6);
603
627
  return t ? `Codemem device ${t}` : "Codemem device";
604
628
  }
605
- function ut(e) {
629
+ function pt(e) {
606
630
  if (!Array.isArray(e) || e.length === 0 || e.length > 100) throw Error("project_summaries_invalid");
607
631
  return e.map((e) => {
608
632
  if (!e || typeof e != "object" || Array.isArray(e)) throw Error("project_summaries_invalid");
609
633
  let t = e;
610
634
  if (!Number.isSafeInteger(t.existing_memory_count) || Number(t.existing_memory_count) < 0) throw Error("project_summaries_invalid");
611
635
  return {
612
- display_name: L(String(t.display_name ?? ""), "project_name"),
636
+ display_name: I(String(t.display_name ?? ""), "project_name"),
613
637
  existing_memory_count: Number(t.existing_memory_count)
614
638
  };
615
639
  });
616
640
  }
617
641
  //#endregion
618
642
  //#region src/recipient-reviewed-intent.ts
619
- var dt = 1, B = class extends Error {
643
+ var mt = 1, z = class extends Error {
620
644
  code;
621
645
  constructor(e) {
622
646
  super(e), this.name = "RecipientReviewedIntentError", this.code = e;
623
647
  }
624
- }, ft = /[\p{Cc}\p{Cf}]/u, pt = 100, mt = 65536;
625
- function V() {
626
- throw new B("recipient_reviewed_intent_invalid");
648
+ }, ht = /[\p{Cc}\p{Cf}]/u, gt = 100, _t = 65536;
649
+ function B() {
650
+ throw new z("recipient_reviewed_intent_invalid");
627
651
  }
628
- function H(e) {
629
- return (!e || typeof e != "object" || Array.isArray(e)) && V(), e;
652
+ function V(e) {
653
+ return (!e || typeof e != "object" || Array.isArray(e)) && B(), e;
630
654
  }
631
- function U(e, t) {
632
- Object.keys(e).some((e) => !t.includes(e)) && V();
655
+ function H(e, t) {
656
+ Object.keys(e).some((e) => !t.includes(e)) && B();
633
657
  }
634
- function W(e, t) {
635
- return (typeof e != "string" || !e || e !== e.trim() || e.length > t || ft.test(e)) && V(), e;
658
+ function U(e, t) {
659
+ return (typeof e != "string" || !e || e !== e.trim() || e.length > t || ht.test(e)) && B(), e;
636
660
  }
637
- function ht(e) {
638
- (typeof e != "string" || ft.test(e)) && V();
661
+ function vt(e) {
662
+ (typeof e != "string" || ht.test(e)) && B();
639
663
  let t = e.trim().replace(/\s+/gu, " ");
640
- return (!t || t.length > 256) && V(), t;
664
+ return (!t || t.length > 256) && B(), t;
641
665
  }
642
- function gt(e) {
643
- typeof e != "string" && V();
666
+ function yt(e) {
667
+ typeof e != "string" && B();
644
668
  try {
645
- return L(e, "identity_display_name");
669
+ return I(e, "identity_display_name");
646
670
  } catch {
647
- return V();
671
+ return B();
648
672
  }
649
673
  }
650
- function _t(e) {
651
- return (typeof e != "number" || !Number.isSafeInteger(e) || e < 0) && V(), e;
674
+ function bt(e) {
675
+ return (typeof e != "number" || !Number.isSafeInteger(e) || e < 0) && B(), e;
652
676
  }
653
- function vt(e, t) {
677
+ function xt(e, t) {
654
678
  return e < t ? -1 : +(e > t);
655
679
  }
656
- function yt(e) {
680
+ function St(e) {
657
681
  return e.kind === "direct" ? "direct" : `team\u0000${e.teamId}`;
658
682
  }
659
- function bt(e) {
660
- let t = H(e);
661
- return t.kind === "direct" ? (U(t, ["kind"]), { kind: "direct" }) : (t.kind !== "team" && V(), U(t, [
683
+ function Ct(e) {
684
+ let t = V(e);
685
+ return t.kind === "direct" ? (H(t, ["kind"]), { kind: "direct" }) : (t.kind !== "team" && B(), H(t, [
662
686
  "kind",
663
687
  "teamId",
664
688
  "displayName"
665
689
  ]), {
666
690
  kind: "team",
667
- teamId: W(t.teamId, 256),
668
- displayName: ht(t.displayName)
691
+ teamId: U(t.teamId, 256),
692
+ displayName: vt(t.displayName)
669
693
  });
670
694
  }
671
- function xt(e) {
672
- let t = H(e);
673
- U(t, [
695
+ function wt(e) {
696
+ let t = V(e);
697
+ H(t, [
674
698
  "canonicalProjectIdentity",
675
699
  "displayName",
676
700
  "existingMemoryCount",
677
701
  "futureMemoriesShared",
678
702
  "sources"
679
- ]), (t.futureMemoriesShared !== !0 || !Array.isArray(t.sources) || !t.sources.length) && V();
680
- let n = t.sources.map(bt).toSorted((e, t) => vt(yt(e), yt(t)));
681
- return new Set(n.map(yt)).size !== n.length && V(), {
682
- canonicalProjectIdentity: W(t.canonicalProjectIdentity, 512),
683
- displayName: ht(t.displayName),
684
- existingMemoryCount: _t(t.existingMemoryCount),
703
+ ]), (t.futureMemoriesShared !== !0 || !Array.isArray(t.sources) || !t.sources.length) && B();
704
+ let n = t.sources.map(Ct).toSorted((e, t) => xt(St(e), St(t)));
705
+ return new Set(n.map(St)).size !== n.length && B(), {
706
+ canonicalProjectIdentity: U(t.canonicalProjectIdentity, 512),
707
+ displayName: vt(t.displayName),
708
+ existingMemoryCount: bt(t.existingMemoryCount),
685
709
  futureMemoriesShared: !0,
686
710
  sources: n
687
711
  };
688
712
  }
689
- function St(e) {
690
- let t = H(e);
691
- return U(t, [
713
+ function Tt(e) {
714
+ let t = V(e);
715
+ return H(t, [
692
716
  "canonicalProjectIdentity",
693
717
  "displayName",
694
718
  "existingMemoryCount"
695
719
  ]), {
696
- canonicalProjectIdentity: W(t.canonicalProjectIdentity, 512),
697
- displayName: ht(t.displayName),
698
- existingMemoryCount: _t(t.existingMemoryCount)
720
+ canonicalProjectIdentity: U(t.canonicalProjectIdentity, 512),
721
+ displayName: vt(t.displayName),
722
+ existingMemoryCount: bt(t.existingMemoryCount)
699
723
  };
700
724
  }
701
- function Ct(e) {
702
- (!Array.isArray(e.projects) || !Array.isArray(e.excludedProjects) || e.projects.length > pt) && V();
703
- let t = e.projects.map(xt).toSorted((e, t) => vt(e.canonicalProjectIdentity, t.canonicalProjectIdentity)), n = e.excludedProjects.map(St).toSorted((e, t) => vt(e.canonicalProjectIdentity, t.canonicalProjectIdentity)), r = t.map((e) => e.canonicalProjectIdentity), i = n.map((e) => e.canonicalProjectIdentity);
704
- return (new Set(r).size !== r.length || new Set(i).size !== i.length || i.some((e) => r.includes(e))) && V(), {
725
+ function Et(e) {
726
+ (!Array.isArray(e.projects) || !Array.isArray(e.excludedProjects) || e.projects.length > gt) && B();
727
+ let t = e.projects.map(wt).toSorted((e, t) => xt(e.canonicalProjectIdentity, t.canonicalProjectIdentity)), n = e.excludedProjects.map(Tt).toSorted((e, t) => xt(e.canonicalProjectIdentity, t.canonicalProjectIdentity)), r = t.map((e) => e.canonicalProjectIdentity), i = n.map((e) => e.canonicalProjectIdentity);
728
+ return (new Set(r).size !== r.length || new Set(i).size !== i.length || i.some((e) => r.includes(e))) && B(), {
705
729
  projects: t,
706
730
  excludedProjects: n
707
731
  };
708
732
  }
709
- function wt(e, t) {
710
- if (!(e.journey === "team" && t.kind === "team_member" && e.team.teamId === t.policyTeamId || e.journey === "add_device" && t.kind === "add_device" && e.targetIdentity.identityId === t.targetIdentityId)) throw new B("recipient_invite_intent_mismatch");
733
+ function Dt(e, t) {
734
+ if (!(e.journey === "team" && t.kind === "team_member" && e.team.teamId === t.policyTeamId || e.journey === "add_device" && t.kind === "add_device" && e.targetIdentity.identityId === t.targetIdentityId)) throw new z("recipient_invite_intent_mismatch");
711
735
  }
712
- function Tt(e, t) {
713
- let n = H(e);
714
- n.version !== 1 && V();
715
- let r = Ct(n), i;
736
+ function Ot(e, t) {
737
+ let n = V(e);
738
+ n.version !== 1 && B();
739
+ let r = Et(n), i;
716
740
  if (n.journey === "team") {
717
- U(n, [
741
+ H(n, [
718
742
  "version",
719
743
  "journey",
720
744
  "team",
721
745
  "projects",
722
746
  "excludedProjects"
723
747
  ]);
724
- let e = H(n.team);
725
- U(e, [
748
+ let e = V(n.team);
749
+ H(e, [
726
750
  "teamId",
727
751
  "displayName",
728
752
  "futureProjectsInherit"
729
- ]), e.futureProjectsInherit !== !0 && V(), i = {
753
+ ]), e.futureProjectsInherit !== !0 && B(), i = {
730
754
  version: 1,
731
755
  journey: "team",
732
756
  team: {
733
- teamId: W(e.teamId, 256),
734
- displayName: ht(e.displayName),
757
+ teamId: U(e.teamId, 256),
758
+ displayName: vt(e.displayName),
735
759
  futureProjectsInherit: !0
736
760
  },
737
761
  ...r
738
762
  };
739
763
  } else if (n.journey === "add_device") {
740
- U(n, [
764
+ H(n, [
741
765
  "version",
742
766
  "journey",
743
767
  "targetIdentity",
744
768
  "projects",
745
769
  "excludedProjects"
746
770
  ]);
747
- let e = H(n.targetIdentity);
748
- U(e, ["identityId", "displayName"]), i = {
771
+ let e = V(n.targetIdentity);
772
+ H(e, ["identityId", "displayName"]), i = {
749
773
  version: 1,
750
774
  journey: "add_device",
751
775
  targetIdentity: {
752
- identityId: W(e.identityId, 256),
753
- displayName: gt(e.displayName)
776
+ identityId: U(e.identityId, 256),
777
+ displayName: yt(e.displayName)
754
778
  },
755
779
  ...r
756
780
  };
757
- } else V();
758
- return t && wt(i, t), new TextEncoder().encode(G(i)).byteLength > mt && V(), i;
781
+ } else B();
782
+ return t && Dt(i, t), new TextEncoder().encode(W(i)).byteLength > _t && B(), i;
759
783
  }
760
- function G(e) {
761
- return Array.isArray(e) ? `[${e.map(G).join(",")}]` : e && typeof e == "object" ? `{${Object.entries(e).toSorted(([e], [t]) => vt(e, t)).map(([e, t]) => `${JSON.stringify(e)}:${G(t)}`).join(",")}}` : JSON.stringify(e) ?? "null";
784
+ function W(e) {
785
+ return Array.isArray(e) ? `[${e.map(W).join(",")}]` : e && typeof e == "object" ? `{${Object.entries(e).toSorted(([e], [t]) => xt(e, t)).map(([e, t]) => `${JSON.stringify(e)}:${W(t)}`).join(",")}}` : JSON.stringify(e) ?? "null";
762
786
  }
763
- function Et(e, t) {
764
- return G(Tt(e, t));
787
+ function kt(e, t) {
788
+ return W(Ot(e, t));
765
789
  }
766
- async function Dt(e, t) {
767
- let n = Et(e, t), r = new TextEncoder().encode(`recipient-reviewed-intent-v1\n${n}`), i = await globalThis.crypto.subtle.digest("SHA-256", r);
790
+ async function At(e, t) {
791
+ let n = kt(e, t), r = new TextEncoder().encode(`recipient-reviewed-intent-v1\n${n}`), i = await globalThis.crypto.subtle.digest("SHA-256", r);
768
792
  return Array.from(new Uint8Array(i), (e) => e.toString(16).padStart(2, "0")).join("");
769
793
  }
770
- async function K(e, t) {
771
- let n = Tt(e, t.target);
772
- if (await Dt(n) !== t.digest) throw new B("recipient_invite_intent_mismatch");
794
+ async function G(e, t) {
795
+ let n = Ot(e, t.target);
796
+ if (await At(n) !== t.digest) throw new z("recipient_invite_intent_mismatch");
773
797
  return n;
774
798
  }
775
- async function Ot(e, t) {
799
+ async function jt(e, t) {
776
800
  if (!e) throw Error("recipient_invite_review_unavailable");
777
801
  let n;
778
802
  try {
@@ -781,16 +805,16 @@ async function Ot(e, t) {
781
805
  throw Error("recipient_invite_review_unavailable");
782
806
  }
783
807
  try {
784
- let r = Tt(n, t.target);
785
- if (G(r) !== e) throw Error("recipient_invite_review_unavailable");
786
- return await K(r, t);
808
+ let r = Ot(n, t.target);
809
+ if (W(r) !== e) throw Error("recipient_invite_review_unavailable");
810
+ return await G(r, t);
787
811
  } catch (e) {
788
- throw e instanceof B && e.code === "recipient_invite_intent_mismatch" || e instanceof Error && e.message === "recipient_invite_review_unavailable" ? e : Error("recipient_invite_review_unavailable");
812
+ throw e instanceof z && e.code === "recipient_invite_intent_mismatch" || e instanceof Error && e.message === "recipient_invite_review_unavailable" ? e : Error("recipient_invite_review_unavailable");
789
813
  }
790
814
  }
791
815
  //#endregion
792
816
  //#region src/coordinator-store-input-rules.ts
793
- function kt(e) {
817
+ function Mt(e) {
794
818
  let t = e.trim();
795
819
  if (!t) return "";
796
820
  let n = t.includes("://") ? t : `http://${t}`;
@@ -801,7 +825,7 @@ function kt(e) {
801
825
  return "";
802
826
  }
803
827
  }
804
- function At(e) {
828
+ function Nt(e) {
805
829
  if (!e) return "";
806
830
  try {
807
831
  let t = new URL(e), n = t.hostname.toLowerCase();
@@ -809,15 +833,15 @@ function At(e) {
809
833
  } catch {}
810
834
  return e;
811
835
  }
812
- function jt(e, t) {
836
+ function Pt(e, t) {
813
837
  let n = [], r = /* @__PURE__ */ new Set();
814
838
  for (let i of [...e, ...t]) {
815
- let e = kt(i), t = At(e);
839
+ let e = Mt(i), t = Nt(e);
816
840
  !e || r.has(t) || (r.add(t), n.push(e));
817
841
  }
818
842
  return n;
819
843
  }
820
- function Mt(e) {
844
+ function Ft(e) {
821
845
  if (!e) return null;
822
846
  let t = String(e.seedDeviceId ?? "").trim(), n = String(e.expiresAt ?? "").trim(), r = String(e.createdBy ?? "").trim() || null;
823
847
  if (!t || !n) throw Error("bootstrapGrant.seedDeviceId and expiresAt are required.");
@@ -829,7 +853,7 @@ function Mt(e) {
829
853
  createdBy: r
830
854
  };
831
855
  }
832
- function Nt(e) {
856
+ function It(e) {
833
857
  let t = String(e.groupId ?? "").trim(), n = String(e.seedDeviceId ?? "").trim(), r = String(e.workerDeviceId ?? "").trim(), i = String(e.expiresAt ?? "").trim(), a = String(e.createdBy ?? "").trim() || null;
834
858
  if (!t || !n || !r || !i) throw Error("groupId, seedDeviceId, workerDeviceId, and expiresAt are required.");
835
859
  return {
@@ -840,21 +864,21 @@ function Nt(e) {
840
864
  createdBy: a
841
865
  };
842
866
  }
843
- function q(e) {
867
+ function K(e) {
844
868
  return e?.trim() || null;
845
869
  }
846
- var Pt = /* @__PURE__ */ new Set([
870
+ var Lt = /* @__PURE__ */ new Set([
847
871
  "legacy_enrollment",
848
872
  "project_share",
849
873
  "team_member",
850
874
  "add_device"
851
875
  ]);
852
- function Ft(e) {
853
- if (!Pt.has(e.inviteKind)) throw Error("inviteKind is invalid.");
876
+ function Rt(e) {
877
+ if (!Lt.has(e.inviteKind)) throw Error("inviteKind is invalid.");
854
878
  if ([e.policyTeamId, e.targetIdentityId].filter((e) => !!e).some((e) => e.length > 256 || /[\p{Cc}\p{Cf}]/u.test(e))) throw Error("recipient invite identifier is invalid.");
855
879
  if (e.reviewedPreviewDigest && !/^[a-f0-9]{64}$/u.test(e.reviewedPreviewDigest)) throw Error("reviewedPreviewDigest must be a SHA-256 digest.");
856
880
  }
857
- var It = {
881
+ var zt = {
858
882
  project_share(e, t) {
859
883
  if (!e) throw Error("project_share invite requires operationId.");
860
884
  if (t.policyTeamId || t.targetIdentityId || t.reviewedPreviewDigest) throw Error("recipient invite metadata requires a recipient invite kind.");
@@ -870,10 +894,10 @@ var It = {
870
894
  if (!t.targetIdentityId || !t.reviewedPreviewDigest || t.policyTeamId || e) throw Error("add_device invite metadata is invalid.");
871
895
  }
872
896
  };
873
- function Lt(e, t) {
874
- It[t.inviteKind](q(e.operationId), t);
897
+ function Bt(e, t) {
898
+ zt[t.inviteKind](K(e.operationId), t);
875
899
  }
876
- function Rt(e) {
900
+ function Vt(e) {
877
901
  if (e.inviteKind === "team_member" && e.policyTeamId && e.reviewedPreviewDigest) return {
878
902
  target: {
879
903
  kind: "team_member",
@@ -890,33 +914,33 @@ function Rt(e) {
890
914
  };
891
915
  throw Error("recipient invite metadata requires a recipient invite kind.");
892
916
  }
893
- async function zt(e) {
917
+ async function Ht(e) {
894
918
  let t = {
895
- inviteKind: e.inviteKind ?? (q(e.operationId) ? "project_share" : "legacy_enrollment"),
896
- policyTeamId: q(e.policyTeamId),
897
- targetIdentityId: q(e.targetIdentityId),
898
- reviewedPreviewDigest: q(e.reviewedPreviewDigest)
919
+ inviteKind: e.inviteKind ?? (K(e.operationId) ? "project_share" : "legacy_enrollment"),
920
+ policyTeamId: K(e.policyTeamId),
921
+ targetIdentityId: K(e.targetIdentityId),
922
+ reviewedPreviewDigest: K(e.reviewedPreviewDigest)
899
923
  };
900
- if (Ft(t), Lt(e, t), e.reviewedIntent === void 0 || e.reviewedIntent === null) {
924
+ if (Rt(t), Bt(e, t), e.reviewedIntent === void 0 || e.reviewedIntent === null) {
901
925
  if (t.inviteKind === "team_member" || t.inviteKind === "add_device") throw Error("recipient_invite_review_unavailable");
902
926
  return {
903
927
  ...t,
904
928
  reviewedIntentJson: null
905
929
  };
906
930
  }
907
- let n = Rt(t);
908
- return await K(e.reviewedIntent, {
931
+ let n = Vt(t);
932
+ return await G(e.reviewedIntent, {
909
933
  target: n.target,
910
934
  digest: n.digest
911
935
  }), {
912
936
  ...t,
913
- reviewedIntentJson: Et(e.reviewedIntent, n.target)
937
+ reviewedIntentJson: kt(e.reviewedIntent, n.target)
914
938
  };
915
939
  }
916
- async function Bt(e) {
940
+ async function Ut(e) {
917
941
  if (e.invite_kind === "team_member") {
918
- if (!e.policy_team_id || !Xe(e.assigned_identity_id) || !e.reviewed_preview_digest) throw Error("invite_invalid");
919
- let t = await Ot(e.reviewed_intent_json, {
942
+ if (!e.policy_team_id || !$e(e.assigned_identity_id) || !e.reviewed_preview_digest) throw Error("invite_invalid");
943
+ let t = await jt(e.reviewed_intent_json, {
920
944
  target: {
921
945
  kind: "team_member",
922
946
  policyTeamId: e.policy_team_id
@@ -935,7 +959,7 @@ async function Bt(e) {
935
959
  }
936
960
  if (e.invite_kind === "add_device") {
937
961
  if (!e.target_identity_id || !e.reviewed_preview_digest) throw Error("invite_invalid");
938
- let t = await Ot(e.reviewed_intent_json, {
962
+ let t = await jt(e.reviewed_intent_json, {
939
963
  target: {
940
964
  kind: "add_device",
941
965
  targetIdentityId: e.target_identity_id
@@ -953,94 +977,94 @@ async function Bt(e) {
953
977
  }
954
978
  return null;
955
979
  }
956
- function Vt(e, t = 0) {
980
+ function Wt(e, t = 0) {
957
981
  if (e == null) return t;
958
982
  if (!Number.isFinite(e) || e < 0) throw Error("membershipEpoch must be non-negative.");
959
983
  return Math.trunc(e);
960
984
  }
961
- function Ht(e) {
962
- let t = q(e.scopeId), n = q(e.label);
985
+ function Gt(e) {
986
+ let t = K(e.scopeId), n = K(e.label);
963
987
  if (!t || !n) throw Error("scopeId and label are required.");
964
988
  return {
965
989
  scopeId: t,
966
990
  label: n,
967
- kind: q(e.kind) ?? "user",
968
- authorityType: q(e.authorityType) ?? "coordinator",
969
- coordinatorId: q(e.coordinatorId),
970
- groupId: q(e.groupId),
971
- manifestIssuerDeviceId: q(e.manifestIssuerDeviceId),
972
- membershipEpoch: Vt(e.membershipEpoch),
973
- manifestHash: q(e.manifestHash),
974
- status: q(e.status) ?? "active"
991
+ kind: K(e.kind) ?? "user",
992
+ authorityType: K(e.authorityType) ?? "coordinator",
993
+ coordinatorId: K(e.coordinatorId),
994
+ groupId: K(e.groupId),
995
+ manifestIssuerDeviceId: K(e.manifestIssuerDeviceId),
996
+ membershipEpoch: Wt(e.membershipEpoch),
997
+ manifestHash: K(e.manifestHash),
998
+ status: K(e.status) ?? "active"
975
999
  };
976
1000
  }
977
- function Ut(e, t, n) {
1001
+ function Kt(e, t, n) {
978
1002
  if (e === void 0) return t;
979
- let r = q(e);
1003
+ let r = K(e);
980
1004
  if (!r) throw Error(`${n} must not be empty.`);
981
1005
  return r;
982
1006
  }
983
- function Wt(e, t) {
984
- return e === void 0 ? t : q(e);
1007
+ function qt(e, t) {
1008
+ return e === void 0 ? t : K(e);
985
1009
  }
986
- function Gt(e, t) {
987
- let n = q(e.scopeId);
1010
+ function Jt(e, t) {
1011
+ let n = K(e.scopeId);
988
1012
  if (!n) throw Error("scopeId is required.");
989
- let r = e.membershipEpoch == null ? null : Vt(e.membershipEpoch);
1013
+ let r = e.membershipEpoch == null ? null : Wt(e.membershipEpoch);
990
1014
  if (r != null && r < t.membership_epoch) throw Error("membershipEpoch must not move backwards.");
991
1015
  return {
992
1016
  scopeId: n,
993
- label: Ut(e.label, t.label, "label"),
994
- kind: Ut(e.kind, t.kind, "kind"),
995
- authorityType: Ut(e.authorityType, t.authority_type, "authorityType"),
996
- coordinatorId: Wt(e.coordinatorId, t.coordinator_id),
997
- groupId: Wt(e.groupId, t.group_id),
998
- manifestIssuerDeviceId: Wt(e.manifestIssuerDeviceId, t.manifest_issuer_device_id),
1017
+ label: Kt(e.label, t.label, "label"),
1018
+ kind: Kt(e.kind, t.kind, "kind"),
1019
+ authorityType: Kt(e.authorityType, t.authority_type, "authorityType"),
1020
+ coordinatorId: qt(e.coordinatorId, t.coordinator_id),
1021
+ groupId: qt(e.groupId, t.group_id),
1022
+ manifestIssuerDeviceId: qt(e.manifestIssuerDeviceId, t.manifest_issuer_device_id),
999
1023
  membershipEpoch: r ?? t.membership_epoch,
1000
- manifestHash: Wt(e.manifestHash, t.manifest_hash),
1001
- status: Ut(e.status, t.status, "status")
1024
+ manifestHash: qt(e.manifestHash, t.manifest_hash),
1025
+ status: Kt(e.status, t.status, "status")
1002
1026
  };
1003
1027
  }
1004
- function Kt(e, t, n) {
1005
- let r = q(e.scopeId), i = q(e.deviceId);
1028
+ function Yt(e, t, n) {
1029
+ let r = K(e.scopeId), i = K(e.deviceId);
1006
1030
  if (!r || !i) throw Error("scopeId and deviceId are required.");
1007
- qt(e, t);
1008
- let a = Jt(e, t, n);
1031
+ Xt(e, t);
1032
+ let a = Zt(e, t, n);
1009
1033
  return {
1010
1034
  scopeId: r,
1011
1035
  deviceId: i,
1012
- role: q(e.role) ?? "member",
1036
+ role: K(e.role) ?? "member",
1013
1037
  membershipEpoch: a,
1014
1038
  coordinatorId: t?.coordinator_id ?? null,
1015
1039
  groupId: t?.group_id ?? null,
1016
- manifestIssuerDeviceId: q(e.manifestIssuerDeviceId) ?? t?.manifest_issuer_device_id ?? null,
1017
- manifestHash: q(e.manifestHash) ?? t?.manifest_hash ?? null,
1018
- signedManifestJson: q(e.signedManifestJson),
1019
- actorType: q(e.actorType),
1020
- actorId: q(e.actorId)
1040
+ manifestIssuerDeviceId: K(e.manifestIssuerDeviceId) ?? t?.manifest_issuer_device_id ?? null,
1041
+ manifestHash: K(e.manifestHash) ?? t?.manifest_hash ?? null,
1042
+ signedManifestJson: K(e.signedManifestJson),
1043
+ actorType: K(e.actorType),
1044
+ actorId: K(e.actorId)
1021
1045
  };
1022
1046
  }
1023
- function qt(e, t) {
1024
- if (q(e.coordinatorId) && q(e.coordinatorId) !== t?.coordinator_id) throw Error("membership coordinatorId must match the scope coordinatorId.");
1025
- if (q(e.groupId) && q(e.groupId) !== t?.group_id) throw new F("scope_group_mismatch");
1047
+ function Xt(e, t) {
1048
+ if (K(e.coordinatorId) && K(e.coordinatorId) !== t?.coordinator_id) throw Error("membership coordinatorId must match the scope coordinatorId.");
1049
+ if (K(e.groupId) && K(e.groupId) !== t?.group_id) throw new P("scope_group_mismatch");
1026
1050
  }
1027
- function Jt(e, t, n) {
1028
- let r = e.membershipEpoch == null ? null : Vt(e.membershipEpoch), i = t?.membership_epoch ?? 0;
1051
+ function Zt(e, t, n) {
1052
+ let r = e.membershipEpoch == null ? null : Wt(e.membershipEpoch), i = t?.membership_epoch ?? 0;
1029
1053
  if (r != null && r < i) throw Error("membershipEpoch must not be lower than the scope membershipEpoch.");
1030
1054
  if (r != null && n && r < (n.status === "revoked" ? n.membership_epoch + 1 : n.membership_epoch)) throw Error("membershipEpoch must not move backwards.");
1031
1055
  return r ?? (n ? Math.max(i, n.membership_epoch + +(n.status === "revoked")) : i);
1032
1056
  }
1033
- function Yt(e) {
1057
+ function Qt(e) {
1034
1058
  return e == null || !Number.isFinite(e) ? 100 : Math.max(1, Math.min(1e3, Math.trunc(e)));
1035
1059
  }
1036
1060
  //#endregion
1037
1061
  //#region src/sync-fingerprint.ts
1038
- function Xt(e) {
1062
+ function $t(e) {
1039
1063
  return t("sha256").update(e, "utf-8").digest("hex");
1040
1064
  }
1041
1065
  //#endregion
1042
1066
  //#region ../../node_modules/.pnpm/hono@4.13.5/node_modules/hono/dist/compose.js
1043
- var Zt = (e, t, n) => (r, i) => {
1067
+ var en = (e, t, n) => (r, i) => {
1044
1068
  let a = -1;
1045
1069
  return o(0);
1046
1070
  async function o(s) {
@@ -1056,45 +1080,45 @@ var Zt = (e, t, n) => (r, i) => {
1056
1080
  else r.finalized === !1 && n && (c = await n(r));
1057
1081
  return c && (r.finalized === !1 || l) && (r.res = c), r;
1058
1082
  }
1059
- }, Qt = /* @__PURE__ */ Symbol(), $t = (e, t) => new Response(e, { headers: { "Content-Type": t.replace(/^[^;]+/, (e) => e.toLowerCase()) } }).formData(), en = 32, tn = 1e4, nn = (e) => "headers" in e, rn = async (e, t = /* @__PURE__ */ Object.create(null)) => {
1060
- let { all: n = !1, dot: r = !1 } = t, i = (nn(e) ? e.headers : e.raw.headers).get("Content-Type")?.split(";")[0].trim().toLowerCase();
1061
- return i === "multipart/form-data" || i === "application/x-www-form-urlencoded" ? an(e, {
1083
+ }, tn = /* @__PURE__ */ Symbol(), nn = (e, t) => new Response(e, { headers: { "Content-Type": t.replace(/^[^;]+/, (e) => e.toLowerCase()) } }).formData(), rn = 32, an = 1e4, on = (e) => "headers" in e, sn = async (e, t = /* @__PURE__ */ Object.create(null)) => {
1084
+ let { all: n = !1, dot: r = !1 } = t, i = (on(e) ? e.headers : e.raw.headers).get("Content-Type")?.split(";")[0].trim().toLowerCase();
1085
+ return i === "multipart/form-data" || i === "application/x-www-form-urlencoded" ? cn(e, {
1062
1086
  all: n,
1063
1087
  dot: r
1064
1088
  }) : {};
1065
1089
  };
1066
- async function an(e, t) {
1067
- if (!nn(e) && e.bodyCache.formData) return on(await e.bodyCache.formData, t);
1068
- let n = nn(e) ? e.headers : e.raw.headers, r = $t(await e.arrayBuffer(), n.get("Content-Type") || "");
1069
- nn(e) || (e.bodyCache.formData = r);
1090
+ async function cn(e, t) {
1091
+ if (!on(e) && e.bodyCache.formData) return ln(await e.bodyCache.formData, t);
1092
+ let n = on(e) ? e.headers : e.raw.headers, r = nn(await e.arrayBuffer(), n.get("Content-Type") || "");
1093
+ on(e) || (e.bodyCache.formData = r);
1070
1094
  let i = await r;
1071
- return i ? on(i, t) : {};
1095
+ return i ? ln(i, t) : {};
1072
1096
  }
1073
- function on(e, t) {
1097
+ function ln(e, t) {
1074
1098
  let n = /* @__PURE__ */ Object.create(null), r = { count: 0 };
1075
1099
  return e.forEach((e, r) => {
1076
- t.all || r.endsWith("[]") ? sn(n, r, e) : n[r] = e;
1100
+ t.all || r.endsWith("[]") ? un(n, r, e) : n[r] = e;
1077
1101
  }), t.dot && Object.entries(n).forEach(([e, t]) => {
1078
- e.includes(".") && (cn(n, e, t, r), delete n[e]);
1102
+ e.includes(".") && (dn(n, e, t, r), delete n[e]);
1079
1103
  }), n;
1080
1104
  }
1081
- var sn = (e, t, n) => {
1105
+ var un = (e, t, n) => {
1082
1106
  e[t] === void 0 ? e[t] = t.endsWith("[]") ? [n] : n : Array.isArray(e[t]) ? e[t].push(n) : e[t] = [e[t], n];
1083
- }, cn = (e, t, n, r) => {
1107
+ }, dn = (e, t, n, r) => {
1084
1108
  if (/(?:^|\.)__proto__\./.test(t)) return;
1085
- let i = e, a = t.split(".", en + 2);
1086
- a.length > en + 1 && ln(), a.forEach((e, t) => {
1087
- t === a.length - 1 ? i[e] = n : ((!i[e] || typeof i[e] != "object" || Array.isArray(i[e]) || i[e] instanceof File) && (r.count++ >= tn && ln(), i[e] = /* @__PURE__ */ Object.create(null)), i = i[e]);
1109
+ let i = e, a = t.split(".", rn + 2);
1110
+ a.length > rn + 1 && fn(), a.forEach((e, t) => {
1111
+ t === a.length - 1 ? i[e] = n : ((!i[e] || typeof i[e] != "object" || Array.isArray(i[e]) || i[e] instanceof File) && (r.count++ >= an && fn(), i[e] = /* @__PURE__ */ Object.create(null)), i = i[e]);
1088
1112
  });
1089
- }, ln = () => {
1113
+ }, fn = () => {
1090
1114
  throw Error("Nesting limit exceeded");
1091
- }, un = (e) => {
1115
+ }, pn = (e) => {
1092
1116
  let t = e.split("/");
1093
1117
  return t[0] === "" && t.shift(), t;
1094
- }, dn = (e) => {
1095
- let { groups: t, path: n } = fn(e);
1096
- return pn(un(n), t);
1097
- }, fn = (e) => {
1118
+ }, mn = (e) => {
1119
+ let { groups: t, path: n } = hn(e);
1120
+ return gn(pn(n), t);
1121
+ }, hn = (e) => {
1098
1122
  let t = [];
1099
1123
  return e = e.replace(/\{[^}]+\}/g, (e, n) => {
1100
1124
  let r = `@${n}`;
@@ -1103,7 +1127,7 @@ var sn = (e, t, n) => {
1103
1127
  groups: t,
1104
1128
  path: e
1105
1129
  };
1106
- }, pn = (e, t) => {
1130
+ }, gn = (e, t) => {
1107
1131
  for (let n = t.length - 1; n >= 0; n--) {
1108
1132
  let [r] = t[n];
1109
1133
  for (let i = e.length - 1; i >= 0; i--) if (e[i].includes(r)) {
@@ -1112,12 +1136,12 @@ var sn = (e, t, n) => {
1112
1136
  }
1113
1137
  }
1114
1138
  return e;
1115
- }, mn = {}, hn = (e, t) => {
1139
+ }, _n = {}, vn = (e, t) => {
1116
1140
  if (e === "*") return "*";
1117
1141
  let n = e.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);
1118
1142
  if (n) {
1119
1143
  let r = `${e}#${t}`;
1120
- return mn[r] || (mn[r] = n[2] ? t && t[0] !== ":" && t[0] !== "*" ? [
1144
+ return _n[r] || (_n[r] = n[2] ? t && t[0] !== ":" && t[0] !== "*" ? [
1121
1145
  r,
1122
1146
  n[1],
1123
1147
  RegExp(`^${n[2]}(?=/${t})`)
@@ -1129,10 +1153,10 @@ var sn = (e, t, n) => {
1129
1153
  e,
1130
1154
  n[1],
1131
1155
  !0
1132
- ]), mn[r];
1156
+ ]), _n[r];
1133
1157
  }
1134
1158
  return null;
1135
- }, gn = (e, t) => {
1159
+ }, yn = (e, t) => {
1136
1160
  try {
1137
1161
  return t(e);
1138
1162
  } catch {
@@ -1144,21 +1168,21 @@ var sn = (e, t, n) => {
1144
1168
  }
1145
1169
  });
1146
1170
  }
1147
- }, _n = (e) => gn(e, decodeURI), vn = (e) => {
1171
+ }, bn = (e) => yn(e, decodeURI), xn = (e) => {
1148
1172
  let t = e.url, n = t.indexOf("/", t.indexOf(":") + 4), r = n;
1149
1173
  for (; r < t.length; r++) {
1150
1174
  let e = t.charCodeAt(r);
1151
1175
  if (e === 37) {
1152
1176
  let e = t.indexOf("?", r), i = t.indexOf("#", r), a = e === -1 ? i === -1 ? void 0 : i : i === -1 ? e : Math.min(e, i), o = t.slice(n, a);
1153
- return _n(o.includes("%25") ? o.replace(/%25/g, "%2525") : o);
1177
+ return bn(o.includes("%25") ? o.replace(/%25/g, "%2525") : o);
1154
1178
  }
1155
1179
  if (e === 63 || e === 35) break;
1156
1180
  }
1157
1181
  return t.slice(n, r);
1158
- }, yn = (e) => {
1159
- let t = vn(e);
1182
+ }, Sn = (e) => {
1183
+ let t = xn(e);
1160
1184
  return t.length > 1 && t.at(-1) === "/" ? t.slice(0, -1) : t;
1161
- }, J = (e, t, ...n) => (n.length && (t = J(t, ...n)), `${e?.[0] === "/" ? "" : "/"}${e}${t === "/" ? "" : `${e?.at(-1) === "/" ? "" : "/"}${t?.[0] === "/" ? t.slice(1) : t}`}`), bn = (e) => {
1185
+ }, q = (e, t, ...n) => (n.length && (t = q(t, ...n)), `${e?.[0] === "/" ? "" : "/"}${e}${t === "/" ? "" : `${e?.at(-1) === "/" ? "" : "/"}${t?.[0] === "/" ? t.slice(1) : t}`}`), Cn = (e) => {
1162
1186
  if (e.charCodeAt(e.length - 1) !== 63 || !e.includes(":")) return null;
1163
1187
  let t = e.split("/"), n = [], r = "";
1164
1188
  return t.forEach((e) => {
@@ -1171,7 +1195,7 @@ var sn = (e, t, n) => {
1171
1195
  } else r += "/" + e;
1172
1196
  }
1173
1197
  }), n.filter((e, t, n) => n.indexOf(e) === t);
1174
- }, xn = (e) => e.indexOf("%") === -1 ? e : gn(e, En), Sn = (e) => (e.indexOf("+") !== -1 && (e = e.replace(/\+/g, " ")), xn(e)), Cn = (e, t, n) => {
1198
+ }, wn = (e) => e.indexOf("%") === -1 ? e : yn(e, kn), Tn = (e) => (e.indexOf("+") !== -1 && (e = e.replace(/\+/g, " ")), wn(e)), En = (e, t, n) => {
1175
1199
  let r = e.indexOf("#", 8);
1176
1200
  r !== -1 && (e = e.slice(0, r));
1177
1201
  let i;
@@ -1182,7 +1206,7 @@ var sn = (e, t, n) => {
1182
1206
  let r = e.charCodeAt(n + t.length + 1);
1183
1207
  if (r === 61) {
1184
1208
  let r = n + t.length + 2, i = e.indexOf("&", r);
1185
- return Sn(e.slice(r, i === -1 ? void 0 : i));
1209
+ return Tn(e.slice(r, i === -1 ? void 0 : i));
1186
1210
  }
1187
1211
  if (r == 38 || isNaN(r)) return "";
1188
1212
  n = e.indexOf(`&${t}`, n + 1);
@@ -1196,12 +1220,12 @@ var sn = (e, t, n) => {
1196
1220
  let t = e.indexOf("&", o + 1), r = e.indexOf("=", o);
1197
1221
  r > t && t !== -1 && (r = -1);
1198
1222
  let s = e.slice(o + 1, r === -1 ? t === -1 ? void 0 : t : r);
1199
- if (i && (s = Sn(s)), o = t, s === "") continue;
1223
+ if (i && (s = Tn(s)), o = t, s === "") continue;
1200
1224
  let c;
1201
- r === -1 ? c = "" : (c = e.slice(r + 1, t === -1 ? void 0 : t), i && (c = Sn(c))), n ? (a[s] && Array.isArray(a[s]) || (a[s] = []), a[s].push(c)) : a[s] ??= c;
1225
+ r === -1 ? c = "" : (c = e.slice(r + 1, t === -1 ? void 0 : t), i && (c = Tn(c))), n ? (a[s] && Array.isArray(a[s]) || (a[s] = []), a[s].push(c)) : a[s] ??= c;
1202
1226
  }
1203
1227
  return t ? a[t] : a;
1204
- }, wn = Cn, Tn = (e, t) => Cn(e, t, !0), En = decodeURIComponent, Dn = class {
1228
+ }, Dn = En, On = (e, t) => En(e, t, !0), kn = decodeURIComponent, An = class {
1205
1229
  raw;
1206
1230
  #e;
1207
1231
  #t;
@@ -1216,13 +1240,13 @@ var sn = (e, t, n) => {
1216
1240
  }
1217
1241
  #n(e) {
1218
1242
  let t = this.#t[0][this.routeIndex]?.[1][e], n = this.#i(t);
1219
- return n && xn(n);
1243
+ return n && wn(n);
1220
1244
  }
1221
1245
  #r() {
1222
1246
  let e = {}, t = Object.keys(this.#t[0][this.routeIndex]?.[1] ?? {});
1223
1247
  for (let n of t) {
1224
1248
  let t = this.#i(this.#t[0][this.routeIndex][1][n]);
1225
- t !== void 0 && (e[n] = xn(t));
1249
+ t !== void 0 && (e[n] = wn(t));
1226
1250
  }
1227
1251
  return e;
1228
1252
  }
@@ -1230,10 +1254,10 @@ var sn = (e, t, n) => {
1230
1254
  return this.#t[1] ? this.#t[1][e] : e;
1231
1255
  }
1232
1256
  query(e) {
1233
- return wn(this.url, e);
1257
+ return Dn(this.url, e);
1234
1258
  }
1235
1259
  queries(e) {
1236
- return Tn(this.url, e);
1260
+ return On(this.url, e);
1237
1261
  }
1238
1262
  header(e) {
1239
1263
  if (e) return this.raw.headers.get(e) ?? void 0;
@@ -1243,7 +1267,7 @@ var sn = (e, t, n) => {
1243
1267
  }), t;
1244
1268
  }
1245
1269
  async parseBody(e) {
1246
- return rn(this, e);
1270
+ return sn(this, e);
1247
1271
  }
1248
1272
  #a = (e) => {
1249
1273
  let { bodyCache: t, raw: n } = this, r = t[e];
@@ -1281,7 +1305,7 @@ var sn = (e, t, n) => {
1281
1305
  get method() {
1282
1306
  return this.raw.method;
1283
1307
  }
1284
- get [Qt]() {
1308
+ get [tn]() {
1285
1309
  return this.#t;
1286
1310
  }
1287
1311
  get matchedRoutes() {
@@ -1290,14 +1314,14 @@ var sn = (e, t, n) => {
1290
1314
  get routePath() {
1291
1315
  return this.#t[0].map(([[, e]]) => e)[this.routeIndex].path;
1292
1316
  }
1293
- }, On = {
1317
+ }, jn = {
1294
1318
  Stringify: 1,
1295
1319
  BeforeStream: 2,
1296
1320
  Stream: 3
1297
- }, kn = (e, t) => {
1321
+ }, Mn = (e, t) => {
1298
1322
  let n = new String(e);
1299
1323
  return n.isEscaped = !0, n.callbacks = t, n;
1300
- }, An = async (e, t, n, r, i) => {
1324
+ }, Nn = async (e, t, n, r, i) => {
1301
1325
  typeof e == "object" && !(e instanceof String) && (e instanceof Promise || (e = e.toString()), e instanceof Promise && (e = await e));
1302
1326
  let a = e.callbacks;
1303
1327
  if (!a?.length) return Promise.resolve(e);
@@ -1306,12 +1330,12 @@ var sn = (e, t, n) => {
1306
1330
  phase: t,
1307
1331
  buffer: i,
1308
1332
  context: r
1309
- }))).then((e) => Promise.all(e.filter(Boolean).map((e) => An(e, t, !1, r, i))).then(() => i[0]));
1310
- return n ? kn(await o, a) : o;
1311
- }, jn = "text/plain; charset=UTF-8", Mn = (e, t) => ({
1333
+ }))).then((e) => Promise.all(e.filter(Boolean).map((e) => Nn(e, t, !1, r, i))).then(() => i[0]));
1334
+ return n ? Mn(await o, a) : o;
1335
+ }, Pn = "text/plain; charset=UTF-8", Fn = (e, t) => ({
1312
1336
  "Content-Type": e,
1313
1337
  ...t
1314
- }), Nn = (e, t) => new Response(e, t), Pn = class {
1338
+ }), J = (e, t) => new Response(e, t), In = class {
1315
1339
  #e;
1316
1340
  #t;
1317
1341
  env = {};
@@ -1331,7 +1355,7 @@ var sn = (e, t, n) => {
1331
1355
  this.#e = e, t && (this.#i = t.executionCtx, this.env = t.env, this.#c = t.notFoundHandler, this.#d = t.path, this.#u = t.matchResult);
1332
1356
  }
1333
1357
  get req() {
1334
- return this.#t ??= new Dn(this.#e, this.#d, this.#u), this.#t;
1358
+ return this.#t ??= new An(this.#e, this.#d, this.#u), this.#t;
1335
1359
  }
1336
1360
  get event() {
1337
1361
  if (this.#i && "respondWith" in this.#i) return this.#i;
@@ -1342,11 +1366,11 @@ var sn = (e, t, n) => {
1342
1366
  throw Error("This context has no ExecutionContext");
1343
1367
  }
1344
1368
  get res() {
1345
- return this.#a ||= Nn(null, { headers: this.#l ??= new Headers() });
1369
+ return this.#a ||= J(null, { headers: this.#l ??= new Headers() });
1346
1370
  }
1347
1371
  set res(e) {
1348
1372
  if (this.#a && e) {
1349
- e = Nn(e.body, e);
1373
+ e = J(e.body, e);
1350
1374
  for (let [t, n] of this.#a.headers.entries()) if (t !== "content-type") {
1351
1375
  if (t === "set-cookie") {
1352
1376
  let t = this.#a.headers.getSetCookie();
@@ -1364,7 +1388,7 @@ var sn = (e, t, n) => {
1364
1388
  this.#s = e;
1365
1389
  };
1366
1390
  header = (e, t, n) => {
1367
- this.finalized && (this.#a = Nn(this.#a.body, this.#a));
1391
+ this.finalized && (this.#a = J(this.#a.body, this.#a));
1368
1392
  let r = this.#a ? this.#a.headers : this.#l ??= new Headers();
1369
1393
  t === void 0 ? r.delete(e) : n?.append ? r.append(e, t) : r.set(e, t);
1370
1394
  };
@@ -1401,25 +1425,25 @@ var sn = (e, t, n) => {
1401
1425
  }
1402
1426
  }
1403
1427
  }
1404
- return Nn(e, {
1428
+ return J(e, {
1405
1429
  status: typeof t == "number" ? t : t?.status ?? this.#r,
1406
1430
  headers: r ?? n
1407
1431
  });
1408
1432
  }
1409
1433
  newResponse = (...e) => this.#f(...e);
1410
1434
  body = (e, t, n) => this.#f(e, t, n);
1411
- text = (e, t, n) => !this.#l && !this.#r && !t && !n && !this.finalized ? new Response(e) : this.#f(e, t, Mn(jn, n));
1412
- json = (e, t, n) => this.#f(JSON.stringify(e), t, Mn("application/json", n));
1435
+ text = (e, t, n) => !this.#l && !this.#r && !t && !n && !this.finalized ? new Response(e) : this.#f(e, t, Fn(Pn, n));
1436
+ json = (e, t, n) => this.#f(JSON.stringify(e), t, Fn("application/json", n));
1413
1437
  html = (e, t, n) => {
1414
- let r = (e) => this.#f(e, t, Mn("text/html; charset=UTF-8", n));
1415
- return typeof e == "object" ? An(e, On.Stringify, !1, {}).then(r) : r(e);
1438
+ let r = (e) => this.#f(e, t, Fn("text/html; charset=UTF-8", n));
1439
+ return typeof e == "object" ? Nn(e, jn.Stringify, !1, {}).then(r) : r(e);
1416
1440
  };
1417
1441
  redirect = (e, t) => {
1418
1442
  let n = String(e);
1419
1443
  return this.header("Location", /[^\x00-\xFF]/.test(n) ? encodeURI(n) : n), this.newResponse(null, t ?? 302);
1420
1444
  };
1421
- notFound = () => (this.#c ??= () => Nn(), this.#c(this));
1422
- }, Fn = [
1445
+ notFound = () => (this.#c ??= () => J(), this.#c(this));
1446
+ }, Ln = [
1423
1447
  "get",
1424
1448
  "post",
1425
1449
  "put",
@@ -1427,13 +1451,13 @@ var sn = (e, t, n) => {
1427
1451
  "options",
1428
1452
  "patch",
1429
1453
  "query"
1430
- ], In = "Can not add a route since the matcher is already built.", Ln = class extends Error {}, Rn = "__COMPOSED_HANDLER", zn = (e) => e.text("404 Not Found", 404), Bn = (e, t) => {
1454
+ ], Rn = "Can not add a route since the matcher is already built.", zn = class extends Error {}, Bn = "__COMPOSED_HANDLER", Vn = (e) => e.text("404 Not Found", 404), Hn = (e, t) => {
1431
1455
  if ("getResponse" in e) {
1432
1456
  let n = e.getResponse();
1433
1457
  return t.newResponse(n.body, n);
1434
1458
  }
1435
1459
  return console.error(e), t.text("Internal Server Error", 500);
1436
- }, Vn = class e {
1460
+ }, Un = class e {
1437
1461
  get;
1438
1462
  post;
1439
1463
  put;
@@ -1450,7 +1474,7 @@ var sn = (e, t, n) => {
1450
1474
  #e = "/";
1451
1475
  routes = [];
1452
1476
  constructor(e = {}) {
1453
- [...Fn, "all"].forEach((e) => {
1477
+ [...Ln, "all"].forEach((e) => {
1454
1478
  this[e] = (t, ...n) => (typeof t == "string" ? this.#e = t : this.#r(e, this.#e, t), n.forEach((t) => {
1455
1479
  this.#r(e, this.#e, t);
1456
1480
  }), this);
@@ -1466,7 +1490,7 @@ var sn = (e, t, n) => {
1466
1490
  this.#r("ALL", this.#e, e);
1467
1491
  }), this);
1468
1492
  let { strict: t, ...n } = e;
1469
- Object.assign(this, n), this.getPath = t ?? !0 ? e.getPath ?? vn : yn;
1493
+ Object.assign(this, n), this.getPath = t ?? !0 ? e.getPath ?? xn : Sn;
1470
1494
  }
1471
1495
  #t() {
1472
1496
  let t = new e({
@@ -1475,18 +1499,18 @@ var sn = (e, t, n) => {
1475
1499
  });
1476
1500
  return t.errorHandler = this.errorHandler, t.#n = this.#n, t.routes = this.routes, t;
1477
1501
  }
1478
- #n = zn;
1479
- errorHandler = Bn;
1502
+ #n = Vn;
1503
+ errorHandler = Hn;
1480
1504
  route(e, t) {
1481
1505
  let n = this.basePath(e);
1482
1506
  return t.routes.map((e) => {
1483
1507
  let r;
1484
- t.errorHandler === Bn ? r = e.handler : (r = async (n, r) => (await Zt([], t.errorHandler)(n, () => e.handler(n, r))).res, r[Rn] = e.handler), n.#r(e.method, e.path, r, e.basePath);
1508
+ t.errorHandler === Hn ? r = e.handler : (r = async (n, r) => (await en([], t.errorHandler)(n, () => e.handler(n, r))).res, r[Bn] = e.handler), n.#r(e.method, e.path, r, e.basePath);
1485
1509
  }), this;
1486
1510
  }
1487
1511
  basePath(e) {
1488
1512
  let t = this.#t();
1489
- return t._basePath = J(this._basePath, e), t;
1513
+ return t._basePath = q(this._basePath, e), t;
1490
1514
  }
1491
1515
  onError = (e) => (this.errorHandler = e, this);
1492
1516
  notFound = (e) => (this.#n = e, this);
@@ -1504,21 +1528,21 @@ var sn = (e, t, n) => {
1504
1528
  return [e.env, t];
1505
1529
  };
1506
1530
  return r ||= (() => {
1507
- let t = J(this._basePath, e), n = t === "/" ? 0 : t.length;
1531
+ let t = q(this._basePath, e), n = t === "/" ? 0 : t.length;
1508
1532
  return (e) => {
1509
1533
  let t = new URL(e.url);
1510
1534
  return t.pathname = this.getPath(e).slice(n) || "/", new Request(t, e);
1511
1535
  };
1512
- })(), this.#r("ALL", J(e, "*"), async (e, n) => {
1536
+ })(), this.#r("ALL", q(e, "*"), async (e, n) => {
1513
1537
  let i = await t(r(e.req.raw), ...a(e));
1514
1538
  if (i) return i;
1515
1539
  await n();
1516
1540
  }), this;
1517
1541
  }
1518
1542
  #r(e, t, n, r) {
1519
- e = e.toUpperCase(), t = J(this._basePath, t);
1543
+ e = e.toUpperCase(), t = q(this._basePath, t);
1520
1544
  let i = {
1521
- basePath: r === void 0 ? this._basePath : J(this._basePath, r),
1545
+ basePath: r === void 0 ? this._basePath : q(this._basePath, r),
1522
1546
  path: t,
1523
1547
  method: e,
1524
1548
  handler: n
@@ -1531,7 +1555,7 @@ var sn = (e, t, n) => {
1531
1555
  }
1532
1556
  #a(e, t, n, r) {
1533
1557
  if (r === "HEAD") return (async () => new Response(null, await this.#a(e, t, n, "GET")))();
1534
- let i = this.getPath(e, { env: n }), a = this.router.match(r, i), o = new Pn(e, {
1558
+ let i = this.getPath(e, { env: n }), a = this.router.match(r, i), o = new In(e, {
1535
1559
  path: i,
1536
1560
  matchResult: a,
1537
1561
  env: n,
@@ -1549,7 +1573,7 @@ var sn = (e, t, n) => {
1549
1573
  }
1550
1574
  return e instanceof Promise ? e.then((e) => e || (o.finalized ? o.res : this.#n(o))).catch((e) => this.#i(e, o)) : e ?? this.#n(o);
1551
1575
  }
1552
- let s = Zt(a[0], this.errorHandler, this.#n);
1576
+ let s = en(a[0], this.errorHandler, this.#n);
1553
1577
  return (async () => {
1554
1578
  try {
1555
1579
  let e = await s(o);
@@ -1561,19 +1585,19 @@ var sn = (e, t, n) => {
1561
1585
  })();
1562
1586
  }
1563
1587
  fetch = (e, ...t) => this.#a(e, t[1], t[0], e.method);
1564
- request = (e, t, n, r) => e instanceof Request ? this.fetch(t ? new Request(e, t) : e, n, r) : (e = e.toString(), this.fetch(new Request(/^https?:\/\//.test(e) ? e : `http://localhost${J("/", e)}`, t), n, r));
1588
+ request = (e, t, n, r) => e instanceof Request ? this.fetch(t ? new Request(e, t) : e, n, r) : (e = e.toString(), this.fetch(new Request(/^https?:\/\//.test(e) ? e : `http://localhost${q("/", e)}`, t), n, r));
1565
1589
  fire = () => {
1566
1590
  addEventListener("fetch", (e) => {
1567
1591
  e.respondWith(this.#a(e.request, e, void 0, e.request.method));
1568
1592
  });
1569
1593
  };
1570
- }, Y = () => /* @__PURE__ */ Object.create(null), Hn = [];
1571
- function Un(e, t) {
1594
+ }, Y = () => /* @__PURE__ */ Object.create(null), Wn = [];
1595
+ function Gn(e, t) {
1572
1596
  let n = this.buildAllMatchers(), r = ((e, t) => {
1573
1597
  let r = n[e] || n.ALL, i = r[2][t];
1574
1598
  if (i) return i;
1575
1599
  let a = t.match(r[0]);
1576
- if (!a) return [[], Hn];
1600
+ if (!a) return [[], Wn];
1577
1601
  let o = a.indexOf("", 1);
1578
1602
  return [r[1][o], a];
1579
1603
  });
@@ -1581,11 +1605,11 @@ function Un(e, t) {
1581
1605
  }
1582
1606
  //#endregion
1583
1607
  //#region ../../node_modules/.pnpm/hono@4.13.5/node_modules/hono/dist/router/reg-exp-router/node.js
1584
- var Wn = "[^/]+", Gn = "(?:|/.*)", Kn = /* @__PURE__ */ Symbol(), qn = /* @__PURE__ */ new Set(".\\+*[^]$()");
1585
- function Jn(e, t) {
1608
+ var Kn = "[^/]+", qn = "(?:|/.*)", Jn = /* @__PURE__ */ Symbol(), Yn = /* @__PURE__ */ new Set(".\\+*[^]$()");
1609
+ function Xn(e, t) {
1586
1610
  return e.length === 1 ? t.length === 1 ? e < t ? -1 : 1 : -1 : t.length === 1 ? 1 : e === ".*" || e === "(?:|/.*)" ? t === "(?:|/.*)" ? -1 : 1 : t === ".*" || t === "(?:|/.*)" ? -1 : e === "[^/]+" ? 1 : t === "[^/]+" ? -1 : e.length === t.length ? e < t ? -1 : 1 : t.length - e.length;
1587
1611
  }
1588
- var Yn = class e {
1612
+ var Zn = class e {
1589
1613
  #e;
1590
1614
  #t;
1591
1615
  #n = Y();
@@ -1599,41 +1623,41 @@ var Yn = class e {
1599
1623
  ] : [
1600
1624
  "",
1601
1625
  "",
1602
- Wn
1626
+ Kn
1603
1627
  ] : null : s === "/*" ? [
1604
1628
  "",
1605
1629
  "",
1606
- Gn
1630
+ qn
1607
1631
  ] : s.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/), l;
1608
1632
  if (c) {
1609
1633
  let t = c[1], n = c[2] || "[^/]+";
1610
- if (t && c[2] && (n === ".*" || (n = n.replace(/^\((?!\?:)(?=[^)]+\)$)/, "(?:"), /\((?!\?:)/.test(n)) || n.length === 1 && qn.has(n))) throw Kn;
1634
+ if (t && c[2] && (n === ".*" || (n = n.replace(/^\((?!\?:)(?=[^)]+\)$)/, "(?:"), /\((?!\?:)/.test(n)) || n.length === 1 && Yn.has(n))) throw Jn;
1611
1635
  if (l = o.#n[n], !l) {
1612
1636
  if (n !== ".*" && n !== "(?:|/.*)") {
1613
- for (let e in o.#n) if ((n.length > 1 || e.length > 1) && e !== ".*" && e !== "(?:|/.*)") throw Kn;
1637
+ for (let e in o.#n) if ((n.length > 1 || e.length > 1) && e !== ".*" && e !== "(?:|/.*)") throw Jn;
1614
1638
  }
1615
1639
  l = o.#n[n] = new e();
1616
1640
  }
1617
1641
  t !== "" && (l.#t ??= i.varIndex++, r.push([t, l.#t]));
1618
1642
  } else if (l = o.#n[s], !l) {
1619
- for (let e in o.#n) if (e.length > 1 && e !== ".*" && e !== "(?:|/.*)") throw Kn;
1643
+ for (let e in o.#n) if (e.length > 1 && e !== ".*" && e !== "(?:|/.*)") throw Jn;
1620
1644
  l = o.#n[s] = new e();
1621
1645
  }
1622
1646
  o = l;
1623
1647
  }
1624
- if (o.#e !== void 0) throw Kn;
1648
+ if (o.#e !== void 0) throw Jn;
1625
1649
  o.#e = a ? -1 : n;
1626
1650
  }
1627
1651
  buildRegExpStr() {
1628
- let e = Object.keys(this.#n).sort(Jn).map((e) => {
1652
+ let e = Object.keys(this.#n).sort(Xn).map((e) => {
1629
1653
  let t = this.#n[e], n = t.buildRegExpStr();
1630
- return n === "" ? "" : (typeof t.#t == "number" ? `(${e})@${t.#t}` : qn.has(e) ? `\\${e}` : e) + n;
1654
+ return n === "" ? "" : (typeof t.#t == "number" ? `(${e})@${t.#t}` : Yn.has(e) ? `\\${e}` : e) + n;
1631
1655
  }).filter(Boolean);
1632
1656
  return typeof this.#e == "number" && this.#e !== -1 && e.unshift(`#${this.#e}`), e.length === 0 ? "" : e.length === 1 ? e[0] : "(?:" + e.join("|") + ")";
1633
1657
  }
1634
- }, Xn = class {
1658
+ }, Qn = class {
1635
1659
  #e = { varIndex: 0 };
1636
- #t = new Yn();
1660
+ #t = new Zn();
1637
1661
  #n = 0;
1638
1662
  paths = Y();
1639
1663
  insert(e, t) {
@@ -1673,33 +1697,33 @@ var Yn = class e {
1673
1697
  r
1674
1698
  ];
1675
1699
  }
1676
- }, Zn = Y();
1677
- function Qn(e) {
1678
- return Zn[e] ??= RegExp(`^${e.replace(/\/:[^/{}]+(?:\{\[\^\/]\+})?(?=[/{]|$)|\/?\*$|([.\\+*[^\]$()?{}|])/g, (e, t) => t ? `\\${t}` : e === "/*" ? Gn : e === "*" ? ".*" : `/:${Wn}`)}$`);
1700
+ }, $n = Y();
1701
+ function er(e) {
1702
+ return $n[e] ??= RegExp(`^${e.replace(/\/:[^/{}]+(?:\{\[\^\/]\+})?(?=[/{]|$)|\/?\*$|([.\\+*[^\]$()?{}|])/g, (e, t) => t ? `\\${t}` : e === "/*" ? qn : e === "*" ? ".*" : `/:${Kn}`)}$`);
1679
1703
  }
1680
- function $n(e, t) {
1681
- for (let n of Object.keys(e).sort((e, t) => t.length - e.length)) if (Qn(n).test(t)) return [...e[n]];
1704
+ function tr(e, t) {
1705
+ for (let n of Object.keys(e).sort((e, t) => t.length - e.length)) if (er(n).test(t)) return [...e[n]];
1682
1706
  }
1683
- var er = class {
1707
+ var nr = class {
1684
1708
  name = "RegExpRouter";
1685
1709
  #e;
1686
1710
  #t;
1687
1711
  #n;
1688
1712
  constructor() {
1689
- this.#e = { ALL: Y() }, this.#t = { ALL: Y() }, this.#n = { ALL: new Xn() };
1713
+ this.#e = { ALL: Y() }, this.#t = { ALL: Y() }, this.#n = { ALL: new Qn() };
1690
1714
  }
1691
1715
  #r(e, t) {
1692
1716
  try {
1693
1717
  this.#n[e].insert(t, !/\*|\/:/.test(t));
1694
1718
  } catch (e) {
1695
- throw e === Kn ? new Ln(t) : e;
1719
+ throw e === Jn ? new zn(t) : e;
1696
1720
  }
1697
1721
  }
1698
1722
  add(e, t, n) {
1699
1723
  let r = this.#e, i = this.#t;
1700
- if (!r) throw Error(In);
1724
+ if (!r) throw Error(Rn);
1701
1725
  if (!r[e]) {
1702
- this.#n[e] = new Xn();
1726
+ this.#n[e] = new Qn();
1703
1727
  for (let t of [r, i]) {
1704
1728
  t[e] = Y();
1705
1729
  for (let n in t.ALL) t[e][n] = [...t.ALL[n]], this.#r(e, n);
@@ -1708,26 +1732,26 @@ var er = class {
1708
1732
  t === "/*" && (t = "*");
1709
1733
  let a = e === "ALL" ? Object.keys(r) : [e];
1710
1734
  if (/\*$/.test(t)) {
1711
- let e = Qn(t);
1712
- for (let e of a) r[e][t] || (this.#r(e, t), r[e][t] = $n(r[e], t) || $n(r.ALL, t) || []);
1735
+ let e = er(t);
1736
+ for (let e of a) r[e][t] || (this.#r(e, t), r[e][t] = tr(r[e], t) || tr(r.ALL, t) || []);
1713
1737
  for (let o of [r, i]) for (let r of a) for (let i in o[r]) e.test(i) && o[r][i].push([n, t]);
1714
1738
  return;
1715
1739
  }
1716
- let o = bn(t) || [t];
1717
- for (let e of o) for (let t of a) i[t][e] || (this.#r(t, e), i[t][e] = $n(r[t], e) || $n(r.ALL, e) || []), i[t][e].push([n, e]);
1740
+ let o = Cn(t) || [t];
1741
+ for (let e of o) for (let t of a) i[t][e] || (this.#r(t, e), i[t][e] = tr(r[t], e) || tr(r.ALL, e) || []), i[t][e].push([n, e]);
1718
1742
  }
1719
- match = Un;
1743
+ match = Gn;
1720
1744
  buildAllMatchers() {
1721
1745
  let e = Y();
1722
1746
  for (let t of Object.keys(this.#t)) e[t] = this.#i(t);
1723
- return this.#e = this.#t = this.#n = void 0, Zn = Y(), e;
1747
+ return this.#e = this.#t = this.#n = void 0, $n = Y(), e;
1724
1748
  }
1725
1749
  #i(e) {
1726
1750
  let t = this.#e[e], n = this.#t[e], r = this.#n[e], i = Y(), a = [], [o, s, c] = r.buildRegExp();
1727
1751
  for (let e of [t, n]) for (let t in e) {
1728
1752
  let n = e[t], o = r.paths[t];
1729
1753
  if (!o) {
1730
- i[t] = [n.map(([e]) => [e, Y()]), Hn];
1754
+ i[t] = [n.map(([e]) => [e, Y()]), Wn];
1731
1755
  continue;
1732
1756
  }
1733
1757
  a[o[0]] = n.map(([e, t]) => [e, r.paths[t][1].reduceRight((e, [t], n) => (e[t] = c[o[1][n][1]], e), Y())]);
@@ -1738,7 +1762,7 @@ var er = class {
1738
1762
  i
1739
1763
  ];
1740
1764
  }
1741
- }, tr = class {
1765
+ }, rr = class {
1742
1766
  name = "SmartRouter";
1743
1767
  #e = [];
1744
1768
  #t = [];
@@ -1746,7 +1770,7 @@ var er = class {
1746
1770
  this.#e = e.routers;
1747
1771
  }
1748
1772
  add(e, t, n) {
1749
- if (!this.#t) throw Error(In);
1773
+ if (!this.#t) throw Error(Rn);
1750
1774
  this.#t.push([
1751
1775
  e,
1752
1776
  t,
@@ -1762,7 +1786,7 @@ var er = class {
1762
1786
  for (let e = 0, t = r.length; e < t; e++) i.add(...r[e]);
1763
1787
  o = i.match(e, t);
1764
1788
  } catch (e) {
1765
- if (e instanceof Ln) continue;
1789
+ if (e instanceof zn) continue;
1766
1790
  throw e;
1767
1791
  }
1768
1792
  this.match = i.match.bind(i), this.#e = [i], this.#t = void 0;
@@ -1775,22 +1799,22 @@ var er = class {
1775
1799
  if (this.#t || this.#e.length !== 1) throw Error("No active router has been determined yet.");
1776
1800
  return this.#e[0];
1777
1801
  }
1778
- }, nr = Y(), rr = 0, ir = class e {
1802
+ }, ir = Y(), ar = 0, or = class e {
1779
1803
  #e = [];
1780
1804
  #t = Y();
1781
1805
  #n = [];
1782
1806
  #r;
1783
- #i = nr;
1807
+ #i = ir;
1784
1808
  insert(t, n, r) {
1785
- let i = this, a = dn(n), o = /* @__PURE__ */ new Set(), s = 0;
1809
+ let i = this, a = mn(n), o = /* @__PURE__ */ new Set(), s = 0;
1786
1810
  for (let t of a) {
1787
- let n = a[++s], r = hn(t, n) || (n === void 0 && t && t.indexOf("*") === t.length - 1 ? t : null), c = Array.isArray(r), l = c ? r[0] : r || t, u = i.#t[l] ||= new e();
1811
+ let n = a[++s], r = vn(t, n) || (n === void 0 && t && t.indexOf("*") === t.length - 1 ? t : null), c = Array.isArray(r), l = c ? r[0] : r || t, u = i.#t[l] ||= new e();
1788
1812
  r && !u.#r && (u.#r = r, i.#n.push(u)), i = u, c && o.add(r[1]);
1789
1813
  }
1790
1814
  i.#e.push({ [t]: {
1791
1815
  handler: r,
1792
1816
  possibleKeys: [...o],
1793
- score: ++rr
1817
+ score: ++ar
1794
1818
  } });
1795
1819
  }
1796
1820
  #a(e, t, n, r, i) {
@@ -1807,15 +1831,15 @@ var er = class {
1807
1831
  }
1808
1832
  search(e, t) {
1809
1833
  let n = [];
1810
- this.#i = nr;
1811
- let r = [this], i = un(t), a = [], o = i.length, s = null;
1834
+ this.#i = ir;
1835
+ let r = [this], i = pn(t), a = [], o = i.length, s = null;
1812
1836
  for (let c = 0; c < o; c++) {
1813
1837
  let l = i[c], u = c === o - 1, d = [];
1814
1838
  for (let f = 0, p = r.length; f < p; f++) {
1815
1839
  let p = r[f], m = p.#t[l];
1816
1840
  m && (m.#i = p.#i, u ? (m.#t["*"] && this.#a(n, m.#t["*"], e, p.#i), this.#a(n, m, e, p.#i)) : d.push(m));
1817
1841
  for (let r of p.#n) {
1818
- let f = r.#r, m = p.#i === nr ? {} : { ...p.#i };
1842
+ let f = r.#r, m = p.#i === ir ? {} : { ...p.#i };
1819
1843
  if (typeof f == "string") {
1820
1844
  (f === "*" || l.startsWith(f.slice(0, -1))) && (this.#a(n, r, e, p.#i), f === "*" && (r.#i = m, d.push(r)));
1821
1845
  continue;
@@ -1849,52 +1873,52 @@ var er = class {
1849
1873
  }
1850
1874
  return n[1] && n.sort((e, t) => e.score - t.score), [n.map(({ handler: e, params: t }) => [e, t])];
1851
1875
  }
1852
- }, ar = class {
1876
+ }, sr = class {
1853
1877
  name = "TrieRouter";
1854
- #e = new ir();
1878
+ #e = new or();
1855
1879
  add(e, t, n) {
1856
- for (let r of bn(t) || [t]) this.#e.insert(e, r, n);
1880
+ for (let r of Cn(t) || [t]) this.#e.insert(e, r, n);
1857
1881
  }
1858
1882
  match(e, t) {
1859
1883
  return this.#e.search(e, t);
1860
1884
  }
1861
- }, or = class extends Vn {
1885
+ }, cr = class extends Un {
1862
1886
  constructor(e = {}) {
1863
- super(e), this.router = e.router ?? new tr({ routers: [new er(), new ar()] });
1887
+ super(e), this.router = e.router ?? new rr({ routers: [new nr(), new sr()] });
1864
1888
  }
1865
1889
  };
1866
1890
  //#endregion
1867
1891
  //#region src/coordinator-invites.ts
1868
- function sr(e) {
1892
+ function lr(e) {
1869
1893
  let t = "";
1870
1894
  for (let n of e) t += String.fromCharCode(n);
1871
1895
  return btoa(t);
1872
1896
  }
1873
- function cr(e) {
1897
+ function ur(e) {
1874
1898
  let t = atob(e), n = new Uint8Array(t.length);
1875
1899
  for (let e = 0; e < t.length; e += 1) n[e] = t.charCodeAt(e);
1876
1900
  return n;
1877
1901
  }
1878
- function lr(e) {
1902
+ function dr(e) {
1879
1903
  return e.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
1880
1904
  }
1881
- function ur(e) {
1905
+ function fr(e) {
1882
1906
  let t = e.replace(/-/g, "+").replace(/_/g, "/");
1883
1907
  return t + "=".repeat((4 - t.length % 4) % 4);
1884
1908
  }
1885
- function dr(e) {
1909
+ function pr(e) {
1886
1910
  let t = JSON.stringify(e);
1887
- return lr(sr(new TextEncoder().encode(t)));
1911
+ return dr(lr(new TextEncoder().encode(t)));
1888
1912
  }
1889
- function fr(e) {
1890
- let t = new TextDecoder().decode(cr(ur(e))), n = JSON.parse(t);
1913
+ function mr(e) {
1914
+ let t = new TextDecoder().decode(ur(fr(e))), n = JSON.parse(t);
1891
1915
  if (typeof n != "object" || !n) throw Error("invalid invite payload");
1892
1916
  return n;
1893
1917
  }
1894
- function pr(e) {
1918
+ function hr(e) {
1895
1919
  return `codemem://join?invite=${encodeURIComponent(e)}`;
1896
1920
  }
1897
- function mr(e) {
1921
+ function gr(e) {
1898
1922
  let t = e.trim();
1899
1923
  if (t.startsWith("codemem://")) {
1900
1924
  let e = new URL(t).searchParams.get("invite") ?? "";
@@ -1905,41 +1929,41 @@ function mr(e) {
1905
1929
  }
1906
1930
  //#endregion
1907
1931
  //#region src/project-invite-acceptance.ts
1908
- var hr = "pending_setup", gr = "project_sync_enablement_failed", _r = "Invitation was accepted, but sync could not be enabled. Make the codemem config writable, then retry.", vr = class extends Error {
1909
- code = gr;
1910
- detail = _r;
1932
+ var _r = "pending_setup", vr = "project_sync_enablement_failed", yr = "Invitation was accepted, but sync could not be enabled. Make the codemem config writable, then retry.", br = class extends Error {
1933
+ code = vr;
1934
+ detail = yr;
1911
1935
  constructor(e) {
1912
- super(_r, e), this.name = "ProjectSyncEnablementError";
1936
+ super(yr, e), this.name = "ProjectSyncEnablementError";
1913
1937
  }
1914
1938
  };
1915
- function yr(e) {
1939
+ function xr(e) {
1916
1940
  return typeof e == "object" && !!e && "code" in e && e.code === "project_sync_enablement_failed" && "detail" in e && e.detail === "Invitation was accepted, but sync could not be enabled. Make the codemem config writable, then retry.";
1917
1941
  }
1918
1942
  //#endregion
1919
1943
  //#region src/project-share-intent.ts
1920
- var br = "existing_and_future";
1921
- function xr(e) {
1944
+ var Sr = "existing_and_future";
1945
+ function Cr(e) {
1922
1946
  return t("sha256").update(JSON.stringify(e)).digest("hex");
1923
1947
  }
1924
- function Sr(e) {
1925
- return xr({
1948
+ function wr(e) {
1949
+ return Cr({
1926
1950
  v: 1,
1927
- historyPolicy: br,
1951
+ historyPolicy: Sr,
1928
1952
  projects: e.map((e) => ({
1929
1953
  canonicalIdentity: e.canonicalIdentity,
1930
1954
  existingMemoryCount: e.existingMemoryCount
1931
1955
  })).toSorted((e, t) => e.canonicalIdentity.localeCompare(t.canonicalIdentity))
1932
1956
  });
1933
1957
  }
1934
- function Cr(e) {
1935
- return Sr(e.map((e) => ({
1958
+ function Tr(e) {
1959
+ return wr(e.map((e) => ({
1936
1960
  canonicalIdentity: e.canonical_identity,
1937
1961
  displayName: e.display_name,
1938
1962
  identitySource: "coordinator_acceptance",
1939
1963
  existingMemoryCount: e.existing_memory_count
1940
1964
  })));
1941
1965
  }
1942
- function wr(e) {
1966
+ function Er(e) {
1943
1967
  if (!Array.isArray(e) || e.length === 0 || e.length > 100) throw Error("operation_intent_invalid");
1944
1968
  let t = e.map((e) => {
1945
1969
  if (!e || typeof e != "object" || Array.isArray(e)) throw Error("operation_intent_invalid");
@@ -1947,7 +1971,7 @@ function wr(e) {
1947
1971
  if (typeof t.canonical_identity != "string" || typeof t.display_name != "string") throw Error("operation_intent_invalid");
1948
1972
  let n = t.canonical_identity, r = n.trim(), i = t.display_name, a;
1949
1973
  try {
1950
- a = L(i, "project_name");
1974
+ a = I(i, "project_name");
1951
1975
  } catch {
1952
1976
  throw Error("operation_intent_invalid");
1953
1977
  }
@@ -1964,20 +1988,20 @@ function wr(e) {
1964
1988
  }
1965
1989
  //#endregion
1966
1990
  //#region ../../node_modules/.pnpm/limiter@3.0.0/node_modules/limiter/dist/esm/clock.js
1967
- function Tr(e) {
1991
+ function Dr(e) {
1968
1992
  let t = performance.now() * .001, n = Math.floor(t), r = Math.floor(t % 1 * 1e9);
1969
1993
  return e != null && (n -= e[0], r -= e[1], r < 0 && (n--, r += 1e9)), [n, r];
1970
1994
  }
1971
- function Er() {
1972
- let [e, t] = Tr();
1995
+ function Or() {
1996
+ let [e, t] = Dr();
1973
1997
  return e * 1e3 + Math.floor(t / 1e6);
1974
1998
  }
1975
- function Dr(e) {
1999
+ function kr(e) {
1976
2000
  return new Promise((t) => setTimeout(t, e));
1977
2001
  }
1978
2002
  //#endregion
1979
2003
  //#region ../../node_modules/.pnpm/limiter@3.0.0/node_modules/limiter/dist/esm/TokenBucket.js
1980
- var Or = class {
2004
+ var Ar = class {
1981
2005
  bucketSize;
1982
2006
  tokensPerInterval;
1983
2007
  interval;
@@ -2004,13 +2028,13 @@ var Or = class {
2004
2028
  default: throw Error("Invalid interval " + n);
2005
2029
  }
2006
2030
  else this.interval = n;
2007
- this.parentBucket = r, this.content = 0, this.lastDrip = Er();
2031
+ this.parentBucket = r, this.content = 0, this.lastDrip = Or();
2008
2032
  }
2009
2033
  async removeTokens(e) {
2010
2034
  if (this.bucketSize === 0) return Infinity;
2011
2035
  if (e > this.bucketSize) throw Error(`Requested tokens ${e} exceeds bucket size ${this.bucketSize}`);
2012
2036
  this.drip();
2013
- let t = async () => (await Dr(Math.ceil((e - this.content) * (this.interval / this.tokensPerInterval))), this.removeTokens(e));
2037
+ let t = async () => (await kr(Math.ceil((e - this.content) * (this.interval / this.tokensPerInterval))), this.removeTokens(e));
2014
2038
  if (e > this.content) return t();
2015
2039
  if (this.parentBucket != null) {
2016
2040
  let n = await this.parentBucket.removeTokens(e);
@@ -2026,30 +2050,30 @@ var Or = class {
2026
2050
  let e = this.content;
2027
2051
  return this.content = this.bucketSize, this.content > e;
2028
2052
  }
2029
- let e = Er(), t = Math.max(e - this.lastDrip, 0);
2053
+ let e = Or(), t = Math.max(e - this.lastDrip, 0);
2030
2054
  this.lastDrip = e;
2031
2055
  let n = t * (this.tokensPerInterval / this.interval), r = this.content;
2032
2056
  return this.content = Math.min(this.content + n, this.bucketSize), Math.floor(this.content) > Math.floor(r);
2033
2057
  }
2034
- }, kr = class {
2058
+ }, jr = class {
2035
2059
  tokenBucket;
2036
2060
  curIntervalStart;
2037
2061
  tokensThisInterval;
2038
2062
  fireImmediately;
2039
2063
  constructor({ tokensPerInterval: e, interval: t, fireImmediately: n }) {
2040
- this.tokenBucket = new Or({
2064
+ this.tokenBucket = new Ar({
2041
2065
  bucketSize: e,
2042
2066
  tokensPerInterval: e,
2043
2067
  interval: t
2044
- }), this.tokenBucket.content = e, this.curIntervalStart = Er(), this.tokensThisInterval = 0, this.fireImmediately = n ?? !1;
2068
+ }), this.tokenBucket.content = e, this.curIntervalStart = Or(), this.tokensThisInterval = 0, this.fireImmediately = n ?? !1;
2045
2069
  }
2046
2070
  async removeTokens(e) {
2047
2071
  if (e > this.tokenBucket.bucketSize) throw Error(`Requested tokens ${e} exceeds maximum tokens per interval ${this.tokenBucket.bucketSize}`);
2048
- let t = Er();
2072
+ let t = Or();
2049
2073
  if ((t < this.curIntervalStart || t - this.curIntervalStart >= this.tokenBucket.interval) && (this.curIntervalStart = t, this.tokensThisInterval = 0), e > this.tokenBucket.tokensPerInterval - this.tokensThisInterval) {
2050
2074
  if (this.fireImmediately) return -1;
2051
2075
  {
2052
- await Dr(Math.ceil(this.curIntervalStart + this.tokenBucket.interval - t));
2076
+ await kr(Math.ceil(this.curIntervalStart + this.tokenBucket.interval - t));
2053
2077
  let n = await this.tokenBucket.removeTokens(e);
2054
2078
  return this.tokensThisInterval += e, n;
2055
2079
  }
@@ -2059,7 +2083,7 @@ var Or = class {
2059
2083
  }
2060
2084
  tryRemoveTokens(e) {
2061
2085
  if (e > this.tokenBucket.bucketSize) return !1;
2062
- let t = Er();
2086
+ let t = Or();
2063
2087
  if ((t < this.curIntervalStart || t - this.curIntervalStart >= this.tokenBucket.interval) && (this.curIntervalStart = t, this.tokensThisInterval = 0), e > this.tokenBucket.tokensPerInterval - this.tokensThisInterval) return !1;
2064
2088
  let n = this.tokenBucket.tryRemoveTokens(e);
2065
2089
  return n && (this.tokensThisInterval += e), n;
@@ -2070,7 +2094,7 @@ var Or = class {
2070
2094
  };
2071
2095
  //#endregion
2072
2096
  //#region src/request-rate-limit.ts
2073
- function Ar(e = {}) {
2097
+ function Mr(e = {}) {
2074
2098
  let t = Math.max(1e3, Math.trunc(e.windowMs ?? 6e4)), n = e.now ?? (() => Date.now()), r = /* @__PURE__ */ new Map(), i = 0;
2075
2099
  function a(e) {
2076
2100
  return Math.max(1, Math.ceil(t / Math.max(1, e) / 1e3));
@@ -2087,7 +2111,7 @@ function Ar(e = {}) {
2087
2111
  o(l);
2088
2112
  let u = `${c}:${e}`, d = r.get(u);
2089
2113
  return d || (d = {
2090
- limiter: new kr({
2114
+ limiter: new jr({
2091
2115
  tokensPerInterval: c,
2092
2116
  interval: t,
2093
2117
  fireImmediately: !0
@@ -2104,8 +2128,8 @@ function Ar(e = {}) {
2104
2128
  }
2105
2129
  //#endregion
2106
2130
  //#region src/scope-membership-semantics.ts
2107
- var jr = "Revocation blocks future sync for this Space. It does not remove data already copied to the revoked device; offline devices, backups, copied databases, malicious peers, or old versions may retain data.";
2108
- function Mr(e) {
2131
+ var Nr = "Revocation blocks future sync for this Space. It does not remove data already copied to the revoked device; offline devices, backups, copied databases, malicious peers, or old versions may retain data.";
2132
+ function Pr(e) {
2109
2133
  let t = Number.isFinite(e.membershipEpoch) ? Number(e.membershipEpoch) : null, n = Number.isFinite(e.requiredEpoch) ? Number(e.requiredEpoch) : null;
2110
2134
  return t == null || n == null ? {
2111
2135
  membership_epoch: t,
@@ -2119,19 +2143,19 @@ function Mr(e) {
2119
2143
  reason: t < n ? "stale_epoch" : "current"
2120
2144
  };
2121
2145
  }
2122
- function Nr(e) {
2146
+ function Fr(e) {
2123
2147
  return {
2124
2148
  scope_id: e.scopeId,
2125
2149
  device_id: e.deviceId,
2126
2150
  membership_epoch: Number.isFinite(e.membershipEpoch) ? Number(e.membershipEpoch) : null,
2127
2151
  prevents_future_sync: !0,
2128
2152
  deletes_already_copied_data: !1,
2129
- message: jr
2153
+ message: Nr
2130
2154
  };
2131
2155
  }
2132
2156
  //#endregion
2133
2157
  //#region src/sync-auth-constants.ts
2134
- var Pr = 300, Fr = 65536, Ir = we + 1024, X = "X-Codemem-Coordinator-Admin", Lr = "X-Codemem-Coordinator-Admin-Actor", Rr = 120, zr = 30;
2158
+ var Ir = 300, Lr = 65536, Rr = Ee + 1024, X = "X-Codemem-Coordinator-Admin", zr = "X-Codemem-Coordinator-Admin-Actor", Br = 120, Vr = 30;
2135
2159
  function Z(e, t) {
2136
2160
  let n = t.adminSecret();
2137
2161
  if (!n) return {
@@ -2150,14 +2174,14 @@ function Z(e, t) {
2150
2174
  error: "missing_admin_header"
2151
2175
  };
2152
2176
  }
2153
- function Br(e) {
2177
+ function Hr(e) {
2154
2178
  let t = new URL(e);
2155
2179
  return t.search ? `${t.pathname}${t.search}` : t.pathname;
2156
2180
  }
2157
- async function Vr(e, t, n, r) {
2181
+ async function Ur(e, t, n, r) {
2158
2182
  return await e.recordNonce(t, n, r);
2159
2183
  }
2160
- async function Hr(e, t) {
2184
+ async function Wr(e, t) {
2161
2185
  await e.cleanupNonces(t);
2162
2186
  }
2163
2187
  async function Q(e, t, n, r) {
@@ -2193,7 +2217,7 @@ async function Q(e, t, n, r) {
2193
2217
  try {
2194
2218
  u = await n({
2195
2219
  method: r.method,
2196
- pathWithQuery: Br(r.url),
2220
+ pathWithQuery: Hr(r.url),
2197
2221
  bodyBytes: r.body,
2198
2222
  timestamp: o,
2199
2223
  nonce: s,
@@ -2214,7 +2238,7 @@ async function Q(e, t, n, r) {
2214
2238
  enrollment: null
2215
2239
  };
2216
2240
  let d = t.now();
2217
- return await Vr(e, i, s, d) ? (await Hr(e, (/* @__PURE__ */ new Date(new Date(d).getTime() - 6e5)).toISOString()), {
2241
+ return await Ur(e, i, s, d) ? (await Wr(e, (/* @__PURE__ */ new Date(new Date(d).getTime() - 6e5)).toISOString()), {
2218
2242
  ok: !0,
2219
2243
  error: "ok",
2220
2244
  enrollment: c
@@ -2227,9 +2251,9 @@ async function Q(e, t, n, r) {
2227
2251
  function $(e) {
2228
2252
  return e === "device_disabled" ? 403 : e === "group_archived" ? 409 : 401;
2229
2253
  }
2230
- function Ur(e) {
2254
+ function Gr(e) {
2231
2255
  if (!e?.storeFactory || !e.runtime || !e.requestVerifier) throw Error("createCoordinatorApp requires storeFactory, runtime, and requestVerifier.");
2232
- let t = e.runtime, n = e.storeFactory, r = e.requestVerifier, i = e.requestRateLimit ?? {}, a = i.limiter ?? Ar(), o = Math.max(1, Math.trunc(i.readLimit ?? Rr)), s = Math.max(1, Math.trunc(i.mutationLimit ?? zr)), c = Math.max(1, Math.trunc(i.unauthenticatedReadLimit ?? Math.min(20, o))), l = Math.max(1, Math.trunc(i.unauthenticatedMutationLimit ?? Math.min(10, s))), u = new or(), d = new TextDecoder();
2256
+ let t = e.runtime, n = e.storeFactory, r = e.requestVerifier, i = e.requestRateLimit ?? {}, a = i.limiter ?? Mr(), o = Math.max(1, Math.trunc(i.readLimit ?? Br)), s = Math.max(1, Math.trunc(i.mutationLimit ?? Vr)), c = Math.max(1, Math.trunc(i.unauthenticatedReadLimit ?? Math.min(20, o))), l = Math.max(1, Math.trunc(i.unauthenticatedMutationLimit ?? Math.min(10, s))), u = new cr(), d = new TextDecoder();
2233
2257
  function f(e, t, n) {
2234
2258
  let r = e.req.method === "GET" || e.req.method === "HEAD" || e.req.method === "OPTIONS", i = a.check(`${e.req.method}:${n ? "auth" : "anon"}:${t}`, n ? r ? o : s : r ? c : l);
2235
2259
  return i.allowed ? null : (e.header("Retry-After", String(i.retryAfterS)), e.json({
@@ -2237,7 +2261,7 @@ function Ur(e) {
2237
2261
  retry_after_s: i.retryAfterS
2238
2262
  }, 429));
2239
2263
  }
2240
- async function p(e, t = Fr) {
2264
+ async function p(e, t = Lr) {
2241
2265
  let n = Number.parseInt(e.req.header("content-length") ?? "", 10);
2242
2266
  if (Number.isFinite(n) && n > t) return null;
2243
2267
  let r = e.req.raw.body;
@@ -2296,7 +2320,7 @@ function Ur(e) {
2296
2320
  }
2297
2321
  function y(e) {
2298
2322
  try {
2299
- return wr(JSON.parse(e ?? ""));
2323
+ return Er(JSON.parse(e ?? ""));
2300
2324
  } catch {
2301
2325
  throw Error("operation_intent_invalid");
2302
2326
  }
@@ -2305,7 +2329,7 @@ function Ur(e) {
2305
2329
  let t = String(e.operation_id ?? "").trim(), n = String(e.reviewed_project_set_digest ?? "").trim();
2306
2330
  if (!/^share_[a-f0-9]{40}$/u.test(t) || !/^[a-f0-9]{64}$/u.test(n)) throw Error("operation_intent_invalid");
2307
2331
  let r = y(e.project_intent_json);
2308
- if (Cr(r) !== n) throw Error("operation_intent_invalid");
2332
+ if (Tr(r) !== n) throw Error("operation_intent_invalid");
2309
2333
  return {
2310
2334
  operation_id: t,
2311
2335
  reviewed_project_set_digest: n,
@@ -2314,7 +2338,7 @@ function Ur(e) {
2314
2338
  }
2315
2339
  function b(e) {
2316
2340
  try {
2317
- return ut(JSON.parse(e ?? ""));
2341
+ return pt(JSON.parse(e ?? ""));
2318
2342
  } catch {
2319
2343
  throw Error("operation_intent_invalid");
2320
2344
  }
@@ -2346,7 +2370,7 @@ function Ur(e) {
2346
2370
  response: r.json({ error: "scope_not_found" }, 404)
2347
2371
  };
2348
2372
  }
2349
- async function te(e, n, i) {
2373
+ async function C(e, n, i) {
2350
2374
  let a = await Q(e, t, r, {
2351
2375
  method: i.req.method,
2352
2376
  url: i.req.url,
@@ -2365,7 +2389,7 @@ function Ur(e) {
2365
2389
  response: f(i, String(a.enrollment.device_id), !0)
2366
2390
  };
2367
2391
  }
2368
- function C(e, t) {
2392
+ function w(e, t) {
2369
2393
  return e.status === "active" && e.membership_epoch >= t.membership_epoch;
2370
2394
  }
2371
2395
  return u.post("/v1/presence", async (e) => {
@@ -2441,7 +2465,7 @@ function Ur(e) {
2441
2465
  if (!t) return e.json({ error: "group_id_required" }, 400);
2442
2466
  let r = n();
2443
2467
  try {
2444
- let { auth: n, response: i } = await te(r, t, e);
2468
+ let { auth: n, response: i } = await C(r, t, e);
2445
2469
  if (i) return i;
2446
2470
  if (!n.enrollment) return e.json({ error: "unknown_device" }, 401);
2447
2471
  let a = await r.listScopes({
@@ -2450,7 +2474,7 @@ function Ur(e) {
2450
2474
  }), o = await r.listDeviceScopeMemberships(String(n.enrollment.device_id), !1), s = new Map(o.map((e) => [e.scope_id, e])), c = a.filter((e) => {
2451
2475
  if (e.status !== "active") return !1;
2452
2476
  let t = s.get(e.scope_id);
2453
- return !!(t && C(t, e));
2477
+ return !!(t && w(t, e));
2454
2478
  });
2455
2479
  return e.json({ items: c });
2456
2480
  } finally {
@@ -2462,7 +2486,7 @@ function Ur(e) {
2462
2486
  if (!r) return e.json({ error: "scope_id_required" }, 400);
2463
2487
  let i = n();
2464
2488
  try {
2465
- let { auth: n, response: a } = await te(i, t, e);
2489
+ let { auth: n, response: a } = await C(i, t, e);
2466
2490
  if (a) return a;
2467
2491
  if (!n.enrollment) return e.json({ error: "unknown_device" }, 401);
2468
2492
  let o = (await i.listScopes({
@@ -2471,7 +2495,7 @@ function Ur(e) {
2471
2495
  })).find((e) => e.scope_id === r) ?? null;
2472
2496
  if (o?.status !== "active") return e.json({ error: "scope_not_found" }, 404);
2473
2497
  let s = await i.listScopeMemberships(r, !1);
2474
- return s.some((e) => e.device_id === String(n.enrollment?.device_id) && C(e, o)) ? e.json({ items: s.filter((e) => C(e, o)) }) : e.json({ error: "scope_not_authorized" }, 403);
2498
+ return s.some((e) => e.device_id === String(n.enrollment?.device_id) && w(e, o)) ? e.json({ items: s.filter((e) => w(e, o)) }) : e.json({ error: "scope_not_authorized" }, 403);
2475
2499
  } finally {
2476
2500
  await i.close();
2477
2501
  }
@@ -2540,7 +2564,7 @@ function Ur(e) {
2540
2564
  request: t
2541
2565
  });
2542
2566
  } catch (t) {
2543
- if (t instanceof $e) return e.json({ error: t.code }, 409);
2567
+ if (t instanceof nt) return e.json({ error: t.code }, 409);
2544
2568
  throw t;
2545
2569
  }
2546
2570
  } finally {
@@ -2582,7 +2606,7 @@ function Ur(e) {
2582
2606
  if (!d || d !== d.trim() || d.length > 256 || /[\p{Cc}\p{Cf}]/u.test(d)) return e.json({ error: "identity_binding_required" }, 403);
2583
2607
  let p;
2584
2608
  try {
2585
- p = await K(a.reviewed_intent, {
2609
+ p = await G(a.reviewed_intent, {
2586
2610
  target: {
2587
2611
  kind: "add_device",
2588
2612
  targetIdentityId: d
@@ -2590,7 +2614,7 @@ function Ur(e) {
2590
2614
  digest: l
2591
2615
  });
2592
2616
  } catch (t) {
2593
- return t instanceof B && t.code === "recipient_invite_intent_mismatch" ? e.json({ error: t.code }, 409) : e.json({ error: "recipient_invite_review_unavailable" }, 400);
2617
+ return t instanceof z && t.code === "recipient_invite_intent_mismatch" ? e.json({ error: t.code }, 409) : e.json({ error: "recipient_invite_review_unavailable" }, 400);
2594
2618
  }
2595
2619
  let m = await u.createInvite({
2596
2620
  groupId: s,
@@ -2614,13 +2638,13 @@ function Ur(e) {
2614
2638
  target_identity_id: m.target_identity_id ?? void 0,
2615
2639
  inviter_device_id: m.inviter_device_id ?? void 0,
2616
2640
  reviewed_preview_digest: m.reviewed_preview_digest ?? void 0
2617
- }, g = dr(h), { token: _, ...v } = m;
2641
+ }, g = pr(h), { token: _, ...v } = m;
2618
2642
  return e.json({
2619
2643
  ok: !0,
2620
2644
  invite: v,
2621
2645
  payload: h,
2622
2646
  encoded: g,
2623
- link: pr(g)
2647
+ link: hr(g)
2624
2648
  });
2625
2649
  } finally {
2626
2650
  await u.close();
@@ -2636,7 +2660,7 @@ function Ur(e) {
2636
2660
  if (!o) return e.json({ error: "invalid_json" }, 400);
2637
2661
  let s = String(o.group_id ?? "").trim(), c = String(o.device_id ?? "").trim(), l = String(o.fingerprint ?? "").trim(), u = String(o.public_key ?? "").trim(), d = String(o.display_name ?? "").trim() || null;
2638
2662
  if (!s || !c || !l || !u) return e.json({ error: "group_id_device_id_fingerprint_public_key_required" }, 400);
2639
- if (Xt(u) !== l) return e.json({ error: "fingerprint_mismatch" }, 400);
2663
+ if ($t(u) !== l) return e.json({ error: "fingerprint_mismatch" }, 400);
2640
2664
  let h = n();
2641
2665
  try {
2642
2666
  await h.createGroup(s), await h.enrollDevice(s, {
@@ -2876,7 +2900,7 @@ function Ur(e) {
2876
2900
  manifestHash: h(o, "manifest_hash"),
2877
2901
  signedManifestJson: h(o, "signed_manifest_json"),
2878
2902
  actorType: "admin",
2879
- actorId: g(e.req.header(Lr))
2903
+ actorId: g(e.req.header(zr))
2880
2904
  });
2881
2905
  return e.json({
2882
2906
  ok: !0,
@@ -2884,9 +2908,9 @@ function Ur(e) {
2884
2908
  }, 201);
2885
2909
  } catch (t) {
2886
2910
  let n = t instanceof Error ? t.message : String(t);
2887
- if (t instanceof F && (t.code === "scope_not_found" || t.code === "scope_group_mismatch")) return e.json({ error: "scope_not_found" }, 404);
2888
- if (t instanceof F && t.code === "device_not_enrolled") return e.json({ error: "device_not_enrolled_for_scope_group" }, 404);
2889
- let r = t instanceof F && t.code === "scope_inactive";
2911
+ if (t instanceof P && (t.code === "scope_not_found" || t.code === "scope_group_mismatch")) return e.json({ error: "scope_not_found" }, 404);
2912
+ if (t instanceof P && t.code === "device_not_enrolled") return e.json({ error: "device_not_enrolled_for_scope_group" }, 404);
2913
+ let r = t instanceof P && t.code === "scope_inactive";
2890
2914
  return e.json({ error: r ? "scope_not_active" : n }, n === "scope_membership_effect_conflict" || r ? 409 : 400);
2891
2915
  } finally {
2892
2916
  await v.close();
@@ -2917,7 +2941,7 @@ function Ur(e) {
2917
2941
  manifestHash: h(o, "manifest_hash"),
2918
2942
  signedManifestJson: h(o, "signed_manifest_json"),
2919
2943
  actorType: "admin",
2920
- actorId: g(e.req.header(Lr))
2944
+ actorId: g(e.req.header(zr))
2921
2945
  })) return e.json({ error: "membership_not_found" }, 404);
2922
2946
  let n;
2923
2947
  try {
@@ -2929,7 +2953,7 @@ function Ur(e) {
2929
2953
  ok: !0,
2930
2954
  scope_id: c,
2931
2955
  device_id: l,
2932
- revocation: Nr({
2956
+ revocation: Fr({
2933
2957
  scopeId: c,
2934
2958
  deviceId: l,
2935
2959
  membershipEpoch: n?.membership_epoch ?? d
@@ -2937,7 +2961,7 @@ function Ur(e) {
2937
2961
  });
2938
2962
  } catch (t) {
2939
2963
  let n = t instanceof Error ? t.message : String(t);
2940
- return t instanceof F && t.code === "scope_group_mismatch" ? e.json({ error: "scope_not_found" }, 404) : e.json({ error: n }, n === "scope_membership_effect_conflict" ? 409 : 400);
2964
+ return t instanceof P && t.code === "scope_group_mismatch" ? e.json({ error: "scope_not_found" }, 404) : e.json({ error: n }, n === "scope_membership_effect_conflict" ? 409 : 400);
2941
2965
  } finally {
2942
2966
  await v.close();
2943
2967
  }
@@ -2972,7 +2996,7 @@ function Ur(e) {
2972
2996
  if (!l) return e.json({ error: "display_name_required" }, 400);
2973
2997
  let u;
2974
2998
  try {
2975
- u = z(l, "display_name");
2999
+ u = R(l, "display_name");
2976
3000
  } catch (t) {
2977
3001
  return e.json({ error: t instanceof Error ? t.message : "display_name_invalid" }, 400);
2978
3002
  }
@@ -3043,16 +3067,16 @@ function Ur(e) {
3043
3067
  if (!r.ok) return f(e, e.req.path, !1) ?? e.json({ error: r.error }, 401);
3044
3068
  let i = f(e, "admin", !0);
3045
3069
  if (i) return i;
3046
- let a = await p(e, Ir);
3070
+ let a = await p(e, Rr);
3047
3071
  if (a == null) return e.json({ error: "body_too_large" }, 413);
3048
3072
  let o = m(a);
3049
3073
  if (!o) return e.json({ error: "invalid_json" }, 400);
3050
3074
  if (Object.keys(o).some((e) => e !== "group_id" && e !== "manifest")) return e.json({ error: "completion_manifest_invalid" }, 400);
3051
3075
  let s, c;
3052
3076
  try {
3053
- let e = Pe([o.group_id])[0];
3077
+ let e = Le([o.group_id])[0];
3054
3078
  if (!e) throw Error("completion_manifest_invalid");
3055
- s = e, c = Ie(o.manifest), Re(c);
3079
+ s = e, c = ze(o.manifest), Ve(c);
3056
3080
  } catch {
3057
3081
  return e.json({ error: "completion_manifest_invalid" }, 400);
3058
3082
  }
@@ -3064,7 +3088,7 @@ function Ur(e) {
3064
3088
  ...t
3065
3089
  }, t.status === "created" ? 201 : 200);
3066
3090
  } catch (t) {
3067
- if (t instanceof ke) return e.json({ error: t.code }, 409);
3091
+ if (t instanceof je) return e.json({ error: t.code }, 409);
3068
3092
  let n = t instanceof Error ? t.message : "completion_manifest_invalid";
3069
3093
  if (n === "group_not_found") return e.json({ error: n }, 404);
3070
3094
  if (n === "group_archived" || n === "completion_manifest_unavailable") return e.json({ error: n }, 409);
@@ -3080,8 +3104,8 @@ function Ur(e) {
3080
3104
  if (i) return i;
3081
3105
  let a = String(e.req.query("group_id") ?? "").trim(), o;
3082
3106
  try {
3083
- if (Pe([a]).length !== 1) throw Error("completion_manifest_invalid");
3084
- o = Fe(e.req.query("candidate_ref"));
3107
+ if (Le([a]).length !== 1) throw Error("completion_manifest_invalid");
3108
+ o = Re(e.req.query("candidate_ref"));
3085
3109
  } catch {
3086
3110
  return e.json({ error: "group_id_and_candidate_ref_required" }, 400);
3087
3111
  }
@@ -3103,7 +3127,7 @@ function Ur(e) {
3103
3127
  if (!o || Object.keys(o).some((e) => e !== "group_ids")) return e.json({ error: "completion_query_invalid" }, 400);
3104
3128
  let s;
3105
3129
  try {
3106
- if (s = Pe(o.group_ids), s.length === 0) throw Error("completion_query_invalid");
3130
+ if (s = Le(o.group_ids), s.length === 0) throw Error("completion_query_invalid");
3107
3131
  } catch {
3108
3132
  return e.json({ error: "completion_query_invalid" }, 400);
3109
3133
  }
@@ -3125,27 +3149,27 @@ function Ur(e) {
3125
3149
  if (a == null) return e.json({ error: "body_too_large" }, 413);
3126
3150
  let o = m(a);
3127
3151
  if (!o) return e.json({ error: "invalid_json" }, 400);
3128
- let s = String(o.group_id ?? "").trim(), c = String(o.policy ?? "auto_admit").trim(), l = String(o.expires_at ?? "").trim(), u = String(o.created_by ?? "").trim() || null, d = String(o.operation_id ?? "").trim() || null, h = String(o.reviewed_project_set_digest ?? "").trim() || null, g = String(o.inviter_actor_id ?? "").trim() || null, _ = String(o.inviter_display_name ?? "").trim() || null, v = String(o.inviter_device_id ?? "").trim() || null, y = String(o.pending_person_id ?? "").trim() || null, ee = String(o.invite_kind ?? o.kind ?? "").trim(), b = String(o.policy_team_id ?? "").trim() || null, x = String(o.target_identity_id ?? "").trim() || null, S = String(o.reviewed_preview_digest ?? "").trim() || null, te, C = null, w = null;
3152
+ let s = String(o.group_id ?? "").trim(), c = String(o.policy ?? "auto_admit").trim(), l = String(o.expires_at ?? "").trim(), u = String(o.created_by ?? "").trim() || null, d = String(o.operation_id ?? "").trim() || null, h = String(o.reviewed_project_set_digest ?? "").trim() || null, g = String(o.inviter_actor_id ?? "").trim() || null, _ = String(o.inviter_display_name ?? "").trim() || null, v = String(o.inviter_device_id ?? "").trim() || null, y = String(o.pending_person_id ?? "").trim() || null, ee = String(o.invite_kind ?? o.kind ?? "").trim(), b = String(o.policy_team_id ?? "").trim() || null, x = String(o.target_identity_id ?? "").trim() || null, S = String(o.reviewed_preview_digest ?? "").trim() || null, C, w = null, T = null;
3129
3153
  if (!s || !["auto_admit", "approval_required"].includes(c) || !l) return e.json({ error: "group_id_policy_and_expires_at_required" }, 400);
3130
3154
  if (Object.hasOwn(o, "assigned_identity_id")) return e.json({ error: "assigned_identity_id_forbidden" }, 400);
3131
3155
  if (Number.isNaN(new Date(l).getTime())) return e.json({ error: "invalid_expires_at" }, 400);
3132
3156
  if (!!d != !!h) return e.json({ error: "operation_intent_reference_incomplete" }, 400);
3133
- let T = ee || (d ? "project_share" : "legacy_enrollment");
3157
+ let E = ee || (d ? "project_share" : "legacy_enrollment");
3134
3158
  if (![
3135
3159
  "legacy_enrollment",
3136
3160
  "project_share",
3137
3161
  "team_member",
3138
3162
  "add_device"
3139
- ].includes(T)) return e.json({ error: "invite_kind_invalid" }, 400);
3140
- if (T === "project_share" ? !d : d) return e.json({ error: "invite_kind_intent_mismatch" }, 400);
3163
+ ].includes(E)) return e.json({ error: "invite_kind_invalid" }, 400);
3164
+ if (E === "project_share" ? !d : d) return e.json({ error: "invite_kind_intent_mismatch" }, 400);
3141
3165
  if (S && !/^[a-f0-9]{64}$/u.test(S)) return e.json({ error: "reviewed_preview_digest_invalid" }, 400);
3142
- if (T === "team_member" && (!b || !S || x) || T === "add_device" && (!x || !S || b) || !["team_member", "add_device"].includes(T) && (b || x || S)) return e.json({ error: "recipient_invite_metadata_invalid" }, 400);
3166
+ if (E === "team_member" && (!b || !S || x) || E === "add_device" && (!x || !S || b) || !["team_member", "add_device"].includes(E) && (b || x || S)) return e.json({ error: "recipient_invite_metadata_invalid" }, 400);
3143
3167
  if ([b, x].filter((e) => !!e).some((e) => e.length > 256 || /[\p{Cc}\p{Cf}]/u.test(e))) return e.json({ error: "recipient_invite_identifier_invalid" }, 400);
3144
- if (T === "team_member" || T === "add_device") {
3168
+ if (E === "team_member" || E === "add_device") {
3145
3169
  if (o.reviewed_intent == null) return e.json({ error: "recipient_invite_review_unavailable" }, 400);
3146
3170
  try {
3147
- te = await K(o.reviewed_intent, {
3148
- target: T === "team_member" ? {
3171
+ C = await G(o.reviewed_intent, {
3172
+ target: E === "team_member" ? {
3149
3173
  kind: "team_member",
3150
3174
  policyTeamId: String(b)
3151
3175
  } : {
@@ -3155,7 +3179,7 @@ function Ur(e) {
3155
3179
  digest: String(S)
3156
3180
  });
3157
3181
  } catch (t) {
3158
- return t instanceof B && t.code === "recipient_invite_intent_mismatch" ? e.json({ error: t.code }, 409) : e.json({ error: "recipient_invite_review_unavailable" }, 400);
3182
+ return t instanceof z && t.code === "recipient_invite_intent_mismatch" ? e.json({ error: t.code }, 409) : e.json({ error: "recipient_invite_review_unavailable" }, 400);
3159
3183
  }
3160
3184
  } else if (o.reviewed_intent != null) return e.json({ error: "recipient_invite_metadata_invalid" }, 400);
3161
3185
  if (d && !/^share_[a-f0-9]{40}$/u.test(d) || h && !/^[a-f0-9]{64}$/u.test(h)) return e.json({ error: "operation_intent_reference_invalid" }, 400);
@@ -3167,27 +3191,27 @@ function Ur(e) {
3167
3191
  y
3168
3192
  ].some((e) => e.length > 256 || /[\p{Cc}\p{Cf}]/u.test(e))) return e.json({ error: "project_invite_identity_context_invalid" }, 400);
3169
3193
  try {
3170
- if (z(_, "inviter_display_name"), C = ut(o.project_summaries), !Array.isArray(o.project_intent) || o.project_intent.length !== C.length || (w = o.project_intent.map((e, t) => {
3194
+ if (R(_, "inviter_display_name"), w = pt(o.project_summaries), !Array.isArray(o.project_intent) || o.project_intent.length !== w.length || (T = o.project_intent.map((e, t) => {
3171
3195
  let n;
3172
3196
  try {
3173
- n = wr([e])[0];
3197
+ n = Er([e])[0];
3174
3198
  } catch {
3175
3199
  throw Error("project_intent_invalid");
3176
3200
  }
3177
- let r = C?.[t];
3201
+ let r = w?.[t];
3178
3202
  if (!n || !r || n.display_name !== r.display_name || n.existing_memory_count !== r.existing_memory_count) throw Error("project_intent_invalid");
3179
3203
  return n;
3180
- }), new Set(w.map((e) => e.canonical_identity)).size !== w.length)) throw Error("project_intent_invalid");
3204
+ }), new Set(T.map((e) => e.canonical_identity)).size !== T.length)) throw Error("project_intent_invalid");
3181
3205
  } catch (t) {
3182
3206
  return e.json({ error: t instanceof Error ? t.message : "project_invite_invalid" }, 400);
3183
3207
  }
3184
3208
  }
3185
- let ne = n();
3209
+ let te = n();
3186
3210
  try {
3187
- let t = await ne.getGroup(s);
3211
+ let t = await te.getGroup(s);
3188
3212
  if (!t) return e.json({ error: "group_not_found" }, 404);
3189
3213
  if (t.archived_at) return e.json({ error: "group_archived" }, 409);
3190
- let n = await ne.createInvite({
3214
+ let n = await te.createInvite({
3191
3215
  groupId: s,
3192
3216
  policy: c,
3193
3217
  expiresAt: l,
@@ -3198,13 +3222,13 @@ function Ur(e) {
3198
3222
  inviterDisplayName: _,
3199
3223
  inviterDeviceId: v,
3200
3224
  pendingPersonId: y,
3201
- projectSummaries: C,
3202
- projectIntent: w,
3203
- inviteKind: T,
3225
+ projectSummaries: w,
3226
+ projectIntent: T,
3227
+ inviteKind: E,
3204
3228
  policyTeamId: b,
3205
3229
  targetIdentityId: x,
3206
3230
  reviewedPreviewDigest: S,
3207
- reviewedIntent: te
3231
+ reviewedIntent: C
3208
3232
  }), r = {
3209
3233
  v: 1,
3210
3234
  kind: n.invite_kind === "team_member" || n.invite_kind === "add_device" ? n.invite_kind : "coordinator_team_invite",
@@ -3217,7 +3241,7 @@ function Ur(e) {
3217
3241
  ...n.operation_id ? {
3218
3242
  operation_id: n.operation_id,
3219
3243
  inviter_name: n.inviter_display_name ?? null,
3220
- project_summaries: C ?? []
3244
+ project_summaries: w ?? []
3221
3245
  } : {},
3222
3246
  ...n.invite_kind === "team_member" ? {
3223
3247
  policy_team_id: n.policy_team_id ?? void 0,
@@ -3229,20 +3253,20 @@ function Ur(e) {
3229
3253
  inviter_device_id: n.inviter_device_id ?? void 0,
3230
3254
  reviewed_preview_digest: n.reviewed_preview_digest ?? void 0
3231
3255
  } : {}
3232
- }, i = dr(r), { token: a, ...f } = n;
3256
+ }, i = pr(r), { token: a, ...f } = n;
3233
3257
  return e.json({
3234
3258
  ok: !0,
3235
3259
  invite: f,
3236
3260
  payload: r,
3237
3261
  encoded: i,
3238
- link: pr(i)
3262
+ link: hr(i)
3239
3263
  });
3240
3264
  } catch (t) {
3241
3265
  if (t instanceof Error && t.message === "invite_operation_intent_conflict") return e.json({ error: "invite_operation_intent_conflict" }, 409);
3242
3266
  if (t instanceof Error && t.message === "invite_already_bound") return e.json({ error: "invite_already_bound" }, 409);
3243
3267
  throw t;
3244
3268
  } finally {
3245
- await ne.close();
3269
+ await te.close();
3246
3270
  }
3247
3271
  }), u.post("/v1/invites/inspect", async (e) => {
3248
3272
  let r = await p(e);
@@ -3337,7 +3361,7 @@ function Ur(e) {
3337
3361
  display_name: String(e.display_name ?? ""),
3338
3362
  existing_memory_count: Number(e.existing_memory_count ?? 0)
3339
3363
  }));
3340
- s = pr(dr({
3364
+ s = hr(pr({
3341
3365
  v: 1,
3342
3366
  kind: "coordinator_team_invite",
3343
3367
  coordinator_url: new URL(e.req.url).origin,
@@ -3454,11 +3478,11 @@ function Ur(e) {
3454
3478
  } finally {
3455
3479
  await c.close();
3456
3480
  }
3457
- }), u.post("/v1/admin/join-requests/approve", async (e) => Wr(e, !0, {
3481
+ }), u.post("/v1/admin/join-requests/approve", async (e) => Kr(e, !0, {
3458
3482
  createStore: n,
3459
3483
  runtime: t,
3460
3484
  rateLimitedResponse: f
3461
- })), u.post("/v1/admin/join-requests/deny", async (e) => Wr(e, !1, {
3485
+ })), u.post("/v1/admin/join-requests/deny", async (e) => Kr(e, !1, {
3462
3486
  createStore: n,
3463
3487
  runtime: t,
3464
3488
  rateLimitedResponse: f
@@ -3482,7 +3506,7 @@ function Ur(e) {
3482
3506
  if (!i) return e.json({ error: "invalid_json" }, 400);
3483
3507
  let a = String(i.token ?? "").trim(), o = String(i.device_id ?? "").trim(), s = String(i.fingerprint ?? "").trim(), c = String(i.public_key ?? "").trim(), l = String(i.display_name ?? "").trim() || null, u = String(i.operation_id ?? "").trim(), d = String(i.recipient_actor_id ?? "").trim(), f = String(i.recipient_display_name ?? "").trim(), h = String(i.device_display_name ?? "").trim();
3484
3508
  if (!a || !o || !s || !c) return e.json({ error: "token_device_id_fingerprint_public_key_required" }, 400);
3485
- if (Xt(c) !== s) return e.json({ error: "fingerprint_mismatch" }, 400);
3509
+ if ($t(c) !== s) return e.json({ error: "fingerprint_mismatch" }, 400);
3486
3510
  let g = n();
3487
3511
  try {
3488
3512
  let n = await g.getInviteByTokenForInspection(a);
@@ -3510,11 +3534,11 @@ function Ur(e) {
3510
3534
  try {
3511
3535
  if (i.recipient_display_name != null) {
3512
3536
  if (typeof i.recipient_display_name != "string") throw Error("recipient_display_name_invalid");
3513
- d = z(i.recipient_display_name, "recipient_display_name");
3537
+ d = R(i.recipient_display_name, "recipient_display_name");
3514
3538
  }
3515
3539
  if (i.device_display_name != null) {
3516
3540
  if (typeof i.device_display_name != "string") throw Error("device_display_name_invalid");
3517
- f = st(i.device_display_name, "device_display_name");
3541
+ f = ut(i.device_display_name, "device_display_name");
3518
3542
  }
3519
3543
  } catch (t) {
3520
3544
  return e.json({ error: t instanceof Error ? t.message : "recipient_invite_identity_invalid" }, 400);
@@ -3569,7 +3593,7 @@ function Ur(e) {
3569
3593
  if (d.length > 256 || /[\p{Cc}\p{Cf}]/u.test(d)) return e.json({ error: "recipient_actor_id_invalid" }, 400);
3570
3594
  let l, p;
3571
3595
  try {
3572
- l = z(f, "recipient_display_name"), p = st(h, "device_display_name");
3596
+ l = R(f, "recipient_display_name"), p = ut(h, "device_display_name");
3573
3597
  } catch (t) {
3574
3598
  return e.json({ error: t instanceof Error ? t.message : "project_invite_identity_invalid" }, 400);
3575
3599
  }
@@ -3593,7 +3617,7 @@ function Ur(e) {
3593
3617
  });
3594
3618
  return e.json({
3595
3619
  ok: !0,
3596
- status: hr,
3620
+ status: _r,
3597
3621
  group_id: n.invite.group_id,
3598
3622
  operation_id: n.invite.operation_id,
3599
3623
  trust_state: n.invite.trust_state,
@@ -3662,14 +3686,14 @@ function Ur(e) {
3662
3686
  }
3663
3687
  }), u;
3664
3688
  }
3665
- async function Wr(e, t, n) {
3689
+ async function Kr(e, t, n) {
3666
3690
  let r = Z(e.req.header(X), n.runtime);
3667
3691
  if (!r.ok) return n.rateLimitedResponse(e, e.req.path, !1) ?? e.json({ error: r.error }, 401);
3668
3692
  let i = n.rateLimitedResponse(e, "admin", !0);
3669
3693
  if (i) return i;
3670
3694
  let a = await (async () => {
3671
3695
  let t = Number.parseInt(e.req.header("content-length") ?? "", 10);
3672
- if (Number.isFinite(t) && t > Fr) return null;
3696
+ if (Number.isFinite(t) && t > Lr) return null;
3673
3697
  let n = e.req.raw.body;
3674
3698
  if (!n) return /* @__PURE__ */ new Uint8Array();
3675
3699
  let r = n.getReader(), i = [], a = 0;
@@ -3678,7 +3702,7 @@ async function Wr(e, t, n) {
3678
3702
  let { done: e, value: t } = await r.read();
3679
3703
  if (e) break;
3680
3704
  if (t) {
3681
- if (a += t.byteLength, a > Fr) return await r.cancel(), null;
3705
+ if (a += t.byteLength, a > Lr) return await r.cancel(), null;
3682
3706
  i.push(t);
3683
3707
  }
3684
3708
  }
@@ -3726,6 +3750,6 @@ async function Wr(e, t, n) {
3726
3750
  }
3727
3751
  }
3728
3752
  //#endregion
3729
- export { Ue as $, Vt as A, ie as At, ct as B, Yt as C, he as Ct, Kt as D, be as Dt, Ht as E, ge as Et, Ot as F, p as Ft, Qe as G, L as H, Dt as I, C as It, Ze as J, Xe as K, K as L, w as Lt, B as M, T as Mt, Et as N, s as Nt, zt as O, O as Ot, Tt as P, o as Pt, qe as Q, lt as R, a as Rt, jt as S, pe as St, Mt as T, ve as Tt, ut as U, z as V, $e as W, Ke as X, F as Y, We as Z, mr as _, fe as _t, Mr as a, Se as at, q as b, se as bt, wr as c, ke as ct, gr as d, Pe as dt, Ge as et, _r as f, Ie as ft, dr as g, me as gt, fr as h, Re as ht, Nr as i, we as it, dt as j, re as jt, Gt as k, ne as kt, Sr as l, Le as lt, yr as m, Be as mt, Pr as n, Te as nt, br as o, Ce as ot, vr as p, ze as pt, Je as q, jr as r, De as rt, Cr as s, xe as st, Ur as t, Oe as tt, hr as u, Fe as ut, pr as v, E as vt, Nt as w, _e as wt, Bt as x, ce as xt, Xt as y, ye as yt, R as z };
3753
+ export { Ke as $, Wt as A, ae as At, dt as B, Qt as C, _e as Ct, Yt as D, Se as Dt, Gt as E, ve as Et, jt as F, p as Ft, tt as G, I as H, At as I, E as It, et as J, $e as K, G as L, te as Lt, z as M, ne as Mt, kt as N, s as Nt, Ht as O, O as Ot, Ot as P, o as Pt, Xe as Q, ft as R, T as Rt, Pt as S, he as St, Ft as T, be as Tt, pt as U, R as V, nt as W, Ye as X, P as Y, qe as Z, gr as _, me as _t, Pr as a, we as at, K as b, le as bt, Er as c, je as ct, vr as d, Le as dt, Je as et, yr as f, ze as ft, pr as g, ge as gt, mr as h, Ve as ht, Fr as i, Ee as it, mt as j, ie as jt, Jt as k, re as kt, wr as l, Be as lt, xr as m, Ue as mt, Ir as n, De as nt, Sr as o, Te as ot, br as p, He as pt, Ze as q, Nr as r, ke as rt, Tr as s, Ce as st, Gr as t, Ae as tt, _r as u, Re as ut, hr as v, oe as vt, It as w, ye as wt, Ut as x, ue as xt, $t as y, xe as yt, L as z, a as zt };
3730
3754
 
3731
- //# sourceMappingURL=coordinator-api-BToPmSNg.js.map
3755
+ //# sourceMappingURL=coordinator-api-CdUQtf5l.js.map