LocalCDN-Firefox-Chrome-Brave/resources/algoliasearch/4.14.2/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,r=a[t=t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r}):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 p(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 h(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 m(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 l(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 l(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},J=2,I=3;function x(t,e){e=1<arguments.length&&void 0!==e?e:1;return g(g({},t),{},{status:e,lastUpdate:Date.now()})}function j(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 a="DELETE",i="GET",D="POST",s="PUT";function q(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:F(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=k(r),t="".concat(t.protocol,"://").concat(t.url,"/").concat("/"===e.charAt(0)?e.substr(1):e);return r.length&&(t+="?".concat(r)),t}(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",H(e)),u.hostsCache.set(a,x(a,t.isTimedOut?I:J))]).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,F(d))}};return u.requester.send(e).then(function(t){return e=i,a=(r=t=t).status,r.isTimedOut||(n=r.isTimedOut,r=r.status,!n&&0==~~r)||2!=~~(a/100)&&4!=~~(a/100)?e.onRetry(t):2==~~(t.status/100)?e.onSuccess(t):e.onFail(t);var e,r,n,a})}var r,n,e,a,d=[],l=function(t,e){if(t.method!==i&&(void 0!==t.data||void 0!==e.data))return t=Array.isArray(t.data)?t.data:g(g({},t.data),e.data),JSON.stringify(t)}(s,c),p=(o=c,r=g(g({},u.headers),o.headers),n={},Object.keys(r).forEach(function(t){var e=r[t];n[t.toLowerCase()]=e}),n),h=s.method,o=s.method!==i?{}:g(g({},s.data),c.data),m=g(g(g({"x-algolia-agent":u.userAgent.value},u.queryParameters),o),c.queryParameters),y=0;return e=u.hostsCache,a=t,Promise.all(a.map(function(t){return e.get(t,function(){return Promise.resolve(x(t))})})).then(function(t){var e=t.filter(function(t){return 1===(t=t).status||12e4<Date.now()-t.lastUpdate}),r=t.filter(function(t){return(t=t).status===I&&Date.now()-t.lastUpdate<=12e4}),t=[].concat(b(e),b(r));return{getTimeout:function(t,e){return(0===r.length&&0===t?1:r.length+3+t)*e},statelessHosts:0<t.length?t.map(j):a}}).then(function(t){return f(b(t.statelessHosts).reverse(),t.getTimeout)})}function S(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(j),read:function(t,e){function r(){return q(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=p(t,2);return t[0],t[1]})})},{miss:function(t){return f.responsesCache.set(a,t)}})},write:function(t,e){return q(f,f.hosts.filter(function(t){return 0!=(t.accept&O.Write)}),t,w(e,f.timeouts.write))}};return f}function k(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 F(t){return t.map(H)}function H(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 M(r){return function(t,e){return r.transporter.write({method:D,path:"2/abtests",data:t},e)}}function K(r){return function(t,e){return r.transporter.write({method:a,path:v("2/abtests/%s",t)},e)}}function W(r){return function(t,e){return r.transporter.read({method:i,path:v("2/abtests/%s",t)},e)}}function B(e){return function(t){return e.transporter.read({method:i,path:"2/abtests"},t)}}function Q(r){return function(t,e){return r.transporter.write({method:D,path:v("2/abtests/%s/stop",t)},e)}}function G(e){return function(t){return e.transporter.read({method:i,path:"1/strategies/personalization"},t)}}function L(r){return function(t,e){return r.transporter.write({method:D,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 V(n){return function(t,e){var e=e||{},r=e.queryParameters,e=d(e,["queryParameters"]),t=g({acl:t},void 0!==r?{queryParameters:r}:{});return l(n.transporter.write({method:D,path:"1/keys",data:t},e),function(t,r){return u(function(e){return N(n)(t.key,r).catch(function(t){if(404!==t.status)throw t;return e()})})})}}function _(n){return function(t,e,r){r=w(r);return r.queryParameters["X-Algolia-User-ID"]=t,n.transporter.write({method:D,path:"1/clusters/mapping",data:{cluster:e}},r)}}function X(n){return function(t,e,r){return n.transporter.write({method:D,path:"1/clusters/mapping/batch",data:{users:t,cluster:e}},r)}}function Y(r){return function(t,e){return l(r.transporter.write({method:D,path:v("/1/dictionaries/%s/batch",t),data:{clearExistingDictionaryEntries:!0,requests:{action:"addEntry",body:[]}}},e),function(t,e){return R(r)(t.taskID,e)})}}function Z(n){return function(t,e,r){return T(n)(t,e,g(g({},r),{},{scope:[o.Rules]}))}}function $(n){return function(t,e,r){return T(n)(t,e,g(g({},r),{},{scope:[o.Settings]}))}}function tt(n){return function(t,e,r){return T(n)(t,e,g(g({},r),{},{scope:[o.Synonyms]}))}}function et(r){return function(t,e){return t.method===i?r.transporter.read(t,e):r.transporter.write(t,e)}}function rt(n){return function(r,t){return l(n.transporter.write({method:a,path:v("1/keys/%s",r)},t),function(t,e){return u(function(t){return N(n)(r,e).then(t).catch(function(t){if(404!==t.status)throw t})})})}}function nt(n){return function(t,e,r){e=e.map(function(t){return{action:"deleteEntry",body:{objectID:t}}});return l(n.transporter.write({method:D,path:v("/1/dictionaries/%s/batch",t),data:{clearExistingDictionaryEntries:!1,requests:e}},r),function(t,e){return R(n)(t.taskID,e)})}}function at(e){return function(t){return e.transporter.read({method:i,path:"/1/dictionaries/*/settings"},t)}}function ot(e){return function(t){return e.transporter.read({method:i,path:"1/logs"},t)}}function it(e){return function(t){return e.transporter.read({method:i,path:"1/clusters/mapping/top"},t)}}function ut(r){return function(t,e){return r.transporter.read({method:i,path:v("1/clusters/mapping/%s",t)},e)}}function st(r){return function(t){var t=t||{},e=t.retrieveMappings,t=d(t,["retrieveMappings"]);return!0===e&&(t.getClusters=!0),r.transporter.read({method:i,path:"1/clusters/mapping/pending"},t)}}function ct(e){return function(t){return e.transporter.read({method:i,path:"1/keys"},t)}}function ft(e){return function(t){return e.transporter.read({method:i,path:"1/clusters"},t)}}function dt(e){return function(t){return e.transporter.read({method:i,path:"1/indexes"},t)}}function lt(e){return function(t){return e.transporter.read({method:i,path:"1/clusters/mapping"},t)}}function pt(n){return function(r,t,e){return l(n.transporter.write({method:D,path:v("1/indexes/%s/operation",r),data:{operation:"move",destination:t}},e),function(t,e){return E(n)(r,{methods:{waitTask:z}}).waitTask(t.taskID,e)})}}function ht(n){return function(t,e){return l(n.transporter.write({method:D,path:"1/indexes/*/batch",data:{requests:t}},e),function(e,r){return Promise.all(Object.keys(e.taskID).map(function(t){return E(n)(t,{methods:{waitTask:z}}).waitTask(e.taskID[t],r)}))})}}function mt(r){return function(t,e){return r.transporter.read({method:D,path:"1/indexes/*/objects",data:{requests:t}},e)}}function yt(r){return function(t,e){t=t.map(function(t){return g(g({},t),{},{params:k(t.params||{})})});return r.transporter.read({method:D,path:"1/indexes/*/queries",data:{requests:t},cacheable:!0},e)}}function gt(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 E(o)(t.indexName,{methods:{searchForFacetValues:oe}}).searchForFacetValues(r,n,g(g({},a),e))}))}}function bt(r){return function(t,e){e=w(e);return e.queryParameters["X-Algolia-User-ID"]=t,r.transporter.write({method:a,path:"1/clusters/mapping"},e)}}function vt(n){return function(t,e,r){e=e.map(function(t){return{action:"addEntry",body:t}});return l(n.transporter.write({method:D,path:v("/1/dictionaries/%s/batch",t),data:{clearExistingDictionaryEntries:!0,requests:e}},r),function(t,e){return R(n)(t.taskID,e)})}}function Pt(a){return function(n,t){return l(a.transporter.write({method:D,path:v("1/keys/%s/restore",n)},t),function(t,r){return u(function(e){return N(a)(n,r).catch(function(t){if(404!==t.status)throw t;return e()})})})}}function wt(n){return function(t,e,r){e=e.map(function(t){return{action:"addEntry",body:t}});return l(n.transporter.write({method:D,path:v("/1/dictionaries/%s/batch",t),data:{clearExistingDictionaryEntries:!1,requests:e}},r),function(t,e){return R(n)(t.taskID,e)})}}function Ot(n){return function(t,e,r){return n.transporter.read({method:D,path:v("/1/dictionaries/%s/search",t),data:{query:e},cacheable:!0},r)}}function It(r){return function(t,e){return r.transporter.read({method:D,path:"1/clusters/mapping/search",data:{query:t}},e)}}function xt(r){return function(t,e){return l(r.transporter.write({method:s,path:"/1/dictionaries/*/settings",data:t},e),function(t,e){return R(r)(t.taskID,e)})}}function jt(i){return function(n,t){var a=Object.assign({},t),t=t||{},e=t.queryParameters,t=d(t,["queryParameters"]),e=e?{queryParameters:e}:{},o=["acl","indexes","referers","restrictSources","queryParameters","description","maxQueriesPerIPPerHour","maxHitsPerQuery"];return l(i.transporter.write({method:s,path:v("1/keys/%s",n),data:e},t),function(t,e){return u(function(r){return N(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 Dt(r){return function(t,e){return l(r.transporter.write({method:D,path:v("1/indexes/%s/batch",r.indexName),data:{requests:t}},e),function(t,e){return z(r)(t.taskID,e)})}}function qt(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:D,path:v("1/indexes/%s/browse",r.indexName),data:t},e)}}))}}function St(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 kt(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 ue(r)("",g(g({},e),t)).then(function(t){return g(g({},t),{},{hits:t.hits.map(function(t){return delete t._highlightResult,t})})})}}))}}function Tt(r){return function(t){return l(r.transporter.write({method:D,path:v("1/indexes/%s/clear",r.indexName)},t),function(t,e){return z(r)(t.taskID,e)})}}function Nt(r){return function(t){var t=t||{},e=t.forwardToReplicas,t=w(d(t,["forwardToReplicas"]));return e&&(t.queryParameters.forwardToReplicas=1),l(r.transporter.write({method:D,path:v("1/indexes/%s/rules/clear",r.indexName)},t),function(t,e){return z(r)(t.taskID,e)})}}function Et(r){return function(t){var t=t||{},e=t.forwardToReplicas,t=w(d(t,["forwardToReplicas"]));return e&&(t.queryParameters.forwardToReplicas=1),l(r.transporter.write({method:D,path:v("1/indexes/%s/synonyms/clear",r.indexName)},t),function(t,e){return z(r)(t.taskID,e)})}}function Rt(r){return function(t,e){return l(r.transporter.write({method:D,path:v("1/indexes/%s/deleteByQuery",r.indexName),data:t},e),function(t,e){return z(r)(t.taskID,e)})}}function At(r){return function(t){return l(r.transporter.write({method:a,path:v("1/indexes/%s",r.indexName)},t),function(t,e){return z(r)(t.taskID,e)})}}function Ct(r){return function(t,e){return l(ee(r)([t],e).then(function(t){return{taskID:t.taskIDs[0]}}),function(t,e){return z(r)(t.taskID,e)})}}function Ut(n){return function(t,e){var e=e||{},r=e.forwardToReplicas,e=w(d(e,["forwardToReplicas"]));return r&&(e.queryParameters.forwardToReplicas=1),l(n.transporter.write({method:a,path:v("1/indexes/%s/rules/%s",n.indexName,t)},e),function(t,e){return z(n)(t.taskID,e)})}}function zt(n){return function(t,e){var e=e||{},r=e.forwardToReplicas,e=w(d(e,["forwardToReplicas"]));return r&&(e.queryParameters.forwardToReplicas=1),l(n.transporter.write({method:a,path:v("1/indexes/%s/synonyms/%s",n.indexName,t)},e),function(t,e){return z(n)(t.taskID,e)})}}function Jt(e){return function(t){return re(e)(t).then(function(){return!0}).catch(function(t){if(404!==t.status)throw t;return!1})}}function Ft(n){return function(t,e,r){return n.transporter.read({method:D,path:v("1/answers/%s/prediction",n.indexName),data:{query:t,queryLanguages:e},cacheable:!0},r)}}function Ht(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 ae(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=p(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 Mt(r){return function(t,e){return r.transporter.read({method:i,path:v("1/indexes/%s/%s",r.indexName,t)},e)}}function Kt(){return function(t,e){for(var r=0,n=Object.entries(t.hits);r<n.length;r++){var a=p(n[r],2),o=a[0];if(a[1].objectID===e)return parseInt(o,10)}return-1}}function Wt(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:D,path:"1/indexes/*/objects",data:{requests:t}},e)}}function Bt(r){return function(t,e){return r.transporter.read({method:i,path:v("1/indexes/%s/rules/%s",r.indexName,t)},e)}}function Qt(r){return function(t,e){return r.transporter.read({method:i,path:v("1/indexes/%s/synonyms/%s",r.indexName,t)},e)}}function Gt(r){return function(t,e){return l(ne(r)([t],e).then(function(t){return{objectID:t.objectIDs[0],taskID:t.taskIDs[0]}}),function(t,e){return z(r)(t.taskID,e)})}}function Lt(f){return function(e,t){function r(t,e,r,n){return l(f.transporter.write({method:D,path:v("1/indexes/%s/operation",t),data:{operation:r,destination:e}},n),function(t,e){return z(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=A({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),l((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 t=p(t,3),e=t[0],r=t[1],t=t[2];return{objectIDs:r.objectIDs,taskIDs:[e.taskID].concat(b(r.taskIDs),[t.taskID])}}),function(t,e){return Promise.all(c.map(function(t){return t.wait(e)}))})}}function Vt(r){return function(t,e){return C(r)(t,g(g({},e),{},{clearExistingRules:!0}))}}function _t(r){return function(t,e){return U(r)(t,g(g({},e),{},{clearExistingSynonyms:!0}))}}function Xt(r){return function(t,e){return l(A(r)([t],e).then(function(t){return{objectID:t.objectIDs[0],taskID:t.taskIDs[0]}}),function(t,e){return z(r)(t.taskID,e)})}}function Yt(r){return function(t,e){return C(r)([t],e)}}function Zt(r){return function(t,e){return U(r)([t],e)}}function $t(n){return function(t,e){var e=e||{},r=e.forwardToReplicas,e=w(d(e,["forwardToReplicas"]));return r&&(e.queryParameters.forwardToReplicas=1),l(n.transporter.write({method:s,path:v("1/indexes/%s/settings",n.indexName),data:t},e),function(t,e){return z(n)(t.taskID,e)})}}var T=function(n){return function(r,t,e){return l(n.transporter.write({method:D,path:v("1/indexes/%s/operation",r),data:{operation:"copy",destination:t}},e),function(t,e){return E(n)(r,{methods:{waitTask:z}}).waitTask(t.taskID,e)})}},N=function(r){return function(t,e){return r.transporter.read({method:i,path:v("1/keys/%s",t)},e)}},te=function(r){return function(t,e){return r.transporter.read({method:i,path:v("1/task/%s",t.toString())},e)}},E=function(e){return function(t){return y({transporter:e.transporter,appId:e.appId,indexName:t},(1<arguments.length&&void 0!==arguments[1]?arguments[1]:{}).methods)}},R=function(n){return function(t,r){return u(function(e){return te(n)(t,r).then(function(t){return"published"!==t.status?e():void 0})})}},c=function(s){return function(n,a,t){var t=t||{},o=t.batchSize,i=d(t,["batchSize"]),u={taskIDs:[],objectIDs:[]};return l(function e(){for(var t=[],r=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0;r<n.length&&(t.push(n[r]),t.length!==(o||1e3));r++);return 0===t.length?Promise.resolve(u):Dt(s)(t.map(function(t){return{action:a,body:t}}),i).then(function(t){return u.objectIDs=u.objectIDs.concat(t.objectIDs),u.taskIDs.push(t.taskID),e(++r)})}(),function(t,e){return Promise.all(t.taskIDs.map(function(t){return z(s)(t,e)}))})}},ee=function(r){return function(t,e){t=t.map(function(t){return{objectID:t}});return c(r)(t,f.DeleteObject,e)}},re=function(e){return function(t){return e.transporter.read({method:i,path:v("1/indexes/%s/settings",e.indexName),data:{getVersion:2}},t)}},ne=function(n){return function(t,e){var e=e||{},r=e.createIfNotExists,e=d(e,["createIfNotExists"]),r=r?f.PartialUpdateObject:f.PartialUpdateObjectNoCreate;return c(n)(t,r,e)}},A=function(s){return function(t,e){var e=e||{},r=e.autoGenerateObjectIDIfNotExist,e=d(e,["autoGenerateObjectIDIfNotExist"]),r=r?f.AddObject:f.UpdateObject;if(r===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 l(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,r,e)}},C=function(a){return function(t,e){var e=e||{},r=e.forwardToReplicas,n=e.clearExistingRules,e=w(d(e,["forwardToReplicas","clearExistingRules"]));return r&&(e.queryParameters.forwardToReplicas=1),n&&(e.queryParameters.clearExistingRules=1),l(a.transporter.write({method:D,path:v("1/indexes/%s/rules/batch",a.indexName),data:t},e),function(t,e){return z(a)(t.taskID,e)})}},U=function(o){return function(t,e){var e=e||{},r=e.forwardToReplicas,n=e.clearExistingSynonyms,a=e.replaceExistingSynonyms,e=w(d(e,["forwardToReplicas","clearExistingSynonyms","replaceExistingSynonyms"]));return r&&(e.queryParameters.forwardToReplicas=1),(a||n)&&(e.queryParameters.replaceExistingSynonyms=1),l(o.transporter.write({method:D,path:v("1/indexes/%s/synonyms/batch",o.indexName),data:t},e),function(t,e){return z(o)(t.taskID,e)})}},ae=function(r){return function(t,e){return r.transporter.read({method:D,path:v("1/indexes/%s/query",r.indexName),data:{query:t},cacheable:!0},e)}},oe=function(n){return function(t,e,r){return n.transporter.read({method:D,path:v("1/indexes/%s/facets/%s/query",n.indexName,t),data:{facetQuery:e},cacheable:!0},r)}},ie=function(r){return function(t,e){return r.transporter.read({method:D,path:v("1/indexes/%s/rules/search",r.indexName),data:{query:t}},e)}},ue=function(r){return function(t,e){return r.transporter.read({method:D,path:v("1/indexes/%s/synonyms/search",r.indexName),data:{query:t}},e)}},z=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"},o={Settings:"settings",Synonyms:"synonyms",Rules:"rules"};function t(t,e,r){function n(){return function(t){return t=g(g(g({},c),t),{},{methods:{getPersonalizationStrategy:G,setPersonalizationStrategy:L}}),e=t.region||"us",r=m(P.WithinHeaders,t.appId,t.apiKey),e=S(g(g({hosts:[{url:"personalization.".concat(e,".algolia.com")}]},t),{},{headers:g(g(g({},r.headers()),{"content-type":"application/json"}),t.headers),queryParameters:g(g({},r.queryParameters()),t.queryParameters)})),y({appId:t.appId,transporter:e},t.methods);var e,r}}var a,o,i,u,s,c={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:h(),requestsCache:h({serializable:!1}),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 p(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:[(o={key:"".concat("4.14.2","-").concat(t)},u="algoliasearch-client-js-".concat(o.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=l()[t];return Promise.all([t||r(),void 0!==t])}).then(function(t){var t=p(t,2),e=t[0],t=t[1];return Promise.all([e,t||n.miss(e)])}).then(function(t){return p(t,1)[0]})},set:function(e,r){return Promise.resolve().then(function(){var t=l();return t[JSON.stringify(e)]=r,d().setItem(u,JSON.stringify(t)),r})},delete:function(e){return Promise.resolve().then(function(){var t=l();delete t[JSON.stringify(e)],d().setItem(u,JSON.stringify(t))})},clear:function(){return Promise.resolve().then(function(){d().removeItem(u)})}}),h()]}),userAgent:(a={value:"Algolia for JavaScript (".concat("4.14.2",")"),add:function(t){t="; ".concat(t.segment).concat(void 0!==t.version?" (".concat(t.version,")"):"");return-1===a.value.indexOf(t)&&(a.value="".concat(a.value).concat(t)),a}}).add({segment:"Browser"})},f=g(g({},c),r);function d(){return i=void 0===i?o.localStorage||window.localStorage:i}function l(){return JSON.parse(d().getItem(u)||"{}")}return e=g(g({},f),{},{methods:{search:yt,searchForFacetValues:gt,multipleBatch:ht,multipleGetObjects:mt,multipleQueries:yt,copyIndex:T,copySettings:$,copySynonyms:tt,copyRules:Z,moveIndex:pt,listIndices:dt,getLogs:ot,listClusters:ft,multipleSearchForFacetValues:gt,getApiKey:N,addApiKey:V,listApiKeys:ct,updateApiKey:jt,deleteApiKey:rt,restoreApiKey:Pt,assignUserID:_,assignUserIDs:X,getUserID:ut,searchUserIDs:It,listUserIDs:lt,getTopUserIDs:it,removeUserID:bt,hasPendingMappings:st,clearDictionaryEntries:Y,deleteDictionaryEntries:nt,getDictionarySettings:at,getAppTask:te,replaceDictionaryEntries:vt,saveDictionaryEntries:wt,searchDictionaryEntries:Ot,setDictionarySettings:xt,waitAppTask:R,customRequest:et,initIndex:function(e){return function(t){return E(e)(t,{methods:{batch:Dt,delete:At,findAnswers:Ft,getObject:Mt,getObjects:Wt,saveObject:Xt,saveObjects:A,search:ae,searchForFacetValues:oe,waitTask:z,setSettings:$t,getSettings:re,partialUpdateObject:Gt,partialUpdateObjects:ne,deleteObject:Ct,deleteObjects:ee,deleteBy:Rt,clearObjects:Tt,browseObjects:qt,getObjectPosition:Kt,findObject:Ht,exists:Jt,saveSynonym:Zt,saveSynonyms:U,getSynonym:Qt,searchSynonyms:ue,browseSynonyms:kt,deleteSynonym:zt,clearSynonyms:Et,replaceAllObjects:Lt,replaceAllSynonyms:_t,searchRules:ie,getRule:Bt,deleteRule:Ut,saveRule:Yt,saveRules:C,replaceAllRules:Vt,browseRules:St,clearRules:Nt}})}},initAnalytics:function(){return function(t){return t=g(g(g({},c),t),{},{methods:{addABTest:M,getABTest:W,getABTests:B,stopABTest:Q,deleteABTest:K}}),e=t.region||"us",r=m(P.WithinHeaders,t.appId,t.apiKey),e=S(g(g({hosts:[{url:"analytics.".concat(e,".algolia.com")}]},t),{},{headers:g(g(g({},r.headers()),{"content-type":"application/json"}),t.headers),queryParameters:g(g({},r.queryParameters()),t.queryParameters)})),y({appId:t.appId,transporter:e},t.methods);var e,r}},initPersonalization:n,initRecommendation:function(){return function(t){return f.logger.info("The `initRecommendation` method is deprecated. Use `initPersonalization` instead."),n()(t)}}}}),t=e.appId,r=m(void 0!==e.authMode?e.authMode:P.WithinHeaders,t,e.apiKey),y({transporter:s=S(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){s.userAgent.add({segment:t,version:e})},clearCache:function(){return Promise.all([s.requestsCache.clear(),s.responsesCache.clear()]).then(function(){})}},e.methods)}return t.version="4.14.2",t});