@aslaluroba/help-center-react 3.0.21 → 3.2.1

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.
@@ -3682,7 +3682,6 @@ class ApiService {
3682
3682
  _this2.tokenExpiryTime = currentTime + response.expiresIn;
3683
3683
  return _this2.currentToken;
3684
3684
  } catch (error) {
3685
- console.error('Error getting token:', error);
3686
3685
  throw error;
3687
3686
  }
3688
3687
  }
@@ -3741,7 +3740,6 @@ class ApiService {
3741
3740
  if (this.config.onError) {
3742
3741
  this.config.onError(error instanceof Error ? error : new Error('Unknown error occurred'));
3743
3742
  }
3744
- console.error('API Error:', error);
3745
3743
  }
3746
3744
  }
3747
3745
 
@@ -4353,7 +4351,7 @@ var ably = {exports: {}};
4353
4351
  });
4354
4352
  return _withTimeoutAsync2.apply(this, arguments);
4355
4353
  }
4356
- var version = "2.13.0";
4354
+ var version = "2.15.0";
4357
4355
 
4358
4356
  // src/common/lib/util/defaults.ts
4359
4357
  var agent = "ably-js/" + version;
@@ -4601,10 +4599,10 @@ var ably = {exports: {}};
4601
4599
  };
4602
4600
  function defaultGetHeaders(options) {
4603
4601
  var {
4604
- format = defaultHeadersOptions.format,
4602
+ format,
4605
4603
  protocolVersion = defaultHeadersOptions.protocolVersion
4606
4604
  } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4607
- var accept = contentTypes[format];
4605
+ var accept = contentTypes[format != null ? format : options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */];
4608
4606
  return {
4609
4607
  accept,
4610
4608
  "X-Ably-Version": protocolVersion.toString(),
@@ -4613,11 +4611,11 @@ var ably = {exports: {}};
4613
4611
  }
4614
4612
  function defaultPostHeaders(options) {
4615
4613
  var {
4616
- format = defaultHeadersOptions.format,
4614
+ format,
4617
4615
  protocolVersion = defaultHeadersOptions.protocolVersion
4618
4616
  } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4619
- var contentType;
4620
- var accept = contentType = contentTypes[format];
4617
+ var accept = contentTypes[format != null ? format : options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */];
4618
+ var contentType = accept;
4621
4619
  return {
4622
4620
  accept,
4623
4621
  "content-type": contentType,
@@ -4941,7 +4939,9 @@ var ably = {exports: {}};
4941
4939
  tokenUri = function tokenUri(host) {
4942
4940
  return client.baseUri(host) + path;
4943
4941
  };
4944
- var requestHeaders = defaults_default.defaultPostHeaders(_this3.client.options);
4942
+ var requestHeaders = defaults_default.defaultPostHeaders(_this3.client.options, {
4943
+ format: "json" /* json */
4944
+ });
4945
4945
  if (resolvedAuthOptions.requestHeaders) _mixin(requestHeaders, resolvedAuthOptions.requestHeaders);
4946
4946
  logger_default.logAction(_this3.logger, logger_default.LOG_MICRO, "Auth.requestToken().requestToken", "Sending POST to " + path + "; Token params: " + JSON.stringify(signedTokenParams));
4947
4947
  _whenPromiseSettles(_this3.client.http.do(HttpMethods_default.Post, tokenUri, requestHeaders, JSON.stringify(signedTokenParams), null), (err, result) => err ? tokenCb(err) : tokenCb(result.error, result.body, result.unpacked));
@@ -6633,9 +6633,7 @@ var ably = {exports: {}};
6633
6633
  return _asyncToGenerator(function* () {
6634
6634
  var client = _this26.client;
6635
6635
  var format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
6636
- headers = defaults_default.defaultPostHeaders(client.options, {
6637
- format
6638
- }),
6636
+ headers = defaults_default.defaultPostHeaders(client.options),
6639
6637
  params = {};
6640
6638
  var body = _mixin({
6641
6639
  recipient
@@ -6659,9 +6657,7 @@ var ably = {exports: {}};
6659
6657
  var client = _this27.client;
6660
6658
  var body = devicedetails_default.fromValues(device);
6661
6659
  var format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
6662
- headers = defaults_default.defaultPostHeaders(client.options, {
6663
- format
6664
- }),
6660
+ headers = defaults_default.defaultPostHeaders(client.options),
6665
6661
  params = {};
6666
6662
  _mixin(headers, client.options.headers);
6667
6663
  if (client.options.pushFullWait) _mixin(params, {
@@ -6677,9 +6673,7 @@ var ably = {exports: {}};
6677
6673
  return _asyncToGenerator(function* () {
6678
6674
  var client = _this28.client,
6679
6675
  format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
6680
- headers = defaults_default.defaultGetHeaders(client.options, {
6681
- format
6682
- }),
6676
+ headers = defaults_default.defaultGetHeaders(client.options),
6683
6677
  deviceId = deviceIdOrDetails.id || deviceIdOrDetails;
6684
6678
  if (typeof deviceId !== "string" || !deviceId.length) {
6685
6679
  throw new _ErrorInfo2("First argument to DeviceRegistrations#get must be a deviceId string or DeviceDetails", 4e4, 400);
@@ -6695,9 +6689,7 @@ var ably = {exports: {}};
6695
6689
  var client = _this29.client,
6696
6690
  format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
6697
6691
  envelope = _this29.client.http.supportsLinkHeaders ? void 0 : format,
6698
- headers = defaults_default.defaultGetHeaders(client.options, {
6699
- format
6700
- });
6692
+ headers = defaults_default.defaultGetHeaders(client.options);
6701
6693
  _mixin(headers, client.options.headers);
6702
6694
  return new paginatedresource_default(client, "/push/deviceRegistrations", headers, envelope, /*#__PURE__*/function () {
6703
6695
  var _ref3 = _asyncToGenerator(function* (body, headers2, unpacked) {
@@ -6713,10 +6705,7 @@ var ably = {exports: {}};
6713
6705
  var _this30 = this;
6714
6706
  return _asyncToGenerator(function* () {
6715
6707
  var client = _this30.client,
6716
- format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
6717
- headers = defaults_default.defaultGetHeaders(client.options, {
6718
- format
6719
- }),
6708
+ headers = defaults_default.defaultGetHeaders(client.options),
6720
6709
  params = {},
6721
6710
  deviceId = deviceIdOrDetails.id || deviceIdOrDetails;
6722
6711
  if (typeof deviceId !== "string" || !deviceId.length) {
@@ -6757,9 +6746,7 @@ var ably = {exports: {}};
6757
6746
  var client = _this32.client;
6758
6747
  var body = pushchannelsubscription_default.fromValues(subscription);
6759
6748
  var format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
6760
- headers = defaults_default.defaultPostHeaders(client.options, {
6761
- format
6762
- }),
6749
+ headers = defaults_default.defaultPostHeaders(client.options),
6763
6750
  params = {};
6764
6751
  _mixin(headers, client.options.headers);
6765
6752
  if (client.options.pushFullWait) _mixin(params, {
@@ -6776,9 +6763,7 @@ var ably = {exports: {}};
6776
6763
  var client = _this33.client,
6777
6764
  format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
6778
6765
  envelope = _this33.client.http.supportsLinkHeaders ? void 0 : format,
6779
- headers = defaults_default.defaultGetHeaders(client.options, {
6780
- format
6781
- });
6766
+ headers = defaults_default.defaultGetHeaders(client.options);
6782
6767
  _mixin(headers, client.options.headers);
6783
6768
  return new paginatedresource_default(client, "/push/channelSubscriptions", headers, envelope, /*#__PURE__*/function () {
6784
6769
  var _ref4 = _asyncToGenerator(function* (body, headers2, unpacked) {
@@ -6811,9 +6796,7 @@ var ably = {exports: {}};
6811
6796
  var client = _this35.client,
6812
6797
  format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
6813
6798
  envelope = _this35.client.http.supportsLinkHeaders ? void 0 : format,
6814
- headers = defaults_default.defaultGetHeaders(client.options, {
6815
- format
6816
- });
6799
+ headers = defaults_default.defaultGetHeaders(client.options);
6817
6800
  _mixin(headers, client.options.headers);
6818
6801
  if (client.options.pushFullWait) _mixin(params, {
6819
6802
  fullWait: "true"
@@ -6976,9 +6959,7 @@ var ably = {exports: {}};
6976
6959
  var client = _this38.channel.client,
6977
6960
  format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
6978
6961
  envelope = _this38.channel.client.http.supportsLinkHeaders ? void 0 : format,
6979
- headers = defaults_default.defaultGetHeaders(client.options, {
6980
- format
6981
- });
6962
+ headers = defaults_default.defaultGetHeaders(client.options);
6982
6963
  _mixin(headers, client.options.headers);
6983
6964
  return new paginatedresource_default(client, _this38.channel.client.rest.presenceMixin.basePath(_this38), headers, envelope, /*#__PURE__*/function () {
6984
6965
  var _ref6 = _asyncToGenerator(function* (body, headers2, unpacked) {
@@ -7102,6 +7083,21 @@ var ably = {exports: {}};
7102
7083
  } else if (!this.annotations.summary) {
7103
7084
  this.annotations.summary = {};
7104
7085
  }
7086
+ if (this.annotations && this.annotations.summary) {
7087
+ for (var [type, summaryEntry] of Object.entries(this.annotations.summary)) {
7088
+ if (type.endsWith(":distinct.v1") || type.endsWith(":unique.v1") || type.endsWith(":multiple.v1")) {
7089
+ for (var [, entry] of Object.entries(summaryEntry)) {
7090
+ if (!entry.clipped) {
7091
+ entry.clipped = false;
7092
+ }
7093
+ }
7094
+ } else if (type.endsWith(":flag.v1")) {
7095
+ if (!summaryEntry.clipped) {
7096
+ summaryEntry.clipped = false;
7097
+ }
7098
+ }
7099
+ }
7100
+ }
7105
7101
  }
7106
7102
  encode(options) {
7107
7103
  var _this40 = this;
@@ -7251,9 +7247,7 @@ var ably = {exports: {}};
7251
7247
  options = client.options,
7252
7248
  format = options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
7253
7249
  idempotentRestPublishing = client.options.idempotentRestPublishing,
7254
- headers = defaults_default.defaultPostHeaders(client.options, {
7255
- format
7256
- });
7250
+ headers = defaults_default.defaultPostHeaders(client.options);
7257
7251
  _mixin(headers, options.headers);
7258
7252
  if (idempotentRestPublishing && allEmptyIds(messages)) {
7259
7253
  var msgIdBase = yield _randomString(MSG_ID_ENTROPY_BYTES);
@@ -7282,6 +7276,38 @@ var ably = {exports: {}};
7282
7276
  return _this46.client.rest.channelMixin.status(_this46);
7283
7277
  })();
7284
7278
  }
7279
+ getMessage(serialOrMessage) {
7280
+ var _this47 = this;
7281
+ return _asyncToGenerator(function* () {
7282
+ logger_default.logAction(_this47.logger, logger_default.LOG_MICRO, "RestChannel.getMessage()", "channel = " + _this47.name);
7283
+ return _this47.client.rest.channelMixin.getMessage(_this47, serialOrMessage);
7284
+ })();
7285
+ }
7286
+ updateMessage(message, operation, params) {
7287
+ var _this48 = this;
7288
+ return _asyncToGenerator(function* () {
7289
+ logger_default.logAction(_this48.logger, logger_default.LOG_MICRO, "RestChannel.updateMessage()", "channel = " + _this48.name);
7290
+ return _this48.client.rest.channelMixin.updateDeleteMessage(_this48, {
7291
+ isDelete: false
7292
+ }, message, operation, params);
7293
+ })();
7294
+ }
7295
+ deleteMessage(message, operation, params) {
7296
+ var _this49 = this;
7297
+ return _asyncToGenerator(function* () {
7298
+ logger_default.logAction(_this49.logger, logger_default.LOG_MICRO, "RestChannel.deleteMessage()", "channel = " + _this49.name);
7299
+ return _this49.client.rest.channelMixin.updateDeleteMessage(_this49, {
7300
+ isDelete: true
7301
+ }, message, operation, params);
7302
+ })();
7303
+ }
7304
+ getMessageVersions(serialOrMessage, params) {
7305
+ var _this50 = this;
7306
+ return _asyncToGenerator(function* () {
7307
+ logger_default.logAction(_this50.logger, logger_default.LOG_MICRO, "RestChannel.getMessageVersions()", "channel = " + _this50.name);
7308
+ return _this50.client.rest.channelMixin.getMessageVersions(_this50, serialOrMessage, params);
7309
+ })();
7310
+ }
7285
7311
  };
7286
7312
  var restchannel_default = RestChannel;
7287
7313
 
@@ -7310,9 +7336,7 @@ var ably = {exports: {}};
7310
7336
  var client = channel.client,
7311
7337
  format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
7312
7338
  envelope = channel.client.http.supportsLinkHeaders ? void 0 : format,
7313
- headers = defaults_default.defaultGetHeaders(client.options, {
7314
- format
7315
- });
7339
+ headers = defaults_default.defaultGetHeaders(client.options);
7316
7340
  _mixin(headers, client.options.headers);
7317
7341
  return new paginatedresource_default(client, this.basePath(channel) + "/messages", headers, envelope, /*#__PURE__*/function () {
7318
7342
  var _ref7 = _asyncToGenerator(function* (body, headers2, unpacked) {
@@ -7325,16 +7349,81 @@ var ably = {exports: {}};
7325
7349
  }()).get(params);
7326
7350
  }
7327
7351
  static status(channel) {
7328
- var _this47 = this;
7352
+ var _this51 = this;
7329
7353
  return _asyncToGenerator(function* () {
7330
7354
  var format = channel.client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */;
7331
- var headers = defaults_default.defaultPostHeaders(channel.client.options, {
7332
- format
7333
- });
7334
- var response = yield resource_default.get(channel.client, _this47.basePath(channel), headers, {}, format, true);
7355
+ var headers = defaults_default.defaultPostHeaders(channel.client.options);
7356
+ var response = yield resource_default.get(channel.client, _this51.basePath(channel), headers, {}, format, true);
7335
7357
  return response.body;
7336
7358
  })();
7337
7359
  }
7360
+ static getMessage(channel, serialOrMessage) {
7361
+ var _this52 = this;
7362
+ return _asyncToGenerator(function* () {
7363
+ var serial = typeof serialOrMessage === "string" ? serialOrMessage : serialOrMessage.serial;
7364
+ if (!serial) {
7365
+ throw new _ErrorInfo2('This message lacks a serial. Make sure you have enabled "Message annotations, updates, and deletes" in channel settings on your dashboard.', 40003, 400);
7366
+ }
7367
+ var client = channel.client;
7368
+ var format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */;
7369
+ var headers = defaults_default.defaultGetHeaders(client.options);
7370
+ _mixin(headers, client.options.headers);
7371
+ var {
7372
+ body,
7373
+ unpacked
7374
+ } = yield resource_default.get(client, _this52.basePath(channel) + "/messages/" + encodeURIComponent(serial), headers, {}, null, true);
7375
+ var decoded = unpacked ? body : _decodeBody(body, client._MsgPack, format);
7376
+ return _fromEncoded2(decoded, channel);
7377
+ })();
7378
+ }
7379
+ static updateDeleteMessage(channel, opts, message, operation, params) {
7380
+ var _this53 = this;
7381
+ return _asyncToGenerator(function* () {
7382
+ if (!message.serial) {
7383
+ throw new _ErrorInfo2('This message lacks a serial and cannot be updated. Make sure you have enabled "Message annotations, updates, and deletes" in channel settings on your dashboard.', 40003, 400);
7384
+ }
7385
+ var client = channel.client;
7386
+ var format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */;
7387
+ var headers = defaults_default.defaultPostHeaders(client.options);
7388
+ _mixin(headers, client.options.headers);
7389
+ var encoded = null;
7390
+ if (message.data !== void 0) {
7391
+ encoded = yield message_default.fromValues(message).encode(channel.channelOptions);
7392
+ }
7393
+ var req = {
7394
+ serial: message.serial,
7395
+ operation,
7396
+ name: message.name,
7397
+ data: encoded && encoded.data,
7398
+ encoding: encoded && encoded.encoding,
7399
+ extras: message.extras
7400
+ };
7401
+ var requestBody = serialize(req, client._MsgPack, format);
7402
+ var method = opts.isDelete ? resource_default.post : resource_default.patch;
7403
+ var pathSuffix = opts.isDelete ? "/delete" : "";
7404
+ yield method(client, _this53.basePath(channel) + "/messages/" + encodeURIComponent(message.serial) + pathSuffix, requestBody, headers, params || {}, null, true);
7405
+ })();
7406
+ }
7407
+ static getMessageVersions(channel, serialOrMessage, params) {
7408
+ var serial = typeof serialOrMessage === "string" ? serialOrMessage : serialOrMessage.serial;
7409
+ if (!serial) {
7410
+ throw new _ErrorInfo2('This message lacks a serial. Make sure you have enabled "Message annotations, updates, and deletes" in channel settings on your dashboard.', 40003, 400);
7411
+ }
7412
+ var client = channel.client;
7413
+ var format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */;
7414
+ var envelope = channel.client.http.supportsLinkHeaders ? void 0 : format;
7415
+ var headers = defaults_default.defaultGetHeaders(client.options);
7416
+ _mixin(headers, client.options.headers);
7417
+ return new paginatedresource_default(client, this.basePath(channel) + "/messages/" + encodeURIComponent(serial) + "/versions", headers, envelope, /*#__PURE__*/function () {
7418
+ var _ref8 = _asyncToGenerator(function* (body, headers2, unpacked) {
7419
+ var decoded = unpacked ? body : _decodeBody(body, client._MsgPack, format);
7420
+ return _fromEncodedArray2(decoded, channel);
7421
+ });
7422
+ return function (_x62, _x63, _x64) {
7423
+ return _ref8.apply(this, arguments);
7424
+ };
7425
+ }()).get(params || {});
7426
+ }
7338
7427
  };
7339
7428
 
7340
7429
  // src/common/lib/client/restpresencemixin.ts
@@ -7343,22 +7432,20 @@ var ably = {exports: {}};
7343
7432
  return RestChannelMixin.basePath(presence.channel) + "/presence";
7344
7433
  }
7345
7434
  static history(presence, params) {
7346
- var _this48 = this;
7435
+ var _this54 = this;
7347
7436
  return _asyncToGenerator(function* () {
7348
7437
  var client = presence.channel.client,
7349
7438
  format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
7350
7439
  envelope = presence.channel.client.http.supportsLinkHeaders ? void 0 : format,
7351
- headers = defaults_default.defaultGetHeaders(client.options, {
7352
- format
7353
- });
7440
+ headers = defaults_default.defaultGetHeaders(client.options);
7354
7441
  _mixin(headers, client.options.headers);
7355
- return new paginatedresource_default(client, _this48.basePath(presence) + "/history", headers, envelope, /*#__PURE__*/function () {
7356
- var _ref8 = _asyncToGenerator(function* (body, headers2, unpacked) {
7442
+ return new paginatedresource_default(client, _this54.basePath(presence) + "/history", headers, envelope, /*#__PURE__*/function () {
7443
+ var _ref9 = _asyncToGenerator(function* (body, headers2, unpacked) {
7357
7444
  var decoded = unpacked ? body : _decodeBody(body, client._MsgPack, format);
7358
7445
  return _fromEncodedArray(decoded, presence.channel);
7359
7446
  });
7360
- return function (_x62, _x63, _x64) {
7361
- return _ref8.apply(this, arguments);
7447
+ return function (_x65, _x66, _x67) {
7448
+ return _ref9.apply(this, arguments);
7362
7449
  };
7363
7450
  }()).get(params);
7364
7451
  })();
@@ -7380,32 +7467,39 @@ var ably = {exports: {}};
7380
7467
  this.push = new push_default(this.client);
7381
7468
  }
7382
7469
  stats(params) {
7383
- var _this49 = this;
7470
+ var _this55 = this;
7384
7471
  return _asyncToGenerator(function* () {
7385
- var headers = defaults_default.defaultGetHeaders(_this49.client.options),
7386
- format = _this49.client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
7387
- envelope = _this49.client.http.supportsLinkHeaders ? void 0 : format;
7388
- _mixin(headers, _this49.client.options.headers);
7389
- return new paginatedresource_default(_this49.client, "/stats", headers, envelope, function (body, headers2, unpacked) {
7390
- var statsValues = unpacked ? body : JSON.parse(body);
7391
- for (var i = 0; i < statsValues.length; i++) statsValues[i] = stats_default.fromValues(statsValues[i]);
7392
- return statsValues;
7393
- }).get(params);
7472
+ var headers = defaults_default.defaultGetHeaders(_this55.client.options),
7473
+ format = _this55.client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
7474
+ envelope = _this55.client.http.supportsLinkHeaders ? void 0 : format;
7475
+ _mixin(headers, _this55.client.options.headers);
7476
+ return new paginatedresource_default(_this55.client, "/stats", headers, envelope, /*#__PURE__*/function () {
7477
+ var _ref0 = _asyncToGenerator(function* (body, _, unpacked) {
7478
+ var statsValues = unpacked ? body : _decodeBody(body, _this55.client._MsgPack, format);
7479
+ for (var i = 0; i < statsValues.length; i++) statsValues[i] = stats_default.fromValues(statsValues[i]);
7480
+ return statsValues;
7481
+ });
7482
+ return function (_x68, _x69, _x70) {
7483
+ return _ref0.apply(this, arguments);
7484
+ };
7485
+ }()).get(params);
7394
7486
  })();
7395
7487
  }
7396
7488
  time(params) {
7397
- var _this50 = this;
7489
+ var _this56 = this;
7398
7490
  return _asyncToGenerator(function* () {
7399
- var headers = defaults_default.defaultGetHeaders(_this50.client.options);
7400
- if (_this50.client.options.headers) _mixin(headers, _this50.client.options.headers);
7491
+ var headers = defaults_default.defaultGetHeaders(_this56.client.options, {
7492
+ format: "json" /* json */
7493
+ });
7494
+ if (_this56.client.options.headers) _mixin(headers, _this56.client.options.headers);
7401
7495
  var timeUri = host => {
7402
- return _this50.client.baseUri(host) + "/time";
7496
+ return _this56.client.baseUri(host) + "/time";
7403
7497
  };
7404
7498
  var {
7405
7499
  error,
7406
7500
  body,
7407
7501
  unpacked
7408
- } = yield _this50.client.http.do(HttpMethods_default.Get, timeUri, headers, null, params);
7502
+ } = yield _this56.client.http.do(HttpMethods_default.Get, timeUri, headers, null, params);
7409
7503
  if (error) {
7410
7504
  throw error;
7411
7505
  }
@@ -7414,47 +7508,47 @@ var ably = {exports: {}};
7414
7508
  if (!time) {
7415
7509
  throw new _ErrorInfo2("Internal error (unexpected result type from GET /time)", 5e4, 500);
7416
7510
  }
7417
- _this50.client.serverTimeOffset = time - Date.now();
7511
+ _this56.client.serverTimeOffset = time - Date.now();
7418
7512
  return time;
7419
7513
  })();
7420
7514
  }
7421
7515
  request(method, path, version2, params, body, customHeaders) {
7422
- var _this51 = this;
7516
+ var _this57 = this;
7423
7517
  return _asyncToGenerator(function* () {
7424
7518
  var _a2;
7425
7519
  var [encoder, decoder, format] = (() => {
7426
- if (_this51.client.options.useBinaryProtocol) {
7427
- if (!_this51.client._MsgPack) {
7520
+ if (_this57.client.options.useBinaryProtocol) {
7521
+ if (!_this57.client._MsgPack) {
7428
7522
  _throwMissingPluginError("MsgPack");
7429
7523
  }
7430
- return [_this51.client._MsgPack.encode, _this51.client._MsgPack.decode, "msgpack" /* msgpack */];
7524
+ return [_this57.client._MsgPack.encode, _this57.client._MsgPack.decode, "msgpack" /* msgpack */];
7431
7525
  } else {
7432
7526
  return [JSON.stringify, JSON.parse, "json" /* json */];
7433
7527
  }
7434
7528
  })();
7435
- var envelope = _this51.client.http.supportsLinkHeaders ? void 0 : format;
7529
+ var envelope = _this57.client.http.supportsLinkHeaders ? void 0 : format;
7436
7530
  params = params || {};
7437
7531
  var _method = method.toLowerCase();
7438
- var headers = _method == "get" ? defaults_default.defaultGetHeaders(_this51.client.options, {
7532
+ var headers = _method == "get" ? defaults_default.defaultGetHeaders(_this57.client.options, {
7439
7533
  format,
7440
7534
  protocolVersion: version2
7441
- }) : defaults_default.defaultPostHeaders(_this51.client.options, {
7535
+ }) : defaults_default.defaultPostHeaders(_this57.client.options, {
7442
7536
  format,
7443
7537
  protocolVersion: version2
7444
7538
  });
7445
7539
  if (typeof body !== "string") {
7446
7540
  body = (_a2 = encoder(body)) != null ? _a2 : null;
7447
7541
  }
7448
- _mixin(headers, _this51.client.options.headers);
7542
+ _mixin(headers, _this57.client.options.headers);
7449
7543
  if (customHeaders) {
7450
7544
  _mixin(headers, customHeaders);
7451
7545
  }
7452
- var paginatedResource = new paginatedresource_default(_this51.client, path, headers, envelope, /*#__PURE__*/function () {
7453
- var _ref9 = _asyncToGenerator(function* (resbody, headers2, unpacked) {
7546
+ var paginatedResource = new paginatedresource_default(_this57.client, path, headers, envelope, /*#__PURE__*/function () {
7547
+ var _ref1 = _asyncToGenerator(function* (resbody, headers2, unpacked) {
7454
7548
  return _ensureArray(unpacked ? resbody : decoder(resbody));
7455
7549
  });
7456
- return function (_x65, _x66, _x67) {
7457
- return _ref9.apply(this, arguments);
7550
+ return function (_x71, _x72, _x73) {
7551
+ return _ref1.apply(this, arguments);
7458
7552
  };
7459
7553
  }(), /* useHttpPaginatedResponse: */
7460
7554
  true);
@@ -7469,7 +7563,7 @@ var ably = {exports: {}};
7469
7563
  })();
7470
7564
  }
7471
7565
  batchPublish(specOrSpecs) {
7472
- var _this52 = this;
7566
+ var _this58 = this;
7473
7567
  return _asyncToGenerator(function* () {
7474
7568
  var requestBodyDTO;
7475
7569
  var singleSpecMode;
@@ -7480,14 +7574,12 @@ var ably = {exports: {}};
7480
7574
  requestBodyDTO = [specOrSpecs];
7481
7575
  singleSpecMode = true;
7482
7576
  }
7483
- var format = _this52.client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
7484
- headers = defaults_default.defaultPostHeaders(_this52.client.options, {
7485
- format
7486
- });
7487
- if (_this52.client.options.headers) _mixin(headers, _this52.client.options.headers);
7488
- var requestBody = _encodeBody(requestBodyDTO, _this52.client._MsgPack, format);
7489
- var response = yield resource_default.post(_this52.client, "/messages", requestBody, headers, {}, null, true);
7490
- var batchResults = response.unpacked ? response.body : _decodeBody(response.body, _this52.client._MsgPack, format);
7577
+ var format = _this58.client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
7578
+ headers = defaults_default.defaultPostHeaders(_this58.client.options);
7579
+ if (_this58.client.options.headers) _mixin(headers, _this58.client.options.headers);
7580
+ var requestBody = _encodeBody(requestBodyDTO, _this58.client._MsgPack, format);
7581
+ var response = yield resource_default.post(_this58.client, "/messages", requestBody, headers, {}, null, true);
7582
+ var batchResults = response.unpacked ? response.body : _decodeBody(response.body, _this58.client._MsgPack, format);
7491
7583
  if (singleSpecMode) {
7492
7584
  return batchResults[0];
7493
7585
  } else {
@@ -7496,39 +7588,35 @@ var ably = {exports: {}};
7496
7588
  })();
7497
7589
  }
7498
7590
  batchPresence(channels) {
7499
- var _this53 = this;
7591
+ var _this59 = this;
7500
7592
  return _asyncToGenerator(function* () {
7501
- var format = _this53.client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
7502
- headers = defaults_default.defaultPostHeaders(_this53.client.options, {
7503
- format
7504
- });
7505
- if (_this53.client.options.headers) _mixin(headers, _this53.client.options.headers);
7593
+ var format = _this59.client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
7594
+ headers = defaults_default.defaultGetHeaders(_this59.client.options);
7595
+ if (_this59.client.options.headers) _mixin(headers, _this59.client.options.headers);
7506
7596
  var channelsParam = channels.join(",");
7507
- var response = yield resource_default.get(_this53.client, "/presence", headers, {
7597
+ var response = yield resource_default.get(_this59.client, "/presence", headers, {
7508
7598
  channels: channelsParam
7509
7599
  }, null, true);
7510
- return response.unpacked ? response.body : _decodeBody(response.body, _this53.client._MsgPack, format);
7600
+ return response.unpacked ? response.body : _decodeBody(response.body, _this59.client._MsgPack, format);
7511
7601
  })();
7512
7602
  }
7513
7603
  revokeTokens(specifiers, options) {
7514
- var _this54 = this;
7604
+ var _this60 = this;
7515
7605
  return _asyncToGenerator(function* () {
7516
- if (useTokenAuth(_this54.client.options)) {
7606
+ if (useTokenAuth(_this60.client.options)) {
7517
7607
  throw new _ErrorInfo2("Cannot revoke tokens when using token auth", 40162, 401);
7518
7608
  }
7519
- var keyName = _this54.client.options.keyName;
7609
+ var keyName = _this60.client.options.keyName;
7520
7610
  var resolvedOptions = options != null ? options : {};
7521
7611
  var requestBodyDTO = __spreadValues({
7522
7612
  targets: specifiers.map(specifier => "".concat(specifier.type, ":").concat(specifier.value))
7523
7613
  }, resolvedOptions);
7524
- var format = _this54.client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
7525
- headers = defaults_default.defaultPostHeaders(_this54.client.options, {
7526
- format
7527
- });
7528
- if (_this54.client.options.headers) _mixin(headers, _this54.client.options.headers);
7529
- var requestBody = _encodeBody(requestBodyDTO, _this54.client._MsgPack, format);
7530
- var response = yield resource_default.post(_this54.client, "/keys/".concat(keyName, "/revokeTokens"), requestBody, headers, {}, null, true);
7531
- return response.unpacked ? response.body : _decodeBody(response.body, _this54.client._MsgPack, format);
7614
+ var format = _this60.client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
7615
+ headers = defaults_default.defaultPostHeaders(_this60.client.options);
7616
+ if (_this60.client.options.headers) _mixin(headers, _this60.client.options.headers);
7617
+ var requestBody = _encodeBody(requestBodyDTO, _this60.client._MsgPack, format);
7618
+ var response = yield resource_default.post(_this60.client, "/keys/".concat(keyName, "/revokeTokens"), requestBody, headers, {}, null, true);
7619
+ return response.unpacked ? response.body : _decodeBody(response.body, _this60.client._MsgPack, format);
7532
7620
  })();
7533
7621
  }
7534
7622
  };
@@ -7612,7 +7700,7 @@ var ably = {exports: {}};
7612
7700
 
7613
7701
  // src/common/lib/types/annotation.ts
7614
7702
  var actions4 = ["annotation.create", "annotation.delete"];
7615
- function fromEncoded3(_x68, _x69, _x70) {
7703
+ function fromEncoded3(_x74, _x75, _x76) {
7616
7704
  return _fromEncoded8.apply(this, arguments);
7617
7705
  }
7618
7706
  function _fromEncoded8() {
@@ -7622,7 +7710,7 @@ var ably = {exports: {}};
7622
7710
  });
7623
7711
  return _fromEncoded8.apply(this, arguments);
7624
7712
  }
7625
- function fromEncodedArray3(_x71, _x72, _x73) {
7713
+ function fromEncodedArray3(_x77, _x78, _x79) {
7626
7714
  return _fromEncodedArray8.apply(this, arguments);
7627
7715
  }
7628
7716
  function _fromEncodedArray8() {
@@ -7633,7 +7721,7 @@ var ably = {exports: {}};
7633
7721
  });
7634
7722
  return _fromEncodedArray8.apply(this, arguments);
7635
7723
  }
7636
- function _fromEncoded3(_x74, _x75) {
7724
+ function _fromEncoded3(_x80, _x81) {
7637
7725
  return _fromEncoded9.apply(this, arguments);
7638
7726
  }
7639
7727
  function _fromEncoded9() {
@@ -7642,7 +7730,7 @@ var ably = {exports: {}};
7642
7730
  });
7643
7731
  return _fromEncoded9.apply(this, arguments);
7644
7732
  }
7645
- function _fromEncodedArray3(_x76, _x77) {
7733
+ function _fromEncodedArray3(_x82, _x83) {
7646
7734
  return _fromEncodedArray9.apply(this, arguments);
7647
7735
  }
7648
7736
  function _fromEncodedArray9() {
@@ -7655,10 +7743,10 @@ var ably = {exports: {}};
7655
7743
  }
7656
7744
  var Annotation = class _Annotation extends BaseMessage {
7657
7745
  encode() {
7658
- var _this55 = this;
7746
+ var _this61 = this;
7659
7747
  return _asyncToGenerator(function* () {
7660
- var res = Object.assign(new WireAnnotation(), _this55, {
7661
- action: actions4.indexOf(_this55.action || "annotation.create")
7748
+ var res = Object.assign(new WireAnnotation(), _this61, {
7749
+ action: actions4.indexOf(_this61.action || "annotation.create")
7662
7750
  });
7663
7751
  return encode(res, {});
7664
7752
  })();
@@ -7687,10 +7775,10 @@ var ably = {exports: {}};
7687
7775
  return values.map(v => _WireAnnotation.fromValues(v));
7688
7776
  }
7689
7777
  decode(channelOptions, logger) {
7690
- var _this56 = this;
7778
+ var _this62 = this;
7691
7779
  return _asyncToGenerator(function* () {
7692
- var res = Object.assign(new Annotation(), __spreadProps(__spreadValues({}, _this56), {
7693
- action: actions4[_this56.action]
7780
+ var res = Object.assign(new Annotation(), __spreadProps(__spreadValues({}, _this62), {
7781
+ action: actions4[_this62.action]
7694
7782
  }));
7695
7783
  try {
7696
7784
  yield decode(res, channelOptions);
@@ -7759,47 +7847,43 @@ var ably = {exports: {}};
7759
7847
  this.channel = channel;
7760
7848
  }
7761
7849
  publish(msgOrSerial, annotationValues) {
7762
- var _this57 = this;
7850
+ var _this63 = this;
7763
7851
  return _asyncToGenerator(function* () {
7764
7852
  var annotation = constructValidateAnnotation(msgOrSerial, annotationValues);
7765
7853
  var wireAnnotation = yield annotation.encode();
7766
- var client = _this57.channel.client,
7854
+ var client = _this63.channel.client,
7767
7855
  options = client.options,
7768
7856
  format = options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
7769
- headers = defaults_default.defaultPostHeaders(client.options, {
7770
- format
7771
- }),
7857
+ headers = defaults_default.defaultPostHeaders(client.options),
7772
7858
  params = {};
7773
7859
  _mixin(headers, client.options.headers);
7774
7860
  var requestBody = _encodeBody([wireAnnotation], client._MsgPack, format);
7775
- yield resource_default.post(client, basePathForSerial(_this57.channel, annotation.messageSerial), requestBody, headers, params, null, true);
7861
+ yield resource_default.post(client, basePathForSerial(_this63.channel, annotation.messageSerial), requestBody, headers, params, null, true);
7776
7862
  })();
7777
7863
  }
7778
7864
  delete(msgOrSerial, annotationValues) {
7779
- var _this58 = this;
7865
+ var _this64 = this;
7780
7866
  return _asyncToGenerator(function* () {
7781
7867
  annotationValues.action = "annotation.delete";
7782
- return _this58.publish(msgOrSerial, annotationValues);
7868
+ return _this64.publish(msgOrSerial, annotationValues);
7783
7869
  })();
7784
7870
  }
7785
7871
  get(msgOrSerial, params) {
7786
- var _this59 = this;
7872
+ var _this65 = this;
7787
7873
  return _asyncToGenerator(function* () {
7788
- var client = _this59.channel.client,
7874
+ var client = _this65.channel.client,
7789
7875
  messageSerial = serialFromMsgOrSerial(msgOrSerial),
7790
7876
  format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
7791
7877
  envelope = client.http.supportsLinkHeaders ? void 0 : format,
7792
- headers = defaults_default.defaultGetHeaders(client.options, {
7793
- format
7794
- });
7878
+ headers = defaults_default.defaultGetHeaders(client.options);
7795
7879
  _mixin(headers, client.options.headers);
7796
- return new paginatedresource_default(client, basePathForSerial(_this59.channel, messageSerial), headers, envelope, /*#__PURE__*/function () {
7797
- var _ref0 = _asyncToGenerator(function* (body, _, unpacked) {
7880
+ return new paginatedresource_default(client, basePathForSerial(_this65.channel, messageSerial), headers, envelope, /*#__PURE__*/function () {
7881
+ var _ref10 = _asyncToGenerator(function* (body, _, unpacked) {
7798
7882
  var decoded = unpacked ? body : _decodeBody(body, client._MsgPack, format);
7799
- return _fromEncodedArray3(decoded, _this59.channel);
7883
+ return _fromEncodedArray3(decoded, _this65.channel);
7800
7884
  });
7801
- return function (_x78, _x79, _x80) {
7802
- return _ref0.apply(this, arguments);
7885
+ return function (_x84, _x85, _x86) {
7886
+ return _ref10.apply(this, arguments);
7803
7887
  };
7804
7888
  }()).get(params);
7805
7889
  })();
@@ -7970,7 +8054,7 @@ var ably = {exports: {}};
7970
8054
  this._mode = 0;
7971
8055
  this.retryCount = 0;
7972
8056
  this.history = /*#__PURE__*/function () {
7973
- var _ref1 = _asyncToGenerator(function* (params) {
8057
+ var _ref11 = _asyncToGenerator(function* (params) {
7974
8058
  logger_default.logAction(this.logger, logger_default.LOG_MICRO, "RealtimeChannel.history()", "channel = " + this.name);
7975
8059
  var restMixin = this.client.rest.channelMixin;
7976
8060
  if (params && params.untilAttach) {
@@ -7985,8 +8069,8 @@ var ably = {exports: {}};
7985
8069
  }
7986
8070
  return restMixin.history(this, params);
7987
8071
  });
7988
- return function (_x81) {
7989
- return _ref1.apply(this, arguments);
8072
+ return function (_x87) {
8073
+ return _ref11.apply(this, arguments);
7990
8074
  };
7991
8075
  }();
7992
8076
  this.whenState = state => {
@@ -8065,20 +8149,20 @@ var ably = {exports: {}};
8065
8149
  return args;
8066
8150
  }
8067
8151
  setOptions(options) {
8068
- var _this60 = this;
8152
+ var _this66 = this;
8069
8153
  return _asyncToGenerator(function* () {
8070
8154
  var _a2;
8071
- var previousChannelOptions = _this60.channelOptions;
8155
+ var previousChannelOptions = _this66.channelOptions;
8072
8156
  var err = validateChannelOptions(options);
8073
8157
  if (err) {
8074
8158
  throw err;
8075
8159
  }
8076
- _this60.channelOptions = normaliseChannelOptions((_a2 = _this60.client._Crypto) != null ? _a2 : null, _this60.logger, options);
8077
- if (_this60._decodingContext) _this60._decodingContext.channelOptions = _this60.channelOptions;
8078
- if (_this60._shouldReattachToSetOptions(options, previousChannelOptions)) {
8079
- _this60.attachImpl();
8160
+ _this66.channelOptions = normaliseChannelOptions((_a2 = _this66.client._Crypto) != null ? _a2 : null, _this66.logger, options);
8161
+ if (_this66._decodingContext) _this66._decodingContext.channelOptions = _this66.channelOptions;
8162
+ if (_this66._shouldReattachToSetOptions(options, previousChannelOptions)) {
8163
+ _this66.attachImpl();
8080
8164
  return new Promise((resolve, reject) => {
8081
- _this60._allChannelChanges.once(["attached", "update", "detached", "failed"], function (stateChange) {
8165
+ _this66._allChannelChanges.once(["attached", "update", "detached", "failed"], function (stateChange) {
8082
8166
  switch (this.event) {
8083
8167
  case "update":
8084
8168
  case "attached":
@@ -8115,7 +8199,7 @@ var ably = {exports: {}};
8115
8199
  }
8116
8200
  publish() {
8117
8201
  var _arguments2 = arguments,
8118
- _this61 = this;
8202
+ _this67 = this;
8119
8203
  return _asyncToGenerator(function* () {
8120
8204
  var messages;
8121
8205
  var argCount = _arguments2.length;
@@ -8133,20 +8217,20 @@ var ably = {exports: {}};
8133
8217
  data: _arguments2.length <= 1 ? undefined : _arguments2[1]
8134
8218
  })];
8135
8219
  }
8136
- var maxMessageSize = _this61.client.options.maxMessageSize;
8137
- var wireMessages = yield encodeArray(messages, _this61.channelOptions);
8220
+ var maxMessageSize = _this67.client.options.maxMessageSize;
8221
+ var wireMessages = yield encodeArray(messages, _this67.channelOptions);
8138
8222
  var size = getMessagesSize(wireMessages);
8139
8223
  if (size > maxMessageSize) {
8140
8224
  throw new _ErrorInfo2("Maximum size of messages that can be published at once exceeded (was ".concat(size, " bytes; limit is ").concat(maxMessageSize, " bytes)"), 40009, 400);
8141
8225
  }
8142
- _this61.throwIfUnpublishableState();
8143
- logger_default.logAction(_this61.logger, logger_default.LOG_MICRO, "RealtimeChannel.publish()", "sending message; channel state is " + _this61.state + ", message count = " + wireMessages.length);
8226
+ _this67.throwIfUnpublishableState();
8227
+ logger_default.logAction(_this67.logger, logger_default.LOG_MICRO, "RealtimeChannel.publish()", "sending message; channel state is " + _this67.state + ", message count = " + wireMessages.length);
8144
8228
  var pm = fromValues({
8145
8229
  action: actions.MESSAGE,
8146
- channel: _this61.name,
8230
+ channel: _this67.name,
8147
8231
  messages: wireMessages
8148
8232
  });
8149
- return _this61.sendMessage(pm);
8233
+ return _this67.sendMessage(pm);
8150
8234
  })();
8151
8235
  }
8152
8236
  throwIfUnpublishableState() {
@@ -8166,13 +8250,13 @@ var ably = {exports: {}};
8166
8250
  }
8167
8251
  }
8168
8252
  attach() {
8169
- var _this62 = this;
8253
+ var _this68 = this;
8170
8254
  return _asyncToGenerator(function* () {
8171
- if (_this62.state === "attached") {
8255
+ if (_this68.state === "attached") {
8172
8256
  return null;
8173
8257
  }
8174
8258
  return new Promise((resolve, reject) => {
8175
- _this62._attach(false, null, (err, result) => err ? reject(err) : resolve(result));
8259
+ _this68._attach(false, null, (err, result) => err ? reject(err) : resolve(result));
8176
8260
  });
8177
8261
  })();
8178
8262
  }
@@ -8230,25 +8314,25 @@ var ably = {exports: {}};
8230
8314
  this.sendMessage(attachMsg).catch(noop);
8231
8315
  }
8232
8316
  detach() {
8233
- var _this63 = this;
8317
+ var _this69 = this;
8234
8318
  return _asyncToGenerator(function* () {
8235
- var connectionManager = _this63.connectionManager;
8319
+ var connectionManager = _this69.connectionManager;
8236
8320
  if (!connectionManager.activeState()) {
8237
8321
  throw connectionManager.getError();
8238
8322
  }
8239
- switch (_this63.state) {
8323
+ switch (_this69.state) {
8240
8324
  case "suspended":
8241
- _this63.notifyState("detached");
8325
+ _this69.notifyState("detached");
8242
8326
  return;
8243
8327
  case "detached":
8244
8328
  return;
8245
8329
  case "failed":
8246
8330
  throw new _ErrorInfo2("Unable to detach; channel state = failed", 90001, 400);
8247
8331
  default:
8248
- _this63.requestState("detaching");
8332
+ _this69.requestState("detaching");
8249
8333
  case "detaching":
8250
8334
  return new Promise((resolve, reject) => {
8251
- _this63.once(function (stateChange) {
8335
+ _this69.once(function (stateChange) {
8252
8336
  switch (this.event) {
8253
8337
  case "detached":
8254
8338
  resolve();
@@ -8277,22 +8361,22 @@ var ably = {exports: {}};
8277
8361
  }
8278
8362
  subscribe() {
8279
8363
  var _arguments3 = arguments,
8280
- _this64 = this;
8364
+ _this70 = this;
8281
8365
  return _asyncToGenerator(function* () {
8282
8366
  for (var _len0 = _arguments3.length, args = new Array(_len0), _key0 = 0; _key0 < _len0; _key0++) {
8283
8367
  args[_key0] = _arguments3[_key0];
8284
8368
  }
8285
8369
  var [event, listener] = _RealtimeChannel.processListenerArgs(args);
8286
- if (_this64.state === "failed") {
8287
- throw _ErrorInfo2.fromValues(_this64.invalidStateError());
8370
+ if (_this70.state === "failed") {
8371
+ throw _ErrorInfo2.fromValues(_this70.invalidStateError());
8288
8372
  }
8289
8373
  if (event && typeof event === "object" && !Array.isArray(event)) {
8290
- _this64.client._FilteredSubscriptions.subscribeFilter(_this64, event, listener);
8374
+ _this70.client._FilteredSubscriptions.subscribeFilter(_this70, event, listener);
8291
8375
  } else {
8292
- _this64.subscriptions.on(event, listener);
8376
+ _this70.subscriptions.on(event, listener);
8293
8377
  }
8294
- if (_this64.channelOptions.attachOnSubscribe !== false) {
8295
- return _this64.attach();
8378
+ if (_this70.channelOptions.attachOnSubscribe !== false) {
8379
+ return _this70.attach();
8296
8380
  } else {
8297
8381
  return null;
8298
8382
  }
@@ -8331,10 +8415,10 @@ var ably = {exports: {}};
8331
8415
  connectionManager.send(syncMessage);
8332
8416
  }
8333
8417
  sendMessage(msg) {
8334
- var _this65 = this;
8418
+ var _this71 = this;
8335
8419
  return _asyncToGenerator(function* () {
8336
8420
  return new Promise((resolve, reject) => {
8337
- _this65.connectionManager.send(msg, _this65.client.options.queueMessages, err => {
8421
+ _this71.connectionManager.send(msg, _this71.client.options.queueMessages, err => {
8338
8422
  if (err) {
8339
8423
  reject(err);
8340
8424
  } else {
@@ -8345,14 +8429,14 @@ var ably = {exports: {}};
8345
8429
  })();
8346
8430
  }
8347
8431
  sendPresence(presence) {
8348
- var _this66 = this;
8432
+ var _this72 = this;
8349
8433
  return _asyncToGenerator(function* () {
8350
8434
  var msg = fromValues({
8351
8435
  action: actions.PRESENCE,
8352
- channel: _this66.name,
8436
+ channel: _this72.name,
8353
8437
  presence
8354
8438
  });
8355
- return _this66.sendMessage(msg);
8439
+ return _this72.sendMessage(msg);
8356
8440
  })();
8357
8441
  }
8358
8442
  sendState(objectMessages) {
@@ -8365,61 +8449,61 @@ var ably = {exports: {}};
8365
8449
  }
8366
8450
  // Access to this method is synchronised by ConnectionManager#processChannelMessage, in order to synchronise access to the state stored in _decodingContext.
8367
8451
  processMessage(message) {
8368
- var _this67 = this;
8452
+ var _this73 = this;
8369
8453
  return _asyncToGenerator(function* () {
8370
8454
  if (message.action === actions.ATTACHED || message.action === actions.MESSAGE || message.action === actions.PRESENCE || message.action === actions.OBJECT || message.action === actions.ANNOTATION) {
8371
- _this67.setChannelSerial(message.channelSerial);
8455
+ _this73.setChannelSerial(message.channelSerial);
8372
8456
  }
8373
8457
  var syncChannelSerial,
8374
8458
  isSync = false;
8375
8459
  switch (message.action) {
8376
8460
  case actions.ATTACHED:
8377
8461
  {
8378
- _this67.properties.attachSerial = message.channelSerial;
8379
- _this67._mode = message.getMode();
8380
- _this67.params = message.params || {};
8462
+ _this73.properties.attachSerial = message.channelSerial;
8463
+ _this73._mode = message.getMode();
8464
+ _this73.params = message.params || {};
8381
8465
  var modesFromFlags = message.decodeModesFromFlags();
8382
- _this67.modes = modesFromFlags && _allToLowerCase(modesFromFlags) || void 0;
8466
+ _this73.modes = modesFromFlags && _allToLowerCase(modesFromFlags) || void 0;
8383
8467
  var resumed = message.hasFlag("RESUMED");
8384
8468
  var hasPresence = message.hasFlag("HAS_PRESENCE");
8385
8469
  var hasBacklog = message.hasFlag("HAS_BACKLOG");
8386
8470
  var hasObjects = message.hasFlag("HAS_OBJECTS");
8387
- if (_this67.state === "attached") {
8471
+ if (_this73.state === "attached") {
8388
8472
  if (!resumed) {
8389
- if (_this67._presence) {
8390
- _this67._presence.onAttached(hasPresence);
8473
+ if (_this73._presence) {
8474
+ _this73._presence.onAttached(hasPresence);
8391
8475
  }
8392
- if (_this67._objects) {
8393
- _this67._objects.onAttached(hasObjects);
8476
+ if (_this73._objects) {
8477
+ _this73._objects.onAttached(hasObjects);
8394
8478
  }
8395
8479
  }
8396
- var change = new channelstatechange_default(_this67.state, _this67.state, resumed, hasBacklog, message.error);
8397
- _this67._allChannelChanges.emit("update", change);
8398
- if (!resumed || _this67.channelOptions.updateOnAttached) {
8399
- _this67.emit("update", change);
8480
+ var change = new channelstatechange_default(_this73.state, _this73.state, resumed, hasBacklog, message.error);
8481
+ _this73._allChannelChanges.emit("update", change);
8482
+ if (!resumed || _this73.channelOptions.updateOnAttached) {
8483
+ _this73.emit("update", change);
8400
8484
  }
8401
- } else if (_this67.state === "detaching") {
8402
- _this67.checkPendingState();
8485
+ } else if (_this73.state === "detaching") {
8486
+ _this73.checkPendingState();
8403
8487
  } else {
8404
- _this67.notifyState("attached", message.error, resumed, hasPresence, hasBacklog, hasObjects);
8488
+ _this73.notifyState("attached", message.error, resumed, hasPresence, hasBacklog, hasObjects);
8405
8489
  }
8406
8490
  break;
8407
8491
  }
8408
8492
  case actions.DETACHED:
8409
8493
  {
8410
8494
  var detachErr = message.error ? _ErrorInfo2.fromValues(message.error) : new _ErrorInfo2("Channel detached", 90001, 404);
8411
- if (_this67.state === "detaching") {
8412
- _this67.notifyState("detached", detachErr);
8413
- } else if (_this67.state === "attaching") {
8414
- _this67.notifyState("suspended", detachErr);
8415
- } else if (_this67.state === "attached" || _this67.state === "suspended") {
8416
- _this67.requestState("attaching", detachErr);
8495
+ if (_this73.state === "detaching") {
8496
+ _this73.notifyState("detached", detachErr);
8497
+ } else if (_this73.state === "attaching") {
8498
+ _this73.notifyState("suspended", detachErr);
8499
+ } else if (_this73.state === "attached" || _this73.state === "suspended") {
8500
+ _this73.requestState("attaching", detachErr);
8417
8501
  }
8418
8502
  break;
8419
8503
  }
8420
8504
  case actions.SYNC:
8421
8505
  isSync = true;
8422
- syncChannelSerial = _this67.syncChannelSerial = message.channelSerial;
8506
+ syncChannelSerial = _this73.syncChannelSerial = message.channelSerial;
8423
8507
  if (!message.presence) break;
8424
8508
  case actions.PRESENCE:
8425
8509
  {
@@ -8427,45 +8511,45 @@ var ably = {exports: {}};
8427
8511
  break;
8428
8512
  }
8429
8513
  populateFieldsFromParent(message);
8430
- var options = _this67.channelOptions;
8431
- if (_this67._presence) {
8514
+ var options = _this73.channelOptions;
8515
+ if (_this73._presence) {
8432
8516
  var presenceMessages = yield Promise.all(message.presence.map(wpm => {
8433
- return wpm.decode(options, _this67.logger);
8517
+ return wpm.decode(options, _this73.logger);
8434
8518
  }));
8435
- _this67._presence.setPresence(presenceMessages, isSync, syncChannelSerial);
8519
+ _this73._presence.setPresence(presenceMessages, isSync, syncChannelSerial);
8436
8520
  }
8437
8521
  break;
8438
8522
  }
8439
8523
  case actions.OBJECT:
8440
8524
  case actions.OBJECT_SYNC:
8441
8525
  {
8442
- if (!_this67._objects || !message.state) {
8526
+ if (!_this73._objects || !message.state) {
8443
8527
  return;
8444
8528
  }
8445
8529
  populateFieldsFromParent(message);
8446
- var format = _this67.client.connection.connectionManager.getActiveTransportFormat();
8447
- var objectMessages = message.state.map(om => om.decode(_this67.client, format));
8530
+ var format = _this73.client.connection.connectionManager.getActiveTransportFormat();
8531
+ var objectMessages = message.state.map(om => om.decode(_this73.client, format));
8448
8532
  if (message.action === actions.OBJECT) {
8449
- _this67._objects.handleObjectMessages(objectMessages);
8533
+ _this73._objects.handleObjectMessages(objectMessages);
8450
8534
  } else {
8451
- _this67._objects.handleObjectSyncMessages(objectMessages, message.channelSerial);
8535
+ _this73._objects.handleObjectSyncMessages(objectMessages, message.channelSerial);
8452
8536
  }
8453
8537
  break;
8454
8538
  }
8455
8539
  case actions.MESSAGE:
8456
8540
  {
8457
- if (_this67.state !== "attached") {
8458
- logger_default.logAction(_this67.logger, logger_default.LOG_MAJOR, "RealtimeChannel.processMessage()", 'Message "' + message.id + '" skipped as this channel "' + _this67.name + '" state is not "attached" (state is "' + _this67.state + '").');
8541
+ if (_this73.state !== "attached") {
8542
+ logger_default.logAction(_this73.logger, logger_default.LOG_MAJOR, "RealtimeChannel.processMessage()", 'Message "' + message.id + '" skipped as this channel "' + _this73.name + '" state is not "attached" (state is "' + _this73.state + '").');
8459
8543
  return;
8460
8544
  }
8461
8545
  populateFieldsFromParent(message);
8462
8546
  var encoded = message.messages,
8463
8547
  firstMessage = encoded[0],
8464
8548
  lastMessage = encoded[encoded.length - 1];
8465
- if (firstMessage.extras && firstMessage.extras.delta && firstMessage.extras.delta.from !== _this67._lastPayload.messageId) {
8466
- var msg = 'Delta message decode failure - previous message not available for message "' + message.id + '" on this channel "' + _this67.name + '".';
8467
- logger_default.logAction(_this67.logger, logger_default.LOG_ERROR, "RealtimeChannel.processMessage()", msg);
8468
- _this67._startDecodeFailureRecovery(new _ErrorInfo2(msg, 40018, 400));
8549
+ if (firstMessage.extras && firstMessage.extras.delta && firstMessage.extras.delta.from !== _this73._lastPayload.messageId) {
8550
+ var msg = 'Delta message decode failure - previous message not available for message "' + message.id + '" on this channel "' + _this73.name + '".';
8551
+ logger_default.logAction(_this73.logger, logger_default.LOG_ERROR, "RealtimeChannel.processMessage()", msg);
8552
+ _this73._startDecodeFailureRecovery(new _ErrorInfo2(msg, 40018, 400));
8469
8553
  break;
8470
8554
  }
8471
8555
  var messages = [];
@@ -8473,34 +8557,34 @@ var ably = {exports: {}};
8473
8557
  var {
8474
8558
  decoded,
8475
8559
  err
8476
- } = yield encoded[i].decodeWithErr(_this67._decodingContext, _this67.logger);
8560
+ } = yield encoded[i].decodeWithErr(_this73._decodingContext, _this73.logger);
8477
8561
  messages[i] = decoded;
8478
8562
  if (err) {
8479
8563
  switch (err.code) {
8480
8564
  case 40018:
8481
- _this67._startDecodeFailureRecovery(err);
8565
+ _this73._startDecodeFailureRecovery(err);
8482
8566
  return;
8483
8567
  case 40019:
8484
8568
  case 40021:
8485
- _this67.notifyState("failed", err);
8569
+ _this73.notifyState("failed", err);
8486
8570
  return;
8487
8571
  }
8488
8572
  }
8489
8573
  }
8490
- _this67._lastPayload.messageId = lastMessage.id;
8491
- _this67._lastPayload.protocolMessageChannelSerial = message.channelSerial;
8492
- _this67.onEvent(messages);
8574
+ _this73._lastPayload.messageId = lastMessage.id;
8575
+ _this73._lastPayload.protocolMessageChannelSerial = message.channelSerial;
8576
+ _this73.onEvent(messages);
8493
8577
  break;
8494
8578
  }
8495
8579
  case actions.ANNOTATION:
8496
8580
  {
8497
8581
  populateFieldsFromParent(message);
8498
- var _options = _this67.channelOptions;
8499
- if (_this67._annotations) {
8582
+ var _options = _this73.channelOptions;
8583
+ if (_this73._annotations) {
8500
8584
  var annotations = yield Promise.all((message.annotations || []).map(wpm => {
8501
- return wpm.decode(_options, _this67.logger);
8585
+ return wpm.decode(_options, _this73.logger);
8502
8586
  }));
8503
- _this67._annotations._processIncoming(annotations);
8587
+ _this73._annotations._processIncoming(annotations);
8504
8588
  }
8505
8589
  break;
8506
8590
  }
@@ -8508,14 +8592,14 @@ var ably = {exports: {}};
8508
8592
  {
8509
8593
  var _err = message.error;
8510
8594
  if (_err && _err.code == 80016) {
8511
- _this67.checkPendingState();
8595
+ _this73.checkPendingState();
8512
8596
  } else {
8513
- _this67.notifyState("failed", _ErrorInfo2.fromValues(_err));
8597
+ _this73.notifyState("failed", _ErrorInfo2.fromValues(_err));
8514
8598
  }
8515
8599
  break;
8516
8600
  }
8517
8601
  default:
8518
- logger_default.logAction(_this67.logger, logger_default.LOG_MAJOR, "RealtimeChannel.processMessage()", "Protocol error: unrecognised message action (" + message.action + ")");
8602
+ logger_default.logAction(_this73.logger, logger_default.LOG_MAJOR, "RealtimeChannel.processMessage()", "Protocol error: unrecognised message action (" + message.action + ")");
8519
8603
  }
8520
8604
  })();
8521
8605
  }
@@ -8671,9 +8755,45 @@ var ably = {exports: {}};
8671
8755
  }
8672
8756
  }
8673
8757
  status() {
8674
- var _this68 = this;
8758
+ var _this74 = this;
8675
8759
  return _asyncToGenerator(function* () {
8676
- return _this68.client.rest.channelMixin.status(_this68);
8760
+ return _this74.client.rest.channelMixin.status(_this74);
8761
+ })();
8762
+ }
8763
+ getMessage(serialOrMessage) {
8764
+ var _this75 = this;
8765
+ return _asyncToGenerator(function* () {
8766
+ logger_default.logAction(_this75.logger, logger_default.LOG_MICRO, "RealtimeChannel.getMessage()", "channel = " + _this75.name);
8767
+ var restMixin = _this75.client.rest.channelMixin;
8768
+ return restMixin.getMessage(_this75, serialOrMessage);
8769
+ })();
8770
+ }
8771
+ updateMessage(message, operation, params) {
8772
+ var _this76 = this;
8773
+ return _asyncToGenerator(function* () {
8774
+ logger_default.logAction(_this76.logger, logger_default.LOG_MICRO, "RealtimeChannel.updateMessage()", "channel = " + _this76.name);
8775
+ var restMixin = _this76.client.rest.channelMixin;
8776
+ return restMixin.updateDeleteMessage(_this76, {
8777
+ isDelete: false
8778
+ }, message, operation, params);
8779
+ })();
8780
+ }
8781
+ deleteMessage(message, operation, params) {
8782
+ var _this77 = this;
8783
+ return _asyncToGenerator(function* () {
8784
+ logger_default.logAction(_this77.logger, logger_default.LOG_MICRO, "RealtimeChannel.deleteMessage()", "channel = " + _this77.name);
8785
+ var restMixin = _this77.client.rest.channelMixin;
8786
+ return restMixin.updateDeleteMessage(_this77, {
8787
+ isDelete: true
8788
+ }, message, operation, params);
8789
+ })();
8790
+ }
8791
+ getMessageVersions(serialOrMessage, params) {
8792
+ var _this78 = this;
8793
+ return _asyncToGenerator(function* () {
8794
+ logger_default.logAction(_this78.logger, logger_default.LOG_MICRO, "RealtimeChannel.getMessageVersions()", "channel = " + _this78.name);
8795
+ var restMixin = _this78.client.rest.channelMixin;
8796
+ return restMixin.getMessageVersions(_this78, serialOrMessage, params);
8677
8797
  })();
8678
8798
  }
8679
8799
  };
@@ -8692,31 +8812,31 @@ var ably = {exports: {}};
8692
8812
  this.subscriptions = new eventemitter_default(this.logger);
8693
8813
  }
8694
8814
  publish(msgOrSerial, annotationValues) {
8695
- var _this69 = this;
8815
+ var _this79 = this;
8696
8816
  return _asyncToGenerator(function* () {
8697
- var channelName = _this69.channel.name;
8817
+ var channelName = _this79.channel.name;
8698
8818
  var annotation = constructValidateAnnotation(msgOrSerial, annotationValues);
8699
8819
  var wireAnnotation = yield annotation.encode();
8700
- _this69.channel.throwIfUnpublishableState();
8701
- logger_default.logAction(_this69.logger, logger_default.LOG_MICRO, "RealtimeAnnotations.publish()", "channelName = " + channelName + ", sending annotation with messageSerial = " + annotation.messageSerial + ", type = " + annotation.type);
8820
+ _this79.channel.throwIfUnpublishableState();
8821
+ logger_default.logAction(_this79.logger, logger_default.LOG_MICRO, "RealtimeAnnotations.publish()", "channelName = " + channelName + ", sending annotation with messageSerial = " + annotation.messageSerial + ", type = " + annotation.type);
8702
8822
  var pm = fromValues({
8703
8823
  action: actions.ANNOTATION,
8704
8824
  channel: channelName,
8705
8825
  annotations: [wireAnnotation]
8706
8826
  });
8707
- return _this69.channel.sendMessage(pm);
8827
+ return _this79.channel.sendMessage(pm);
8708
8828
  })();
8709
8829
  }
8710
8830
  delete(msgOrSerial, annotationValues) {
8711
- var _this70 = this;
8831
+ var _this80 = this;
8712
8832
  return _asyncToGenerator(function* () {
8713
8833
  annotationValues.action = "annotation.delete";
8714
- return _this70.publish(msgOrSerial, annotationValues);
8834
+ return _this80.publish(msgOrSerial, annotationValues);
8715
8835
  })();
8716
8836
  }
8717
8837
  subscribe() {
8718
8838
  var _arguments4 = arguments,
8719
- _this71 = this;
8839
+ _this81 = this;
8720
8840
  return _asyncToGenerator(function* () {
8721
8841
  for (var _len10 = _arguments4.length, _args = new Array(_len10), _key10 = 0; _key10 < _len10; _key10++) {
8722
8842
  _args[_key10] = _arguments4[_key10];
@@ -8724,15 +8844,15 @@ var ably = {exports: {}};
8724
8844
  var args = realtimechannel_default.processListenerArgs(_args);
8725
8845
  var event = args[0];
8726
8846
  var listener = args[1];
8727
- var channel = _this71.channel;
8847
+ var channel = _this81.channel;
8728
8848
  if (channel.state === "failed") {
8729
8849
  throw _ErrorInfo2.fromValues(channel.invalidStateError());
8730
8850
  }
8731
- _this71.subscriptions.on(event, listener);
8732
- if (_this71.channel.channelOptions.attachOnSubscribe !== false) {
8851
+ _this81.subscriptions.on(event, listener);
8852
+ if (_this81.channel.channelOptions.attachOnSubscribe !== false) {
8733
8853
  yield channel.attach();
8734
8854
  }
8735
- if ((_this71.channel.state === "attached" && _this71.channel._mode & flags.ANNOTATION_SUBSCRIBE) === 0) {
8855
+ if ((_this81.channel.state === "attached" && _this81.channel._mode & flags.ANNOTATION_SUBSCRIBE) === 0) {
8736
8856
  throw new _ErrorInfo2("You are trying to add an annotation listener, but you haven't requested the annotation_subscribe channel mode in ChannelOptions, so this won't do anything (we only deliver annotations to clients who have explicitly requested them)", 93001, 400);
8737
8857
  }
8738
8858
  })();
@@ -8752,9 +8872,9 @@ var ably = {exports: {}};
8752
8872
  }
8753
8873
  }
8754
8874
  get(msgOrSerial, params) {
8755
- var _this72 = this;
8875
+ var _this82 = this;
8756
8876
  return _asyncToGenerator(function* () {
8757
- return restannotations_default.prototype.get.call(_this72, msgOrSerial, params);
8877
+ return restannotations_default.prototype.get.call(_this82, msgOrSerial, params);
8758
8878
  })();
8759
8879
  }
8760
8880
  };
@@ -10416,23 +10536,23 @@ var ably = {exports: {}};
10416
10536
  }
10417
10537
  }
10418
10538
  processChannelMessage(message) {
10419
- var _this73 = this;
10539
+ var _this83 = this;
10420
10540
  return _asyncToGenerator(function* () {
10421
- yield _this73.realtime.channels.processChannelMessage(message);
10541
+ yield _this83.realtime.channels.processChannelMessage(message);
10422
10542
  })();
10423
10543
  }
10424
10544
  ping() {
10425
- var _this74 = this;
10545
+ var _this84 = this;
10426
10546
  return _asyncToGenerator(function* () {
10427
10547
  var _a2;
10428
- if (_this74.state.state !== "connected") {
10548
+ if (_this84.state.state !== "connected") {
10429
10549
  throw new _ErrorInfo2("Unable to ping service; not connected", 4e4, 400);
10430
10550
  }
10431
- var transport = (_a2 = _this74.activeProtocol) == null ? void 0 : _a2.getTransport();
10551
+ var transport = (_a2 = _this84.activeProtocol) == null ? void 0 : _a2.getTransport();
10432
10552
  if (!transport) {
10433
- throw _this74.getStateError();
10553
+ throw _this84.getStateError();
10434
10554
  }
10435
- logger_default.logAction(_this74.logger, logger_default.LOG_MINOR, "ConnectionManager.ping()", "transport = " + transport);
10555
+ logger_default.logAction(_this84.logger, logger_default.LOG_MINOR, "ConnectionManager.ping()", "transport = " + transport);
10436
10556
  var pingStart = Date.now();
10437
10557
  var id = _cheapRandStr();
10438
10558
  return _withTimeoutAsync(new Promise(resolve => {
@@ -10444,7 +10564,7 @@ var ably = {exports: {}};
10444
10564
  };
10445
10565
  transport.on("heartbeat", onHeartbeat);
10446
10566
  transport.ping(id);
10447
- }), _this74.options.timeouts.realtimeRequestTimeout, "Timeout waiting for heartbeat response");
10567
+ }), _this84.options.timeouts.realtimeRequestTimeout, "Timeout waiting for heartbeat response");
10448
10568
  })();
10449
10569
  }
10450
10570
  abort(error) {
@@ -10593,10 +10713,10 @@ var ably = {exports: {}};
10593
10713
  });
10594
10714
  }
10595
10715
  ping() {
10596
- var _this75 = this;
10716
+ var _this85 = this;
10597
10717
  return _asyncToGenerator(function* () {
10598
- logger_default.logAction(_this75.logger, logger_default.LOG_MINOR, "Connection.ping()", "");
10599
- return _this75.connectionManager.ping();
10718
+ logger_default.logAction(_this85.logger, logger_default.LOG_MINOR, "Connection.ping()", "");
10719
+ return _this85.connectionManager.ping();
10600
10720
  })();
10601
10721
  }
10602
10722
  close() {
@@ -10652,6 +10772,9 @@ var ably = {exports: {}};
10652
10772
  get channels() {
10653
10773
  return this._channels;
10654
10774
  }
10775
+ get clientId() {
10776
+ return this.auth.clientId;
10777
+ }
10655
10778
  connect() {
10656
10779
  logger_default.logAction(this.logger, logger_default.LOG_MINOR, "Realtime.connect()", "");
10657
10780
  this.connection.connect();
@@ -10692,16 +10815,16 @@ var ably = {exports: {}};
10692
10815
  }
10693
10816
  // Access to this method is synchronised by ConnectionManager#processChannelMessage.
10694
10817
  processChannelMessage(msg) {
10695
- var _this76 = this;
10818
+ var _this86 = this;
10696
10819
  return _asyncToGenerator(function* () {
10697
10820
  var channelName = msg.channel;
10698
10821
  if (channelName === void 0) {
10699
- logger_default.logAction(_this76.logger, logger_default.LOG_ERROR, "Channels.processChannelMessage()", "received event unspecified channel, action = " + msg.action);
10822
+ logger_default.logAction(_this86.logger, logger_default.LOG_ERROR, "Channels.processChannelMessage()", "received event unspecified channel, action = " + msg.action);
10700
10823
  return;
10701
10824
  }
10702
- var channel = _this76.all[channelName];
10825
+ var channel = _this86.all[channelName];
10703
10826
  if (!channel) {
10704
- logger_default.logAction(_this76.logger, logger_default.LOG_ERROR, "Channels.processChannelMessage()", "received event for non-existent channel: " + channelName);
10827
+ logger_default.logAction(_this86.logger, logger_default.LOG_ERROR, "Channels.processChannelMessage()", "received event for non-existent channel: " + channelName);
10705
10828
  return;
10706
10829
  }
10707
10830
  yield channel.processMessage(msg);
@@ -10956,43 +11079,43 @@ var ably = {exports: {}};
10956
11079
  this.pendingPresence = [];
10957
11080
  }
10958
11081
  enter(data) {
10959
- var _this77 = this;
11082
+ var _this87 = this;
10960
11083
  return _asyncToGenerator(function* () {
10961
- if (isAnonymousOrWildcard(_this77)) {
11084
+ if (isAnonymousOrWildcard(_this87)) {
10962
11085
  throw new _ErrorInfo2("clientId must be specified to enter a presence channel", 40012, 400);
10963
11086
  }
10964
- return _this77._enterOrUpdateClient(void 0, void 0, data, "enter");
11087
+ return _this87._enterOrUpdateClient(void 0, void 0, data, "enter");
10965
11088
  })();
10966
11089
  }
10967
11090
  update(data) {
10968
- var _this78 = this;
11091
+ var _this88 = this;
10969
11092
  return _asyncToGenerator(function* () {
10970
- if (isAnonymousOrWildcard(_this78)) {
11093
+ if (isAnonymousOrWildcard(_this88)) {
10971
11094
  throw new _ErrorInfo2("clientId must be specified to update presence data", 40012, 400);
10972
11095
  }
10973
- return _this78._enterOrUpdateClient(void 0, void 0, data, "update");
11096
+ return _this88._enterOrUpdateClient(void 0, void 0, data, "update");
10974
11097
  })();
10975
11098
  }
10976
11099
  enterClient(clientId, data) {
10977
- var _this79 = this;
11100
+ var _this89 = this;
10978
11101
  return _asyncToGenerator(function* () {
10979
- return _this79._enterOrUpdateClient(void 0, clientId, data, "enter");
11102
+ return _this89._enterOrUpdateClient(void 0, clientId, data, "enter");
10980
11103
  })();
10981
11104
  }
10982
11105
  updateClient(clientId, data) {
10983
- var _this80 = this;
11106
+ var _this90 = this;
10984
11107
  return _asyncToGenerator(function* () {
10985
- return _this80._enterOrUpdateClient(void 0, clientId, data, "update");
11108
+ return _this90._enterOrUpdateClient(void 0, clientId, data, "update");
10986
11109
  })();
10987
11110
  }
10988
11111
  _enterOrUpdateClient(id, clientId, data, action) {
10989
- var _this81 = this;
11112
+ var _this91 = this;
10990
11113
  return _asyncToGenerator(function* () {
10991
- var channel = _this81.channel;
11114
+ var channel = _this91.channel;
10992
11115
  if (!channel.connectionManager.activeState()) {
10993
11116
  throw channel.connectionManager.getError();
10994
11117
  }
10995
- logger_default.logAction(_this81.logger, logger_default.LOG_MICRO, "RealtimePresence." + action + "Client()", "channel = " + channel.name + ", id = " + id + ", client = " + (clientId || "(implicit) " + getClientId(_this81)));
11118
+ logger_default.logAction(_this91.logger, logger_default.LOG_MICRO, "RealtimePresence." + action + "Client()", "channel = " + channel.name + ", id = " + id + ", client = " + (clientId || "(implicit) " + getClientId(_this91)));
10996
11119
  var presence = presencemessage_default.fromData(data);
10997
11120
  presence.action = action;
10998
11121
  if (id) {
@@ -11010,7 +11133,7 @@ var ably = {exports: {}};
11010
11133
  channel.attach();
11011
11134
  case "attaching":
11012
11135
  return new Promise((resolve, reject) => {
11013
- _this81.pendingPresence.push({
11136
+ _this91.pendingPresence.push({
11014
11137
  presence: wirePresMsg,
11015
11138
  callback: err => err ? reject(err) : resolve()
11016
11139
  });
@@ -11025,22 +11148,22 @@ var ably = {exports: {}};
11025
11148
  })();
11026
11149
  }
11027
11150
  leave(data) {
11028
- var _this82 = this;
11151
+ var _this92 = this;
11029
11152
  return _asyncToGenerator(function* () {
11030
- if (isAnonymousOrWildcard(_this82)) {
11153
+ if (isAnonymousOrWildcard(_this92)) {
11031
11154
  throw new _ErrorInfo2("clientId must have been specified to enter or leave a presence channel", 40012, 400);
11032
11155
  }
11033
- return _this82.leaveClient(void 0, data);
11156
+ return _this92.leaveClient(void 0, data);
11034
11157
  })();
11035
11158
  }
11036
11159
  leaveClient(clientId, data) {
11037
- var _this83 = this;
11160
+ var _this93 = this;
11038
11161
  return _asyncToGenerator(function* () {
11039
- var channel = _this83.channel;
11162
+ var channel = _this93.channel;
11040
11163
  if (!channel.connectionManager.activeState()) {
11041
11164
  throw channel.connectionManager.getError();
11042
11165
  }
11043
- logger_default.logAction(_this83.logger, logger_default.LOG_MICRO, "RealtimePresence.leaveClient()", "leaving; channel = " + _this83.channel.name + ", client = " + clientId);
11166
+ logger_default.logAction(_this93.logger, logger_default.LOG_MICRO, "RealtimePresence.leaveClient()", "leaving; channel = " + _this93.channel.name + ", client = " + clientId);
11044
11167
  var presence = presencemessage_default.fromData(data);
11045
11168
  presence.action = "leave";
11046
11169
  if (clientId) {
@@ -11052,7 +11175,7 @@ var ably = {exports: {}};
11052
11175
  return channel.sendPresence([wirePresMsg]);
11053
11176
  case "attaching":
11054
11177
  return new Promise((resolve, reject) => {
11055
- _this83.pendingPresence.push({
11178
+ _this93.pendingPresence.push({
11056
11179
  presence: wirePresMsg,
11057
11180
  callback: err => err ? reject(err) : resolve()
11058
11181
  });
@@ -11068,14 +11191,14 @@ var ably = {exports: {}};
11068
11191
  })();
11069
11192
  }
11070
11193
  get(params) {
11071
- var _this84 = this;
11194
+ var _this94 = this;
11072
11195
  return _asyncToGenerator(function* () {
11073
11196
  var waitForSync = !params || ("waitForSync" in params ? params.waitForSync : true);
11074
11197
  return new Promise((resolve, reject) => {
11075
11198
  function returnMembers(members) {
11076
11199
  resolve(params ? members.list(params) : members.values());
11077
11200
  }
11078
- if (_this84.channel.state === "suspended") {
11201
+ if (_this94.channel.state === "suspended") {
11079
11202
  if (waitForSync) {
11080
11203
  reject(_ErrorInfo2.fromValues({
11081
11204
  statusCode: 400,
@@ -11083,12 +11206,12 @@ var ably = {exports: {}};
11083
11206
  message: "Presence state is out of sync due to channel being in the SUSPENDED state"
11084
11207
  }));
11085
11208
  } else {
11086
- returnMembers(_this84.members);
11209
+ returnMembers(_this94.members);
11087
11210
  }
11088
11211
  return;
11089
11212
  }
11090
- waitAttached(_this84.channel, err => reject(err), () => {
11091
- var members = _this84.members;
11213
+ waitAttached(_this94.channel, err => reject(err), () => {
11214
+ var members = _this94.members;
11092
11215
  if (waitForSync) {
11093
11216
  members.waitSync(function () {
11094
11217
  returnMembers(members);
@@ -11101,19 +11224,19 @@ var ably = {exports: {}};
11101
11224
  })();
11102
11225
  }
11103
11226
  history(params) {
11104
- var _this85 = this;
11227
+ var _this95 = this;
11105
11228
  return _asyncToGenerator(function* () {
11106
- logger_default.logAction(_this85.logger, logger_default.LOG_MICRO, "RealtimePresence.history()", "channel = " + _this85.name);
11107
- var restMixin = _this85.channel.client.rest.presenceMixin;
11229
+ logger_default.logAction(_this95.logger, logger_default.LOG_MICRO, "RealtimePresence.history()", "channel = " + _this95.name);
11230
+ var restMixin = _this95.channel.client.rest.presenceMixin;
11108
11231
  if (params && params.untilAttach) {
11109
- if (_this85.channel.state === "attached") {
11232
+ if (_this95.channel.state === "attached") {
11110
11233
  delete params.untilAttach;
11111
- params.from_serial = _this85.channel.properties.attachSerial;
11234
+ params.from_serial = _this95.channel.properties.attachSerial;
11112
11235
  } else {
11113
- throw new _ErrorInfo2("option untilAttach requires the channel to be attached, was: " + _this85.channel.state, 4e4, 400);
11236
+ throw new _ErrorInfo2("option untilAttach requires the channel to be attached, was: " + _this95.channel.state, 4e4, 400);
11114
11237
  }
11115
11238
  }
11116
- return restMixin.history(_this85, params);
11239
+ return restMixin.history(_this95, params);
11117
11240
  })();
11118
11241
  }
11119
11242
  setPresence(presenceSet, isSync, syncChannelSerial) {
@@ -11241,7 +11364,7 @@ var ably = {exports: {}};
11241
11364
  }
11242
11365
  subscribe() {
11243
11366
  var _arguments5 = arguments,
11244
- _this86 = this;
11367
+ _this96 = this;
11245
11368
  return _asyncToGenerator(function* () {
11246
11369
  for (var _len12 = _arguments5.length, _args = new Array(_len12), _key12 = 0; _key12 < _len12; _key12++) {
11247
11370
  _args[_key12] = _arguments5[_key12];
@@ -11249,11 +11372,11 @@ var ably = {exports: {}};
11249
11372
  var args = realtimechannel_default.processListenerArgs(_args);
11250
11373
  var event = args[0];
11251
11374
  var listener = args[1];
11252
- var channel = _this86.channel;
11375
+ var channel = _this96.channel;
11253
11376
  if (channel.state === "failed") {
11254
11377
  throw _ErrorInfo2.fromValues(channel.invalidStateError());
11255
11378
  }
11256
- _this86.subscriptions.on(event, listener);
11379
+ _this96.subscriptions.on(event, listener);
11257
11380
  if (channel.channelOptions.attachOnSubscribe !== false) {
11258
11381
  yield channel.attach();
11259
11382
  }
@@ -11425,8 +11548,8 @@ var ably = {exports: {}};
11425
11548
  isRef: !!((_f = (_e = m.extras) == null ? void 0 : _e.ref) == null ? void 0 : _f.timeserial),
11426
11549
  clientId: m.clientId
11427
11550
  };
11428
- if (Object.entries(filter).find(_ref10 => {
11429
- var [key, value] = _ref10;
11551
+ if (Object.entries(filter).find(_ref12 => {
11552
+ var [key, value] = _ref12;
11430
11553
  return value !== void 0 ? mapping[key] !== value : false;
11431
11554
  })) {
11432
11555
  return;
@@ -11454,8 +11577,8 @@ var ably = {exports: {}};
11454
11577
  return [];
11455
11578
  }
11456
11579
  if (!realListener && filter) {
11457
- return Array.from(channel.filteredSubscriptions.entries()).map(_ref11 => {
11458
- var [key, filterMaps] = _ref11;
11580
+ return Array.from(channel.filteredSubscriptions.entries()).map(_ref13 => {
11581
+ var [key, filterMaps] = _ref13;
11459
11582
  var _a2;
11460
11583
  var listenerMaps = filterMaps.get(filter);
11461
11584
  filterMaps.delete(filter);
@@ -11927,38 +12050,38 @@ var ably = {exports: {}};
11927
12050
  return output;
11928
12051
  }
11929
12052
  encrypt(plaintext) {
11930
- var _this87 = this;
12053
+ var _this97 = this;
11931
12054
  return _asyncToGenerator(function* () {
11932
- logger_default.logAction(_this87.logger, logger_default.LOG_MICRO, "CBCCipher.encrypt()", "");
11933
- var iv = yield _this87.getIv();
11934
- var cryptoKey = yield crypto.subtle.importKey("raw", _this87.key, _this87.webCryptoAlgorithm, false, ["encrypt"]);
12055
+ logger_default.logAction(_this97.logger, logger_default.LOG_MICRO, "CBCCipher.encrypt()", "");
12056
+ var iv = yield _this97.getIv();
12057
+ var cryptoKey = yield crypto.subtle.importKey("raw", _this97.key, _this97.webCryptoAlgorithm, false, ["encrypt"]);
11935
12058
  var ciphertext = yield crypto.subtle.encrypt({
11936
- name: _this87.webCryptoAlgorithm,
12059
+ name: _this97.webCryptoAlgorithm,
11937
12060
  iv
11938
12061
  }, cryptoKey, plaintext);
11939
- return _this87.concat(iv, ciphertext);
12062
+ return _this97.concat(iv, ciphertext);
11940
12063
  })();
11941
12064
  }
11942
12065
  decrypt(ciphertext) {
11943
- var _this88 = this;
12066
+ var _this98 = this;
11944
12067
  return _asyncToGenerator(function* () {
11945
- logger_default.logAction(_this88.logger, logger_default.LOG_MICRO, "CBCCipher.decrypt()", "");
12068
+ logger_default.logAction(_this98.logger, logger_default.LOG_MICRO, "CBCCipher.decrypt()", "");
11946
12069
  var ciphertextArrayBuffer = bufferUtils.toArrayBuffer(ciphertext);
11947
12070
  var iv = ciphertextArrayBuffer.slice(0, DEFAULT_BLOCKLENGTH);
11948
12071
  var ciphertextBody = ciphertextArrayBuffer.slice(DEFAULT_BLOCKLENGTH);
11949
- var cryptoKey = yield crypto.subtle.importKey("raw", _this88.key, _this88.webCryptoAlgorithm, false, ["decrypt"]);
12072
+ var cryptoKey = yield crypto.subtle.importKey("raw", _this98.key, _this98.webCryptoAlgorithm, false, ["decrypt"]);
11950
12073
  return crypto.subtle.decrypt({
11951
- name: _this88.webCryptoAlgorithm,
12074
+ name: _this98.webCryptoAlgorithm,
11952
12075
  iv
11953
12076
  }, cryptoKey, ciphertextBody);
11954
12077
  })();
11955
12078
  }
11956
12079
  getIv() {
11957
- var _this89 = this;
12080
+ var _this99 = this;
11958
12081
  return _asyncToGenerator(function* () {
11959
- if (_this89.iv) {
11960
- var iv = _this89.iv;
11961
- _this89.iv = null;
12082
+ if (_this99.iv) {
12083
+ var iv = _this99.iv;
12084
+ _this99.iv = null;
11962
12085
  return iv;
11963
12086
  }
11964
12087
  var randomBlock = yield config.getRandomArrayBuffer(DEFAULT_BLOCKLENGTH);
@@ -12005,7 +12128,7 @@ var ably = {exports: {}};
12005
12128
  if (Platform.Config.xhrSupported && xhrRequestImplementation) {
12006
12129
  this.supportsAuthHeaders = true;
12007
12130
  this.Request = /*#__PURE__*/function () {
12008
- var _ref12 = _asyncToGenerator(function* (method, uri, headers, params, body) {
12131
+ var _ref14 = _asyncToGenerator(function* (method, uri, headers, params, body) {
12009
12132
  return new Promise(resolve => {
12010
12133
  var _a3;
12011
12134
  var req = xhrRequestImplementation.createRequest(uri, headers, params, body, XHRStates_default.REQ_SEND, (_a3 = client && client.options.timeouts) != null ? _a3 : null, this.logger, method);
@@ -12019,8 +12142,8 @@ var ably = {exports: {}};
12019
12142
  req.exec();
12020
12143
  });
12021
12144
  });
12022
- return function (_x82, _x83, _x84, _x85, _x86) {
12023
- return _ref12.apply(this, arguments);
12145
+ return function (_x88, _x89, _x90, _x91, _x92) {
12146
+ return _ref14.apply(this, arguments);
12024
12147
  };
12025
12148
  }();
12026
12149
  if (client == null ? void 0 : client.options.disableConnectivityCheck) {
@@ -12045,11 +12168,11 @@ var ably = {exports: {}};
12045
12168
  } else if (Platform.Config.fetchSupported && fetchRequestImplementation) {
12046
12169
  this.supportsAuthHeaders = true;
12047
12170
  this.Request = /*#__PURE__*/function () {
12048
- var _ref15 = _asyncToGenerator(function* (method, uri, headers, params, body) {
12171
+ var _ref17 = _asyncToGenerator(function* (method, uri, headers, params, body) {
12049
12172
  return fetchRequestImplementation(method, client != null ? client : null, uri, headers, params, body);
12050
12173
  });
12051
- return function (_x87, _x88, _x89, _x90, _x91) {
12052
- return _ref15.apply(this, arguments);
12174
+ return function (_x93, _x94, _x95, _x96, _x97) {
12175
+ return _ref17.apply(this, arguments);
12053
12176
  };
12054
12177
  }();
12055
12178
  if (client == null ? void 0 : client.options.disableConnectivityCheck) {
@@ -12080,14 +12203,14 @@ var ably = {exports: {}};
12080
12203
  return (_b = (_a2 = this.client) == null ? void 0 : _a2.logger) != null ? _b : logger_default.defaultLogger;
12081
12204
  }
12082
12205
  doUri(method, uri, headers, body, params) {
12083
- var _this90 = this;
12206
+ var _this100 = this;
12084
12207
  return _asyncToGenerator(function* () {
12085
- if (!_this90.Request) {
12208
+ if (!_this100.Request) {
12086
12209
  return {
12087
12210
  error: new PartialErrorInfo("Request invoked before assigned to", null, 500)
12088
12211
  };
12089
12212
  }
12090
- return _this90.Request(method, uri, headers, params, body);
12213
+ return _this100.Request(method, uri, headers, params, body);
12091
12214
  })();
12092
12215
  }
12093
12216
  shouldFallback(errorInfo) {
@@ -12217,7 +12340,7 @@ var ably = {exports: {}};
12217
12340
  globalObject4.crypto.getRandomValues(byteArray);
12218
12341
  return byteArray.buffer;
12219
12342
  });
12220
- function getRandomArrayBuffer(_x92) {
12343
+ function getRandomArrayBuffer(_x98) {
12221
12344
  return _getRandomArrayBuffer.apply(this, arguments);
12222
12345
  }
12223
12346
  return getRandomArrayBuffer;
@@ -13362,7 +13485,7 @@ var ably = {exports: {}};
13362
13485
  });
13363
13486
  return result;
13364
13487
  }
13365
- function fetchRequest(_x93, _x94, _x95, _x96, _x97, _x98) {
13488
+ function fetchRequest(_x99, _x100, _x101, _x102, _x103, _x104) {
13366
13489
  return _fetchRequest.apply(this, arguments);
13367
13490
  } // src/platform/web/lib/http/request/index.ts
13368
13491
  function _fetchRequest() {
@@ -13558,15 +13681,15 @@ class ClientAblyService {
13558
13681
  _this2.channel = _this2.client.channels.get(roomName);
13559
13682
  // Subscribe to assistant/system responses
13560
13683
  _this2.channel.subscribe('ReceiveMessage', message => {
13561
- var _a, _b, _c, _d;
13684
+ var _a, _b, _c, _d, _e, _f;
13562
13685
  try {
13563
13686
  var messageContent = typeof message.data === 'string' ? message.data : ((_a = message.data) === null || _a === void 0 ? void 0 : _a.content) || ((_b = message.data) === null || _b === void 0 ? void 0 : _b.message);
13564
13687
  var senderType = ((_c = message.data) === null || _c === void 0 ? void 0 : _c.senderType) || 3; // Assistant
13565
- var needsAgent = ((_d = message.data) === null || _d === void 0 ? void 0 : _d.needsAgent) || false;
13566
- onMessageReceived(messageContent, senderType, needsAgent);
13688
+ var needsAgent = ((_d = message.data) === null || _d === void 0 ? void 0 : _d.needsAgent) || ((_e = message.data) === null || _e === void 0 ? void 0 : _e.actionType) == "needs_agent" || false;
13689
+ var attachments = ((_f = message.data) === null || _f === void 0 ? void 0 : _f.attachments) || [];
13690
+ onMessageReceived(messageContent, senderType, needsAgent, attachments);
13567
13691
  } catch (error) {
13568
13692
  // Handle error silently
13569
- console.error('[AblyService] Error processing ReceiveMessage:', error);
13570
13693
  }
13571
13694
  });
13572
13695
  yield _this2.channel.attach();
@@ -13690,10 +13813,10 @@ function _getValidToken() {
13690
13813
  var forceRefresh = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
13691
13814
  var _a;
13692
13815
  if (!getTokenFunction) {
13693
- throw new Error("API module not initialized. Call initializeAPI(getToken) first.");
13816
+ throw new Error('API module not initialized. Call initializeAPI(getToken) first.');
13694
13817
  }
13695
- var storedToken = localStorage.getItem("chatbot-token");
13696
- var storedExpiry = localStorage.getItem("chatbot-token-expiry");
13818
+ var storedToken = localStorage.getItem('chatbot-token');
13819
+ var storedExpiry = localStorage.getItem('chatbot-token-expiry');
13697
13820
  var currentTime = Math.floor(Date.now() / 1000);
13698
13821
  // Add buffer time to prevent token expiry during request
13699
13822
  var bufferTime = 60; // 1 minute buffer
@@ -13703,10 +13826,9 @@ function _getValidToken() {
13703
13826
  var tokenResponse = yield getTokenFunction();
13704
13827
  storedToken = tokenResponse.token;
13705
13828
  storedExpiry = String(currentTime + ((_a = tokenResponse.expiresIn) !== null && _a !== void 0 ? _a : 900));
13706
- localStorage.setItem("chatbot-token", storedToken);
13707
- localStorage.setItem("chatbot-token-expiry", storedExpiry);
13829
+ localStorage.setItem('chatbot-token', storedToken);
13830
+ localStorage.setItem('chatbot-token-expiry', storedExpiry);
13708
13831
  } catch (error) {
13709
- console.error("Failed to refresh token:", error);
13710
13832
  throw error;
13711
13833
  }
13712
13834
  }
@@ -13723,11 +13845,11 @@ function _fetchWithAuth() {
13723
13845
  var headers = new Headers(options.headers);
13724
13846
  try {
13725
13847
  var token = yield getValidToken();
13726
- headers.set("Authorization", "Bearer ".concat(token));
13848
+ headers.set('Authorization', "Bearer ".concat(token));
13727
13849
  // Add performance optimizations
13728
- headers.set("Accept", "application/json");
13729
- headers.set("Accept-Encoding", "gzip, deflate, br");
13730
- headers.set("Connection", "keep-alive");
13850
+ headers.set('Accept', 'application/json');
13851
+ headers.set('Accept-Encoding', 'gzip, deflate, br');
13852
+ headers.set('Connection', 'keep-alive');
13731
13853
  options.headers = headers;
13732
13854
  // Add timeout to prevent hanging requests
13733
13855
  var controller = new AbortController();
@@ -13736,15 +13858,14 @@ function _fetchWithAuth() {
13736
13858
  var response = yield fetch(url, _objectSpread2(_objectSpread2({}, options), {}, {
13737
13859
  signal: controller.signal,
13738
13860
  // Add HTTP/2 optimization hints
13739
- cache: "no-cache",
13740
- mode: "cors"
13861
+ cache: 'no-cache',
13862
+ mode: 'cors'
13741
13863
  }));
13742
13864
  clearTimeout(timeoutId);
13743
13865
  // Handle 401/403 with token refresh
13744
13866
  if ((response.status === 401 || response.status === 403) && retry) {
13745
- console.warn("Token expired, refreshing...");
13746
13867
  var newToken = yield getValidToken(true);
13747
- headers.set("Authorization", "Bearer ".concat(newToken));
13868
+ headers.set('Authorization', "Bearer ".concat(newToken));
13748
13869
  options.headers = headers;
13749
13870
  // Retry the request with new token
13750
13871
  return fetchWithAuth(url, options, false);
@@ -13752,13 +13873,12 @@ function _fetchWithAuth() {
13752
13873
  return response;
13753
13874
  } catch (error) {
13754
13875
  clearTimeout(timeoutId);
13755
- if (error instanceof Error && error.name === "AbortError") {
13756
- throw new Error("Request timeout - please try again");
13876
+ if (error instanceof Error && error.name === 'AbortError') {
13877
+ throw new Error('Request timeout - please try again');
13757
13878
  }
13758
13879
  throw error;
13759
13880
  }
13760
13881
  } catch (error) {
13761
- console.error("Fetch error:", error);
13762
13882
  throw error;
13763
13883
  }
13764
13884
  });
@@ -13798,10 +13918,10 @@ function apiRequest(_x3) {
13798
13918
  }
13799
13919
  function _apiRequest() {
13800
13920
  _apiRequest = _asyncToGenerator(function* (endpoint) {
13801
- var method = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "GET";
13921
+ var method = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'GET';
13802
13922
  var body = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
13803
13923
  var options = arguments.length > 3 ? arguments[3] : undefined;
13804
- if (!baseUrl) throw new Error("API not initialized");
13924
+ if (!baseUrl) throw new Error('API not initialized');
13805
13925
  var url = "".concat(baseUrl, "/").concat(endpoint);
13806
13926
  var requestKey = "".concat(method, ":").concat(endpoint, ":").concat(JSON.stringify(body));
13807
13927
  // Check for duplicate in-flight requests
@@ -13810,7 +13930,7 @@ function _apiRequest() {
13810
13930
  return duplicateRequest;
13811
13931
  }
13812
13932
  // Check cache for GET requests (except real-time endpoints)
13813
- if (method === "GET" && options.cache !== false && !endpoint.includes("/send-message")) {
13933
+ if (method === 'GET' && options.cache !== false && !endpoint.includes('/send-message')) {
13814
13934
  var cached = getCachedResponse(requestKey);
13815
13935
  if (cached) {
13816
13936
  return Promise.resolve(cached);
@@ -13819,9 +13939,9 @@ function _apiRequest() {
13819
13939
  var requestOptions = {
13820
13940
  method,
13821
13941
  headers: {
13822
- "Content-Type": "application/json",
13823
- "Cache-Control": method === "GET" ? "max-age=30" : "no-cache",
13824
- "Accept-Language": options.language
13942
+ 'Content-Type': 'application/json',
13943
+ 'Cache-Control': method === 'GET' ? 'max-age=30' : 'no-cache',
13944
+ 'Accept-Language': options.language
13825
13945
  },
13826
13946
  body: body ? JSON.stringify(body) : null
13827
13947
  };
@@ -13829,26 +13949,37 @@ function _apiRequest() {
13829
13949
  try {
13830
13950
  var response = yield fetchWithAuth(url, requestOptions);
13831
13951
  if (!response.ok) {
13832
- var errorMessage = "API request failed";
13952
+ var errorMessage = 'API request failed';
13833
13953
  try {
13834
- var errorData = yield response.json();
13835
- errorMessage = errorData.message || errorMessage;
13836
- } catch (_a) {
13837
- errorMessage = "HTTP ".concat(response.status, ": ").concat(response.statusText);
13954
+ // Clone response before reading to avoid consuming the body
13955
+ var errorResponse = response.clone();
13956
+ var errorData = yield errorResponse.json();
13957
+ errorMessage = errorData.message || errorData.error || errorMessage;
13958
+ } catch (parseError) {
13959
+ // If JSON parsing fails, try to get text
13960
+ try {
13961
+ var _errorResponse = response.clone();
13962
+ var errorText = yield _errorResponse.text();
13963
+ errorMessage = errorText || "HTTP ".concat(response.status, ": ").concat(response.statusText);
13964
+ } catch (_a) {
13965
+ errorMessage = "HTTP ".concat(response.status, ": ").concat(response.statusText);
13966
+ }
13838
13967
  }
13839
13968
  throw new Error(errorMessage);
13840
13969
  }
13841
13970
  // Cache successful GET responses
13842
- if (method === "GET" && options.cache !== false) {
13971
+ // Note: We clone before caching to avoid consuming the original response body
13972
+ if (method === 'GET' && options.cache !== false) {
13843
13973
  var responseData = response.clone();
13844
13974
  var data = yield responseData.json();
13845
13975
  setCachedResponse(requestKey, {
13846
13976
  json: () => Promise.resolve(data)
13847
13977
  });
13848
13978
  }
13979
+ // Return the original response - it's body hasn't been consumed yet
13980
+ // (we only cloned for caching, and the clone was consumed)
13849
13981
  return response;
13850
13982
  } catch (error) {
13851
- console.error("API request failed for ".concat(endpoint, ":"), error);
13852
13983
  throw error;
13853
13984
  }
13854
13985
  })();