@liveblocks/core 2.18.3 → 2.18.4-uns1

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-uns1";
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,72 @@ 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 (!value) {
3640
+ raise(
3641
+ `In order to use the '${channel}' channel, please set up your project first. See <link to docs>`
3642
+ );
3643
+ }
3644
+ return value;
3645
+ }
3646
+ };
3647
+ }
3648
+ return create(null, descriptors);
3649
+ }
3650
+ function patchUserNotificationSettings(existing, patch) {
3651
+ const outcoming = createUserNotificationSettings({
3652
+ ...existing[kPrivate].__plain__
3653
+ });
3654
+ for (const channel of keys(patch)) {
3655
+ const updates = patch[channel];
3656
+ if (updates !== void 0) {
3657
+ const kindUpdates = Object.fromEntries(
3658
+ entries(updates).filter(([, value]) => value !== void 0)
3659
+ );
3660
+ outcoming[kPrivate].__plain__[channel] = {
3661
+ ...outcoming[kPrivate].__plain__[channel],
3662
+ ...kindUpdates
3663
+ };
3664
+ }
3665
+ }
3666
+ return outcoming;
3667
+ }
3668
+ function isNotificationChannelEnabled(settings) {
3669
+ return values(settings).every((enabled) => enabled === true);
3670
+ }
3671
+
3600
3672
  // src/lib/position.ts
3601
3673
  var MIN_CODE = 32;
3602
3674
  var MAX_CODE = 126;
@@ -3966,7 +4038,7 @@ var LiveRegister = class _LiveRegister extends AbstractCrdt {
3966
4038
  return [
3967
4039
  {
3968
4040
  type: 8 /* CREATE_REGISTER */,
3969
- opId: pool?.generateOpId(),
4041
+ opId: _optionalChain([pool, 'optionalAccess', _65 => _65.generateOpId, 'call', _66 => _66()]),
3970
4042
  id: this._id,
3971
4043
  parentId,
3972
4044
  parentKey,
@@ -4002,7 +4074,7 @@ var LiveRegister = class _LiveRegister extends AbstractCrdt {
4002
4074
  _toTreeNode(key) {
4003
4075
  return {
4004
4076
  type: "Json",
4005
- id: this._id ?? nanoid(),
4077
+ id: _nullishCoalesce(this._id, () => ( nanoid())),
4006
4078
  key,
4007
4079
  payload: this.#data
4008
4080
  };
@@ -4072,7 +4144,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
4072
4144
  const ops = [];
4073
4145
  const op = {
4074
4146
  id: this._id,
4075
- opId: pool?.generateOpId(),
4147
+ opId: _optionalChain([pool, 'optionalAccess', _67 => _67.generateOpId, 'call', _68 => _68()]),
4076
4148
  type: 2 /* CREATE_LIST */,
4077
4149
  parentId,
4078
4150
  parentKey
@@ -4343,7 +4415,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
4343
4415
  #applyInsertUndoRedo(op) {
4344
4416
  const { id, parentKey: key } = op;
4345
4417
  const child = creationOpToLiveNode(op);
4346
- if (this._pool?.getNode(id) !== void 0) {
4418
+ if (_optionalChain([this, 'access', _69 => _69._pool, 'optionalAccess', _70 => _70.getNode, 'call', _71 => _71(id)]) !== void 0) {
4347
4419
  return { modified: false };
4348
4420
  }
4349
4421
  child._attach(id, nn(this._pool));
@@ -4351,8 +4423,8 @@ var LiveList = class _LiveList extends AbstractCrdt {
4351
4423
  const existingItemIndex = this._indexOfPosition(key);
4352
4424
  let newKey = key;
4353
4425
  if (existingItemIndex !== -1) {
4354
- const before2 = this.#items[existingItemIndex]?._parentPos;
4355
- const after2 = this.#items[existingItemIndex + 1]?._parentPos;
4426
+ const before2 = _optionalChain([this, 'access', _72 => _72.#items, 'access', _73 => _73[existingItemIndex], 'optionalAccess', _74 => _74._parentPos]);
4427
+ const after2 = _optionalChain([this, 'access', _75 => _75.#items, 'access', _76 => _76[existingItemIndex + 1], 'optionalAccess', _77 => _77._parentPos]);
4356
4428
  newKey = makePosition(before2, after2);
4357
4429
  child._setParentLink(this, newKey);
4358
4430
  }
@@ -4366,7 +4438,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
4366
4438
  #applySetUndoRedo(op) {
4367
4439
  const { id, parentKey: key } = op;
4368
4440
  const child = creationOpToLiveNode(op);
4369
- if (this._pool?.getNode(id) !== void 0) {
4441
+ if (_optionalChain([this, 'access', _78 => _78._pool, 'optionalAccess', _79 => _79.getNode, 'call', _80 => _80(id)]) !== void 0) {
4370
4442
  return { modified: false };
4371
4443
  }
4372
4444
  this.#unacknowledgedSets.set(key, nn(op.opId));
@@ -4487,7 +4559,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
4487
4559
  } else {
4488
4560
  this.#items[existingItemIndex]._setParentLink(
4489
4561
  this,
4490
- makePosition(newKey, this.#items[existingItemIndex + 1]?._parentPos)
4562
+ makePosition(newKey, _optionalChain([this, 'access', _81 => _81.#items, 'access', _82 => _82[existingItemIndex + 1], 'optionalAccess', _83 => _83._parentPos]))
4491
4563
  );
4492
4564
  const previousIndex = this.#items.indexOf(child);
4493
4565
  child._setParentLink(this, newKey);
@@ -4512,7 +4584,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
4512
4584
  if (existingItemIndex !== -1) {
4513
4585
  this.#items[existingItemIndex]._setParentLink(
4514
4586
  this,
4515
- makePosition(newKey, this.#items[existingItemIndex + 1]?._parentPos)
4587
+ makePosition(newKey, _optionalChain([this, 'access', _84 => _84.#items, 'access', _85 => _85[existingItemIndex + 1], 'optionalAccess', _86 => _86._parentPos]))
4516
4588
  );
4517
4589
  }
4518
4590
  child._setParentLink(this, newKey);
@@ -4531,7 +4603,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
4531
4603
  if (existingItemIndex !== -1) {
4532
4604
  this.#items[existingItemIndex]._setParentLink(
4533
4605
  this,
4534
- makePosition(newKey, this.#items[existingItemIndex + 1]?._parentPos)
4606
+ makePosition(newKey, _optionalChain([this, 'access', _87 => _87.#items, 'access', _88 => _88[existingItemIndex + 1], 'optionalAccess', _89 => _89._parentPos]))
4535
4607
  );
4536
4608
  }
4537
4609
  child._setParentLink(this, newKey);
@@ -4558,7 +4630,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
4558
4630
  if (existingItemIndex !== -1) {
4559
4631
  this.#items[existingItemIndex]._setParentLink(
4560
4632
  this,
4561
- makePosition(newKey, this.#items[existingItemIndex + 1]?._parentPos)
4633
+ makePosition(newKey, _optionalChain([this, 'access', _90 => _90.#items, 'access', _91 => _91[existingItemIndex + 1], 'optionalAccess', _92 => _92._parentPos]))
4562
4634
  );
4563
4635
  }
4564
4636
  child._setParentLink(this, newKey);
@@ -4616,7 +4688,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
4616
4688
  * @param element The element to add to the end of the LiveList.
4617
4689
  */
4618
4690
  push(element) {
4619
- this._pool?.assertStorageIsWritable();
4691
+ _optionalChain([this, 'access', _93 => _93._pool, 'optionalAccess', _94 => _94.assertStorageIsWritable, 'call', _95 => _95()]);
4620
4692
  return this.insert(element, this.length);
4621
4693
  }
4622
4694
  /**
@@ -4625,7 +4697,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
4625
4697
  * @param index The index at which you want to insert the element.
4626
4698
  */
4627
4699
  insert(element, index) {
4628
- this._pool?.assertStorageIsWritable();
4700
+ _optionalChain([this, 'access', _96 => _96._pool, 'optionalAccess', _97 => _97.assertStorageIsWritable, 'call', _98 => _98()]);
4629
4701
  if (index < 0 || index > this.#items.length) {
4630
4702
  throw new Error(
4631
4703
  `Cannot insert list item at index "${index}". index should be between 0 and ${this.#items.length}`
@@ -4655,7 +4727,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
4655
4727
  * @param targetIndex The index where the element should be after moving.
4656
4728
  */
4657
4729
  move(index, targetIndex) {
4658
- this._pool?.assertStorageIsWritable();
4730
+ _optionalChain([this, 'access', _99 => _99._pool, 'optionalAccess', _100 => _100.assertStorageIsWritable, 'call', _101 => _101()]);
4659
4731
  if (targetIndex < 0) {
4660
4732
  throw new Error("targetIndex cannot be less than 0");
4661
4733
  }
@@ -4713,7 +4785,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
4713
4785
  * @param index The index of the element to delete
4714
4786
  */
4715
4787
  delete(index) {
4716
- this._pool?.assertStorageIsWritable();
4788
+ _optionalChain([this, 'access', _102 => _102._pool, 'optionalAccess', _103 => _103.assertStorageIsWritable, 'call', _104 => _104()]);
4717
4789
  if (index < 0 || index >= this.#items.length) {
4718
4790
  throw new Error(
4719
4791
  `Cannot delete list item at index "${index}". index should be between 0 and ${this.#items.length - 1}`
@@ -4746,7 +4818,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
4746
4818
  }
4747
4819
  }
4748
4820
  clear() {
4749
- this._pool?.assertStorageIsWritable();
4821
+ _optionalChain([this, 'access', _105 => _105._pool, 'optionalAccess', _106 => _106.assertStorageIsWritable, 'call', _107 => _107()]);
4750
4822
  if (this._pool) {
4751
4823
  const ops = [];
4752
4824
  const reverseOps = [];
@@ -4780,7 +4852,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
4780
4852
  }
4781
4853
  }
4782
4854
  set(index, item) {
4783
- this._pool?.assertStorageIsWritable();
4855
+ _optionalChain([this, 'access', _108 => _108._pool, 'optionalAccess', _109 => _109.assertStorageIsWritable, 'call', _110 => _110()]);
4784
4856
  if (index < 0 || index >= this.#items.length) {
4785
4857
  throw new Error(
4786
4858
  `Cannot set list item at index "${index}". index should be between 0 and ${this.#items.length - 1}`
@@ -4926,7 +4998,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
4926
4998
  #shiftItemPosition(index, key) {
4927
4999
  const shiftedPosition = makePosition(
4928
5000
  key,
4929
- this.#items.length > index + 1 ? this.#items[index + 1]?._parentPos : void 0
5001
+ this.#items.length > index + 1 ? _optionalChain([this, 'access', _111 => _111.#items, 'access', _112 => _112[index + 1], 'optionalAccess', _113 => _113._parentPos]) : void 0
4930
5002
  );
4931
5003
  this.#items[index]._setParentLink(this, shiftedPosition);
4932
5004
  }
@@ -4934,7 +5006,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
4934
5006
  _toTreeNode(key) {
4935
5007
  return {
4936
5008
  type: "LiveList",
4937
- id: this._id ?? nanoid(),
5009
+ id: _nullishCoalesce(this._id, () => ( nanoid())),
4938
5010
  key,
4939
5011
  payload: this.#items.map(
4940
5012
  (item, index) => item.toTreeNode(index.toString())
@@ -5051,7 +5123,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
5051
5123
  const ops = [];
5052
5124
  const op = {
5053
5125
  id: this._id,
5054
- opId: pool?.generateOpId(),
5126
+ opId: _optionalChain([pool, 'optionalAccess', _114 => _114.generateOpId, 'call', _115 => _115()]),
5055
5127
  type: 7 /* CREATE_MAP */,
5056
5128
  parentId,
5057
5129
  parentKey
@@ -5186,7 +5258,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
5186
5258
  * @param value The value of the element to add. Should be serializable to JSON.
5187
5259
  */
5188
5260
  set(key, value) {
5189
- this._pool?.assertStorageIsWritable();
5261
+ _optionalChain([this, 'access', _116 => _116._pool, 'optionalAccess', _117 => _117.assertStorageIsWritable, 'call', _118 => _118()]);
5190
5262
  const oldValue = this.#map.get(key);
5191
5263
  if (oldValue) {
5192
5264
  oldValue._detach();
@@ -5232,7 +5304,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
5232
5304
  * @returns true if an element existed and has been removed, or false if the element does not exist.
5233
5305
  */
5234
5306
  delete(key) {
5235
- this._pool?.assertStorageIsWritable();
5307
+ _optionalChain([this, 'access', _119 => _119._pool, 'optionalAccess', _120 => _120.assertStorageIsWritable, 'call', _121 => _121()]);
5236
5308
  const item = this.#map.get(key);
5237
5309
  if (item === void 0) {
5238
5310
  return false;
@@ -5335,7 +5407,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
5335
5407
  _toTreeNode(key) {
5336
5408
  return {
5337
5409
  type: "LiveMap",
5338
- id: this._id ?? nanoid(),
5410
+ id: _nullishCoalesce(this._id, () => ( nanoid())),
5339
5411
  key,
5340
5412
  payload: Array.from(this.#map.entries()).map(
5341
5413
  ([key2, val]) => val.toTreeNode(key2)
@@ -5411,7 +5483,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
5411
5483
  if (this._id === void 0) {
5412
5484
  throw new Error("Cannot serialize item is not attached");
5413
5485
  }
5414
- const opId = pool?.generateOpId();
5486
+ const opId = _optionalChain([pool, 'optionalAccess', _122 => _122.generateOpId, 'call', _123 => _123()]);
5415
5487
  const ops = [];
5416
5488
  const op = {
5417
5489
  type: 4 /* CREATE_OBJECT */,
@@ -5683,7 +5755,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
5683
5755
  * @param value The value of the property to add
5684
5756
  */
5685
5757
  set(key, value) {
5686
- this._pool?.assertStorageIsWritable();
5758
+ _optionalChain([this, 'access', _124 => _124._pool, 'optionalAccess', _125 => _125.assertStorageIsWritable, 'call', _126 => _126()]);
5687
5759
  this.update({ [key]: value });
5688
5760
  }
5689
5761
  /**
@@ -5698,7 +5770,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
5698
5770
  * @param key The key of the property to delete
5699
5771
  */
5700
5772
  delete(key) {
5701
- this._pool?.assertStorageIsWritable();
5773
+ _optionalChain([this, 'access', _127 => _127._pool, 'optionalAccess', _128 => _128.assertStorageIsWritable, 'call', _129 => _129()]);
5702
5774
  const keyAsString = key;
5703
5775
  const oldValue = this.#map.get(keyAsString);
5704
5776
  if (oldValue === void 0) {
@@ -5751,7 +5823,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
5751
5823
  * @param patch The object used to overrides properties
5752
5824
  */
5753
5825
  update(patch) {
5754
- this._pool?.assertStorageIsWritable();
5826
+ _optionalChain([this, 'access', _130 => _130._pool, 'optionalAccess', _131 => _131.assertStorageIsWritable, 'call', _132 => _132()]);
5755
5827
  if (this._pool === void 0 || this._id === void 0) {
5756
5828
  for (const key in patch) {
5757
5829
  const newValue = patch[key];
@@ -5841,7 +5913,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
5841
5913
  }
5842
5914
  /** @internal */
5843
5915
  _toTreeNode(key) {
5844
- const nodeId = this._id ?? nanoid();
5916
+ const nodeId = _nullishCoalesce(this._id, () => ( nanoid()));
5845
5917
  return {
5846
5918
  type: "LiveObject",
5847
5919
  id: nodeId,
@@ -6237,7 +6309,7 @@ var ManagedOthers = class {
6237
6309
  #internal;
6238
6310
  #userCache;
6239
6311
  // The "clean" signal that is exposed to the outside world
6240
- signal;
6312
+
6241
6313
  constructor() {
6242
6314
  this.#internal = new MutableSignal({
6243
6315
  connections: /* @__PURE__ */ new Map(),
@@ -6359,7 +6431,7 @@ var ManagedOthers = class {
6359
6431
 
6360
6432
  // src/types/LiveblocksError.ts
6361
6433
  var LiveblocksError = class _LiveblocksError extends Error {
6362
- context;
6434
+
6363
6435
  constructor(message, context, cause) {
6364
6436
  super(message, { cause });
6365
6437
  this.context = context;
@@ -6460,15 +6532,15 @@ function installBackgroundTabSpy() {
6460
6532
  const doc = typeof document !== "undefined" ? document : void 0;
6461
6533
  const inBackgroundSince = { current: null };
6462
6534
  function onVisibilityChange() {
6463
- if (doc?.visibilityState === "hidden") {
6464
- inBackgroundSince.current = inBackgroundSince.current ?? Date.now();
6535
+ if (_optionalChain([doc, 'optionalAccess', _133 => _133.visibilityState]) === "hidden") {
6536
+ inBackgroundSince.current = _nullishCoalesce(inBackgroundSince.current, () => ( Date.now()));
6465
6537
  } else {
6466
6538
  inBackgroundSince.current = null;
6467
6539
  }
6468
6540
  }
6469
- doc?.addEventListener("visibilitychange", onVisibilityChange);
6541
+ _optionalChain([doc, 'optionalAccess', _134 => _134.addEventListener, 'call', _135 => _135("visibilitychange", onVisibilityChange)]);
6470
6542
  const unsub = () => {
6471
- doc?.removeEventListener("visibilitychange", onVisibilityChange);
6543
+ _optionalChain([doc, 'optionalAccess', _136 => _136.removeEventListener, 'call', _137 => _137("visibilitychange", onVisibilityChange)]);
6472
6544
  };
6473
6545
  return [inBackgroundSince, unsub];
6474
6546
  }
@@ -6653,7 +6725,7 @@ function createRoom(options, config) {
6653
6725
  }
6654
6726
  },
6655
6727
  assertStorageIsWritable: () => {
6656
- const scopes = context.dynamicSessionInfoSig.get()?.scopes;
6728
+ const scopes = _optionalChain([context, 'access', _138 => _138.dynamicSessionInfoSig, 'access', _139 => _139.get, 'call', _140 => _140(), 'optionalAccess', _141 => _141.scopes]);
6657
6729
  if (scopes === void 0) {
6658
6730
  return;
6659
6731
  }
@@ -6761,7 +6833,7 @@ function createRoom(options, config) {
6761
6833
  return new TextEncoder().encode(text).length >= MAX_SOCKET_MESSAGE_SIZE;
6762
6834
  }
6763
6835
  function sendMessages(messages) {
6764
- const strategy = config.largeMessageStrategy ?? "default";
6836
+ const strategy = _nullishCoalesce(config.largeMessageStrategy, () => ( "default"));
6765
6837
  const text = stringifyOrLog(messages);
6766
6838
  if (!isTooBigForWebSocket(text)) {
6767
6839
  return managedSocket.send(text);
@@ -6780,7 +6852,7 @@ function createRoom(options, config) {
6780
6852
  }
6781
6853
  case "experimental-fallback-to-http": {
6782
6854
  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");
6855
+ 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
6856
  void httpClient.sendMessages({ roomId, nonce, messages }).then((resp) => {
6785
6857
  if (!resp.ok && resp.status === 403) {
6786
6858
  managedSocket.reconnect();
@@ -6831,7 +6903,7 @@ function createRoom(options, config) {
6831
6903
  } else {
6832
6904
  context.root = LiveObject._fromItems(message.items, pool);
6833
6905
  }
6834
- const canWrite = self.get()?.canWrite ?? true;
6906
+ const canWrite = _nullishCoalesce(_optionalChain([self, 'access', _146 => _146.get, 'call', _147 => _147(), 'optionalAccess', _148 => _148.canWrite]), () => ( true));
6835
6907
  const stackSizeBefore = context.undoStack.length;
6836
6908
  for (const key in context.initialStorage) {
6837
6909
  if (context.root.get(key) === void 0) {
@@ -6881,7 +6953,7 @@ function createRoom(options, config) {
6881
6953
  eventHub.others.notify({ ...event, others });
6882
6954
  }
6883
6955
  }
6884
- if (updates.presence ?? false) {
6956
+ if (_nullishCoalesce(updates.presence, () => ( false))) {
6885
6957
  notifySelfChanged();
6886
6958
  eventHub.myPresence.notify(context.myPresence.get());
6887
6959
  }
@@ -7034,7 +7106,7 @@ function createRoom(options, config) {
7034
7106
  }
7035
7107
  context.myPresence.patch(patch);
7036
7108
  if (context.activeBatch) {
7037
- if (options2?.addToHistory) {
7109
+ if (_optionalChain([options2, 'optionalAccess', _149 => _149.addToHistory])) {
7038
7110
  context.activeBatch.reverseOps.pushLeft({
7039
7111
  type: "presence",
7040
7112
  data: oldValues
@@ -7043,7 +7115,7 @@ function createRoom(options, config) {
7043
7115
  context.activeBatch.updates.presence = true;
7044
7116
  } else {
7045
7117
  flushNowOrSoon();
7046
- if (options2?.addToHistory) {
7118
+ if (_optionalChain([options2, 'optionalAccess', _150 => _150.addToHistory])) {
7047
7119
  addToUndoStack([{ type: "presence", data: oldValues }]);
7048
7120
  }
7049
7121
  notify({ presence: true });
@@ -7192,7 +7264,7 @@ function createRoom(options, config) {
7192
7264
  const others = context.others.get();
7193
7265
  eventHub.customEvent.notify({
7194
7266
  connectionId: message.actor,
7195
- user: message.actor < 0 ? null : others.find((u) => u.connectionId === message.actor) ?? null,
7267
+ user: message.actor < 0 ? null : _nullishCoalesce(others.find((u) => u.connectionId === message.actor), () => ( null)),
7196
7268
  event: message.event
7197
7269
  });
7198
7270
  break;
@@ -7240,7 +7312,7 @@ function createRoom(options, config) {
7240
7312
  if (process.env.NODE_ENV !== "production") {
7241
7313
  const traces = /* @__PURE__ */ new Set();
7242
7314
  for (const opId of message.opIds) {
7243
- const trace = context.opStackTraces?.get(opId);
7315
+ const trace = _optionalChain([context, 'access', _151 => _151.opStackTraces, 'optionalAccess', _152 => _152.get, 'call', _153 => _153(opId)]);
7244
7316
  if (trace) {
7245
7317
  traces.add(trace);
7246
7318
  }
@@ -7374,7 +7446,7 @@ ${Array.from(traces).join("\n\n")}`
7374
7446
  const unacknowledgedOps = new Map(context.unacknowledgedOps);
7375
7447
  createOrUpdateRootFromMessage(message);
7376
7448
  applyAndSendOps(unacknowledgedOps);
7377
- _resolveStoragePromise?.();
7449
+ _optionalChain([_resolveStoragePromise, 'optionalCall', _154 => _154()]);
7378
7450
  notifyStorageStatus();
7379
7451
  eventHub.storageDidLoad.notify();
7380
7452
  }
@@ -7597,8 +7669,8 @@ ${Array.from(traces).join("\n\n")}`
7597
7669
  async function getThreads(options2) {
7598
7670
  return httpClient.getThreads({
7599
7671
  roomId,
7600
- query: options2?.query,
7601
- cursor: options2?.cursor
7672
+ query: _optionalChain([options2, 'optionalAccess', _155 => _155.query]),
7673
+ cursor: _optionalChain([options2, 'optionalAccess', _156 => _156.cursor])
7602
7674
  });
7603
7675
  }
7604
7676
  async function getThread(threadId) {
@@ -7699,7 +7771,7 @@ ${Array.from(traces).join("\n\n")}`
7699
7771
  function getNotificationSettings(options2) {
7700
7772
  return httpClient.getNotificationSettings({
7701
7773
  roomId,
7702
- signal: options2?.signal
7774
+ signal: _optionalChain([options2, 'optionalAccess', _157 => _157.signal])
7703
7775
  });
7704
7776
  }
7705
7777
  function updateNotificationSettings(settings) {
@@ -7721,7 +7793,7 @@ ${Array.from(traces).join("\n\n")}`
7721
7793
  {
7722
7794
  [kInternal]: {
7723
7795
  get presenceBuffer() {
7724
- return deepClone(context.buffer.presenceUpdates?.data ?? null);
7796
+ return deepClone(_nullishCoalesce(_optionalChain([context, 'access', _158 => _158.buffer, 'access', _159 => _159.presenceUpdates, 'optionalAccess', _160 => _160.data]), () => ( null)));
7725
7797
  },
7726
7798
  // prettier-ignore
7727
7799
  get undoStack() {
@@ -7736,9 +7808,9 @@ ${Array.from(traces).join("\n\n")}`
7736
7808
  return context.yjsProvider;
7737
7809
  },
7738
7810
  setYjsProvider(newProvider) {
7739
- context.yjsProvider?.off("status", yjsStatusDidChange);
7811
+ _optionalChain([context, 'access', _161 => _161.yjsProvider, 'optionalAccess', _162 => _162.off, 'call', _163 => _163("status", yjsStatusDidChange)]);
7740
7812
  context.yjsProvider = newProvider;
7741
- newProvider?.on("status", yjsStatusDidChange);
7813
+ _optionalChain([newProvider, 'optionalAccess', _164 => _164.on, 'call', _165 => _165("status", yjsStatusDidChange)]);
7742
7814
  context.yjsProviderDidChange.notify();
7743
7815
  },
7744
7816
  yjsProviderDidChange: context.yjsProviderDidChange.observable,
@@ -7784,7 +7856,7 @@ ${Array.from(traces).join("\n\n")}`
7784
7856
  source[Symbol.dispose]();
7785
7857
  }
7786
7858
  eventHub.roomWillDestroy.notify();
7787
- context.yjsProvider?.off("status", yjsStatusDidChange);
7859
+ _optionalChain([context, 'access', _166 => _166.yjsProvider, 'optionalAccess', _167 => _167.off, 'call', _168 => _168("status", yjsStatusDidChange)]);
7788
7860
  syncSourceForStorage.destroy();
7789
7861
  syncSourceForYjs.destroy();
7790
7862
  uninstallBgTabSpy();
@@ -7930,7 +8002,7 @@ function makeClassicSubscribeFn(roomId, events, errorEvents) {
7930
8002
  }
7931
8003
  if (isLiveNode(first)) {
7932
8004
  const node = first;
7933
- if (options?.isDeep) {
8005
+ if (_optionalChain([options, 'optionalAccess', _169 => _169.isDeep])) {
7934
8006
  const storageCallback = second;
7935
8007
  return subscribeToLiveStructureDeeply(node, storageCallback);
7936
8008
  } else {
@@ -7954,7 +8026,7 @@ function makeAuthDelegateForRoom(roomId, authManager) {
7954
8026
  }
7955
8027
  function makeCreateSocketDelegateForRoom(roomId, baseUrl, WebSocketPolyfill) {
7956
8028
  return (authValue) => {
7957
- const ws = WebSocketPolyfill ?? (typeof WebSocket === "undefined" ? void 0 : WebSocket);
8029
+ const ws = _nullishCoalesce(WebSocketPolyfill, () => ( (typeof WebSocket === "undefined" ? void 0 : WebSocket)));
7958
8030
  if (ws === void 0) {
7959
8031
  throw new StopRetrying(
7960
8032
  "To use Liveblocks client in a non-DOM environment, you need to provide a WebSocket polyfill."
@@ -7996,9 +8068,9 @@ function getBaseUrl(baseUrl) {
7996
8068
  }
7997
8069
  function createClient(options) {
7998
8070
  const clientOptions = options;
7999
- const throttleDelay = getThrottle(clientOptions.throttle ?? DEFAULT_THROTTLE);
8071
+ const throttleDelay = getThrottle(_nullishCoalesce(clientOptions.throttle, () => ( DEFAULT_THROTTLE)));
8000
8072
  const lostConnectionTimeout = getLostConnectionTimeout(
8001
- clientOptions.lostConnectionTimeout ?? DEFAULT_LOST_CONNECTION_TIMEOUT
8073
+ _nullishCoalesce(clientOptions.lostConnectionTimeout, () => ( DEFAULT_LOST_CONNECTION_TIMEOUT))
8002
8074
  );
8003
8075
  const backgroundKeepAliveTimeout = getBackgroundKeepAliveTimeout(
8004
8076
  clientOptions.backgroundKeepAliveTimeout
@@ -8009,8 +8081,8 @@ function createClient(options) {
8009
8081
  const userId = token.k === "sec-legacy" /* SECRET_LEGACY */ ? token.id : token.uid;
8010
8082
  currentUserId.set(() => userId);
8011
8083
  });
8012
- const fetchPolyfill = clientOptions.polyfills?.fetch || /* istanbul ignore next */
8013
- globalThis.fetch?.bind(globalThis);
8084
+ const fetchPolyfill = _optionalChain([clientOptions, 'access', _170 => _170.polyfills, 'optionalAccess', _171 => _171.fetch]) || /* istanbul ignore next */
8085
+ _optionalChain([globalThis, 'access', _172 => _172.fetch, 'optionalAccess', _173 => _173.bind, 'call', _174 => _174(globalThis)]);
8014
8086
  const httpClient = createApiClient({
8015
8087
  baseUrl,
8016
8088
  fetchPolyfill,
@@ -8046,9 +8118,9 @@ function createClient(options) {
8046
8118
  if (existing !== void 0) {
8047
8119
  return leaseRoom(existing);
8048
8120
  }
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) ?? {};
8121
+ const options2 = _nullishCoalesce(args[0], () => ( {}));
8122
+ const initialPresence = _nullishCoalesce((typeof options2.initialPresence === "function" ? options2.initialPresence(roomId) : options2.initialPresence), () => ( {}));
8123
+ const initialStorage = _nullishCoalesce((typeof options2.initialStorage === "function" ? options2.initialStorage(roomId) : options2.initialStorage), () => ( {}));
8052
8124
  const newRoom = createRoom(
8053
8125
  { initialPresence, initialStorage },
8054
8126
  {
@@ -8057,18 +8129,18 @@ function createClient(options) {
8057
8129
  lostConnectionTimeout,
8058
8130
  backgroundKeepAliveTimeout,
8059
8131
  polyfills: clientOptions.polyfills,
8060
- delegates: clientOptions.mockedDelegates ?? {
8132
+ delegates: _nullishCoalesce(clientOptions.mockedDelegates, () => ( {
8061
8133
  createSocket: makeCreateSocketDelegateForRoom(
8062
8134
  roomId,
8063
8135
  baseUrl,
8064
- clientOptions.polyfills?.WebSocket
8136
+ _optionalChain([clientOptions, 'access', _175 => _175.polyfills, 'optionalAccess', _176 => _176.WebSocket])
8065
8137
  ),
8066
8138
  authenticate: makeAuthDelegateForRoom(roomId, authManager)
8067
- },
8139
+ })),
8068
8140
  enableDebugLogging: clientOptions.enableDebugLogging,
8069
8141
  baseUrl,
8070
8142
  errorEventSource: liveblocksErrorSource,
8071
- largeMessageStrategy: clientOptions.largeMessageStrategy ?? (clientOptions.unstable_fallbackToHTTP ? "experimental-fallback-to-http" : void 0),
8143
+ largeMessageStrategy: _nullishCoalesce(clientOptions.largeMessageStrategy, () => ( (clientOptions.unstable_fallbackToHTTP ? "experimental-fallback-to-http" : void 0))),
8072
8144
  unstable_streamData: !!clientOptions.unstable_streamData,
8073
8145
  roomHttpClient: httpClient,
8074
8146
  createSyncSource
@@ -8081,10 +8153,10 @@ function createClient(options) {
8081
8153
  roomsById.set(roomId, newRoomDetails);
8082
8154
  setupDevTools(() => Array.from(roomsById.keys()));
8083
8155
  linkDevTools(roomId, newRoom);
8084
- const shouldConnect = options2.autoConnect ?? true;
8156
+ const shouldConnect = _nullishCoalesce(options2.autoConnect, () => ( true));
8085
8157
  if (shouldConnect) {
8086
8158
  if (typeof atob === "undefined") {
8087
- if (clientOptions.polyfills?.atob === void 0) {
8159
+ if (_optionalChain([clientOptions, 'access', _177 => _177.polyfills, 'optionalAccess', _178 => _178.atob]) === void 0) {
8088
8160
  throw new Error(
8089
8161
  "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
8162
  );
@@ -8096,7 +8168,7 @@ function createClient(options) {
8096
8168
  return leaseRoom(newRoomDetails);
8097
8169
  }
8098
8170
  function getRoom(roomId) {
8099
- const room = roomsById.get(roomId)?.room;
8171
+ const room = _optionalChain([roomsById, 'access', _179 => _179.get, 'call', _180 => _180(roomId), 'optionalAccess', _181 => _181.room]);
8100
8172
  return room ? room : null;
8101
8173
  }
8102
8174
  function logout() {
@@ -8116,9 +8188,9 @@ function createClient(options) {
8116
8188
  const batchedResolveUsers = new Batch(
8117
8189
  async (batchedUserIds) => {
8118
8190
  const userIds = batchedUserIds.flat();
8119
- const users = await resolveUsers?.({ userIds });
8191
+ const users = await _optionalChain([resolveUsers, 'optionalCall', _182 => _182({ userIds })]);
8120
8192
  warnIfNoResolveUsers();
8121
- return users ?? userIds.map(() => void 0);
8193
+ return _nullishCoalesce(users, () => ( userIds.map(() => void 0)));
8122
8194
  },
8123
8195
  { delay: RESOLVE_USERS_BATCH_DELAY }
8124
8196
  );
@@ -8134,9 +8206,9 @@ function createClient(options) {
8134
8206
  const batchedResolveRoomsInfo = new Batch(
8135
8207
  async (batchedRoomIds) => {
8136
8208
  const roomIds = batchedRoomIds.flat();
8137
- const roomsInfo = await resolveRoomsInfo?.({ roomIds });
8209
+ const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall', _183 => _183({ roomIds })]);
8138
8210
  warnIfNoResolveRoomsInfo();
8139
- return roomsInfo ?? roomIds.map(() => void 0);
8211
+ return _nullishCoalesce(roomsInfo, () => ( roomIds.map(() => void 0)));
8140
8212
  },
8141
8213
  { delay: RESOLVE_ROOMS_INFO_BATCH_DELAY }
8142
8214
  );
@@ -8187,7 +8259,17 @@ function createClient(options) {
8187
8259
  }
8188
8260
  };
8189
8261
  const win = typeof window !== "undefined" ? window : void 0;
8190
- win?.addEventListener("beforeunload", maybePreventClose);
8262
+ _optionalChain([win, 'optionalAccess', _184 => _184.addEventListener, 'call', _185 => _185("beforeunload", maybePreventClose)]);
8263
+ }
8264
+ async function getNotificationSettings(options2) {
8265
+ const plainSettings = await httpClient.getUserNotificationSettings(options2);
8266
+ const settings = createUserNotificationSettings(plainSettings);
8267
+ return settings;
8268
+ }
8269
+ async function updateNotificationSettings(settings) {
8270
+ const plainSettings = await httpClient.updateUserNotificationSettings(settings);
8271
+ const settingsObject = createUserNotificationSettings(plainSettings);
8272
+ return settingsObject;
8191
8273
  }
8192
8274
  const client = Object.defineProperty(
8193
8275
  {
@@ -8202,9 +8284,9 @@ function createClient(options) {
8202
8284
  markInboxNotificationAsRead: httpClient.markInboxNotificationAsRead,
8203
8285
  deleteAllInboxNotifications: httpClient.deleteAllInboxNotifications,
8204
8286
  deleteInboxNotification: httpClient.deleteInboxNotification,
8205
- // Public channel notification settings API
8206
- getNotificationSettings: httpClient.getUserNotificationSettings,
8207
- updateNotificationSettings: httpClient.updateUserNotificationSettings,
8287
+ // Public user notification settings API
8288
+ getNotificationSettings,
8289
+ updateNotificationSettings,
8208
8290
  // Advanced resolvers APIs
8209
8291
  resolvers: {
8210
8292
  invalidateUsers: invalidateResolvedUsers,
@@ -8249,7 +8331,7 @@ function createClient(options) {
8249
8331
  function checkBounds(option, value, min, max, recommendedMin) {
8250
8332
  if (typeof value !== "number" || value < min || max !== void 0 && value > max) {
8251
8333
  throw new Error(
8252
- max !== void 0 ? `${option} should be between ${recommendedMin ?? min} and ${max}.` : `${option} should be at least ${recommendedMin ?? min}.`
8334
+ max !== void 0 ? `${option} should be between ${_nullishCoalesce(recommendedMin, () => ( min))} and ${max}.` : `${option} should be at least ${_nullishCoalesce(recommendedMin, () => ( min))}.`
8253
8335
  );
8254
8336
  }
8255
8337
  return value;
@@ -8315,7 +8397,7 @@ var commentBodyElementsTypes = {
8315
8397
  mention: "inline"
8316
8398
  };
8317
8399
  function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
8318
- if (!body || !body?.content) {
8400
+ if (!body || !_optionalChain([body, 'optionalAccess', _186 => _186.content])) {
8319
8401
  return;
8320
8402
  }
8321
8403
  const element = typeof elementOrVisitor === "string" ? elementOrVisitor : void 0;
@@ -8325,13 +8407,13 @@ function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
8325
8407
  for (const block of body.content) {
8326
8408
  if (type === "all" || type === "block") {
8327
8409
  if (guard(block)) {
8328
- visitor?.(block);
8410
+ _optionalChain([visitor, 'optionalCall', _187 => _187(block)]);
8329
8411
  }
8330
8412
  }
8331
8413
  if (type === "all" || type === "inline") {
8332
8414
  for (const inline of block.children) {
8333
8415
  if (guard(inline)) {
8334
- visitor?.(inline);
8416
+ _optionalChain([visitor, 'optionalCall', _188 => _188(inline)]);
8335
8417
  }
8336
8418
  }
8337
8419
  }
@@ -8356,7 +8438,7 @@ async function resolveUsersInCommentBody(body, resolveUsers) {
8356
8438
  userIds
8357
8439
  });
8358
8440
  for (const [index, userId] of userIds.entries()) {
8359
- const user = users?.[index];
8441
+ const user = _optionalChain([users, 'optionalAccess', _189 => _189[index]]);
8360
8442
  if (user) {
8361
8443
  resolvedUsers.set(userId, user);
8362
8444
  }
@@ -8481,9 +8563,9 @@ function toAbsoluteUrl(url2) {
8481
8563
  var stringifyCommentBodyPlainElements = {
8482
8564
  paragraph: ({ children }) => children,
8483
8565
  text: ({ element }) => element.text,
8484
- link: ({ element }) => element.text ?? element.url,
8566
+ link: ({ element }) => _nullishCoalesce(element.text, () => ( element.url)),
8485
8567
  mention: ({ element, user }) => {
8486
- return `@${user?.name ?? element.id}`;
8568
+ return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _190 => _190.name]), () => ( element.id))}`;
8487
8569
  }
8488
8570
  };
8489
8571
  var stringifyCommentBodyHtmlElements = {
@@ -8513,7 +8595,7 @@ var stringifyCommentBodyHtmlElements = {
8513
8595
  return html`<a href="${href}" target="_blank" rel="noopener noreferrer">${element.text ? html`${element.text}` : element.url}</a>`;
8514
8596
  },
8515
8597
  mention: ({ element, user }) => {
8516
- return html`<span data-mention>@${user?.name ? html`${user?.name}` : element.id}</span>`;
8598
+ return html`<span data-mention>@${_optionalChain([user, 'optionalAccess', _191 => _191.name]) ? html`${_optionalChain([user, 'optionalAccess', _192 => _192.name])}` : element.id}</span>`;
8517
8599
  }
8518
8600
  };
8519
8601
  var stringifyCommentBodyMarkdownElements = {
@@ -8540,22 +8622,22 @@ var stringifyCommentBodyMarkdownElements = {
8540
8622
  return children;
8541
8623
  },
8542
8624
  link: ({ element, href }) => {
8543
- return markdown`[${element.text ?? element.url}](${href})`;
8625
+ return markdown`[${_nullishCoalesce(element.text, () => ( element.url))}](${href})`;
8544
8626
  },
8545
8627
  mention: ({ element, user }) => {
8546
- return markdown`@${user?.name ?? element.id}`;
8628
+ return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _193 => _193.name]), () => ( element.id))}`;
8547
8629
  }
8548
8630
  };
8549
8631
  async function stringifyCommentBody(body, options) {
8550
- const format = options?.format ?? "plain";
8551
- const separator = options?.separator ?? (format === "markdown" ? "\n\n" : "\n");
8632
+ const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _194 => _194.format]), () => ( "plain"));
8633
+ const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _195 => _195.separator]), () => ( (format === "markdown" ? "\n\n" : "\n")));
8552
8634
  const elements = {
8553
8635
  ...format === "html" ? stringifyCommentBodyHtmlElements : format === "markdown" ? stringifyCommentBodyMarkdownElements : stringifyCommentBodyPlainElements,
8554
- ...options?.elements
8636
+ ..._optionalChain([options, 'optionalAccess', _196 => _196.elements])
8555
8637
  };
8556
8638
  const resolvedUsers = await resolveUsersInCommentBody(
8557
8639
  body,
8558
- options?.resolveUsers
8640
+ _optionalChain([options, 'optionalAccess', _197 => _197.resolveUsers])
8559
8641
  );
8560
8642
  const blocks = body.content.flatMap((block, blockIndex) => {
8561
8643
  switch (block.type) {
@@ -8577,7 +8659,7 @@ async function stringifyCommentBody(body, options) {
8577
8659
  elements.link(
8578
8660
  {
8579
8661
  element: inline,
8580
- href: toAbsoluteUrl(inline.url) ?? inline.url
8662
+ href: _nullishCoalesce(toAbsoluteUrl(inline.url), () => ( inline.url))
8581
8663
  },
8582
8664
  inlineIndex
8583
8665
  )
@@ -8846,12 +8928,12 @@ function legacy_patchImmutableNode(state, path, update) {
8846
8928
  }
8847
8929
  const newState = Object.assign({}, state);
8848
8930
  for (const key in update.updates) {
8849
- if (update.updates[key]?.type === "update") {
8931
+ if (_optionalChain([update, 'access', _198 => _198.updates, 'access', _199 => _199[key], 'optionalAccess', _200 => _200.type]) === "update") {
8850
8932
  const val = update.node.get(key);
8851
8933
  if (val !== void 0) {
8852
8934
  newState[key] = lsonToJson(val);
8853
8935
  }
8854
- } else if (update.updates[key]?.type === "delete") {
8936
+ } else if (_optionalChain([update, 'access', _201 => _201.updates, 'access', _202 => _202[key], 'optionalAccess', _203 => _203.type]) === "delete") {
8855
8937
  delete newState[key];
8856
8938
  }
8857
8939
  }
@@ -8912,12 +8994,12 @@ function legacy_patchImmutableNode(state, path, update) {
8912
8994
  }
8913
8995
  const newState = Object.assign({}, state);
8914
8996
  for (const key in update.updates) {
8915
- if (update.updates[key]?.type === "update") {
8997
+ if (_optionalChain([update, 'access', _204 => _204.updates, 'access', _205 => _205[key], 'optionalAccess', _206 => _206.type]) === "update") {
8916
8998
  const value = update.node.get(key);
8917
8999
  if (value !== void 0) {
8918
9000
  newState[key] = lsonToJson(value);
8919
9001
  }
8920
- } else if (update.updates[key]?.type === "delete") {
9002
+ } else if (_optionalChain([update, 'access', _207 => _207.updates, 'access', _208 => _208[key], 'optionalAccess', _209 => _209.type]) === "delete") {
8921
9003
  delete newState[key];
8922
9004
  }
8923
9005
  }
@@ -8988,9 +9070,9 @@ function makePoller(callback, intervalMs, options) {
8988
9070
  const startTime = performance.now();
8989
9071
  const doc = typeof document !== "undefined" ? document : void 0;
8990
9072
  const win = typeof window !== "undefined" ? window : void 0;
8991
- const maxStaleTimeMs = options?.maxStaleTimeMs ?? Number.POSITIVE_INFINITY;
9073
+ const maxStaleTimeMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _210 => _210.maxStaleTimeMs]), () => ( Number.POSITIVE_INFINITY));
8992
9074
  const context = {
8993
- inForeground: doc?.visibilityState !== "hidden",
9075
+ inForeground: _optionalChain([doc, 'optionalAccess', _211 => _211.visibilityState]) !== "hidden",
8994
9076
  lastSuccessfulPollAt: startTime,
8995
9077
  count: 0,
8996
9078
  backoff: 0
@@ -9032,7 +9114,7 @@ function makePoller(callback, intervalMs, options) {
9032
9114
  return {
9033
9115
  target: mayPoll() ? "@enabled" : "@idle",
9034
9116
  effect: () => {
9035
- context.backoff = BACKOFF_DELAYS2.find((delay) => delay > context.backoff) ?? BACKOFF_DELAYS2[BACKOFF_DELAYS2.length - 1];
9117
+ context.backoff = _nullishCoalesce(BACKOFF_DELAYS2.find((delay) => delay > context.backoff), () => ( BACKOFF_DELAYS2[BACKOFF_DELAYS2.length - 1]));
9036
9118
  }
9037
9119
  };
9038
9120
  },
@@ -9068,11 +9150,11 @@ function makePoller(callback, intervalMs, options) {
9068
9150
  pollNowIfStale();
9069
9151
  }
9070
9152
  function onVisibilityChange() {
9071
- setInForeground(doc?.visibilityState !== "hidden");
9153
+ setInForeground(_optionalChain([doc, 'optionalAccess', _212 => _212.visibilityState]) !== "hidden");
9072
9154
  }
9073
- doc?.addEventListener("visibilitychange", onVisibilityChange);
9074
- win?.addEventListener("online", onVisibilityChange);
9075
- win?.addEventListener("focus", pollNowIfStale);
9155
+ _optionalChain([doc, 'optionalAccess', _213 => _213.addEventListener, 'call', _214 => _214("visibilitychange", onVisibilityChange)]);
9156
+ _optionalChain([win, 'optionalAccess', _215 => _215.addEventListener, 'call', _216 => _216("online", onVisibilityChange)]);
9157
+ _optionalChain([win, 'optionalAccess', _217 => _217.addEventListener, 'call', _218 => _218("focus", pollNowIfStale)]);
9076
9158
  fsm.start();
9077
9159
  return {
9078
9160
  inc,
@@ -9194,11 +9276,6 @@ var SortedList = class _SortedList {
9194
9276
  }
9195
9277
  };
9196
9278
 
9197
- // src/protocol/UserNotificationSettings.ts
9198
- function isNotificationChannelEnabled(settings) {
9199
- return values(settings).every((enabled) => enabled === true);
9200
- }
9201
-
9202
9279
  // src/types/Others.ts
9203
9280
  var TextEditorType = /* @__PURE__ */ ((TextEditorType2) => {
9204
9281
  TextEditorType2["Lexical"] = "lexical";
@@ -9210,94 +9287,96 @@ var TextEditorType = /* @__PURE__ */ ((TextEditorType2) => {
9210
9287
  detectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);
9211
9288
  var CommentsApiError = HttpError;
9212
9289
  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
9290
+
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
+ 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;
9382
+ //# sourceMappingURL=index.cjs.map