@aslaluroba/help-center-react 3.2.0 → 3.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -6962,7 +6962,7 @@ var ably = {exports: {}};
6962
6962
  });
6963
6963
  return _withTimeoutAsync2.apply(this, arguments);
6964
6964
  }
6965
- var version = "2.13.0";
6965
+ var version = "2.15.0";
6966
6966
 
6967
6967
  // src/common/lib/util/defaults.ts
6968
6968
  var agent = "ably-js/" + version;
@@ -7210,10 +7210,10 @@ var ably = {exports: {}};
7210
7210
  };
7211
7211
  function defaultGetHeaders(options) {
7212
7212
  var {
7213
- format = defaultHeadersOptions.format,
7213
+ format,
7214
7214
  protocolVersion = defaultHeadersOptions.protocolVersion
7215
7215
  } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
7216
- var accept = contentTypes[format];
7216
+ var accept = contentTypes[format != null ? format : options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */];
7217
7217
  return {
7218
7218
  accept,
7219
7219
  "X-Ably-Version": protocolVersion.toString(),
@@ -7222,11 +7222,11 @@ var ably = {exports: {}};
7222
7222
  }
7223
7223
  function defaultPostHeaders(options) {
7224
7224
  var {
7225
- format = defaultHeadersOptions.format,
7225
+ format,
7226
7226
  protocolVersion = defaultHeadersOptions.protocolVersion
7227
7227
  } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
7228
- var contentType;
7229
- var accept = contentType = contentTypes[format];
7228
+ var accept = contentTypes[format != null ? format : options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */];
7229
+ var contentType = accept;
7230
7230
  return {
7231
7231
  accept,
7232
7232
  "content-type": contentType,
@@ -7550,7 +7550,9 @@ var ably = {exports: {}};
7550
7550
  tokenUri = function tokenUri(host) {
7551
7551
  return client.baseUri(host) + path;
7552
7552
  };
7553
- var requestHeaders = defaults_default.defaultPostHeaders(_this3.client.options);
7553
+ var requestHeaders = defaults_default.defaultPostHeaders(_this3.client.options, {
7554
+ format: "json" /* json */
7555
+ });
7554
7556
  if (resolvedAuthOptions.requestHeaders) _mixin(requestHeaders, resolvedAuthOptions.requestHeaders);
7555
7557
  logger_default.logAction(_this3.logger, logger_default.LOG_MICRO, "Auth.requestToken().requestToken", "Sending POST to " + path + "; Token params: " + JSON.stringify(signedTokenParams));
7556
7558
  _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));
@@ -9242,9 +9244,7 @@ var ably = {exports: {}};
9242
9244
  return _asyncToGenerator(function* () {
9243
9245
  var client = _this26.client;
9244
9246
  var format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
9245
- headers = defaults_default.defaultPostHeaders(client.options, {
9246
- format
9247
- }),
9247
+ headers = defaults_default.defaultPostHeaders(client.options),
9248
9248
  params = {};
9249
9249
  var body = _mixin({
9250
9250
  recipient
@@ -9268,9 +9268,7 @@ var ably = {exports: {}};
9268
9268
  var client = _this27.client;
9269
9269
  var body = devicedetails_default.fromValues(device);
9270
9270
  var format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
9271
- headers = defaults_default.defaultPostHeaders(client.options, {
9272
- format
9273
- }),
9271
+ headers = defaults_default.defaultPostHeaders(client.options),
9274
9272
  params = {};
9275
9273
  _mixin(headers, client.options.headers);
9276
9274
  if (client.options.pushFullWait) _mixin(params, {
@@ -9286,9 +9284,7 @@ var ably = {exports: {}};
9286
9284
  return _asyncToGenerator(function* () {
9287
9285
  var client = _this28.client,
9288
9286
  format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
9289
- headers = defaults_default.defaultGetHeaders(client.options, {
9290
- format
9291
- }),
9287
+ headers = defaults_default.defaultGetHeaders(client.options),
9292
9288
  deviceId = deviceIdOrDetails.id || deviceIdOrDetails;
9293
9289
  if (typeof deviceId !== "string" || !deviceId.length) {
9294
9290
  throw new _ErrorInfo2("First argument to DeviceRegistrations#get must be a deviceId string or DeviceDetails", 4e4, 400);
@@ -9304,9 +9300,7 @@ var ably = {exports: {}};
9304
9300
  var client = _this29.client,
9305
9301
  format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
9306
9302
  envelope = _this29.client.http.supportsLinkHeaders ? void 0 : format,
9307
- headers = defaults_default.defaultGetHeaders(client.options, {
9308
- format
9309
- });
9303
+ headers = defaults_default.defaultGetHeaders(client.options);
9310
9304
  _mixin(headers, client.options.headers);
9311
9305
  return new paginatedresource_default(client, "/push/deviceRegistrations", headers, envelope, /*#__PURE__*/function () {
9312
9306
  var _ref3 = _asyncToGenerator(function* (body, headers2, unpacked) {
@@ -9322,10 +9316,7 @@ var ably = {exports: {}};
9322
9316
  var _this30 = this;
9323
9317
  return _asyncToGenerator(function* () {
9324
9318
  var client = _this30.client,
9325
- format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
9326
- headers = defaults_default.defaultGetHeaders(client.options, {
9327
- format
9328
- }),
9319
+ headers = defaults_default.defaultGetHeaders(client.options),
9329
9320
  params = {},
9330
9321
  deviceId = deviceIdOrDetails.id || deviceIdOrDetails;
9331
9322
  if (typeof deviceId !== "string" || !deviceId.length) {
@@ -9366,9 +9357,7 @@ var ably = {exports: {}};
9366
9357
  var client = _this32.client;
9367
9358
  var body = pushchannelsubscription_default.fromValues(subscription);
9368
9359
  var format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
9369
- headers = defaults_default.defaultPostHeaders(client.options, {
9370
- format
9371
- }),
9360
+ headers = defaults_default.defaultPostHeaders(client.options),
9372
9361
  params = {};
9373
9362
  _mixin(headers, client.options.headers);
9374
9363
  if (client.options.pushFullWait) _mixin(params, {
@@ -9385,9 +9374,7 @@ var ably = {exports: {}};
9385
9374
  var client = _this33.client,
9386
9375
  format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
9387
9376
  envelope = _this33.client.http.supportsLinkHeaders ? void 0 : format,
9388
- headers = defaults_default.defaultGetHeaders(client.options, {
9389
- format
9390
- });
9377
+ headers = defaults_default.defaultGetHeaders(client.options);
9391
9378
  _mixin(headers, client.options.headers);
9392
9379
  return new paginatedresource_default(client, "/push/channelSubscriptions", headers, envelope, /*#__PURE__*/function () {
9393
9380
  var _ref4 = _asyncToGenerator(function* (body, headers2, unpacked) {
@@ -9420,9 +9407,7 @@ var ably = {exports: {}};
9420
9407
  var client = _this35.client,
9421
9408
  format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
9422
9409
  envelope = _this35.client.http.supportsLinkHeaders ? void 0 : format,
9423
- headers = defaults_default.defaultGetHeaders(client.options, {
9424
- format
9425
- });
9410
+ headers = defaults_default.defaultGetHeaders(client.options);
9426
9411
  _mixin(headers, client.options.headers);
9427
9412
  if (client.options.pushFullWait) _mixin(params, {
9428
9413
  fullWait: "true"
@@ -9585,9 +9570,7 @@ var ably = {exports: {}};
9585
9570
  var client = _this38.channel.client,
9586
9571
  format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
9587
9572
  envelope = _this38.channel.client.http.supportsLinkHeaders ? void 0 : format,
9588
- headers = defaults_default.defaultGetHeaders(client.options, {
9589
- format
9590
- });
9573
+ headers = defaults_default.defaultGetHeaders(client.options);
9591
9574
  _mixin(headers, client.options.headers);
9592
9575
  return new paginatedresource_default(client, _this38.channel.client.rest.presenceMixin.basePath(_this38), headers, envelope, /*#__PURE__*/function () {
9593
9576
  var _ref6 = _asyncToGenerator(function* (body, headers2, unpacked) {
@@ -9711,6 +9694,21 @@ var ably = {exports: {}};
9711
9694
  } else if (!this.annotations.summary) {
9712
9695
  this.annotations.summary = {};
9713
9696
  }
9697
+ if (this.annotations && this.annotations.summary) {
9698
+ for (var [type, summaryEntry] of Object.entries(this.annotations.summary)) {
9699
+ if (type.endsWith(":distinct.v1") || type.endsWith(":unique.v1") || type.endsWith(":multiple.v1")) {
9700
+ for (var [, entry] of Object.entries(summaryEntry)) {
9701
+ if (!entry.clipped) {
9702
+ entry.clipped = false;
9703
+ }
9704
+ }
9705
+ } else if (type.endsWith(":flag.v1")) {
9706
+ if (!summaryEntry.clipped) {
9707
+ summaryEntry.clipped = false;
9708
+ }
9709
+ }
9710
+ }
9711
+ }
9714
9712
  }
9715
9713
  encode(options) {
9716
9714
  var _this40 = this;
@@ -9860,9 +9858,7 @@ var ably = {exports: {}};
9860
9858
  options = client.options,
9861
9859
  format = options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
9862
9860
  idempotentRestPublishing = client.options.idempotentRestPublishing,
9863
- headers = defaults_default.defaultPostHeaders(client.options, {
9864
- format
9865
- });
9861
+ headers = defaults_default.defaultPostHeaders(client.options);
9866
9862
  _mixin(headers, options.headers);
9867
9863
  if (idempotentRestPublishing && allEmptyIds(messages)) {
9868
9864
  var msgIdBase = yield _randomString(MSG_ID_ENTROPY_BYTES);
@@ -9891,6 +9887,38 @@ var ably = {exports: {}};
9891
9887
  return _this46.client.rest.channelMixin.status(_this46);
9892
9888
  })();
9893
9889
  }
9890
+ getMessage(serialOrMessage) {
9891
+ var _this47 = this;
9892
+ return _asyncToGenerator(function* () {
9893
+ logger_default.logAction(_this47.logger, logger_default.LOG_MICRO, "RestChannel.getMessage()", "channel = " + _this47.name);
9894
+ return _this47.client.rest.channelMixin.getMessage(_this47, serialOrMessage);
9895
+ })();
9896
+ }
9897
+ updateMessage(message, operation, params) {
9898
+ var _this48 = this;
9899
+ return _asyncToGenerator(function* () {
9900
+ logger_default.logAction(_this48.logger, logger_default.LOG_MICRO, "RestChannel.updateMessage()", "channel = " + _this48.name);
9901
+ return _this48.client.rest.channelMixin.updateDeleteMessage(_this48, {
9902
+ isDelete: false
9903
+ }, message, operation, params);
9904
+ })();
9905
+ }
9906
+ deleteMessage(message, operation, params) {
9907
+ var _this49 = this;
9908
+ return _asyncToGenerator(function* () {
9909
+ logger_default.logAction(_this49.logger, logger_default.LOG_MICRO, "RestChannel.deleteMessage()", "channel = " + _this49.name);
9910
+ return _this49.client.rest.channelMixin.updateDeleteMessage(_this49, {
9911
+ isDelete: true
9912
+ }, message, operation, params);
9913
+ })();
9914
+ }
9915
+ getMessageVersions(serialOrMessage, params) {
9916
+ var _this50 = this;
9917
+ return _asyncToGenerator(function* () {
9918
+ logger_default.logAction(_this50.logger, logger_default.LOG_MICRO, "RestChannel.getMessageVersions()", "channel = " + _this50.name);
9919
+ return _this50.client.rest.channelMixin.getMessageVersions(_this50, serialOrMessage, params);
9920
+ })();
9921
+ }
9894
9922
  };
9895
9923
  var restchannel_default = RestChannel;
9896
9924
 
@@ -9919,9 +9947,7 @@ var ably = {exports: {}};
9919
9947
  var client = channel.client,
9920
9948
  format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
9921
9949
  envelope = channel.client.http.supportsLinkHeaders ? void 0 : format,
9922
- headers = defaults_default.defaultGetHeaders(client.options, {
9923
- format
9924
- });
9950
+ headers = defaults_default.defaultGetHeaders(client.options);
9925
9951
  _mixin(headers, client.options.headers);
9926
9952
  return new paginatedresource_default(client, this.basePath(channel) + "/messages", headers, envelope, /*#__PURE__*/function () {
9927
9953
  var _ref7 = _asyncToGenerator(function* (body, headers2, unpacked) {
@@ -9934,16 +9960,81 @@ var ably = {exports: {}};
9934
9960
  }()).get(params);
9935
9961
  }
9936
9962
  static status(channel) {
9937
- var _this47 = this;
9963
+ var _this51 = this;
9938
9964
  return _asyncToGenerator(function* () {
9939
9965
  var format = channel.client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */;
9940
- var headers = defaults_default.defaultPostHeaders(channel.client.options, {
9941
- format
9942
- });
9943
- var response = yield resource_default.get(channel.client, _this47.basePath(channel), headers, {}, format, true);
9966
+ var headers = defaults_default.defaultPostHeaders(channel.client.options);
9967
+ var response = yield resource_default.get(channel.client, _this51.basePath(channel), headers, {}, format, true);
9944
9968
  return response.body;
9945
9969
  })();
9946
9970
  }
9971
+ static getMessage(channel, serialOrMessage) {
9972
+ var _this52 = this;
9973
+ return _asyncToGenerator(function* () {
9974
+ var serial = typeof serialOrMessage === "string" ? serialOrMessage : serialOrMessage.serial;
9975
+ if (!serial) {
9976
+ 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);
9977
+ }
9978
+ var client = channel.client;
9979
+ var format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */;
9980
+ var headers = defaults_default.defaultGetHeaders(client.options);
9981
+ _mixin(headers, client.options.headers);
9982
+ var {
9983
+ body,
9984
+ unpacked
9985
+ } = yield resource_default.get(client, _this52.basePath(channel) + "/messages/" + encodeURIComponent(serial), headers, {}, null, true);
9986
+ var decoded = unpacked ? body : _decodeBody(body, client._MsgPack, format);
9987
+ return _fromEncoded2(decoded, channel);
9988
+ })();
9989
+ }
9990
+ static updateDeleteMessage(channel, opts, message, operation, params) {
9991
+ var _this53 = this;
9992
+ return _asyncToGenerator(function* () {
9993
+ if (!message.serial) {
9994
+ 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);
9995
+ }
9996
+ var client = channel.client;
9997
+ var format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */;
9998
+ var headers = defaults_default.defaultPostHeaders(client.options);
9999
+ _mixin(headers, client.options.headers);
10000
+ var encoded = null;
10001
+ if (message.data !== void 0) {
10002
+ encoded = yield message_default.fromValues(message).encode(channel.channelOptions);
10003
+ }
10004
+ var req = {
10005
+ serial: message.serial,
10006
+ operation,
10007
+ name: message.name,
10008
+ data: encoded && encoded.data,
10009
+ encoding: encoded && encoded.encoding,
10010
+ extras: message.extras
10011
+ };
10012
+ var requestBody = serialize(req, client._MsgPack, format);
10013
+ var method = opts.isDelete ? resource_default.post : resource_default.patch;
10014
+ var pathSuffix = opts.isDelete ? "/delete" : "";
10015
+ yield method(client, _this53.basePath(channel) + "/messages/" + encodeURIComponent(message.serial) + pathSuffix, requestBody, headers, params || {}, null, true);
10016
+ })();
10017
+ }
10018
+ static getMessageVersions(channel, serialOrMessage, params) {
10019
+ var serial = typeof serialOrMessage === "string" ? serialOrMessage : serialOrMessage.serial;
10020
+ if (!serial) {
10021
+ 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);
10022
+ }
10023
+ var client = channel.client;
10024
+ var format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */;
10025
+ var envelope = channel.client.http.supportsLinkHeaders ? void 0 : format;
10026
+ var headers = defaults_default.defaultGetHeaders(client.options);
10027
+ _mixin(headers, client.options.headers);
10028
+ return new paginatedresource_default(client, this.basePath(channel) + "/messages/" + encodeURIComponent(serial) + "/versions", headers, envelope, /*#__PURE__*/function () {
10029
+ var _ref8 = _asyncToGenerator(function* (body, headers2, unpacked) {
10030
+ var decoded = unpacked ? body : _decodeBody(body, client._MsgPack, format);
10031
+ return _fromEncodedArray2(decoded, channel);
10032
+ });
10033
+ return function (_x62, _x63, _x64) {
10034
+ return _ref8.apply(this, arguments);
10035
+ };
10036
+ }()).get(params || {});
10037
+ }
9947
10038
  };
9948
10039
 
9949
10040
  // src/common/lib/client/restpresencemixin.ts
@@ -9952,22 +10043,20 @@ var ably = {exports: {}};
9952
10043
  return RestChannelMixin.basePath(presence.channel) + "/presence";
9953
10044
  }
9954
10045
  static history(presence, params) {
9955
- var _this48 = this;
10046
+ var _this54 = this;
9956
10047
  return _asyncToGenerator(function* () {
9957
10048
  var client = presence.channel.client,
9958
10049
  format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
9959
10050
  envelope = presence.channel.client.http.supportsLinkHeaders ? void 0 : format,
9960
- headers = defaults_default.defaultGetHeaders(client.options, {
9961
- format
9962
- });
10051
+ headers = defaults_default.defaultGetHeaders(client.options);
9963
10052
  _mixin(headers, client.options.headers);
9964
- return new paginatedresource_default(client, _this48.basePath(presence) + "/history", headers, envelope, /*#__PURE__*/function () {
9965
- var _ref8 = _asyncToGenerator(function* (body, headers2, unpacked) {
10053
+ return new paginatedresource_default(client, _this54.basePath(presence) + "/history", headers, envelope, /*#__PURE__*/function () {
10054
+ var _ref9 = _asyncToGenerator(function* (body, headers2, unpacked) {
9966
10055
  var decoded = unpacked ? body : _decodeBody(body, client._MsgPack, format);
9967
10056
  return _fromEncodedArray(decoded, presence.channel);
9968
10057
  });
9969
- return function (_x62, _x63, _x64) {
9970
- return _ref8.apply(this, arguments);
10058
+ return function (_x65, _x66, _x67) {
10059
+ return _ref9.apply(this, arguments);
9971
10060
  };
9972
10061
  }()).get(params);
9973
10062
  })();
@@ -9989,32 +10078,39 @@ var ably = {exports: {}};
9989
10078
  this.push = new push_default(this.client);
9990
10079
  }
9991
10080
  stats(params) {
9992
- var _this49 = this;
10081
+ var _this55 = this;
9993
10082
  return _asyncToGenerator(function* () {
9994
- var headers = defaults_default.defaultGetHeaders(_this49.client.options),
9995
- format = _this49.client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
9996
- envelope = _this49.client.http.supportsLinkHeaders ? void 0 : format;
9997
- _mixin(headers, _this49.client.options.headers);
9998
- return new paginatedresource_default(_this49.client, "/stats", headers, envelope, function (body, headers2, unpacked) {
9999
- var statsValues = unpacked ? body : JSON.parse(body);
10000
- for (var i = 0; i < statsValues.length; i++) statsValues[i] = stats_default.fromValues(statsValues[i]);
10001
- return statsValues;
10002
- }).get(params);
10083
+ var headers = defaults_default.defaultGetHeaders(_this55.client.options),
10084
+ format = _this55.client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
10085
+ envelope = _this55.client.http.supportsLinkHeaders ? void 0 : format;
10086
+ _mixin(headers, _this55.client.options.headers);
10087
+ return new paginatedresource_default(_this55.client, "/stats", headers, envelope, /*#__PURE__*/function () {
10088
+ var _ref0 = _asyncToGenerator(function* (body, _, unpacked) {
10089
+ var statsValues = unpacked ? body : _decodeBody(body, _this55.client._MsgPack, format);
10090
+ for (var i = 0; i < statsValues.length; i++) statsValues[i] = stats_default.fromValues(statsValues[i]);
10091
+ return statsValues;
10092
+ });
10093
+ return function (_x68, _x69, _x70) {
10094
+ return _ref0.apply(this, arguments);
10095
+ };
10096
+ }()).get(params);
10003
10097
  })();
10004
10098
  }
10005
10099
  time(params) {
10006
- var _this50 = this;
10100
+ var _this56 = this;
10007
10101
  return _asyncToGenerator(function* () {
10008
- var headers = defaults_default.defaultGetHeaders(_this50.client.options);
10009
- if (_this50.client.options.headers) _mixin(headers, _this50.client.options.headers);
10102
+ var headers = defaults_default.defaultGetHeaders(_this56.client.options, {
10103
+ format: "json" /* json */
10104
+ });
10105
+ if (_this56.client.options.headers) _mixin(headers, _this56.client.options.headers);
10010
10106
  var timeUri = host => {
10011
- return _this50.client.baseUri(host) + "/time";
10107
+ return _this56.client.baseUri(host) + "/time";
10012
10108
  };
10013
10109
  var {
10014
10110
  error,
10015
10111
  body,
10016
10112
  unpacked
10017
- } = yield _this50.client.http.do(HttpMethods_default.Get, timeUri, headers, null, params);
10113
+ } = yield _this56.client.http.do(HttpMethods_default.Get, timeUri, headers, null, params);
10018
10114
  if (error) {
10019
10115
  throw error;
10020
10116
  }
@@ -10023,47 +10119,47 @@ var ably = {exports: {}};
10023
10119
  if (!time) {
10024
10120
  throw new _ErrorInfo2("Internal error (unexpected result type from GET /time)", 5e4, 500);
10025
10121
  }
10026
- _this50.client.serverTimeOffset = time - Date.now();
10122
+ _this56.client.serverTimeOffset = time - Date.now();
10027
10123
  return time;
10028
10124
  })();
10029
10125
  }
10030
10126
  request(method, path, version2, params, body, customHeaders) {
10031
- var _this51 = this;
10127
+ var _this57 = this;
10032
10128
  return _asyncToGenerator(function* () {
10033
10129
  var _a2;
10034
10130
  var [encoder, decoder, format] = (() => {
10035
- if (_this51.client.options.useBinaryProtocol) {
10036
- if (!_this51.client._MsgPack) {
10131
+ if (_this57.client.options.useBinaryProtocol) {
10132
+ if (!_this57.client._MsgPack) {
10037
10133
  _throwMissingPluginError("MsgPack");
10038
10134
  }
10039
- return [_this51.client._MsgPack.encode, _this51.client._MsgPack.decode, "msgpack" /* msgpack */];
10135
+ return [_this57.client._MsgPack.encode, _this57.client._MsgPack.decode, "msgpack" /* msgpack */];
10040
10136
  } else {
10041
10137
  return [JSON.stringify, JSON.parse, "json" /* json */];
10042
10138
  }
10043
10139
  })();
10044
- var envelope = _this51.client.http.supportsLinkHeaders ? void 0 : format;
10140
+ var envelope = _this57.client.http.supportsLinkHeaders ? void 0 : format;
10045
10141
  params = params || {};
10046
10142
  var _method = method.toLowerCase();
10047
- var headers = _method == "get" ? defaults_default.defaultGetHeaders(_this51.client.options, {
10143
+ var headers = _method == "get" ? defaults_default.defaultGetHeaders(_this57.client.options, {
10048
10144
  format,
10049
10145
  protocolVersion: version2
10050
- }) : defaults_default.defaultPostHeaders(_this51.client.options, {
10146
+ }) : defaults_default.defaultPostHeaders(_this57.client.options, {
10051
10147
  format,
10052
10148
  protocolVersion: version2
10053
10149
  });
10054
10150
  if (typeof body !== "string") {
10055
10151
  body = (_a2 = encoder(body)) != null ? _a2 : null;
10056
10152
  }
10057
- _mixin(headers, _this51.client.options.headers);
10153
+ _mixin(headers, _this57.client.options.headers);
10058
10154
  if (customHeaders) {
10059
10155
  _mixin(headers, customHeaders);
10060
10156
  }
10061
- var paginatedResource = new paginatedresource_default(_this51.client, path, headers, envelope, /*#__PURE__*/function () {
10062
- var _ref9 = _asyncToGenerator(function* (resbody, headers2, unpacked) {
10157
+ var paginatedResource = new paginatedresource_default(_this57.client, path, headers, envelope, /*#__PURE__*/function () {
10158
+ var _ref1 = _asyncToGenerator(function* (resbody, headers2, unpacked) {
10063
10159
  return _ensureArray(unpacked ? resbody : decoder(resbody));
10064
10160
  });
10065
- return function (_x65, _x66, _x67) {
10066
- return _ref9.apply(this, arguments);
10161
+ return function (_x71, _x72, _x73) {
10162
+ return _ref1.apply(this, arguments);
10067
10163
  };
10068
10164
  }(), /* useHttpPaginatedResponse: */
10069
10165
  true);
@@ -10078,7 +10174,7 @@ var ably = {exports: {}};
10078
10174
  })();
10079
10175
  }
10080
10176
  batchPublish(specOrSpecs) {
10081
- var _this52 = this;
10177
+ var _this58 = this;
10082
10178
  return _asyncToGenerator(function* () {
10083
10179
  var requestBodyDTO;
10084
10180
  var singleSpecMode;
@@ -10089,14 +10185,12 @@ var ably = {exports: {}};
10089
10185
  requestBodyDTO = [specOrSpecs];
10090
10186
  singleSpecMode = true;
10091
10187
  }
10092
- var format = _this52.client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
10093
- headers = defaults_default.defaultPostHeaders(_this52.client.options, {
10094
- format
10095
- });
10096
- if (_this52.client.options.headers) _mixin(headers, _this52.client.options.headers);
10097
- var requestBody = _encodeBody(requestBodyDTO, _this52.client._MsgPack, format);
10098
- var response = yield resource_default.post(_this52.client, "/messages", requestBody, headers, {}, null, true);
10099
- var batchResults = response.unpacked ? response.body : _decodeBody(response.body, _this52.client._MsgPack, format);
10188
+ var format = _this58.client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
10189
+ headers = defaults_default.defaultPostHeaders(_this58.client.options);
10190
+ if (_this58.client.options.headers) _mixin(headers, _this58.client.options.headers);
10191
+ var requestBody = _encodeBody(requestBodyDTO, _this58.client._MsgPack, format);
10192
+ var response = yield resource_default.post(_this58.client, "/messages", requestBody, headers, {}, null, true);
10193
+ var batchResults = response.unpacked ? response.body : _decodeBody(response.body, _this58.client._MsgPack, format);
10100
10194
  if (singleSpecMode) {
10101
10195
  return batchResults[0];
10102
10196
  } else {
@@ -10105,39 +10199,35 @@ var ably = {exports: {}};
10105
10199
  })();
10106
10200
  }
10107
10201
  batchPresence(channels) {
10108
- var _this53 = this;
10202
+ var _this59 = this;
10109
10203
  return _asyncToGenerator(function* () {
10110
- var format = _this53.client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
10111
- headers = defaults_default.defaultPostHeaders(_this53.client.options, {
10112
- format
10113
- });
10114
- if (_this53.client.options.headers) _mixin(headers, _this53.client.options.headers);
10204
+ var format = _this59.client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
10205
+ headers = defaults_default.defaultGetHeaders(_this59.client.options);
10206
+ if (_this59.client.options.headers) _mixin(headers, _this59.client.options.headers);
10115
10207
  var channelsParam = channels.join(",");
10116
- var response = yield resource_default.get(_this53.client, "/presence", headers, {
10208
+ var response = yield resource_default.get(_this59.client, "/presence", headers, {
10117
10209
  channels: channelsParam
10118
10210
  }, null, true);
10119
- return response.unpacked ? response.body : _decodeBody(response.body, _this53.client._MsgPack, format);
10211
+ return response.unpacked ? response.body : _decodeBody(response.body, _this59.client._MsgPack, format);
10120
10212
  })();
10121
10213
  }
10122
10214
  revokeTokens(specifiers, options) {
10123
- var _this54 = this;
10215
+ var _this60 = this;
10124
10216
  return _asyncToGenerator(function* () {
10125
- if (useTokenAuth(_this54.client.options)) {
10217
+ if (useTokenAuth(_this60.client.options)) {
10126
10218
  throw new _ErrorInfo2("Cannot revoke tokens when using token auth", 40162, 401);
10127
10219
  }
10128
- var keyName = _this54.client.options.keyName;
10220
+ var keyName = _this60.client.options.keyName;
10129
10221
  var resolvedOptions = options != null ? options : {};
10130
10222
  var requestBodyDTO = __spreadValues({
10131
10223
  targets: specifiers.map(specifier => "".concat(specifier.type, ":").concat(specifier.value))
10132
10224
  }, resolvedOptions);
10133
- var format = _this54.client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
10134
- headers = defaults_default.defaultPostHeaders(_this54.client.options, {
10135
- format
10136
- });
10137
- if (_this54.client.options.headers) _mixin(headers, _this54.client.options.headers);
10138
- var requestBody = _encodeBody(requestBodyDTO, _this54.client._MsgPack, format);
10139
- var response = yield resource_default.post(_this54.client, "/keys/".concat(keyName, "/revokeTokens"), requestBody, headers, {}, null, true);
10140
- return response.unpacked ? response.body : _decodeBody(response.body, _this54.client._MsgPack, format);
10225
+ var format = _this60.client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
10226
+ headers = defaults_default.defaultPostHeaders(_this60.client.options);
10227
+ if (_this60.client.options.headers) _mixin(headers, _this60.client.options.headers);
10228
+ var requestBody = _encodeBody(requestBodyDTO, _this60.client._MsgPack, format);
10229
+ var response = yield resource_default.post(_this60.client, "/keys/".concat(keyName, "/revokeTokens"), requestBody, headers, {}, null, true);
10230
+ return response.unpacked ? response.body : _decodeBody(response.body, _this60.client._MsgPack, format);
10141
10231
  })();
10142
10232
  }
10143
10233
  };
@@ -10221,7 +10311,7 @@ var ably = {exports: {}};
10221
10311
 
10222
10312
  // src/common/lib/types/annotation.ts
10223
10313
  var actions4 = ["annotation.create", "annotation.delete"];
10224
- function fromEncoded3(_x68, _x69, _x70) {
10314
+ function fromEncoded3(_x74, _x75, _x76) {
10225
10315
  return _fromEncoded8.apply(this, arguments);
10226
10316
  }
10227
10317
  function _fromEncoded8() {
@@ -10231,7 +10321,7 @@ var ably = {exports: {}};
10231
10321
  });
10232
10322
  return _fromEncoded8.apply(this, arguments);
10233
10323
  }
10234
- function fromEncodedArray3(_x71, _x72, _x73) {
10324
+ function fromEncodedArray3(_x77, _x78, _x79) {
10235
10325
  return _fromEncodedArray8.apply(this, arguments);
10236
10326
  }
10237
10327
  function _fromEncodedArray8() {
@@ -10242,7 +10332,7 @@ var ably = {exports: {}};
10242
10332
  });
10243
10333
  return _fromEncodedArray8.apply(this, arguments);
10244
10334
  }
10245
- function _fromEncoded3(_x74, _x75) {
10335
+ function _fromEncoded3(_x80, _x81) {
10246
10336
  return _fromEncoded9.apply(this, arguments);
10247
10337
  }
10248
10338
  function _fromEncoded9() {
@@ -10251,7 +10341,7 @@ var ably = {exports: {}};
10251
10341
  });
10252
10342
  return _fromEncoded9.apply(this, arguments);
10253
10343
  }
10254
- function _fromEncodedArray3(_x76, _x77) {
10344
+ function _fromEncodedArray3(_x82, _x83) {
10255
10345
  return _fromEncodedArray9.apply(this, arguments);
10256
10346
  }
10257
10347
  function _fromEncodedArray9() {
@@ -10264,10 +10354,10 @@ var ably = {exports: {}};
10264
10354
  }
10265
10355
  var Annotation = class _Annotation extends BaseMessage {
10266
10356
  encode() {
10267
- var _this55 = this;
10357
+ var _this61 = this;
10268
10358
  return _asyncToGenerator(function* () {
10269
- var res = Object.assign(new WireAnnotation(), _this55, {
10270
- action: actions4.indexOf(_this55.action || "annotation.create")
10359
+ var res = Object.assign(new WireAnnotation(), _this61, {
10360
+ action: actions4.indexOf(_this61.action || "annotation.create")
10271
10361
  });
10272
10362
  return encode(res, {});
10273
10363
  })();
@@ -10296,10 +10386,10 @@ var ably = {exports: {}};
10296
10386
  return values.map(v => _WireAnnotation.fromValues(v));
10297
10387
  }
10298
10388
  decode(channelOptions, logger) {
10299
- var _this56 = this;
10389
+ var _this62 = this;
10300
10390
  return _asyncToGenerator(function* () {
10301
- var res = Object.assign(new Annotation(), __spreadProps(__spreadValues({}, _this56), {
10302
- action: actions4[_this56.action]
10391
+ var res = Object.assign(new Annotation(), __spreadProps(__spreadValues({}, _this62), {
10392
+ action: actions4[_this62.action]
10303
10393
  }));
10304
10394
  try {
10305
10395
  yield decode(res, channelOptions);
@@ -10368,47 +10458,43 @@ var ably = {exports: {}};
10368
10458
  this.channel = channel;
10369
10459
  }
10370
10460
  publish(msgOrSerial, annotationValues) {
10371
- var _this57 = this;
10461
+ var _this63 = this;
10372
10462
  return _asyncToGenerator(function* () {
10373
10463
  var annotation = constructValidateAnnotation(msgOrSerial, annotationValues);
10374
10464
  var wireAnnotation = yield annotation.encode();
10375
- var client = _this57.channel.client,
10465
+ var client = _this63.channel.client,
10376
10466
  options = client.options,
10377
10467
  format = options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
10378
- headers = defaults_default.defaultPostHeaders(client.options, {
10379
- format
10380
- }),
10468
+ headers = defaults_default.defaultPostHeaders(client.options),
10381
10469
  params = {};
10382
10470
  _mixin(headers, client.options.headers);
10383
10471
  var requestBody = _encodeBody([wireAnnotation], client._MsgPack, format);
10384
- yield resource_default.post(client, basePathForSerial(_this57.channel, annotation.messageSerial), requestBody, headers, params, null, true);
10472
+ yield resource_default.post(client, basePathForSerial(_this63.channel, annotation.messageSerial), requestBody, headers, params, null, true);
10385
10473
  })();
10386
10474
  }
10387
10475
  delete(msgOrSerial, annotationValues) {
10388
- var _this58 = this;
10476
+ var _this64 = this;
10389
10477
  return _asyncToGenerator(function* () {
10390
10478
  annotationValues.action = "annotation.delete";
10391
- return _this58.publish(msgOrSerial, annotationValues);
10479
+ return _this64.publish(msgOrSerial, annotationValues);
10392
10480
  })();
10393
10481
  }
10394
10482
  get(msgOrSerial, params) {
10395
- var _this59 = this;
10483
+ var _this65 = this;
10396
10484
  return _asyncToGenerator(function* () {
10397
- var client = _this59.channel.client,
10485
+ var client = _this65.channel.client,
10398
10486
  messageSerial = serialFromMsgOrSerial(msgOrSerial),
10399
10487
  format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
10400
10488
  envelope = client.http.supportsLinkHeaders ? void 0 : format,
10401
- headers = defaults_default.defaultGetHeaders(client.options, {
10402
- format
10403
- });
10489
+ headers = defaults_default.defaultGetHeaders(client.options);
10404
10490
  _mixin(headers, client.options.headers);
10405
- return new paginatedresource_default(client, basePathForSerial(_this59.channel, messageSerial), headers, envelope, /*#__PURE__*/function () {
10406
- var _ref0 = _asyncToGenerator(function* (body, _, unpacked) {
10491
+ return new paginatedresource_default(client, basePathForSerial(_this65.channel, messageSerial), headers, envelope, /*#__PURE__*/function () {
10492
+ var _ref10 = _asyncToGenerator(function* (body, _, unpacked) {
10407
10493
  var decoded = unpacked ? body : _decodeBody(body, client._MsgPack, format);
10408
- return _fromEncodedArray3(decoded, _this59.channel);
10494
+ return _fromEncodedArray3(decoded, _this65.channel);
10409
10495
  });
10410
- return function (_x78, _x79, _x80) {
10411
- return _ref0.apply(this, arguments);
10496
+ return function (_x84, _x85, _x86) {
10497
+ return _ref10.apply(this, arguments);
10412
10498
  };
10413
10499
  }()).get(params);
10414
10500
  })();
@@ -10579,7 +10665,7 @@ var ably = {exports: {}};
10579
10665
  this._mode = 0;
10580
10666
  this.retryCount = 0;
10581
10667
  this.history = /*#__PURE__*/function () {
10582
- var _ref1 = _asyncToGenerator(function* (params) {
10668
+ var _ref11 = _asyncToGenerator(function* (params) {
10583
10669
  logger_default.logAction(this.logger, logger_default.LOG_MICRO, "RealtimeChannel.history()", "channel = " + this.name);
10584
10670
  var restMixin = this.client.rest.channelMixin;
10585
10671
  if (params && params.untilAttach) {
@@ -10594,8 +10680,8 @@ var ably = {exports: {}};
10594
10680
  }
10595
10681
  return restMixin.history(this, params);
10596
10682
  });
10597
- return function (_x81) {
10598
- return _ref1.apply(this, arguments);
10683
+ return function (_x87) {
10684
+ return _ref11.apply(this, arguments);
10599
10685
  };
10600
10686
  }();
10601
10687
  this.whenState = state => {
@@ -10674,20 +10760,20 @@ var ably = {exports: {}};
10674
10760
  return args;
10675
10761
  }
10676
10762
  setOptions(options) {
10677
- var _this60 = this;
10763
+ var _this66 = this;
10678
10764
  return _asyncToGenerator(function* () {
10679
10765
  var _a2;
10680
- var previousChannelOptions = _this60.channelOptions;
10766
+ var previousChannelOptions = _this66.channelOptions;
10681
10767
  var err = validateChannelOptions(options);
10682
10768
  if (err) {
10683
10769
  throw err;
10684
10770
  }
10685
- _this60.channelOptions = normaliseChannelOptions((_a2 = _this60.client._Crypto) != null ? _a2 : null, _this60.logger, options);
10686
- if (_this60._decodingContext) _this60._decodingContext.channelOptions = _this60.channelOptions;
10687
- if (_this60._shouldReattachToSetOptions(options, previousChannelOptions)) {
10688
- _this60.attachImpl();
10771
+ _this66.channelOptions = normaliseChannelOptions((_a2 = _this66.client._Crypto) != null ? _a2 : null, _this66.logger, options);
10772
+ if (_this66._decodingContext) _this66._decodingContext.channelOptions = _this66.channelOptions;
10773
+ if (_this66._shouldReattachToSetOptions(options, previousChannelOptions)) {
10774
+ _this66.attachImpl();
10689
10775
  return new Promise((resolve, reject) => {
10690
- _this60._allChannelChanges.once(["attached", "update", "detached", "failed"], function (stateChange) {
10776
+ _this66._allChannelChanges.once(["attached", "update", "detached", "failed"], function (stateChange) {
10691
10777
  switch (this.event) {
10692
10778
  case "update":
10693
10779
  case "attached":
@@ -10724,7 +10810,7 @@ var ably = {exports: {}};
10724
10810
  }
10725
10811
  publish() {
10726
10812
  var _arguments2 = arguments,
10727
- _this61 = this;
10813
+ _this67 = this;
10728
10814
  return _asyncToGenerator(function* () {
10729
10815
  var messages;
10730
10816
  var argCount = _arguments2.length;
@@ -10742,20 +10828,20 @@ var ably = {exports: {}};
10742
10828
  data: _arguments2.length <= 1 ? undefined : _arguments2[1]
10743
10829
  })];
10744
10830
  }
10745
- var maxMessageSize = _this61.client.options.maxMessageSize;
10746
- var wireMessages = yield encodeArray(messages, _this61.channelOptions);
10831
+ var maxMessageSize = _this67.client.options.maxMessageSize;
10832
+ var wireMessages = yield encodeArray(messages, _this67.channelOptions);
10747
10833
  var size = getMessagesSize(wireMessages);
10748
10834
  if (size > maxMessageSize) {
10749
10835
  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);
10750
10836
  }
10751
- _this61.throwIfUnpublishableState();
10752
- logger_default.logAction(_this61.logger, logger_default.LOG_MICRO, "RealtimeChannel.publish()", "sending message; channel state is " + _this61.state + ", message count = " + wireMessages.length);
10837
+ _this67.throwIfUnpublishableState();
10838
+ logger_default.logAction(_this67.logger, logger_default.LOG_MICRO, "RealtimeChannel.publish()", "sending message; channel state is " + _this67.state + ", message count = " + wireMessages.length);
10753
10839
  var pm = fromValues({
10754
10840
  action: actions.MESSAGE,
10755
- channel: _this61.name,
10841
+ channel: _this67.name,
10756
10842
  messages: wireMessages
10757
10843
  });
10758
- return _this61.sendMessage(pm);
10844
+ return _this67.sendMessage(pm);
10759
10845
  })();
10760
10846
  }
10761
10847
  throwIfUnpublishableState() {
@@ -10775,13 +10861,13 @@ var ably = {exports: {}};
10775
10861
  }
10776
10862
  }
10777
10863
  attach() {
10778
- var _this62 = this;
10864
+ var _this68 = this;
10779
10865
  return _asyncToGenerator(function* () {
10780
- if (_this62.state === "attached") {
10866
+ if (_this68.state === "attached") {
10781
10867
  return null;
10782
10868
  }
10783
10869
  return new Promise((resolve, reject) => {
10784
- _this62._attach(false, null, (err, result) => err ? reject(err) : resolve(result));
10870
+ _this68._attach(false, null, (err, result) => err ? reject(err) : resolve(result));
10785
10871
  });
10786
10872
  })();
10787
10873
  }
@@ -10839,25 +10925,25 @@ var ably = {exports: {}};
10839
10925
  this.sendMessage(attachMsg).catch(noop);
10840
10926
  }
10841
10927
  detach() {
10842
- var _this63 = this;
10928
+ var _this69 = this;
10843
10929
  return _asyncToGenerator(function* () {
10844
- var connectionManager = _this63.connectionManager;
10930
+ var connectionManager = _this69.connectionManager;
10845
10931
  if (!connectionManager.activeState()) {
10846
10932
  throw connectionManager.getError();
10847
10933
  }
10848
- switch (_this63.state) {
10934
+ switch (_this69.state) {
10849
10935
  case "suspended":
10850
- _this63.notifyState("detached");
10936
+ _this69.notifyState("detached");
10851
10937
  return;
10852
10938
  case "detached":
10853
10939
  return;
10854
10940
  case "failed":
10855
10941
  throw new _ErrorInfo2("Unable to detach; channel state = failed", 90001, 400);
10856
10942
  default:
10857
- _this63.requestState("detaching");
10943
+ _this69.requestState("detaching");
10858
10944
  case "detaching":
10859
10945
  return new Promise((resolve, reject) => {
10860
- _this63.once(function (stateChange) {
10946
+ _this69.once(function (stateChange) {
10861
10947
  switch (this.event) {
10862
10948
  case "detached":
10863
10949
  resolve();
@@ -10886,22 +10972,22 @@ var ably = {exports: {}};
10886
10972
  }
10887
10973
  subscribe() {
10888
10974
  var _arguments3 = arguments,
10889
- _this64 = this;
10975
+ _this70 = this;
10890
10976
  return _asyncToGenerator(function* () {
10891
10977
  for (var _len0 = _arguments3.length, args = new Array(_len0), _key0 = 0; _key0 < _len0; _key0++) {
10892
10978
  args[_key0] = _arguments3[_key0];
10893
10979
  }
10894
10980
  var [event, listener] = _RealtimeChannel.processListenerArgs(args);
10895
- if (_this64.state === "failed") {
10896
- throw _ErrorInfo2.fromValues(_this64.invalidStateError());
10981
+ if (_this70.state === "failed") {
10982
+ throw _ErrorInfo2.fromValues(_this70.invalidStateError());
10897
10983
  }
10898
10984
  if (event && typeof event === "object" && !Array.isArray(event)) {
10899
- _this64.client._FilteredSubscriptions.subscribeFilter(_this64, event, listener);
10985
+ _this70.client._FilteredSubscriptions.subscribeFilter(_this70, event, listener);
10900
10986
  } else {
10901
- _this64.subscriptions.on(event, listener);
10987
+ _this70.subscriptions.on(event, listener);
10902
10988
  }
10903
- if (_this64.channelOptions.attachOnSubscribe !== false) {
10904
- return _this64.attach();
10989
+ if (_this70.channelOptions.attachOnSubscribe !== false) {
10990
+ return _this70.attach();
10905
10991
  } else {
10906
10992
  return null;
10907
10993
  }
@@ -10940,10 +11026,10 @@ var ably = {exports: {}};
10940
11026
  connectionManager.send(syncMessage);
10941
11027
  }
10942
11028
  sendMessage(msg) {
10943
- var _this65 = this;
11029
+ var _this71 = this;
10944
11030
  return _asyncToGenerator(function* () {
10945
11031
  return new Promise((resolve, reject) => {
10946
- _this65.connectionManager.send(msg, _this65.client.options.queueMessages, err => {
11032
+ _this71.connectionManager.send(msg, _this71.client.options.queueMessages, err => {
10947
11033
  if (err) {
10948
11034
  reject(err);
10949
11035
  } else {
@@ -10954,14 +11040,14 @@ var ably = {exports: {}};
10954
11040
  })();
10955
11041
  }
10956
11042
  sendPresence(presence) {
10957
- var _this66 = this;
11043
+ var _this72 = this;
10958
11044
  return _asyncToGenerator(function* () {
10959
11045
  var msg = fromValues({
10960
11046
  action: actions.PRESENCE,
10961
- channel: _this66.name,
11047
+ channel: _this72.name,
10962
11048
  presence
10963
11049
  });
10964
- return _this66.sendMessage(msg);
11050
+ return _this72.sendMessage(msg);
10965
11051
  })();
10966
11052
  }
10967
11053
  sendState(objectMessages) {
@@ -10974,61 +11060,61 @@ var ably = {exports: {}};
10974
11060
  }
10975
11061
  // Access to this method is synchronised by ConnectionManager#processChannelMessage, in order to synchronise access to the state stored in _decodingContext.
10976
11062
  processMessage(message) {
10977
- var _this67 = this;
11063
+ var _this73 = this;
10978
11064
  return _asyncToGenerator(function* () {
10979
11065
  if (message.action === actions.ATTACHED || message.action === actions.MESSAGE || message.action === actions.PRESENCE || message.action === actions.OBJECT || message.action === actions.ANNOTATION) {
10980
- _this67.setChannelSerial(message.channelSerial);
11066
+ _this73.setChannelSerial(message.channelSerial);
10981
11067
  }
10982
11068
  var syncChannelSerial,
10983
11069
  isSync = false;
10984
11070
  switch (message.action) {
10985
11071
  case actions.ATTACHED:
10986
11072
  {
10987
- _this67.properties.attachSerial = message.channelSerial;
10988
- _this67._mode = message.getMode();
10989
- _this67.params = message.params || {};
11073
+ _this73.properties.attachSerial = message.channelSerial;
11074
+ _this73._mode = message.getMode();
11075
+ _this73.params = message.params || {};
10990
11076
  var modesFromFlags = message.decodeModesFromFlags();
10991
- _this67.modes = modesFromFlags && _allToLowerCase(modesFromFlags) || void 0;
11077
+ _this73.modes = modesFromFlags && _allToLowerCase(modesFromFlags) || void 0;
10992
11078
  var resumed = message.hasFlag("RESUMED");
10993
11079
  var hasPresence = message.hasFlag("HAS_PRESENCE");
10994
11080
  var hasBacklog = message.hasFlag("HAS_BACKLOG");
10995
11081
  var hasObjects = message.hasFlag("HAS_OBJECTS");
10996
- if (_this67.state === "attached") {
11082
+ if (_this73.state === "attached") {
10997
11083
  if (!resumed) {
10998
- if (_this67._presence) {
10999
- _this67._presence.onAttached(hasPresence);
11084
+ if (_this73._presence) {
11085
+ _this73._presence.onAttached(hasPresence);
11000
11086
  }
11001
- if (_this67._objects) {
11002
- _this67._objects.onAttached(hasObjects);
11087
+ if (_this73._objects) {
11088
+ _this73._objects.onAttached(hasObjects);
11003
11089
  }
11004
11090
  }
11005
- var change = new channelstatechange_default(_this67.state, _this67.state, resumed, hasBacklog, message.error);
11006
- _this67._allChannelChanges.emit("update", change);
11007
- if (!resumed || _this67.channelOptions.updateOnAttached) {
11008
- _this67.emit("update", change);
11091
+ var change = new channelstatechange_default(_this73.state, _this73.state, resumed, hasBacklog, message.error);
11092
+ _this73._allChannelChanges.emit("update", change);
11093
+ if (!resumed || _this73.channelOptions.updateOnAttached) {
11094
+ _this73.emit("update", change);
11009
11095
  }
11010
- } else if (_this67.state === "detaching") {
11011
- _this67.checkPendingState();
11096
+ } else if (_this73.state === "detaching") {
11097
+ _this73.checkPendingState();
11012
11098
  } else {
11013
- _this67.notifyState("attached", message.error, resumed, hasPresence, hasBacklog, hasObjects);
11099
+ _this73.notifyState("attached", message.error, resumed, hasPresence, hasBacklog, hasObjects);
11014
11100
  }
11015
11101
  break;
11016
11102
  }
11017
11103
  case actions.DETACHED:
11018
11104
  {
11019
11105
  var detachErr = message.error ? _ErrorInfo2.fromValues(message.error) : new _ErrorInfo2("Channel detached", 90001, 404);
11020
- if (_this67.state === "detaching") {
11021
- _this67.notifyState("detached", detachErr);
11022
- } else if (_this67.state === "attaching") {
11023
- _this67.notifyState("suspended", detachErr);
11024
- } else if (_this67.state === "attached" || _this67.state === "suspended") {
11025
- _this67.requestState("attaching", detachErr);
11106
+ if (_this73.state === "detaching") {
11107
+ _this73.notifyState("detached", detachErr);
11108
+ } else if (_this73.state === "attaching") {
11109
+ _this73.notifyState("suspended", detachErr);
11110
+ } else if (_this73.state === "attached" || _this73.state === "suspended") {
11111
+ _this73.requestState("attaching", detachErr);
11026
11112
  }
11027
11113
  break;
11028
11114
  }
11029
11115
  case actions.SYNC:
11030
11116
  isSync = true;
11031
- syncChannelSerial = _this67.syncChannelSerial = message.channelSerial;
11117
+ syncChannelSerial = _this73.syncChannelSerial = message.channelSerial;
11032
11118
  if (!message.presence) break;
11033
11119
  case actions.PRESENCE:
11034
11120
  {
@@ -11036,45 +11122,45 @@ var ably = {exports: {}};
11036
11122
  break;
11037
11123
  }
11038
11124
  populateFieldsFromParent(message);
11039
- var options = _this67.channelOptions;
11040
- if (_this67._presence) {
11125
+ var options = _this73.channelOptions;
11126
+ if (_this73._presence) {
11041
11127
  var presenceMessages = yield Promise.all(message.presence.map(wpm => {
11042
- return wpm.decode(options, _this67.logger);
11128
+ return wpm.decode(options, _this73.logger);
11043
11129
  }));
11044
- _this67._presence.setPresence(presenceMessages, isSync, syncChannelSerial);
11130
+ _this73._presence.setPresence(presenceMessages, isSync, syncChannelSerial);
11045
11131
  }
11046
11132
  break;
11047
11133
  }
11048
11134
  case actions.OBJECT:
11049
11135
  case actions.OBJECT_SYNC:
11050
11136
  {
11051
- if (!_this67._objects || !message.state) {
11137
+ if (!_this73._objects || !message.state) {
11052
11138
  return;
11053
11139
  }
11054
11140
  populateFieldsFromParent(message);
11055
- var format = _this67.client.connection.connectionManager.getActiveTransportFormat();
11056
- var objectMessages = message.state.map(om => om.decode(_this67.client, format));
11141
+ var format = _this73.client.connection.connectionManager.getActiveTransportFormat();
11142
+ var objectMessages = message.state.map(om => om.decode(_this73.client, format));
11057
11143
  if (message.action === actions.OBJECT) {
11058
- _this67._objects.handleObjectMessages(objectMessages);
11144
+ _this73._objects.handleObjectMessages(objectMessages);
11059
11145
  } else {
11060
- _this67._objects.handleObjectSyncMessages(objectMessages, message.channelSerial);
11146
+ _this73._objects.handleObjectSyncMessages(objectMessages, message.channelSerial);
11061
11147
  }
11062
11148
  break;
11063
11149
  }
11064
11150
  case actions.MESSAGE:
11065
11151
  {
11066
- if (_this67.state !== "attached") {
11067
- 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 + '").');
11152
+ if (_this73.state !== "attached") {
11153
+ 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 + '").');
11068
11154
  return;
11069
11155
  }
11070
11156
  populateFieldsFromParent(message);
11071
11157
  var encoded = message.messages,
11072
11158
  firstMessage = encoded[0],
11073
11159
  lastMessage = encoded[encoded.length - 1];
11074
- if (firstMessage.extras && firstMessage.extras.delta && firstMessage.extras.delta.from !== _this67._lastPayload.messageId) {
11075
- var msg = 'Delta message decode failure - previous message not available for message "' + message.id + '" on this channel "' + _this67.name + '".';
11076
- logger_default.logAction(_this67.logger, logger_default.LOG_ERROR, "RealtimeChannel.processMessage()", msg);
11077
- _this67._startDecodeFailureRecovery(new _ErrorInfo2(msg, 40018, 400));
11160
+ if (firstMessage.extras && firstMessage.extras.delta && firstMessage.extras.delta.from !== _this73._lastPayload.messageId) {
11161
+ var msg = 'Delta message decode failure - previous message not available for message "' + message.id + '" on this channel "' + _this73.name + '".';
11162
+ logger_default.logAction(_this73.logger, logger_default.LOG_ERROR, "RealtimeChannel.processMessage()", msg);
11163
+ _this73._startDecodeFailureRecovery(new _ErrorInfo2(msg, 40018, 400));
11078
11164
  break;
11079
11165
  }
11080
11166
  var messages = [];
@@ -11082,34 +11168,34 @@ var ably = {exports: {}};
11082
11168
  var {
11083
11169
  decoded,
11084
11170
  err
11085
- } = yield encoded[i].decodeWithErr(_this67._decodingContext, _this67.logger);
11171
+ } = yield encoded[i].decodeWithErr(_this73._decodingContext, _this73.logger);
11086
11172
  messages[i] = decoded;
11087
11173
  if (err) {
11088
11174
  switch (err.code) {
11089
11175
  case 40018:
11090
- _this67._startDecodeFailureRecovery(err);
11176
+ _this73._startDecodeFailureRecovery(err);
11091
11177
  return;
11092
11178
  case 40019:
11093
11179
  case 40021:
11094
- _this67.notifyState("failed", err);
11180
+ _this73.notifyState("failed", err);
11095
11181
  return;
11096
11182
  }
11097
11183
  }
11098
11184
  }
11099
- _this67._lastPayload.messageId = lastMessage.id;
11100
- _this67._lastPayload.protocolMessageChannelSerial = message.channelSerial;
11101
- _this67.onEvent(messages);
11185
+ _this73._lastPayload.messageId = lastMessage.id;
11186
+ _this73._lastPayload.protocolMessageChannelSerial = message.channelSerial;
11187
+ _this73.onEvent(messages);
11102
11188
  break;
11103
11189
  }
11104
11190
  case actions.ANNOTATION:
11105
11191
  {
11106
11192
  populateFieldsFromParent(message);
11107
- var _options = _this67.channelOptions;
11108
- if (_this67._annotations) {
11193
+ var _options = _this73.channelOptions;
11194
+ if (_this73._annotations) {
11109
11195
  var annotations = yield Promise.all((message.annotations || []).map(wpm => {
11110
- return wpm.decode(_options, _this67.logger);
11196
+ return wpm.decode(_options, _this73.logger);
11111
11197
  }));
11112
- _this67._annotations._processIncoming(annotations);
11198
+ _this73._annotations._processIncoming(annotations);
11113
11199
  }
11114
11200
  break;
11115
11201
  }
@@ -11117,14 +11203,14 @@ var ably = {exports: {}};
11117
11203
  {
11118
11204
  var _err = message.error;
11119
11205
  if (_err && _err.code == 80016) {
11120
- _this67.checkPendingState();
11206
+ _this73.checkPendingState();
11121
11207
  } else {
11122
- _this67.notifyState("failed", _ErrorInfo2.fromValues(_err));
11208
+ _this73.notifyState("failed", _ErrorInfo2.fromValues(_err));
11123
11209
  }
11124
11210
  break;
11125
11211
  }
11126
11212
  default:
11127
- logger_default.logAction(_this67.logger, logger_default.LOG_MAJOR, "RealtimeChannel.processMessage()", "Protocol error: unrecognised message action (" + message.action + ")");
11213
+ logger_default.logAction(_this73.logger, logger_default.LOG_MAJOR, "RealtimeChannel.processMessage()", "Protocol error: unrecognised message action (" + message.action + ")");
11128
11214
  }
11129
11215
  })();
11130
11216
  }
@@ -11280,9 +11366,45 @@ var ably = {exports: {}};
11280
11366
  }
11281
11367
  }
11282
11368
  status() {
11283
- var _this68 = this;
11369
+ var _this74 = this;
11370
+ return _asyncToGenerator(function* () {
11371
+ return _this74.client.rest.channelMixin.status(_this74);
11372
+ })();
11373
+ }
11374
+ getMessage(serialOrMessage) {
11375
+ var _this75 = this;
11376
+ return _asyncToGenerator(function* () {
11377
+ logger_default.logAction(_this75.logger, logger_default.LOG_MICRO, "RealtimeChannel.getMessage()", "channel = " + _this75.name);
11378
+ var restMixin = _this75.client.rest.channelMixin;
11379
+ return restMixin.getMessage(_this75, serialOrMessage);
11380
+ })();
11381
+ }
11382
+ updateMessage(message, operation, params) {
11383
+ var _this76 = this;
11384
+ return _asyncToGenerator(function* () {
11385
+ logger_default.logAction(_this76.logger, logger_default.LOG_MICRO, "RealtimeChannel.updateMessage()", "channel = " + _this76.name);
11386
+ var restMixin = _this76.client.rest.channelMixin;
11387
+ return restMixin.updateDeleteMessage(_this76, {
11388
+ isDelete: false
11389
+ }, message, operation, params);
11390
+ })();
11391
+ }
11392
+ deleteMessage(message, operation, params) {
11393
+ var _this77 = this;
11394
+ return _asyncToGenerator(function* () {
11395
+ logger_default.logAction(_this77.logger, logger_default.LOG_MICRO, "RealtimeChannel.deleteMessage()", "channel = " + _this77.name);
11396
+ var restMixin = _this77.client.rest.channelMixin;
11397
+ return restMixin.updateDeleteMessage(_this77, {
11398
+ isDelete: true
11399
+ }, message, operation, params);
11400
+ })();
11401
+ }
11402
+ getMessageVersions(serialOrMessage, params) {
11403
+ var _this78 = this;
11284
11404
  return _asyncToGenerator(function* () {
11285
- return _this68.client.rest.channelMixin.status(_this68);
11405
+ logger_default.logAction(_this78.logger, logger_default.LOG_MICRO, "RealtimeChannel.getMessageVersions()", "channel = " + _this78.name);
11406
+ var restMixin = _this78.client.rest.channelMixin;
11407
+ return restMixin.getMessageVersions(_this78, serialOrMessage, params);
11286
11408
  })();
11287
11409
  }
11288
11410
  };
@@ -11301,31 +11423,31 @@ var ably = {exports: {}};
11301
11423
  this.subscriptions = new eventemitter_default(this.logger);
11302
11424
  }
11303
11425
  publish(msgOrSerial, annotationValues) {
11304
- var _this69 = this;
11426
+ var _this79 = this;
11305
11427
  return _asyncToGenerator(function* () {
11306
- var channelName = _this69.channel.name;
11428
+ var channelName = _this79.channel.name;
11307
11429
  var annotation = constructValidateAnnotation(msgOrSerial, annotationValues);
11308
11430
  var wireAnnotation = yield annotation.encode();
11309
- _this69.channel.throwIfUnpublishableState();
11310
- logger_default.logAction(_this69.logger, logger_default.LOG_MICRO, "RealtimeAnnotations.publish()", "channelName = " + channelName + ", sending annotation with messageSerial = " + annotation.messageSerial + ", type = " + annotation.type);
11431
+ _this79.channel.throwIfUnpublishableState();
11432
+ logger_default.logAction(_this79.logger, logger_default.LOG_MICRO, "RealtimeAnnotations.publish()", "channelName = " + channelName + ", sending annotation with messageSerial = " + annotation.messageSerial + ", type = " + annotation.type);
11311
11433
  var pm = fromValues({
11312
11434
  action: actions.ANNOTATION,
11313
11435
  channel: channelName,
11314
11436
  annotations: [wireAnnotation]
11315
11437
  });
11316
- return _this69.channel.sendMessage(pm);
11438
+ return _this79.channel.sendMessage(pm);
11317
11439
  })();
11318
11440
  }
11319
11441
  delete(msgOrSerial, annotationValues) {
11320
- var _this70 = this;
11442
+ var _this80 = this;
11321
11443
  return _asyncToGenerator(function* () {
11322
11444
  annotationValues.action = "annotation.delete";
11323
- return _this70.publish(msgOrSerial, annotationValues);
11445
+ return _this80.publish(msgOrSerial, annotationValues);
11324
11446
  })();
11325
11447
  }
11326
11448
  subscribe() {
11327
11449
  var _arguments4 = arguments,
11328
- _this71 = this;
11450
+ _this81 = this;
11329
11451
  return _asyncToGenerator(function* () {
11330
11452
  for (var _len10 = _arguments4.length, _args = new Array(_len10), _key10 = 0; _key10 < _len10; _key10++) {
11331
11453
  _args[_key10] = _arguments4[_key10];
@@ -11333,15 +11455,15 @@ var ably = {exports: {}};
11333
11455
  var args = realtimechannel_default.processListenerArgs(_args);
11334
11456
  var event = args[0];
11335
11457
  var listener = args[1];
11336
- var channel = _this71.channel;
11458
+ var channel = _this81.channel;
11337
11459
  if (channel.state === "failed") {
11338
11460
  throw _ErrorInfo2.fromValues(channel.invalidStateError());
11339
11461
  }
11340
- _this71.subscriptions.on(event, listener);
11341
- if (_this71.channel.channelOptions.attachOnSubscribe !== false) {
11462
+ _this81.subscriptions.on(event, listener);
11463
+ if (_this81.channel.channelOptions.attachOnSubscribe !== false) {
11342
11464
  yield channel.attach();
11343
11465
  }
11344
- if ((_this71.channel.state === "attached" && _this71.channel._mode & flags.ANNOTATION_SUBSCRIBE) === 0) {
11466
+ if ((_this81.channel.state === "attached" && _this81.channel._mode & flags.ANNOTATION_SUBSCRIBE) === 0) {
11345
11467
  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);
11346
11468
  }
11347
11469
  })();
@@ -11361,9 +11483,9 @@ var ably = {exports: {}};
11361
11483
  }
11362
11484
  }
11363
11485
  get(msgOrSerial, params) {
11364
- var _this72 = this;
11486
+ var _this82 = this;
11365
11487
  return _asyncToGenerator(function* () {
11366
- return restannotations_default.prototype.get.call(_this72, msgOrSerial, params);
11488
+ return restannotations_default.prototype.get.call(_this82, msgOrSerial, params);
11367
11489
  })();
11368
11490
  }
11369
11491
  };
@@ -13025,23 +13147,23 @@ var ably = {exports: {}};
13025
13147
  }
13026
13148
  }
13027
13149
  processChannelMessage(message) {
13028
- var _this73 = this;
13150
+ var _this83 = this;
13029
13151
  return _asyncToGenerator(function* () {
13030
- yield _this73.realtime.channels.processChannelMessage(message);
13152
+ yield _this83.realtime.channels.processChannelMessage(message);
13031
13153
  })();
13032
13154
  }
13033
13155
  ping() {
13034
- var _this74 = this;
13156
+ var _this84 = this;
13035
13157
  return _asyncToGenerator(function* () {
13036
13158
  var _a2;
13037
- if (_this74.state.state !== "connected") {
13159
+ if (_this84.state.state !== "connected") {
13038
13160
  throw new _ErrorInfo2("Unable to ping service; not connected", 4e4, 400);
13039
13161
  }
13040
- var transport = (_a2 = _this74.activeProtocol) == null ? void 0 : _a2.getTransport();
13162
+ var transport = (_a2 = _this84.activeProtocol) == null ? void 0 : _a2.getTransport();
13041
13163
  if (!transport) {
13042
- throw _this74.getStateError();
13164
+ throw _this84.getStateError();
13043
13165
  }
13044
- logger_default.logAction(_this74.logger, logger_default.LOG_MINOR, "ConnectionManager.ping()", "transport = " + transport);
13166
+ logger_default.logAction(_this84.logger, logger_default.LOG_MINOR, "ConnectionManager.ping()", "transport = " + transport);
13045
13167
  var pingStart = Date.now();
13046
13168
  var id = _cheapRandStr();
13047
13169
  return _withTimeoutAsync(new Promise(resolve => {
@@ -13053,7 +13175,7 @@ var ably = {exports: {}};
13053
13175
  };
13054
13176
  transport.on("heartbeat", onHeartbeat);
13055
13177
  transport.ping(id);
13056
- }), _this74.options.timeouts.realtimeRequestTimeout, "Timeout waiting for heartbeat response");
13178
+ }), _this84.options.timeouts.realtimeRequestTimeout, "Timeout waiting for heartbeat response");
13057
13179
  })();
13058
13180
  }
13059
13181
  abort(error) {
@@ -13202,10 +13324,10 @@ var ably = {exports: {}};
13202
13324
  });
13203
13325
  }
13204
13326
  ping() {
13205
- var _this75 = this;
13327
+ var _this85 = this;
13206
13328
  return _asyncToGenerator(function* () {
13207
- logger_default.logAction(_this75.logger, logger_default.LOG_MINOR, "Connection.ping()", "");
13208
- return _this75.connectionManager.ping();
13329
+ logger_default.logAction(_this85.logger, logger_default.LOG_MINOR, "Connection.ping()", "");
13330
+ return _this85.connectionManager.ping();
13209
13331
  })();
13210
13332
  }
13211
13333
  close() {
@@ -13261,6 +13383,9 @@ var ably = {exports: {}};
13261
13383
  get channels() {
13262
13384
  return this._channels;
13263
13385
  }
13386
+ get clientId() {
13387
+ return this.auth.clientId;
13388
+ }
13264
13389
  connect() {
13265
13390
  logger_default.logAction(this.logger, logger_default.LOG_MINOR, "Realtime.connect()", "");
13266
13391
  this.connection.connect();
@@ -13301,16 +13426,16 @@ var ably = {exports: {}};
13301
13426
  }
13302
13427
  // Access to this method is synchronised by ConnectionManager#processChannelMessage.
13303
13428
  processChannelMessage(msg) {
13304
- var _this76 = this;
13429
+ var _this86 = this;
13305
13430
  return _asyncToGenerator(function* () {
13306
13431
  var channelName = msg.channel;
13307
13432
  if (channelName === void 0) {
13308
- logger_default.logAction(_this76.logger, logger_default.LOG_ERROR, "Channels.processChannelMessage()", "received event unspecified channel, action = " + msg.action);
13433
+ logger_default.logAction(_this86.logger, logger_default.LOG_ERROR, "Channels.processChannelMessage()", "received event unspecified channel, action = " + msg.action);
13309
13434
  return;
13310
13435
  }
13311
- var channel = _this76.all[channelName];
13436
+ var channel = _this86.all[channelName];
13312
13437
  if (!channel) {
13313
- logger_default.logAction(_this76.logger, logger_default.LOG_ERROR, "Channels.processChannelMessage()", "received event for non-existent channel: " + channelName);
13438
+ logger_default.logAction(_this86.logger, logger_default.LOG_ERROR, "Channels.processChannelMessage()", "received event for non-existent channel: " + channelName);
13314
13439
  return;
13315
13440
  }
13316
13441
  yield channel.processMessage(msg);
@@ -13565,43 +13690,43 @@ var ably = {exports: {}};
13565
13690
  this.pendingPresence = [];
13566
13691
  }
13567
13692
  enter(data) {
13568
- var _this77 = this;
13693
+ var _this87 = this;
13569
13694
  return _asyncToGenerator(function* () {
13570
- if (isAnonymousOrWildcard(_this77)) {
13695
+ if (isAnonymousOrWildcard(_this87)) {
13571
13696
  throw new _ErrorInfo2("clientId must be specified to enter a presence channel", 40012, 400);
13572
13697
  }
13573
- return _this77._enterOrUpdateClient(void 0, void 0, data, "enter");
13698
+ return _this87._enterOrUpdateClient(void 0, void 0, data, "enter");
13574
13699
  })();
13575
13700
  }
13576
13701
  update(data) {
13577
- var _this78 = this;
13702
+ var _this88 = this;
13578
13703
  return _asyncToGenerator(function* () {
13579
- if (isAnonymousOrWildcard(_this78)) {
13704
+ if (isAnonymousOrWildcard(_this88)) {
13580
13705
  throw new _ErrorInfo2("clientId must be specified to update presence data", 40012, 400);
13581
13706
  }
13582
- return _this78._enterOrUpdateClient(void 0, void 0, data, "update");
13707
+ return _this88._enterOrUpdateClient(void 0, void 0, data, "update");
13583
13708
  })();
13584
13709
  }
13585
13710
  enterClient(clientId, data) {
13586
- var _this79 = this;
13711
+ var _this89 = this;
13587
13712
  return _asyncToGenerator(function* () {
13588
- return _this79._enterOrUpdateClient(void 0, clientId, data, "enter");
13713
+ return _this89._enterOrUpdateClient(void 0, clientId, data, "enter");
13589
13714
  })();
13590
13715
  }
13591
13716
  updateClient(clientId, data) {
13592
- var _this80 = this;
13717
+ var _this90 = this;
13593
13718
  return _asyncToGenerator(function* () {
13594
- return _this80._enterOrUpdateClient(void 0, clientId, data, "update");
13719
+ return _this90._enterOrUpdateClient(void 0, clientId, data, "update");
13595
13720
  })();
13596
13721
  }
13597
13722
  _enterOrUpdateClient(id, clientId, data, action) {
13598
- var _this81 = this;
13723
+ var _this91 = this;
13599
13724
  return _asyncToGenerator(function* () {
13600
- var channel = _this81.channel;
13725
+ var channel = _this91.channel;
13601
13726
  if (!channel.connectionManager.activeState()) {
13602
13727
  throw channel.connectionManager.getError();
13603
13728
  }
13604
- logger_default.logAction(_this81.logger, logger_default.LOG_MICRO, "RealtimePresence." + action + "Client()", "channel = " + channel.name + ", id = " + id + ", client = " + (clientId || "(implicit) " + getClientId(_this81)));
13729
+ logger_default.logAction(_this91.logger, logger_default.LOG_MICRO, "RealtimePresence." + action + "Client()", "channel = " + channel.name + ", id = " + id + ", client = " + (clientId || "(implicit) " + getClientId(_this91)));
13605
13730
  var presence = presencemessage_default.fromData(data);
13606
13731
  presence.action = action;
13607
13732
  if (id) {
@@ -13619,7 +13744,7 @@ var ably = {exports: {}};
13619
13744
  channel.attach();
13620
13745
  case "attaching":
13621
13746
  return new Promise((resolve, reject) => {
13622
- _this81.pendingPresence.push({
13747
+ _this91.pendingPresence.push({
13623
13748
  presence: wirePresMsg,
13624
13749
  callback: err => err ? reject(err) : resolve()
13625
13750
  });
@@ -13634,22 +13759,22 @@ var ably = {exports: {}};
13634
13759
  })();
13635
13760
  }
13636
13761
  leave(data) {
13637
- var _this82 = this;
13762
+ var _this92 = this;
13638
13763
  return _asyncToGenerator(function* () {
13639
- if (isAnonymousOrWildcard(_this82)) {
13764
+ if (isAnonymousOrWildcard(_this92)) {
13640
13765
  throw new _ErrorInfo2("clientId must have been specified to enter or leave a presence channel", 40012, 400);
13641
13766
  }
13642
- return _this82.leaveClient(void 0, data);
13767
+ return _this92.leaveClient(void 0, data);
13643
13768
  })();
13644
13769
  }
13645
13770
  leaveClient(clientId, data) {
13646
- var _this83 = this;
13771
+ var _this93 = this;
13647
13772
  return _asyncToGenerator(function* () {
13648
- var channel = _this83.channel;
13773
+ var channel = _this93.channel;
13649
13774
  if (!channel.connectionManager.activeState()) {
13650
13775
  throw channel.connectionManager.getError();
13651
13776
  }
13652
- logger_default.logAction(_this83.logger, logger_default.LOG_MICRO, "RealtimePresence.leaveClient()", "leaving; channel = " + _this83.channel.name + ", client = " + clientId);
13777
+ logger_default.logAction(_this93.logger, logger_default.LOG_MICRO, "RealtimePresence.leaveClient()", "leaving; channel = " + _this93.channel.name + ", client = " + clientId);
13653
13778
  var presence = presencemessage_default.fromData(data);
13654
13779
  presence.action = "leave";
13655
13780
  if (clientId) {
@@ -13661,7 +13786,7 @@ var ably = {exports: {}};
13661
13786
  return channel.sendPresence([wirePresMsg]);
13662
13787
  case "attaching":
13663
13788
  return new Promise((resolve, reject) => {
13664
- _this83.pendingPresence.push({
13789
+ _this93.pendingPresence.push({
13665
13790
  presence: wirePresMsg,
13666
13791
  callback: err => err ? reject(err) : resolve()
13667
13792
  });
@@ -13677,14 +13802,14 @@ var ably = {exports: {}};
13677
13802
  })();
13678
13803
  }
13679
13804
  get(params) {
13680
- var _this84 = this;
13805
+ var _this94 = this;
13681
13806
  return _asyncToGenerator(function* () {
13682
13807
  var waitForSync = !params || ("waitForSync" in params ? params.waitForSync : true);
13683
13808
  return new Promise((resolve, reject) => {
13684
13809
  function returnMembers(members) {
13685
13810
  resolve(params ? members.list(params) : members.values());
13686
13811
  }
13687
- if (_this84.channel.state === "suspended") {
13812
+ if (_this94.channel.state === "suspended") {
13688
13813
  if (waitForSync) {
13689
13814
  reject(_ErrorInfo2.fromValues({
13690
13815
  statusCode: 400,
@@ -13692,12 +13817,12 @@ var ably = {exports: {}};
13692
13817
  message: "Presence state is out of sync due to channel being in the SUSPENDED state"
13693
13818
  }));
13694
13819
  } else {
13695
- returnMembers(_this84.members);
13820
+ returnMembers(_this94.members);
13696
13821
  }
13697
13822
  return;
13698
13823
  }
13699
- waitAttached(_this84.channel, err => reject(err), () => {
13700
- var members = _this84.members;
13824
+ waitAttached(_this94.channel, err => reject(err), () => {
13825
+ var members = _this94.members;
13701
13826
  if (waitForSync) {
13702
13827
  members.waitSync(function () {
13703
13828
  returnMembers(members);
@@ -13710,19 +13835,19 @@ var ably = {exports: {}};
13710
13835
  })();
13711
13836
  }
13712
13837
  history(params) {
13713
- var _this85 = this;
13838
+ var _this95 = this;
13714
13839
  return _asyncToGenerator(function* () {
13715
- logger_default.logAction(_this85.logger, logger_default.LOG_MICRO, "RealtimePresence.history()", "channel = " + _this85.name);
13716
- var restMixin = _this85.channel.client.rest.presenceMixin;
13840
+ logger_default.logAction(_this95.logger, logger_default.LOG_MICRO, "RealtimePresence.history()", "channel = " + _this95.name);
13841
+ var restMixin = _this95.channel.client.rest.presenceMixin;
13717
13842
  if (params && params.untilAttach) {
13718
- if (_this85.channel.state === "attached") {
13843
+ if (_this95.channel.state === "attached") {
13719
13844
  delete params.untilAttach;
13720
- params.from_serial = _this85.channel.properties.attachSerial;
13845
+ params.from_serial = _this95.channel.properties.attachSerial;
13721
13846
  } else {
13722
- throw new _ErrorInfo2("option untilAttach requires the channel to be attached, was: " + _this85.channel.state, 4e4, 400);
13847
+ throw new _ErrorInfo2("option untilAttach requires the channel to be attached, was: " + _this95.channel.state, 4e4, 400);
13723
13848
  }
13724
13849
  }
13725
- return restMixin.history(_this85, params);
13850
+ return restMixin.history(_this95, params);
13726
13851
  })();
13727
13852
  }
13728
13853
  setPresence(presenceSet, isSync, syncChannelSerial) {
@@ -13850,7 +13975,7 @@ var ably = {exports: {}};
13850
13975
  }
13851
13976
  subscribe() {
13852
13977
  var _arguments5 = arguments,
13853
- _this86 = this;
13978
+ _this96 = this;
13854
13979
  return _asyncToGenerator(function* () {
13855
13980
  for (var _len12 = _arguments5.length, _args = new Array(_len12), _key12 = 0; _key12 < _len12; _key12++) {
13856
13981
  _args[_key12] = _arguments5[_key12];
@@ -13858,11 +13983,11 @@ var ably = {exports: {}};
13858
13983
  var args = realtimechannel_default.processListenerArgs(_args);
13859
13984
  var event = args[0];
13860
13985
  var listener = args[1];
13861
- var channel = _this86.channel;
13986
+ var channel = _this96.channel;
13862
13987
  if (channel.state === "failed") {
13863
13988
  throw _ErrorInfo2.fromValues(channel.invalidStateError());
13864
13989
  }
13865
- _this86.subscriptions.on(event, listener);
13990
+ _this96.subscriptions.on(event, listener);
13866
13991
  if (channel.channelOptions.attachOnSubscribe !== false) {
13867
13992
  yield channel.attach();
13868
13993
  }
@@ -14034,8 +14159,8 @@ var ably = {exports: {}};
14034
14159
  isRef: !!((_f = (_e = m.extras) == null ? void 0 : _e.ref) == null ? void 0 : _f.timeserial),
14035
14160
  clientId: m.clientId
14036
14161
  };
14037
- if (Object.entries(filter).find(_ref10 => {
14038
- var [key, value] = _ref10;
14162
+ if (Object.entries(filter).find(_ref12 => {
14163
+ var [key, value] = _ref12;
14039
14164
  return value !== void 0 ? mapping[key] !== value : false;
14040
14165
  })) {
14041
14166
  return;
@@ -14063,8 +14188,8 @@ var ably = {exports: {}};
14063
14188
  return [];
14064
14189
  }
14065
14190
  if (!realListener && filter) {
14066
- return Array.from(channel.filteredSubscriptions.entries()).map(_ref11 => {
14067
- var [key, filterMaps] = _ref11;
14191
+ return Array.from(channel.filteredSubscriptions.entries()).map(_ref13 => {
14192
+ var [key, filterMaps] = _ref13;
14068
14193
  var _a2;
14069
14194
  var listenerMaps = filterMaps.get(filter);
14070
14195
  filterMaps.delete(filter);
@@ -14536,38 +14661,38 @@ var ably = {exports: {}};
14536
14661
  return output;
14537
14662
  }
14538
14663
  encrypt(plaintext) {
14539
- var _this87 = this;
14664
+ var _this97 = this;
14540
14665
  return _asyncToGenerator(function* () {
14541
- logger_default.logAction(_this87.logger, logger_default.LOG_MICRO, "CBCCipher.encrypt()", "");
14542
- var iv = yield _this87.getIv();
14543
- var cryptoKey = yield crypto.subtle.importKey("raw", _this87.key, _this87.webCryptoAlgorithm, false, ["encrypt"]);
14666
+ logger_default.logAction(_this97.logger, logger_default.LOG_MICRO, "CBCCipher.encrypt()", "");
14667
+ var iv = yield _this97.getIv();
14668
+ var cryptoKey = yield crypto.subtle.importKey("raw", _this97.key, _this97.webCryptoAlgorithm, false, ["encrypt"]);
14544
14669
  var ciphertext = yield crypto.subtle.encrypt({
14545
- name: _this87.webCryptoAlgorithm,
14670
+ name: _this97.webCryptoAlgorithm,
14546
14671
  iv
14547
14672
  }, cryptoKey, plaintext);
14548
- return _this87.concat(iv, ciphertext);
14673
+ return _this97.concat(iv, ciphertext);
14549
14674
  })();
14550
14675
  }
14551
14676
  decrypt(ciphertext) {
14552
- var _this88 = this;
14677
+ var _this98 = this;
14553
14678
  return _asyncToGenerator(function* () {
14554
- logger_default.logAction(_this88.logger, logger_default.LOG_MICRO, "CBCCipher.decrypt()", "");
14679
+ logger_default.logAction(_this98.logger, logger_default.LOG_MICRO, "CBCCipher.decrypt()", "");
14555
14680
  var ciphertextArrayBuffer = bufferUtils.toArrayBuffer(ciphertext);
14556
14681
  var iv = ciphertextArrayBuffer.slice(0, DEFAULT_BLOCKLENGTH);
14557
14682
  var ciphertextBody = ciphertextArrayBuffer.slice(DEFAULT_BLOCKLENGTH);
14558
- var cryptoKey = yield crypto.subtle.importKey("raw", _this88.key, _this88.webCryptoAlgorithm, false, ["decrypt"]);
14683
+ var cryptoKey = yield crypto.subtle.importKey("raw", _this98.key, _this98.webCryptoAlgorithm, false, ["decrypt"]);
14559
14684
  return crypto.subtle.decrypt({
14560
- name: _this88.webCryptoAlgorithm,
14685
+ name: _this98.webCryptoAlgorithm,
14561
14686
  iv
14562
14687
  }, cryptoKey, ciphertextBody);
14563
14688
  })();
14564
14689
  }
14565
14690
  getIv() {
14566
- var _this89 = this;
14691
+ var _this99 = this;
14567
14692
  return _asyncToGenerator(function* () {
14568
- if (_this89.iv) {
14569
- var iv = _this89.iv;
14570
- _this89.iv = null;
14693
+ if (_this99.iv) {
14694
+ var iv = _this99.iv;
14695
+ _this99.iv = null;
14571
14696
  return iv;
14572
14697
  }
14573
14698
  var randomBlock = yield config.getRandomArrayBuffer(DEFAULT_BLOCKLENGTH);
@@ -14614,7 +14739,7 @@ var ably = {exports: {}};
14614
14739
  if (Platform.Config.xhrSupported && xhrRequestImplementation) {
14615
14740
  this.supportsAuthHeaders = true;
14616
14741
  this.Request = /*#__PURE__*/function () {
14617
- var _ref12 = _asyncToGenerator(function* (method, uri, headers, params, body) {
14742
+ var _ref14 = _asyncToGenerator(function* (method, uri, headers, params, body) {
14618
14743
  return new Promise(resolve => {
14619
14744
  var _a3;
14620
14745
  var req = xhrRequestImplementation.createRequest(uri, headers, params, body, XHRStates_default.REQ_SEND, (_a3 = client && client.options.timeouts) != null ? _a3 : null, this.logger, method);
@@ -14628,8 +14753,8 @@ var ably = {exports: {}};
14628
14753
  req.exec();
14629
14754
  });
14630
14755
  });
14631
- return function (_x82, _x83, _x84, _x85, _x86) {
14632
- return _ref12.apply(this, arguments);
14756
+ return function (_x88, _x89, _x90, _x91, _x92) {
14757
+ return _ref14.apply(this, arguments);
14633
14758
  };
14634
14759
  }();
14635
14760
  if (client == null ? void 0 : client.options.disableConnectivityCheck) {
@@ -14654,11 +14779,11 @@ var ably = {exports: {}};
14654
14779
  } else if (Platform.Config.fetchSupported && fetchRequestImplementation) {
14655
14780
  this.supportsAuthHeaders = true;
14656
14781
  this.Request = /*#__PURE__*/function () {
14657
- var _ref15 = _asyncToGenerator(function* (method, uri, headers, params, body) {
14782
+ var _ref17 = _asyncToGenerator(function* (method, uri, headers, params, body) {
14658
14783
  return fetchRequestImplementation(method, client != null ? client : null, uri, headers, params, body);
14659
14784
  });
14660
- return function (_x87, _x88, _x89, _x90, _x91) {
14661
- return _ref15.apply(this, arguments);
14785
+ return function (_x93, _x94, _x95, _x96, _x97) {
14786
+ return _ref17.apply(this, arguments);
14662
14787
  };
14663
14788
  }();
14664
14789
  if (client == null ? void 0 : client.options.disableConnectivityCheck) {
@@ -14689,14 +14814,14 @@ var ably = {exports: {}};
14689
14814
  return (_b = (_a2 = this.client) == null ? void 0 : _a2.logger) != null ? _b : logger_default.defaultLogger;
14690
14815
  }
14691
14816
  doUri(method, uri, headers, body, params) {
14692
- var _this90 = this;
14817
+ var _this100 = this;
14693
14818
  return _asyncToGenerator(function* () {
14694
- if (!_this90.Request) {
14819
+ if (!_this100.Request) {
14695
14820
  return {
14696
14821
  error: new PartialErrorInfo("Request invoked before assigned to", null, 500)
14697
14822
  };
14698
14823
  }
14699
- return _this90.Request(method, uri, headers, params, body);
14824
+ return _this100.Request(method, uri, headers, params, body);
14700
14825
  })();
14701
14826
  }
14702
14827
  shouldFallback(errorInfo) {
@@ -14826,7 +14951,7 @@ var ably = {exports: {}};
14826
14951
  globalObject4.crypto.getRandomValues(byteArray);
14827
14952
  return byteArray.buffer;
14828
14953
  });
14829
- function getRandomArrayBuffer(_x92) {
14954
+ function getRandomArrayBuffer(_x98) {
14830
14955
  return _getRandomArrayBuffer.apply(this, arguments);
14831
14956
  }
14832
14957
  return getRandomArrayBuffer;
@@ -15971,7 +16096,7 @@ var ably = {exports: {}};
15971
16096
  });
15972
16097
  return result;
15973
16098
  }
15974
- function fetchRequest(_x93, _x94, _x95, _x96, _x97, _x98) {
16099
+ function fetchRequest(_x99, _x100, _x101, _x102, _x103, _x104) {
15975
16100
  return _fetchRequest.apply(this, arguments);
15976
16101
  } // src/platform/web/lib/http/request/index.ts
15977
16102
  function _fetchRequest() {
@@ -16120,10 +16245,19 @@ class ClientAblyService {
16120
16245
  token: ablyToken,
16121
16246
  autoConnect: true
16122
16247
  });
16248
+ _this.client.connection.on('failed', stateChange => {
16249
+ var _a;
16250
+ console.error('[AblyService] Connection state: failed', {
16251
+ reason: (_a = stateChange.reason) === null || _a === void 0 ? void 0 : _a.message,
16252
+ error: stateChange.reason
16253
+ });
16254
+ });
16123
16255
  // Wait for connection to be established
16124
16256
  yield new Promise((resolve, reject) => {
16125
16257
  if (!_this.client) {
16126
- reject(new Error('Failed to initialize Ably client'));
16258
+ var error = new Error('Failed to initialize Ably client');
16259
+ console.error('[AblyService]', error);
16260
+ reject(error);
16127
16261
  return;
16128
16262
  }
16129
16263
  _this.client.connection.once('connected', () => {
@@ -16132,23 +16266,38 @@ class ClientAblyService {
16132
16266
  resolve();
16133
16267
  });
16134
16268
  _this.client.connection.once('failed', stateChange => {
16135
- var _a;
16136
- reject(new Error("Ably connection failed: ".concat(((_a = stateChange.reason) === null || _a === void 0 ? void 0 : _a.message) || 'Unknown error')));
16269
+ var _a, _b;
16270
+ var error = new Error("Ably connection failed: ".concat(((_a = stateChange.reason) === null || _a === void 0 ? void 0 : _a.message) || 'Unknown error'));
16271
+ console.error('[AblyService] Connection failed', {
16272
+ reason: (_b = stateChange.reason) === null || _b === void 0 ? void 0 : _b.message,
16273
+ error: stateChange.reason
16274
+ });
16275
+ reject(error);
16137
16276
  });
16138
16277
  _this.client.connection.once('disconnected', stateChange => {
16139
- var _a;
16140
- reject(new Error("Ably connection disconnected: ".concat(((_a = stateChange.reason) === null || _a === void 0 ? void 0 : _a.message) || 'Unknown error')));
16278
+ var _a, _b;
16279
+ var error = new Error("Ably connection disconnected: ".concat(((_a = stateChange.reason) === null || _a === void 0 ? void 0 : _a.message) || 'Unknown error'));
16280
+ console.error('[AblyService] Connection disconnected', {
16281
+ reason: (_b = stateChange.reason) === null || _b === void 0 ? void 0 : _b.message
16282
+ });
16283
+ reject(error);
16141
16284
  });
16142
16285
  // Set a timeout for connection
16143
16286
  setTimeout(() => {
16144
16287
  if (!_this.isConnected) {
16145
- reject(new Error('Ably connection timeout'));
16288
+ var _error = new Error('Ably connection timeout');
16289
+ console.error('[AblyService] Connection timeout after 10 seconds');
16290
+ reject(_error);
16146
16291
  }
16147
16292
  }, 10000);
16148
16293
  });
16149
16294
  // Subscribe to the session room
16150
16295
  yield _this.joinChannel(sessionId, onMessageReceived, tenantId);
16151
16296
  } catch (error) {
16297
+ console.error('[AblyService] Error in startConnection', {
16298
+ error,
16299
+ sessionId
16300
+ });
16152
16301
  _this.isConnected = false;
16153
16302
  _this.sessionId = null;
16154
16303
  throw error;
@@ -16159,23 +16308,53 @@ class ClientAblyService {
16159
16308
  var _this2 = this;
16160
16309
  return _asyncToGenerator(function* () {
16161
16310
  if (!_this2.client) {
16162
- throw new Error('Chat client not initialized');
16311
+ var error = new Error('Chat client not initialized');
16312
+ console.error('[AblyService] joinChannel error:', error);
16313
+ throw error;
16163
16314
  }
16164
16315
  var roomName = "session:".concat(tenantId, ":").concat(sessionId);
16165
16316
  // Set up raw channel subscription for server messages
16166
16317
  if (_this2.client) {
16167
16318
  _this2.channel = _this2.client.channels.get(roomName);
16319
+ _this2.channel.on('failed', stateChange => {
16320
+ var _a;
16321
+ console.error('[AblyService] Channel failed', {
16322
+ roomName,
16323
+ reason: (_a = stateChange.reason) === null || _a === void 0 ? void 0 : _a.message,
16324
+ error: stateChange.reason
16325
+ });
16326
+ });
16168
16327
  // Subscribe to assistant/system responses
16169
16328
  _this2.channel.subscribe('ReceiveMessage', message => {
16170
- var _a, _b, _c, _d, _e;
16329
+ var _a, _b, _c, _d, _e, _f, _g, _h;
16171
16330
  try {
16172
- 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);
16173
- var senderType = ((_c = message.data) === null || _c === void 0 ? void 0 : _c.senderType) || 3; // Assistant
16174
- var needsAgent = ((_d = message.data) === null || _d === void 0 ? void 0 : _d.needsAgent) || false;
16175
- var attachments = ((_e = message.data) === null || _e === void 0 ? void 0 : _e.attachments) || [];
16176
- onMessageReceived(messageContent, senderType, needsAgent, attachments);
16331
+ // Ensure messageContent is always a string (default to empty string if undefined)
16332
+ var messageContent = typeof message.data === 'string' ? message.data : (_d = (_b = (_a = message.data) === null || _a === void 0 ? void 0 : _a.content) !== null && _b !== void 0 ? _b : (_c = message.data) === null || _c === void 0 ? void 0 : _c.message) !== null && _d !== void 0 ? _d : '';
16333
+ var senderType = ((_e = message.data) === null || _e === void 0 ? void 0 : _e.senderType) || 3; // Assistant
16334
+ var needsAgent = ((_f = message.data) === null || _f === void 0 ? void 0 : _f.needsAgent) || ((_g = message.data) === null || _g === void 0 ? void 0 : _g.actionType) == 'needs_agent' || false;
16335
+ var attachments = ((_h = message.data) === null || _h === void 0 ? void 0 : _h.attachments) || [];
16336
+ // Extract downloadUrl from attachments (Ably now returns downloadUrl directly)
16337
+ // Attachments can be: strings (URLs), objects with downloadUrl, or objects with id
16338
+ var attachmentUrls = attachments.map(attachment => {
16339
+ if (typeof attachment === 'string') {
16340
+ // If it's already a string, it's a URL
16341
+ return attachment;
16342
+ } else if (attachment === null || attachment === void 0 ? void 0 : attachment.downloadUrl) {
16343
+ // If it's an object with downloadUrl, use that
16344
+ return attachment.downloadUrl;
16345
+ } else if (attachment === null || attachment === void 0 ? void 0 : attachment.url) {
16346
+ // Fallback to url property
16347
+ return attachment.url;
16348
+ }
16349
+ // If it's an object with id, we'll need to keep it for backward compatibility
16350
+ return null;
16351
+ }).filter(url => url !== null);
16352
+ onMessageReceived(messageContent, senderType, needsAgent, attachmentUrls);
16177
16353
  } catch (error) {
16178
- // Handle error silently
16354
+ console.error('[AblyService] Error processing message', {
16355
+ error,
16356
+ message
16357
+ });
16179
16358
  }
16180
16359
  });
16181
16360
  yield _this2.channel.attach();
@@ -16205,6 +16384,9 @@ class ClientAblyService {
16205
16384
  _this3.isConnected = false;
16206
16385
  _this3.sessionId = null;
16207
16386
  } catch (error) {
16387
+ console.error('[AblyService] Error in stopConnection', {
16388
+ error
16389
+ });
16208
16390
  // Reset state even if there's an error
16209
16391
  _this3.isConnected = false;
16210
16392
  _this3.sessionId = null;
@@ -16357,19 +16539,21 @@ function useTypewriter(text) {
16357
16539
  var onType = arguments.length > 2 ? arguments[2] : undefined;
16358
16540
  var [displayedText, setDisplayedText] = useState('');
16359
16541
  useEffect(() => {
16542
+ // Ensure text is always a string to prevent errors
16543
+ var safeText = text !== null && text !== void 0 ? text : '';
16360
16544
  var index = 0;
16361
16545
  setDisplayedText('');
16362
16546
  var interval = setInterval(() => {
16363
16547
  setDisplayedText(() => {
16364
- var next = text.slice(0, index + 1);
16548
+ var next = safeText.slice(0, index + 1);
16365
16549
  index++;
16366
16550
  if (onType) onType();
16367
- if (index >= text.length) clearInterval(interval);
16551
+ if (index >= safeText.length) clearInterval(interval);
16368
16552
  return next;
16369
16553
  });
16370
16554
  }, speed);
16371
16555
  return () => clearInterval(interval);
16372
- }, [text]);
16556
+ }, [text, onType]);
16373
16557
  return displayedText;
16374
16558
  }
16375
16559
 
@@ -34156,11 +34340,13 @@ var AgentResponse = _ref => {
34156
34340
  messageId,
34157
34341
  onType
34158
34342
  } = _ref;
34343
+ // Ensure messageContent is always a string to prevent errors
34344
+ var safeMessageContent = messageContent !== null && messageContent !== void 0 ? messageContent : '';
34159
34345
  var shouldAnimate = (senderType === 2 || senderType === 3) && !seenMessagesRef.has(messageId);
34160
- var animatedText = useTypewriter(messageContent, 20, onType);
34161
- var finalMessage = shouldAnimate ? animatedText : messageContent;
34346
+ var animatedText = useTypewriter(safeMessageContent, 20, onType);
34347
+ var finalMessage = shouldAnimate ? animatedText : safeMessageContent;
34162
34348
  // Mark message as "seen" after full animation
34163
- if (shouldAnimate && finalMessage === messageContent) {
34349
+ if (shouldAnimate && finalMessage === safeMessageContent) {
34164
34350
  seenMessagesRef.add(messageId);
34165
34351
  }
34166
34352
  return jsx("div", {
@@ -34310,6 +34496,32 @@ var ImagePreviewDialog = _ref => {
34310
34496
  y: 0
34311
34497
  });
34312
34498
  }, []);
34499
+ var handleDownload = useCallback(/*#__PURE__*/_asyncToGenerator(function* () {
34500
+ if (!currentImageUrl) return;
34501
+ try {
34502
+ // Fetch the image as a blob
34503
+ var response = yield fetch(currentImageUrl);
34504
+ var blob = yield response.blob();
34505
+ // Create a temporary URL for the blob
34506
+ var blobUrl = URL.createObjectURL(blob);
34507
+ // Extract filename from URL or use a default
34508
+ var urlParts = currentImageUrl.split('/');
34509
+ var filename = urlParts[urlParts.length - 1].split('?')[0] || 'image.png';
34510
+ // Create a temporary anchor element and trigger download
34511
+ var link = document.createElement('a');
34512
+ link.href = blobUrl;
34513
+ link.download = filename;
34514
+ document.body.appendChild(link);
34515
+ link.click();
34516
+ // Cleanup
34517
+ document.body.removeChild(link);
34518
+ URL.revokeObjectURL(blobUrl);
34519
+ } catch (error) {
34520
+ console.error('Failed to download image:', error);
34521
+ // Fallback: open in new tab if download fails
34522
+ window.open(currentImageUrl, '_blank');
34523
+ }
34524
+ }), [currentImageUrl]);
34313
34525
  var handleClose = useCallback(() => {
34314
34526
  setZoomLevel(1);
34315
34527
  setImagePosition({
@@ -34510,6 +34722,27 @@ var ImagePreviewDialog = _ref => {
34510
34722
  "aria-label": 'Reset zoom',
34511
34723
  type: 'button',
34512
34724
  children: "Reset"
34725
+ }), jsx("div", {
34726
+ className: 'babylai-h-9 babylai-w-px babylai-bg-white/20 babylai-mx-1'
34727
+ }), jsx(Button, {
34728
+ variant: 'ghost',
34729
+ size: 'icon',
34730
+ onClick: handleDownload,
34731
+ className: 'babylai-text-white hover:babylai-text-white/80 hover:babylai-bg-white/10 babylai-h-9 babylai-w-9',
34732
+ "aria-label": 'Download image',
34733
+ type: 'button',
34734
+ children: jsx("svg", {
34735
+ className: 'babylai-w-5 babylai-h-5',
34736
+ fill: 'none',
34737
+ stroke: 'currentColor',
34738
+ viewBox: '0 0 24 24',
34739
+ children: jsx("path", {
34740
+ strokeLinecap: 'round',
34741
+ strokeLinejoin: 'round',
34742
+ strokeWidth: 2,
34743
+ d: 'M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4'
34744
+ })
34745
+ })
34513
34746
  })]
34514
34747
  }), hasMultipleImages && jsx("div", {
34515
34748
  className: cn('babylai-absolute babylai-top-4 babylai-z-[60]', 'babylai-bg-black/50 babylai-backdrop-blur-sm babylai-rounded-lg babylai-px-4 babylai-py-2', dir === 'rtl' ? 'babylai-right-1/2 babylai-translate-x-1/2' : 'babylai-left-1/2 -babylai-translate-x-1/2'),
@@ -34543,6 +34776,7 @@ ImagePreviewDialog.displayName = 'ImagePreviewDialog';
34543
34776
  var ImageAttachment = _ref => {
34544
34777
  var {
34545
34778
  fileId,
34779
+ imageUrl: propImageUrl,
34546
34780
  className,
34547
34781
  enablePreview = true,
34548
34782
  onClick
@@ -34550,30 +34784,39 @@ var ImageAttachment = _ref => {
34550
34784
  var {
34551
34785
  i18n
34552
34786
  } = useLocalTranslation();
34553
- var [imageUrl, setImageUrl] = useState(null);
34554
- var [loading, setLoading] = useState(true);
34787
+ var [imageUrl, setImageUrl] = useState(propImageUrl || null);
34788
+ var [loading, setLoading] = useState(!propImageUrl && !!fileId);
34555
34789
  var [error, setError] = useState(false);
34556
34790
  var [isPreviewOpen, setIsPreviewOpen] = useState(false);
34557
34791
  useEffect(() => {
34558
- var fetchImageUrl = /*#__PURE__*/function () {
34559
- var _ref2 = _asyncToGenerator(function* () {
34560
- try {
34561
- setLoading(true);
34562
- setError(false);
34563
- var response = yield presignDownload(fileId, i18n.language);
34564
- setImageUrl(response.downloadUrl);
34565
- } catch (err) {
34566
- setError(true);
34567
- } finally {
34568
- setLoading(false);
34569
- }
34570
- });
34571
- return function fetchImageUrl() {
34572
- return _ref2.apply(this, arguments);
34573
- };
34574
- }();
34575
- fetchImageUrl();
34576
- }, [fileId, i18n.language]);
34792
+ // If we have a direct URL, use it immediately
34793
+ if (propImageUrl) {
34794
+ setImageUrl(propImageUrl);
34795
+ setLoading(false);
34796
+ return;
34797
+ }
34798
+ // If we only have a fileId, fetch the URL using presignDownload
34799
+ if (fileId) {
34800
+ var fetchImageUrl = /*#__PURE__*/function () {
34801
+ var _ref2 = _asyncToGenerator(function* () {
34802
+ try {
34803
+ setLoading(true);
34804
+ setError(false);
34805
+ var response = yield presignDownload(fileId, i18n.language);
34806
+ setImageUrl(response.downloadUrl);
34807
+ } catch (err) {
34808
+ setError(true);
34809
+ } finally {
34810
+ setLoading(false);
34811
+ }
34812
+ });
34813
+ return function fetchImageUrl() {
34814
+ return _ref2.apply(this, arguments);
34815
+ };
34816
+ }();
34817
+ fetchImageUrl();
34818
+ }
34819
+ }, [fileId, propImageUrl, i18n.language]);
34577
34820
  var handleImageClick = () => {
34578
34821
  if (onClick) {
34579
34822
  onClick();
@@ -38125,39 +38368,63 @@ var ChatWindowFooter = props => {
38125
38368
  var _a;
38126
38369
  (_a = fileInputRef.current) === null || _a === void 0 ? void 0 : _a.click();
38127
38370
  }, []);
38128
- var handleFileSelect = useCallback(/*#__PURE__*/function () {
38129
- var _ref = _asyncToGenerator(function* (e) {
38130
- var files = Array.from(e.target.files || []);
38131
- // Validate that all files are images
38132
- var imageFiles = files.filter(file => file.type.startsWith('image/'));
38133
- // Only image files are allowed
38134
- // Create preview URLs and add to selected files
38135
- var newFiles = imageFiles.map(file => ({
38136
- file,
38137
- previewUrl: URL.createObjectURL(file),
38138
- uploading: false,
38139
- uploadedId: null,
38140
- error: null
38141
- }));
38142
- setSelectedFiles(prev => [...prev, ...newFiles]);
38143
- // Clear the input
38144
- if (fileInputRef.current) {
38145
- fileInputRef.current.value = '';
38371
+ var handleFileSelect = useCallback(e => {
38372
+ var files = Array.from(e.target.files || []);
38373
+ // Validate that all files are images
38374
+ var imageFiles = files.filter(file => file.type.startsWith('image/'));
38375
+ // Create preview URLs and add to selected files (don't upload yet)
38376
+ var newFiles = imageFiles.map(file => ({
38377
+ file,
38378
+ previewUrl: URL.createObjectURL(file),
38379
+ uploading: false,
38380
+ uploadedId: null,
38381
+ error: null
38382
+ }));
38383
+ setSelectedFiles(prev => [...prev, ...newFiles]);
38384
+ // Clear the input
38385
+ if (fileInputRef.current) {
38386
+ fileInputRef.current.value = '';
38387
+ }
38388
+ // Don't upload files immediately - wait for send button click
38389
+ }, []);
38390
+ // Removed handleUploadFiles - files are now uploaded in handleSendMessageWithAttachments
38391
+ var handleRemoveFile = useCallback(previewUrl => {
38392
+ setSelectedFiles(prev => {
38393
+ var fileToRemove = prev.find(f => f.previewUrl === previewUrl);
38394
+ if (fileToRemove) {
38395
+ URL.revokeObjectURL(fileToRemove.previewUrl);
38146
38396
  }
38147
- // Start uploading immediately
38148
- yield handleUploadFiles(newFiles);
38397
+ return prev.filter(f => f.previewUrl !== previewUrl);
38149
38398
  });
38150
- return function (_x) {
38151
- return _ref.apply(this, arguments);
38152
- };
38153
- }(), []);
38154
- var handleUploadFiles = useCallback(/*#__PURE__*/function () {
38155
- var _ref2 = _asyncToGenerator(function* (filesToUpload) {
38156
- // Get session ID
38157
- var sessionId;
38399
+ }, []);
38400
+ var handleSendMessageWithAttachments = useCallback(/*#__PURE__*/_asyncToGenerator(function* () {
38401
+ // Prevent sending if already loading
38402
+ if (props.isLoading) {
38403
+ return;
38404
+ }
38405
+ // Get files that need to be uploaded (those without uploadedId)
38406
+ var filesToUpload = selectedFiles.filter(f => f.uploadedId === null && !f.error);
38407
+ var alreadyUploadedIds = selectedFiles.filter(f => f.uploadedId !== null).map(f => f.uploadedId);
38408
+ // Declare uploadedIds outside the if block so it's accessible later
38409
+ var uploadedIds = [];
38410
+ // If there are files to upload, upload them first
38411
+ if (filesToUpload.length > 0) {
38412
+ // Get session ID - only use existing, never create new one
38413
+ var sessionId = null;
38158
38414
  try {
38159
- sessionId = yield props.onEnsureSession();
38415
+ // Only use existing sessionId, never call onEnsureSession
38416
+ if (props.sessionId) {
38417
+ sessionId = props.sessionId;
38418
+ } else {
38419
+ // Mark all files as error
38420
+ setSelectedFiles(prev => prev.map(f => filesToUpload.some(ftl => ftl.previewUrl === f.previewUrl) ? _objectSpread2(_objectSpread2({}, f), {}, {
38421
+ error: 'No session available',
38422
+ uploading: false
38423
+ }) : f));
38424
+ return;
38425
+ }
38160
38426
  } catch (error) {
38427
+ console.error('[ChatWindowFooter] Failed to get sessionId for file upload:', error);
38161
38428
  // Mark all files as error
38162
38429
  setSelectedFiles(prev => prev.map(f => filesToUpload.some(ftl => ftl.previewUrl === f.previewUrl) ? _objectSpread2(_objectSpread2({}, f), {}, {
38163
38430
  error: 'Failed to initialize session',
@@ -38165,7 +38432,9 @@ var ChatWindowFooter = props => {
38165
38432
  }) : f));
38166
38433
  return;
38167
38434
  }
38168
- // Upload each file
38435
+ // Upload each file and collect uploaded IDs
38436
+ uploadedIds = [];
38437
+ var hasUploadErrors = false;
38169
38438
  var _loop = function* _loop(fileDto) {
38170
38439
  try {
38171
38440
  // Mark as uploading
@@ -38176,7 +38445,6 @@ var ChatWindowFooter = props => {
38176
38445
  // Get presigned URL
38177
38446
  var presignResponse = yield presignUpload(sessionId, fileDto.file, i18n.language);
38178
38447
  // Upload file to presigned URL using axios
38179
- // Important: Content-Type must match the file type (e.g., 'image/png'), not 'multipart/form-data'
38180
38448
  var uploadResponse = yield axios$1.put(presignResponse.uploadUrl, fileDto.file, {
38181
38449
  headers: {
38182
38450
  'Content-Type': fileDto.file.type
@@ -38188,6 +38456,8 @@ var ChatWindowFooter = props => {
38188
38456
  if (uploadResponse.status !== 200 && uploadResponse.status !== 204) {
38189
38457
  throw new Error("Upload failed with status ".concat(uploadResponse.status));
38190
38458
  }
38459
+ // Collect uploaded ID
38460
+ uploadedIds.push(presignResponse.id);
38191
38461
  // Update with uploaded ID
38192
38462
  setSelectedFiles(prev => prev.map(f => f.previewUrl === fileDto.previewUrl ? _objectSpread2(_objectSpread2({}, f), {}, {
38193
38463
  uploading: false,
@@ -38195,6 +38465,8 @@ var ChatWindowFooter = props => {
38195
38465
  error: null
38196
38466
  }) : f));
38197
38467
  } catch (error) {
38468
+ console.error('[ChatWindowFooter] File upload failed:', error);
38469
+ hasUploadErrors = true;
38198
38470
  setSelectedFiles(prev => prev.map(f => f.previewUrl === fileDto.previewUrl ? _objectSpread2(_objectSpread2({}, f), {}, {
38199
38471
  uploading: false,
38200
38472
  error: 'Upload failed',
@@ -38205,43 +38477,28 @@ var ChatWindowFooter = props => {
38205
38477
  for (var fileDto of filesToUpload) {
38206
38478
  yield* _loop(fileDto);
38207
38479
  }
38208
- });
38209
- return function (_x2) {
38210
- return _ref2.apply(this, arguments);
38211
- };
38212
- }(), [props.onEnsureSession, i18n.language]);
38213
- var handleRemoveFile = useCallback(previewUrl => {
38214
- setSelectedFiles(prev => {
38215
- var fileToRemove = prev.find(f => f.previewUrl === previewUrl);
38216
- if (fileToRemove) {
38217
- URL.revokeObjectURL(fileToRemove.previewUrl);
38480
+ // If any uploads failed, don't send the message
38481
+ if (hasUploadErrors) {
38482
+ console.error('[ChatWindowFooter] Some files failed to upload, not sending message');
38483
+ return;
38218
38484
  }
38219
- return prev.filter(f => f.previewUrl !== previewUrl);
38220
- });
38221
- }, []);
38222
- var handleSendMessageWithAttachments = useCallback(() => {
38223
- // Only allow sending if all files have finished uploading (either successfully or with error)
38224
- var hasUploadingFiles = selectedFiles.some(f => f.uploading);
38225
- if (hasUploadingFiles) {
38226
- return; // Prevent sending if any files are still uploading
38227
- }
38228
- // Get all successfully uploaded file IDs
38229
- var attachmentIds = selectedFiles.filter(f => f.uploadedId !== null).map(f => f.uploadedId);
38485
+ }
38486
+ // Get all successfully uploaded file IDs (already uploaded + newly uploaded)
38487
+ // Use uploadedIds from the upload loop instead of reading from state
38488
+ var allAttachmentIds = [...alreadyUploadedIds, ...uploadedIds];
38230
38489
  // Call the original send message with attachment IDs
38231
- props.handleSendMessage(attachmentIds);
38490
+ props.handleSendMessage(allAttachmentIds);
38232
38491
  // Clear selected files and revoke URLs
38233
38492
  selectedFiles.forEach(f => URL.revokeObjectURL(f.previewUrl));
38234
38493
  setSelectedFiles([]);
38235
- }, [selectedFiles, props]);
38494
+ }), [selectedFiles, props, i18n.language]);
38236
38495
  // Check if any files are currently uploading
38237
38496
  var hasUploadingFiles = selectedFiles.some(f => f.uploading);
38238
- // Check if there are files that haven't finished (no uploadedId, no error, not uploading)
38239
- // This shouldn't happen in normal flow, but we check for safety
38240
- var hasPendingFiles = selectedFiles.some(f => !f.uploading && f.uploadedId === null && f.error === null);
38241
- // Check if all files have errors (no successful uploads)
38242
- var hasSuccessfulUploads = selectedFiles.some(f => f.uploadedId !== null);
38243
- var allFilesHaveErrors = selectedFiles.length > 0 && !hasSuccessfulUploads && !hasUploadingFiles && !hasPendingFiles;
38244
- var isSendDisabled = props.isLoading || props.inputMessage.trim() === '' || hasUploadingFiles || hasPendingFiles || allFilesHaveErrors;
38497
+ // Check if there are files with errors
38498
+ var hasFileErrors = selectedFiles.some(f => f.error !== null);
38499
+ // Allow sending if there's text OR files selected (files will be uploaded on send)
38500
+ var hasContentToSend = props.inputMessage.trim() !== '' || selectedFiles.length > 0;
38501
+ var isSendDisabled = props.isLoading || !hasContentToSend || hasUploadingFiles || hasFileErrors;
38245
38502
  var handleKeyDown = useCallback(e => {
38246
38503
  if (e.key === 'Enter' && !e.shiftKey) {
38247
38504
  e.preventDefault();
@@ -38406,10 +38663,12 @@ var MessageComponent = /*#__PURE__*/React__default.memo(_ref => {
38406
38663
  var isFirstHumanAgentMessage = index === firstHumanAgentIndex && message.senderType === 2;
38407
38664
  var textDirection = message.senderType === 1 ? 'babylai-justify-end' : 'babylai-justify-start';
38408
38665
  var handleImageClick = useCallback(clickedIndex => {
38409
- if (message.attachmentIds && message.attachmentIds.length > 0) {
38410
- onImageClick(message.attachmentIds, clickedIndex);
38666
+ // Use attachmentUrls if available (from Ably), otherwise use attachmentIds (user-sent)
38667
+ var attachments = message.attachmentUrls || message.attachmentIds || [];
38668
+ if (attachments.length > 0) {
38669
+ onImageClick(attachments, clickedIndex);
38411
38670
  }
38412
- }, [message.attachmentIds, onImageClick]);
38671
+ }, [message.attachmentIds, message.attachmentUrls, onImageClick]);
38413
38672
  return jsxs("div", {
38414
38673
  children: [isFirstHumanAgentMessage && jsx("div", {
38415
38674
  className: 'babylai-flex babylai-justify-center babylai-items-center babylai-my-4',
@@ -38432,14 +38691,21 @@ var MessageComponent = /*#__PURE__*/React__default.memo(_ref => {
38432
38691
  className: 'babylai-flex-shrink-0 babylai-me-3 babylai-w-8'
38433
38692
  }), jsxs("div", {
38434
38693
  className: 'babylai-flex babylai-flex-col babylai-gap-2',
38435
- children: [message.attachmentIds && message.attachmentIds.length > 0 && jsx("div", {
38694
+ children: [message.attachmentUrls && message.attachmentUrls.length > 0 && jsx("div", {
38695
+ className: 'babylai-flex babylai-flex-row babylai-flex-wrap babylai-gap-2 babylai-max-w-full',
38696
+ children: message.attachmentUrls.map((attachmentUrl, imgIndex) => jsx(ImageAttachment, {
38697
+ imageUrl: attachmentUrl,
38698
+ enablePreview: false,
38699
+ onClick: () => handleImageClick(imgIndex)
38700
+ }, attachmentUrl))
38701
+ }), message.attachmentIds && message.attachmentIds.length > 0 && jsx("div", {
38436
38702
  className: 'babylai-flex babylai-flex-row babylai-flex-wrap babylai-gap-2 babylai-max-w-full',
38437
38703
  children: message.attachmentIds.map((attachmentId, imgIndex) => jsx(ImageAttachment, {
38438
38704
  fileId: attachmentId,
38439
38705
  enablePreview: false,
38440
38706
  onClick: () => handleImageClick(imgIndex)
38441
38707
  }, attachmentId))
38442
- }), jsx(AgentResponse$1, {
38708
+ }), message.messageContent && message.messageContent.trim() !== '' && jsx(AgentResponse$1, {
38443
38709
  messageContent: message.messageContent,
38444
38710
  senderType: message.senderType,
38445
38711
  messageId: message.id,
@@ -38484,7 +38750,8 @@ var ChatWindow = /*#__PURE__*/React__default.memo(_ref3 => {
38484
38750
  onEnsureSession,
38485
38751
  messages,
38486
38752
  assistantStatus = 'loading',
38487
- needsAgent
38753
+ needsAgent,
38754
+ sessionId
38488
38755
  } = _ref3;
38489
38756
  var {
38490
38757
  i18n
@@ -38527,7 +38794,8 @@ var ChatWindow = /*#__PURE__*/React__default.memo(_ref3 => {
38527
38794
  };
38528
38795
  }, []);
38529
38796
  var handleSendMessage = useCallback(attachmentIds => {
38530
- if (inputMessage.trim()) {
38797
+ // Allow sending if there's text OR attachments
38798
+ if (inputMessage.trim() || attachmentIds.length > 0) {
38531
38799
  onSendMessage(inputMessage, attachmentIds);
38532
38800
  setInputMessage('');
38533
38801
  }
@@ -38538,13 +38806,32 @@ var ChatWindow = /*#__PURE__*/React__default.memo(_ref3 => {
38538
38806
  }, [messages]);
38539
38807
  // Handle image gallery opening
38540
38808
  var handleImageClick = useCallback(/*#__PURE__*/function () {
38541
- var _ref4 = _asyncToGenerator(function* (attachmentIds, clickedIndex) {
38542
- if (!attachmentIds || attachmentIds.length === 0) {
38809
+ var _ref4 = _asyncToGenerator(function* (attachmentIdsOrUrls, clickedIndex) {
38810
+ var _a, _b;
38811
+ if (!attachmentIdsOrUrls || attachmentIdsOrUrls.length === 0) {
38543
38812
  return;
38544
38813
  }
38545
38814
  try {
38546
- // Fetch all image URLs with comprehensive error handling
38547
- var imageUrlPromises = attachmentIds.map(fileId => {
38815
+ // Check if the first item is a URL (starts with http:// or https://)
38816
+ // If so, they're all URLs from Ably and can be used directly
38817
+ var isUrl = ((_a = attachmentIdsOrUrls[0]) === null || _a === void 0 ? void 0 : _a.startsWith('http://')) || ((_b = attachmentIdsOrUrls[0]) === null || _b === void 0 ? void 0 : _b.startsWith('https://'));
38818
+ var imageUrls;
38819
+ if (isUrl) {
38820
+ // These are already URLs from Ably, use them directly (no async needed)
38821
+ imageUrls = attachmentIdsOrUrls.filter(url => url !== null && url.length > 0);
38822
+ // Open gallery immediately with URLs
38823
+ if (imageUrls.length > 0) {
38824
+ var _adjustedIndex = Math.max(0, Math.min(clickedIndex, imageUrls.length - 1));
38825
+ setGalleryState({
38826
+ isOpen: true,
38827
+ imageUrls,
38828
+ initialIndex: _adjustedIndex
38829
+ });
38830
+ }
38831
+ return; // Exit early since we don't need to fetch anything
38832
+ }
38833
+ // These are file IDs, need to fetch URLs using presignDownload
38834
+ var imageUrlPromises = attachmentIdsOrUrls.map(fileId => {
38548
38835
  if (!fileId || typeof fileId !== 'string') {
38549
38836
  return Promise.resolve(null);
38550
38837
  }
@@ -38558,7 +38845,7 @@ var ChatWindow = /*#__PURE__*/React__default.memo(_ref3 => {
38558
38845
  return null;
38559
38846
  });
38560
38847
  });
38561
- var imageUrls = (yield Promise.all(imageUrlPromises)).filter(url => url !== null && url.length > 0);
38848
+ imageUrls = (yield Promise.all(imageUrlPromises)).filter(url => url !== null && url.length > 0);
38562
38849
  if (imageUrls.length === 0) {
38563
38850
  return;
38564
38851
  }
@@ -38620,7 +38907,8 @@ var ChatWindow = /*#__PURE__*/React__default.memo(_ref3 => {
38620
38907
  handleSendMessage: handleSendMessage,
38621
38908
  setInputMessage: setInputMessage,
38622
38909
  isLoading: isLoading,
38623
- onEnsureSession: onEnsureSession
38910
+ onEnsureSession: onEnsureSession,
38911
+ sessionId: sessionId
38624
38912
  }), galleryState.isOpen && galleryState.imageUrls.length > 0 && jsx(ImagePreviewDialog, {
38625
38913
  imageUrls: galleryState.imageUrls,
38626
38914
  initialIndex: galleryState.initialIndex,
@@ -39239,7 +39527,8 @@ var HelpPopup = _ref => {
39239
39527
  }
39240
39528
  }, [onStartChat, setSelectedOption, sessionId, setStartNewChatConfirmation, setTempSelectedOption]);
39241
39529
  var handleSendMessage = useCallback((message, attachmentIds) => {
39242
- if (message.trim()) {
39530
+ // Allow sending if there's text OR attachments
39531
+ if (message.trim() || attachmentIds.length > 0) {
39243
39532
  onSendMessage(message.trim(), attachmentIds);
39244
39533
  }
39245
39534
  }, [onSendMessage]);
@@ -39295,7 +39584,8 @@ var HelpPopup = _ref => {
39295
39584
  messages: memoizedMessages,
39296
39585
  assistantStatus: assistantStatus,
39297
39586
  needsAgent: needsAgent,
39298
- isAblyConnected: isAblyConnected
39587
+ isAblyConnected: isAblyConnected,
39588
+ sessionId: sessionId
39299
39589
  })]
39300
39590
  });
39301
39591
  }
@@ -39434,7 +39724,7 @@ var HelpCenterContent = _ref => {
39434
39724
  sentAt: new Date(),
39435
39725
  isSeen: true
39436
39726
  }, attachments.length > 0 && {
39437
- attachmentIds: attachments
39727
+ attachmentUrls: attachments
39438
39728
  });
39439
39729
  return [...prevMessages, newMessage];
39440
39730
  });
@@ -39563,10 +39853,11 @@ var HelpCenterContent = _ref => {
39563
39853
  var handleEnsureSession = /*#__PURE__*/function () {
39564
39854
  var _ref7 = _asyncToGenerator(function* () {
39565
39855
  // If we already have a session ID and connection, return it
39566
- if (sessionId && isAblyConnected) {
39856
+ // NEVER create a new session if one already exists
39857
+ if (sessionId) {
39567
39858
  return sessionId;
39568
39859
  }
39569
- // If we have a selected option but no session, create one
39860
+ // Only create a new session if we don't have one and have a selected option
39570
39861
  if (selectedOption) {
39571
39862
  var newSessionId = yield startNewChatSession(selectedOption);
39572
39863
  return newSessionId;
@@ -39580,28 +39871,32 @@ var HelpCenterContent = _ref => {
39580
39871
  var handleSendMessage = /*#__PURE__*/function () {
39581
39872
  var _ref8 = _asyncToGenerator(function* (message) {
39582
39873
  var attachmentIds = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
39583
- if (message.trim() !== '') {
39874
+ // Allow sending if there's text OR attachments
39875
+ if (message.trim() !== '' || attachmentIds.length > 0) {
39584
39876
  try {
39585
39877
  setAssistantStatus('typing');
39586
39878
  var userMessage = {
39587
39879
  id: Date.now(),
39588
39880
  senderType: 1,
39589
- messageContent: message,
39881
+ messageContent: message || '',
39882
+ // Use empty string if message is empty but attachments exist
39590
39883
  sentAt: new Date(),
39591
39884
  isSeen: false,
39592
39885
  attachmentIds: attachmentIds.length > 0 ? attachmentIds : undefined
39593
39886
  };
39594
39887
  setMessages(prevMessages => [...prevMessages, userMessage]);
39595
- // Handle session creation if needed
39888
+ // Handle session creation if needed - only create if no session exists
39596
39889
  var currentSessionId = sessionId;
39597
- if (!isAblyConnected && selectedOption) {
39890
+ // Only create a new session if we don't have one and we have a selected option
39891
+ // This ensures session is only created once with the first message
39892
+ if (!currentSessionId && !isAblyConnected && selectedOption) {
39598
39893
  currentSessionId = yield startNewChatSession(selectedOption);
39599
39894
  }
39600
39895
  if (!currentSessionId) {
39601
39896
  throw new Error('No active session available');
39602
39897
  }
39603
39898
  var messageDto = _objectSpread2({
39604
- messageContent: message
39899
+ messageContent: message || ''
39605
39900
  }, attachmentIds.length > 0 && {
39606
39901
  attachmentIds
39607
39902
  });