@xapp/chat-widget 1.97.0 → 1.98.0

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.js CHANGED
@@ -321,13 +321,14 @@ const color_1 = color;
321
321
  /** Fallback when a crawl found no branding. Deliberately neutral. */
322
322
  const DEFAULT_PRIMARY = "#1AA7DC";
323
323
  function buildChatWidgetChannel(props) {
324
+ var _a;
324
325
  const { appId, apiUrl, mcpUrl, formWidgetKey, phoneNumber } = props;
326
+ const businessName = (_a = props.businessName) === null || _a === void 0 ? void 0 : _a.trim();
325
327
  // Only a colour whose contrast can actually be computed, so the background
326
328
  // and the text on it are always a matched pair rather than one scraped
327
329
  // value and one guess.
328
330
  const primaryColor = (0, color_1.usableColorOr)(props.primaryColor, DEFAULT_PRIMARY);
329
- return {
330
- type: "chat-widget",
331
+ return Object.assign({ type: "chat-widget",
331
332
  // MCP by default. The widget runs on a public page, so homeowner mode
332
333
  // — which is unauthenticated and carries the appId in the url — is the
333
334
  // only one that can work there; business_owner needs a token, and a
@@ -338,10 +339,7 @@ function buildChatWidgetChannel(props) {
338
339
  mcp: {
339
340
  mode: "homeowner"
340
341
  }
341
- },
342
- theme: buildChatTheme(primaryColor, props.secondaryColor),
343
- actionBar: buildActionBar({ apiUrl, formWidgetKey, phoneNumber })
344
- };
342
+ }, theme: buildChatTheme(primaryColor, props.secondaryColor), actionBar: buildActionBar({ apiUrl, formWidgetKey, phoneNumber }) }, (businessName ? { botName: businessName } : {}));
345
343
  }
346
344
  /**
347
345
  * The dock of buttons that replaces the plain chat bubble.
@@ -1135,15 +1133,15 @@ PERFORMANCE OF THIS SOFTWARE.
1135
1133
  /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
1136
1134
 
1137
1135
 
1138
- var __assign = function() {
1139
- __assign = Object.assign || function __assign(t) {
1136
+ var __assign$1 = function() {
1137
+ __assign$1 = Object.assign || function __assign(t) {
1140
1138
  for (var s, i = 1, n = arguments.length; i < n; i++) {
1141
1139
  s = arguments[i];
1142
1140
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
1143
1141
  }
1144
1142
  return t;
1145
1143
  };
1146
- return __assign.apply(this, arguments);
1144
+ return __assign$1.apply(this, arguments);
1147
1145
  };
1148
1146
 
1149
1147
  function __rest(s, e) {
@@ -1720,7 +1718,7 @@ function useServerConfig(env, nonce) {
1720
1718
  */
1721
1719
  function foldChannelId(mcp, channelId) {
1722
1720
  var _a;
1723
- return mcp ? __assign(__assign({}, mcp), { channelId: (_a = mcp.channelId) !== null && _a !== void 0 ? _a : channelId }) : mcp;
1721
+ return mcp ? __assign$1(__assign$1({}, mcp), { channelId: (_a = mcp.channelId) !== null && _a !== void 0 ? _a : channelId }) : mcp;
1724
1722
  }
1725
1723
  function useConnectionInfo(env) {
1726
1724
  var nonce = reactRedux.useSelector(function (state) { return state.connection.nonce; });
@@ -2430,9 +2428,9 @@ function executeAction(text, meta) {
2430
2428
  return function (chatServer) { return function (dispatch, getState) {
2431
2429
  // add in attributes from meta
2432
2430
  var attributes = getState().attributes;
2433
- attributes = __assign(__assign({}, attributes), { currentUrl: window.location.href });
2431
+ attributes = __assign$1(__assign$1({}, attributes), { currentUrl: window.location.href });
2434
2432
  var _a = meta || {}, token = _a.token, rest = __rest(_a, ["token"]);
2435
- attributes = __assign(__assign({}, attributes), rest);
2433
+ attributes = __assign$1(__assign$1({}, attributes), rest);
2436
2434
  // Add user message to Redux BEFORE sending to server
2437
2435
  // to ensure it appears above the bot's streaming response
2438
2436
  var visitor = getState().visitor;
@@ -3089,6 +3087,17 @@ PERFORMANCE OF THIS SOFTWARE.
3089
3087
  /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
3090
3088
 
3091
3089
 
3090
+ var __assign = function() {
3091
+ __assign = Object.assign || function __assign(t) {
3092
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
3093
+ s = arguments[i];
3094
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
3095
+ }
3096
+ return t;
3097
+ };
3098
+ return __assign.apply(this, arguments);
3099
+ };
3100
+
3092
3101
  function __awaiter(thisArg, _arguments, P, generator) {
3093
3102
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3094
3103
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -3322,6 +3331,162 @@ function useSuggestionsFetch$1(options) {
3322
3331
  return response;
3323
3332
  }
3324
3333
 
3334
+ /**
3335
+ * Marketing attribution capture, shared by every widget surface.
3336
+ *
3337
+ * The chat widget historically sent only `currentUrl`, which meant attribution
3338
+ * survived only when the visitor opened the chat on the very page the ad landed
3339
+ * them on. Anyone who browsed first arrived unattributed. These helpers capture
3340
+ * the parameters on first sight and persist them, so a conversation started three
3341
+ * pages later still carries the click that paid for it.
3342
+ *
3343
+ * Only the parameters below are ever read or stored. The query string as a whole
3344
+ * is not, because it routinely carries session tokens and PII.
3345
+ */
3346
+ /** Standard UTM parameters. */
3347
+ var UTM_PARAMETERS = [
3348
+ "utm_source",
3349
+ "utm_medium",
3350
+ "utm_campaign",
3351
+ "utm_term",
3352
+ "utm_content"
3353
+ ];
3354
+ /**
3355
+ * Platform click ids.
3356
+ *
3357
+ * `gbraid` and `wbraid` are what Google substitutes for `gclid` when the click
3358
+ * cannot be tied to a cookie — iOS and consent-mode traffic. For home services,
3359
+ * where most paid traffic is mobile, omitting them loses attribution on the
3360
+ * majority of the spend.
3361
+ */
3362
+ var CLICK_ID_PARAMETERS = [
3363
+ "gclid",
3364
+ "gbraid",
3365
+ "wbraid",
3366
+ "msclkid",
3367
+ "fbclid"
3368
+ ];
3369
+ var ATTRIBUTION_PARAMETERS = __spreadArray(__spreadArray([], UTM_PARAMETERS, true), CLICK_ID_PARAMETERS);
3370
+ var STORAGE_KEY_PREFIX = "xa_tracking_";
3371
+ /** Matches the 30 day window the form widget already uses. */
3372
+ var DEFAULT_PERSISTENCE_DAYS = 30;
3373
+ var MAX_VALUE_LENGTH = 255;
3374
+ /**
3375
+ * Values land in a request body and, downstream, in a CRM. Cap the length and
3376
+ * reject anything carrying markup or control characters.
3377
+ */
3378
+ function isValidValue(value) {
3379
+ // eslint-disable-next-line no-control-regex
3380
+ return value.length <= MAX_VALUE_LENGTH && !/[<>"'\x00-\x1f]/.test(value);
3381
+ }
3382
+ /**
3383
+ * Reads the attribution parameters present on a URL. Never throws — a URL we
3384
+ * cannot parse simply contributes nothing.
3385
+ */
3386
+ function extractAttributionFromUrl(url) {
3387
+ var parsed;
3388
+ try {
3389
+ parsed = new URL(url);
3390
+ }
3391
+ catch (_a) {
3392
+ return {};
3393
+ }
3394
+ var attribution = {};
3395
+ ATTRIBUTION_PARAMETERS.forEach(function (parameter) {
3396
+ var value = parsed.searchParams.get(parameter);
3397
+ if (value && isValidValue(value)) {
3398
+ attribution[parameter] = value;
3399
+ }
3400
+ });
3401
+ return attribution;
3402
+ }
3403
+ /**
3404
+ * Persists attribution for later conversations. Existing values are overwritten,
3405
+ * so the most recent click wins, matching how the ad platforms attribute.
3406
+ */
3407
+ function storeAttribution(attribution, persistenceDays) {
3408
+ if (persistenceDays === void 0) { persistenceDays = DEFAULT_PERSISTENCE_DAYS; }
3409
+ var expires = Date.now() + persistenceDays * 24 * 60 * 60 * 1000;
3410
+ Object.entries(attribution).forEach(function (_a) {
3411
+ var key = _a[0], value = _a[1];
3412
+ if (!value) {
3413
+ return;
3414
+ }
3415
+ try {
3416
+ localStorage.setItem("".concat(STORAGE_KEY_PREFIX).concat(key), JSON.stringify({ value: value, expires: expires }));
3417
+ }
3418
+ catch (_b) {
3419
+ // Storage can be full or blocked by the browser. Attribution is best
3420
+ // effort — never let it break the conversation.
3421
+ }
3422
+ });
3423
+ }
3424
+ /** Reads back unexpired stored attribution, cleaning up anything unreadable. */
3425
+ function getStoredAttribution() {
3426
+ var attribution = {};
3427
+ ATTRIBUTION_PARAMETERS.forEach(function (parameter) {
3428
+ var key = "".concat(STORAGE_KEY_PREFIX).concat(parameter);
3429
+ var stored;
3430
+ try {
3431
+ stored = localStorage.getItem(key);
3432
+ }
3433
+ catch (_a) {
3434
+ return;
3435
+ }
3436
+ if (!stored) {
3437
+ return;
3438
+ }
3439
+ try {
3440
+ var parsed = JSON.parse(stored);
3441
+ if (parsed && parsed.expires > Date.now() && typeof parsed.value === "string") {
3442
+ attribution[parameter] = parsed.value;
3443
+ }
3444
+ else {
3445
+ localStorage.removeItem(key);
3446
+ }
3447
+ }
3448
+ catch (_b) {
3449
+ localStorage.removeItem(key);
3450
+ }
3451
+ });
3452
+ return attribution;
3453
+ }
3454
+ /**
3455
+ * The attribution to send with a request: whatever is stored, with anything on
3456
+ * the current URL layered on top, and the current URL's values persisted for
3457
+ * subsequent pages.
3458
+ */
3459
+ function getAttribution(url) {
3460
+ if (url === void 0) { url = window.location.href; }
3461
+ var fromUrl = extractAttributionFromUrl(url);
3462
+ if (Object.keys(fromUrl).length > 0) {
3463
+ storeAttribution(fromUrl);
3464
+ }
3465
+ return __assign(__assign({}, getStoredAttribution()), fromUrl);
3466
+ }
3467
+ /**
3468
+ * Strips the query string from a URL, leaving origin + pathname.
3469
+ *
3470
+ * Referrers and page URLs routinely carry session tokens, email addresses and other
3471
+ * PII in their query strings, and a referrer captured at session start is sent with
3472
+ * every subsequent message — so the raw value must never be stored. Attribution is
3473
+ * read separately, by allowlist, before this is applied.
3474
+ *
3475
+ * Returns undefined for an empty or unparseable URL rather than passing it through.
3476
+ */
3477
+ function stripQueryString(url) {
3478
+ if (!url) {
3479
+ return undefined;
3480
+ }
3481
+ try {
3482
+ var parsed = new URL(url);
3483
+ return parsed.origin + parsed.pathname;
3484
+ }
3485
+ catch (_a) {
3486
+ return undefined;
3487
+ }
3488
+ }
3489
+
3325
3490
  /**
3326
3491
  * Stop the host page scrolling behind an open overlay.
3327
3492
  *
@@ -3603,13 +3768,14 @@ function uuid() {
3603
3768
  });
3604
3769
  return newUuid;
3605
3770
  }
3606
-
3607
3771
  var IconButton_1 = IconButton;
3608
3772
  var RichInput_1 = RichInput;
3609
3773
  var SuggestionsList_1 = SuggestionsList;
3610
3774
  var findItemByIndex_1 = findItemByIndex;
3775
+ var getAttribution_1 = getAttribution;
3611
3776
  var getItemsLength_1 = getItemsLength;
3612
3777
  var parseSuggestionsResponse_1 = parseSuggestionsResponse;
3778
+ var stripQueryString_1 = stripQueryString;
3613
3779
  var useBodyScrollLock_1 = useBodyScrollLock;
3614
3780
  var useSuggestionsFetch_1 = useSuggestionsFetch$1;
3615
3781
  var useVisualViewportProperties_1 = useVisualViewportProperties;
@@ -4067,7 +4233,19 @@ function getLocalISOString(date) {
4067
4233
  * PRIVACY NOTE: Query strings are stripped from URLs by default as they
4068
4234
  * may contain sensitive data (tokens, PII). Only origin + pathname are sent.
4069
4235
  */
4236
+ /**
4237
+ * Reads attribution for the current page, or undefined when there is none or there is
4238
+ * no browser to read it from.
4239
+ */
4240
+ function collectAttribution() {
4241
+ if (typeof window === "undefined") {
4242
+ return undefined;
4243
+ }
4244
+ var attribution = getAttribution_1(window.location.href);
4245
+ return Object.keys(attribution).length > 0 ? attribution : undefined;
4246
+ }
4070
4247
  function getPageContext(override) {
4248
+ var _a;
4071
4249
  var localTime = getLocalISOString();
4072
4250
  // If override provided, merge with defaults (override wins)
4073
4251
  // Overrides are typically for testing and may include full URLs
@@ -4078,6 +4256,14 @@ function getPageContext(override) {
4078
4256
  path: override.path,
4079
4257
  title: override.title,
4080
4258
  referrer: override.referrer,
4259
+ // Never skip attribution just because the page context was overridden.
4260
+ // The public knob is WidgetEnv.mcp.pageContextOverride, typed
4261
+ // PageContextOverride -- url/path/title/referrer, with no attribution
4262
+ // field -- and an SPA integrator sets it on every virtual route change.
4263
+ // Taking override.attribution alone would therefore be undefined for every
4264
+ // real caller, silently disabling attribution on the MCP path for exactly
4265
+ // the browse-then-chat case this exists to capture.
4266
+ attribution: (_a = override.attribution) !== null && _a !== void 0 ? _a : collectAttribution(),
4081
4267
  localTime: localTime,
4082
4268
  };
4083
4269
  }
@@ -4086,23 +4272,18 @@ function getPageContext(override) {
4086
4272
  }
4087
4273
  // Strip query strings from URL for privacy (may contain tokens/PII)
4088
4274
  var urlWithoutQuery = window.location.origin + window.location.pathname;
4089
- // Strip query strings from referrer as well
4090
- var referrerWithoutQuery;
4091
- if (document.referrer) {
4092
- try {
4093
- var refUrl = new URL(document.referrer);
4094
- referrerWithoutQuery = refUrl.origin + refUrl.pathname;
4095
- }
4096
- catch (_a) {
4097
- // Invalid referrer URL, skip it
4098
- referrerWithoutQuery = undefined;
4099
- }
4100
- }
4275
+ // Strip query strings from referrer as well -- shared with StentorDirectChat so the
4276
+ // two chat paths cannot disagree about what is safe to send.
4277
+ var referrerWithoutQuery = stripQueryString_1(document.referrer);
4278
+ // Pull the attribution parameters out BEFORE the query string is discarded.
4279
+ // Only the known utm_* and click id keys are read; everything else in the
4280
+ // query string stays stripped, so the privacy posture above is unchanged.
4101
4281
  return {
4102
4282
  url: urlWithoutQuery,
4103
4283
  path: window.location.pathname,
4104
4284
  title: document.title || undefined,
4105
4285
  referrer: referrerWithoutQuery,
4286
+ attribution: collectAttribution(),
4106
4287
  localTime: localTime,
4107
4288
  };
4108
4289
  }
@@ -4234,7 +4415,7 @@ var MCPChat = /** @class */ (function () {
4234
4415
  */
4235
4416
  MCPChat.prototype.buildRequestPayload = function (additionalData) {
4236
4417
  if (additionalData === void 0) { additionalData = {}; }
4237
- return __assign(__assign({
4418
+ return __assign$1(__assign$1({
4238
4419
  // Identity - server generates these, we just send back what we have
4239
4420
  userId: this._userId || undefined, sessionId: this._sessionId || undefined,
4240
4421
  // Fingerprint for user identification (can be disabled for privacy)
@@ -4697,12 +4878,12 @@ var MCPChat = /** @class */ (function () {
4697
4878
  if (!user) {
4698
4879
  // Ensure bot nick has agent: prefix and mark as AI
4699
4880
  var defaultBot = bot || { nick: "agent:robot", displayName: "Assistant" };
4700
- return __assign(__assign({}, defaultBot), { nick: this.ensureAgentNick(defaultBot.nick), isAI: true });
4881
+ return __assign$1(__assign$1({}, defaultBot), { nick: this.ensureAgentNick(defaultBot.nick), isAI: true });
4701
4882
  }
4702
4883
  if (user.displayName && user.nick && user.avatarPath) {
4703
- return __assign(__assign({}, user), { nick: this.ensureAgentNick(user.nick), isAI: true });
4884
+ return __assign$1(__assign$1({}, user), { nick: this.ensureAgentNick(user.nick), isAI: true });
4704
4885
  }
4705
- return __assign(__assign({}, user), { nick: this.ensureAgentNick(user.nick || (bot === null || bot === void 0 ? void 0 : bot.nick)), displayName: user.displayName || (bot === null || bot === void 0 ? void 0 : bot.displayName) || "Assistant", avatarPath: user.avatarPath || (bot === null || bot === void 0 ? void 0 : bot.avatarPath), isAI: true });
4886
+ return __assign$1(__assign$1({}, user), { nick: this.ensureAgentNick(user.nick || (bot === null || bot === void 0 ? void 0 : bot.nick)), displayName: user.displayName || (bot === null || bot === void 0 ? void 0 : bot.displayName) || "Assistant", avatarPath: user.avatarPath || (bot === null || bot === void 0 ? void 0 : bot.avatarPath), isAI: true });
4706
4887
  };
4707
4888
  MCPChat.prototype.sendChatMsgRequest = function (serviceRequest, cb) {
4708
4889
  return __awaiter$1(this, void 0, void 0, function () {
@@ -4884,7 +5065,7 @@ var MCPChat = /** @class */ (function () {
4884
5065
  // WARNING: Do not log headers object - it contains sensitive auth tokens
4885
5066
  cjs.fetchEventSource(endpoint, {
4886
5067
  method: "POST",
4887
- headers: __assign({ "Content-Type": "application/json" }, ((_this.config.mode || "homeowner") === "business_owner" && _this.config.authToken
5068
+ headers: __assign$1({ "Content-Type": "application/json" }, ((_this.config.mode || "homeowner") === "business_owner" && _this.config.authToken
4888
5069
  ? { Authorization: "Bearer ".concat(_this.config.authToken) }
4889
5070
  : {})),
4890
5071
  body: JSON.stringify(body),
@@ -5185,7 +5366,7 @@ var MCPChat = /** @class */ (function () {
5185
5366
  MCPChat.prototype.sendTyping = function () { };
5186
5367
  MCPChat.prototype.setVisitorInfo = function (visitorInfo, sessionId, cb) {
5187
5368
  this.visitorInfo = visitorInfo;
5188
- this._attributes = __assign({}, this.visitorInfo.attributes);
5369
+ this._attributes = __assign$1({}, this.visitorInfo.attributes);
5189
5370
  // do not set currentUrl if localhost
5190
5371
  var href = new URL(window.location.href);
5191
5372
  if (href === null || href === void 0 ? void 0 : href.host.toLowerCase().startsWith("localhost")) {
@@ -5425,6 +5606,35 @@ var MCPChat = /** @class */ (function () {
5425
5606
  return MCPChat;
5426
5607
  }());
5427
5608
 
5609
+ /**
5610
+ * Builds the attribute set for one outgoing message.
5611
+ *
5612
+ * Returns a **fresh object every call**. That is the point of this function, not an
5613
+ * incidental detail: the chat server's `_attributes` is a single object that lives for
5614
+ * the whole conversation, so writing attribution into it directly means the first value
5615
+ * seen is the value sent forever. A visitor who navigates within an SPA to a page with a
5616
+ * different `gclid` would keep sending the original one, which contradicts the
5617
+ * most-recent-click-wins behaviour `attribution.ts` documents and the ad platforms
5618
+ * assume.
5619
+ *
5620
+ * Precedence: whatever the host page set explicitly wins, because that was deliberate.
5621
+ * Everything else comes from the current attribution read.
5622
+ *
5623
+ * @param hostAttributes attributes the host page set at session start
5624
+ * @param attribution the attribution resolved for this message
5625
+ */
5626
+ function mergeAttribution(hostAttributes, attribution) {
5627
+ var host = hostAttributes || {};
5628
+ var merged = __assign$1({}, attribution);
5629
+ for (var _i = 0, _a = Object.entries(host); _i < _a.length; _i++) {
5630
+ var _b = _a[_i], key = _b[0], value = _b[1];
5631
+ if (value !== undefined) {
5632
+ merged[key] = value;
5633
+ }
5634
+ }
5635
+ return merged;
5636
+ }
5637
+
5428
5638
  /**
5429
5639
  * Sends a POST to your STENTOR based server.
5430
5640
  *
@@ -5601,10 +5811,10 @@ function responseToMessage(botResponse, now) {
5601
5811
  user: undefined
5602
5812
  };
5603
5813
  if (text && !html) {
5604
- responseMessage.msg = __assign(__assign({}, responseMessage.msg), { text: text });
5814
+ responseMessage.msg = __assign$1(__assign$1({}, responseMessage.msg), { text: text });
5605
5815
  }
5606
5816
  if (html) {
5607
- responseMessage.msg = __assign(__assign({}, responseMessage.msg), { html: html });
5817
+ responseMessage.msg = __assign$1(__assign$1({}, responseMessage.msg), { html: html });
5608
5818
  }
5609
5819
  if ((_e = outputSpeech === null || outputSpeech === void 0 ? void 0 : outputSpeech.suggestions) === null || _e === void 0 ? void 0 : _e.length) {
5610
5820
  responseMessage.msg.options = outputSpeech.suggestions.map(function (suggestion) {
@@ -5700,7 +5910,7 @@ var StentorDirectChat = /** @class */ (function () {
5700
5910
  type: "chat",
5701
5911
  detail: {
5702
5912
  type: "chat.msg",
5703
- user: __assign(__assign({}, data.user), { nick: "agent:robot" }),
5913
+ user: __assign$1(__assign$1({}, data.user), { nick: "agent:robot" }),
5704
5914
  msg: data.msg,
5705
5915
  timestamp: +new Date(),
5706
5916
  },
@@ -5712,7 +5922,7 @@ var StentorDirectChat = /** @class */ (function () {
5712
5922
  type: "chat",
5713
5923
  detail: {
5714
5924
  type: "chat.memberjoin",
5715
- user: __assign(__assign({}, data.user), { nick: "agent:robot" }),
5925
+ user: __assign$1(__assign$1({}, data.user), { nick: "agent:robot" }),
5716
5926
  timestamp: +new Date(),
5717
5927
  },
5718
5928
  });
@@ -5827,7 +6037,7 @@ var StentorDirectChat = /** @class */ (function () {
5827
6037
  if (user.displayName && user.nick && user.avatarPath) {
5828
6038
  return user;
5829
6039
  }
5830
- return __assign(__assign({}, user), { nick: user.nick || bot.nick || "Bot", displayName: user.displayName || bot.displayName || "Bot", avatarPath: user.avatarPath || bot.avatarPath });
6040
+ return __assign$1(__assign$1({}, user), { nick: user.nick || bot.nick || "Bot", displayName: user.displayName || bot.displayName || "Bot", avatarPath: user.avatarPath || bot.avatarPath });
5831
6041
  };
5832
6042
  StentorDirectChat.prototype.sendChatMsgRequest = function (serviceRequest, cb) {
5833
6043
  return __awaiter$1(this, void 0, void 0, function () {
@@ -5839,7 +6049,7 @@ var StentorDirectChat = /** @class */ (function () {
5839
6049
  case 1:
5840
6050
  agentResponse = _b.sent();
5841
6051
  if (!((_a = agentResponse.user) === null || _a === void 0 ? void 0 : _a.displayName)) {
5842
- agentResponse = __assign(__assign({}, agentResponse), { user: this.getBot(agentResponse.user) });
6052
+ agentResponse = __assign$1(__assign$1({}, agentResponse), { user: this.getBot(agentResponse.user) });
5843
6053
  }
5844
6054
  this.sendNewMessage(agentResponse);
5845
6055
  cb();
@@ -5851,7 +6061,7 @@ var StentorDirectChat = /** @class */ (function () {
5851
6061
  StentorDirectChat.prototype.sendTyping = function () { };
5852
6062
  StentorDirectChat.prototype.setVisitorInfo = function (visitorInfo, sessionId, cb) {
5853
6063
  this.visitorInfo = visitorInfo;
5854
- this._attributes = __assign({}, this.visitorInfo.attributes);
6064
+ this._attributes = __assign$1({}, this.visitorInfo.attributes);
5855
6065
  // do not set currentUrl if localhost, localhost is not liked by some firewalls, like AWS WAF
5856
6066
  var href = new URL(window.location.href);
5857
6067
  if (href === null || href === void 0 ? void 0 : href.host.toLowerCase().startsWith("localhost")) {
@@ -5862,6 +6072,18 @@ var StentorDirectChat = /** @class */ (function () {
5862
6072
  // not localhost, set it
5863
6073
  this._attributes.currentUrl = window.location.href;
5864
6074
  }
6075
+ // The page the visitor arrived FROM, which is a separate attribution signal
6076
+ // from currentUrl — the page they arrived ON.
6077
+ //
6078
+ // Stored WITHOUT its query string. A referrer captured here lives in
6079
+ // _attributes for the whole conversation and is sent with every message, and
6080
+ // referrer query strings routinely carry session tokens and email addresses.
6081
+ // The attribution parameters are read separately, by allowlist, so nothing of
6082
+ // value is lost by dropping the rest.
6083
+ var referrer = stripQueryString_1(document.referrer);
6084
+ if (referrer) {
6085
+ this._attributes.referrer = referrer;
6086
+ }
5865
6087
  this._accessToken = this.visitorInfo.accessToken;
5866
6088
  // This is for the bot
5867
6089
  this.userJoined({
@@ -5893,7 +6115,7 @@ var StentorDirectChat = /** @class */ (function () {
5893
6115
  userId = this._userId;
5894
6116
  sessionId = this._sessionId;
5895
6117
  accessToken = this._accessToken;
5896
- attributes = this._attributes || {};
6118
+ attributes = mergeAttribution(this._attributes, getAttribution_1());
5897
6119
  rwgToken = localStorage.getItem("xa_rwg_token");
5898
6120
  if (rwgToken) {
5899
6121
  attributes["rwg_token"] = rwgToken;
@@ -5938,7 +6160,7 @@ var StentorDirectChat = /** @class */ (function () {
5938
6160
  else {
5939
6161
  permissionRequest = (_c = message.msg) === null || _c === void 0 ? void 0 : _c.permissionRequest;
5940
6162
  if (permissionRequest) {
5941
- message = __assign(__assign({}, message), { msg: __assign(__assign({}, message.msg), { permissionRequest: undefined }) });
6163
+ message = __assign$1(__assign$1({}, message), { msg: __assign$1(__assign$1({}, message.msg), { permissionRequest: undefined }) });
5942
6164
  expired = now - permissionRequest.time > PERMISSION_QUESTION_EXPIRATION_MS$1;
5943
6165
  text = (_d = message.msg.text) === null || _d === void 0 ? void 0 : _d.toLowerCase();
5944
6166
  granted = !expired;
@@ -5979,7 +6201,7 @@ var StentorDirectChat = /** @class */ (function () {
5979
6201
  };
5980
6202
  }
5981
6203
  else if (message.type === "custom") {
5982
- request = __assign(__assign({}, JSON.parse(message.payload)), {
6204
+ request = __assign$1(__assign$1({}, JSON.parse(message.payload)), {
5983
6205
  // token: message.msg.token,
5984
6206
  sessionId: this._sessionId, userId: this._userId, isNewSession: false,
5985
6207
  // intentId: "OptionSelect",
@@ -6210,7 +6432,7 @@ function requestFromMessage(message, userId, isNewSession, sessionId, accessToke
6210
6432
  // Pending permission request?
6211
6433
  var permissionRequest = (_c = message.msg) === null || _c === void 0 ? void 0 : _c.permissionRequest;
6212
6434
  if (permissionRequest) {
6213
- message = __assign(__assign({}, message), { msg: __assign(__assign({}, message.msg), { permissionRequest: undefined }) });
6435
+ message = __assign$1(__assign$1({}, message), { msg: __assign$1(__assign$1({}, message.msg), { permissionRequest: undefined }) });
6214
6436
  var expired = now - permissionRequest.time > PERMISSION_QUESTION_EXPIRATION_MS;
6215
6437
  var text = (_d = message.msg.text) === null || _d === void 0 ? void 0 : _d.toLowerCase();
6216
6438
  var granted = !expired;
@@ -6249,7 +6471,7 @@ function requestFromMessage(message, userId, isNewSession, sessionId, accessToke
6249
6471
  };
6250
6472
  }
6251
6473
  else if (message.type === "custom") {
6252
- request = __assign(__assign({}, JSON.parse(message.payload)), {
6474
+ request = __assign$1(__assign$1({}, JSON.parse(message.payload)), {
6253
6475
  // token: message.msg.token,
6254
6476
  sessionId: sessionId, userId: userId, isNewSession: false,
6255
6477
  // intentId: "OptionSelect",
@@ -6285,7 +6507,7 @@ function requestFromMessage(message, userId, isNewSession, sessionId, accessToke
6285
6507
  }
6286
6508
  }
6287
6509
  if ((_e = message.msg) === null || _e === void 0 ? void 0 : _e.attributes) {
6288
- request.attributes = __assign(__assign({}, request.attributes), message.msg.attributes);
6510
+ request.attributes = __assign$1(__assign$1({}, request.attributes), message.msg.attributes);
6289
6511
  }
6290
6512
  return request;
6291
6513
  }
@@ -6447,7 +6669,7 @@ var StentorRouterChat = /** @class */ (function () {
6447
6669
  var response = data;
6448
6670
  // Extract router-managed attributes from message root (adjacent to event, data, sender, etc.)
6449
6671
  if (attributes && typeof attributes === "object" && Object.keys(attributes).length > 0) {
6450
- _this.routerAttributes = __assign({}, attributes);
6672
+ _this.routerAttributes = __assign$1({}, attributes);
6451
6673
  log("Extracted router attributes: ".concat(JSON.stringify(_this.routerAttributes)));
6452
6674
  }
6453
6675
  if (typeof ((_a = _this.options.hooks) === null || _a === void 0 ? void 0 : _a.onResponse) === "function") {
@@ -6954,7 +7176,7 @@ var StentorRouterChat = /** @class */ (function () {
6954
7176
  isAdmin: this.isAdmin,
6955
7177
  urlAttributes: this.urlAttributes,
6956
7178
  };
6957
- this.attributes = __assign(__assign(__assign({}, visitorInfoMessage.attributes), this.attributes), { currentUrl: window.location.href });
7179
+ this.attributes = __assign$1(__assign$1(__assign$1({}, visitorInfoMessage.attributes), this.attributes), { currentUrl: window.location.href });
6958
7180
  this.accessToken = visitorInfoMessage.accessToken;
6959
7181
  this.startSession(sessionId);
6960
7182
  this.postVisitorInfo(); // we, the widget, joined the server
@@ -12210,7 +12432,7 @@ var MultiSelect = function (props) {
12210
12432
  var handleToggle = React.useCallback(function (ev) {
12211
12433
  var _a;
12212
12434
  var id = ev.target.value;
12213
- onChange(__assign(__assign({}, checked), (_a = {}, _a[id] = !checked[id], _a)));
12435
+ onChange(__assign$1(__assign$1({}, checked), (_a = {}, _a[id] = !checked[id], _a)));
12214
12436
  }, [checked, onChange]);
12215
12437
  return (require$$0.jsx("ul", { className: "xappw-multiselect", children: items === null || items === void 0 ? void 0 : items.map(function (item) { return (require$$0.jsx("li", { children: require$$0.jsxs("label", { children: [require$$0.jsx("input", { type: "checkbox", checked: checked[item.id] || false, onChange: handleToggle, value: item.id }), require$$0.jsx("span", { children: item.title })] }) }, item.id)); }) }));
12216
12438
  };
@@ -12926,7 +13148,7 @@ function useGreeting(active) {
12926
13148
  visitorId: curr.visitorId,
12927
13149
  userId: curr.userId,
12928
13150
  accessToken: curr.accessToken,
12929
- attributes: __assign(__assign({}, curr.attributes), { currentUrl: window.location.href })
13151
+ attributes: __assign$1(__assign$1({}, curr.attributes), { currentUrl: window.location.href })
12930
13152
  }, sessionId));
12931
13153
  if (!isAdmin) {
12932
13154
  var timeoutId_1 = setTimeout(function () {
@@ -34758,7 +34980,7 @@ function dateTimeToSpeech(value, type) {
34758
34980
  // If it is a time only, we need to just add the
34759
34981
  // current date for parsing. It won't be spoken
34760
34982
  // back to the user, just for parsing.
34761
- var toParse = __assign({}, value);
34983
+ var toParse = __assign$1({}, value);
34762
34984
  if (!toParse.date) {
34763
34985
  toParse.date = ("yyyy-MM-dd");
34764
34986
  }
@@ -35295,7 +35517,7 @@ var MessageList = function (_a) {
35295
35517
  case "chat.msg":
35296
35518
  return (require$$0.jsx(ChatMessage, { message: msg, sibling: sibling, agent: user, messageMiddleware: messageMiddleware, middlewareContext: ctxCache.resolve(user), minimizeOnClick: minimizeOnClick }, "cm-".concat(msg.type, "-").concat(msg.timestamp)));
35297
35519
  case "chat.failureMsg":
35298
- return (require$$0.jsx(FailureMessage, __assign({ agents: agents, time: time }, msg.failureMsg), "fm-".concat(msg.type, "-").concat(msg.timestamp)));
35520
+ return (require$$0.jsx(FailureMessage, __assign$1({ agents: agents, time: time }, msg.failureMsg), "fm-".concat(msg.type, "-").concat(msg.timestamp)));
35299
35521
  case "chat.memberjoin":
35300
35522
  case "chat.memberleave":
35301
35523
  case "chat.systemmessage":
@@ -35835,11 +36057,11 @@ var ErrorOverlay = function (_a) {
35835
36057
  if (lastError && lastError.message === error.message) {
35836
36058
  // Update count of last error
35837
36059
  return __spreadArray$1(__spreadArray$1([], prev.slice(0, -1), true), [
35838
- __assign(__assign({}, lastError), { count: lastError.count + 1, timestamp: timestamp }),
36060
+ __assign$1(__assign$1({}, lastError), { count: lastError.count + 1, timestamp: timestamp }),
35839
36061
  ], false);
35840
36062
  }
35841
36063
  // Add new error
35842
- var newError = __assign({ id: "".concat(timestamp, "-").concat(Math.random()), timestamp: timestamp, count: 1 }, error);
36064
+ var newError = __assign$1({ id: "".concat(timestamp, "-").concat(Math.random()), timestamp: timestamp, count: 1 }, error);
35843
36065
  // Keep only last 50 errors
35844
36066
  var updated = __spreadArray$1(__spreadArray$1([], prev, true), [newError], false);
35845
36067
  return updated.slice(-50);
@@ -36066,7 +36288,7 @@ function createDefaultState(state, options) {
36066
36288
  debugMode = true;
36067
36289
  }
36068
36290
  }
36069
- return __assign({ connection: {
36291
+ return __assign$1({ connection: {
36070
36292
  connectionStatus: "offline",
36071
36293
  token: null,
36072
36294
  greetingRequested: false
@@ -36081,7 +36303,7 @@ function createStateFromMessages(messages) {
36081
36303
  var lastMessage = messages.length > 0 ? messages[messages.length - 1] : undefined;
36082
36304
  var lastMsg = (lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.type) === "chat.msg" ? lastMessage.msg : null;
36083
36305
  var chips = ((_a = lastMsg === null || lastMsg === void 0 ? void 0 : lastMsg.options) === null || _a === void 0 ? void 0 : _a.length) ? lastMsg.options : [];
36084
- return __assign(__assign({}, def), { connection: __assign(__assign({}, def.connection), { connectionStatus: "online" }), accountStatus: "online", chats: __spreadArray$1([], messages, true), chips: chips, isChatting: true, visuals: {
36306
+ return __assign$1(__assign$1({}, def), { connection: __assign$1(__assign$1({}, def.connection), { connectionStatus: "online" }), accountStatus: "online", chats: __spreadArray$1([], messages, true), chips: chips, isChatting: true, visuals: {
36085
36307
  visible: true,
36086
36308
  opened: true,
36087
36309
  } });
@@ -36562,12 +36784,12 @@ var StaticChatWidgetContainer = function (props) {
36562
36784
  return createStaticStore(state);
36563
36785
  }, [state]);
36564
36786
  var config = React.useMemo(function () {
36565
- return __assign(__assign({}, props.config), { connection: {
36787
+ return __assign$1(__assign$1({}, props.config), { connection: {
36566
36788
  serverUrl: "",
36567
36789
  type: "local",
36568
36790
  } });
36569
36791
  }, [props.config]);
36570
- return (require$$0.jsx(reactRedux.Provider, { store: store, children: require$$0.jsx(ChatWidgetUI, __assign({}, props, { config: config, disableAutoScroll: props.disableAutoScroll, preview: props.preview })) }));
36792
+ return (require$$0.jsx(reactRedux.Provider, { store: store, children: require$$0.jsx(ChatWidgetUI, __assign$1({}, props, { config: config, disableAutoScroll: props.disableAutoScroll, preview: props.preview })) }));
36571
36793
  };
36572
36794
 
36573
36795
  var StaticMessagesChatWidgetContainer = function (props) {
@@ -36707,7 +36929,7 @@ var ChatWidgetConnected = function (props) {
36707
36929
  var connection = useConnectionInfo(rawConfig);
36708
36930
  var config = React.useMemo(function () {
36709
36931
  var _a;
36710
- return (__assign(__assign({}, rawConfig), { connection: connection, assetUrl: (_a = connection === null || connection === void 0 ? void 0 : connection.serverUrl) !== null && _a !== void 0 ? _a : defaultServerUrl, env: rawConfig }));
36932
+ return (__assign$1(__assign$1({}, rawConfig), { connection: connection, assetUrl: (_a = connection === null || connection === void 0 ? void 0 : connection.serverUrl) !== null && _a !== void 0 ? _a : defaultServerUrl, env: rawConfig }));
36711
36933
  }, [connection, rawConfig]);
36712
36934
  var token = reactRedux.useSelector(function (state) { return state.connection.token; });
36713
36935
  var options = React.useMemo(function () {
@@ -36747,7 +36969,7 @@ var ChatWidgetConnected = function (props) {
36747
36969
  if (configError) {
36748
36970
  return (require$$0.jsx("div", { className: "widget-container widget-container--error ".concat(modeClass), children: require$$0.jsxs("div", { className: "widget-error-message", children: ["Failed to load chat configuration: ", configError.message] }) }));
36749
36971
  }
36750
- return (require$$0.jsx(ChatConfigContext.Provider, { value: config, children: require$$0.jsx(ChatServerContext.Provider, { value: chatServer, children: require$$0.jsx(ChatWidgetUI, __assign({}, props, { config: rawConfig })) }) }));
36972
+ return (require$$0.jsx(ChatConfigContext.Provider, { value: config, children: require$$0.jsx(ChatServerContext.Provider, { value: chatServer, children: require$$0.jsx(ChatWidgetUI, __assign$1({}, props, { config: rawConfig })) }) }));
36751
36973
  };
36752
36974
  /**
36753
36975
  * Inner ChatWidget component that renders the actual UI.
@@ -37096,7 +37318,7 @@ var ChatWidgetUI = function (props) {
37096
37318
  // Update the button state to show it's pressed
37097
37319
  innerDispatch({
37098
37320
  type: "ws_button_display",
37099
- detail: __assign(__assign({}, chatState.wsButton), { isPressed: true, timestamp: +new Date() })
37321
+ detail: __assign$1(__assign$1({}, chatState.wsButton), { isPressed: true, timestamp: +new Date() })
37100
37322
  });
37101
37323
  }
37102
37324
  // Send the button pressed event to the server
@@ -37107,7 +37329,7 @@ var ChatWidgetUI = function (props) {
37107
37329
  if (chatState.wsButton) {
37108
37330
  innerDispatch({
37109
37331
  type: "ws_button_display",
37110
- detail: __assign(__assign({}, chatState.wsButton), { isPressed: false, timestamp: +new Date() })
37332
+ detail: __assign$1(__assign$1({}, chatState.wsButton), { isPressed: false, timestamp: +new Date() })
37111
37333
  });
37112
37334
  }
37113
37335
  });
@@ -37117,7 +37339,7 @@ var ChatWidgetUI = function (props) {
37117
37339
  // First set dismissing state to trigger animation
37118
37340
  innerDispatch({
37119
37341
  type: "ws_button_display",
37120
- detail: __assign(__assign({}, chatState.wsButton), { isDismissing: true, timestamp: +new Date() })
37342
+ detail: __assign$1(__assign$1({}, chatState.wsButton), { isDismissing: true, timestamp: +new Date() })
37121
37343
  });
37122
37344
  // Then actually dismiss after animation completes
37123
37345
  setTimeout(function () {
@@ -37205,7 +37427,7 @@ var ChatWidgetUI = function (props) {
37205
37427
  avatarPath: config.avatarUrl,
37206
37428
  display_name: "Agent",
37207
37429
  };
37208
- return (require$$0.jsxs(require$$0.Fragment, { children: [require$$0.jsxs("div", { className: "widget-container ".concat(modeClass, " ").concat(getVisibilityClass()).concat(actionBarVisible ? " widget-container--with-action-bar" : ""), children: [require$$0.jsx(WidgetStylesheet, { theme: config === null || config === void 0 ? void 0 : config.theme }), require$$0.jsx(ChatHeader, { accountStatus: chatState.accountStatus, refreshOnClick: handleRestartClick, minimizeOnClick: handleMinimizeClick, cancelOnClick: handleCancelClick, agent: widgetAgent, canRefresh: canRefresh, canMinimize: canMinimize, canCancel: canCancel, config: config === null || config === void 0 ? void 0 : config.header, menuConfig: config.menu, debugMode: (_x = (_w = (_v = props.config) === null || _v === void 0 ? void 0 : _v.connection) === null || _w === void 0 ? void 0 : _w.mcp) === null || _x === void 0 ? void 0 : _x.debugMode, onSubmit: handleOnSubmit }), require$$0.jsx(MessageList, { visible: visible, queuePosition: chatState.queuePosition, isChatting: chatState.isChatting, isOffline: isOffline, messages: messages, agents: chatState.agents, agent: config === null || config === void 0 ? void 0 : config.agent, lastRatingRequestTimestamp: chatState.lastRatingRequestTimestamp, hasRating: chatState.hasRating, visitorId: chatState.visitorId, hasWsButton: !!chatState.wsButton, messageMiddleware: props.messageMiddleware, textTypingStatusEnabled: (_z = (_y = props.config) === null || _y === void 0 ? void 0 : _y.typingStatus) === null || _z === void 0 ? void 0 : _z.textTypingStatusEnabled, disableAutoScroll: props.disableAutoScroll, onSend: handleSendMessage, onWrite: handleWriteMessage, onOpenUrl: handleOpenUrl, minimizeOnClick: handleMinimizeClick }), require$$0.jsx("div", { className: "xa-spinner-container ".concat(visible && connectionStatus === "pending" ? "visible" : ""), children: require$$0.jsx("div", { className: "xa-spinner" }) }), connectionStatus === "offline" && require$$0.jsx(ServerOffline, {}), chatState.wsButton && visible && (require$$0.jsx(WsButton, { button: chatState.wsButton, onPress: handleWsButtonPress })), require$$0.jsx(ChatFooter, { isAdmin: config === null || config === void 0 ? void 0 : config.isAdmin, isChatting: chatState.isChatting, placeholder: (_0 = config === null || config === void 0 ? void 0 : config.input) === null || _0 === void 0 ? void 0 : _0.placeholder, sendButtonIcon: (_2 = (_1 = config === null || config === void 0 ? void 0 : config.footer) === null || _1 === void 0 ? void 0 : _1.sendButton) === null || _2 === void 0 ? void 0 : _2.icon, sendButtonIconHover: (_4 = (_3 = config === null || config === void 0 ? void 0 : config.footer) === null || _3 === void 0 ? void 0 : _3.sendButton) === null || _4 === void 0 ? void 0 : _4.iconHover, sendButtonIconDisabled: (_6 = (_5 = config === null || config === void 0 ? void 0 : config.footer) === null || _5 === void 0 ? void 0 : _5.sendButton) === null || _6 === void 0 ? void 0 : _6.iconDisabled, visible: visible, hasWsButton: !!chatState.wsButton, menuConfig: (_7 = props.config) === null || _7 === void 0 ? void 0 : _7.menu, footerConfig: (_8 = props.config) === null || _8 === void 0 ? void 0 : _8.footer, inputConfig: (_9 = props.config) === null || _9 === void 0 ? void 0 : _9.input, disabled: previewMode, onChange: handleOnChange, onSubmit: handleOnSubmit, onFileUpload: handleFileUpload }), require$$0.jsx("div", { className: "restartModal", ref: modalRef, onClick: handleRestartModalCloseClick, children: require$$0.jsx(ModalContent, { onClose: handleRestartModalCloseClick, onReset: handleReset }) })] }), actionBarVisible && config.actionBar ? (require$$0.jsxs(require$$0.Fragment, { children: [require$$0.jsx(ActionBar, { config: __assign(__assign({}, config.actionBar), {
37430
+ return (require$$0.jsxs(require$$0.Fragment, { children: [require$$0.jsxs("div", { className: "widget-container ".concat(modeClass, " ").concat(getVisibilityClass()).concat(actionBarVisible ? " widget-container--with-action-bar" : ""), children: [require$$0.jsx(WidgetStylesheet, { theme: config === null || config === void 0 ? void 0 : config.theme }), require$$0.jsx(ChatHeader, { accountStatus: chatState.accountStatus, refreshOnClick: handleRestartClick, minimizeOnClick: handleMinimizeClick, cancelOnClick: handleCancelClick, agent: widgetAgent, canRefresh: canRefresh, canMinimize: canMinimize, canCancel: canCancel, config: config === null || config === void 0 ? void 0 : config.header, menuConfig: config.menu, debugMode: (_x = (_w = (_v = props.config) === null || _v === void 0 ? void 0 : _v.connection) === null || _w === void 0 ? void 0 : _w.mcp) === null || _x === void 0 ? void 0 : _x.debugMode, onSubmit: handleOnSubmit }), require$$0.jsx(MessageList, { visible: visible, queuePosition: chatState.queuePosition, isChatting: chatState.isChatting, isOffline: isOffline, messages: messages, agents: chatState.agents, agent: config === null || config === void 0 ? void 0 : config.agent, lastRatingRequestTimestamp: chatState.lastRatingRequestTimestamp, hasRating: chatState.hasRating, visitorId: chatState.visitorId, hasWsButton: !!chatState.wsButton, messageMiddleware: props.messageMiddleware, textTypingStatusEnabled: (_z = (_y = props.config) === null || _y === void 0 ? void 0 : _y.typingStatus) === null || _z === void 0 ? void 0 : _z.textTypingStatusEnabled, disableAutoScroll: props.disableAutoScroll, onSend: handleSendMessage, onWrite: handleWriteMessage, onOpenUrl: handleOpenUrl, minimizeOnClick: handleMinimizeClick }), require$$0.jsx("div", { className: "xa-spinner-container ".concat(visible && connectionStatus === "pending" ? "visible" : ""), children: require$$0.jsx("div", { className: "xa-spinner" }) }), connectionStatus === "offline" && require$$0.jsx(ServerOffline, {}), chatState.wsButton && visible && (require$$0.jsx(WsButton, { button: chatState.wsButton, onPress: handleWsButtonPress })), require$$0.jsx(ChatFooter, { isAdmin: config === null || config === void 0 ? void 0 : config.isAdmin, isChatting: chatState.isChatting, placeholder: (_0 = config === null || config === void 0 ? void 0 : config.input) === null || _0 === void 0 ? void 0 : _0.placeholder, sendButtonIcon: (_2 = (_1 = config === null || config === void 0 ? void 0 : config.footer) === null || _1 === void 0 ? void 0 : _1.sendButton) === null || _2 === void 0 ? void 0 : _2.icon, sendButtonIconHover: (_4 = (_3 = config === null || config === void 0 ? void 0 : config.footer) === null || _3 === void 0 ? void 0 : _3.sendButton) === null || _4 === void 0 ? void 0 : _4.iconHover, sendButtonIconDisabled: (_6 = (_5 = config === null || config === void 0 ? void 0 : config.footer) === null || _5 === void 0 ? void 0 : _5.sendButton) === null || _6 === void 0 ? void 0 : _6.iconDisabled, visible: visible, hasWsButton: !!chatState.wsButton, menuConfig: (_7 = props.config) === null || _7 === void 0 ? void 0 : _7.menu, footerConfig: (_8 = props.config) === null || _8 === void 0 ? void 0 : _8.footer, inputConfig: (_9 = props.config) === null || _9 === void 0 ? void 0 : _9.input, disabled: previewMode, onChange: handleOnChange, onSubmit: handleOnSubmit, onFileUpload: handleFileUpload }), require$$0.jsx("div", { className: "restartModal", ref: modalRef, onClick: handleRestartModalCloseClick, children: require$$0.jsx(ModalContent, { onClose: handleRestartModalCloseClick, onReset: handleReset }) })] }), actionBarVisible && config.actionBar ? (require$$0.jsxs(require$$0.Fragment, { children: [require$$0.jsx(ActionBar, { config: __assign$1(__assign$1({}, config.actionBar), {
37209
37431
  // Use actionBar.cta if set, otherwise fall back to widget-level cta
37210
37432
  cta: (_10 = config.actionBar.cta) !== null && _10 !== void 0 ? _10 : config.cta }), visible: visible, chatDisabled: config.disabled, formDisabled: isFormPage, hasUserInteracted: (_11 = chatState.visuals) === null || _11 === void 0 ? void 0 : _11.hasInteracted, onChatClick: chatButtonOnClick, onChatMinimize: handleMinimizeClick, onFormClick: handleFormButtonClick, onCtaDismiss: handleCtaDismiss }), formModalOpen && activeFormConfig && (require$$0.jsx(FormModal, { config: activeFormConfig, widgetEnv: config, onClose: handleFormModalClose }))] })) : (require$$0.jsx(ChatButton, { addClass: visible ? "visible" : "", onClick: chatButtonOnClick, config: config === null || config === void 0 ? void 0 : config.cta, imageUrl: (_12 = config === null || config === void 0 ? void 0 : config.chatButton) === null || _12 === void 0 ? void 0 : _12.imageUrl, visible: visible, hasInteracted: (_13 = chatState.visuals) === null || _13 === void 0 ? void 0 : _13.hasInteracted, onCtaDismiss: handleCtaDismiss })), require$$0.jsx(ErrorOverlay, { enableErrorOverlay: config === null || config === void 0 ? void 0 : config.enableErrorOverlay })] }));
37211
37433
  };
@@ -37221,9 +37443,9 @@ var ChatWidgetWrapper = function (props) {
37221
37443
  // For visual layout, use "static" when mode is "preview" (legacy), otherwise use the actual mode
37222
37444
  var visualMode = rawMode === "preview" ? "static" : rawMode;
37223
37445
  if (isPreviewMode) {
37224
- return require$$0.jsx(ChatWidgetPreview, __assign({}, props, { mode: visualMode }));
37446
+ return require$$0.jsx(ChatWidgetPreview, __assign$1({}, props, { mode: visualMode }));
37225
37447
  }
37226
- return require$$0.jsx(ChatWidgetConnected, __assign({}, props));
37448
+ return require$$0.jsx(ChatWidgetConnected, __assign$1({}, props));
37227
37449
  };
37228
37450
 
37229
37451
  function tryParseJson(str) {
@@ -37303,7 +37525,7 @@ function persistStateReducer(storage, initialState, innerReducer) {
37303
37525
  // Clean up transient visual state on page load - don't persist across browser refreshes
37304
37526
  // visible is derived from config (autoOpenOnWidth, autoOpenOnPattern) and visuals.opened
37305
37527
  if (obj && obj.visuals) {
37306
- obj = __assign(__assign({}, obj), { visuals: __assign(__assign({}, obj.visuals), { hasInteracted: undefined, visible: undefined }) });
37528
+ obj = __assign$1(__assign$1({}, obj), { visuals: __assign$1(__assign$1({}, obj.visuals), { hasInteracted: undefined, visible: undefined }) });
37307
37529
  }
37308
37530
  return function (state, action) {
37309
37531
  if (state === void 0) { state = obj; }
@@ -37316,11 +37538,11 @@ function persistStateReducer(storage, initialState, innerReducer) {
37316
37538
  function connectionReducer(state, action) {
37317
37539
  switch (action.type) {
37318
37540
  case "connection_update":
37319
- return __assign(__assign({}, state), { connectionStatus: action.detail.status });
37541
+ return __assign$1(__assign$1({}, state), { connectionStatus: action.detail.status });
37320
37542
  case "receiveToken":
37321
- return __assign(__assign({}, state), { token: action.detail.token });
37543
+ return __assign$1(__assign$1({}, state), { token: action.detail.token });
37322
37544
  case "sendGreeting":
37323
- return __assign(__assign({}, state), { greetingRequested: true });
37545
+ return __assign$1(__assign$1({}, state), { greetingRequested: true });
37324
37546
  }
37325
37547
  return state;
37326
37548
  }
@@ -37335,9 +37557,9 @@ function memberJoin(state, detail) {
37335
37557
  // console.log(`######### No chats in member join action`);
37336
37558
  // set("sessionId", "");
37337
37559
  // }
37338
- var agents = __assign({}, state.agents);
37560
+ var agents = __assign$1({}, state.agents);
37339
37561
  var prevAgentInfo = state.agents[detail.user.nick];
37340
- agents[detail.user.nick] = __assign(__assign({}, prevAgentInfo), { user: __assign(__assign({}, detail.user), { displayName: detail.user.displayName || "Agent" }), joined: true, typing: false, hideUserInfo: detail.hideUserInfo });
37562
+ agents[detail.user.nick] = __assign$1(__assign$1({}, prevAgentInfo), { user: __assign$1(__assign$1({}, detail.user), { displayName: detail.user.displayName || "Agent" }), joined: true, typing: false, hideUserInfo: detail.hideUserInfo });
37341
37563
  if (isAgent(detail.user.nick)) {
37342
37564
  // Always show join messages with special visual features (divider or custom message)
37343
37565
  // These are important conversation markers, not routine join notifications
@@ -37353,18 +37575,18 @@ function memberJoin(state, detail) {
37353
37575
  log("Agent \"".concat(detail.user.displayName || "Unknown", "\" (nick: ").concat(detail.user.nick, ") is joining. Adding join message to chat."));
37354
37576
  }
37355
37577
  }
37356
- return __assign(__assign({}, state), { isChatting: true, chats: ((prevAgentInfo === null || prevAgentInfo === void 0 ? void 0 : prevAgentInfo.joined) && !hasSpecialVisuals) ? state.chats : joinMessages(state.chats, detail), agents: agents });
37578
+ return __assign$1(__assign$1({}, state), { isChatting: true, chats: ((prevAgentInfo === null || prevAgentInfo === void 0 ? void 0 : prevAgentInfo.joined) && !hasSpecialVisuals) ? state.chats : joinMessages(state.chats, detail), agents: agents });
37357
37579
  }
37358
37580
  else {
37359
37581
  log("Non-agent member \"".concat(detail.user.displayName || "Unknown", "\" (nick: ").concat(detail.user.nick, ") is joining. Adding join message to chat."));
37360
- return __assign(__assign({}, state), { isChatting: true, chats: joinMessages(state.chats, detail), agents: agents });
37582
+ return __assign$1(__assign$1({}, state), { isChatting: true, chats: joinMessages(state.chats, detail), agents: agents });
37361
37583
  }
37362
37584
  }
37363
37585
 
37364
37586
  function memberLeave(state, detail) {
37365
- var agents = __assign({}, state.agents);
37587
+ var agents = __assign$1({}, state.agents);
37366
37588
  var prevAgentInfo = state.agents[detail.user.nick];
37367
- agents[detail.user.nick] = __assign(__assign({}, prevAgentInfo), { joined: false, typing: false });
37589
+ agents[detail.user.nick] = __assign$1(__assign$1({}, prevAgentInfo), { joined: false, typing: false });
37368
37590
  // count number of agents that are still joined
37369
37591
  var agentsJoined = Object.values(agents).filter(function (agent) { return agent.joined; });
37370
37592
  var isChatting = agentsJoined.length > 0;
@@ -37381,11 +37603,11 @@ function memberLeave(state, detail) {
37381
37603
  else {
37382
37604
  log("DEDUPLICATION: Agent \"".concat(detail.user.displayName || "Unknown", "\" (nick: ").concat(detail.user.nick, ") already left. NOT adding duplicate leave message to chat."));
37383
37605
  }
37384
- return __assign(__assign({}, state), { isChatting: isChatting, chats: (prevAgentInfo === null || prevAgentInfo === void 0 ? void 0 : prevAgentInfo.joined) ? joinMessages(state.chats, detail) : state.chats, agents: agents });
37606
+ return __assign$1(__assign$1({}, state), { isChatting: isChatting, chats: (prevAgentInfo === null || prevAgentInfo === void 0 ? void 0 : prevAgentInfo.joined) ? joinMessages(state.chats, detail) : state.chats, agents: agents });
37385
37607
  }
37386
37608
  else {
37387
37609
  log("Non-agent member \"".concat(detail.user.displayName || "Unknown", "\" (nick: ").concat(detail.user.nick, ") is leaving. Adding leave message to chat."));
37388
- return __assign(__assign({}, state), { isChatting: isChatting, chats: joinMessages(state.chats, detail), agents: agents });
37610
+ return __assign$1(__assign$1({}, state), { isChatting: isChatting, chats: joinMessages(state.chats, detail), agents: agents });
37389
37611
  }
37390
37612
  }
37391
37613
 
@@ -37402,7 +37624,7 @@ function resetReducer(state) {
37402
37624
  var wasOnline = state.connection.connectionStatus === 'online';
37403
37625
  // Preserve opened state so widget doesn't close on refresh
37404
37626
  var wasOpened = (_a = state.visuals) === null || _a === void 0 ? void 0 : _a.opened;
37405
- return __assign(__assign({}, defaultState), { connection: __assign(__assign({}, defaultState.connection), { greetingRequested: false,
37627
+ return __assign$1(__assign$1({}, defaultState), { connection: __assign$1(__assign$1({}, defaultState.connection), { greetingRequested: false,
37406
37628
  // Generate new nonce to trigger server recreation and start fresh session
37407
37629
  nonce: uuid_1(),
37408
37630
  // Preserve connection status during transition if we were online
@@ -37456,24 +37678,24 @@ function update(state, action) {
37456
37678
  // workaround until state is split. Use combineReducers afterwards
37457
37679
  var newConnectionState = connectionReducer(state.connection, action);
37458
37680
  if (state.connection !== newConnectionState) {
37459
- state = __assign(__assign({}, state), { lastTimestamp: (_e = action.detail) === null || _e === void 0 ? void 0 : _e.timestamp, connection: newConnectionState });
37681
+ state = __assign$1(__assign$1({}, state), { lastTimestamp: (_e = action.detail) === null || _e === void 0 ? void 0 : _e.timestamp, connection: newConnectionState });
37460
37682
  }
37461
37683
  return state;
37462
37684
  case "account_status":
37463
- return __assign(__assign({}, state), { lastTimestamp: (_f = action.detail) === null || _f === void 0 ? void 0 : _f.timestamp, accountStatus: action.detail.status });
37685
+ return __assign$1(__assign$1({}, state), { lastTimestamp: (_f = action.detail) === null || _f === void 0 ? void 0 : _f.timestamp, accountStatus: action.detail.status });
37464
37686
  case "session_id":
37465
- return __assign(__assign({}, state), { lastTimestamp: (_g = action.detail) === null || _g === void 0 ? void 0 : _g.timestamp, sessionId: action.detail.sessionId });
37687
+ return __assign$1(__assign$1({}, state), { lastTimestamp: (_g = action.detail) === null || _g === void 0 ? void 0 : _g.timestamp, sessionId: action.detail.sessionId });
37466
37688
  case "visual_status":
37467
- return __assign(__assign({}, state), { lastTimestamp: (_h = action.detail) === null || _h === void 0 ? void 0 : _h.timestamp, visuals: __assign(__assign(__assign(__assign(__assign({}, (state.visuals || {})), (action.detail.status.drawer !== undefined && { drawer: action.detail.status.drawer })), (action.detail.status.opened !== undefined && { opened: action.detail.status.opened })), (action.detail.status.visible !== undefined && { visible: action.detail.status.visible })), (action.detail.status.hasInteracted !== undefined && { hasInteracted: action.detail.status.hasInteracted })) });
37689
+ return __assign$1(__assign$1({}, state), { lastTimestamp: (_h = action.detail) === null || _h === void 0 ? void 0 : _h.timestamp, visuals: __assign$1(__assign$1(__assign$1(__assign$1(__assign$1({}, (state.visuals || {})), (action.detail.status.drawer !== undefined && { drawer: action.detail.status.drawer })), (action.detail.status.opened !== undefined && { opened: action.detail.status.opened })), (action.detail.status.visible !== undefined && { visible: action.detail.status.visible })), (action.detail.status.hasInteracted !== undefined && { hasInteracted: action.detail.status.hasInteracted })) });
37468
37690
  case "toggle_debug_mode":
37469
37691
  var newDebugMode = !state.debugMode;
37470
37692
  // Update localStorage to persist the setting
37471
37693
  if (typeof window !== 'undefined' && window.localStorage) {
37472
37694
  window.localStorage.setItem('xaErrorOverlay', newDebugMode ? 'enabled' : 'disabled');
37473
37695
  }
37474
- return __assign(__assign({}, state), { debugMode: newDebugMode });
37696
+ return __assign$1(__assign$1({}, state), { debugMode: newDebugMode });
37475
37697
  case "ws_button_display":
37476
- return __assign(__assign({}, state), { lastTimestamp: (_j = action.detail) === null || _j === void 0 ? void 0 : _j.timestamp, wsButton: {
37698
+ return __assign$1(__assign$1({}, state), { lastTimestamp: (_j = action.detail) === null || _j === void 0 ? void 0 : _j.timestamp, wsButton: {
37477
37699
  id: action.detail.id,
37478
37700
  // Preserve existing text if new text is empty (e.g., during dismiss animation)
37479
37701
  text: action.detail.text || ((_k = state.wsButton) === null || _k === void 0 ? void 0 : _k.text) || '',
@@ -37484,19 +37706,19 @@ function update(state, action) {
37484
37706
  case "ws_button_dismiss":
37485
37707
  // Only dismiss if the id matches
37486
37708
  if (((_o = state.wsButton) === null || _o === void 0 ? void 0 : _o.id) === action.detail.id) {
37487
- return __assign(__assign({}, state), { lastTimestamp: (_p = action.detail) === null || _p === void 0 ? void 0 : _p.timestamp, wsButton: undefined });
37709
+ return __assign$1(__assign$1({}, state), { lastTimestamp: (_p = action.detail) === null || _p === void 0 ? void 0 : _p.timestamp, wsButton: undefined });
37488
37710
  }
37489
37711
  return state;
37490
37712
  case "department_update":
37491
- return __assign(__assign({}, state), { lastTimestamp: (_q = action.detail) === null || _q === void 0 ? void 0 : _q.timestamp, departments: __assign(__assign({}, state.departments), (_a = {}, _a[action.detail.id] = __assign({}, action.detail), _a)) });
37713
+ return __assign$1(__assign$1({}, state), { lastTimestamp: (_q = action.detail) === null || _q === void 0 ? void 0 : _q.timestamp, departments: __assign$1(__assign$1({}, state.departments), (_a = {}, _a[action.detail.id] = __assign$1({}, action.detail), _a)) });
37492
37714
  case "visitor_update":
37493
- return __assign(__assign({}, state), { lastTimestamp: (_r = action.detail) === null || _r === void 0 ? void 0 : _r.timestamp, visitor: __assign(__assign({}, state.visitor), action.detail) });
37715
+ return __assign$1(__assign$1({}, state), { lastTimestamp: (_r = action.detail) === null || _r === void 0 ? void 0 : _r.timestamp, visitor: __assign$1(__assign$1({}, state.visitor), action.detail) });
37494
37716
  case "agent_update":
37495
37717
  var prevUpdateAgent = state.agents[action.detail.nick];
37496
- return __assign(__assign({}, state), { lastTimestamp: (_s = action.detail) === null || _s === void 0 ? void 0 : _s.timestamp, agents: __assign(__assign({}, state.agents), (_b = {}, _b[action.detail.nick] = __assign(__assign({}, prevUpdateAgent), { user: __assign(__assign({}, prevUpdateAgent.user), action.detail), typing: (prevUpdateAgent || { typing: false }).typing // if we had it - keep it
37718
+ return __assign$1(__assign$1({}, state), { lastTimestamp: (_s = action.detail) === null || _s === void 0 ? void 0 : _s.timestamp, agents: __assign$1(__assign$1({}, state.agents), (_b = {}, _b[action.detail.nick] = __assign$1(__assign$1({}, prevUpdateAgent), { user: __assign$1(__assign$1({}, prevUpdateAgent.user), action.detail), typing: (prevUpdateAgent || { typing: false }).typing // if we had it - keep it
37497
37719
  }), _b)) });
37498
37720
  case "chat":
37499
- var newState = __assign(__assign({}, state), { lastTimestamp: (_t = action.detail) === null || _t === void 0 ? void 0 : _t.timestamp });
37721
+ var newState = __assign$1(__assign$1({}, state), { lastTimestamp: (_t = action.detail) === null || _t === void 0 ? void 0 : _t.timestamp });
37500
37722
  switch (action.detail.type) {
37501
37723
  case "chat.memberjoin":
37502
37724
  return memberJoin(state, action.detail);
@@ -37509,7 +37731,7 @@ function update(state, action) {
37509
37731
  case "chat.systemmessagedismiss":
37510
37732
  // Remove system message(s) with the specified id
37511
37733
  var dismissId_1 = action.detail.id;
37512
- return __assign(__assign({}, newState), { chats: newState.chats.filter(function (chat) {
37734
+ return __assign$1(__assign$1({}, newState), { chats: newState.chats.filter(function (chat) {
37513
37735
  // Keep all non-system messages, and system messages that don't match the id
37514
37736
  if (isChatSystemMessage(chat)) {
37515
37737
  return chat.id !== dismissId_1;
@@ -37521,10 +37743,10 @@ function update(state, action) {
37521
37743
  return newState;
37522
37744
  case "chat.request.rating":
37523
37745
  appendMessageToState(newState, action.detail);
37524
- return __assign(__assign({}, newState), { lastRatingRequestTimestamp: action.detail.timestamp });
37746
+ return __assign$1(__assign$1({}, newState), { lastRatingRequestTimestamp: action.detail.timestamp });
37525
37747
  case "chat.rating":
37526
37748
  appendMessageToState(newState, action.detail);
37527
- return __assign(__assign({}, newState), { hasRating: !!action.detail.newRating });
37749
+ return __assign$1(__assign$1({}, newState), { hasRating: !!action.detail.newRating });
37528
37750
  case "chat.file":
37529
37751
  case "chat.msg":
37530
37752
  appendMessageToState(newState, action.detail);
@@ -37544,19 +37766,19 @@ function update(state, action) {
37544
37766
  var clearedChats = newState.chats.filter(function (item) {
37545
37767
  return item !== oldFailureMsg_1;
37546
37768
  });
37547
- finalState = __assign(__assign({}, newState), { chats: clearedChats });
37769
+ finalState = __assign$1(__assign$1({}, newState), { chats: clearedChats });
37548
37770
  }
37549
37771
  appendMessageToState(finalState, action.detail);
37550
- return __assign(__assign({}, finalState), { agents: __assign(__assign({}, finalState.agents), (_c = {}, _c[action.detail.user.nick] = __assign(__assign({}, agentDetails), { typing: false, requestFailed: true }), _c)), failureMsg: action.detail.failureMsg });
37772
+ return __assign$1(__assign$1({}, finalState), { agents: __assign$1(__assign$1({}, finalState.agents), (_c = {}, _c[action.detail.user.nick] = __assign$1(__assign$1({}, agentDetails), { typing: false, requestFailed: true }), _c)), failureMsg: action.detail.failureMsg });
37551
37773
  case "chat.typing":
37552
37774
  var agent = state.agents[action.detail.user.nick];
37553
- return __assign(__assign({}, state), { lastTimestamp: (_v = action.detail) === null || _v === void 0 ? void 0 : _v.timestamp, agents: __assign(__assign({}, state.agents), (_d = {}, _d[action.detail.user.nick] = __assign(__assign({}, agent), { typing: action.detail.typing }), _d)) });
37775
+ return __assign$1(__assign$1({}, state), { lastTimestamp: (_v = action.detail) === null || _v === void 0 ? void 0 : _v.timestamp, agents: __assign$1(__assign$1({}, state.agents), (_d = {}, _d[action.detail.user.nick] = __assign$1(__assign$1({}, agent), { typing: action.detail.typing }), _d)) });
37554
37776
  case "chat.stream.start": {
37555
37777
  // Clean up any orphan streaming messages from interrupted streams
37556
37778
  // before creating the new placeholder.
37557
37779
  var cleanedChats = newState.chats.map(function (chat) {
37558
37780
  if (isChatMsgDetail(chat) && chat.isStreaming) {
37559
- return __assign(__assign({}, chat), { isStreaming: false, wasStreamed: true });
37781
+ return __assign$1(__assign$1({}, chat), { isStreaming: false, wasStreamed: true });
37560
37782
  }
37561
37783
  return chat;
37562
37784
  });
@@ -37574,7 +37796,7 @@ function update(state, action) {
37574
37796
  isStreaming: true,
37575
37797
  };
37576
37798
  var newChats = joinMessages(cleanedChats, streamingMsg);
37577
- return __assign(__assign({}, newState), { chats: newChats, streamingMessageId: action.detail.messageId });
37799
+ return __assign$1(__assign$1({}, newState), { chats: newChats, streamingMessageId: action.detail.messageId });
37578
37800
  }
37579
37801
  case "chat.stream.chunk": {
37580
37802
  // Find the streaming message by ID and append text
@@ -37584,10 +37806,10 @@ function update(state, action) {
37584
37806
  var streamingIndex_1 = findLastStreamingIndex(state.chats);
37585
37807
  if (streamingIndex_1 >= 0) {
37586
37808
  var chunkText_1 = chunkDetail.text;
37587
- return __assign(__assign({}, state), { lastTimestamp: chunkDetail === null || chunkDetail === void 0 ? void 0 : chunkDetail.timestamp, chats: state.chats.map(function (chat, index) {
37809
+ return __assign$1(__assign$1({}, state), { lastTimestamp: chunkDetail === null || chunkDetail === void 0 ? void 0 : chunkDetail.timestamp, chats: state.chats.map(function (chat, index) {
37588
37810
  var _a;
37589
37811
  if (index === streamingIndex_1 && isChatMsgDetail(chat)) {
37590
- return __assign(__assign({}, chat), { msg: __assign(__assign({}, chat.msg), { text: (((_a = chat.msg) === null || _a === void 0 ? void 0 : _a.text) || "") + chunkText_1 }) });
37812
+ return __assign$1(__assign$1({}, chat), { msg: __assign$1(__assign$1({}, chat.msg), { text: (((_a = chat.msg) === null || _a === void 0 ? void 0 : _a.text) || "") + chunkText_1 }) });
37591
37813
  }
37592
37814
  return chat;
37593
37815
  }) });
@@ -37603,10 +37825,10 @@ function update(state, action) {
37603
37825
  // Find the streaming message by ID (not by index - other messages could be inserted)
37604
37826
  var streamingIndex_2 = findLastStreamingIndex(state.chats);
37605
37827
  if (streamingIndex_2 >= 0) {
37606
- return __assign(__assign({}, state), { lastTimestamp: toolStartDetail_1.timestamp, chats: state.chats.map(function (chat, index) {
37828
+ return __assign$1(__assign$1({}, state), { lastTimestamp: toolStartDetail_1.timestamp, chats: state.chats.map(function (chat, index) {
37607
37829
  if (index === streamingIndex_2 && isChatMsgDetail(chat)) {
37608
37830
  var existingToolCalls = chat.toolCalls || [];
37609
- return __assign(__assign({}, chat), { toolCalls: __spreadArray$1(__spreadArray$1([], existingToolCalls, true), [
37831
+ return __assign$1(__assign$1({}, chat), { toolCalls: __spreadArray$1(__spreadArray$1([], existingToolCalls, true), [
37610
37832
  {
37611
37833
  name: toolStartDetail_1.toolName,
37612
37834
  toolCallId: toolStartDetail_1.toolCallId,
@@ -37633,7 +37855,7 @@ function update(state, action) {
37633
37855
  // Find the streaming message by ID (not by index - other messages could be inserted)
37634
37856
  var streamingIndex_3 = findLastStreamingIndex(state.chats);
37635
37857
  if (streamingIndex_3 >= 0) {
37636
- return __assign(__assign({}, state), { lastTimestamp: toolEndDetail_1.timestamp, chats: state.chats.map(function (chat, index) {
37858
+ return __assign$1(__assign$1({}, state), { lastTimestamp: toolEndDetail_1.timestamp, chats: state.chats.map(function (chat, index) {
37637
37859
  var _a;
37638
37860
  if (index === streamingIndex_3 && isChatMsgDetail(chat)) {
37639
37861
  var toolCalls = (_a = chat.toolCalls) === null || _a === void 0 ? void 0 : _a.map(function (tc) {
@@ -37643,11 +37865,11 @@ function update(state, action) {
37643
37865
  ? tc.toolCallId === toolEndDetail_1.toolCallId
37644
37866
  : tc.name === toolEndDetail_1.toolName && tc.isExecuting;
37645
37867
  if (isMatch) {
37646
- return __assign(__assign({}, tc), { displayName: toolEndDetail_1.displayName || tc.displayName, label: toolEndDetail_1.label, hidden: (_a = toolEndDetail_1.hidden) !== null && _a !== void 0 ? _a : tc.hidden, input: (_b = toolEndDetail_1.toolInput) !== null && _b !== void 0 ? _b : tc.input, result: toolEndDetail_1.toolResult, error: toolEndDetail_1.toolError, endTime: toolEndDetail_1.timestamp, isExecuting: false });
37868
+ return __assign$1(__assign$1({}, tc), { displayName: toolEndDetail_1.displayName || tc.displayName, label: toolEndDetail_1.label, hidden: (_a = toolEndDetail_1.hidden) !== null && _a !== void 0 ? _a : tc.hidden, input: (_b = toolEndDetail_1.toolInput) !== null && _b !== void 0 ? _b : tc.input, result: toolEndDetail_1.toolResult, error: toolEndDetail_1.toolError, endTime: toolEndDetail_1.timestamp, isExecuting: false });
37647
37869
  }
37648
37870
  return tc;
37649
37871
  });
37650
- return __assign(__assign({}, chat), { toolCalls: toolCalls });
37872
+ return __assign$1(__assign$1({}, chat), { toolCalls: toolCalls });
37651
37873
  }
37652
37874
  return chat;
37653
37875
  }) });
@@ -37669,9 +37891,9 @@ function update(state, action) {
37669
37891
  var toolCalls_1 = endDetail.toolCalls || endStreamingChat.toolCalls;
37670
37892
  // Update chips from message options (same as chat.msg handler)
37671
37893
  var chips = ((_w = finalMsg_1 === null || finalMsg_1 === void 0 ? void 0 : finalMsg_1.options) === null || _w === void 0 ? void 0 : _w.length) ? finalMsg_1.options : [];
37672
- return __assign(__assign({}, state), { lastTimestamp: endDetail === null || endDetail === void 0 ? void 0 : endDetail.timestamp, streamingMessageId: undefined, chips: chips, chats: state.chats.map(function (chat, index) {
37894
+ return __assign$1(__assign$1({}, state), { lastTimestamp: endDetail === null || endDetail === void 0 ? void 0 : endDetail.timestamp, streamingMessageId: undefined, chips: chips, chats: state.chats.map(function (chat, index) {
37673
37895
  if (index === streamingIndex_4 && isChatMsgDetail(chat)) {
37674
- return __assign(__assign({}, chat), { msg: finalMsg_1, isStreaming: false, wasStreamed: true, toolCalls: toolCalls_1 });
37896
+ return __assign$1(__assign$1({}, chat), { msg: finalMsg_1, isStreaming: false, wasStreamed: true, toolCalls: toolCalls_1 });
37675
37897
  }
37676
37898
  return chat;
37677
37899
  }) });
@@ -37686,9 +37908,9 @@ function update(state, action) {
37686
37908
  if (state.streamingMessageId === abortDetail.messageId) {
37687
37909
  var streamingIndex_5 = findLastStreamingIndex(state.chats);
37688
37910
  if (streamingIndex_5 >= 0) {
37689
- return __assign(__assign({}, state), { lastTimestamp: abortDetail.timestamp, streamingMessageId: undefined, chats: state.chats.map(function (chat, index) {
37911
+ return __assign$1(__assign$1({}, state), { lastTimestamp: abortDetail.timestamp, streamingMessageId: undefined, chats: state.chats.map(function (chat, index) {
37690
37912
  if (index === streamingIndex_5 && isChatMsgDetail(chat)) {
37691
- return __assign(__assign({}, chat), { isStreaming: false, wasStreamed: true });
37913
+ return __assign$1(__assign$1({}, chat), { isStreaming: false, wasStreamed: true });
37692
37914
  }
37693
37915
  return chat;
37694
37916
  }) });
@@ -37715,9 +37937,9 @@ function update(state, action) {
37715
37937
  }
37716
37938
  }
37717
37939
  if (lastBotIndex_1 >= 0) {
37718
- return __assign(__assign({}, state), { lastTimestamp: resumeDetail.timestamp, streamingMessageId: resumeDetail.messageId, chats: state.chats.map(function (chat, index) {
37940
+ return __assign$1(__assign$1({}, state), { lastTimestamp: resumeDetail.timestamp, streamingMessageId: resumeDetail.messageId, chats: state.chats.map(function (chat, index) {
37719
37941
  if (index === lastBotIndex_1 && isChatMsgDetail(chat)) {
37720
- return __assign(__assign({}, chat), { isStreaming: true, wasStreamed: false });
37942
+ return __assign$1(__assign$1({}, chat), { isStreaming: true, wasStreamed: false });
37721
37943
  }
37722
37944
  return chat;
37723
37945
  }) });
@@ -37869,8 +38091,8 @@ function generateKey(connection, sessionId) {
37869
38091
  */
37870
38092
  var ChatWidgetPreviewContainer = function (props) {
37871
38093
  var messageMiddleware = useStandardMiddleware();
37872
- var widgetProps = __assign(__assign({}, props), { messageMiddleware: messageMiddleware });
37873
- return require$$0.jsx(ChatWidgetWrapper, __assign({}, widgetProps));
38094
+ var widgetProps = __assign$1(__assign$1({}, props), { messageMiddleware: messageMiddleware });
38095
+ return require$$0.jsx(ChatWidgetWrapper, __assign$1({}, widgetProps));
37874
38096
  };
37875
38097
  /**
37876
38098
  * Connected mode container - creates store and connects to server.
@@ -37893,9 +38115,9 @@ var ChatWidgetConnectedContainer = function (props) {
37893
38115
  if ((_f = props.config) === null || _f === void 0 ? void 0 : _f.disabled) {
37894
38116
  return require$$0.jsx(require$$0.Fragment, {});
37895
38117
  }
37896
- var widgetProps = __assign(__assign({}, props), { messageMiddleware: messageMiddleware, getConfig: props.getConfig // Pass through getConfig callback
38118
+ var widgetProps = __assign$1(__assign$1({}, props), { messageMiddleware: messageMiddleware, getConfig: props.getConfig // Pass through getConfig callback
37897
38119
  });
37898
- return (require$$0.jsx(reactRedux.Provider, { store: chatStore, children: require$$0.jsx(ChatWidgetWrapper, __assign({}, widgetProps)) }));
38120
+ return (require$$0.jsx(reactRedux.Provider, { store: chatStore, children: require$$0.jsx(ChatWidgetWrapper, __assign$1({}, widgetProps)) }));
37899
38121
  };
37900
38122
  /**
37901
38123
  * Top-level container that dispatches between preview and connected modes.
@@ -37906,9 +38128,9 @@ var ChatWidgetContainer = function (props) {
37906
38128
  // Support both `preview` prop and legacy `mode="preview"`
37907
38129
  var isPreviewMode = props.preview === true || rawMode === "preview";
37908
38130
  if (isPreviewMode) {
37909
- return require$$0.jsx(ChatWidgetPreviewContainer, __assign({}, props));
38131
+ return require$$0.jsx(ChatWidgetPreviewContainer, __assign$1({}, props));
37910
38132
  }
37911
- return require$$0.jsx(ChatWidgetConnectedContainer, __assign({}, props));
38133
+ return require$$0.jsx(ChatWidgetConnectedContainer, __assign$1({}, props));
37912
38134
  };
37913
38135
 
37914
38136
  exports.React = React;