Socket
Socket
Sign inDemoInstall

@meilisearch/instant-meilisearch

Package Overview
Dependencies
Maintainers
6
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@meilisearch/instant-meilisearch - npm Package Compare versions

Comparing version 0.13.2 to 0.13.3-prototype-search-for-facet-values.0

57

dist/instant-meilisearch.cjs.js

@@ -811,2 +811,17 @@ 'use strict';

}
// TODO: avoid code duplication
/**
* @param {AlgoliaMultipleQueriesQuery} searchRequest
* @param {Context} options
* @returns {SearchContext}
*/
function createFacetSearchContext(searchRequest, options) {
// Split index name and possible sorting rules
var _a = searchRequest.indexName.split(':'), indexUid = _a[0], sortByArray = _a.slice(1);
var instantSearchParams = searchRequest.params;
var paginationState = createPaginationState(options.finitePagination, instantSearchParams === null || instantSearchParams === void 0 ? void 0 : instantSearchParams.hitsPerPage, instantSearchParams === null || instantSearchParams === void 0 ? void 0 : instantSearchParams.page);
var sortState = createSortState(sortByArray.join(':'));
var searchContext = __assign(__assign(__assign({}, options), instantSearchParams), { sort: sortState, indexUid: indexUid, pagination: paginationState, placeholderSearch: options.placeholderSearch !== false, keepZeroFacets: !!options.keepZeroFacets });
return searchContext;
}

@@ -889,3 +904,3 @@ /**

var PACKAGE_VERSION = '0.13.2';
var PACKAGE_VERSION = '0.13.3-prototype-search-for-facet-values.0';

@@ -977,11 +992,39 @@ var constructClientAgents = function (clientAgents) {

},
searchForFacetValues: function (_) {
searchForFacetValues: function (requests) {
return __awaiter(this, void 0, void 0, function () {
var results, _i, requests_1, request, searchContext, meilisearchSearchQuery, index, meilisearchRequest, meilisearchResponse, facetHits, result;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, new Promise(function (resolve, reject) {
reject(new Error('SearchForFacetValues is not compatible with Meilisearch'));
resolve([]); // added here to avoid compilation error
})];
case 1: return [2 /*return*/, _a.sent()];
case 0:
console.log(requests);
results = [];
_i = 0, requests_1 = requests;
_a.label = 1;
case 1:
if (!(_i < requests_1.length)) return [3 /*break*/, 4];
request = requests_1[_i];
searchContext = createFacetSearchContext(request, instantMeiliSearchOptions);
meilisearchSearchQuery = adaptSearchParams(searchContext);
index = request.indexName;
meilisearchRequest = __assign(__assign({}, meilisearchSearchQuery), { facetQuery: request.params.facetQuery, facetName: request.params.facetName });
delete meilisearchRequest.indexUid;
return [4 /*yield*/, meilisearchClient
.index(index)
.searchForFacetValues(meilisearchRequest)];
case 2:
meilisearchResponse = _a.sent();
facetHits = meilisearchResponse.facetHits.map(function (facetHit) { return (__assign(__assign({}, facetHit), {
// not currently supported
highlighted: facetHit.value })); });
result = {
facetHits: facetHits,
exhaustiveFacetsCount: false,
processingTimeMS: meilisearchResponse.processingTimeMs
};
results.push(result);
_a.label = 3;
case 3:
_i++;
return [3 /*break*/, 1];
case 4: return [2 /*return*/, results];
}

@@ -988,0 +1031,0 @@ });

2

dist/instant-meilisearch.cjs.min.js

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("meilisearch"),e=function(){return e=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},e.apply(this,arguments)};function r(t,e,r,n){return new(r||(r=Promise))((function(i,a){function o(t){try{c(n.next(t))}catch(t){a(t)}}function u(t){try{c(n.throw(t))}catch(t){a(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,u)}c((n=n.apply(t,e||[])).next())}))}function n(t,e){var r,n,i,a,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(c){return function(u){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(o=0)),o;)try{if(r=1,n&&(i=2&u[0]?n.return:u[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,u[1])).done)return i;switch(n=0,i&&(u=[2&u[0],i.value]),u[0]){case 0:case 1:i=u;break;case 4:return o.label++,{value:u[1],done:!1};case 5:o.label++,n=u[1],u=[0];continue;case 7:u=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==u[0]&&2!==u[0])){o=0;continue}if(3===u[0]&&(!i||u[1]>i[0]&&u[1]<i[3])){o.label=u[1];break}if(6===u[0]&&o.label<i[1]){o.label=i[1],i=u;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(u);break}i[2]&&o.ops.pop(),o.trys.pop();continue}u=e.call(t,o)}catch(t){u=[6,t],n=0}finally{r=i=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}}function i(t,e,r){if(r||2===arguments.length)for(var n,i=0,a=e.length;i<a;i++)!n&&i in e||(n||(n=Array.prototype.slice.call(e,0,i)),n[i]=e[i]);return t.concat(n||Array.prototype.slice.call(e))}function a(t){return"object"==typeof t&&!Array.isArray(t)&&null!==t}function o(t){return t.replace(/(.*):(.*)/i,'"$1"="$2"')}function u(t){return"string"==typeof t?o(t):Array.isArray(t)?t.map((function(t){return Array.isArray(t)?t.map((function(t){return o(t)})).filter((function(t){return t})):o(t)})).filter((function(t){return t})):[]}function c(t){return""===t?[]:"string"==typeof t?[t]:t}function s(t,e,r){return function(t,e,r){var n=r.trim(),a=c(t),o=c(e);return i(i(i([],a,!0),o,!0),[n],!1).filter((function(t){return Array.isArray(t)?t.length:t}))}(u(r||[]),u(e||[]),t||"")}function l(t){var e={},r=t.facets,n=t.attributesToSnippet,i=t.snippetEllipsisText,a=t.attributesToRetrieve,o=t.attributesToHighlight,u=t.highlightPreTag,c=t.highlightPostTag,l=t.placeholderSearch,f=t.query,d=t.sort,g=t.pagination,h=t.matchingStrategy,p=t.filters,v=t.numericFilters,y=t.facetFilters,m=t.indexUid,P=s(p,v,y);return{getParams:function(){return e},addQuery:function(){e.q=f},addIndexUid:function(){e.indexUid=m},addFacets:function(){Array.isArray(r)?e.facets=r:"string"==typeof r&&(e.facets=[r])},addAttributesToCrop:function(){n&&(e.attributesToCrop=n)},addCropMarker:function(){null!=i&&(e.cropMarker=i)},addAttributesToRetrieve:function(){a&&(e.attributesToRetrieve=a)},addFilters:function(){P.length&&(e.filter=P)},addAttributesToHighlight:function(){e.attributesToHighlight=o||["*"]},addPreTag:function(){e.highlightPreTag=u||"__ais-highlight__"},addPostTag:function(){e.highlightPostTag=c||"__/ais-highlight__"},addPagination:function(){var t=function(t,e,r){return!!(r||e||t&&0!==t.length)}(P,f,l);if(g.finite){var r=function(t,e){var r=t.page,n=t.hitsPerPage;return e?{hitsPerPage:n,page:r+1}:{hitsPerPage:0,page:r+1}}(g,t),n=r.hitsPerPage,i=r.page;e.hitsPerPage=n,e.page=i}else{var a=function(t,e){var r=t.page,n=t.hitsPerPage;return e?{limit:n+1,offset:r*n}:{limit:0,offset:0}}(g,t),o=a.limit,u=a.offset;e.limit=o,e.offset=u}},addSort:function(){(null==d?void 0:d.length)&&(e.sort=Array.isArray(d)?d:[d])},addGeoSearchFilter:function(){var r=function(t){var e,r,n,i=t.insideBoundingBox,a=t.aroundLatLng,o=t.aroundRadius,u=t.minimumAroundRadius;if(a){var c=a.split(",").map((function(t){return Number.parseFloat(t).toFixed(5)}));e=[h=c[0],p=c[1]]}if(null==o&&null==u||("all"===o?console.warn("instant-meilisearch is not compatible with the `all` value on the aroundRadius parameter"):r=null!=o?o:u),i&&"string"==typeof i){var s=i.split(",").map((function(t){return parseFloat(t)})),l=s[0],f=s[1],d=s[2],g=s[3];n="_geoBoundingBox([".concat(l,", ").concat(f,"], [").concat(d,", ").concat(g,"])")}else if(null!=e&&null!=r){var h=e[0],p=e[1];n="_geoRadius(".concat(h,", ").concat(p,", ").concat(r,")")}return n}({insideBoundingBox:t.insideBoundingBox,aroundLatLng:t.aroundLatLng,aroundRadius:t.aroundRadius,minimumAroundRadius:t.minimumAroundRadius});r&&(e.filter?e.filter.unshift(r):e.filter=[r])},addMatchingStrategy:function(){h&&(e.matchingStrategy=h)}}}function f(t){var e=l(t);return e.addQuery(),e.addIndexUid(),e.addFacets(),e.addAttributesToHighlight(),e.addPreTag(),e.addPostTag(),e.addAttributesToRetrieve(),e.addAttributesToCrop(),e.addCropMarker(),e.addPagination(),e.addFilters(),e.addSort(),e.addGeoSearchFilter(),e.addMatchingStrategy(),e.getParams()}function d(t){return"string"==typeof t?t:void 0===t?JSON.stringify(null):JSON.stringify(t)}function g(t){return Array.isArray(t)?t.map((function(t){return g(t)})):a(t)?Object.keys(t).reduce((function(e,r){return e[r]=g(t[r]),e}),{}):{value:d(t)}}function h(t){if(!t)return{};var e=g(t);return{_highlightResult:e,_snippetResult:e}}function p(t,e){var r=t.hits,n=t.pagination.hitsPerPage,i=e.finitePagination,a=e.primaryKey;!i&&r.length>n&&r.splice(r.length-1,1);var o=r.map((function(t){if(Object.keys(t).length>0){var e=t._formatted;t._matchesPosition;var r=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]])}return r}(t,["_formatted","_matchesPosition"]),n=Object.assign(r,h(e));return a&&(n.objectID=t[a]),n}return t}));return o=function(t){for(var e,r=0;r<t.length;r++){var n="".concat(r+1e6*Math.random());t[r]._geo&&(t[r]._geoloc=t[r]._geo,t[r].objectID=n),(null===(e=t[r]._formatted)||void 0===e?void 0:e._geo)&&(t[r]._formatted._geoloc=t[r]._formatted._geo,t[r]._formatted.objectID=n)}return t}(o),o}function v(t){return Object.keys(t).reduce((function(r,n){return r[n]=e(e({},t[n]),{avg:0,sum:0}),r}),{})}function y(t,e,r){var n=t.map((function(t){return function(t,e,r){var n=t.processingTimeMs,i=t.query,a=t.indexUid,o=t.facetDistribution,u=void 0===o?{}:o,c=t.facetStats,s=void 0===c?{}:c,l=Object.keys(u),f=function(t,e){var r=e.hitsPerPage,n=e.page,i=function(t,e){if(null!=t.totalPages)return t.totalPages;if(0===e)return 0;var r=t.limit,n=void 0===r?20:r,i=t.offset;return(void 0===i?0:i)/e+1+(t.hits.length>=n?1:0)}(t,r);return{page:n,nbPages:i,hitsPerPage:r}}(t,t.pagination),d=f.hitsPerPage,g=f.page,h=f.nbPages,y=p(t,r),m=function(t){var e=t.hitsPerPage,r=void 0===e?0:e,n=t.totalPages,i=void 0===n?0:n,a=t.estimatedTotalHits,o=t.totalHits;return null!=a?a:null!=o?o:r*i}(t),P=function(t,e,r,n){return t?function(t,e,r){for(var n=function(t){return t?"string"==typeof t?[t]:t:[]}(t),i={},a=0,o=n;a<o.length;a++){var u=o[a];for(var c in e[u])i[u]||(i[u]=r[u]||{}),i[u][c]?i[u][c]=r[u][c]:i[u][c]=0}return i}(e,r,n=n||{}):n}(r.keepZeroFacets,l,e,u);return{index:a,hitsPerPage:d,page:g,facets:P,nbPages:h,nbHits:m,processingTimeMS:n,query:i,hits:y,params:"",exhaustiveNbHits:!1,facets_stats:v(s)}}(t,e[t.indexUid],r)}));return{results:n}}function m(t,r){var n,i,a,o=t.indexName.split(":"),u=o[0],c=o.slice(1),s=t.query,l=t.params,f=(n=r.finitePagination,i=null==l?void 0:l.hitsPerPage,a=null==l?void 0:l.page,{hitsPerPage:void 0===i?20:i,page:a||0,finite:!!n}),d=c.join(":").split(",").map((function(t){return t.trim()})).filter((function(t){return!!t}));return e(e(e(e({},r),{query:s}),l),{sort:d,indexUid:u,pagination:f,placeholderSearch:!1!==r.placeholderSearch,keepZeroFacets:!!r.keepZeroFacets})}function P(t){void 0===t&&(t={});var e=t;return{getEntry:function(t){if(e[t])try{return JSON.parse(e[t])}catch(t){return}},formatKey:function(t){return t.reduce((function(t,e){return t+JSON.stringify(e)}),"")},setEntry:function(t,r){e[t]=JSON.stringify(r)},clearCache:function(){e={}}}}function b(t){var r=l(e(e({},t),{placeholderSearch:!0,query:""}));return r.addFacets(),r.addIndexUid(),r.addPagination(),r.getParams()}function w(t,e,i){return r(this,void 0,void 0,(function(){var r,a,o,u,c,s;return n(this,(function(n){switch(n.label){case 0:return l="indexUid",f=[],r=function(t){return!f.includes(t[l])&&(f.push(t[l]),!0)},a=e.filter(r).filter((function(t){var e=t.indexUid;return!Object.keys(i).includes(e)})),0===a.length?[2,i]:[4,t.multiSearch(a,[])];case 1:for(o=n.sent(),u=0,c=o;u<c.length;u++)s=c[u],i[s.indexUid]=s.facetDistribution||{};return[2,i]}var l,f}))}))}var S;exports.MatchingStrategies=void 0,(S=exports.MatchingStrategies||(exports.MatchingStrategies={})).ALL="all",S.LAST="last",exports.instantMeiliSearch=function(i,o,u){void 0===o&&(o=""),void 0===u&&(u={}),function(t,e,r){var n=r.requestConfig,i=r.httpClient;if("string"!=typeof t)throw new TypeError("Provided hostUrl value (1st parameter) is not a string, expected string");if("string"!=typeof e&&"function"!=typeof e)throw new TypeError("Provided apiKey value (2nd parameter) is not a string or a function, expected string or function");if(void 0!==n&&!a(n))throw new TypeError("Provided requestConfig should be an object");if(i&&"function"!=typeof i)throw new TypeError("Provided custom httpClient should be a function")}(i,o,u);var c={host:i,apiKey:o=function(t){if("function"==typeof t){var e=t();if("string"!=typeof e)throw new TypeError("Provided apiKey function (2nd parameter) did not return a string, expected string");return e}return t}(o),clientAgents:function(t){void 0===t&&(t=[]);var e="Meilisearch instant-meilisearch (v".concat("0.13.2",")");return t.concat(e)}(u.clientAgents)};void 0!==u.httpClient&&(c.httpClient=u.httpClient),void 0!==u.requestConfig&&(c.requestConfig=u.requestConfig);var s,l,d,g=new t.MeiliSearch(c),h=P(),p=(s=g,l=h,{multiSearch:function(t,i){return r(this,void 0,void 0,(function(){var r,a,o,u;return n(this,(function(n){switch(n.label){case 0:return r=l.formatKey([t]),(a=l.getEntry(r))?[2,a]:[4,s.multiSearch({queries:t})];case 1:return o=n.sent(),u=o.results.map((function(t,r){return e(e({},t),{pagination:i[r]||{}})})),l.setEntry(r,u),[2,u]}}))}))}}),v={},S=(d=u,e(e({},{placeholderSearch:!0,keepZeroFacets:!1,clientAgents:[],finitePagination:!1}),d));return{clearCache:function(){return h.clearCache()},search:function(t){return r(this,void 0,void 0,(function(){var e,r,i,a,o,c,s,l,d,g,h;return n(this,(function(n){switch(n.label){case 0:for(n.trys.push([0,3,,4]),e=[],r=[],i=[],a=0,o=t;a<o.length;a++)c=o[a],s=m(c,u),l=f(s),e.push(l),d=b(s),i.push(d),r.push(s.pagination);return[4,w(p,i,v)];case 1:return v=n.sent(),[4,p.multiSearch(e,r)];case 2:return g=n.sent(),[2,y(g,v,S)];case 3:throw h=n.sent(),console.error(h),new Error(h);case 4:return[2]}}))}))},searchForFacetValues:function(t){return r(this,void 0,void 0,(function(){return n(this,(function(t){switch(t.label){case 0:return[4,new Promise((function(t,e){e(new Error("SearchForFacetValues is not compatible with Meilisearch")),t([])}))];case 1:return[2,t.sent()]}}))}))}}};
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("meilisearch"),e=function(){return e=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},e.apply(this,arguments)};function r(t,e,r,n){return new(r||(r=Promise))((function(i,a){function o(t){try{c(n.next(t))}catch(t){a(t)}}function u(t){try{c(n.throw(t))}catch(t){a(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,u)}c((n=n.apply(t,e||[])).next())}))}function n(t,e){var r,n,i,a,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(c){return function(u){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(o=0)),o;)try{if(r=1,n&&(i=2&u[0]?n.return:u[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,u[1])).done)return i;switch(n=0,i&&(u=[2&u[0],i.value]),u[0]){case 0:case 1:i=u;break;case 4:return o.label++,{value:u[1],done:!1};case 5:o.label++,n=u[1],u=[0];continue;case 7:u=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==u[0]&&2!==u[0])){o=0;continue}if(3===u[0]&&(!i||u[1]>i[0]&&u[1]<i[3])){o.label=u[1];break}if(6===u[0]&&o.label<i[1]){o.label=i[1],i=u;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(u);break}i[2]&&o.ops.pop(),o.trys.pop();continue}u=e.call(t,o)}catch(t){u=[6,t],n=0}finally{r=i=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}}function i(t,e,r){if(r||2===arguments.length)for(var n,i=0,a=e.length;i<a;i++)!n&&i in e||(n||(n=Array.prototype.slice.call(e,0,i)),n[i]=e[i]);return t.concat(n||Array.prototype.slice.call(e))}function a(t){return"object"==typeof t&&!Array.isArray(t)&&null!==t}function o(t){return t.replace(/(.*):(.*)/i,'"$1"="$2"')}function u(t){return"string"==typeof t?o(t):Array.isArray(t)?t.map((function(t){return Array.isArray(t)?t.map((function(t){return o(t)})).filter((function(t){return t})):o(t)})).filter((function(t){return t})):[]}function c(t){return""===t?[]:"string"==typeof t?[t]:t}function s(t,e,r){return function(t,e,r){var n=r.trim(),a=c(t),o=c(e);return i(i(i([],a,!0),o,!0),[n],!1).filter((function(t){return Array.isArray(t)?t.length:t}))}(u(r||[]),u(e||[]),t||"")}function l(t){var e={},r=t.facets,n=t.attributesToSnippet,i=t.snippetEllipsisText,a=t.attributesToRetrieve,o=t.attributesToHighlight,u=t.highlightPreTag,c=t.highlightPostTag,l=t.placeholderSearch,f=t.query,d=t.sort,g=t.pagination,h=t.matchingStrategy,p=t.filters,v=t.numericFilters,y=t.facetFilters,m=t.indexUid,P=s(p,v,y);return{getParams:function(){return e},addQuery:function(){e.q=f},addIndexUid:function(){e.indexUid=m},addFacets:function(){Array.isArray(r)?e.facets=r:"string"==typeof r&&(e.facets=[r])},addAttributesToCrop:function(){n&&(e.attributesToCrop=n)},addCropMarker:function(){null!=i&&(e.cropMarker=i)},addAttributesToRetrieve:function(){a&&(e.attributesToRetrieve=a)},addFilters:function(){P.length&&(e.filter=P)},addAttributesToHighlight:function(){e.attributesToHighlight=o||["*"]},addPreTag:function(){e.highlightPreTag=u||"__ais-highlight__"},addPostTag:function(){e.highlightPostTag=c||"__/ais-highlight__"},addPagination:function(){var t=function(t,e,r){return!!(r||e||t&&0!==t.length)}(P,f,l);if(g.finite){var r=function(t,e){var r=t.page,n=t.hitsPerPage;return e?{hitsPerPage:n,page:r+1}:{hitsPerPage:0,page:r+1}}(g,t),n=r.hitsPerPage,i=r.page;e.hitsPerPage=n,e.page=i}else{var a=function(t,e){var r=t.page,n=t.hitsPerPage;return e?{limit:n+1,offset:r*n}:{limit:0,offset:0}}(g,t),o=a.limit,u=a.offset;e.limit=o,e.offset=u}},addSort:function(){(null==d?void 0:d.length)&&(e.sort=Array.isArray(d)?d:[d])},addGeoSearchFilter:function(){var r=function(t){var e,r,n,i=t.insideBoundingBox,a=t.aroundLatLng,o=t.aroundRadius,u=t.minimumAroundRadius;if(a){var c=a.split(",").map((function(t){return Number.parseFloat(t).toFixed(5)}));e=[h=c[0],p=c[1]]}if(null==o&&null==u||("all"===o?console.warn("instant-meilisearch is not compatible with the `all` value on the aroundRadius parameter"):r=null!=o?o:u),i&&"string"==typeof i){var s=i.split(",").map((function(t){return parseFloat(t)})),l=s[0],f=s[1],d=s[2],g=s[3];n="_geoBoundingBox([".concat(l,", ").concat(f,"], [").concat(d,", ").concat(g,"])")}else if(null!=e&&null!=r){var h=e[0],p=e[1];n="_geoRadius(".concat(h,", ").concat(p,", ").concat(r,")")}return n}({insideBoundingBox:t.insideBoundingBox,aroundLatLng:t.aroundLatLng,aroundRadius:t.aroundRadius,minimumAroundRadius:t.minimumAroundRadius});r&&(e.filter?e.filter.unshift(r):e.filter=[r])},addMatchingStrategy:function(){h&&(e.matchingStrategy=h)}}}function f(t){var e=l(t);return e.addQuery(),e.addIndexUid(),e.addFacets(),e.addAttributesToHighlight(),e.addPreTag(),e.addPostTag(),e.addAttributesToRetrieve(),e.addAttributesToCrop(),e.addCropMarker(),e.addPagination(),e.addFilters(),e.addSort(),e.addGeoSearchFilter(),e.addMatchingStrategy(),e.getParams()}function d(t){return"string"==typeof t?t:void 0===t?JSON.stringify(null):JSON.stringify(t)}function g(t){return Array.isArray(t)?t.map((function(t){return g(t)})):a(t)?Object.keys(t).reduce((function(e,r){return e[r]=g(t[r]),e}),{}):{value:d(t)}}function h(t){if(!t)return{};var e=g(t);return{_highlightResult:e,_snippetResult:e}}function p(t,e){var r=t.hits,n=t.pagination.hitsPerPage,i=e.finitePagination,a=e.primaryKey;!i&&r.length>n&&r.splice(r.length-1,1);var o=r.map((function(t){if(Object.keys(t).length>0){var e=t._formatted;t._matchesPosition;var r=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]])}return r}(t,["_formatted","_matchesPosition"]),n=Object.assign(r,h(e));return a&&(n.objectID=t[a]),n}return t}));return o=function(t){for(var e,r=0;r<t.length;r++){var n="".concat(r+1e6*Math.random());t[r]._geo&&(t[r]._geoloc=t[r]._geo,t[r].objectID=n),(null===(e=t[r]._formatted)||void 0===e?void 0:e._geo)&&(t[r]._formatted._geoloc=t[r]._formatted._geo,t[r]._formatted.objectID=n)}return t}(o),o}function v(t){return Object.keys(t).reduce((function(r,n){return r[n]=e(e({},t[n]),{avg:0,sum:0}),r}),{})}function y(t,e,r){var n=t.map((function(t){return function(t,e,r){var n=t.processingTimeMs,i=t.query,a=t.indexUid,o=t.facetDistribution,u=void 0===o?{}:o,c=t.facetStats,s=void 0===c?{}:c,l=Object.keys(u),f=function(t,e){var r=e.hitsPerPage,n=e.page,i=function(t,e){if(null!=t.totalPages)return t.totalPages;if(0===e)return 0;var r=t.limit,n=void 0===r?20:r,i=t.offset;return(void 0===i?0:i)/e+1+(t.hits.length>=n?1:0)}(t,r);return{page:n,nbPages:i,hitsPerPage:r}}(t,t.pagination),d=f.hitsPerPage,g=f.page,h=f.nbPages,y=p(t,r),m=function(t){var e=t.hitsPerPage,r=void 0===e?0:e,n=t.totalPages,i=void 0===n?0:n,a=t.estimatedTotalHits,o=t.totalHits;return null!=a?a:null!=o?o:r*i}(t),P=function(t,e,r,n){return t?function(t,e,r){for(var n=function(t){return t?"string"==typeof t?[t]:t:[]}(t),i={},a=0,o=n;a<o.length;a++){var u=o[a];for(var c in e[u])i[u]||(i[u]=r[u]||{}),i[u][c]?i[u][c]=r[u][c]:i[u][c]=0}return i}(e,r,n=n||{}):n}(r.keepZeroFacets,l,e,u);return{index:a,hitsPerPage:d,page:g,facets:P,nbPages:h,nbHits:m,processingTimeMS:n,query:i,hits:y,params:"",exhaustiveNbHits:!1,facets_stats:v(s)}}(t,e[t.indexUid],r)}));return{results:n}}function m(t,e,r){return{hitsPerPage:void 0===e?20:e,page:r||0,finite:!!t}}function P(t){return t.split(",").map((function(t){return t.trim()})).filter((function(t){return!!t}))}function b(t,r){var n=t.indexName.split(":"),i=n[0],a=n.slice(1),o=t.query,u=t.params,c=m(r.finitePagination,null==u?void 0:u.hitsPerPage,null==u?void 0:u.page),s=P(a.join(":"));return e(e(e(e({},r),{query:o}),u),{sort:s,indexUid:i,pagination:c,placeholderSearch:!1!==r.placeholderSearch,keepZeroFacets:!!r.keepZeroFacets})}function x(t){void 0===t&&(t={});var e=t;return{getEntry:function(t){if(e[t])try{return JSON.parse(e[t])}catch(t){return}},formatKey:function(t){return t.reduce((function(t,e){return t+JSON.stringify(e)}),"")},setEntry:function(t,r){e[t]=JSON.stringify(r)},clearCache:function(){e={}}}}function S(t){var r=l(e(e({},t),{placeholderSearch:!0,query:""}));return r.addFacets(),r.addIndexUid(),r.addPagination(),r.getParams()}function w(t,e,i){return r(this,void 0,void 0,(function(){var r,a,o,u,c,s;return n(this,(function(n){switch(n.label){case 0:return l="indexUid",f=[],r=function(t){return!f.includes(t[l])&&(f.push(t[l]),!0)},a=e.filter(r).filter((function(t){var e=t.indexUid;return!Object.keys(i).includes(e)})),0===a.length?[2,i]:[4,t.multiSearch(a,[])];case 1:for(o=n.sent(),u=0,c=o;u<c.length;u++)s=c[u],i[s.indexUid]=s.facetDistribution||{};return[2,i]}var l,f}))}))}var T;exports.MatchingStrategies=void 0,(T=exports.MatchingStrategies||(exports.MatchingStrategies={})).ALL="all",T.LAST="last",exports.instantMeiliSearch=function(i,o,u){void 0===o&&(o=""),void 0===u&&(u={}),function(t,e,r){var n=r.requestConfig,i=r.httpClient;if("string"!=typeof t)throw new TypeError("Provided hostUrl value (1st parameter) is not a string, expected string");if("string"!=typeof e&&"function"!=typeof e)throw new TypeError("Provided apiKey value (2nd parameter) is not a string or a function, expected string or function");if(void 0!==n&&!a(n))throw new TypeError("Provided requestConfig should be an object");if(i&&"function"!=typeof i)throw new TypeError("Provided custom httpClient should be a function")}(i,o,u);var c={host:i,apiKey:o=function(t){if("function"==typeof t){var e=t();if("string"!=typeof e)throw new TypeError("Provided apiKey function (2nd parameter) did not return a string, expected string");return e}return t}(o),clientAgents:function(t){void 0===t&&(t=[]);var e="Meilisearch instant-meilisearch (v".concat("0.13.3-prototype-search-for-facet-values.0",")");return t.concat(e)}(u.clientAgents)};void 0!==u.httpClient&&(c.httpClient=u.httpClient),void 0!==u.requestConfig&&(c.requestConfig=u.requestConfig);var s,l,d,g=new t.MeiliSearch(c),h=x(),p=(s=g,l=h,{multiSearch:function(t,i){return r(this,void 0,void 0,(function(){var r,a,o,u;return n(this,(function(n){switch(n.label){case 0:return r=l.formatKey([t]),(a=l.getEntry(r))?[2,a]:[4,s.multiSearch({queries:t})];case 1:return o=n.sent(),u=o.results.map((function(t,r){return e(e({},t),{pagination:i[r]||{}})})),l.setEntry(r,u),[2,u]}}))}))}}),v={},T=(d=u,e(e({},{placeholderSearch:!0,keepZeroFacets:!1,clientAgents:[],finitePagination:!1}),d));return{clearCache:function(){return h.clearCache()},search:function(t){return r(this,void 0,void 0,(function(){var e,r,i,a,o,c,s,l,d,g,h;return n(this,(function(n){switch(n.label){case 0:for(n.trys.push([0,3,,4]),e=[],r=[],i=[],a=0,o=t;a<o.length;a++)c=o[a],s=b(c,u),l=f(s),e.push(l),d=S(s),i.push(d),r.push(s.pagination);return[4,w(p,i,v)];case 1:return v=n.sent(),[4,p.multiSearch(e,r)];case 2:return g=n.sent(),[2,y(g,v,T)];case 3:throw h=n.sent(),console.error(h),new Error(h);case 4:return[2]}}))}))},searchForFacetValues:function(t){return r(this,void 0,void 0,(function(){var r,i,a,o,c,s,l,d,h,p,v;return n(this,(function(n){switch(n.label){case 0:console.log(t),r=[],i=0,a=t,n.label=1;case 1:return i<a.length?(o=a[i],c=function(t,r){var n=t.indexName.split(":"),i=n[0],a=n.slice(1),o=t.params,u=m(r.finitePagination,null==o?void 0:o.hitsPerPage,null==o?void 0:o.page),c=P(a.join(":"));return e(e(e({},r),o),{sort:c,indexUid:i,pagination:u,placeholderSearch:!1!==r.placeholderSearch,keepZeroFacets:!!r.keepZeroFacets})}(o,u),s=f(c),l=o.indexName,delete(d=e(e({},s),{facetQuery:o.params.facetQuery,facetName:o.params.facetName})).indexUid,[4,g.index(l).searchForFacetValues(d)]):[3,4];case 2:h=n.sent(),p=h.facetHits.map((function(t){return e(e({},t),{highlighted:t.value})})),v={facetHits:p,exhaustiveFacetsCount:!1,processingTimeMS:h.processingTimeMs},r.push(v),n.label=3;case 3:return i++,[3,1];case 4:return[2,r]}}))}))}}};
//# sourceMappingURL=instant-meilisearch.cjs.min.js.map

@@ -807,2 +807,17 @@ import { MeiliSearch } from 'meilisearch';

}
// TODO: avoid code duplication
/**
* @param {AlgoliaMultipleQueriesQuery} searchRequest
* @param {Context} options
* @returns {SearchContext}
*/
function createFacetSearchContext(searchRequest, options) {
// Split index name and possible sorting rules
var _a = searchRequest.indexName.split(':'), indexUid = _a[0], sortByArray = _a.slice(1);
var instantSearchParams = searchRequest.params;
var paginationState = createPaginationState(options.finitePagination, instantSearchParams === null || instantSearchParams === void 0 ? void 0 : instantSearchParams.hitsPerPage, instantSearchParams === null || instantSearchParams === void 0 ? void 0 : instantSearchParams.page);
var sortState = createSortState(sortByArray.join(':'));
var searchContext = __assign(__assign(__assign({}, options), instantSearchParams), { sort: sortState, indexUid: indexUid, pagination: paginationState, placeholderSearch: options.placeholderSearch !== false, keepZeroFacets: !!options.keepZeroFacets });
return searchContext;
}

@@ -885,3 +900,3 @@ /**

var PACKAGE_VERSION = '0.13.2';
var PACKAGE_VERSION = '0.13.3-prototype-search-for-facet-values.0';

@@ -973,11 +988,39 @@ var constructClientAgents = function (clientAgents) {

},
searchForFacetValues: function (_) {
searchForFacetValues: function (requests) {
return __awaiter(this, void 0, void 0, function () {
var results, _i, requests_1, request, searchContext, meilisearchSearchQuery, index, meilisearchRequest, meilisearchResponse, facetHits, result;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, new Promise(function (resolve, reject) {
reject(new Error('SearchForFacetValues is not compatible with Meilisearch'));
resolve([]); // added here to avoid compilation error
})];
case 1: return [2 /*return*/, _a.sent()];
case 0:
console.log(requests);
results = [];
_i = 0, requests_1 = requests;
_a.label = 1;
case 1:
if (!(_i < requests_1.length)) return [3 /*break*/, 4];
request = requests_1[_i];
searchContext = createFacetSearchContext(request, instantMeiliSearchOptions);
meilisearchSearchQuery = adaptSearchParams(searchContext);
index = request.indexName;
meilisearchRequest = __assign(__assign({}, meilisearchSearchQuery), { facetQuery: request.params.facetQuery, facetName: request.params.facetName });
delete meilisearchRequest.indexUid;
return [4 /*yield*/, meilisearchClient
.index(index)
.searchForFacetValues(meilisearchRequest)];
case 2:
meilisearchResponse = _a.sent();
facetHits = meilisearchResponse.facetHits.map(function (facetHit) { return (__assign(__assign({}, facetHit), {
// not currently supported
highlighted: facetHit.value })); });
result = {
facetHits: facetHits,
exhaustiveFacetsCount: false,
processingTimeMS: meilisearchResponse.processingTimeMs
};
results.push(result);
_a.label = 3;
case 3:
_i++;
return [3 /*break*/, 1];
case 4: return [2 /*return*/, results];
}

@@ -984,0 +1027,0 @@ });

@@ -1,2 +0,2 @@

import{MeiliSearch as t}from"meilisearch";var e=function(){return e=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},e.apply(this,arguments)};function r(t,e,r,n){return new(r||(r=Promise))((function(i,a){function o(t){try{c(n.next(t))}catch(t){a(t)}}function u(t){try{c(n.throw(t))}catch(t){a(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,u)}c((n=n.apply(t,e||[])).next())}))}function n(t,e){var r,n,i,a,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(c){return function(u){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(o=0)),o;)try{if(r=1,n&&(i=2&u[0]?n.return:u[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,u[1])).done)return i;switch(n=0,i&&(u=[2&u[0],i.value]),u[0]){case 0:case 1:i=u;break;case 4:return o.label++,{value:u[1],done:!1};case 5:o.label++,n=u[1],u=[0];continue;case 7:u=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==u[0]&&2!==u[0])){o=0;continue}if(3===u[0]&&(!i||u[1]>i[0]&&u[1]<i[3])){o.label=u[1];break}if(6===u[0]&&o.label<i[1]){o.label=i[1],i=u;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(u);break}i[2]&&o.ops.pop(),o.trys.pop();continue}u=e.call(t,o)}catch(t){u=[6,t],n=0}finally{r=i=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}}function i(t,e,r){if(r||2===arguments.length)for(var n,i=0,a=e.length;i<a;i++)!n&&i in e||(n||(n=Array.prototype.slice.call(e,0,i)),n[i]=e[i]);return t.concat(n||Array.prototype.slice.call(e))}function a(t){return"object"==typeof t&&!Array.isArray(t)&&null!==t}function o(t){return t.replace(/(.*):(.*)/i,'"$1"="$2"')}function u(t){return"string"==typeof t?o(t):Array.isArray(t)?t.map((function(t){return Array.isArray(t)?t.map((function(t){return o(t)})).filter((function(t){return t})):o(t)})).filter((function(t){return t})):[]}function c(t){return""===t?[]:"string"==typeof t?[t]:t}function s(t,e,r){return function(t,e,r){var n=r.trim(),a=c(t),o=c(e);return i(i(i([],a,!0),o,!0),[n],!1).filter((function(t){return Array.isArray(t)?t.length:t}))}(u(r||[]),u(e||[]),t||"")}function f(t){var e={},r=t.facets,n=t.attributesToSnippet,i=t.snippetEllipsisText,a=t.attributesToRetrieve,o=t.attributesToHighlight,u=t.highlightPreTag,c=t.highlightPostTag,f=t.placeholderSearch,l=t.query,d=t.sort,g=t.pagination,h=t.matchingStrategy,p=t.filters,v=t.numericFilters,y=t.facetFilters,m=t.indexUid,P=s(p,v,y);return{getParams:function(){return e},addQuery:function(){e.q=l},addIndexUid:function(){e.indexUid=m},addFacets:function(){Array.isArray(r)?e.facets=r:"string"==typeof r&&(e.facets=[r])},addAttributesToCrop:function(){n&&(e.attributesToCrop=n)},addCropMarker:function(){null!=i&&(e.cropMarker=i)},addAttributesToRetrieve:function(){a&&(e.attributesToRetrieve=a)},addFilters:function(){P.length&&(e.filter=P)},addAttributesToHighlight:function(){e.attributesToHighlight=o||["*"]},addPreTag:function(){e.highlightPreTag=u||"__ais-highlight__"},addPostTag:function(){e.highlightPostTag=c||"__/ais-highlight__"},addPagination:function(){var t=function(t,e,r){return!!(r||e||t&&0!==t.length)}(P,l,f);if(g.finite){var r=function(t,e){var r=t.page,n=t.hitsPerPage;return e?{hitsPerPage:n,page:r+1}:{hitsPerPage:0,page:r+1}}(g,t),n=r.hitsPerPage,i=r.page;e.hitsPerPage=n,e.page=i}else{var a=function(t,e){var r=t.page,n=t.hitsPerPage;return e?{limit:n+1,offset:r*n}:{limit:0,offset:0}}(g,t),o=a.limit,u=a.offset;e.limit=o,e.offset=u}},addSort:function(){(null==d?void 0:d.length)&&(e.sort=Array.isArray(d)?d:[d])},addGeoSearchFilter:function(){var r=function(t){var e,r,n,i=t.insideBoundingBox,a=t.aroundLatLng,o=t.aroundRadius,u=t.minimumAroundRadius;if(a){var c=a.split(",").map((function(t){return Number.parseFloat(t).toFixed(5)}));e=[h=c[0],p=c[1]]}if(null==o&&null==u||("all"===o?console.warn("instant-meilisearch is not compatible with the `all` value on the aroundRadius parameter"):r=null!=o?o:u),i&&"string"==typeof i){var s=i.split(",").map((function(t){return parseFloat(t)})),f=s[0],l=s[1],d=s[2],g=s[3];n="_geoBoundingBox([".concat(f,", ").concat(l,"], [").concat(d,", ").concat(g,"])")}else if(null!=e&&null!=r){var h=e[0],p=e[1];n="_geoRadius(".concat(h,", ").concat(p,", ").concat(r,")")}return n}({insideBoundingBox:t.insideBoundingBox,aroundLatLng:t.aroundLatLng,aroundRadius:t.aroundRadius,minimumAroundRadius:t.minimumAroundRadius});r&&(e.filter?e.filter.unshift(r):e.filter=[r])},addMatchingStrategy:function(){h&&(e.matchingStrategy=h)}}}function l(t){var e=f(t);return e.addQuery(),e.addIndexUid(),e.addFacets(),e.addAttributesToHighlight(),e.addPreTag(),e.addPostTag(),e.addAttributesToRetrieve(),e.addAttributesToCrop(),e.addCropMarker(),e.addPagination(),e.addFilters(),e.addSort(),e.addGeoSearchFilter(),e.addMatchingStrategy(),e.getParams()}function d(t){return"string"==typeof t?t:void 0===t?JSON.stringify(null):JSON.stringify(t)}function g(t){return Array.isArray(t)?t.map((function(t){return g(t)})):a(t)?Object.keys(t).reduce((function(e,r){return e[r]=g(t[r]),e}),{}):{value:d(t)}}function h(t){if(!t)return{};var e=g(t);return{_highlightResult:e,_snippetResult:e}}function p(t,e){var r=t.hits,n=t.pagination.hitsPerPage,i=e.finitePagination,a=e.primaryKey;!i&&r.length>n&&r.splice(r.length-1,1);var o=r.map((function(t){if(Object.keys(t).length>0){var e=t._formatted;t._matchesPosition;var r=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]])}return r}(t,["_formatted","_matchesPosition"]),n=Object.assign(r,h(e));return a&&(n.objectID=t[a]),n}return t}));return o=function(t){for(var e,r=0;r<t.length;r++){var n="".concat(r+1e6*Math.random());t[r]._geo&&(t[r]._geoloc=t[r]._geo,t[r].objectID=n),(null===(e=t[r]._formatted)||void 0===e?void 0:e._geo)&&(t[r]._formatted._geoloc=t[r]._formatted._geo,t[r]._formatted.objectID=n)}return t}(o),o}function v(t){return Object.keys(t).reduce((function(r,n){return r[n]=e(e({},t[n]),{avg:0,sum:0}),r}),{})}function y(t,e,r){var n=t.map((function(t){return function(t,e,r){var n=t.processingTimeMs,i=t.query,a=t.indexUid,o=t.facetDistribution,u=void 0===o?{}:o,c=t.facetStats,s=void 0===c?{}:c,f=Object.keys(u),l=function(t,e){var r=e.hitsPerPage,n=e.page,i=function(t,e){if(null!=t.totalPages)return t.totalPages;if(0===e)return 0;var r=t.limit,n=void 0===r?20:r,i=t.offset;return(void 0===i?0:i)/e+1+(t.hits.length>=n?1:0)}(t,r);return{page:n,nbPages:i,hitsPerPage:r}}(t,t.pagination),d=l.hitsPerPage,g=l.page,h=l.nbPages,y=p(t,r),m=function(t){var e=t.hitsPerPage,r=void 0===e?0:e,n=t.totalPages,i=void 0===n?0:n,a=t.estimatedTotalHits,o=t.totalHits;return null!=a?a:null!=o?o:r*i}(t),P=function(t,e,r,n){return t?function(t,e,r){for(var n=function(t){return t?"string"==typeof t?[t]:t:[]}(t),i={},a=0,o=n;a<o.length;a++){var u=o[a];for(var c in e[u])i[u]||(i[u]=r[u]||{}),i[u][c]?i[u][c]=r[u][c]:i[u][c]=0}return i}(e,r,n=n||{}):n}(r.keepZeroFacets,f,e,u);return{index:a,hitsPerPage:d,page:g,facets:P,nbPages:h,nbHits:m,processingTimeMS:n,query:i,hits:y,params:"",exhaustiveNbHits:!1,facets_stats:v(s)}}(t,e[t.indexUid],r)}));return{results:n}}function m(t,r){var n,i,a,o=t.indexName.split(":"),u=o[0],c=o.slice(1),s=t.query,f=t.params,l=(n=r.finitePagination,i=null==f?void 0:f.hitsPerPage,a=null==f?void 0:f.page,{hitsPerPage:void 0===i?20:i,page:a||0,finite:!!n}),d=c.join(":").split(",").map((function(t){return t.trim()})).filter((function(t){return!!t}));return e(e(e(e({},r),{query:s}),f),{sort:d,indexUid:u,pagination:l,placeholderSearch:!1!==r.placeholderSearch,keepZeroFacets:!!r.keepZeroFacets})}function P(t){void 0===t&&(t={});var e=t;return{getEntry:function(t){if(e[t])try{return JSON.parse(e[t])}catch(t){return}},formatKey:function(t){return t.reduce((function(t,e){return t+JSON.stringify(e)}),"")},setEntry:function(t,r){e[t]=JSON.stringify(r)},clearCache:function(){e={}}}}function b(t){var r=f(e(e({},t),{placeholderSearch:!0,query:""}));return r.addFacets(),r.addIndexUid(),r.addPagination(),r.getParams()}function w(t,e,i){return r(this,void 0,void 0,(function(){var r,a,o,u,c,s;return n(this,(function(n){switch(n.label){case 0:return f="indexUid",l=[],r=function(t){return!l.includes(t[f])&&(l.push(t[f]),!0)},a=e.filter(r).filter((function(t){var e=t.indexUid;return!Object.keys(i).includes(e)})),0===a.length?[2,i]:[4,t.multiSearch(a,[])];case 1:for(o=n.sent(),u=0,c=o;u<c.length;u++)s=c[u],i[s.indexUid]=s.facetDistribution||{};return[2,i]}var f,l}))}))}var x;function S(i,o,u){void 0===o&&(o=""),void 0===u&&(u={}),function(t,e,r){var n=r.requestConfig,i=r.httpClient;if("string"!=typeof t)throw new TypeError("Provided hostUrl value (1st parameter) is not a string, expected string");if("string"!=typeof e&&"function"!=typeof e)throw new TypeError("Provided apiKey value (2nd parameter) is not a string or a function, expected string or function");if(void 0!==n&&!a(n))throw new TypeError("Provided requestConfig should be an object");if(i&&"function"!=typeof i)throw new TypeError("Provided custom httpClient should be a function")}(i,o,u);var c={host:i,apiKey:o=function(t){if("function"==typeof t){var e=t();if("string"!=typeof e)throw new TypeError("Provided apiKey function (2nd parameter) did not return a string, expected string");return e}return t}(o),clientAgents:function(t){void 0===t&&(t=[]);var e="Meilisearch instant-meilisearch (v".concat("0.13.2",")");return t.concat(e)}(u.clientAgents)};void 0!==u.httpClient&&(c.httpClient=u.httpClient),void 0!==u.requestConfig&&(c.requestConfig=u.requestConfig);var s,f,d,g=new t(c),h=P(),p=(s=g,f=h,{multiSearch:function(t,i){return r(this,void 0,void 0,(function(){var r,a,o,u;return n(this,(function(n){switch(n.label){case 0:return r=f.formatKey([t]),(a=f.getEntry(r))?[2,a]:[4,s.multiSearch({queries:t})];case 1:return o=n.sent(),u=o.results.map((function(t,r){return e(e({},t),{pagination:i[r]||{}})})),f.setEntry(r,u),[2,u]}}))}))}}),v={},x=(d=u,e(e({},{placeholderSearch:!0,keepZeroFacets:!1,clientAgents:[],finitePagination:!1}),d));return{clearCache:function(){return h.clearCache()},search:function(t){return r(this,void 0,void 0,(function(){var e,r,i,a,o,c,s,f,d,g,h;return n(this,(function(n){switch(n.label){case 0:for(n.trys.push([0,3,,4]),e=[],r=[],i=[],a=0,o=t;a<o.length;a++)c=o[a],s=m(c,u),f=l(s),e.push(f),d=b(s),i.push(d),r.push(s.pagination);return[4,w(p,i,v)];case 1:return v=n.sent(),[4,p.multiSearch(e,r)];case 2:return g=n.sent(),[2,y(g,v,x)];case 3:throw h=n.sent(),console.error(h),new Error(h);case 4:return[2]}}))}))},searchForFacetValues:function(t){return r(this,void 0,void 0,(function(){return n(this,(function(t){switch(t.label){case 0:return[4,new Promise((function(t,e){e(new Error("SearchForFacetValues is not compatible with Meilisearch")),t([])}))];case 1:return[2,t.sent()]}}))}))}}}!function(t){t.ALL="all",t.LAST="last"}(x||(x={}));export{x as MatchingStrategies,S as instantMeiliSearch};
import{MeiliSearch as t}from"meilisearch";var e=function(){return e=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},e.apply(this,arguments)};function r(t,e,r,n){return new(r||(r=Promise))((function(i,a){function o(t){try{c(n.next(t))}catch(t){a(t)}}function u(t){try{c(n.throw(t))}catch(t){a(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,u)}c((n=n.apply(t,e||[])).next())}))}function n(t,e){var r,n,i,a,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(c){return function(u){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(o=0)),o;)try{if(r=1,n&&(i=2&u[0]?n.return:u[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,u[1])).done)return i;switch(n=0,i&&(u=[2&u[0],i.value]),u[0]){case 0:case 1:i=u;break;case 4:return o.label++,{value:u[1],done:!1};case 5:o.label++,n=u[1],u=[0];continue;case 7:u=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==u[0]&&2!==u[0])){o=0;continue}if(3===u[0]&&(!i||u[1]>i[0]&&u[1]<i[3])){o.label=u[1];break}if(6===u[0]&&o.label<i[1]){o.label=i[1],i=u;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(u);break}i[2]&&o.ops.pop(),o.trys.pop();continue}u=e.call(t,o)}catch(t){u=[6,t],n=0}finally{r=i=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}}function i(t,e,r){if(r||2===arguments.length)for(var n,i=0,a=e.length;i<a;i++)!n&&i in e||(n||(n=Array.prototype.slice.call(e,0,i)),n[i]=e[i]);return t.concat(n||Array.prototype.slice.call(e))}function a(t){return"object"==typeof t&&!Array.isArray(t)&&null!==t}function o(t){return t.replace(/(.*):(.*)/i,'"$1"="$2"')}function u(t){return"string"==typeof t?o(t):Array.isArray(t)?t.map((function(t){return Array.isArray(t)?t.map((function(t){return o(t)})).filter((function(t){return t})):o(t)})).filter((function(t){return t})):[]}function c(t){return""===t?[]:"string"==typeof t?[t]:t}function s(t,e,r){return function(t,e,r){var n=r.trim(),a=c(t),o=c(e);return i(i(i([],a,!0),o,!0),[n],!1).filter((function(t){return Array.isArray(t)?t.length:t}))}(u(r||[]),u(e||[]),t||"")}function l(t){var e={},r=t.facets,n=t.attributesToSnippet,i=t.snippetEllipsisText,a=t.attributesToRetrieve,o=t.attributesToHighlight,u=t.highlightPreTag,c=t.highlightPostTag,l=t.placeholderSearch,f=t.query,d=t.sort,g=t.pagination,h=t.matchingStrategy,p=t.filters,v=t.numericFilters,y=t.facetFilters,m=t.indexUid,P=s(p,v,y);return{getParams:function(){return e},addQuery:function(){e.q=f},addIndexUid:function(){e.indexUid=m},addFacets:function(){Array.isArray(r)?e.facets=r:"string"==typeof r&&(e.facets=[r])},addAttributesToCrop:function(){n&&(e.attributesToCrop=n)},addCropMarker:function(){null!=i&&(e.cropMarker=i)},addAttributesToRetrieve:function(){a&&(e.attributesToRetrieve=a)},addFilters:function(){P.length&&(e.filter=P)},addAttributesToHighlight:function(){e.attributesToHighlight=o||["*"]},addPreTag:function(){e.highlightPreTag=u||"__ais-highlight__"},addPostTag:function(){e.highlightPostTag=c||"__/ais-highlight__"},addPagination:function(){var t=function(t,e,r){return!!(r||e||t&&0!==t.length)}(P,f,l);if(g.finite){var r=function(t,e){var r=t.page,n=t.hitsPerPage;return e?{hitsPerPage:n,page:r+1}:{hitsPerPage:0,page:r+1}}(g,t),n=r.hitsPerPage,i=r.page;e.hitsPerPage=n,e.page=i}else{var a=function(t,e){var r=t.page,n=t.hitsPerPage;return e?{limit:n+1,offset:r*n}:{limit:0,offset:0}}(g,t),o=a.limit,u=a.offset;e.limit=o,e.offset=u}},addSort:function(){(null==d?void 0:d.length)&&(e.sort=Array.isArray(d)?d:[d])},addGeoSearchFilter:function(){var r=function(t){var e,r,n,i=t.insideBoundingBox,a=t.aroundLatLng,o=t.aroundRadius,u=t.minimumAroundRadius;if(a){var c=a.split(",").map((function(t){return Number.parseFloat(t).toFixed(5)}));e=[h=c[0],p=c[1]]}if(null==o&&null==u||("all"===o?console.warn("instant-meilisearch is not compatible with the `all` value on the aroundRadius parameter"):r=null!=o?o:u),i&&"string"==typeof i){var s=i.split(",").map((function(t){return parseFloat(t)})),l=s[0],f=s[1],d=s[2],g=s[3];n="_geoBoundingBox([".concat(l,", ").concat(f,"], [").concat(d,", ").concat(g,"])")}else if(null!=e&&null!=r){var h=e[0],p=e[1];n="_geoRadius(".concat(h,", ").concat(p,", ").concat(r,")")}return n}({insideBoundingBox:t.insideBoundingBox,aroundLatLng:t.aroundLatLng,aroundRadius:t.aroundRadius,minimumAroundRadius:t.minimumAroundRadius});r&&(e.filter?e.filter.unshift(r):e.filter=[r])},addMatchingStrategy:function(){h&&(e.matchingStrategy=h)}}}function f(t){var e=l(t);return e.addQuery(),e.addIndexUid(),e.addFacets(),e.addAttributesToHighlight(),e.addPreTag(),e.addPostTag(),e.addAttributesToRetrieve(),e.addAttributesToCrop(),e.addCropMarker(),e.addPagination(),e.addFilters(),e.addSort(),e.addGeoSearchFilter(),e.addMatchingStrategy(),e.getParams()}function d(t){return"string"==typeof t?t:void 0===t?JSON.stringify(null):JSON.stringify(t)}function g(t){return Array.isArray(t)?t.map((function(t){return g(t)})):a(t)?Object.keys(t).reduce((function(e,r){return e[r]=g(t[r]),e}),{}):{value:d(t)}}function h(t){if(!t)return{};var e=g(t);return{_highlightResult:e,_snippetResult:e}}function p(t,e){var r=t.hits,n=t.pagination.hitsPerPage,i=e.finitePagination,a=e.primaryKey;!i&&r.length>n&&r.splice(r.length-1,1);var o=r.map((function(t){if(Object.keys(t).length>0){var e=t._formatted;t._matchesPosition;var r=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]])}return r}(t,["_formatted","_matchesPosition"]),n=Object.assign(r,h(e));return a&&(n.objectID=t[a]),n}return t}));return o=function(t){for(var e,r=0;r<t.length;r++){var n="".concat(r+1e6*Math.random());t[r]._geo&&(t[r]._geoloc=t[r]._geo,t[r].objectID=n),(null===(e=t[r]._formatted)||void 0===e?void 0:e._geo)&&(t[r]._formatted._geoloc=t[r]._formatted._geo,t[r]._formatted.objectID=n)}return t}(o),o}function v(t){return Object.keys(t).reduce((function(r,n){return r[n]=e(e({},t[n]),{avg:0,sum:0}),r}),{})}function y(t,e,r){var n=t.map((function(t){return function(t,e,r){var n=t.processingTimeMs,i=t.query,a=t.indexUid,o=t.facetDistribution,u=void 0===o?{}:o,c=t.facetStats,s=void 0===c?{}:c,l=Object.keys(u),f=function(t,e){var r=e.hitsPerPage,n=e.page,i=function(t,e){if(null!=t.totalPages)return t.totalPages;if(0===e)return 0;var r=t.limit,n=void 0===r?20:r,i=t.offset;return(void 0===i?0:i)/e+1+(t.hits.length>=n?1:0)}(t,r);return{page:n,nbPages:i,hitsPerPage:r}}(t,t.pagination),d=f.hitsPerPage,g=f.page,h=f.nbPages,y=p(t,r),m=function(t){var e=t.hitsPerPage,r=void 0===e?0:e,n=t.totalPages,i=void 0===n?0:n,a=t.estimatedTotalHits,o=t.totalHits;return null!=a?a:null!=o?o:r*i}(t),P=function(t,e,r,n){return t?function(t,e,r){for(var n=function(t){return t?"string"==typeof t?[t]:t:[]}(t),i={},a=0,o=n;a<o.length;a++){var u=o[a];for(var c in e[u])i[u]||(i[u]=r[u]||{}),i[u][c]?i[u][c]=r[u][c]:i[u][c]=0}return i}(e,r,n=n||{}):n}(r.keepZeroFacets,l,e,u);return{index:a,hitsPerPage:d,page:g,facets:P,nbPages:h,nbHits:m,processingTimeMS:n,query:i,hits:y,params:"",exhaustiveNbHits:!1,facets_stats:v(s)}}(t,e[t.indexUid],r)}));return{results:n}}function m(t,e,r){return{hitsPerPage:void 0===e?20:e,page:r||0,finite:!!t}}function P(t){return t.split(",").map((function(t){return t.trim()})).filter((function(t){return!!t}))}function b(t,r){var n=t.indexName.split(":"),i=n[0],a=n.slice(1),o=t.query,u=t.params,c=m(r.finitePagination,null==u?void 0:u.hitsPerPage,null==u?void 0:u.page),s=P(a.join(":"));return e(e(e(e({},r),{query:o}),u),{sort:s,indexUid:i,pagination:c,placeholderSearch:!1!==r.placeholderSearch,keepZeroFacets:!!r.keepZeroFacets})}function x(t){void 0===t&&(t={});var e=t;return{getEntry:function(t){if(e[t])try{return JSON.parse(e[t])}catch(t){return}},formatKey:function(t){return t.reduce((function(t,e){return t+JSON.stringify(e)}),"")},setEntry:function(t,r){e[t]=JSON.stringify(r)},clearCache:function(){e={}}}}function w(t){var r=l(e(e({},t),{placeholderSearch:!0,query:""}));return r.addFacets(),r.addIndexUid(),r.addPagination(),r.getParams()}function S(t,e,i){return r(this,void 0,void 0,(function(){var r,a,o,u,c,s;return n(this,(function(n){switch(n.label){case 0:return l="indexUid",f=[],r=function(t){return!f.includes(t[l])&&(f.push(t[l]),!0)},a=e.filter(r).filter((function(t){var e=t.indexUid;return!Object.keys(i).includes(e)})),0===a.length?[2,i]:[4,t.multiSearch(a,[])];case 1:for(o=n.sent(),u=0,c=o;u<c.length;u++)s=c[u],i[s.indexUid]=s.facetDistribution||{};return[2,i]}var l,f}))}))}var T;function A(i,o,u){void 0===o&&(o=""),void 0===u&&(u={}),function(t,e,r){var n=r.requestConfig,i=r.httpClient;if("string"!=typeof t)throw new TypeError("Provided hostUrl value (1st parameter) is not a string, expected string");if("string"!=typeof e&&"function"!=typeof e)throw new TypeError("Provided apiKey value (2nd parameter) is not a string or a function, expected string or function");if(void 0!==n&&!a(n))throw new TypeError("Provided requestConfig should be an object");if(i&&"function"!=typeof i)throw new TypeError("Provided custom httpClient should be a function")}(i,o,u);var c={host:i,apiKey:o=function(t){if("function"==typeof t){var e=t();if("string"!=typeof e)throw new TypeError("Provided apiKey function (2nd parameter) did not return a string, expected string");return e}return t}(o),clientAgents:function(t){void 0===t&&(t=[]);var e="Meilisearch instant-meilisearch (v".concat("0.13.3-prototype-search-for-facet-values.0",")");return t.concat(e)}(u.clientAgents)};void 0!==u.httpClient&&(c.httpClient=u.httpClient),void 0!==u.requestConfig&&(c.requestConfig=u.requestConfig);var s,l,d,g=new t(c),h=x(),p=(s=g,l=h,{multiSearch:function(t,i){return r(this,void 0,void 0,(function(){var r,a,o,u;return n(this,(function(n){switch(n.label){case 0:return r=l.formatKey([t]),(a=l.getEntry(r))?[2,a]:[4,s.multiSearch({queries:t})];case 1:return o=n.sent(),u=o.results.map((function(t,r){return e(e({},t),{pagination:i[r]||{}})})),l.setEntry(r,u),[2,u]}}))}))}}),v={},T=(d=u,e(e({},{placeholderSearch:!0,keepZeroFacets:!1,clientAgents:[],finitePagination:!1}),d));return{clearCache:function(){return h.clearCache()},search:function(t){return r(this,void 0,void 0,(function(){var e,r,i,a,o,c,s,l,d,g,h;return n(this,(function(n){switch(n.label){case 0:for(n.trys.push([0,3,,4]),e=[],r=[],i=[],a=0,o=t;a<o.length;a++)c=o[a],s=b(c,u),l=f(s),e.push(l),d=w(s),i.push(d),r.push(s.pagination);return[4,S(p,i,v)];case 1:return v=n.sent(),[4,p.multiSearch(e,r)];case 2:return g=n.sent(),[2,y(g,v,T)];case 3:throw h=n.sent(),console.error(h),new Error(h);case 4:return[2]}}))}))},searchForFacetValues:function(t){return r(this,void 0,void 0,(function(){var r,i,a,o,c,s,l,d,h,p,v;return n(this,(function(n){switch(n.label){case 0:console.log(t),r=[],i=0,a=t,n.label=1;case 1:return i<a.length?(o=a[i],c=function(t,r){var n=t.indexName.split(":"),i=n[0],a=n.slice(1),o=t.params,u=m(r.finitePagination,null==o?void 0:o.hitsPerPage,null==o?void 0:o.page),c=P(a.join(":"));return e(e(e({},r),o),{sort:c,indexUid:i,pagination:u,placeholderSearch:!1!==r.placeholderSearch,keepZeroFacets:!!r.keepZeroFacets})}(o,u),s=f(c),l=o.indexName,delete(d=e(e({},s),{facetQuery:o.params.facetQuery,facetName:o.params.facetName})).indexUid,[4,g.index(l).searchForFacetValues(d)]):[3,4];case 2:h=n.sent(),p=h.facetHits.map((function(t){return e(e({},t),{highlighted:t.value})})),v={facetHits:p,exhaustiveFacetsCount:!1,processingTimeMS:h.processingTimeMs},r.push(v),n.label=3;case 3:return i++,[3,1];case 4:return[2,r]}}))}))}}}!function(t){t.ALL="all",t.LAST="last"}(T||(T={}));export{T as MatchingStrategies,A as instantMeiliSearch};
//# sourceMappingURL=instant-meilisearch.esm.min.js.map

@@ -1,2 +0,2 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("cross-fetch/polyfill")):"function"==typeof define&&define.amd?define(["exports","cross-fetch/polyfill"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).window=t.window||{})}(this,(function(t){"use strict";var e=function(){return e=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},e.apply(this,arguments)};function n(t,e,n,r){return new(n||(n=Promise))((function(i,s){function o(t){try{a(r.next(t))}catch(t){s(t)}}function u(t){try{a(r.throw(t))}catch(t){s(t)}}function a(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,u)}a((r=r.apply(t,e||[])).next())}))}function r(t,e){var n,r,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function u(u){return function(a){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,u[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&u[0]?r.return:u[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,u[1])).done)return i;switch(r=0,i&&(u=[2&u[0],i.value]),u[0]){case 0:case 1:i=u;break;case 4:return o.label++,{value:u[1],done:!1};case 5:o.label++,r=u[1],u=[0];continue;case 7:u=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==u[0]&&2!==u[0])){o=0;continue}if(3===u[0]&&(!i||u[1]>i[0]&&u[1]<i[3])){o.label=u[1];break}if(6===u[0]&&o.label<i[1]){o.label=i[1],i=u;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(u);break}i[2]&&o.ops.pop(),o.trys.pop();continue}u=e.call(t,o)}catch(t){u=[6,t],r=0}finally{n=i=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,a])}}}function i(t,e,n){if(n||2===arguments.length)for(var r,i=0,s=e.length;i<s;i++)!r&&i in e||(r||(r=Array.prototype.slice.call(e,0,i)),r[i]=e[i]);return t.concat(r||Array.prototype.slice.call(e))}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var s=function(t){var e={exports:{}};return t(e,e.exports),e.exports}((function(t,e){!function(t){var e={ALL:"all",LAST:"last"},n={JSON:"application/json",CSV:"text/csv",NDJSON:"application/x-ndjson"},r=function(t,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},r(t,e)};function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var s=function(){return s=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},s.apply(this,arguments)};function o(t,e,n,r){function i(t){return t instanceof n?t:new n((function(e){e(t)}))}return new(n||(n=Promise))((function(n,s){function o(t){try{a(r.next(t))}catch(t){s(t)}}function u(t){try{a(r.throw(t))}catch(t){s(t)}}function a(t){t.done?n(t.value):i(t.value).then(o,u)}a((r=r.apply(t,e||[])).next())}))}function u(t,e){var n,r,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function u(t){return function(e){return a([t,e])}}function a(s){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,r=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=e.call(t,o)}catch(t){s=[6,t],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}var a=function(t){function e(n,r,i,s){var o,u,a,c=this;return c=t.call(this,n)||this,Object.setPrototypeOf(c,e.prototype),c.name="MeiliSearchCommunicationError",r instanceof Response&&(c.message=r.statusText,c.statusCode=r.status),r instanceof Error&&(c.errno=r.errno,c.code=r.code),s?(c.stack=s,c.stack=null===(o=c.stack)||void 0===o?void 0:o.replace(/(TypeError|FetchError)/,c.name),c.stack=null===(u=c.stack)||void 0===u?void 0:u.replace("Failed to fetch","request to ".concat(i," failed, reason: connect ECONNREFUSED")),c.stack=null===(a=c.stack)||void 0===a?void 0:a.replace("Not Found","Not Found: ".concat(i))):Error.captureStackTrace&&Error.captureStackTrace(c,e),c}return i(e,t),e}(Error),c=function(t){function e(e,n){var r=t.call(this,e.message)||this;return Object.setPrototypeOf(r,c.prototype),r.name="MeiliSearchApiError",r.code=e.code,r.type=e.type,r.link=e.link,r.message=e.message,r.httpStatus=n,Error.captureStackTrace&&Error.captureStackTrace(r,c),r}return i(e,t),e}(Error);function h(t){return o(this,void 0,void 0,(function(){var e;return u(this,(function(n){switch(n.label){case 0:if(t.ok)return[3,5];e=void 0,n.label=1;case 1:return n.trys.push([1,3,,4]),[4,t.json()];case 2:return e=n.sent(),[3,4];case 3:throw n.sent(),new a(t.statusText,t,t.url);case 4:throw new c(e,t.status);case 5:return[2,t]}}))}))}function d(t,e,n){if("MeiliSearchApiError"!==t.name)throw new a(t.message,t,n,e);throw t}var l=function(t){function e(n){var r=t.call(this,n)||this;return Object.setPrototypeOf(r,e.prototype),r.name="MeiliSearchError",Error.captureStackTrace&&Error.captureStackTrace(r,e),r}return i(e,t),e}(Error),f=function(t){function e(n){var r=t.call(this,n)||this;return Object.setPrototypeOf(r,e.prototype),r.name="MeiliSearchTimeOutError",Error.captureStackTrace&&Error.captureStackTrace(r,e),r}return i(e,t),e}(Error);function p(t,e){return"".concat(t,"\nHint: It might not be working because maybe you're not up to date with the Meilisearch version that ").concat(e," call requires.")}function v(t){return v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},v(t)}function y(t){return Object.entries(t).reduce((function(t,e){var n=e[0],r=e[1];return void 0!==r&&(t[n]=r),t}),{})}function g(t){return o(this,void 0,void 0,(function(){return u(this,(function(e){switch(e.label){case 0:return[4,new Promise((function(e){return setTimeout(e,t)}))];case 1:return[2,e.sent()]}}))}))}function b(t){return t.startsWith("https://")||t.startsWith("http://")?t:"http://".concat(t)}function w(t){return t.endsWith("/")||(t+="/"),t}var m="0.33.0";function q(t){return Object.keys(t).reduce((function(e,n){var r,i,o,u=t[n];return void 0===u?e:Array.isArray(u)?s(s({},e),((r={})[n]=u.join(","),r)):u instanceof Date?s(s({},e),((i={})[n]=u.toISOString(),i)):s(s({},e),((o={})[n]=u,o))}),{})}function x(t){try{return t=w(t=b(t))}catch(t){throw new l("The provided host is not valid.")}}function A(t){if(Array.isArray(t))return t.reduce((function(t,e){return t[e[0]]=e[1],t}),{});if("has"in t){var e={};return t.forEach((function(t,n){return e[n]=t})),e}return Object.assign({},t)}function T(t){var e,n,r="X-Meilisearch-Client",i="Meilisearch JavaScript (v".concat(m,")"),s="Content-Type",o="Authorization",u=A(null!==(n=null===(e=t.requestConfig)||void 0===e?void 0:e.headers)&&void 0!==n?n:{});if(t.apiKey&&!u[o]&&(u[o]="Bearer ".concat(t.apiKey)),u[s]||(u["Content-Type"]="application/json"),t.clientAgents&&Array.isArray(t.clientAgents)){var a=t.clientAgents.concat(i);u[r]=a.join(" ; ")}else{if(t.clientAgents&&!Array.isArray(t.clientAgents))throw new l('Meilisearch: The header "'.concat(r,'" should be an array of string(s).\n'));u[r]=i}return u}var R=function(){function t(t){this.headers=T(t),this.requestConfig=t.requestConfig,this.httpClient=t.httpClient;try{var e=x(t.host);this.url=new URL(e)}catch(t){throw new l("The provided host is not valid.")}}return t.prototype.request=function(t){var e,n=t.method,r=t.url,i=t.params,a=t.body,c=t.config,l=void 0===c?{}:c;return o(this,void 0,void 0,(function(){var t,o,c,f,p,v,y;return u(this,(function(u){switch(u.label){case 0:t=new URL(r,this.url),i&&(o=new URLSearchParams,Object.keys(i).filter((function(t){return null!==i[t]})).map((function(t){return o.set(t,i[t])})),t.search=o.toString()),(null===(e=l.headers)||void 0===e?void 0:e["Content-Type"])||(a=JSON.stringify(a)),c=s(s({},this.headers),l.headers),u.label=1;case 1:return u.trys.push([1,6,,7]),f=this.httpClient?this.httpClient:fetch,p=f(t.toString(),s(s(s({},l),this.requestConfig),{method:n,body:a,headers:c})),this.httpClient?[4,p]:[3,3];case 2:return[2,u.sent()];case 3:return[4,p.then((function(t){return h(t)}))];case 4:return[4,u.sent().json().catch((function(){}))];case 5:return[2,u.sent()];case 6:return v=u.sent(),y=v.stack,d(v,y,t.toString()),[3,7];case 7:return[2]}}))}))},t.prototype.get=function(t,e,n){return o(this,void 0,void 0,(function(){return u(this,(function(r){switch(r.label){case 0:return[4,this.request({method:"GET",url:t,params:e,config:n})];case 1:return[2,r.sent()]}}))}))},t.prototype.post=function(t,e,n,r){return o(this,void 0,void 0,(function(){return u(this,(function(i){switch(i.label){case 0:return[4,this.request({method:"POST",url:t,body:e,params:n,config:r})];case 1:return[2,i.sent()]}}))}))},t.prototype.put=function(t,e,n,r){return o(this,void 0,void 0,(function(){return u(this,(function(i){switch(i.label){case 0:return[4,this.request({method:"PUT",url:t,body:e,params:n,config:r})];case 1:return[2,i.sent()]}}))}))},t.prototype.patch=function(t,e,n,r){return o(this,void 0,void 0,(function(){return u(this,(function(i){switch(i.label){case 0:return[4,this.request({method:"PATCH",url:t,body:e,params:n,config:r})];case 1:return[2,i.sent()]}}))}))},t.prototype.delete=function(t,e,n,r){return o(this,void 0,void 0,(function(){return u(this,(function(i){switch(i.label){case 0:return[4,this.request({method:"DELETE",url:t,body:e,params:n,config:r})];case 1:return[2,i.sent()]}}))}))},t}(),k=function(){function t(t){this.taskUid=t.taskUid,this.indexUid=t.indexUid,this.status=t.status,this.type=t.type,this.enqueuedAt=new Date(t.enqueuedAt)}return t}(),S=function(){function t(t){this.indexUid=t.indexUid,this.status=t.status,this.type=t.type,this.uid=t.uid,this.details=t.details,this.canceledBy=t.canceledBy,this.error=t.error,this.duration=t.duration,this.startedAt=new Date(t.startedAt),this.enqueuedAt=new Date(t.enqueuedAt),this.finishedAt=new Date(t.finishedAt)}return t}(),P=function(){function t(t){this.httpRequest=new R(t)}return t.prototype.getTask=function(t){return o(this,void 0,void 0,(function(){var e,n;return u(this,(function(r){switch(r.label){case 0:return e="tasks/".concat(t),[4,this.httpRequest.get(e)];case 1:return n=r.sent(),[2,new S(n)]}}))}))},t.prototype.getTasks=function(t){return void 0===t&&(t={}),o(this,void 0,void 0,(function(){var e,n;return u(this,(function(r){switch(r.label){case 0:return e="tasks",[4,this.httpRequest.get(e,q(t))];case 1:return n=r.sent(),[2,s(s({},n),{results:n.results.map((function(t){return new S(t)}))})]}}))}))},t.prototype.waitForTask=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,i=void 0===r?5e3:r,s=n.intervalMs,a=void 0===s?50:s;return o(this,void 0,void 0,(function(){var e,n;return u(this,(function(r){switch(r.label){case 0:e=Date.now(),r.label=1;case 1:return Date.now()-e<i?[4,this.getTask(t)]:[3,4];case 2:return n=r.sent(),["enqueued","processing"].includes(n.status)?[4,g(a)]:[2,n];case 3:return r.sent(),[3,1];case 4:throw new f("timeout of ".concat(i,"ms has exceeded on process ").concat(t," when waiting a task to be resolved."))}}))}))},t.prototype.waitForTasks=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,i=void 0===r?5e3:r,s=n.intervalMs,a=void 0===s?50:s;return o(this,void 0,void 0,(function(){var e,n,r,s,o;return u(this,(function(u){switch(u.label){case 0:e=[],n=0,r=t,u.label=1;case 1:return n<r.length?(s=r[n],[4,this.waitForTask(s,{timeOutMs:i,intervalMs:a})]):[3,4];case 2:o=u.sent(),e.push(o),u.label=3;case 3:return n++,[3,1];case 4:return[2,e]}}))}))},t.prototype.cancelTasks=function(t){return void 0===t&&(t={}),o(this,void 0,void 0,(function(){var e,n;return u(this,(function(r){switch(r.label){case 0:return e="tasks/cancel",[4,this.httpRequest.post(e,{},q(t))];case 1:return n=r.sent(),[2,new k(n)]}}))}))},t.prototype.deleteTasks=function(t){return void 0===t&&(t={}),o(this,void 0,void 0,(function(){var e,n;return u(this,(function(r){switch(r.label){case 0:return e="tasks",[4,this.httpRequest.delete(e,{},q(t))];case 1:return n=r.sent(),[2,new k(n)]}}))}))},t}(),O=function(){function t(t,e,n){this.uid=e,this.primaryKey=n,this.httpRequest=new R(t),this.tasks=new P(t)}return t.prototype.search=function(t,e,n){return o(this,void 0,void 0,(function(){var r;return u(this,(function(i){switch(i.label){case 0:return r="indexes/".concat(this.uid,"/search"),[4,this.httpRequest.post(r,y(s({q:t},e)),void 0,n)];case 1:return[2,i.sent()]}}))}))},t.prototype.searchGet=function(t,e,n){var r,i,a,c,h;return o(this,void 0,void 0,(function(){var o,d,f;return u(this,(function(u){switch(u.label){case 0:return o="indexes/".concat(this.uid,"/search"),d=function(t){if("string"==typeof t)return t;if(Array.isArray(t))throw new l("The filter query parameter should be in string format when using searchGet")},f=s(s({q:t},e),{filter:d(null==e?void 0:e.filter),sort:null===(r=null==e?void 0:e.sort)||void 0===r?void 0:r.join(","),facets:null===(i=null==e?void 0:e.facets)||void 0===i?void 0:i.join(","),attributesToRetrieve:null===(a=null==e?void 0:e.attributesToRetrieve)||void 0===a?void 0:a.join(","),attributesToCrop:null===(c=null==e?void 0:e.attributesToCrop)||void 0===c?void 0:c.join(","),attributesToHighlight:null===(h=null==e?void 0:e.attributesToHighlight)||void 0===h?void 0:h.join(",")}),[4,this.httpRequest.get(o,y(f),n)];case 1:return[2,u.sent()]}}))}))},t.prototype.getRawInfo=function(){return o(this,void 0,void 0,(function(){var t,e;return u(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid),[4,this.httpRequest.get(t)];case 1:return e=n.sent(),this.primaryKey=e.primaryKey,this.updatedAt=new Date(e.updatedAt),this.createdAt=new Date(e.createdAt),[2,e]}}))}))},t.prototype.fetchInfo=function(){return o(this,void 0,void 0,(function(){return u(this,(function(t){switch(t.label){case 0:return[4,this.getRawInfo()];case 1:return t.sent(),[2,this]}}))}))},t.prototype.fetchPrimaryKey=function(){return o(this,void 0,void 0,(function(){var t;return u(this,(function(e){switch(e.label){case 0:return t=this,[4,this.getRawInfo()];case 1:return t.primaryKey=e.sent().primaryKey,[2,this.primaryKey]}}))}))},t.create=function(t,e,n){return void 0===e&&(e={}),o(this,void 0,void 0,(function(){var r,i;return u(this,(function(o){switch(o.label){case 0:return r="indexes",[4,new R(n).post(r,s(s({},e),{uid:t}))];case 1:return i=o.sent(),[2,new k(i)]}}))}))},t.prototype.update=function(t){return o(this,void 0,void 0,(function(){var e,n;return u(this,(function(r){switch(r.label){case 0:return e="indexes/".concat(this.uid),[4,this.httpRequest.patch(e,t)];case 1:return(n=r.sent()).enqueuedAt=new Date(n.enqueuedAt),[2,n]}}))}))},t.prototype.delete=function(){return o(this,void 0,void 0,(function(){var t,e;return u(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid),[4,this.httpRequest.delete(t)];case 1:return e=n.sent(),[2,new k(e)]}}))}))},t.prototype.getTasks=function(t){return void 0===t&&(t={}),o(this,void 0,void 0,(function(){return u(this,(function(e){switch(e.label){case 0:return[4,this.tasks.getTasks(s(s({},t),{indexUids:[this.uid]}))];case 1:return[2,e.sent()]}}))}))},t.prototype.getTask=function(t){return o(this,void 0,void 0,(function(){return u(this,(function(e){switch(e.label){case 0:return[4,this.tasks.getTask(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.waitForTasks=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,i=void 0===r?5e3:r,s=n.intervalMs,a=void 0===s?50:s;return o(this,void 0,void 0,(function(){return u(this,(function(e){switch(e.label){case 0:return[4,this.tasks.waitForTasks(t,{timeOutMs:i,intervalMs:a})];case 1:return[2,e.sent()]}}))}))},t.prototype.waitForTask=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,i=void 0===r?5e3:r,s=n.intervalMs,a=void 0===s?50:s;return o(this,void 0,void 0,(function(){return u(this,(function(e){switch(e.label){case 0:return[4,this.tasks.waitForTask(t,{timeOutMs:i,intervalMs:a})];case 1:return[2,e.sent()]}}))}))},t.prototype.getStats=function(){return o(this,void 0,void 0,(function(){var t;return u(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/stats"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getDocuments=function(t){var e;return void 0===t&&(t={}),o(this,void 0,void 0,(function(){var n,r,i;return u(this,(function(o){switch(o.label){case 0:if(void 0===(t=y(t)).filter)return[3,5];o.label=1;case 1:return o.trys.push([1,3,,4]),r="indexes/".concat(this.uid,"/documents/fetch"),[4,this.httpRequest.post(r,t)];case 2:return[2,o.sent()];case 3:throw((n=o.sent())instanceof a||n instanceof c)&&(n.message=p(n.message,"getDocuments")),n;case 4:return[3,7];case 5:return r="indexes/".concat(this.uid,"/documents"),i=Array.isArray(null==t?void 0:t.fields)?{fields:null===(e=null==t?void 0:t.fields)||void 0===e?void 0:e.join(",")}:{},[4,this.httpRequest.get(r,s(s({},t),i))];case 6:return[2,o.sent()];case 7:return[2]}}))}))},t.prototype.getDocument=function(t,e){return o(this,void 0,void 0,(function(){var n,r;return u(this,(function(i){switch(i.label){case 0:return n="indexes/".concat(this.uid,"/documents/").concat(t),r=function(){var t;if(Array.isArray(null==e?void 0:e.fields))return null===(t=null==e?void 0:e.fields)||void 0===t?void 0:t.join(",")}(),[4,this.httpRequest.get(n,y(s(s({},e),{fields:r})))];case 1:return[2,i.sent()]}}))}))},t.prototype.addDocuments=function(t,e){return o(this,void 0,void 0,(function(){var n,r;return u(this,(function(i){switch(i.label){case 0:return n="indexes/".concat(this.uid,"/documents"),[4,this.httpRequest.post(n,t,e)];case 1:return r=i.sent(),[2,new k(r)]}}))}))},t.prototype.addDocumentsFromString=function(t,e,n){return o(this,void 0,void 0,(function(){var r,i;return u(this,(function(s){switch(s.label){case 0:return r="indexes/".concat(this.uid,"/documents"),[4,this.httpRequest.post(r,t,n,{headers:{"Content-Type":e}})];case 1:return i=s.sent(),[2,new k(i)]}}))}))},t.prototype.addDocumentsInBatches=function(t,e,n){return void 0===e&&(e=1e3),o(this,void 0,void 0,(function(){var r,i,s,o;return u(this,(function(u){switch(u.label){case 0:r=[],i=0,u.label=1;case 1:return i<t.length?(o=(s=r).push,[4,this.addDocuments(t.slice(i,i+e),n)]):[3,4];case 2:o.apply(s,[u.sent()]),u.label=3;case 3:return i+=e,[3,1];case 4:return[2,r]}}))}))},t.prototype.updateDocuments=function(t,e){return o(this,void 0,void 0,(function(){var n,r;return u(this,(function(i){switch(i.label){case 0:return n="indexes/".concat(this.uid,"/documents"),[4,this.httpRequest.put(n,t,e)];case 1:return r=i.sent(),[2,new k(r)]}}))}))},t.prototype.updateDocumentsInBatches=function(t,e,n){return void 0===e&&(e=1e3),o(this,void 0,void 0,(function(){var r,i,s,o;return u(this,(function(u){switch(u.label){case 0:r=[],i=0,u.label=1;case 1:return i<t.length?(o=(s=r).push,[4,this.updateDocuments(t.slice(i,i+e),n)]):[3,4];case 2:o.apply(s,[u.sent()]),u.label=3;case 3:return i+=e,[3,1];case 4:return[2,r]}}))}))},t.prototype.updateDocumentsFromString=function(t,e,n){return o(this,void 0,void 0,(function(){var r,i;return u(this,(function(s){switch(s.label){case 0:return r="indexes/".concat(this.uid,"/documents"),[4,this.httpRequest.put(r,t,n,{headers:{"Content-Type":e}})];case 1:return i=s.sent(),[2,new k(i)]}}))}))},t.prototype.deleteDocument=function(t){return o(this,void 0,void 0,(function(){var e,n;return u(this,(function(r){switch(r.label){case 0:return e="indexes/".concat(this.uid,"/documents/").concat(t),[4,this.httpRequest.delete(e)];case 1:return(n=r.sent()).enqueuedAt=new Date(n.enqueuedAt),[2,n]}}))}))},t.prototype.deleteDocuments=function(t){return o(this,void 0,void 0,(function(){var e,n,r,i,s;return u(this,(function(o){switch(o.label){case 0:e=!Array.isArray(t)&&"object"===v(t),n=e?"documents/delete":"documents/delete-batch",r="indexes/".concat(this.uid,"/").concat(n),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,this.httpRequest.post(r,t)];case 2:return i=o.sent(),[2,new k(i)];case 3:throw((s=o.sent())instanceof a&&e||s instanceof c)&&(s.message=p(s.message,"deleteDocuments")),s;case 4:return[2]}}))}))},t.prototype.deleteAllDocuments=function(){return o(this,void 0,void 0,(function(){var t,e;return u(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid,"/documents"),[4,this.httpRequest.delete(t)];case 1:return(e=n.sent()).enqueuedAt=new Date(e.enqueuedAt),[2,e]}}))}))},t.prototype.getSettings=function(){return o(this,void 0,void 0,(function(){var t;return u(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateSettings=function(t){return o(this,void 0,void 0,(function(){var e,n;return u(this,(function(r){switch(r.label){case 0:return e="indexes/".concat(this.uid,"/settings"),[4,this.httpRequest.patch(e,t)];case 1:return(n=r.sent()).enqueued=new Date(n.enqueuedAt),[2,n]}}))}))},t.prototype.resetSettings=function(){return o(this,void 0,void 0,(function(){var t,e;return u(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid,"/settings"),[4,this.httpRequest.delete(t)];case 1:return(e=n.sent()).enqueuedAt=new Date(e.enqueuedAt),[2,e]}}))}))},t.prototype.getPagination=function(){return o(this,void 0,void 0,(function(){var t;return u(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/pagination"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updatePagination=function(t){return o(this,void 0,void 0,(function(){var e,n;return u(this,(function(r){switch(r.label){case 0:return e="indexes/".concat(this.uid,"/settings/pagination"),[4,this.httpRequest.patch(e,t)];case 1:return n=r.sent(),[2,new k(n)]}}))}))},t.prototype.resetPagination=function(){return o(this,void 0,void 0,(function(){var t,e;return u(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid,"/settings/pagination"),[4,this.httpRequest.delete(t)];case 1:return e=n.sent(),[2,new k(e)]}}))}))},t.prototype.getSynonyms=function(){return o(this,void 0,void 0,(function(){var t;return u(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/synonyms"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateSynonyms=function(t){return o(this,void 0,void 0,(function(){var e,n;return u(this,(function(r){switch(r.label){case 0:return e="indexes/".concat(this.uid,"/settings/synonyms"),[4,this.httpRequest.put(e,t)];case 1:return n=r.sent(),[2,new k(n)]}}))}))},t.prototype.resetSynonyms=function(){return o(this,void 0,void 0,(function(){var t,e;return u(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid,"/settings/synonyms"),[4,this.httpRequest.delete(t)];case 1:return(e=n.sent()).enqueuedAt=new Date(e.enqueuedAt),[2,e]}}))}))},t.prototype.getStopWords=function(){return o(this,void 0,void 0,(function(){var t;return u(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/stop-words"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateStopWords=function(t){return o(this,void 0,void 0,(function(){var e,n;return u(this,(function(r){switch(r.label){case 0:return e="indexes/".concat(this.uid,"/settings/stop-words"),[4,this.httpRequest.put(e,t)];case 1:return n=r.sent(),[2,new k(n)]}}))}))},t.prototype.resetStopWords=function(){return o(this,void 0,void 0,(function(){var t,e;return u(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid,"/settings/stop-words"),[4,this.httpRequest.delete(t)];case 1:return(e=n.sent()).enqueuedAt=new Date(e.enqueuedAt),[2,e]}}))}))},t.prototype.getRankingRules=function(){return o(this,void 0,void 0,(function(){var t;return u(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/ranking-rules"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateRankingRules=function(t){return o(this,void 0,void 0,(function(){var e,n;return u(this,(function(r){switch(r.label){case 0:return e="indexes/".concat(this.uid,"/settings/ranking-rules"),[4,this.httpRequest.put(e,t)];case 1:return n=r.sent(),[2,new k(n)]}}))}))},t.prototype.resetRankingRules=function(){return o(this,void 0,void 0,(function(){var t,e;return u(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid,"/settings/ranking-rules"),[4,this.httpRequest.delete(t)];case 1:return(e=n.sent()).enqueuedAt=new Date(e.enqueuedAt),[2,e]}}))}))},t.prototype.getDistinctAttribute=function(){return o(this,void 0,void 0,(function(){var t;return u(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/distinct-attribute"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateDistinctAttribute=function(t){return o(this,void 0,void 0,(function(){var e,n;return u(this,(function(r){switch(r.label){case 0:return e="indexes/".concat(this.uid,"/settings/distinct-attribute"),[4,this.httpRequest.put(e,t)];case 1:return n=r.sent(),[2,new k(n)]}}))}))},t.prototype.resetDistinctAttribute=function(){return o(this,void 0,void 0,(function(){var t,e;return u(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid,"/settings/distinct-attribute"),[4,this.httpRequest.delete(t)];case 1:return(e=n.sent()).enqueuedAt=new Date(e.enqueuedAt),[2,e]}}))}))},t.prototype.getFilterableAttributes=function(){return o(this,void 0,void 0,(function(){var t;return u(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/filterable-attributes"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateFilterableAttributes=function(t){return o(this,void 0,void 0,(function(){var e,n;return u(this,(function(r){switch(r.label){case 0:return e="indexes/".concat(this.uid,"/settings/filterable-attributes"),[4,this.httpRequest.put(e,t)];case 1:return n=r.sent(),[2,new k(n)]}}))}))},t.prototype.resetFilterableAttributes=function(){return o(this,void 0,void 0,(function(){var t,e;return u(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid,"/settings/filterable-attributes"),[4,this.httpRequest.delete(t)];case 1:return(e=n.sent()).enqueuedAt=new Date(e.enqueuedAt),[2,e]}}))}))},t.prototype.getSortableAttributes=function(){return o(this,void 0,void 0,(function(){var t;return u(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/sortable-attributes"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateSortableAttributes=function(t){return o(this,void 0,void 0,(function(){var e,n;return u(this,(function(r){switch(r.label){case 0:return e="indexes/".concat(this.uid,"/settings/sortable-attributes"),[4,this.httpRequest.put(e,t)];case 1:return n=r.sent(),[2,new k(n)]}}))}))},t.prototype.resetSortableAttributes=function(){return o(this,void 0,void 0,(function(){var t,e;return u(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid,"/settings/sortable-attributes"),[4,this.httpRequest.delete(t)];case 1:return(e=n.sent()).enqueuedAt=new Date(e.enqueuedAt),[2,e]}}))}))},t.prototype.getSearchableAttributes=function(){return o(this,void 0,void 0,(function(){var t;return u(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/searchable-attributes"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateSearchableAttributes=function(t){return o(this,void 0,void 0,(function(){var e,n;return u(this,(function(r){switch(r.label){case 0:return e="indexes/".concat(this.uid,"/settings/searchable-attributes"),[4,this.httpRequest.put(e,t)];case 1:return n=r.sent(),[2,new k(n)]}}))}))},t.prototype.resetSearchableAttributes=function(){return o(this,void 0,void 0,(function(){var t,e;return u(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid,"/settings/searchable-attributes"),[4,this.httpRequest.delete(t)];case 1:return(e=n.sent()).enqueuedAt=new Date(e.enqueuedAt),[2,e]}}))}))},t.prototype.getDisplayedAttributes=function(){return o(this,void 0,void 0,(function(){var t;return u(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/displayed-attributes"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateDisplayedAttributes=function(t){return o(this,void 0,void 0,(function(){var e,n;return u(this,(function(r){switch(r.label){case 0:return e="indexes/".concat(this.uid,"/settings/displayed-attributes"),[4,this.httpRequest.put(e,t)];case 1:return n=r.sent(),[2,new k(n)]}}))}))},t.prototype.resetDisplayedAttributes=function(){return o(this,void 0,void 0,(function(){var t,e;return u(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid,"/settings/displayed-attributes"),[4,this.httpRequest.delete(t)];case 1:return(e=n.sent()).enqueuedAt=new Date(e.enqueuedAt),[2,e]}}))}))},t.prototype.getTypoTolerance=function(){return o(this,void 0,void 0,(function(){var t;return u(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/typo-tolerance"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateTypoTolerance=function(t){return o(this,void 0,void 0,(function(){var e,n;return u(this,(function(r){switch(r.label){case 0:return e="indexes/".concat(this.uid,"/settings/typo-tolerance"),[4,this.httpRequest.patch(e,t)];case 1:return(n=r.sent()).enqueuedAt=new Date(n.enqueuedAt),[2,n]}}))}))},t.prototype.resetTypoTolerance=function(){return o(this,void 0,void 0,(function(){var t,e;return u(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid,"/settings/typo-tolerance"),[4,this.httpRequest.delete(t)];case 1:return(e=n.sent()).enqueuedAt=new Date(e.enqueuedAt),[2,e]}}))}))},t.prototype.getFaceting=function(){return o(this,void 0,void 0,(function(){var t;return u(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/faceting"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateFaceting=function(t){return o(this,void 0,void 0,(function(){var e,n;return u(this,(function(r){switch(r.label){case 0:return e="indexes/".concat(this.uid,"/settings/faceting"),[4,this.httpRequest.patch(e,t)];case 1:return n=r.sent(),[2,new k(n)]}}))}))},t.prototype.resetFaceting=function(){return o(this,void 0,void 0,(function(){var t,e;return u(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid,"/settings/faceting"),[4,this.httpRequest.delete(t)];case 1:return e=n.sent(),[2,new k(e)]}}))}))},t}(),D=function(t){function e(e){return t.call(this,e)||this}return i(e,t),e}(function(){function t(t){this.config=t,this.httpRequest=new R(t),this.tasks=new P(t)}return t.prototype.index=function(t){return new O(this.config,t)},t.prototype.getIndex=function(t){return o(this,void 0,void 0,(function(){return u(this,(function(e){return[2,new O(this.config,t).fetchInfo()]}))}))},t.prototype.getRawIndex=function(t){return o(this,void 0,void 0,(function(){return u(this,(function(e){return[2,new O(this.config,t).getRawInfo()]}))}))},t.prototype.getIndexes=function(t){return void 0===t&&(t={}),o(this,void 0,void 0,(function(){var e,n,r=this;return u(this,(function(i){switch(i.label){case 0:return[4,this.getRawIndexes(t)];case 1:return e=i.sent(),n=e.results.map((function(t){return new O(r.config,t.uid,t.primaryKey)})),[2,s(s({},e),{results:n})]}}))}))},t.prototype.getRawIndexes=function(t){return void 0===t&&(t={}),o(this,void 0,void 0,(function(){var e;return u(this,(function(n){switch(n.label){case 0:return e="indexes",[4,this.httpRequest.get(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.createIndex=function(t,e){return void 0===e&&(e={}),o(this,void 0,void 0,(function(){return u(this,(function(n){switch(n.label){case 0:return[4,O.create(t,e,this.config)];case 1:return[2,n.sent()]}}))}))},t.prototype.updateIndex=function(t,e){return void 0===e&&(e={}),o(this,void 0,void 0,(function(){return u(this,(function(n){switch(n.label){case 0:return[4,new O(this.config,t).update(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.deleteIndex=function(t){return o(this,void 0,void 0,(function(){return u(this,(function(e){switch(e.label){case 0:return[4,new O(this.config,t).delete()];case 1:return[2,e.sent()]}}))}))},t.prototype.deleteIndexIfExists=function(t){return o(this,void 0,void 0,(function(){var e;return u(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.deleteIndex(t)];case 1:return n.sent(),[2,!0];case 2:if("index_not_found"===(e=n.sent()).code)return[2,!1];throw e;case 3:return[2]}}))}))},t.prototype.swapIndexes=function(t){return o(this,void 0,void 0,(function(){var e;return u(this,(function(n){switch(n.label){case 0:return e="/swap-indexes",[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.multiSearch=function(t,e){return o(this,void 0,void 0,(function(){var n;return u(this,(function(r){switch(r.label){case 0:return n="multi-search",[4,this.httpRequest.post(n,t,void 0,e)];case 1:return[2,r.sent()]}}))}))},t.prototype.getTasks=function(t){return void 0===t&&(t={}),o(this,void 0,void 0,(function(){return u(this,(function(e){switch(e.label){case 0:return[4,this.tasks.getTasks(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getTask=function(t){return o(this,void 0,void 0,(function(){return u(this,(function(e){switch(e.label){case 0:return[4,this.tasks.getTask(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.waitForTasks=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,i=void 0===r?5e3:r,s=n.intervalMs,a=void 0===s?50:s;return o(this,void 0,void 0,(function(){return u(this,(function(e){switch(e.label){case 0:return[4,this.tasks.waitForTasks(t,{timeOutMs:i,intervalMs:a})];case 1:return[2,e.sent()]}}))}))},t.prototype.waitForTask=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,i=void 0===r?5e3:r,s=n.intervalMs,a=void 0===s?50:s;return o(this,void 0,void 0,(function(){return u(this,(function(e){switch(e.label){case 0:return[4,this.tasks.waitForTask(t,{timeOutMs:i,intervalMs:a})];case 1:return[2,e.sent()]}}))}))},t.prototype.cancelTasks=function(t){return o(this,void 0,void 0,(function(){return u(this,(function(e){switch(e.label){case 0:return[4,this.tasks.cancelTasks(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.deleteTasks=function(t){return void 0===t&&(t={}),o(this,void 0,void 0,(function(){return u(this,(function(e){switch(e.label){case 0:return[4,this.tasks.deleteTasks(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getKeys=function(t){return void 0===t&&(t={}),o(this,void 0,void 0,(function(){var e,n;return u(this,(function(r){switch(r.label){case 0:return e="keys",[4,this.httpRequest.get(e,t)];case 1:return(n=r.sent()).results=n.results.map((function(t){return s(s({},t),{createdAt:new Date(t.createdAt),updateAt:new Date(t.updateAt)})})),[2,n]}}))}))},t.prototype.getKey=function(t){return o(this,void 0,void 0,(function(){var e;return u(this,(function(n){switch(n.label){case 0:return e="keys/".concat(t),[4,this.httpRequest.get(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.createKey=function(t){return o(this,void 0,void 0,(function(){var e;return u(this,(function(n){switch(n.label){case 0:return e="keys",[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.updateKey=function(t,e){return o(this,void 0,void 0,(function(){var n;return u(this,(function(r){switch(r.label){case 0:return n="keys/".concat(t),[4,this.httpRequest.patch(n,e)];case 1:return[2,r.sent()]}}))}))},t.prototype.deleteKey=function(t){return o(this,void 0,void 0,(function(){var e;return u(this,(function(n){switch(n.label){case 0:return e="keys/".concat(t),[4,this.httpRequest.delete(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.health=function(){return o(this,void 0,void 0,(function(){var t;return u(this,(function(e){switch(e.label){case 0:return t="health",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.isHealthy=function(){return o(this,void 0,void 0,(function(){var t;return u(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),t="health",[4,this.httpRequest.get(t)];case 1:return e.sent(),[2,!0];case 2:return e.sent(),[2,!1];case 3:return[2]}}))}))},t.prototype.getStats=function(){return o(this,void 0,void 0,(function(){var t;return u(this,(function(e){switch(e.label){case 0:return t="stats",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getVersion=function(){return o(this,void 0,void 0,(function(){var t;return u(this,(function(e){switch(e.label){case 0:return t="version",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.createDump=function(){return o(this,void 0,void 0,(function(){var t,e;return u(this,(function(n){switch(n.label){case 0:return t="dumps",[4,this.httpRequest.post(t)];case 1:return e=n.sent(),[2,new k(e)]}}))}))},t.prototype.generateTenantToken=function(t,e,n){var r=new Error;throw new Error("Meilisearch: failed to generate a tenant token. Generation of a token only works in a node environment \n ".concat(r.stack,"."))},t}());t.ContentTypeEnum=n,t.Index=O,t.MatchingStrategies=e,t.MeiliSearch=D,t.MeiliSearchApiError=c,t.MeiliSearchCommunicationError=a,t.MeiliSearchError=l,t.MeiliSearchTimeOutError=f,t.default=D,t.httpErrorHandler=d,t.httpResponseErrorHandler=h,t.versionErrorHintMessage=p,Object.defineProperty(t,"__esModule",{value:!0})}(e)}));function o(t){return"object"==typeof t&&!Array.isArray(t)&&null!==t}function u(t){return t.replace(/(.*):(.*)/i,'"$1"="$2"')}function a(t){return"string"==typeof t?u(t):Array.isArray(t)?t.map((function(t){return Array.isArray(t)?t.map((function(t){return u(t)})).filter((function(t){return t})):u(t)})).filter((function(t){return t})):[]}function c(t){return""===t?[]:"string"==typeof t?[t]:t}function h(t,e,n){return function(t,e,n){var r=n.trim(),s=c(t),o=c(e);return i(i(i([],s,!0),o,!0),[r],!1).filter((function(t){return Array.isArray(t)?t.length:t}))}(a(n||[]),a(e||[]),t||"")}function d(t){var e={},n=t.facets,r=t.attributesToSnippet,i=t.snippetEllipsisText,s=t.attributesToRetrieve,o=t.attributesToHighlight,u=t.highlightPreTag,a=t.highlightPostTag,c=t.placeholderSearch,d=t.query,l=t.sort,f=t.pagination,p=t.matchingStrategy,v=t.filters,y=t.numericFilters,g=t.facetFilters,b=t.indexUid,w=h(v,y,g);return{getParams:function(){return e},addQuery:function(){e.q=d},addIndexUid:function(){e.indexUid=b},addFacets:function(){Array.isArray(n)?e.facets=n:"string"==typeof n&&(e.facets=[n])},addAttributesToCrop:function(){r&&(e.attributesToCrop=r)},addCropMarker:function(){null!=i&&(e.cropMarker=i)},addAttributesToRetrieve:function(){s&&(e.attributesToRetrieve=s)},addFilters:function(){w.length&&(e.filter=w)},addAttributesToHighlight:function(){e.attributesToHighlight=o||["*"]},addPreTag:function(){e.highlightPreTag=u||"__ais-highlight__"},addPostTag:function(){e.highlightPostTag=a||"__/ais-highlight__"},addPagination:function(){var t=function(t,e,n){return!!(n||e||t&&0!==t.length)}(w,d,c);if(f.finite){var n=function(t,e){var n=t.page,r=t.hitsPerPage;return e?{hitsPerPage:r,page:n+1}:{hitsPerPage:0,page:n+1}}(f,t),r=n.hitsPerPage,i=n.page;e.hitsPerPage=r,e.page=i}else{var s=function(t,e){var n=t.page,r=t.hitsPerPage;return e?{limit:r+1,offset:n*r}:{limit:0,offset:0}}(f,t),o=s.limit,u=s.offset;e.limit=o,e.offset=u}},addSort:function(){(null==l?void 0:l.length)&&(e.sort=Array.isArray(l)?l:[l])},addGeoSearchFilter:function(){var n=function(t){var e,n,r,i=t.insideBoundingBox,s=t.aroundLatLng,o=t.aroundRadius,u=t.minimumAroundRadius;if(s){var a=s.split(",").map((function(t){return Number.parseFloat(t).toFixed(5)}));e=[p=a[0],v=a[1]]}if(null==o&&null==u||("all"===o?console.warn("instant-meilisearch is not compatible with the `all` value on the aroundRadius parameter"):n=null!=o?o:u),i&&"string"==typeof i){var c=i.split(",").map((function(t){return parseFloat(t)})),h=c[0],d=c[1],l=c[2],f=c[3];r="_geoBoundingBox([".concat(h,", ").concat(d,"], [").concat(l,", ").concat(f,"])")}else if(null!=e&&null!=n){var p=e[0],v=e[1];r="_geoRadius(".concat(p,", ").concat(v,", ").concat(n,")")}return r}({insideBoundingBox:t.insideBoundingBox,aroundLatLng:t.aroundLatLng,aroundRadius:t.aroundRadius,minimumAroundRadius:t.minimumAroundRadius});n&&(e.filter?e.filter.unshift(n):e.filter=[n])},addMatchingStrategy:function(){p&&(e.matchingStrategy=p)}}}function l(t){var e=d(t);return e.addQuery(),e.addIndexUid(),e.addFacets(),e.addAttributesToHighlight(),e.addPreTag(),e.addPostTag(),e.addAttributesToRetrieve(),e.addAttributesToCrop(),e.addCropMarker(),e.addPagination(),e.addFilters(),e.addSort(),e.addGeoSearchFilter(),e.addMatchingStrategy(),e.getParams()}function f(t){return"string"==typeof t?t:void 0===t?JSON.stringify(null):JSON.stringify(t)}function p(t){return Array.isArray(t)?t.map((function(t){return p(t)})):o(t)?Object.keys(t).reduce((function(e,n){return e[n]=p(t[n]),e}),{}):{value:f(t)}}function v(t){if(!t)return{};var e=p(t);return{_highlightResult:e,_snippetResult:e}}function y(t,e){var n=t.hits,r=t.pagination.hitsPerPage,i=e.finitePagination,s=e.primaryKey;!i&&n.length>r&&n.splice(n.length-1,1);var o=n.map((function(t){if(Object.keys(t).length>0){var e=t._formatted;t._matchesPosition;var n=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]])}return n}(t,["_formatted","_matchesPosition"]),r=Object.assign(n,v(e));return s&&(r.objectID=t[s]),r}return t}));return o=function(t){for(var e,n=0;n<t.length;n++){var r="".concat(n+1e6*Math.random());t[n]._geo&&(t[n]._geoloc=t[n]._geo,t[n].objectID=r),(null===(e=t[n]._formatted)||void 0===e?void 0:e._geo)&&(t[n]._formatted._geoloc=t[n]._formatted._geo,t[n]._formatted.objectID=r)}return t}(o),o}function g(t){return Object.keys(t).reduce((function(n,r){return n[r]=e(e({},t[r]),{avg:0,sum:0}),n}),{})}function b(t,e,n){var r=t.map((function(t){return function(t,e,n){var r=t.processingTimeMs,i=t.query,s=t.indexUid,o=t.facetDistribution,u=void 0===o?{}:o,a=t.facetStats,c=void 0===a?{}:a,h=Object.keys(u),d=function(t,e){var n=e.hitsPerPage,r=e.page,i=function(t,e){if(null!=t.totalPages)return t.totalPages;if(0===e)return 0;var n=t.limit,r=void 0===n?20:n,i=t.offset;return(void 0===i?0:i)/e+1+(t.hits.length>=r?1:0)}(t,n);return{page:r,nbPages:i,hitsPerPage:n}}(t,t.pagination),l=d.hitsPerPage,f=d.page,p=d.nbPages,v=y(t,n),b=function(t){var e=t.hitsPerPage,n=void 0===e?0:e,r=t.totalPages,i=void 0===r?0:r,s=t.estimatedTotalHits,o=t.totalHits;return null!=s?s:null!=o?o:n*i}(t),w=function(t,e,n,r){return t?function(t,e,n){for(var r=function(t){return t?"string"==typeof t?[t]:t:[]}(t),i={},s=0,o=r;s<o.length;s++){var u=o[s];for(var a in e[u])i[u]||(i[u]=n[u]||{}),i[u][a]?i[u][a]=n[u][a]:i[u][a]=0}return i}(e,n,r=r||{}):r}(n.keepZeroFacets,h,e,u);return{index:s,hitsPerPage:l,page:f,facets:w,nbPages:p,nbHits:b,processingTimeMS:r,query:i,hits:v,params:"",exhaustiveNbHits:!1,facets_stats:g(c)}}(t,e[t.indexUid],n)}));return{results:r}}function w(t,n){var r,i,s,o=t.indexName.split(":"),u=o[0],a=o.slice(1),c=t.query,h=t.params,d=(r=n.finitePagination,i=null==h?void 0:h.hitsPerPage,s=null==h?void 0:h.page,{hitsPerPage:void 0===i?20:i,page:s||0,finite:!!r}),l=a.join(":").split(",").map((function(t){return t.trim()})).filter((function(t){return!!t}));return e(e(e(e({},n),{query:c}),h),{sort:l,indexUid:u,pagination:d,placeholderSearch:!1!==n.placeholderSearch,keepZeroFacets:!!n.keepZeroFacets})}function m(t){void 0===t&&(t={});var e=t;return{getEntry:function(t){if(e[t])try{return JSON.parse(e[t])}catch(t){return}},formatKey:function(t){return t.reduce((function(t,e){return t+JSON.stringify(e)}),"")},setEntry:function(t,n){e[t]=JSON.stringify(n)},clearCache:function(){e={}}}}function q(t){var n=d(e(e({},t),{placeholderSearch:!0,query:""}));return n.addFacets(),n.addIndexUid(),n.addPagination(),n.getParams()}function x(t,e,i){return n(this,void 0,void 0,(function(){var n,s,o,u,a,c;return r(this,(function(r){switch(r.label){case 0:return h="indexUid",d=[],n=function(t){return!d.includes(t[h])&&(d.push(t[h]),!0)},s=e.filter(n).filter((function(t){var e=t.indexUid;return!Object.keys(i).includes(e)})),0===s.length?[2,i]:[4,t.multiSearch(s,[])];case 1:for(o=r.sent(),u=0,a=o;u<a.length;u++)c=a[u],i[c.indexUid]=c.facetDistribution||{};return[2,i]}var h,d}))}))}var A;t.MatchingStrategies=void 0,(A=t.MatchingStrategies||(t.MatchingStrategies={})).ALL="all",A.LAST="last",t.instantMeiliSearch=function(t,i,u){void 0===i&&(i=""),void 0===u&&(u={}),function(t,e,n){var r=n.requestConfig,i=n.httpClient;if("string"!=typeof t)throw new TypeError("Provided hostUrl value (1st parameter) is not a string, expected string");if("string"!=typeof e&&"function"!=typeof e)throw new TypeError("Provided apiKey value (2nd parameter) is not a string or a function, expected string or function");if(void 0!==r&&!o(r))throw new TypeError("Provided requestConfig should be an object");if(i&&"function"!=typeof i)throw new TypeError("Provided custom httpClient should be a function")}(t,i,u);var a={host:t,apiKey:i=function(t){if("function"==typeof t){var e=t();if("string"!=typeof e)throw new TypeError("Provided apiKey function (2nd parameter) did not return a string, expected string");return e}return t}(i),clientAgents:function(t){void 0===t&&(t=[]);var e="Meilisearch instant-meilisearch (v".concat("0.13.2",")");return t.concat(e)}(u.clientAgents)};void 0!==u.httpClient&&(a.httpClient=u.httpClient),void 0!==u.requestConfig&&(a.requestConfig=u.requestConfig);var c,h,d,f=new s.MeiliSearch(a),p=m(),v=(c=f,h=p,{multiSearch:function(t,i){return n(this,void 0,void 0,(function(){var n,s,o,u;return r(this,(function(r){switch(r.label){case 0:return n=h.formatKey([t]),(s=h.getEntry(n))?[2,s]:[4,c.multiSearch({queries:t})];case 1:return o=r.sent(),u=o.results.map((function(t,n){return e(e({},t),{pagination:i[n]||{}})})),h.setEntry(n,u),[2,u]}}))}))}}),y={},g=(d=u,e(e({},{placeholderSearch:!0,keepZeroFacets:!1,clientAgents:[],finitePagination:!1}),d));return{clearCache:function(){return p.clearCache()},search:function(t){return n(this,void 0,void 0,(function(){var e,n,i,s,o,a,c,h,d,f,p;return r(this,(function(r){switch(r.label){case 0:for(r.trys.push([0,3,,4]),e=[],n=[],i=[],s=0,o=t;s<o.length;s++)a=o[s],c=w(a,u),h=l(c),e.push(h),d=q(c),i.push(d),n.push(c.pagination);return[4,x(v,i,y)];case 1:return y=r.sent(),[4,v.multiSearch(e,n)];case 2:return f=r.sent(),[2,b(f,y,g)];case 3:throw p=r.sent(),console.error(p),new Error(p);case 4:return[2]}}))}))},searchForFacetValues:function(t){return n(this,void 0,void 0,(function(){return r(this,(function(t){switch(t.label){case 0:return[4,new Promise((function(t,e){e(new Error("SearchForFacetValues is not compatible with Meilisearch")),t([])}))];case 1:return[2,t.sent()]}}))}))}}},Object.defineProperty(t,"__esModule",{value:!0})}));
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("cross-fetch/polyfill")):"function"==typeof define&&define.amd?define(["exports","cross-fetch/polyfill"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).window=t.window||{})}(this,(function(t){"use strict";var e=function(){return e=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},e.apply(this,arguments)};function n(t,e,n,r){return new(n||(n=Promise))((function(i,s){function o(t){try{a(r.next(t))}catch(t){s(t)}}function u(t){try{a(r.throw(t))}catch(t){s(t)}}function a(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,u)}a((r=r.apply(t,e||[])).next())}))}function r(t,e){var n,r,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function u(u){return function(a){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,u[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&u[0]?r.return:u[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,u[1])).done)return i;switch(r=0,i&&(u=[2&u[0],i.value]),u[0]){case 0:case 1:i=u;break;case 4:return o.label++,{value:u[1],done:!1};case 5:o.label++,r=u[1],u=[0];continue;case 7:u=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==u[0]&&2!==u[0])){o=0;continue}if(3===u[0]&&(!i||u[1]>i[0]&&u[1]<i[3])){o.label=u[1];break}if(6===u[0]&&o.label<i[1]){o.label=i[1],i=u;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(u);break}i[2]&&o.ops.pop(),o.trys.pop();continue}u=e.call(t,o)}catch(t){u=[6,t],r=0}finally{n=i=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,a])}}}function i(t,e,n){if(n||2===arguments.length)for(var r,i=0,s=e.length;i<s;i++)!r&&i in e||(r||(r=Array.prototype.slice.call(e,0,i)),r[i]=e[i]);return t.concat(r||Array.prototype.slice.call(e))}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var s=function(t){var e={exports:{}};return t(e,e.exports),e.exports}((function(t,e){!function(t){var e={ALL:"all",LAST:"last"},n={COUNT:"error",ALPHA:"alpha"},r={JSON:"application/json",CSV:"text/csv",NDJSON:"application/x-ndjson"},i=function(t,e){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},i(t,e)};function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var o=function(){return o=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},o.apply(this,arguments)};function u(t,e,n,r){function i(t){return t instanceof n?t:new n((function(e){e(t)}))}return new(n||(n=Promise))((function(n,s){function o(t){try{a(r.next(t))}catch(t){s(t)}}function u(t){try{a(r.throw(t))}catch(t){s(t)}}function a(t){t.done?n(t.value):i(t.value).then(o,u)}a((r=r.apply(t,e||[])).next())}))}function a(t,e){var n,r,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function u(t){return function(e){return a([t,e])}}function a(s){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,r=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=e.call(t,o)}catch(t){s=[6,t],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}var c=function(t){function e(n,r,i,s){var o,u,a,c=this;return c=t.call(this,n)||this,Object.setPrototypeOf(c,e.prototype),c.name="MeiliSearchCommunicationError",r instanceof Response&&(c.message=r.statusText,c.statusCode=r.status),r instanceof Error&&(c.errno=r.errno,c.code=r.code),s?(c.stack=s,c.stack=null===(o=c.stack)||void 0===o?void 0:o.replace(/(TypeError|FetchError)/,c.name),c.stack=null===(u=c.stack)||void 0===u?void 0:u.replace("Failed to fetch","request to ".concat(i," failed, reason: connect ECONNREFUSED")),c.stack=null===(a=c.stack)||void 0===a?void 0:a.replace("Not Found","Not Found: ".concat(i))):Error.captureStackTrace&&Error.captureStackTrace(c,e),c}return s(e,t),e}(Error),h=function(t){function e(e,n){var r=t.call(this,e.message)||this;return Object.setPrototypeOf(r,h.prototype),r.name="MeiliSearchApiError",r.code=e.code,r.type=e.type,r.link=e.link,r.message=e.message,r.httpStatus=n,Error.captureStackTrace&&Error.captureStackTrace(r,h),r}return s(e,t),e}(Error);function d(t){return u(this,void 0,void 0,(function(){var e;return a(this,(function(n){switch(n.label){case 0:if(t.ok)return[3,5];e=void 0,n.label=1;case 1:return n.trys.push([1,3,,4]),[4,t.json()];case 2:return e=n.sent(),[3,4];case 3:throw n.sent(),new c(t.statusText,t,t.url);case 4:throw new h(e,t.status);case 5:return[2,t]}}))}))}function l(t,e,n){if("MeiliSearchApiError"!==t.name)throw new c(t.message,t,n,e);throw t}var f=function(t){function e(n){var r=t.call(this,n)||this;return Object.setPrototypeOf(r,e.prototype),r.name="MeiliSearchError",Error.captureStackTrace&&Error.captureStackTrace(r,e),r}return s(e,t),e}(Error),p=function(t){function e(n){var r=t.call(this,n)||this;return Object.setPrototypeOf(r,e.prototype),r.name="MeiliSearchTimeOutError",Error.captureStackTrace&&Error.captureStackTrace(r,e),r}return s(e,t),e}(Error);function v(t,e){return"".concat(t,"\nHint: It might not be working because maybe you're not up to date with the Meilisearch version that ").concat(e," call requires.")}function y(t){return y="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},y(t)}function g(t){return Object.entries(t).reduce((function(t,e){var n=e[0],r=e[1];return void 0!==r&&(t[n]=r),t}),{})}function b(t){return u(this,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return[4,new Promise((function(e){return setTimeout(e,t)}))];case 1:return[2,e.sent()]}}))}))}function w(t){return t.startsWith("https://")||t.startsWith("http://")?t:"http://".concat(t)}function m(t){return t.endsWith("/")||(t+="/"),t}var q="0.33.0-prototype-search-for-facet-values.1";function x(t){return Object.keys(t).reduce((function(e,n){var r,i,s,u=t[n];return void 0===u?e:Array.isArray(u)?o(o({},e),((r={})[n]=u.join(","),r)):u instanceof Date?o(o({},e),((i={})[n]=u.toISOString(),i)):o(o({},e),((s={})[n]=u,s))}),{})}function A(t){try{return t=m(t=w(t))}catch(t){throw new f("The provided host is not valid.")}}function T(t){if(Array.isArray(t))return t.reduce((function(t,e){return t[e[0]]=e[1],t}),{});if("has"in t){var e={};return t.forEach((function(t,n){return e[n]=t})),e}return Object.assign({},t)}function R(t){var e,n,r="X-Meilisearch-Client",i="Meilisearch JavaScript (v".concat(q,")"),s="Content-Type",o="Authorization",u=T(null!==(n=null===(e=t.requestConfig)||void 0===e?void 0:e.headers)&&void 0!==n?n:{});if(t.apiKey&&!u[o]&&(u[o]="Bearer ".concat(t.apiKey)),u[s]||(u["Content-Type"]="application/json"),t.clientAgents&&Array.isArray(t.clientAgents)){var a=t.clientAgents.concat(i);u[r]=a.join(" ; ")}else{if(t.clientAgents&&!Array.isArray(t.clientAgents))throw new f('Meilisearch: The header "'.concat(r,'" should be an array of string(s).\n'));u[r]=i}return u}var k=function(){function t(t){this.headers=R(t),this.requestConfig=t.requestConfig,this.httpClient=t.httpClient;try{var e=A(t.host);this.url=new URL(e)}catch(t){throw new f("The provided host is not valid.")}}return t.prototype.request=function(t){var e,n=t.method,r=t.url,i=t.params,s=t.body,c=t.config,h=void 0===c?{}:c;return u(this,void 0,void 0,(function(){var t,u,c,f,p,v,y;return a(this,(function(a){switch(a.label){case 0:t=new URL(r,this.url),i&&(u=new URLSearchParams,Object.keys(i).filter((function(t){return null!==i[t]})).map((function(t){return u.set(t,i[t])})),t.search=u.toString()),(null===(e=h.headers)||void 0===e?void 0:e["Content-Type"])||(s=JSON.stringify(s)),c=o(o({},this.headers),h.headers),a.label=1;case 1:return a.trys.push([1,6,,7]),f=this.httpClient?this.httpClient:fetch,p=f(t.toString(),o(o(o({},h),this.requestConfig),{method:n,body:s,headers:c})),this.httpClient?[4,p]:[3,3];case 2:return[2,a.sent()];case 3:return[4,p.then((function(t){return d(t)}))];case 4:return[4,a.sent().json().catch((function(){}))];case 5:return[2,a.sent()];case 6:return v=a.sent(),y=v.stack,l(v,y,t.toString()),[3,7];case 7:return[2]}}))}))},t.prototype.get=function(t,e,n){return u(this,void 0,void 0,(function(){return a(this,(function(r){switch(r.label){case 0:return[4,this.request({method:"GET",url:t,params:e,config:n})];case 1:return[2,r.sent()]}}))}))},t.prototype.post=function(t,e,n,r){return u(this,void 0,void 0,(function(){return a(this,(function(i){switch(i.label){case 0:return[4,this.request({method:"POST",url:t,body:e,params:n,config:r})];case 1:return[2,i.sent()]}}))}))},t.prototype.put=function(t,e,n,r){return u(this,void 0,void 0,(function(){return a(this,(function(i){switch(i.label){case 0:return[4,this.request({method:"PUT",url:t,body:e,params:n,config:r})];case 1:return[2,i.sent()]}}))}))},t.prototype.patch=function(t,e,n,r){return u(this,void 0,void 0,(function(){return a(this,(function(i){switch(i.label){case 0:return[4,this.request({method:"PATCH",url:t,body:e,params:n,config:r})];case 1:return[2,i.sent()]}}))}))},t.prototype.delete=function(t,e,n,r){return u(this,void 0,void 0,(function(){return a(this,(function(i){switch(i.label){case 0:return[4,this.request({method:"DELETE",url:t,body:e,params:n,config:r})];case 1:return[2,i.sent()]}}))}))},t}(),S=function(){function t(t){this.taskUid=t.taskUid,this.indexUid=t.indexUid,this.status=t.status,this.type=t.type,this.enqueuedAt=new Date(t.enqueuedAt)}return t}(),P=function(){function t(t){this.indexUid=t.indexUid,this.status=t.status,this.type=t.type,this.uid=t.uid,this.details=t.details,this.canceledBy=t.canceledBy,this.error=t.error,this.duration=t.duration,this.startedAt=new Date(t.startedAt),this.enqueuedAt=new Date(t.enqueuedAt),this.finishedAt=new Date(t.finishedAt)}return t}(),O=function(){function t(t){this.httpRequest=new k(t)}return t.prototype.getTask=function(t){return u(this,void 0,void 0,(function(){var e,n;return a(this,(function(r){switch(r.label){case 0:return e="tasks/".concat(t),[4,this.httpRequest.get(e)];case 1:return n=r.sent(),[2,new P(n)]}}))}))},t.prototype.getTasks=function(t){return void 0===t&&(t={}),u(this,void 0,void 0,(function(){var e,n;return a(this,(function(r){switch(r.label){case 0:return e="tasks",[4,this.httpRequest.get(e,x(t))];case 1:return n=r.sent(),[2,o(o({},n),{results:n.results.map((function(t){return new P(t)}))})]}}))}))},t.prototype.waitForTask=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,i=void 0===r?5e3:r,s=n.intervalMs,o=void 0===s?50:s;return u(this,void 0,void 0,(function(){var e,n;return a(this,(function(r){switch(r.label){case 0:e=Date.now(),r.label=1;case 1:return Date.now()-e<i?[4,this.getTask(t)]:[3,4];case 2:return n=r.sent(),["enqueued","processing"].includes(n.status)?[4,b(o)]:[2,n];case 3:return r.sent(),[3,1];case 4:throw new p("timeout of ".concat(i,"ms has exceeded on process ").concat(t," when waiting a task to be resolved."))}}))}))},t.prototype.waitForTasks=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,i=void 0===r?5e3:r,s=n.intervalMs,o=void 0===s?50:s;return u(this,void 0,void 0,(function(){var e,n,r,s,u;return a(this,(function(a){switch(a.label){case 0:e=[],n=0,r=t,a.label=1;case 1:return n<r.length?(s=r[n],[4,this.waitForTask(s,{timeOutMs:i,intervalMs:o})]):[3,4];case 2:u=a.sent(),e.push(u),a.label=3;case 3:return n++,[3,1];case 4:return[2,e]}}))}))},t.prototype.cancelTasks=function(t){return void 0===t&&(t={}),u(this,void 0,void 0,(function(){var e,n;return a(this,(function(r){switch(r.label){case 0:return e="tasks/cancel",[4,this.httpRequest.post(e,{},x(t))];case 1:return n=r.sent(),[2,new S(n)]}}))}))},t.prototype.deleteTasks=function(t){return void 0===t&&(t={}),u(this,void 0,void 0,(function(){var e,n;return a(this,(function(r){switch(r.label){case 0:return e="tasks",[4,this.httpRequest.delete(e,{},x(t))];case 1:return n=r.sent(),[2,new S(n)]}}))}))},t}(),M=function(){function t(t,e,n){this.uid=e,this.primaryKey=n,this.httpRequest=new k(t),this.tasks=new O(t)}return t.prototype.search=function(t,e,n){return u(this,void 0,void 0,(function(){var r;return a(this,(function(i){switch(i.label){case 0:return r="indexes/".concat(this.uid,"/search"),[4,this.httpRequest.post(r,g(o({q:t},e)),void 0,n)];case 1:return[2,i.sent()]}}))}))},t.prototype.searchGet=function(t,e,n){var r,i,s,c,h;return u(this,void 0,void 0,(function(){var u,d,l;return a(this,(function(a){switch(a.label){case 0:return u="indexes/".concat(this.uid,"/search"),d=function(t){if("string"==typeof t)return t;if(Array.isArray(t))throw new f("The filter query parameter should be in string format when using searchGet")},l=o(o({q:t},e),{filter:d(null==e?void 0:e.filter),sort:null===(r=null==e?void 0:e.sort)||void 0===r?void 0:r.join(","),facets:null===(i=null==e?void 0:e.facets)||void 0===i?void 0:i.join(","),attributesToRetrieve:null===(s=null==e?void 0:e.attributesToRetrieve)||void 0===s?void 0:s.join(","),attributesToCrop:null===(c=null==e?void 0:e.attributesToCrop)||void 0===c?void 0:c.join(","),attributesToHighlight:null===(h=null==e?void 0:e.attributesToHighlight)||void 0===h?void 0:h.join(",")}),[4,this.httpRequest.get(u,g(l),n)];case 1:return[2,a.sent()]}}))}))},t.prototype.searchForFacetValues=function(t,e){return u(this,void 0,void 0,(function(){var n;return a(this,(function(r){switch(r.label){case 0:return n="indexes/".concat(this.uid,"/facet-search"),[4,this.httpRequest.post(n,g(t),void 0,e)];case 1:return[2,r.sent()]}}))}))},t.prototype.getRawInfo=function(){return u(this,void 0,void 0,(function(){var t,e;return a(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid),[4,this.httpRequest.get(t)];case 1:return e=n.sent(),this.primaryKey=e.primaryKey,this.updatedAt=new Date(e.updatedAt),this.createdAt=new Date(e.createdAt),[2,e]}}))}))},t.prototype.fetchInfo=function(){return u(this,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,this.getRawInfo()];case 1:return t.sent(),[2,this]}}))}))},t.prototype.fetchPrimaryKey=function(){return u(this,void 0,void 0,(function(){var t;return a(this,(function(e){switch(e.label){case 0:return t=this,[4,this.getRawInfo()];case 1:return t.primaryKey=e.sent().primaryKey,[2,this.primaryKey]}}))}))},t.create=function(t,e,n){return void 0===e&&(e={}),u(this,void 0,void 0,(function(){var r,i;return a(this,(function(s){switch(s.label){case 0:return r="indexes",[4,new k(n).post(r,o(o({},e),{uid:t}))];case 1:return i=s.sent(),[2,new S(i)]}}))}))},t.prototype.update=function(t){return u(this,void 0,void 0,(function(){var e,n;return a(this,(function(r){switch(r.label){case 0:return e="indexes/".concat(this.uid),[4,this.httpRequest.patch(e,t)];case 1:return(n=r.sent()).enqueuedAt=new Date(n.enqueuedAt),[2,n]}}))}))},t.prototype.delete=function(){return u(this,void 0,void 0,(function(){var t,e;return a(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid),[4,this.httpRequest.delete(t)];case 1:return e=n.sent(),[2,new S(e)]}}))}))},t.prototype.getTasks=function(t){return void 0===t&&(t={}),u(this,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return[4,this.tasks.getTasks(o(o({},t),{indexUids:[this.uid]}))];case 1:return[2,e.sent()]}}))}))},t.prototype.getTask=function(t){return u(this,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return[4,this.tasks.getTask(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.waitForTasks=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,i=void 0===r?5e3:r,s=n.intervalMs,o=void 0===s?50:s;return u(this,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return[4,this.tasks.waitForTasks(t,{timeOutMs:i,intervalMs:o})];case 1:return[2,e.sent()]}}))}))},t.prototype.waitForTask=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,i=void 0===r?5e3:r,s=n.intervalMs,o=void 0===s?50:s;return u(this,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return[4,this.tasks.waitForTask(t,{timeOutMs:i,intervalMs:o})];case 1:return[2,e.sent()]}}))}))},t.prototype.getStats=function(){return u(this,void 0,void 0,(function(){var t;return a(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/stats"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getDocuments=function(t){var e;return void 0===t&&(t={}),u(this,void 0,void 0,(function(){var n,r,i;return a(this,(function(s){switch(s.label){case 0:if(void 0===(t=g(t)).filter)return[3,5];s.label=1;case 1:return s.trys.push([1,3,,4]),r="indexes/".concat(this.uid,"/documents/fetch"),[4,this.httpRequest.post(r,t)];case 2:return[2,s.sent()];case 3:throw((n=s.sent())instanceof c||n instanceof h)&&(n.message=v(n.message,"getDocuments")),n;case 4:return[3,7];case 5:return r="indexes/".concat(this.uid,"/documents"),i=Array.isArray(null==t?void 0:t.fields)?{fields:null===(e=null==t?void 0:t.fields)||void 0===e?void 0:e.join(",")}:{},[4,this.httpRequest.get(r,o(o({},t),i))];case 6:return[2,s.sent()];case 7:return[2]}}))}))},t.prototype.getDocument=function(t,e){return u(this,void 0,void 0,(function(){var n,r;return a(this,(function(i){switch(i.label){case 0:return n="indexes/".concat(this.uid,"/documents/").concat(t),r=function(){var t;if(Array.isArray(null==e?void 0:e.fields))return null===(t=null==e?void 0:e.fields)||void 0===t?void 0:t.join(",")}(),[4,this.httpRequest.get(n,g(o(o({},e),{fields:r})))];case 1:return[2,i.sent()]}}))}))},t.prototype.addDocuments=function(t,e){return u(this,void 0,void 0,(function(){var n,r;return a(this,(function(i){switch(i.label){case 0:return n="indexes/".concat(this.uid,"/documents"),[4,this.httpRequest.post(n,t,e)];case 1:return r=i.sent(),[2,new S(r)]}}))}))},t.prototype.addDocumentsFromString=function(t,e,n){return u(this,void 0,void 0,(function(){var r,i;return a(this,(function(s){switch(s.label){case 0:return r="indexes/".concat(this.uid,"/documents"),[4,this.httpRequest.post(r,t,n,{headers:{"Content-Type":e}})];case 1:return i=s.sent(),[2,new S(i)]}}))}))},t.prototype.addDocumentsInBatches=function(t,e,n){return void 0===e&&(e=1e3),u(this,void 0,void 0,(function(){var r,i,s,o;return a(this,(function(u){switch(u.label){case 0:r=[],i=0,u.label=1;case 1:return i<t.length?(o=(s=r).push,[4,this.addDocuments(t.slice(i,i+e),n)]):[3,4];case 2:o.apply(s,[u.sent()]),u.label=3;case 3:return i+=e,[3,1];case 4:return[2,r]}}))}))},t.prototype.updateDocuments=function(t,e){return u(this,void 0,void 0,(function(){var n,r;return a(this,(function(i){switch(i.label){case 0:return n="indexes/".concat(this.uid,"/documents"),[4,this.httpRequest.put(n,t,e)];case 1:return r=i.sent(),[2,new S(r)]}}))}))},t.prototype.updateDocumentsInBatches=function(t,e,n){return void 0===e&&(e=1e3),u(this,void 0,void 0,(function(){var r,i,s,o;return a(this,(function(u){switch(u.label){case 0:r=[],i=0,u.label=1;case 1:return i<t.length?(o=(s=r).push,[4,this.updateDocuments(t.slice(i,i+e),n)]):[3,4];case 2:o.apply(s,[u.sent()]),u.label=3;case 3:return i+=e,[3,1];case 4:return[2,r]}}))}))},t.prototype.updateDocumentsFromString=function(t,e,n){return u(this,void 0,void 0,(function(){var r,i;return a(this,(function(s){switch(s.label){case 0:return r="indexes/".concat(this.uid,"/documents"),[4,this.httpRequest.put(r,t,n,{headers:{"Content-Type":e}})];case 1:return i=s.sent(),[2,new S(i)]}}))}))},t.prototype.deleteDocument=function(t){return u(this,void 0,void 0,(function(){var e,n;return a(this,(function(r){switch(r.label){case 0:return e="indexes/".concat(this.uid,"/documents/").concat(t),[4,this.httpRequest.delete(e)];case 1:return(n=r.sent()).enqueuedAt=new Date(n.enqueuedAt),[2,n]}}))}))},t.prototype.deleteDocuments=function(t){return u(this,void 0,void 0,(function(){var e,n,r,i,s;return a(this,(function(o){switch(o.label){case 0:e=!Array.isArray(t)&&"object"===y(t),n=e?"documents/delete":"documents/delete-batch",r="indexes/".concat(this.uid,"/").concat(n),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,this.httpRequest.post(r,t)];case 2:return i=o.sent(),[2,new S(i)];case 3:throw((s=o.sent())instanceof c&&e||s instanceof h)&&(s.message=v(s.message,"deleteDocuments")),s;case 4:return[2]}}))}))},t.prototype.deleteAllDocuments=function(){return u(this,void 0,void 0,(function(){var t,e;return a(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid,"/documents"),[4,this.httpRequest.delete(t)];case 1:return(e=n.sent()).enqueuedAt=new Date(e.enqueuedAt),[2,e]}}))}))},t.prototype.getSettings=function(){return u(this,void 0,void 0,(function(){var t;return a(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateSettings=function(t){return u(this,void 0,void 0,(function(){var e,n;return a(this,(function(r){switch(r.label){case 0:return e="indexes/".concat(this.uid,"/settings"),[4,this.httpRequest.patch(e,t)];case 1:return(n=r.sent()).enqueued=new Date(n.enqueuedAt),[2,n]}}))}))},t.prototype.resetSettings=function(){return u(this,void 0,void 0,(function(){var t,e;return a(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid,"/settings"),[4,this.httpRequest.delete(t)];case 1:return(e=n.sent()).enqueuedAt=new Date(e.enqueuedAt),[2,e]}}))}))},t.prototype.getPagination=function(){return u(this,void 0,void 0,(function(){var t;return a(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/pagination"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updatePagination=function(t){return u(this,void 0,void 0,(function(){var e,n;return a(this,(function(r){switch(r.label){case 0:return e="indexes/".concat(this.uid,"/settings/pagination"),[4,this.httpRequest.patch(e,t)];case 1:return n=r.sent(),[2,new S(n)]}}))}))},t.prototype.resetPagination=function(){return u(this,void 0,void 0,(function(){var t,e;return a(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid,"/settings/pagination"),[4,this.httpRequest.delete(t)];case 1:return e=n.sent(),[2,new S(e)]}}))}))},t.prototype.getSynonyms=function(){return u(this,void 0,void 0,(function(){var t;return a(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/synonyms"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateSynonyms=function(t){return u(this,void 0,void 0,(function(){var e,n;return a(this,(function(r){switch(r.label){case 0:return e="indexes/".concat(this.uid,"/settings/synonyms"),[4,this.httpRequest.put(e,t)];case 1:return n=r.sent(),[2,new S(n)]}}))}))},t.prototype.resetSynonyms=function(){return u(this,void 0,void 0,(function(){var t,e;return a(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid,"/settings/synonyms"),[4,this.httpRequest.delete(t)];case 1:return(e=n.sent()).enqueuedAt=new Date(e.enqueuedAt),[2,e]}}))}))},t.prototype.getStopWords=function(){return u(this,void 0,void 0,(function(){var t;return a(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/stop-words"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateStopWords=function(t){return u(this,void 0,void 0,(function(){var e,n;return a(this,(function(r){switch(r.label){case 0:return e="indexes/".concat(this.uid,"/settings/stop-words"),[4,this.httpRequest.put(e,t)];case 1:return n=r.sent(),[2,new S(n)]}}))}))},t.prototype.resetStopWords=function(){return u(this,void 0,void 0,(function(){var t,e;return a(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid,"/settings/stop-words"),[4,this.httpRequest.delete(t)];case 1:return(e=n.sent()).enqueuedAt=new Date(e.enqueuedAt),[2,e]}}))}))},t.prototype.getRankingRules=function(){return u(this,void 0,void 0,(function(){var t;return a(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/ranking-rules"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateRankingRules=function(t){return u(this,void 0,void 0,(function(){var e,n;return a(this,(function(r){switch(r.label){case 0:return e="indexes/".concat(this.uid,"/settings/ranking-rules"),[4,this.httpRequest.put(e,t)];case 1:return n=r.sent(),[2,new S(n)]}}))}))},t.prototype.resetRankingRules=function(){return u(this,void 0,void 0,(function(){var t,e;return a(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid,"/settings/ranking-rules"),[4,this.httpRequest.delete(t)];case 1:return(e=n.sent()).enqueuedAt=new Date(e.enqueuedAt),[2,e]}}))}))},t.prototype.getDistinctAttribute=function(){return u(this,void 0,void 0,(function(){var t;return a(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/distinct-attribute"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateDistinctAttribute=function(t){return u(this,void 0,void 0,(function(){var e,n;return a(this,(function(r){switch(r.label){case 0:return e="indexes/".concat(this.uid,"/settings/distinct-attribute"),[4,this.httpRequest.put(e,t)];case 1:return n=r.sent(),[2,new S(n)]}}))}))},t.prototype.resetDistinctAttribute=function(){return u(this,void 0,void 0,(function(){var t,e;return a(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid,"/settings/distinct-attribute"),[4,this.httpRequest.delete(t)];case 1:return(e=n.sent()).enqueuedAt=new Date(e.enqueuedAt),[2,e]}}))}))},t.prototype.getFilterableAttributes=function(){return u(this,void 0,void 0,(function(){var t;return a(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/filterable-attributes"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateFilterableAttributes=function(t){return u(this,void 0,void 0,(function(){var e,n;return a(this,(function(r){switch(r.label){case 0:return e="indexes/".concat(this.uid,"/settings/filterable-attributes"),[4,this.httpRequest.put(e,t)];case 1:return n=r.sent(),[2,new S(n)]}}))}))},t.prototype.resetFilterableAttributes=function(){return u(this,void 0,void 0,(function(){var t,e;return a(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid,"/settings/filterable-attributes"),[4,this.httpRequest.delete(t)];case 1:return(e=n.sent()).enqueuedAt=new Date(e.enqueuedAt),[2,e]}}))}))},t.prototype.getSortableAttributes=function(){return u(this,void 0,void 0,(function(){var t;return a(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/sortable-attributes"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateSortableAttributes=function(t){return u(this,void 0,void 0,(function(){var e,n;return a(this,(function(r){switch(r.label){case 0:return e="indexes/".concat(this.uid,"/settings/sortable-attributes"),[4,this.httpRequest.put(e,t)];case 1:return n=r.sent(),[2,new S(n)]}}))}))},t.prototype.resetSortableAttributes=function(){return u(this,void 0,void 0,(function(){var t,e;return a(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid,"/settings/sortable-attributes"),[4,this.httpRequest.delete(t)];case 1:return(e=n.sent()).enqueuedAt=new Date(e.enqueuedAt),[2,e]}}))}))},t.prototype.getSearchableAttributes=function(){return u(this,void 0,void 0,(function(){var t;return a(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/searchable-attributes"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateSearchableAttributes=function(t){return u(this,void 0,void 0,(function(){var e,n;return a(this,(function(r){switch(r.label){case 0:return e="indexes/".concat(this.uid,"/settings/searchable-attributes"),[4,this.httpRequest.put(e,t)];case 1:return n=r.sent(),[2,new S(n)]}}))}))},t.prototype.resetSearchableAttributes=function(){return u(this,void 0,void 0,(function(){var t,e;return a(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid,"/settings/searchable-attributes"),[4,this.httpRequest.delete(t)];case 1:return(e=n.sent()).enqueuedAt=new Date(e.enqueuedAt),[2,e]}}))}))},t.prototype.getDisplayedAttributes=function(){return u(this,void 0,void 0,(function(){var t;return a(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/displayed-attributes"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateDisplayedAttributes=function(t){return u(this,void 0,void 0,(function(){var e,n;return a(this,(function(r){switch(r.label){case 0:return e="indexes/".concat(this.uid,"/settings/displayed-attributes"),[4,this.httpRequest.put(e,t)];case 1:return n=r.sent(),[2,new S(n)]}}))}))},t.prototype.resetDisplayedAttributes=function(){return u(this,void 0,void 0,(function(){var t,e;return a(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid,"/settings/displayed-attributes"),[4,this.httpRequest.delete(t)];case 1:return(e=n.sent()).enqueuedAt=new Date(e.enqueuedAt),[2,e]}}))}))},t.prototype.getTypoTolerance=function(){return u(this,void 0,void 0,(function(){var t;return a(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/typo-tolerance"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateTypoTolerance=function(t){return u(this,void 0,void 0,(function(){var e,n;return a(this,(function(r){switch(r.label){case 0:return e="indexes/".concat(this.uid,"/settings/typo-tolerance"),[4,this.httpRequest.patch(e,t)];case 1:return(n=r.sent()).enqueuedAt=new Date(n.enqueuedAt),[2,n]}}))}))},t.prototype.resetTypoTolerance=function(){return u(this,void 0,void 0,(function(){var t,e;return a(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid,"/settings/typo-tolerance"),[4,this.httpRequest.delete(t)];case 1:return(e=n.sent()).enqueuedAt=new Date(e.enqueuedAt),[2,e]}}))}))},t.prototype.getFaceting=function(){return u(this,void 0,void 0,(function(){var t;return a(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/faceting"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateFaceting=function(t){return u(this,void 0,void 0,(function(){var e,n;return a(this,(function(r){switch(r.label){case 0:return e="indexes/".concat(this.uid,"/settings/faceting"),[4,this.httpRequest.patch(e,t)];case 1:return n=r.sent(),[2,new S(n)]}}))}))},t.prototype.resetFaceting=function(){return u(this,void 0,void 0,(function(){var t,e;return a(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid,"/settings/faceting"),[4,this.httpRequest.delete(t)];case 1:return e=n.sent(),[2,new S(e)]}}))}))},t}(),D=function(t){function e(e){return t.call(this,e)||this}return s(e,t),e}(function(){function t(t){this.config=t,this.httpRequest=new k(t),this.tasks=new O(t)}return t.prototype.index=function(t){return new M(this.config,t)},t.prototype.getIndex=function(t){return u(this,void 0,void 0,(function(){return a(this,(function(e){return[2,new M(this.config,t).fetchInfo()]}))}))},t.prototype.getRawIndex=function(t){return u(this,void 0,void 0,(function(){return a(this,(function(e){return[2,new M(this.config,t).getRawInfo()]}))}))},t.prototype.getIndexes=function(t){return void 0===t&&(t={}),u(this,void 0,void 0,(function(){var e,n,r=this;return a(this,(function(i){switch(i.label){case 0:return[4,this.getRawIndexes(t)];case 1:return e=i.sent(),n=e.results.map((function(t){return new M(r.config,t.uid,t.primaryKey)})),[2,o(o({},e),{results:n})]}}))}))},t.prototype.getRawIndexes=function(t){return void 0===t&&(t={}),u(this,void 0,void 0,(function(){var e;return a(this,(function(n){switch(n.label){case 0:return e="indexes",[4,this.httpRequest.get(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.createIndex=function(t,e){return void 0===e&&(e={}),u(this,void 0,void 0,(function(){return a(this,(function(n){switch(n.label){case 0:return[4,M.create(t,e,this.config)];case 1:return[2,n.sent()]}}))}))},t.prototype.updateIndex=function(t,e){return void 0===e&&(e={}),u(this,void 0,void 0,(function(){return a(this,(function(n){switch(n.label){case 0:return[4,new M(this.config,t).update(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.deleteIndex=function(t){return u(this,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return[4,new M(this.config,t).delete()];case 1:return[2,e.sent()]}}))}))},t.prototype.deleteIndexIfExists=function(t){return u(this,void 0,void 0,(function(){var e;return a(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.deleteIndex(t)];case 1:return n.sent(),[2,!0];case 2:if("index_not_found"===(e=n.sent()).code)return[2,!1];throw e;case 3:return[2]}}))}))},t.prototype.swapIndexes=function(t){return u(this,void 0,void 0,(function(){var e;return a(this,(function(n){switch(n.label){case 0:return e="/swap-indexes",[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.multiSearch=function(t,e){return u(this,void 0,void 0,(function(){var n;return a(this,(function(r){switch(r.label){case 0:return n="multi-search",[4,this.httpRequest.post(n,t,void 0,e)];case 1:return[2,r.sent()]}}))}))},t.prototype.getTasks=function(t){return void 0===t&&(t={}),u(this,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return[4,this.tasks.getTasks(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getTask=function(t){return u(this,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return[4,this.tasks.getTask(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.waitForTasks=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,i=void 0===r?5e3:r,s=n.intervalMs,o=void 0===s?50:s;return u(this,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return[4,this.tasks.waitForTasks(t,{timeOutMs:i,intervalMs:o})];case 1:return[2,e.sent()]}}))}))},t.prototype.waitForTask=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,i=void 0===r?5e3:r,s=n.intervalMs,o=void 0===s?50:s;return u(this,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return[4,this.tasks.waitForTask(t,{timeOutMs:i,intervalMs:o})];case 1:return[2,e.sent()]}}))}))},t.prototype.cancelTasks=function(t){return u(this,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return[4,this.tasks.cancelTasks(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.deleteTasks=function(t){return void 0===t&&(t={}),u(this,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return[4,this.tasks.deleteTasks(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getKeys=function(t){return void 0===t&&(t={}),u(this,void 0,void 0,(function(){var e,n;return a(this,(function(r){switch(r.label){case 0:return e="keys",[4,this.httpRequest.get(e,t)];case 1:return(n=r.sent()).results=n.results.map((function(t){return o(o({},t),{createdAt:new Date(t.createdAt),updateAt:new Date(t.updateAt)})})),[2,n]}}))}))},t.prototype.getKey=function(t){return u(this,void 0,void 0,(function(){var e;return a(this,(function(n){switch(n.label){case 0:return e="keys/".concat(t),[4,this.httpRequest.get(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.createKey=function(t){return u(this,void 0,void 0,(function(){var e;return a(this,(function(n){switch(n.label){case 0:return e="keys",[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.updateKey=function(t,e){return u(this,void 0,void 0,(function(){var n;return a(this,(function(r){switch(r.label){case 0:return n="keys/".concat(t),[4,this.httpRequest.patch(n,e)];case 1:return[2,r.sent()]}}))}))},t.prototype.deleteKey=function(t){return u(this,void 0,void 0,(function(){var e;return a(this,(function(n){switch(n.label){case 0:return e="keys/".concat(t),[4,this.httpRequest.delete(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.health=function(){return u(this,void 0,void 0,(function(){var t;return a(this,(function(e){switch(e.label){case 0:return t="health",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.isHealthy=function(){return u(this,void 0,void 0,(function(){var t;return a(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),t="health",[4,this.httpRequest.get(t)];case 1:return e.sent(),[2,!0];case 2:return e.sent(),[2,!1];case 3:return[2]}}))}))},t.prototype.getStats=function(){return u(this,void 0,void 0,(function(){var t;return a(this,(function(e){switch(e.label){case 0:return t="stats",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getVersion=function(){return u(this,void 0,void 0,(function(){var t;return a(this,(function(e){switch(e.label){case 0:return t="version",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.createDump=function(){return u(this,void 0,void 0,(function(){var t,e;return a(this,(function(n){switch(n.label){case 0:return t="dumps",[4,this.httpRequest.post(t)];case 1:return e=n.sent(),[2,new S(e)]}}))}))},t.prototype.generateTenantToken=function(t,e,n){var r=new Error;throw new Error("Meilisearch: failed to generate a tenant token. Generation of a token only works in a node environment \n ".concat(r.stack,"."))},t}());t.ContentTypeEnum=r,t.Index=M,t.MatchingStrategies=e,t.MeiliSearch=D,t.MeiliSearchApiError=h,t.MeiliSearchCommunicationError=c,t.MeiliSearchError=f,t.MeiliSearchTimeOutError=p,t.SortFacetValuesBy=n,t.default=D,t.httpErrorHandler=l,t.httpResponseErrorHandler=d,t.versionErrorHintMessage=v,Object.defineProperty(t,"__esModule",{value:!0})}(e)}));function o(t){return"object"==typeof t&&!Array.isArray(t)&&null!==t}function u(t){return t.replace(/(.*):(.*)/i,'"$1"="$2"')}function a(t){return"string"==typeof t?u(t):Array.isArray(t)?t.map((function(t){return Array.isArray(t)?t.map((function(t){return u(t)})).filter((function(t){return t})):u(t)})).filter((function(t){return t})):[]}function c(t){return""===t?[]:"string"==typeof t?[t]:t}function h(t,e,n){return function(t,e,n){var r=n.trim(),s=c(t),o=c(e);return i(i(i([],s,!0),o,!0),[r],!1).filter((function(t){return Array.isArray(t)?t.length:t}))}(a(n||[]),a(e||[]),t||"")}function d(t){var e={},n=t.facets,r=t.attributesToSnippet,i=t.snippetEllipsisText,s=t.attributesToRetrieve,o=t.attributesToHighlight,u=t.highlightPreTag,a=t.highlightPostTag,c=t.placeholderSearch,d=t.query,l=t.sort,f=t.pagination,p=t.matchingStrategy,v=t.filters,y=t.numericFilters,g=t.facetFilters,b=t.indexUid,w=h(v,y,g);return{getParams:function(){return e},addQuery:function(){e.q=d},addIndexUid:function(){e.indexUid=b},addFacets:function(){Array.isArray(n)?e.facets=n:"string"==typeof n&&(e.facets=[n])},addAttributesToCrop:function(){r&&(e.attributesToCrop=r)},addCropMarker:function(){null!=i&&(e.cropMarker=i)},addAttributesToRetrieve:function(){s&&(e.attributesToRetrieve=s)},addFilters:function(){w.length&&(e.filter=w)},addAttributesToHighlight:function(){e.attributesToHighlight=o||["*"]},addPreTag:function(){e.highlightPreTag=u||"__ais-highlight__"},addPostTag:function(){e.highlightPostTag=a||"__/ais-highlight__"},addPagination:function(){var t=function(t,e,n){return!!(n||e||t&&0!==t.length)}(w,d,c);if(f.finite){var n=function(t,e){var n=t.page,r=t.hitsPerPage;return e?{hitsPerPage:r,page:n+1}:{hitsPerPage:0,page:n+1}}(f,t),r=n.hitsPerPage,i=n.page;e.hitsPerPage=r,e.page=i}else{var s=function(t,e){var n=t.page,r=t.hitsPerPage;return e?{limit:r+1,offset:n*r}:{limit:0,offset:0}}(f,t),o=s.limit,u=s.offset;e.limit=o,e.offset=u}},addSort:function(){(null==l?void 0:l.length)&&(e.sort=Array.isArray(l)?l:[l])},addGeoSearchFilter:function(){var n=function(t){var e,n,r,i=t.insideBoundingBox,s=t.aroundLatLng,o=t.aroundRadius,u=t.minimumAroundRadius;if(s){var a=s.split(",").map((function(t){return Number.parseFloat(t).toFixed(5)}));e=[p=a[0],v=a[1]]}if(null==o&&null==u||("all"===o?console.warn("instant-meilisearch is not compatible with the `all` value on the aroundRadius parameter"):n=null!=o?o:u),i&&"string"==typeof i){var c=i.split(",").map((function(t){return parseFloat(t)})),h=c[0],d=c[1],l=c[2],f=c[3];r="_geoBoundingBox([".concat(h,", ").concat(d,"], [").concat(l,", ").concat(f,"])")}else if(null!=e&&null!=n){var p=e[0],v=e[1];r="_geoRadius(".concat(p,", ").concat(v,", ").concat(n,")")}return r}({insideBoundingBox:t.insideBoundingBox,aroundLatLng:t.aroundLatLng,aroundRadius:t.aroundRadius,minimumAroundRadius:t.minimumAroundRadius});n&&(e.filter?e.filter.unshift(n):e.filter=[n])},addMatchingStrategy:function(){p&&(e.matchingStrategy=p)}}}function l(t){var e=d(t);return e.addQuery(),e.addIndexUid(),e.addFacets(),e.addAttributesToHighlight(),e.addPreTag(),e.addPostTag(),e.addAttributesToRetrieve(),e.addAttributesToCrop(),e.addCropMarker(),e.addPagination(),e.addFilters(),e.addSort(),e.addGeoSearchFilter(),e.addMatchingStrategy(),e.getParams()}function f(t){return"string"==typeof t?t:void 0===t?JSON.stringify(null):JSON.stringify(t)}function p(t){return Array.isArray(t)?t.map((function(t){return p(t)})):o(t)?Object.keys(t).reduce((function(e,n){return e[n]=p(t[n]),e}),{}):{value:f(t)}}function v(t){if(!t)return{};var e=p(t);return{_highlightResult:e,_snippetResult:e}}function y(t,e){var n=t.hits,r=t.pagination.hitsPerPage,i=e.finitePagination,s=e.primaryKey;!i&&n.length>r&&n.splice(n.length-1,1);var o=n.map((function(t){if(Object.keys(t).length>0){var e=t._formatted;t._matchesPosition;var n=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]])}return n}(t,["_formatted","_matchesPosition"]),r=Object.assign(n,v(e));return s&&(r.objectID=t[s]),r}return t}));return o=function(t){for(var e,n=0;n<t.length;n++){var r="".concat(n+1e6*Math.random());t[n]._geo&&(t[n]._geoloc=t[n]._geo,t[n].objectID=r),(null===(e=t[n]._formatted)||void 0===e?void 0:e._geo)&&(t[n]._formatted._geoloc=t[n]._formatted._geo,t[n]._formatted.objectID=r)}return t}(o),o}function g(t){return Object.keys(t).reduce((function(n,r){return n[r]=e(e({},t[r]),{avg:0,sum:0}),n}),{})}function b(t,e,n){var r=t.map((function(t){return function(t,e,n){var r=t.processingTimeMs,i=t.query,s=t.indexUid,o=t.facetDistribution,u=void 0===o?{}:o,a=t.facetStats,c=void 0===a?{}:a,h=Object.keys(u),d=function(t,e){var n=e.hitsPerPage,r=e.page,i=function(t,e){if(null!=t.totalPages)return t.totalPages;if(0===e)return 0;var n=t.limit,r=void 0===n?20:n,i=t.offset;return(void 0===i?0:i)/e+1+(t.hits.length>=r?1:0)}(t,n);return{page:r,nbPages:i,hitsPerPage:n}}(t,t.pagination),l=d.hitsPerPage,f=d.page,p=d.nbPages,v=y(t,n),b=function(t){var e=t.hitsPerPage,n=void 0===e?0:e,r=t.totalPages,i=void 0===r?0:r,s=t.estimatedTotalHits,o=t.totalHits;return null!=s?s:null!=o?o:n*i}(t),w=function(t,e,n,r){return t?function(t,e,n){for(var r=function(t){return t?"string"==typeof t?[t]:t:[]}(t),i={},s=0,o=r;s<o.length;s++){var u=o[s];for(var a in e[u])i[u]||(i[u]=n[u]||{}),i[u][a]?i[u][a]=n[u][a]:i[u][a]=0}return i}(e,n,r=r||{}):r}(n.keepZeroFacets,h,e,u);return{index:s,hitsPerPage:l,page:f,facets:w,nbPages:p,nbHits:b,processingTimeMS:r,query:i,hits:v,params:"",exhaustiveNbHits:!1,facets_stats:g(c)}}(t,e[t.indexUid],n)}));return{results:r}}function w(t,e,n){return{hitsPerPage:void 0===e?20:e,page:n||0,finite:!!t}}function m(t){return t.split(",").map((function(t){return t.trim()})).filter((function(t){return!!t}))}function q(t,n){var r=t.indexName.split(":"),i=r[0],s=r.slice(1),o=t.query,u=t.params,a=w(n.finitePagination,null==u?void 0:u.hitsPerPage,null==u?void 0:u.page),c=m(s.join(":"));return e(e(e(e({},n),{query:o}),u),{sort:c,indexUid:i,pagination:a,placeholderSearch:!1!==n.placeholderSearch,keepZeroFacets:!!n.keepZeroFacets})}function x(t){void 0===t&&(t={});var e=t;return{getEntry:function(t){if(e[t])try{return JSON.parse(e[t])}catch(t){return}},formatKey:function(t){return t.reduce((function(t,e){return t+JSON.stringify(e)}),"")},setEntry:function(t,n){e[t]=JSON.stringify(n)},clearCache:function(){e={}}}}function A(t){var n=d(e(e({},t),{placeholderSearch:!0,query:""}));return n.addFacets(),n.addIndexUid(),n.addPagination(),n.getParams()}function T(t,e,i){return n(this,void 0,void 0,(function(){var n,s,o,u,a,c;return r(this,(function(r){switch(r.label){case 0:return h="indexUid",d=[],n=function(t){return!d.includes(t[h])&&(d.push(t[h]),!0)},s=e.filter(n).filter((function(t){var e=t.indexUid;return!Object.keys(i).includes(e)})),0===s.length?[2,i]:[4,t.multiSearch(s,[])];case 1:for(o=r.sent(),u=0,a=o;u<a.length;u++)c=a[u],i[c.indexUid]=c.facetDistribution||{};return[2,i]}var h,d}))}))}var R;t.MatchingStrategies=void 0,(R=t.MatchingStrategies||(t.MatchingStrategies={})).ALL="all",R.LAST="last",t.instantMeiliSearch=function(t,i,u){void 0===i&&(i=""),void 0===u&&(u={}),function(t,e,n){var r=n.requestConfig,i=n.httpClient;if("string"!=typeof t)throw new TypeError("Provided hostUrl value (1st parameter) is not a string, expected string");if("string"!=typeof e&&"function"!=typeof e)throw new TypeError("Provided apiKey value (2nd parameter) is not a string or a function, expected string or function");if(void 0!==r&&!o(r))throw new TypeError("Provided requestConfig should be an object");if(i&&"function"!=typeof i)throw new TypeError("Provided custom httpClient should be a function")}(t,i,u);var a={host:t,apiKey:i=function(t){if("function"==typeof t){var e=t();if("string"!=typeof e)throw new TypeError("Provided apiKey function (2nd parameter) did not return a string, expected string");return e}return t}(i),clientAgents:function(t){void 0===t&&(t=[]);var e="Meilisearch instant-meilisearch (v".concat("0.13.3-prototype-search-for-facet-values.0",")");return t.concat(e)}(u.clientAgents)};void 0!==u.httpClient&&(a.httpClient=u.httpClient),void 0!==u.requestConfig&&(a.requestConfig=u.requestConfig);var c,h,d,f=new s.MeiliSearch(a),p=x(),v=(c=f,h=p,{multiSearch:function(t,i){return n(this,void 0,void 0,(function(){var n,s,o,u;return r(this,(function(r){switch(r.label){case 0:return n=h.formatKey([t]),(s=h.getEntry(n))?[2,s]:[4,c.multiSearch({queries:t})];case 1:return o=r.sent(),u=o.results.map((function(t,n){return e(e({},t),{pagination:i[n]||{}})})),h.setEntry(n,u),[2,u]}}))}))}}),y={},g=(d=u,e(e({},{placeholderSearch:!0,keepZeroFacets:!1,clientAgents:[],finitePagination:!1}),d));return{clearCache:function(){return p.clearCache()},search:function(t){return n(this,void 0,void 0,(function(){var e,n,i,s,o,a,c,h,d,f,p;return r(this,(function(r){switch(r.label){case 0:for(r.trys.push([0,3,,4]),e=[],n=[],i=[],s=0,o=t;s<o.length;s++)a=o[s],c=q(a,u),h=l(c),e.push(h),d=A(c),i.push(d),n.push(c.pagination);return[4,T(v,i,y)];case 1:return y=r.sent(),[4,v.multiSearch(e,n)];case 2:return f=r.sent(),[2,b(f,y,g)];case 3:throw p=r.sent(),console.error(p),new Error(p);case 4:return[2]}}))}))},searchForFacetValues:function(t){return n(this,void 0,void 0,(function(){var n,i,s,o,a,c,h,d,p,v,y;return r(this,(function(r){switch(r.label){case 0:console.log(t),n=[],i=0,s=t,r.label=1;case 1:return i<s.length?(o=s[i],a=function(t,n){var r=t.indexName.split(":"),i=r[0],s=r.slice(1),o=t.params,u=w(n.finitePagination,null==o?void 0:o.hitsPerPage,null==o?void 0:o.page),a=m(s.join(":"));return e(e(e({},n),o),{sort:a,indexUid:i,pagination:u,placeholderSearch:!1!==n.placeholderSearch,keepZeroFacets:!!n.keepZeroFacets})}(o,u),c=l(a),h=o.indexName,delete(d=e(e({},c),{facetQuery:o.params.facetQuery,facetName:o.params.facetName})).indexUid,[4,f.index(h).searchForFacetValues(d)]):[3,4];case 2:p=r.sent(),v=p.facetHits.map((function(t){return e(e({},t),{highlighted:t.value})})),y={facetHits:v,exhaustiveFacetsCount:!1,processingTimeMS:p.processingTimeMs},n.push(y),r.label=3;case 3:return i++,[3,1];case 4:return[2,n]}}))}))}}},Object.defineProperty(t,"__esModule",{value:!0})}));
//# sourceMappingURL=instant-meilisearch.umd.min.js.map

@@ -1,2 +0,2 @@

export { createSearchContext } from './search-context';
export { createSearchContext, createFacetSearchContext } from './search-context';
//# sourceMappingURL=index.d.ts.map

@@ -1,2 +0,2 @@

import { InstantMeiliSearchOptions, AlgoliaMultipleQueriesQuery, SearchContext } from '../types';
import { InstantMeiliSearchOptions, AlgoliaMultipleQueriesQuery, SearchContext, AlgoliaSearchForFacetValuesRequest } from '../types';
/**

@@ -8,2 +8,8 @@ * @param {AlgoliaMultipleQueriesQuery} searchRequest

export declare function createSearchContext(searchRequest: AlgoliaMultipleQueriesQuery, options: InstantMeiliSearchOptions): SearchContext;
/**
* @param {AlgoliaMultipleQueriesQuery} searchRequest
* @param {Context} options
* @returns {SearchContext}
*/
export declare function createFacetSearchContext(searchRequest: AlgoliaSearchForFacetValuesRequest, options: InstantMeiliSearchOptions): SearchContext;
//# sourceMappingURL=search-context.d.ts.map

@@ -1,2 +0,2 @@

export declare const PACKAGE_VERSION = "0.13.2";
export declare const PACKAGE_VERSION = "0.13.3-prototype-search-for-facet-values.0";
//# sourceMappingURL=package-version.d.ts.map
import type { SearchClient } from 'instantsearch.js';
import type { MultipleQueriesQuery as AlgoliaMultipleQueriesQuery } from '@algolia/client-search';
import type { MultipleQueriesQuery as AlgoliaMultipleQueriesQuery, multipleSearchForFacetValues } from '@algolia/client-search';
import type { MultiSearchQuery as MeiliSearchMultiSearchParams, MultiSearchResult, Config as MeilisearchConfig } from 'meilisearch';
export type { AlgoliaMultipleQueriesQuery, MultiSearchResult };
export type { SearchResponse as AlgoliaSearchResponse, SearchForFacetValuesResponse as AlgoliaSearchForFacetValuesResponse, } from '@algolia/client-search';
export type AlgoliaSearchForFacetValuesRequests = Parameters<ReturnType<typeof multipleSearchForFacetValues>>[0];
export type AlgoliaSearchForFacetValuesRequest = AlgoliaSearchForFacetValuesRequests[0];
export type { Filter, FacetDistribution, MeiliSearch, FacetStats as MeiliFacetStats, MultiSearchQuery as MeiliSearchMultiSearchParams, Config as MeilisearchConfig, } from 'meilisearch';

@@ -7,0 +9,0 @@ export type InstantSearchParams = AlgoliaMultipleQueriesQuery['params'];

{
"name": "@meilisearch/instant-meilisearch",
"version": "0.13.2",
"version": "0.13.3-prototype-search-for-facet-values.0",
"private": false,

@@ -50,3 +50,3 @@ "description": "The search client to use Meilisearch with InstantSearch.",

"dependencies": {
"meilisearch": "^0.33.0"
"meilisearch": "0.33.0-prototype-search-for-facet-values.1"
},

@@ -53,0 +53,0 @@ "devDependencies": {

@@ -704,7 +704,7 @@ <p align="center">

- ✅ showMoreLimit: The maximum number of displayed items. Does not work when showMoreLimit > limit.
- ❌ searchable: Whether to add a search input to let the user search for more facet values. Not supported by Meilisearch. If you'd like to see it implemented [please vote](https://roadmap.meilisearch.com/c/64-search-for-facet-values?utm_medium=social&utm_source=portal_share).
- ❌ searchablePlaceholder: The value of the search input’s placeholder. Not supported, see `searchable`.
- ❌ searchableIsAlwaysActive: When false, disables the facet search input. Not supported, see `searchable`.
- ❌ searchableEscapeFacetValues: When true, escapes the facet values. Not supported, see `searchable`.
- ❌ sortBy: Not supported natively but can be implemented manually using `transformItems` options.
- ✅ searchable: Whether to add a search input to let the user search for more facet values. Not supported by Meilisearch. If you'd like to see it implemented [please vote](https://roadmap.meilisearch.com/c/64-search-for-facet-values?utm_medium=social&utm_source=portal_share).
- ✅ searchablePlaceholder: The value of the search input’s placeholder. Not supported, see `searchable`.
- ✅ searchableIsAlwaysActive: When false, disables the facet search input. Not supported, see `searchable`.
- ❌ searchableEscapeFacetValues: When true, escapes the facet values.
- ❌ sortBy: Not supported but can be implemented manually using `transformItems` options.
- ✅ transformItems: A function to transform the items passed to the templates.

@@ -711,0 +711,0 @@ - ✅ templates: The templates to use for the widget.

@@ -11,2 +11,4 @@ import { MeiliSearch } from 'meilisearch'

MeilisearchConfig,
AlgoliaSearchForFacetValuesRequests,
AlgoliaSearchForFacetValuesResponse,
} from '../types'

@@ -23,3 +25,3 @@ import {

} from '../adapter'
import { createSearchContext } from '../contexts'
import { createSearchContext, createFacetSearchContext } from '../contexts'
import {

@@ -137,11 +139,46 @@ SearchCache,

},
searchForFacetValues: async function (_: any) {
return await new Promise((resolve, reject) => {
reject(
new Error('SearchForFacetValues is not compatible with Meilisearch')
searchForFacetValues: async function (
requests: AlgoliaSearchForFacetValuesRequests
): Promise<AlgoliaSearchForFacetValuesResponse[]> {
console.log(requests)
const results = []
for (const request of requests) {
const searchContext: SearchContext = createFacetSearchContext(
request,
instantMeiliSearchOptions
)
resolve([]) // added here to avoid compilation error
})
const meilisearchSearchQuery = adaptSearchParams(searchContext)
const index = request.indexName
const meilisearchRequest: any = {
...meilisearchSearchQuery,
facetQuery: request.params.facetQuery,
facetName: request.params.facetName,
}
delete meilisearchRequest.indexUid
const meilisearchResponse = await meilisearchClient
.index(index)
.searchForFacetValues(meilisearchRequest)
const facetHits = meilisearchResponse.facetHits.map((facetHit) => ({
...facetHit,
// not currently supported
highlighted: facetHit.value,
}))
const result = {
facetHits,
exhaustiveFacetsCount: false,
processingTimeMS: meilisearchResponse.processingTimeMs,
}
results.push(result)
}
return results
},
}
}

@@ -1,1 +0,1 @@

export { createSearchContext } from './search-context'
export { createSearchContext, createFacetSearchContext } from './search-context'

@@ -5,2 +5,3 @@ import {

SearchContext,
AlgoliaSearchForFacetValuesRequest,
} from '../types'

@@ -44,1 +45,35 @@

}
// TODO: avoid code duplication
/**
* @param {AlgoliaMultipleQueriesQuery} searchRequest
* @param {Context} options
* @returns {SearchContext}
*/
export function createFacetSearchContext(
searchRequest: AlgoliaSearchForFacetValuesRequest,
options: InstantMeiliSearchOptions
): SearchContext {
// Split index name and possible sorting rules
const [indexUid, ...sortByArray] = searchRequest.indexName.split(':')
const { params: instantSearchParams } = searchRequest
const paginationState = createPaginationState(
options.finitePagination,
instantSearchParams?.hitsPerPage,
instantSearchParams?.page
)
const sortState = createSortState(sortByArray.join(':'))
const searchContext: SearchContext = {
...options,
...instantSearchParams,
sort: sortState,
indexUid,
pagination: paginationState,
placeholderSearch: options.placeholderSearch !== false, // true by default
keepZeroFacets: !!options.keepZeroFacets, // false by default
}
return searchContext
}

@@ -1,1 +0,1 @@

export const PACKAGE_VERSION = '0.13.2'
export const PACKAGE_VERSION = '0.13.3-prototype-search-for-facet-values.0'
import type { SearchClient } from 'instantsearch.js'
import type { MultipleQueriesQuery as AlgoliaMultipleQueriesQuery } from '@algolia/client-search'
import type {
MultipleQueriesQuery as AlgoliaMultipleQueriesQuery,
multipleSearchForFacetValues,
} from '@algolia/client-search'
import type {
MultiSearchQuery as MeiliSearchMultiSearchParams,

@@ -15,2 +18,9 @@ MultiSearchResult,

export type AlgoliaSearchForFacetValuesRequests = Parameters<
ReturnType<typeof multipleSearchForFacetValues>
>[0]
export type AlgoliaSearchForFacetValuesRequest =
AlgoliaSearchForFacetValuesRequests[0]
export type {

@@ -17,0 +27,0 @@ Filter,

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc