react-instantsearch 6.40.2 → 6.40.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1280,25 +1280,21 @@
1280
1280
  performance.webkitNow ||
1281
1281
  function(){ return (new Date()).getTime() };
1282
1282
 
1283
- function _typeof$4(obj) {
1284
- "@babel/helpers - typeof";
1285
-
1286
- return _typeof$4 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
1287
- return typeof obj;
1288
- } : function (obj) {
1289
- return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
1290
- }, _typeof$4(obj);
1291
- }
1292
-
1293
1283
  function clone(value) {
1294
- if (_typeof$4(value) === 'object' && value !== null) {
1284
+ if (typeof value === 'object' && value !== null) {
1295
1285
  return _merge(Array.isArray(value) ? [] : {}, value);
1296
1286
  }
1297
1287
  return value;
1298
1288
  }
1289
+
1299
1290
  function isObjectOrArrayOrFunction(value) {
1300
- return typeof value === 'function' || Array.isArray(value) || Object.prototype.toString.call(value) === '[object Object]';
1291
+ return (
1292
+ typeof value === 'function' ||
1293
+ Array.isArray(value) ||
1294
+ Object.prototype.toString.call(value) === '[object Object]'
1295
+ );
1301
1296
  }
1297
+
1302
1298
  function _merge(target, source) {
1303
1299
  if (target === source) {
1304
1300
  return target;
@@ -1306,17 +1302,27 @@
1306
1302
 
1307
1303
  // eslint-disable-next-line no-restricted-syntax
1308
1304
  for (var key in source) {
1309
- if (!Object.prototype.hasOwnProperty.call(source, key) || key === '__proto__' || key === 'constructor') {
1305
+ if (
1306
+ !Object.prototype.hasOwnProperty.call(source, key) ||
1307
+ key === '__proto__' ||
1308
+ key === 'constructor'
1309
+ ) {
1310
1310
  // eslint-disable-next-line no-continue
1311
1311
  continue;
1312
1312
  }
1313
+
1313
1314
  var sourceVal = source[key];
1314
1315
  var targetVal = target[key];
1316
+
1315
1317
  if (typeof targetVal !== 'undefined' && typeof sourceVal === 'undefined') {
1316
1318
  // eslint-disable-next-line no-continue
1317
1319
  continue;
1318
1320
  }
1319
- if (isObjectOrArrayOrFunction(targetVal) && isObjectOrArrayOrFunction(sourceVal)) {
1321
+
1322
+ if (
1323
+ isObjectOrArrayOrFunction(targetVal) &&
1324
+ isObjectOrArrayOrFunction(sourceVal)
1325
+ ) {
1320
1326
  target[key] = _merge(targetVal, sourceVal);
1321
1327
  } else {
1322
1328
  target[key] = clone(sourceVal);
@@ -1344,24 +1350,24 @@
1344
1350
  if (!isObjectOrArrayOrFunction(target)) {
1345
1351
  target = {};
1346
1352
  }
1353
+
1347
1354
  for (var i = 1, l = arguments.length; i < l; i++) {
1348
1355
  var source = arguments[i];
1356
+
1349
1357
  if (isObjectOrArrayOrFunction(source)) {
1350
1358
  _merge(target, source);
1351
1359
  }
1352
1360
  }
1353
1361
  return target;
1354
1362
  }
1355
- module.exports = merge;
1356
1363
 
1357
- var merge$1 = /*#__PURE__*/Object.freeze({
1358
- __proto__: null
1359
- });
1364
+ var merge_1 = merge;
1360
1365
 
1361
1366
  // NOTE: this behaves like lodash/defaults, but doesn't mutate the target
1362
1367
  // it also preserve keys order
1363
1368
  var defaultsPure = function defaultsPure() {
1364
1369
  var sources = Array.prototype.slice.call(arguments);
1370
+
1365
1371
  return sources.reduceRight(function (acc, source) {
1366
1372
  Object.keys(Object(source)).forEach(function (key) {
1367
1373
  if (source[key] === undefined) {
@@ -1379,7 +1385,10 @@
1379
1385
 
1380
1386
  function intersection(arr1, arr2) {
1381
1387
  return arr1.filter(function (value, index) {
1382
- return arr2.indexOf(value) > -1 && arr1.indexOf(value) === index /* skips duplicates */;
1388
+ return (
1389
+ arr2.indexOf(value) > -1 &&
1390
+ arr1.indexOf(value) === index /* skips duplicates */
1391
+ );
1383
1392
  });
1384
1393
  }
1385
1394
 
@@ -1390,11 +1399,13 @@
1390
1399
  if (!Array.isArray(array)) {
1391
1400
  return undefined;
1392
1401
  }
1402
+
1393
1403
  for (var i = 0; i < array.length; i++) {
1394
1404
  if (comparator(array[i])) {
1395
1405
  return array[i];
1396
1406
  }
1397
1407
  }
1408
+
1398
1409
  return undefined;
1399
1410
  };
1400
1411
 
@@ -1406,8 +1417,12 @@
1406
1417
  } else if (Array.isArray(v)) {
1407
1418
  return v.map(valToNumber);
1408
1419
  }
1409
- throw new Error('The value should be a number, a parsable string or an array of those.');
1420
+
1421
+ throw new Error(
1422
+ 'The value should be a number, a parsable string or an array of those.'
1423
+ );
1410
1424
  }
1425
+
1411
1426
  var valToNumber_1 = valToNumber;
1412
1427
 
1413
1428
  // https://github.com/babel/babel/blob/3aaafae053fa75febb3aa45d45b6f00646e30ba4/packages/babel-helpers/src/helpers.js#L604-L620
@@ -1425,11 +1440,13 @@
1425
1440
  }
1426
1441
  return target;
1427
1442
  }
1443
+
1428
1444
  var omit$1 = _objectWithoutPropertiesLoose$2;
1429
1445
 
1430
1446
  function objectHasKeys$1(obj) {
1431
1447
  return obj && Object.keys(obj).length > 0;
1432
1448
  }
1449
+
1433
1450
  var objectHasKeys_1 = objectHasKeys$1;
1434
1451
 
1435
1452
  var isValidUserToken = function isValidUserToken(userToken) {
@@ -1453,6 +1470,8 @@
1453
1470
 
1454
1471
 
1455
1472
 
1473
+
1474
+
1456
1475
  var lib = {
1457
1476
  /**
1458
1477
  * Adds a refinement to a RefinementList
@@ -1465,10 +1484,17 @@
1465
1484
  if (lib.isRefined(refinementList, attribute, value)) {
1466
1485
  return refinementList;
1467
1486
  }
1487
+
1468
1488
  var valueAsString = '' + value;
1469
- var facetRefinement = !refinementList[attribute] ? [valueAsString] : refinementList[attribute].concat(valueAsString);
1489
+
1490
+ var facetRefinement = !refinementList[attribute]
1491
+ ? [valueAsString]
1492
+ : refinementList[attribute].concat(valueAsString);
1493
+
1470
1494
  var mod = {};
1495
+
1471
1496
  mod[attribute] = facetRefinement;
1497
+
1472
1498
  return defaultsPure({}, mod, refinementList);
1473
1499
  },
1474
1500
  /**
@@ -1480,7 +1506,11 @@
1480
1506
  * @param {string} [value] the value of the refinement
1481
1507
  * @return {RefinementList} a new and updated refinement lst
1482
1508
  */
1483
- removeRefinement: function removeRefinement(refinementList, attribute, value) {
1509
+ removeRefinement: function removeRefinement(
1510
+ refinementList,
1511
+ attribute,
1512
+ value
1513
+ ) {
1484
1514
  if (value === undefined) {
1485
1515
  // we use the "filter" form of clearRefinement, since it leaves empty values as-is
1486
1516
  // the form with a string will remove the attribute completely
@@ -1488,7 +1518,9 @@
1488
1518
  return attribute === f;
1489
1519
  });
1490
1520
  }
1521
+
1491
1522
  var valueAsString = '' + value;
1523
+
1492
1524
  return lib.clearRefinement(refinementList, function (v, f) {
1493
1525
  return attribute === f && valueAsString === v;
1494
1526
  });
@@ -1500,11 +1532,18 @@
1500
1532
  * @param {string} value the value of the refinement
1501
1533
  * @return {RefinementList} a new and updated list
1502
1534
  */
1503
- toggleRefinement: function toggleRefinement(refinementList, attribute, value) {
1504
- if (value === undefined) throw new Error('toggleRefinement should be used with a value');
1535
+ toggleRefinement: function toggleRefinement(
1536
+ refinementList,
1537
+ attribute,
1538
+ value
1539
+ ) {
1540
+ if (value === undefined)
1541
+ throw new Error('toggleRefinement should be used with a value');
1542
+
1505
1543
  if (lib.isRefined(refinementList, attribute, value)) {
1506
1544
  return lib.removeRefinement(refinementList, attribute, value);
1507
1545
  }
1546
+
1508
1547
  return lib.addRefinement(refinementList, attribute, value);
1509
1548
  },
1510
1549
  /**
@@ -1518,7 +1557,11 @@
1518
1557
  * @param {string} [refinementType] optional parameter to give more context to the attribute function
1519
1558
  * @return {RefinementList} a new and updated refinement list
1520
1559
  */
1521
- clearRefinement: function clearRefinement(refinementList, attribute, refinementType) {
1560
+ clearRefinement: function clearRefinement(
1561
+ refinementList,
1562
+ attribute,
1563
+ refinementType
1564
+ ) {
1522
1565
  if (attribute === undefined) {
1523
1566
  // return the same object if the list is already empty
1524
1567
  // this is mainly for tests, as it doesn't have much impact on performance
@@ -1530,17 +1573,26 @@
1530
1573
  return omit$1(refinementList, [attribute]);
1531
1574
  } else if (typeof attribute === 'function') {
1532
1575
  var hasChanged = false;
1533
- var newRefinementList = Object.keys(refinementList).reduce(function (memo, key) {
1576
+
1577
+ var newRefinementList = Object.keys(refinementList).reduce(function (
1578
+ memo,
1579
+ key
1580
+ ) {
1534
1581
  var values = refinementList[key] || [];
1535
1582
  var facetList = values.filter(function (value) {
1536
1583
  return !attribute(value, key, refinementType);
1537
1584
  });
1585
+
1538
1586
  if (facetList.length !== values.length) {
1539
1587
  hasChanged = true;
1540
1588
  }
1589
+
1541
1590
  memo[key] = facetList;
1591
+
1542
1592
  return memo;
1543
- }, {});
1593
+ },
1594
+ {});
1595
+
1544
1596
  if (hasChanged) return newRefinementList;
1545
1597
  return refinementList;
1546
1598
  }
@@ -1559,14 +1611,20 @@
1559
1611
  * @return {boolean} true if the attribute is refined, false otherwise
1560
1612
  */
1561
1613
  isRefined: function isRefined(refinementList, attribute, refinementValue) {
1562
- var containsRefinements = Boolean(refinementList[attribute]) && refinementList[attribute].length > 0;
1614
+ var containsRefinements =
1615
+ Boolean(refinementList[attribute]) &&
1616
+ refinementList[attribute].length > 0;
1617
+
1563
1618
  if (refinementValue === undefined || !containsRefinements) {
1564
1619
  return containsRefinements;
1565
1620
  }
1621
+
1566
1622
  var refinementValueAsString = '' + refinementValue;
1623
+
1567
1624
  return refinementList[attribute].indexOf(refinementValueAsString) !== -1;
1568
- }
1625
+ },
1569
1626
  };
1627
+
1570
1628
  var RefinementList = lib;
1571
1629
 
1572
1630
  /**
@@ -1581,9 +1639,12 @@
1581
1639
  */
1582
1640
  function isEqualNumericRefinement(a, b) {
1583
1641
  if (Array.isArray(a) && Array.isArray(b)) {
1584
- return a.length === b.length && a.every(function (el, i) {
1585
- return isEqualNumericRefinement(b[i], el);
1586
- });
1642
+ return (
1643
+ a.length === b.length &&
1644
+ a.every(function (el, i) {
1645
+ return isEqualNumericRefinement(b[i], el);
1646
+ })
1647
+ );
1587
1648
  }
1588
1649
  return a === b;
1589
1650
  }
@@ -1650,10 +1711,15 @@
1650
1711
  }
1651
1712
  */
1652
1713
  function SearchParameters(newParameters) {
1653
- var params = newParameters ? SearchParameters._parseNumbers(newParameters) : {};
1714
+ var params = newParameters
1715
+ ? SearchParameters._parseNumbers(newParameters)
1716
+ : {};
1717
+
1654
1718
  if (params.userToken !== undefined && !isValidUserToken(params.userToken)) {
1655
1719
  // eslint-disable-next-line no-console
1656
- console.warn('[algoliasearch-helper] The `userToken` parameter is invalid. This can lead to wrong analytics.\n - Format: [a-zA-Z0-9_-]{1,64}');
1720
+ console.warn(
1721
+ '[algoliasearch-helper] The `userToken` parameter is invalid. This can lead to wrong analytics.\n - Format: [a-zA-Z0-9_-]{1,64}'
1722
+ );
1657
1723
  }
1658
1724
  /**
1659
1725
  * This attribute contains the list of all the conjunctive facets
@@ -1753,13 +1819,15 @@
1753
1819
  * be translated into the `facetFilters` attribute.
1754
1820
  * @member {Object.<string, SearchParameters.FacetList>}
1755
1821
  */
1756
- this.hierarchicalFacetsRefinements = params.hierarchicalFacetsRefinements || {};
1822
+ this.hierarchicalFacetsRefinements =
1823
+ params.hierarchicalFacetsRefinements || {};
1757
1824
 
1758
1825
  // eslint-disable-next-line consistent-this
1759
1826
  var self = this;
1760
1827
  Object.keys(params).forEach(function (paramName) {
1761
1828
  var isKeyKnown = SearchParameters.PARAMETERS.indexOf(paramName) !== -1;
1762
1829
  var isValueDefined = params[paramName] !== undefined;
1830
+
1763
1831
  if (!isKeyKnown && isValueDefined) {
1764
1832
  self[paramName] = params[paramName];
1765
1833
  }
@@ -1781,8 +1849,23 @@
1781
1849
  SearchParameters._parseNumbers = function (partialState) {
1782
1850
  // Do not parse numbers again in SearchParameters, they ought to be parsed already
1783
1851
  if (partialState instanceof SearchParameters) return partialState;
1852
+
1784
1853
  var numbers = {};
1785
- var numberKeys = ['aroundPrecision', 'aroundRadius', 'getRankingInfo', 'minWordSizefor2Typos', 'minWordSizefor1Typo', 'page', 'maxValuesPerFacet', 'distinct', 'minimumAroundRadius', 'hitsPerPage', 'minProximity'];
1854
+
1855
+ var numberKeys = [
1856
+ 'aroundPrecision',
1857
+ 'aroundRadius',
1858
+ 'getRankingInfo',
1859
+ 'minWordSizefor2Typos',
1860
+ 'minWordSizefor1Typo',
1861
+ 'page',
1862
+ 'maxValuesPerFacet',
1863
+ 'distinct',
1864
+ 'minimumAroundRadius',
1865
+ 'hitsPerPage',
1866
+ 'minProximity',
1867
+ ];
1868
+
1786
1869
  numberKeys.forEach(function (k) {
1787
1870
  var value = partialState[k];
1788
1871
  if (typeof value === 'string') {
@@ -1795,7 +1878,9 @@
1795
1878
  // there's two formats of insideBoundingBox, we need to parse
1796
1879
  // the one which is an array of float geo rectangles
1797
1880
  if (Array.isArray(partialState.insideBoundingBox)) {
1798
- numbers.insideBoundingBox = partialState.insideBoundingBox.map(function (geoRect) {
1881
+ numbers.insideBoundingBox = partialState.insideBoundingBox.map(function (
1882
+ geoRect
1883
+ ) {
1799
1884
  if (Array.isArray(geoRect)) {
1800
1885
  return geoRect.map(function (value) {
1801
1886
  return parseFloat(value);
@@ -1804,6 +1889,7 @@
1804
1889
  return geoRect;
1805
1890
  });
1806
1891
  }
1892
+
1807
1893
  if (partialState.numericRefinements) {
1808
1894
  var numericRefinements = {};
1809
1895
  Object.keys(partialState.numericRefinements).forEach(function (attribute) {
@@ -1829,7 +1915,8 @@
1829
1915
  });
1830
1916
  numbers.numericRefinements = numericRefinements;
1831
1917
  }
1832
- return merge$1({}, partialState, numbers);
1918
+
1919
+ return merge_1({}, partialState, numbers);
1833
1920
  };
1834
1921
 
1835
1922
  /**
@@ -1840,21 +1927,30 @@
1840
1927
  */
1841
1928
  SearchParameters.make = function makeSearchParameters(newParameters) {
1842
1929
  var instance = new SearchParameters(newParameters);
1930
+
1843
1931
  var hierarchicalFacets = newParameters.hierarchicalFacets || [];
1844
1932
  hierarchicalFacets.forEach(function (facet) {
1845
1933
  if (facet.rootPath) {
1846
1934
  var currentRefinement = instance.getHierarchicalRefinement(facet.name);
1847
- if (currentRefinement.length > 0 && currentRefinement[0].indexOf(facet.rootPath) !== 0) {
1935
+
1936
+ if (
1937
+ currentRefinement.length > 0 &&
1938
+ currentRefinement[0].indexOf(facet.rootPath) !== 0
1939
+ ) {
1848
1940
  instance = instance.clearRefinements(facet.name);
1849
1941
  }
1850
1942
 
1851
1943
  // get it again in case it has been cleared
1852
1944
  currentRefinement = instance.getHierarchicalRefinement(facet.name);
1853
1945
  if (currentRefinement.length === 0) {
1854
- instance = instance.toggleHierarchicalFacetRefinement(facet.name, facet.rootPath);
1946
+ instance = instance.toggleHierarchicalFacetRefinement(
1947
+ facet.name,
1948
+ facet.rootPath
1949
+ );
1855
1950
  }
1856
1951
  }
1857
1952
  });
1953
+
1858
1954
  return instance;
1859
1955
  };
1860
1956
 
@@ -1866,22 +1962,51 @@
1866
1962
  */
1867
1963
  SearchParameters.validate = function (currentState, parameters) {
1868
1964
  var params = parameters || {};
1869
- if (currentState.tagFilters && params.tagRefinements && params.tagRefinements.length > 0) {
1870
- return new Error('[Tags] Cannot switch from the managed tag API to the advanced API. It is probably ' + 'an error, if it is really what you want, you should first clear the tags with clearTags method.');
1965
+
1966
+ if (
1967
+ currentState.tagFilters &&
1968
+ params.tagRefinements &&
1969
+ params.tagRefinements.length > 0
1970
+ ) {
1971
+ return new Error(
1972
+ '[Tags] Cannot switch from the managed tag API to the advanced API. It is probably ' +
1973
+ 'an error, if it is really what you want, you should first clear the tags with clearTags method.'
1974
+ );
1871
1975
  }
1976
+
1872
1977
  if (currentState.tagRefinements.length > 0 && params.tagFilters) {
1873
- return new Error('[Tags] Cannot switch from the advanced tag API to the managed API. It is probably ' + 'an error, if it is not, you should first clear the tags with clearTags method.');
1978
+ return new Error(
1979
+ '[Tags] Cannot switch from the advanced tag API to the managed API. It is probably ' +
1980
+ 'an error, if it is not, you should first clear the tags with clearTags method.'
1981
+ );
1874
1982
  }
1875
- if (currentState.numericFilters && params.numericRefinements && objectHasKeys_1(params.numericRefinements)) {
1876
- return new Error("[Numeric filters] Can't switch from the advanced to the managed API. It" + ' is probably an error, if this is really what you want, you have to first' + ' clear the numeric filters.');
1983
+
1984
+ if (
1985
+ currentState.numericFilters &&
1986
+ params.numericRefinements &&
1987
+ objectHasKeys_1(params.numericRefinements)
1988
+ ) {
1989
+ return new Error(
1990
+ "[Numeric filters] Can't switch from the advanced to the managed API. It" +
1991
+ ' is probably an error, if this is really what you want, you have to first' +
1992
+ ' clear the numeric filters.'
1993
+ );
1877
1994
  }
1995
+
1878
1996
  if (objectHasKeys_1(currentState.numericRefinements) && params.numericFilters) {
1879
- return new Error("[Numeric filters] Can't switch from the managed API to the advanced. It" + ' is probably an error, if this is really what you want, you have to first' + ' clear the numeric filters.');
1997
+ return new Error(
1998
+ "[Numeric filters] Can't switch from the managed API to the advanced. It" +
1999
+ ' is probably an error, if this is really what you want, you have to first' +
2000
+ ' clear the numeric filters.'
2001
+ );
1880
2002
  }
2003
+
1881
2004
  return null;
1882
2005
  };
2006
+
1883
2007
  SearchParameters.prototype = {
1884
2008
  constructor: SearchParameters,
2009
+
1885
2010
  /**
1886
2011
  * Remove all refinements (disjunctive + conjunctive + excludes + numeric filters)
1887
2012
  * @method
@@ -1894,12 +2019,35 @@
1894
2019
  clearRefinements: function clearRefinements(attribute) {
1895
2020
  var patch = {
1896
2021
  numericRefinements: this._clearNumericRefinements(attribute),
1897
- facetsRefinements: RefinementList.clearRefinement(this.facetsRefinements, attribute, 'conjunctiveFacet'),
1898
- facetsExcludes: RefinementList.clearRefinement(this.facetsExcludes, attribute, 'exclude'),
1899
- disjunctiveFacetsRefinements: RefinementList.clearRefinement(this.disjunctiveFacetsRefinements, attribute, 'disjunctiveFacet'),
1900
- hierarchicalFacetsRefinements: RefinementList.clearRefinement(this.hierarchicalFacetsRefinements, attribute, 'hierarchicalFacet')
2022
+ facetsRefinements: RefinementList.clearRefinement(
2023
+ this.facetsRefinements,
2024
+ attribute,
2025
+ 'conjunctiveFacet'
2026
+ ),
2027
+ facetsExcludes: RefinementList.clearRefinement(
2028
+ this.facetsExcludes,
2029
+ attribute,
2030
+ 'exclude'
2031
+ ),
2032
+ disjunctiveFacetsRefinements: RefinementList.clearRefinement(
2033
+ this.disjunctiveFacetsRefinements,
2034
+ attribute,
2035
+ 'disjunctiveFacet'
2036
+ ),
2037
+ hierarchicalFacetsRefinements: RefinementList.clearRefinement(
2038
+ this.hierarchicalFacetsRefinements,
2039
+ attribute,
2040
+ 'hierarchicalFacet'
2041
+ ),
1901
2042
  };
1902
- if (patch.numericRefinements === this.numericRefinements && patch.facetsRefinements === this.facetsRefinements && patch.facetsExcludes === this.facetsExcludes && patch.disjunctiveFacetsRefinements === this.disjunctiveFacetsRefinements && patch.hierarchicalFacetsRefinements === this.hierarchicalFacetsRefinements) {
2043
+ if (
2044
+ patch.numericRefinements === this.numericRefinements &&
2045
+ patch.facetsRefinements === this.facetsRefinements &&
2046
+ patch.facetsExcludes === this.facetsExcludes &&
2047
+ patch.disjunctiveFacetsRefinements ===
2048
+ this.disjunctiveFacetsRefinements &&
2049
+ patch.hierarchicalFacetsRefinements === this.hierarchicalFacetsRefinements
2050
+ ) {
1903
2051
  return this;
1904
2052
  }
1905
2053
  return this.setQueryParameters(patch);
@@ -1910,10 +2058,12 @@
1910
2058
  * @return {SearchParameters} new instance with tags cleared
1911
2059
  */
1912
2060
  clearTags: function clearTags() {
1913
- if (this.tagFilters === undefined && this.tagRefinements.length === 0) return this;
2061
+ if (this.tagFilters === undefined && this.tagRefinements.length === 0)
2062
+ return this;
2063
+
1914
2064
  return this.setQueryParameters({
1915
2065
  tagFilters: undefined,
1916
- tagRefinements: []
2066
+ tagRefinements: [],
1917
2067
  });
1918
2068
  },
1919
2069
  /**
@@ -1924,8 +2074,9 @@
1924
2074
  */
1925
2075
  setIndex: function setIndex(index) {
1926
2076
  if (index === this.index) return this;
2077
+
1927
2078
  return this.setQueryParameters({
1928
- index: index
2079
+ index: index,
1929
2080
  });
1930
2081
  },
1931
2082
  /**
@@ -1936,8 +2087,9 @@
1936
2087
  */
1937
2088
  setQuery: function setQuery(newQuery) {
1938
2089
  if (newQuery === this.query) return this;
2090
+
1939
2091
  return this.setQueryParameters({
1940
- query: newQuery
2092
+ query: newQuery,
1941
2093
  });
1942
2094
  },
1943
2095
  /**
@@ -1948,8 +2100,9 @@
1948
2100
  */
1949
2101
  setPage: function setPage(newPage) {
1950
2102
  if (newPage === this.page) return this;
2103
+
1951
2104
  return this.setQueryParameters({
1952
- page: newPage
2105
+ page: newPage,
1953
2106
  });
1954
2107
  },
1955
2108
  /**
@@ -1961,7 +2114,7 @@
1961
2114
  */
1962
2115
  setFacets: function setFacets(facets) {
1963
2116
  return this.setQueryParameters({
1964
- facets: facets
2117
+ facets: facets,
1965
2118
  });
1966
2119
  },
1967
2120
  /**
@@ -1973,7 +2126,7 @@
1973
2126
  */
1974
2127
  setDisjunctiveFacets: function setDisjunctiveFacets(facets) {
1975
2128
  return this.setQueryParameters({
1976
- disjunctiveFacets: facets
2129
+ disjunctiveFacets: facets,
1977
2130
  });
1978
2131
  },
1979
2132
  /**
@@ -1985,8 +2138,9 @@
1985
2138
  */
1986
2139
  setHitsPerPage: function setHitsPerPage(n) {
1987
2140
  if (this.hitsPerPage === n) return this;
2141
+
1988
2142
  return this.setQueryParameters({
1989
- hitsPerPage: n
2143
+ hitsPerPage: n,
1990
2144
  });
1991
2145
  },
1992
2146
  /**
@@ -1998,8 +2152,9 @@
1998
2152
  */
1999
2153
  setTypoTolerance: function setTypoTolerance(typoTolerance) {
2000
2154
  if (this.typoTolerance === typoTolerance) return this;
2155
+
2001
2156
  return this.setQueryParameters({
2002
- typoTolerance: typoTolerance
2157
+ typoTolerance: typoTolerance,
2003
2158
  });
2004
2159
  },
2005
2160
  /**
@@ -2019,11 +2174,15 @@
2019
2174
  * state.addNumericRefinement('size', '=', 38);
2020
2175
  * state.addNumericRefinement('size', '=', 40);
2021
2176
  */
2022
- addNumericRefinement: function addNumericRefinement(attribute, operator, value) {
2177
+ addNumericRefinement: function (attribute, operator, value) {
2023
2178
  var val = valToNumber_1(value);
2179
+
2024
2180
  if (this.isNumericRefined(attribute, operator, val)) return this;
2025
- var mod = merge$1({}, this.numericRefinements);
2026
- mod[attribute] = merge$1({}, mod[attribute]);
2181
+
2182
+ var mod = merge_1({}, this.numericRefinements);
2183
+
2184
+ mod[attribute] = merge_1({}, mod[attribute]);
2185
+
2027
2186
  if (mod[attribute][operator]) {
2028
2187
  // Array copy
2029
2188
  mod[attribute][operator] = mod[attribute][operator].slice();
@@ -2032,8 +2191,9 @@
2032
2191
  } else {
2033
2192
  mod[attribute][operator] = [val];
2034
2193
  }
2194
+
2035
2195
  return this.setQueryParameters({
2036
- numericRefinements: mod
2196
+ numericRefinements: mod,
2037
2197
  });
2038
2198
  },
2039
2199
  /**
@@ -2041,7 +2201,7 @@
2041
2201
  * @param {string} facetName name of the attribute used for faceting
2042
2202
  * @return {string[]} list of refinements
2043
2203
  */
2044
- getConjunctiveRefinements: function getConjunctiveRefinements(facetName) {
2204
+ getConjunctiveRefinements: function (facetName) {
2045
2205
  if (!this.isConjunctiveFacet(facetName)) {
2046
2206
  return [];
2047
2207
  }
@@ -2052,7 +2212,7 @@
2052
2212
  * @param {string} facetName name of the attribute used for faceting
2053
2213
  * @return {string[]} list of refinements
2054
2214
  */
2055
- getDisjunctiveRefinements: function getDisjunctiveRefinements(facetName) {
2215
+ getDisjunctiveRefinements: function (facetName) {
2056
2216
  if (!this.isDisjunctiveFacet(facetName)) {
2057
2217
  return [];
2058
2218
  }
@@ -2063,7 +2223,7 @@
2063
2223
  * @param {string} facetName name of the attribute used for faceting
2064
2224
  * @return {string[]} list of refinements
2065
2225
  */
2066
- getHierarchicalRefinement: function getHierarchicalRefinement(facetName) {
2226
+ getHierarchicalRefinement: function (facetName) {
2067
2227
  // we send an array but we currently do not support multiple
2068
2228
  // hierarchicalRefinements for a hierarchicalFacet
2069
2229
  return this.hierarchicalFacetsRefinements[facetName] || [];
@@ -2073,12 +2233,13 @@
2073
2233
  * @param {string} facetName name of the attribute used for faceting
2074
2234
  * @return {string[]} list of refinements
2075
2235
  */
2076
- getExcludeRefinements: function getExcludeRefinements(facetName) {
2236
+ getExcludeRefinements: function (facetName) {
2077
2237
  if (!this.isConjunctiveFacet(facetName)) {
2078
2238
  return [];
2079
2239
  }
2080
2240
  return this.facetsExcludes[facetName] || [];
2081
2241
  },
2242
+
2082
2243
  /**
2083
2244
  * Remove all the numeric filter for a given (attribute, operator)
2084
2245
  * @method
@@ -2087,30 +2248,41 @@
2087
2248
  * @param {number} [number] the value to be removed
2088
2249
  * @return {SearchParameters} new instance
2089
2250
  */
2090
- removeNumericRefinement: function removeNumericRefinement(attribute, operator, number) {
2251
+ removeNumericRefinement: function (attribute, operator, number) {
2091
2252
  var paramValue = number;
2092
2253
  if (paramValue !== undefined) {
2093
2254
  if (!this.isNumericRefined(attribute, operator, paramValue)) {
2094
2255
  return this;
2095
2256
  }
2096
2257
  return this.setQueryParameters({
2097
- numericRefinements: this._clearNumericRefinements(function (value, key) {
2098
- return key === attribute && value.op === operator && isEqualNumericRefinement(value.val, valToNumber_1(paramValue));
2099
- })
2258
+ numericRefinements: this._clearNumericRefinements(function (
2259
+ value,
2260
+ key
2261
+ ) {
2262
+ return (
2263
+ key === attribute &&
2264
+ value.op === operator &&
2265
+ isEqualNumericRefinement(value.val, valToNumber_1(paramValue))
2266
+ );
2267
+ }),
2100
2268
  });
2101
2269
  } else if (operator !== undefined) {
2102
2270
  if (!this.isNumericRefined(attribute, operator)) return this;
2103
2271
  return this.setQueryParameters({
2104
- numericRefinements: this._clearNumericRefinements(function (value, key) {
2272
+ numericRefinements: this._clearNumericRefinements(function (
2273
+ value,
2274
+ key
2275
+ ) {
2105
2276
  return key === attribute && value.op === operator;
2106
- })
2277
+ }),
2107
2278
  });
2108
2279
  }
2280
+
2109
2281
  if (!this.isNumericRefined(attribute)) return this;
2110
2282
  return this.setQueryParameters({
2111
2283
  numericRefinements: this._clearNumericRefinements(function (value, key) {
2112
2284
  return key === attribute;
2113
- })
2285
+ }),
2114
2286
  });
2115
2287
  },
2116
2288
  /**
@@ -2118,7 +2290,7 @@
2118
2290
  * @param {string} facetName name of the attribute used for faceting
2119
2291
  * @return {SearchParameters.OperatorList} list of refinements
2120
2292
  */
2121
- getNumericRefinements: function getNumericRefinements(facetName) {
2293
+ getNumericRefinements: function (facetName) {
2122
2294
  return this.numericRefinements[facetName] || {};
2123
2295
  },
2124
2296
  /**
@@ -2127,8 +2299,11 @@
2127
2299
  * @param {string} operator operator applied on the refined values
2128
2300
  * @return {Array.<number|number[]>} refined values
2129
2301
  */
2130
- getNumericRefinement: function getNumericRefinement(attribute, operator) {
2131
- return this.numericRefinements[attribute] && this.numericRefinements[attribute][operator];
2302
+ getNumericRefinement: function (attribute, operator) {
2303
+ return (
2304
+ this.numericRefinements[attribute] &&
2305
+ this.numericRefinements[attribute][operator]
2306
+ );
2132
2307
  },
2133
2308
  /**
2134
2309
  * Clear numeric filters.
@@ -2151,28 +2326,36 @@
2151
2326
  } else if (typeof attribute === 'function') {
2152
2327
  var hasChanged = false;
2153
2328
  var numericRefinements = this.numericRefinements;
2154
- var newNumericRefinements = Object.keys(numericRefinements).reduce(function (memo, key) {
2155
- var operators = numericRefinements[key];
2156
- var operatorList = {};
2157
- operators = operators || {};
2158
- Object.keys(operators).forEach(function (operator) {
2159
- var values = operators[operator] || [];
2160
- var outValues = [];
2161
- values.forEach(function (value) {
2162
- var predicateResult = attribute({
2163
- val: value,
2164
- op: operator
2165
- }, key, 'numeric');
2166
- if (!predicateResult) outValues.push(value);
2329
+ var newNumericRefinements = Object.keys(numericRefinements).reduce(
2330
+ function (memo, key) {
2331
+ var operators = numericRefinements[key];
2332
+ var operatorList = {};
2333
+
2334
+ operators = operators || {};
2335
+ Object.keys(operators).forEach(function (operator) {
2336
+ var values = operators[operator] || [];
2337
+ var outValues = [];
2338
+ values.forEach(function (value) {
2339
+ var predicateResult = attribute(
2340
+ { val: value, op: operator },
2341
+ key,
2342
+ 'numeric'
2343
+ );
2344
+ if (!predicateResult) outValues.push(value);
2345
+ });
2346
+ if (outValues.length !== values.length) {
2347
+ hasChanged = true;
2348
+ }
2349
+ operatorList[operator] = outValues;
2167
2350
  });
2168
- if (outValues.length !== values.length) {
2169
- hasChanged = true;
2170
- }
2171
- operatorList[operator] = outValues;
2172
- });
2173
- memo[key] = operatorList;
2174
- return memo;
2175
- }, {});
2351
+
2352
+ memo[key] = operatorList;
2353
+
2354
+ return memo;
2355
+ },
2356
+ {}
2357
+ );
2358
+
2176
2359
  if (hasChanged) return newNumericRefinements;
2177
2360
  return this.numericRefinements;
2178
2361
  }
@@ -2192,8 +2375,9 @@
2192
2375
  if (this.isConjunctiveFacet(facet)) {
2193
2376
  return this;
2194
2377
  }
2378
+
2195
2379
  return this.setQueryParameters({
2196
- facets: this.facets.concat([facet])
2380
+ facets: this.facets.concat([facet]),
2197
2381
  });
2198
2382
  },
2199
2383
  /**
@@ -2207,8 +2391,9 @@
2207
2391
  if (this.isDisjunctiveFacet(facet)) {
2208
2392
  return this;
2209
2393
  }
2394
+
2210
2395
  return this.setQueryParameters({
2211
- disjunctiveFacets: this.disjunctiveFacets.concat([facet])
2396
+ disjunctiveFacets: this.disjunctiveFacets.concat([facet]),
2212
2397
  });
2213
2398
  },
2214
2399
  /**
@@ -2221,10 +2406,15 @@
2221
2406
  */
2222
2407
  addHierarchicalFacet: function addHierarchicalFacet(hierarchicalFacet) {
2223
2408
  if (this.isHierarchicalFacet(hierarchicalFacet.name)) {
2224
- throw new Error('Cannot declare two hierarchical facets with the same name: `' + hierarchicalFacet.name + '`');
2409
+ throw new Error(
2410
+ 'Cannot declare two hierarchical facets with the same name: `' +
2411
+ hierarchicalFacet.name +
2412
+ '`'
2413
+ );
2225
2414
  }
2415
+
2226
2416
  return this.setQueryParameters({
2227
- hierarchicalFacets: this.hierarchicalFacets.concat([hierarchicalFacet])
2417
+ hierarchicalFacets: this.hierarchicalFacets.concat([hierarchicalFacet]),
2228
2418
  });
2229
2419
  },
2230
2420
  /**
@@ -2236,11 +2426,20 @@
2236
2426
  */
2237
2427
  addFacetRefinement: function addFacetRefinement(facet, value) {
2238
2428
  if (!this.isConjunctiveFacet(facet)) {
2239
- throw new Error(facet + ' is not defined in the facets attribute of the helper configuration');
2429
+ throw new Error(
2430
+ facet +
2431
+ ' is not defined in the facets attribute of the helper configuration'
2432
+ );
2240
2433
  }
2241
- if (RefinementList.isRefined(this.facetsRefinements, facet, value)) return this;
2434
+ if (RefinementList.isRefined(this.facetsRefinements, facet, value))
2435
+ return this;
2436
+
2242
2437
  return this.setQueryParameters({
2243
- facetsRefinements: RefinementList.addRefinement(this.facetsRefinements, facet, value)
2438
+ facetsRefinements: RefinementList.addRefinement(
2439
+ this.facetsRefinements,
2440
+ facet,
2441
+ value
2442
+ ),
2244
2443
  });
2245
2444
  },
2246
2445
  /**
@@ -2252,11 +2451,20 @@
2252
2451
  */
2253
2452
  addExcludeRefinement: function addExcludeRefinement(facet, value) {
2254
2453
  if (!this.isConjunctiveFacet(facet)) {
2255
- throw new Error(facet + ' is not defined in the facets attribute of the helper configuration');
2454
+ throw new Error(
2455
+ facet +
2456
+ ' is not defined in the facets attribute of the helper configuration'
2457
+ );
2256
2458
  }
2257
- if (RefinementList.isRefined(this.facetsExcludes, facet, value)) return this;
2459
+ if (RefinementList.isRefined(this.facetsExcludes, facet, value))
2460
+ return this;
2461
+
2258
2462
  return this.setQueryParameters({
2259
- facetsExcludes: RefinementList.addRefinement(this.facetsExcludes, facet, value)
2463
+ facetsExcludes: RefinementList.addRefinement(
2464
+ this.facetsExcludes,
2465
+ facet,
2466
+ value
2467
+ ),
2260
2468
  });
2261
2469
  },
2262
2470
  /**
@@ -2266,13 +2474,28 @@
2266
2474
  * @param {string} value value of the attribute (will be converted to string)
2267
2475
  * @return {SearchParameters} new instance
2268
2476
  */
2269
- addDisjunctiveFacetRefinement: function addDisjunctiveFacetRefinement(facet, value) {
2477
+ addDisjunctiveFacetRefinement: function addDisjunctiveFacetRefinement(
2478
+ facet,
2479
+ value
2480
+ ) {
2270
2481
  if (!this.isDisjunctiveFacet(facet)) {
2271
- throw new Error(facet + ' is not defined in the disjunctiveFacets attribute of the helper configuration');
2482
+ throw new Error(
2483
+ facet +
2484
+ ' is not defined in the disjunctiveFacets attribute of the helper configuration'
2485
+ );
2272
2486
  }
2273
- if (RefinementList.isRefined(this.disjunctiveFacetsRefinements, facet, value)) return this;
2487
+
2488
+ if (
2489
+ RefinementList.isRefined(this.disjunctiveFacetsRefinements, facet, value)
2490
+ )
2491
+ return this;
2492
+
2274
2493
  return this.setQueryParameters({
2275
- disjunctiveFacetsRefinements: RefinementList.addRefinement(this.disjunctiveFacetsRefinements, facet, value)
2494
+ disjunctiveFacetsRefinements: RefinementList.addRefinement(
2495
+ this.disjunctiveFacetsRefinements,
2496
+ facet,
2497
+ value
2498
+ ),
2276
2499
  });
2277
2500
  },
2278
2501
  /**
@@ -2282,9 +2505,11 @@
2282
2505
  */
2283
2506
  addTagRefinement: function addTagRefinement(tag) {
2284
2507
  if (this.isTagRefined(tag)) return this;
2508
+
2285
2509
  var modification = {
2286
- tagRefinements: this.tagRefinements.concat(tag)
2510
+ tagRefinements: this.tagRefinements.concat(tag),
2287
2511
  };
2512
+
2288
2513
  return this.setQueryParameters(modification);
2289
2514
  },
2290
2515
  /**
@@ -2298,10 +2523,11 @@
2298
2523
  if (!this.isConjunctiveFacet(facet)) {
2299
2524
  return this;
2300
2525
  }
2526
+
2301
2527
  return this.clearRefinements(facet).setQueryParameters({
2302
2528
  facets: this.facets.filter(function (f) {
2303
2529
  return f !== facet;
2304
- })
2530
+ }),
2305
2531
  });
2306
2532
  },
2307
2533
  /**
@@ -2315,10 +2541,11 @@
2315
2541
  if (!this.isDisjunctiveFacet(facet)) {
2316
2542
  return this;
2317
2543
  }
2544
+
2318
2545
  return this.clearRefinements(facet).setQueryParameters({
2319
2546
  disjunctiveFacets: this.disjunctiveFacets.filter(function (f) {
2320
2547
  return f !== facet;
2321
- })
2548
+ }),
2322
2549
  });
2323
2550
  },
2324
2551
  /**
@@ -2332,10 +2559,11 @@
2332
2559
  if (!this.isHierarchicalFacet(facet)) {
2333
2560
  return this;
2334
2561
  }
2562
+
2335
2563
  return this.clearRefinements(facet).setQueryParameters({
2336
2564
  hierarchicalFacets: this.hierarchicalFacets.filter(function (f) {
2337
2565
  return f.name !== facet;
2338
- })
2566
+ }),
2339
2567
  });
2340
2568
  },
2341
2569
  /**
@@ -2349,11 +2577,20 @@
2349
2577
  */
2350
2578
  removeFacetRefinement: function removeFacetRefinement(facet, value) {
2351
2579
  if (!this.isConjunctiveFacet(facet)) {
2352
- throw new Error(facet + ' is not defined in the facets attribute of the helper configuration');
2580
+ throw new Error(
2581
+ facet +
2582
+ ' is not defined in the facets attribute of the helper configuration'
2583
+ );
2353
2584
  }
2354
- if (!RefinementList.isRefined(this.facetsRefinements, facet, value)) return this;
2585
+ if (!RefinementList.isRefined(this.facetsRefinements, facet, value))
2586
+ return this;
2587
+
2355
2588
  return this.setQueryParameters({
2356
- facetsRefinements: RefinementList.removeRefinement(this.facetsRefinements, facet, value)
2589
+ facetsRefinements: RefinementList.removeRefinement(
2590
+ this.facetsRefinements,
2591
+ facet,
2592
+ value
2593
+ ),
2357
2594
  });
2358
2595
  },
2359
2596
  /**
@@ -2365,11 +2602,20 @@
2365
2602
  */
2366
2603
  removeExcludeRefinement: function removeExcludeRefinement(facet, value) {
2367
2604
  if (!this.isConjunctiveFacet(facet)) {
2368
- throw new Error(facet + ' is not defined in the facets attribute of the helper configuration');
2605
+ throw new Error(
2606
+ facet +
2607
+ ' is not defined in the facets attribute of the helper configuration'
2608
+ );
2369
2609
  }
2370
- if (!RefinementList.isRefined(this.facetsExcludes, facet, value)) return this;
2610
+ if (!RefinementList.isRefined(this.facetsExcludes, facet, value))
2611
+ return this;
2612
+
2371
2613
  return this.setQueryParameters({
2372
- facetsExcludes: RefinementList.removeRefinement(this.facetsExcludes, facet, value)
2614
+ facetsExcludes: RefinementList.removeRefinement(
2615
+ this.facetsExcludes,
2616
+ facet,
2617
+ value
2618
+ ),
2373
2619
  });
2374
2620
  },
2375
2621
  /**
@@ -2379,13 +2625,27 @@
2379
2625
  * @param {string} value value used to filter
2380
2626
  * @return {SearchParameters} new instance
2381
2627
  */
2382
- removeDisjunctiveFacetRefinement: function removeDisjunctiveFacetRefinement(facet, value) {
2628
+ removeDisjunctiveFacetRefinement: function removeDisjunctiveFacetRefinement(
2629
+ facet,
2630
+ value
2631
+ ) {
2383
2632
  if (!this.isDisjunctiveFacet(facet)) {
2384
- throw new Error(facet + ' is not defined in the disjunctiveFacets attribute of the helper configuration');
2385
- }
2386
- if (!RefinementList.isRefined(this.disjunctiveFacetsRefinements, facet, value)) return this;
2633
+ throw new Error(
2634
+ facet +
2635
+ ' is not defined in the disjunctiveFacets attribute of the helper configuration'
2636
+ );
2637
+ }
2638
+ if (
2639
+ !RefinementList.isRefined(this.disjunctiveFacetsRefinements, facet, value)
2640
+ )
2641
+ return this;
2642
+
2387
2643
  return this.setQueryParameters({
2388
- disjunctiveFacetsRefinements: RefinementList.removeRefinement(this.disjunctiveFacetsRefinements, facet, value)
2644
+ disjunctiveFacetsRefinements: RefinementList.removeRefinement(
2645
+ this.disjunctiveFacetsRefinements,
2646
+ facet,
2647
+ value
2648
+ ),
2389
2649
  });
2390
2650
  },
2391
2651
  /**
@@ -2396,11 +2656,13 @@
2396
2656
  */
2397
2657
  removeTagRefinement: function removeTagRefinement(tag) {
2398
2658
  if (!this.isTagRefined(tag)) return this;
2659
+
2399
2660
  var modification = {
2400
2661
  tagRefinements: this.tagRefinements.filter(function (t) {
2401
2662
  return t !== tag;
2402
- })
2663
+ }),
2403
2664
  };
2665
+
2404
2666
  return this.setQueryParameters(modification);
2405
2667
  },
2406
2668
  /**
@@ -2431,7 +2693,12 @@
2431
2693
  } else if (this.isDisjunctiveFacet(facet)) {
2432
2694
  return this.toggleDisjunctiveFacetRefinement(facet, value);
2433
2695
  }
2434
- throw new Error('Cannot refine the undeclared facet ' + facet + '; it should be added to the helper options facets, disjunctiveFacets or hierarchicalFacets');
2696
+
2697
+ throw new Error(
2698
+ 'Cannot refine the undeclared facet ' +
2699
+ facet +
2700
+ '; it should be added to the helper options facets, disjunctiveFacets or hierarchicalFacets'
2701
+ );
2435
2702
  },
2436
2703
  /**
2437
2704
  * Switch the refinement applied over a facet/value
@@ -2440,12 +2707,23 @@
2440
2707
  * @param {value} value value used for filtering
2441
2708
  * @return {SearchParameters} new instance
2442
2709
  */
2443
- toggleConjunctiveFacetRefinement: function toggleConjunctiveFacetRefinement(facet, value) {
2710
+ toggleConjunctiveFacetRefinement: function toggleConjunctiveFacetRefinement(
2711
+ facet,
2712
+ value
2713
+ ) {
2444
2714
  if (!this.isConjunctiveFacet(facet)) {
2445
- throw new Error(facet + ' is not defined in the facets attribute of the helper configuration');
2715
+ throw new Error(
2716
+ facet +
2717
+ ' is not defined in the facets attribute of the helper configuration'
2718
+ );
2446
2719
  }
2720
+
2447
2721
  return this.setQueryParameters({
2448
- facetsRefinements: RefinementList.toggleRefinement(this.facetsRefinements, facet, value)
2722
+ facetsRefinements: RefinementList.toggleRefinement(
2723
+ this.facetsRefinements,
2724
+ facet,
2725
+ value
2726
+ ),
2449
2727
  });
2450
2728
  },
2451
2729
  /**
@@ -2455,12 +2733,23 @@
2455
2733
  * @param {value} value value used for filtering
2456
2734
  * @return {SearchParameters} new instance
2457
2735
  */
2458
- toggleExcludeFacetRefinement: function toggleExcludeFacetRefinement(facet, value) {
2736
+ toggleExcludeFacetRefinement: function toggleExcludeFacetRefinement(
2737
+ facet,
2738
+ value
2739
+ ) {
2459
2740
  if (!this.isConjunctiveFacet(facet)) {
2460
- throw new Error(facet + ' is not defined in the facets attribute of the helper configuration');
2741
+ throw new Error(
2742
+ facet +
2743
+ ' is not defined in the facets attribute of the helper configuration'
2744
+ );
2461
2745
  }
2746
+
2462
2747
  return this.setQueryParameters({
2463
- facetsExcludes: RefinementList.toggleRefinement(this.facetsExcludes, facet, value)
2748
+ facetsExcludes: RefinementList.toggleRefinement(
2749
+ this.facetsExcludes,
2750
+ facet,
2751
+ value
2752
+ ),
2464
2753
  });
2465
2754
  },
2466
2755
  /**
@@ -2470,12 +2759,23 @@
2470
2759
  * @param {value} value value used for filtering
2471
2760
  * @return {SearchParameters} new instance
2472
2761
  */
2473
- toggleDisjunctiveFacetRefinement: function toggleDisjunctiveFacetRefinement(facet, value) {
2762
+ toggleDisjunctiveFacetRefinement: function toggleDisjunctiveFacetRefinement(
2763
+ facet,
2764
+ value
2765
+ ) {
2474
2766
  if (!this.isDisjunctiveFacet(facet)) {
2475
- throw new Error(facet + ' is not defined in the disjunctiveFacets attribute of the helper configuration');
2767
+ throw new Error(
2768
+ facet +
2769
+ ' is not defined in the disjunctiveFacets attribute of the helper configuration'
2770
+ );
2476
2771
  }
2772
+
2477
2773
  return this.setQueryParameters({
2478
- disjunctiveFacetsRefinements: RefinementList.toggleRefinement(this.disjunctiveFacetsRefinements, facet, value)
2774
+ disjunctiveFacetsRefinements: RefinementList.toggleRefinement(
2775
+ this.disjunctiveFacetsRefinements,
2776
+ facet,
2777
+ value
2778
+ ),
2479
2779
  });
2480
2780
  },
2481
2781
  /**
@@ -2485,21 +2785,37 @@
2485
2785
  * @param {value} value value used for filtering
2486
2786
  * @return {SearchParameters} new instance
2487
2787
  */
2488
- toggleHierarchicalFacetRefinement: function toggleHierarchicalFacetRefinement(facet, value) {
2788
+ toggleHierarchicalFacetRefinement: function toggleHierarchicalFacetRefinement(
2789
+ facet,
2790
+ value
2791
+ ) {
2489
2792
  if (!this.isHierarchicalFacet(facet)) {
2490
- throw new Error(facet + ' is not defined in the hierarchicalFacets attribute of the helper configuration');
2793
+ throw new Error(
2794
+ facet +
2795
+ ' is not defined in the hierarchicalFacets attribute of the helper configuration'
2796
+ );
2491
2797
  }
2492
- var separator = this._getHierarchicalFacetSeparator(this.getHierarchicalFacetByName(facet));
2798
+
2799
+ var separator = this._getHierarchicalFacetSeparator(
2800
+ this.getHierarchicalFacetByName(facet)
2801
+ );
2802
+
2493
2803
  var mod = {};
2494
- var upOneOrMultipleLevel = this.hierarchicalFacetsRefinements[facet] !== undefined && this.hierarchicalFacetsRefinements[facet].length > 0 && (
2495
- // remove current refinement:
2496
- // refinement was 'beer > IPA', call is toggleRefine('beer > IPA'), refinement should be `beer`
2497
- this.hierarchicalFacetsRefinements[facet][0] === value ||
2498
- // remove a parent refinement of the current refinement:
2499
- // - refinement was 'beer > IPA > Flying dog'
2500
- // - call is toggleRefine('beer > IPA')
2501
- // - refinement should be `beer`
2502
- this.hierarchicalFacetsRefinements[facet][0].indexOf(value + separator) === 0);
2804
+
2805
+ var upOneOrMultipleLevel =
2806
+ this.hierarchicalFacetsRefinements[facet] !== undefined &&
2807
+ this.hierarchicalFacetsRefinements[facet].length > 0 &&
2808
+ // remove current refinement:
2809
+ // refinement was 'beer > IPA', call is toggleRefine('beer > IPA'), refinement should be `beer`
2810
+ (this.hierarchicalFacetsRefinements[facet][0] === value ||
2811
+ // remove a parent refinement of the current refinement:
2812
+ // - refinement was 'beer > IPA > Flying dog'
2813
+ // - call is toggleRefine('beer > IPA')
2814
+ // - refinement should be `beer`
2815
+ this.hierarchicalFacetsRefinements[facet][0].indexOf(
2816
+ value + separator
2817
+ ) === 0);
2818
+
2503
2819
  if (upOneOrMultipleLevel) {
2504
2820
  if (value.indexOf(separator) === -1) {
2505
2821
  // go back to root level
@@ -2510,10 +2826,16 @@
2510
2826
  } else {
2511
2827
  mod[facet] = [value];
2512
2828
  }
2829
+
2513
2830
  return this.setQueryParameters({
2514
- hierarchicalFacetsRefinements: defaultsPure({}, mod, this.hierarchicalFacetsRefinements)
2831
+ hierarchicalFacetsRefinements: defaultsPure(
2832
+ {},
2833
+ mod,
2834
+ this.hierarchicalFacetsRefinements
2835
+ ),
2515
2836
  });
2516
2837
  },
2838
+
2517
2839
  /**
2518
2840
  * Adds a refinement on a hierarchical facet.
2519
2841
  * @param {string} facet the facet name
@@ -2521,33 +2843,45 @@
2521
2843
  * @return {SearchParameter} the new state
2522
2844
  * @throws Error if the facet is not defined or if the facet is refined
2523
2845
  */
2524
- addHierarchicalFacetRefinement: function addHierarchicalFacetRefinement(facet, path) {
2846
+ addHierarchicalFacetRefinement: function (facet, path) {
2525
2847
  if (this.isHierarchicalFacetRefined(facet)) {
2526
2848
  throw new Error(facet + ' is already refined.');
2527
2849
  }
2528
2850
  if (!this.isHierarchicalFacet(facet)) {
2529
- throw new Error(facet + ' is not defined in the hierarchicalFacets attribute of the helper configuration.');
2851
+ throw new Error(
2852
+ facet +
2853
+ ' is not defined in the hierarchicalFacets attribute of the helper configuration.'
2854
+ );
2530
2855
  }
2531
2856
  var mod = {};
2532
2857
  mod[facet] = [path];
2533
2858
  return this.setQueryParameters({
2534
- hierarchicalFacetsRefinements: defaultsPure({}, mod, this.hierarchicalFacetsRefinements)
2859
+ hierarchicalFacetsRefinements: defaultsPure(
2860
+ {},
2861
+ mod,
2862
+ this.hierarchicalFacetsRefinements
2863
+ ),
2535
2864
  });
2536
2865
  },
2866
+
2537
2867
  /**
2538
2868
  * Removes the refinement set on a hierarchical facet.
2539
2869
  * @param {string} facet the facet name
2540
2870
  * @return {SearchParameter} the new state
2541
2871
  * @throws Error if the facet is not defined or if the facet is not refined
2542
2872
  */
2543
- removeHierarchicalFacetRefinement: function removeHierarchicalFacetRefinement(facet) {
2873
+ removeHierarchicalFacetRefinement: function (facet) {
2544
2874
  if (!this.isHierarchicalFacetRefined(facet)) {
2545
2875
  return this;
2546
2876
  }
2547
2877
  var mod = {};
2548
2878
  mod[facet] = [];
2549
2879
  return this.setQueryParameters({
2550
- hierarchicalFacetsRefinements: defaultsPure({}, mod, this.hierarchicalFacetsRefinements)
2880
+ hierarchicalFacetsRefinements: defaultsPure(
2881
+ {},
2882
+ mod,
2883
+ this.hierarchicalFacetsRefinements
2884
+ ),
2551
2885
  });
2552
2886
  },
2553
2887
  /**
@@ -2560,6 +2894,7 @@
2560
2894
  if (this.isTagRefined(tag)) {
2561
2895
  return this.removeTagRefinement(tag);
2562
2896
  }
2897
+
2563
2898
  return this.addTagRefinement(tag);
2564
2899
  },
2565
2900
  /**
@@ -2568,7 +2903,7 @@
2568
2903
  * @param {string} facet facet name to test
2569
2904
  * @return {boolean} true if facet is a disjunctive facet
2570
2905
  */
2571
- isDisjunctiveFacet: function isDisjunctiveFacet(facet) {
2906
+ isDisjunctiveFacet: function (facet) {
2572
2907
  return this.disjunctiveFacets.indexOf(facet) > -1;
2573
2908
  },
2574
2909
  /**
@@ -2577,7 +2912,7 @@
2577
2912
  * @param {string} facetName facet name to test
2578
2913
  * @return {boolean} true if facetName is a hierarchical facet
2579
2914
  */
2580
- isHierarchicalFacet: function isHierarchicalFacet(facetName) {
2915
+ isHierarchicalFacet: function (facetName) {
2581
2916
  return this.getHierarchicalFacetByName(facetName) !== undefined;
2582
2917
  },
2583
2918
  /**
@@ -2586,7 +2921,7 @@
2586
2921
  * @param {string} facet facet name to test
2587
2922
  * @return {boolean} true if facet is a conjunctive facet
2588
2923
  */
2589
- isConjunctiveFacet: function isConjunctiveFacet(facet) {
2924
+ isConjunctiveFacet: function (facet) {
2590
2925
  return this.facets.indexOf(facet) > -1;
2591
2926
  },
2592
2927
  /**
@@ -2633,7 +2968,11 @@
2633
2968
  if (!this.isDisjunctiveFacet(facet)) {
2634
2969
  return false;
2635
2970
  }
2636
- return RefinementList.isRefined(this.disjunctiveFacetsRefinements, facet, value);
2971
+ return RefinementList.isRefined(
2972
+ this.disjunctiveFacetsRefinements,
2973
+ facet,
2974
+ value
2975
+ );
2637
2976
  },
2638
2977
  /**
2639
2978
  * Returns true if the facet contains a refinement, or if a value passed is a
@@ -2644,14 +2983,20 @@
2644
2983
  * if there is one, otherwise will test if the facet contains any refinement
2645
2984
  * @return {boolean} true if the facet is refined
2646
2985
  */
2647
- isHierarchicalFacetRefined: function isHierarchicalFacetRefined(facet, value) {
2986
+ isHierarchicalFacetRefined: function isHierarchicalFacetRefined(
2987
+ facet,
2988
+ value
2989
+ ) {
2648
2990
  if (!this.isHierarchicalFacet(facet)) {
2649
2991
  return false;
2650
2992
  }
2993
+
2651
2994
  var refinements = this.getHierarchicalRefinement(facet);
2995
+
2652
2996
  if (!value) {
2653
2997
  return refinements.length > 0;
2654
2998
  }
2999
+
2655
3000
  return refinements.indexOf(value) !== -1;
2656
3001
  },
2657
3002
  /**
@@ -2668,12 +3013,20 @@
2668
3013
  if (value === undefined && operator === undefined) {
2669
3014
  return Boolean(this.numericRefinements[attribute]);
2670
3015
  }
2671
- var isOperatorDefined = this.numericRefinements[attribute] && this.numericRefinements[attribute][operator] !== undefined;
3016
+
3017
+ var isOperatorDefined =
3018
+ this.numericRefinements[attribute] &&
3019
+ this.numericRefinements[attribute][operator] !== undefined;
3020
+
2672
3021
  if (value === undefined || !isOperatorDefined) {
2673
3022
  return isOperatorDefined;
2674
3023
  }
3024
+
2675
3025
  var parsedValue = valToNumber_1(value);
2676
- var isAttributeValueDefined = findArray(this.numericRefinements[attribute][operator], parsedValue) !== undefined;
3026
+ var isAttributeValueDefined =
3027
+ findArray(this.numericRefinements[attribute][operator], parsedValue) !==
3028
+ undefined;
3029
+
2677
3030
  return isOperatorDefined && isAttributeValueDefined;
2678
3031
  },
2679
3032
  /**
@@ -2697,12 +3050,19 @@
2697
3050
  var self = this;
2698
3051
 
2699
3052
  // attributes used for numeric filter can also be disjunctive
2700
- var disjunctiveNumericRefinedFacets = intersection_1(Object.keys(this.numericRefinements).filter(function (facet) {
2701
- return Object.keys(self.numericRefinements[facet]).length > 0;
2702
- }), this.disjunctiveFacets);
2703
- return Object.keys(this.disjunctiveFacetsRefinements).filter(function (facet) {
2704
- return self.disjunctiveFacetsRefinements[facet].length > 0;
2705
- }).concat(disjunctiveNumericRefinedFacets).concat(this.getRefinedHierarchicalFacets());
3053
+ var disjunctiveNumericRefinedFacets = intersection_1(
3054
+ Object.keys(this.numericRefinements).filter(function (facet) {
3055
+ return Object.keys(self.numericRefinements[facet]).length > 0;
3056
+ }),
3057
+ this.disjunctiveFacets
3058
+ );
3059
+
3060
+ return Object.keys(this.disjunctiveFacetsRefinements)
3061
+ .filter(function (facet) {
3062
+ return self.disjunctiveFacetsRefinements[facet].length > 0;
3063
+ })
3064
+ .concat(disjunctiveNumericRefinedFacets)
3065
+ .concat(this.getRefinedHierarchicalFacets());
2706
3066
  },
2707
3067
  /**
2708
3068
  * Returns the list of all disjunctive facets refined
@@ -2715,38 +3075,61 @@
2715
3075
  // eslint-disable-next-line consistent-this
2716
3076
  var self = this;
2717
3077
  return intersection_1(
2718
- // enforce the order between the two arrays,
2719
- // so that refinement name index === hierarchical facet index
2720
- this.hierarchicalFacets.map(function (facet) {
2721
- return facet.name;
2722
- }), Object.keys(this.hierarchicalFacetsRefinements).filter(function (facet) {
2723
- return self.hierarchicalFacetsRefinements[facet].length > 0;
2724
- }));
3078
+ // enforce the order between the two arrays,
3079
+ // so that refinement name index === hierarchical facet index
3080
+ this.hierarchicalFacets.map(function (facet) {
3081
+ return facet.name;
3082
+ }),
3083
+ Object.keys(this.hierarchicalFacetsRefinements).filter(function (facet) {
3084
+ return self.hierarchicalFacetsRefinements[facet].length > 0;
3085
+ })
3086
+ );
2725
3087
  },
2726
3088
  /**
2727
3089
  * Returned the list of all disjunctive facets not refined
2728
3090
  * @method
2729
3091
  * @return {string[]} returns the list of facets that are not refined
2730
3092
  */
2731
- getUnrefinedDisjunctiveFacets: function getUnrefinedDisjunctiveFacets() {
3093
+ getUnrefinedDisjunctiveFacets: function () {
2732
3094
  var refinedFacets = this.getRefinedDisjunctiveFacets();
3095
+
2733
3096
  return this.disjunctiveFacets.filter(function (f) {
2734
3097
  return refinedFacets.indexOf(f) === -1;
2735
3098
  });
2736
3099
  },
2737
- managedParameters: ['index', 'facets', 'disjunctiveFacets', 'facetsRefinements', 'hierarchicalFacets', 'facetsExcludes', 'disjunctiveFacetsRefinements', 'numericRefinements', 'tagRefinements', 'hierarchicalFacetsRefinements'],
3100
+
3101
+ managedParameters: [
3102
+ 'index',
3103
+
3104
+ 'facets',
3105
+ 'disjunctiveFacets',
3106
+ 'facetsRefinements',
3107
+ 'hierarchicalFacets',
3108
+ 'facetsExcludes',
3109
+
3110
+ 'disjunctiveFacetsRefinements',
3111
+ 'numericRefinements',
3112
+ 'tagRefinements',
3113
+ 'hierarchicalFacetsRefinements',
3114
+ ],
3115
+
2738
3116
  getQueryParams: function getQueryParams() {
2739
3117
  var managedParameters = this.managedParameters;
3118
+
2740
3119
  var queryParams = {};
2741
3120
 
2742
3121
  // eslint-disable-next-line consistent-this
2743
3122
  var self = this;
2744
3123
  Object.keys(this).forEach(function (paramName) {
2745
3124
  var paramValue = self[paramName];
2746
- if (managedParameters.indexOf(paramName) === -1 && paramValue !== undefined) {
3125
+ if (
3126
+ managedParameters.indexOf(paramName) === -1 &&
3127
+ paramValue !== undefined
3128
+ ) {
2747
3129
  queryParams[paramName] = paramValue;
2748
3130
  }
2749
3131
  });
3132
+
2750
3133
  return queryParams;
2751
3134
  },
2752
3135
  /**
@@ -2761,8 +3144,11 @@
2761
3144
  */
2762
3145
  setQueryParameter: function setParameter(parameter, value) {
2763
3146
  if (this[parameter] === value) return this;
3147
+
2764
3148
  var modification = {};
3149
+
2765
3150
  modification[parameter] = value;
3151
+
2766
3152
  return this.setQueryParameters(modification);
2767
3153
  },
2768
3154
  /**
@@ -2773,7 +3159,9 @@
2773
3159
  */
2774
3160
  setQueryParameters: function setQueryParameters(params) {
2775
3161
  if (!params) return this;
3162
+
2776
3163
  var error = SearchParameters.validate(this, params);
3164
+
2777
3165
  if (error) {
2778
3166
  throw error;
2779
3167
  }
@@ -2785,99 +3173,121 @@
2785
3173
  acc[key] = self[key];
2786
3174
  return acc;
2787
3175
  }, {});
2788
- var nextPlainObject = Object.keys(nextWithNumbers).reduce(function (previous, key) {
3176
+
3177
+ var nextPlainObject = Object.keys(nextWithNumbers).reduce(function (
3178
+ previous,
3179
+ key
3180
+ ) {
2789
3181
  var isPreviousValueDefined = previous[key] !== undefined;
2790
3182
  var isNextValueDefined = nextWithNumbers[key] !== undefined;
3183
+
2791
3184
  if (isPreviousValueDefined && !isNextValueDefined) {
2792
3185
  return omit$1(previous, [key]);
2793
3186
  }
3187
+
2794
3188
  if (isNextValueDefined) {
2795
3189
  previous[key] = nextWithNumbers[key];
2796
3190
  }
3191
+
2797
3192
  return previous;
2798
- }, previousPlainObject);
3193
+ },
3194
+ previousPlainObject);
3195
+
2799
3196
  return new this.constructor(nextPlainObject);
2800
3197
  },
3198
+
2801
3199
  /**
2802
3200
  * Returns a new instance with the page reset. Two scenarios possible:
2803
3201
  * the page is omitted -> return the given instance
2804
3202
  * the page is set -> return a new instance with a page of 0
2805
3203
  * @return {SearchParameters} a new updated instance
2806
3204
  */
2807
- resetPage: function resetPage() {
3205
+ resetPage: function () {
2808
3206
  if (this.page === undefined) {
2809
3207
  return this;
2810
3208
  }
3209
+
2811
3210
  return this.setPage(0);
2812
3211
  },
3212
+
2813
3213
  /**
2814
3214
  * Helper function to get the hierarchicalFacet separator or the default one (`>`)
2815
3215
  * @param {object} hierarchicalFacet the hierarchicalFacet object
2816
3216
  * @return {string} returns the hierarchicalFacet.separator or `>` as default
2817
3217
  */
2818
- _getHierarchicalFacetSortBy: function _getHierarchicalFacetSortBy(hierarchicalFacet) {
3218
+ _getHierarchicalFacetSortBy: function (hierarchicalFacet) {
2819
3219
  return hierarchicalFacet.sortBy || ['isRefined:desc', 'name:asc'];
2820
3220
  },
3221
+
2821
3222
  /**
2822
3223
  * Helper function to get the hierarchicalFacet separator or the default one (`>`)
2823
3224
  * @private
2824
3225
  * @param {object} hierarchicalFacet the hierarchicalFacet object
2825
3226
  * @return {string} returns the hierarchicalFacet.separator or `>` as default
2826
3227
  */
2827
- _getHierarchicalFacetSeparator: function _getHierarchicalFacetSeparator(hierarchicalFacet) {
3228
+ _getHierarchicalFacetSeparator: function (hierarchicalFacet) {
2828
3229
  return hierarchicalFacet.separator || ' > ';
2829
3230
  },
3231
+
2830
3232
  /**
2831
3233
  * Helper function to get the hierarchicalFacet prefix path or null
2832
3234
  * @private
2833
3235
  * @param {object} hierarchicalFacet the hierarchicalFacet object
2834
3236
  * @return {string} returns the hierarchicalFacet.rootPath or null as default
2835
3237
  */
2836
- _getHierarchicalRootPath: function _getHierarchicalRootPath(hierarchicalFacet) {
3238
+ _getHierarchicalRootPath: function (hierarchicalFacet) {
2837
3239
  return hierarchicalFacet.rootPath || null;
2838
3240
  },
3241
+
2839
3242
  /**
2840
3243
  * Helper function to check if we show the parent level of the hierarchicalFacet
2841
3244
  * @private
2842
3245
  * @param {object} hierarchicalFacet the hierarchicalFacet object
2843
3246
  * @return {string} returns the hierarchicalFacet.showParentLevel or true as default
2844
3247
  */
2845
- _getHierarchicalShowParentLevel: function _getHierarchicalShowParentLevel(hierarchicalFacet) {
3248
+ _getHierarchicalShowParentLevel: function (hierarchicalFacet) {
2846
3249
  if (typeof hierarchicalFacet.showParentLevel === 'boolean') {
2847
3250
  return hierarchicalFacet.showParentLevel;
2848
3251
  }
2849
3252
  return true;
2850
3253
  },
3254
+
2851
3255
  /**
2852
3256
  * Helper function to get the hierarchicalFacet by it's name
2853
3257
  * @param {string} hierarchicalFacetName the hierarchicalFacet name
2854
3258
  * @return {object} a hierarchicalFacet
2855
3259
  */
2856
- getHierarchicalFacetByName: function getHierarchicalFacetByName(hierarchicalFacetName) {
3260
+ getHierarchicalFacetByName: function (hierarchicalFacetName) {
2857
3261
  return find$1(this.hierarchicalFacets, function (f) {
2858
3262
  return f.name === hierarchicalFacetName;
2859
3263
  });
2860
3264
  },
3265
+
2861
3266
  /**
2862
3267
  * Get the current breadcrumb for a hierarchical facet, as an array
2863
3268
  * @param {string} facetName Hierarchical facet name
2864
3269
  * @return {array.<string>} the path as an array of string
2865
3270
  */
2866
- getHierarchicalFacetBreadcrumb: function getHierarchicalFacetBreadcrumb(facetName) {
3271
+ getHierarchicalFacetBreadcrumb: function (facetName) {
2867
3272
  if (!this.isHierarchicalFacet(facetName)) {
2868
3273
  return [];
2869
3274
  }
3275
+
2870
3276
  var refinement = this.getHierarchicalRefinement(facetName)[0];
2871
3277
  if (!refinement) return [];
2872
- var separator = this._getHierarchicalFacetSeparator(this.getHierarchicalFacetByName(facetName));
3278
+
3279
+ var separator = this._getHierarchicalFacetSeparator(
3280
+ this.getHierarchicalFacetByName(facetName)
3281
+ );
2873
3282
  var path = refinement.split(separator);
2874
3283
  return path.map(function (part) {
2875
3284
  return part.trim();
2876
3285
  });
2877
3286
  },
2878
- toString: function toString() {
3287
+
3288
+ toString: function () {
2879
3289
  return JSON.stringify(this, null, 2);
2880
- }
3290
+ },
2881
3291
  };
2882
3292
 
2883
3293
  /**
@@ -2895,12 +3305,22 @@
2895
3305
  if (value !== other) {
2896
3306
  var valIsDefined = value !== undefined;
2897
3307
  var valIsNull = value === null;
3308
+
2898
3309
  var othIsDefined = other !== undefined;
2899
3310
  var othIsNull = other === null;
2900
- if (!othIsNull && value > other || valIsNull && othIsDefined || !valIsDefined) {
3311
+
3312
+ if (
3313
+ (!othIsNull && value > other) ||
3314
+ (valIsNull && othIsDefined) ||
3315
+ !valIsDefined
3316
+ ) {
2901
3317
  return 1;
2902
3318
  }
2903
- if (!valIsNull && value < other || othIsNull && valIsDefined || !othIsDefined) {
3319
+ if (
3320
+ (!valIsNull && value < other) ||
3321
+ (othIsNull && valIsDefined) ||
3322
+ !othIsDefined
3323
+ ) {
2904
3324
  return -1;
2905
3325
  }
2906
3326
  }
@@ -2917,20 +3337,24 @@
2917
3337
  if (!Array.isArray(collection)) {
2918
3338
  return [];
2919
3339
  }
3340
+
2920
3341
  if (!Array.isArray(orders)) {
2921
3342
  orders = [];
2922
3343
  }
3344
+
2923
3345
  var result = collection.map(function (value, index) {
2924
3346
  return {
2925
3347
  criteria: iteratees.map(function (iteratee) {
2926
3348
  return value[iteratee];
2927
3349
  }),
2928
3350
  index: index,
2929
- value: value
3351
+ value: value,
2930
3352
  };
2931
3353
  });
3354
+
2932
3355
  result.sort(function comparer(object, other) {
2933
3356
  var index = -1;
3357
+
2934
3358
  while (++index < object.criteria.length) {
2935
3359
  var res = compareAscending(object.criteria[index], other.criteria[index]);
2936
3360
  if (res) {
@@ -2948,16 +3372,19 @@
2948
3372
  // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details.
2949
3373
  return object.index - other.index;
2950
3374
  });
3375
+
2951
3376
  return result.map(function (res) {
2952
3377
  return res.value;
2953
3378
  });
2954
3379
  }
3380
+
2955
3381
  var orderBy_1 = orderBy;
2956
3382
 
2957
3383
  var compact = function compact(array) {
2958
3384
  if (!Array.isArray(array)) {
2959
3385
  return [];
2960
3386
  }
3387
+
2961
3388
  return array.filter(Boolean);
2962
3389
  };
2963
3390
 
@@ -2966,6 +3393,7 @@
2966
3393
  if (!Array.isArray(array)) {
2967
3394
  return -1;
2968
3395
  }
3396
+
2969
3397
  for (var i = 0; i < array.length; i++) {
2970
3398
  if (comparator(array[i])) {
2971
3399
  return i;
@@ -2984,20 +3412,30 @@
2984
3412
  var defaultInstructions = (defaults || []).map(function (sort) {
2985
3413
  return sort.split(':');
2986
3414
  });
2987
- return sortBy.reduce(function preparePredicate(out, sort) {
2988
- var sortInstruction = sort.split(':');
2989
- var matchingDefault = find$1(defaultInstructions, function (defaultInstruction) {
2990
- return defaultInstruction[0] === sortInstruction[0];
2991
- });
2992
- if (sortInstruction.length > 1 || !matchingDefault) {
2993
- out[0].push(sortInstruction[0]);
2994
- out[1].push(sortInstruction[1]);
3415
+
3416
+ return sortBy.reduce(
3417
+ function preparePredicate(out, sort) {
3418
+ var sortInstruction = sort.split(':');
3419
+
3420
+ var matchingDefault = find$1(
3421
+ defaultInstructions,
3422
+ function (defaultInstruction) {
3423
+ return defaultInstruction[0] === sortInstruction[0];
3424
+ }
3425
+ );
3426
+
3427
+ if (sortInstruction.length > 1 || !matchingDefault) {
3428
+ out[0].push(sortInstruction[0]);
3429
+ out[1].push(sortInstruction[1]);
3430
+ return out;
3431
+ }
3432
+
3433
+ out[0].push(matchingDefault[0]);
3434
+ out[1].push(matchingDefault[1]);
2995
3435
  return out;
2996
- }
2997
- out[0].push(matchingDefault[0]);
2998
- out[1].push(matchingDefault[1]);
2999
- return out;
3000
- }, [[], []]);
3436
+ },
3437
+ [[], []]
3438
+ );
3001
3439
  };
3002
3440
 
3003
3441
  /**
@@ -3008,6 +3446,7 @@
3008
3446
  */
3009
3447
  function escapeFacetValue(value) {
3010
3448
  if (typeof value !== 'string') return value;
3449
+
3011
3450
  return String(value).replace(/^-/, '\\-');
3012
3451
  }
3013
3452
 
@@ -3019,11 +3458,13 @@
3019
3458
  */
3020
3459
  function unescapeFacetValue$1(value) {
3021
3460
  if (typeof value !== 'string') return value;
3461
+
3022
3462
  return value.replace(/^\\-/, '-');
3023
3463
  }
3464
+
3024
3465
  var escapeFacetValue_1 = {
3025
3466
  escapeFacetValue: escapeFacetValue,
3026
- unescapeFacetValue: unescapeFacetValue$1
3467
+ unescapeFacetValue: unescapeFacetValue$1,
3027
3468
  };
3028
3469
 
3029
3470
  var generateHierarchicalTree_1 = generateTrees;
@@ -3031,44 +3472,78 @@
3031
3472
 
3032
3473
 
3033
3474
 
3475
+
3034
3476
  var escapeFacetValue$1 = escapeFacetValue_1.escapeFacetValue;
3035
3477
  var unescapeFacetValue$2 = escapeFacetValue_1.unescapeFacetValue;
3478
+
3036
3479
  function generateTrees(state) {
3037
3480
  return function generate(hierarchicalFacetResult, hierarchicalFacetIndex) {
3038
3481
  var hierarchicalFacet = state.hierarchicalFacets[hierarchicalFacetIndex];
3039
- var hierarchicalFacetRefinement = state.hierarchicalFacetsRefinements[hierarchicalFacet.name] && state.hierarchicalFacetsRefinements[hierarchicalFacet.name][0] || '';
3040
- var hierarchicalSeparator = state._getHierarchicalFacetSeparator(hierarchicalFacet);
3041
- var hierarchicalRootPath = state._getHierarchicalRootPath(hierarchicalFacet);
3042
- var hierarchicalShowParentLevel = state._getHierarchicalShowParentLevel(hierarchicalFacet);
3043
- var sortBy = formatSort(state._getHierarchicalFacetSortBy(hierarchicalFacet));
3482
+ var hierarchicalFacetRefinement =
3483
+ (state.hierarchicalFacetsRefinements[hierarchicalFacet.name] &&
3484
+ state.hierarchicalFacetsRefinements[hierarchicalFacet.name][0]) ||
3485
+ '';
3486
+ var hierarchicalSeparator =
3487
+ state._getHierarchicalFacetSeparator(hierarchicalFacet);
3488
+ var hierarchicalRootPath =
3489
+ state._getHierarchicalRootPath(hierarchicalFacet);
3490
+ var hierarchicalShowParentLevel =
3491
+ state._getHierarchicalShowParentLevel(hierarchicalFacet);
3492
+ var sortBy = formatSort(
3493
+ state._getHierarchicalFacetSortBy(hierarchicalFacet)
3494
+ );
3495
+
3044
3496
  var rootExhaustive = hierarchicalFacetResult.every(function (facetResult) {
3045
3497
  return facetResult.exhaustive;
3046
3498
  });
3047
- var generateTreeFn = generateHierarchicalTree(sortBy, hierarchicalSeparator, hierarchicalRootPath, hierarchicalShowParentLevel, hierarchicalFacetRefinement);
3499
+
3500
+ var generateTreeFn = generateHierarchicalTree(
3501
+ sortBy,
3502
+ hierarchicalSeparator,
3503
+ hierarchicalRootPath,
3504
+ hierarchicalShowParentLevel,
3505
+ hierarchicalFacetRefinement
3506
+ );
3507
+
3048
3508
  var results = hierarchicalFacetResult;
3509
+
3049
3510
  if (hierarchicalRootPath) {
3050
- results = hierarchicalFacetResult.slice(hierarchicalRootPath.split(hierarchicalSeparator).length);
3511
+ results = hierarchicalFacetResult.slice(
3512
+ hierarchicalRootPath.split(hierarchicalSeparator).length
3513
+ );
3051
3514
  }
3515
+
3052
3516
  return results.reduce(generateTreeFn, {
3053
3517
  name: state.hierarchicalFacets[hierarchicalFacetIndex].name,
3054
- count: null,
3055
- // root level, no count
3056
- isRefined: true,
3057
- // root level, always refined
3058
- path: null,
3059
- // root level, no path
3518
+ count: null, // root level, no count
3519
+ isRefined: true, // root level, always refined
3520
+ path: null, // root level, no path
3060
3521
  escapedValue: null,
3061
3522
  exhaustive: rootExhaustive,
3062
- data: null
3523
+ data: null,
3063
3524
  });
3064
3525
  };
3065
3526
  }
3066
- function generateHierarchicalTree(sortBy, hierarchicalSeparator, hierarchicalRootPath, hierarchicalShowParentLevel, currentRefinement) {
3067
- return function generateTree(hierarchicalTree, hierarchicalFacetResult, currentHierarchicalLevel) {
3527
+
3528
+ function generateHierarchicalTree(
3529
+ sortBy,
3530
+ hierarchicalSeparator,
3531
+ hierarchicalRootPath,
3532
+ hierarchicalShowParentLevel,
3533
+ currentRefinement
3534
+ ) {
3535
+ return function generateTree(
3536
+ hierarchicalTree,
3537
+ hierarchicalFacetResult,
3538
+ currentHierarchicalLevel
3539
+ ) {
3068
3540
  var parent = hierarchicalTree;
3541
+
3069
3542
  if (currentHierarchicalLevel > 0) {
3070
3543
  var level = 0;
3544
+
3071
3545
  parent = hierarchicalTree;
3546
+
3072
3547
  while (level < currentHierarchicalLevel) {
3073
3548
  /**
3074
3549
  * @type {object[]]} hierarchical data
@@ -3094,51 +3569,102 @@
3094
3569
  // If parent refinement is `beers`, then we do not want to have `bières > Belges`
3095
3570
  // showing up
3096
3571
 
3097
- var picked = Object.keys(hierarchicalFacetResult.data).map(function (facetValue) {
3098
- return [facetValue, hierarchicalFacetResult.data[facetValue]];
3099
- }).filter(function (tuple) {
3100
- var facetValue = tuple[0];
3101
- return onlyMatchingTree(facetValue, parent.path || hierarchicalRootPath, currentRefinement, hierarchicalSeparator, hierarchicalRootPath, hierarchicalShowParentLevel);
3102
- });
3103
- parent.data = orderBy_1(picked.map(function (tuple) {
3104
- var facetValue = tuple[0];
3105
- var facetCount = tuple[1];
3106
- return format(facetCount, facetValue, hierarchicalSeparator, unescapeFacetValue$2(currentRefinement), hierarchicalFacetResult.exhaustive);
3107
- }), sortBy[0], sortBy[1]);
3572
+ var picked = Object.keys(hierarchicalFacetResult.data)
3573
+ .map(function (facetValue) {
3574
+ return [facetValue, hierarchicalFacetResult.data[facetValue]];
3575
+ })
3576
+ .filter(function (tuple) {
3577
+ var facetValue = tuple[0];
3578
+ return onlyMatchingTree(
3579
+ facetValue,
3580
+ parent.path || hierarchicalRootPath,
3581
+ currentRefinement,
3582
+ hierarchicalSeparator,
3583
+ hierarchicalRootPath,
3584
+ hierarchicalShowParentLevel
3585
+ );
3586
+ });
3587
+
3588
+ parent.data = orderBy_1(
3589
+ picked.map(function (tuple) {
3590
+ var facetValue = tuple[0];
3591
+ var facetCount = tuple[1];
3592
+
3593
+ return format(
3594
+ facetCount,
3595
+ facetValue,
3596
+ hierarchicalSeparator,
3597
+ unescapeFacetValue$2(currentRefinement),
3598
+ hierarchicalFacetResult.exhaustive
3599
+ );
3600
+ }),
3601
+ sortBy[0],
3602
+ sortBy[1]
3603
+ );
3108
3604
  }
3605
+
3109
3606
  return hierarchicalTree;
3110
3607
  };
3111
3608
  }
3112
3609
 
3113
3610
  // eslint-disable-next-line max-params
3114
- function onlyMatchingTree(facetValue, parentPath, currentRefinement, hierarchicalSeparator, hierarchicalRootPath, hierarchicalShowParentLevel) {
3611
+ function onlyMatchingTree(
3612
+ facetValue,
3613
+ parentPath,
3614
+ currentRefinement,
3615
+ hierarchicalSeparator,
3616
+ hierarchicalRootPath,
3617
+ hierarchicalShowParentLevel
3618
+ ) {
3115
3619
  // we want the facetValue is a child of hierarchicalRootPath
3116
- if (hierarchicalRootPath && (facetValue.indexOf(hierarchicalRootPath) !== 0 || hierarchicalRootPath === facetValue)) {
3620
+ if (
3621
+ hierarchicalRootPath &&
3622
+ (facetValue.indexOf(hierarchicalRootPath) !== 0 ||
3623
+ hierarchicalRootPath === facetValue)
3624
+ ) {
3117
3625
  return false;
3118
3626
  }
3119
3627
 
3120
3628
  // we always want root levels (only when there is no prefix path)
3121
- return !hierarchicalRootPath && facetValue.indexOf(hierarchicalSeparator) === -1 ||
3122
- // if there is a rootPath, being root level mean 1 level under rootPath
3123
- hierarchicalRootPath && facetValue.split(hierarchicalSeparator).length - hierarchicalRootPath.split(hierarchicalSeparator).length === 1 ||
3124
- // if current refinement is a root level and current facetValue is a root level,
3125
- // keep the facetValue
3126
- facetValue.indexOf(hierarchicalSeparator) === -1 && currentRefinement.indexOf(hierarchicalSeparator) === -1 ||
3127
- // currentRefinement is a child of the facet value
3128
- currentRefinement.indexOf(facetValue) === 0 ||
3129
- // facetValue is a child of the current parent, add it
3130
- facetValue.indexOf(parentPath + hierarchicalSeparator) === 0 && (hierarchicalShowParentLevel || facetValue.indexOf(currentRefinement) === 0);
3131
- }
3132
- function format(facetCount, facetValue, hierarchicalSeparator, currentRefinement, exhaustive) {
3629
+ return (
3630
+ (!hierarchicalRootPath &&
3631
+ facetValue.indexOf(hierarchicalSeparator) === -1) ||
3632
+ // if there is a rootPath, being root level mean 1 level under rootPath
3633
+ (hierarchicalRootPath &&
3634
+ facetValue.split(hierarchicalSeparator).length -
3635
+ hierarchicalRootPath.split(hierarchicalSeparator).length ===
3636
+ 1) ||
3637
+ // if current refinement is a root level and current facetValue is a root level,
3638
+ // keep the facetValue
3639
+ (facetValue.indexOf(hierarchicalSeparator) === -1 &&
3640
+ currentRefinement.indexOf(hierarchicalSeparator) === -1) ||
3641
+ // currentRefinement is a child of the facet value
3642
+ currentRefinement.indexOf(facetValue) === 0 ||
3643
+ // facetValue is a child of the current parent, add it
3644
+ (facetValue.indexOf(parentPath + hierarchicalSeparator) === 0 &&
3645
+ (hierarchicalShowParentLevel ||
3646
+ facetValue.indexOf(currentRefinement) === 0))
3647
+ );
3648
+ }
3649
+
3650
+ function format(
3651
+ facetCount,
3652
+ facetValue,
3653
+ hierarchicalSeparator,
3654
+ currentRefinement,
3655
+ exhaustive
3656
+ ) {
3133
3657
  var parts = facetValue.split(hierarchicalSeparator);
3134
3658
  return {
3135
3659
  name: parts[parts.length - 1].trim(),
3136
3660
  path: facetValue,
3137
3661
  escapedValue: escapeFacetValue$1(facetValue),
3138
3662
  count: facetCount,
3139
- isRefined: currentRefinement === facetValue || currentRefinement.indexOf(facetValue + hierarchicalSeparator) === 0,
3663
+ isRefined:
3664
+ currentRefinement === facetValue ||
3665
+ currentRefinement.indexOf(facetValue + hierarchicalSeparator) === 0,
3140
3666
  exhaustive: exhaustive,
3141
- data: null
3667
+ data: null,
3142
3668
  };
3143
3669
  }
3144
3670
 
@@ -3146,6 +3672,7 @@
3146
3672
  var unescapeFacetValue$3 = escapeFacetValue_1.unescapeFacetValue;
3147
3673
 
3148
3674
 
3675
+
3149
3676
  /**
3150
3677
  * @typedef SearchResults.Facet
3151
3678
  * @type {object}
@@ -3194,11 +3721,14 @@
3194
3721
  */
3195
3722
  function getIndices(attributes) {
3196
3723
  var indices = {};
3724
+
3197
3725
  attributes.forEach(function (val, idx) {
3198
3726
  indices[val] = idx;
3199
3727
  });
3728
+
3200
3729
  return indices;
3201
3730
  }
3731
+
3202
3732
  function assignFacetStats(dest, facetStats, key) {
3203
3733
  if (facetStats && facetStats[key]) {
3204
3734
  dest.stats = facetStats[key];
@@ -3216,11 +3746,17 @@
3216
3746
  * @param {string} hierarchicalAttributeName The name of the hierarchical attribute
3217
3747
  * @return {HierarchicalFacet} The hierarchical facet matching the attribute name
3218
3748
  */
3219
- function findMatchingHierarchicalFacetFromAttributeName(hierarchicalFacets, hierarchicalAttributeName) {
3220
- return find$1(hierarchicalFacets, function facetKeyMatchesAttribute(hierarchicalFacet) {
3221
- var facetNames = hierarchicalFacet.attributes || [];
3222
- return facetNames.indexOf(hierarchicalAttributeName) > -1;
3223
- });
3749
+ function findMatchingHierarchicalFacetFromAttributeName(
3750
+ hierarchicalFacets,
3751
+ hierarchicalAttributeName
3752
+ ) {
3753
+ return find$1(
3754
+ hierarchicalFacets,
3755
+ function facetKeyMatchesAttribute(hierarchicalFacet) {
3756
+ var facetNames = hierarchicalFacet.attributes || [];
3757
+ return facetNames.indexOf(hierarchicalAttributeName) > -1;
3758
+ }
3759
+ );
3224
3760
  }
3225
3761
 
3226
3762
  // eslint-disable-next-line valid-jsdoc
@@ -3356,6 +3892,7 @@
3356
3892
  **/
3357
3893
  function SearchResults(state, results, options) {
3358
3894
  var mainSubResponse = results[0];
3895
+
3359
3896
  this._rawResults = results;
3360
3897
 
3361
3898
  // eslint-disable-next-line consistent-this
@@ -3512,7 +4049,9 @@
3512
4049
  * @instance
3513
4050
  */
3514
4051
  this.processingTimeMS = results.reduce(function (sum, result) {
3515
- return result.processingTimeMS === undefined ? sum : sum + result.processingTimeMS;
4052
+ return result.processingTimeMS === undefined
4053
+ ? sum
4054
+ : sum + result.processingTimeMS;
3516
4055
  }, 0);
3517
4056
 
3518
4057
  /**
@@ -3524,15 +4063,19 @@
3524
4063
  * disjunctive facets results
3525
4064
  * @member {SearchResults.HierarchicalFacet[]}
3526
4065
  */
3527
- this.hierarchicalFacets = state.hierarchicalFacets.map(function initFutureTree() {
3528
- return [];
3529
- });
4066
+ this.hierarchicalFacets = state.hierarchicalFacets.map(
4067
+ function initFutureTree() {
4068
+ return [];
4069
+ }
4070
+ );
3530
4071
  /**
3531
4072
  * other facets results
3532
4073
  * @member {SearchResults.Facet[]}
3533
4074
  */
3534
4075
  this.facets = [];
4076
+
3535
4077
  var disjunctiveFacets = state.getRefinedDisjunctiveFacets();
4078
+
3536
4079
  var facetsIndices = getIndices(state.facets);
3537
4080
  var disjunctiveFacetsIndices = getIndices(state.disjunctiveFacets);
3538
4081
  var nextDisjunctiveResult = 1;
@@ -3541,9 +4084,15 @@
3541
4084
  // we get the facets information from the first, general, response.
3542
4085
 
3543
4086
  var mainFacets = mainSubResponse.facets || {};
4087
+
3544
4088
  Object.keys(mainFacets).forEach(function (facetKey) {
3545
4089
  var facetValueObject = mainFacets[facetKey];
3546
- var hierarchicalFacet = findMatchingHierarchicalFacetFromAttributeName(state.hierarchicalFacets, facetKey);
4090
+
4091
+ var hierarchicalFacet = findMatchingHierarchicalFacetFromAttributeName(
4092
+ state.hierarchicalFacets,
4093
+ facetKey
4094
+ );
4095
+
3547
4096
  if (hierarchicalFacet) {
3548
4097
  // Place the hierarchicalFacet data at the correct index depending on
3549
4098
  // the attributes order that was defined at the helper initialization
@@ -3554,29 +4103,38 @@
3554
4103
  self.hierarchicalFacets[idxAttributeName][facetIndex] = {
3555
4104
  attribute: facetKey,
3556
4105
  data: facetValueObject,
3557
- exhaustive: mainSubResponse.exhaustiveFacetsCount
4106
+ exhaustive: mainSubResponse.exhaustiveFacetsCount,
3558
4107
  };
3559
4108
  } else {
3560
4109
  var isFacetDisjunctive = state.disjunctiveFacets.indexOf(facetKey) !== -1;
3561
4110
  var isFacetConjunctive = state.facets.indexOf(facetKey) !== -1;
3562
4111
  var position;
4112
+
3563
4113
  if (isFacetDisjunctive) {
3564
4114
  position = disjunctiveFacetsIndices[facetKey];
3565
4115
  self.disjunctiveFacets[position] = {
3566
4116
  name: facetKey,
3567
4117
  data: facetValueObject,
3568
- exhaustive: mainSubResponse.exhaustiveFacetsCount
4118
+ exhaustive: mainSubResponse.exhaustiveFacetsCount,
3569
4119
  };
3570
- assignFacetStats(self.disjunctiveFacets[position], mainSubResponse.facets_stats, facetKey);
4120
+ assignFacetStats(
4121
+ self.disjunctiveFacets[position],
4122
+ mainSubResponse.facets_stats,
4123
+ facetKey
4124
+ );
3571
4125
  }
3572
4126
  if (isFacetConjunctive) {
3573
4127
  position = facetsIndices[facetKey];
3574
4128
  self.facets[position] = {
3575
4129
  name: facetKey,
3576
4130
  data: facetValueObject,
3577
- exhaustive: mainSubResponse.exhaustiveFacetsCount
4131
+ exhaustive: mainSubResponse.exhaustiveFacetsCount,
3578
4132
  };
3579
- assignFacetStats(self.facets[position], mainSubResponse.facets_stats, facetKey);
4133
+ assignFacetStats(
4134
+ self.facets[position],
4135
+ mainSubResponse.facets_stats,
4136
+ facetKey
4137
+ );
3580
4138
  }
3581
4139
  }
3582
4140
  });
@@ -3593,33 +4151,58 @@
3593
4151
  // There should be only item in facets.
3594
4152
  Object.keys(facets).forEach(function (dfacet) {
3595
4153
  var facetResults = facets[dfacet];
4154
+
3596
4155
  var position;
4156
+
3597
4157
  if (hierarchicalFacet) {
3598
4158
  position = findIndex(state.hierarchicalFacets, function (f) {
3599
4159
  return f.name === hierarchicalFacet.name;
3600
4160
  });
3601
- var attributeIndex = findIndex(self.hierarchicalFacets[position], function (f) {
3602
- return f.attribute === dfacet;
3603
- });
4161
+ var attributeIndex = findIndex(
4162
+ self.hierarchicalFacets[position],
4163
+ function (f) {
4164
+ return f.attribute === dfacet;
4165
+ }
4166
+ );
3604
4167
 
3605
4168
  // previous refinements and no results so not able to find it
3606
4169
  if (attributeIndex === -1) {
3607
4170
  return;
3608
4171
  }
3609
- self.hierarchicalFacets[position][attributeIndex].data = merge$1({}, self.hierarchicalFacets[position][attributeIndex].data, facetResults);
4172
+
4173
+ self.hierarchicalFacets[position][attributeIndex].data = merge_1(
4174
+ {},
4175
+ self.hierarchicalFacets[position][attributeIndex].data,
4176
+ facetResults
4177
+ );
3610
4178
  } else {
3611
4179
  position = disjunctiveFacetsIndices[dfacet];
3612
- var dataFromMainRequest = mainSubResponse.facets && mainSubResponse.facets[dfacet] || {};
4180
+
4181
+ var dataFromMainRequest =
4182
+ (mainSubResponse.facets && mainSubResponse.facets[dfacet]) || {};
4183
+
3613
4184
  self.disjunctiveFacets[position] = {
3614
4185
  name: dfacet,
3615
4186
  data: defaultsPure({}, facetResults, dataFromMainRequest),
3616
- exhaustive: result.exhaustiveFacetsCount
4187
+ exhaustive: result.exhaustiveFacetsCount,
3617
4188
  };
3618
- assignFacetStats(self.disjunctiveFacets[position], result.facets_stats, dfacet);
4189
+ assignFacetStats(
4190
+ self.disjunctiveFacets[position],
4191
+ result.facets_stats,
4192
+ dfacet
4193
+ );
4194
+
3619
4195
  if (state.disjunctiveFacetsRefinements[dfacet]) {
3620
- state.disjunctiveFacetsRefinements[dfacet].forEach(function (refinementValue) {
4196
+ state.disjunctiveFacetsRefinements[dfacet].forEach(function (
4197
+ refinementValue
4198
+ ) {
3621
4199
  // add the disjunctive refinements if it is no more retrieved
3622
- if (!self.disjunctiveFacets[position].data[refinementValue] && state.disjunctiveFacetsRefinements[dfacet].indexOf(unescapeFacetValue$3(refinementValue)) > -1) {
4200
+ if (
4201
+ !self.disjunctiveFacets[position].data[refinementValue] &&
4202
+ state.disjunctiveFacetsRefinements[dfacet].indexOf(
4203
+ unescapeFacetValue$3(refinementValue)
4204
+ ) > -1
4205
+ ) {
3623
4206
  self.disjunctiveFacets[position].data[refinementValue] = 0;
3624
4207
  }
3625
4208
  });
@@ -3633,22 +4216,31 @@
3633
4216
  state.getRefinedHierarchicalFacets().forEach(function (refinedFacet) {
3634
4217
  var hierarchicalFacet = state.getHierarchicalFacetByName(refinedFacet);
3635
4218
  var separator = state._getHierarchicalFacetSeparator(hierarchicalFacet);
4219
+
3636
4220
  var currentRefinement = state.getHierarchicalRefinement(refinedFacet);
3637
4221
  // if we are already at a root refinement (or no refinement at all), there is no
3638
4222
  // root level values request
3639
- if (currentRefinement.length === 0 || currentRefinement[0].split(separator).length < 2) {
4223
+ if (
4224
+ currentRefinement.length === 0 ||
4225
+ currentRefinement[0].split(separator).length < 2
4226
+ ) {
3640
4227
  return;
3641
4228
  }
4229
+
3642
4230
  results.slice(nextDisjunctiveResult).forEach(function (result) {
3643
4231
  var facets = result && result.facets ? result.facets : {};
4232
+
3644
4233
  Object.keys(facets).forEach(function (dfacet) {
3645
4234
  var facetResults = facets[dfacet];
3646
4235
  var position = findIndex(state.hierarchicalFacets, function (f) {
3647
4236
  return f.name === hierarchicalFacet.name;
3648
4237
  });
3649
- var attributeIndex = findIndex(self.hierarchicalFacets[position], function (f) {
3650
- return f.attribute === dfacet;
3651
- });
4238
+ var attributeIndex = findIndex(
4239
+ self.hierarchicalFacets[position],
4240
+ function (f) {
4241
+ return f.attribute === dfacet;
4242
+ }
4243
+ );
3652
4244
 
3653
4245
  // previous refinements and no results so not able to find it
3654
4246
  if (attributeIndex === -1) {
@@ -3664,12 +4256,20 @@
3664
4256
  // | beers (5)
3665
4257
  // > IPA (5)
3666
4258
  var defaultData = {};
4259
+
3667
4260
  if (currentRefinement.length > 0) {
3668
4261
  var root = currentRefinement[0].split(separator)[0];
3669
- defaultData[root] = self.hierarchicalFacets[position][attributeIndex].data[root];
4262
+ defaultData[root] =
4263
+ self.hierarchicalFacets[position][attributeIndex].data[root];
3670
4264
  }
3671
- self.hierarchicalFacets[position][attributeIndex].data = defaultsPure(defaultData, facetResults, self.hierarchicalFacets[position][attributeIndex].data);
4265
+
4266
+ self.hierarchicalFacets[position][attributeIndex].data = defaultsPure(
4267
+ defaultData,
4268
+ facetResults,
4269
+ self.hierarchicalFacets[position][attributeIndex].data
4270
+ );
3672
4271
  });
4272
+
3673
4273
  nextDisjunctiveResult++;
3674
4274
  });
3675
4275
  });
@@ -3678,15 +4278,14 @@
3678
4278
  Object.keys(state.facetsExcludes).forEach(function (facetName) {
3679
4279
  var excludes = state.facetsExcludes[facetName];
3680
4280
  var position = facetsIndices[facetName];
4281
+
3681
4282
  self.facets[position] = {
3682
4283
  name: facetName,
3683
4284
  data: mainFacets[facetName],
3684
- exhaustive: mainSubResponse.exhaustiveFacetsCount
4285
+ exhaustive: mainSubResponse.exhaustiveFacetsCount,
3685
4286
  };
3686
4287
  excludes.forEach(function (facetValue) {
3687
- self.facets[position] = self.facets[position] || {
3688
- name: facetName
3689
- };
4288
+ self.facets[position] = self.facets[position] || { name: facetName };
3690
4289
  self.facets[position].data = self.facets[position].data || {};
3691
4290
  self.facets[position].data[facetValue] = 0;
3692
4291
  });
@@ -3695,7 +4294,9 @@
3695
4294
  /**
3696
4295
  * @type {Array}
3697
4296
  */
3698
- this.hierarchicalFacets = this.hierarchicalFacets.map(generateHierarchicalTree_1(state));
4297
+ this.hierarchicalFacets = this.hierarchicalFacets.map(
4298
+ generateHierarchicalTree_1(state)
4299
+ );
3699
4300
 
3700
4301
  /**
3701
4302
  * @type {Array}
@@ -3705,6 +4306,7 @@
3705
4306
  * @type {Array}
3706
4307
  */
3707
4308
  this.disjunctiveFacets = compact(this.disjunctiveFacets);
4309
+
3708
4310
  this._state = state;
3709
4311
  }
3710
4312
 
@@ -3718,7 +4320,12 @@
3718
4320
  function predicate(facet) {
3719
4321
  return facet.name === name;
3720
4322
  }
3721
- return find$1(this.facets, predicate) || find$1(this.disjunctiveFacets, predicate) || find$1(this.hierarchicalFacets, predicate);
4323
+
4324
+ return (
4325
+ find$1(this.facets, predicate) ||
4326
+ find$1(this.disjunctiveFacets, predicate) ||
4327
+ find$1(this.hierarchicalFacets, predicate)
4328
+ );
3722
4329
  };
3723
4330
 
3724
4331
  /**
@@ -3732,9 +4339,11 @@
3732
4339
  function predicate(facet) {
3733
4340
  return facet.name === attribute;
3734
4341
  }
4342
+
3735
4343
  if (results._state.isConjunctiveFacet(attribute)) {
3736
4344
  var facet = find$1(results.facets, predicate);
3737
4345
  if (!facet) return [];
4346
+
3738
4347
  return Object.keys(facet.data).map(function (name) {
3739
4348
  var value = escapeFacetValue$2(name);
3740
4349
  return {
@@ -3742,35 +4351,49 @@
3742
4351
  escapedValue: value,
3743
4352
  count: facet.data[name],
3744
4353
  isRefined: results._state.isFacetRefined(attribute, value),
3745
- isExcluded: results._state.isExcludeRefined(attribute, name)
4354
+ isExcluded: results._state.isExcludeRefined(attribute, name),
3746
4355
  };
3747
4356
  });
3748
4357
  } else if (results._state.isDisjunctiveFacet(attribute)) {
3749
4358
  var disjunctiveFacet = find$1(results.disjunctiveFacets, predicate);
3750
4359
  if (!disjunctiveFacet) return [];
4360
+
3751
4361
  return Object.keys(disjunctiveFacet.data).map(function (name) {
3752
4362
  var value = escapeFacetValue$2(name);
3753
4363
  return {
3754
4364
  name: name,
3755
4365
  escapedValue: value,
3756
4366
  count: disjunctiveFacet.data[name],
3757
- isRefined: results._state.isDisjunctiveFacetRefined(attribute, value)
4367
+ isRefined: results._state.isDisjunctiveFacetRefined(attribute, value),
3758
4368
  };
3759
4369
  });
3760
4370
  } else if (results._state.isHierarchicalFacet(attribute)) {
3761
4371
  var hierarchicalFacetValues = find$1(results.hierarchicalFacets, predicate);
3762
4372
  if (!hierarchicalFacetValues) return hierarchicalFacetValues;
3763
- var hierarchicalFacet = results._state.getHierarchicalFacetByName(attribute);
3764
- var separator = results._state._getHierarchicalFacetSeparator(hierarchicalFacet);
3765
- var currentRefinement = unescapeFacetValue$3(results._state.getHierarchicalRefinement(attribute)[0] || '');
4373
+
4374
+ var hierarchicalFacet =
4375
+ results._state.getHierarchicalFacetByName(attribute);
4376
+ var separator =
4377
+ results._state._getHierarchicalFacetSeparator(hierarchicalFacet);
4378
+ var currentRefinement = unescapeFacetValue$3(
4379
+ results._state.getHierarchicalRefinement(attribute)[0] || ''
4380
+ );
4381
+
3766
4382
  if (currentRefinement.indexOf(hierarchicalFacet.rootPath) === 0) {
3767
- currentRefinement = currentRefinement.replace(hierarchicalFacet.rootPath + separator, '');
4383
+ currentRefinement = currentRefinement.replace(
4384
+ hierarchicalFacet.rootPath + separator,
4385
+ ''
4386
+ );
3768
4387
  }
4388
+
3769
4389
  var currentRefinementSplit = currentRefinement.split(separator);
3770
4390
  currentRefinementSplit.unshift(attribute);
4391
+
3771
4392
  setIsRefined(hierarchicalFacetValues, currentRefinementSplit, 0);
4393
+
3772
4394
  return hierarchicalFacetValues;
3773
4395
  }
4396
+
3774
4397
  return undefined;
3775
4398
  }
3776
4399
 
@@ -3801,22 +4424,25 @@
3801
4424
  */
3802
4425
  function recSort(sortFn, node, names, level) {
3803
4426
  level = level || 0;
4427
+
3804
4428
  if (Array.isArray(node)) {
3805
4429
  return sortFn(node, names[level]);
3806
4430
  }
4431
+
3807
4432
  if (!node.data || node.data.length === 0) {
3808
4433
  return node;
3809
4434
  }
4435
+
3810
4436
  var children = node.data.map(function (childNode) {
3811
4437
  return recSort(sortFn, childNode, names, level + 1);
3812
4438
  });
3813
4439
  var sortedChildren = sortFn(children, names[level]);
3814
- var newNode = defaultsPure({
3815
- data: sortedChildren
3816
- }, node);
4440
+ var newNode = defaultsPure({ data: sortedChildren }, node);
3817
4441
  return newNode;
3818
4442
  }
4443
+
3819
4444
  SearchResults.DEFAULT_SORT = ['isRefined:desc', 'count:desc', 'name:asc'];
4445
+
3820
4446
  function vanillaSortFn(order, data) {
3821
4447
  return data.sort(order);
3822
4448
  }
@@ -3837,6 +4463,7 @@
3837
4463
  function sortViaFacetOrdering(facetValues, facetOrdering) {
3838
4464
  var orderedFacets = [];
3839
4465
  var remainingFacets = [];
4466
+
3840
4467
  var order = facetOrdering.order || [];
3841
4468
  /**
3842
4469
  * an object with the keys being the values in order, the values their index:
@@ -3846,6 +4473,7 @@
3846
4473
  acc[name] = i;
3847
4474
  return acc;
3848
4475
  }, {});
4476
+
3849
4477
  facetValues.forEach(function (item) {
3850
4478
  // hierarchical facets get sorted using their raw name
3851
4479
  var name = item.path || item.name;
@@ -3855,19 +4483,27 @@
3855
4483
  remainingFacets.push(item);
3856
4484
  }
3857
4485
  });
4486
+
3858
4487
  orderedFacets = orderedFacets.filter(function (facet) {
3859
4488
  return facet;
3860
4489
  });
4490
+
3861
4491
  var sortRemainingBy = facetOrdering.sortRemainingBy;
3862
4492
  var ordering;
3863
4493
  if (sortRemainingBy === 'hidden') {
3864
4494
  return orderedFacets;
3865
4495
  } else if (sortRemainingBy === 'alpha') {
3866
- ordering = [['path', 'name'], ['asc', 'asc']];
4496
+ ordering = [
4497
+ ['path', 'name'],
4498
+ ['asc', 'asc'],
4499
+ ];
3867
4500
  } else {
3868
4501
  ordering = [['count'], ['desc']];
3869
4502
  }
3870
- return orderedFacets.concat(orderBy_1(remainingFacets, ordering[0], ordering[1]));
4503
+
4504
+ return orderedFacets.concat(
4505
+ orderBy_1(remainingFacets, ordering[0], ordering[1])
4506
+ );
3871
4507
  }
3872
4508
 
3873
4509
  /**
@@ -3876,7 +4512,12 @@
3876
4512
  * @returns {FacetOrdering | undefined} the facet ordering
3877
4513
  */
3878
4514
  function getFacetOrdering(results, attribute) {
3879
- return results.renderingContent && results.renderingContent.facetOrdering && results.renderingContent.facetOrdering.values && results.renderingContent.facetOrdering.values[attribute];
4515
+ return (
4516
+ results.renderingContent &&
4517
+ results.renderingContent.facetOrdering &&
4518
+ results.renderingContent.facetOrdering.values &&
4519
+ results.renderingContent.facetOrdering.values[attribute]
4520
+ );
3880
4521
  }
3881
4522
 
3882
4523
  /**
@@ -3932,11 +4573,12 @@
3932
4573
  if (!facetValues) {
3933
4574
  return undefined;
3934
4575
  }
4576
+
3935
4577
  var options = defaultsPure({}, opts, {
3936
4578
  sortBy: SearchResults.DEFAULT_SORT,
3937
4579
  // if no sortBy is given, attempt to sort based on facetOrdering
3938
4580
  // if it is given, we still allow to sort via facet ordering first
3939
- facetOrdering: !(opts && opts.sortBy)
4581
+ facetOrdering: !(opts && opts.sortBy),
3940
4582
  });
3941
4583
 
3942
4584
  // eslint-disable-next-line consistent-this
@@ -3948,21 +4590,30 @@
3948
4590
  var config = results._state.getHierarchicalFacetByName(facetValues.name);
3949
4591
  attributes = config.attributes;
3950
4592
  }
3951
- return recSort(function (data, facetName) {
3952
- if (options.facetOrdering) {
3953
- var facetOrdering = getFacetOrdering(results, facetName);
3954
- if (facetOrdering) {
3955
- return sortViaFacetOrdering(data, facetOrdering);
4593
+
4594
+ return recSort(
4595
+ function (data, facetName) {
4596
+ if (options.facetOrdering) {
4597
+ var facetOrdering = getFacetOrdering(results, facetName);
4598
+ if (facetOrdering) {
4599
+ return sortViaFacetOrdering(data, facetOrdering);
4600
+ }
3956
4601
  }
3957
- }
3958
- if (Array.isArray(options.sortBy)) {
3959
- var order = formatSort(options.sortBy, SearchResults.DEFAULT_SORT);
3960
- return orderBy_1(data, order[0], order[1]);
3961
- } else if (typeof options.sortBy === 'function') {
3962
- return vanillaSortFn(options.sortBy, data);
3963
- }
3964
- throw new Error('options.sortBy is optional but if defined it must be ' + 'either an array of string (predicates) or a sorting function');
3965
- }, facetValues, attributes);
4602
+
4603
+ if (Array.isArray(options.sortBy)) {
4604
+ var order = formatSort(options.sortBy, SearchResults.DEFAULT_SORT);
4605
+ return orderBy_1(data, order[0], order[1]);
4606
+ } else if (typeof options.sortBy === 'function') {
4607
+ return vanillaSortFn(options.sortBy, data);
4608
+ }
4609
+ throw new Error(
4610
+ 'options.sortBy is optional but if defined it must be ' +
4611
+ 'either an array of string (predicates) or a sorting function'
4612
+ );
4613
+ },
4614
+ facetValues,
4615
+ attributes
4616
+ );
3966
4617
  };
3967
4618
 
3968
4619
  /**
@@ -3977,6 +4628,7 @@
3977
4628
  } else if (this._state.isDisjunctiveFacet(attribute)) {
3978
4629
  return getFacetStatsIfAvailable(this.disjunctiveFacets, attribute);
3979
4630
  }
4631
+
3980
4632
  return undefined;
3981
4633
  };
3982
4634
 
@@ -4014,26 +4666,54 @@
4014
4666
  // eslint-disable-next-line consistent-this
4015
4667
  var results = this;
4016
4668
  var res = [];
4669
+
4017
4670
  Object.keys(state.facetsRefinements).forEach(function (attributeName) {
4018
4671
  state.facetsRefinements[attributeName].forEach(function (name) {
4019
- res.push(getRefinement(state, 'facet', attributeName, name, results.facets));
4672
+ res.push(
4673
+ getRefinement(state, 'facet', attributeName, name, results.facets)
4674
+ );
4020
4675
  });
4021
4676
  });
4677
+
4022
4678
  Object.keys(state.facetsExcludes).forEach(function (attributeName) {
4023
4679
  state.facetsExcludes[attributeName].forEach(function (name) {
4024
- res.push(getRefinement(state, 'exclude', attributeName, name, results.facets));
4680
+ res.push(
4681
+ getRefinement(state, 'exclude', attributeName, name, results.facets)
4682
+ );
4025
4683
  });
4026
4684
  });
4027
- Object.keys(state.disjunctiveFacetsRefinements).forEach(function (attributeName) {
4685
+
4686
+ Object.keys(state.disjunctiveFacetsRefinements).forEach(function (
4687
+ attributeName
4688
+ ) {
4028
4689
  state.disjunctiveFacetsRefinements[attributeName].forEach(function (name) {
4029
- res.push(getRefinement(state, 'disjunctive', attributeName, name, results.disjunctiveFacets));
4690
+ res.push(
4691
+ getRefinement(
4692
+ state,
4693
+ 'disjunctive',
4694
+ attributeName,
4695
+ name,
4696
+ results.disjunctiveFacets
4697
+ )
4698
+ );
4030
4699
  });
4031
4700
  });
4032
- Object.keys(state.hierarchicalFacetsRefinements).forEach(function (attributeName) {
4701
+
4702
+ Object.keys(state.hierarchicalFacetsRefinements).forEach(function (
4703
+ attributeName
4704
+ ) {
4033
4705
  state.hierarchicalFacetsRefinements[attributeName].forEach(function (name) {
4034
- res.push(getHierarchicalRefinement(state, attributeName, name, results.hierarchicalFacets));
4706
+ res.push(
4707
+ getHierarchicalRefinement(
4708
+ state,
4709
+ attributeName,
4710
+ name,
4711
+ results.hierarchicalFacets
4712
+ )
4713
+ );
4035
4714
  });
4036
4715
  });
4716
+
4037
4717
  Object.keys(state.numericRefinements).forEach(function (attributeName) {
4038
4718
  var operators = state.numericRefinements[attributeName];
4039
4719
  Object.keys(operators).forEach(function (operator) {
@@ -4043,18 +4723,16 @@
4043
4723
  attributeName: attributeName,
4044
4724
  name: value,
4045
4725
  numericValue: value,
4046
- operator: operator
4726
+ operator: operator,
4047
4727
  });
4048
4728
  });
4049
4729
  });
4050
4730
  });
4731
+
4051
4732
  state.tagRefinements.forEach(function (name) {
4052
- res.push({
4053
- type: 'tag',
4054
- attributeName: '_tags',
4055
- name: name
4056
- });
4733
+ res.push({ type: 'tag', attributeName: '_tags', name: name });
4057
4734
  });
4735
+
4058
4736
  return res;
4059
4737
  };
4060
4738
 
@@ -4078,13 +4756,14 @@
4078
4756
  return f.name === attributeName;
4079
4757
  });
4080
4758
  var count = facet && facet.data && facet.data[name] ? facet.data[name] : 0;
4081
- var exhaustive = facet && facet.exhaustive || false;
4759
+ var exhaustive = (facet && facet.exhaustive) || false;
4760
+
4082
4761
  return {
4083
4762
  type: type,
4084
4763
  attributeName: attributeName,
4085
4764
  name: name,
4086
4765
  count: count,
4087
- exhaustive: exhaustive
4766
+ exhaustive: exhaustive,
4088
4767
  };
4089
4768
  }
4090
4769
 
@@ -4102,23 +4781,29 @@
4102
4781
  var rootFacet = find$1(resultsFacets, function (facet) {
4103
4782
  return facet.name === attributeName;
4104
4783
  });
4784
+
4105
4785
  var facet = split.reduce(function (intermediateFacet, part) {
4106
- var newFacet = intermediateFacet && find$1(intermediateFacet.data, function (f) {
4107
- return f.name === part;
4108
- });
4786
+ var newFacet =
4787
+ intermediateFacet &&
4788
+ find$1(intermediateFacet.data, function (f) {
4789
+ return f.name === part;
4790
+ });
4109
4791
  return newFacet !== undefined ? newFacet : intermediateFacet;
4110
4792
  }, rootFacet);
4111
- var count = facet && facet.count || 0;
4112
- var exhaustive = facet && facet.exhaustive || false;
4113
- var path = facet && facet.path || '';
4793
+
4794
+ var count = (facet && facet.count) || 0;
4795
+ var exhaustive = (facet && facet.exhaustive) || false;
4796
+ var path = (facet && facet.path) || '';
4797
+
4114
4798
  return {
4115
4799
  type: 'hierarchical',
4116
4800
  attributeName: attributeName,
4117
4801
  name: path,
4118
4802
  count: count,
4119
- exhaustive: exhaustive
4803
+ exhaustive: exhaustive,
4120
4804
  };
4121
4805
  }
4806
+
4122
4807
  var SearchResults_1 = SearchResults;
4123
4808
 
4124
4809
  // Copyright Joyent, Inc. and other Node contributors.
@@ -4430,10 +5115,11 @@
4430
5115
  value: ctor,
4431
5116
  enumerable: false,
4432
5117
  writable: true,
4433
- configurable: true
4434
- }
5118
+ configurable: true,
5119
+ },
4435
5120
  });
4436
5121
  }
5122
+
4437
5123
  var inherits_1 = inherits;
4438
5124
 
4439
5125
  /**
@@ -4453,6 +5139,7 @@
4453
5139
  this.fn = fn;
4454
5140
  this.lastResults = null;
4455
5141
  }
5142
+
4456
5143
  inherits_1(DerivedHelper, events);
4457
5144
 
4458
5145
  /**
@@ -4464,19 +5151,24 @@
4464
5151
  this.removeAllListeners();
4465
5152
  this.main.detachDerivedHelper(this);
4466
5153
  };
5154
+
4467
5155
  DerivedHelper.prototype.getModifiedState = function (parameters) {
4468
5156
  return this.fn(parameters);
4469
5157
  };
5158
+
4470
5159
  var DerivedHelper_1 = DerivedHelper;
4471
5160
 
4472
5161
  function sortObject(obj) {
4473
- return Object.keys(obj).sort(function (a, b) {
4474
- return a.localeCompare(b);
4475
- }).reduce(function (acc, curr) {
4476
- acc[curr] = obj[curr];
4477
- return acc;
4478
- }, {});
5162
+ return Object.keys(obj)
5163
+ .sort(function (a, b) {
5164
+ return a.localeCompare(b);
5165
+ })
5166
+ .reduce(function (acc, curr) {
5167
+ acc[curr] = obj[curr];
5168
+ return acc;
5169
+ }, {});
4479
5170
  }
5171
+
4480
5172
  var requestBuilder = {
4481
5173
  /**
4482
5174
  * Get all the queries to send to the client, those queries can used directly
@@ -4492,14 +5184,17 @@
4492
5184
  // One query for the hits
4493
5185
  queries.push({
4494
5186
  indexName: index,
4495
- params: requestBuilder._getHitsSearchParams(state)
5187
+ params: requestBuilder._getHitsSearchParams(state),
4496
5188
  });
4497
5189
 
4498
5190
  // One for each disjunctive facets
4499
5191
  state.getRefinedDisjunctiveFacets().forEach(function (refinedFacet) {
4500
5192
  queries.push({
4501
5193
  indexName: index,
4502
- params: requestBuilder._getDisjunctiveFacetSearchParams(state, refinedFacet)
5194
+ params: requestBuilder._getDisjunctiveFacetSearchParams(
5195
+ state,
5196
+ refinedFacet
5197
+ ),
4503
5198
  });
4504
5199
  });
4505
5200
 
@@ -4511,16 +5206,30 @@
4511
5206
 
4512
5207
  // If we are deeper than level 0 (starting from `beer > IPA`)
4513
5208
  // we want to get all parent values
4514
- if (currentRefinement.length > 0 && currentRefinement[0].split(separator).length > 1) {
5209
+ if (
5210
+ currentRefinement.length > 0 &&
5211
+ currentRefinement[0].split(separator).length > 1
5212
+ ) {
4515
5213
  // We generate a map of the filters we will use for our facet values queries
4516
- var filtersMap = currentRefinement[0].split(separator).slice(0, -1).reduce(function createFiltersMap(map, segment, level) {
4517
- return map.concat({
4518
- attribute: hierarchicalFacet.attributes[level],
4519
- value: level === 0 ? segment : [map[map.length - 1].value, segment].join(separator)
4520
- });
4521
- }, []);
5214
+ var filtersMap = currentRefinement[0]
5215
+ .split(separator)
5216
+ .slice(0, -1)
5217
+ .reduce(function createFiltersMap(map, segment, level) {
5218
+ return map.concat({
5219
+ attribute: hierarchicalFacet.attributes[level],
5220
+ value:
5221
+ level === 0
5222
+ ? segment
5223
+ : [map[map.length - 1].value, segment].join(separator),
5224
+ });
5225
+ }, []);
5226
+
4522
5227
  filtersMap.forEach(function (filter, level) {
4523
- var params = requestBuilder._getDisjunctiveFacetSearchParams(state, filter.attribute, level === 0);
5228
+ var params = requestBuilder._getDisjunctiveFacetSearchParams(
5229
+ state,
5230
+ filter.attribute,
5231
+ level === 0
5232
+ );
4524
5233
 
4525
5234
  // Keep facet filters unrelated to current hierarchical attributes
4526
5235
  function hasHierarchicalFacetFilter(value) {
@@ -4528,58 +5237,81 @@
4528
5237
  return attribute === value.split(':')[0];
4529
5238
  });
4530
5239
  }
4531
- var filteredFacetFilters = (params.facetFilters || []).reduce(function (acc, facetFilter) {
4532
- if (Array.isArray(facetFilter)) {
4533
- var filtered = facetFilter.filter(function (filterValue) {
4534
- return !hasHierarchicalFacetFilter(filterValue);
4535
- });
4536
- if (filtered.length > 0) {
4537
- acc.push(filtered);
5240
+
5241
+ var filteredFacetFilters = (params.facetFilters || []).reduce(
5242
+ function (acc, facetFilter) {
5243
+ if (Array.isArray(facetFilter)) {
5244
+ var filtered = facetFilter.filter(function (filterValue) {
5245
+ return !hasHierarchicalFacetFilter(filterValue);
5246
+ });
5247
+
5248
+ if (filtered.length > 0) {
5249
+ acc.push(filtered);
5250
+ }
4538
5251
  }
4539
- }
4540
- if (typeof facetFilter === 'string' && !hasHierarchicalFacetFilter(facetFilter)) {
4541
- acc.push(facetFilter);
4542
- }
4543
- return acc;
4544
- }, []);
5252
+
5253
+ if (
5254
+ typeof facetFilter === 'string' &&
5255
+ !hasHierarchicalFacetFilter(facetFilter)
5256
+ ) {
5257
+ acc.push(facetFilter);
5258
+ }
5259
+
5260
+ return acc;
5261
+ },
5262
+ []
5263
+ );
5264
+
4545
5265
  var parent = filtersMap[level - 1];
4546
5266
  if (level > 0) {
4547
- params.facetFilters = filteredFacetFilters.concat(parent.attribute + ':' + parent.value);
5267
+ params.facetFilters = filteredFacetFilters.concat(
5268
+ parent.attribute + ':' + parent.value
5269
+ );
4548
5270
  } else {
4549
- params.facetFilters = filteredFacetFilters.length > 0 ? filteredFacetFilters : undefined;
5271
+ params.facetFilters =
5272
+ filteredFacetFilters.length > 0
5273
+ ? filteredFacetFilters
5274
+ : undefined;
4550
5275
  }
4551
- queries.push({
4552
- indexName: index,
4553
- params: params
4554
- });
5276
+
5277
+ queries.push({ indexName: index, params: params });
4555
5278
  });
4556
5279
  }
4557
5280
  });
5281
+
4558
5282
  return queries;
4559
5283
  },
5284
+
4560
5285
  /**
4561
5286
  * Build search parameters used to fetch hits
4562
5287
  * @private
4563
5288
  * @param {SearchParameters} state The state from which to get the queries
4564
5289
  * @return {object.<string, any>} The search parameters for hits
4565
5290
  */
4566
- _getHitsSearchParams: function _getHitsSearchParams(state) {
4567
- var facets = state.facets.concat(state.disjunctiveFacets).concat(requestBuilder._getHitsHierarchicalFacetsAttributes(state));
5291
+ _getHitsSearchParams: function (state) {
5292
+ var facets = state.facets
5293
+ .concat(state.disjunctiveFacets)
5294
+ .concat(requestBuilder._getHitsHierarchicalFacetsAttributes(state));
5295
+
4568
5296
  var facetFilters = requestBuilder._getFacetFilters(state);
4569
5297
  var numericFilters = requestBuilder._getNumericFilters(state);
4570
5298
  var tagFilters = requestBuilder._getTagFilters(state);
4571
5299
  var additionalParams = {
4572
5300
  facets: facets.indexOf('*') > -1 ? ['*'] : facets,
4573
- tagFilters: tagFilters
5301
+ tagFilters: tagFilters,
4574
5302
  };
5303
+
4575
5304
  if (facetFilters.length > 0) {
4576
5305
  additionalParams.facetFilters = facetFilters;
4577
5306
  }
5307
+
4578
5308
  if (numericFilters.length > 0) {
4579
5309
  additionalParams.numericFilters = numericFilters;
4580
5310
  }
4581
- return sortObject(merge$1({}, state.getQueryParams(), additionalParams));
5311
+
5312
+ return sortObject(merge_1({}, state.getQueryParams(), additionalParams));
4582
5313
  },
5314
+
4583
5315
  /**
4584
5316
  * Build search parameters used to fetch a disjunctive facet
4585
5317
  * @private
@@ -4588,33 +5320,53 @@
4588
5320
  * @param {boolean} hierarchicalRootLevel ?? FIXME
4589
5321
  * @return {object} The search parameters for a disjunctive facet
4590
5322
  */
4591
- _getDisjunctiveFacetSearchParams: function _getDisjunctiveFacetSearchParams(state, facet, hierarchicalRootLevel) {
4592
- var facetFilters = requestBuilder._getFacetFilters(state, facet, hierarchicalRootLevel);
5323
+ _getDisjunctiveFacetSearchParams: function (
5324
+ state,
5325
+ facet,
5326
+ hierarchicalRootLevel
5327
+ ) {
5328
+ var facetFilters = requestBuilder._getFacetFilters(
5329
+ state,
5330
+ facet,
5331
+ hierarchicalRootLevel
5332
+ );
4593
5333
  var numericFilters = requestBuilder._getNumericFilters(state, facet);
4594
5334
  var tagFilters = requestBuilder._getTagFilters(state);
4595
5335
  var additionalParams = {
4596
5336
  hitsPerPage: 0,
4597
5337
  page: 0,
4598
5338
  analytics: false,
4599
- clickAnalytics: false
5339
+ clickAnalytics: false,
4600
5340
  };
5341
+
4601
5342
  if (tagFilters.length > 0) {
4602
5343
  additionalParams.tagFilters = tagFilters;
4603
5344
  }
5345
+
4604
5346
  var hierarchicalFacet = state.getHierarchicalFacetByName(facet);
5347
+
4605
5348
  if (hierarchicalFacet) {
4606
- additionalParams.facets = requestBuilder._getDisjunctiveHierarchicalFacetAttribute(state, hierarchicalFacet, hierarchicalRootLevel);
5349
+ additionalParams.facets =
5350
+ requestBuilder._getDisjunctiveHierarchicalFacetAttribute(
5351
+ state,
5352
+ hierarchicalFacet,
5353
+ hierarchicalRootLevel
5354
+ );
4607
5355
  } else {
4608
5356
  additionalParams.facets = facet;
4609
5357
  }
5358
+
4610
5359
  if (numericFilters.length > 0) {
4611
5360
  additionalParams.numericFilters = numericFilters;
4612
5361
  }
5362
+
4613
5363
  if (facetFilters.length > 0) {
4614
5364
  additionalParams.facetFilters = facetFilters;
4615
5365
  }
4616
- return sortObject(merge$1({}, state.getQueryParams(), additionalParams));
5366
+
5367
+ return sortObject(merge_1({}, state.getQueryParams(), additionalParams));
4617
5368
  },
5369
+
4618
5370
  /**
4619
5371
  * Return the numeric filters in an algolia request fashion
4620
5372
  * @private
@@ -4622,11 +5374,13 @@
4622
5374
  * @param {string} [facetName] the name of the attribute for which the filters should be excluded
4623
5375
  * @return {string[]} the numeric filters in the algolia format
4624
5376
  */
4625
- _getNumericFilters: function _getNumericFilters(state, facetName) {
5377
+ _getNumericFilters: function (state, facetName) {
4626
5378
  if (state.numericFilters) {
4627
5379
  return state.numericFilters;
4628
5380
  }
5381
+
4629
5382
  var numericFilters = [];
5383
+
4630
5384
  Object.keys(state.numericRefinements).forEach(function (attribute) {
4631
5385
  var operators = state.numericRefinements[attribute] || {};
4632
5386
  Object.keys(operators).forEach(function (operator) {
@@ -4645,20 +5399,24 @@
4645
5399
  }
4646
5400
  });
4647
5401
  });
5402
+
4648
5403
  return numericFilters;
4649
5404
  },
5405
+
4650
5406
  /**
4651
5407
  * Return the tags filters depending on which format is used, either tagFilters or tagRefinements
4652
5408
  * @private
4653
5409
  * @param {SearchParameters} state the state from which to get the filters
4654
5410
  * @return {string} Tag filters in a single string
4655
5411
  */
4656
- _getTagFilters: function _getTagFilters(state) {
5412
+ _getTagFilters: function (state) {
4657
5413
  if (state.tagFilters) {
4658
5414
  return state.tagFilters;
4659
5415
  }
5416
+
4660
5417
  return state.tagRefinements.join(',');
4661
5418
  },
5419
+
4662
5420
  /**
4663
5421
  * Build facetFilters parameter based on current refinements. The array returned
4664
5422
  * contains strings representing the facet filters in the algolia format.
@@ -4668,8 +5426,9 @@
4668
5426
  * @param {boolean} [hierarchicalRootLevel] ?? FIXME
4669
5427
  * @return {array.<string>} The facet filters in the algolia format
4670
5428
  */
4671
- _getFacetFilters: function _getFacetFilters(state, facet, hierarchicalRootLevel) {
5429
+ _getFacetFilters: function (state, facet, hierarchicalRootLevel) {
4672
5430
  var facetFilters = [];
5431
+
4673
5432
  var facetsRefinements = state.facetsRefinements || {};
4674
5433
  Object.keys(facetsRefinements).forEach(function (facetName) {
4675
5434
  var facetValues = facetsRefinements[facetName] || [];
@@ -4677,6 +5436,7 @@
4677
5436
  facetFilters.push(facetName + ':' + facetValue);
4678
5437
  });
4679
5438
  });
5439
+
4680
5440
  var facetsExcludes = state.facetsExcludes || {};
4681
5441
  Object.keys(facetsExcludes).forEach(function (facetName) {
4682
5442
  var facetValues = facetsExcludes[facetName] || [];
@@ -4684,6 +5444,7 @@
4684
5444
  facetFilters.push(facetName + ':-' + facetValue);
4685
5445
  });
4686
5446
  });
5447
+
4687
5448
  var disjunctiveFacetsRefinements = state.disjunctiveFacetsRefinements || {};
4688
5449
  Object.keys(disjunctiveFacetsRefinements).forEach(function (facetName) {
4689
5450
  var facetValues = disjunctiveFacetsRefinements[facetName] || [];
@@ -4691,18 +5452,24 @@
4691
5452
  return;
4692
5453
  }
4693
5454
  var orFilters = [];
5455
+
4694
5456
  facetValues.forEach(function (facetValue) {
4695
5457
  orFilters.push(facetName + ':' + facetValue);
4696
5458
  });
5459
+
4697
5460
  facetFilters.push(orFilters);
4698
5461
  });
4699
- var hierarchicalFacetsRefinements = state.hierarchicalFacetsRefinements || {};
5462
+
5463
+ var hierarchicalFacetsRefinements =
5464
+ state.hierarchicalFacetsRefinements || {};
4700
5465
  Object.keys(hierarchicalFacetsRefinements).forEach(function (facetName) {
4701
5466
  var facetValues = hierarchicalFacetsRefinements[facetName] || [];
4702
5467
  var facetValue = facetValues[0];
5468
+
4703
5469
  if (facetValue === undefined) {
4704
5470
  return;
4705
5471
  }
5472
+
4706
5473
  var hierarchicalFacet = state.getHierarchicalFacetByName(facetName);
4707
5474
  var separator = state._getHierarchicalFacetSeparator(hierarchicalFacet);
4708
5475
  var rootPath = state._getHierarchicalRootPath(hierarchicalFacet);
@@ -4713,9 +5480,16 @@
4713
5480
  if (facet === facetName) {
4714
5481
  // if we are at the root level already, no need to ask for facet values, we get them from
4715
5482
  // the hits query
4716
- if (facetValue.indexOf(separator) === -1 || !rootPath && hierarchicalRootLevel === true || rootPath && rootPath.split(separator).length === facetValue.split(separator).length) {
5483
+ if (
5484
+ facetValue.indexOf(separator) === -1 ||
5485
+ (!rootPath && hierarchicalRootLevel === true) ||
5486
+ (rootPath &&
5487
+ rootPath.split(separator).length ===
5488
+ facetValue.split(separator).length)
5489
+ ) {
4717
5490
  return;
4718
5491
  }
5492
+
4719
5493
  if (!rootPath) {
4720
5494
  attributesIndex = facetValue.split(separator).length - 2;
4721
5495
  facetValue = facetValue.slice(0, facetValue.lastIndexOf(separator));
@@ -4723,67 +5497,100 @@
4723
5497
  attributesIndex = rootPath.split(separator).length - 1;
4724
5498
  facetValue = rootPath;
4725
5499
  }
5500
+
4726
5501
  attributeToRefine = hierarchicalFacet.attributes[attributesIndex];
4727
5502
  } else {
4728
5503
  attributesIndex = facetValue.split(separator).length - 1;
5504
+
4729
5505
  attributeToRefine = hierarchicalFacet.attributes[attributesIndex];
4730
5506
  }
5507
+
4731
5508
  if (attributeToRefine) {
4732
5509
  facetFilters.push([attributeToRefine + ':' + facetValue]);
4733
5510
  }
4734
5511
  });
5512
+
4735
5513
  return facetFilters;
4736
5514
  },
4737
- _getHitsHierarchicalFacetsAttributes: function _getHitsHierarchicalFacetsAttributes(state) {
5515
+
5516
+ _getHitsHierarchicalFacetsAttributes: function (state) {
4738
5517
  var out = [];
5518
+
4739
5519
  return state.hierarchicalFacets.reduce(
4740
- // ask for as much levels as there's hierarchical refinements
4741
- function getHitsAttributesForHierarchicalFacet(allAttributes, hierarchicalFacet) {
4742
- var hierarchicalRefinement = state.getHierarchicalRefinement(hierarchicalFacet.name)[0];
4743
-
4744
- // if no refinement, ask for root level
4745
- if (!hierarchicalRefinement) {
4746
- allAttributes.push(hierarchicalFacet.attributes[0]);
4747
- return allAttributes;
4748
- }
4749
- var separator = state._getHierarchicalFacetSeparator(hierarchicalFacet);
4750
- var level = hierarchicalRefinement.split(separator).length;
4751
- var newAttributes = hierarchicalFacet.attributes.slice(0, level + 1);
4752
- return allAttributes.concat(newAttributes);
4753
- }, out);
5520
+ // ask for as much levels as there's hierarchical refinements
5521
+ function getHitsAttributesForHierarchicalFacet(
5522
+ allAttributes,
5523
+ hierarchicalFacet
5524
+ ) {
5525
+ var hierarchicalRefinement = state.getHierarchicalRefinement(
5526
+ hierarchicalFacet.name
5527
+ )[0];
5528
+
5529
+ // if no refinement, ask for root level
5530
+ if (!hierarchicalRefinement) {
5531
+ allAttributes.push(hierarchicalFacet.attributes[0]);
5532
+ return allAttributes;
5533
+ }
5534
+
5535
+ var separator = state._getHierarchicalFacetSeparator(hierarchicalFacet);
5536
+ var level = hierarchicalRefinement.split(separator).length;
5537
+ var newAttributes = hierarchicalFacet.attributes.slice(0, level + 1);
5538
+
5539
+ return allAttributes.concat(newAttributes);
5540
+ },
5541
+ out
5542
+ );
4754
5543
  },
4755
- _getDisjunctiveHierarchicalFacetAttribute: function _getDisjunctiveHierarchicalFacetAttribute(state, hierarchicalFacet, rootLevel) {
5544
+
5545
+ _getDisjunctiveHierarchicalFacetAttribute: function (
5546
+ state,
5547
+ hierarchicalFacet,
5548
+ rootLevel
5549
+ ) {
4756
5550
  var separator = state._getHierarchicalFacetSeparator(hierarchicalFacet);
4757
5551
  if (rootLevel === true) {
4758
5552
  var rootPath = state._getHierarchicalRootPath(hierarchicalFacet);
4759
5553
  var attributeIndex = 0;
5554
+
4760
5555
  if (rootPath) {
4761
5556
  attributeIndex = rootPath.split(separator).length;
4762
5557
  }
4763
5558
  return [hierarchicalFacet.attributes[attributeIndex]];
4764
5559
  }
4765
- var hierarchicalRefinement = state.getHierarchicalRefinement(hierarchicalFacet.name)[0] || '';
5560
+
5561
+ var hierarchicalRefinement =
5562
+ state.getHierarchicalRefinement(hierarchicalFacet.name)[0] || '';
4766
5563
  // if refinement is 'beers > IPA > Flying dog',
4767
5564
  // then we want `facets: ['beers > IPA']` as disjunctive facet (parent level values)
4768
5565
 
4769
5566
  var parentLevel = hierarchicalRefinement.split(separator).length - 1;
4770
5567
  return hierarchicalFacet.attributes.slice(0, parentLevel + 1);
4771
5568
  },
4772
- getSearchForFacetQuery: function getSearchForFacetQuery(facetName, query, maxFacetHits, state) {
4773
- var stateForSearchForFacetValues = state.isDisjunctiveFacet(facetName) ? state.clearRefinements(facetName) : state;
5569
+
5570
+ getSearchForFacetQuery: function (facetName, query, maxFacetHits, state) {
5571
+ var stateForSearchForFacetValues = state.isDisjunctiveFacet(facetName)
5572
+ ? state.clearRefinements(facetName)
5573
+ : state;
4774
5574
  var searchForFacetSearchParameters = {
4775
5575
  facetQuery: query,
4776
- facetName: facetName
5576
+ facetName: facetName,
4777
5577
  };
4778
5578
  if (typeof maxFacetHits === 'number') {
4779
5579
  searchForFacetSearchParameters.maxFacetHits = maxFacetHits;
4780
5580
  }
4781
- return sortObject(merge$1({}, requestBuilder._getHitsSearchParams(stateForSearchForFacetValues), searchForFacetSearchParameters));
4782
- }
5581
+ return sortObject(
5582
+ merge_1(
5583
+ {},
5584
+ requestBuilder._getHitsSearchParams(stateForSearchForFacetValues),
5585
+ searchForFacetSearchParameters
5586
+ )
5587
+ );
5588
+ },
4783
5589
  };
5590
+
4784
5591
  var requestBuilder_1 = requestBuilder;
4785
5592
 
4786
- var version = '3.13.3';
5593
+ var version = '3.13.5';
4787
5594
 
4788
5595
  var escapeFacetValue$3 = escapeFacetValue_1.escapeFacetValue;
4789
5596
 
@@ -4894,6 +5701,7 @@
4894
5701
  if (typeof client.addAlgoliaAgent === 'function') {
4895
5702
  client.addAlgoliaAgent('JS Helper (' + version + ')');
4896
5703
  }
5704
+
4897
5705
  this.setClient(client);
4898
5706
  var opts = options || {};
4899
5707
  opts.index = index;
@@ -4904,6 +5712,7 @@
4904
5712
  this.derivedHelpers = [];
4905
5713
  this._currentNbQueries = 0;
4906
5714
  }
5715
+
4907
5716
  inherits_1(AlgoliaSearchHelper, events);
4908
5717
 
4909
5718
  /**
@@ -4918,15 +5727,12 @@
4918
5727
  * @chainable
4919
5728
  */
4920
5729
  AlgoliaSearchHelper.prototype.search = function () {
4921
- this._search({
4922
- onlyWithDerivedHelpers: false
4923
- });
5730
+ this._search({ onlyWithDerivedHelpers: false });
4924
5731
  return this;
4925
5732
  };
5733
+
4926
5734
  AlgoliaSearchHelper.prototype.searchOnlyWithDerivedHelpers = function () {
4927
- this._search({
4928
- onlyWithDerivedHelpers: true
4929
- });
5735
+ this._search({ onlyWithDerivedHelpers: true });
4930
5736
  return this;
4931
5737
  };
4932
5738
 
@@ -4977,43 +5783,58 @@
4977
5783
  * }
4978
5784
  */
4979
5785
  AlgoliaSearchHelper.prototype.searchOnce = function (options, cb) {
4980
- var tempState = !options ? this.state : this.state.setQueryParameters(options);
5786
+ var tempState = !options
5787
+ ? this.state
5788
+ : this.state.setQueryParameters(options);
4981
5789
  var queries = requestBuilder_1._getQueries(tempState.index, tempState);
4982
5790
  // eslint-disable-next-line consistent-this
4983
5791
  var self = this;
5792
+
4984
5793
  this._currentNbQueries++;
5794
+
4985
5795
  this.emit('searchOnce', {
4986
- state: tempState
5796
+ state: tempState,
4987
5797
  });
5798
+
4988
5799
  if (cb) {
4989
- this.client.search(queries).then(function (content) {
4990
- self._currentNbQueries--;
4991
- if (self._currentNbQueries === 0) {
4992
- self.emit('searchQueueEmpty');
4993
- }
4994
- cb(null, new SearchResults_1(tempState, content.results), tempState);
4995
- }).catch(function (err) {
4996
- self._currentNbQueries--;
4997
- if (self._currentNbQueries === 0) {
4998
- self.emit('searchQueueEmpty');
4999
- }
5000
- cb(err, null, tempState);
5001
- });
5800
+ this.client
5801
+ .search(queries)
5802
+ .then(function (content) {
5803
+ self._currentNbQueries--;
5804
+ if (self._currentNbQueries === 0) {
5805
+ self.emit('searchQueueEmpty');
5806
+ }
5807
+
5808
+ cb(null, new SearchResults_1(tempState, content.results), tempState);
5809
+ })
5810
+ .catch(function (err) {
5811
+ self._currentNbQueries--;
5812
+ if (self._currentNbQueries === 0) {
5813
+ self.emit('searchQueueEmpty');
5814
+ }
5815
+
5816
+ cb(err, null, tempState);
5817
+ });
5818
+
5002
5819
  return undefined;
5003
5820
  }
5004
- return this.client.search(queries).then(function (content) {
5005
- self._currentNbQueries--;
5006
- if (self._currentNbQueries === 0) self.emit('searchQueueEmpty');
5007
- return {
5008
- content: new SearchResults_1(tempState, content.results),
5009
- state: tempState,
5010
- _originalResponse: content
5011
- };
5012
- }, function (e) {
5013
- self._currentNbQueries--;
5014
- if (self._currentNbQueries === 0) self.emit('searchQueueEmpty');
5015
- throw e;
5016
- });
5821
+
5822
+ return this.client.search(queries).then(
5823
+ function (content) {
5824
+ self._currentNbQueries--;
5825
+ if (self._currentNbQueries === 0) self.emit('searchQueueEmpty');
5826
+ return {
5827
+ content: new SearchResults_1(tempState, content.results),
5828
+ state: tempState,
5829
+ _originalResponse: content,
5830
+ };
5831
+ },
5832
+ function (e) {
5833
+ self._currentNbQueries--;
5834
+ if (self._currentNbQueries === 0) self.emit('searchQueueEmpty');
5835
+ throw e;
5836
+ }
5837
+ );
5017
5838
  };
5018
5839
 
5019
5840
  /**
@@ -5036,13 +5857,23 @@
5036
5857
  return Promise.resolve([]);
5037
5858
  }
5038
5859
  var derivedState = derivedHelper.getModifiedState(state);
5039
- var data = merge$1({
5040
- attributesForPrediction: options.attributesForPrediction,
5041
- nbHits: options.nbHits
5042
- }, {
5043
- params: omit$1(requestBuilder_1._getHitsSearchParams(derivedState), ['attributesToSnippet', 'hitsPerPage', 'restrictSearchableAttributes', 'snippetEllipsisText'])
5044
- });
5045
- var errorMessage = 'search for answers was called, but this client does not have a function client.initIndex(index).findAnswers';
5860
+ var data = merge_1(
5861
+ {
5862
+ attributesForPrediction: options.attributesForPrediction,
5863
+ nbHits: options.nbHits,
5864
+ },
5865
+ {
5866
+ params: omit$1(requestBuilder_1._getHitsSearchParams(derivedState), [
5867
+ 'attributesToSnippet',
5868
+ 'hitsPerPage',
5869
+ 'restrictSearchableAttributes',
5870
+ 'snippetEllipsisText',
5871
+ ]),
5872
+ }
5873
+ );
5874
+
5875
+ var errorMessage =
5876
+ 'search for answers was called, but this client does not have a function client.initIndex(index).findAnswers';
5046
5877
  if (typeof this.client.initIndex !== 'function') {
5047
5878
  throw new Error(errorMessage);
5048
5879
  }
@@ -5087,60 +5918,93 @@
5087
5918
  * it in the generated query.
5088
5919
  * @return {promise.<FacetSearchResult>} the results of the search
5089
5920
  */
5090
- AlgoliaSearchHelper.prototype.searchForFacetValues = function (facet, query, maxFacetHits, userState) {
5921
+ AlgoliaSearchHelper.prototype.searchForFacetValues = function (
5922
+ facet,
5923
+ query,
5924
+ maxFacetHits,
5925
+ userState
5926
+ ) {
5091
5927
  var clientHasSFFV = typeof this.client.searchForFacetValues === 'function';
5092
5928
  var clientHasInitIndex = typeof this.client.initIndex === 'function';
5093
- if (!clientHasSFFV && !clientHasInitIndex && typeof this.client.search !== 'function') {
5094
- throw new Error('search for facet values (searchable) was called, but this client does not have a function client.searchForFacetValues or client.initIndex(index).searchForFacetValues');
5929
+ if (
5930
+ !clientHasSFFV &&
5931
+ !clientHasInitIndex &&
5932
+ typeof this.client.search !== 'function'
5933
+ ) {
5934
+ throw new Error(
5935
+ 'search for facet values (searchable) was called, but this client does not have a function client.searchForFacetValues or client.initIndex(index).searchForFacetValues'
5936
+ );
5095
5937
  }
5938
+
5096
5939
  var state = this.state.setQueryParameters(userState || {});
5097
5940
  var isDisjunctive = state.isDisjunctiveFacet(facet);
5098
- var algoliaQuery = requestBuilder_1.getSearchForFacetQuery(facet, query, maxFacetHits, state);
5941
+ var algoliaQuery = requestBuilder_1.getSearchForFacetQuery(
5942
+ facet,
5943
+ query,
5944
+ maxFacetHits,
5945
+ state
5946
+ );
5947
+
5099
5948
  this._currentNbQueries++;
5100
5949
  // eslint-disable-next-line consistent-this
5101
5950
  var self = this;
5102
5951
  var searchForFacetValuesPromise;
5103
5952
  // newer algoliasearch ^3.27.1 - ~4.0.0
5104
5953
  if (clientHasSFFV) {
5105
- searchForFacetValuesPromise = this.client.searchForFacetValues([{
5106
- indexName: state.index,
5107
- params: algoliaQuery
5108
- }]);
5954
+ searchForFacetValuesPromise = this.client.searchForFacetValues([
5955
+ { indexName: state.index, params: algoliaQuery },
5956
+ ]);
5109
5957
  // algoliasearch < 3.27.1
5110
5958
  } else if (clientHasInitIndex) {
5111
- searchForFacetValuesPromise = this.client.initIndex(state.index).searchForFacetValues(algoliaQuery);
5959
+ searchForFacetValuesPromise = this.client
5960
+ .initIndex(state.index)
5961
+ .searchForFacetValues(algoliaQuery);
5112
5962
  // algoliasearch ~5.0.0
5113
5963
  } else {
5114
5964
  // @MAJOR only use client.search
5115
5965
  delete algoliaQuery.facetName;
5116
- searchForFacetValuesPromise = this.client.search([{
5117
- type: 'facet',
5118
- facet: facet,
5119
- indexName: state.index,
5120
- params: algoliaQuery
5121
- }]).then(function processResponse(response) {
5122
- return response.results[0];
5123
- });
5966
+ searchForFacetValuesPromise = this.client
5967
+ .search([
5968
+ {
5969
+ type: 'facet',
5970
+ facet: facet,
5971
+ indexName: state.index,
5972
+ params: algoliaQuery,
5973
+ },
5974
+ ])
5975
+ .then(function processResponse(response) {
5976
+ return response.results[0];
5977
+ });
5124
5978
  }
5979
+
5125
5980
  this.emit('searchForFacetValues', {
5126
5981
  state: state,
5127
5982
  facet: facet,
5128
- query: query
5129
- });
5130
- return searchForFacetValuesPromise.then(function addIsRefined(content) {
5131
- self._currentNbQueries--;
5132
- if (self._currentNbQueries === 0) self.emit('searchQueueEmpty');
5133
- content = Array.isArray(content) ? content[0] : content;
5134
- content.facetHits.forEach(function (f) {
5135
- f.escapedValue = escapeFacetValue$3(f.value);
5136
- f.isRefined = isDisjunctive ? state.isDisjunctiveFacetRefined(facet, f.escapedValue) : state.isFacetRefined(facet, f.escapedValue);
5137
- });
5138
- return content;
5139
- }, function (e) {
5140
- self._currentNbQueries--;
5141
- if (self._currentNbQueries === 0) self.emit('searchQueueEmpty');
5142
- throw e;
5983
+ query: query,
5143
5984
  });
5985
+
5986
+ return searchForFacetValuesPromise.then(
5987
+ function addIsRefined(content) {
5988
+ self._currentNbQueries--;
5989
+ if (self._currentNbQueries === 0) self.emit('searchQueueEmpty');
5990
+
5991
+ content = Array.isArray(content) ? content[0] : content;
5992
+
5993
+ content.facetHits.forEach(function (f) {
5994
+ f.escapedValue = escapeFacetValue$3(f.value);
5995
+ f.isRefined = isDisjunctive
5996
+ ? state.isDisjunctiveFacetRefined(facet, f.escapedValue)
5997
+ : state.isFacetRefined(facet, f.escapedValue);
5998
+ });
5999
+
6000
+ return content;
6001
+ },
6002
+ function (e) {
6003
+ self._currentNbQueries--;
6004
+ if (self._currentNbQueries === 0) self.emit('searchQueueEmpty');
6005
+ throw e;
6006
+ }
6007
+ );
5144
6008
  };
5145
6009
 
5146
6010
  /**
@@ -5155,8 +6019,9 @@
5155
6019
  AlgoliaSearchHelper.prototype.setQuery = function (q) {
5156
6020
  this._change({
5157
6021
  state: this.state.resetPage().setQuery(q),
5158
- isPageReset: true
6022
+ isPageReset: true,
5159
6023
  });
6024
+
5160
6025
  return this;
5161
6026
  };
5162
6027
 
@@ -5186,8 +6051,9 @@
5186
6051
  AlgoliaSearchHelper.prototype.clearRefinements = function (name) {
5187
6052
  this._change({
5188
6053
  state: this.state.resetPage().clearRefinements(name),
5189
- isPageReset: true
6054
+ isPageReset: true,
5190
6055
  });
6056
+
5191
6057
  return this;
5192
6058
  };
5193
6059
 
@@ -5202,8 +6068,9 @@
5202
6068
  AlgoliaSearchHelper.prototype.clearTags = function () {
5203
6069
  this._change({
5204
6070
  state: this.state.resetPage().clearTags(),
5205
- isPageReset: true
6071
+ isPageReset: true,
5206
6072
  });
6073
+
5207
6074
  return this;
5208
6075
  };
5209
6076
 
@@ -5218,11 +6085,15 @@
5218
6085
  * @fires change
5219
6086
  * @chainable
5220
6087
  */
5221
- AlgoliaSearchHelper.prototype.addDisjunctiveFacetRefinement = function (facet, value) {
6088
+ AlgoliaSearchHelper.prototype.addDisjunctiveFacetRefinement = function (
6089
+ facet,
6090
+ value
6091
+ ) {
5222
6092
  this._change({
5223
6093
  state: this.state.resetPage().addDisjunctiveFacetRefinement(facet, value),
5224
- isPageReset: true
6094
+ isPageReset: true,
5225
6095
  });
6096
+
5226
6097
  return this;
5227
6098
  };
5228
6099
 
@@ -5247,11 +6118,15 @@
5247
6118
  * @chainable
5248
6119
  * @fires change
5249
6120
  */
5250
- AlgoliaSearchHelper.prototype.addHierarchicalFacetRefinement = function (facet, path) {
6121
+ AlgoliaSearchHelper.prototype.addHierarchicalFacetRefinement = function (
6122
+ facet,
6123
+ path
6124
+ ) {
5251
6125
  this._change({
5252
6126
  state: this.state.resetPage().addHierarchicalFacetRefinement(facet, path),
5253
- isPageReset: true
6127
+ isPageReset: true,
5254
6128
  });
6129
+
5255
6130
  return this;
5256
6131
  };
5257
6132
 
@@ -5267,11 +6142,18 @@
5267
6142
  * @fires change
5268
6143
  * @chainable
5269
6144
  */
5270
- AlgoliaSearchHelper.prototype.addNumericRefinement = function (attribute, operator, value) {
6145
+ AlgoliaSearchHelper.prototype.addNumericRefinement = function (
6146
+ attribute,
6147
+ operator,
6148
+ value
6149
+ ) {
5271
6150
  this._change({
5272
- state: this.state.resetPage().addNumericRefinement(attribute, operator, value),
5273
- isPageReset: true
6151
+ state: this.state
6152
+ .resetPage()
6153
+ .addNumericRefinement(attribute, operator, value),
6154
+ isPageReset: true,
5274
6155
  });
6156
+
5275
6157
  return this;
5276
6158
  };
5277
6159
 
@@ -5289,8 +6171,9 @@
5289
6171
  AlgoliaSearchHelper.prototype.addFacetRefinement = function (facet, value) {
5290
6172
  this._change({
5291
6173
  state: this.state.resetPage().addFacetRefinement(facet, value),
5292
- isPageReset: true
6174
+ isPageReset: true,
5293
6175
  });
6176
+
5294
6177
  return this;
5295
6178
  };
5296
6179
 
@@ -5316,8 +6199,9 @@
5316
6199
  AlgoliaSearchHelper.prototype.addFacetExclusion = function (facet, value) {
5317
6200
  this._change({
5318
6201
  state: this.state.resetPage().addExcludeRefinement(facet, value),
5319
- isPageReset: true
6202
+ isPageReset: true,
5320
6203
  });
6204
+
5321
6205
  return this;
5322
6206
  };
5323
6207
 
@@ -5342,8 +6226,9 @@
5342
6226
  AlgoliaSearchHelper.prototype.addTag = function (tag) {
5343
6227
  this._change({
5344
6228
  state: this.state.resetPage().addTagRefinement(tag),
5345
- isPageReset: true
6229
+ isPageReset: true,
5346
6230
  });
6231
+
5347
6232
  return this;
5348
6233
  };
5349
6234
 
@@ -5365,11 +6250,18 @@
5365
6250
  * @fires change
5366
6251
  * @chainable
5367
6252
  */
5368
- AlgoliaSearchHelper.prototype.removeNumericRefinement = function (attribute, operator, value) {
6253
+ AlgoliaSearchHelper.prototype.removeNumericRefinement = function (
6254
+ attribute,
6255
+ operator,
6256
+ value
6257
+ ) {
5369
6258
  this._change({
5370
- state: this.state.resetPage().removeNumericRefinement(attribute, operator, value),
5371
- isPageReset: true
6259
+ state: this.state
6260
+ .resetPage()
6261
+ .removeNumericRefinement(attribute, operator, value),
6262
+ isPageReset: true,
5372
6263
  });
6264
+
5373
6265
  return this;
5374
6266
  };
5375
6267
 
@@ -5387,11 +6279,17 @@
5387
6279
  * @fires change
5388
6280
  * @chainable
5389
6281
  */
5390
- AlgoliaSearchHelper.prototype.removeDisjunctiveFacetRefinement = function (facet, value) {
6282
+ AlgoliaSearchHelper.prototype.removeDisjunctiveFacetRefinement = function (
6283
+ facet,
6284
+ value
6285
+ ) {
5391
6286
  this._change({
5392
- state: this.state.resetPage().removeDisjunctiveFacetRefinement(facet, value),
5393
- isPageReset: true
6287
+ state: this.state
6288
+ .resetPage()
6289
+ .removeDisjunctiveFacetRefinement(facet, value),
6290
+ isPageReset: true,
5394
6291
  });
6292
+
5395
6293
  return this;
5396
6294
  };
5397
6295
 
@@ -5411,11 +6309,14 @@
5411
6309
  * @fires change
5412
6310
  * @chainable
5413
6311
  */
5414
- AlgoliaSearchHelper.prototype.removeHierarchicalFacetRefinement = function (facet) {
6312
+ AlgoliaSearchHelper.prototype.removeHierarchicalFacetRefinement = function (
6313
+ facet
6314
+ ) {
5415
6315
  this._change({
5416
6316
  state: this.state.resetPage().removeHierarchicalFacetRefinement(facet),
5417
- isPageReset: true
6317
+ isPageReset: true,
5418
6318
  });
6319
+
5419
6320
  return this;
5420
6321
  };
5421
6322
 
@@ -5436,8 +6337,9 @@
5436
6337
  AlgoliaSearchHelper.prototype.removeFacetRefinement = function (facet, value) {
5437
6338
  this._change({
5438
6339
  state: this.state.resetPage().removeFacetRefinement(facet, value),
5439
- isPageReset: true
6340
+ isPageReset: true,
5440
6341
  });
6342
+
5441
6343
  return this;
5442
6344
  };
5443
6345
 
@@ -5466,8 +6368,9 @@
5466
6368
  AlgoliaSearchHelper.prototype.removeFacetExclusion = function (facet, value) {
5467
6369
  this._change({
5468
6370
  state: this.state.resetPage().removeExcludeRefinement(facet, value),
5469
- isPageReset: true
6371
+ isPageReset: true,
5470
6372
  });
6373
+
5471
6374
  return this;
5472
6375
  };
5473
6376
 
@@ -5492,8 +6395,9 @@
5492
6395
  AlgoliaSearchHelper.prototype.removeTag = function (tag) {
5493
6396
  this._change({
5494
6397
  state: this.state.resetPage().removeTagRefinement(tag),
5495
- isPageReset: true
6398
+ isPageReset: true,
5496
6399
  });
6400
+
5497
6401
  return this;
5498
6402
  };
5499
6403
 
@@ -5511,8 +6415,9 @@
5511
6415
  AlgoliaSearchHelper.prototype.toggleFacetExclusion = function (facet, value) {
5512
6416
  this._change({
5513
6417
  state: this.state.resetPage().toggleExcludeFacetRefinement(facet, value),
5514
- isPageReset: true
6418
+ isPageReset: true,
5515
6419
  });
6420
+
5516
6421
  return this;
5517
6422
  };
5518
6423
 
@@ -5560,8 +6465,9 @@
5560
6465
  AlgoliaSearchHelper.prototype.toggleFacetRefinement = function (facet, value) {
5561
6466
  this._change({
5562
6467
  state: this.state.resetPage().toggleFacetRefinement(facet, value),
5563
- isPageReset: true
6468
+ isPageReset: true,
5564
6469
  });
6470
+
5565
6471
  return this;
5566
6472
  };
5567
6473
 
@@ -5586,8 +6492,9 @@
5586
6492
  AlgoliaSearchHelper.prototype.toggleTag = function (tag) {
5587
6493
  this._change({
5588
6494
  state: this.state.resetPage().toggleTagRefinement(tag),
5589
- isPageReset: true
6495
+ isPageReset: true,
5590
6496
  });
6497
+
5591
6498
  return this;
5592
6499
  };
5593
6500
 
@@ -5628,10 +6535,12 @@
5628
6535
  */
5629
6536
  function setCurrentPage(page) {
5630
6537
  if (page < 0) throw new Error('Page requested below 0.');
6538
+
5631
6539
  this._change({
5632
6540
  state: this.state.setPage(page),
5633
- isPageReset: false
6541
+ isPageReset: false,
5634
6542
  });
6543
+
5635
6544
  return this;
5636
6545
  }
5637
6546
 
@@ -5667,8 +6576,9 @@
5667
6576
  AlgoliaSearchHelper.prototype.setIndex = function (name) {
5668
6577
  this._change({
5669
6578
  state: this.state.resetPage().setIndex(name),
5670
- isPageReset: true
6579
+ isPageReset: true,
5671
6580
  });
6581
+
5672
6582
  return this;
5673
6583
  };
5674
6584
 
@@ -5692,8 +6602,9 @@
5692
6602
  AlgoliaSearchHelper.prototype.setQueryParameter = function (parameter, value) {
5693
6603
  this._change({
5694
6604
  state: this.state.resetPage().setQueryParameter(parameter, value),
5695
- isPageReset: true
6605
+ isPageReset: true,
5696
6606
  });
6607
+
5697
6608
  return this;
5698
6609
  };
5699
6610
 
@@ -5707,8 +6618,9 @@
5707
6618
  AlgoliaSearchHelper.prototype.setState = function (newState) {
5708
6619
  this._change({
5709
6620
  state: SearchParameters_1.make(newState),
5710
- isPageReset: false
6621
+ isPageReset: false,
5711
6622
  });
6623
+
5712
6624
  return this;
5713
6625
  };
5714
6626
 
@@ -5729,10 +6641,11 @@
5729
6641
  * }
5730
6642
  * @chainable
5731
6643
  */
5732
- AlgoliaSearchHelper.prototype.overrideStateWithoutTriggeringChangeEvent = function (newState) {
5733
- this.state = new SearchParameters_1(newState);
5734
- return this;
5735
- };
6644
+ AlgoliaSearchHelper.prototype.overrideStateWithoutTriggeringChangeEvent =
6645
+ function (newState) {
6646
+ this.state = new SearchParameters_1(newState);
6647
+ return this;
6648
+ };
5736
6649
 
5737
6650
  /**
5738
6651
  * Check if an attribute has any numeric, conjunctive, disjunctive or hierarchical filters.
@@ -5834,6 +6747,7 @@
5834
6747
  AlgoliaSearchHelper.prototype.getIndex = function () {
5835
6748
  return this.state.index;
5836
6749
  };
6750
+
5837
6751
  function getCurrentPage() {
5838
6752
  return this.state.page;
5839
6753
  }
@@ -5906,39 +6820,49 @@
5906
6820
  */
5907
6821
  AlgoliaSearchHelper.prototype.getRefinements = function (facetName) {
5908
6822
  var refinements = [];
6823
+
5909
6824
  if (this.state.isConjunctiveFacet(facetName)) {
5910
6825
  var conjRefinements = this.state.getConjunctiveRefinements(facetName);
6826
+
5911
6827
  conjRefinements.forEach(function (r) {
5912
6828
  refinements.push({
5913
6829
  value: r,
5914
- type: 'conjunctive'
6830
+ type: 'conjunctive',
5915
6831
  });
5916
6832
  });
6833
+
5917
6834
  var excludeRefinements = this.state.getExcludeRefinements(facetName);
6835
+
5918
6836
  excludeRefinements.forEach(function (r) {
5919
6837
  refinements.push({
5920
6838
  value: r,
5921
- type: 'exclude'
6839
+ type: 'exclude',
5922
6840
  });
5923
6841
  });
5924
6842
  } else if (this.state.isDisjunctiveFacet(facetName)) {
5925
- var disjunctiveRefinements = this.state.getDisjunctiveRefinements(facetName);
6843
+ var disjunctiveRefinements =
6844
+ this.state.getDisjunctiveRefinements(facetName);
6845
+
5926
6846
  disjunctiveRefinements.forEach(function (r) {
5927
6847
  refinements.push({
5928
6848
  value: r,
5929
- type: 'disjunctive'
6849
+ type: 'disjunctive',
5930
6850
  });
5931
6851
  });
5932
6852
  }
6853
+
5933
6854
  var numericRefinements = this.state.getNumericRefinements(facetName);
6855
+
5934
6856
  Object.keys(numericRefinements).forEach(function (operator) {
5935
6857
  var value = numericRefinements[operator];
6858
+
5936
6859
  refinements.push({
5937
6860
  value: value,
5938
6861
  operator: operator,
5939
- type: 'numeric'
6862
+ type: 'numeric',
5940
6863
  });
5941
6864
  });
6865
+
5942
6866
  return refinements;
5943
6867
  };
5944
6868
 
@@ -5948,7 +6872,10 @@
5948
6872
  * @param {string} operator operator applied on the refined values
5949
6873
  * @return {Array.<number|number[]>} refined values
5950
6874
  */
5951
- AlgoliaSearchHelper.prototype.getNumericRefinement = function (attribute, operator) {
6875
+ AlgoliaSearchHelper.prototype.getNumericRefinement = function (
6876
+ attribute,
6877
+ operator
6878
+ ) {
5952
6879
  return this.state.getNumericRefinement(attribute, operator);
5953
6880
  };
5954
6881
 
@@ -5957,7 +6884,9 @@
5957
6884
  * @param {string} facetName Hierarchical facet name
5958
6885
  * @return {array.<string>} the path as an array of string
5959
6886
  */
5960
- AlgoliaSearchHelper.prototype.getHierarchicalFacetBreadcrumb = function (facetName) {
6887
+ AlgoliaSearchHelper.prototype.getHierarchicalFacetBreadcrumb = function (
6888
+ facetName
6889
+ ) {
5961
6890
  return this.state.getHierarchicalFacetBreadcrumb(facetName);
5962
6891
  };
5963
6892
 
@@ -5977,48 +6906,65 @@
5977
6906
  var state = this.state;
5978
6907
  var states = [];
5979
6908
  var mainQueries = [];
6909
+
5980
6910
  if (!options.onlyWithDerivedHelpers) {
5981
6911
  mainQueries = requestBuilder_1._getQueries(state.index, state);
6912
+
5982
6913
  states.push({
5983
6914
  state: state,
5984
6915
  queriesCount: mainQueries.length,
5985
- helper: this
6916
+ helper: this,
5986
6917
  });
6918
+
5987
6919
  this.emit('search', {
5988
6920
  state: state,
5989
- results: this.lastResults
6921
+ results: this.lastResults,
5990
6922
  });
5991
6923
  }
6924
+
5992
6925
  var derivedQueries = this.derivedHelpers.map(function (derivedHelper) {
5993
6926
  var derivedState = derivedHelper.getModifiedState(state);
5994
- var derivedStateQueries = derivedState.index ? requestBuilder_1._getQueries(derivedState.index, derivedState) : [];
6927
+ var derivedStateQueries = derivedState.index
6928
+ ? requestBuilder_1._getQueries(derivedState.index, derivedState)
6929
+ : [];
6930
+
5995
6931
  states.push({
5996
6932
  state: derivedState,
5997
6933
  queriesCount: derivedStateQueries.length,
5998
- helper: derivedHelper
6934
+ helper: derivedHelper,
5999
6935
  });
6936
+
6000
6937
  derivedHelper.emit('search', {
6001
6938
  state: derivedState,
6002
- results: derivedHelper.lastResults
6939
+ results: derivedHelper.lastResults,
6003
6940
  });
6941
+
6004
6942
  return derivedStateQueries;
6005
6943
  });
6944
+
6006
6945
  var queries = Array.prototype.concat.apply(mainQueries, derivedQueries);
6946
+
6007
6947
  var queryId = this._queryId++;
6008
6948
  this._currentNbQueries++;
6949
+
6009
6950
  if (!queries.length) {
6010
- return Promise.resolve({
6011
- results: []
6012
- }).then(this._dispatchAlgoliaResponse.bind(this, states, queryId));
6951
+ return Promise.resolve({ results: [] }).then(
6952
+ this._dispatchAlgoliaResponse.bind(this, states, queryId)
6953
+ );
6013
6954
  }
6955
+
6014
6956
  try {
6015
- this.client.search(queries).then(this._dispatchAlgoliaResponse.bind(this, states, queryId)).catch(this._dispatchAlgoliaError.bind(this, queryId));
6957
+ this.client
6958
+ .search(queries)
6959
+ .then(this._dispatchAlgoliaResponse.bind(this, states, queryId))
6960
+ .catch(this._dispatchAlgoliaError.bind(this, queryId));
6016
6961
  } catch (error) {
6017
6962
  // If we reach this part, we're in an internal error state
6018
6963
  this.emit('error', {
6019
- error: error
6964
+ error: error,
6020
6965
  });
6021
6966
  }
6967
+
6022
6968
  return undefined;
6023
6969
  };
6024
6970
 
@@ -6032,50 +6978,79 @@
6032
6978
  * @param {object} content content of the response
6033
6979
  * @return {undefined}
6034
6980
  */
6035
- AlgoliaSearchHelper.prototype._dispatchAlgoliaResponse = function (states, queryId, content) {
6981
+ AlgoliaSearchHelper.prototype._dispatchAlgoliaResponse = function (
6982
+ states,
6983
+ queryId,
6984
+ content
6985
+ ) {
6036
6986
  // @TODO remove the number of outdated queries discarded instead of just one
6037
6987
 
6038
6988
  if (queryId < this._lastQueryIdReceived) {
6039
6989
  // Outdated answer
6040
6990
  return;
6041
6991
  }
6992
+
6042
6993
  this._currentNbQueries -= queryId - this._lastQueryIdReceived;
6043
6994
  this._lastQueryIdReceived = queryId;
6995
+
6044
6996
  if (this._currentNbQueries === 0) this.emit('searchQueueEmpty');
6997
+
6045
6998
  var results = content.results.slice();
6999
+
6046
7000
  states.forEach(function (s) {
6047
7001
  var state = s.state;
6048
7002
  var queriesCount = s.queriesCount;
6049
7003
  var helper = s.helper;
6050
7004
  var specificResults = results.splice(0, queriesCount);
7005
+
6051
7006
  if (!state.index) {
6052
7007
  helper.emit('result', {
6053
7008
  results: null,
6054
- state: state
7009
+ state: state,
6055
7010
  });
6056
7011
  return;
6057
7012
  }
7013
+
6058
7014
  helper.lastResults = new SearchResults_1(state, specificResults);
7015
+
6059
7016
  helper.emit('result', {
6060
7017
  results: helper.lastResults,
6061
- state: state
7018
+ state: state,
6062
7019
  });
6063
7020
  });
6064
7021
  };
6065
- AlgoliaSearchHelper.prototype._dispatchAlgoliaError = function (queryId, error) {
7022
+
7023
+ AlgoliaSearchHelper.prototype._dispatchAlgoliaError = function (
7024
+ queryId,
7025
+ error
7026
+ ) {
6066
7027
  if (queryId < this._lastQueryIdReceived) {
6067
7028
  // Outdated answer
6068
7029
  return;
6069
7030
  }
7031
+
6070
7032
  this._currentNbQueries -= queryId - this._lastQueryIdReceived;
6071
7033
  this._lastQueryIdReceived = queryId;
7034
+
6072
7035
  this.emit('error', {
6073
- error: error
7036
+ error: error,
6074
7037
  });
7038
+
6075
7039
  if (this._currentNbQueries === 0) this.emit('searchQueueEmpty');
6076
7040
  };
6077
- AlgoliaSearchHelper.prototype.containsRefinement = function (query, facetFilters, numericFilters, tagFilters) {
6078
- return query || facetFilters.length !== 0 || numericFilters.length !== 0 || tagFilters.length !== 0;
7041
+
7042
+ AlgoliaSearchHelper.prototype.containsRefinement = function (
7043
+ query,
7044
+ facetFilters,
7045
+ numericFilters,
7046
+ tagFilters
7047
+ ) {
7048
+ return (
7049
+ query ||
7050
+ facetFilters.length !== 0 ||
7051
+ numericFilters.length !== 0 ||
7052
+ tagFilters.length !== 0
7053
+ );
6079
7054
  };
6080
7055
 
6081
7056
  /**
@@ -6085,17 +7060,23 @@
6085
7060
  * @return {boolean} true if there are refinements on this attribute
6086
7061
  */
6087
7062
  AlgoliaSearchHelper.prototype._hasDisjunctiveRefinements = function (facet) {
6088
- return this.state.disjunctiveRefinements[facet] && this.state.disjunctiveRefinements[facet].length > 0;
7063
+ return (
7064
+ this.state.disjunctiveRefinements[facet] &&
7065
+ this.state.disjunctiveRefinements[facet].length > 0
7066
+ );
6089
7067
  };
7068
+
6090
7069
  AlgoliaSearchHelper.prototype._change = function (event) {
6091
7070
  var state = event.state;
6092
7071
  var isPageReset = event.isPageReset;
7072
+
6093
7073
  if (state !== this.state) {
6094
7074
  this.state = state;
7075
+
6095
7076
  this.emit('change', {
6096
7077
  state: this.state,
6097
7078
  results: this.lastResults,
6098
- isPageReset: isPageReset
7079
+ isPageReset: isPageReset,
6099
7080
  });
6100
7081
  }
6101
7082
  };
@@ -6117,10 +7098,12 @@
6117
7098
  */
6118
7099
  AlgoliaSearchHelper.prototype.setClient = function (newClient) {
6119
7100
  if (this.client === newClient) return this;
7101
+
6120
7102
  if (typeof newClient.addAlgoliaAgent === 'function') {
6121
7103
  newClient.addAlgoliaAgent('JS Helper (' + version + ')');
6122
7104
  }
6123
7105
  this.client = newClient;
7106
+
6124
7107
  return this;
6125
7108
  };
6126
7109
 
@@ -6259,16 +7242,17 @@
6259
7242
  * @type {SearchResults}
6260
7243
  */
6261
7244
  algoliasearchHelper.SearchResults = SearchResults_1;
7245
+
6262
7246
  var algoliasearchHelper_1 = algoliasearchHelper;
6263
7247
 
6264
- function _typeof$5(obj) {
7248
+ function _typeof$4(obj) {
6265
7249
  "@babel/helpers - typeof";
6266
7250
 
6267
- return _typeof$5 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
7251
+ return _typeof$4 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
6268
7252
  return typeof obj;
6269
7253
  } : function (obj) {
6270
7254
  return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
6271
- }, _typeof$5(obj);
7255
+ }, _typeof$4(obj);
6272
7256
  }
6273
7257
  function _toConsumableArray(arr) {
6274
7258
  return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
@@ -6332,14 +7316,14 @@
6332
7316
  }
6333
7317
  function _toPropertyKey$4(arg) {
6334
7318
  var key = _toPrimitive$4(arg, "string");
6335
- return _typeof$5(key) === "symbol" ? key : String(key);
7319
+ return _typeof$4(key) === "symbol" ? key : String(key);
6336
7320
  }
6337
7321
  function _toPrimitive$4(input, hint) {
6338
- if (_typeof$5(input) !== "object" || input === null) return input;
7322
+ if (_typeof$4(input) !== "object" || input === null) return input;
6339
7323
  var prim = input[Symbol.toPrimitive];
6340
7324
  if (prim !== undefined) {
6341
7325
  var res = prim.call(input, hint || "default");
6342
- if (_typeof$5(res) !== "object") return res;
7326
+ if (_typeof$4(res) !== "object") return res;
6343
7327
  throw new TypeError("@@toPrimitive must return a primitive value.");
6344
7328
  }
6345
7329
  return (hint === "string" ? String : Number)(input);
@@ -6540,26 +7524,30 @@
6540
7524
  */
6541
7525
 
6542
7526
  var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
7527
+
6543
7528
  var ReactPropTypesSecret_1 = ReactPropTypesSecret;
6544
7529
 
6545
7530
  function emptyFunction() {}
6546
7531
  function emptyFunctionWithReset() {}
6547
7532
  emptyFunctionWithReset.resetWarningCache = emptyFunction;
6548
- var factoryWithThrowingShims = function () {
7533
+
7534
+ var factoryWithThrowingShims = function() {
6549
7535
  function shim(props, propName, componentName, location, propFullName, secret) {
6550
7536
  if (secret === ReactPropTypesSecret_1) {
6551
7537
  // It is still safe when called from React.
6552
7538
  return;
6553
7539
  }
6554
- var err = new Error('Calling PropTypes validators directly is not supported by the `prop-types` package. ' + 'Use PropTypes.checkPropTypes() to call them. ' + 'Read more at http://fb.me/use-check-prop-types');
7540
+ var err = new Error(
7541
+ 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
7542
+ 'Use PropTypes.checkPropTypes() to call them. ' +
7543
+ 'Read more at http://fb.me/use-check-prop-types'
7544
+ );
6555
7545
  err.name = 'Invariant Violation';
6556
7546
  throw err;
6557
- }
6558
- shim.isRequired = shim;
7547
+ } shim.isRequired = shim;
6559
7548
  function getShim() {
6560
7549
  return shim;
6561
- }
6562
- // Important!
7550
+ } // Important!
6563
7551
  // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
6564
7552
  var ReactPropTypes = {
6565
7553
  array: shim,
@@ -6570,6 +7558,7 @@
6570
7558
  object: shim,
6571
7559
  string: shim,
6572
7560
  symbol: shim,
7561
+
6573
7562
  any: shim,
6574
7563
  arrayOf: getShim,
6575
7564
  element: shim,
@@ -6581,10 +7570,13 @@
6581
7570
  oneOfType: getShim,
6582
7571
  shape: getShim,
6583
7572
  exact: getShim,
7573
+
6584
7574
  checkPropTypes: emptyFunctionWithReset,
6585
7575
  resetWarningCache: emptyFunction
6586
7576
  };
7577
+
6587
7578
  ReactPropTypes.PropTypes = ReactPropTypes;
7579
+
6588
7580
  return ReactPropTypes;
6589
7581
  };
6590
7582
 
@@ -6656,14 +7648,14 @@
6656
7648
  }
6657
7649
  });
6658
7650
 
6659
- function _typeof$6(obj) {
7651
+ function _typeof$5(obj) {
6660
7652
  "@babel/helpers - typeof";
6661
7653
 
6662
- return _typeof$6 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
7654
+ return _typeof$5 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
6663
7655
  return typeof obj;
6664
7656
  } : function (obj) {
6665
7657
  return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
6666
- }, _typeof$6(obj);
7658
+ }, _typeof$5(obj);
6667
7659
  }
6668
7660
  function _defineProperty$5(obj, key, value) {
6669
7661
  key = _toPropertyKey$5(key);
@@ -6681,14 +7673,14 @@
6681
7673
  }
6682
7674
  function _toPropertyKey$5(arg) {
6683
7675
  var key = _toPrimitive$5(arg, "string");
6684
- return _typeof$6(key) === "symbol" ? key : String(key);
7676
+ return _typeof$5(key) === "symbol" ? key : String(key);
6685
7677
  }
6686
7678
  function _toPrimitive$5(input, hint) {
6687
- if (_typeof$6(input) !== "object" || input === null) return input;
7679
+ if (_typeof$5(input) !== "object" || input === null) return input;
6688
7680
  var prim = input[Symbol.toPrimitive];
6689
7681
  if (prim !== undefined) {
6690
7682
  var res = prim.call(input, hint || "default");
6691
- if (_typeof$6(res) !== "object") return res;
7683
+ if (_typeof$5(res) !== "object") return res;
6692
7684
  throw new TypeError("@@toPrimitive must return a primitive value.");
6693
7685
  }
6694
7686
  return (hint === "string" ? String : Number)(input);
@@ -6802,14 +7794,14 @@
6802
7794
  }
6803
7795
  });
6804
7796
 
6805
- function _typeof$7(obj) {
7797
+ function _typeof$6(obj) {
6806
7798
  "@babel/helpers - typeof";
6807
7799
 
6808
- return _typeof$7 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
7800
+ return _typeof$6 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
6809
7801
  return typeof obj;
6810
7802
  } : function (obj) {
6811
7803
  return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
6812
- }, _typeof$7(obj);
7804
+ }, _typeof$6(obj);
6813
7805
  }
6814
7806
  function _defineProperty$6(obj, key, value) {
6815
7807
  key = _toPropertyKey$6(key);
@@ -6827,14 +7819,14 @@
6827
7819
  }
6828
7820
  function _toPropertyKey$6(arg) {
6829
7821
  var key = _toPrimitive$6(arg, "string");
6830
- return _typeof$7(key) === "symbol" ? key : String(key);
7822
+ return _typeof$6(key) === "symbol" ? key : String(key);
6831
7823
  }
6832
7824
  function _toPrimitive$6(input, hint) {
6833
- if (_typeof$7(input) !== "object" || input === null) return input;
7825
+ if (_typeof$6(input) !== "object" || input === null) return input;
6834
7826
  var prim = input[Symbol.toPrimitive];
6835
7827
  if (prim !== undefined) {
6836
7828
  var res = prim.call(input, hint || "default");
6837
- if (_typeof$7(res) !== "object") return res;
7829
+ if (_typeof$6(res) !== "object") return res;
6838
7830
  throw new TypeError("@@toPrimitive must return a primitive value.");
6839
7831
  }
6840
7832
  return (hint === "string" ? String : Number)(input);
@@ -6948,14 +7940,14 @@
6948
7940
  }
6949
7941
  });
6950
7942
 
6951
- function _typeof$8(obj) {
7943
+ function _typeof$7(obj) {
6952
7944
  "@babel/helpers - typeof";
6953
7945
 
6954
- return _typeof$8 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
7946
+ return _typeof$7 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
6955
7947
  return typeof obj;
6956
7948
  } : function (obj) {
6957
7949
  return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
6958
- }, _typeof$8(obj);
7950
+ }, _typeof$7(obj);
6959
7951
  }
6960
7952
  function ownKeys$5(object, enumerableOnly) {
6961
7953
  var keys = Object.keys(object);
@@ -6994,14 +7986,14 @@
6994
7986
  }
6995
7987
  function _toPropertyKey$7(arg) {
6996
7988
  var key = _toPrimitive$7(arg, "string");
6997
- return _typeof$8(key) === "symbol" ? key : String(key);
7989
+ return _typeof$7(key) === "symbol" ? key : String(key);
6998
7990
  }
6999
7991
  function _toPrimitive$7(input, hint) {
7000
- if (_typeof$8(input) !== "object" || input === null) return input;
7992
+ if (_typeof$7(input) !== "object" || input === null) return input;
7001
7993
  var prim = input[Symbol.toPrimitive];
7002
7994
  if (prim !== undefined) {
7003
7995
  var res = prim.call(input, hint || "default");
7004
- if (_typeof$8(res) !== "object") return res;
7996
+ if (_typeof$7(res) !== "object") return res;
7005
7997
  throw new TypeError("@@toPrimitive must return a primitive value.");
7006
7998
  }
7007
7999
  return (hint === "string" ? String : Number)(input);
@@ -7061,14 +8053,14 @@
7061
8053
  }
7062
8054
  });
7063
8055
 
7064
- function _typeof$9(obj) {
8056
+ function _typeof$8(obj) {
7065
8057
  "@babel/helpers - typeof";
7066
8058
 
7067
- return _typeof$9 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
8059
+ return _typeof$8 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
7068
8060
  return typeof obj;
7069
8061
  } : function (obj) {
7070
8062
  return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
7071
- }, _typeof$9(obj);
8063
+ }, _typeof$8(obj);
7072
8064
  }
7073
8065
  var _excluded$2 = ["defaultRefinement"];
7074
8066
  function _defineProperty$8(obj, key, value) {
@@ -7087,14 +8079,14 @@
7087
8079
  }
7088
8080
  function _toPropertyKey$8(arg) {
7089
8081
  var key = _toPrimitive$8(arg, "string");
7090
- return _typeof$9(key) === "symbol" ? key : String(key);
8082
+ return _typeof$8(key) === "symbol" ? key : String(key);
7091
8083
  }
7092
8084
  function _toPrimitive$8(input, hint) {
7093
- if (_typeof$9(input) !== "object" || input === null) return input;
8085
+ if (_typeof$8(input) !== "object" || input === null) return input;
7094
8086
  var prim = input[Symbol.toPrimitive];
7095
8087
  if (prim !== undefined) {
7096
8088
  var res = prim.call(input, hint || "default");
7097
- if (_typeof$9(res) !== "object") return res;
8089
+ if (_typeof$8(res) !== "object") return res;
7098
8090
  throw new TypeError("@@toPrimitive must return a primitive value.");
7099
8091
  }
7100
8092
  return (hint === "string" ? String : Number)(input);
@@ -7299,14 +8291,14 @@
7299
8291
  }
7300
8292
  });
7301
8293
 
7302
- function _typeof$a(obj) {
8294
+ function _typeof$9(obj) {
7303
8295
  "@babel/helpers - typeof";
7304
8296
 
7305
- return _typeof$a = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
8297
+ return _typeof$9 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
7306
8298
  return typeof obj;
7307
8299
  } : function (obj) {
7308
8300
  return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
7309
- }, _typeof$a(obj);
8301
+ }, _typeof$9(obj);
7310
8302
  }
7311
8303
  function ownKeys$6(object, enumerableOnly) {
7312
8304
  var keys = Object.keys(object);
@@ -7345,14 +8337,14 @@
7345
8337
  }
7346
8338
  function _toPropertyKey$9(arg) {
7347
8339
  var key = _toPrimitive$9(arg, "string");
7348
- return _typeof$a(key) === "symbol" ? key : String(key);
8340
+ return _typeof$9(key) === "symbol" ? key : String(key);
7349
8341
  }
7350
8342
  function _toPrimitive$9(input, hint) {
7351
- if (_typeof$a(input) !== "object" || input === null) return input;
8343
+ if (_typeof$9(input) !== "object" || input === null) return input;
7352
8344
  var prim = input[Symbol.toPrimitive];
7353
8345
  if (prim !== undefined) {
7354
8346
  var res = prim.call(input, hint || "default");
7355
- if (_typeof$a(res) !== "object") return res;
8347
+ if (_typeof$9(res) !== "object") return res;
7356
8348
  throw new TypeError("@@toPrimitive must return a primitive value.");
7357
8349
  }
7358
8350
  return (hint === "string" ? String : Number)(input);
@@ -7767,14 +8759,14 @@
7767
8759
  }
7768
8760
  });
7769
8761
 
7770
- function _typeof$b(obj) {
8762
+ function _typeof$a(obj) {
7771
8763
  "@babel/helpers - typeof";
7772
8764
 
7773
- return _typeof$b = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
8765
+ return _typeof$a = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
7774
8766
  return typeof obj;
7775
8767
  } : function (obj) {
7776
8768
  return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
7777
- }, _typeof$b(obj);
8769
+ }, _typeof$a(obj);
7778
8770
  }
7779
8771
  function ownKeys$7(object, enumerableOnly) {
7780
8772
  var keys = Object.keys(object);
@@ -7813,14 +8805,14 @@
7813
8805
  }
7814
8806
  function _toPropertyKey$a(arg) {
7815
8807
  var key = _toPrimitive$a(arg, "string");
7816
- return _typeof$b(key) === "symbol" ? key : String(key);
8808
+ return _typeof$a(key) === "symbol" ? key : String(key);
7817
8809
  }
7818
8810
  function _toPrimitive$a(input, hint) {
7819
- if (_typeof$b(input) !== "object" || input === null) return input;
8811
+ if (_typeof$a(input) !== "object" || input === null) return input;
7820
8812
  var prim = input[Symbol.toPrimitive];
7821
8813
  if (prim !== undefined) {
7822
8814
  var res = prim.call(input, hint || "default");
7823
- if (_typeof$b(res) !== "object") return res;
8815
+ if (_typeof$a(res) !== "object") return res;
7824
8816
  throw new TypeError("@@toPrimitive must return a primitive value.");
7825
8817
  }
7826
8818
  return (hint === "string" ? String : Number)(input);
@@ -7906,14 +8898,14 @@
7906
8898
  }
7907
8899
  });
7908
8900
 
7909
- function _typeof$c(obj) {
8901
+ function _typeof$b(obj) {
7910
8902
  "@babel/helpers - typeof";
7911
8903
 
7912
- return _typeof$c = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
8904
+ return _typeof$b = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
7913
8905
  return typeof obj;
7914
8906
  } : function (obj) {
7915
8907
  return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
7916
- }, _typeof$c(obj);
8908
+ }, _typeof$b(obj);
7917
8909
  }
7918
8910
  var _excluded$3 = ["page"];
7919
8911
  function _defineProperty$b(obj, key, value) {
@@ -7932,14 +8924,14 @@
7932
8924
  }
7933
8925
  function _toPropertyKey$b(arg) {
7934
8926
  var key = _toPrimitive$b(arg, "string");
7935
- return _typeof$c(key) === "symbol" ? key : String(key);
8927
+ return _typeof$b(key) === "symbol" ? key : String(key);
7936
8928
  }
7937
8929
  function _toPrimitive$b(input, hint) {
7938
- if (_typeof$c(input) !== "object" || input === null) return input;
8930
+ if (_typeof$b(input) !== "object" || input === null) return input;
7939
8931
  var prim = input[Symbol.toPrimitive];
7940
8932
  if (prim !== undefined) {
7941
8933
  var res = prim.call(input, hint || "default");
7942
- if (_typeof$c(res) !== "object") return res;
8934
+ if (_typeof$b(res) !== "object") return res;
7943
8935
  throw new TypeError("@@toPrimitive must return a primitive value.");
7944
8936
  }
7945
8937
  return (hint === "string" ? String : Number)(input);
@@ -8126,14 +9118,14 @@
8126
9118
  }
8127
9119
  });
8128
9120
 
8129
- function _typeof$d(obj) {
9121
+ function _typeof$c(obj) {
8130
9122
  "@babel/helpers - typeof";
8131
9123
 
8132
- return _typeof$d = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
9124
+ return _typeof$c = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
8133
9125
  return typeof obj;
8134
9126
  } : function (obj) {
8135
9127
  return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
8136
- }, _typeof$d(obj);
9128
+ }, _typeof$c(obj);
8137
9129
  }
8138
9130
  function _defineProperty$c(obj, key, value) {
8139
9131
  key = _toPropertyKey$c(key);
@@ -8151,14 +9143,14 @@
8151
9143
  }
8152
9144
  function _toPropertyKey$c(arg) {
8153
9145
  var key = _toPrimitive$c(arg, "string");
8154
- return _typeof$d(key) === "symbol" ? key : String(key);
9146
+ return _typeof$c(key) === "symbol" ? key : String(key);
8155
9147
  }
8156
9148
  function _toPrimitive$c(input, hint) {
8157
- if (_typeof$d(input) !== "object" || input === null) return input;
9149
+ if (_typeof$c(input) !== "object" || input === null) return input;
8158
9150
  var prim = input[Symbol.toPrimitive];
8159
9151
  if (prim !== undefined) {
8160
9152
  var res = prim.call(input, hint || "default");
8161
- if (_typeof$d(res) !== "object") return res;
9153
+ if (_typeof$c(res) !== "object") return res;
8162
9154
  throw new TypeError("@@toPrimitive must return a primitive value.");
8163
9155
  }
8164
9156
  return (hint === "string" ? String : Number)(input);
@@ -8369,14 +9361,14 @@
8369
9361
  }
8370
9362
  });
8371
9363
 
8372
- function _typeof$e(obj) {
9364
+ function _typeof$d(obj) {
8373
9365
  "@babel/helpers - typeof";
8374
9366
 
8375
- return _typeof$e = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
9367
+ return _typeof$d = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
8376
9368
  return typeof obj;
8377
9369
  } : function (obj) {
8378
9370
  return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
8379
- }, _typeof$e(obj);
9371
+ }, _typeof$d(obj);
8380
9372
  }
8381
9373
  function _defineProperty$d(obj, key, value) {
8382
9374
  key = _toPropertyKey$d(key);
@@ -8394,14 +9386,14 @@
8394
9386
  }
8395
9387
  function _toPropertyKey$d(arg) {
8396
9388
  var key = _toPrimitive$d(arg, "string");
8397
- return _typeof$e(key) === "symbol" ? key : String(key);
9389
+ return _typeof$d(key) === "symbol" ? key : String(key);
8398
9390
  }
8399
9391
  function _toPrimitive$d(input, hint) {
8400
- if (_typeof$e(input) !== "object" || input === null) return input;
9392
+ if (_typeof$d(input) !== "object" || input === null) return input;
8401
9393
  var prim = input[Symbol.toPrimitive];
8402
9394
  if (prim !== undefined) {
8403
9395
  var res = prim.call(input, hint || "default");
8404
- if (_typeof$e(res) !== "object") return res;
9396
+ if (_typeof$d(res) !== "object") return res;
8405
9397
  throw new TypeError("@@toPrimitive must return a primitive value.");
8406
9398
  }
8407
9399
  return (hint === "string" ? String : Number)(input);
@@ -8644,14 +9636,14 @@
8644
9636
  }
8645
9637
  });
8646
9638
 
8647
- function _typeof$f(obj) {
9639
+ function _typeof$e(obj) {
8648
9640
  "@babel/helpers - typeof";
8649
9641
 
8650
- return _typeof$f = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
9642
+ return _typeof$e = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
8651
9643
  return typeof obj;
8652
9644
  } : function (obj) {
8653
9645
  return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
8654
- }, _typeof$f(obj);
9646
+ }, _typeof$e(obj);
8655
9647
  }
8656
9648
  function _defineProperty$e(obj, key, value) {
8657
9649
  key = _toPropertyKey$e(key);
@@ -8669,14 +9661,14 @@
8669
9661
  }
8670
9662
  function _toPropertyKey$e(arg) {
8671
9663
  var key = _toPrimitive$e(arg, "string");
8672
- return _typeof$f(key) === "symbol" ? key : String(key);
9664
+ return _typeof$e(key) === "symbol" ? key : String(key);
8673
9665
  }
8674
9666
  function _toPrimitive$e(input, hint) {
8675
- if (_typeof$f(input) !== "object" || input === null) return input;
9667
+ if (_typeof$e(input) !== "object" || input === null) return input;
8676
9668
  var prim = input[Symbol.toPrimitive];
8677
9669
  if (prim !== undefined) {
8678
9670
  var res = prim.call(input, hint || "default");
8679
- if (_typeof$f(res) !== "object") return res;
9671
+ if (_typeof$e(res) !== "object") return res;
8680
9672
  throw new TypeError("@@toPrimitive must return a primitive value.");
8681
9673
  }
8682
9674
  return (hint === "string" ? String : Number)(input);
@@ -8781,14 +9773,14 @@
8781
9773
  }
8782
9774
  });
8783
9775
 
8784
- function _typeof$g(obj) {
9776
+ function _typeof$f(obj) {
8785
9777
  "@babel/helpers - typeof";
8786
9778
 
8787
- return _typeof$g = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
9779
+ return _typeof$f = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
8788
9780
  return typeof obj;
8789
9781
  } : function (obj) {
8790
9782
  return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
8791
- }, _typeof$g(obj);
9783
+ }, _typeof$f(obj);
8792
9784
  }
8793
9785
  function _defineProperty$f(obj, key, value) {
8794
9786
  key = _toPropertyKey$f(key);
@@ -8806,14 +9798,14 @@
8806
9798
  }
8807
9799
  function _toPropertyKey$f(arg) {
8808
9800
  var key = _toPrimitive$f(arg, "string");
8809
- return _typeof$g(key) === "symbol" ? key : String(key);
9801
+ return _typeof$f(key) === "symbol" ? key : String(key);
8810
9802
  }
8811
9803
  function _toPrimitive$f(input, hint) {
8812
- if (_typeof$g(input) !== "object" || input === null) return input;
9804
+ if (_typeof$f(input) !== "object" || input === null) return input;
8813
9805
  var prim = input[Symbol.toPrimitive];
8814
9806
  if (prim !== undefined) {
8815
9807
  var res = prim.call(input, hint || "default");
8816
- if (_typeof$g(res) !== "object") return res;
9808
+ if (_typeof$f(res) !== "object") return res;
8817
9809
  throw new TypeError("@@toPrimitive must return a primitive value.");
8818
9810
  }
8819
9811
  return (hint === "string" ? String : Number)(input);
@@ -9092,14 +10084,14 @@
9092
10084
  }
9093
10085
  });
9094
10086
 
9095
- function _typeof$h(obj) {
10087
+ function _typeof$g(obj) {
9096
10088
  "@babel/helpers - typeof";
9097
10089
 
9098
- return _typeof$h = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
10090
+ return _typeof$g = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
9099
10091
  return typeof obj;
9100
10092
  } : function (obj) {
9101
10093
  return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
9102
- }, _typeof$h(obj);
10094
+ }, _typeof$g(obj);
9103
10095
  }
9104
10096
  function _defineProperty$g(obj, key, value) {
9105
10097
  key = _toPropertyKey$g(key);
@@ -9117,14 +10109,14 @@
9117
10109
  }
9118
10110
  function _toPropertyKey$g(arg) {
9119
10111
  var key = _toPrimitive$g(arg, "string");
9120
- return _typeof$h(key) === "symbol" ? key : String(key);
10112
+ return _typeof$g(key) === "symbol" ? key : String(key);
9121
10113
  }
9122
10114
  function _toPrimitive$g(input, hint) {
9123
- if (_typeof$h(input) !== "object" || input === null) return input;
10115
+ if (_typeof$g(input) !== "object" || input === null) return input;
9124
10116
  var prim = input[Symbol.toPrimitive];
9125
10117
  if (prim !== undefined) {
9126
10118
  var res = prim.call(input, hint || "default");
9127
- if (_typeof$h(res) !== "object") return res;
10119
+ if (_typeof$g(res) !== "object") return res;
9128
10120
  throw new TypeError("@@toPrimitive must return a primitive value.");
9129
10121
  }
9130
10122
  return (hint === "string" ? String : Number)(input);
@@ -9416,14 +10408,14 @@
9416
10408
  }
9417
10409
  });
9418
10410
 
9419
- function _typeof$i(obj) {
10411
+ function _typeof$h(obj) {
9420
10412
  "@babel/helpers - typeof";
9421
10413
 
9422
- return _typeof$i = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
10414
+ return _typeof$h = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
9423
10415
  return typeof obj;
9424
10416
  } : function (obj) {
9425
10417
  return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
9426
- }, _typeof$i(obj);
10418
+ }, _typeof$h(obj);
9427
10419
  }
9428
10420
  function _defineProperty$h(obj, key, value) {
9429
10421
  key = _toPropertyKey$h(key);
@@ -9441,14 +10433,14 @@
9441
10433
  }
9442
10434
  function _toPropertyKey$h(arg) {
9443
10435
  var key = _toPrimitive$h(arg, "string");
9444
- return _typeof$i(key) === "symbol" ? key : String(key);
10436
+ return _typeof$h(key) === "symbol" ? key : String(key);
9445
10437
  }
9446
10438
  function _toPrimitive$h(input, hint) {
9447
- if (_typeof$i(input) !== "object" || input === null) return input;
10439
+ if (_typeof$h(input) !== "object" || input === null) return input;
9448
10440
  var prim = input[Symbol.toPrimitive];
9449
10441
  if (prim !== undefined) {
9450
10442
  var res = prim.call(input, hint || "default");
9451
- if (_typeof$i(res) !== "object") return res;
10443
+ if (_typeof$h(res) !== "object") return res;
9452
10444
  throw new TypeError("@@toPrimitive must return a primitive value.");
9453
10445
  }
9454
10446
  return (hint === "string" ? String : Number)(input);
@@ -9543,14 +10535,14 @@
9543
10535
  }
9544
10536
  });
9545
10537
 
9546
- function _typeof$j(obj) {
10538
+ function _typeof$i(obj) {
9547
10539
  "@babel/helpers - typeof";
9548
10540
 
9549
- return _typeof$j = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
10541
+ return _typeof$i = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
9550
10542
  return typeof obj;
9551
10543
  } : function (obj) {
9552
10544
  return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
9553
- }, _typeof$j(obj);
10545
+ }, _typeof$i(obj);
9554
10546
  }
9555
10547
  function _defineProperty$i(obj, key, value) {
9556
10548
  key = _toPropertyKey$i(key);
@@ -9568,14 +10560,14 @@
9568
10560
  }
9569
10561
  function _toPropertyKey$i(arg) {
9570
10562
  var key = _toPrimitive$i(arg, "string");
9571
- return _typeof$j(key) === "symbol" ? key : String(key);
10563
+ return _typeof$i(key) === "symbol" ? key : String(key);
9572
10564
  }
9573
10565
  function _toPrimitive$i(input, hint) {
9574
- if (_typeof$j(input) !== "object" || input === null) return input;
10566
+ if (_typeof$i(input) !== "object" || input === null) return input;
9575
10567
  var prim = input[Symbol.toPrimitive];
9576
10568
  if (prim !== undefined) {
9577
10569
  var res = prim.call(input, hint || "default");
9578
- if (_typeof$j(res) !== "object") return res;
10570
+ if (_typeof$i(res) !== "object") return res;
9579
10571
  throw new TypeError("@@toPrimitive must return a primitive value.");
9580
10572
  }
9581
10573
  return (hint === "string" ? String : Number)(input);
@@ -9623,14 +10615,14 @@
9623
10615
  }
9624
10616
  });
9625
10617
 
9626
- function _typeof$k(obj) {
10618
+ function _typeof$j(obj) {
9627
10619
  "@babel/helpers - typeof";
9628
10620
 
9629
- return _typeof$k = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
10621
+ return _typeof$j = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
9630
10622
  return typeof obj;
9631
10623
  } : function (obj) {
9632
10624
  return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
9633
- }, _typeof$k(obj);
10625
+ }, _typeof$j(obj);
9634
10626
  }
9635
10627
  function ownKeys$8(object, enumerableOnly) {
9636
10628
  var keys = Object.keys(object);
@@ -9669,14 +10661,14 @@
9669
10661
  }
9670
10662
  function _toPropertyKey$j(arg) {
9671
10663
  var key = _toPrimitive$j(arg, "string");
9672
- return _typeof$k(key) === "symbol" ? key : String(key);
10664
+ return _typeof$j(key) === "symbol" ? key : String(key);
9673
10665
  }
9674
10666
  function _toPrimitive$j(input, hint) {
9675
- if (_typeof$k(input) !== "object" || input === null) return input;
10667
+ if (_typeof$j(input) !== "object" || input === null) return input;
9676
10668
  var prim = input[Symbol.toPrimitive];
9677
10669
  if (prim !== undefined) {
9678
10670
  var res = prim.call(input, hint || "default");
9679
- if (_typeof$k(res) !== "object") return res;
10671
+ if (_typeof$j(res) !== "object") return res;
9680
10672
  throw new TypeError("@@toPrimitive must return a primitive value.");
9681
10673
  }
9682
10674
  return (hint === "string" ? String : Number)(input);
@@ -9864,14 +10856,14 @@
9864
10856
  }
9865
10857
  });
9866
10858
 
9867
- function _typeof$l(obj) {
10859
+ function _typeof$k(obj) {
9868
10860
  "@babel/helpers - typeof";
9869
10861
 
9870
- return _typeof$l = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
10862
+ return _typeof$k = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
9871
10863
  return typeof obj;
9872
10864
  } : function (obj) {
9873
10865
  return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
9874
- }, _typeof$l(obj);
10866
+ }, _typeof$k(obj);
9875
10867
  }
9876
10868
  function _defineProperty$k(obj, key, value) {
9877
10869
  key = _toPropertyKey$k(key);
@@ -9889,14 +10881,14 @@
9889
10881
  }
9890
10882
  function _toPropertyKey$k(arg) {
9891
10883
  var key = _toPrimitive$k(arg, "string");
9892
- return _typeof$l(key) === "symbol" ? key : String(key);
10884
+ return _typeof$k(key) === "symbol" ? key : String(key);
9893
10885
  }
9894
10886
  function _toPrimitive$k(input, hint) {
9895
- if (_typeof$l(input) !== "object" || input === null) return input;
10887
+ if (_typeof$k(input) !== "object" || input === null) return input;
9896
10888
  var prim = input[Symbol.toPrimitive];
9897
10889
  if (prim !== undefined) {
9898
10890
  var res = prim.call(input, hint || "default");
9899
- if (_typeof$l(res) !== "object") return res;
10891
+ if (_typeof$k(res) !== "object") return res;
9900
10892
  throw new TypeError("@@toPrimitive must return a primitive value.");
9901
10893
  }
9902
10894
  return (hint === "string" ? String : Number)(input);
@@ -10049,14 +11041,14 @@
10049
11041
  }
10050
11042
  });
10051
11043
 
10052
- function _typeof$m(obj) {
11044
+ function _typeof$l(obj) {
10053
11045
  "@babel/helpers - typeof";
10054
11046
 
10055
- return _typeof$m = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
11047
+ return _typeof$l = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
10056
11048
  return typeof obj;
10057
11049
  } : function (obj) {
10058
11050
  return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
10059
- }, _typeof$m(obj);
11051
+ }, _typeof$l(obj);
10060
11052
  }
10061
11053
  function ownKeys$9(object, enumerableOnly) {
10062
11054
  var keys = Object.keys(object);
@@ -10095,14 +11087,14 @@
10095
11087
  }
10096
11088
  function _toPropertyKey$l(arg) {
10097
11089
  var key = _toPrimitive$l(arg, "string");
10098
- return _typeof$m(key) === "symbol" ? key : String(key);
11090
+ return _typeof$l(key) === "symbol" ? key : String(key);
10099
11091
  }
10100
11092
  function _toPrimitive$l(input, hint) {
10101
- if (_typeof$m(input) !== "object" || input === null) return input;
11093
+ if (_typeof$l(input) !== "object" || input === null) return input;
10102
11094
  var prim = input[Symbol.toPrimitive];
10103
11095
  if (prim !== undefined) {
10104
11096
  var res = prim.call(input, hint || "default");
10105
- if (_typeof$m(res) !== "object") return res;
11097
+ if (_typeof$l(res) !== "object") return res;
10106
11098
  throw new TypeError("@@toPrimitive must return a primitive value.");
10107
11099
  }
10108
11100
  return (hint === "string" ? String : Number)(input);