react-instantsearch 7.34.0 → 7.35.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- /*! React InstantSearch 7.34.0 | © Algolia, Inc. and contributors; MIT License | https://github.com/algolia/instantsearch */
1
+ /*! React InstantSearch 7.35.1 | © Algolia, Inc. and contributors; MIT License | https://github.com/algolia/instantsearch */
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react')) :
4
4
  typeof define === 'function' && define.amd ? define(['exports', 'react'], factory) :
@@ -24,7 +24,7 @@
24
24
 
25
25
  var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
26
26
 
27
- var version$2 = '7.34.0';
27
+ var version$2 = '7.35.1';
28
28
 
29
29
  function _define_property(obj, key, value) {
30
30
  if (key in obj) {
@@ -10821,7 +10821,7 @@
10821
10821
  };
10822
10822
  }
10823
10823
 
10824
- var version = '4.100.0';
10824
+ var version = '4.101.1';
10825
10825
 
10826
10826
  var withUsage$r = createDocumentationMessageGenerator({
10827
10827
  name: 'instantsearch'
@@ -12211,16 +12211,21 @@
12211
12211
  onDone();
12212
12212
  return;
12213
12213
  }
12214
- var result = onChunk(value);
12215
- if (result && typeof result.then === 'function') {
12216
- result.then(function() {
12217
- return read();
12218
- }, function(error) {
12219
- reader.releaseLock();
12220
- onError(error);
12221
- });
12222
- } else {
12223
- read();
12214
+ try {
12215
+ var result = onChunk(value);
12216
+ if (result && typeof result.then === 'function') {
12217
+ result.then(function() {
12218
+ return read();
12219
+ }, function(error) {
12220
+ reader.releaseLock();
12221
+ onError(error);
12222
+ });
12223
+ } else {
12224
+ read();
12225
+ }
12226
+ } catch (error) {
12227
+ reader.releaseLock();
12228
+ onError(error);
12224
12229
  }
12225
12230
  }, function(error) {
12226
12231
  reader.releaseLock();
@@ -12230,6 +12235,49 @@
12230
12235
  read();
12231
12236
  }
12232
12237
 
12238
+ function _construct(Parent, args, Class) {
12239
+ if (_is_native_reflect_construct()) _construct = Reflect.construct;
12240
+ else {
12241
+ _construct = function construct(Parent, args, Class) {
12242
+ var a = [null];
12243
+ a.push.apply(a, args);
12244
+ var Constructor = Function.bind.apply(Parent, a);
12245
+ var instance = new Constructor();
12246
+
12247
+ if (Class) _set_prototype_of(instance, Class.prototype);
12248
+
12249
+ return instance;
12250
+ };
12251
+ }
12252
+
12253
+ return _construct.apply(null, arguments);
12254
+ }
12255
+
12256
+ function _is_native_function(fn) {
12257
+ return Function.toString.call(fn).indexOf("[native code]") !== -1;
12258
+ }
12259
+
12260
+ function _wrap_native_super(Class) {
12261
+ var _cache = typeof Map === "function" ? new Map() : undefined;
12262
+ _wrap_native_super = function(Class) {
12263
+ if (Class === null || !_is_native_function(Class)) return Class;
12264
+ if (typeof Class !== "function") throw new TypeError("Super expression must either be null or a function");
12265
+ if (typeof _cache !== "undefined") {
12266
+ if (_cache.has(Class)) return _cache.get(Class);
12267
+ _cache.set(Class, Wrapper);
12268
+ }
12269
+
12270
+ function Wrapper() {
12271
+ return _construct(Class, arguments, _get_prototype_of(this).constructor);
12272
+ }
12273
+ Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } });
12274
+
12275
+ return _set_prototype_of(Wrapper, Class);
12276
+ };
12277
+
12278
+ return _wrap_native_super(Class);
12279
+ }
12280
+
12233
12281
  function generateId() {
12234
12282
  return Math.random().toString(36).substring(2, 9);
12235
12283
  }
@@ -12302,6 +12350,49 @@
12302
12350
  }
12303
12351
  return Promise.resolve(value);
12304
12352
  }
12353
+ /**
12354
+ * Error raised when the upstream stream emits a `data-guardrail-violation`
12355
+ * chunk. The `message` carries the service-provided `fallbackResponse`, which
12356
+ * is intentionally surfaced verbatim through the chat error UI (unlike
12357
+ * generic cost-control / 4xx errors, where the raw API message is hidden
12358
+ * behind a friendly default).
12359
+ *
12360
+ * Detection across package boundaries should rely on `error.name` rather than
12361
+ * `instanceof` to avoid issues with mixed module copies in bundled apps.
12362
+ */ var GuardrailViolationError = /*#__PURE__*/ function(Error1) {
12363
+ _inherits(GuardrailViolationError, Error1);
12364
+ function GuardrailViolationError(message) {
12365
+ _class_call_check(this, GuardrailViolationError);
12366
+ var _this;
12367
+ _this = _call_super(this, GuardrailViolationError, [
12368
+ message
12369
+ ]);
12370
+ _this.name = 'GuardrailViolationError';
12371
+ return _this;
12372
+ }
12373
+ return GuardrailViolationError;
12374
+ }(_wrap_native_super(Error));
12375
+ /**
12376
+ * Reads a non-empty `message` field off a JSON-serialized error envelope.
12377
+ *
12378
+ * Both transports backing `AbstractChat` (stream `error` chunks and HTTP error
12379
+ * responses) serialize errors as `{"message": "...", ...}` — the same shape as
12380
+ * the shared `ErrorResponse` on the API side. Returns the trimmed message if
12381
+ * the input is such a JSON object, otherwise `undefined`.
12382
+ */ function tryParseErrorMessage(text) {
12383
+ try {
12384
+ var parsed = JSON.parse(text);
12385
+ if (parsed && (typeof parsed === "undefined" ? "undefined" : _type_of(parsed)) === 'object' && !Array.isArray(parsed) && typeof parsed.message === 'string') {
12386
+ var message = parsed.message.trim();
12387
+ if (message) {
12388
+ return message;
12389
+ }
12390
+ }
12391
+ } catch (unused) {
12392
+ // Not JSON — caller falls back to its own default.
12393
+ }
12394
+ return undefined;
12395
+ }
12305
12396
 
12306
12397
  var tryParseJson = function tryParseJson(value) {
12307
12398
  try {
@@ -12380,7 +12471,7 @@
12380
12471
  var _param_generateId = param.generateId, generateId$1 = _param_generateId === void 0 ? generateId : _param_generateId, _param_id = param.id, id = _param_id === void 0 ? generateId$1() : _param_id, transport = param.transport, state = param.state, onError = param.onError, onToolCall = param.onToolCall, onFinish = param.onFinish, onData = param.onData, sendAutomaticallyWhen = param.sendAutomaticallyWhen, shouldRepairToolInput = param.shouldRepairToolInput;
12381
12472
  var _this1 = this;
12382
12473
  _class_call_check(this, AbstractChat);
12383
- _define_property(this, "id", void 0);
12474
+ _define_property(this, "conversationId", void 0);
12384
12475
  _define_property(this, "generateId", void 0);
12385
12476
  _define_property(this, "state", void 0);
12386
12477
  _define_property(this, "transport", void 0);
@@ -12536,12 +12627,6 @@
12536
12627
  }
12537
12628
  });
12538
12629
  /**
12539
- * Regenerate the chat id. Use this to start a fresh conversation on the
12540
- * server while keeping the same Chat instance and its registered listeners.
12541
- */ _define_property(this, "regenerateId", function() {
12542
- _this.id = _this.generateId();
12543
- });
12544
- /**
12545
12630
  * Add a tool result for a tool call.
12546
12631
  */ _define_property(this, "addToolResult", function(param) {
12547
12632
  var tool = param.tool, toolCallId = param.toolCallId, output = param.output;
@@ -12596,7 +12681,7 @@
12596
12681
  });
12597
12682
  return Promise.resolve();
12598
12683
  });
12599
- this.id = id;
12684
+ this.conversationId = id;
12600
12685
  this.generateId = generateId$1;
12601
12686
  this.state = state;
12602
12687
  this.transport = transport;
@@ -12608,6 +12693,12 @@
12608
12693
  this.shouldRepairToolInput = shouldRepairToolInput;
12609
12694
  }
12610
12695
  _create_class(AbstractChat, [
12696
+ {
12697
+ key: "id",
12698
+ get: function get() {
12699
+ return this.conversationId;
12700
+ }
12701
+ },
12611
12702
  {
12612
12703
  key: "status",
12613
12704
  get: /**
@@ -12637,6 +12728,17 @@
12637
12728
  return this.state.error;
12638
12729
  }
12639
12730
  },
12731
+ {
12732
+ /**
12733
+ * Starts a new server-side conversation thread by rotating the id sent as
12734
+ * `chatId` / `id` on the next request. The InstantSearch connector calls this
12735
+ * after the user clears the transcript so completions are not tied to prior
12736
+ * context.
12737
+ */ key: "resetConversationId",
12738
+ value: function resetConversationId() {
12739
+ this.conversationId = this.generateId();
12740
+ }
12741
+ },
12640
12742
  {
12641
12743
  key: "messages",
12642
12744
  get: function get() {
@@ -13005,8 +13107,7 @@
13005
13107
  var updatedParts7 = _to_consumable_array(currentMessage.parts);
13006
13108
  var existingPart2 = updatedParts7[toolIndex2];
13007
13109
  // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
13008
- existingPart2.rawOutput;
13009
- var rest = _object_without_properties(existingPart2, [
13110
+ var _ignored = existingPart2.rawOutput, rest = _object_without_properties(existingPart2, [
13010
13111
  "rawOutput"
13011
13112
  ]);
13012
13113
  updatedParts7[toolIndex2] = _object_spread_props(_object_spread({}, rest), {
@@ -13034,10 +13135,7 @@
13034
13135
  delete toolRawOutputByCallId[chunk.toolCallId];
13035
13136
  var updatedParts8 = _to_consumable_array(currentMessage.parts);
13036
13137
  var existingPart3 = updatedParts8[toolIndex3];
13037
- // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
13038
- existingPart3.rawOutput; // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
13039
- existingPart3.preliminary;
13040
- var rest1 = _object_without_properties(existingPart3, [
13138
+ var _ignoredRawOutput = existingPart3.rawOutput, _ignoredPreliminary = existingPart3.preliminary, rest1 = _object_without_properties(existingPart3, [
13041
13139
  "rawOutput",
13042
13140
  "preliminary"
13043
13141
  ]);
@@ -13132,7 +13230,8 @@
13132
13230
  case 'error':
13133
13231
  {
13134
13232
  isError = true;
13135
- throw new Error(chunk.errorText);
13233
+ var text = chunk.errorText.trim();
13234
+ throw new Error(tryParseErrorMessage(text) || text || 'Unknown error');
13136
13235
  }
13137
13236
  case 'abort':
13138
13237
  {
@@ -13149,9 +13248,32 @@
13149
13248
  }
13150
13249
  break;
13151
13250
  }
13251
+ // Surface guardrail violations through the error state, but
13252
+ // distinct from generic cost-control / 4xx errors: throw a
13253
+ // `GuardrailViolationError` so the UI can render the
13254
+ // service-provided `fallbackResponse` verbatim (it's authored for
13255
+ // end-user display) instead of the friendly default used for
13256
+ // opaque transport errors. Also discard any in-progress assistant
13257
+ // message so no partial text lingers above the fallback, and
13258
+ // clear the local cursor so the `onFinish` callback doesn't
13259
+ // receive a `currentMessage` that no longer exists in state.
13260
+ case 'data-guardrail-violation':
13261
+ {
13262
+ isError = true;
13263
+ if (currentMessageIndex >= 0) {
13264
+ _this.state.messages = _this.state.messages.slice(0, currentMessageIndex);
13265
+ currentMessage = undefined;
13266
+ currentMessageIndex = -1;
13267
+ }
13268
+ // `chunk.data` widens to `unknown` here: the chunk union also
13269
+ // carries a generic `data-${string}` member, and the literal
13270
+ // matches both, so narrowing can't pick the specific shape.
13271
+ var fallbackResponse = chunk.data.fallbackResponse;
13272
+ throw new GuardrailViolationError(fallbackResponse || 'Sorry, we are not able to generate a response at the moment.');
13273
+ }
13152
13274
  default:
13153
13275
  {
13154
- // Handle data parts (data-*)
13276
+ // Handle generic data parts (data-*)
13155
13277
  var chunkType = chunk.type;
13156
13278
  if ((chunkType === null || chunkType === void 0 ? void 0 : chunkType.startsWith('data-')) && currentMessage) {
13157
13279
  var dataPart = {
@@ -13453,7 +13575,7 @@
13453
13575
  return (chatRenderState === null || chatRenderState === void 0 ? void 0 : chatRenderState.status) === 'submitted' || (chatRenderState === null || chatRenderState === void 0 ? void 0 : chatRenderState.status) === 'streaming';
13454
13576
  }
13455
13577
 
13456
- var SearchIndexToolType$1 = 'algolia_search_index';
13578
+ var SearchIndexToolType$2 = 'algolia_search_index';
13457
13579
  var RecommendToolType = 'algolia_recommend';
13458
13580
  var MemorizeToolType = 'algolia_memorize';
13459
13581
  var MemorySearchToolType = 'algolia_memory_search';
@@ -13466,6 +13588,20 @@
13466
13588
  }, []);
13467
13589
  }
13468
13590
 
13591
+ /**
13592
+ * Reads a human-readable message from a failed HTTP response body when the
13593
+ * server returns JSON such as `{ "message": "..." }` (the shared
13594
+ * `ErrorResponse` shape used by every status code), falling back to the HTTP
13595
+ * status line when the body is empty or not parseable.
13596
+ */ function getHttpErrorMessage(response) {
13597
+ var fallback = "HTTP error: ".concat(response.status, " ").concat(response.statusText);
13598
+ return response.text().then(function(text) {
13599
+ var _tryParseErrorMessage;
13600
+ return (_tryParseErrorMessage = tryParseErrorMessage(text)) !== null && _tryParseErrorMessage !== void 0 ? _tryParseErrorMessage : fallback;
13601
+ }).catch(function() {
13602
+ return fallback;
13603
+ });
13604
+ }
13469
13605
  /**
13470
13606
  * Abstract base class for HTTP-based chat transports.
13471
13607
  */ var HttpChatTransport = /*#__PURE__*/ function() {
@@ -13544,7 +13680,9 @@
13544
13680
  credentials: credentials
13545
13681
  }).then(function(response) {
13546
13682
  if (!response.ok) {
13547
- throw new Error("HTTP error: ".concat(response.status, " ").concat(response.statusText));
13683
+ return getHttpErrorMessage(response).then(function(message) {
13684
+ throw new Error(message);
13685
+ });
13548
13686
  }
13549
13687
  if (!response.body) {
13550
13688
  throw new Error('Response body is empty');
@@ -13602,7 +13740,9 @@
13602
13740
  if (response.status === 404) {
13603
13741
  return null;
13604
13742
  }
13605
- throw new Error("HTTP error: ".concat(response.status, " ").concat(response.statusText));
13743
+ return getHttpErrorMessage(response).then(function(message) {
13744
+ throw new Error(message);
13745
+ });
13606
13746
  }
13607
13747
  if (!response.body) {
13608
13748
  return null;
@@ -13750,7 +13890,7 @@
13750
13890
  var onClearTransitionEnd = function onClearTransitionEnd() {
13751
13891
  setMessages([]);
13752
13892
  _chatInstance.clearError();
13753
- _chatInstance.regenerateId();
13893
+ _chatInstance.resetConversationId();
13754
13894
  feedbackState = {};
13755
13895
  setIsClearing(false);
13756
13896
  };
@@ -13854,8 +13994,8 @@
13854
13994
  sendAutomaticallyWhen: lastAssistantMessageIsCompleteWithToolCalls,
13855
13995
  shouldRepairToolInput: function shouldRepairToolInput(toolName) {
13856
13996
  var tool = tools[toolName];
13857
- if (!tool && toolName.startsWith("".concat(SearchIndexToolType$1, "_"))) {
13858
- tool = tools[SearchIndexToolType$1];
13997
+ if (!tool && toolName.startsWith("".concat(SearchIndexToolType$2, "_"))) {
13998
+ tool = tools[SearchIndexToolType$2];
13859
13999
  }
13860
14000
  if (!tool) return true;
13861
14001
  return Boolean(tool.streamInput);
@@ -13864,8 +14004,8 @@
13864
14004
  var toolCall = param.toolCall;
13865
14005
  var tool = tools[toolCall.toolName];
13866
14006
  // Compatibility shim with Algolia MCP Server search tool
13867
- if (!tool && toolCall.toolName.startsWith("".concat(SearchIndexToolType$1, "_"))) {
13868
- tool = tools[SearchIndexToolType$1];
14007
+ if (!tool && toolCall.toolName.startsWith("".concat(SearchIndexToolType$2, "_"))) {
14008
+ tool = tools[SearchIndexToolType$2];
13869
14009
  }
13870
14010
  if (!tool) {
13871
14011
  return _chatInstance.addToolResult({
@@ -19728,6 +19868,8 @@
19728
19868
  return str.slice(0, prefix.length) === prefix;
19729
19869
  }
19730
19870
 
19871
+ // Keep in sync with packages/instantsearch.js/src/lib/chat/index.ts
19872
+ var SearchIndexToolType$1 = 'algolia_search_index';
19731
19873
  var getTextContent = function getTextContent(message) {
19732
19874
  return message.parts.map(function(part) {
19733
19875
  return 'text' in part ? part.text : '';
@@ -19754,6 +19896,117 @@
19754
19896
  }
19755
19897
  return tool;
19756
19898
  };
19899
+ var FACET_KEY_PREFIX = 'facet_';
19900
+ /**
19901
+ * Extracts the `facetFilters` from a search tool input.
19902
+ *
19903
+ * The default search tool provides a ready-to-use `facet_filters` array. The
19904
+ * Algolia MCP Server search tool instead expresses refinements as individual
19905
+ * `facet_<attribute>` keys (e.g. `facet_categories: ['Books', 'Toys']`), which
19906
+ * are converted here into the `[['attribute:value']]` shape `applyFilters`
19907
+ * expects.
19908
+ */ var getFacetFiltersFromToolInput = function getFacetFiltersFromToolInput(input) {
19909
+ if (!input) {
19910
+ return undefined;
19911
+ }
19912
+ if (Array.isArray(input.facet_filters)) {
19913
+ return input.facet_filters;
19914
+ }
19915
+ var facetFilters = Object.entries(input).reduce(function(acc, param) {
19916
+ var _param = _sliced_to_array(param, 2), key = _param[0], value = _param[1];
19917
+ if (!startsWith(key, FACET_KEY_PREFIX) || !Array.isArray(value)) {
19918
+ return acc;
19919
+ }
19920
+ var attribute = key.slice(FACET_KEY_PREFIX.length);
19921
+ var values = value.filter(function(item) {
19922
+ return typeof item === 'string';
19923
+ });
19924
+ if (attribute && values.length > 0) {
19925
+ acc.push(values.map(function(item) {
19926
+ return "".concat(attribute, ":").concat(item);
19927
+ }));
19928
+ }
19929
+ return acc;
19930
+ }, []);
19931
+ return facetFilters.length > 0 ? facetFilters : undefined;
19932
+ };
19933
+ var isSearchToolPart = function isSearchToolPart(part) {
19934
+ return part.type === "tool-".concat(SearchIndexToolType$1) || // Compatibility shim with Algolia MCP Server search tool
19935
+ startsWith(part.type, "tool-".concat(SearchIndexToolType$1, "_"));
19936
+ };
19937
+ var collectHitsFromPart = function collectHitsFromPart(part, hitsByObjectID) {
19938
+ var output = part.state === 'output-available' ? part.output : undefined;
19939
+ var hits = output === null || output === void 0 ? void 0 : output.hits;
19940
+ if (!Array.isArray(hits)) {
19941
+ return;
19942
+ }
19943
+ hits.forEach(function(hit) {
19944
+ if (!hit) {
19945
+ return;
19946
+ }
19947
+ if (typeof hit.objectID === 'string' && hit.objectID !== '') {
19948
+ hitsByObjectID[hit.objectID] = hit;
19949
+ }
19950
+ });
19951
+ };
19952
+ /**
19953
+ * Builds a map of `objectID` -> full record by collecting the hits from search
19954
+ * tool outputs across the conversation.
19955
+ *
19956
+ * The display results tool only receives object IDs from the backend, so it
19957
+ * relies on this map to hydrate each result with the full record that the
19958
+ * preceding search tool already fetched.
19959
+ *
19960
+ * Pass `untilToolCallId` (the display tool's own `toolCallId`) to scope
19961
+ * collection to the turn that produced it: hits are only gathered up to and
19962
+ * including the message that contains that tool call. This prevents a later
19963
+ * turn's search from overwriting an earlier display tool's records (and their
19964
+ * per-query metadata like `__queryID`).
19965
+ */ var getHitsByObjectID = function getHitsByObjectID(messages, untilToolCallId) {
19966
+ var hitsByObjectID = {};
19967
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
19968
+ try {
19969
+ var _loop = function _loop() {
19970
+ var message = _step.value;
19971
+ var reachedBoundary = false;
19972
+ message.parts.forEach(function(part) {
19973
+ if (!isPartTool(part)) {
19974
+ return;
19975
+ }
19976
+ // Note the boundary but keep processing the rest of this message's parts:
19977
+ // the search tool that fed this display tool lives in the same message,
19978
+ // so its hits must still be collected before we stop.
19979
+ if (untilToolCallId && part.toolCallId === untilToolCallId) {
19980
+ reachedBoundary = true;
19981
+ }
19982
+ if (isSearchToolPart(part)) {
19983
+ collectHitsFromPart(part, hitsByObjectID);
19984
+ }
19985
+ });
19986
+ if (reachedBoundary) {
19987
+ return "break";
19988
+ }
19989
+ };
19990
+ for(var _iterator = messages[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
19991
+ var _ret = _loop();
19992
+ if (_ret === "break") break;
19993
+ }
19994
+ } catch (err) {
19995
+ _didIteratorError = true;
19996
+ _iteratorError = err;
19997
+ } finally{
19998
+ try {
19999
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
20000
+ _iterator.return();
20001
+ }
20002
+ } finally{
20003
+ if (_didIteratorError) {
20004
+ throw _iteratorError;
20005
+ }
20006
+ }
20007
+ }
20008
+ return hitsByObjectID;
20009
+ };
19757
20010
 
19758
20011
  function n(){return n=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t]);}return e},n.apply(this,arguments)}const o=["allowFullScreen","allowTransparency","autoComplete","autoFocus","autoPlay","cellPadding","cellSpacing","charSet","classId","colSpan","contentEditable","contextMenu","crossOrigin","encType","formAction","formEncType","formMethod","formNoValidate","formTarget","frameBorder","hrefLang","inputMode","keyParams","keyType","marginHeight","marginWidth","maxLength","mediaGroup","minLength","noValidate","radioGroup","readOnly","rowSpan","spellCheck","srcDoc","srcLang","srcSet","tabIndex","useMap"].reduce((e,n)=>(e[n.toLowerCase()]=n,e),{class:"className",for:"htmlFor"}),a={amp:"&",apos:"'",gt:">",lt:"<",nbsp:" ",quot:"“"},c=["style","script","pre"],i=["src","href","data","formAction","srcDoc","action"],u=/([-A-Z0-9_:]+)(?:\s*=\s*(?:(?:"((?:\\.|[^"])*)")|(?:'((?:\\.|[^'])*)')|(?:\{((?:\\.|{[^}]*?}|[^}])*)\})))?/gi,l=/\n{2,}$/,s=/^(\s*>[\s\S]*?)(?=\n\n|$)/,f=/^ *> ?/gm,_=/^(?:\[!([^\]]*)\]\n)?([\s\S]*)/,d=/^ {2,}\n/,p=/^(?:([-*_])( *\1){2,}) *(?:\n *)+\n/,y=/^(?: {1,3})?(`{3,}|~{3,}) *(\S+)? *([^\n]*?)?\n([\s\S]*?)(?:\1\n?|$)/,h=/^(?: {4}[^\n]+\n*)+(?:\n *)+\n?/,g=/^(`+)((?:\\`|(?!\1)`|[^`])+)\1/,m=/^(?:\n *)*\n/,k=/\r\n?/g,x=/^\[\^([^\]]+)](:(.*)((\n+ {4,}.*)|(\n(?!\[\^).+))*)/,q=/^\[\^([^\]]+)]/,v=/\f/g,b=/^---[ \t]*\n(.|\n)*\n---[ \t]*\n/,$=/^\s*?\[(x|\s)\]/,S=/^ *(#{1,6}) *([^\n]+?)(?: +#*)?(?:\n *)*(?:\n|$)/,z=/^ *(#{1,6}) +([^\n]+?)(?: +#*)?(?:\n *)*(?:\n|$)/,E=/^([^\n]+)\n *(=|-)\2{2,} *\n/,A=/^ *(?!<[a-z][^ >/]* ?\/>)<([a-z][^ >/]*) ?((?:[^>]*[^/])?)>\n?(\s*(?:<\1[^>]*?>[\s\S]*?<\/\1>|(?!<\1\b)[\s\S])*?)<\/\1>(?!<\/\1>)\n*/i,R=/&([a-z0-9]+|#[0-9]{1,6}|#x[0-9a-fA-F]{1,6});/gi,B=/^<!--[\s\S]*?(?:-->)/,L=/^(data|aria|x)-[a-z_][a-z\d_.-]*$/,O=/^ *<([a-z][a-z0-9:]*)(?:\s+((?:<.*?>|[^>])*))?\/?>(?!<\/\1>)(\s*\n)?/i,j=/^\{.*\}$/,C=/^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/,I=/^<([^ >]+[:@\/][^ >]+)>/,T=/-([a-z])?/gi,M=/^(\|.*)\n(?: *(\|? *[-:]+ *\|[-| :]*)\n((?:.*\|.*\n)*))?\n?/,w=/^[^\n]+(?: \n|\n{2,})/,D=/^\[([^\]]*)\]:\s+<?([^\s>]+)>?\s*("([^"]*)")?/,F=/^!\[([^\]]*)\] ?\[([^\]]*)\]/,P=/^\[([^\]]*)\] ?\[([^\]]*)\]/,Z=/(\n|^[-*]\s|^#|^ {2,}|^-{2,}|^>\s)/,N=/\t/g,G=/(^ *\||\| *$)/g,U=/^ *:-+: *$/,V=/^ *:-+ *$/,H=/^ *-+: *$/,Q=e=>`(?=[\\s\\S]+?\\1${e?"\\1":""})`,W="((?:\\[.*?\\][([].*?[)\\]]|<.*?>(?:.*?<.*?>)?|`.*?`|\\\\\\1|[\\s\\S])+?)",J=RegExp(`^([*_])\\1${Q(1)}${W}\\1\\1(?!\\1)`),K=RegExp(`^([*_])${Q(0)}${W}\\1(?!\\1)`),X=RegExp(`^(==)${Q(0)}${W}\\1`),Y=RegExp(`^(~~)${Q(0)}${W}\\1`),ee=/^(:[a-zA-Z0-9-_]+:)/,ne=/^\\([^0-9A-Za-z\s])/,re=/\\([^0-9A-Za-z\s])/g,te=/^[\s\S](?:(?! \n|[0-9]\.|http)[^=*_~\-\n:<`\\\[!])*/,oe=/^\n+/,ae=/^([ \t]*)/,ce=/(?:^|\n)( *)$/,ie="(?:\\d+\\.)",ue="(?:[*+-])";function le(e){return "( *)("+(1===e?ie:ue)+") +"}const se=le(1),fe=le(2);function _e(e){return RegExp("^"+(1===e?se:fe))}const de=_e(1),pe=_e(2);function ye(e){return RegExp("^"+(1===e?se:fe)+"[^\\n]*(?:\\n(?!\\1"+(1===e?ie:ue)+" )[^\\n]*)*(\\n|$)","gm")}const he=ye(1),ge=ye(2);function me(e){const n=1===e?ie:ue;return RegExp("^( *)("+n+") [\\s\\S]+?(?:\\n{2,}(?! )(?!\\1"+n+" (?!"+n+" ))\\n*|\\s*\\n*$)")}const ke=me(1),xe=me(2);function qe(e,n){const r=1===n,t=r?ke:xe,o=r?he:ge,a=r?de:pe;return {t:e=>a.test(e),o:je(function(e,n){const r=ce.exec(n.prevCapture);return r&&(n.list||!n.inline&&!n.simple)?t.exec(e=r[1]+e):null}),i:1,u(e,n,t){const c=r?+e[2]:void 0,i=e[0].replace(l,"\n").match(o);let u=!1;return {items:i.map(function(e,r){const o=a.exec(e)[0].length,c=RegExp("^ {1,"+o+"}","gm"),l=e.replace(c,"").replace(a,""),s=r===i.length-1,f=-1!==l.indexOf("\n\n")||s&&u;u=f;const _=t.inline,d=t.list;let p;t.list=!0,f?(t.inline=!1,p=Se(l)+"\n\n"):(t.inline=!0,p=Se(l));const y=n(p,t);return t.inline=_,t.list=d,y}),ordered:r,start:c}},l:(n,r,t)=>e(n.ordered?"ol":"ul",{key:t.key,start:"20"===n.type?n.start:void 0},n.items.map(function(n,o){return e("li",{key:o},r(n,t))}))}}const ve=RegExp("^\\[((?:\\[[^\\[\\]]*(?:\\[[^\\[\\]]*\\][^\\[\\]]*)*\\]|[^\\[\\]])*)\\]\\(\\s*<?((?:\\([^)]*\\)|[^\\s\\\\]|\\\\.)*?)>?(?:\\s+['\"]([\\s\\S]*?)['\"])?\\s*\\)"),be=/^!\[(.*?)\]\( *((?:\([^)]*\)|[^() ])*) *"?([^)"]*)?"?\)/;function $e(e){return "string"==typeof e}function Se(e){let n=e.length;for(;n>0&&e[n-1]<=" ";)n--;return e.slice(0,n)}function ze(e,n){return e.startsWith(n)}function Ee(e,n,r){if(Array.isArray(r)){for(let n=0;n<r.length;n++)if(ze(e,r[n]))return !0;return !1}return r(e,n)}function Ae(e){return e.replace(/[ÀÁÂÃÄÅàáâãä忯]/g,"a").replace(/[çÇ]/g,"c").replace(/[ðÐ]/g,"d").replace(/[ÈÉÊËéèêë]/g,"e").replace(/[ÏïÎîÍíÌì]/g,"i").replace(/[Ññ]/g,"n").replace(/[øØœŒÕõÔôÓóÒò]/g,"o").replace(/[ÜüÛûÚúÙù]/g,"u").replace(/[ŸÿÝý]/g,"y").replace(/[^a-z0-9- ]/gi,"").replace(/ /gi,"-").toLowerCase()}function Re(e){return H.test(e)?"right":U.test(e)?"center":V.test(e)?"left":null}function Be(e,n,r,t){const o=r.inTable;r.inTable=!0;let a=[[]],c="";function i(){if(!c)return;const e=a[a.length-1];e.push.apply(e,n(c,r)),c="";}return e.trim().split(/(`[^`]*`|\\\||\|)/).filter(Boolean).forEach((e,n,r)=>{"|"===e.trim()&&(i(),t)?0!==n&&n!==r.length-1&&a.push([]):c+=e;}),i(),r.inTable=o,a}function Le(e,n,r){r.inline=!0;const t=e[2]?e[2].replace(G,"").split("|").map(Re):[],o=e[3]?function(e,n,r){return e.trim().split("\n").map(function(e){return Be(e,n,r,!0)})}(e[3],n,r):[],a=Be(e[1],n,r,!!o.length);return r.inline=!1,o.length?{align:t,cells:o,header:a,type:"25"}:{children:a,type:"21"}}function Oe(e,n){return null==e.align[n]?{}:{textAlign:e.align[n]}}function je(e){return e.inline=1,e}function Ce(e){return je(function(n,r){return r.inline?e.exec(n):null})}function Ie(e){return je(function(n,r){return r.inline||r.simple?e.exec(n):null})}function Te(e){return function(n,r){return r.inline||r.simple?null:e.exec(n)}}function Me(e){return je(function(n){return e.exec(n)})}const we=/(javascript|vbscript|data(?!:image)):/i;function De(e){try{const n=decodeURIComponent(e).replace(/[^A-Za-z0-9/:]/g,"");if(we.test(n))return null}catch(e){return null}return e}function Fe(e){return e?e.replace(re,"$1"):e}function Pe(e,n,r){const t=r.inline||!1,o=r.simple||!1;r.inline=!0,r.simple=!0;const a=e(n,r);return r.inline=t,r.simple=o,a}function Ze(e,n,r){const t=r.inline||!1,o=r.simple||!1;r.inline=!1,r.simple=!0;const a=e(n,r);return r.inline=t,r.simple=o,a}function Ne(e,n,r){const t=r.inline||!1;r.inline=!1;const o=e(n,r);return r.inline=t,o}const Ge=(e,n,r)=>({children:Pe(n,e[2],r)});function Ue(){return {}}function Ve(){return null}function He(...e){return e.filter(Boolean).join(" ")}function Qe(e,n,r){let t=e;const o=n.split(".");for(;o.length&&(t=t[o[0]],void 0!==t);)o.shift();return t||r}function We(r="",t={}){t.overrides=t.overrides||{},t.namedCodesToUnicode=t.namedCodesToUnicode?n({},a,t.namedCodesToUnicode):a;const l=t.slugify||Ae,G=t.sanitizer||De,U=t.createElement||React__namespace.createElement,V=[s,y,h,t.enforceAtxHeadings?z:S,E,M,ke,xe],H=[...V,w,A,B,O];function Q(e,n){for(let r=0;r<e.length;r++)if(e[r].test(n))return !0;return !1}function W(e,r,...o){const a=Qe(t.overrides,e+".props",{});return U(function(e,n){const r=Qe(n,e);return r?"function"==typeof r||"object"==typeof r&&"render"in r?r:Qe(n,e+".component",e):e}(e,t.overrides),n({},r,a,{className:He(null==r?void 0:r.className,a.className)||void 0}),...o)}function re(e){e=e.replace(b,"");let n=!1;t.forceInline?n=!0:t.forceBlock||(n=!1===Z.test(e));const r=fe(se(n?e:Se(e).replace(oe,"")+"\n\n",{inline:n}));for(;$e(r[r.length-1])&&!r[r.length-1].trim();)r.pop();if(null===t.wrapper)return r;const o=t.wrapper||(n?"span":"div");let a;if(r.length>1||t.forceWrapper)a=r;else {if(1===r.length)return a=r[0],"string"==typeof a?W("span",{key:"outer"},a):a;a=null;}return U(o,{key:"outer"},a)}function ce(e,n){if(!n||!n.trim())return null;const r=n.match(u);return r?r.reduce(function(n,r){const t=r.indexOf("=");if(-1!==t){const a=function(e){return -1!==e.indexOf("-")&&null===e.match(L)&&(e=e.replace(T,function(e,n){return n.toUpperCase()})),e}(r.slice(0,t)).trim(),c=function(e){const n=e[0];return ('"'===n||"'"===n)&&e.length>=2&&e[e.length-1]===n?e.slice(1,-1):e}(r.slice(t+1).trim()),u=o[a]||a;if("ref"===u)return n;const l=n[u]=function(e,n,r,t){return "style"===n?function(e){const n=[];let r="",t=!1,o=!1,a="";if(!e)return n;for(let c=0;c<e.length;c++){const i=e[c];if('"'!==i&&"'"!==i||t||(o?i===a&&(o=!1,a=""):(o=!0,a=i)),"("===i&&r.endsWith("url")?t=!0:")"===i&&t&&(t=!1),";"!==i||o||t)r+=i;else {const e=r.trim();if(e){const r=e.indexOf(":");if(r>0){const t=e.slice(0,r).trim(),o=e.slice(r+1).trim();n.push([t,o]);}}r="";}}const c=r.trim();if(c){const e=c.indexOf(":");if(e>0){const r=c.slice(0,e).trim(),t=c.slice(e+1).trim();n.push([r,t]);}}return n}(r).reduce(function(n,[r,o]){return n[r.replace(/(-[a-z])/g,e=>e[1].toUpperCase())]=t(o,e,r),n},{}):-1!==i.indexOf(n)?t(Fe(r),e,n):(r.match(j)&&(r=Fe(r.slice(1,r.length-1))),"true"===r||"false"!==r&&r)}(e,a,c,G);"string"==typeof l&&(A.test(l)||O.test(l))&&(n[u]=re(l.trim()));}else "style"!==r&&(n[o[r]||r]=!0);return n},{}):null}const ie=[],ue={},le={0:{t:[">"],o:Te(s),i:1,u(e,n,r){const[,t,o]=e[0].replace(f,"").match(_);return {alert:t,children:n(o,r)}},l(e,n,r){const t={key:r.key};return e.alert&&(t.className="markdown-alert-"+l(e.alert.toLowerCase(),Ae),e.children.unshift({attrs:{},children:[{type:"27",text:e.alert}],noInnerParse:!0,type:"11",tag:"header"})),W("blockquote",t,n(e.children,r))}},1:{t:[" "],o:Me(d),i:1,u:Ue,l:(e,n,r)=>W("br",{key:r.key})},2:{t:["--","__","**","- ","* ","_ "],o:Te(p),i:1,u:Ue,l:(e,n,r)=>W("hr",{key:r.key})},3:{t:[" "],o:Te(h),i:0,u:e=>({lang:void 0,text:Fe(Se(e[0].replace(/^ {4}/gm,"")))}),l:(e,r,t)=>W("pre",{key:t.key},W("code",n({},e.attrs,{className:e.lang?"lang-"+e.lang:""}),e.text))},4:{t:["```","~~~"],o:Te(y),i:0,u:e=>({attrs:ce("code",e[3]||""),lang:e[2]||void 0,text:e[4],type:"3"})},5:{t:["`"],o:Ie(g),i:3,u:e=>({text:Fe(e[2])}),l:(e,n,r)=>W("code",{key:r.key},e.text)},6:{t:["[^"],o:Te(x),i:0,u:e=>(ie.push({footnote:e[2],identifier:e[1]}),{}),l:Ve},7:{t:["[^"],o:Ce(q),i:1,u:e=>({target:"#"+l(e[1],Ae),text:e[1]}),l:(e,n,r)=>W("a",{key:r.key,href:G(e.target,"a","href")},W("sup",{key:r.key},e.text))},8:{t:["[ ]","[x]"],o:Ce($),i:1,u:e=>({completed:"x"===e[1].toLowerCase()}),l:(e,n,r)=>W("input",{checked:e.completed,key:r.key,readOnly:!0,type:"checkbox"})},9:{t:["#"],o:Te(t.enforceAtxHeadings?z:S),i:1,u:(e,n,r)=>({children:Pe(n,e[2],r),id:l(e[2],Ae),level:e[1].length}),l:(e,n,r)=>W("h"+e.level,{id:e.id,key:r.key},n(e.children,r))},10:{t:e=>{const n=e.indexOf("\n");return n>0&&n<e.length-1&&("="===e[n+1]||"-"===e[n+1])},o:Te(E),i:0,u:(e,n,r)=>({children:Pe(n,e[1],r),level:"="===e[2]?1:2,type:"9"})},11:{t:["<"],o:Me(A),i:1,u(e,n,r){const[,t]=e[3].match(ae),o=RegExp("^"+t,"gm"),a=e[3].replace(o,""),i=Q(H,a)?Ne:Pe,u=e[1].toLowerCase(),l=-1!==c.indexOf(u),s=(l?u:e[1]).trim(),f={attrs:ce(s,e[2]),noInnerParse:l,tag:s};if(r.inAnchor=r.inAnchor||"a"===u,l)f.text=e[3];else {const e=r.inHTML;r.inHTML=!0,f.children=i(n,a,r),r.inHTML=e;}return r.inAnchor=!1,f},l:(e,r,t)=>W(e.tag,n({key:t.key},e.attrs),e.text||(e.children?r(e.children,t):""))},13:{t:["<"],o:Me(O),i:1,u(e){const n=e[1].trim();return {attrs:ce(n,e[2]||""),tag:n}},l:(e,r,t)=>W(e.tag,n({},e.attrs,{key:t.key}))},12:{t:["\x3c!--"],o:Me(B),i:1,u:()=>({}),l:Ve},14:{t:["!["],o:Ie(be),i:1,u:e=>({alt:Fe(e[1]),target:Fe(e[2]),title:Fe(e[3])}),l:(e,n,r)=>W("img",{key:r.key,alt:e.alt||void 0,title:e.title||void 0,src:G(e.target,"img","src")})},15:{t:["["],o:Ce(ve),i:3,u:(e,n,r)=>({children:Ze(n,e[1],r),target:Fe(e[2]),title:Fe(e[3])}),l:(e,n,r)=>W("a",{key:r.key,href:G(e.target,"a","href"),title:e.title},n(e.children,r))},16:{t:["<"],o:Ce(I),i:0,u(e){let n=e[1],r=!1;return -1!==n.indexOf("@")&&-1===n.indexOf("//")&&(r=!0,n=n.replace("mailto:","")),{children:[{text:n,type:"27"}],target:r?"mailto:"+n:n,type:"15"}}},17:{t:(e,n)=>!n.inAnchor&&!t.disableAutoLink&&(ze(e,"http://")||ze(e,"https://")),o:Ce(C),i:0,u:e=>({children:[{text:e[1],type:"27"}],target:e[1],title:void 0,type:"15"})},20:qe(W,1),33:qe(W,2),19:{t:["\n"],o:Te(m),i:3,u:Ue,l:()=>"\n"},21:{o:je(function(e,n){if(n.inline||n.simple||n.inHTML&&-1===e.indexOf("\n\n")&&-1===n.prevCapture.indexOf("\n\n"))return null;let r="",t=0;for(;;){const n=e.indexOf("\n",t),o=e.slice(t,-1===n?void 0:n+1);if(Q(V,o))break;if(r+=o,-1===n||!o.trim())break;t=n+1;}const o=Se(r);return ""===o?null:[r,,o]}),i:3,u:Ge,l:(e,n,r)=>W("p",{key:r.key},n(e.children,r))},22:{t:["["],o:Ce(D),i:0,u:e=>(ue[e[1]]={target:e[2],title:e[4]},{}),l:Ve},23:{t:["!["],o:Ie(F),i:0,u:e=>({alt:e[1]?Fe(e[1]):void 0,ref:e[2]}),l:(e,n,r)=>ue[e.ref]?W("img",{key:r.key,alt:e.alt,src:G(ue[e.ref].target,"img","src"),title:ue[e.ref].title}):null},24:{t:e=>"["===e[0]&&-1===e.indexOf("]("),o:Ce(P),i:0,u:(e,n,r)=>({children:n(e[1],r),fallbackChildren:e[0],ref:e[2]}),l:(e,n,r)=>ue[e.ref]?W("a",{key:r.key,href:G(ue[e.ref].target,"a","href"),title:ue[e.ref].title},n(e.children,r)):W("span",{key:r.key},e.fallbackChildren)},25:{t:["|"],o:Te(M),i:1,u:Le,l(e,n,r){const t=e;return W("table",{key:r.key},W("thead",null,W("tr",null,t.header.map(function(e,o){return W("th",{key:o,style:Oe(t,o)},n(e,r))}))),W("tbody",null,t.cells.map(function(e,o){return W("tr",{key:o},e.map(function(e,o){return W("td",{key:o,style:Oe(t,o)},n(e,r))}))})))}},27:{o:je(function(e,n){let r;return ze(e,":")&&(r=ee.exec(e)),r||te.exec(e)}),i:4,u(e){const n=e[0];return {text:-1===n.indexOf("&")?n:n.replace(R,(e,n)=>t.namedCodesToUnicode[n]||e)}},l:e=>e.text},28:{t:["**","__"],o:Ie(J),i:2,u:(e,n,r)=>({children:n(e[2],r)}),l:(e,n,r)=>W("strong",{key:r.key},n(e.children,r))},29:{t:e=>{const n=e[0];return ("*"===n||"_"===n)&&e[1]!==n},o:Ie(K),i:3,u:(e,n,r)=>({children:n(e[2],r)}),l:(e,n,r)=>W("em",{key:r.key},n(e.children,r))},30:{t:["\\"],o:Ie(ne),i:1,u:e=>({text:e[1],type:"27"})},31:{t:["=="],o:Ie(X),i:3,u:Ge,l:(e,n,r)=>W("mark",{key:r.key},n(e.children,r))},32:{t:["~~"],o:Ie(Y),i:3,u:Ge,l:(e,n,r)=>W("del",{key:r.key},n(e.children,r))}};!0===t.disableParsingRawHTML&&(delete le[11],delete le[13]);const se=function(e){var n=Object.keys(e);function r(t,o){var a=[];if(o.prevCapture=o.prevCapture||"",t.trim())for(;t;)for(var c=0;c<n.length;){var i=n[c],u=e[i];if(!u.t||Ee(t,o,u.t)){var l=u.o(t,o);if(l&&l[0]){t=t.substring(l[0].length);var s=u.u(l,r,o);o.prevCapture+=l[0],s.type||(s.type=i),a.push(s);break}c++;}else c++;}return o.prevCapture="",a}return n.sort(function(n,r){return e[n].i-e[r].i||(n<r?-1:1)}),function(e,n){return r(function(e){return e.replace(k,"\n").replace(v,"").replace(N," ")}(e),n)}}(le),fe=function(e,n){return function r(t,o={}){if(Array.isArray(t)){const e=o.key,n=[];let a=!1;for(let e=0;e<t.length;e++){o.key=e;const c=r(t[e],o),i=$e(c);i&&a?n[n.length-1]+=c:null!==c&&n.push(c),a=i;}return o.key=e,n}return function(r,t,o){const a=e[r.type].l;return n?n(()=>a(r,t,o),r,t,o):a(r,t,o)}(t,r,o)}}(le,t.renderRule),_e=re(r);return ie.length?W("div",null,_e,W("footer",{key:"footer"},ie.map(function(e){return W("div",{id:l(e.identifier,Ae),key:e.identifier},e.identifier,fe(se(e.footnote,{inline:!0})))}))):_e}
19759
20012
 
@@ -19765,7 +20018,7 @@
19765
20018
  createElement: createElement
19766
20019
  });
19767
20020
  return function ChatMessage(userProps) {
19768
- var _userProps_classNames = userProps.classNames, classNames = _userProps_classNames === void 0 ? {} : _userProps_classNames, message = userProps.message, status = userProps.status, _userProps_side = userProps.side, side = _userProps_side === void 0 ? 'left' : _userProps_side, _userProps_variant = userProps.variant, variant = _userProps_variant === void 0 ? 'subtle' : _userProps_variant, _userProps_actions = userProps.actions, actions = _userProps_actions === void 0 ? [] : _userProps_actions, _userProps_autoHideActions = userProps.autoHideActions, autoHideActions = _userProps_autoHideActions === void 0 ? false : _userProps_autoHideActions, LeadingComponent = userProps.leadingComponent, ActionsComponent = userProps.actionsComponent, FooterComponent = userProps.footerComponent, _userProps_tools = userProps.tools, tools = _userProps_tools === void 0 ? {} : _userProps_tools, indexUiState = userProps.indexUiState, setIndexUiState = userProps.setIndexUiState, onClose = userProps.onClose, userTranslations = userProps.translations, suggestionsElement = userProps.suggestionsElement, props = _object_without_properties(userProps, [
20021
+ var _userProps_classNames = userProps.classNames, classNames = _userProps_classNames === void 0 ? {} : _userProps_classNames, message = userProps.message, status = userProps.status, _userProps_side = userProps.side, side = _userProps_side === void 0 ? 'left' : _userProps_side, _userProps_variant = userProps.variant, variant = _userProps_variant === void 0 ? 'subtle' : _userProps_variant, _userProps_actions = userProps.actions, actions = _userProps_actions === void 0 ? [] : _userProps_actions, _userProps_autoHideActions = userProps.autoHideActions, autoHideActions = _userProps_autoHideActions === void 0 ? false : _userProps_autoHideActions, LeadingComponent = userProps.leadingComponent, ActionsComponent = userProps.actionsComponent, FooterComponent = userProps.footerComponent, _userProps_tools = userProps.tools, tools = _userProps_tools === void 0 ? {} : _userProps_tools, indexUiState = userProps.indexUiState, setIndexUiState = userProps.setIndexUiState, messages = userProps.messages, onClose = userProps.onClose, userTranslations = userProps.translations, suggestionsElement = userProps.suggestionsElement, props = _object_without_properties(userProps, [
19769
20022
  "classNames",
19770
20023
  "message",
19771
20024
  "status",
@@ -19779,6 +20032,7 @@
19779
20032
  "tools",
19780
20033
  "indexUiState",
19781
20034
  "setIndexUiState",
20035
+ "messages",
19782
20036
  "onClose",
19783
20037
  "translations",
19784
20038
  "suggestionsElement"
@@ -19854,6 +20108,7 @@
19854
20108
  message: toolMessage,
19855
20109
  indexUiState: indexUiState,
19856
20110
  setIndexUiState: setIndexUiState,
20111
+ messages: messages,
19857
20112
  addToolResult: boundAddToolResult,
19858
20113
  applyFilters: tool.applyFilters,
19859
20114
  sendEvent: tool.sendEvent || function() {},
@@ -19908,15 +20163,32 @@
19908
20163
  createElement: createElement
19909
20164
  });
19910
20165
  return function ChatMessageError(userProps) {
19911
- var onReload = userProps.onReload, actions = userProps.actions, userTranslations = userProps.translations, props = _object_without_properties(userProps, [
20166
+ var _ref, _ref1;
20167
+ var errorMessage = userProps.errorMessage, onReload = userProps.onReload, onNewConversation = userProps.onNewConversation, actions = userProps.actions, userTranslations = userProps.translations, props = _object_without_properties(userProps, [
20168
+ "errorMessage",
19912
20169
  "onReload",
20170
+ "onNewConversation",
19913
20171
  "actions",
19914
20172
  "translations"
19915
20173
  ]);
19916
- var translations = _object_spread({
19917
- errorMessage: 'Sorry, we are not able to generate a response at the moment. Please retry or contact support.',
19918
- retryText: 'Retry'
19919
- }, userTranslations);
20174
+ var defaultErrorMessage = 'Sorry, we are not able to generate a response at the moment. Please contact support.';
20175
+ var defaultNewConversationText = 'Start a new conversation';
20176
+ var defaultRetryText = 'Retry';
20177
+ var errorMessageTranslation = userTranslations === null || userTranslations === void 0 ? void 0 : userTranslations.errorMessage;
20178
+ var resolvedErrorMessage = typeof errorMessageTranslation === 'function' ? errorMessageTranslation({
20179
+ errorMessage: errorMessage
20180
+ }) : errorMessageTranslation !== null && errorMessageTranslation !== void 0 ? errorMessageTranslation : defaultErrorMessage;
20181
+ var newConversationText = (_ref = userTranslations === null || userTranslations === void 0 ? void 0 : userTranslations.newConversationText) !== null && _ref !== void 0 ? _ref : defaultNewConversationText;
20182
+ var retryText = (_ref1 = userTranslations === null || userTranslations === void 0 ? void 0 : userTranslations.retryText) !== null && _ref1 !== void 0 ? _ref1 : defaultRetryText;
20183
+ // Action precedence:
20184
+ // 1. `actions` (full custom)
20185
+ // 2. `onNewConversation` (recommended for permanent / guardrail errors)
20186
+ // 3. `onReload` (legacy retry, suitable for transient failures)
20187
+ // 4. nothing
20188
+ var hasCustomActions = Boolean(actions);
20189
+ var showNewConversation = !hasCustomActions && Boolean(onNewConversation);
20190
+ var showRetry = !hasCustomActions && !showNewConversation && Boolean(onReload);
20191
+ var hasActions = hasCustomActions || showNewConversation || showRetry;
19920
20192
  return /*#__PURE__*/ createElement("article", _object_spread({
19921
20193
  className: "ais-ChatMessageError ais-ChatMessage ais-ChatMessage--left ais-ChatMessage--subtle"
19922
20194
  }, props), /*#__PURE__*/ createElement("div", {
@@ -19925,15 +20197,22 @@
19925
20197
  className: "ais-ChatMessage-content"
19926
20198
  }, /*#__PURE__*/ createElement("div", {
19927
20199
  className: "ais-ChatMessage-message"
19928
- }, translations.errorMessage), (actions || onReload) && /*#__PURE__*/ createElement("div", {
20200
+ }, resolvedErrorMessage), hasActions && /*#__PURE__*/ createElement("div", {
19929
20201
  className: "ais-ChatMessage-actions"
19930
- }, actions ? actions.map(function(action, index) {
20202
+ }, hasCustomActions ? actions.map(function(action, index) {
19931
20203
  return /*#__PURE__*/ createElement(Button, _object_spread({
19932
20204
  key: index,
19933
20205
  variant: "ghost",
19934
20206
  className: "ais-ChatMessage-action"
19935
20207
  }, action), action.children);
19936
- }) : /*#__PURE__*/ createElement(Button, {
20208
+ }) : showNewConversation ? /*#__PURE__*/ createElement(Button, {
20209
+ variant: "primary",
20210
+ size: "md",
20211
+ className: "ais-ChatMessage-errorAction",
20212
+ onClick: function onClick() {
20213
+ return onNewConversation === null || onNewConversation === void 0 ? void 0 : onNewConversation();
20214
+ }
20215
+ }, newConversationText) : /*#__PURE__*/ createElement(Button, {
19937
20216
  variant: "primary",
19938
20217
  size: "md",
19939
20218
  className: "ais-ChatMessage-errorAction",
@@ -19942,7 +20221,7 @@
19942
20221
  }
19943
20222
  }, /*#__PURE__*/ createElement(ReloadIcon, {
19944
20223
  createElement: createElement
19945
- }), translations.retryText)))));
20224
+ }), retryText)))));
19946
20225
  };
19947
20226
  }
19948
20227
 
@@ -19991,7 +20270,7 @@
19991
20270
  Fragment: Fragment
19992
20271
  });
19993
20272
  return function DefaultMessage(param) {
19994
- var message = param.message, status = param.status, userMessageProps = param.userMessageProps, assistantMessageProps = param.assistantMessageProps, tools = param.tools, indexUiState = param.indexUiState, setIndexUiState = param.setIndexUiState, onReload = param.onReload, onClose = param.onClose, onFeedback = param.onFeedback, feedbackState = param.feedbackState, actionsComponent = param.actionsComponent, classNames = param.classNames, messageTranslations = param.messageTranslations, translations = param.translations, suggestionsElement = param.suggestionsElement;
20273
+ var message = param.message, status = param.status, userMessageProps = param.userMessageProps, assistantMessageProps = param.assistantMessageProps, tools = param.tools, indexUiState = param.indexUiState, setIndexUiState = param.setIndexUiState, messages = param.messages, onReload = param.onReload, onClose = param.onClose, onFeedback = param.onFeedback, feedbackState = param.feedbackState, actionsComponent = param.actionsComponent, classNames = param.classNames, messageTranslations = param.messageTranslations, translations = param.translations, suggestionsElement = param.suggestionsElement;
19995
20274
  var defaultAssistantActions = _to_consumable_array(hasTextContent(message) ? [
19996
20275
  {
19997
20276
  title: translations.copyToClipboardLabel,
@@ -20079,6 +20358,7 @@
20079
20358
  tools: tools,
20080
20359
  indexUiState: indexUiState,
20081
20360
  setIndexUiState: setIndexUiState,
20361
+ messages: messages,
20082
20362
  onClose: onClose,
20083
20363
  actions: defaultActions,
20084
20364
  actionsComponent: actionsComponent,
@@ -20106,7 +20386,7 @@
20106
20386
  });
20107
20387
  return function ChatMessages(userProps) {
20108
20388
  var _lastMessage_parts;
20109
- var _userProps_classNames = userProps.classNames, classNames = _userProps_classNames === void 0 ? {} : _userProps_classNames, _userProps_messageClassNames = userProps.messageClassNames, messageClassNames = _userProps_messageClassNames === void 0 ? {} : _userProps_messageClassNames, messageTranslations = userProps.messageTranslations, _userProps_messages = userProps.messages, messages = _userProps_messages === void 0 ? [] : _userProps_messages, MessageComponent = userProps.messageComponent, LoaderComponent = userProps.loaderComponent, ErrorComponent = userProps.errorComponent, EmptyComponent = userProps.emptyComponent, ActionsComponent = userProps.actionsComponent, tools = userProps.tools, indexUiState = userProps.indexUiState, setIndexUiState = userProps.setIndexUiState, _userProps_status = userProps.status, status = _userProps_status === void 0 ? 'ready' : _userProps_status, _userProps_hideScrollToBottom = userProps.hideScrollToBottom, hideScrollToBottom = _userProps_hideScrollToBottom === void 0 ? false : _userProps_hideScrollToBottom, onReload = userProps.onReload, onClose = userProps.onClose, sendMessage = userProps.sendMessage, setInput = userProps.setInput, userTranslations = userProps.translations, userMessageProps = userProps.userMessageProps, assistantMessageProps = userProps.assistantMessageProps, _userProps_isClearing = userProps.isClearing, isClearing = _userProps_isClearing === void 0 ? false : _userProps_isClearing, onClearTransitionEnd = userProps.onClearTransitionEnd, isScrollAtBottom = userProps.isScrollAtBottom, scrollRef = userProps.scrollRef, contentRef = userProps.contentRef, onScrollToBottom = userProps.onScrollToBottom, suggestionsElement = userProps.suggestionsElement, onFeedback = userProps.onFeedback, feedbackState = userProps.feedbackState, props = _object_without_properties(userProps, [
20389
+ var _userProps_classNames = userProps.classNames, classNames = _userProps_classNames === void 0 ? {} : _userProps_classNames, _userProps_messageClassNames = userProps.messageClassNames, messageClassNames = _userProps_messageClassNames === void 0 ? {} : _userProps_messageClassNames, messageTranslations = userProps.messageTranslations, _userProps_messages = userProps.messages, messages = _userProps_messages === void 0 ? [] : _userProps_messages, MessageComponent = userProps.messageComponent, LoaderComponent = userProps.loaderComponent, ErrorComponent = userProps.errorComponent, EmptyComponent = userProps.emptyComponent, ActionsComponent = userProps.actionsComponent, tools = userProps.tools, indexUiState = userProps.indexUiState, setIndexUiState = userProps.setIndexUiState, _userProps_status = userProps.status, status = _userProps_status === void 0 ? 'ready' : _userProps_status, error = userProps.error, _userProps_hideScrollToBottom = userProps.hideScrollToBottom, hideScrollToBottom = _userProps_hideScrollToBottom === void 0 ? false : _userProps_hideScrollToBottom, onReload = userProps.onReload, onNewConversation = userProps.onNewConversation, onClose = userProps.onClose, sendMessage = userProps.sendMessage, setInput = userProps.setInput, userTranslations = userProps.translations, userMessageProps = userProps.userMessageProps, assistantMessageProps = userProps.assistantMessageProps, _userProps_isClearing = userProps.isClearing, isClearing = _userProps_isClearing === void 0 ? false : _userProps_isClearing, onClearTransitionEnd = userProps.onClearTransitionEnd, isScrollAtBottom = userProps.isScrollAtBottom, scrollRef = userProps.scrollRef, contentRef = userProps.contentRef, onScrollToBottom = userProps.onScrollToBottom, suggestionsElement = userProps.suggestionsElement, onFeedback = userProps.onFeedback, feedbackState = userProps.feedbackState, props = _object_without_properties(userProps, [
20110
20390
  "classNames",
20111
20391
  "messageClassNames",
20112
20392
  "messageTranslations",
@@ -20120,8 +20400,10 @@
20120
20400
  "indexUiState",
20121
20401
  "setIndexUiState",
20122
20402
  "status",
20403
+ "error",
20123
20404
  "hideScrollToBottom",
20124
20405
  "onReload",
20406
+ "onNewConversation",
20125
20407
  "onClose",
20126
20408
  "sendMessage",
20127
20409
  "setInput",
@@ -20191,6 +20473,7 @@
20191
20473
  tools: tools,
20192
20474
  indexUiState: indexUiState,
20193
20475
  setIndexUiState: setIndexUiState,
20476
+ messages: messages,
20194
20477
  onReload: onReload,
20195
20478
  onFeedback: onFeedback,
20196
20479
  feedbackState: feedbackState,
@@ -20206,7 +20489,18 @@
20206
20489
  loaderText: translations.loaderText
20207
20490
  }
20208
20491
  }), status === 'error' && /*#__PURE__*/ createElement(DefaultError, {
20209
- onReload: onReload
20492
+ onNewConversation: onNewConversation,
20493
+ errorMessage: error === null || error === void 0 ? void 0 : error.message,
20494
+ translations: // `fallbackResponse` that's safe to display verbatim; for
20495
+ // every other error we keep hiding the raw `error.message`
20496
+ // behind the friendly default. Detection is by `error.name`
20497
+ // to avoid coupling this package to `instantsearch.js`.
20498
+ (error === null || error === void 0 ? void 0 : error.name) === 'GuardrailViolationError' ? {
20499
+ errorMessage: function errorMessage(param) {
20500
+ var rawMessage = param.errorMessage;
20501
+ return rawMessage !== null && rawMessage !== void 0 ? rawMessage : '';
20502
+ }
20503
+ } : undefined
20210
20504
  }))), /*#__PURE__*/ createElement(Button, {
20211
20505
  variant: "outline",
20212
20506
  size: "sm",
@@ -20506,6 +20800,7 @@
20506
20800
  maximized: maximized
20507
20801
  }));
20508
20802
  var messagesComponent = /*#__PURE__*/ createElement(ChatMessages, _object_spread_props(_object_spread({}, messagesProps), {
20803
+ error: error,
20509
20804
  classNames: classNames.messages,
20510
20805
  messageClassNames: classNames.message,
20511
20806
  suggestionsElement: createElement(SuggestionsComponent || ChatPromptSuggestions, _object_spread_props(_object_spread({}, suggestionsProps), {
@@ -20718,11 +21013,18 @@
20718
21013
  streamingLabel: 'Curating results…'
20719
21014
  };
20720
21015
  function createDisplayResultsToolComponent(param) {
20721
- var createElement = param.createElement, Fragment = param.Fragment;
21016
+ var createElement = param.createElement, Fragment = param.Fragment, useMemo = param.useMemo;
20722
21017
  return function DisplayResultsTool(userProps) {
20723
- var toolProps = userProps.toolProps, GroupCarousel = userProps.groupCarouselComponent, userTranslations = userProps.translations;
20724
- var message = toolProps.message, sendEvent = toolProps.sendEvent;
21018
+ var toolProps = userProps.toolProps, renderGroupCarousel = userProps.groupCarouselComponent, userTranslations = userProps.translations;
21019
+ var message = toolProps.message, messages = toolProps.messages, sendEvent = toolProps.sendEvent;
20725
21020
  var translations = _object_spread({}, DEFAULT_TRANSLATIONS$1, userTranslations);
21021
+ var toolCallId = message === null || message === void 0 ? void 0 : message.toolCallId;
21022
+ var hitsByObjectID = useMemo(function() {
21023
+ return messages ? getHitsByObjectID(messages, toolCallId) : undefined;
21024
+ }, [
21025
+ messages,
21026
+ toolCallId
21027
+ ]);
20726
21028
  var output = message === null || message === void 0 ? void 0 : message.output;
20727
21029
  var intro = typeof (output === null || output === void 0 ? void 0 : output.intro) === 'string' ? output.intro : undefined;
20728
21030
  var groups = Array.isArray(output === null || output === void 0 ? void 0 : output.groups) ? output.groups : [];
@@ -20740,8 +21042,11 @@
20740
21042
  }) : [];
20741
21043
  if (results.length === 0) return null;
20742
21044
  var items = results.map(function(result, idx) {
20743
- return _object_spread_props(_object_spread({}, result), {
20744
- __position: idx + 1
21045
+ var hydrated = hitsByObjectID === null || hitsByObjectID === void 0 ? void 0 : hitsByObjectID[result.objectID];
21046
+ return _object_spread_props(_object_spread({}, hydrated), {
21047
+ objectID: result.objectID,
21048
+ __position: idx + 1,
21049
+ __displayToolResult: result
20745
21050
  });
20746
21051
  });
20747
21052
  return /*#__PURE__*/ createElement("div", {
@@ -20751,7 +21056,7 @@
20751
21056
  className: "ais-ChatToolDisplayResults-groupTitle"
20752
21057
  }, group.title), group.why && /*#__PURE__*/ createElement("div", {
20753
21058
  className: "ais-ChatToolDisplayResults-groupWhy"
20754
- }, group.why), /*#__PURE__*/ createElement(GroupCarousel, {
21059
+ }, group.why), renderGroupCarousel({
20755
21060
  items: items,
20756
21061
  sendEvent: sendEvent
20757
21062
  }));
@@ -22667,7 +22972,8 @@
22667
22972
  function createDisplayResultsTool(itemComponent) {
22668
22973
  var DisplayResultsUIComponent = createDisplayResultsToolComponent({
22669
22974
  createElement: React.createElement,
22670
- Fragment: React.Fragment
22975
+ Fragment: React.Fragment,
22976
+ useMemo: React.useMemo
22671
22977
  });
22672
22978
  var Button = createButtonComponent({
22673
22979
  createElement: React.createElement
@@ -22774,7 +23080,7 @@
22774
23080
  if (!input || !applyFilters) return;
22775
23081
  var params = applyFilters({
22776
23082
  query: input.query,
22777
- facetFilters: input.facet_filters
23083
+ facetFilters: getFacetFiltersFromToolInput(input)
22778
23084
  });
22779
23085
  if (getSearchPageURL && new URL(getSearchPageURL(params)).pathname !== window.location.pathname) {
22780
23086
  window.location.href = getSearchPageURL(params);
@@ -22817,7 +23123,7 @@
22817
23123
  });
22818
23124
  function createDefaultTools(itemComponent, getSearchPageURL) {
22819
23125
  var _obj;
22820
- return _obj = {}, _define_property(_obj, SearchIndexToolType$1, createCarouselTool(true, itemComponent, getSearchPageURL)), _define_property(_obj, RecommendToolType, createCarouselTool(false, itemComponent, getSearchPageURL)), _define_property(_obj, DisplayResultsToolType, createDisplayResultsTool(itemComponent)), _define_property(_obj, MemorizeToolType, {}), _define_property(_obj, MemorySearchToolType, {}), _define_property(_obj, PonderToolType, {}), _obj;
23126
+ return _obj = {}, _define_property(_obj, SearchIndexToolType$2, createCarouselTool(true, itemComponent, getSearchPageURL)), _define_property(_obj, RecommendToolType, createCarouselTool(false, itemComponent, getSearchPageURL)), _define_property(_obj, DisplayResultsToolType, createDisplayResultsTool(itemComponent)), _define_property(_obj, MemorizeToolType, {}), _define_property(_obj, MemorySearchToolType, {}), _define_property(_obj, PonderToolType, {}), _obj;
22821
23127
  }
22822
23128
  function ChatInner(_0, _1) {
22823
23129
  var _ref = [
@@ -22932,13 +23238,14 @@
22932
23238
  maximizeIconComponent: headerMaximizeIconComponent,
22933
23239
  translations: headerTranslations
22934
23240
  }, headerProps),
22935
- messagesProps: _object_spread({
23241
+ messagesProps: _object_spread_props(_object_spread({
22936
23242
  status: status,
22937
23243
  onReload: function onReload(messageId) {
22938
23244
  return regenerate({
22939
23245
  messageId: messageId
22940
23246
  });
22941
23247
  },
23248
+ onNewConversation: clearMessages,
22942
23249
  onClose: function onClose() {
22943
23250
  return setOpen(false);
22944
23251
  },
@@ -22970,7 +23277,9 @@
22970
23277
  }, messagesProps === null || messagesProps === void 0 ? void 0 : messagesProps.userMessageProps),
22971
23278
  translations: messagesTranslations,
22972
23279
  messageTranslations: messageTranslations
22973
- }, messagesProps),
23280
+ }, messagesProps), {
23281
+ error: error
23282
+ }),
22974
23283
  promptProps: _object_spread({
22975
23284
  promptRef: promptRef,
22976
23285
  status: status,
@@ -24848,7 +25157,7 @@
24848
25157
  exports.RelatedProducts = RelatedProducts;
24849
25158
  exports.ReverseHighlight = ReverseHighlight;
24850
25159
  exports.SearchBox = SearchBox;
24851
- exports.SearchIndexToolType = SearchIndexToolType$1;
25160
+ exports.SearchIndexToolType = SearchIndexToolType$2;
24852
25161
  exports.Snippet = Snippet;
24853
25162
  exports.SortBy = SortBy;
24854
25163
  exports.Stats = Stats;