@ada-support/embed2 1.0.47 → 1.0.52

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.
@@ -2,7 +2,7 @@ import type { EventSubscriptionCallback } from "client/helpers/event-subscriptio
2
2
  import { MessageService } from "client/lib/message-service";
3
3
  import { StoreProxy } from "client/lib/store-proxy";
4
4
  import "client/lib/error-tracker";
5
- import type Client from "common/models/client";
5
+ import type { Client } from "common/models/client";
6
6
  import type { EvaluateCampaignParams, ResetParams, WindowInfo } from "common/types";
7
7
  import type { MetaFieldPayload } from "common/types/store";
8
8
  import type { StartOptions } from "common/types/store-state";
@@ -1,7 +1,7 @@
1
- import { ClientObject, ClientResponse } from "common/types/http";
2
- export declare function clientMatchesExpectedFormat(client: ClientObject): boolean;
1
+ import type { ClientObject, ClientResponse } from "common/types/http";
2
+ export declare function isClientObject(client: Record<string, unknown>): client is ClientObject;
3
3
  /**
4
4
  * Tries fetching the client from cache. If this fails, tries fetching it from API.
5
5
  * If this also fails, returns null.
6
6
  */
7
- export declare function fetchClient(handle: string, cluster: string, domain: string, language: string): Promise<ClientResponse>;
7
+ export declare function fetchClient(handle: string, cluster: string, domain: string, language: string): Promise<ClientResponse | null>;
@@ -1,5 +1,5 @@
1
- import { CurrentIntro, Intro } from "common/types/http";
1
+ import type { CurrentIntro, Intro } from "common/types/http";
2
2
  export declare function getProcessedPath(path: string): string;
3
3
  export declare function getPathSearchRegex(path: string): RegExp;
4
4
  export declare function doesUrlMatchPath(url: string, path: string): boolean;
5
- export declare function getIntroForCurrentUrl(intros: Intro[], language: string): CurrentIntro | null;
5
+ export declare function getIntroForCurrentUrl(intros: Intro[], language: string): CurrentIntro | undefined;
@@ -11,7 +11,7 @@ export interface CSInterface {
11
11
  domain?: string;
12
12
  route?: string;
13
13
  qp?: {
14
- [key: string]: string | boolean | number;
14
+ [key: string]: string | boolean | number | null | undefined;
15
15
  };
16
16
  isEmbedFramed?: boolean;
17
17
  }
@@ -15,7 +15,6 @@ export declare class FrameChannel extends Channel {
15
15
  name: string;
16
16
  targetWindow: Window;
17
17
  targetOrigin: string;
18
- eventTarget: Window;
19
18
  isConnected: boolean;
20
19
  constructor(name: string, targetWindow: Window, targetOrigin?: string);
21
20
  private static isMessageEvent;
@@ -1,14 +1,14 @@
1
- import { BusinessEvent } from "businessEvents/types";
2
- import { ChatButton, ClientResponse, CurrentIntro, Features } from "common/types/http";
3
- import { LanguageMap } from "common/types/languages";
4
- import { MarketingCampaign } from "src/campaigns/types";
5
- export default class Client {
1
+ import type { BusinessEvent } from "businessEvents/types";
2
+ import type { ChatButton, ClientResponse, CurrentIntro, Features } from "common/types/http";
3
+ import type { LanguageKey, LanguageMap } from "common/types/languages";
4
+ import type { MarketingCampaign } from "src/campaigns/types";
5
+ export declare class Client {
6
6
  tint: string;
7
7
  chat: boolean;
8
8
  intro?: CurrentIntro;
9
9
  handle: string;
10
10
  rollout: number;
11
- language: keyof LanguageMap;
11
+ language: LanguageKey;
12
12
  privacy: boolean;
13
13
  features: Features;
14
14
  persistence: string;
@@ -1,4 +1,5 @@
1
- import { BusinessEvent } from "businessEvents/types";
1
+ import type { BusinessEvent } from "businessEvents/types";
2
+ import type { LanguageKey } from "common/types/languages";
2
3
  export interface ChatButton {
3
4
  size: number;
4
5
  background_color: string;
@@ -43,20 +44,21 @@ export interface ClientObject {
43
44
  rollout: number;
44
45
  chat: boolean;
45
46
  persistence: string;
46
- language: string;
47
+ language: LanguageKey;
47
48
  privacy: boolean;
48
49
  tint: string;
49
50
  chat_button: ChatButton | null;
50
51
  intro?: CurrentIntro;
51
52
  features: Features;
52
53
  marketing_campaigns_order?: string[];
54
+ [key: string]: unknown;
53
55
  }
54
56
  export interface CachedClientObject {
55
57
  handle: string;
56
58
  rollout: number;
57
59
  chat: boolean;
58
60
  persistence: string;
59
- language: string;
61
+ language: LanguageKey;
60
62
  privacy: boolean;
61
63
  tint: string;
62
64
  chat_button: ChatButton | null;
@@ -64,6 +66,7 @@ export interface CachedClientObject {
64
66
  features: Features;
65
67
  business_events?: BusinessEvent[];
66
68
  marketing_campaigns_order?: string[];
69
+ [key: string]: unknown;
67
70
  }
68
71
  export interface ClientResponse {
69
72
  client: ClientObject;
@@ -1,5 +1,4 @@
1
- declare type LanguageKeys = "en" | "da" | "de" | "es" | "fi" | "fr" | "hi" | "ht" | "id" | "it" | "ja" | "km" | "ko" | "ms" | "my" | "no" | "nl" | "pa" | "pt" | "ru" | "sv" | "ta" | "th" | "tl" | "tr" | "vi" | "zh" | "zh-tw" | "bg" | "ro" | "el" | "hu" | "pl" | "cs" | "et" | "hr" | "lt" | "lv" | "sl" | "sk" | "is" | "ar" | "he";
1
+ export declare type LanguageKey = "en" | "da" | "de" | "es" | "fi" | "fr" | "hi" | "ht" | "id" | "it" | "ja" | "km" | "ko" | "ms" | "my" | "no" | "nl" | "pa" | "pt" | "ru" | "sv" | "ta" | "th" | "tl" | "tr" | "vi" | "zh" | "zh-tw" | "bg" | "ro" | "el" | "hu" | "pl" | "cs" | "et" | "hr" | "lt" | "lv" | "sl" | "sk" | "is" | "ar" | "he";
2
2
  export declare type LanguageMap = {
3
- [K in LanguageKeys]?: string;
3
+ [K in LanguageKey]?: string;
4
4
  };
5
- export {};
@@ -1,5 +1,5 @@
1
1
  import type { ConnectionState } from "common/constants/events";
2
- import type Client from "common/models/client";
2
+ import type { Client } from "common/models/client";
3
3
  import type { ChatterEventPayload } from "common/types/events";
4
4
  export interface StartOptions {
5
5
  handle?: string;
@@ -22,7 +22,7 @@ export interface StartOptions {
22
22
  onAdaEmbedLoaded?(): void;
23
23
  toggleCallback?(isDrawerOpen: boolean): void;
24
24
  eventCallbacks?: {
25
- [eventName: string]: (customJavascriptEvent: object) => void;
25
+ [eventName: string]: ((customJavascriptEvent: object) => void) | undefined;
26
26
  };
27
27
  zdChatterAuthCallback?(callback: (token: string) => void): void;
28
28
  embedStyles?: string;
@@ -1,5 +1,5 @@
1
- import Client from "common/models/client";
2
- import { StorageKey, StorageValueByKey } from "frames/lib/safe-storage";
1
+ import type { Client } from "common/models/client";
2
+ import type { StorageKey, StorageValueByKey } from "frames/lib/safe-storage";
3
3
  export declare const PERSISTENCE_NORMAL = "normal";
4
4
  export declare const PERSISTENCE_SESSION = "session";
5
5
  /**
@@ -190,6 +190,13 @@ module.exports = __webpack_require__(3685);
190
190
 
191
191
  /***/ }),
192
192
 
193
+ /***/ 3263:
194
+ /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
195
+
196
+ module.exports = __webpack_require__(4710);
197
+
198
+ /***/ }),
199
+
193
200
  /***/ 4889:
194
201
  /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
195
202
 
@@ -197,6 +204,13 @@ module.exports = __webpack_require__(4303);
197
204
 
198
205
  /***/ }),
199
206
 
207
+ /***/ 9356:
208
+ /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
209
+
210
+ module.exports = __webpack_require__(3799);
211
+
212
+ /***/ }),
213
+
200
214
  /***/ 9542:
201
215
  /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
202
216
 
@@ -722,7 +736,7 @@ var browserPerformanceTimeOrigin = (function () {
722
736
 
723
737
  /***/ }),
724
738
 
725
- /***/ 7054:
739
+ /***/ 9136:
726
740
  /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
727
741
 
728
742
  "use strict";
@@ -8500,7 +8514,7 @@ var client = new error_tracker_BrowserClient({
8500
8514
  return event;
8501
8515
  },
8502
8516
  environment: "production",
8503
- release: "1.0.47-df9664f",
8517
+ release: "1.0.52-921d431",
8504
8518
  sampleRate: 0.25,
8505
8519
  autoSessionTracking: false,
8506
8520
  // Integrations don't seem to work with Sentry: https://github.com/getsentry/sentry-javascript/issues/2541
@@ -8730,7 +8744,7 @@ var Channel = /*#__PURE__*/function () {
8730
8744
  }).catch(function (e) {
8731
8745
  // We should NOT silently catch errors for "GET_STATE" request event - it is critical for application to work.
8732
8746
  if (requestEvent === "GET_STATE") {
8733
- throw new errors/* AdaEmbedError */.S("Failed to respond to \"GET_STATE\" request. Reason: ".concat(e.message, "."));
8747
+ throw new errors/* AdaEmbedError */.S("Failed to respond to \"GET_STATE\" request. Reason: \"".concat(e.message, "\"."));
8734
8748
  } // handling promise
8735
8749
 
8736
8750
 
@@ -8825,8 +8839,6 @@ var FrameChannel = /*#__PURE__*/function (_Channel) {
8825
8839
 
8826
8840
  (0,defineProperty/* default */.Z)((0,assertThisInitialized/* default */.Z)(_this), "targetOrigin", void 0);
8827
8841
 
8828
- (0,defineProperty/* default */.Z)((0,assertThisInitialized/* default */.Z)(_this), "eventTarget", void 0);
8829
-
8830
8842
  (0,defineProperty/* default */.Z)((0,assertThisInitialized/* default */.Z)(_this), "isConnected", false);
8831
8843
 
8832
8844
  _this.name = name;
@@ -8898,20 +8910,20 @@ var FrameChannel = /*#__PURE__*/function (_Channel) {
8898
8910
  status: status
8899
8911
  });
8900
8912
  } catch (e) {
8901
- var _context3, _context4;
8913
+ var _context4, _context5;
8902
8914
 
8903
8915
  var reason = e instanceof Error ? e.message : "unknown";
8904
8916
  var payloadRootKeys = payload && (0,esm_typeof/* default */.Z)(payload) === "object" ? keys_default()(payload) : [];
8905
8917
 
8906
8918
  if (eventName === "DISPATCH" && payload && (0,esm_typeof/* default */.Z)(payload) === "object") {
8907
- var _context2;
8919
+ var _context2, _context3;
8908
8920
 
8909
8921
  var p = payload;
8910
8922
  var dispatchPayloadKeys = p.payload && (0,esm_typeof/* default */.Z)(p.payload) === "object" ? keys_default()(p.payload) : [];
8911
- throw new errors/* AdaEmbedError */.S(concat_default()(_context2 = "Failed to stringify payload for \"DISPATCH\" event. Reason: \"".concat(reason, "\". Payload keys: ")).call(_context2, dispatchPayloadKeys.join(", "), "."));
8923
+ throw new errors/* AdaEmbedError */.S(concat_default()(_context2 = concat_default()(_context3 = "Failed to stringify payload for \"DISPATCH\" event. Reason: \"".concat(reason, "\". Action: \"")).call(_context3, p.actionKey, "\". Payload keys: ")).call(_context2, dispatchPayloadKeys.join(", "), "."));
8912
8924
  }
8913
8925
 
8914
- throw new errors/* AdaEmbedError */.S(concat_default()(_context3 = concat_default()(_context4 = "Failed to stringify object. Reason: \"".concat(reason, "\". Event: \"")).call(_context4, eventName, "\". Payload keys: ")).call(_context3, payloadRootKeys.join(", "), "."));
8926
+ throw new errors/* AdaEmbedError */.S(concat_default()(_context4 = concat_default()(_context5 = "Failed to stringify object. Reason: \"".concat(reason, "\". Event: \"")).call(_context5, eventName, "\". Payload keys: ")).call(_context4, payloadRootKeys.join(", "), "."));
8915
8927
  }
8916
8928
  }
8917
8929
  }], [{
@@ -9201,7 +9213,7 @@ function getEmbedURL(_ref) {
9201
9213
  polyfillVersionString = "legacy";
9202
9214
  }
9203
9215
 
9204
- return concat_default()(_context5 = concat_default()(_context6 = concat_default()(_context7 = "".concat(host, "/embed/")).call(_context7, polyfillVersionString, "/")).call(_context6, frameName, "/")).call(_context5, "df9664f", "/index.html");
9216
+ return concat_default()(_context5 = concat_default()(_context6 = concat_default()(_context7 = "".concat(host, "/embed/")).call(_context7, polyfillVersionString, "/")).call(_context6, frameName, "/")).call(_context5, "921d431", "/index.html");
9205
9217
  }
9206
9218
  /**
9207
9219
  * Generate the Chat / API URL
@@ -9218,12 +9230,18 @@ function getURL(_ref2) {
9218
9230
  _ref2$qp = _ref2.qp,
9219
9231
  qp = _ref2$qp === void 0 ? {} : _ref2$qp;
9220
9232
 
9221
- var queryString = map_default()(_context8 = filter_default()(_context9 = keys_default()(qp)).call(_context9, function (key) {
9222
- return qp[key] !== undefined && qp[key] !== null;
9223
- })).call(_context8, function (key) {
9233
+ var queryString = filter_default()(_context8 = map_default()(_context9 = keys_default()(qp)).call(_context9, function (key) {
9224
9234
  var _context10;
9225
9235
 
9226
- return concat_default()(_context10 = "".concat(key, "=")).call(_context10, window.encodeURIComponent(qp[key]));
9236
+ var value = qp[key];
9237
+
9238
+ if (value === undefined || value === null) {
9239
+ return null;
9240
+ }
9241
+
9242
+ return concat_default()(_context10 = "".concat(key, "=")).call(_context10, window.encodeURIComponent(value));
9243
+ })).call(_context8, function (v) {
9244
+ return v !== null;
9227
9245
  }).join("&");
9228
9246
 
9229
9247
  var questionSym = queryString.length ? "?" : "";
@@ -10044,8 +10062,6 @@ var trim_default = /*#__PURE__*/__webpack_require__.n(trim);
10044
10062
 
10045
10063
 
10046
10064
 
10047
- var INTRO_STYLE_EMOJI = "Emoji";
10048
- var INTRO_STYLE_TEXT = "Text";
10049
10065
  function getProcessedPath(path) {
10050
10066
  var regex = new RegExp("^http(s)?://(www.)?");
10051
10067
  return trim_default()(path).call(path).replace(regex, "");
@@ -10095,20 +10111,10 @@ function getIntroForCurrentUrl(intros, language) {
10095
10111
  var matchingIntro = findMatchingIntro(intros);
10096
10112
 
10097
10113
  if (!matchingIntro) {
10098
- return null;
10114
+ return undefined;
10099
10115
  }
10100
10116
 
10101
- if (matchingIntro.style === INTRO_STYLE_TEXT) {
10102
- return {
10103
- response_id: matchingIntro.response_id,
10104
- body: matchingIntro.body.message_text[language],
10105
- style: matchingIntro.style,
10106
- delay: matchingIntro.delay,
10107
- duration: matchingIntro.duration
10108
- };
10109
- }
10110
-
10111
- if (matchingIntro.style === INTRO_STYLE_EMOJI) {
10117
+ if (matchingIntro.style === "Emoji") {
10112
10118
  return {
10113
10119
  response_id: matchingIntro.response_id,
10114
10120
  body: matchingIntro.body.emoji_link,
@@ -10116,9 +10122,16 @@ function getIntroForCurrentUrl(intros, language) {
10116
10122
  delay: matchingIntro.delay,
10117
10123
  duration: matchingIntro.duration
10118
10124
  };
10119
- }
10125
+ } // Default - "Text" style
10120
10126
 
10121
- return null;
10127
+
10128
+ return {
10129
+ response_id: matchingIntro.response_id,
10130
+ body: matchingIntro.body.message_text[language],
10131
+ style: matchingIntro.style,
10132
+ delay: matchingIntro.delay,
10133
+ duration: matchingIntro.duration
10134
+ };
10122
10135
  }
10123
10136
  ;// CONCATENATED MODULE: ./src/campaigns/TriggerConditionEvaluator.ts
10124
10137
 
@@ -10688,7 +10701,7 @@ function fetch_client_objectSpread(target) { for (var i = 1; i < arguments.lengt
10688
10701
 
10689
10702
 
10690
10703
 
10691
- function clientMatchesExpectedFormat(client) {
10704
+ function isClientObject(client) {
10692
10705
  // We require the following properties defined
10693
10706
  return ["handle", "rollout", "chat", "features"].every(function (key) {
10694
10707
  return client[key] !== undefined;
@@ -10719,14 +10732,14 @@ function _fetchClient() {
10719
10732
  case 3:
10720
10733
  cachedClient = _context.sent;
10721
10734
 
10722
- if (!(cachedClient && clientMatchesExpectedFormat(cachedClient))) {
10735
+ if (!(cachedClient && isClientObject(cachedClient))) {
10723
10736
  _context.next = 6;
10724
10737
  break;
10725
10738
  }
10726
10739
 
10727
10740
  return _context.abrupt("return", {
10728
10741
  client: fetch_client_objectSpread({
10729
- intro: getIntroForCurrentUrl(cachedClient.intros, language || cachedClient.language)
10742
+ intro: getIntroForCurrentUrl(cachedClient.intros || [], language || cachedClient.language)
10730
10743
  }, cachedClient)
10731
10744
  });
10732
10745
 
@@ -10807,6 +10820,53 @@ function wait(ms) {
10807
10820
  return setTimeout(resolve, ms);
10808
10821
  });
10809
10822
  }
10823
+ // EXTERNAL MODULE: ./node_modules/@babel/runtime-corejs3/core-js/object/get-own-property-symbols.js
10824
+ var object_get_own_property_symbols = __webpack_require__(3263);
10825
+ // EXTERNAL MODULE: ./node_modules/@babel/runtime-corejs3/core-js/instance/index-of.js
10826
+ var index_of = __webpack_require__(5683);
10827
+ // EXTERNAL MODULE: ./node_modules/@babel/runtime-corejs3/core-js/object/keys.js
10828
+ var keys = __webpack_require__(9356);
10829
+ ;// CONCATENATED MODULE: ./node_modules/@babel/runtime-corejs3/helpers/esm/objectWithoutPropertiesLoose.js
10830
+
10831
+
10832
+ function _objectWithoutPropertiesLoose(source, excluded) {
10833
+ if (source == null) return {};
10834
+ var target = {};
10835
+
10836
+ var sourceKeys = keys(source);
10837
+
10838
+ var key, i;
10839
+
10840
+ for (i = 0; i < sourceKeys.length; i++) {
10841
+ key = sourceKeys[i];
10842
+ if (index_of(excluded).call(excluded, key) >= 0) continue;
10843
+ target[key] = source[key];
10844
+ }
10845
+
10846
+ return target;
10847
+ }
10848
+ ;// CONCATENATED MODULE: ./node_modules/@babel/runtime-corejs3/helpers/esm/objectWithoutProperties.js
10849
+
10850
+
10851
+
10852
+ function _objectWithoutProperties(source, excluded) {
10853
+ if (source == null) return {};
10854
+ var target = _objectWithoutPropertiesLoose(source, excluded);
10855
+ var key, i;
10856
+
10857
+ if (object_get_own_property_symbols) {
10858
+ var sourceSymbolKeys = object_get_own_property_symbols(source);
10859
+
10860
+ for (i = 0; i < sourceSymbolKeys.length; i++) {
10861
+ key = sourceSymbolKeys[i];
10862
+ if (index_of(excluded).call(excluded, key) >= 0) continue;
10863
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
10864
+ target[key] = source[key];
10865
+ }
10866
+ }
10867
+
10868
+ return target;
10869
+ }
10810
10870
  // EXTERNAL MODULE: ./node_modules/@babel/runtime-corejs3/core-js-stable/object/assign.js
10811
10871
  var core_js_stable_object_assign = __webpack_require__(1942);
10812
10872
  var object_assign_default = /*#__PURE__*/__webpack_require__.n(core_js_stable_object_assign);
@@ -10814,6 +10874,7 @@ var object_assign_default = /*#__PURE__*/__webpack_require__.n(core_js_stable_ob
10814
10874
 
10815
10875
 
10816
10876
 
10877
+ var _excluded = ["chat", "chat_button", "features", "handle", "language", "persistence", "privacy", "rollout", "tint"];
10817
10878
 
10818
10879
  var Client = function Client(clientResponse) {
10819
10880
  (0,classCallCheck/* default */.Z)(this, Client);
@@ -10846,15 +10907,34 @@ var Client = function Client(clientResponse) {
10846
10907
 
10847
10908
  (0,defineProperty/* default */.Z)(this, "ui_settings", void 0);
10848
10909
 
10910
+ var chat = clientResponse.chat,
10911
+ chatButton = clientResponse.chat_button,
10912
+ features = clientResponse.features,
10913
+ handle = clientResponse.handle,
10914
+ language = clientResponse.language,
10915
+ persistence = clientResponse.persistence,
10916
+ privacy = clientResponse.privacy,
10917
+ rollout = clientResponse.rollout,
10918
+ tint = clientResponse.tint,
10919
+ rest = _objectWithoutProperties(clientResponse, _excluded);
10920
+
10921
+ this.chat = chat;
10922
+ this.chat_button = chatButton;
10923
+ this.features = features;
10924
+ this.handle = handle;
10925
+ this.language = language;
10926
+ this.persistence = persistence;
10927
+ this.privacy = privacy;
10928
+ this.rollout = rollout;
10929
+ this.tint = tint;
10849
10930
  /**
10850
10931
  * Even if some properties are not used by Embed2, they may be used by Chat.
10851
10932
  * Chat can "pull" the client object from Embed2 in order to reduce an API
10852
10933
  * request. Embed2 should thus not modify keys.
10853
10934
  */
10854
- object_assign_default()(this, clientResponse);
10855
- };
10856
-
10857
10935
 
10936
+ object_assign_default()(this, rest);
10937
+ };
10858
10938
  function hasCampaignsEnabled(client) {
10859
10939
  return (client === null || client === void 0 ? void 0 : client.features.afm_proactive_messaging) || (client === null || client === void 0 ? void 0 : client.features.afm_proactive_messaging_free_tier);
10860
10940
  }
@@ -11311,6 +11391,8 @@ function ChatFrame_isNativeReflectConstruct() { if (typeof Reflect === "undefine
11311
11391
 
11312
11392
 
11313
11393
 
11394
+ var documentBodyStyle = window.document.body.style;
11395
+
11314
11396
  var ChatFrame = /*#__PURE__*/function (_Component) {
11315
11397
  (0,inherits/* default */.Z)(ChatFrame, _Component);
11316
11398
 
@@ -11331,21 +11413,19 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11331
11413
 
11332
11414
  (0,defineProperty/* default */.Z)((0,assertThisInitialized/* default */.Z)(_this), "iframeRef", y());
11333
11415
 
11334
- (0,defineProperty/* default */.Z)((0,assertThisInitialized/* default */.Z)(_this), "pageYOffset", void 0);
11335
-
11336
- (0,defineProperty/* default */.Z)((0,assertThisInitialized/* default */.Z)(_this), "documentBodyOverflow", void 0);
11416
+ (0,defineProperty/* default */.Z)((0,assertThisInitialized/* default */.Z)(_this), "pageYOffset", window.pageYOffset);
11337
11417
 
11338
- (0,defineProperty/* default */.Z)((0,assertThisInitialized/* default */.Z)(_this), "documentBodyPosition", void 0);
11418
+ (0,defineProperty/* default */.Z)((0,assertThisInitialized/* default */.Z)(_this), "documentBodyOverflow", documentBodyStyle.overflow);
11339
11419
 
11340
- (0,defineProperty/* default */.Z)((0,assertThisInitialized/* default */.Z)(_this), "documentBodyTop", void 0);
11420
+ (0,defineProperty/* default */.Z)((0,assertThisInitialized/* default */.Z)(_this), "documentBodyPosition", documentBodyStyle.position);
11341
11421
 
11342
- (0,defineProperty/* default */.Z)((0,assertThisInitialized/* default */.Z)(_this), "documentBodyBottom", void 0);
11422
+ (0,defineProperty/* default */.Z)((0,assertThisInitialized/* default */.Z)(_this), "documentBodyTop", documentBodyStyle.top);
11343
11423
 
11344
- (0,defineProperty/* default */.Z)((0,assertThisInitialized/* default */.Z)(_this), "documentBodyLeft", void 0);
11424
+ (0,defineProperty/* default */.Z)((0,assertThisInitialized/* default */.Z)(_this), "documentBodyBottom", documentBodyStyle.bottom);
11345
11425
 
11346
- (0,defineProperty/* default */.Z)((0,assertThisInitialized/* default */.Z)(_this), "documentBodyRight", void 0);
11426
+ (0,defineProperty/* default */.Z)((0,assertThisInitialized/* default */.Z)(_this), "documentBodyLeft", documentBodyStyle.left);
11347
11427
 
11348
- (0,defineProperty/* default */.Z)((0,assertThisInitialized/* default */.Z)(_this), "frameConnected", void 0);
11428
+ (0,defineProperty/* default */.Z)((0,assertThisInitialized/* default */.Z)(_this), "documentBodyRight", documentBodyStyle.right);
11349
11429
 
11350
11430
  (0,defineProperty/* default */.Z)((0,assertThisInitialized/* default */.Z)(_this), "url", _this.getURL);
11351
11431
 
@@ -11365,6 +11445,8 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11365
11445
  var _this2 = this;
11366
11446
 
11367
11447
  var _this$props = this.props,
11448
+ adaSettings = _this$props.adaSettings,
11449
+ handle = _this$props.handle,
11368
11450
  name = _this$props.name,
11369
11451
  setChatHasBeenRendered = _this$props.setChatHasBeenRendered,
11370
11452
  messageService = _this$props.messageService,
@@ -11373,7 +11455,12 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11373
11455
  this.channel = messageService.registerFrameChannel(name, this.iframeRef.current.contentWindow, this.iframeRef.current.src);
11374
11456
  store.addChannelListener(name);
11375
11457
  this.bindChatEventHandlers();
11376
- this.handleScrollLock(); // Delay to allow inline css animation to work.
11458
+ this.handleScrollLock(); // We use this log to track number of chat impressions (times when users see chat iFrame render first time).
11459
+
11460
+ (0,services_logger/* log */.c)("Chat frame mount", {
11461
+ handle: handle,
11462
+ embedSettings: adaSettings
11463
+ }); // Delay to allow inline css animation to work.
11377
11464
 
11378
11465
  setTimeout(function () {
11379
11466
  _this2.setState({
@@ -11410,7 +11497,7 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11410
11497
  }
11411
11498
 
11412
11499
  var theme = client.ui_settings.chat.theme;
11413
- var systemDarkMode = Boolean(window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches);
11500
+ var systemDarkMode = window.matchMedia("(prefers-color-scheme: dark)").matches;
11414
11501
  return theme === "dark" || theme === "auto" && systemDarkMode;
11415
11502
  }
11416
11503
  /**
@@ -11432,6 +11519,11 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11432
11519
  privateMode = _this$props3.privateMode,
11433
11520
  testMode = _this$props3.testMode,
11434
11521
  adaSettings = _this$props3.adaSettings;
11522
+
11523
+ if (!handle) {
11524
+ throw new errors/* AdaEmbedError */.S("`handle` is not defined");
11525
+ }
11526
+
11435
11527
  return getURL({
11436
11528
  name: name,
11437
11529
  handle: handle,
@@ -11452,7 +11544,7 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11452
11544
  }, {
11453
11545
  key: "styles",
11454
11546
  get: function get() {
11455
- var _client$ui_settings2, _context10, _context11, _context12, _context13, _context14;
11547
+ var _client$ui_settings2, _client$ui_settings2$, _context10, _context11, _context12, _context13, _context14;
11456
11548
 
11457
11549
  var _this$props4 = this.props,
11458
11550
  isDrawerOpen = _this$props4.isDrawerOpen,
@@ -11469,7 +11561,7 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11469
11561
  closeTransitionTime = _this$state.closeTransitionTime;
11470
11562
  var isShown = isDrawerOpen && isMounted;
11471
11563
  var backgroundColor = this.darkMode ? "#121212" : "#fff";
11472
- var borderRadius = ((_client$ui_settings2 = client.ui_settings) === null || _client$ui_settings2 === void 0 ? void 0 : _client$ui_settings2.chat.style) === "rectangular" ? "8px" : "16px";
11564
+ var borderRadius = ((_client$ui_settings2 = client.ui_settings) === null || _client$ui_settings2 === void 0 ? void 0 : (_client$ui_settings2$ = _client$ui_settings2.chat) === null || _client$ui_settings2$ === void 0 ? void 0 : _client$ui_settings2$.style) === "rectangular" ? "8px" : "16px";
11473
11565
  var WINDOW_HEIGHT = 725;
11474
11566
  var TEST_BOT_NAV_HEIGHT = 48;
11475
11567
  var isTestBot = client.features.embed_test_bot && testMode;
@@ -11498,12 +11590,17 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11498
11590
  var _this$props5 = this.props,
11499
11591
  chatDimensions = _this$props5.chatDimensions,
11500
11592
  client = _this$props5.client,
11501
- adaSettings = _this$props5.adaSettings; // delta is used to determine how much of the button's height should be ignored
11593
+ adaSettings = _this$props5.adaSettings;
11594
+
11595
+ if (!(client !== null && client !== void 0 && client.chat_button)) {
11596
+ return "";
11597
+ } // delta is used to determine how much of the button's height should be ignored
11502
11598
  // when spacing the proactive message
11503
11599
 
11600
+
11504
11601
  var delta = 3;
11505
11602
  var TEXT_BUTTON_HEIGHT = 44;
11506
- var bottomOffset = (client === null || client === void 0 ? void 0 : (_client$ui_settings3 = client.ui_settings) === null || _client$ui_settings3 === void 0 ? void 0 : (_client$ui_settings3$ = _client$ui_settings3.embed) === null || _client$ui_settings3$ === void 0 ? void 0 : _client$ui_settings3$.style) === "text" ? TEXT_BUTTON_HEIGHT - delta : (client === null || client === void 0 ? void 0 : client.chat_button.size) - delta;
11603
+ var bottomOffset = ((_client$ui_settings3 = client.ui_settings) === null || _client$ui_settings3 === void 0 ? void 0 : (_client$ui_settings3$ = _client$ui_settings3.embed) === null || _client$ui_settings3$ === void 0 ? void 0 : _client$ui_settings3$.style) === "text" ? TEXT_BUTTON_HEIGHT - delta : client.chat_button.size - delta;
11507
11604
  return concat_default()(_context15 = concat_default()(_context16 = concat_default()(_context17 = "\n box-shadow: none;\n background: none;\n height: ".concat(chatDimensions === null || chatDimensions === void 0 ? void 0 : chatDimensions.height, "px !important;\n width: ")).call(_context17, chatDimensions === null || chatDimensions === void 0 ? void 0 : chatDimensions.width, "px !important;\n ")).call(_context16, getAlignment(adaSettings), ": 0;\n bottom: ")).call(_context15, bottomOffset, "px;\n z-index: 9999;\n ");
11508
11605
  }
11509
11606
  }, {
@@ -11519,6 +11616,10 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11519
11616
  return ChatFrame.parentElementStyles;
11520
11617
  }
11521
11618
 
11619
+ if (!client) {
11620
+ throw new errors/* AdaEmbedError */.S("`client` is not defined");
11621
+ }
11622
+
11522
11623
  if (client.features.afm_proactive_messaging && !isDrawerOpen) {
11523
11624
  var _context21;
11524
11625
 
@@ -11538,11 +11639,18 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11538
11639
  value: function handleScrollLock() {
11539
11640
  var _this3 = this;
11540
11641
 
11541
- var isDrawerOpen = this.props.isDrawerOpen;
11542
- var closeTransitionTime = this.state.closeTransitionTime;
11642
+ var _this$props7 = this.props,
11643
+ isDrawerOpen = _this$props7.isDrawerOpen,
11644
+ parentElement = _this$props7.parentElement;
11645
+ var closeTransitionTime = this.state.closeTransitionTime; // Lock scroll only on mobile
11543
11646
 
11544
11647
  if (!isMobile) {
11545
11648
  return;
11649
+ } // And if parentElement is not used
11650
+
11651
+
11652
+ if (parentElement) {
11653
+ return;
11546
11654
  }
11547
11655
 
11548
11656
  if (isDrawerOpen) {
@@ -11575,7 +11683,7 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11575
11683
  }, {
11576
11684
  key: "lockDocumentBodyFromScrolling",
11577
11685
  value: function lockDocumentBodyFromScrolling() {
11578
- // save current page position so we can scroll back there
11686
+ // Save current page position so we can scroll back there
11579
11687
  this.pageYOffset = window.pageYOffset;
11580
11688
  this.documentBodyOverflow = window.document.body.style.overflow;
11581
11689
  this.documentBodyPosition = window.document.body.style.position;
@@ -11623,9 +11731,9 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11623
11731
  var title = payload.title,
11624
11732
  body = payload.body,
11625
11733
  icon = payload.icon;
11626
- var _this$props7 = this.props,
11627
- isDrawerOpen = _this$props7.isDrawerOpen,
11628
- parentElement = _this$props7.parentElement;
11734
+ var _this$props8 = this.props,
11735
+ isDrawerOpen = _this$props8.isDrawerOpen,
11736
+ parentElement = _this$props8.parentElement;
11629
11737
  var isChatOpen = isDrawerOpen || Boolean(parentElement);
11630
11738
  var onClickHandler = this.notificationOnClickHandler.bind(this, isChatOpen);
11631
11739
  createNotification(title, isChatOpen, onClickHandler, {
@@ -11639,40 +11747,56 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11639
11747
  var _handleChatEvent = (0,asyncToGenerator/* default */.Z)( /*#__PURE__*/regenerator_default().mark(function _callee(type, payload, id) {
11640
11748
  var _this4 = this;
11641
11749
 
11642
- var _this$props8, adaSettings, setState, setConnectionState, _ref, eventKey, data, _ref2, analytics, analyticsCallback, client, _ref3, chatter, created, chatterTokenCallback, _client, _ref4, zdSessionId, zdPreviousTags, storage, _client2, _ref5, inLiveChat, eventCallbacks, customJavascriptEvent, specificCallback, genericCallback, resetChat, zdChatterAuthCallback, conversationEndCallback;
11750
+ var _this$props9, adaSettings, setState, setConnectionState, _ref, eventKey, data, _ref2, analytics, analyticsCallback, client, _ref3, chatter, created, chatterTokenCallback, _client, _ref4, zdSessionId, zdPreviousTags, storage, _client2, _ref5, inLiveChat, eventCallbacks, customJavascriptEvent, specificCallback, genericCallback, resetChat, zdChatterAuthCallback, conversationEndCallback;
11643
11751
 
11644
11752
  return regenerator_default().wrap(function _callee$(_context22) {
11645
11753
  while (1) {
11646
11754
  switch (_context22.prev = _context22.next) {
11647
11755
  case 0:
11648
- _this$props8 = this.props, adaSettings = _this$props8.adaSettings, setState = _this$props8.setState, setConnectionState = _this$props8.setConnectionState;
11756
+ _this$props9 = this.props, adaSettings = _this$props9.adaSettings, setState = _this$props9.setState, setConnectionState = _this$props9.setConnectionState;
11649
11757
  _context22.t0 = type;
11650
- _context22.next = _context22.t0 === GET_WINDOW_ORIGIN ? 4 : _context22.t0 === CHAT_STARTED ? 6 : _context22.t0 === CHAT_WEBSOCKET_CONNECTED ? 9 : _context22.t0 === PUBLISH_EVENT ? 11 : _context22.t0 === ANALYTICS_EVENT ? 14 : _context22.t0 === CHATTER_EVENT ? 18 : _context22.t0 === "ZD_SESSION" ? 28 : _context22.t0 === CHATTER_LIVECHAT_EVENT ? 37 : _context22.t0 === CUSTOM_JAVASCRIPT_EVENT ? 43 : _context22.t0 === RESET_FROM_CHAT_EVENT ? 52 : _context22.t0 === ZD_JWT_AUTH_EVENT ? 55 : _context22.t0 === CREATE_NOTIFICATION_EVENT ? 58 : _context22.t0 === BROWSER_HAS_NOTIFICATIONS_EVENT ? 60 : _context22.t0 === REQUEST_NOTIFICATIONS_EVENT ? 62 : _context22.t0 === END_CONVERSATION_EVENT ? 64 : 67;
11758
+ _context22.next = _context22.t0 === GET_WINDOW_ORIGIN ? 4 : _context22.t0 === CHAT_STARTED ? 8 : _context22.t0 === CHAT_WEBSOCKET_CONNECTED ? 13 : _context22.t0 === PUBLISH_EVENT ? 15 : _context22.t0 === ANALYTICS_EVENT ? 18 : _context22.t0 === CHATTER_EVENT ? 22 : _context22.t0 === "ZD_SESSION" ? 32 : _context22.t0 === CHATTER_LIVECHAT_EVENT ? 41 : _context22.t0 === CUSTOM_JAVASCRIPT_EVENT ? 49 : _context22.t0 === RESET_FROM_CHAT_EVENT ? 58 : _context22.t0 === ZD_JWT_AUTH_EVENT ? 61 : _context22.t0 === CREATE_NOTIFICATION_EVENT ? 79 : _context22.t0 === BROWSER_HAS_NOTIFICATIONS_EVENT ? 81 : _context22.t0 === REQUEST_NOTIFICATIONS_EVENT ? 85 : _context22.t0 === END_CONVERSATION_EVENT ? 87 : 90;
11651
11759
  break;
11652
11760
 
11653
11761
  case 4:
11654
- this.channel.postMessage("SET_WINDOW_ORIGIN", window.location, id);
11655
- return _context22.abrupt("break", 68);
11762
+ if (this.channel) {
11763
+ _context22.next = 6;
11764
+ break;
11765
+ }
11766
+
11767
+ throw new errors/* AdaEmbedError */.S("`this.channel` is not defined");
11656
11768
 
11657
11769
  case 6:
11770
+ this.channel.postMessage("SET_WINDOW_ORIGIN", window.location, id);
11771
+ return _context22.abrupt("break", 91);
11772
+
11773
+ case 8:
11774
+ if (this.channel) {
11775
+ _context22.next = 10;
11776
+ break;
11777
+ }
11778
+
11779
+ throw new errors/* AdaEmbedError */.S("`this.channel` is not defined");
11780
+
11781
+ case 10:
11658
11782
  this.channel.isConnected = true;
11659
11783
  setConnectionState({
11660
11784
  "chat": ConnectionState.Done
11661
11785
  });
11662
- return _context22.abrupt("break", 68);
11786
+ return _context22.abrupt("break", 91);
11663
11787
 
11664
- case 9:
11788
+ case 13:
11665
11789
  setState({
11666
11790
  isChatWebsocketConnected: true
11667
11791
  });
11668
- return _context22.abrupt("break", 68);
11792
+ return _context22.abrupt("break", 91);
11669
11793
 
11670
- case 11:
11794
+ case 15:
11671
11795
  _ref = payload, eventKey = _ref.eventKey, data = _ref.data;
11672
11796
  publishEvent(eventKey, data);
11673
- return _context22.abrupt("break", 68);
11797
+ return _context22.abrupt("break", 91);
11674
11798
 
11675
- case 14:
11799
+ case 18:
11676
11800
  _ref2 = payload, analytics = _ref2.analytics;
11677
11801
  analyticsCallback = adaSettings.analyticsCallback;
11678
11802
 
@@ -11680,28 +11804,28 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11680
11804
  analyticsCallback(analytics);
11681
11805
  }
11682
11806
 
11683
- return _context22.abrupt("break", 68);
11807
+ return _context22.abrupt("break", 91);
11684
11808
 
11685
- case 18:
11809
+ case 22:
11686
11810
  client = this.props.client;
11687
11811
  _ref3 = payload, chatter = _ref3.chatter, created = _ref3.created;
11688
11812
  chatterTokenCallback = adaSettings.chatterTokenCallback;
11689
11813
 
11690
11814
  if (client) {
11691
- _context22.next = 23;
11815
+ _context22.next = 27;
11692
11816
  break;
11693
11817
  }
11694
11818
 
11695
11819
  throw new errors/* AdaEmbedError */.S("`client` is undefined");
11696
11820
 
11697
- case 23:
11698
- _context22.next = 25;
11821
+ case 27:
11822
+ _context22.next = 29;
11699
11823
  return setState({
11700
11824
  chatterToken: chatter,
11701
11825
  chatterCreated: created
11702
11826
  });
11703
11827
 
11704
- case 25:
11828
+ case 29:
11705
11829
  /**
11706
11830
  * Store the token so when embed loads in the future, it doesn't have to wait for it to
11707
11831
  * come from chat. This is important for campaign and business event triggers.
@@ -11718,26 +11842,26 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11718
11842
  chatterTokenCallback(chatter);
11719
11843
  }
11720
11844
 
11721
- return _context22.abrupt("break", 68);
11845
+ return _context22.abrupt("break", 91);
11722
11846
 
11723
- case 28:
11847
+ case 32:
11724
11848
  _client = this.props.client;
11725
11849
  _ref4 = payload, zdSessionId = _ref4.zdSessionId, zdPreviousTags = _ref4.zdPreviousTags;
11726
11850
 
11727
11851
  if (_client) {
11728
- _context22.next = 32;
11852
+ _context22.next = 36;
11729
11853
  break;
11730
11854
  }
11731
11855
 
11732
11856
  throw new errors/* AdaEmbedError */.S("`client` is undefined");
11733
11857
 
11734
- case 32:
11735
- _context22.next = 34;
11858
+ case 36:
11859
+ _context22.next = 38;
11736
11860
  return setState({
11737
11861
  zdSessionId: zdSessionId
11738
11862
  });
11739
11863
 
11740
- case 34:
11864
+ case 38:
11741
11865
  storage = function () {
11742
11866
  if (_client.persistence === PERSISTENCE_NORMAL) {
11743
11867
  return safeLocalStorage;
@@ -11764,17 +11888,25 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11764
11888
  }
11765
11889
  }
11766
11890
 
11767
- return _context22.abrupt("break", 68);
11891
+ return _context22.abrupt("break", 91);
11768
11892
 
11769
- case 37:
11893
+ case 41:
11770
11894
  _client2 = this.props.client;
11771
11895
  _ref5 = payload, inLiveChat = _ref5.inLiveChat;
11772
- _context22.next = 41;
11896
+ _context22.next = 45;
11773
11897
  return setState({
11774
11898
  chatterInLiveChat: inLiveChat
11775
11899
  });
11776
11900
 
11777
- case 41:
11901
+ case 45:
11902
+ if (_client2) {
11903
+ _context22.next = 47;
11904
+ break;
11905
+ }
11906
+
11907
+ throw new errors/* AdaEmbedError */.S("`client` is not defined");
11908
+
11909
+ case 47:
11778
11910
  /**
11779
11911
  * Store the token so when embed loads in the future, it doesn't have to wait for it to
11780
11912
  * come from chat. This is important for campaign and business event triggers.
@@ -11785,19 +11917,19 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11785
11917
  safeSessionStorage.setItem(IN_LIVE_CHAT_STORAGE_KEY, inLiveChat);
11786
11918
  }
11787
11919
 
11788
- return _context22.abrupt("break", 68);
11920
+ return _context22.abrupt("break", 91);
11789
11921
 
11790
- case 43:
11922
+ case 49:
11791
11923
  eventCallbacks = adaSettings.eventCallbacks;
11792
11924
 
11793
11925
  if (eventCallbacks) {
11794
- _context22.next = 46;
11926
+ _context22.next = 52;
11795
11927
  break;
11796
11928
  }
11797
11929
 
11798
- return _context22.abrupt("break", 68);
11930
+ return _context22.abrupt("break", 91);
11799
11931
 
11800
- case 46:
11932
+ case 52:
11801
11933
  customJavascriptEvent = payload.event_data;
11802
11934
  specificCallback = eventCallbacks[customJavascriptEvent.event_name];
11803
11935
  genericCallback = eventCallbacks["*"];
@@ -11810,65 +11942,107 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11810
11942
  genericCallback(customJavascriptEvent);
11811
11943
  }
11812
11944
 
11813
- return _context22.abrupt("break", 68);
11945
+ return _context22.abrupt("break", 91);
11814
11946
 
11815
- case 52:
11947
+ case 58:
11816
11948
  resetChat = this.props.resetChat;
11817
11949
  resetChat();
11818
- return _context22.abrupt("break", 68);
11950
+ return _context22.abrupt("break", 91);
11819
11951
 
11820
- case 55:
11952
+ case 61:
11821
11953
  zdChatterAuthCallback = adaSettings.zdChatterAuthCallback;
11822
11954
 
11823
- if (zdChatterAuthCallback) {
11824
- try {
11825
- zdChatterAuthCallback(function (token) {
11826
- _this4.channel.postMessage(ZD_JWT_AUTH_RESPONSE_EVENT, {
11827
- token: token
11828
- }, id);
11829
- });
11830
- } catch (e) {
11831
- console.warn("Function for zdChatterAuthCallback produced an error - please ensure the callback is functioning normally");
11832
- this.channel.postMessage(ZD_JWT_AUTH_RESPONSE_EVENT, {}, id);
11955
+ if (!zdChatterAuthCallback) {
11956
+ _context22.next = 75;
11957
+ break;
11958
+ }
11959
+
11960
+ _context22.prev = 63;
11961
+ zdChatterAuthCallback(function (token) {
11962
+ if (!_this4.channel) {
11963
+ throw new errors/* AdaEmbedError */.S("`this.channel` is not defined");
11833
11964
  }
11834
- } else {
11835
- this.channel.postMessage(ZD_JWT_AUTH_RESPONSE_EVENT, {}, id);
11965
+
11966
+ _this4.channel.postMessage(ZD_JWT_AUTH_RESPONSE_EVENT, {
11967
+ token: token
11968
+ }, id);
11969
+ });
11970
+ _context22.next = 73;
11971
+ break;
11972
+
11973
+ case 67:
11974
+ _context22.prev = 67;
11975
+ _context22.t1 = _context22["catch"](63);
11976
+ console.warn("Function for zdChatterAuthCallback produced an error - please ensure the callback is functioning normally");
11977
+
11978
+ if (this.channel) {
11979
+ _context22.next = 72;
11980
+ break;
11836
11981
  }
11837
11982
 
11838
- return _context22.abrupt("break", 68);
11983
+ throw new errors/* AdaEmbedError */.S("`this.channel` is not defined");
11839
11984
 
11840
- case 58:
11985
+ case 72:
11986
+ this.channel.postMessage(ZD_JWT_AUTH_RESPONSE_EVENT, {}, id);
11987
+
11988
+ case 73:
11989
+ _context22.next = 78;
11990
+ break;
11991
+
11992
+ case 75:
11993
+ if (this.channel) {
11994
+ _context22.next = 77;
11995
+ break;
11996
+ }
11997
+
11998
+ throw new errors/* AdaEmbedError */.S("`this.channel` is not defined");
11999
+
12000
+ case 77:
12001
+ this.channel.postMessage(ZD_JWT_AUTH_RESPONSE_EVENT, {}, id);
12002
+
12003
+ case 78:
12004
+ return _context22.abrupt("break", 91);
12005
+
12006
+ case 79:
11841
12007
  this.handleNotifications(payload);
11842
- return _context22.abrupt("break", 68);
12008
+ return _context22.abrupt("break", 91);
11843
12009
 
11844
- case 60:
12010
+ case 81:
12011
+ if (this.channel) {
12012
+ _context22.next = 83;
12013
+ break;
12014
+ }
12015
+
12016
+ throw new errors/* AdaEmbedError */.S("`this.channel` is not defined");
12017
+
12018
+ case 83:
11845
12019
  this.channel.postMessage(BROWSER_HAS_NOTIFICATIONS_RESPONSE_EVENT, {
11846
12020
  browserHasNotificationSupport: browserHasNotificationSupport
11847
12021
  });
11848
- return _context22.abrupt("break", 68);
12022
+ return _context22.abrupt("break", 91);
11849
12023
 
11850
- case 62:
12024
+ case 85:
11851
12025
  requestNotificationPermission();
11852
- return _context22.abrupt("break", 68);
12026
+ return _context22.abrupt("break", 91);
11853
12027
 
11854
- case 64:
12028
+ case 87:
11855
12029
  conversationEndCallback = adaSettings.conversationEndCallback;
11856
12030
 
11857
12031
  if (conversationEndCallback) {
11858
12032
  conversationEndCallback(payload);
11859
12033
  }
11860
12034
 
11861
- return _context22.abrupt("break", 68);
12035
+ return _context22.abrupt("break", 91);
11862
12036
 
11863
- case 67:
11864
- return _context22.abrupt("break", 68);
12037
+ case 90:
12038
+ return _context22.abrupt("break", 91);
11865
12039
 
11866
- case 68:
12040
+ case 91:
11867
12041
  case "end":
11868
12042
  return _context22.stop();
11869
12043
  }
11870
12044
  }
11871
- }, _callee, this);
12045
+ }, _callee, this, [[63, 67]]);
11872
12046
  }));
11873
12047
 
11874
12048
  function handleChatEvent(_x, _x2, _x3) {
@@ -11882,19 +12056,25 @@ var ChatFrame = /*#__PURE__*/function (_Component) {
11882
12056
  value: function bindChatEventHandlers() {
11883
12057
  var _this5 = this;
11884
12058
 
11885
- var _this$props9 = this.props,
11886
- name = _this$props9.name,
11887
- messageService = _this$props9.messageService;
11888
- messageService.getChannel(name).addEventListener(function (type, payload, id) {
12059
+ var _this$props10 = this.props,
12060
+ name = _this$props10.name,
12061
+ messageService = _this$props10.messageService;
12062
+ var channel = messageService.getChannel(name);
12063
+
12064
+ if (!channel) {
12065
+ throw new errors/* AdaEmbedError */.S("`channel` is not defined");
12066
+ }
12067
+
12068
+ channel.addEventListener(function (type, payload, id) {
11889
12069
  _this5.handleChatEvent(type, payload, id);
11890
12070
  });
11891
12071
  }
11892
12072
  }, {
11893
12073
  key: "render",
11894
12074
  value: function render() {
11895
- var _this$props10 = this.props,
11896
- name = _this$props10.name,
11897
- isDrawerOpen = _this$props10.isDrawerOpen;
12075
+ var _this$props11 = this.props,
12076
+ name = _this$props11.name,
12077
+ isDrawerOpen = _this$props11.isDrawerOpen;
11898
12078
  var iFrameName = "ada-".concat(name, "-frame");
11899
12079
  return v("iframe", {
11900
12080
  src: this.url,
@@ -12672,7 +12852,7 @@ var Container = /*#__PURE__*/function (_Component) {
12672
12852
 
12673
12853
  case 6:
12674
12854
  _context3.t0 = type;
12675
- _context3.next = _context3.t0 === TRACK_EVENT ? 9 : _context3.t0 === TRIGGER_CAMPAIGN ? 14 : _context3.t0 === EVAL_CAMPAIGN_CONDITIONS ? 19 : _context3.t0 === TOGGLE ? 24 : _context3.t0 === GET_INFO ? 29 : _context3.t0 === SET_META_FIELDS ? 33 : _context3.t0 === "SET_SENSITIVE_META_FIELDS" ? 40 : _context3.t0 === STOP ? 45 : _context3.t0 === RESET ? 48 : _context3.t0 === DELETE_HISTORY ? 66 : _context3.t0 === CREATE_PROACTIVE ? 78 : 89;
12855
+ _context3.next = _context3.t0 === TRACK_EVENT ? 9 : _context3.t0 === TRIGGER_CAMPAIGN ? 14 : _context3.t0 === EVAL_CAMPAIGN_CONDITIONS ? 19 : _context3.t0 === TOGGLE ? 24 : _context3.t0 === GET_INFO ? 29 : _context3.t0 === SET_META_FIELDS ? 33 : _context3.t0 === "SET_SENSITIVE_META_FIELDS" ? 40 : _context3.t0 === STOP ? 45 : _context3.t0 === RESET ? 48 : _context3.t0 === DELETE_HISTORY ? 66 : _context3.t0 === CREATE_PROACTIVE ? 78 : 91;
12676
12856
  break;
12677
12857
 
12678
12858
  case 9:
@@ -12686,7 +12866,7 @@ var Container = /*#__PURE__*/function (_Component) {
12686
12866
 
12687
12867
  case 12:
12688
12868
  this.trackEvent(payload);
12689
- return _context3.abrupt("break", 89);
12869
+ return _context3.abrupt("break", 91);
12690
12870
 
12691
12871
  case 14:
12692
12872
  if (client.features.afm_proactive_messaging) {
@@ -12699,7 +12879,7 @@ var Container = /*#__PURE__*/function (_Component) {
12699
12879
 
12700
12880
  case 17:
12701
12881
  this.triggerCampaign(payload);
12702
- return _context3.abrupt("break", 89);
12882
+ return _context3.abrupt("break", 91);
12703
12883
 
12704
12884
  case 19:
12705
12885
  if (client.features.afm_proactive_messaging) {
@@ -12712,7 +12892,7 @@ var Container = /*#__PURE__*/function (_Component) {
12712
12892
 
12713
12893
  case 22:
12714
12894
  this.evaluateCampaignConditions(payload);
12715
- return _context3.abrupt("break", 89);
12895
+ return _context3.abrupt("break", 91);
12716
12896
 
12717
12897
  case 24:
12718
12898
  toggleChat = this.props.toggleChat;
@@ -12721,7 +12901,7 @@ var Container = /*#__PURE__*/function (_Component) {
12721
12901
 
12722
12902
  case 27:
12723
12903
  localChannel.postMessage(TOGGLE_RESPONSE, null, id);
12724
- return _context3.abrupt("break", 89);
12904
+ return _context3.abrupt("break", 91);
12725
12905
 
12726
12906
  case 29:
12727
12907
  _this$props10 = this.props, isDrawerOpen = _this$props10.isDrawerOpen, drawerHasBeenOpened = _this$props10.drawerHasBeenOpened, chatterToken = _this$props10.chatterToken;
@@ -12732,7 +12912,7 @@ var Container = /*#__PURE__*/function (_Component) {
12732
12912
  hasClosedChat: drawerHasBeenOpened && !isDrawerOpen
12733
12913
  };
12734
12914
  localChannel.postMessage(GET_INFO_RESPONSE, contentToReturn, id);
12735
- return _context3.abrupt("break", 89);
12915
+ return _context3.abrupt("break", 91);
12736
12916
 
12737
12917
  case 33:
12738
12918
  _this$props11 = this.props, metaFields = _this$props11.metaFields, setState = _this$props11.setState;
@@ -12745,7 +12925,7 @@ var Container = /*#__PURE__*/function (_Component) {
12745
12925
 
12746
12926
  case 38:
12747
12927
  localChannel.postMessage(SET_META_FIELDS_RESPONSE, null, id);
12748
- return _context3.abrupt("break", 89);
12928
+ return _context3.abrupt("break", 91);
12749
12929
 
12750
12930
  case 40:
12751
12931
  _this$props12 = this.props, sensitiveMetaFields = _this$props12.sensitiveMetaFields, _setState = _this$props12.setState;
@@ -12756,12 +12936,12 @@ var Container = /*#__PURE__*/function (_Component) {
12756
12936
 
12757
12937
  case 43:
12758
12938
  localChannel.postMessage("SET_SENSITIVE_META_FIELDS_RESPONSE", null, id);
12759
- return _context3.abrupt("break", 89);
12939
+ return _context3.abrupt("break", 91);
12760
12940
 
12761
12941
  case 45:
12762
12942
  localChannel.postMessage(STOP_RESPONSE, null, id);
12763
12943
  this.unmount();
12764
- return _context3.abrupt("break", 89);
12944
+ return _context3.abrupt("break", 91);
12765
12945
 
12766
12946
  case 48:
12767
12947
  _ref = payload, greeting = _ref.greeting, language = _ref.language, _newMetaFields = _ref.metaFields, _sensitiveMetaFields = _ref.sensitiveMetaFields, _ref$resetChatHistory = _ref.resetChatHistory, resetChatHistory = _ref$resetChatHistory === void 0 ? true : _ref$resetChatHistory;
@@ -12815,7 +12995,7 @@ var Container = /*#__PURE__*/function (_Component) {
12815
12995
  }
12816
12996
 
12817
12997
  localChannel.postMessage(RESET_RESPONSE, null, id);
12818
- return _context3.abrupt("break", 89);
12998
+ return _context3.abrupt("break", 91);
12819
12999
 
12820
13000
  case 66:
12821
13001
  _setState3 = this.props.setState;
@@ -12843,23 +13023,32 @@ var Container = /*#__PURE__*/function (_Component) {
12843
13023
  case 75:
12844
13024
  xStorageChannel.postMessage(DELETE_HISTORY_EVENT);
12845
13025
  localChannel.postMessage(DELETE_HISTORY_RESPONSE, null, id);
12846
- return _context3.abrupt("break", 89);
13026
+ return _context3.abrupt("break", 91);
12847
13027
 
12848
13028
  case 78:
12849
13029
  _ref2 = payload, body = _ref2.body, duration = _ref2.duration;
12850
- EXTRA_PROACTIVE_DELAY = 1000; // Free tier campaigns re-use the createProactive infrastructure
13030
+ EXTRA_PROACTIVE_DELAY = 1000;
13031
+
13032
+ if (client) {
13033
+ _context3.next = 82;
13034
+ break;
13035
+ }
13036
+
13037
+ throw new errors/* AdaEmbedError */.S("`client` is not defined");
12851
13038
 
13039
+ case 82:
13040
+ // Free tier campaigns re-use the createProactive infrastructure
12852
13041
  canCreateProactive = client.features.developer_proactive || client.features.afm_proactive_messaging_free_tier;
12853
13042
 
12854
13043
  if (canCreateProactive) {
12855
- _context3.next = 84;
13044
+ _context3.next = 86;
12856
13045
  break;
12857
13046
  }
12858
13047
 
12859
13048
  localChannel.postMessage(CREATE_PROACTIVE_RESPONSE, "Ada Embed - Proactive intros are not available in your feature set.", id, FetchEventStatus.Failure);
12860
13049
  return _context3.abrupt("return");
12861
13050
 
12862
- case 84:
13051
+ case 86:
12863
13052
  this.setState({
12864
13053
  hideIntroOverride: true
12865
13054
  }, /*#__PURE__*/(0,asyncToGenerator/* default */.Z)( /*#__PURE__*/regenerator_default().mark(function _callee() {
@@ -12897,14 +13086,14 @@ var Container = /*#__PURE__*/function (_Component) {
12897
13086
  }
12898
13087
  }, _callee);
12899
13088
  })));
12900
- _context3.next = 87;
13089
+ _context3.next = 89;
12901
13090
  return wait(duration * 1000 + EXTRA_PROACTIVE_DELAY);
12902
13091
 
12903
- case 87:
13092
+ case 89:
12904
13093
  localChannel.postMessage(CREATE_PROACTIVE_RESPONSE, null, id);
12905
- return _context3.abrupt("break", 89);
13094
+ return _context3.abrupt("break", 91);
12906
13095
 
12907
- case 89:
13096
+ case 91:
12908
13097
  case "end":
12909
13098
  return _context3.stop();
12910
13099
  }
@@ -13199,15 +13388,15 @@ var Container = /*#__PURE__*/function (_Component) {
13199
13388
  }, {
13200
13389
  key: "renderIntroFrame",
13201
13390
  value: function renderIntroFrame() {
13202
- var _intro$style;
13391
+ var _client$intro;
13203
13392
 
13204
13393
  var _this$props15 = this.props,
13205
13394
  adaSettings = _this$props15.adaSettings,
13206
- intro = _this$props15.intro;
13395
+ client = _this$props15.client;
13207
13396
  var parentElement = adaSettings.parentElement;
13208
13397
  var hideIntroOverride = this.state.hideIntroOverride;
13209
13398
 
13210
- if (parentElement || (intro === null || intro === void 0 ? void 0 : (_intro$style = intro.style) === null || _intro$style === void 0 ? void 0 : _intro$style.toLocaleLowerCase()) !== "text" || hideIntroOverride || // This avoids intros and campaigns being shown at the same time
13399
+ if (parentElement || (client === null || client === void 0 ? void 0 : (_client$intro = client.intro) === null || _client$intro === void 0 ? void 0 : _client$intro.style.toLocaleLowerCase()) !== "text" || hideIntroOverride || // This avoids intros and campaigns being shown at the same time
13211
13400
  this.shouldRenderChatFrame) {
13212
13401
  return null;
13213
13402
  }
@@ -13328,7 +13517,6 @@ function Container_mapStateToProps(storeState) {
13328
13517
  isChatWebsocketConnected: isChatWebsocketConnected,
13329
13518
  isDrawerOpen: isDrawerOpen,
13330
13519
  chatterToken: chatterToken,
13331
- intro: client === null || client === void 0 ? void 0 : client.intro,
13332
13520
  appConnectionState: appConnectionState,
13333
13521
  drawerHasBeenOpened: drawerHasBeenOpened,
13334
13522
  chatterInLiveChat: chatterInLiveChat,
@@ -13898,7 +14086,7 @@ window.__AdaEmbedConstructor = Embed;
13898
14086
  /* harmony export */ });
13899
14087
  var isModern = new RegExp("((CPU[ +]OS|iPhone[ +]OS|CPU[ +]iPhone|CPU IPhone OS)[ +]+(14|(1[5-9]|[2-9]\\d|\\d{3,}))[_.]\\d+(?:[_.]\\d+)?)|((Chromium|Chrome)\\/(92|(9[3-9]|\\d{3,}))\\.\\d+(?:\\.\\d+)?)|(Version\\/(14|(1[5-9]|[2-9]\\d|\\d{3,}))\\.\\d+(?:\\.\\d+)? Safari\\/)|(Firefox\\/(91|(9[2-9]|\\d{3,}))\\.\\d+\\.\\d+)|(Firefox\\/(91|(9[2-9]|\\d{3,}))\\.\\d+(pre|[ab]\\d+[a-z]*)?)").test(navigator.userAgent);
13900
14088
  var isProduction = "production" === "production";
13901
- var embed2Version = "df9664f";
14089
+ var embed2Version = "921d431";
13902
14090
 
13903
14091
  /***/ }),
13904
14092
 
@@ -14231,9 +14419,9 @@ function _log() {
14231
14419
  service: "embed",
14232
14420
  env: "production",
14233
14421
  embedVersion: 2,
14234
- version: "1.0.47",
14422
+ version: "1.0.52",
14235
14423
  isNpm: true,
14236
- commitHash: "df9664f"
14424
+ commitHash: "921d431"
14237
14425
  }))
14238
14426
  });
14239
14427
 
@@ -14915,6 +15103,16 @@ var parent = __webpack_require__(1910);
14915
15103
  module.exports = parent;
14916
15104
 
14917
15105
 
15106
+ /***/ }),
15107
+
15108
+ /***/ 4710:
15109
+ /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
15110
+
15111
+ var parent = __webpack_require__(9534);
15112
+
15113
+ module.exports = parent;
15114
+
15115
+
14918
15116
  /***/ }),
14919
15117
 
14920
15118
  /***/ 4303:
@@ -14925,6 +15123,16 @@ var parent = __webpack_require__(6507);
14925
15123
  module.exports = parent;
14926
15124
 
14927
15125
 
15126
+ /***/ }),
15127
+
15128
+ /***/ 3799:
15129
+ /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
15130
+
15131
+ var parent = __webpack_require__(3059);
15132
+
15133
+ module.exports = parent;
15134
+
15135
+
14928
15136
  /***/ }),
14929
15137
 
14930
15138
  /***/ 5122:
@@ -23688,7 +23896,7 @@ function _loadEmbed() {
23688
23896
  polyfillVersionString = "legacy";
23689
23897
  }
23690
23898
 
23691
- embedScriptSource = concat_default()(_context16 = concat_default()(_context17 = "".concat(host, "/embed/")).call(_context17, polyfillVersionString, "/client/")).call(_context16, "df9664f", "/index.js");
23899
+ embedScriptSource = concat_default()(_context16 = concat_default()(_context17 = "".concat(host, "/embed/")).call(_context17, polyfillVersionString, "/client/")).call(_context16, "921d431", "/index.js");
23692
23900
  }
23693
23901
 
23694
23902
  clientScriptExists = Boolean( true || // The client script is bundled with npm module
@@ -24226,7 +24434,7 @@ function createEmbedObject() {
24226
24434
  }
24227
24435
  ;// CONCATENATED MODULE: ./src/index-npm.ts
24228
24436
 
24229
- Promise.resolve(/* import() eager */).then(__webpack_require__.bind(__webpack_require__, 7054));
24437
+ Promise.resolve(/* import() eager */).then(__webpack_require__.bind(__webpack_require__, 9136));
24230
24438
  /* harmony default export */ var index_npm = (createEmbedObject());
24231
24439
  }();
24232
24440
  module.exports = __webpack_exports__;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ada-support/embed2",
3
- "version": "1.0.47",
3
+ "version": "1.0.52",
4
4
  "description": "",
5
5
  "main": "dist/npm-entry",
6
6
  "typings": "dist/npm-entry/index.d.ts",
@@ -10,7 +10,7 @@
10
10
  "build:modern": "NODE_ENV=production BROWSERSLIST_ENV=modern npx webpack --config webpack.prod.ts",
11
11
  "build:npm-types": "tsc --project tsconfig.npm.json --declaration --outDir dist/npm-entry --emitDeclarationOnly --allowJs false --checkJs false",
12
12
  "build:npm": "./npm-build.sh",
13
- "lint": "tsc --noEmit --strict false && ./node_modules/.bin/eslint --report-unused-disable-directives --ext .js,.jsx,.ts,.tsx . --max-warnings 109",
13
+ "lint": "tsc --noEmit --strict false && ./node_modules/.bin/eslint --report-unused-disable-directives --ext .js,.jsx,.ts,.tsx . --max-warnings 86",
14
14
  "lint:fix": "yarn lint --fix",
15
15
  "deploy-legacy": "TS_NODE_PROJECT=wp.tsconfig.json NODE_ENV=production BROWSERSLIST_ENV=legacy npx webpack --config webpack.prod.ts",
16
16
  "deploy-modern": "TS_NODE_PROJECT=wp.tsconfig.json NODE_ENV=production BROWSERSLIST_ENV=modern npx webpack --config webpack.prod.ts",
@@ -68,7 +68,7 @@
68
68
  "@types/node": "^16.7.1",
69
69
  "@types/webpack": "^5.28.0",
70
70
  "@types/webpack-bundle-analyzer": "^4.4.1",
71
- "@types/webpack-dev-server": "^4.0.0",
71
+ "@types/webpack-dev-server": "^4.7.2",
72
72
  "babel-loader": "^8.0.6",
73
73
  "babel-preset-preact": "^2.0.0",
74
74
  "browserslist": "^4.17.4",