!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).window=t.window||{})}(this,(function(t){"use strict";var e={TASK_SUCCEEDED:"succeeded",TASK_PROCESSING:"processing",TASK_FAILED:"failed",TASK_ENQUEUED:"enqueued",TASK_CANCELED:"canceled"},n={INDEX_CREATION_FAILED:"index_creation_failed",MISSING_INDEX_UID:"missing_index_uid",INDEX_ALREADY_EXISTS:"index_already_exists",INDEX_NOT_FOUND:"index_not_found",INVALID_INDEX_UID:"invalid_index_uid",INDEX_NOT_ACCESSIBLE:"index_not_accessible",INVALID_INDEX_OFFSET:"invalid_index_offset",INVALID_INDEX_LIMIT:"invalid_index_limit",INVALID_STATE:"invalid_state",PRIMARY_KEY_INFERENCE_FAILED:"primary_key_inference_failed",INDEX_PRIMARY_KEY_ALREADY_EXISTS:"index_primary_key_already_exists",INVALID_INDEX_PRIMARY_KEY:"invalid_index_primary_key",DOCUMENTS_FIELDS_LIMIT_REACHED:"document_fields_limit_reached",MISSING_DOCUMENT_ID:"missing_document_id",INVALID_DOCUMENT_ID:"invalid_document_id",INVALID_CONTENT_TYPE:"invalid_content_type",MISSING_CONTENT_TYPE:"missing_content_type",INVALID_DOCUMENT_FIELDS:"invalid_document_fields",INVALID_DOCUMENT_LIMIT:"invalid_document_limit",INVALID_DOCUMENT_OFFSET:"invalid_document_offset",INVALID_DOCUMENT_FILTER:"invalid_document_filter",MISSING_DOCUMENT_FILTER:"missing_document_filter",INVALID_DOCUMENT_VECTORS_FIELD:"invalid_document_vectors_field",PAYLOAD_TOO_LARGE:"payload_too_large",MISSING_PAYLOAD:"missing_payload",MALFORMED_PAYLOAD:"malformed_payload",NO_SPACE_LEFT_ON_DEVICE:"no_space_left_on_device",INVALID_STORE_FILE:"invalid_store_file",INVALID_RANKING_RULES:"missing_document_id",INVALID_REQUEST:"invalid_request",INVALID_DOCUMENT_GEO_FIELD:"invalid_document_geo_field",INVALID_SEARCH_Q:"invalid_search_q",INVALID_SEARCH_OFFSET:"invalid_search_offset",INVALID_SEARCH_LIMIT:"invalid_search_limit",INVALID_SEARCH_PAGE:"invalid_search_page",INVALID_SEARCH_HITS_PER_PAGE:"invalid_search_hits_per_page",INVALID_SEARCH_ATTRIBUTES_TO_RETRIEVE:"invalid_search_attributes_to_retrieve",INVALID_SEARCH_ATTRIBUTES_TO_CROP:"invalid_search_attributes_to_crop",INVALID_SEARCH_CROP_LENGTH:"invalid_search_crop_length",INVALID_SEARCH_ATTRIBUTES_TO_HIGHLIGHT:"invalid_search_attributes_to_highlight",INVALID_SEARCH_SHOW_MATCHES_POSITION:"invalid_search_show_matches_position",INVALID_SEARCH_FILTER:"invalid_search_filter",INVALID_SEARCH_SORT:"invalid_search_sort",INVALID_SEARCH_FACETS:"invalid_search_facets",INVALID_SEARCH_HIGHLIGHT_PRE_TAG:"invalid_search_highlight_pre_tag",INVALID_SEARCH_HIGHLIGHT_POST_TAG:"invalid_search_highlight_post_tag",INVALID_SEARCH_CROP_MARKER:"invalid_search_crop_marker",INVALID_SEARCH_MATCHING_STRATEGY:"invalid_search_matching_strategy",INVALID_SEARCH_VECTOR:"invalid_search_vector",INVALID_SEARCH_ATTRIBUTES_TO_SEARCH_ON:"invalid_search_attributes_to_search_on",BAD_REQUEST:"bad_request",DOCUMENT_NOT_FOUND:"document_not_found",INTERNAL:"internal",INVALID_API_KEY:"invalid_api_key",INVALID_API_KEY_DESCRIPTION:"invalid_api_key_description",INVALID_API_KEY_ACTIONS:"invalid_api_key_actions",INVALID_API_KEY_INDEXES:"invalid_api_key_indexes",INVALID_API_KEY_EXPIRES_AT:"invalid_api_key_expires_at",API_KEY_NOT_FOUND:"api_key_not_found",IMMUTABLE_API_KEY_UID:"immutable_api_key_uid",IMMUTABLE_API_KEY_ACTIONS:"immutable_api_key_actions",IMMUTABLE_API_KEY_INDEXES:"immutable_api_key_indexes",IMMUTABLE_API_KEY_EXPIRES_AT:"immutable_api_key_expires_at",IMMUTABLE_API_KEY_CREATED_AT:"immutable_api_key_created_at",IMMUTABLE_API_KEY_UPDATED_AT:"immutable_api_key_updated_at",MISSING_AUTHORIZATION_HEADER:"missing_authorization_header",UNRETRIEVABLE_DOCUMENT:"unretrievable_document",MAX_DATABASE_SIZE_LIMIT_REACHED:"database_size_limit_reached",TASK_NOT_FOUND:"task_not_found",DUMP_PROCESS_FAILED:"dump_process_failed",DUMP_NOT_FOUND:"dump_not_found",INVALID_SWAP_DUPLICATE_INDEX_FOUND:"invalid_swap_duplicate_index_found",INVALID_SWAP_INDEXES:"invalid_swap_indexes",MISSING_SWAP_INDEXES:"missing_swap_indexes",MISSING_MASTER_KEY:"missing_master_key",INVALID_TASK_TYPES:"invalid_task_types",INVALID_TASK_UIDS:"invalid_task_uids",INVALID_TASK_STATUSES:"invalid_task_statuses",INVALID_TASK_LIMIT:"invalid_task_limit",INVALID_TASK_FROM:"invalid_task_from",INVALID_TASK_CANCELED_BY:"invalid_task_canceled_by",MISSING_TASK_FILTERS:"missing_task_filters",TOO_MANY_OPEN_FILES:"too_many_open_files",IO_ERROR:"io_error",INVALID_TASK_INDEX_UIDS:"invalid_task_index_uids",IMMUTABLE_INDEX_UID:"immutable_index_uid",IMMUTABLE_INDEX_CREATED_AT:"immutable_index_created_at",IMMUTABLE_INDEX_UPDATED_AT:"immutable_index_updated_at",INVALID_SETTINGS_DISPLAYED_ATTRIBUTES:"invalid_settings_displayed_attributes",INVALID_SETTINGS_SEARCHABLE_ATTRIBUTES:"invalid_settings_searchable_attributes",INVALID_SETTINGS_FILTERABLE_ATTRIBUTES:"invalid_settings_filterable_attributes",INVALID_SETTINGS_SORTABLE_ATTRIBUTES:"invalid_settings_sortable_attributes",INVALID_SETTINGS_RANKING_RULES:"invalid_settings_ranking_rules",INVALID_SETTINGS_STOP_WORDS:"invalid_settings_stop_words",INVALID_SETTINGS_SYNONYMS:"invalid_settings_synonyms",INVALID_SETTINGS_DISTINCT_ATTRIBUTE:"invalid_settings_distinct_attribute",INVALID_SETTINGS_TYPO_TOLERANCE:"invalid_settings_typo_tolerance",INVALID_SETTINGS_FACETING:"invalid_settings_faceting",INVALID_SETTINGS_PAGINATION:"invalid_settings_pagination",INVALID_SETTINGS_SEARCH_CUTOFF_MS:"invalid_settings_search_cutoff_ms",INVALID_SETTINGS_LOCALIZED_ATTRIBUTES:"invalid_settings_localized_attributes",INVALID_TASK_BEFORE_ENQUEUED_AT:"invalid_task_before_enqueued_at",INVALID_TASK_AFTER_ENQUEUED_AT:"invalid_task_after_enqueued_at",INVALID_TASK_BEFORE_STARTED_AT:"invalid_task_before_started_at",INVALID_TASK_AFTER_STARTED_AT:"invalid_task_after_started_at",INVALID_TASK_BEFORE_FINISHED_AT:"invalid_task_before_finished_at",INVALID_TASK_AFTER_FINISHED_AT:"invalid_task_after_finished_at",MISSING_API_KEY_ACTIONS:"missing_api_key_actions",MISSING_API_KEY_INDEXES:"missing_api_key_indexes",MISSING_API_KEY_EXPIRES_AT:"missing_api_key_expires_at",INVALID_API_KEY_LIMIT:"invalid_api_key_limit",INVALID_API_KEY_OFFSET:"invalid_api_key_offset",INVALID_FACET_SEARCH_FACET_NAME:"invalid_facet_search_facet_name",MISSING_FACET_SEARCH_FACET_NAME:"missing_facet_search_facet_name",INVALID_FACET_SEARCH_FACET_QUERY:"invalid_facet_search_facet_query",INVALID_SEARCH_RANKING_SCORE_THRESHOLD:"invalid_search_ranking_score_threshold",INVALID_SIMILAR_RANKING_SCORE_THRESHOLD:"invalid_similar_ranking_score_threshold"};function r(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:s}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,u=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==n.return||n.return()}finally{if(u)throw i}}}}function h(t,e,n){return(e=m(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function f(t){return f=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},f(t)}function d(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&w(t,e)}function l(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(l=function(){return!!t})()}function v(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function _(t){for(var e=1;e=0;--i){var a=this.tryEntries[i],u=a.completion;if("root"===a.tryLoc)return s("end");if(a.tryLoc<=this.prev){var c=r.call(a,"catchLoc"),o=r.call(a,"finallyLoc");if(c&&o){if(this.prev=0;--n){var s=this.tryEntries[n];if(s.tryLoc<=this.prev&&r.call(s,"finallyLoc")&&this.prev=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),R(n),_}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var s=r.arg;R(n)}return s}}throw Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={iterator:O(e),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=t),_}},e}function w(t,e){return w=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},w(t,e)}function x(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,s,i,a,u=[],c=!0,o=!1;try{if(i=(n=n.call(t)).next,0===e);else for(;!(c=(r=i.call(n)).done)&&(u.push(r.value),u.length!==e);c=!0);}catch(t){o=!0,s=t}finally{try{if(!c&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(o)throw s}}return u}}(t,e)||A(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function m(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e);if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t,"string");return"symbol"==typeof e?e:e+""}function k(t){return k="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},k(t)}function A(t,e){if(t){if("string"==typeof t)return r(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(t,e):void 0}}function I(t){var e="function"==typeof Map?new Map:void 0;return I=function(t){if(null===t||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(e){return"function"==typeof t}}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return function(t,e,n){if(l())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,e);var s=new(t.bind.apply(t,r));return n&&w(s,n.prototype),s}(t,arguments,f(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),w(n,t)},I(t)}var g=function(t){function e(){var t;u(this,e);for(var n=arguments.length,r=new Array(n),s=0;s0&&void 0!==r[0]?r[0]:{},t.next=4,this.httpRequest.get("tasks",O(e));case 4:return n=t.sent,t.abrupt("return",_(_({},n),{},{results:n.results.map((function(t){return new M(t)}))}));case 6:case"end":return t.stop()}}),t,this)}))),function(){return a.apply(this,arguments)})},{key:"waitForTask",value:(s=i(y().mark((function t(n){var r,s,i,a,u,c,o,p=arguments;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:s=(r=p.length>1&&void 0!==p[1]?p[1]:{}).timeOutMs,i=void 0===s?5e3:s,a=r.intervalMs,u=void 0===a?50:a,c=Date.now();case 2:if(!(Date.now()-c1&&void 0!==d[1]?d[1]:{}).timeOutMs,s=void 0===r?5e3:r,i=n.intervalMs,a=void 0===i?50:i,u=[],c=p(e),t.prev=3,c.s();case 5:if((o=c.n()).done){t.next=13;break}return h=o.value,t.next=9,this.waitForTask(h,{timeOutMs:s,intervalMs:a});case 9:f=t.sent,u.push(f);case 11:t.next=5;break;case 13:t.next=18;break;case 15:t.prev=15,t.t0=t.catch(3),c.e(t.t0);case 18:return t.prev=18,c.f(),t.finish(18);case 21:return t.abrupt("return",u);case 22:case"end":return t.stop()}}),t,this,[[3,15,18,21]])}))),function(t){return r.apply(this,arguments)})},{key:"cancelTasks",value:(n=i(y().mark((function t(){var e,n,r=arguments;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=r.length>0&&void 0!==r[0]?r[0]:{},t.next=4,this.httpRequest.post("tasks/cancel",{},O(e));case 4:return n=t.sent,t.abrupt("return",new C(n));case 6:case"end":return t.stop()}}),t,this)}))),function(){return n.apply(this,arguments)})},{key:"deleteTasks",value:(t=i(y().mark((function t(){var e,n,r=arguments;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=r.length>0&&void 0!==r[0]?r[0]:{},t.next=4,this.httpRequest.delete("tasks",{},O(e));case 4:return n=t.sent,t.abrupt("return",new C(n));case 6:case"end":return t.stop()}}),t,this)}))),function(){return t.apply(this,arguments)})}]);var t,n,r,s,a,c}(),U=function(){return o((function t(e,n,r){u(this,t),h(this,"uid",void 0),h(this,"primaryKey",void 0),h(this,"createdAt",void 0),h(this,"updatedAt",void 0),h(this,"httpRequest",void 0),h(this,"tasks",void 0),this.uid=n,this.primaryKey=r,this.httpRequest=new q(e),this.tasks=new P(e)}),[{key:"search",value:(Ht=i(y().mark((function t(e,n,r){var s;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s="indexes/".concat(this.uid,"/search"),t.next=3,this.httpRequest.post(s,D(_({q:e},n)),void 0,r);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)}))),function(t,e,n){return Ht.apply(this,arguments)})},{key:"searchGet",value:(Gt=i(y().mark((function t(e,n,r){var s,i,a,u,c,o,p,h,f,d;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return h="indexes/".concat(this.uid,"/search"),f=function(t){if("string"==typeof t)return t;if(Array.isArray(t))throw new g("The filter query parameter should be in string format when using searchGet")},d=_(_({q:e},n),{},{filter:f(null==n?void 0:n.filter),sort:null==n||null===(s=n.sort)||void 0===s?void 0:s.join(","),facets:null==n||null===(i=n.facets)||void 0===i?void 0:i.join(","),attributesToRetrieve:null==n||null===(a=n.attributesToRetrieve)||void 0===a?void 0:a.join(","),attributesToCrop:null==n||null===(u=n.attributesToCrop)||void 0===u?void 0:u.join(","),attributesToHighlight:null==n||null===(c=n.attributesToHighlight)||void 0===c?void 0:c.join(","),vector:null==n||null===(o=n.vector)||void 0===o?void 0:o.join(","),attributesToSearchOn:null==n||null===(p=n.attributesToSearchOn)||void 0===p?void 0:p.join(",")}),t.next=5,this.httpRequest.get(h,D(d),r);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),t,this)}))),function(t,e,n){return Gt.apply(this,arguments)})},{key:"searchForFacetValues",value:(jt=i(y().mark((function t(e,n){var r;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r="indexes/".concat(this.uid,"/facet-search"),t.next=3,this.httpRequest.post(r,D(e),void 0,n);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)}))),function(t,e){return jt.apply(this,arguments)})},{key:"searchSimilarDocuments",value:(Kt=i(y().mark((function t(e){var n;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n="indexes/".concat(this.uid,"/similar"),t.next=3,this.httpRequest.post(n,D(e),void 0);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)}))),function(t){return Kt.apply(this,arguments)})},{key:"getRawInfo",value:(Ft=i(y().mark((function t(){var e,n;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e="indexes/".concat(this.uid),t.next=3,this.httpRequest.get(e);case 3:return n=t.sent,this.primaryKey=n.primaryKey,this.updatedAt=new Date(n.updatedAt),this.createdAt=new Date(n.createdAt),t.abrupt("return",n);case 8:case"end":return t.stop()}}),t,this)}))),function(){return Ft.apply(this,arguments)})},{key:"fetchInfo",value:(Vt=i(y().mark((function t(){return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getRawInfo();case 2:return t.abrupt("return",this);case 3:case"end":return t.stop()}}),t,this)}))),function(){return Vt.apply(this,arguments)})},{key:"fetchPrimaryKey",value:(Ut=i(y().mark((function t(){return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getRawInfo();case 2:return this.primaryKey=t.sent.primaryKey,t.abrupt("return",this.primaryKey);case 4:case"end":return t.stop()}}),t,this)}))),function(){return Ut.apply(this,arguments)})},{key:"update",value:(Pt=i(y().mark((function t(e){var n,r;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n="indexes/".concat(this.uid),t.next=3,this.httpRequest.patch(n,e);case 3:return(r=t.sent).enqueuedAt=new Date(r.enqueuedAt),t.abrupt("return",r);case 6:case"end":return t.stop()}}),t,this)}))),function(t){return Pt.apply(this,arguments)})},{key:"delete",value:(Mt=i(y().mark((function t(){var e,n;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e="indexes/".concat(this.uid),t.next=3,this.httpRequest.delete(e);case 3:return n=t.sent,t.abrupt("return",new C(n));case 5:case"end":return t.stop()}}),t,this)}))),function(){return Mt.apply(this,arguments)})},{key:"getTasks",value:(Ct=i(y().mark((function t(){var e,n=arguments;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=n.length>0&&void 0!==n[0]?n[0]:{},t.next=3,this.tasks.getTasks(_(_({},e),{},{indexUids:[this.uid]}));case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)}))),function(){return Ct.apply(this,arguments)})},{key:"getTask",value:(qt=i(y().mark((function t(e){return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.tasks.getTask(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)}))),function(t){return qt.apply(this,arguments)})},{key:"waitForTasks",value:(Lt=i(y().mark((function t(e){var n,r,s,i,a,u=arguments;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=(n=u.length>1&&void 0!==u[1]?u[1]:{}).timeOutMs,s=void 0===r?5e3:r,i=n.intervalMs,a=void 0===i?50:i,t.next=3,this.tasks.waitForTasks(e,{timeOutMs:s,intervalMs:a});case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)}))),function(t){return Lt.apply(this,arguments)})},{key:"waitForTask",value:(Ot=i(y().mark((function t(e){var n,r,s,i,a,u=arguments;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=(n=u.length>1&&void 0!==u[1]?u[1]:{}).timeOutMs,s=void 0===r?5e3:r,i=n.intervalMs,a=void 0===i?50:i,t.next=3,this.tasks.waitForTask(e,{timeOutMs:s,intervalMs:a});case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)}))),function(t){return Ot.apply(this,arguments)})},{key:"getStats",value:(Nt=i(y().mark((function t(){var e;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e="indexes/".concat(this.uid,"/stats"),t.next=3,this.httpRequest.get(e);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)}))),function(){return Nt.apply(this,arguments)})},{key:"getDocuments",value:(Rt=i(y().mark((function t(){var e,n,r,s,i,a,u=arguments;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(void 0===(e=D(e=u.length>0&&void 0!==u[0]?u[0]:{})).filter){t.next=16;break}return t.prev=3,n="indexes/".concat(this.uid,"/documents/fetch"),t.next=7,this.httpRequest.post(n,e);case 7:case 20:return t.abrupt("return",t.sent);case 10:throw t.prev=10,t.t0=t.catch(3),(t.t0 instanceof E||t.t0 instanceof b)&&(t.t0.message=S(t.t0.message,"getDocuments")),t.t0;case 14:t.next=21;break;case 16:return i="indexes/".concat(this.uid,"/documents"),a=Array.isArray(null===(r=e)||void 0===r?void 0:r.fields)?{fields:null===(s=e)||void 0===s||null===(s=s.fields)||void 0===s?void 0:s.join(",")}:{},t.next=20,this.httpRequest.get(i,_(_({},e),a));case 21:case"end":return t.stop()}}),t,this,[[3,10]])}))),function(){return Rt.apply(this,arguments)})},{key:"getDocument",value:(Dt=i(y().mark((function t(e,n){var r,s;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r="indexes/".concat(this.uid,"/documents/").concat(e),s=function(){var t;if(Array.isArray(null==n?void 0:n.fields))return null==n||null===(t=n.fields)||void 0===t?void 0:t.join(",")}(),t.next=4,this.httpRequest.get(r,D(_(_({},n),{},{fields:s})));case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),t,this)}))),function(t,e){return Dt.apply(this,arguments)})},{key:"addDocuments",value:(St=i(y().mark((function t(e,n){var r,s;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r="indexes/".concat(this.uid,"/documents"),t.next=3,this.httpRequest.post(r,e,n);case 3:return s=t.sent,t.abrupt("return",new C(s));case 5:case"end":return t.stop()}}),t,this)}))),function(t,e){return St.apply(this,arguments)})},{key:"addDocumentsFromString",value:(Tt=i(y().mark((function t(e,n,r){var s,i;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s="indexes/".concat(this.uid,"/documents"),t.next=3,this.httpRequest.post(s,e,r,{headers:{"Content-Type":n}});case 3:return i=t.sent,t.abrupt("return",new C(i));case 5:case"end":return t.stop()}}),t,this)}))),function(t,e,n){return Tt.apply(this,arguments)})},{key:"addDocumentsInBatches",value:(Et=i(y().mark((function t(e){var n,r,s,i,a=arguments;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=a.length>1&&void 0!==a[1]?a[1]:1e3,r=a.length>2?a[2]:void 0,s=[],i=0;case 4:if(!(i1&&void 0!==a[1]?a[1]:1e3,r=a.length>2?a[2]:void 0,s=[],i=0;case 4:if(!(i1&&void 0!==i[1]?i[1]:{},r=new q(i.length>2?i[2]:void 0),t.next=6,r.post("indexes",_(_({},n),{},{uid:e}));case 6:return s=t.sent,t.abrupt("return",new C(s));case 8:case"end":return t.stop()}}),t)}))),function(e){return t.apply(this,arguments)})}]);var t,e,n,r,s,a,c,p,f,d,l,v,w,x,m,A,I,T,R,N,O,L,M,U,V,F,K,j,G,H,Y,B,X,W,z,Q,J,Z,$,tt,et,nt,rt,st,it,at,ut,ct,ot,pt,ht,ft,dt,lt,vt,_t,yt,wt,xt,mt,kt,At,It,gt,bt,Et,Tt,St,Dt,Rt,Nt,Ot,Lt,qt,Ct,Mt,Pt,Ut,Vt,Ft,Kt,jt,Gt,Ht}(),V=function(){return o((function t(e){u(this,t),h(this,"config",void 0),h(this,"httpRequest",void 0),h(this,"tasks",void 0),this.config=e,this.httpRequest=new q(e),this.tasks=new P(e)}),[{key:"index",value:function(t){return new U(this.config,t)}},{key:"getIndex",value:(L=i(y().mark((function t(e){return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new U(this.config,e).fetchInfo());case 1:case"end":return t.stop()}}),t,this)}))),function(t){return L.apply(this,arguments)})},{key:"getRawIndex",value:(O=i(y().mark((function t(e){return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new U(this.config,e).getRawInfo());case 1:case"end":return t.stop()}}),t,this)}))),function(t){return O.apply(this,arguments)})},{key:"getIndexes",value:(N=i(y().mark((function t(){var e,n,r,s=this,i=arguments;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=i.length>0&&void 0!==i[0]?i[0]:{},t.next=3,this.getRawIndexes(e);case 3:return n=t.sent,r=n.results.map((function(t){return new U(s.config,t.uid,t.primaryKey)})),t.abrupt("return",_(_({},n),{},{results:r}));case 6:case"end":return t.stop()}}),t,this)}))),function(){return N.apply(this,arguments)})},{key:"getRawIndexes",value:(R=i(y().mark((function t(){var e,n=arguments;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=n.length>0&&void 0!==n[0]?n[0]:{},t.next=4,this.httpRequest.get("indexes",e);case 4:return t.abrupt("return",t.sent);case 5:case"end":return t.stop()}}),t,this)}))),function(){return R.apply(this,arguments)})},{key:"createIndex",value:(D=i(y().mark((function t(e){var n,r=arguments;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=r.length>1&&void 0!==r[1]?r[1]:{},t.next=3,U.create(e,n,this.config);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)}))),function(t){return D.apply(this,arguments)})},{key:"updateIndex",value:(S=i(y().mark((function t(e){var n,r=arguments;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=r.length>1&&void 0!==r[1]?r[1]:{},t.next=3,new U(this.config,e).update(n);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)}))),function(t){return S.apply(this,arguments)})},{key:"deleteIndex",value:(T=i(y().mark((function t(e){return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,new U(this.config,e).delete();case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)}))),function(t){return T.apply(this,arguments)})},{key:"deleteIndexIfExists",value:(E=i(y().mark((function t(e){return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this.deleteIndex(e);case 3:return t.abrupt("return",!0);case 6:if(t.prev=6,t.t0=t.catch(0),t.t0.code!==n.INDEX_NOT_FOUND){t.next=10;break}return t.abrupt("return",!1);case 10:throw t.t0;case 11:case"end":return t.stop()}}),t,this,[[0,6]])}))),function(t){return E.apply(this,arguments)})},{key:"swapIndexes",value:(b=i(y().mark((function t(e){return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=3,this.httpRequest.post("/swap-indexes",e);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)}))),function(t){return b.apply(this,arguments)})},{key:"multiSearch",value:(g=i(y().mark((function t(e,n){return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=3,this.httpRequest.post("multi-search",e,void 0,n);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)}))),function(t,e){return g.apply(this,arguments)})},{key:"getTasks",value:(I=i(y().mark((function t(){var e,n=arguments;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=n.length>0&&void 0!==n[0]?n[0]:{},t.next=3,this.tasks.getTasks(e);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)}))),function(){return I.apply(this,arguments)})},{key:"getTask",value:(A=i(y().mark((function t(e){return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.tasks.getTask(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)}))),function(t){return A.apply(this,arguments)})},{key:"waitForTasks",value:(k=i(y().mark((function t(e){var n,r,s,i,a,u=arguments;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=(n=u.length>1&&void 0!==u[1]?u[1]:{}).timeOutMs,s=void 0===r?5e3:r,i=n.intervalMs,a=void 0===i?50:i,t.next=3,this.tasks.waitForTasks(e,{timeOutMs:s,intervalMs:a});case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)}))),function(t){return k.apply(this,arguments)})},{key:"waitForTask",value:(m=i(y().mark((function t(e){var n,r,s,i,a,u=arguments;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=(n=u.length>1&&void 0!==u[1]?u[1]:{}).timeOutMs,s=void 0===r?5e3:r,i=n.intervalMs,a=void 0===i?50:i,t.next=3,this.tasks.waitForTask(e,{timeOutMs:s,intervalMs:a});case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)}))),function(t){return m.apply(this,arguments)})},{key:"cancelTasks",value:(x=i(y().mark((function t(e){return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.tasks.cancelTasks(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)}))),function(t){return x.apply(this,arguments)})},{key:"deleteTasks",value:(w=i(y().mark((function t(){var e,n=arguments;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=n.length>0&&void 0!==n[0]?n[0]:{},t.next=3,this.tasks.deleteTasks(e);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)}))),function(){return w.apply(this,arguments)})},{key:"getKeys",value:(v=i(y().mark((function t(){var e,n,r=arguments;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=r.length>0&&void 0!==r[0]?r[0]:{},t.next=4,this.httpRequest.get("keys",e);case 4:return(n=t.sent).results=n.results.map((function(t){return _(_({},t),{},{createdAt:new Date(t.createdAt),updatedAt:new Date(t.updatedAt)})})),t.abrupt("return",n);case 7:case"end":return t.stop()}}),t,this)}))),function(){return v.apply(this,arguments)})},{key:"getKey",value:(l=i(y().mark((function t(e){var n;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n="keys/".concat(e),t.next=3,this.httpRequest.get(n);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)}))),function(t){return l.apply(this,arguments)})},{key:"createKey",value:(d=i(y().mark((function t(e){return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=3,this.httpRequest.post("keys",e);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)}))),function(t){return d.apply(this,arguments)})},{key:"updateKey",value:(f=i(y().mark((function t(e,n){var r;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r="keys/".concat(e),t.next=3,this.httpRequest.patch(r,n);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)}))),function(t,e){return f.apply(this,arguments)})},{key:"deleteKey",value:(p=i(y().mark((function t(e){var n;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n="keys/".concat(e),t.next=3,this.httpRequest.delete(n);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)}))),function(t){return p.apply(this,arguments)})},{key:"health",value:(c=i(y().mark((function t(){return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=3,this.httpRequest.get("health");case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)}))),function(){return c.apply(this,arguments)})},{key:"isHealthy",value:(a=i(y().mark((function t(){return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=4,this.httpRequest.get("health");case 4:return t.abrupt("return",!0);case 7:return t.prev=7,t.t0=t.catch(0),t.abrupt("return",!1);case 10:case"end":return t.stop()}}),t,this,[[0,7]])}))),function(){return a.apply(this,arguments)})},{key:"getStats",value:(s=i(y().mark((function t(){return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=3,this.httpRequest.get("stats");case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)}))),function(){return s.apply(this,arguments)})},{key:"getVersion",value:(r=i(y().mark((function t(){return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=3,this.httpRequest.get("version");case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)}))),function(){return r.apply(this,arguments)})},{key:"createDump",value:(e=i(y().mark((function t(){var e;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=3,this.httpRequest.post("dumps");case 3:return e=t.sent,t.abrupt("return",new C(e));case 5:case"end":return t.stop()}}),t,this)}))),function(){return e.apply(this,arguments)})},{key:"createSnapshot",value:(t=i(y().mark((function t(){var e;return y().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=3,this.httpRequest.post("snapshots");case 3:return e=t.sent,t.abrupt("return",new C(e));case 5:case"end":return t.stop()}}),t,this)}))),function(){return t.apply(this,arguments)})},{key:"generateTenantToken",value:function(t,e,n){var r=new Error;return r.message="Meilisearch: failed to generate a tenant token. Generation of a token only works in a node environment \n ".concat(r.stack,"."),Promise.reject(r)}}]);var t,e,r,s,a,c,p,f,d,l,v,w,x,m,k,A,I,g,b,E,T,S,D,R,N,O,L}(),F=function(t){function e(t){return u(this,e),a(this,e,[t])}return d(e,t),o(e)}(V);t.ContentTypeEnum={JSON:"application/json",CSV:"text/csv",NDJSON:"application/x-ndjson"},t.ErrorStatusCode=n,t.Index=U,t.MatchingStrategies={ALL:"all",LAST:"last",FREQUENCY:"frequency"},t.MeiliSearch=F,t.MeiliSearchApiError=b,t.MeiliSearchError=g,t.MeiliSearchRequestError=E,t.MeiliSearchTimeOutError=T,t.Meilisearch=F,t.TaskStatus=e,t.TaskTypes={DOCUMENTS_ADDITION_OR_UPDATE:"documentAdditionOrUpdate",DOCUMENT_DELETION:"documentDeletion",DUMP_CREATION:"dumpCreation",INDEX_CREATION:"indexCreation",INDEX_DELETION:"indexDeletion",INDEXES_SWAP:"indexSwap",INDEX_UPDATE:"indexUpdate",SETTINGS_UPDATE:"settingsUpdate",SNAPSHOT_CREATION:"snapshotCreation",TASK_CANCELATION:"taskCancelation",TASK_DELETION:"taskDeletion"},t.default=F,t.versionErrorHintMessage=S,Object.defineProperty(t,"__esModule",{value:!0})})); //# sourceMappingURL=meilisearch.umd.min.js.map