@liveblocks/core 3.8.0-tiptap1 → 3.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -6,7 +6,7 @@ var __export = (target, all) => {
6
6
 
7
7
  // src/version.ts
8
8
  var PKG_NAME = "@liveblocks/core";
9
- var PKG_VERSION = "3.8.0-tiptap1";
9
+ var PKG_VERSION = "3.8.0";
10
10
  var PKG_FORMAT = "cjs";
11
11
 
12
12
  // src/dupe-detection.ts
@@ -927,6 +927,9 @@ function isPlainObject(blob) {
927
927
  function isStartsWithOperator(blob) {
928
928
  return isPlainObject(blob) && typeof blob.startsWith === "string";
929
929
  }
930
+ function isNumberOperator(blob) {
931
+ return isPlainObject(blob) && (typeof blob.lt === "number" || typeof blob.gt === "number" || typeof blob.lte === "number" || typeof blob.gte === "number");
932
+ }
930
933
 
931
934
  // src/lib/autoRetry.ts
932
935
  var HttpError = class _HttpError extends Error {
@@ -1281,7 +1284,7 @@ function objectToQuery(obj) {
1281
1284
  if (isSimpleValue(value)) {
1282
1285
  keyValuePairs.push([key, value]);
1283
1286
  } else if (isPlainObject(value)) {
1284
- if (isStartsWithOperator(value)) {
1287
+ if (isStartsWithOperator(value) || isNumberOperator(value)) {
1285
1288
  keyValuePairsWithOperator.push([key, value]);
1286
1289
  } else {
1287
1290
  indexedKeys.push([key, value]);
@@ -1302,7 +1305,7 @@ function objectToQuery(obj) {
1302
1305
  }
1303
1306
  if (isSimpleValue(nestedValue)) {
1304
1307
  nKeyValuePairs.push([formatFilterKey(key, nestedKey), nestedValue]);
1305
- } else if (isStartsWithOperator(nestedValue)) {
1308
+ } else if (isStartsWithOperator(nestedValue) || isNumberOperator(nestedValue)) {
1306
1309
  nKeyValuePairsWithOperator.push([
1307
1310
  formatFilterKey(key, nestedKey),
1308
1311
  nestedValue
@@ -1338,6 +1341,34 @@ var getFiltersFromKeyValuePairsWithOperator = (keyValuePairsWithOperator) => {
1338
1341
  value: value.startsWith
1339
1342
  });
1340
1343
  }
1344
+ if ("lt" in value && typeof value.lt === "number") {
1345
+ filters.push({
1346
+ key,
1347
+ operator: "<",
1348
+ value: value.lt
1349
+ });
1350
+ }
1351
+ if ("gt" in value && typeof value.gt === "number") {
1352
+ filters.push({
1353
+ key,
1354
+ operator: ">",
1355
+ value: value.gt
1356
+ });
1357
+ }
1358
+ if ("gte" in value && typeof value.gte === "number") {
1359
+ filters.push({
1360
+ key,
1361
+ operator: ">=",
1362
+ value: value.gte
1363
+ });
1364
+ }
1365
+ if ("lte" in value && typeof value.lte === "number") {
1366
+ filters.push({
1367
+ key,
1368
+ operator: "<=",
1369
+ value: value.lte
1370
+ });
1371
+ }
1341
1372
  });
1342
1373
  return filters;
1343
1374
  };
@@ -2143,7 +2174,7 @@ function createApiClient({
2143
2174
  );
2144
2175
  return await result.json();
2145
2176
  }
2146
- async function sendMessages(options) {
2177
+ async function sendMessagesOverHTTP(options) {
2147
2178
  return httpClient.rawPost(
2148
2179
  url`/v2/c/rooms/${options.roomId}/send-message`,
2149
2180
  await authManager.getAuthValue({
@@ -2212,10 +2243,16 @@ function createApiClient({
2212
2243
  requestedAt: new Date(json.meta.requestedAt)
2213
2244
  };
2214
2245
  }
2215
- async function getUnreadInboxNotificationsCount() {
2246
+ async function getUnreadInboxNotificationsCount(options) {
2247
+ let query;
2248
+ if (_optionalChain([options, 'optionalAccess', _23 => _23.query])) {
2249
+ query = objectToQuery(options.query);
2250
+ }
2216
2251
  const { count } = await httpClient.get(
2217
2252
  url`/v2/c/inbox-notifications/count`,
2218
- await authManager.getAuthValue({ requestedScope: "comments:read" })
2253
+ await authManager.getAuthValue({ requestedScope: "comments:read" }),
2254
+ { query },
2255
+ { signal: _optionalChain([options, 'optionalAccess', _24 => _24.signal]) }
2219
2256
  );
2220
2257
  return count;
2221
2258
  }
@@ -2265,7 +2302,7 @@ function createApiClient({
2265
2302
  url`/v2/c/notification-settings`,
2266
2303
  await authManager.getAuthValue({ requestedScope: "comments:read" }),
2267
2304
  void 0,
2268
- { signal: _optionalChain([options, 'optionalAccess', _23 => _23.signal]) }
2305
+ { signal: _optionalChain([options, 'optionalAccess', _25 => _25.signal]) }
2269
2306
  );
2270
2307
  }
2271
2308
  async function updateNotificationSettings(settings) {
@@ -2277,7 +2314,7 @@ function createApiClient({
2277
2314
  }
2278
2315
  async function getUserThreads_experimental(options) {
2279
2316
  let query;
2280
- if (_optionalChain([options, 'optionalAccess', _24 => _24.query])) {
2317
+ if (_optionalChain([options, 'optionalAccess', _26 => _26.query])) {
2281
2318
  query = objectToQuery(options.query);
2282
2319
  }
2283
2320
  const PAGE_SIZE = 50;
@@ -2285,7 +2322,7 @@ function createApiClient({
2285
2322
  url`/v2/c/threads`,
2286
2323
  await authManager.getAuthValue({ requestedScope: "comments:read" }),
2287
2324
  {
2288
- cursor: _optionalChain([options, 'optionalAccess', _25 => _25.cursor]),
2325
+ cursor: _optionalChain([options, 'optionalAccess', _27 => _27.cursor]),
2289
2326
  query,
2290
2327
  limit: PAGE_SIZE
2291
2328
  }
@@ -2388,7 +2425,7 @@ function createApiClient({
2388
2425
  getChatAttachmentUrl,
2389
2426
  // Room storage
2390
2427
  streamStorage,
2391
- sendMessages,
2428
+ sendMessagesOverHTTP,
2392
2429
  // Notifications
2393
2430
  getInboxNotifications,
2394
2431
  getInboxNotificationsSince,
@@ -2450,7 +2487,7 @@ var HttpClient = class {
2450
2487
  // These headers are default, but can be overriden by custom headers
2451
2488
  "Content-Type": "application/json; charset=utf-8",
2452
2489
  // Possible header overrides
2453
- ..._optionalChain([options, 'optionalAccess', _26 => _26.headers]),
2490
+ ..._optionalChain([options, 'optionalAccess', _28 => _28.headers]),
2454
2491
  // Cannot be overriden by custom headers
2455
2492
  Authorization: `Bearer ${getBearerTokenFromAuthValue(authValue)}`,
2456
2493
  "X-LB-Client": PKG_VERSION || "dev"
@@ -2907,7 +2944,7 @@ var FSM = class {
2907
2944
  });
2908
2945
  }
2909
2946
  #getTargetFn(eventName) {
2910
- return _optionalChain([this, 'access', _27 => _27.#allowedTransitions, 'access', _28 => _28.get, 'call', _29 => _29(this.currentState), 'optionalAccess', _30 => _30.get, 'call', _31 => _31(eventName)]);
2947
+ return _optionalChain([this, 'access', _29 => _29.#allowedTransitions, 'access', _30 => _30.get, 'call', _31 => _31(this.currentState), 'optionalAccess', _32 => _32.get, 'call', _33 => _33(eventName)]);
2911
2948
  }
2912
2949
  /**
2913
2950
  * Exits the current state, and executes any necessary cleanup functions.
@@ -2924,7 +2961,7 @@ var FSM = class {
2924
2961
  this.#currentContext.allowPatching((patchableContext) => {
2925
2962
  levels = _nullishCoalesce(levels, () => ( this.#cleanupStack.length));
2926
2963
  for (let i = 0; i < levels; i++) {
2927
- _optionalChain([this, 'access', _32 => _32.#cleanupStack, 'access', _33 => _33.pop, 'call', _34 => _34(), 'optionalCall', _35 => _35(patchableContext)]);
2964
+ _optionalChain([this, 'access', _34 => _34.#cleanupStack, 'access', _35 => _35.pop, 'call', _36 => _36(), 'optionalCall', _37 => _37(patchableContext)]);
2928
2965
  }
2929
2966
  });
2930
2967
  }
@@ -2940,7 +2977,7 @@ var FSM = class {
2940
2977
  this.#currentContext.allowPatching((patchableContext) => {
2941
2978
  for (const pattern of enterPatterns) {
2942
2979
  const enterFn = this.#enterFns.get(pattern);
2943
- const cleanupFn = _optionalChain([enterFn, 'optionalCall', _36 => _36(patchableContext)]);
2980
+ const cleanupFn = _optionalChain([enterFn, 'optionalCall', _38 => _38(patchableContext)]);
2944
2981
  if (typeof cleanupFn === "function") {
2945
2982
  this.#cleanupStack.push(cleanupFn);
2946
2983
  } else {
@@ -3334,7 +3371,7 @@ function createConnectionStateMachine(delegates, options) {
3334
3371
  }
3335
3372
  function waitForActorId(event) {
3336
3373
  const serverMsg = tryParseJson(event.data);
3337
- if (_optionalChain([serverMsg, 'optionalAccess', _37 => _37.type]) === 104 /* ROOM_STATE */) {
3374
+ if (_optionalChain([serverMsg, 'optionalAccess', _39 => _39.type]) === 104 /* ROOM_STATE */) {
3338
3375
  didReceiveActor();
3339
3376
  }
3340
3377
  }
@@ -3443,12 +3480,12 @@ function createConnectionStateMachine(delegates, options) {
3443
3480
  const sendHeartbeat = {
3444
3481
  target: "@ok.awaiting-pong",
3445
3482
  effect: (ctx) => {
3446
- _optionalChain([ctx, 'access', _38 => _38.socket, 'optionalAccess', _39 => _39.send, 'call', _40 => _40("ping")]);
3483
+ _optionalChain([ctx, 'access', _40 => _40.socket, 'optionalAccess', _41 => _41.send, 'call', _42 => _42("ping")]);
3447
3484
  }
3448
3485
  };
3449
3486
  const maybeHeartbeat = () => {
3450
3487
  const doc = typeof document !== "undefined" ? document : void 0;
3451
- const canZombie = _optionalChain([doc, 'optionalAccess', _41 => _41.visibilityState]) === "hidden" && delegates.canZombie();
3488
+ const canZombie = _optionalChain([doc, 'optionalAccess', _43 => _43.visibilityState]) === "hidden" && delegates.canZombie();
3452
3489
  return canZombie ? "@idle.zombie" : sendHeartbeat;
3453
3490
  };
3454
3491
  machine.addTimedTransition("@ok.connected", HEARTBEAT_INTERVAL, maybeHeartbeat).addTransitions("@ok.connected", {
@@ -3487,7 +3524,7 @@ function createConnectionStateMachine(delegates, options) {
3487
3524
  // socket, or not. So always check to see if the socket is still OPEN or
3488
3525
  // not. When still OPEN, don't transition.
3489
3526
  EXPLICIT_SOCKET_ERROR: (_, context) => {
3490
- if (_optionalChain([context, 'access', _42 => _42.socket, 'optionalAccess', _43 => _43.readyState]) === 1) {
3527
+ if (_optionalChain([context, 'access', _44 => _44.socket, 'optionalAccess', _45 => _45.readyState]) === 1) {
3491
3528
  return null;
3492
3529
  }
3493
3530
  return {
@@ -3539,17 +3576,17 @@ function createConnectionStateMachine(delegates, options) {
3539
3576
  machine.send({ type: "NAVIGATOR_ONLINE" });
3540
3577
  }
3541
3578
  function onVisibilityChange() {
3542
- if (_optionalChain([doc, 'optionalAccess', _44 => _44.visibilityState]) === "visible") {
3579
+ if (_optionalChain([doc, 'optionalAccess', _46 => _46.visibilityState]) === "visible") {
3543
3580
  machine.send({ type: "WINDOW_GOT_FOCUS" });
3544
3581
  }
3545
3582
  }
3546
- _optionalChain([win, 'optionalAccess', _45 => _45.addEventListener, 'call', _46 => _46("online", onNetworkBackOnline)]);
3547
- _optionalChain([win, 'optionalAccess', _47 => _47.addEventListener, 'call', _48 => _48("offline", onNetworkOffline)]);
3548
- _optionalChain([root, 'optionalAccess', _49 => _49.addEventListener, 'call', _50 => _50("visibilitychange", onVisibilityChange)]);
3583
+ _optionalChain([win, 'optionalAccess', _47 => _47.addEventListener, 'call', _48 => _48("online", onNetworkBackOnline)]);
3584
+ _optionalChain([win, 'optionalAccess', _49 => _49.addEventListener, 'call', _50 => _50("offline", onNetworkOffline)]);
3585
+ _optionalChain([root, 'optionalAccess', _51 => _51.addEventListener, 'call', _52 => _52("visibilitychange", onVisibilityChange)]);
3549
3586
  return () => {
3550
- _optionalChain([root, 'optionalAccess', _51 => _51.removeEventListener, 'call', _52 => _52("visibilitychange", onVisibilityChange)]);
3551
- _optionalChain([win, 'optionalAccess', _53 => _53.removeEventListener, 'call', _54 => _54("online", onNetworkBackOnline)]);
3552
- _optionalChain([win, 'optionalAccess', _55 => _55.removeEventListener, 'call', _56 => _56("offline", onNetworkOffline)]);
3587
+ _optionalChain([root, 'optionalAccess', _53 => _53.removeEventListener, 'call', _54 => _54("visibilitychange", onVisibilityChange)]);
3588
+ _optionalChain([win, 'optionalAccess', _55 => _55.removeEventListener, 'call', _56 => _56("online", onNetworkBackOnline)]);
3589
+ _optionalChain([win, 'optionalAccess', _57 => _57.removeEventListener, 'call', _58 => _58("offline", onNetworkOffline)]);
3553
3590
  teardownSocket(ctx.socket);
3554
3591
  };
3555
3592
  });
@@ -3638,7 +3675,7 @@ var ManagedSocket = class {
3638
3675
  * message if this is somehow impossible.
3639
3676
  */
3640
3677
  send(data) {
3641
- const socket = _optionalChain([this, 'access', _57 => _57.#machine, 'access', _58 => _58.context, 'optionalAccess', _59 => _59.socket]);
3678
+ const socket = _optionalChain([this, 'access', _59 => _59.#machine, 'access', _60 => _60.context, 'optionalAccess', _61 => _61.socket]);
3642
3679
  if (socket === null) {
3643
3680
  warn("Cannot send: not connected yet", data);
3644
3681
  } else if (socket.readyState !== 1) {
@@ -4076,7 +4113,7 @@ function replaceOrAppend(content, newItem, keyFn, now2) {
4076
4113
  }
4077
4114
  }
4078
4115
  function closePart(prevPart, endedAt) {
4079
- if (_optionalChain([prevPart, 'optionalAccess', _60 => _60.type]) === "reasoning") {
4116
+ if (_optionalChain([prevPart, 'optionalAccess', _62 => _62.type]) === "reasoning") {
4080
4117
  prevPart.endedAt ??= endedAt;
4081
4118
  }
4082
4119
  }
@@ -4087,7 +4124,7 @@ function patchContentWithDelta(content, delta) {
4087
4124
  const lastPart = content[content.length - 1];
4088
4125
  switch (delta.type) {
4089
4126
  case "text-delta":
4090
- if (_optionalChain([lastPart, 'optionalAccess', _61 => _61.type]) === "text") {
4127
+ if (_optionalChain([lastPart, 'optionalAccess', _63 => _63.type]) === "text") {
4091
4128
  lastPart.text += delta.textDelta;
4092
4129
  } else {
4093
4130
  closePart(lastPart, now2);
@@ -4095,7 +4132,7 @@ function patchContentWithDelta(content, delta) {
4095
4132
  }
4096
4133
  break;
4097
4134
  case "reasoning-delta":
4098
- if (_optionalChain([lastPart, 'optionalAccess', _62 => _62.type]) === "reasoning") {
4135
+ if (_optionalChain([lastPart, 'optionalAccess', _64 => _64.type]) === "reasoning") {
4099
4136
  lastPart.text += delta.textDelta;
4100
4137
  } else {
4101
4138
  closePart(lastPart, now2);
@@ -4115,8 +4152,8 @@ function patchContentWithDelta(content, delta) {
4115
4152
  break;
4116
4153
  }
4117
4154
  case "tool-delta": {
4118
- if (_optionalChain([lastPart, 'optionalAccess', _63 => _63.type]) === "tool-invocation" && lastPart.stage === "receiving") {
4119
- _optionalChain([lastPart, 'access', _64 => _64.__appendDelta, 'optionalCall', _65 => _65(delta.delta)]);
4155
+ if (_optionalChain([lastPart, 'optionalAccess', _65 => _65.type]) === "tool-invocation" && lastPart.stage === "receiving") {
4156
+ _optionalChain([lastPart, 'access', _66 => _66.__appendDelta, 'optionalCall', _67 => _67(delta.delta)]);
4120
4157
  }
4121
4158
  break;
4122
4159
  }
@@ -4235,7 +4272,7 @@ function createStore_forTools() {
4235
4272
  return DerivedSignal.from(() => {
4236
4273
  return (
4237
4274
  // A tool that's registered and scoped to a specific chat ID...
4238
- _nullishCoalesce(_optionalChain([(chatId !== void 0 ? toolsByChatId\u03A3.getOrCreate(chatId).getOrCreate(name) : void 0), 'optionalAccess', _66 => _66.get, 'call', _67 => _67()]), () => ( // ...or a globally registered tool
4275
+ _nullishCoalesce(_optionalChain([(chatId !== void 0 ? toolsByChatId\u03A3.getOrCreate(chatId).getOrCreate(name) : void 0), 'optionalAccess', _68 => _68.get, 'call', _69 => _69()]), () => ( // ...or a globally registered tool
4239
4276
  toolsByChatId\u03A3.getOrCreate(kWILDCARD).getOrCreate(name).get()))
4240
4277
  );
4241
4278
  });
@@ -4265,8 +4302,8 @@ function createStore_forTools() {
4265
4302
  const globalTools\u03A3 = toolsByChatId\u03A3.get(kWILDCARD);
4266
4303
  const scopedTools\u03A3 = toolsByChatId\u03A3.get(chatId);
4267
4304
  return Array.from([
4268
- ..._nullishCoalesce(_optionalChain([globalTools\u03A3, 'optionalAccess', _68 => _68.entries, 'call', _69 => _69()]), () => ( [])),
4269
- ..._nullishCoalesce(_optionalChain([scopedTools\u03A3, 'optionalAccess', _70 => _70.entries, 'call', _71 => _71()]), () => ( []))
4305
+ ..._nullishCoalesce(_optionalChain([globalTools\u03A3, 'optionalAccess', _70 => _70.entries, 'call', _71 => _71()]), () => ( [])),
4306
+ ..._nullishCoalesce(_optionalChain([scopedTools\u03A3, 'optionalAccess', _72 => _72.entries, 'call', _73 => _73()]), () => ( []))
4270
4307
  ]).flatMap(([name, tool\u03A3]) => {
4271
4308
  const tool = tool\u03A3.get();
4272
4309
  return tool && (_nullishCoalesce(tool.enabled, () => ( true))) ? [{ name, description: tool.description, parameters: tool.parameters }] : [];
@@ -4369,7 +4406,7 @@ function createStore_forChatMessages(toolsStore, setToolResultFn) {
4369
4406
  } else {
4370
4407
  continue;
4371
4408
  }
4372
- const executeFn = _optionalChain([toolsStore, 'access', _72 => _72.getTool\u03A3, 'call', _73 => _73(toolInvocation.name, message.chatId), 'access', _74 => _74.get, 'call', _75 => _75(), 'optionalAccess', _76 => _76.execute]);
4409
+ const executeFn = _optionalChain([toolsStore, 'access', _74 => _74.getTool\u03A3, 'call', _75 => _75(toolInvocation.name, message.chatId), 'access', _76 => _76.get, 'call', _77 => _77(), 'optionalAccess', _78 => _78.execute]);
4373
4410
  if (executeFn) {
4374
4411
  (async () => {
4375
4412
  const result = await executeFn(toolInvocation.args, {
@@ -4468,8 +4505,8 @@ function createStore_forChatMessages(toolsStore, setToolResultFn) {
4468
4505
  const spine = [];
4469
4506
  let lastVisitedMessage = null;
4470
4507
  for (const message2 of pool.walkUp(leaf.id)) {
4471
- const prev = _nullishCoalesce(_optionalChain([first, 'call', _77 => _77(pool.walkLeft(message2.id, isAlive)), 'optionalAccess', _78 => _78.id]), () => ( null));
4472
- const next = _nullishCoalesce(_optionalChain([first, 'call', _79 => _79(pool.walkRight(message2.id, isAlive)), 'optionalAccess', _80 => _80.id]), () => ( null));
4508
+ const prev = _nullishCoalesce(_optionalChain([first, 'call', _79 => _79(pool.walkLeft(message2.id, isAlive)), 'optionalAccess', _80 => _80.id]), () => ( null));
4509
+ const next = _nullishCoalesce(_optionalChain([first, 'call', _81 => _81(pool.walkRight(message2.id, isAlive)), 'optionalAccess', _82 => _82.id]), () => ( null));
4473
4510
  if (!message2.deletedAt || prev || next) {
4474
4511
  const node = {
4475
4512
  ...message2,
@@ -4535,7 +4572,7 @@ function createStore_forChatMessages(toolsStore, setToolResultFn) {
4535
4572
  const latest = pool.sorted.findRight(
4536
4573
  (m) => m.role === "assistant" && !m.deletedAt
4537
4574
  );
4538
- return _optionalChain([latest, 'optionalAccess', _81 => _81.copilotId]);
4575
+ return _optionalChain([latest, 'optionalAccess', _83 => _83.copilotId]);
4539
4576
  }
4540
4577
  return {
4541
4578
  // Readers
@@ -4566,11 +4603,11 @@ function createStore_forChatMessages(toolsStore, setToolResultFn) {
4566
4603
  *getAutoExecutingMessageIds() {
4567
4604
  for (const messageId of myMessages) {
4568
4605
  const message = getMessageById(messageId);
4569
- if (_optionalChain([message, 'optionalAccess', _82 => _82.role]) === "assistant" && message.status === "awaiting-tool") {
4606
+ if (_optionalChain([message, 'optionalAccess', _84 => _84.role]) === "assistant" && message.status === "awaiting-tool") {
4570
4607
  const isAutoExecuting = message.contentSoFar.some((part) => {
4571
4608
  if (part.type === "tool-invocation" && part.stage === "executing") {
4572
4609
  const tool = toolsStore.getTool\u03A3(part.name, message.chatId).get();
4573
- return typeof _optionalChain([tool, 'optionalAccess', _83 => _83.execute]) === "function";
4610
+ return typeof _optionalChain([tool, 'optionalAccess', _85 => _85.execute]) === "function";
4574
4611
  }
4575
4612
  return false;
4576
4613
  });
@@ -4715,7 +4752,7 @@ function createAi(config) {
4715
4752
  flushPendingDeltas();
4716
4753
  switch (msg.event) {
4717
4754
  case "cmd-failed":
4718
- _optionalChain([pendingCmd, 'optionalAccess', _84 => _84.reject, 'call', _85 => _85(new Error(msg.error))]);
4755
+ _optionalChain([pendingCmd, 'optionalAccess', _86 => _86.reject, 'call', _87 => _87(new Error(msg.error))]);
4719
4756
  break;
4720
4757
  case "settle": {
4721
4758
  context.messagesStore.upsert(msg.message);
@@ -4792,7 +4829,7 @@ function createAi(config) {
4792
4829
  return assertNever(msg, "Unhandled case");
4793
4830
  }
4794
4831
  }
4795
- _optionalChain([pendingCmd, 'optionalAccess', _86 => _86.resolve, 'call', _87 => _87(msg)]);
4832
+ _optionalChain([pendingCmd, 'optionalAccess', _88 => _88.resolve, 'call', _89 => _89(msg)]);
4796
4833
  }
4797
4834
  managedSocket.events.onMessage.subscribe(handleServerMessage);
4798
4835
  managedSocket.events.statusDidChange.subscribe(onStatusDidChange);
@@ -4877,9 +4914,9 @@ function createAi(config) {
4877
4914
  invocationId,
4878
4915
  result,
4879
4916
  generationOptions: {
4880
- copilotId: _optionalChain([options, 'optionalAccess', _88 => _88.copilotId]),
4881
- stream: _optionalChain([options, 'optionalAccess', _89 => _89.stream]),
4882
- timeout: _optionalChain([options, 'optionalAccess', _90 => _90.timeout]),
4917
+ copilotId: _optionalChain([options, 'optionalAccess', _90 => _90.copilotId]),
4918
+ stream: _optionalChain([options, 'optionalAccess', _91 => _91.stream]),
4919
+ timeout: _optionalChain([options, 'optionalAccess', _92 => _92.timeout]),
4883
4920
  // Knowledge and tools aren't coming from the options, but retrieved
4884
4921
  // from the global context
4885
4922
  knowledge: knowledge.length > 0 ? knowledge : void 0,
@@ -4897,7 +4934,7 @@ function createAi(config) {
4897
4934
  }
4898
4935
  }
4899
4936
  const win = typeof window !== "undefined" ? window : void 0;
4900
- _optionalChain([win, 'optionalAccess', _91 => _91.addEventListener, 'call', _92 => _92("beforeunload", handleBeforeUnload, { once: true })]);
4937
+ _optionalChain([win, 'optionalAccess', _93 => _93.addEventListener, 'call', _94 => _94("beforeunload", handleBeforeUnload, { once: true })]);
4901
4938
  return Object.defineProperty(
4902
4939
  {
4903
4940
  [kInternal]: {
@@ -4916,7 +4953,7 @@ function createAi(config) {
4916
4953
  clearChat: (chatId) => sendClientMsgWithResponse({ cmd: "clear-chat", chatId }),
4917
4954
  askUserMessageInChat: async (chatId, userMessage, targetMessageId, options) => {
4918
4955
  const globalKnowledge = context.knowledge.get();
4919
- const requestKnowledge = _optionalChain([options, 'optionalAccess', _93 => _93.knowledge]) || [];
4956
+ const requestKnowledge = _optionalChain([options, 'optionalAccess', _95 => _95.knowledge]) || [];
4920
4957
  const combinedKnowledge = [...globalKnowledge, ...requestKnowledge];
4921
4958
  const tools = context.toolsStore.getToolDescriptions(chatId);
4922
4959
  messagesStore.markMine(targetMessageId);
@@ -4926,9 +4963,9 @@ function createAi(config) {
4926
4963
  sourceMessage: userMessage,
4927
4964
  targetMessageId,
4928
4965
  generationOptions: {
4929
- copilotId: _optionalChain([options, 'optionalAccess', _94 => _94.copilotId]),
4930
- stream: _optionalChain([options, 'optionalAccess', _95 => _95.stream]),
4931
- timeout: _optionalChain([options, 'optionalAccess', _96 => _96.timeout]),
4966
+ copilotId: _optionalChain([options, 'optionalAccess', _96 => _96.copilotId]),
4967
+ stream: _optionalChain([options, 'optionalAccess', _97 => _97.stream]),
4968
+ timeout: _optionalChain([options, 'optionalAccess', _98 => _98.timeout]),
4932
4969
  // Combine global knowledge with request-specific knowledge
4933
4970
  knowledge: combinedKnowledge.length > 0 ? combinedKnowledge : void 0,
4934
4971
  tools: tools.length > 0 ? tools : void 0
@@ -5029,7 +5066,7 @@ function createAuthManager(authOptions, onAuthenticate) {
5029
5066
  return void 0;
5030
5067
  }
5031
5068
  async function makeAuthRequest(options) {
5032
- const fetcher = _nullishCoalesce(_optionalChain([authOptions, 'access', _97 => _97.polyfills, 'optionalAccess', _98 => _98.fetch]), () => ( (typeof window === "undefined" ? void 0 : window.fetch)));
5069
+ const fetcher = _nullishCoalesce(_optionalChain([authOptions, 'access', _99 => _99.polyfills, 'optionalAccess', _100 => _100.fetch]), () => ( (typeof window === "undefined" ? void 0 : window.fetch)));
5033
5070
  if (authentication.type === "private") {
5034
5071
  if (fetcher === void 0) {
5035
5072
  throw new StopRetrying(
@@ -5045,7 +5082,7 @@ function createAuthManager(authOptions, onAuthenticate) {
5045
5082
  "The same Liveblocks auth token was issued from the backend before. Caching Liveblocks tokens is not supported."
5046
5083
  );
5047
5084
  }
5048
- _optionalChain([onAuthenticate, 'optionalCall', _99 => _99(parsed.parsed)]);
5085
+ _optionalChain([onAuthenticate, 'optionalCall', _101 => _101(parsed.parsed)]);
5049
5086
  return parsed;
5050
5087
  }
5051
5088
  if (authentication.type === "custom") {
@@ -5053,7 +5090,7 @@ function createAuthManager(authOptions, onAuthenticate) {
5053
5090
  if (response && typeof response === "object") {
5054
5091
  if (typeof response.token === "string") {
5055
5092
  const parsed = parseAuthToken(response.token);
5056
- _optionalChain([onAuthenticate, 'optionalCall', _100 => _100(parsed.parsed)]);
5093
+ _optionalChain([onAuthenticate, 'optionalCall', _102 => _102(parsed.parsed)]);
5057
5094
  return parsed;
5058
5095
  } else if (typeof response.error === "string") {
5059
5096
  const reason = `Authentication failed: ${"reason" in response && typeof response.reason === "string" ? response.reason : "Forbidden"}`;
@@ -5212,7 +5249,7 @@ function sendToPanel(message, options) {
5212
5249
  ...message,
5213
5250
  source: "liveblocks-devtools-client"
5214
5251
  };
5215
- if (!(_optionalChain([options, 'optionalAccess', _101 => _101.force]) || _bridgeActive)) {
5252
+ if (!(_optionalChain([options, 'optionalAccess', _103 => _103.force]) || _bridgeActive)) {
5216
5253
  return;
5217
5254
  }
5218
5255
  window.postMessage(fullMsg, "*");
@@ -5220,7 +5257,7 @@ function sendToPanel(message, options) {
5220
5257
  var eventSource = makeEventSource();
5221
5258
  if (process.env.NODE_ENV !== "production" && typeof window !== "undefined") {
5222
5259
  window.addEventListener("message", (event) => {
5223
- if (event.source === window && _optionalChain([event, 'access', _102 => _102.data, 'optionalAccess', _103 => _103.source]) === "liveblocks-devtools-panel") {
5260
+ if (event.source === window && _optionalChain([event, 'access', _104 => _104.data, 'optionalAccess', _105 => _105.source]) === "liveblocks-devtools-panel") {
5224
5261
  eventSource.notify(event.data);
5225
5262
  } else {
5226
5263
  }
@@ -5362,7 +5399,7 @@ function fullSync(room) {
5362
5399
  msg: "room::sync::full",
5363
5400
  roomId: room.id,
5364
5401
  status: room.getStatus(),
5365
- storage: _nullishCoalesce(_optionalChain([root, 'optionalAccess', _104 => _104.toTreeNode, 'call', _105 => _105("root"), 'access', _106 => _106.payload]), () => ( null)),
5402
+ storage: _nullishCoalesce(_optionalChain([root, 'optionalAccess', _106 => _106.toTreeNode, 'call', _107 => _107("root"), 'access', _108 => _108.payload]), () => ( null)),
5366
5403
  me,
5367
5404
  others
5368
5405
  });
@@ -5669,7 +5706,7 @@ function createManagedPool(roomId, options) {
5669
5706
  generateId: () => `${getCurrentConnectionId()}:${clock++}`,
5670
5707
  generateOpId: () => `${getCurrentConnectionId()}:${opClock++}`,
5671
5708
  dispatch(ops, reverse, storageUpdates) {
5672
- _optionalChain([onDispatch, 'optionalCall', _107 => _107(ops, reverse, storageUpdates)]);
5709
+ _optionalChain([onDispatch, 'optionalCall', _109 => _109(ops, reverse, storageUpdates)]);
5673
5710
  },
5674
5711
  assertStorageIsWritable: () => {
5675
5712
  if (!isStorageWritable()) {
@@ -5896,7 +5933,7 @@ var LiveRegister = class _LiveRegister extends AbstractCrdt {
5896
5933
  return [
5897
5934
  {
5898
5935
  type: 8 /* CREATE_REGISTER */,
5899
- opId: _optionalChain([pool, 'optionalAccess', _108 => _108.generateOpId, 'call', _109 => _109()]),
5936
+ opId: _optionalChain([pool, 'optionalAccess', _110 => _110.generateOpId, 'call', _111 => _111()]),
5900
5937
  id: this._id,
5901
5938
  parentId,
5902
5939
  parentKey,
@@ -6002,7 +6039,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
6002
6039
  const ops = [];
6003
6040
  const op = {
6004
6041
  id: this._id,
6005
- opId: _optionalChain([pool, 'optionalAccess', _110 => _110.generateOpId, 'call', _111 => _111()]),
6042
+ opId: _optionalChain([pool, 'optionalAccess', _112 => _112.generateOpId, 'call', _113 => _113()]),
6006
6043
  type: 2 /* CREATE_LIST */,
6007
6044
  parentId,
6008
6045
  parentKey
@@ -6273,7 +6310,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
6273
6310
  #applyInsertUndoRedo(op) {
6274
6311
  const { id, parentKey: key } = op;
6275
6312
  const child = creationOpToLiveNode(op);
6276
- if (_optionalChain([this, 'access', _112 => _112._pool, 'optionalAccess', _113 => _113.getNode, 'call', _114 => _114(id)]) !== void 0) {
6313
+ if (_optionalChain([this, 'access', _114 => _114._pool, 'optionalAccess', _115 => _115.getNode, 'call', _116 => _116(id)]) !== void 0) {
6277
6314
  return { modified: false };
6278
6315
  }
6279
6316
  child._attach(id, nn(this._pool));
@@ -6281,8 +6318,8 @@ var LiveList = class _LiveList extends AbstractCrdt {
6281
6318
  const existingItemIndex = this._indexOfPosition(key);
6282
6319
  let newKey = key;
6283
6320
  if (existingItemIndex !== -1) {
6284
- const before2 = _optionalChain([this, 'access', _115 => _115.#items, 'access', _116 => _116[existingItemIndex], 'optionalAccess', _117 => _117._parentPos]);
6285
- const after2 = _optionalChain([this, 'access', _118 => _118.#items, 'access', _119 => _119[existingItemIndex + 1], 'optionalAccess', _120 => _120._parentPos]);
6321
+ const before2 = _optionalChain([this, 'access', _117 => _117.#items, 'access', _118 => _118[existingItemIndex], 'optionalAccess', _119 => _119._parentPos]);
6322
+ const after2 = _optionalChain([this, 'access', _120 => _120.#items, 'access', _121 => _121[existingItemIndex + 1], 'optionalAccess', _122 => _122._parentPos]);
6286
6323
  newKey = makePosition(before2, after2);
6287
6324
  child._setParentLink(this, newKey);
6288
6325
  }
@@ -6296,7 +6333,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
6296
6333
  #applySetUndoRedo(op) {
6297
6334
  const { id, parentKey: key } = op;
6298
6335
  const child = creationOpToLiveNode(op);
6299
- if (_optionalChain([this, 'access', _121 => _121._pool, 'optionalAccess', _122 => _122.getNode, 'call', _123 => _123(id)]) !== void 0) {
6336
+ if (_optionalChain([this, 'access', _123 => _123._pool, 'optionalAccess', _124 => _124.getNode, 'call', _125 => _125(id)]) !== void 0) {
6300
6337
  return { modified: false };
6301
6338
  }
6302
6339
  this.#unacknowledgedSets.set(key, nn(op.opId));
@@ -6417,7 +6454,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
6417
6454
  } else {
6418
6455
  this.#items[existingItemIndex]._setParentLink(
6419
6456
  this,
6420
- makePosition(newKey, _optionalChain([this, 'access', _124 => _124.#items, 'access', _125 => _125[existingItemIndex + 1], 'optionalAccess', _126 => _126._parentPos]))
6457
+ makePosition(newKey, _optionalChain([this, 'access', _126 => _126.#items, 'access', _127 => _127[existingItemIndex + 1], 'optionalAccess', _128 => _128._parentPos]))
6421
6458
  );
6422
6459
  const previousIndex = this.#items.indexOf(child);
6423
6460
  child._setParentLink(this, newKey);
@@ -6442,7 +6479,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
6442
6479
  if (existingItemIndex !== -1) {
6443
6480
  this.#items[existingItemIndex]._setParentLink(
6444
6481
  this,
6445
- makePosition(newKey, _optionalChain([this, 'access', _127 => _127.#items, 'access', _128 => _128[existingItemIndex + 1], 'optionalAccess', _129 => _129._parentPos]))
6482
+ makePosition(newKey, _optionalChain([this, 'access', _129 => _129.#items, 'access', _130 => _130[existingItemIndex + 1], 'optionalAccess', _131 => _131._parentPos]))
6446
6483
  );
6447
6484
  }
6448
6485
  child._setParentLink(this, newKey);
@@ -6461,7 +6498,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
6461
6498
  if (existingItemIndex !== -1) {
6462
6499
  this.#items[existingItemIndex]._setParentLink(
6463
6500
  this,
6464
- makePosition(newKey, _optionalChain([this, 'access', _130 => _130.#items, 'access', _131 => _131[existingItemIndex + 1], 'optionalAccess', _132 => _132._parentPos]))
6501
+ makePosition(newKey, _optionalChain([this, 'access', _132 => _132.#items, 'access', _133 => _133[existingItemIndex + 1], 'optionalAccess', _134 => _134._parentPos]))
6465
6502
  );
6466
6503
  }
6467
6504
  child._setParentLink(this, newKey);
@@ -6489,7 +6526,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
6489
6526
  if (existingItemIndex !== -1) {
6490
6527
  actualNewKey = makePosition(
6491
6528
  newKey,
6492
- _optionalChain([this, 'access', _133 => _133.#items, 'access', _134 => _134[existingItemIndex + 1], 'optionalAccess', _135 => _135._parentPos])
6529
+ _optionalChain([this, 'access', _135 => _135.#items, 'access', _136 => _136[existingItemIndex + 1], 'optionalAccess', _137 => _137._parentPos])
6493
6530
  );
6494
6531
  }
6495
6532
  child._setParentLink(this, actualNewKey);
@@ -6547,7 +6584,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
6547
6584
  * @param element The element to add to the end of the LiveList.
6548
6585
  */
6549
6586
  push(element) {
6550
- _optionalChain([this, 'access', _136 => _136._pool, 'optionalAccess', _137 => _137.assertStorageIsWritable, 'call', _138 => _138()]);
6587
+ _optionalChain([this, 'access', _138 => _138._pool, 'optionalAccess', _139 => _139.assertStorageIsWritable, 'call', _140 => _140()]);
6551
6588
  return this.insert(element, this.length);
6552
6589
  }
6553
6590
  /**
@@ -6556,7 +6593,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
6556
6593
  * @param index The index at which you want to insert the element.
6557
6594
  */
6558
6595
  insert(element, index) {
6559
- _optionalChain([this, 'access', _139 => _139._pool, 'optionalAccess', _140 => _140.assertStorageIsWritable, 'call', _141 => _141()]);
6596
+ _optionalChain([this, 'access', _141 => _141._pool, 'optionalAccess', _142 => _142.assertStorageIsWritable, 'call', _143 => _143()]);
6560
6597
  if (index < 0 || index > this.#items.length) {
6561
6598
  throw new Error(
6562
6599
  `Cannot insert list item at index "${index}". index should be between 0 and ${this.#items.length}`
@@ -6586,7 +6623,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
6586
6623
  * @param targetIndex The index where the element should be after moving.
6587
6624
  */
6588
6625
  move(index, targetIndex) {
6589
- _optionalChain([this, 'access', _142 => _142._pool, 'optionalAccess', _143 => _143.assertStorageIsWritable, 'call', _144 => _144()]);
6626
+ _optionalChain([this, 'access', _144 => _144._pool, 'optionalAccess', _145 => _145.assertStorageIsWritable, 'call', _146 => _146()]);
6590
6627
  if (targetIndex < 0) {
6591
6628
  throw new Error("targetIndex cannot be less than 0");
6592
6629
  }
@@ -6644,7 +6681,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
6644
6681
  * @param index The index of the element to delete
6645
6682
  */
6646
6683
  delete(index) {
6647
- _optionalChain([this, 'access', _145 => _145._pool, 'optionalAccess', _146 => _146.assertStorageIsWritable, 'call', _147 => _147()]);
6684
+ _optionalChain([this, 'access', _147 => _147._pool, 'optionalAccess', _148 => _148.assertStorageIsWritable, 'call', _149 => _149()]);
6648
6685
  if (index < 0 || index >= this.#items.length) {
6649
6686
  throw new Error(
6650
6687
  `Cannot delete list item at index "${index}". index should be between 0 and ${this.#items.length - 1}`
@@ -6677,7 +6714,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
6677
6714
  }
6678
6715
  }
6679
6716
  clear() {
6680
- _optionalChain([this, 'access', _148 => _148._pool, 'optionalAccess', _149 => _149.assertStorageIsWritable, 'call', _150 => _150()]);
6717
+ _optionalChain([this, 'access', _150 => _150._pool, 'optionalAccess', _151 => _151.assertStorageIsWritable, 'call', _152 => _152()]);
6681
6718
  if (this._pool) {
6682
6719
  const ops = [];
6683
6720
  const reverseOps = [];
@@ -6711,7 +6748,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
6711
6748
  }
6712
6749
  }
6713
6750
  set(index, item) {
6714
- _optionalChain([this, 'access', _151 => _151._pool, 'optionalAccess', _152 => _152.assertStorageIsWritable, 'call', _153 => _153()]);
6751
+ _optionalChain([this, 'access', _153 => _153._pool, 'optionalAccess', _154 => _154.assertStorageIsWritable, 'call', _155 => _155()]);
6715
6752
  if (index < 0 || index >= this.#items.length) {
6716
6753
  throw new Error(
6717
6754
  `Cannot set list item at index "${index}". index should be between 0 and ${this.#items.length - 1}`
@@ -6857,7 +6894,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
6857
6894
  #shiftItemPosition(index, key) {
6858
6895
  const shiftedPosition = makePosition(
6859
6896
  key,
6860
- this.#items.length > index + 1 ? _optionalChain([this, 'access', _154 => _154.#items, 'access', _155 => _155[index + 1], 'optionalAccess', _156 => _156._parentPos]) : void 0
6897
+ this.#items.length > index + 1 ? _optionalChain([this, 'access', _156 => _156.#items, 'access', _157 => _157[index + 1], 'optionalAccess', _158 => _158._parentPos]) : void 0
6861
6898
  );
6862
6899
  this.#items[index]._setParentLink(this, shiftedPosition);
6863
6900
  }
@@ -6982,7 +7019,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
6982
7019
  const ops = [];
6983
7020
  const op = {
6984
7021
  id: this._id,
6985
- opId: _optionalChain([pool, 'optionalAccess', _157 => _157.generateOpId, 'call', _158 => _158()]),
7022
+ opId: _optionalChain([pool, 'optionalAccess', _159 => _159.generateOpId, 'call', _160 => _160()]),
6986
7023
  type: 7 /* CREATE_MAP */,
6987
7024
  parentId,
6988
7025
  parentKey
@@ -7084,7 +7121,12 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
7084
7121
  const storageUpdate = {
7085
7122
  node: this,
7086
7123
  type: "LiveMap",
7087
- updates: { [parentKey]: { type: "delete" } }
7124
+ updates: {
7125
+ [parentKey]: {
7126
+ type: "delete",
7127
+ deletedItem: liveNodeToLson(child)
7128
+ }
7129
+ }
7088
7130
  };
7089
7131
  return { modified: storageUpdate, reverse };
7090
7132
  }
@@ -7117,7 +7159,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
7117
7159
  * @param value The value of the element to add. Should be serializable to JSON.
7118
7160
  */
7119
7161
  set(key, value) {
7120
- _optionalChain([this, 'access', _159 => _159._pool, 'optionalAccess', _160 => _160.assertStorageIsWritable, 'call', _161 => _161()]);
7162
+ _optionalChain([this, 'access', _161 => _161._pool, 'optionalAccess', _162 => _162.assertStorageIsWritable, 'call', _163 => _163()]);
7121
7163
  const oldValue = this.#map.get(key);
7122
7164
  if (oldValue) {
7123
7165
  oldValue._detach();
@@ -7163,7 +7205,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
7163
7205
  * @returns true if an element existed and has been removed, or false if the element does not exist.
7164
7206
  */
7165
7207
  delete(key) {
7166
- _optionalChain([this, 'access', _162 => _162._pool, 'optionalAccess', _163 => _163.assertStorageIsWritable, 'call', _164 => _164()]);
7208
+ _optionalChain([this, 'access', _164 => _164._pool, 'optionalAccess', _165 => _165.assertStorageIsWritable, 'call', _166 => _166()]);
7167
7209
  const item = this.#map.get(key);
7168
7210
  if (item === void 0) {
7169
7211
  return false;
@@ -7177,7 +7219,12 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
7177
7219
  storageUpdates.set(thisId, {
7178
7220
  node: this,
7179
7221
  type: "LiveMap",
7180
- updates: { [key]: { type: "delete" } }
7222
+ updates: {
7223
+ [key]: {
7224
+ type: "delete",
7225
+ deletedItem: liveNodeToLson(item)
7226
+ }
7227
+ }
7181
7228
  });
7182
7229
  this._pool.dispatch(
7183
7230
  [
@@ -7353,7 +7400,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
7353
7400
  if (this._id === void 0) {
7354
7401
  throw new Error("Cannot serialize item is not attached");
7355
7402
  }
7356
- const opId = _optionalChain([pool, 'optionalAccess', _165 => _165.generateOpId, 'call', _166 => _166()]);
7403
+ const opId = _optionalChain([pool, 'optionalAccess', _167 => _167.generateOpId, 'call', _168 => _168()]);
7357
7404
  const ops = [];
7358
7405
  const op = {
7359
7406
  type: 4 /* CREATE_OBJECT */,
@@ -7581,13 +7628,13 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
7581
7628
  }
7582
7629
  #applyDeleteObjectKey(op, isLocal) {
7583
7630
  const key = op.key;
7584
- if (this.#map.has(key) === false) {
7631
+ const oldValue = this.#map.get(key);
7632
+ if (oldValue === void 0) {
7585
7633
  return { modified: false };
7586
7634
  }
7587
7635
  if (!isLocal && this.#propToLastUpdate.get(key) !== void 0) {
7588
7636
  return { modified: false };
7589
7637
  }
7590
- const oldValue = this.#map.get(key);
7591
7638
  const id = nn(this._id);
7592
7639
  let reverse = [];
7593
7640
  if (isLiveNode(oldValue)) {
@@ -7608,7 +7655,9 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
7608
7655
  modified: {
7609
7656
  node: this,
7610
7657
  type: "LiveObject",
7611
- updates: { [op.key]: { type: "delete" } }
7658
+ updates: {
7659
+ [op.key]: { type: "delete", deletedItem: oldValue }
7660
+ }
7612
7661
  },
7613
7662
  reverse
7614
7663
  };
@@ -7625,7 +7674,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
7625
7674
  * @param value The value of the property to add
7626
7675
  */
7627
7676
  set(key, value) {
7628
- _optionalChain([this, 'access', _167 => _167._pool, 'optionalAccess', _168 => _168.assertStorageIsWritable, 'call', _169 => _169()]);
7677
+ _optionalChain([this, 'access', _169 => _169._pool, 'optionalAccess', _170 => _170.assertStorageIsWritable, 'call', _171 => _171()]);
7629
7678
  this.update({ [key]: value });
7630
7679
  }
7631
7680
  /**
@@ -7640,7 +7689,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
7640
7689
  * @param key The key of the property to delete
7641
7690
  */
7642
7691
  delete(key) {
7643
- _optionalChain([this, 'access', _170 => _170._pool, 'optionalAccess', _171 => _171.assertStorageIsWritable, 'call', _172 => _172()]);
7692
+ _optionalChain([this, 'access', _172 => _172._pool, 'optionalAccess', _173 => _173.assertStorageIsWritable, 'call', _174 => _174()]);
7644
7693
  const keyAsString = key;
7645
7694
  const oldValue = this.#map.get(keyAsString);
7646
7695
  if (oldValue === void 0) {
@@ -7673,7 +7722,9 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
7673
7722
  storageUpdates.set(this._id, {
7674
7723
  node: this,
7675
7724
  type: "LiveObject",
7676
- updates: { [key]: { type: "delete" } }
7725
+ updates: {
7726
+ [key]: { type: "delete", deletedItem: oldValue }
7727
+ }
7677
7728
  });
7678
7729
  this._pool.dispatch(
7679
7730
  [
@@ -7693,7 +7744,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
7693
7744
  * @param patch The object used to overrides properties
7694
7745
  */
7695
7746
  update(patch) {
7696
- _optionalChain([this, 'access', _173 => _173._pool, 'optionalAccess', _174 => _174.assertStorageIsWritable, 'call', _175 => _175()]);
7747
+ _optionalChain([this, 'access', _175 => _175._pool, 'optionalAccess', _176 => _176.assertStorageIsWritable, 'call', _177 => _177()]);
7697
7748
  if (_LiveObject.detectLargeObjects) {
7698
7749
  const data = {};
7699
7750
  for (const [key, value] of this.#map) {
@@ -8441,15 +8492,15 @@ function installBackgroundTabSpy() {
8441
8492
  const doc = typeof document !== "undefined" ? document : void 0;
8442
8493
  const inBackgroundSince = { current: null };
8443
8494
  function onVisibilityChange() {
8444
- if (_optionalChain([doc, 'optionalAccess', _176 => _176.visibilityState]) === "hidden") {
8495
+ if (_optionalChain([doc, 'optionalAccess', _178 => _178.visibilityState]) === "hidden") {
8445
8496
  inBackgroundSince.current = _nullishCoalesce(inBackgroundSince.current, () => ( Date.now()));
8446
8497
  } else {
8447
8498
  inBackgroundSince.current = null;
8448
8499
  }
8449
8500
  }
8450
- _optionalChain([doc, 'optionalAccess', _177 => _177.addEventListener, 'call', _178 => _178("visibilitychange", onVisibilityChange)]);
8501
+ _optionalChain([doc, 'optionalAccess', _179 => _179.addEventListener, 'call', _180 => _180("visibilitychange", onVisibilityChange)]);
8451
8502
  const unsub = () => {
8452
- _optionalChain([doc, 'optionalAccess', _179 => _179.removeEventListener, 'call', _180 => _180("visibilitychange", onVisibilityChange)]);
8503
+ _optionalChain([doc, 'optionalAccess', _181 => _181.removeEventListener, 'call', _182 => _182("visibilitychange", onVisibilityChange)]);
8453
8504
  };
8454
8505
  return [inBackgroundSince, unsub];
8455
8506
  }
@@ -8629,7 +8680,7 @@ function createRoom(options, config) {
8629
8680
  }
8630
8681
  }
8631
8682
  function isStorageWritable() {
8632
- const scopes = _optionalChain([context, 'access', _181 => _181.dynamicSessionInfoSig, 'access', _182 => _182.get, 'call', _183 => _183(), 'optionalAccess', _184 => _184.scopes]);
8683
+ const scopes = _optionalChain([context, 'access', _183 => _183.dynamicSessionInfoSig, 'access', _184 => _184.get, 'call', _185 => _185(), 'optionalAccess', _186 => _186.scopes]);
8633
8684
  return scopes !== void 0 ? canWriteStorage(scopes) : true;
8634
8685
  }
8635
8686
  const eventHub = {
@@ -8753,13 +8804,22 @@ function createRoom(options, config) {
8753
8804
  }
8754
8805
  return;
8755
8806
  }
8807
+ // NOTE: This strategy is experimental as it will not work in all situations.
8808
+ // It should only be used for broadcasting, presence updates, but isn't suitable
8809
+ // for Storage or Yjs updates yet (because through this channel the server does
8810
+ // not respond with acks or rejections, causing the client's reported status to
8811
+ // be stuck in "synchronizing" forever).
8756
8812
  case "experimental-fallback-to-http": {
8757
8813
  warn("Message is too large for websockets, so sending over HTTP instead");
8758
- const nonce = _nullishCoalesce(_optionalChain([context, 'access', _185 => _185.dynamicSessionInfoSig, 'access', _186 => _186.get, 'call', _187 => _187(), 'optionalAccess', _188 => _188.nonce]), () => ( raise("Session is not authorized to send message over HTTP")));
8759
- void httpClient.sendMessages({ roomId, nonce, messages }).then((resp) => {
8814
+ const nonce = _nullishCoalesce(_optionalChain([context, 'access', _187 => _187.dynamicSessionInfoSig, 'access', _188 => _188.get, 'call', _189 => _189(), 'optionalAccess', _190 => _190.nonce]), () => ( raise("Session is not authorized to send message over HTTP")));
8815
+ void httpClient.sendMessagesOverHTTP({ roomId, nonce, messages }).then((resp) => {
8760
8816
  if (!resp.ok && resp.status === 403) {
8761
8817
  managedSocket.reconnect();
8762
8818
  }
8819
+ }).catch((err) => {
8820
+ error2(
8821
+ `Failed to deliver message over HTTP: ${String(err)}`
8822
+ );
8763
8823
  });
8764
8824
  return;
8765
8825
  }
@@ -8806,7 +8866,7 @@ function createRoom(options, config) {
8806
8866
  } else {
8807
8867
  context.root = LiveObject._fromItems(message.items, context.pool);
8808
8868
  }
8809
- const canWrite = _nullishCoalesce(_optionalChain([self, 'access', _189 => _189.get, 'call', _190 => _190(), 'optionalAccess', _191 => _191.canWrite]), () => ( true));
8869
+ const canWrite = _nullishCoalesce(_optionalChain([self, 'access', _191 => _191.get, 'call', _192 => _192(), 'optionalAccess', _193 => _193.canWrite]), () => ( true));
8810
8870
  const stackSizeBefore = context.undoStack.length;
8811
8871
  for (const key in context.initialStorage) {
8812
8872
  if (context.root.get(key) === void 0) {
@@ -9009,7 +9069,7 @@ function createRoom(options, config) {
9009
9069
  }
9010
9070
  context.myPresence.patch(patch);
9011
9071
  if (context.activeBatch) {
9012
- if (_optionalChain([options2, 'optionalAccess', _192 => _192.addToHistory])) {
9072
+ if (_optionalChain([options2, 'optionalAccess', _194 => _194.addToHistory])) {
9013
9073
  context.activeBatch.reverseOps.pushLeft({
9014
9074
  type: "presence",
9015
9075
  data: oldValues
@@ -9018,7 +9078,7 @@ function createRoom(options, config) {
9018
9078
  context.activeBatch.updates.presence = true;
9019
9079
  } else {
9020
9080
  flushNowOrSoon();
9021
- if (_optionalChain([options2, 'optionalAccess', _193 => _193.addToHistory])) {
9081
+ if (_optionalChain([options2, 'optionalAccess', _195 => _195.addToHistory])) {
9022
9082
  addToUndoStack([{ type: "presence", data: oldValues }]);
9023
9083
  }
9024
9084
  notify({ presence: true });
@@ -9215,7 +9275,7 @@ function createRoom(options, config) {
9215
9275
  if (process.env.NODE_ENV !== "production") {
9216
9276
  const traces = /* @__PURE__ */ new Set();
9217
9277
  for (const opId of message.opIds) {
9218
- const trace = _optionalChain([context, 'access', _194 => _194.opStackTraces, 'optionalAccess', _195 => _195.get, 'call', _196 => _196(opId)]);
9278
+ const trace = _optionalChain([context, 'access', _196 => _196.opStackTraces, 'optionalAccess', _197 => _197.get, 'call', _198 => _198(opId)]);
9219
9279
  if (trace) {
9220
9280
  traces.add(trace);
9221
9281
  }
@@ -9349,7 +9409,7 @@ ${Array.from(traces).join("\n\n")}`
9349
9409
  const unacknowledgedOps = new Map(context.unacknowledgedOps);
9350
9410
  createOrUpdateRootFromMessage(message);
9351
9411
  applyAndSendOps(unacknowledgedOps);
9352
- _optionalChain([_resolveStoragePromise, 'optionalCall', _197 => _197()]);
9412
+ _optionalChain([_resolveStoragePromise, 'optionalCall', _199 => _199()]);
9353
9413
  notifyStorageStatus();
9354
9414
  eventHub.storageDidLoad.notify();
9355
9415
  }
@@ -9570,8 +9630,8 @@ ${Array.from(traces).join("\n\n")}`
9570
9630
  async function getThreads(options2) {
9571
9631
  return httpClient.getThreads({
9572
9632
  roomId,
9573
- query: _optionalChain([options2, 'optionalAccess', _198 => _198.query]),
9574
- cursor: _optionalChain([options2, 'optionalAccess', _199 => _199.cursor])
9633
+ query: _optionalChain([options2, 'optionalAccess', _200 => _200.query]),
9634
+ cursor: _optionalChain([options2, 'optionalAccess', _201 => _201.cursor])
9575
9635
  });
9576
9636
  }
9577
9637
  async function getThread(threadId) {
@@ -9678,7 +9738,7 @@ ${Array.from(traces).join("\n\n")}`
9678
9738
  function getSubscriptionSettings(options2) {
9679
9739
  return httpClient.getSubscriptionSettings({
9680
9740
  roomId,
9681
- signal: _optionalChain([options2, 'optionalAccess', _200 => _200.signal])
9741
+ signal: _optionalChain([options2, 'optionalAccess', _202 => _202.signal])
9682
9742
  });
9683
9743
  }
9684
9744
  function updateSubscriptionSettings(settings) {
@@ -9700,7 +9760,7 @@ ${Array.from(traces).join("\n\n")}`
9700
9760
  {
9701
9761
  [kInternal]: {
9702
9762
  get presenceBuffer() {
9703
- return deepClone(_nullishCoalesce(_optionalChain([context, 'access', _201 => _201.buffer, 'access', _202 => _202.presenceUpdates, 'optionalAccess', _203 => _203.data]), () => ( null)));
9763
+ return deepClone(_nullishCoalesce(_optionalChain([context, 'access', _203 => _203.buffer, 'access', _204 => _204.presenceUpdates, 'optionalAccess', _205 => _205.data]), () => ( null)));
9704
9764
  },
9705
9765
  // prettier-ignore
9706
9766
  get undoStack() {
@@ -9715,9 +9775,9 @@ ${Array.from(traces).join("\n\n")}`
9715
9775
  return context.yjsProvider;
9716
9776
  },
9717
9777
  setYjsProvider(newProvider) {
9718
- _optionalChain([context, 'access', _204 => _204.yjsProvider, 'optionalAccess', _205 => _205.off, 'call', _206 => _206("status", yjsStatusDidChange)]);
9778
+ _optionalChain([context, 'access', _206 => _206.yjsProvider, 'optionalAccess', _207 => _207.off, 'call', _208 => _208("status", yjsStatusDidChange)]);
9719
9779
  context.yjsProvider = newProvider;
9720
- _optionalChain([newProvider, 'optionalAccess', _207 => _207.on, 'call', _208 => _208("status", yjsStatusDidChange)]);
9780
+ _optionalChain([newProvider, 'optionalAccess', _209 => _209.on, 'call', _210 => _210("status", yjsStatusDidChange)]);
9721
9781
  context.yjsProviderDidChange.notify();
9722
9782
  },
9723
9783
  yjsProviderDidChange: context.yjsProviderDidChange.observable,
@@ -9763,7 +9823,7 @@ ${Array.from(traces).join("\n\n")}`
9763
9823
  source.dispose();
9764
9824
  }
9765
9825
  eventHub.roomWillDestroy.notify();
9766
- _optionalChain([context, 'access', _209 => _209.yjsProvider, 'optionalAccess', _210 => _210.off, 'call', _211 => _211("status", yjsStatusDidChange)]);
9826
+ _optionalChain([context, 'access', _211 => _211.yjsProvider, 'optionalAccess', _212 => _212.off, 'call', _213 => _213("status", yjsStatusDidChange)]);
9767
9827
  syncSourceForStorage.destroy();
9768
9828
  syncSourceForYjs.destroy();
9769
9829
  uninstallBgTabSpy();
@@ -9913,7 +9973,7 @@ function makeClassicSubscribeFn(roomId, events, errorEvents) {
9913
9973
  }
9914
9974
  if (isLiveNode(first)) {
9915
9975
  const node = first;
9916
- if (_optionalChain([options, 'optionalAccess', _212 => _212.isDeep])) {
9976
+ if (_optionalChain([options, 'optionalAccess', _214 => _214.isDeep])) {
9917
9977
  const storageCallback = second;
9918
9978
  return subscribeToLiveStructureDeeply(node, storageCallback);
9919
9979
  } else {
@@ -9993,8 +10053,8 @@ function createClient(options) {
9993
10053
  const userId = token.k === "sec-legacy" /* SECRET_LEGACY */ ? token.id : token.uid;
9994
10054
  currentUserId.set(() => userId);
9995
10055
  });
9996
- const fetchPolyfill = _optionalChain([clientOptions, 'access', _213 => _213.polyfills, 'optionalAccess', _214 => _214.fetch]) || /* istanbul ignore next */
9997
- _optionalChain([globalThis, 'access', _215 => _215.fetch, 'optionalAccess', _216 => _216.bind, 'call', _217 => _217(globalThis)]);
10056
+ const fetchPolyfill = _optionalChain([clientOptions, 'access', _215 => _215.polyfills, 'optionalAccess', _216 => _216.fetch]) || /* istanbul ignore next */
10057
+ _optionalChain([globalThis, 'access', _217 => _217.fetch, 'optionalAccess', _218 => _218.bind, 'call', _219 => _219(globalThis)]);
9998
10058
  const httpClient = createApiClient({
9999
10059
  baseUrl,
10000
10060
  fetchPolyfill,
@@ -10012,7 +10072,7 @@ function createClient(options) {
10012
10072
  delegates: {
10013
10073
  createSocket: makeCreateSocketDelegateForAi(
10014
10074
  baseUrl,
10015
- _optionalChain([clientOptions, 'access', _218 => _218.polyfills, 'optionalAccess', _219 => _219.WebSocket])
10075
+ _optionalChain([clientOptions, 'access', _220 => _220.polyfills, 'optionalAccess', _221 => _221.WebSocket])
10016
10076
  ),
10017
10077
  authenticate: async () => {
10018
10078
  const resp = await authManager.getAuthValue({
@@ -10024,12 +10084,6 @@ function createClient(options) {
10024
10084
  );
10025
10085
  } else if (resp.token.parsed.k === "sec-legacy" /* SECRET_LEGACY */) {
10026
10086
  throw new StopRetrying("AI Copilots requires an ID or Access token");
10027
- } else {
10028
- if (!resp.token.parsed.ai) {
10029
- throw new StopRetrying(
10030
- "AI Copilots is not yet enabled for this account. To get started, see https://liveblocks.io/docs/get-started/ai-copilots#Quickstart"
10031
- );
10032
- }
10033
10087
  }
10034
10088
  return resp;
10035
10089
  },
@@ -10080,7 +10134,7 @@ function createClient(options) {
10080
10134
  createSocket: makeCreateSocketDelegateForRoom(
10081
10135
  roomId,
10082
10136
  baseUrl,
10083
- _optionalChain([clientOptions, 'access', _220 => _220.polyfills, 'optionalAccess', _221 => _221.WebSocket])
10137
+ _optionalChain([clientOptions, 'access', _222 => _222.polyfills, 'optionalAccess', _223 => _223.WebSocket])
10084
10138
  ),
10085
10139
  authenticate: makeAuthDelegateForRoom(roomId, authManager)
10086
10140
  })),
@@ -10103,7 +10157,7 @@ function createClient(options) {
10103
10157
  const shouldConnect = _nullishCoalesce(options2.autoConnect, () => ( true));
10104
10158
  if (shouldConnect) {
10105
10159
  if (typeof atob === "undefined") {
10106
- if (_optionalChain([clientOptions, 'access', _222 => _222.polyfills, 'optionalAccess', _223 => _223.atob]) === void 0) {
10160
+ if (_optionalChain([clientOptions, 'access', _224 => _224.polyfills, 'optionalAccess', _225 => _225.atob]) === void 0) {
10107
10161
  throw new Error(
10108
10162
  "You need to polyfill atob to use the client in your environment. Please follow the instructions at https://liveblocks.io/docs/errors/liveblocks-client/atob-polyfill"
10109
10163
  );
@@ -10115,7 +10169,7 @@ function createClient(options) {
10115
10169
  return leaseRoom(newRoomDetails);
10116
10170
  }
10117
10171
  function getRoom(roomId) {
10118
- const room = _optionalChain([roomsById, 'access', _224 => _224.get, 'call', _225 => _225(roomId), 'optionalAccess', _226 => _226.room]);
10172
+ const room = _optionalChain([roomsById, 'access', _226 => _226.get, 'call', _227 => _227(roomId), 'optionalAccess', _228 => _228.room]);
10119
10173
  return room ? room : null;
10120
10174
  }
10121
10175
  function logout() {
@@ -10131,7 +10185,7 @@ function createClient(options) {
10131
10185
  const batchedResolveUsers = new Batch(
10132
10186
  async (batchedUserIds) => {
10133
10187
  const userIds = batchedUserIds.flat();
10134
- const users = await _optionalChain([resolveUsers, 'optionalCall', _227 => _227({ userIds })]);
10188
+ const users = await _optionalChain([resolveUsers, 'optionalCall', _229 => _229({ userIds })]);
10135
10189
  warnOnceIf(
10136
10190
  !resolveUsers,
10137
10191
  "Set the resolveUsers option in createClient to specify user info."
@@ -10148,7 +10202,7 @@ function createClient(options) {
10148
10202
  const batchedResolveRoomsInfo = new Batch(
10149
10203
  async (batchedRoomIds) => {
10150
10204
  const roomIds = batchedRoomIds.flat();
10151
- const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall', _228 => _228({ roomIds })]);
10205
+ const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall', _230 => _230({ roomIds })]);
10152
10206
  warnOnceIf(
10153
10207
  !resolveRoomsInfo,
10154
10208
  "Set the resolveRoomsInfo option in createClient to specify room info."
@@ -10165,7 +10219,7 @@ function createClient(options) {
10165
10219
  const batchedResolveGroupsInfo = new Batch(
10166
10220
  async (batchedGroupIds) => {
10167
10221
  const groupIds = batchedGroupIds.flat();
10168
- const groupsInfo = await _optionalChain([resolveGroupsInfo, 'optionalCall', _229 => _229({ groupIds })]);
10222
+ const groupsInfo = await _optionalChain([resolveGroupsInfo, 'optionalCall', _231 => _231({ groupIds })]);
10169
10223
  warnOnceIf(
10170
10224
  !resolveGroupsInfo,
10171
10225
  "Set the resolveGroupsInfo option in createClient to specify group info."
@@ -10221,7 +10275,7 @@ function createClient(options) {
10221
10275
  }
10222
10276
  };
10223
10277
  const win = typeof window !== "undefined" ? window : void 0;
10224
- _optionalChain([win, 'optionalAccess', _230 => _230.addEventListener, 'call', _231 => _231("beforeunload", maybePreventClose)]);
10278
+ _optionalChain([win, 'optionalAccess', _232 => _232.addEventListener, 'call', _233 => _233("beforeunload", maybePreventClose)]);
10225
10279
  }
10226
10280
  async function getNotificationSettings(options2) {
10227
10281
  const plainSettings = await httpClient.getNotificationSettings(options2);
@@ -10348,7 +10402,7 @@ var commentBodyElementsTypes = {
10348
10402
  mention: "inline"
10349
10403
  };
10350
10404
  function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
10351
- if (!body || !_optionalChain([body, 'optionalAccess', _232 => _232.content])) {
10405
+ if (!body || !_optionalChain([body, 'optionalAccess', _234 => _234.content])) {
10352
10406
  return;
10353
10407
  }
10354
10408
  const element = typeof elementOrVisitor === "string" ? elementOrVisitor : void 0;
@@ -10358,13 +10412,13 @@ function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
10358
10412
  for (const block of body.content) {
10359
10413
  if (type === "all" || type === "block") {
10360
10414
  if (guard(block)) {
10361
- _optionalChain([visitor, 'optionalCall', _233 => _233(block)]);
10415
+ _optionalChain([visitor, 'optionalCall', _235 => _235(block)]);
10362
10416
  }
10363
10417
  }
10364
10418
  if (type === "all" || type === "inline") {
10365
10419
  for (const inline of block.children) {
10366
10420
  if (guard(inline)) {
10367
- _optionalChain([visitor, 'optionalCall', _234 => _234(inline)]);
10421
+ _optionalChain([visitor, 'optionalCall', _236 => _236(inline)]);
10368
10422
  }
10369
10423
  }
10370
10424
  }
@@ -10534,7 +10588,7 @@ var stringifyCommentBodyPlainElements = {
10534
10588
  text: ({ element }) => element.text,
10535
10589
  link: ({ element }) => _nullishCoalesce(element.text, () => ( element.url)),
10536
10590
  mention: ({ element, user, group }) => {
10537
- return `@${_nullishCoalesce(_nullishCoalesce(_optionalChain([user, 'optionalAccess', _235 => _235.name]), () => ( _optionalChain([group, 'optionalAccess', _236 => _236.name]))), () => ( element.id))}`;
10591
+ return `@${_nullishCoalesce(_nullishCoalesce(_optionalChain([user, 'optionalAccess', _237 => _237.name]), () => ( _optionalChain([group, 'optionalAccess', _238 => _238.name]))), () => ( element.id))}`;
10538
10592
  }
10539
10593
  };
10540
10594
  var stringifyCommentBodyHtmlElements = {
@@ -10564,7 +10618,7 @@ var stringifyCommentBodyHtmlElements = {
10564
10618
  return html`<a href="${href}" target="_blank" rel="noopener noreferrer">${element.text ? html`${element.text}` : element.url}</a>`;
10565
10619
  },
10566
10620
  mention: ({ element, user, group }) => {
10567
- return html`<span data-mention>@${_optionalChain([user, 'optionalAccess', _237 => _237.name]) ? html`${_optionalChain([user, 'optionalAccess', _238 => _238.name])}` : _optionalChain([group, 'optionalAccess', _239 => _239.name]) ? html`${_optionalChain([group, 'optionalAccess', _240 => _240.name])}` : element.id}</span>`;
10621
+ return html`<span data-mention>@${_optionalChain([user, 'optionalAccess', _239 => _239.name]) ? html`${_optionalChain([user, 'optionalAccess', _240 => _240.name])}` : _optionalChain([group, 'optionalAccess', _241 => _241.name]) ? html`${_optionalChain([group, 'optionalAccess', _242 => _242.name])}` : element.id}</span>`;
10568
10622
  }
10569
10623
  };
10570
10624
  var stringifyCommentBodyMarkdownElements = {
@@ -10594,20 +10648,20 @@ var stringifyCommentBodyMarkdownElements = {
10594
10648
  return markdown`[${_nullishCoalesce(element.text, () => ( element.url))}](${href})`;
10595
10649
  },
10596
10650
  mention: ({ element, user, group }) => {
10597
- return markdown`@${_nullishCoalesce(_nullishCoalesce(_optionalChain([user, 'optionalAccess', _241 => _241.name]), () => ( _optionalChain([group, 'optionalAccess', _242 => _242.name]))), () => ( element.id))}`;
10651
+ return markdown`@${_nullishCoalesce(_nullishCoalesce(_optionalChain([user, 'optionalAccess', _243 => _243.name]), () => ( _optionalChain([group, 'optionalAccess', _244 => _244.name]))), () => ( element.id))}`;
10598
10652
  }
10599
10653
  };
10600
10654
  async function stringifyCommentBody(body, options) {
10601
- const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _243 => _243.format]), () => ( "plain"));
10602
- const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _244 => _244.separator]), () => ( (format === "markdown" ? "\n\n" : "\n")));
10655
+ const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _245 => _245.format]), () => ( "plain"));
10656
+ const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _246 => _246.separator]), () => ( (format === "markdown" ? "\n\n" : "\n")));
10603
10657
  const elements = {
10604
10658
  ...format === "html" ? stringifyCommentBodyHtmlElements : format === "markdown" ? stringifyCommentBodyMarkdownElements : stringifyCommentBodyPlainElements,
10605
- ..._optionalChain([options, 'optionalAccess', _245 => _245.elements])
10659
+ ..._optionalChain([options, 'optionalAccess', _247 => _247.elements])
10606
10660
  };
10607
10661
  const { users: resolvedUsers, groups: resolvedGroupsInfo } = await resolveMentionsInCommentBody(
10608
10662
  body,
10609
- _optionalChain([options, 'optionalAccess', _246 => _246.resolveUsers]),
10610
- _optionalChain([options, 'optionalAccess', _247 => _247.resolveGroupsInfo])
10663
+ _optionalChain([options, 'optionalAccess', _248 => _248.resolveUsers]),
10664
+ _optionalChain([options, 'optionalAccess', _249 => _249.resolveGroupsInfo])
10611
10665
  );
10612
10666
  const blocks = body.content.flatMap((block, blockIndex) => {
10613
10667
  switch (block.type) {
@@ -10894,12 +10948,12 @@ function legacy_patchImmutableNode(state, path, update) {
10894
10948
  }
10895
10949
  const newState = Object.assign({}, state);
10896
10950
  for (const key in update.updates) {
10897
- if (_optionalChain([update, 'access', _248 => _248.updates, 'access', _249 => _249[key], 'optionalAccess', _250 => _250.type]) === "update") {
10951
+ if (_optionalChain([update, 'access', _250 => _250.updates, 'access', _251 => _251[key], 'optionalAccess', _252 => _252.type]) === "update") {
10898
10952
  const val = update.node.get(key);
10899
10953
  if (val !== void 0) {
10900
10954
  newState[key] = lsonToJson(val);
10901
10955
  }
10902
- } else if (_optionalChain([update, 'access', _251 => _251.updates, 'access', _252 => _252[key], 'optionalAccess', _253 => _253.type]) === "delete") {
10956
+ } else if (_optionalChain([update, 'access', _253 => _253.updates, 'access', _254 => _254[key], 'optionalAccess', _255 => _255.type]) === "delete") {
10903
10957
  delete newState[key];
10904
10958
  }
10905
10959
  }
@@ -10960,12 +11014,12 @@ function legacy_patchImmutableNode(state, path, update) {
10960
11014
  }
10961
11015
  const newState = Object.assign({}, state);
10962
11016
  for (const key in update.updates) {
10963
- if (_optionalChain([update, 'access', _254 => _254.updates, 'access', _255 => _255[key], 'optionalAccess', _256 => _256.type]) === "update") {
11017
+ if (_optionalChain([update, 'access', _256 => _256.updates, 'access', _257 => _257[key], 'optionalAccess', _258 => _258.type]) === "update") {
10964
11018
  const value = update.node.get(key);
10965
11019
  if (value !== void 0) {
10966
11020
  newState[key] = lsonToJson(value);
10967
11021
  }
10968
- } else if (_optionalChain([update, 'access', _257 => _257.updates, 'access', _258 => _258[key], 'optionalAccess', _259 => _259.type]) === "delete") {
11022
+ } else if (_optionalChain([update, 'access', _259 => _259.updates, 'access', _260 => _260[key], 'optionalAccess', _261 => _261.type]) === "delete") {
10969
11023
  delete newState[key];
10970
11024
  }
10971
11025
  }
@@ -11045,9 +11099,9 @@ function makePoller(callback, intervalMs, options) {
11045
11099
  const startTime = performance.now();
11046
11100
  const doc = typeof document !== "undefined" ? document : void 0;
11047
11101
  const win = typeof window !== "undefined" ? window : void 0;
11048
- const maxStaleTimeMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _260 => _260.maxStaleTimeMs]), () => ( Number.POSITIVE_INFINITY));
11102
+ const maxStaleTimeMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _262 => _262.maxStaleTimeMs]), () => ( Number.POSITIVE_INFINITY));
11049
11103
  const context = {
11050
- inForeground: _optionalChain([doc, 'optionalAccess', _261 => _261.visibilityState]) !== "hidden",
11104
+ inForeground: _optionalChain([doc, 'optionalAccess', _263 => _263.visibilityState]) !== "hidden",
11051
11105
  lastSuccessfulPollAt: startTime,
11052
11106
  count: 0,
11053
11107
  backoff: 0
@@ -11128,11 +11182,11 @@ function makePoller(callback, intervalMs, options) {
11128
11182
  pollNowIfStale();
11129
11183
  }
11130
11184
  function onVisibilityChange() {
11131
- setInForeground(_optionalChain([doc, 'optionalAccess', _262 => _262.visibilityState]) !== "hidden");
11185
+ setInForeground(_optionalChain([doc, 'optionalAccess', _264 => _264.visibilityState]) !== "hidden");
11132
11186
  }
11133
- _optionalChain([doc, 'optionalAccess', _263 => _263.addEventListener, 'call', _264 => _264("visibilitychange", onVisibilityChange)]);
11134
- _optionalChain([win, 'optionalAccess', _265 => _265.addEventListener, 'call', _266 => _266("online", onVisibilityChange)]);
11135
- _optionalChain([win, 'optionalAccess', _267 => _267.addEventListener, 'call', _268 => _268("focus", pollNowIfStale)]);
11187
+ _optionalChain([doc, 'optionalAccess', _265 => _265.addEventListener, 'call', _266 => _266("visibilitychange", onVisibilityChange)]);
11188
+ _optionalChain([win, 'optionalAccess', _267 => _267.addEventListener, 'call', _268 => _268("online", onVisibilityChange)]);
11189
+ _optionalChain([win, 'optionalAccess', _269 => _269.addEventListener, 'call', _270 => _270("focus", pollNowIfStale)]);
11136
11190
  fsm.start();
11137
11191
  return {
11138
11192
  inc,
@@ -11266,5 +11320,6 @@ detectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);
11266
11320
 
11267
11321
 
11268
11322
 
11269
- exports.ClientMsgCode = ClientMsgCode; exports.CrdtType = CrdtType; exports.DefaultMap = DefaultMap; exports.Deque = Deque; exports.DerivedSignal = DerivedSignal; exports.HttpError = HttpError; exports.LiveList = LiveList; exports.LiveMap = LiveMap; exports.LiveObject = LiveObject; exports.LiveblocksError = LiveblocksError; exports.MENTION_CHARACTER = MENTION_CHARACTER; exports.MutableSignal = MutableSignal; exports.OpCode = OpCode; exports.Permission = Permission; exports.Promise_withResolvers = Promise_withResolvers; exports.ServerMsgCode = ServerMsgCode; exports.Signal = Signal; exports.SortedList = SortedList; exports.TextEditorType = TextEditorType; exports.WebsocketCloseCodes = WebsocketCloseCodes; exports.ackOp = ackOp; exports.asPos = asPos; exports.assert = assert; exports.assertNever = assertNever; exports.autoRetry = autoRetry; exports.b64decode = b64decode; exports.batch = batch; exports.checkBounds = checkBounds; exports.chunk = chunk; exports.cloneLson = cloneLson; exports.compactObject = compactObject; exports.console = fancy_console_exports; exports.convertToCommentData = convertToCommentData; exports.convertToCommentUserReaction = convertToCommentUserReaction; exports.convertToGroupData = convertToGroupData; exports.convertToInboxNotificationData = convertToInboxNotificationData; exports.convertToSubscriptionData = convertToSubscriptionData; exports.convertToThreadData = convertToThreadData; exports.convertToUserSubscriptionData = convertToUserSubscriptionData; exports.createClient = createClient; exports.createCommentAttachmentId = createCommentAttachmentId; exports.createCommentId = createCommentId; exports.createInboxNotificationId = createInboxNotificationId; exports.createManagedPool = createManagedPool; exports.createNotificationSettings = createNotificationSettings; exports.createThreadId = createThreadId; exports.defineAiTool = defineAiTool; exports.deprecate = deprecate; exports.deprecateIf = deprecateIf; exports.detectDupes = detectDupes; exports.entries = entries; exports.errorIf = errorIf; exports.findLastIndex = findLastIndex; exports.freeze = freeze; exports.generateUrl = generateUrl; exports.getMentionsFromCommentBody = getMentionsFromCommentBody; exports.getSubscriptionKey = getSubscriptionKey; exports.html = html; exports.htmlSafe = htmlSafe; exports.isChildCrdt = isChildCrdt; exports.isCommentBodyLink = isCommentBodyLink; exports.isCommentBodyMention = isCommentBodyMention; exports.isCommentBodyText = isCommentBodyText; exports.isJsonArray = isJsonArray; exports.isJsonObject = isJsonObject; exports.isJsonScalar = isJsonScalar; exports.isLiveNode = isLiveNode; exports.isNotificationChannelEnabled = isNotificationChannelEnabled; exports.isPlainObject = isPlainObject; exports.isRootCrdt = isRootCrdt; exports.isStartsWithOperator = isStartsWithOperator; exports.isUrl = isUrl; exports.kInternal = kInternal; exports.keys = keys; exports.legacy_patchImmutableObject = legacy_patchImmutableObject; exports.lsonToJson = lsonToJson; exports.makeAbortController = makeAbortController; exports.makeEventSource = makeEventSource; exports.makePoller = makePoller; exports.makePosition = makePosition; exports.mapValues = mapValues; exports.memoizeOnSuccess = memoizeOnSuccess; exports.nanoid = nanoid; exports.nn = nn; exports.objectToQuery = objectToQuery; exports.patchLiveObjectKey = patchLiveObjectKey; exports.patchNotificationSettings = patchNotificationSettings; exports.raise = raise; exports.resolveMentionsInCommentBody = resolveMentionsInCommentBody; exports.sanitizeUrl = sanitizeUrl; exports.shallow = shallow; exports.shallow2 = shallow2; exports.stableStringify = stableStringify; exports.stringifyCommentBody = stringifyCommentBody; exports.throwUsageError = throwUsageError; exports.toPlainLson = toPlainLson; exports.tryParseJson = tryParseJson; exports.url = url; exports.urljoin = urljoin; exports.wait = wait; exports.warnOnce = warnOnce; exports.warnOnceIf = warnOnceIf; exports.withTimeout = withTimeout;
11323
+
11324
+ exports.ClientMsgCode = ClientMsgCode; exports.CrdtType = CrdtType; exports.DefaultMap = DefaultMap; exports.Deque = Deque; exports.DerivedSignal = DerivedSignal; exports.HttpError = HttpError; exports.LiveList = LiveList; exports.LiveMap = LiveMap; exports.LiveObject = LiveObject; exports.LiveblocksError = LiveblocksError; exports.MENTION_CHARACTER = MENTION_CHARACTER; exports.MutableSignal = MutableSignal; exports.OpCode = OpCode; exports.Permission = Permission; exports.Promise_withResolvers = Promise_withResolvers; exports.ServerMsgCode = ServerMsgCode; exports.Signal = Signal; exports.SortedList = SortedList; exports.TextEditorType = TextEditorType; exports.WebsocketCloseCodes = WebsocketCloseCodes; exports.ackOp = ackOp; exports.asPos = asPos; exports.assert = assert; exports.assertNever = assertNever; exports.autoRetry = autoRetry; exports.b64decode = b64decode; exports.batch = batch; exports.checkBounds = checkBounds; exports.chunk = chunk; exports.cloneLson = cloneLson; exports.compactObject = compactObject; exports.console = fancy_console_exports; exports.convertToCommentData = convertToCommentData; exports.convertToCommentUserReaction = convertToCommentUserReaction; exports.convertToGroupData = convertToGroupData; exports.convertToInboxNotificationData = convertToInboxNotificationData; exports.convertToSubscriptionData = convertToSubscriptionData; exports.convertToThreadData = convertToThreadData; exports.convertToUserSubscriptionData = convertToUserSubscriptionData; exports.createClient = createClient; exports.createCommentAttachmentId = createCommentAttachmentId; exports.createCommentId = createCommentId; exports.createInboxNotificationId = createInboxNotificationId; exports.createManagedPool = createManagedPool; exports.createNotificationSettings = createNotificationSettings; exports.createThreadId = createThreadId; exports.defineAiTool = defineAiTool; exports.deprecate = deprecate; exports.deprecateIf = deprecateIf; exports.detectDupes = detectDupes; exports.entries = entries; exports.errorIf = errorIf; exports.findLastIndex = findLastIndex; exports.freeze = freeze; exports.generateUrl = generateUrl; exports.getMentionsFromCommentBody = getMentionsFromCommentBody; exports.getSubscriptionKey = getSubscriptionKey; exports.html = html; exports.htmlSafe = htmlSafe; exports.isChildCrdt = isChildCrdt; exports.isCommentBodyLink = isCommentBodyLink; exports.isCommentBodyMention = isCommentBodyMention; exports.isCommentBodyText = isCommentBodyText; exports.isJsonArray = isJsonArray; exports.isJsonObject = isJsonObject; exports.isJsonScalar = isJsonScalar; exports.isLiveNode = isLiveNode; exports.isNotificationChannelEnabled = isNotificationChannelEnabled; exports.isNumberOperator = isNumberOperator; exports.isPlainObject = isPlainObject; exports.isRootCrdt = isRootCrdt; exports.isStartsWithOperator = isStartsWithOperator; exports.isUrl = isUrl; exports.kInternal = kInternal; exports.keys = keys; exports.legacy_patchImmutableObject = legacy_patchImmutableObject; exports.lsonToJson = lsonToJson; exports.makeAbortController = makeAbortController; exports.makeEventSource = makeEventSource; exports.makePoller = makePoller; exports.makePosition = makePosition; exports.mapValues = mapValues; exports.memoizeOnSuccess = memoizeOnSuccess; exports.nanoid = nanoid; exports.nn = nn; exports.objectToQuery = objectToQuery; exports.patchLiveObjectKey = patchLiveObjectKey; exports.patchNotificationSettings = patchNotificationSettings; exports.raise = raise; exports.resolveMentionsInCommentBody = resolveMentionsInCommentBody; exports.sanitizeUrl = sanitizeUrl; exports.shallow = shallow; exports.shallow2 = shallow2; exports.stableStringify = stableStringify; exports.stringifyCommentBody = stringifyCommentBody; exports.throwUsageError = throwUsageError; exports.toPlainLson = toPlainLson; exports.tryParseJson = tryParseJson; exports.url = url; exports.urljoin = urljoin; exports.wait = wait; exports.warnOnce = warnOnce; exports.warnOnceIf = warnOnceIf; exports.withTimeout = withTimeout;
11270
11325
  //# sourceMappingURL=index.cjs.map