@liveblocks/core 2.18.3 → 2.18.4-uns2

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.
@@ -1,4 +1,4 @@
1
- var __defProp = Object.defineProperty;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;var __defProp = Object.defineProperty;
2
2
  var __export = (target, all) => {
3
3
  for (var name in all)
4
4
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -6,8 +6,8 @@ var __export = (target, all) => {
6
6
 
7
7
  // src/version.ts
8
8
  var PKG_NAME = "@liveblocks/core";
9
- var PKG_VERSION = "2.18.3";
10
- var PKG_FORMAT = "esm";
9
+ var PKG_VERSION = "2.18.4-uns2";
10
+ var PKG_FORMAT = "cjs";
11
11
 
12
12
  // src/dupe-detection.ts
13
13
  var g = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : {};
@@ -187,6 +187,12 @@ function keys(obj) {
187
187
  function values(obj) {
188
188
  return Object.values(obj);
189
189
  }
190
+ function create(obj, descriptors) {
191
+ if (typeof descriptors !== "undefined") {
192
+ return Object.create(obj, descriptors);
193
+ }
194
+ return Object.create(obj);
195
+ }
190
196
  function mapValues(obj, mapFn) {
191
197
  const result = {};
192
198
  for (const pair of Object.entries(obj)) {
@@ -266,8 +272,8 @@ function memoizeOnSuccess(factoryFn) {
266
272
 
267
273
  // src/lib/autoRetry.ts
268
274
  var HttpError = class _HttpError extends Error {
269
- response;
270
- details;
275
+
276
+
271
277
  constructor(message, response, details) {
272
278
  super(message);
273
279
  this.name = "HttpError";
@@ -278,7 +284,7 @@ var HttpError = class _HttpError extends Error {
278
284
  let bodyAsText;
279
285
  try {
280
286
  bodyAsText = await response.text();
281
- } catch {
287
+ } catch (e2) {
282
288
  }
283
289
  const bodyAsJson = bodyAsText ? tryParseJson(bodyAsText) : void 0;
284
290
  let bodyAsJsonObject;
@@ -286,8 +292,8 @@ var HttpError = class _HttpError extends Error {
286
292
  bodyAsJsonObject = bodyAsJson;
287
293
  }
288
294
  let message = "";
289
- message ||= typeof bodyAsJsonObject?.message === "string" ? bodyAsJsonObject.message : "";
290
- message ||= typeof bodyAsJsonObject?.error === "string" ? bodyAsJsonObject.error : "";
295
+ message ||= typeof _optionalChain([bodyAsJsonObject, 'optionalAccess', _2 => _2.message]) === "string" ? bodyAsJsonObject.message : "";
296
+ message ||= typeof _optionalChain([bodyAsJsonObject, 'optionalAccess', _3 => _3.error]) === "string" ? bodyAsJsonObject.error : "";
291
297
  if (bodyAsJson === void 0) {
292
298
  message ||= bodyAsText || "";
293
299
  }
@@ -295,7 +301,7 @@ var HttpError = class _HttpError extends Error {
295
301
  let path;
296
302
  try {
297
303
  path = new URL(response.url).pathname;
298
- } catch {
304
+ } catch (e3) {
299
305
  }
300
306
  message += path !== void 0 ? ` (got status ${response.status} from ${path})` : ` (got status ${response.status})`;
301
307
  const details = bodyAsJsonObject;
@@ -324,7 +330,7 @@ async function autoRetry(promiseFn, maxTries, backoff, shouldStopRetrying = DONT
324
330
  throw new Error(`Failed after ${maxTries} attempts: ${String(err)}`);
325
331
  }
326
332
  }
327
- const delay = backoff[attempt - 1] ?? fallbackBackoff;
333
+ const delay = _nullishCoalesce(backoff[attempt - 1], () => ( fallbackBackoff));
328
334
  warn(
329
335
  `Attempt ${attempt} was unsuccessful. Retrying in ${delay} milliseconds.`
330
336
  );
@@ -369,7 +375,7 @@ function makeEventSource() {
369
375
  res(event);
370
376
  }
371
377
  });
372
- }).finally(() => unsub?.());
378
+ }).finally(() => _optionalChain([unsub, 'optionalCall', _4 => _4()]));
373
379
  }
374
380
  function notify(event) {
375
381
  let called = false;
@@ -486,12 +492,12 @@ function merge(target, patch) {
486
492
  }
487
493
  var AbstractSignal = class {
488
494
  /** @internal */
489
- equals;
495
+
490
496
  #eventSource;
491
497
  /** @internal */
492
- [kSinks];
498
+
493
499
  constructor(equals) {
494
- this.equals = equals ?? Object.is;
500
+ this.equals = _nullishCoalesce(equals, () => ( Object.is));
495
501
  this.#eventSource = makeEventSource();
496
502
  this[kSinks] = /* @__PURE__ */ new Set();
497
503
  this.get = this.get.bind(this);
@@ -560,7 +566,7 @@ var Signal = class extends AbstractSignal {
560
566
  this.#value = "(disposed)";
561
567
  }
562
568
  get() {
563
- trackedReads?.add(this);
569
+ _optionalChain([trackedReads, 'optionalAccess', _5 => _5.add, 'call', _6 => _6(this)]);
564
570
  return this.#value;
565
571
  }
566
572
  set(newValue) {
@@ -670,7 +676,7 @@ var DerivedSignal = class _DerivedSignal extends AbstractSignal {
670
676
  if (this.#dirty) {
671
677
  this.#recompute();
672
678
  }
673
- trackedReads?.add(this);
679
+ _optionalChain([trackedReads, 'optionalAccess', _7 => _7.add, 'call', _8 => _8(this)]);
674
680
  return this.#prevValue;
675
681
  }
676
682
  /**
@@ -700,7 +706,7 @@ var MutableSignal = class extends AbstractSignal {
700
706
  this.#state = "(disposed)";
701
707
  }
702
708
  get() {
703
- trackedReads?.add(this);
709
+ _optionalChain([trackedReads, 'optionalAccess', _9 => _9.add, 'call', _10 => _10(this)]);
704
710
  return this.#state;
705
711
  }
706
712
  /**
@@ -747,10 +753,10 @@ function stringifyOrLog(value) {
747
753
  // src/lib/batch.ts
748
754
  var DEFAULT_SIZE = 50;
749
755
  var BatchCall = class {
750
- input;
751
- resolve;
752
- reject;
753
- promise;
756
+
757
+
758
+
759
+
754
760
  constructor(input) {
755
761
  this.input = input;
756
762
  const { promise, resolve, reject } = Promise_withResolvers();
@@ -759,16 +765,16 @@ var BatchCall = class {
759
765
  this.reject = reject;
760
766
  }
761
767
  };
762
- var Batch = class {
768
+ var Batch = (_class = class {
763
769
  #queue = [];
764
770
  #callback;
765
771
  #size;
766
772
  #delay;
767
773
  #delayTimeoutId;
768
- error = false;
769
- constructor(callback, options) {
774
+ __init() {this.error = false}
775
+ constructor(callback, options) {;_class.prototype.__init.call(this);
770
776
  this.#callback = callback;
771
- this.#size = options.size ?? DEFAULT_SIZE;
777
+ this.#size = _nullishCoalesce(options.size, () => ( DEFAULT_SIZE));
772
778
  this.#delay = options.delay;
773
779
  }
774
780
  #clearDelayTimeout() {
@@ -795,7 +801,7 @@ var Batch = class {
795
801
  const results = await this.#callback(inputs);
796
802
  this.error = false;
797
803
  calls.forEach((call, index) => {
798
- const result = results?.[index];
804
+ const result = _optionalChain([results, 'optionalAccess', _11 => _11[index]]);
799
805
  if (!Array.isArray(results)) {
800
806
  call.reject(new Error("Callback must return an array."));
801
807
  } else if (calls.length !== results.length) {
@@ -834,7 +840,7 @@ var Batch = class {
834
840
  this.error = false;
835
841
  this.#clearDelayTimeout();
836
842
  }
837
- };
843
+ }, _class);
838
844
  function createBatchStore(batch2) {
839
845
  const signal = new MutableSignal(/* @__PURE__ */ new Map());
840
846
  function getCacheKey(args) {
@@ -950,7 +956,7 @@ var DefaultMap = class extends Map {
950
956
  if (super.has(key)) {
951
957
  return super.get(key);
952
958
  } else {
953
- const fn = defaultFn ?? this.#defaultFn ?? raise("DefaultMap used without a factory function");
959
+ const fn = _nullishCoalesce(_nullishCoalesce(defaultFn, () => ( this.#defaultFn)), () => ( raise("DefaultMap used without a factory function")));
954
960
  const value = fn(key);
955
961
  this.set(key, value);
956
962
  return value;
@@ -1075,7 +1081,7 @@ function urljoin(baseUrl, path, params) {
1075
1081
  }
1076
1082
  function url(strings, ...values2) {
1077
1083
  return strings.reduce(
1078
- (result, str, i) => result + encodeURIComponent(values2[i - 1] ?? "") + str
1084
+ (result, str, i) => result + encodeURIComponent(_nullishCoalesce(values2[i - 1], () => ( ""))) + str
1079
1085
  );
1080
1086
  }
1081
1087
 
@@ -1163,8 +1169,8 @@ function createApiClient({
1163
1169
  }
1164
1170
  }
1165
1171
  async function createThread(options) {
1166
- const commentId = options.commentId ?? createCommentId();
1167
- const threadId = options.threadId ?? createThreadId();
1172
+ const commentId = _nullishCoalesce(options.commentId, () => ( createCommentId()));
1173
+ const threadId = _nullishCoalesce(options.threadId, () => ( createThreadId()));
1168
1174
  const thread = await httpClient.post(
1169
1175
  url`/v2/c/rooms/${options.roomId}/threads`,
1170
1176
  await authManager.getAuthValue({
@@ -1228,7 +1234,7 @@ function createApiClient({
1228
1234
  );
1229
1235
  }
1230
1236
  async function createComment(options) {
1231
- const commentId = options.commentId ?? createCommentId();
1237
+ const commentId = _nullishCoalesce(options.commentId, () => ( createCommentId()));
1232
1238
  const comment = await httpClient.post(
1233
1239
  url`/v2/c/rooms/${options.roomId}/threads/${options.threadId}/comments`,
1234
1240
  await authManager.getAuthValue({
@@ -1312,11 +1318,11 @@ function createApiClient({
1312
1318
  `Upload of attachment ${options.attachment.id} was aborted.`,
1313
1319
  "AbortError"
1314
1320
  ) : void 0;
1315
- if (abortSignal?.aborted) {
1321
+ if (_optionalChain([abortSignal, 'optionalAccess', _12 => _12.aborted])) {
1316
1322
  throw abortError;
1317
1323
  }
1318
1324
  const handleRetryError = (err) => {
1319
- if (abortSignal?.aborted) {
1325
+ if (_optionalChain([abortSignal, 'optionalAccess', _13 => _13.aborted])) {
1320
1326
  throw abortError;
1321
1327
  }
1322
1328
  if (err instanceof HttpError && err.status === 413) {
@@ -1388,7 +1394,7 @@ function createApiClient({
1388
1394
  try {
1389
1395
  uploadId = createMultiPartUpload.uploadId;
1390
1396
  const parts = splitFileIntoParts(attachment.file);
1391
- if (abortSignal?.aborted) {
1397
+ if (_optionalChain([abortSignal, 'optionalAccess', _14 => _14.aborted])) {
1392
1398
  throw abortError;
1393
1399
  }
1394
1400
  const batches = chunk(parts, 5);
@@ -1415,7 +1421,7 @@ function createApiClient({
1415
1421
  }
1416
1422
  uploadedParts.push(...await Promise.all(uploadedPartsPromises));
1417
1423
  }
1418
- if (abortSignal?.aborted) {
1424
+ if (_optionalChain([abortSignal, 'optionalAccess', _15 => _15.aborted])) {
1419
1425
  throw abortError;
1420
1426
  }
1421
1427
  const sortedUploadedParts = uploadedParts.sort(
@@ -1431,7 +1437,7 @@ function createApiClient({
1431
1437
  { signal: abortSignal }
1432
1438
  );
1433
1439
  } catch (error3) {
1434
- if (uploadId && error3?.name && (error3.name === "AbortError" || error3.name === "TimeoutError")) {
1440
+ if (uploadId && _optionalChain([error3, 'optionalAccess', _16 => _16.name]) && (error3.name === "AbortError" || error3.name === "TimeoutError")) {
1435
1441
  try {
1436
1442
  await httpClient.rawDelete(
1437
1443
  url`/v2/c/rooms/${roomId}/attachments/${attachment.id}/multipart/${uploadId}`,
@@ -1460,7 +1466,7 @@ function createApiClient({
1460
1466
  { attachmentIds }
1461
1467
  );
1462
1468
  return urls.map(
1463
- (url2) => url2 ?? new Error("There was an error while getting this attachment's URL")
1469
+ (url2) => _nullishCoalesce(url2, () => ( new Error("There was an error while getting this attachment's URL")))
1464
1470
  );
1465
1471
  },
1466
1472
  { delay: 50 }
@@ -1661,7 +1667,7 @@ function createApiClient({
1661
1667
  url`/v2/c/inbox-notifications`,
1662
1668
  await authManager.getAuthValue({ requestedScope: "comments:read" }),
1663
1669
  {
1664
- cursor: options?.cursor,
1670
+ cursor: _optionalChain([options, 'optionalAccess', _17 => _17.cursor]),
1665
1671
  limit: PAGE_SIZE
1666
1672
  }
1667
1673
  );
@@ -1748,7 +1754,7 @@ function createApiClient({
1748
1754
  url`/v2/c/notification-settings`,
1749
1755
  await authManager.getAuthValue({ requestedScope: "comments:read" }),
1750
1756
  void 0,
1751
- { signal: options?.signal }
1757
+ { signal: _optionalChain([options, 'optionalAccess', _18 => _18.signal]) }
1752
1758
  );
1753
1759
  }
1754
1760
  async function updateUserNotificationSettings(settings) {
@@ -1760,7 +1766,7 @@ function createApiClient({
1760
1766
  }
1761
1767
  async function getUserThreads_experimental(options) {
1762
1768
  let query;
1763
- if (options?.query) {
1769
+ if (_optionalChain([options, 'optionalAccess', _19 => _19.query])) {
1764
1770
  query = objectToQuery(options.query);
1765
1771
  }
1766
1772
  const PAGE_SIZE = 50;
@@ -1768,7 +1774,7 @@ function createApiClient({
1768
1774
  url`/v2/c/threads`,
1769
1775
  await authManager.getAuthValue({ requestedScope: "comments:read" }),
1770
1776
  {
1771
- cursor: options?.cursor,
1777
+ cursor: _optionalChain([options, 'optionalAccess', _20 => _20.cursor]),
1772
1778
  query,
1773
1779
  limit: PAGE_SIZE
1774
1780
  }
@@ -1897,7 +1903,7 @@ var HttpClient = class {
1897
1903
  // These headers are default, but can be overriden by custom headers
1898
1904
  "Content-Type": "application/json; charset=utf-8",
1899
1905
  // Possible header overrides
1900
- ...options?.headers,
1906
+ ..._optionalChain([options, 'optionalAccess', _21 => _21.headers]),
1901
1907
  // Cannot be overriden by custom headers
1902
1908
  Authorization: `Bearer ${getBearerTokenFromAuthValue(authValue)}`,
1903
1909
  "X-LB-Client": PKG_VERSION || "dev"
@@ -1926,7 +1932,7 @@ var HttpClient = class {
1926
1932
  let body;
1927
1933
  try {
1928
1934
  body = await response.json();
1929
- } catch {
1935
+ } catch (e4) {
1930
1936
  body = {};
1931
1937
  }
1932
1938
  return body;
@@ -2102,7 +2108,7 @@ var SafeContext = class {
2102
2108
  };
2103
2109
  var nextId = 1;
2104
2110
  var FSM = class {
2105
- id;
2111
+
2106
2112
  // Indicates whether this state machine is still being configured, has
2107
2113
  // started, or has terminated
2108
2114
  #runningState;
@@ -2111,7 +2117,7 @@ var FSM = class {
2111
2117
  #currentStateOrNull;
2112
2118
  #allowedTransitions;
2113
2119
  #eventHub;
2114
- events;
2120
+
2115
2121
  //
2116
2122
  // The cleanup stack is a stack of (optional) callback functions that will
2117
2123
  // be run when exiting the current state. If a state (or state group) does
@@ -2372,7 +2378,7 @@ var FSM = class {
2372
2378
  });
2373
2379
  }
2374
2380
  #getTargetFn(eventName) {
2375
- return this.#allowedTransitions.get(this.currentState)?.get(eventName);
2381
+ return _optionalChain([this, 'access', _22 => _22.#allowedTransitions, 'access', _23 => _23.get, 'call', _24 => _24(this.currentState), 'optionalAccess', _25 => _25.get, 'call', _26 => _26(eventName)]);
2376
2382
  }
2377
2383
  /**
2378
2384
  * Exits the current state, and executes any necessary cleanup functions.
@@ -2387,9 +2393,9 @@ var FSM = class {
2387
2393
  #exit(levels) {
2388
2394
  this.#eventHub.willExitState.notify(this.currentState);
2389
2395
  this.#currentContext.allowPatching((patchableContext) => {
2390
- levels = levels ?? this.#cleanupStack.length;
2396
+ levels = _nullishCoalesce(levels, () => ( this.#cleanupStack.length));
2391
2397
  for (let i = 0; i < levels; i++) {
2392
- this.#cleanupStack.pop()?.(patchableContext);
2398
+ _optionalChain([this, 'access', _27 => _27.#cleanupStack, 'access', _28 => _28.pop, 'call', _29 => _29(), 'optionalCall', _30 => _30(patchableContext)]);
2393
2399
  }
2394
2400
  });
2395
2401
  }
@@ -2400,12 +2406,12 @@ var FSM = class {
2400
2406
  #enter(levels) {
2401
2407
  const enterPatterns = patterns(
2402
2408
  this.currentState,
2403
- levels ?? this.currentState.split(".").length + 1
2409
+ _nullishCoalesce(levels, () => ( this.currentState.split(".").length + 1))
2404
2410
  );
2405
2411
  this.#currentContext.allowPatching((patchableContext) => {
2406
2412
  for (const pattern of enterPatterns) {
2407
2413
  const enterFn = this.#enterFns.get(pattern);
2408
- const cleanupFn = enterFn?.(patchableContext);
2414
+ const cleanupFn = _optionalChain([enterFn, 'optionalCall', _31 => _31(patchableContext)]);
2409
2415
  if (typeof cleanupFn === "function") {
2410
2416
  this.#cleanupStack.push(cleanupFn);
2411
2417
  } else {
@@ -2566,7 +2572,7 @@ var StopRetrying = class extends Error {
2566
2572
  }
2567
2573
  };
2568
2574
  function nextBackoffDelay(currentDelay, delays) {
2569
- return delays.find((delay) => delay > currentDelay) ?? delays[delays.length - 1];
2575
+ return _nullishCoalesce(delays.find((delay) => delay > currentDelay), () => ( delays[delays.length - 1]));
2570
2576
  }
2571
2577
  function increaseBackoffDelay(context) {
2572
2578
  context.patch({
@@ -2799,7 +2805,7 @@ function createConnectionStateMachine(delegates, options) {
2799
2805
  }
2800
2806
  function waitForActorId(event) {
2801
2807
  const serverMsg = tryParseJson(event.data);
2802
- if (serverMsg?.type === 104 /* ROOM_STATE */) {
2808
+ if (_optionalChain([serverMsg, 'optionalAccess', _32 => _32.type]) === 104 /* ROOM_STATE */) {
2803
2809
  didReceiveActor();
2804
2810
  }
2805
2811
  }
@@ -2908,12 +2914,12 @@ function createConnectionStateMachine(delegates, options) {
2908
2914
  const sendHeartbeat = {
2909
2915
  target: "@ok.awaiting-pong",
2910
2916
  effect: (ctx) => {
2911
- ctx.socket?.send("ping");
2917
+ _optionalChain([ctx, 'access', _33 => _33.socket, 'optionalAccess', _34 => _34.send, 'call', _35 => _35("ping")]);
2912
2918
  }
2913
2919
  };
2914
2920
  const maybeHeartbeat = () => {
2915
2921
  const doc = typeof document !== "undefined" ? document : void 0;
2916
- const canZombie = doc?.visibilityState === "hidden" && delegates.canZombie();
2922
+ const canZombie = _optionalChain([doc, 'optionalAccess', _36 => _36.visibilityState]) === "hidden" && delegates.canZombie();
2917
2923
  return canZombie ? "@idle.zombie" : sendHeartbeat;
2918
2924
  };
2919
2925
  machine.addTimedTransition("@ok.connected", HEARTBEAT_INTERVAL, maybeHeartbeat).addTransitions("@ok.connected", {
@@ -2952,7 +2958,7 @@ function createConnectionStateMachine(delegates, options) {
2952
2958
  // socket, or not. So always check to see if the socket is still OPEN or
2953
2959
  // not. When still OPEN, don't transition.
2954
2960
  EXPLICIT_SOCKET_ERROR: (_, context) => {
2955
- if (context.socket?.readyState === 1) {
2961
+ if (_optionalChain([context, 'access', _37 => _37.socket, 'optionalAccess', _38 => _38.readyState]) === 1) {
2956
2962
  return null;
2957
2963
  }
2958
2964
  return {
@@ -2995,7 +3001,7 @@ function createConnectionStateMachine(delegates, options) {
2995
3001
  if (typeof document !== "undefined") {
2996
3002
  const doc = typeof document !== "undefined" ? document : void 0;
2997
3003
  const win = typeof window !== "undefined" ? window : void 0;
2998
- const root = win ?? doc;
3004
+ const root = _nullishCoalesce(win, () => ( doc));
2999
3005
  machine.onEnter("*", (ctx) => {
3000
3006
  function onNetworkOffline() {
3001
3007
  machine.send({ type: "NAVIGATOR_OFFLINE" });
@@ -3004,17 +3010,17 @@ function createConnectionStateMachine(delegates, options) {
3004
3010
  machine.send({ type: "NAVIGATOR_ONLINE" });
3005
3011
  }
3006
3012
  function onVisibilityChange() {
3007
- if (doc?.visibilityState === "visible") {
3013
+ if (_optionalChain([doc, 'optionalAccess', _39 => _39.visibilityState]) === "visible") {
3008
3014
  machine.send({ type: "WINDOW_GOT_FOCUS" });
3009
3015
  }
3010
3016
  }
3011
- win?.addEventListener("online", onNetworkBackOnline);
3012
- win?.addEventListener("offline", onNetworkOffline);
3013
- root?.addEventListener("visibilitychange", onVisibilityChange);
3017
+ _optionalChain([win, 'optionalAccess', _40 => _40.addEventListener, 'call', _41 => _41("online", onNetworkBackOnline)]);
3018
+ _optionalChain([win, 'optionalAccess', _42 => _42.addEventListener, 'call', _43 => _43("offline", onNetworkOffline)]);
3019
+ _optionalChain([root, 'optionalAccess', _44 => _44.addEventListener, 'call', _45 => _45("visibilitychange", onVisibilityChange)]);
3014
3020
  return () => {
3015
- root?.removeEventListener("visibilitychange", onVisibilityChange);
3016
- win?.removeEventListener("online", onNetworkBackOnline);
3017
- win?.removeEventListener("offline", onNetworkOffline);
3021
+ _optionalChain([root, 'optionalAccess', _46 => _46.removeEventListener, 'call', _47 => _47("visibilitychange", onVisibilityChange)]);
3022
+ _optionalChain([win, 'optionalAccess', _48 => _48.removeEventListener, 'call', _49 => _49("online", onNetworkBackOnline)]);
3023
+ _optionalChain([win, 'optionalAccess', _50 => _50.removeEventListener, 'call', _51 => _51("offline", onNetworkOffline)]);
3018
3024
  teardownSocket(ctx.socket);
3019
3025
  };
3020
3026
  });
@@ -3042,7 +3048,7 @@ function createConnectionStateMachine(delegates, options) {
3042
3048
  var ManagedSocket = class {
3043
3049
  #machine;
3044
3050
  #cleanups;
3045
- events;
3051
+
3046
3052
  constructor(delegates, enableDebugLogging = false, waitForActorId = true) {
3047
3053
  const { machine, events, cleanups } = createConnectionStateMachine(
3048
3054
  delegates,
@@ -3055,7 +3061,7 @@ var ManagedSocket = class {
3055
3061
  getStatus() {
3056
3062
  try {
3057
3063
  return toNewConnectionStatus(this.#machine);
3058
- } catch {
3064
+ } catch (e5) {
3059
3065
  return "initial";
3060
3066
  }
3061
3067
  }
@@ -3103,7 +3109,7 @@ var ManagedSocket = class {
3103
3109
  * message if this is somehow impossible.
3104
3110
  */
3105
3111
  send(data) {
3106
- const socket = this.#machine.context?.socket;
3112
+ const socket = _optionalChain([this, 'access', _52 => _52.#machine, 'access', _53 => _53.context, 'optionalAccess', _54 => _54.socket]);
3107
3113
  if (socket === null) {
3108
3114
  warn("Cannot send: not connected yet", data);
3109
3115
  } else if (socket.readyState !== 1) {
@@ -3207,7 +3213,7 @@ function createAuthManager(authOptions, onAuthenticate) {
3207
3213
  return void 0;
3208
3214
  }
3209
3215
  async function makeAuthRequest(options) {
3210
- const fetcher = authOptions.polyfills?.fetch ?? (typeof window === "undefined" ? void 0 : window.fetch);
3216
+ const fetcher = _nullishCoalesce(_optionalChain([authOptions, 'access', _55 => _55.polyfills, 'optionalAccess', _56 => _56.fetch]), () => ( (typeof window === "undefined" ? void 0 : window.fetch)));
3211
3217
  if (authentication.type === "private") {
3212
3218
  if (fetcher === void 0) {
3213
3219
  throw new StopRetrying(
@@ -3223,7 +3229,7 @@ function createAuthManager(authOptions, onAuthenticate) {
3223
3229
  "The same Liveblocks auth token was issued from the backend before. Caching Liveblocks tokens is not supported."
3224
3230
  );
3225
3231
  }
3226
- onAuthenticate?.(parsed.parsed);
3232
+ _optionalChain([onAuthenticate, 'optionalCall', _57 => _57(parsed.parsed)]);
3227
3233
  return parsed;
3228
3234
  }
3229
3235
  if (authentication.type === "custom") {
@@ -3231,7 +3237,7 @@ function createAuthManager(authOptions, onAuthenticate) {
3231
3237
  if (response && typeof response === "object") {
3232
3238
  if (typeof response.token === "string") {
3233
3239
  const parsed = parseAuthToken(response.token);
3234
- onAuthenticate?.(parsed.parsed);
3240
+ _optionalChain([onAuthenticate, 'optionalCall', _58 => _58(parsed.parsed)]);
3235
3241
  return parsed;
3236
3242
  } else if (typeof response.error === "string") {
3237
3243
  const reason = `Authentication failed: ${"reason" in response && typeof response.reason === "string" ? response.reason : "Forbidden"}`;
@@ -3392,7 +3398,7 @@ function sendToPanel(message, options) {
3392
3398
  ...message,
3393
3399
  source: "liveblocks-devtools-client"
3394
3400
  };
3395
- if (!(options?.force || _bridgeActive)) {
3401
+ if (!(_optionalChain([options, 'optionalAccess', _59 => _59.force]) || _bridgeActive)) {
3396
3402
  return;
3397
3403
  }
3398
3404
  window.postMessage(fullMsg, "*");
@@ -3400,7 +3406,7 @@ function sendToPanel(message, options) {
3400
3406
  var eventSource = makeEventSource();
3401
3407
  if (process.env.NODE_ENV !== "production" && typeof window !== "undefined") {
3402
3408
  window.addEventListener("message", (event) => {
3403
- if (event.source === window && event.data?.source === "liveblocks-devtools-panel") {
3409
+ if (event.source === window && _optionalChain([event, 'access', _60 => _60.data, 'optionalAccess', _61 => _61.source]) === "liveblocks-devtools-panel") {
3404
3410
  eventSource.notify(event.data);
3405
3411
  } else {
3406
3412
  }
@@ -3444,7 +3450,7 @@ function setupDevTools(getAllRooms) {
3444
3450
  }
3445
3451
  var unsubsByRoomId = /* @__PURE__ */ new Map();
3446
3452
  function stopSyncStream(roomId) {
3447
- const unsubs = unsubsByRoomId.get(roomId) ?? [];
3453
+ const unsubs = _nullishCoalesce(unsubsByRoomId.get(roomId), () => ( []));
3448
3454
  unsubsByRoomId.delete(roomId);
3449
3455
  for (const unsub of unsubs) {
3450
3456
  unsub();
@@ -3542,7 +3548,7 @@ function fullSync(room) {
3542
3548
  msg: "room::sync::full",
3543
3549
  roomId: room.id,
3544
3550
  status: room.getStatus(),
3545
- storage: root?.toTreeNode("root").payload ?? null,
3551
+ storage: _nullishCoalesce(_optionalChain([root, 'optionalAccess', _62 => _62.toTreeNode, 'call', _63 => _63("root"), 'access', _64 => _64.payload]), () => ( null)),
3546
3552
  me,
3547
3553
  others
3548
3554
  });
@@ -3597,6 +3603,73 @@ function unlinkDevTools(roomId) {
3597
3603
  });
3598
3604
  }
3599
3605
 
3606
+ // src/protocol/UserNotificationSettings.ts
3607
+ var kPrivate = Symbol("user-notification-settings-private");
3608
+ function createUserNotificationSettings(plain) {
3609
+ const channels = [
3610
+ "email",
3611
+ "slack",
3612
+ "teams",
3613
+ "webPush"
3614
+ ];
3615
+ const descriptors = {
3616
+ [kPrivate]: {
3617
+ value: {
3618
+ __plain__: plain
3619
+ },
3620
+ enumerable: false
3621
+ }
3622
+ };
3623
+ for (const channel of channels) {
3624
+ descriptors[channel] = {
3625
+ enumerable: true,
3626
+ /**
3627
+ * In the TypeScript standard library definitions, the built-in interface for a property descriptor
3628
+ * does not include a specialized type for the “this” context in the getter or setter functions.
3629
+ * As a result, both the ⁠get and ⁠set methods implicitly have ⁠this: any.
3630
+ * The reason is that property descriptors in JavaScript are used across various objects with
3631
+ * no enforced shape for ⁠this. And so the standard library definitions have to remain as broad as possible
3632
+ * to support any valid JavaScript usage (e.g `Object.defineProperty`).
3633
+ *
3634
+ * So we can safely tells that this getter is typed as `this: UserNotificationSettings` because we're
3635
+ * creating a well known shaped object → `UserNotificationSettings`.
3636
+ */
3637
+ get() {
3638
+ const value = this[kPrivate].__plain__[channel];
3639
+ if (typeof value === "undefined") {
3640
+ error2(
3641
+ `In order to use the '${channel}' channel, please set up your project first. For more information https://liveblocks.io/docs/errors/enable-a-notification-channel`
3642
+ );
3643
+ return null;
3644
+ }
3645
+ return value;
3646
+ }
3647
+ };
3648
+ }
3649
+ return create(null, descriptors);
3650
+ }
3651
+ function patchUserNotificationSettings(existing, patch) {
3652
+ const outcoming = createUserNotificationSettings({
3653
+ ...existing[kPrivate].__plain__
3654
+ });
3655
+ for (const channel of keys(patch)) {
3656
+ const updates = patch[channel];
3657
+ if (updates !== void 0) {
3658
+ const kindUpdates = Object.fromEntries(
3659
+ entries(updates).filter(([, value]) => value !== void 0)
3660
+ );
3661
+ outcoming[kPrivate].__plain__[channel] = {
3662
+ ...outcoming[kPrivate].__plain__[channel],
3663
+ ...kindUpdates
3664
+ };
3665
+ }
3666
+ }
3667
+ return outcoming;
3668
+ }
3669
+ function isNotificationChannelEnabled(settings) {
3670
+ return settings !== null ? values(settings).every((enabled) => enabled === true) : false;
3671
+ }
3672
+
3600
3673
  // src/lib/position.ts
3601
3674
  var MIN_CODE = 32;
3602
3675
  var MAX_CODE = 126;
@@ -3966,7 +4039,7 @@ var LiveRegister = class _LiveRegister extends AbstractCrdt {
3966
4039
  return [
3967
4040
  {
3968
4041
  type: 8 /* CREATE_REGISTER */,
3969
- opId: pool?.generateOpId(),
4042
+ opId: _optionalChain([pool, 'optionalAccess', _65 => _65.generateOpId, 'call', _66 => _66()]),
3970
4043
  id: this._id,
3971
4044
  parentId,
3972
4045
  parentKey,
@@ -4002,7 +4075,7 @@ var LiveRegister = class _LiveRegister extends AbstractCrdt {
4002
4075
  _toTreeNode(key) {
4003
4076
  return {
4004
4077
  type: "Json",
4005
- id: this._id ?? nanoid(),
4078
+ id: _nullishCoalesce(this._id, () => ( nanoid())),
4006
4079
  key,
4007
4080
  payload: this.#data
4008
4081
  };
@@ -4072,7 +4145,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
4072
4145
  const ops = [];
4073
4146
  const op = {
4074
4147
  id: this._id,
4075
- opId: pool?.generateOpId(),
4148
+ opId: _optionalChain([pool, 'optionalAccess', _67 => _67.generateOpId, 'call', _68 => _68()]),
4076
4149
  type: 2 /* CREATE_LIST */,
4077
4150
  parentId,
4078
4151
  parentKey
@@ -4343,7 +4416,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
4343
4416
  #applyInsertUndoRedo(op) {
4344
4417
  const { id, parentKey: key } = op;
4345
4418
  const child = creationOpToLiveNode(op);
4346
- if (this._pool?.getNode(id) !== void 0) {
4419
+ if (_optionalChain([this, 'access', _69 => _69._pool, 'optionalAccess', _70 => _70.getNode, 'call', _71 => _71(id)]) !== void 0) {
4347
4420
  return { modified: false };
4348
4421
  }
4349
4422
  child._attach(id, nn(this._pool));
@@ -4351,8 +4424,8 @@ var LiveList = class _LiveList extends AbstractCrdt {
4351
4424
  const existingItemIndex = this._indexOfPosition(key);
4352
4425
  let newKey = key;
4353
4426
  if (existingItemIndex !== -1) {
4354
- const before2 = this.#items[existingItemIndex]?._parentPos;
4355
- const after2 = this.#items[existingItemIndex + 1]?._parentPos;
4427
+ const before2 = _optionalChain([this, 'access', _72 => _72.#items, 'access', _73 => _73[existingItemIndex], 'optionalAccess', _74 => _74._parentPos]);
4428
+ const after2 = _optionalChain([this, 'access', _75 => _75.#items, 'access', _76 => _76[existingItemIndex + 1], 'optionalAccess', _77 => _77._parentPos]);
4356
4429
  newKey = makePosition(before2, after2);
4357
4430
  child._setParentLink(this, newKey);
4358
4431
  }
@@ -4366,7 +4439,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
4366
4439
  #applySetUndoRedo(op) {
4367
4440
  const { id, parentKey: key } = op;
4368
4441
  const child = creationOpToLiveNode(op);
4369
- if (this._pool?.getNode(id) !== void 0) {
4442
+ if (_optionalChain([this, 'access', _78 => _78._pool, 'optionalAccess', _79 => _79.getNode, 'call', _80 => _80(id)]) !== void 0) {
4370
4443
  return { modified: false };
4371
4444
  }
4372
4445
  this.#unacknowledgedSets.set(key, nn(op.opId));
@@ -4487,7 +4560,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
4487
4560
  } else {
4488
4561
  this.#items[existingItemIndex]._setParentLink(
4489
4562
  this,
4490
- makePosition(newKey, this.#items[existingItemIndex + 1]?._parentPos)
4563
+ makePosition(newKey, _optionalChain([this, 'access', _81 => _81.#items, 'access', _82 => _82[existingItemIndex + 1], 'optionalAccess', _83 => _83._parentPos]))
4491
4564
  );
4492
4565
  const previousIndex = this.#items.indexOf(child);
4493
4566
  child._setParentLink(this, newKey);
@@ -4512,7 +4585,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
4512
4585
  if (existingItemIndex !== -1) {
4513
4586
  this.#items[existingItemIndex]._setParentLink(
4514
4587
  this,
4515
- makePosition(newKey, this.#items[existingItemIndex + 1]?._parentPos)
4588
+ makePosition(newKey, _optionalChain([this, 'access', _84 => _84.#items, 'access', _85 => _85[existingItemIndex + 1], 'optionalAccess', _86 => _86._parentPos]))
4516
4589
  );
4517
4590
  }
4518
4591
  child._setParentLink(this, newKey);
@@ -4531,7 +4604,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
4531
4604
  if (existingItemIndex !== -1) {
4532
4605
  this.#items[existingItemIndex]._setParentLink(
4533
4606
  this,
4534
- makePosition(newKey, this.#items[existingItemIndex + 1]?._parentPos)
4607
+ makePosition(newKey, _optionalChain([this, 'access', _87 => _87.#items, 'access', _88 => _88[existingItemIndex + 1], 'optionalAccess', _89 => _89._parentPos]))
4535
4608
  );
4536
4609
  }
4537
4610
  child._setParentLink(this, newKey);
@@ -4558,7 +4631,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
4558
4631
  if (existingItemIndex !== -1) {
4559
4632
  this.#items[existingItemIndex]._setParentLink(
4560
4633
  this,
4561
- makePosition(newKey, this.#items[existingItemIndex + 1]?._parentPos)
4634
+ makePosition(newKey, _optionalChain([this, 'access', _90 => _90.#items, 'access', _91 => _91[existingItemIndex + 1], 'optionalAccess', _92 => _92._parentPos]))
4562
4635
  );
4563
4636
  }
4564
4637
  child._setParentLink(this, newKey);
@@ -4616,7 +4689,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
4616
4689
  * @param element The element to add to the end of the LiveList.
4617
4690
  */
4618
4691
  push(element) {
4619
- this._pool?.assertStorageIsWritable();
4692
+ _optionalChain([this, 'access', _93 => _93._pool, 'optionalAccess', _94 => _94.assertStorageIsWritable, 'call', _95 => _95()]);
4620
4693
  return this.insert(element, this.length);
4621
4694
  }
4622
4695
  /**
@@ -4625,7 +4698,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
4625
4698
  * @param index The index at which you want to insert the element.
4626
4699
  */
4627
4700
  insert(element, index) {
4628
- this._pool?.assertStorageIsWritable();
4701
+ _optionalChain([this, 'access', _96 => _96._pool, 'optionalAccess', _97 => _97.assertStorageIsWritable, 'call', _98 => _98()]);
4629
4702
  if (index < 0 || index > this.#items.length) {
4630
4703
  throw new Error(
4631
4704
  `Cannot insert list item at index "${index}". index should be between 0 and ${this.#items.length}`
@@ -4655,7 +4728,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
4655
4728
  * @param targetIndex The index where the element should be after moving.
4656
4729
  */
4657
4730
  move(index, targetIndex) {
4658
- this._pool?.assertStorageIsWritable();
4731
+ _optionalChain([this, 'access', _99 => _99._pool, 'optionalAccess', _100 => _100.assertStorageIsWritable, 'call', _101 => _101()]);
4659
4732
  if (targetIndex < 0) {
4660
4733
  throw new Error("targetIndex cannot be less than 0");
4661
4734
  }
@@ -4713,7 +4786,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
4713
4786
  * @param index The index of the element to delete
4714
4787
  */
4715
4788
  delete(index) {
4716
- this._pool?.assertStorageIsWritable();
4789
+ _optionalChain([this, 'access', _102 => _102._pool, 'optionalAccess', _103 => _103.assertStorageIsWritable, 'call', _104 => _104()]);
4717
4790
  if (index < 0 || index >= this.#items.length) {
4718
4791
  throw new Error(
4719
4792
  `Cannot delete list item at index "${index}". index should be between 0 and ${this.#items.length - 1}`
@@ -4746,7 +4819,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
4746
4819
  }
4747
4820
  }
4748
4821
  clear() {
4749
- this._pool?.assertStorageIsWritable();
4822
+ _optionalChain([this, 'access', _105 => _105._pool, 'optionalAccess', _106 => _106.assertStorageIsWritable, 'call', _107 => _107()]);
4750
4823
  if (this._pool) {
4751
4824
  const ops = [];
4752
4825
  const reverseOps = [];
@@ -4780,7 +4853,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
4780
4853
  }
4781
4854
  }
4782
4855
  set(index, item) {
4783
- this._pool?.assertStorageIsWritable();
4856
+ _optionalChain([this, 'access', _108 => _108._pool, 'optionalAccess', _109 => _109.assertStorageIsWritable, 'call', _110 => _110()]);
4784
4857
  if (index < 0 || index >= this.#items.length) {
4785
4858
  throw new Error(
4786
4859
  `Cannot set list item at index "${index}". index should be between 0 and ${this.#items.length - 1}`
@@ -4926,7 +4999,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
4926
4999
  #shiftItemPosition(index, key) {
4927
5000
  const shiftedPosition = makePosition(
4928
5001
  key,
4929
- this.#items.length > index + 1 ? this.#items[index + 1]?._parentPos : void 0
5002
+ this.#items.length > index + 1 ? _optionalChain([this, 'access', _111 => _111.#items, 'access', _112 => _112[index + 1], 'optionalAccess', _113 => _113._parentPos]) : void 0
4930
5003
  );
4931
5004
  this.#items[index]._setParentLink(this, shiftedPosition);
4932
5005
  }
@@ -4934,7 +5007,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
4934
5007
  _toTreeNode(key) {
4935
5008
  return {
4936
5009
  type: "LiveList",
4937
- id: this._id ?? nanoid(),
5010
+ id: _nullishCoalesce(this._id, () => ( nanoid())),
4938
5011
  key,
4939
5012
  payload: this.#items.map(
4940
5013
  (item, index) => item.toTreeNode(index.toString())
@@ -5051,7 +5124,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
5051
5124
  const ops = [];
5052
5125
  const op = {
5053
5126
  id: this._id,
5054
- opId: pool?.generateOpId(),
5127
+ opId: _optionalChain([pool, 'optionalAccess', _114 => _114.generateOpId, 'call', _115 => _115()]),
5055
5128
  type: 7 /* CREATE_MAP */,
5056
5129
  parentId,
5057
5130
  parentKey
@@ -5186,7 +5259,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
5186
5259
  * @param value The value of the element to add. Should be serializable to JSON.
5187
5260
  */
5188
5261
  set(key, value) {
5189
- this._pool?.assertStorageIsWritable();
5262
+ _optionalChain([this, 'access', _116 => _116._pool, 'optionalAccess', _117 => _117.assertStorageIsWritable, 'call', _118 => _118()]);
5190
5263
  const oldValue = this.#map.get(key);
5191
5264
  if (oldValue) {
5192
5265
  oldValue._detach();
@@ -5232,7 +5305,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
5232
5305
  * @returns true if an element existed and has been removed, or false if the element does not exist.
5233
5306
  */
5234
5307
  delete(key) {
5235
- this._pool?.assertStorageIsWritable();
5308
+ _optionalChain([this, 'access', _119 => _119._pool, 'optionalAccess', _120 => _120.assertStorageIsWritable, 'call', _121 => _121()]);
5236
5309
  const item = this.#map.get(key);
5237
5310
  if (item === void 0) {
5238
5311
  return false;
@@ -5335,7 +5408,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
5335
5408
  _toTreeNode(key) {
5336
5409
  return {
5337
5410
  type: "LiveMap",
5338
- id: this._id ?? nanoid(),
5411
+ id: _nullishCoalesce(this._id, () => ( nanoid())),
5339
5412
  key,
5340
5413
  payload: Array.from(this.#map.entries()).map(
5341
5414
  ([key2, val]) => val.toTreeNode(key2)
@@ -5411,7 +5484,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
5411
5484
  if (this._id === void 0) {
5412
5485
  throw new Error("Cannot serialize item is not attached");
5413
5486
  }
5414
- const opId = pool?.generateOpId();
5487
+ const opId = _optionalChain([pool, 'optionalAccess', _122 => _122.generateOpId, 'call', _123 => _123()]);
5415
5488
  const ops = [];
5416
5489
  const op = {
5417
5490
  type: 4 /* CREATE_OBJECT */,
@@ -5683,7 +5756,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
5683
5756
  * @param value The value of the property to add
5684
5757
  */
5685
5758
  set(key, value) {
5686
- this._pool?.assertStorageIsWritable();
5759
+ _optionalChain([this, 'access', _124 => _124._pool, 'optionalAccess', _125 => _125.assertStorageIsWritable, 'call', _126 => _126()]);
5687
5760
  this.update({ [key]: value });
5688
5761
  }
5689
5762
  /**
@@ -5698,7 +5771,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
5698
5771
  * @param key The key of the property to delete
5699
5772
  */
5700
5773
  delete(key) {
5701
- this._pool?.assertStorageIsWritable();
5774
+ _optionalChain([this, 'access', _127 => _127._pool, 'optionalAccess', _128 => _128.assertStorageIsWritable, 'call', _129 => _129()]);
5702
5775
  const keyAsString = key;
5703
5776
  const oldValue = this.#map.get(keyAsString);
5704
5777
  if (oldValue === void 0) {
@@ -5751,7 +5824,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
5751
5824
  * @param patch The object used to overrides properties
5752
5825
  */
5753
5826
  update(patch) {
5754
- this._pool?.assertStorageIsWritable();
5827
+ _optionalChain([this, 'access', _130 => _130._pool, 'optionalAccess', _131 => _131.assertStorageIsWritable, 'call', _132 => _132()]);
5755
5828
  if (this._pool === void 0 || this._id === void 0) {
5756
5829
  for (const key in patch) {
5757
5830
  const newValue = patch[key];
@@ -5841,7 +5914,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
5841
5914
  }
5842
5915
  /** @internal */
5843
5916
  _toTreeNode(key) {
5844
- const nodeId = this._id ?? nanoid();
5917
+ const nodeId = _nullishCoalesce(this._id, () => ( nanoid()));
5845
5918
  return {
5846
5919
  type: "LiveObject",
5847
5920
  id: nodeId,
@@ -6237,7 +6310,7 @@ var ManagedOthers = class {
6237
6310
  #internal;
6238
6311
  #userCache;
6239
6312
  // The "clean" signal that is exposed to the outside world
6240
- signal;
6313
+
6241
6314
  constructor() {
6242
6315
  this.#internal = new MutableSignal({
6243
6316
  connections: /* @__PURE__ */ new Map(),
@@ -6359,7 +6432,7 @@ var ManagedOthers = class {
6359
6432
 
6360
6433
  // src/types/LiveblocksError.ts
6361
6434
  var LiveblocksError = class _LiveblocksError extends Error {
6362
- context;
6435
+
6363
6436
  constructor(message, context, cause) {
6364
6437
  super(message, { cause });
6365
6438
  this.context = context;
@@ -6460,15 +6533,15 @@ function installBackgroundTabSpy() {
6460
6533
  const doc = typeof document !== "undefined" ? document : void 0;
6461
6534
  const inBackgroundSince = { current: null };
6462
6535
  function onVisibilityChange() {
6463
- if (doc?.visibilityState === "hidden") {
6464
- inBackgroundSince.current = inBackgroundSince.current ?? Date.now();
6536
+ if (_optionalChain([doc, 'optionalAccess', _133 => _133.visibilityState]) === "hidden") {
6537
+ inBackgroundSince.current = _nullishCoalesce(inBackgroundSince.current, () => ( Date.now()));
6465
6538
  } else {
6466
6539
  inBackgroundSince.current = null;
6467
6540
  }
6468
6541
  }
6469
- doc?.addEventListener("visibilitychange", onVisibilityChange);
6542
+ _optionalChain([doc, 'optionalAccess', _134 => _134.addEventListener, 'call', _135 => _135("visibilitychange", onVisibilityChange)]);
6470
6543
  const unsub = () => {
6471
- doc?.removeEventListener("visibilitychange", onVisibilityChange);
6544
+ _optionalChain([doc, 'optionalAccess', _136 => _136.removeEventListener, 'call', _137 => _137("visibilitychange", onVisibilityChange)]);
6472
6545
  };
6473
6546
  return [inBackgroundSince, unsub];
6474
6547
  }
@@ -6653,7 +6726,7 @@ function createRoom(options, config) {
6653
6726
  }
6654
6727
  },
6655
6728
  assertStorageIsWritable: () => {
6656
- const scopes = context.dynamicSessionInfoSig.get()?.scopes;
6729
+ const scopes = _optionalChain([context, 'access', _138 => _138.dynamicSessionInfoSig, 'access', _139 => _139.get, 'call', _140 => _140(), 'optionalAccess', _141 => _141.scopes]);
6657
6730
  if (scopes === void 0) {
6658
6731
  return;
6659
6732
  }
@@ -6761,7 +6834,7 @@ function createRoom(options, config) {
6761
6834
  return new TextEncoder().encode(text).length >= MAX_SOCKET_MESSAGE_SIZE;
6762
6835
  }
6763
6836
  function sendMessages(messages) {
6764
- const strategy = config.largeMessageStrategy ?? "default";
6837
+ const strategy = _nullishCoalesce(config.largeMessageStrategy, () => ( "default"));
6765
6838
  const text = stringifyOrLog(messages);
6766
6839
  if (!isTooBigForWebSocket(text)) {
6767
6840
  return managedSocket.send(text);
@@ -6780,7 +6853,7 @@ function createRoom(options, config) {
6780
6853
  }
6781
6854
  case "experimental-fallback-to-http": {
6782
6855
  warn("Message is too large for websockets, so sending over HTTP instead");
6783
- const nonce = context.dynamicSessionInfoSig.get()?.nonce ?? raise("Session is not authorized to send message over HTTP");
6856
+ const nonce = _nullishCoalesce(_optionalChain([context, 'access', _142 => _142.dynamicSessionInfoSig, 'access', _143 => _143.get, 'call', _144 => _144(), 'optionalAccess', _145 => _145.nonce]), () => ( raise("Session is not authorized to send message over HTTP")));
6784
6857
  void httpClient.sendMessages({ roomId, nonce, messages }).then((resp) => {
6785
6858
  if (!resp.ok && resp.status === 403) {
6786
6859
  managedSocket.reconnect();
@@ -6831,7 +6904,7 @@ function createRoom(options, config) {
6831
6904
  } else {
6832
6905
  context.root = LiveObject._fromItems(message.items, pool);
6833
6906
  }
6834
- const canWrite = self.get()?.canWrite ?? true;
6907
+ const canWrite = _nullishCoalesce(_optionalChain([self, 'access', _146 => _146.get, 'call', _147 => _147(), 'optionalAccess', _148 => _148.canWrite]), () => ( true));
6835
6908
  const stackSizeBefore = context.undoStack.length;
6836
6909
  for (const key in context.initialStorage) {
6837
6910
  if (context.root.get(key) === void 0) {
@@ -6881,7 +6954,7 @@ function createRoom(options, config) {
6881
6954
  eventHub.others.notify({ ...event, others });
6882
6955
  }
6883
6956
  }
6884
- if (updates.presence ?? false) {
6957
+ if (_nullishCoalesce(updates.presence, () => ( false))) {
6885
6958
  notifySelfChanged();
6886
6959
  eventHub.myPresence.notify(context.myPresence.get());
6887
6960
  }
@@ -7034,7 +7107,7 @@ function createRoom(options, config) {
7034
7107
  }
7035
7108
  context.myPresence.patch(patch);
7036
7109
  if (context.activeBatch) {
7037
- if (options2?.addToHistory) {
7110
+ if (_optionalChain([options2, 'optionalAccess', _149 => _149.addToHistory])) {
7038
7111
  context.activeBatch.reverseOps.pushLeft({
7039
7112
  type: "presence",
7040
7113
  data: oldValues
@@ -7043,7 +7116,7 @@ function createRoom(options, config) {
7043
7116
  context.activeBatch.updates.presence = true;
7044
7117
  } else {
7045
7118
  flushNowOrSoon();
7046
- if (options2?.addToHistory) {
7119
+ if (_optionalChain([options2, 'optionalAccess', _150 => _150.addToHistory])) {
7047
7120
  addToUndoStack([{ type: "presence", data: oldValues }]);
7048
7121
  }
7049
7122
  notify({ presence: true });
@@ -7192,7 +7265,7 @@ function createRoom(options, config) {
7192
7265
  const others = context.others.get();
7193
7266
  eventHub.customEvent.notify({
7194
7267
  connectionId: message.actor,
7195
- user: message.actor < 0 ? null : others.find((u) => u.connectionId === message.actor) ?? null,
7268
+ user: message.actor < 0 ? null : _nullishCoalesce(others.find((u) => u.connectionId === message.actor), () => ( null)),
7196
7269
  event: message.event
7197
7270
  });
7198
7271
  break;
@@ -7240,7 +7313,7 @@ function createRoom(options, config) {
7240
7313
  if (process.env.NODE_ENV !== "production") {
7241
7314
  const traces = /* @__PURE__ */ new Set();
7242
7315
  for (const opId of message.opIds) {
7243
- const trace = context.opStackTraces?.get(opId);
7316
+ const trace = _optionalChain([context, 'access', _151 => _151.opStackTraces, 'optionalAccess', _152 => _152.get, 'call', _153 => _153(opId)]);
7244
7317
  if (trace) {
7245
7318
  traces.add(trace);
7246
7319
  }
@@ -7374,7 +7447,7 @@ ${Array.from(traces).join("\n\n")}`
7374
7447
  const unacknowledgedOps = new Map(context.unacknowledgedOps);
7375
7448
  createOrUpdateRootFromMessage(message);
7376
7449
  applyAndSendOps(unacknowledgedOps);
7377
- _resolveStoragePromise?.();
7450
+ _optionalChain([_resolveStoragePromise, 'optionalCall', _154 => _154()]);
7378
7451
  notifyStorageStatus();
7379
7452
  eventHub.storageDidLoad.notify();
7380
7453
  }
@@ -7597,8 +7670,8 @@ ${Array.from(traces).join("\n\n")}`
7597
7670
  async function getThreads(options2) {
7598
7671
  return httpClient.getThreads({
7599
7672
  roomId,
7600
- query: options2?.query,
7601
- cursor: options2?.cursor
7673
+ query: _optionalChain([options2, 'optionalAccess', _155 => _155.query]),
7674
+ cursor: _optionalChain([options2, 'optionalAccess', _156 => _156.cursor])
7602
7675
  });
7603
7676
  }
7604
7677
  async function getThread(threadId) {
@@ -7699,7 +7772,7 @@ ${Array.from(traces).join("\n\n")}`
7699
7772
  function getNotificationSettings(options2) {
7700
7773
  return httpClient.getNotificationSettings({
7701
7774
  roomId,
7702
- signal: options2?.signal
7775
+ signal: _optionalChain([options2, 'optionalAccess', _157 => _157.signal])
7703
7776
  });
7704
7777
  }
7705
7778
  function updateNotificationSettings(settings) {
@@ -7721,7 +7794,7 @@ ${Array.from(traces).join("\n\n")}`
7721
7794
  {
7722
7795
  [kInternal]: {
7723
7796
  get presenceBuffer() {
7724
- return deepClone(context.buffer.presenceUpdates?.data ?? null);
7797
+ return deepClone(_nullishCoalesce(_optionalChain([context, 'access', _158 => _158.buffer, 'access', _159 => _159.presenceUpdates, 'optionalAccess', _160 => _160.data]), () => ( null)));
7725
7798
  },
7726
7799
  // prettier-ignore
7727
7800
  get undoStack() {
@@ -7736,9 +7809,9 @@ ${Array.from(traces).join("\n\n")}`
7736
7809
  return context.yjsProvider;
7737
7810
  },
7738
7811
  setYjsProvider(newProvider) {
7739
- context.yjsProvider?.off("status", yjsStatusDidChange);
7812
+ _optionalChain([context, 'access', _161 => _161.yjsProvider, 'optionalAccess', _162 => _162.off, 'call', _163 => _163("status", yjsStatusDidChange)]);
7740
7813
  context.yjsProvider = newProvider;
7741
- newProvider?.on("status", yjsStatusDidChange);
7814
+ _optionalChain([newProvider, 'optionalAccess', _164 => _164.on, 'call', _165 => _165("status", yjsStatusDidChange)]);
7742
7815
  context.yjsProviderDidChange.notify();
7743
7816
  },
7744
7817
  yjsProviderDidChange: context.yjsProviderDidChange.observable,
@@ -7784,7 +7857,7 @@ ${Array.from(traces).join("\n\n")}`
7784
7857
  source[Symbol.dispose]();
7785
7858
  }
7786
7859
  eventHub.roomWillDestroy.notify();
7787
- context.yjsProvider?.off("status", yjsStatusDidChange);
7860
+ _optionalChain([context, 'access', _166 => _166.yjsProvider, 'optionalAccess', _167 => _167.off, 'call', _168 => _168("status", yjsStatusDidChange)]);
7788
7861
  syncSourceForStorage.destroy();
7789
7862
  syncSourceForYjs.destroy();
7790
7863
  uninstallBgTabSpy();
@@ -7930,7 +8003,7 @@ function makeClassicSubscribeFn(roomId, events, errorEvents) {
7930
8003
  }
7931
8004
  if (isLiveNode(first)) {
7932
8005
  const node = first;
7933
- if (options?.isDeep) {
8006
+ if (_optionalChain([options, 'optionalAccess', _169 => _169.isDeep])) {
7934
8007
  const storageCallback = second;
7935
8008
  return subscribeToLiveStructureDeeply(node, storageCallback);
7936
8009
  } else {
@@ -7954,7 +8027,7 @@ function makeAuthDelegateForRoom(roomId, authManager) {
7954
8027
  }
7955
8028
  function makeCreateSocketDelegateForRoom(roomId, baseUrl, WebSocketPolyfill) {
7956
8029
  return (authValue) => {
7957
- const ws = WebSocketPolyfill ?? (typeof WebSocket === "undefined" ? void 0 : WebSocket);
8030
+ const ws = _nullishCoalesce(WebSocketPolyfill, () => ( (typeof WebSocket === "undefined" ? void 0 : WebSocket)));
7958
8031
  if (ws === void 0) {
7959
8032
  throw new StopRetrying(
7960
8033
  "To use Liveblocks client in a non-DOM environment, you need to provide a WebSocket polyfill."
@@ -7996,9 +8069,9 @@ function getBaseUrl(baseUrl) {
7996
8069
  }
7997
8070
  function createClient(options) {
7998
8071
  const clientOptions = options;
7999
- const throttleDelay = getThrottle(clientOptions.throttle ?? DEFAULT_THROTTLE);
8072
+ const throttleDelay = getThrottle(_nullishCoalesce(clientOptions.throttle, () => ( DEFAULT_THROTTLE)));
8000
8073
  const lostConnectionTimeout = getLostConnectionTimeout(
8001
- clientOptions.lostConnectionTimeout ?? DEFAULT_LOST_CONNECTION_TIMEOUT
8074
+ _nullishCoalesce(clientOptions.lostConnectionTimeout, () => ( DEFAULT_LOST_CONNECTION_TIMEOUT))
8002
8075
  );
8003
8076
  const backgroundKeepAliveTimeout = getBackgroundKeepAliveTimeout(
8004
8077
  clientOptions.backgroundKeepAliveTimeout
@@ -8009,8 +8082,8 @@ function createClient(options) {
8009
8082
  const userId = token.k === "sec-legacy" /* SECRET_LEGACY */ ? token.id : token.uid;
8010
8083
  currentUserId.set(() => userId);
8011
8084
  });
8012
- const fetchPolyfill = clientOptions.polyfills?.fetch || /* istanbul ignore next */
8013
- globalThis.fetch?.bind(globalThis);
8085
+ const fetchPolyfill = _optionalChain([clientOptions, 'access', _170 => _170.polyfills, 'optionalAccess', _171 => _171.fetch]) || /* istanbul ignore next */
8086
+ _optionalChain([globalThis, 'access', _172 => _172.fetch, 'optionalAccess', _173 => _173.bind, 'call', _174 => _174(globalThis)]);
8014
8087
  const httpClient = createApiClient({
8015
8088
  baseUrl,
8016
8089
  fetchPolyfill,
@@ -8046,9 +8119,9 @@ function createClient(options) {
8046
8119
  if (existing !== void 0) {
8047
8120
  return leaseRoom(existing);
8048
8121
  }
8049
- const options2 = args[0] ?? {};
8050
- const initialPresence = (typeof options2.initialPresence === "function" ? options2.initialPresence(roomId) : options2.initialPresence) ?? {};
8051
- const initialStorage = (typeof options2.initialStorage === "function" ? options2.initialStorage(roomId) : options2.initialStorage) ?? {};
8122
+ const options2 = _nullishCoalesce(args[0], () => ( {}));
8123
+ const initialPresence = _nullishCoalesce((typeof options2.initialPresence === "function" ? options2.initialPresence(roomId) : options2.initialPresence), () => ( {}));
8124
+ const initialStorage = _nullishCoalesce((typeof options2.initialStorage === "function" ? options2.initialStorage(roomId) : options2.initialStorage), () => ( {}));
8052
8125
  const newRoom = createRoom(
8053
8126
  { initialPresence, initialStorage },
8054
8127
  {
@@ -8057,18 +8130,18 @@ function createClient(options) {
8057
8130
  lostConnectionTimeout,
8058
8131
  backgroundKeepAliveTimeout,
8059
8132
  polyfills: clientOptions.polyfills,
8060
- delegates: clientOptions.mockedDelegates ?? {
8133
+ delegates: _nullishCoalesce(clientOptions.mockedDelegates, () => ( {
8061
8134
  createSocket: makeCreateSocketDelegateForRoom(
8062
8135
  roomId,
8063
8136
  baseUrl,
8064
- clientOptions.polyfills?.WebSocket
8137
+ _optionalChain([clientOptions, 'access', _175 => _175.polyfills, 'optionalAccess', _176 => _176.WebSocket])
8065
8138
  ),
8066
8139
  authenticate: makeAuthDelegateForRoom(roomId, authManager)
8067
- },
8140
+ })),
8068
8141
  enableDebugLogging: clientOptions.enableDebugLogging,
8069
8142
  baseUrl,
8070
8143
  errorEventSource: liveblocksErrorSource,
8071
- largeMessageStrategy: clientOptions.largeMessageStrategy ?? (clientOptions.unstable_fallbackToHTTP ? "experimental-fallback-to-http" : void 0),
8144
+ largeMessageStrategy: _nullishCoalesce(clientOptions.largeMessageStrategy, () => ( (clientOptions.unstable_fallbackToHTTP ? "experimental-fallback-to-http" : void 0))),
8072
8145
  unstable_streamData: !!clientOptions.unstable_streamData,
8073
8146
  roomHttpClient: httpClient,
8074
8147
  createSyncSource
@@ -8081,10 +8154,10 @@ function createClient(options) {
8081
8154
  roomsById.set(roomId, newRoomDetails);
8082
8155
  setupDevTools(() => Array.from(roomsById.keys()));
8083
8156
  linkDevTools(roomId, newRoom);
8084
- const shouldConnect = options2.autoConnect ?? true;
8157
+ const shouldConnect = _nullishCoalesce(options2.autoConnect, () => ( true));
8085
8158
  if (shouldConnect) {
8086
8159
  if (typeof atob === "undefined") {
8087
- if (clientOptions.polyfills?.atob === void 0) {
8160
+ if (_optionalChain([clientOptions, 'access', _177 => _177.polyfills, 'optionalAccess', _178 => _178.atob]) === void 0) {
8088
8161
  throw new Error(
8089
8162
  "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"
8090
8163
  );
@@ -8096,7 +8169,7 @@ function createClient(options) {
8096
8169
  return leaseRoom(newRoomDetails);
8097
8170
  }
8098
8171
  function getRoom(roomId) {
8099
- const room = roomsById.get(roomId)?.room;
8172
+ const room = _optionalChain([roomsById, 'access', _179 => _179.get, 'call', _180 => _180(roomId), 'optionalAccess', _181 => _181.room]);
8100
8173
  return room ? room : null;
8101
8174
  }
8102
8175
  function logout() {
@@ -8116,9 +8189,9 @@ function createClient(options) {
8116
8189
  const batchedResolveUsers = new Batch(
8117
8190
  async (batchedUserIds) => {
8118
8191
  const userIds = batchedUserIds.flat();
8119
- const users = await resolveUsers?.({ userIds });
8192
+ const users = await _optionalChain([resolveUsers, 'optionalCall', _182 => _182({ userIds })]);
8120
8193
  warnIfNoResolveUsers();
8121
- return users ?? userIds.map(() => void 0);
8194
+ return _nullishCoalesce(users, () => ( userIds.map(() => void 0)));
8122
8195
  },
8123
8196
  { delay: RESOLVE_USERS_BATCH_DELAY }
8124
8197
  );
@@ -8134,9 +8207,9 @@ function createClient(options) {
8134
8207
  const batchedResolveRoomsInfo = new Batch(
8135
8208
  async (batchedRoomIds) => {
8136
8209
  const roomIds = batchedRoomIds.flat();
8137
- const roomsInfo = await resolveRoomsInfo?.({ roomIds });
8210
+ const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall', _183 => _183({ roomIds })]);
8138
8211
  warnIfNoResolveRoomsInfo();
8139
- return roomsInfo ?? roomIds.map(() => void 0);
8212
+ return _nullishCoalesce(roomsInfo, () => ( roomIds.map(() => void 0)));
8140
8213
  },
8141
8214
  { delay: RESOLVE_ROOMS_INFO_BATCH_DELAY }
8142
8215
  );
@@ -8187,7 +8260,17 @@ function createClient(options) {
8187
8260
  }
8188
8261
  };
8189
8262
  const win = typeof window !== "undefined" ? window : void 0;
8190
- win?.addEventListener("beforeunload", maybePreventClose);
8263
+ _optionalChain([win, 'optionalAccess', _184 => _184.addEventListener, 'call', _185 => _185("beforeunload", maybePreventClose)]);
8264
+ }
8265
+ async function getNotificationSettings(options2) {
8266
+ const plainSettings = await httpClient.getUserNotificationSettings(options2);
8267
+ const settings = createUserNotificationSettings(plainSettings);
8268
+ return settings;
8269
+ }
8270
+ async function updateNotificationSettings(settings) {
8271
+ const plainSettings = await httpClient.updateUserNotificationSettings(settings);
8272
+ const settingsObject = createUserNotificationSettings(plainSettings);
8273
+ return settingsObject;
8191
8274
  }
8192
8275
  const client = Object.defineProperty(
8193
8276
  {
@@ -8202,9 +8285,9 @@ function createClient(options) {
8202
8285
  markInboxNotificationAsRead: httpClient.markInboxNotificationAsRead,
8203
8286
  deleteAllInboxNotifications: httpClient.deleteAllInboxNotifications,
8204
8287
  deleteInboxNotification: httpClient.deleteInboxNotification,
8205
- // Public channel notification settings API
8206
- getNotificationSettings: httpClient.getUserNotificationSettings,
8207
- updateNotificationSettings: httpClient.updateUserNotificationSettings,
8288
+ // Public user notification settings API
8289
+ getNotificationSettings,
8290
+ updateNotificationSettings,
8208
8291
  // Advanced resolvers APIs
8209
8292
  resolvers: {
8210
8293
  invalidateUsers: invalidateResolvedUsers,
@@ -8249,7 +8332,7 @@ function createClient(options) {
8249
8332
  function checkBounds(option, value, min, max, recommendedMin) {
8250
8333
  if (typeof value !== "number" || value < min || max !== void 0 && value > max) {
8251
8334
  throw new Error(
8252
- max !== void 0 ? `${option} should be between ${recommendedMin ?? min} and ${max}.` : `${option} should be at least ${recommendedMin ?? min}.`
8335
+ max !== void 0 ? `${option} should be between ${_nullishCoalesce(recommendedMin, () => ( min))} and ${max}.` : `${option} should be at least ${_nullishCoalesce(recommendedMin, () => ( min))}.`
8253
8336
  );
8254
8337
  }
8255
8338
  return value;
@@ -8315,7 +8398,7 @@ var commentBodyElementsTypes = {
8315
8398
  mention: "inline"
8316
8399
  };
8317
8400
  function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
8318
- if (!body || !body?.content) {
8401
+ if (!body || !_optionalChain([body, 'optionalAccess', _186 => _186.content])) {
8319
8402
  return;
8320
8403
  }
8321
8404
  const element = typeof elementOrVisitor === "string" ? elementOrVisitor : void 0;
@@ -8325,13 +8408,13 @@ function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
8325
8408
  for (const block of body.content) {
8326
8409
  if (type === "all" || type === "block") {
8327
8410
  if (guard(block)) {
8328
- visitor?.(block);
8411
+ _optionalChain([visitor, 'optionalCall', _187 => _187(block)]);
8329
8412
  }
8330
8413
  }
8331
8414
  if (type === "all" || type === "inline") {
8332
8415
  for (const inline of block.children) {
8333
8416
  if (guard(inline)) {
8334
- visitor?.(inline);
8417
+ _optionalChain([visitor, 'optionalCall', _188 => _188(inline)]);
8335
8418
  }
8336
8419
  }
8337
8420
  }
@@ -8356,7 +8439,7 @@ async function resolveUsersInCommentBody(body, resolveUsers) {
8356
8439
  userIds
8357
8440
  });
8358
8441
  for (const [index, userId] of userIds.entries()) {
8359
- const user = users?.[index];
8442
+ const user = _optionalChain([users, 'optionalAccess', _189 => _189[index]]);
8360
8443
  if (user) {
8361
8444
  resolvedUsers.set(userId, user);
8362
8445
  }
@@ -8481,9 +8564,9 @@ function toAbsoluteUrl(url2) {
8481
8564
  var stringifyCommentBodyPlainElements = {
8482
8565
  paragraph: ({ children }) => children,
8483
8566
  text: ({ element }) => element.text,
8484
- link: ({ element }) => element.text ?? element.url,
8567
+ link: ({ element }) => _nullishCoalesce(element.text, () => ( element.url)),
8485
8568
  mention: ({ element, user }) => {
8486
- return `@${user?.name ?? element.id}`;
8569
+ return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _190 => _190.name]), () => ( element.id))}`;
8487
8570
  }
8488
8571
  };
8489
8572
  var stringifyCommentBodyHtmlElements = {
@@ -8513,7 +8596,7 @@ var stringifyCommentBodyHtmlElements = {
8513
8596
  return html`<a href="${href}" target="_blank" rel="noopener noreferrer">${element.text ? html`${element.text}` : element.url}</a>`;
8514
8597
  },
8515
8598
  mention: ({ element, user }) => {
8516
- return html`<span data-mention>@${user?.name ? html`${user?.name}` : element.id}</span>`;
8599
+ return html`<span data-mention>@${_optionalChain([user, 'optionalAccess', _191 => _191.name]) ? html`${_optionalChain([user, 'optionalAccess', _192 => _192.name])}` : element.id}</span>`;
8517
8600
  }
8518
8601
  };
8519
8602
  var stringifyCommentBodyMarkdownElements = {
@@ -8540,22 +8623,22 @@ var stringifyCommentBodyMarkdownElements = {
8540
8623
  return children;
8541
8624
  },
8542
8625
  link: ({ element, href }) => {
8543
- return markdown`[${element.text ?? element.url}](${href})`;
8626
+ return markdown`[${_nullishCoalesce(element.text, () => ( element.url))}](${href})`;
8544
8627
  },
8545
8628
  mention: ({ element, user }) => {
8546
- return markdown`@${user?.name ?? element.id}`;
8629
+ return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _193 => _193.name]), () => ( element.id))}`;
8547
8630
  }
8548
8631
  };
8549
8632
  async function stringifyCommentBody(body, options) {
8550
- const format = options?.format ?? "plain";
8551
- const separator = options?.separator ?? (format === "markdown" ? "\n\n" : "\n");
8633
+ const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _194 => _194.format]), () => ( "plain"));
8634
+ const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _195 => _195.separator]), () => ( (format === "markdown" ? "\n\n" : "\n")));
8552
8635
  const elements = {
8553
8636
  ...format === "html" ? stringifyCommentBodyHtmlElements : format === "markdown" ? stringifyCommentBodyMarkdownElements : stringifyCommentBodyPlainElements,
8554
- ...options?.elements
8637
+ ..._optionalChain([options, 'optionalAccess', _196 => _196.elements])
8555
8638
  };
8556
8639
  const resolvedUsers = await resolveUsersInCommentBody(
8557
8640
  body,
8558
- options?.resolveUsers
8641
+ _optionalChain([options, 'optionalAccess', _197 => _197.resolveUsers])
8559
8642
  );
8560
8643
  const blocks = body.content.flatMap((block, blockIndex) => {
8561
8644
  switch (block.type) {
@@ -8577,7 +8660,7 @@ async function stringifyCommentBody(body, options) {
8577
8660
  elements.link(
8578
8661
  {
8579
8662
  element: inline,
8580
- href: toAbsoluteUrl(inline.url) ?? inline.url
8663
+ href: _nullishCoalesce(toAbsoluteUrl(inline.url), () => ( inline.url))
8581
8664
  },
8582
8665
  inlineIndex
8583
8666
  )
@@ -8846,12 +8929,12 @@ function legacy_patchImmutableNode(state, path, update) {
8846
8929
  }
8847
8930
  const newState = Object.assign({}, state);
8848
8931
  for (const key in update.updates) {
8849
- if (update.updates[key]?.type === "update") {
8932
+ if (_optionalChain([update, 'access', _198 => _198.updates, 'access', _199 => _199[key], 'optionalAccess', _200 => _200.type]) === "update") {
8850
8933
  const val = update.node.get(key);
8851
8934
  if (val !== void 0) {
8852
8935
  newState[key] = lsonToJson(val);
8853
8936
  }
8854
- } else if (update.updates[key]?.type === "delete") {
8937
+ } else if (_optionalChain([update, 'access', _201 => _201.updates, 'access', _202 => _202[key], 'optionalAccess', _203 => _203.type]) === "delete") {
8855
8938
  delete newState[key];
8856
8939
  }
8857
8940
  }
@@ -8912,12 +8995,12 @@ function legacy_patchImmutableNode(state, path, update) {
8912
8995
  }
8913
8996
  const newState = Object.assign({}, state);
8914
8997
  for (const key in update.updates) {
8915
- if (update.updates[key]?.type === "update") {
8998
+ if (_optionalChain([update, 'access', _204 => _204.updates, 'access', _205 => _205[key], 'optionalAccess', _206 => _206.type]) === "update") {
8916
8999
  const value = update.node.get(key);
8917
9000
  if (value !== void 0) {
8918
9001
  newState[key] = lsonToJson(value);
8919
9002
  }
8920
- } else if (update.updates[key]?.type === "delete") {
9003
+ } else if (_optionalChain([update, 'access', _207 => _207.updates, 'access', _208 => _208[key], 'optionalAccess', _209 => _209.type]) === "delete") {
8921
9004
  delete newState[key];
8922
9005
  }
8923
9006
  }
@@ -8988,9 +9071,9 @@ function makePoller(callback, intervalMs, options) {
8988
9071
  const startTime = performance.now();
8989
9072
  const doc = typeof document !== "undefined" ? document : void 0;
8990
9073
  const win = typeof window !== "undefined" ? window : void 0;
8991
- const maxStaleTimeMs = options?.maxStaleTimeMs ?? Number.POSITIVE_INFINITY;
9074
+ const maxStaleTimeMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _210 => _210.maxStaleTimeMs]), () => ( Number.POSITIVE_INFINITY));
8992
9075
  const context = {
8993
- inForeground: doc?.visibilityState !== "hidden",
9076
+ inForeground: _optionalChain([doc, 'optionalAccess', _211 => _211.visibilityState]) !== "hidden",
8994
9077
  lastSuccessfulPollAt: startTime,
8995
9078
  count: 0,
8996
9079
  backoff: 0
@@ -9032,7 +9115,7 @@ function makePoller(callback, intervalMs, options) {
9032
9115
  return {
9033
9116
  target: mayPoll() ? "@enabled" : "@idle",
9034
9117
  effect: () => {
9035
- context.backoff = BACKOFF_DELAYS2.find((delay) => delay > context.backoff) ?? BACKOFF_DELAYS2[BACKOFF_DELAYS2.length - 1];
9118
+ context.backoff = _nullishCoalesce(BACKOFF_DELAYS2.find((delay) => delay > context.backoff), () => ( BACKOFF_DELAYS2[BACKOFF_DELAYS2.length - 1]));
9036
9119
  }
9037
9120
  };
9038
9121
  },
@@ -9068,11 +9151,11 @@ function makePoller(callback, intervalMs, options) {
9068
9151
  pollNowIfStale();
9069
9152
  }
9070
9153
  function onVisibilityChange() {
9071
- setInForeground(doc?.visibilityState !== "hidden");
9154
+ setInForeground(_optionalChain([doc, 'optionalAccess', _212 => _212.visibilityState]) !== "hidden");
9072
9155
  }
9073
- doc?.addEventListener("visibilitychange", onVisibilityChange);
9074
- win?.addEventListener("online", onVisibilityChange);
9075
- win?.addEventListener("focus", pollNowIfStale);
9156
+ _optionalChain([doc, 'optionalAccess', _213 => _213.addEventListener, 'call', _214 => _214("visibilitychange", onVisibilityChange)]);
9157
+ _optionalChain([win, 'optionalAccess', _215 => _215.addEventListener, 'call', _216 => _216("online", onVisibilityChange)]);
9158
+ _optionalChain([win, 'optionalAccess', _217 => _217.addEventListener, 'call', _218 => _218("focus", pollNowIfStale)]);
9076
9159
  fsm.start();
9077
9160
  return {
9078
9161
  inc,
@@ -9194,11 +9277,6 @@ var SortedList = class _SortedList {
9194
9277
  }
9195
9278
  };
9196
9279
 
9197
- // src/protocol/UserNotificationSettings.ts
9198
- function isNotificationChannelEnabled(settings) {
9199
- return values(settings).every((enabled) => enabled === true);
9200
- }
9201
-
9202
9280
  // src/types/Others.ts
9203
9281
  var TextEditorType = /* @__PURE__ */ ((TextEditorType2) => {
9204
9282
  TextEditorType2["Lexical"] = "lexical";
@@ -9210,94 +9288,96 @@ var TextEditorType = /* @__PURE__ */ ((TextEditorType2) => {
9210
9288
  detectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);
9211
9289
  var CommentsApiError = HttpError;
9212
9290
  var NotificationsApiError = HttpError;
9213
- export {
9214
- ClientMsgCode,
9215
- CommentsApiError,
9216
- CrdtType,
9217
- DefaultMap,
9218
- DerivedSignal,
9219
- HttpError,
9220
- LiveList,
9221
- LiveMap,
9222
- LiveObject,
9223
- LiveblocksError,
9224
- MutableSignal,
9225
- NotificationsApiError,
9226
- OpCode,
9227
- Permission,
9228
- Promise_withResolvers,
9229
- ServerMsgCode,
9230
- Signal,
9231
- SortedList,
9232
- TextEditorType,
9233
- WebsocketCloseCodes,
9234
- ackOp,
9235
- asPos,
9236
- assert,
9237
- assertNever,
9238
- autoRetry,
9239
- b64decode,
9240
- batch,
9241
- chunk,
9242
- cloneLson,
9243
- compactObject,
9244
- fancy_console_exports as console,
9245
- convertToCommentData,
9246
- convertToCommentUserReaction,
9247
- convertToInboxNotificationData,
9248
- convertToThreadData,
9249
- createClient,
9250
- createCommentAttachmentId,
9251
- createCommentId,
9252
- createInboxNotificationId,
9253
- createThreadId,
9254
- deprecate,
9255
- deprecateIf,
9256
- detectDupes,
9257
- entries,
9258
- errorIf,
9259
- freeze,
9260
- generateCommentUrl,
9261
- getMentionedIdsFromCommentBody,
9262
- html,
9263
- htmlSafe,
9264
- isChildCrdt,
9265
- isCommentBodyLink,
9266
- isCommentBodyMention,
9267
- isCommentBodyText,
9268
- isJsonArray,
9269
- isJsonObject,
9270
- isJsonScalar,
9271
- isLiveNode,
9272
- isNotificationChannelEnabled,
9273
- isPlainObject,
9274
- isRootCrdt,
9275
- isStartsWithOperator,
9276
- kInternal,
9277
- keys,
9278
- legacy_patchImmutableObject,
9279
- lsonToJson,
9280
- makeEventSource,
9281
- makePoller,
9282
- makePosition,
9283
- mapValues,
9284
- memoizeOnSuccess,
9285
- nanoid,
9286
- nn,
9287
- objectToQuery,
9288
- patchLiveObjectKey,
9289
- raise,
9290
- resolveUsersInCommentBody,
9291
- shallow,
9292
- stableStringify,
9293
- stringifyCommentBody,
9294
- throwUsageError,
9295
- toAbsoluteUrl,
9296
- toPlainLson,
9297
- tryParseJson,
9298
- url,
9299
- urljoin,
9300
- wait,
9301
- withTimeout
9302
- };
9303
- //# sourceMappingURL=index.mjs.map
9291
+
9292
+
9293
+
9294
+
9295
+
9296
+
9297
+
9298
+
9299
+
9300
+
9301
+
9302
+
9303
+
9304
+
9305
+
9306
+
9307
+
9308
+
9309
+
9310
+
9311
+
9312
+
9313
+
9314
+
9315
+
9316
+
9317
+
9318
+
9319
+
9320
+
9321
+
9322
+
9323
+
9324
+
9325
+
9326
+
9327
+
9328
+
9329
+
9330
+
9331
+
9332
+
9333
+
9334
+
9335
+
9336
+
9337
+
9338
+
9339
+
9340
+
9341
+
9342
+
9343
+
9344
+
9345
+
9346
+
9347
+
9348
+
9349
+
9350
+
9351
+
9352
+
9353
+
9354
+
9355
+
9356
+
9357
+
9358
+
9359
+
9360
+
9361
+
9362
+
9363
+
9364
+
9365
+
9366
+
9367
+
9368
+
9369
+
9370
+
9371
+
9372
+
9373
+
9374
+
9375
+
9376
+
9377
+
9378
+
9379
+
9380
+
9381
+
9382
+ exports.ClientMsgCode = ClientMsgCode; exports.CommentsApiError = CommentsApiError; exports.CrdtType = CrdtType; exports.DefaultMap = DefaultMap; exports.DerivedSignal = DerivedSignal; exports.HttpError = HttpError; exports.LiveList = LiveList; exports.LiveMap = LiveMap; exports.LiveObject = LiveObject; exports.LiveblocksError = LiveblocksError; exports.MutableSignal = MutableSignal; exports.NotificationsApiError = NotificationsApiError; 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.chunk = chunk; exports.cloneLson = cloneLson; exports.compactObject = compactObject; exports.console = fancy_console_exports; exports.convertToCommentData = convertToCommentData; exports.convertToCommentUserReaction = convertToCommentUserReaction; exports.convertToInboxNotificationData = convertToInboxNotificationData; exports.convertToThreadData = convertToThreadData; exports.createClient = createClient; exports.createCommentAttachmentId = createCommentAttachmentId; exports.createCommentId = createCommentId; exports.createInboxNotificationId = createInboxNotificationId; exports.createThreadId = createThreadId; exports.createUserNotificationSettings = createUserNotificationSettings; exports.deprecate = deprecate; exports.deprecateIf = deprecateIf; exports.detectDupes = detectDupes; exports.entries = entries; exports.errorIf = errorIf; exports.freeze = freeze; exports.generateCommentUrl = generateCommentUrl; exports.getMentionedIdsFromCommentBody = getMentionedIdsFromCommentBody; 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.kInternal = kInternal; exports.keys = keys; exports.legacy_patchImmutableObject = legacy_patchImmutableObject; exports.lsonToJson = lsonToJson; 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.patchUserNotificationSettings = patchUserNotificationSettings; exports.raise = raise; exports.resolveUsersInCommentBody = resolveUsersInCommentBody; exports.shallow = shallow; exports.stableStringify = stableStringify; exports.stringifyCommentBody = stringifyCommentBody; exports.throwUsageError = throwUsageError; exports.toAbsoluteUrl = toAbsoluteUrl; exports.toPlainLson = toPlainLson; exports.tryParseJson = tryParseJson; exports.url = url; exports.urljoin = urljoin; exports.wait = wait; exports.withTimeout = withTimeout;
9383
+ //# sourceMappingURL=index.cjs.map