LocalCDN-Firefox-Chrome-Brave/resources/algoliasearch/4.9.1/algoliasearch.min.jsm

1 line
31 KiB
JavaScript

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).algoliasearch=e()}(this,function(){"use strict";function e(e,t){var r,n=Object.keys(e);return Object.getOwnPropertySymbols&&(r=Object.getOwnPropertySymbols(e),t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)),n}function g(n){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?e(Object(a),!0).forEach(function(t){var e,r;e=n,t=a[r=t],r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(a)):e(Object(a)).forEach(function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(a,t))})}return n}function d(t,e){if(null==t)return{};var r,n=function(t,e){if(null==t)return{};for(var r,n={},a=Object.keys(t),o=0;o<a.length;o++)r=a[o],0<=e.indexOf(r)||(n[r]=t[r]);return n}(t,e);if(Object.getOwnPropertySymbols)for(var a=Object.getOwnPropertySymbols(t),o=0;o<a.length;o++)r=a[o],0<=e.indexOf(r)||Object.prototype.propertyIsEnumerable.call(t,r)&&(n[r]=t[r]);return n}function l(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t)){var r=[],n=!0,a=!1,o=void 0;try{for(var i,u=t[Symbol.iterator]();!(n=(i=u.next()).done)&&(r.push(i.value),!e||r.length!==e);n=!0);}catch(t){a=!0,o=t}finally{try{n||null==u.return||u.return()}finally{if(a)throw o}}return r}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function b(t){return function(t){if(Array.isArray(t)){for(var e=0,r=new Array(t.length);e<t.length;e++)r[e]=t[e];return r}}(t)||function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function p(t){var o=0<arguments.length&&void 0!==t?t:{serializable:!0},i={};return{get:function(t,e){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{miss:function(){return Promise.resolve()}},t=JSON.stringify(t);if(t in i)return Promise.resolve(o.serializable?JSON.parse(i[t]):i[t]);var n=e(),a=r&&r.miss||function(){return Promise.resolve()};return n.then(function(t){return a(t)}).then(function(){return n})},set:function(t,e){return i[JSON.stringify(t)]=o.serializable?JSON.stringify(e):e,Promise.resolve(e)},delete:function(t){return delete i[JSON.stringify(t)],Promise.resolve()},clear:function(){return i={},Promise.resolve()}}}function h(t,e,r){var n={"x-algolia-api-key":r,"x-algolia-application-id":e};return{headers:function(){return t===P.WithinHeaders?n:{}},queryParameters:function(){return t===P.WithinQueryParameters?n:{}}}}function u(r){var n=0;return r(function e(){return n++,new Promise(function(t){setTimeout(function(){t(r(e))},Math.min(100*n,1e3))})})}function m(t,e){var r=1<arguments.length&&void 0!==e?e:function(t,e){return Promise.resolve()};return Object.assign(t,{wait:function(e){return m(t.then(function(t){return Promise.all([r(t,e),t])}).then(function(t){return t[1]}))}})}function y(e,r){return r&&Object.keys(r).forEach(function(t){e[t]=r[t](e)}),e}function v(t){for(var e=arguments.length,r=new Array(1<e?e-1:0),n=1;n<e;n++)r[n-1]=arguments[n];var a=0;return t.replace(/%s/g,function(){return encodeURIComponent(r[a++])})}var P={WithinQueryParameters:0,WithinHeaders:1};function w(t,e){var r=t||{},n=r.data||{};return Object.keys(r).forEach(function(t){-1===["timeout","headers","queryParameters","data","cacheable"].indexOf(t)&&(n[t]=r[t])}),{data:0<Object.entries(n).length?n:void 0,timeout:r.timeout||e,headers:r.headers||{},queryParameters:r.queryParameters||{},cacheable:r.cacheable}}var O={Read:1,Write:2,Any:3},a=1,I=2,x=3;function j(t,e){e=1<arguments.length&&void 0!==e?e:a;return g(g({},t),{},{status:e,lastUpdate:Date.now()})}function D(t){return"string"==typeof t?{protocol:"https",url:t,accept:O.Any}:{protocol:t.protocol||"https",url:t.url,accept:t.accept||O.Any}}var o="DELETE",i="GET",q="POST",s="PUT";function S(e,n){return Promise.all(n.map(function(t){return e.get(t,function(){return Promise.resolve(j(t))})})).then(function(t){var e=t.filter(function(t){return(t=t).status===a||12e4<Date.now()-t.lastUpdate}),r=t.filter(function(t){return(t=t).status===x&&Date.now()-t.lastUpdate<=12e4}),e=[].concat(b(e),b(r));return{getTimeout:function(t,e){return(0===r.length&&0===t?1:r.length+3+t)*e},statelessHosts:0<e.length?e.map(D):n}})}function k(u,t,s,c){function f(r,n){var a=r.pop();if(void 0===a)throw{name:"RetryError",message:"Unreachable hosts - your application id may be incorrect. If the error persists, contact support@algolia.com.",transporterStackTrace:E(d)};function o(t){return t={request:e,response:t,host:a,triesLeft:r.length},d.push(t),t}var e={data:l,headers:p,method:h,url:function(t,e,r){r=N(r),e="".concat(t.protocol,"://").concat(t.url,"/").concat("/"===e.charAt(0)?e.substr(1):e);return r.length&&(e+="?".concat(r)),e}(a,s.path,m),connectTimeout:n(y,u.timeouts.connect),responseTimeout:n(y,c.timeout)},i={onSuccess:function(e){try{return JSON.parse(e.content)}catch(t){throw{name:"DeserializationError",message:t.message,response:e}}},onRetry:function(t){var e=o(t);return t.isTimedOut&&y++,Promise.all([u.logger.info("Retryable failure",R(e)),u.hostsCache.set(a,j(a,t.isTimedOut?x:I))]).then(function(){return f(r,n)})},onFail:function(t){throw o(t),function(t,e){var r=t.content,n=t.status,a=r;try{a=JSON.parse(r).message}catch(t){}return{name:"ApiError",message:a,status:n,transporterStackTrace:e}}(t,E(d))}};return u.requester.send(e).then(function(t){return r=i,a=(n=e=t).status,n.isTimedOut||(t=n.isTimedOut,n=n.status,!t&&0==~~n)||2!=~~(a/100)&&4!=~~(a/100)?r.onRetry(e):2==~~(e.status/100)?r.onSuccess(e):r.onFail(e);var e,r,n,a})}var e,r,n,d=[],l=function(t,e){if(t.method!==i&&(void 0!==t.data||void 0!==e.data)){e=Array.isArray(t.data)?t.data:g(g({},t.data),e.data);return JSON.stringify(e)}}(s,c),p=(e=c,r=g(g({},u.headers),e.headers),n={},Object.keys(r).forEach(function(t){var e=r[t];n[t.toLowerCase()]=e}),n),h=s.method,e=s.method!==i?{}:g(g({},s.data),c.data),m=g(g(g({"x-algolia-agent":u.userAgent.value},u.queryParameters),e),c.queryParameters),y=0;return S(u.hostsCache,t).then(function(t){return f(b(t.statelessHosts).reverse(),t.getTimeout)})}function T(t){var e=t.hostsCache,r=t.logger,n=t.requester,a=t.requestsCache,o=t.responsesCache,i=t.timeouts,u=t.userAgent,s=t.hosts,c=t.queryParameters,f={hostsCache:e,logger:r,requester:n,requestsCache:a,responsesCache:o,timeouts:i,userAgent:u,headers:t.headers,queryParameters:c,hosts:s.map(D),read:function(t,e){function r(){return k(f,f.hosts.filter(function(t){return 0!=(t.accept&O.Read)}),t,n)}var n=w(e,f.timeouts.read);if(!0!==(void 0!==n.cacheable?n:t).cacheable)return r();var a={request:t,mappedRequestOptions:n,transporter:{queryParameters:f.queryParameters,headers:f.headers}};return f.responsesCache.get(a,function(){return f.requestsCache.get(a,function(){return f.requestsCache.set(a,r()).then(function(t){return Promise.all([f.requestsCache.delete(a),t])},function(t){return Promise.all([f.requestsCache.delete(a),Promise.reject(t)])}).then(function(t){t=l(t,2);return t[0],t[1]})})},{miss:function(t){return f.responsesCache.set(a,t)}})},write:function(t,e){return k(f,f.hosts.filter(function(t){return 0!=(t.accept&O.Write)}),t,w(e,f.timeouts.write))}};return f}function N(r){return Object.keys(r).map(function(t){return v("%s=%s",t,(e=r[t],"[object Object]"===Object.prototype.toString.call(e)||"[object Array]"===Object.prototype.toString.call(e)?JSON.stringify(r[t]):r[t]));var e}).join("&")}function E(t){return t.map(R)}function R(t){var e=t.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return g(g({},t),{},{request:g(g({},t.request),{},{headers:g(g({},t.request.headers),e)})})}function A(r){return function(t,e){return r.transporter.write({method:q,path:"2/abtests",data:t},e)}}function C(r){return function(t,e){return r.transporter.write({method:o,path:v("2/abtests/%s",t)},e)}}function U(r){return function(t,e){return r.transporter.read({method:i,path:v("2/abtests/%s",t)},e)}}function J(e){return function(t){return e.transporter.read({method:i,path:"2/abtests"},t)}}function z(r){return function(t,e){return r.transporter.write({method:q,path:v("2/abtests/%s/stop",t)},e)}}function F(e){return function(t){return e.transporter.read({method:i,path:"1/strategies/personalization"},t)}}function H(r){return function(t,e){return r.transporter.write({method:q,path:"1/strategies/personalization",data:t},e)}}function n(n){return function e(r){return n.request(r).then(function(t){if(void 0!==n.batch&&n.batch(t.hits),!n.shouldStop(t))return t.cursor?e({cursor:t.cursor}):e({page:(r.page||0)+1})})}({})}function M(n){return function(t,e){var r=e||{},e=r.queryParameters,r=d(r,["queryParameters"]),e=g({acl:t},void 0!==e?{queryParameters:e}:{});return m(n.transporter.write({method:q,path:"1/keys",data:e},r),function(t,r){return u(function(e){return Vt(n)(t.key,r).catch(function(t){if(404!==t.status)throw t;return e()})})})}}function K(n){return function(t,e,r){r=w(r);return r.queryParameters["X-Algolia-User-ID"]=t,n.transporter.write({method:q,path:"1/clusters/mapping",data:{cluster:e}},r)}}function W(n){return function(t,e,r){return n.transporter.write({method:q,path:"1/clusters/mapping/batch",data:{users:t,cluster:e}},r)}}function B(r){return function(t,e){return m(r.transporter.write({method:q,path:v("/1/dictionaries/%s/batch",t),data:{clearExistingDictionaryEntries:!0,requests:{action:"addEntry",body:[]}}},e),function(t,e){return Xt(r)(t.taskID,e)})}}function Q(n){return function(r,t,e){return m(n.transporter.write({method:q,path:v("1/indexes/%s/operation",r),data:{operation:"copy",destination:t}},e),function(t,e){return _t(n)(r,{methods:{waitTask:ue}}).waitTask(t.taskID,e)})}}function G(n){return function(t,e,r){return Q(n)(t,e,g(g({},r),{},{scope:[se.Rules]}))}}function L(n){return function(t,e,r){return Q(n)(t,e,g(g({},r),{},{scope:[se.Settings]}))}}function V(n){return function(t,e,r){return Q(n)(t,e,g(g({},r),{},{scope:[se.Synonyms]}))}}function _(n){return function(r,t){return m(n.transporter.write({method:o,path:v("1/keys/%s",r)},t),function(t,e){return u(function(t){return Vt(n)(r,e).then(t).catch(function(t){if(404!==t.status)throw t})})})}}function X(n){return function(t,e,r){e=e.map(function(t){return{action:"deleteEntry",body:{objectID:t}}});return m(n.transporter.write({method:q,path:v("/1/dictionaries/%s/batch",t),data:{clearExistingDictionaryEntries:!1,requests:e}},r),function(t,e){return Xt(n)(t.taskID,e)})}}function Y(e){return function(t){return e.transporter.read({method:i,path:"/1/dictionaries/*/settings"},t)}}function Z(e){return function(t){return e.transporter.read({method:i,path:"1/logs"},t)}}function $(e){return function(t){return e.transporter.read({method:i,path:"1/clusters/mapping/top"},t)}}function tt(r){return function(t,e){return r.transporter.read({method:i,path:v("1/task/%s",t.toString())},e)}}function et(r){return function(t,e){return r.transporter.read({method:i,path:v("1/clusters/mapping/%s",t)},e)}}function rt(r){return function(t){var e=t||{},t=e.retrieveMappings,e=d(e,["retrieveMappings"]);return!0===t&&(e.getClusters=!0),r.transporter.read({method:i,path:"1/clusters/mapping/pending"},e)}}function nt(e){return function(t){return e.transporter.read({method:i,path:"1/keys"},t)}}function at(e){return function(t){return e.transporter.read({method:i,path:"1/clusters"},t)}}function ot(e){return function(t){return e.transporter.read({method:i,path:"1/indexes"},t)}}function it(e){return function(t){return e.transporter.read({method:i,path:"1/clusters/mapping"},t)}}function ut(n){return function(r,t,e){return m(n.transporter.write({method:q,path:v("1/indexes/%s/operation",r),data:{operation:"move",destination:t}},e),function(t,e){return _t(n)(r,{methods:{waitTask:ue}}).waitTask(t.taskID,e)})}}function st(n){return function(t,e){return m(n.transporter.write({method:q,path:"1/indexes/*/batch",data:{requests:t}},e),function(e,r){return Promise.all(Object.keys(e.taskID).map(function(t){return _t(n)(t,{methods:{waitTask:ue}}).waitTask(e.taskID[t],r)}))})}}function ct(r){return function(t,e){return r.transporter.read({method:q,path:"1/indexes/*/objects",data:{requests:t}},e)}}function ft(r){return function(t,e){t=t.map(function(t){return g(g({},t),{},{params:N(t.params||{})})});return r.transporter.read({method:q,path:"1/indexes/*/queries",data:{requests:t},cacheable:!0},e)}}function dt(o){return function(t,a){return Promise.all(t.map(function(t){var e=t.params,r=e.facetName,n=e.facetQuery,e=d(e,["facetName","facetQuery"]);return _t(o)(t.indexName,{methods:{searchForFacetValues:ae}}).searchForFacetValues(r,n,g(g({},a),e))}))}}function lt(r){return function(t,e){e=w(e);return e.queryParameters["X-Algolia-User-ID"]=t,r.transporter.write({method:o,path:"1/clusters/mapping"},e)}}function pt(n){return function(t,e,r){e=e.map(function(t){return{action:"addEntry",body:t}});return m(n.transporter.write({method:q,path:v("/1/dictionaries/%s/batch",t),data:{clearExistingDictionaryEntries:!0,requests:e}},r),function(t,e){return Xt(n)(t.taskID,e)})}}function ht(a){return function(n,t){return m(a.transporter.write({method:q,path:v("1/keys/%s/restore",n)},t),function(t,r){return u(function(e){return Vt(a)(n,r).catch(function(t){if(404!==t.status)throw t;return e()})})})}}function mt(n){return function(t,e,r){e=e.map(function(t){return{action:"addEntry",body:t}});return m(n.transporter.write({method:q,path:v("/1/dictionaries/%s/batch",t),data:{clearExistingDictionaryEntries:!1,requests:e}},r),function(t,e){return Xt(n)(t.taskID,e)})}}function yt(n){return function(t,e,r){return n.transporter.read({method:q,path:v("/1/dictionaries/%s/search",t),data:{query:e},cacheable:!0},r)}}function gt(r){return function(t,e){return r.transporter.read({method:q,path:"1/clusters/mapping/search",data:{query:t}},e)}}function bt(r){return function(t,e){return m(r.transporter.write({method:s,path:"/1/dictionaries/*/settings",data:t},e),function(t,e){return Xt(r)(t.taskID,e)})}}function vt(i){return function(n,t){var a=Object.assign({},t),e=t||{},t=e.queryParameters,e=d(e,["queryParameters"]),t=t?{queryParameters:t}:{},o=["acl","indexes","referers","restrictSources","queryParameters","description","maxQueriesPerIPPerHour","maxHitsPerQuery"];return m(i.transporter.write({method:s,path:v("1/keys/%s",n),data:t},e),function(t,e){return u(function(r){return Vt(i)(n,e).then(function(t){return e=t,Object.keys(a).filter(function(t){return-1!==o.indexOf(t)}).every(function(t){return e[t]===a[t]})?Promise.resolve():r();var e})})})}}function Pt(r){return function(t,e){return m(r.transporter.write({method:q,path:v("1/indexes/%s/batch",r.indexName),data:{requests:t}},e),function(t,e){return ue(r)(t.taskID,e)})}}function wt(r){return function(e){return n(g(g({shouldStop:function(t){return void 0===t.cursor}},e),{},{request:function(t){return r.transporter.read({method:q,path:v("1/indexes/%s/browse",r.indexName),data:t},e)}}))}}function Ot(r){return function(t){var e=g({hitsPerPage:1e3},t);return n(g(g({shouldStop:function(t){return t.hits.length<e.hitsPerPage}},e),{},{request:function(t){return oe(r)("",g(g({},e),t)).then(function(t){return g(g({},t),{},{hits:t.hits.map(function(t){return delete t._highlightResult,t})})})}}))}}function It(r){return function(t){var e=g({hitsPerPage:1e3},t);return n(g(g({shouldStop:function(t){return t.hits.length<e.hitsPerPage}},e),{},{request:function(t){return ie(r)("",g(g({},e),t)).then(function(t){return g(g({},t),{},{hits:t.hits.map(function(t){return delete t._highlightResult,t})})})}}))}}function c(c){return function(a,o,t){var t=t||{},i=t.batchSize,u=d(t,["batchSize"]),s={taskIDs:[],objectIDs:[]};return m(function e(t){for(var r=[],n=0<arguments.length&&void 0!==t?t:0;n<a.length&&(r.push(a[n]),r.length!==(i||1e3));n++);return 0===r.length?Promise.resolve(s):Pt(c)(r.map(function(t){return{action:o,body:t}}),u).then(function(t){return s.objectIDs=s.objectIDs.concat(t.objectIDs),s.taskIDs.push(t.taskID),e(++n)})}(),function(t,e){return Promise.all(t.taskIDs.map(function(t){return ue(c)(t,e)}))})}}function xt(r){return function(t){return m(r.transporter.write({method:q,path:v("1/indexes/%s/clear",r.indexName)},t),function(t,e){return ue(r)(t.taskID,e)})}}function jt(r){return function(t){var e=t||{},t=e.forwardToReplicas,e=w(d(e,["forwardToReplicas"]));return t&&(e.queryParameters.forwardToReplicas=1),m(r.transporter.write({method:q,path:v("1/indexes/%s/rules/clear",r.indexName)},e),function(t,e){return ue(r)(t.taskID,e)})}}function Dt(r){return function(t){var e=t||{},t=e.forwardToReplicas,e=w(d(e,["forwardToReplicas"]));return t&&(e.queryParameters.forwardToReplicas=1),m(r.transporter.write({method:q,path:v("1/indexes/%s/synonyms/clear",r.indexName)},e),function(t,e){return ue(r)(t.taskID,e)})}}function qt(r){return function(t,e){return m(r.transporter.write({method:q,path:v("1/indexes/%s/deleteByQuery",r.indexName),data:t},e),function(t,e){return ue(r)(t.taskID,e)})}}function St(r){return function(t){return m(r.transporter.write({method:o,path:v("1/indexes/%s",r.indexName)},t),function(t,e){return ue(r)(t.taskID,e)})}}function kt(r){return function(t,e){return m(Yt(r)([t],e).then(function(t){return{taskID:t.taskIDs[0]}}),function(t,e){return ue(r)(t.taskID,e)})}}function Tt(n){return function(t,e){var r=e||{},e=r.forwardToReplicas,r=w(d(r,["forwardToReplicas"]));return e&&(r.queryParameters.forwardToReplicas=1),m(n.transporter.write({method:o,path:v("1/indexes/%s/rules/%s",n.indexName,t)},r),function(t,e){return ue(n)(t.taskID,e)})}}function Nt(n){return function(t,e){var r=e||{},e=r.forwardToReplicas,r=w(d(r,["forwardToReplicas"]));return e&&(r.queryParameters.forwardToReplicas=1),m(n.transporter.write({method:o,path:v("1/indexes/%s/synonyms/%s",n.indexName,t)},r),function(t,e){return ue(n)(t.taskID,e)})}}function Et(e){return function(t){return Zt(e)(t).then(function(){return!0}).catch(function(t){if(404!==t.status)throw t;return!1})}}function Rt(n){return function(t,e,r){return n.transporter.read({method:q,path:v("1/answers/%s/prediction",n.indexName),data:{query:t,queryLanguages:e},cacheable:!0},r)}}function At(n){return function(i,t){var t=t||{},e=t.query,u=t.paginate,r=d(t,["query","paginate"]),s=0;return function o(){return ne(n)(e||"",g(g({},r),{},{page:s})).then(function(t){for(var e=0,r=Object.entries(t.hits);e<r.length;e++){var n=l(r[e],2),a=n[0],n=n[1];if(i(n))return{object:n,position:parseInt(a,10),page:s}}if(s++,!1===u||s>=t.nbPages)throw{name:"ObjectNotFoundError",message:"Object not found."};return o()})}()}}function Ct(r){return function(t,e){return r.transporter.read({method:i,path:v("1/indexes/%s/%s",r.indexName,t)},e)}}function Ut(){return function(t,e){for(var r=0,n=Object.entries(t.hits);r<n.length;r++){var a=l(n[r],2),o=a[0];if(a[1].objectID===e)return parseInt(o,10)}return-1}}function Jt(n){return function(t,e){var e=e||{},r=e.attributesToRetrieve,e=d(e,["attributesToRetrieve"]),t=t.map(function(t){return g({indexName:n.indexName,objectID:t},r?{attributesToRetrieve:r}:{})});return n.transporter.read({method:q,path:"1/indexes/*/objects",data:{requests:t}},e)}}function zt(r){return function(t,e){return r.transporter.read({method:i,path:v("1/indexes/%s/rules/%s",r.indexName,t)},e)}}function Ft(r){return function(t,e){return r.transporter.read({method:i,path:v("1/indexes/%s/synonyms/%s",r.indexName,t)},e)}}function Ht(r){return function(t,e){return m($t(r)([t],e).then(function(t){return{objectID:t.objectIDs[0],taskID:t.taskIDs[0]}}),function(t,e){return ue(r)(t.taskID,e)})}}function Mt(f){return function(e,t){function r(t,e,r,n){return m(f.transporter.write({method:q,path:v("1/indexes/%s/operation",t),data:{operation:r,destination:e}},n),function(t,e){return ue(f)(t.taskID,e)})}var t=t||{},n=t.safe,a=t.autoGenerateObjectIDIfNotExist,o=t.batchSize,i=d(t,["safe","autoGenerateObjectIDIfNotExist","batchSize"]),t=Math.random().toString(36).substring(7),u="".concat(f.indexName,"_tmp_").concat(t),s=te({appId:f.appId,transporter:f.transporter,indexName:u}),c=[],t=r(f.indexName,u,"copy",g(g({},i),{},{scope:["settings","synonyms","rules"]}));return c.push(t),m((n?t.wait(i):t).then(function(){var t=s(e,g(g({},i),{},{autoGenerateObjectIDIfNotExist:a,batchSize:o}));return c.push(t),n?t.wait(i):t}).then(function(){var t=r(u,f.indexName,"move",i);return c.push(t),n?t.wait(i):t}).then(function(){return Promise.all(c)}).then(function(t){var e=l(t,3),r=e[0],t=e[1],e=e[2];return{objectIDs:t.objectIDs,taskIDs:[r.taskID].concat(b(t.taskIDs),[e.taskID])}}),function(t,e){return Promise.all(c.map(function(t){return t.wait(e)}))})}}function Kt(r){return function(t,e){return ee(r)(t,g(g({},e),{},{clearExistingRules:!0}))}}function Wt(r){return function(t,e){return re(r)(t,g(g({},e),{},{clearExistingSynonyms:!0}))}}function Bt(r){return function(t,e){return m(te(r)([t],e).then(function(t){return{objectID:t.objectIDs[0],taskID:t.taskIDs[0]}}),function(t,e){return ue(r)(t.taskID,e)})}}function Qt(r){return function(t,e){return ee(r)([t],e)}}function Gt(r){return function(t,e){return re(r)([t],e)}}function Lt(n){return function(t,e){var r=e||{},e=r.forwardToReplicas,r=w(d(r,["forwardToReplicas"]));return e&&(r.queryParameters.forwardToReplicas=1),m(n.transporter.write({method:s,path:v("1/indexes/%s/settings",n.indexName),data:t},r),function(t,e){return ue(n)(t.taskID,e)})}}var Vt=function(r){return function(t,e){return r.transporter.read({method:i,path:v("1/keys/%s",t)},e)}},_t=function(r){return function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};return y({transporter:r.transporter,appId:r.appId,indexName:t},e.methods)}},Xt=function(n){return function(t,r){return u(function(e){return tt(n)(t,r).then(function(t){return"published"!==t.status?e():void 0})})}},Yt=function(r){return function(t,e){t=t.map(function(t){return{objectID:t}});return c(r)(t,f.DeleteObject,e)}},Zt=function(e){return function(t){return e.transporter.read({method:i,path:v("1/indexes/%s/settings",e.indexName),data:{getVersion:2}},t)}},$t=function(n){return function(t,e){var r=e||{},e=r.createIfNotExists,r=d(r,["createIfNotExists"]),e=e?f.PartialUpdateObject:f.PartialUpdateObjectNoCreate;return c(n)(t,e,r)}},te=function(s){return function(t,e){var r=e||{},e=r.autoGenerateObjectIDIfNotExist,r=d(r,["autoGenerateObjectIDIfNotExist"]),e=e?f.AddObject:f.UpdateObject;if(e===f.UpdateObject){var n=!0,a=!1,o=void 0;try{for(var i,u=t[Symbol.iterator]();!(n=(i=u.next()).done);n=!0)if(void 0===i.value.objectID)return m(Promise.reject({name:"MissingObjectIDError",message:"All objects must have an unique objectID (like a primary key) to be valid. Algolia is also able to generate objectIDs automatically but *it's not recommended*. To do it, use the `{'autoGenerateObjectIDIfNotExist': true}` option."}))}catch(t){a=!0,o=t}finally{try{n||null==u.return||u.return()}finally{if(a)throw o}}}return c(s)(t,e,r)}},ee=function(a){return function(t,e){var r=e||{},n=r.forwardToReplicas,e=r.clearExistingRules,r=w(d(r,["forwardToReplicas","clearExistingRules"]));return n&&(r.queryParameters.forwardToReplicas=1),e&&(r.queryParameters.clearExistingRules=1),m(a.transporter.write({method:q,path:v("1/indexes/%s/rules/batch",a.indexName),data:t},r),function(t,e){return ue(a)(t.taskID,e)})}},re=function(o){return function(t,e){var r=e||{},n=r.forwardToReplicas,a=r.clearExistingSynonyms,e=r.replaceExistingSynonyms,r=w(d(r,["forwardToReplicas","clearExistingSynonyms","replaceExistingSynonyms"]));return n&&(r.queryParameters.forwardToReplicas=1),(e||a)&&(r.queryParameters.replaceExistingSynonyms=1),m(o.transporter.write({method:q,path:v("1/indexes/%s/synonyms/batch",o.indexName),data:t},r),function(t,e){return ue(o)(t.taskID,e)})}},ne=function(r){return function(t,e){return r.transporter.read({method:q,path:v("1/indexes/%s/query",r.indexName),data:{query:t},cacheable:!0},e)}},ae=function(n){return function(t,e,r){return n.transporter.read({method:q,path:v("1/indexes/%s/facets/%s/query",n.indexName,t),data:{facetQuery:e},cacheable:!0},r)}},oe=function(r){return function(t,e){return r.transporter.read({method:q,path:v("1/indexes/%s/rules/search",r.indexName),data:{query:t}},e)}},ie=function(r){return function(t,e){return r.transporter.read({method:q,path:v("1/indexes/%s/synonyms/search",r.indexName),data:{query:t}},e)}},ue=function(a){return function(t,n){return u(function(e){return r=a,function(t,e){return r.transporter.read({method:i,path:v("1/indexes/%s/task/%s",r.indexName,t.toString())},e)}(t,n).then(function(t){return"published"!==t.status?e():void 0});var r})}},f={AddObject:"addObject",UpdateObject:"updateObject",PartialUpdateObject:"partialUpdateObject",PartialUpdateObjectNoCreate:"partialUpdateObjectNoCreate",DeleteObject:"deleteObject",DeleteIndex:"delete",ClearIndex:"clear"},se={Settings:"settings",Synonyms:"synonyms",Rules:"rules"};function t(t,e,r){var n,a,o,i,u,s={appId:t,apiKey:e,timeouts:{connect:1,read:2,write:30},requester:{send:function(o){return new Promise(function(r){var n=new XMLHttpRequest;n.open(o.method,o.url,!0),Object.keys(o.headers).forEach(function(t){return n.setRequestHeader(t,o.headers[t])});function t(t,e){return setTimeout(function(){n.abort(),r({status:0,content:e,isTimedOut:!0})},1e3*t)}var e,a=t(o.connectTimeout,"Connection timeout");n.onreadystatechange=function(){n.readyState>n.OPENED&&void 0===e&&(clearTimeout(a),e=t(o.responseTimeout,"Socket timeout"))},n.onerror=function(){0===n.status&&(clearTimeout(a),clearTimeout(e),r({content:n.responseText||"Network request failed",status:n.status,isTimedOut:!1}))},n.onload=function(){clearTimeout(a),clearTimeout(e),r({content:n.responseText,status:n.status,isTimedOut:!1})},n.send(o.data)})}},logger:{debug:function(t,e){return Promise.resolve()},info:function(t,e){return Promise.resolve()},error:function(t,e){return console.error(t,e),Promise.resolve()}},responsesCache:p(),requestsCache:p({serializable:!3}),hostsCache:function n(t){var a=b(t.caches),o=a.shift();return void 0===o?{get:function(t,e){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{miss:function(){return Promise.resolve()}};return e().then(function(t){return Promise.all([t,r.miss(t)])}).then(function(t){return l(t,1)[0]})},set:function(t,e){return Promise.resolve(e)},delete:function(t){return Promise.resolve()},clear:function(){return Promise.resolve()}}:{get:function(t,e){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{miss:function(){return Promise.resolve()}};return o.get(t,e,r).catch(function(){return n({caches:a}).get(t,e,r)})},set:function(t,e){return o.set(t,e).catch(function(){return n({caches:a}).set(t,e)})},delete:function(t){return o.delete(t).catch(function(){return n({caches:a}).delete(t)})},clear:function(){return o.clear().catch(function(){return n({caches:a}).clear()})}}}({caches:[(a={key:"".concat("4.9.1","-").concat(t)},i="algoliasearch-client-js-".concat(a.key),{get:function(e,r){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{miss:function(){return Promise.resolve()}};return Promise.resolve().then(function(){var t=JSON.stringify(e),t=f()[t];return Promise.all([t||r(),void 0!==t])}).then(function(t){var e=l(t,2),t=e[0],e=e[1];return Promise.all([t,e||n.miss(t)])}).then(function(t){return l(t,1)[0]})},set:function(e,r){return Promise.resolve().then(function(){var t=f();return t[JSON.stringify(e)]=r,c().setItem(i,JSON.stringify(t)),r})},delete:function(e){return Promise.resolve().then(function(){var t=f();delete t[JSON.stringify(e)],c().setItem(i,JSON.stringify(t))})},clear:function(){return Promise.resolve().then(function(){c().removeItem(i)})}}),p()]}),userAgent:(n={value:"Algolia for JavaScript (".concat("4.9.1",")"),add:function(t){t="; ".concat(t.segment).concat(void 0!==t.version?" (".concat(t.version,")"):"");return-1===n.value.indexOf(t)&&(n.value="".concat(n.value).concat(t)),n}}).add({segment:"Browser"})};function c(){return void 0===o&&(o=a.localStorage||window.localStorage),o}function f(){return JSON.parse(c().getItem(i)||"{}")}return e=g(g(g({},s),r),{},{methods:{search:ft,searchForFacetValues:dt,multipleBatch:st,multipleGetObjects:ct,multipleQueries:ft,copyIndex:Q,copySettings:L,copySynonyms:V,copyRules:G,moveIndex:ut,listIndices:ot,getLogs:Z,listClusters:at,multipleSearchForFacetValues:dt,getApiKey:Vt,addApiKey:M,listApiKeys:nt,updateApiKey:vt,deleteApiKey:_,restoreApiKey:ht,assignUserID:K,assignUserIDs:W,getUserID:et,searchUserIDs:gt,listUserIDs:it,getTopUserIDs:$,removeUserID:lt,hasPendingMappings:rt,clearDictionaryEntries:B,deleteDictionaryEntries:X,getDictionarySettings:Y,getAppTask:tt,replaceDictionaryEntries:pt,saveDictionaryEntries:mt,searchDictionaryEntries:yt,setDictionarySettings:bt,waitAppTask:Xt,initIndex:function(e){return function(t){return _t(e)(t,{methods:{batch:Pt,delete:St,findAnswers:Rt,getObject:Ct,getObjects:Jt,saveObject:Bt,saveObjects:te,search:ne,searchForFacetValues:ae,waitTask:ue,setSettings:Lt,getSettings:Zt,partialUpdateObject:Ht,partialUpdateObjects:$t,deleteObject:kt,deleteObjects:Yt,deleteBy:qt,clearObjects:xt,browseObjects:wt,getObjectPosition:Ut,findObject:At,exists:Et,saveSynonym:Gt,saveSynonyms:re,getSynonym:Ft,searchSynonyms:ie,browseSynonyms:It,deleteSynonym:Nt,clearSynonyms:Dt,replaceAllObjects:Mt,replaceAllSynonyms:Wt,searchRules:oe,getRule:zt,deleteRule:Tt,saveRule:Qt,saveRules:ee,replaceAllRules:Kt,browseRules:Ot,clearRules:jt}})}},initAnalytics:function(){return function(t){return e=g(g(g({},s),t),{},{methods:{addABTest:A,getABTest:U,getABTests:J,stopABTest:z,deleteABTest:C}}),r=e.region||"us",t=h(P.WithinHeaders,e.appId,e.apiKey),t=T(g(g({hosts:[{url:"analytics.".concat(r,".algolia.com")}]},e),{},{headers:g(g(g({},t.headers()),{"content-type":"application/json"}),e.headers),queryParameters:g(g({},t.queryParameters()),e.queryParameters)})),y({appId:e.appId,transporter:t},e.methods);var e,r}},initRecommendation:function(){return function(t){return e=g(g(g({},s),t),{},{methods:{getPersonalizationStrategy:F,setPersonalizationStrategy:H}}),r=e.region||"us",t=h(P.WithinHeaders,e.appId,e.apiKey),t=T(g(g({hosts:[{url:"recommendation.".concat(r,".algolia.com")}]},e),{},{headers:g(g(g({},t.headers()),{"content-type":"application/json"}),e.headers),queryParameters:g(g({},t.queryParameters()),e.queryParameters)})),y({appId:e.appId,transporter:t},e.methods);var e,r}}}}),t=e.appId,r=h(void 0!==e.authMode?e.authMode:P.WithinHeaders,t,e.apiKey),y({transporter:u=T(g(g({hosts:[{url:"".concat(t,"-dsn.algolia.net"),accept:O.Read},{url:"".concat(t,".algolia.net"),accept:O.Write}].concat(function(t){for(var e=t.length-1;0<e;e--){var r=Math.floor(Math.random()*(e+1)),n=t[e];t[e]=t[r],t[r]=n}return t}([{url:"".concat(t,"-1.algolianet.com")},{url:"".concat(t,"-2.algolianet.com")},{url:"".concat(t,"-3.algolianet.com")}]))},e),{},{headers:g(g(g({},r.headers()),{"content-type":"application/x-www-form-urlencoded"}),e.headers),queryParameters:g(g({},r.queryParameters()),e.queryParameters)})),appId:t,addAlgoliaAgent:function(t,e){u.userAgent.add({segment:t,version:e})},clearCache:function(){return Promise.all([u.requestsCache.clear(),u.responsesCache.clear()]).then(function(){})}},e.methods)}return t.version="4.9.1",t});