react-instantsearch 7.49.1 → 7.50.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/cjs/widgets/Chat.js +12 -12
- package/dist/cjs/widgets/CompareBar.js +46 -0
- package/dist/cjs/widgets/chat/tools/CompareProductsTool.js +50 -0
- package/dist/cjs/widgets/chat/tools/ComparisonTableTool.js +40 -0
- package/dist/cjs/widgets/chat/tools/{DisplayResultsTool.js → GroupedResultsTool.js} +11 -11
- package/dist/cjs/widgets/index.js +1 -0
- package/dist/es/index.js +2 -1
- package/dist/es/widgets/Chat.d.ts +2 -2
- package/dist/es/widgets/Chat.js +10 -14
- package/dist/es/widgets/CompareBar.d.ts +27 -0
- package/dist/es/widgets/CompareBar.js +45 -0
- package/dist/es/widgets/chat/tools/CompareProductsTool.d.ts +13 -0
- package/dist/es/widgets/chat/tools/CompareProductsTool.js +41 -0
- package/dist/es/widgets/chat/tools/ComparisonTableTool.d.ts +15 -0
- package/dist/es/widgets/chat/tools/ComparisonTableTool.js +31 -0
- package/dist/es/widgets/chat/tools/{DisplayResultsTool.js → GroupedResultsTool.js} +12 -12
- package/dist/es/widgets/index.d.ts +1 -0
- package/dist/es/widgets/index.js +2 -1
- package/dist/umd/ReactInstantSearch.js +639 -95
- package/dist/umd/ReactInstantSearch.min.js +3 -3
- package/package.json +5 -5
- /package/dist/es/widgets/chat/tools/{DisplayResultsTool.d.ts → GroupedResultsTool.d.ts} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! React InstantSearch 7.
|
|
1
|
+
/*! React InstantSearch 7.50.0 | © 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.
|
|
27
|
+
var version$2 = '7.50.0';
|
|
28
28
|
|
|
29
29
|
function _define_property(obj, key, value) {
|
|
30
30
|
if (key in obj) {
|
|
@@ -5980,7 +5980,7 @@
|
|
|
5980
5980
|
}
|
|
5981
5981
|
}
|
|
5982
5982
|
|
|
5983
|
-
var withUsage$
|
|
5983
|
+
var withUsage$y = createDocumentationMessageGenerator({
|
|
5984
5984
|
name: 'configure',
|
|
5985
5985
|
connector: true
|
|
5986
5986
|
});
|
|
@@ -5996,7 +5996,7 @@
|
|
|
5996
5996
|
var renderFn = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : noop, unmountFn = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : noop;
|
|
5997
5997
|
return function(widgetParams) {
|
|
5998
5998
|
if (!widgetParams || !isPlainObject(widgetParams.searchParameters)) {
|
|
5999
|
-
throw new Error(withUsage$
|
|
5999
|
+
throw new Error(withUsage$y('The `searchParameters` option expects an object.'));
|
|
6000
6000
|
}
|
|
6001
6001
|
var connectorState = {};
|
|
6002
6002
|
function refine(helper) {
|
|
@@ -7808,13 +7808,13 @@
|
|
|
7808
7808
|
return null;
|
|
7809
7809
|
}
|
|
7810
7810
|
|
|
7811
|
-
var withUsage$
|
|
7811
|
+
var withUsage$x = createDocumentationMessageGenerator({
|
|
7812
7812
|
name: 'dynamic-widgets',
|
|
7813
7813
|
connector: true
|
|
7814
7814
|
});
|
|
7815
7815
|
var connectDynamicWidgets = function connectDynamicWidgets(renderFn) {
|
|
7816
7816
|
var unmountFn = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : noop;
|
|
7817
|
-
checkRendering(renderFn, withUsage$
|
|
7817
|
+
checkRendering(renderFn, withUsage$x());
|
|
7818
7818
|
return function(widgetParams) {
|
|
7819
7819
|
var widgets = widgetParams.widgets, _widgetParams_maxValuesPerFacet = widgetParams.maxValuesPerFacet, maxValuesPerFacet = _widgetParams_maxValuesPerFacet === void 0 ? 20 : _widgetParams_maxValuesPerFacet, _widgetParams_facets = widgetParams.facets, facets = _widgetParams_facets === void 0 ? [
|
|
7820
7820
|
'*'
|
|
@@ -7824,10 +7824,10 @@
|
|
|
7824
7824
|
if (!(widgets && Array.isArray(widgets) && widgets.every(function(widget) {
|
|
7825
7825
|
return (typeof widget === "undefined" ? "undefined" : _type_of(widget)) === 'object';
|
|
7826
7826
|
}))) {
|
|
7827
|
-
throw new Error(withUsage$
|
|
7827
|
+
throw new Error(withUsage$x('The `widgets` option expects an array of widgets.'));
|
|
7828
7828
|
}
|
|
7829
7829
|
if (!Array.isArray(facets)) {
|
|
7830
|
-
throw new Error(withUsage$
|
|
7830
|
+
throw new Error(withUsage$x("The `facets` option only accepts an array of facets, you passed ".concat(JSON.stringify(facets))));
|
|
7831
7831
|
}
|
|
7832
7832
|
var localWidgets = new Map();
|
|
7833
7833
|
return {
|
|
@@ -7929,7 +7929,7 @@
|
|
|
7929
7929
|
results: results
|
|
7930
7930
|
});
|
|
7931
7931
|
if (!Array.isArray(attributesToRender)) {
|
|
7932
|
-
throw new Error(withUsage$
|
|
7932
|
+
throw new Error(withUsage$x('The `transformItems` option expects a function that returns an Array.'));
|
|
7933
7933
|
}
|
|
7934
7934
|
return {
|
|
7935
7935
|
attributesToRender: attributesToRender,
|
|
@@ -8319,19 +8319,19 @@
|
|
|
8319
8319
|
return toFeedSearchResults(lastResults._state, raw);
|
|
8320
8320
|
});
|
|
8321
8321
|
}
|
|
8322
|
-
var withUsage$
|
|
8322
|
+
var withUsage$w = createDocumentationMessageGenerator({
|
|
8323
8323
|
name: 'feeds',
|
|
8324
8324
|
connector: true
|
|
8325
8325
|
});
|
|
8326
8326
|
var connectFeeds = function connectFeeds(renderFn) {
|
|
8327
8327
|
var unmountFn = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : noop;
|
|
8328
|
-
checkRendering(renderFn, withUsage$
|
|
8328
|
+
checkRendering(renderFn, withUsage$w());
|
|
8329
8329
|
return function(widgetParams) {
|
|
8330
8330
|
var isolated = widgetParams.isolated, _widgetParams_transformFeeds = widgetParams.transformFeeds, transformFeeds = _widgetParams_transformFeeds === void 0 ? function(feeds) {
|
|
8331
8331
|
return feeds;
|
|
8332
8332
|
} : _widgetParams_transformFeeds;
|
|
8333
8333
|
if (isolated !== false) {
|
|
8334
|
-
throw new Error(withUsage$
|
|
8334
|
+
throw new Error(withUsage$w('The `isolated` option currently only supports `false`.'));
|
|
8335
8335
|
}
|
|
8336
8336
|
return {
|
|
8337
8337
|
$$type: 'ais.feeds',
|
|
@@ -8339,7 +8339,7 @@
|
|
|
8339
8339
|
init: function init(initOptions) {
|
|
8340
8340
|
var instantSearchInstance = initOptions.instantSearchInstance;
|
|
8341
8341
|
if (!instantSearchInstance.compositionID) {
|
|
8342
|
-
throw new Error(withUsage$
|
|
8342
|
+
throw new Error(withUsage$w('The `feeds` widget requires a composition-based InstantSearch instance (compositionID must be set).'));
|
|
8343
8343
|
}
|
|
8344
8344
|
hydrateFeedsFromInitialResultsIfNeeded(instantSearchInstance, initOptions.parent);
|
|
8345
8345
|
renderFn(_object_spread_props(_object_spread({}, this.getWidgetRenderState(initOptions)), {
|
|
@@ -8385,12 +8385,12 @@
|
|
|
8385
8385
|
];
|
|
8386
8386
|
feedIDs = transformFeeds(feedIDs);
|
|
8387
8387
|
if (!Array.isArray(feedIDs)) {
|
|
8388
|
-
throw new Error(withUsage$
|
|
8388
|
+
throw new Error(withUsage$w('The `transformFeeds` option expects a function that returns an Array.'));
|
|
8389
8389
|
}
|
|
8390
8390
|
if (!feedIDs.every(function(feedID) {
|
|
8391
8391
|
return typeof feedID === 'string';
|
|
8392
8392
|
})) {
|
|
8393
|
-
throw new Error(withUsage$
|
|
8393
|
+
throw new Error(withUsage$w('The `transformFeeds` option expects a function that returns an array of feed IDs (strings).'));
|
|
8394
8394
|
}
|
|
8395
8395
|
return {
|
|
8396
8396
|
feedIDs: feedIDs,
|
|
@@ -8501,7 +8501,7 @@
|
|
|
8501
8501
|
}));
|
|
8502
8502
|
}
|
|
8503
8503
|
|
|
8504
|
-
var withUsage$
|
|
8504
|
+
var withUsage$v = createDocumentationMessageGenerator({
|
|
8505
8505
|
name: 'index-widget'
|
|
8506
8506
|
});
|
|
8507
8507
|
/**
|
|
@@ -8629,7 +8629,7 @@
|
|
|
8629
8629
|
var index = function index(widgetParams) {
|
|
8630
8630
|
var _widgetParams_EXPERIMENTAL_isolated;
|
|
8631
8631
|
if (widgetParams === undefined || widgetParams.indexName === undefined && !widgetParams.isolated && !widgetParams.EXPERIMENTAL_isolated) {
|
|
8632
|
-
throw new Error(withUsage$
|
|
8632
|
+
throw new Error(withUsage$v('The `indexName` option is required.'));
|
|
8633
8633
|
}
|
|
8634
8634
|
// When isolated=true, we use an empty string as the default indexName.
|
|
8635
8635
|
// This is intentional: isolated indices do not require a real index name.
|
|
@@ -8727,7 +8727,7 @@
|
|
|
8727
8727
|
addWidgets: function addWidgets(widgets) {
|
|
8728
8728
|
var _this = this;
|
|
8729
8729
|
if (!Array.isArray(widgets)) {
|
|
8730
|
-
throw new Error(withUsage$
|
|
8730
|
+
throw new Error(withUsage$v('The `addWidgets` method expects an array of widgets.'));
|
|
8731
8731
|
}
|
|
8732
8732
|
var flatWidgets = widgets.reduce(function(acc, w) {
|
|
8733
8733
|
return acc.concat(Array.isArray(w) ? w : [
|
|
@@ -8737,7 +8737,7 @@
|
|
|
8737
8737
|
if (flatWidgets.some(function(widget) {
|
|
8738
8738
|
return typeof widget.init !== 'function' && typeof widget.render !== 'function';
|
|
8739
8739
|
})) {
|
|
8740
|
-
throw new Error(withUsage$
|
|
8740
|
+
throw new Error(withUsage$v('The widget definition expects a `render` and/or an `init` method.'));
|
|
8741
8741
|
}
|
|
8742
8742
|
flatWidgets.forEach(function(widget) {
|
|
8743
8743
|
widget.parent = _this;
|
|
@@ -8787,10 +8787,10 @@
|
|
|
8787
8787
|
},
|
|
8788
8788
|
updateWidget: function updateWidget(previousWidget, nextWidget) {
|
|
8789
8789
|
if (typeof previousWidget.dispose !== 'function') {
|
|
8790
|
-
throw new Error(withUsage$
|
|
8790
|
+
throw new Error(withUsage$v('The widget definition expects a `dispose` method.'));
|
|
8791
8791
|
}
|
|
8792
8792
|
if (typeof nextWidget.init !== 'function' && typeof nextWidget.render !== 'function') {
|
|
8793
|
-
throw new Error(withUsage$
|
|
8793
|
+
throw new Error(withUsage$v('The widget definition expects a `render` and/or an `init` method.'));
|
|
8794
8794
|
}
|
|
8795
8795
|
// The `uiState` as it is before the previous widget is detached, so that
|
|
8796
8796
|
// the state it owns can be handed over to the next widget.
|
|
@@ -8874,7 +8874,7 @@
|
|
|
8874
8874
|
removeWidgets: function removeWidgets(widgets) {
|
|
8875
8875
|
var _this = this;
|
|
8876
8876
|
if (!Array.isArray(widgets)) {
|
|
8877
|
-
throw new Error(withUsage$
|
|
8877
|
+
throw new Error(withUsage$v('The `removeWidgets` method expects an array of widgets.'));
|
|
8878
8878
|
}
|
|
8879
8879
|
var flatWidgets = widgets.reduce(function(acc, w) {
|
|
8880
8880
|
return acc.concat(Array.isArray(w) ? w : [
|
|
@@ -8884,7 +8884,7 @@
|
|
|
8884
8884
|
if (flatWidgets.some(function(widget) {
|
|
8885
8885
|
return typeof widget.dispose !== 'function';
|
|
8886
8886
|
})) {
|
|
8887
|
-
throw new Error(withUsage$
|
|
8887
|
+
throw new Error(withUsage$v('The widget definition expects a `dispose` method.'));
|
|
8888
8888
|
}
|
|
8889
8889
|
localWidgets = localWidgets.filter(function(widget) {
|
|
8890
8890
|
return flatWidgets.indexOf(widget) === -1;
|
|
@@ -9392,7 +9392,7 @@
|
|
|
9392
9392
|
});
|
|
9393
9393
|
}
|
|
9394
9394
|
|
|
9395
|
-
var version = '4.
|
|
9395
|
+
var version = '4.118.0';
|
|
9396
9396
|
|
|
9397
9397
|
var ANONYMOUS_TOKEN_COOKIE_KEY = '_ALGOLIA';
|
|
9398
9398
|
function getCookie(name) {
|
|
@@ -11254,7 +11254,7 @@
|
|
|
11254
11254
|
};
|
|
11255
11255
|
}
|
|
11256
11256
|
|
|
11257
|
-
var withUsage$
|
|
11257
|
+
var withUsage$u = createDocumentationMessageGenerator({
|
|
11258
11258
|
name: 'instantsearch'
|
|
11259
11259
|
});
|
|
11260
11260
|
function defaultCreateURL() {
|
|
@@ -11325,7 +11325,7 @@
|
|
|
11325
11325
|
_this.setMaxListeners(100);
|
|
11326
11326
|
var _options_indexName = options.indexName, indexName = _options_indexName === void 0 ? '' : _options_indexName, compositionID = options.compositionID, numberLocale = options.numberLocale, _options_initialUiState = options.initialUiState, initialUiState = _options_initialUiState === void 0 ? {} : _options_initialUiState, _options_routing = options.routing, routing = _options_routing === void 0 ? null : _options_routing, _options_insights = options.insights, insights = _options_insights === void 0 ? undefined : _options_insights, searchFunction = options.searchFunction, _options_stalledSearchDelay = options.stalledSearchDelay, stalledSearchDelay = _options_stalledSearchDelay === void 0 ? 200 : _options_stalledSearchDelay, _options_searchClient = options.searchClient, searchClient = _options_searchClient === void 0 ? null : _options_searchClient, _options_insightsClient = options.insightsClient, insightsClient = _options_insightsClient === void 0 ? null : _options_insightsClient, _options_onStateChange = options.onStateChange, onStateChange = _options_onStateChange === void 0 ? null : _options_onStateChange, _options_future1 = options.future, future = _options_future1 === void 0 ? _object_spread({}, INSTANTSEARCH_FUTURE_DEFAULTS, options.future || {}) : _options_future1;
|
|
11327
11327
|
if (searchClient === null) {
|
|
11328
|
-
throw new Error(withUsage$
|
|
11328
|
+
throw new Error(withUsage$u('The `searchClient` option is required.'));
|
|
11329
11329
|
}
|
|
11330
11330
|
if (typeof searchClient.search !== 'function') {
|
|
11331
11331
|
throw new Error("The `searchClient` must implement a `search` method.\n\nSee: https://www.algolia.com/doc/guides/building-search-ui/going-further/backend-search/in-depth/backend-instantsearch/js/");
|
|
@@ -11334,7 +11334,7 @@
|
|
|
11334
11334
|
searchClient.addAlgoliaAgent("instantsearch.js (".concat(version, ")"));
|
|
11335
11335
|
}
|
|
11336
11336
|
if (insightsClient && typeof insightsClient !== 'function') {
|
|
11337
|
-
throw new Error(withUsage$
|
|
11337
|
+
throw new Error(withUsage$u('The `insightsClient` option should be a function.'));
|
|
11338
11338
|
}
|
|
11339
11339
|
_this._initialOptions = options;
|
|
11340
11340
|
_this.client = searchClient;
|
|
@@ -11483,12 +11483,12 @@
|
|
|
11483
11483
|
* @param widgets The array of widgets to add to InstantSearch.
|
|
11484
11484
|
*/ function addWidgets(widgets) {
|
|
11485
11485
|
if (!Array.isArray(widgets)) {
|
|
11486
|
-
throw new Error(withUsage$
|
|
11486
|
+
throw new Error(withUsage$u('The `addWidgets` method expects an array of widgets. Please use `addWidget`.'));
|
|
11487
11487
|
}
|
|
11488
11488
|
if (this.compositionID && widgets.some(function(w) {
|
|
11489
11489
|
return !Array.isArray(w) && isIndexWidget(w) && !w._isolated;
|
|
11490
11490
|
})) {
|
|
11491
|
-
throw new Error(withUsage$
|
|
11491
|
+
throw new Error(withUsage$u('The `index` widget cannot be used with a composition-based InstantSearch implementation.'));
|
|
11492
11492
|
}
|
|
11493
11493
|
this.mainIndex.addWidgets(widgets);
|
|
11494
11494
|
return this;
|
|
@@ -11517,7 +11517,7 @@
|
|
|
11517
11517
|
* The widgets must implement a `dispose()` method to clear their states.
|
|
11518
11518
|
*/ function removeWidgets(widgets) {
|
|
11519
11519
|
if (!Array.isArray(widgets)) {
|
|
11520
|
-
throw new Error(withUsage$
|
|
11520
|
+
throw new Error(withUsage$u('The `removeWidgets` method expects an array of widgets. Please use `removeWidget`.'));
|
|
11521
11521
|
}
|
|
11522
11522
|
this.mainIndex.removeWidgets(widgets);
|
|
11523
11523
|
return this;
|
|
@@ -11531,7 +11531,7 @@
|
|
|
11531
11531
|
*/ function start() {
|
|
11532
11532
|
var _this = this;
|
|
11533
11533
|
if (this.started) {
|
|
11534
|
-
throw new Error(withUsage$
|
|
11534
|
+
throw new Error(withUsage$u('The `start` method has already been called once.'));
|
|
11535
11535
|
}
|
|
11536
11536
|
// This Helper is used for the queries, we don't care about its state. The
|
|
11537
11537
|
// states are managed at the `index` level. We use this Helper to create
|
|
@@ -11739,7 +11739,7 @@
|
|
|
11739
11739
|
var _this = this;
|
|
11740
11740
|
var callOnStateChange = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
|
|
11741
11741
|
if (!this.mainHelper) {
|
|
11742
|
-
throw new Error(withUsage$
|
|
11742
|
+
throw new Error(withUsage$u('The `start` method needs to be called before `setUiState`.'));
|
|
11743
11743
|
}
|
|
11744
11744
|
// We refresh the index UI state to update the local UI state that the
|
|
11745
11745
|
// main index passes to the function form of `setUiState`.
|
|
@@ -11776,7 +11776,7 @@
|
|
|
11776
11776
|
value: function createURL() {
|
|
11777
11777
|
var nextState = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
11778
11778
|
if (!this.started) {
|
|
11779
|
-
throw new Error(withUsage$
|
|
11779
|
+
throw new Error(withUsage$u('The `start` method needs to be called before `createURL`.'));
|
|
11780
11780
|
}
|
|
11781
11781
|
return this._createURL(nextState);
|
|
11782
11782
|
}
|
|
@@ -11785,7 +11785,7 @@
|
|
|
11785
11785
|
key: "refresh",
|
|
11786
11786
|
value: function refresh() {
|
|
11787
11787
|
if (!this.mainHelper) {
|
|
11788
|
-
throw new Error(withUsage$
|
|
11788
|
+
throw new Error(withUsage$u('The `start` method needs to be called before `refresh`.'));
|
|
11789
11789
|
}
|
|
11790
11790
|
this.mainHelper.clearCache().search();
|
|
11791
11791
|
}
|
|
@@ -12298,13 +12298,13 @@
|
|
|
12298
12298
|
}, children);
|
|
12299
12299
|
}
|
|
12300
12300
|
|
|
12301
|
-
var withUsage$
|
|
12301
|
+
var withUsage$t = createDocumentationMessageGenerator({
|
|
12302
12302
|
name: 'autocomplete',
|
|
12303
12303
|
connector: true
|
|
12304
12304
|
});
|
|
12305
12305
|
var connectAutocomplete = function connectAutocomplete(renderFn) {
|
|
12306
12306
|
var unmountFn = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : noop;
|
|
12307
|
-
checkRendering(renderFn, withUsage$
|
|
12307
|
+
checkRendering(renderFn, withUsage$t());
|
|
12308
12308
|
return function(widgetParams) {
|
|
12309
12309
|
var _ref = widgetParams || {}, _ref_escapeHTML = _ref.escapeHTML, escapeHTML = _ref_escapeHTML === void 0 ? true : _ref_escapeHTML, _ref_transformItems = _ref.transformItems, transformItems = _ref_transformItems === void 0 ? function(indices) {
|
|
12310
12310
|
return indices;
|
|
@@ -12417,20 +12417,20 @@
|
|
|
12417
12417
|
return useConnector(connectAutocomplete, props, additionalWidgetProperties);
|
|
12418
12418
|
}
|
|
12419
12419
|
|
|
12420
|
-
var withUsage$
|
|
12420
|
+
var withUsage$s = createDocumentationMessageGenerator({
|
|
12421
12421
|
name: 'breadcrumb',
|
|
12422
12422
|
connector: true
|
|
12423
12423
|
});
|
|
12424
12424
|
var connectBreadcrumb = function connectBreadcrumb(renderFn) {
|
|
12425
12425
|
var unmountFn = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : noop;
|
|
12426
|
-
checkRendering(renderFn, withUsage$
|
|
12426
|
+
checkRendering(renderFn, withUsage$s());
|
|
12427
12427
|
var connectorState = {};
|
|
12428
12428
|
return function(widgetParams) {
|
|
12429
12429
|
var _ref = widgetParams || {}, attributes = _ref.attributes, _ref_separator = _ref.separator, separator = _ref_separator === void 0 ? ' > ' : _ref_separator, _ref_rootPath = _ref.rootPath, rootPath = _ref_rootPath === void 0 ? null : _ref_rootPath, _ref_transformItems = _ref.transformItems, transformItems = _ref_transformItems === void 0 ? function(items) {
|
|
12430
12430
|
return items;
|
|
12431
12431
|
} : _ref_transformItems;
|
|
12432
12432
|
if (!attributes || !Array.isArray(attributes) || attributes.length === 0) {
|
|
12433
|
-
throw new Error(withUsage$
|
|
12433
|
+
throw new Error(withUsage$s('The `attributes` option expects an array of strings.'));
|
|
12434
12434
|
}
|
|
12435
12435
|
var _attributes = _sliced_to_array(attributes, 1), hierarchicalFacetName = _attributes[0];
|
|
12436
12436
|
function getRefinedState(state, facetValue) {
|
|
@@ -14380,6 +14380,26 @@
|
|
|
14380
14380
|
facetFilters: getFacetFilters(query)
|
|
14381
14381
|
};
|
|
14382
14382
|
};
|
|
14383
|
+
/**
|
|
14384
|
+
* Whether the agent handed the turn to the Grouped Results tool for this
|
|
14385
|
+
* message, i.e. that tool renders the records and the search tool must not.
|
|
14386
|
+
*
|
|
14387
|
+
* The backend sets exactly one of the two flags, depending on which tool name
|
|
14388
|
+
* the agent was configured with: `groupedResultsEnabled` for
|
|
14389
|
+
* `algolia_grouped_results`, `displayResultsEnabled` for agents still on the
|
|
14390
|
+
* legacy `algolia_display_results`.
|
|
14391
|
+
*/ var isGroupedResultsEnabled = function isGroupedResultsEnabled(metadata) {
|
|
14392
|
+
var flags = metadata;
|
|
14393
|
+
return (flags === null || flags === void 0 ? void 0 : flags.groupedResultsEnabled) === true || (flags === null || flags === void 0 ? void 0 : flags.displayResultsEnabled) === true;
|
|
14394
|
+
};
|
|
14395
|
+
/**
|
|
14396
|
+
* `shouldRender` for the search tool: it presents its own records only on turns
|
|
14397
|
+
* the agent did not hand to the Grouped Results tool, which would otherwise
|
|
14398
|
+
* present the same records a second time.
|
|
14399
|
+
*/ var shouldSearchToolRenderResults = function shouldSearchToolRenderResults(param) {
|
|
14400
|
+
var parentMessage = param.parentMessage;
|
|
14401
|
+
return !isGroupedResultsEnabled(parentMessage.metadata);
|
|
14402
|
+
};
|
|
14383
14403
|
|
|
14384
14404
|
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 t={blockQuote:"0",breakLine:"1",breakThematic:"2",codeBlock:"3",codeFenced:"4",codeInline:"5",footnote:"6",footnoteReference:"7",gfmTask:"8",heading:"9",headingSetext:"10",htmlBlock:"11",htmlComment:"12",htmlSelfClosing:"13",image:"14",link:"15",linkAngleBraceStyleDetector:"16",linkBareUrlDetector:"17",linkMailtoDetector:"18",newlineCoalescer:"19",orderedList:"20",paragraph:"21",ref:"22",refImage:"23",refLink:"24",table:"25",tableSeparator:"26",text:"27",textBolded:"28",textEmphasized:"29",textEscaped:"30",textMarked:"31",textStrikethroughed:"32",unorderedList:"33"},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}
|
|
14385
14405
|
|
|
@@ -16372,13 +16392,144 @@
|
|
|
16372
16392
|
};
|
|
16373
16393
|
}
|
|
16374
16394
|
|
|
16395
|
+
var defaultComparisonTableTranslations = {
|
|
16396
|
+
missingValueLabel: '—',
|
|
16397
|
+
productColumnLabel: 'Product'
|
|
16398
|
+
};
|
|
16399
|
+
/** The display name of a product, sourced ONLY from the catalog record. */ function productLabel(hit) {
|
|
16400
|
+
var _ref, _hit_name;
|
|
16401
|
+
if (!hit) {
|
|
16402
|
+
return undefined;
|
|
16403
|
+
}
|
|
16404
|
+
return (_ref = (_hit_name = hit.name) !== null && _hit_name !== void 0 ? _hit_name : hit.title) !== null && _ref !== void 0 ? _ref : hit.objectID;
|
|
16405
|
+
}
|
|
16406
|
+
/**
|
|
16407
|
+
* Catalog values are arbitrary JSON. Primitives (and arrays of them) have an
|
|
16408
|
+
* obvious textual form; objects (e.g. `price: { value, currency }`) would
|
|
16409
|
+
* stringify to `[object Object]`, so they render as the missing marker
|
|
16410
|
+
* instead — an honest "no displayable value" beats a garbled cell.
|
|
16411
|
+
*/ function formatCellValue(value) {
|
|
16412
|
+
if (value === undefined || value === null || value === '') {
|
|
16413
|
+
return undefined;
|
|
16414
|
+
}
|
|
16415
|
+
if (Array.isArray(value)) {
|
|
16416
|
+
var printable = value.filter(function(item) {
|
|
16417
|
+
return typeof item === 'string' && item !== '' || typeof item === 'number' || typeof item === 'boolean';
|
|
16418
|
+
});
|
|
16419
|
+
return printable.length > 0 ? printable.join(', ') : undefined;
|
|
16420
|
+
}
|
|
16421
|
+
if ((typeof value === "undefined" ? "undefined" : _type_of(value)) === 'object') {
|
|
16422
|
+
return undefined;
|
|
16423
|
+
}
|
|
16424
|
+
return String(value);
|
|
16425
|
+
}
|
|
16426
|
+
function createGroundedComparisonTableComponent(param) {
|
|
16427
|
+
var createElement = param.createElement, Fragment = param.Fragment;
|
|
16428
|
+
return function GroundedComparisonTable(props) {
|
|
16429
|
+
var _ref;
|
|
16430
|
+
var intro = props.intro, objectIDs = props.objectIDs, attributes = props.attributes, columns = props.columns, records = props.records;
|
|
16431
|
+
var translations = props.translations;
|
|
16432
|
+
if (objectIDs.length === 0) {
|
|
16433
|
+
return /*#__PURE__*/ createElement(Fragment, null);
|
|
16434
|
+
}
|
|
16435
|
+
// `columns` is model-authored and only trusted when it labels EVERY
|
|
16436
|
+
// column (`[product, ...attributes]`). A shorter list would shift labels
|
|
16437
|
+
// onto the wrong cells — `['Price', 'Rating']` over product/price/rating
|
|
16438
|
+
// puts the product names under "Price". Misaligned input falls back to
|
|
16439
|
+
// the attribute keys: correct data under plain headers.
|
|
16440
|
+
var columnLabels = columns && columns.length === attributes.length + 1 ? columns : undefined;
|
|
16441
|
+
var headerLabels = [
|
|
16442
|
+
(_ref = columnLabels === null || columnLabels === void 0 ? void 0 : columnLabels[0]) !== null && _ref !== void 0 ? _ref : translations.productColumnLabel
|
|
16443
|
+
].concat(_to_consumable_array(attributes.map(function(attr, index) {
|
|
16444
|
+
var _ref;
|
|
16445
|
+
return (_ref = columnLabels === null || columnLabels === void 0 ? void 0 : columnLabels[index + 1]) !== null && _ref !== void 0 ? _ref : attr;
|
|
16446
|
+
})));
|
|
16447
|
+
return /*#__PURE__*/ createElement("div", {
|
|
16448
|
+
className: "ais-ChatToolComparisonTable"
|
|
16449
|
+
}, intro && /*#__PURE__*/ createElement("div", {
|
|
16450
|
+
className: "ais-ChatToolComparisonTable-intro"
|
|
16451
|
+
}, intro), /*#__PURE__*/ createElement("table", {
|
|
16452
|
+
className: "ais-ChatToolComparisonTable-table"
|
|
16453
|
+
}, /*#__PURE__*/ createElement("thead", null, /*#__PURE__*/ createElement("tr", null, headerLabels.map(function(label, index) {
|
|
16454
|
+
return /*#__PURE__*/ createElement("th", {
|
|
16455
|
+
key: "h-".concat(index),
|
|
16456
|
+
scope: "col",
|
|
16457
|
+
className: "ais-ChatToolComparisonTable-header"
|
|
16458
|
+
}, label);
|
|
16459
|
+
}))), /*#__PURE__*/ createElement("tbody", null, objectIDs.map(function(objectID) {
|
|
16460
|
+
var _formatCellValue;
|
|
16461
|
+
var hit = records === null || records === void 0 ? void 0 : records.get(objectID);
|
|
16462
|
+
var name = productLabel(hit);
|
|
16463
|
+
return /*#__PURE__*/ createElement("tr", {
|
|
16464
|
+
key: objectID,
|
|
16465
|
+
"data-object-id": objectID,
|
|
16466
|
+
className: "ais-ChatToolComparisonTable-row"
|
|
16467
|
+
}, /*#__PURE__*/ createElement("th", {
|
|
16468
|
+
scope: "row",
|
|
16469
|
+
"data-testid": "product-".concat(objectID),
|
|
16470
|
+
className: "ais-ChatToolComparisonTable-product"
|
|
16471
|
+
}, (_formatCellValue = formatCellValue(name)) !== null && _formatCellValue !== void 0 ? _formatCellValue : translations.missingValueLabel), attributes.map(function(attribute) {
|
|
16472
|
+
// The ONLY source of a cell value is the catalog record.
|
|
16473
|
+
var value = formatCellValue(hit ? hit[attribute] : undefined);
|
|
16474
|
+
return /*#__PURE__*/ createElement("td", {
|
|
16475
|
+
key: "".concat(objectID, "-").concat(attribute),
|
|
16476
|
+
"data-testid": "cell-".concat(objectID, "-").concat(attribute),
|
|
16477
|
+
className: "ais-ChatToolComparisonTable-cell"
|
|
16478
|
+
}, value !== null && value !== void 0 ? value : translations.missingValueLabel);
|
|
16479
|
+
}));
|
|
16480
|
+
}))));
|
|
16481
|
+
};
|
|
16482
|
+
}
|
|
16483
|
+
|
|
16484
|
+
/** Keeps only non-empty string entries, dropping anything else the model sent. */ function stringList(value) {
|
|
16485
|
+
if (!Array.isArray(value)) {
|
|
16486
|
+
return [];
|
|
16487
|
+
}
|
|
16488
|
+
return value.filter(function(entry) {
|
|
16489
|
+
return typeof entry === 'string' && entry !== '';
|
|
16490
|
+
});
|
|
16491
|
+
}
|
|
16492
|
+
function createCompareProductsToolComponent(param) {
|
|
16493
|
+
var createElement = param.createElement, Fragment = param.Fragment;
|
|
16494
|
+
var GroundedComparisonTable = createGroundedComparisonTableComponent({
|
|
16495
|
+
createElement: createElement,
|
|
16496
|
+
Fragment: Fragment
|
|
16497
|
+
});
|
|
16498
|
+
return function CompareProductsTool(userProps) {
|
|
16499
|
+
var _message_input;
|
|
16500
|
+
var toolProps = userProps.toolProps, userTranslations = userProps.translations;
|
|
16501
|
+
var _toolProps_context = toolProps.context, message = _toolProps_context.message, records = _toolProps_context.records;
|
|
16502
|
+
var translations = _object_spread({}, defaultComparisonTableTranslations, userTranslations);
|
|
16503
|
+
// Wait for the agent's arguments to be complete before rendering.
|
|
16504
|
+
if (!message || message.state !== 'input-available' && message.state !== 'output-available') {
|
|
16505
|
+
return /*#__PURE__*/ createElement(Fragment, null);
|
|
16506
|
+
}
|
|
16507
|
+
var input = (_message_input = message.input) !== null && _message_input !== void 0 ? _message_input : {};
|
|
16508
|
+
var objectIDs = stringList(input.objectIDs);
|
|
16509
|
+
var attributes = stringList(input.attributes);
|
|
16510
|
+
var columns = Array.isArray(input.columns) ? stringList(input.columns) : undefined;
|
|
16511
|
+
var intro = typeof input.intro === 'string' ? input.intro : undefined;
|
|
16512
|
+
if (objectIDs.length === 0) {
|
|
16513
|
+
return /*#__PURE__*/ createElement(Fragment, null);
|
|
16514
|
+
}
|
|
16515
|
+
return /*#__PURE__*/ createElement(GroundedComparisonTable, {
|
|
16516
|
+
intro: intro,
|
|
16517
|
+
objectIDs: objectIDs,
|
|
16518
|
+
attributes: attributes,
|
|
16519
|
+
columns: columns,
|
|
16520
|
+
records: records,
|
|
16521
|
+
translations: translations
|
|
16522
|
+
});
|
|
16523
|
+
};
|
|
16524
|
+
}
|
|
16525
|
+
|
|
16375
16526
|
var isObject = function isObject(value) {
|
|
16376
16527
|
return value !== null && (typeof value === "undefined" ? "undefined" : _type_of(value)) === 'object';
|
|
16377
16528
|
};
|
|
16378
16529
|
var hasOwn = function hasOwn(value, key) {
|
|
16379
16530
|
return Object.prototype.hasOwnProperty.call(value, key);
|
|
16380
16531
|
};
|
|
16381
|
-
var
|
|
16532
|
+
var claimsGroupedResultsPayload = function claimsGroupedResultsPayload(value) {
|
|
16382
16533
|
return isObject(value) && (hasOwn(value, 'intro') || hasOwn(value, 'groups'));
|
|
16383
16534
|
};
|
|
16384
16535
|
/**
|
|
@@ -16453,21 +16604,21 @@
|
|
|
16453
16604
|
}
|
|
16454
16605
|
return inString && !isKey && ((_frames_ = frames[frames.length - 1]) === null || _frames_ === void 0 ? void 0 : _frames_.lastKey) === 'objectID' && ((_frames_1 = frames[frames.length - 2]) === null || _frames_1 === void 0 ? void 0 : _frames_1.key) === 'results' && ((_frames_2 = frames[frames.length - 4]) === null || _frames_2 === void 0 ? void 0 : _frames_2.key) === 'groups';
|
|
16455
16606
|
};
|
|
16456
|
-
var DEFAULT_TRANSLATIONS$
|
|
16607
|
+
var DEFAULT_TRANSLATIONS$2 = {
|
|
16457
16608
|
streamingLabel: 'Curating results…'
|
|
16458
16609
|
};
|
|
16459
|
-
function
|
|
16610
|
+
function createGroupedResultsToolComponent(param) {
|
|
16460
16611
|
var createElement = param.createElement, Fragment = param.Fragment, useEffect = param.useEffect, useRef = param.useRef;
|
|
16461
|
-
return function
|
|
16612
|
+
return function GroupedResultsTool(userProps) {
|
|
16462
16613
|
var _ref;
|
|
16463
16614
|
var toolProps = userProps.toolProps, renderGroupCarousel = userProps.groupCarouselComponent, userTranslations = userProps.translations;
|
|
16464
16615
|
var context = toolProps.context;
|
|
16465
16616
|
var message = context.message, insightsEventContext = context.insightsEventContext, sendEvent = context.sendEvent, messages = context.messages, status = context.status, records = context.records;
|
|
16466
16617
|
var instantSearchStatus = (_ref = insightsEventContext === null || insightsEventContext === void 0 ? void 0 : insightsEventContext.instantSearchStatus) !== null && _ref !== void 0 ? _ref : 'idle';
|
|
16467
|
-
var translations = _object_spread({}, DEFAULT_TRANSLATIONS$
|
|
16468
|
-
var inputClaimsPayload =
|
|
16618
|
+
var translations = _object_spread({}, DEFAULT_TRANSLATIONS$2, userTranslations);
|
|
16619
|
+
var inputClaimsPayload = claimsGroupedResultsPayload(message === null || message === void 0 ? void 0 : message.input);
|
|
16469
16620
|
var legacyOutput = (message === null || message === void 0 ? void 0 : message.state) === 'output-available' && message.preliminary !== true && !inputClaimsPayload ? message.output : undefined;
|
|
16470
|
-
var payload = inputClaimsPayload ? message === null || message === void 0 ? void 0 : message.input :
|
|
16621
|
+
var payload = inputClaimsPayload ? message === null || message === void 0 ? void 0 : message.input : claimsGroupedResultsPayload(legacyOutput) ? legacyOutput : undefined;
|
|
16471
16622
|
var intro = typeof (payload === null || payload === void 0 ? void 0 : payload.intro) === 'string' ? payload.intro : undefined;
|
|
16472
16623
|
var groups = Array.isArray(payload === null || payload === void 0 ? void 0 : payload.groups) ? payload.groups.filter(isObject) : [];
|
|
16473
16624
|
var latestMessage = messages === null || messages === void 0 ? void 0 : messages[messages.length - 1];
|
|
@@ -16493,7 +16644,7 @@
|
|
|
16493
16644
|
renderedItems.push(_object_spread_props(_object_spread({}, hydrated), {
|
|
16494
16645
|
objectID: result.objectID,
|
|
16495
16646
|
__position: renderedItems.length + 1,
|
|
16496
|
-
|
|
16647
|
+
__groupedToolResult: result
|
|
16497
16648
|
}));
|
|
16498
16649
|
return renderedItems;
|
|
16499
16650
|
}, []);
|
|
@@ -16536,27 +16687,112 @@
|
|
|
16536
16687
|
return /*#__PURE__*/ createElement(Fragment, null);
|
|
16537
16688
|
}
|
|
16538
16689
|
return /*#__PURE__*/ createElement("div", {
|
|
16539
|
-
className: "ais-
|
|
16690
|
+
className: "ais-ChatToolGroupedResults"
|
|
16540
16691
|
}, intro && /*#__PURE__*/ createElement("div", {
|
|
16541
|
-
className: "ais-
|
|
16692
|
+
className: "ais-ChatToolGroupedResults-intro"
|
|
16542
16693
|
}, intro), renderableGroups.map(function(group) {
|
|
16543
16694
|
return /*#__PURE__*/ createElement("div", {
|
|
16544
16695
|
key: group.key,
|
|
16545
|
-
className: "ais-
|
|
16696
|
+
className: "ais-ChatToolGroupedResults-group"
|
|
16546
16697
|
}, group.title && /*#__PURE__*/ createElement("div", {
|
|
16547
|
-
className: "ais-
|
|
16698
|
+
className: "ais-ChatToolGroupedResults-groupTitle"
|
|
16548
16699
|
}, group.title), group.why && /*#__PURE__*/ createElement("div", {
|
|
16549
|
-
className: "ais-
|
|
16700
|
+
className: "ais-ChatToolGroupedResults-groupWhy"
|
|
16550
16701
|
}, group.why), renderGroupCarousel({
|
|
16551
16702
|
items: group.items,
|
|
16552
16703
|
sendEvent: sendEvent
|
|
16553
16704
|
}));
|
|
16554
16705
|
}), isStreaming && /*#__PURE__*/ createElement("div", {
|
|
16555
|
-
className: "ais-
|
|
16706
|
+
className: "ais-ChatToolGroupedResults-streaming"
|
|
16556
16707
|
}, translations.streamingLabel));
|
|
16557
16708
|
};
|
|
16558
16709
|
}
|
|
16559
16710
|
|
|
16711
|
+
var DEFAULT_TRANSLATIONS$1 = {
|
|
16712
|
+
title: 'Compare',
|
|
16713
|
+
countText: function countText(count, maxItems) {
|
|
16714
|
+
return "".concat(count, " of ").concat(maxItems);
|
|
16715
|
+
},
|
|
16716
|
+
compareButtonText: function compareButtonText(count) {
|
|
16717
|
+
return "Compare ".concat(count);
|
|
16718
|
+
},
|
|
16719
|
+
clearButtonText: 'Clear all',
|
|
16720
|
+
removeItemLabel: function removeItemLabel(itemLabel) {
|
|
16721
|
+
return "Remove ".concat(itemLabel, " from comparison");
|
|
16722
|
+
},
|
|
16723
|
+
minItemsHint: function minItemsHint(minItems) {
|
|
16724
|
+
return "Select at least ".concat(minItems, " products to compare.");
|
|
16725
|
+
},
|
|
16726
|
+
limitReachedHint: 'Compare limit reached — remove a product to add another.'
|
|
16727
|
+
};
|
|
16728
|
+
/** The display label of a selected record. */ function getCompareBarItemLabel(item) {
|
|
16729
|
+
var _item_name;
|
|
16730
|
+
var label = (_item_name = item.name) !== null && _item_name !== void 0 ? _item_name : item.title;
|
|
16731
|
+
return typeof label === 'string' && label !== '' ? label : item.objectID;
|
|
16732
|
+
}
|
|
16733
|
+
function createCompareBarComponent(param) {
|
|
16734
|
+
var createElement = param.createElement;
|
|
16735
|
+
var Button = createButtonComponent({
|
|
16736
|
+
createElement: createElement
|
|
16737
|
+
});
|
|
16738
|
+
return function CompareBar(userProps) {
|
|
16739
|
+
var items = userProps.items, minItems = userProps.minItems, maxItems = userProps.maxItems, canCompare = userProps.canCompare, onCompare = userProps.onCompare, onRemove = userProps.onRemove, onClear = userProps.onClear, ItemComponent = userProps.itemComponent, _userProps_classNames = userProps.classNames, classNames = _userProps_classNames === void 0 ? {} : _userProps_classNames, userTranslations = userProps.translations;
|
|
16740
|
+
var translations = _object_spread({}, DEFAULT_TRANSLATIONS$1, userTranslations);
|
|
16741
|
+
if (items.length === 0) {
|
|
16742
|
+
return null;
|
|
16743
|
+
}
|
|
16744
|
+
var hint = items.length < minItems ? translations.minItemsHint(minItems) : items.length >= maxItems ? translations.limitReachedHint : undefined;
|
|
16745
|
+
return /*#__PURE__*/ createElement("section", {
|
|
16746
|
+
className: cx('ais-CompareBar', classNames.root),
|
|
16747
|
+
"aria-label": translations.title
|
|
16748
|
+
}, /*#__PURE__*/ createElement("div", {
|
|
16749
|
+
className: cx('ais-CompareBar-header', classNames.header)
|
|
16750
|
+
}, /*#__PURE__*/ createElement("span", {
|
|
16751
|
+
className: cx('ais-CompareBar-title', classNames.title)
|
|
16752
|
+
}, translations.title), /*#__PURE__*/ createElement("span", {
|
|
16753
|
+
className: cx('ais-CompareBar-count', classNames.count),
|
|
16754
|
+
"aria-live": "polite"
|
|
16755
|
+
}, translations.countText(items.length, maxItems))), /*#__PURE__*/ createElement("ul", {
|
|
16756
|
+
className: cx('ais-CompareBar-list', classNames.list)
|
|
16757
|
+
}, items.map(function(item) {
|
|
16758
|
+
var label = getCompareBarItemLabel(item);
|
|
16759
|
+
return /*#__PURE__*/ createElement("li", {
|
|
16760
|
+
key: item.objectID,
|
|
16761
|
+
"data-object-id": item.objectID,
|
|
16762
|
+
className: cx('ais-CompareBar-item', classNames.item)
|
|
16763
|
+
}, /*#__PURE__*/ createElement("span", {
|
|
16764
|
+
className: cx('ais-CompareBar-itemLabel', classNames.itemLabel)
|
|
16765
|
+
}, ItemComponent ? /*#__PURE__*/ createElement(ItemComponent, {
|
|
16766
|
+
item: item
|
|
16767
|
+
}) : label), /*#__PURE__*/ createElement("button", {
|
|
16768
|
+
type: "button",
|
|
16769
|
+
className: cx('ais-CompareBar-itemRemove', classNames.itemRemove),
|
|
16770
|
+
"aria-label": translations.removeItemLabel(label),
|
|
16771
|
+
onClick: function onClick() {
|
|
16772
|
+
return onRemove(item);
|
|
16773
|
+
}
|
|
16774
|
+
}, /*#__PURE__*/ createElement(CloseIcon, {
|
|
16775
|
+
createElement: createElement
|
|
16776
|
+
})));
|
|
16777
|
+
})), hint && /*#__PURE__*/ createElement("div", {
|
|
16778
|
+
className: cx('ais-CompareBar-hint', classNames.hint)
|
|
16779
|
+
}, hint), /*#__PURE__*/ createElement("div", {
|
|
16780
|
+
className: cx('ais-CompareBar-actions', classNames.actions)
|
|
16781
|
+
}, /*#__PURE__*/ createElement(Button, {
|
|
16782
|
+
variant: "outline",
|
|
16783
|
+
size: "sm",
|
|
16784
|
+
className: cx('ais-CompareBar-clearButton', classNames.clearButton),
|
|
16785
|
+
onClick: onClear
|
|
16786
|
+
}, translations.clearButtonText), /*#__PURE__*/ createElement(Button, {
|
|
16787
|
+
variant: "primary",
|
|
16788
|
+
size: "md",
|
|
16789
|
+
className: cx('ais-CompareBar-compareButton', classNames.compareButton),
|
|
16790
|
+
disabled: !canCompare,
|
|
16791
|
+
onClick: onCompare
|
|
16792
|
+
}, translations.compareButtonText(items.length))));
|
|
16793
|
+
};
|
|
16794
|
+
}
|
|
16795
|
+
|
|
16560
16796
|
function createDefaultEmptyComponent(param) {
|
|
16561
16797
|
var createElement = param.createElement, Fragment = param.Fragment;
|
|
16562
16798
|
return function DefaultEmpty() {
|
|
@@ -19581,8 +19817,13 @@
|
|
|
19581
19817
|
var MemorizeToolType = 'algolia_memorize';
|
|
19582
19818
|
var MemorySearchToolType = 'algolia_memory_search';
|
|
19583
19819
|
var PonderToolType = 'algolia_ponder';
|
|
19584
|
-
var
|
|
19820
|
+
var CompareProductsToolType = 'algolia_compare_products';
|
|
19585
19821
|
var GroupedResultsToolType = 'algolia_grouped_results';
|
|
19822
|
+
/**
|
|
19823
|
+
* @deprecated The tool is now `algolia_grouped_results`
|
|
19824
|
+
* ({@link GroupedResultsToolType}). This name is still emitted by agents
|
|
19825
|
+
* configured before the rename, and renders the same UI.
|
|
19826
|
+
*/ var DisplayResultsToolType = 'algolia_display_results';
|
|
19586
19827
|
/**
|
|
19587
19828
|
* Whether `toolName` is the search tool as the Algolia MCP Server exposes it:
|
|
19588
19829
|
* one tool per index, named after the index it searches
|
|
@@ -19787,7 +20028,7 @@
|
|
|
19787
20028
|
return DefaultChatTransport;
|
|
19788
20029
|
}(HttpChatTransport);
|
|
19789
20030
|
|
|
19790
|
-
var withUsage$
|
|
20031
|
+
var withUsage$r = createDocumentationMessageGenerator({
|
|
19791
20032
|
name: 'chat',
|
|
19792
20033
|
connector: true
|
|
19793
20034
|
});
|
|
@@ -19918,7 +20159,7 @@
|
|
|
19918
20159
|
}
|
|
19919
20160
|
var connectChat = function connectChat(renderFn) {
|
|
19920
20161
|
var unmountFn = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : noop;
|
|
19921
|
-
checkRendering(renderFn, withUsage$
|
|
20162
|
+
checkRendering(renderFn, withUsage$r());
|
|
19922
20163
|
return function(widgetParams) {
|
|
19923
20164
|
var _ref = widgetParams || {}, _ref_resume = _ref.resume, resume = _ref_resume === void 0 ? false : _ref_resume, tmp = _ref.tools, tools_ = tmp === void 0 ? {} : tmp, _ref_type = _ref.type, type = _ref_type === void 0 ? 'chat' : _ref_type, persistence = _ref.persistence, context = _ref.context, initialUserMessage = _ref.initialUserMessage, initialMessages = _ref.initialMessages, _ref_disableTriggerValidation = _ref.disableTriggerValidation, disableTriggerValidation = _ref_disableTriggerValidation === void 0 ? false : _ref_disableTriggerValidation, _ref_sendAutomaticallyWhen = _ref.sendAutomaticallyWhen, sendAutomaticallyWhen = _ref_sendAutomaticallyWhen === void 0 ? lastAssistantMessageIsCompleteWithToolCalls : _ref_sendAutomaticallyWhen, _ref_requiresSearch = _ref.requiresSearch, requiresSearch = _ref_requiresSearch === void 0 ? true : _ref_requiresSearch, options = _object_without_properties(_ref, [
|
|
19924
20165
|
"resume",
|
|
@@ -20078,7 +20319,7 @@
|
|
|
20078
20319
|
if ('agentId' in options && options.agentId) {
|
|
20079
20320
|
var _options_requestOptions, _options_requestOptions1;
|
|
20080
20321
|
if (!appId || !apiKey) {
|
|
20081
|
-
throw new Error(withUsage$
|
|
20322
|
+
throw new Error(withUsage$r('Could not extract Algolia credentials from the search client.'));
|
|
20082
20323
|
}
|
|
20083
20324
|
var createApi = function createApi() {
|
|
20084
20325
|
var bypassCache = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
|
|
@@ -20117,7 +20358,7 @@
|
|
|
20117
20358
|
});
|
|
20118
20359
|
}
|
|
20119
20360
|
if (!transport) {
|
|
20120
|
-
throw new Error(withUsage$
|
|
20361
|
+
throw new Error(withUsage$r('You need to provide either an `agentId` or a `transport`.'));
|
|
20121
20362
|
}
|
|
20122
20363
|
var canRepairRestoredPendingToolParts = !resume;
|
|
20123
20364
|
var chat = new Chat$1(_object_spread_props(_object_spread({}, options), {
|
|
@@ -20307,7 +20548,7 @@
|
|
|
20307
20548
|
if (agentId && feedback) {
|
|
20308
20549
|
var _getAppIdAndApiKey = _sliced_to_array(getAppIdAndApiKey(initOptions.instantSearchInstance.client), 2), appId = _getAppIdAndApiKey[0], apiKey = _getAppIdAndApiKey[1];
|
|
20309
20550
|
if (!appId || !apiKey) {
|
|
20310
|
-
throw new Error(withUsage$
|
|
20551
|
+
throw new Error(withUsage$r('Could not extract Algolia credentials from the search client.'));
|
|
20311
20552
|
}
|
|
20312
20553
|
feedbackAbortController = new AbortController();
|
|
20313
20554
|
_sendChatMessageFeedback = function _sendChatMessageFeedback(messageId, vote) {
|
|
@@ -20908,20 +21149,20 @@
|
|
|
20908
21149
|
};
|
|
20909
21150
|
}
|
|
20910
21151
|
|
|
20911
|
-
var withUsage$
|
|
21152
|
+
var withUsage$q = createDocumentationMessageGenerator({
|
|
20912
21153
|
name: 'tasks',
|
|
20913
21154
|
connector: true
|
|
20914
21155
|
});
|
|
20915
21156
|
var connectTasks = function connectTasks(renderFn) {
|
|
20916
21157
|
var unmountFn = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : noop;
|
|
20917
|
-
checkRendering(renderFn, withUsage$
|
|
21158
|
+
checkRendering(renderFn, withUsage$q());
|
|
20918
21159
|
return function(widgetParams) {
|
|
20919
21160
|
var agentId = widgetParams.agentId, transport = widgetParams.transport, task = widgetParams.task, kind = widgetParams.kind, _widgetParams_stream = widgetParams.stream, stream = _widgetParams_stream === void 0 ? true : _widgetParams_stream;
|
|
20920
21161
|
if (!agentId && !transport) {
|
|
20921
|
-
throw new Error(withUsage$
|
|
21162
|
+
throw new Error(withUsage$q('The `agentId` option is required unless a custom `transport` is provided.'));
|
|
20922
21163
|
}
|
|
20923
21164
|
if (!task && !kind) {
|
|
20924
|
-
throw new Error(withUsage$
|
|
21165
|
+
throw new Error(withUsage$q('Either the `task` or `kind` option is required.'));
|
|
20925
21166
|
}
|
|
20926
21167
|
var runner;
|
|
20927
21168
|
var output;
|
|
@@ -20995,7 +21236,7 @@
|
|
|
20995
21236
|
if (agentId) {
|
|
20996
21237
|
var _getAppIdAndApiKey = _sliced_to_array(getAppIdAndApiKey(instantSearchInstance.client), 2), appId = _getAppIdAndApiKey[0], apiKey = _getAppIdAndApiKey[1];
|
|
20997
21238
|
if (!appId || !apiKey) {
|
|
20998
|
-
throw new Error(withUsage$
|
|
21239
|
+
throw new Error(withUsage$q('Could not extract Algolia credentials from the search client.'));
|
|
20999
21240
|
}
|
|
21000
21241
|
var taskTransport = createTaskTransport({
|
|
21001
21242
|
transport: transport,
|
|
@@ -21042,7 +21283,7 @@
|
|
|
21042
21283
|
};
|
|
21043
21284
|
};
|
|
21044
21285
|
|
|
21045
|
-
var withUsage$
|
|
21286
|
+
var withUsage$p = createDocumentationMessageGenerator({
|
|
21046
21287
|
name: 'prompt-suggestions',
|
|
21047
21288
|
connector: true
|
|
21048
21289
|
});
|
|
@@ -21139,13 +21380,13 @@
|
|
|
21139
21380
|
}
|
|
21140
21381
|
var connectPromptSuggestions = function connectPromptSuggestions(renderFn) {
|
|
21141
21382
|
var unmountFn = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : noop;
|
|
21142
|
-
checkRendering(renderFn, withUsage$
|
|
21383
|
+
checkRendering(renderFn, withUsage$p());
|
|
21143
21384
|
return function(widgetParams) {
|
|
21144
21385
|
var agentId = widgetParams.agentId, configurationId = widgetParams.configurationId, _widgetParams_transformHits = widgetParams.transformHits, transformHits = _widgetParams_transformHits === void 0 ? DEFAULT_TRANSFORM_HITS : _widgetParams_transformHits, context = widgetParams.context, _widgetParams_transformItems = widgetParams.transformItems, transformItems = _widgetParams_transformItems === void 0 ? function(items) {
|
|
21145
21386
|
return items;
|
|
21146
21387
|
} : _widgetParams_transformItems, transport = widgetParams.transport;
|
|
21147
21388
|
if (!agentId && !transport) {
|
|
21148
|
-
throw new Error(withUsage$
|
|
21389
|
+
throw new Error(withUsage$p('The `agentId` option is required unless a custom `transport` is provided.'));
|
|
21149
21390
|
}
|
|
21150
21391
|
var tasksState;
|
|
21151
21392
|
var suggestions = [];
|
|
@@ -21425,7 +21666,7 @@
|
|
|
21425
21666
|
stream: true
|
|
21426
21667
|
};
|
|
21427
21668
|
} else {
|
|
21428
|
-
throw new Error(withUsage$
|
|
21669
|
+
throw new Error(withUsage$p('The `agentId` option is required unless a custom `transport` is provided.'));
|
|
21429
21670
|
}
|
|
21430
21671
|
var tasksWidget = connectTasks(handleInnerRender, noop)(tasksParams);
|
|
21431
21672
|
return {
|
|
@@ -21509,14 +21750,14 @@
|
|
|
21509
21750
|
return useConnector(connectPromptSuggestions, props, additionalWidgetProperties);
|
|
21510
21751
|
}
|
|
21511
21752
|
|
|
21512
|
-
var withUsage$
|
|
21753
|
+
var withUsage$o = createDocumentationMessageGenerator({
|
|
21513
21754
|
name: 'chatTrigger',
|
|
21514
21755
|
connector: true
|
|
21515
21756
|
});
|
|
21516
21757
|
// Reads the sibling chat widget's render state from the live cross-index
|
|
21517
21758
|
// `instantSearchInstance.renderState` map. We resolve at call time so that
|
|
21518
21759
|
// `toggleOpen` always sees the latest `open`/`setOpen` values.
|
|
21519
|
-
function getChatRenderState(options) {
|
|
21760
|
+
function getChatRenderState$1(options) {
|
|
21520
21761
|
var _options_parent, _options_instantSearchInstance_renderState_indexId;
|
|
21521
21762
|
var indexId = (_options_parent = options.parent) === null || _options_parent === void 0 ? void 0 : _options_parent.getIndexId();
|
|
21522
21763
|
if (!indexId) return undefined;
|
|
@@ -21524,17 +21765,17 @@
|
|
|
21524
21765
|
}
|
|
21525
21766
|
var connectChatTrigger = function connectChatTrigger(renderFn) {
|
|
21526
21767
|
var unmountFn = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : noop;
|
|
21527
|
-
checkRendering(renderFn, withUsage$
|
|
21768
|
+
checkRendering(renderFn, withUsage$o());
|
|
21528
21769
|
return function(widgetParams) {
|
|
21529
21770
|
var params = widgetParams !== null && widgetParams !== void 0 ? widgetParams : {};
|
|
21530
21771
|
var lastOptions = null;
|
|
21531
21772
|
function openChatFromTrigger(options) {
|
|
21532
21773
|
if (!lastOptions) return false;
|
|
21533
|
-
return openChat(getChatRenderState(lastOptions), options);
|
|
21774
|
+
return openChat(getChatRenderState$1(lastOptions), options);
|
|
21534
21775
|
}
|
|
21535
21776
|
function toggleOpen() {
|
|
21536
21777
|
if (!lastOptions) return;
|
|
21537
|
-
var chatState = getChatRenderState(lastOptions);
|
|
21778
|
+
var chatState = getChatRenderState$1(lastOptions);
|
|
21538
21779
|
if (!chatState) return;
|
|
21539
21780
|
if (chatState.open) {
|
|
21540
21781
|
var _chatState_setOpen;
|
|
@@ -21564,7 +21805,7 @@
|
|
|
21564
21805
|
},
|
|
21565
21806
|
getWidgetRenderState: function getWidgetRenderState(renderOptions) {
|
|
21566
21807
|
var _ref;
|
|
21567
|
-
var chatState = getChatRenderState(renderOptions);
|
|
21808
|
+
var chatState = getChatRenderState$1(renderOptions);
|
|
21568
21809
|
return {
|
|
21569
21810
|
open: (_ref = chatState === null || chatState === void 0 ? void 0 : chatState.open) !== null && _ref !== void 0 ? _ref : false,
|
|
21570
21811
|
toggleOpen: toggleOpen,
|
|
@@ -21590,6 +21831,235 @@
|
|
|
21590
21831
|
return useConnector(connectChatTrigger, props, additionalWidgetProperties);
|
|
21591
21832
|
}
|
|
21592
21833
|
|
|
21834
|
+
var withUsage$n = createDocumentationMessageGenerator({
|
|
21835
|
+
name: 'compare',
|
|
21836
|
+
connector: true
|
|
21837
|
+
});
|
|
21838
|
+
/**
|
|
21839
|
+
* Builds the placeholder message for a dashboard-configured comparison. The
|
|
21840
|
+
* Agent Studio backend resolves it against the agent's comparison
|
|
21841
|
+
* configuration: the LLM gets the configured instructions and the transcript
|
|
21842
|
+
* keeps a natural-language message naming the selection.
|
|
21843
|
+
*/ function getComparisonPlaceholderMessage(configurationId) {
|
|
21844
|
+
return "__ALGOLIA_COMPARISON_".concat(configurationId, "__");
|
|
21845
|
+
}
|
|
21846
|
+
/**
|
|
21847
|
+
* Builds the default comparison message. It names each selected item so the
|
|
21848
|
+
* agent can ground the comparison: it re-retrieves the records with
|
|
21849
|
+
* `algolia_search_index` and renders them with the builtin
|
|
21850
|
+
* `algolia_compare_products` tool. Works with the default shopping assistant
|
|
21851
|
+
* prompt — no agent configuration required.
|
|
21852
|
+
*/ function getDefaultComparisonMessage(items) {
|
|
21853
|
+
var labels = items.map(function(item) {
|
|
21854
|
+
var _item_name;
|
|
21855
|
+
var name = (_item_name = item.name) !== null && _item_name !== void 0 ? _item_name : item.title;
|
|
21856
|
+
return typeof name === 'string' && name !== '' ? '"'.concat(name, '" (objectID: ').concat(item.objectID, ")") : 'the product with objectID "'.concat(item.objectID, '"');
|
|
21857
|
+
});
|
|
21858
|
+
return "Compare these products: ".concat(labels.join(' vs '));
|
|
21859
|
+
}
|
|
21860
|
+
// Turn-context payload for the comparison hand-off, per the Agent Studio
|
|
21861
|
+
// contract: the selection rides `selected_products` (JSON-encoded records,
|
|
21862
|
+
// `_`-prefixed internal metadata stripped) so the agent grounds the comparison
|
|
21863
|
+
// in what the shopper actually selected, and `comparison_configuration_id`
|
|
21864
|
+
// identifies the dashboard configuration when one is set.
|
|
21865
|
+
function buildComparisonTurnContext(items, configurationId) {
|
|
21866
|
+
var records = items.map(function(item) {
|
|
21867
|
+
var clean = {};
|
|
21868
|
+
Object.keys(item).forEach(function(key) {
|
|
21869
|
+
if (!key.startsWith('_')) {
|
|
21870
|
+
clean[key] = item[key];
|
|
21871
|
+
}
|
|
21872
|
+
});
|
|
21873
|
+
return clean;
|
|
21874
|
+
});
|
|
21875
|
+
return _object_spread({
|
|
21876
|
+
selected_products: JSON.stringify(records)
|
|
21877
|
+
}, configurationId ? {
|
|
21878
|
+
comparison_configuration_id: configurationId
|
|
21879
|
+
} : {});
|
|
21880
|
+
}
|
|
21881
|
+
// The selection is shared by every `compare` widget of the same InstantSearch
|
|
21882
|
+
// instance (per-hit toggles, the compare bar, a picker modal, ...), so it
|
|
21883
|
+
// lives in a store keyed by the instance rather than in any single widget.
|
|
21884
|
+
var compareStores = new WeakMap();
|
|
21885
|
+
function getCompareStore(instantSearchInstance) {
|
|
21886
|
+
var store = compareStores.get(instantSearchInstance);
|
|
21887
|
+
if (!store) {
|
|
21888
|
+
store = {
|
|
21889
|
+
items: [],
|
|
21890
|
+
listeners: new Set()
|
|
21891
|
+
};
|
|
21892
|
+
compareStores.set(instantSearchInstance, store);
|
|
21893
|
+
}
|
|
21894
|
+
return store;
|
|
21895
|
+
}
|
|
21896
|
+
// Reads the sibling chat widget's render state from the live cross-index
|
|
21897
|
+
// `instantSearchInstance.renderState` map. Resolved at call time so that
|
|
21898
|
+
// `compare` always sees the latest `open`/`sendMessage` values.
|
|
21899
|
+
function getChatRenderState(options) {
|
|
21900
|
+
var _options_parent, _options_instantSearchInstance_renderState_indexId;
|
|
21901
|
+
var indexId = (_options_parent = options.parent) === null || _options_parent === void 0 ? void 0 : _options_parent.getIndexId();
|
|
21902
|
+
if (!indexId) return undefined;
|
|
21903
|
+
return (_options_instantSearchInstance_renderState_indexId = options.instantSearchInstance.renderState[indexId]) === null || _options_instantSearchInstance_renderState_indexId === void 0 ? void 0 : _options_instantSearchInstance_renderState_indexId.chat;
|
|
21904
|
+
}
|
|
21905
|
+
/**
|
|
21906
|
+
* Compare connector.
|
|
21907
|
+
*
|
|
21908
|
+
* Owns the "products selected for comparison" state and the hand-off into the
|
|
21909
|
+
* chat: `compare()` opens the sibling `chat` widget and sends a comparison
|
|
21910
|
+
* message naming the selected records, which the agent answers with the
|
|
21911
|
+
* grounded `algolia_compare_products` table.
|
|
21912
|
+
*
|
|
21913
|
+
* The selection is shared across all `compare` widgets mounted on the same
|
|
21914
|
+
* InstantSearch instance, so per-hit "Compare" toggles and the `compareBar`
|
|
21915
|
+
* widget stay in sync. The widget is marked with `opensChat`, so it satisfies
|
|
21916
|
+
* the `chat` widget's entry-point validation.
|
|
21917
|
+
*/ var connectCompare = function connectCompare(renderFn) {
|
|
21918
|
+
var unmountFn = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : noop;
|
|
21919
|
+
checkRendering(renderFn, withUsage$n());
|
|
21920
|
+
return function(widgetParams) {
|
|
21921
|
+
var _ref = widgetParams || {}, _ref_minItems = _ref.minItems, minItems = _ref_minItems === void 0 ? 2 : _ref_minItems, _ref_maxItems = _ref.maxItems, maxItems = _ref_maxItems === void 0 ? 3 : _ref_maxItems, configurationId = _ref.configurationId, _ref_getComparisonMessage = _ref.getComparisonMessage, getComparisonMessage = _ref_getComparisonMessage === void 0 ? configurationId ? function() {
|
|
21922
|
+
return getComparisonPlaceholderMessage(configurationId);
|
|
21923
|
+
} : getDefaultComparisonMessage : _ref_getComparisonMessage;
|
|
21924
|
+
if (minItems < 2) {
|
|
21925
|
+
throw new Error(withUsage$n('The `minItems` option must be at least 2.'));
|
|
21926
|
+
}
|
|
21927
|
+
if (maxItems < minItems) {
|
|
21928
|
+
throw new Error(withUsage$n('The `maxItems` option must be greater than `minItems`.'));
|
|
21929
|
+
}
|
|
21930
|
+
var lastOptions = null;
|
|
21931
|
+
var unsubscribe = null;
|
|
21932
|
+
function getStore() {
|
|
21933
|
+
if (!lastOptions) return null;
|
|
21934
|
+
return getCompareStore(lastOptions.instantSearchInstance);
|
|
21935
|
+
}
|
|
21936
|
+
// Re-renders every subscribed `compare` widget, then schedules a full
|
|
21937
|
+
// render so anything else reading `renderState.compare` catches up.
|
|
21938
|
+
function notify(store) {
|
|
21939
|
+
store.listeners.forEach(function(listener) {
|
|
21940
|
+
return listener();
|
|
21941
|
+
});
|
|
21942
|
+
lastOptions === null || lastOptions === void 0 ? void 0 : lastOptions.instantSearchInstance.scheduleRender();
|
|
21943
|
+
}
|
|
21944
|
+
function isSelected(objectID) {
|
|
21945
|
+
var store = getStore();
|
|
21946
|
+
return Boolean(store === null || store === void 0 ? void 0 : store.items.some(function(item) {
|
|
21947
|
+
return item.objectID === objectID;
|
|
21948
|
+
}));
|
|
21949
|
+
}
|
|
21950
|
+
function addItem(item) {
|
|
21951
|
+
var store = getStore();
|
|
21952
|
+
if (!store || store.items.length >= maxItems || isSelected(item.objectID)) {
|
|
21953
|
+
return;
|
|
21954
|
+
}
|
|
21955
|
+
store.items = _to_consumable_array(store.items).concat([
|
|
21956
|
+
item
|
|
21957
|
+
]);
|
|
21958
|
+
notify(store);
|
|
21959
|
+
}
|
|
21960
|
+
function removeItem(objectID) {
|
|
21961
|
+
var store = getStore();
|
|
21962
|
+
if (!store || !isSelected(objectID)) return;
|
|
21963
|
+
store.items = store.items.filter(function(item) {
|
|
21964
|
+
return item.objectID !== objectID;
|
|
21965
|
+
});
|
|
21966
|
+
notify(store);
|
|
21967
|
+
}
|
|
21968
|
+
function toggleItem(item) {
|
|
21969
|
+
if (isSelected(item.objectID)) {
|
|
21970
|
+
removeItem(item.objectID);
|
|
21971
|
+
} else {
|
|
21972
|
+
addItem(item);
|
|
21973
|
+
}
|
|
21974
|
+
}
|
|
21975
|
+
function clearItems() {
|
|
21976
|
+
var store = getStore();
|
|
21977
|
+
if (!store || store.items.length === 0) return;
|
|
21978
|
+
store.items = [];
|
|
21979
|
+
notify(store);
|
|
21980
|
+
}
|
|
21981
|
+
function compare() {
|
|
21982
|
+
var store = getStore();
|
|
21983
|
+
if (!store || !lastOptions || store.items.length < minItems) {
|
|
21984
|
+
return false;
|
|
21985
|
+
}
|
|
21986
|
+
return openChat(getChatRenderState(lastOptions), {
|
|
21987
|
+
message: getComparisonMessage(store.items),
|
|
21988
|
+
referer: 'compare',
|
|
21989
|
+
turnContext: buildComparisonTurnContext(store.items, configurationId)
|
|
21990
|
+
});
|
|
21991
|
+
}
|
|
21992
|
+
return {
|
|
21993
|
+
$$type: 'ais.compare',
|
|
21994
|
+
opensChat: true,
|
|
21995
|
+
init: function init(initOptions) {
|
|
21996
|
+
var _this = this;
|
|
21997
|
+
lastOptions = initOptions;
|
|
21998
|
+
var store = getCompareStore(initOptions.instantSearchInstance);
|
|
21999
|
+
var listener = function listener() {
|
|
22000
|
+
if (!lastOptions) return;
|
|
22001
|
+
renderFn(_object_spread_props(_object_spread({}, _this.getWidgetRenderState(lastOptions)), {
|
|
22002
|
+
instantSearchInstance: lastOptions.instantSearchInstance
|
|
22003
|
+
}), false);
|
|
22004
|
+
};
|
|
22005
|
+
store.listeners.add(listener);
|
|
22006
|
+
unsubscribe = function unsubscribe() {
|
|
22007
|
+
return store.listeners.delete(listener);
|
|
22008
|
+
};
|
|
22009
|
+
renderFn(_object_spread_props(_object_spread({}, this.getWidgetRenderState(initOptions)), {
|
|
22010
|
+
instantSearchInstance: initOptions.instantSearchInstance
|
|
22011
|
+
}), true);
|
|
22012
|
+
},
|
|
22013
|
+
render: function render(renderOptions) {
|
|
22014
|
+
lastOptions = renderOptions;
|
|
22015
|
+
renderFn(_object_spread_props(_object_spread({}, this.getWidgetRenderState(renderOptions)), {
|
|
22016
|
+
instantSearchInstance: renderOptions.instantSearchInstance
|
|
22017
|
+
}), false);
|
|
22018
|
+
},
|
|
22019
|
+
dispose: function dispose() {
|
|
22020
|
+
unsubscribe === null || unsubscribe === void 0 ? void 0 : unsubscribe();
|
|
22021
|
+
unsubscribe = null;
|
|
22022
|
+
unmountFn();
|
|
22023
|
+
},
|
|
22024
|
+
getWidgetRenderState: function getWidgetRenderState(renderOptions) {
|
|
22025
|
+
lastOptions = renderOptions;
|
|
22026
|
+
var store = getCompareStore(renderOptions.instantSearchInstance);
|
|
22027
|
+
return {
|
|
22028
|
+
items: store.items,
|
|
22029
|
+
isSelected: isSelected,
|
|
22030
|
+
addItem: addItem,
|
|
22031
|
+
removeItem: removeItem,
|
|
22032
|
+
toggleItem: toggleItem,
|
|
22033
|
+
clearItems: clearItems,
|
|
22034
|
+
canAddItems: store.items.length < maxItems,
|
|
22035
|
+
canCompare: store.items.length >= minItems,
|
|
22036
|
+
minItems: minItems,
|
|
22037
|
+
maxItems: maxItems,
|
|
22038
|
+
compare: compare,
|
|
22039
|
+
widgetParams: widgetParams || {}
|
|
22040
|
+
};
|
|
22041
|
+
},
|
|
22042
|
+
getRenderState: function getRenderState(renderState, renderOptions) {
|
|
22043
|
+
return _object_spread_props(_object_spread({}, renderState), {
|
|
22044
|
+
compare: this.getWidgetRenderState(renderOptions)
|
|
22045
|
+
});
|
|
22046
|
+
}
|
|
22047
|
+
};
|
|
22048
|
+
};
|
|
22049
|
+
};
|
|
22050
|
+
|
|
22051
|
+
/**
|
|
22052
|
+
* Exposes the shared comparison selection and the chat hand-off.
|
|
22053
|
+
*
|
|
22054
|
+
* The selection is shared by every `useCompare` call on the same InstantSearch
|
|
22055
|
+
* instance, so a per-hit "Compare" toggle (`toggleItem`) and the `<CompareBar>`
|
|
22056
|
+
* widget stay in sync. `compare()` opens the `<Chat>` widget and sends the
|
|
22057
|
+
* comparison message for the current selection.
|
|
22058
|
+
*/ function useCompare() {
|
|
22059
|
+
var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, additionalWidgetProperties = arguments.length > 1 ? arguments[1] : void 0;
|
|
22060
|
+
return useConnector(connectCompare, props, additionalWidgetProperties);
|
|
22061
|
+
}
|
|
22062
|
+
|
|
21593
22063
|
var withUsage$m = createDocumentationMessageGenerator({
|
|
21594
22064
|
name: 'clear-refinements',
|
|
21595
22065
|
connector: true
|
|
@@ -26960,6 +27430,43 @@
|
|
|
26960
27430
|
useState: React.useState
|
|
26961
27431
|
});
|
|
26962
27432
|
|
|
27433
|
+
/**
|
|
27434
|
+
* Builtin comparison tool (`algolia_compare_products`).
|
|
27435
|
+
*
|
|
27436
|
+
* Registered by default in the chat widget so the agent can trigger a grounded
|
|
27437
|
+
* side-by-side comparison: its tool call names only the product objectIDs and
|
|
27438
|
+
* the attribute keys, and every cell is hydrated client-side from the real
|
|
27439
|
+
* `algolia_search_index` hits. The model never types a value, so it cannot
|
|
27440
|
+
* hallucinate one. See `instantsearch-ui-components` `CompareProductsTool` for
|
|
27441
|
+
* the contract, and `comparison-eval/README.md` for the study behind it.
|
|
27442
|
+
*/ function createCompareProductsTool(translations) {
|
|
27443
|
+
var CompareProductsUIComponent = createCompareProductsToolComponent({
|
|
27444
|
+
createElement: React.createElement,
|
|
27445
|
+
Fragment: React.Fragment
|
|
27446
|
+
});
|
|
27447
|
+
var CompareProductsLayoutComponent = function CompareProductsLayoutComponent(toolProps) {
|
|
27448
|
+
return /*#__PURE__*/ React.createElement(CompareProductsUIComponent, {
|
|
27449
|
+
toolProps: toolProps,
|
|
27450
|
+
translations: translations
|
|
27451
|
+
});
|
|
27452
|
+
};
|
|
27453
|
+
return {
|
|
27454
|
+
layoutComponent: CompareProductsLayoutComponent,
|
|
27455
|
+
// Client-side tool: acknowledge the call so the agent's turn can complete.
|
|
27456
|
+
// The table itself is rendered from the call's input + real search hits.
|
|
27457
|
+
onToolCall: function onToolCall(param) {
|
|
27458
|
+
var input = param.input, addToolResult = param.addToolResult;
|
|
27459
|
+
var objectIDs = input === null || input === void 0 ? void 0 : input.objectIDs;
|
|
27460
|
+
addToolResult({
|
|
27461
|
+
output: {
|
|
27462
|
+
status: 'displayed',
|
|
27463
|
+
objectIDs: Array.isArray(objectIDs) ? objectIDs : []
|
|
27464
|
+
}
|
|
27465
|
+
});
|
|
27466
|
+
}
|
|
27467
|
+
};
|
|
27468
|
+
}
|
|
27469
|
+
|
|
26963
27470
|
var CarouselUiComponent = createCarouselComponent({
|
|
26964
27471
|
createElement: React.createElement,
|
|
26965
27472
|
Fragment: React.Fragment,
|
|
@@ -27009,7 +27516,7 @@
|
|
|
27009
27516
|
});
|
|
27010
27517
|
|
|
27011
27518
|
function createGroupedResultsTool(itemComponent) {
|
|
27012
|
-
var
|
|
27519
|
+
var GroupedResultsUIComponent = createGroupedResultsToolComponent({
|
|
27013
27520
|
createElement: React.createElement,
|
|
27014
27521
|
Fragment: React.Fragment,
|
|
27015
27522
|
useEffect: React.useEffect,
|
|
@@ -27018,14 +27525,14 @@
|
|
|
27018
27525
|
var Button = createButtonComponent({
|
|
27019
27526
|
createElement: React.createElement
|
|
27020
27527
|
});
|
|
27021
|
-
var
|
|
27528
|
+
var GroupedResultsCarouselHeader = function GroupedResultsCarouselHeader(param) {
|
|
27022
27529
|
var nbItems = param.nbItems, canScrollLeft = param.canScrollLeft, canScrollRight = param.canScrollRight, scrollLeft = param.scrollLeft, scrollRight = param.scrollRight;
|
|
27023
27530
|
return /*#__PURE__*/ React.createElement("div", {
|
|
27024
|
-
className: "ais-
|
|
27531
|
+
className: "ais-ChatToolGroupedResultsCarouselHeader"
|
|
27025
27532
|
}, /*#__PURE__*/ React.createElement("div", {
|
|
27026
|
-
className: "ais-
|
|
27533
|
+
className: "ais-ChatToolGroupedResultsCarouselHeaderCount"
|
|
27027
27534
|
}, nbItems, " result", nbItems > 1 ? 's' : ''), /*#__PURE__*/ React.createElement("div", {
|
|
27028
|
-
className: "ais-
|
|
27535
|
+
className: "ais-ChatToolGroupedResultsCarouselHeaderScrollButtons"
|
|
27029
27536
|
}, /*#__PURE__*/ React.createElement(Button, {
|
|
27030
27537
|
variant: "outline",
|
|
27031
27538
|
size: "sm",
|
|
@@ -27033,7 +27540,7 @@
|
|
|
27033
27540
|
"aria-label": "Previous",
|
|
27034
27541
|
onClick: scrollLeft,
|
|
27035
27542
|
disabled: !canScrollLeft,
|
|
27036
|
-
className: "ais-
|
|
27543
|
+
className: "ais-ChatToolGroupedResultsCarouselHeaderScrollButton"
|
|
27037
27544
|
}, /*#__PURE__*/ React.createElement(ChevronLeftIcon, {
|
|
27038
27545
|
createElement: React.createElement
|
|
27039
27546
|
})), /*#__PURE__*/ React.createElement(Button, {
|
|
@@ -27043,13 +27550,13 @@
|
|
|
27043
27550
|
"aria-label": "Next",
|
|
27044
27551
|
onClick: scrollRight,
|
|
27045
27552
|
disabled: !canScrollRight,
|
|
27046
|
-
className: "ais-
|
|
27553
|
+
className: "ais-ChatToolGroupedResultsCarouselHeaderScrollButton"
|
|
27047
27554
|
}, /*#__PURE__*/ React.createElement(ChevronRightIcon, {
|
|
27048
27555
|
createElement: React.createElement
|
|
27049
27556
|
}))));
|
|
27050
27557
|
};
|
|
27051
|
-
var
|
|
27052
|
-
return /*#__PURE__*/ React.createElement(
|
|
27558
|
+
var GroupedResultsLayoutComponent = function GroupedResultsLayoutComponent(toolProps) {
|
|
27559
|
+
return /*#__PURE__*/ React.createElement(GroupedResultsUIComponent, {
|
|
27053
27560
|
toolProps: toolProps,
|
|
27054
27561
|
groupCarouselComponent: function groupCarouselComponent(param) {
|
|
27055
27562
|
var items = param.items, sendEvent = param.sendEvent;
|
|
@@ -27058,13 +27565,13 @@
|
|
|
27058
27565
|
itemComponent: itemComponent,
|
|
27059
27566
|
sendEvent: sendEvent,
|
|
27060
27567
|
showNavigation: false,
|
|
27061
|
-
headerComponent:
|
|
27568
|
+
headerComponent: GroupedResultsCarouselHeader
|
|
27062
27569
|
});
|
|
27063
27570
|
}
|
|
27064
27571
|
});
|
|
27065
27572
|
};
|
|
27066
27573
|
return {
|
|
27067
|
-
layoutComponent:
|
|
27574
|
+
layoutComponent: GroupedResultsLayoutComponent,
|
|
27068
27575
|
streamInput: true
|
|
27069
27576
|
};
|
|
27070
27577
|
}
|
|
@@ -27101,20 +27608,15 @@
|
|
|
27101
27608
|
useEffect: React.useEffect
|
|
27102
27609
|
});
|
|
27103
27610
|
function createDefaultTools(itemComponent, getSearchPageURL) {
|
|
27611
|
+
var groupedResultsTool = createGroupedResultsTool(itemComponent);
|
|
27104
27612
|
var _obj;
|
|
27105
27613
|
return _obj = {}, _define_property(_obj, SearchIndexToolType, _object_spread_props(_object_spread({}, createCarouselTool(true, itemComponent, getSearchPageURL)), {
|
|
27106
27614
|
// The agent decides per turn whether the richer Grouped Results tool
|
|
27107
27615
|
// takes over the rendering of the search results.
|
|
27108
|
-
shouldRender:
|
|
27109
|
-
})), _define_property(_obj, RecommendToolType, createCarouselTool(false, itemComponent, getSearchPageURL)), _define_property(_obj,
|
|
27110
|
-
|
|
27111
|
-
|
|
27112
|
-
* Whether the search tool renders its own results, i.e. the agent did not hand
|
|
27113
|
-
* the turn to the Grouped Results tool. Set on the message by the backend.
|
|
27114
|
-
*/ function isDisplayResultsDisabled(param) {
|
|
27115
|
-
var parentMessage = param.parentMessage;
|
|
27116
|
-
var _parentMessage_metadata;
|
|
27117
|
-
return ((_parentMessage_metadata = parentMessage.metadata) === null || _parentMessage_metadata === void 0 ? void 0 : _parentMessage_metadata.displayResultsEnabled) !== true;
|
|
27616
|
+
shouldRender: shouldSearchToolRenderResults
|
|
27617
|
+
})), _define_property(_obj, RecommendToolType, createCarouselTool(false, itemComponent, getSearchPageURL)), _define_property(_obj, GroupedResultsToolType, groupedResultsTool), // Agents configured before the rename still emit the legacy tool name.
|
|
27618
|
+
// eslint-disable-next-line typescript/no-deprecated
|
|
27619
|
+
_define_property(_obj, DisplayResultsToolType, groupedResultsTool), _define_property(_obj, CompareProductsToolType, createCompareProductsTool()), _define_property(_obj, MemorizeToolType, {}), _define_property(_obj, MemorySearchToolType, {}), _define_property(_obj, PonderToolType, {}), _obj;
|
|
27118
27620
|
}
|
|
27119
27621
|
function mergeToolOptions(defaultTools, userTools) {
|
|
27120
27622
|
if (!userTools) {
|
|
@@ -27511,6 +28013,45 @@
|
|
|
27511
28013
|
}, props));
|
|
27512
28014
|
}
|
|
27513
28015
|
|
|
28016
|
+
var CompareBarUiComponent = createCompareBarComponent({
|
|
28017
|
+
createElement: React.createElement,
|
|
28018
|
+
Fragment: React.Fragment
|
|
28019
|
+
});
|
|
28020
|
+
/**
|
|
28021
|
+
* Renders the comparison selection bar: the records picked for comparison,
|
|
28022
|
+
* a clear-selection action, and the "Compare" call-to-action that opens the
|
|
28023
|
+
* `<Chat>` widget with the comparison message.
|
|
28024
|
+
*
|
|
28025
|
+
* Select records from your own UI (e.g. a "Compare" button in your hit
|
|
28026
|
+
* component) with `useCompare().toggleItem(hit)` — the selection is shared
|
|
28027
|
+
* with this widget.
|
|
28028
|
+
*/ function CompareBar(_0) {
|
|
28029
|
+
var classNames = _0.classNames, translations = _0.translations, itemComponent = _0.itemComponent, props = _object_without_properties(_0, [
|
|
28030
|
+
"classNames",
|
|
28031
|
+
"translations",
|
|
28032
|
+
"itemComponent"
|
|
28033
|
+
]);
|
|
28034
|
+
var _useCompare = useCompare(props, {
|
|
28035
|
+
$$widgetType: 'ais.compareBar'
|
|
28036
|
+
}), items = _useCompare.items, minItems = _useCompare.minItems, maxItems = _useCompare.maxItems, canCompare = _useCompare.canCompare, removeItem = _useCompare.removeItem, clearItems = _useCompare.clearItems, compare = _useCompare.compare;
|
|
28037
|
+
return /*#__PURE__*/ React.createElement(CompareBarUiComponent, {
|
|
28038
|
+
items: items,
|
|
28039
|
+
minItems: minItems,
|
|
28040
|
+
maxItems: maxItems,
|
|
28041
|
+
canCompare: canCompare,
|
|
28042
|
+
onCompare: function onCompare() {
|
|
28043
|
+
return compare();
|
|
28044
|
+
},
|
|
28045
|
+
onRemove: function onRemove(item) {
|
|
28046
|
+
return removeItem(item.objectID);
|
|
28047
|
+
},
|
|
28048
|
+
onClear: clearItems,
|
|
28049
|
+
itemComponent: itemComponent,
|
|
28050
|
+
classNames: classNames,
|
|
28051
|
+
translations: translations
|
|
28052
|
+
});
|
|
28053
|
+
}
|
|
28054
|
+
|
|
27514
28055
|
function ClearRefinements$1(_0) {
|
|
27515
28056
|
var _0_classNames = _0.classNames, classNames = _0_classNames === void 0 ? {} : _0_classNames, _0_disabled = _0.disabled, disabled = _0_disabled === void 0 ? false : _0_disabled, _0_onClick = _0.onClick, onClick = _0_onClick === void 0 ? function() {} : _0_onClick, translations = _0.translations, props = _object_without_properties(_0, [
|
|
27516
28057
|
"classNames",
|
|
@@ -29343,6 +29884,8 @@
|
|
|
29343
29884
|
exports.ChatSidePanelLayout = ChatSidePanelLayout;
|
|
29344
29885
|
exports.ChatTrigger = ChatTrigger;
|
|
29345
29886
|
exports.ClearRefinements = ClearRefinements;
|
|
29887
|
+
exports.CompareBar = CompareBar;
|
|
29888
|
+
exports.CompareProductsToolType = CompareProductsToolType;
|
|
29346
29889
|
exports.Configure = Configure;
|
|
29347
29890
|
exports.CurrentRefinements = CurrentRefinements;
|
|
29348
29891
|
exports.DisplayResultsToolType = DisplayResultsToolType;
|
|
@@ -29391,6 +29934,7 @@
|
|
|
29391
29934
|
exports.useChat = useChat;
|
|
29392
29935
|
exports.useChatTrigger = useChatTrigger;
|
|
29393
29936
|
exports.useClearRefinements = useClearRefinements;
|
|
29937
|
+
exports.useCompare = useCompare;
|
|
29394
29938
|
exports.useConfigure = useConfigure;
|
|
29395
29939
|
exports.useConnector = useConnector;
|
|
29396
29940
|
exports.useCurrentRefinements = useCurrentRefinements;
|