algoliasearch 3.25.0 → 3.27.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,3 @@
1
- /*! algoliasearch 3.25.0 | © 2014, 2015 Algolia SAS | github.com/algolia/algoliasearch-client-js */
2
- !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.algoliasearch=e()}}(function(){var e;return function t(e,o,r){function n(s,a){if(!o[s]){if(!e[s]){var u="function"==typeof require&&require;if(!a&&u)return u(s,!0);if(i)return i(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var l=o[s]={exports:{}};e[s][0].call(l.exports,function(t){var o=e[s][1][t];return n(o?o:t)},l,l.exports,t,e,o,r)}return o[s].exports}for(var i="function"==typeof require&&require,s=0;s<r.length;s++)n(r[s]);return n}({1:[function(e,t,o){(function(r){function n(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type)||("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))}function i(e){var t=this.useColors;if(e[0]=(t?"%c":"")+this.namespace+(t?" %c":" ")+e[0]+(t?"%c ":" ")+"+"+o.humanize(this.diff),t){var r="color: "+this.color;e.splice(1,0,r,"color: inherit");var n=0,i=0;e[0].replace(/%[a-zA-Z%]/g,function(e){"%%"!==e&&(n++,"%c"===e&&(i=n))}),e.splice(i,0,r)}}function s(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function a(e){try{null==e?o.storage.removeItem("debug"):o.storage.debug=e}catch(t){}}function u(){var e;try{e=o.storage.debug}catch(t){}return!e&&"undefined"!=typeof r&&"env"in r&&(e=r.env.DEBUG),e}function c(){try{return window.localStorage}catch(e){}}o=t.exports=e(2),o.log=s,o.formatArgs=i,o.save=a,o.load=u,o.useColors=n,o.storage="undefined"!=typeof chrome&&"undefined"!=typeof chrome.storage?chrome.storage.local:c(),o.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],o.formatters.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}},o.enable(u())}).call(this,e(11))},{11:11,2:2}],2:[function(e,t,o){function r(e){var t,r=0;for(t in e)r=(r<<5)-r+e.charCodeAt(t),r|=0;return o.colors[Math.abs(r)%o.colors.length]}function n(e){function t(){if(t.enabled){var e=t,r=+new Date,n=r-(c||r);e.diff=n,e.prev=c,e.curr=r,c=r;for(var i=new Array(arguments.length),s=0;s<i.length;s++)i[s]=arguments[s];i[0]=o.coerce(i[0]),"string"!=typeof i[0]&&i.unshift("%O");var a=0;i[0]=i[0].replace(/%([a-zA-Z%])/g,function(t,r){if("%%"===t)return t;a++;var n=o.formatters[r];if("function"==typeof n){var s=i[a];t=n.call(e,s),i.splice(a,1),a--}return t}),o.formatArgs.call(e,i);var u=t.log||o.log||console.log.bind(console);u.apply(e,i)}}return t.namespace=e,t.enabled=o.enabled(e),t.useColors=o.useColors(),t.color=r(e),"function"==typeof o.init&&o.init(t),t}function i(e){o.save(e),o.names=[],o.skips=[];for(var t=("string"==typeof e?e:"").split(/[\s,]+/),r=t.length,n=0;n<r;n++)t[n]&&(e=t[n].replace(/\*/g,".*?"),"-"===e[0]?o.skips.push(new RegExp("^"+e.substr(1)+"$")):o.names.push(new RegExp("^"+e+"$")))}function s(){o.enable("")}function a(e){var t,r;for(t=0,r=o.skips.length;t<r;t++)if(o.skips[t].test(e))return!1;for(t=0,r=o.names.length;t<r;t++)if(o.names[t].test(e))return!0;return!1}function u(e){return e instanceof Error?e.stack||e.message:e}o=t.exports=n.debug=n["default"]=n,o.coerce=u,o.disable=s,o.enable=i,o.enabled=a,o.humanize=e(8),o.names=[],o.skips=[],o.formatters={};var c},{8:8}],3:[function(t,o,r){(function(n,i){!function(t,n){"object"==typeof r&&"undefined"!=typeof o?o.exports=n():"function"==typeof e&&e.amd?e(n):t.ES6Promise=n()}(this,function(){"use strict";function e(e){var t=typeof e;return null!==e&&("object"===t||"function"===t)}function o(e){return"function"==typeof e}function r(e){Y=e}function s(e){z=e}function a(){return function(){return n.nextTick(f)}}function u(){return"undefined"!=typeof G?function(){G(f)}:p()}function c(){var e=0,t=new Z(f),o=document.createTextNode("");return t.observe(o,{characterData:!0}),function(){o.data=e=++e%2}}function l(){var e=new MessageChannel;return e.port1.onmessage=f,function(){return e.port2.postMessage(0)}}function p(){var e=setTimeout;return function(){return e(f,1)}}function f(){for(var e=0;e<V;e+=2){var t=oe[e],o=oe[e+1];t(o),oe[e]=void 0,oe[e+1]=void 0}V=0}function d(){try{var e=t,o=e("vertx");return G=o.runOnLoop||o.runOnContext,u()}catch(r){return p()}}function h(e,t){var o=arguments,r=this,n=new this.constructor(m);void 0===n[ne]&&P(n);var i=r._state;return i?!function(){var e=o[i-1];z(function(){return C(i,n,e,r._result)})}():k(r,n,e,t),n}function y(e){var t=this;if(e&&"object"==typeof e&&e.constructor===t)return e;var o=new t(m);return x(o,e),o}function m(){}function g(){return new TypeError("You cannot resolve a promise with itself")}function v(){return new TypeError("A promises callback cannot return that same promise.")}function b(e){try{return e.then}catch(t){return ue.error=t,ue}}function w(e,t,o,r){try{e.call(t,o,r)}catch(n){return n}}function _(e,t,o){z(function(e){var r=!1,n=w(o,t,function(o){r||(r=!0,t!==o?x(e,o):j(e,o))},function(t){r||(r=!0,O(e,t))},"Settle: "+(e._label||" unknown promise"));!r&&n&&(r=!0,O(e,n))},e)}function T(e,t){t._state===se?j(e,t._result):t._state===ae?O(e,t._result):k(t,void 0,function(t){return x(e,t)},function(t){return O(e,t)})}function S(e,t,r){t.constructor===e.constructor&&r===h&&t.constructor.resolve===y?T(e,t):r===ue?(O(e,ue.error),ue.error=null):void 0===r?j(e,t):o(r)?_(e,t,r):j(e,t)}function x(t,o){t===o?O(t,g()):e(o)?S(t,o,b(o)):j(t,o)}function A(e){e._onerror&&e._onerror(e._result),I(e)}function j(e,t){e._state===ie&&(e._result=t,e._state=se,0!==e._subscribers.length&&z(I,e))}function O(e,t){e._state===ie&&(e._state=ae,e._result=t,z(A,e))}function k(e,t,o,r){var n=e._subscribers,i=n.length;e._onerror=null,n[i]=t,n[i+se]=o,n[i+ae]=r,0===i&&e._state&&z(I,e)}function I(e){var t=e._subscribers,o=e._state;if(0!==t.length){for(var r=void 0,n=void 0,i=e._result,s=0;s<t.length;s+=3)r=t[s],n=t[s+o],r?C(o,r,n,i):n(i);e._subscribers.length=0}}function E(){this.error=null}function R(e,t){try{return e(t)}catch(o){return ce.error=o,ce}}function C(e,t,r,n){var i=o(r),s=void 0,a=void 0,u=void 0,c=void 0;if(i){if(s=R(r,n),s===ce?(c=!0,a=s.error,s.error=null):u=!0,t===s)return void O(t,v())}else s=n,u=!0;t._state!==ie||(i&&u?x(t,s):c?O(t,a):e===se?j(t,s):e===ae&&O(t,s))}function N(e,t){try{t(function(t){x(e,t)},function(t){O(e,t)})}catch(o){O(e,o)}}function q(){return le++}function P(e){e[ne]=le++,e._state=void 0,e._result=void 0,e._subscribers=[]}function U(e,t){this._instanceConstructor=e,this.promise=new e(m),this.promise[ne]||P(this.promise),K(t)?(this.length=t.length,this._remaining=t.length,this._result=new Array(this.length),0===this.length?j(this.promise,this._result):(this.length=this.length||0,this._enumerate(t),0===this._remaining&&j(this.promise,this._result))):O(this.promise,D())}function D(){return new Error("Array Methods must be provided an Array")}function M(e){return new U(this,e).promise}function H(e){var t=this;return new t(K(e)?function(o,r){for(var n=e.length,i=0;i<n;i++)t.resolve(e[i]).then(o,r)}:function(e,t){return t(new TypeError("You must pass an array to race."))})}function J(e){var t=this,o=new t(m);return O(o,e),o}function F(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function $(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}function L(e){this[ne]=q(),this._result=this._state=void 0,this._subscribers=[],m!==e&&("function"!=typeof e&&F(),this instanceof L?N(this,e):$())}function B(){var e=void 0;if("undefined"!=typeof i)e=i;else if("undefined"!=typeof self)e=self;else try{e=Function("return this")()}catch(t){throw new Error("polyfill failed because global object is unavailable in this environment")}var o=e.Promise;if(o){var r=null;try{r=Object.prototype.toString.call(o.resolve())}catch(t){}if("[object Promise]"===r&&!o.cast)return}e.Promise=L}var X=void 0;X=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)};var K=X,V=0,G=void 0,Y=void 0,z=function(e,t){oe[V]=e,oe[V+1]=t,V+=2,2===V&&(Y?Y(f):re())},Q="undefined"!=typeof window?window:void 0,W=Q||{},Z=W.MutationObserver||W.WebKitMutationObserver,ee="undefined"==typeof self&&"undefined"!=typeof n&&"[object process]"==={}.toString.call(n),te="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel,oe=new Array(1e3),re=void 0;re=ee?a():Z?c():te?l():void 0===Q&&"function"==typeof t?d():p();var ne=Math.random().toString(36).substring(16),ie=void 0,se=1,ae=2,ue=new E,ce=new E,le=0;return U.prototype._enumerate=function(e){for(var t=0;this._state===ie&&t<e.length;t++)this._eachEntry(e[t],t)},U.prototype._eachEntry=function(e,t){var o=this._instanceConstructor,r=o.resolve;if(r===y){var n=b(e);if(n===h&&e._state!==ie)this._settledAt(e._state,t,e._result);else if("function"!=typeof n)this._remaining--,this._result[t]=e;else if(o===L){var i=new o(m);S(i,e,n),this._willSettleAt(i,t)}else this._willSettleAt(new o(function(t){return t(e)}),t)}else this._willSettleAt(r(e),t)},U.prototype._settledAt=function(e,t,o){var r=this.promise;r._state===ie&&(this._remaining--,e===ae?O(r,o):this._result[t]=o),0===this._remaining&&j(r,this._result)},U.prototype._willSettleAt=function(e,t){var o=this;k(e,void 0,function(e){return o._settledAt(se,t,e)},function(e){return o._settledAt(ae,t,e)})},L.all=M,L.race=H,L.resolve=y,L.reject=J,L._setScheduler=r,L._setAsap=s,L._asap=z,L.prototype={constructor:L,then:h,"catch":function(e){return this.then(null,e)}},L.polyfill=B,L.Promise=L,L})}).call(this,t(11),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{11:11}],4:[function(e,t,o){var r=Object.prototype.hasOwnProperty,n=Object.prototype.toString;t.exports=function(e,t,o){if("[object Function]"!==n.call(t))throw new TypeError("iterator must be a function");var i=e.length;if(i===+i)for(var s=0;s<i;s++)t.call(o,e[s],s,e);else for(var a in e)r.call(e,a)&&t.call(o,e[a],a,e)}},{}],5:[function(e,t,o){(function(e){var o;o="undefined"!=typeof window?window:"undefined"!=typeof e?e:"undefined"!=typeof self?self:{},t.exports=o}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],6:[function(e,t,o){"function"==typeof Object.create?t.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:t.exports=function(e,t){e.super_=t;var o=function(){};o.prototype=t.prototype,e.prototype=new o,e.prototype.constructor=e}},{}],7:[function(e,t,o){var r={}.toString;t.exports=Array.isArray||function(e){return"[object Array]"==r.call(e)}},{}],8:[function(e,t,o){function r(e){if(e=String(e),!(e.length>100)){var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(t){var o=parseFloat(t[1]),r=(t[2]||"ms").toLowerCase();switch(r){case"years":case"year":case"yrs":case"yr":case"y":return o*p;case"days":case"day":case"d":return o*l;case"hours":case"hour":case"hrs":case"hr":case"h":return o*c;case"minutes":case"minute":case"mins":case"min":case"m":return o*u;case"seconds":case"second":case"secs":case"sec":case"s":return o*a;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return o;default:return}}}}function n(e){return e>=l?Math.round(e/l)+"d":e>=c?Math.round(e/c)+"h":e>=u?Math.round(e/u)+"m":e>=a?Math.round(e/a)+"s":e+"ms"}function i(e){return s(e,l,"day")||s(e,c,"hour")||s(e,u,"minute")||s(e,a,"second")||e+" ms"}function s(e,t,o){if(!(e<t))return e<1.5*t?Math.floor(e/t)+" "+o:Math.ceil(e/t)+" "+o+"s"}var a=1e3,u=60*a,c=60*u,l=24*c,p=365.25*l;t.exports=function(e,t){t=t||{};var o=typeof e;if("string"===o&&e.length>0)return r(e);if("number"===o&&isNaN(e)===!1)return t["long"]?i(e):n(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},{}],9:[function(e,t,o){"use strict";var r=Object.prototype.hasOwnProperty,n=Object.prototype.toString,i=Array.prototype.slice,s=e(10),a=Object.prototype.propertyIsEnumerable,u=!a.call({toString:null},"toString"),c=a.call(function(){},"prototype"),l=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],p=function(e){var t=e.constructor;return t&&t.prototype===e},f={$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},d=function(){if("undefined"==typeof window)return!1;for(var e in window)try{if(!f["$"+e]&&r.call(window,e)&&null!==window[e]&&"object"==typeof window[e])try{p(window[e])}catch(t){return!0}}catch(t){return!0}return!1}(),h=function(e){if("undefined"==typeof window||!d)return p(e);try{return p(e)}catch(t){return!1}},y=function(e){var t=null!==e&&"object"==typeof e,o="[object Function]"===n.call(e),i=s(e),a=t&&"[object String]"===n.call(e),p=[];if(!t&&!o&&!i)throw new TypeError("Object.keys called on a non-object");var f=c&&o;if(a&&e.length>0&&!r.call(e,0))for(var d=0;d<e.length;++d)p.push(String(d));if(i&&e.length>0)for(var y=0;y<e.length;++y)p.push(String(y));else for(var m in e)f&&"prototype"===m||!r.call(e,m)||p.push(String(m));if(u)for(var g=h(e),v=0;v<l.length;++v)g&&"constructor"===l[v]||!r.call(e,l[v])||p.push(l[v]);return p};y.shim=function(){if(Object.keys){var e=function(){return 2===(Object.keys(arguments)||"").length}(1,2);if(!e){var t=Object.keys;Object.keys=function(e){return t(s(e)?i.call(e):e)}}}else Object.keys=y;return Object.keys||y},t.exports=y},{10:10}],10:[function(e,t,o){"use strict";var r=Object.prototype.toString;t.exports=function(e){var t=r.call(e),o="[object Arguments]"===t;return o||(o="[object Array]"!==t&&null!==e&&"object"==typeof e&&"number"==typeof e.length&&e.length>=0&&"[object Function]"===r.call(e.callee)),o}},{}],11:[function(e,t,o){function r(){throw new Error("setTimeout has not been defined")}function n(){throw new Error("clearTimeout has not been defined")}function i(e){if(p===setTimeout)return setTimeout(e,0);if((p===r||!p)&&setTimeout)return p=setTimeout,setTimeout(e,0);try{return p(e,0)}catch(t){try{return p.call(null,e,0)}catch(t){return p.call(this,e,0)}}}function s(e){if(f===clearTimeout)return clearTimeout(e);if((f===n||!f)&&clearTimeout)return f=clearTimeout,clearTimeout(e);try{return f(e)}catch(t){try{return f.call(null,e)}catch(t){return f.call(this,e)}}}function a(){m&&h&&(m=!1,h.length?y=h.concat(y):g=-1,y.length&&u())}function u(){if(!m){var e=i(a);m=!0;for(var t=y.length;t;){for(h=y,y=[];++g<t;)h&&h[g].run();g=-1,t=y.length}h=null,m=!1,s(e)}}function c(e,t){this.fun=e,this.array=t}function l(){}var p,f,d=t.exports={};!function(){try{p="function"==typeof setTimeout?setTimeout:r}catch(e){p=r}try{f="function"==typeof clearTimeout?clearTimeout:n}catch(e){f=n}}();var h,y=[],m=!1,g=-1;d.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var o=1;o<arguments.length;o++)t[o-1]=arguments[o];y.push(new c(e,t)),1!==y.length||m||i(u)},c.prototype.run=function(){this.fun.apply(null,this.array)},d.title="browser",d.browser=!0,d.env={},d.argv=[],d.version="",d.versions={},d.on=l,d.addListener=l,d.once=l,d.off=l,d.removeListener=l,d.removeAllListeners=l,d.emit=l,d.binding=function(e){throw new Error("process.binding is not supported")},d.cwd=function(){return"/"},d.chdir=function(e){throw new Error("process.chdir is not supported")},d.umask=function(){return 0}},{}],12:[function(e,t,o){"use strict";function r(e,t){if(e.map)return e.map(t);for(var o=[],r=0;r<e.length;r++)o.push(t(e[r],r));return o}var n=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};t.exports=function(e,t,o,a){return t=t||"&",o=o||"=",null===e&&(e=void 0),"object"==typeof e?r(s(e),function(s){var a=encodeURIComponent(n(s))+o;return i(e[s])?r(e[s],function(e){return a+encodeURIComponent(n(e))}).join(t):a+encodeURIComponent(n(e[s]))}).join(t):a?encodeURIComponent(n(a))+o+encodeURIComponent(n(e)):""};var i=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},s=Object.keys||function(e){var t=[];for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.push(o);return t}},{}],13:[function(e,t,o){(function(o){function r(t,o,r){var i=e(1)("algoliasearch"),s=e(20),a=e(7),c=e(25),l="Usage: algoliasearch(applicationID, apiKey, opts)";if(r._allowEmptyCredentials!==!0&&!t)throw new u.AlgoliaSearchError("Please provide an application ID. "+l);if(r._allowEmptyCredentials!==!0&&!o)throw new u.AlgoliaSearchError("Please provide an API key. "+l);this.applicationID=t,this.apiKey=o,this.hosts={read:[],write:[]},r=r||{};var p=r.protocol||"https:";if(this._timeouts=r.timeouts||{connect:1e3,read:2e3,write:3e4},r.timeout&&(this._timeouts.connect=this._timeouts.read=this._timeouts.write=r.timeout),/:$/.test(p)||(p+=":"),"http:"!==r.protocol&&"https:"!==r.protocol)throw new u.AlgoliaSearchError("protocol must be `http:` or `https:` (was `"+r.protocol+"`)");if(this._checkAppIdData(),r.hosts)a(r.hosts)?(this.hosts.read=s(r.hosts),this.hosts.write=s(r.hosts)):(this.hosts.read=s(r.hosts.read),this.hosts.write=s(r.hosts.write));else{var f=c(this._shuffleResult,function(e){return t+"-"+e+".algolianet.com"});this.hosts.read=[this.applicationID+"-dsn.algolia.net"].concat(f),this.hosts.write=[this.applicationID+".algolia.net"].concat(f)}this.hosts.read=c(this.hosts.read,n(p)),this.hosts.write=c(this.hosts.write,n(p)),this.extraHeaders={},this.cache=r._cache||{},this._ua=r._ua,this._useCache=!(void 0!==r._useCache&&!r._cache)||r._useCache,this._useFallback=void 0===r.useFallback||r.useFallback,this._setTimeout=r._setTimeout,i("init done, %j",this)}function n(e){return function(t){return e+"//"+t.toLowerCase()}}function i(e){if(void 0===Array.prototype.toJSON)return JSON.stringify(e);var t=Array.prototype.toJSON;delete Array.prototype.toJSON;var o=JSON.stringify(e);return Array.prototype.toJSON=t,o}function s(e){for(var t,o,r=e.length;0!==r;)o=Math.floor(Math.random()*r),r-=1,t=e[r],e[r]=e[o],e[o]=t;return e}function a(e){var t={};for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var r;r="x-algolia-api-key"===o||"x-algolia-application-id"===o?"**hidden for security purposes**":e[o],t[o]=r}return t}t.exports=r;var u=e(23),c=e(24),l=e(14),p=e(29),f=500,d=o.env.RESET_APP_DATA_TIMER&&parseInt(o.env.RESET_APP_DATA_TIMER,10)||12e4;r.prototype.initIndex=function(e){return new l(this,e)},r.prototype.setExtraHeader=function(e,t){this.extraHeaders[e.toLowerCase()]=t},r.prototype.getExtraHeader=function(e){return this.extraHeaders[e.toLowerCase()]},r.prototype.unsetExtraHeader=function(e){delete this.extraHeaders[e.toLowerCase()]},r.prototype.addAlgoliaAgent=function(e){this._ua.indexOf(";"+e)===-1&&(this._ua+=";"+e)},r.prototype._jsonRequest=function(t){function o(e,c){function f(e){var t=e&&e.body&&e.body.message&&e.body.status||e.statusCode||e&&e.body&&200;s("received response: statusCode: %s, computed statusCode: %d, headers: %j",e.statusCode,t,e.headers);var o=2===Math.floor(t/100),i=new Date;if(g.push({currentHost:S,headers:a(n),content:r||null,contentLength:void 0!==r?r.length:null,method:c.method,timeouts:c.timeouts,url:c.url,startTime:T,endTime:i,duration:i-T,statusCode:t}),o)return d._useCache&&p&&(p[_]=e.responseText),e.body;var l=4!==Math.floor(t/100);if(l)return h+=1,b();s("unrecoverable error");var f=new u.AlgoliaSearchError(e.body&&e.body.message,{debugData:g,statusCode:t});return d._promise.reject(f)}function v(e){s("error: %s, stack: %s",e.message,e.stack);var o=new Date;return g.push({currentHost:S,headers:a(n),content:r||null,contentLength:void 0!==r?r.length:null,method:c.method,timeouts:c.timeouts,url:c.url,startTime:T,endTime:o,duration:o-T}),e instanceof u.AlgoliaSearchError||(e=new u.Unknown(e&&e.message,e)),h+=1,e instanceof u.Unknown||e instanceof u.UnparsableJSON||h>=d.hosts[t.hostType].length&&(y||!m)?(e.debugData=g,d._promise.reject(e)):e instanceof u.RequestTimeout?w():b()}function b(){return s("retrying request"),d._incrementHostIndex(t.hostType),o(e,c)}function w(){return s("retrying request with higher timeout"),d._incrementHostIndex(t.hostType),d._incrementTimeoutMultipler(),c.timeouts=d._getTimeoutsForRequest(t.hostType),o(e,c)}d._checkAppIdData();var _,T=new Date;if(d._useCache&&(_=t.url),d._useCache&&r&&(_+="_body_"+c.body),d._useCache&&p&&void 0!==p[_])return s("serving response from cache"),d._promise.resolve(JSON.parse(p[_]));if(h>=d.hosts[t.hostType].length)return!m||y?(s("could not get any response"),d._promise.reject(new u.AlgoliaSearchError("Cannot connect to the AlgoliaSearch API. Send an email to support@algolia.com to report and resolve the issue. Application id was: "+d.applicationID,{debugData:g}))):(s("switching to fallback"),h=0,c.method=t.fallback.method,c.url=t.fallback.url,c.jsonBody=t.fallback.body,c.jsonBody&&(c.body=i(c.jsonBody)),n=d._computeRequestHeaders({additionalUA:l,headers:t.headers}),c.timeouts=d._getTimeoutsForRequest(t.hostType),d._setHostIndexByType(0,t.hostType),y=!0,o(d._request.fallback,c));var S=d._getHostByType(t.hostType),x=S+c.url,A={body:c.body,jsonBody:c.jsonBody,method:c.method,headers:n,timeouts:c.timeouts,debug:s};return s("method: %s, url: %s, headers: %j, timeouts: %d",A.method,x,A.headers,A.timeouts),e===d._request.fallback&&s("using fallback"),e.call(d,x,A).then(f,v)}this._checkAppIdData();var r,n,s=e(1)("algoliasearch:"+t.url),l=t.additionalUA||"",p=t.cache,d=this,h=0,y=!1,m=d._useFallback&&d._request.fallback&&t.fallback;this.apiKey.length>f&&void 0!==t.body&&(void 0!==t.body.params||void 0!==t.body.requests)?(t.body.apiKey=this.apiKey,n=this._computeRequestHeaders({additionalUA:l,withApiKey:!1,headers:t.headers})):n=this._computeRequestHeaders({additionalUA:l,headers:t.headers}),void 0!==t.body&&(r=i(t.body)),s("request start");var g=[],v=o(d._request,{url:t.url,method:t.method,body:r,jsonBody:t.body,timeouts:d._getTimeoutsForRequest(t.hostType)});return"function"!=typeof t.callback?v:void v.then(function(e){c(function(){t.callback(null,e)},d._setTimeout||setTimeout)},function(e){c(function(){t.callback(e)},d._setTimeout||setTimeout)})},r.prototype._getSearchParams=function(e,t){if(void 0===e||null===e)return t;for(var o in e)null!==o&&void 0!==e[o]&&e.hasOwnProperty(o)&&(t+=""===t?"":"&",t+=o+"="+encodeURIComponent("[object Array]"===Object.prototype.toString.call(e[o])?i(e[o]):e[o]));return t},r.prototype._computeRequestHeaders=function(t){var o=e(4),r=t.additionalUA?this._ua+";"+t.additionalUA:this._ua,n={"x-algolia-agent":r,"x-algolia-application-id":this.applicationID};return t.withApiKey!==!1&&(n["x-algolia-api-key"]=this.apiKey),this.userToken&&(n["x-algolia-usertoken"]=this.userToken),this.securityTags&&(n["x-algolia-tagfilters"]=this.securityTags),o(this.extraHeaders,function(e,t){n[t]=e}),t.headers&&o(t.headers,function(e,t){n[t]=e}),n},r.prototype.search=function(t,o,r){var n=e(7),i=e(25),s="Usage: client.search(arrayOfQueries[, callback])";if(!n(t))throw new Error(s);"function"==typeof o?(r=o,o={}):void 0===o&&(o={});var a=this,u={requests:i(t,function(e){var t="";return void 0!==e.query&&(t+="query="+encodeURIComponent(e.query)),{indexName:e.indexName,params:a._getSearchParams(e.params,t)}})},c=i(u.requests,function(e,t){return t+"="+encodeURIComponent("/1/indexes/"+encodeURIComponent(e.indexName)+"?"+e.params)}).join("&"),l="/1/indexes/*/queries";return void 0!==o.strategy&&(l+="?strategy="+o.strategy),this._jsonRequest({cache:this.cache,method:"POST",url:l,body:u,hostType:"read",fallback:{method:"GET",url:"/1/indexes/*",body:{params:c}},callback:r})},r.prototype.setSecurityTags=function(e){if("[object Array]"===Object.prototype.toString.call(e)){for(var t=[],o=0;o<e.length;++o)if("[object Array]"===Object.prototype.toString.call(e[o])){for(var r=[],n=0;n<e[o].length;++n)r.push(e[o][n]);t.push("("+r.join(",")+")")}else t.push(e[o]);e=t.join(",")}this.securityTags=e},r.prototype.setUserToken=function(e){this.userToken=e},r.prototype.clearCache=function(){this.cache={}},r.prototype.setRequestTimeout=function(e){e&&(this._timeouts.connect=this._timeouts.read=this._timeouts.write=e)},r.prototype.setTimeouts=function(e){this._timeouts=e},r.prototype.getTimeouts=function(){return this._timeouts},r.prototype._getAppIdData=function(){var e=p.get(this.applicationID);return null!==e&&this._cacheAppIdData(e),e},r.prototype._setAppIdData=function(e){return e.lastChange=(new Date).getTime(),this._cacheAppIdData(e),p.set(this.applicationID,e)},r.prototype._checkAppIdData=function(){var e=this._getAppIdData(),t=(new Date).getTime();return null===e||t-e.lastChange>d?this._resetInitialAppIdData(e):e},r.prototype._resetInitialAppIdData=function(e){var t=e||{};return t.hostIndexes={read:0,write:0},t.timeoutMultiplier=1,t.shuffleResult=t.shuffleResult||s([1,2,3]),this._setAppIdData(t)},r.prototype._cacheAppIdData=function(e){this._hostIndexes=e.hostIndexes,this._timeoutMultiplier=e.timeoutMultiplier,this._shuffleResult=e.shuffleResult},r.prototype._partialAppIdDataUpdate=function(t){var o=e(4),r=this._getAppIdData();return o(t,function(e,t){r[t]=e}),this._setAppIdData(r)},r.prototype._getHostByType=function(e){return this.hosts[e][this._getHostIndexByType(e)]},r.prototype._getTimeoutMultiplier=function(){return this._timeoutMultiplier},r.prototype._getHostIndexByType=function(e){return this._hostIndexes[e]},r.prototype._setHostIndexByType=function(t,o){var r=e(20),n=r(this._hostIndexes);return n[o]=t,this._partialAppIdDataUpdate({hostIndexes:n}),t},r.prototype._incrementHostIndex=function(e){return this._setHostIndexByType((this._getHostIndexByType(e)+1)%this.hosts[e].length,e)},r.prototype._incrementTimeoutMultipler=function(){var e=Math.max(this._timeoutMultiplier+1,4);return this._partialAppIdDataUpdate({timeoutMultiplier:e})},r.prototype._getTimeoutsForRequest=function(e){return{connect:this._timeouts.connect*this._timeoutMultiplier,complete:this._timeouts[e]*this._timeoutMultiplier}}}).call(this,e(11))},{1:1,11:11,14:14,20:20,23:23,24:24,25:25,29:29,4:4,7:7}],14:[function(e,t,o){function r(e,t){this.indexName=t,this.as=e,this.typeAheadArgs=null,this.typeAheadValueOption=null,this.cache={}}var n=e(19),i=e(21),s=e(22);t.exports=r,r.prototype.clearCache=function(){this.cache={}},r.prototype.search=n("query"),r.prototype.similarSearch=n("similarQuery"),r.prototype.browse=function(t,o,r){var n,i,s=e(26),a=this;0===arguments.length||1===arguments.length&&"function"==typeof arguments[0]?(n=0,r=arguments[0],t=void 0):"number"==typeof arguments[0]?(n=arguments[0],"number"==typeof arguments[1]?i=arguments[1]:"function"==typeof arguments[1]&&(r=arguments[1],i=void 0),t=void 0,o=void 0):"object"==typeof arguments[0]?("function"==typeof arguments[1]&&(r=arguments[1]),o=arguments[0],t=void 0):"string"==typeof arguments[0]&&"function"==typeof arguments[1]&&(r=arguments[1],o=void 0),o=s({},o||{},{page:n,hitsPerPage:i,query:t});var u=this.as._getSearchParams(o,"");return this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(a.indexName)+"/browse",body:{params:u},hostType:"read",callback:r})},r.prototype.browseFrom=function(e,t){return this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/browse",body:{cursor:e},hostType:"read",callback:t})},r.prototype.searchForFacetValues=function(t,o){var r=e(20),n=e(27),i="Usage: index.searchForFacetValues({facetName, facetQuery, ...params}[, callback])";if(void 0===t.facetName||void 0===t.facetQuery)throw new Error(i);var s=t.facetName,a=n(r(t),function(e){return"facetName"===e}),u=this.as._getSearchParams(a,"");return this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/facets/"+encodeURIComponent(s)+"/query",hostType:"read",body:{params:u},callback:o})},r.prototype.searchFacet=i(function(e,t){return this.searchForFacetValues(e,t)},s("index.searchFacet(params[, callback])","index.searchForFacetValues(params[, callback])")),r.prototype._search=function(e,t,o,r){return this.as._jsonRequest({cache:this.cache,method:"POST",url:t||"/1/indexes/"+encodeURIComponent(this.indexName)+"/query",body:{params:e},hostType:"read",fallback:{method:"GET",url:"/1/indexes/"+encodeURIComponent(this.indexName),body:{params:e}},callback:o,additionalUA:r})},r.prototype.getObject=function(e,t,o){var r=this;1!==arguments.length&&"function"!=typeof t||(o=t,t=void 0);var n="";if(void 0!==t){n="?attributes=";for(var i=0;i<t.length;++i)0!==i&&(n+=","),n+=t[i]}return this.as._jsonRequest({method:"GET",url:"/1/indexes/"+encodeURIComponent(r.indexName)+"/"+encodeURIComponent(e)+n,hostType:"read",callback:o})},r.prototype.getObjects=function(t,o,r){var n=e(7),i=e(25),s="Usage: index.getObjects(arrayOfObjectIDs[, callback])";if(!n(t))throw new Error(s);var a=this;1!==arguments.length&&"function"!=typeof o||(r=o,o=void 0);var u={requests:i(t,function(e){var t={indexName:a.indexName,objectID:e};return o&&(t.attributesToRetrieve=o.join(",")),t})};return this.as._jsonRequest({method:"POST",url:"/1/indexes/*/objects",hostType:"read",body:u,callback:r})},r.prototype.as=null,r.prototype.indexName=null,r.prototype.typeAheadArgs=null,r.prototype.typeAheadValueOption=null},{19:19,20:20,21:21,22:22,25:25,26:26,27:27,7:7}],15:[function(e,t,o){"use strict";var r=e(13),n=e(16);t.exports=n(r,"(lite) ")},{13:13,16:16}],16:[function(e,t,o){(function(o){"use strict";var r=e(5),n=r.Promise||e(3).Promise;t.exports=function(t,i){function s(t,o,r){var n=e(20);return r=n(r||{}),r._ua=r._ua||s.ua,new a(t,o,r)}function a(){t.apply(this,arguments)}var u=e(6),c=e(23),l=e(17),p=e(18),f=e(28);i=i||"","debug"===o.env.NODE_ENV&&e(1).enable("algoliasearch*"),s.version=e(30),s.ua="Algolia for vanilla JavaScript "+i+s.version,s.initPlaces=f(s),r.__algolia={debug:e(1),algoliasearch:s};var d={hasXMLHttpRequest:"XMLHttpRequest"in r,hasXDomainRequest:"XDomainRequest"in r};return d.hasXMLHttpRequest&&(d.cors="withCredentials"in new XMLHttpRequest),u(a,t),a.prototype._request=function(e,t){return new n(function(o,r){function n(){if(!h){clearTimeout(f);var e;try{e={body:JSON.parse(m.responseText),responseText:m.responseText,statusCode:m.status,headers:m.getAllResponseHeaders&&m.getAllResponseHeaders()||{}}}catch(t){e=new c.UnparsableJSON({more:m.responseText})}e instanceof c.UnparsableJSON?r(e):o(e)}}function i(e){h||(clearTimeout(f),r(new c.Network({more:e})))}function s(){h=!0,m.abort(),r(new c.RequestTimeout)}function a(){g=!0,clearTimeout(f),f=setTimeout(s,t.timeouts.complete)}function u(){g||a()}function p(){!g&&m.readyState>1&&a()}if(!d.cors&&!d.hasXDomainRequest)return void r(new c.Network("CORS not supported"));e=l(e,t.headers);var f,h,y=t.body,m=d.cors?new XMLHttpRequest:new XDomainRequest,g=!1;f=setTimeout(s,t.timeouts.connect),m.onprogress=u,"onreadystatechange"in m&&(m.onreadystatechange=p),m.onload=n,m.onerror=i,m instanceof XMLHttpRequest?m.open(t.method,e,!0):m.open(t.method,e),d.cors&&(y&&("POST"===t.method?m.setRequestHeader("content-type","application/x-www-form-urlencoded"):m.setRequestHeader("content-type","application/json")),m.setRequestHeader("accept","application/json")),
3
- m.send(y)})},a.prototype._request.fallback=function(e,t){return e=l(e,t.headers),new n(function(o,r){p(e,t,function(e,t){return e?void r(e):void o(t)})})},a.prototype._promise={reject:function(e){return n.reject(e)},resolve:function(e){return n.resolve(e)},delay:function(e){return new n(function(t){setTimeout(t,e)})}},s}}).call(this,e(11))},{1:1,11:11,17:17,18:18,20:20,23:23,28:28,3:3,30:30,5:5,6:6}],17:[function(e,t,o){"use strict";function r(e,t){return e+=/\?/.test(e)?"&":"?",e+n(t)}t.exports=r;var n=e(12)},{12:12}],18:[function(e,t,o){"use strict";function r(e,t,o){function r(){t.debug("JSONP: success"),m||f||(m=!0,p||(t.debug("JSONP: Fail. Script loaded but did not call the callback"),a(),o(new n.JSONPScriptFail)))}function s(){"loaded"!==this.readyState&&"complete"!==this.readyState||r()}function a(){clearTimeout(g),h.onload=null,h.onreadystatechange=null,h.onerror=null,d.removeChild(h)}function u(){try{delete window[y],delete window[y+"_loaded"]}catch(e){window[y]=window[y+"_loaded"]=void 0}}function c(){t.debug("JSONP: Script timeout"),f=!0,a(),o(new n.RequestTimeout)}function l(){t.debug("JSONP: Script error"),m||f||(a(),o(new n.JSONPScriptError))}if("GET"!==t.method)return void o(new Error("Method "+t.method+" "+e+" is not supported by JSONP."));t.debug("JSONP: start");var p=!1,f=!1;i+=1;var d=document.getElementsByTagName("head")[0],h=document.createElement("script"),y="algoliaJSONP_"+i,m=!1;window[y]=function(e){return u(),f?void t.debug("JSONP: Late answer, ignoring"):(p=!0,a(),void o(null,{body:e}))},e+="&callback="+y,t.jsonBody&&t.jsonBody.params&&(e+="&"+t.jsonBody.params);var g=setTimeout(c,t.timeouts.complete);h.onreadystatechange=s,h.onload=r,h.onerror=l,h.async=!0,h.defer=!0,h.src=e,d.appendChild(h)}t.exports=r;var n=e(23),i=0},{23:23}],19:[function(e,t,o){function r(e,t){return function(o,r,i){if("function"==typeof o&&"object"==typeof r||"object"==typeof i)throw new n.AlgoliaSearchError("index.search usage is index.search(query, params, cb)");0===arguments.length||"function"==typeof o?(i=o,o=""):1!==arguments.length&&"function"!=typeof r||(i=r,r=void 0),"object"==typeof o&&null!==o?(r=o,o=void 0):void 0!==o&&null!==o||(o="");var s="";void 0!==o&&(s+=e+"="+encodeURIComponent(o));var a;return void 0!==r&&(r.additionalUA&&(a=r.additionalUA,delete r.additionalUA),s=this.as._getSearchParams(r,s)),this._search(s,t,i,a)}}t.exports=r;var n=e(23)},{23:23}],20:[function(e,t,o){t.exports=function(e){return JSON.parse(JSON.stringify(e))}},{}],21:[function(e,t,o){t.exports=function(e,t){function o(){return r||(console.warn(t),r=!0),e.apply(this,arguments)}var r=!1;return o}},{}],22:[function(e,t,o){t.exports=function(e,t){var o=e.toLowerCase().replace(/[\.\(\)]/g,"");return"algoliasearch: `"+e+"` was replaced by `"+t+"`. Please see https://github.com/algolia/algoliasearch-client-javascript/wiki/Deprecated#"+o}},{}],23:[function(e,t,o){"use strict";function r(t,o){var r=e(4),n=this;"function"==typeof Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):n.stack=(new Error).stack||"Cannot get a stacktrace, browser is too old",this.name="AlgoliaSearchError",this.message=t||"Unknown error",o&&r(o,function(e,t){n[t]=e})}function n(e,t){function o(){var o=Array.prototype.slice.call(arguments,0);"string"!=typeof o[0]&&o.unshift(t),r.apply(this,o),this.name="AlgoliaSearch"+e+"Error"}return i(o,r),o}var i=e(6);i(r,Error),t.exports={AlgoliaSearchError:r,UnparsableJSON:n("UnparsableJSON","Could not parse the incoming response as JSON, see err.more for details"),RequestTimeout:n("RequestTimeout","Request timedout before getting a response"),Network:n("Network","Network issue, see err.more for details"),JSONPScriptFail:n("JSONPScriptFail","<script> was loaded but did not call our provided callback"),JSONPScriptError:n("JSONPScriptError","<script> unable to load due to an `error` event on it"),Unknown:n("Unknown","Unknown error occured")}},{4:4,6:6}],24:[function(e,t,o){t.exports=function(e,t){t(e,0)}},{}],25:[function(e,t,o){var r=e(4);t.exports=function(e,t){var o=[];return r(e,function(r,n){o.push(t(r,n,e))}),o}},{4:4}],26:[function(e,t,o){var r=e(4);t.exports=function n(e){var t=Array.prototype.slice.call(arguments);return r(t,function(t){for(var o in t)t.hasOwnProperty(o)&&("object"==typeof e[o]&&"object"==typeof t[o]?e[o]=n({},e[o],t[o]):void 0!==t[o]&&(e[o]=t[o]))}),e}},{4:4}],27:[function(e,t,o){t.exports=function(t,o){var r=e(9),n=e(4),i={};return n(r(t),function(e){o(e)!==!0&&(i[e]=t[e])}),i}},{4:4,9:9}],28:[function(e,t,o){function r(t){return function(o,r,i){var s=e(20);i=i&&s(i)||{},i.hosts=i.hosts||["places-dsn.algolia.net","places-1.algolianet.com","places-2.algolianet.com","places-3.algolianet.com"],0!==arguments.length&&"object"!=typeof o&&void 0!==o||(o="",r="",i._allowEmptyCredentials=!0);var a=t(o,r,i),u=a.initIndex("places");return u.search=n("query","/1/places/query"),u.getObject=function(e,t){return this.as._jsonRequest({method:"GET",url:"/1/places/"+encodeURIComponent(e),hostType:"read",callback:t})},u}}t.exports=r;var n=e(19)},{19:19,20:20}],29:[function(e,t,o){(function(o){function r(e,t){return u("localStorage failed with",t),s(),a=l,a.get(e)}function n(e,t){return 1===arguments.length?a.get(e):a.set(e,t)}function i(){try{return"localStorage"in o&&null!==o.localStorage&&(o.localStorage[c]||o.localStorage.setItem(c,JSON.stringify({})),!0)}catch(e){return!1}}function s(){try{o.localStorage.removeItem(c)}catch(e){}}var a,u=e(1)("algoliasearch:src/hostIndexState.js"),c="algoliasearch-client-js",l={state:{},set:function(e,t){return this.state[e]=t,this.state[e]},get:function(e){return this.state[e]||null}},p={set:function(e,t){l.set(e,t);try{var n=JSON.parse(o.localStorage[c]);return n[e]=t,o.localStorage[c]=JSON.stringify(n),n[e]}catch(i){return r(e,i)}},get:function(e){try{return JSON.parse(o.localStorage[c])[e]||null}catch(t){return r(e,t)}}};a=i()?p:l,t.exports={get:n,set:n,supportsLocalStorage:i}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{1:1}],30:[function(e,t,o){"use strict";t.exports="3.25.0"},{}]},{},[15])(15)});
1
+ /*! algoliasearch 3.27.1 | © 2014, 2015 Algolia SAS | github.com/algolia/algoliasearch-client-js */
2
+ !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.algoliasearch=e()}}(function(){var e;return function t(e,r,o){function n(a,s){if(!r[a]){if(!e[a]){var c="function"==typeof require&&require;if(!s&&c)return c(a,!0);if(i)return i(a,!0);var u=new Error("Cannot find module '"+a+"'");throw u.code="MODULE_NOT_FOUND",u}var l=r[a]={exports:{}};e[a][0].call(l.exports,function(t){var r=e[a][1][t];return n(r?r:t)},l,l.exports,t,e,r,o)}return r[a].exports}for(var i="function"==typeof require&&require,a=0;a<o.length;a++)n(o[a]);return n}({1:[function(e,t,r){(function(o){function n(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type)||("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))}function i(e){var t=this.useColors;if(e[0]=(t?"%c":"")+this.namespace+(t?" %c":" ")+e[0]+(t?"%c ":" ")+"+"+r.humanize(this.diff),t){var o="color: "+this.color;e.splice(1,0,o,"color: inherit");var n=0,i=0;e[0].replace(/%[a-zA-Z%]/g,function(e){"%%"!==e&&(n++,"%c"===e&&(i=n))}),e.splice(i,0,o)}}function a(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function s(e){try{null==e?r.storage.removeItem("debug"):r.storage.debug=e}catch(t){}}function c(){var e;try{e=r.storage.debug}catch(t){}return!e&&"undefined"!=typeof o&&"env"in o&&(e=o.env.DEBUG),e}function u(){try{return window.localStorage}catch(e){}}r=t.exports=e(2),r.log=a,r.formatArgs=i,r.save=s,r.load=c,r.useColors=n,r.storage="undefined"!=typeof chrome&&"undefined"!=typeof chrome.storage?chrome.storage.local:u(),r.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],r.formatters.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}},r.enable(c())}).call(this,e(11))},{11:11,2:2}],2:[function(e,t,r){function o(e){var t,o=0;for(t in e)o=(o<<5)-o+e.charCodeAt(t),o|=0;return r.colors[Math.abs(o)%r.colors.length]}function n(e){function t(){if(t.enabled){var e=t,o=+new Date,n=o-(u||o);e.diff=n,e.prev=u,e.curr=o,u=o;for(var i=new Array(arguments.length),a=0;a<i.length;a++)i[a]=arguments[a];i[0]=r.coerce(i[0]),"string"!=typeof i[0]&&i.unshift("%O");var s=0;i[0]=i[0].replace(/%([a-zA-Z%])/g,function(t,o){if("%%"===t)return t;s++;var n=r.formatters[o];if("function"==typeof n){var a=i[s];t=n.call(e,a),i.splice(s,1),s--}return t}),r.formatArgs.call(e,i);var c=t.log||r.log||console.log.bind(console);c.apply(e,i)}}return t.namespace=e,t.enabled=r.enabled(e),t.useColors=r.useColors(),t.color=o(e),"function"==typeof r.init&&r.init(t),t}function i(e){r.save(e),r.names=[],r.skips=[];for(var t=("string"==typeof e?e:"").split(/[\s,]+/),o=t.length,n=0;n<o;n++)t[n]&&(e=t[n].replace(/\*/g,".*?"),"-"===e[0]?r.skips.push(new RegExp("^"+e.substr(1)+"$")):r.names.push(new RegExp("^"+e+"$")))}function a(){r.enable("")}function s(e){var t,o;for(t=0,o=r.skips.length;t<o;t++)if(r.skips[t].test(e))return!1;for(t=0,o=r.names.length;t<o;t++)if(r.names[t].test(e))return!0;return!1}function c(e){return e instanceof Error?e.stack||e.message:e}r=t.exports=n.debug=n["default"]=n,r.coerce=c,r.disable=a,r.enable=i,r.enabled=s,r.humanize=e(8),r.names=[],r.skips=[],r.formatters={};var u},{8:8}],3:[function(t,r,o){(function(n,i){!function(t,n){"object"==typeof o&&"undefined"!=typeof r?r.exports=n():"function"==typeof e&&e.amd?e(n):t.ES6Promise=n()}(this,function(){"use strict";function e(e){var t=typeof e;return null!==e&&("object"===t||"function"===t)}function r(e){return"function"==typeof e}function o(e){Q=e}function a(e){Y=e}function s(){return function(){return n.nextTick(f)}}function c(){return"undefined"!=typeof G?function(){G(f)}:p()}function u(){var e=0,t=new Z(f),r=document.createTextNode("");return t.observe(r,{characterData:!0}),function(){r.data=e=++e%2}}function l(){var e=new MessageChannel;return e.port1.onmessage=f,function(){return e.port2.postMessage(0)}}function p(){var e=setTimeout;return function(){return e(f,1)}}function f(){for(var e=0;e<V;e+=2){var t=re[e],r=re[e+1];t(r),re[e]=void 0,re[e+1]=void 0}V=0}function d(){try{var e=t,r=e("vertx");return G=r.runOnLoop||r.runOnContext,c()}catch(o){return p()}}function h(e,t){var r=arguments,o=this,n=new this.constructor(m);void 0===n[ne]&&P(n);var i=o._state;return i?!function(){var e=r[i-1];Y(function(){return N(i,n,e,o._result)})}():k(o,n,e,t),n}function y(e){var t=this;if(e&&"object"==typeof e&&e.constructor===t)return e;var r=new t(m);return S(r,e),r}function m(){}function g(){return new TypeError("You cannot resolve a promise with itself")}function v(){return new TypeError("A promises callback cannot return that same promise.")}function b(e){try{return e.then}catch(t){return ce.error=t,ce}}function w(e,t,r,o){try{e.call(t,r,o)}catch(n){return n}}function _(e,t,r){Y(function(e){var o=!1,n=w(r,t,function(r){o||(o=!0,t!==r?S(e,r):j(e,r))},function(t){o||(o=!0,O(e,t))},"Settle: "+(e._label||" unknown promise"));!o&&n&&(o=!0,O(e,n))},e)}function T(e,t){t._state===ae?j(e,t._result):t._state===se?O(e,t._result):k(t,void 0,function(t){return S(e,t)},function(t){return O(e,t)})}function x(e,t,o){t.constructor===e.constructor&&o===h&&t.constructor.resolve===y?T(e,t):o===ce?(O(e,ce.error),ce.error=null):void 0===o?j(e,t):r(o)?_(e,t,o):j(e,t)}function S(t,r){t===r?O(t,g()):e(r)?x(t,r,b(r)):j(t,r)}function A(e){e._onerror&&e._onerror(e._result),I(e)}function j(e,t){e._state===ie&&(e._result=t,e._state=ae,0!==e._subscribers.length&&Y(I,e))}function O(e,t){e._state===ie&&(e._state=se,e._result=t,Y(A,e))}function k(e,t,r,o){var n=e._subscribers,i=n.length;e._onerror=null,n[i]=t,n[i+ae]=r,n[i+se]=o,0===i&&e._state&&Y(I,e)}function I(e){var t=e._subscribers,r=e._state;if(0!==t.length){for(var o=void 0,n=void 0,i=e._result,a=0;a<t.length;a+=3)o=t[a],n=t[a+r],o?N(r,o,n,i):n(i);e._subscribers.length=0}}function E(){this.error=null}function R(e,t){try{return e(t)}catch(r){return ue.error=r,ue}}function N(e,t,o,n){var i=r(o),a=void 0,s=void 0,c=void 0,u=void 0;if(i){if(a=R(o,n),a===ue?(u=!0,s=a.error,a.error=null):c=!0,t===a)return void O(t,v())}else a=n,c=!0;t._state!==ie||(i&&c?S(t,a):u?O(t,s):e===ae?j(t,a):e===se&&O(t,a))}function C(e,t){try{t(function(t){S(e,t)},function(t){O(e,t)})}catch(r){O(e,r)}}function q(){return le++}function P(e){e[ne]=le++,e._state=void 0,e._result=void 0,e._subscribers=[]}function U(e,t){this._instanceConstructor=e,this.promise=new e(m),this.promise[ne]||P(this.promise),K(t)?(this.length=t.length,this._remaining=t.length,this._result=new Array(this.length),0===this.length?j(this.promise,this._result):(this.length=this.length||0,this._enumerate(t),0===this._remaining&&j(this.promise,this._result))):O(this.promise,D())}function D(){return new Error("Array Methods must be provided an Array")}function M(e){return new U(this,e).promise}function H(e){var t=this;return new t(K(e)?function(r,o){for(var n=e.length,i=0;i<n;i++)t.resolve(e[i]).then(r,o)}:function(e,t){return t(new TypeError("You must pass an array to race."))})}function J(e){var t=this,r=new t(m);return O(r,e),r}function F(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function $(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}function L(e){this[ne]=q(),this._result=this._state=void 0,this._subscribers=[],m!==e&&("function"!=typeof e&&F(),this instanceof L?C(this,e):$())}function B(){var e=void 0;if("undefined"!=typeof i)e=i;else if("undefined"!=typeof self)e=self;else try{e=Function("return this")()}catch(t){throw new Error("polyfill failed because global object is unavailable in this environment")}var r=e.Promise;if(r){var o=null;try{o=Object.prototype.toString.call(r.resolve())}catch(t){}if("[object Promise]"===o&&!r.cast)return}e.Promise=L}var X=void 0;X=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)};var K=X,V=0,G=void 0,Q=void 0,Y=function(e,t){re[V]=e,re[V+1]=t,V+=2,2===V&&(Q?Q(f):oe())},z="undefined"!=typeof window?window:void 0,W=z||{},Z=W.MutationObserver||W.WebKitMutationObserver,ee="undefined"==typeof self&&"undefined"!=typeof n&&"[object process]"==={}.toString.call(n),te="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel,re=new Array(1e3),oe=void 0;oe=ee?s():Z?u():te?l():void 0===z&&"function"==typeof t?d():p();var ne=Math.random().toString(36).substring(16),ie=void 0,ae=1,se=2,ce=new E,ue=new E,le=0;return U.prototype._enumerate=function(e){for(var t=0;this._state===ie&&t<e.length;t++)this._eachEntry(e[t],t)},U.prototype._eachEntry=function(e,t){var r=this._instanceConstructor,o=r.resolve;if(o===y){var n=b(e);if(n===h&&e._state!==ie)this._settledAt(e._state,t,e._result);else if("function"!=typeof n)this._remaining--,this._result[t]=e;else if(r===L){var i=new r(m);x(i,e,n),this._willSettleAt(i,t)}else this._willSettleAt(new r(function(t){return t(e)}),t)}else this._willSettleAt(o(e),t)},U.prototype._settledAt=function(e,t,r){var o=this.promise;o._state===ie&&(this._remaining--,e===se?O(o,r):this._result[t]=r),0===this._remaining&&j(o,this._result)},U.prototype._willSettleAt=function(e,t){var r=this;k(e,void 0,function(e){return r._settledAt(ae,t,e)},function(e){return r._settledAt(se,t,e)})},L.all=M,L.race=H,L.resolve=y,L.reject=J,L._setScheduler=o,L._setAsap=a,L._asap=Y,L.prototype={constructor:L,then:h,"catch":function(e){return this.then(null,e)}},L.polyfill=B,L.Promise=L,L})}).call(this,t(11),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{11:11}],4:[function(e,t,r){var o=Object.prototype.hasOwnProperty,n=Object.prototype.toString;t.exports=function(e,t,r){if("[object Function]"!==n.call(t))throw new TypeError("iterator must be a function");var i=e.length;if(i===+i)for(var a=0;a<i;a++)t.call(r,e[a],a,e);else for(var s in e)o.call(e,s)&&t.call(r,e[s],s,e)}},{}],5:[function(e,t,r){(function(e){var r;r="undefined"!=typeof window?window:"undefined"!=typeof e?e:"undefined"!=typeof self?self:{},t.exports=r}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],6:[function(e,t,r){"function"==typeof Object.create?t.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:t.exports=function(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}},{}],7:[function(e,t,r){var o={}.toString;t.exports=Array.isArray||function(e){return"[object Array]"==o.call(e)}},{}],8:[function(e,t,r){function o(e){if(e=String(e),!(e.length>100)){var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(t){var r=parseFloat(t[1]),o=(t[2]||"ms").toLowerCase();switch(o){case"years":case"year":case"yrs":case"yr":case"y":return r*p;case"days":case"day":case"d":return r*l;case"hours":case"hour":case"hrs":case"hr":case"h":return r*u;case"minutes":case"minute":case"mins":case"min":case"m":return r*c;case"seconds":case"second":case"secs":case"sec":case"s":return r*s;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function n(e){return e>=l?Math.round(e/l)+"d":e>=u?Math.round(e/u)+"h":e>=c?Math.round(e/c)+"m":e>=s?Math.round(e/s)+"s":e+"ms"}function i(e){return a(e,l,"day")||a(e,u,"hour")||a(e,c,"minute")||a(e,s,"second")||e+" ms"}function a(e,t,r){if(!(e<t))return e<1.5*t?Math.floor(e/t)+" "+r:Math.ceil(e/t)+" "+r+"s"}var s=1e3,c=60*s,u=60*c,l=24*u,p=365.25*l;t.exports=function(e,t){t=t||{};var r=typeof e;if("string"===r&&e.length>0)return o(e);if("number"===r&&isNaN(e)===!1)return t["long"]?i(e):n(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},{}],9:[function(e,t,r){"use strict";var o=Object.prototype.hasOwnProperty,n=Object.prototype.toString,i=Array.prototype.slice,a=e(10),s=Object.prototype.propertyIsEnumerable,c=!s.call({toString:null},"toString"),u=s.call(function(){},"prototype"),l=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],p=function(e){var t=e.constructor;return t&&t.prototype===e},f={$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},d=function(){if("undefined"==typeof window)return!1;for(var e in window)try{if(!f["$"+e]&&o.call(window,e)&&null!==window[e]&&"object"==typeof window[e])try{p(window[e])}catch(t){return!0}}catch(t){return!0}return!1}(),h=function(e){if("undefined"==typeof window||!d)return p(e);try{return p(e)}catch(t){return!1}},y=function(e){var t=null!==e&&"object"==typeof e,r="[object Function]"===n.call(e),i=a(e),s=t&&"[object String]"===n.call(e),p=[];if(!t&&!r&&!i)throw new TypeError("Object.keys called on a non-object");var f=u&&r;if(s&&e.length>0&&!o.call(e,0))for(var d=0;d<e.length;++d)p.push(String(d));if(i&&e.length>0)for(var y=0;y<e.length;++y)p.push(String(y));else for(var m in e)f&&"prototype"===m||!o.call(e,m)||p.push(String(m));if(c)for(var g=h(e),v=0;v<l.length;++v)g&&"constructor"===l[v]||!o.call(e,l[v])||p.push(l[v]);return p};y.shim=function(){if(Object.keys){var e=function(){return 2===(Object.keys(arguments)||"").length}(1,2);if(!e){var t=Object.keys;Object.keys=function(e){return t(a(e)?i.call(e):e)}}}else Object.keys=y;return Object.keys||y},t.exports=y},{10:10}],10:[function(e,t,r){"use strict";var o=Object.prototype.toString;t.exports=function(e){var t=o.call(e),r="[object Arguments]"===t;return r||(r="[object Array]"!==t&&null!==e&&"object"==typeof e&&"number"==typeof e.length&&e.length>=0&&"[object Function]"===o.call(e.callee)),r}},{}],11:[function(e,t,r){function o(){throw new Error("setTimeout has not been defined")}function n(){throw new Error("clearTimeout has not been defined")}function i(e){if(p===setTimeout)return setTimeout(e,0);if((p===o||!p)&&setTimeout)return p=setTimeout,setTimeout(e,0);try{return p(e,0)}catch(t){try{return p.call(null,e,0)}catch(t){return p.call(this,e,0)}}}function a(e){if(f===clearTimeout)return clearTimeout(e);if((f===n||!f)&&clearTimeout)return f=clearTimeout,clearTimeout(e);try{return f(e)}catch(t){try{return f.call(null,e)}catch(t){return f.call(this,e)}}}function s(){m&&h&&(m=!1,h.length?y=h.concat(y):g=-1,y.length&&c())}function c(){if(!m){var e=i(s);m=!0;for(var t=y.length;t;){for(h=y,y=[];++g<t;)h&&h[g].run();g=-1,t=y.length}h=null,m=!1,a(e)}}function u(e,t){this.fun=e,this.array=t}function l(){}var p,f,d=t.exports={};!function(){try{p="function"==typeof setTimeout?setTimeout:o}catch(e){p=o}try{f="function"==typeof clearTimeout?clearTimeout:n}catch(e){f=n}}();var h,y=[],m=!1,g=-1;d.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];y.push(new u(e,t)),1!==y.length||m||i(c)},u.prototype.run=function(){this.fun.apply(null,this.array)},d.title="browser",d.browser=!0,d.env={},d.argv=[],d.version="",d.versions={},d.on=l,d.addListener=l,d.once=l,d.off=l,d.removeListener=l,d.removeAllListeners=l,d.emit=l,d.binding=function(e){throw new Error("process.binding is not supported")},d.cwd=function(){return"/"},d.chdir=function(e){throw new Error("process.chdir is not supported")},d.umask=function(){return 0}},{}],12:[function(e,t,r){"use strict";function o(e,t){if(e.map)return e.map(t);for(var r=[],o=0;o<e.length;o++)r.push(t(e[o],o));return r}var n=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};t.exports=function(e,t,r,s){return t=t||"&",r=r||"=",null===e&&(e=void 0),"object"==typeof e?o(a(e),function(a){var s=encodeURIComponent(n(a))+r;return i(e[a])?o(e[a],function(e){return s+encodeURIComponent(n(e))}).join(t):s+encodeURIComponent(n(e[a]))}).join(t):s?encodeURIComponent(n(s))+r+encodeURIComponent(n(e)):""};var i=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},a=Object.keys||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.push(r);return t}},{}],13:[function(e,t,r){(function(r){function o(t,r,o){var i=e(1)("algoliasearch"),a=e(20),s=e(7),u=e(25),l="Usage: algoliasearch(applicationID, apiKey, opts)";if(o._allowEmptyCredentials!==!0&&!t)throw new c.AlgoliaSearchError("Please provide an application ID. "+l);if(o._allowEmptyCredentials!==!0&&!r)throw new c.AlgoliaSearchError("Please provide an API key. "+l);this.applicationID=t,this.apiKey=r,this.hosts={read:[],write:[]},o=o||{},this._timeouts=o.timeouts||{connect:1e3,read:2e3,write:3e4},o.timeout&&(this._timeouts.connect=this._timeouts.read=this._timeouts.write=o.timeout);var p=o.protocol||"https:";if(/:$/.test(p)||(p+=":"),"http:"!==p&&"https:"!==p)throw new c.AlgoliaSearchError("protocol must be `http:` or `https:` (was `"+o.protocol+"`)");if(this._checkAppIdData(),o.hosts)s(o.hosts)?(this.hosts.read=a(o.hosts),this.hosts.write=a(o.hosts)):(this.hosts.read=a(o.hosts.read),this.hosts.write=a(o.hosts.write));else{var f=u(this._shuffleResult,function(e){return t+"-"+e+".algolianet.com"}),d=(o.dsn===!1?"":"-dsn")+".algolia.net";this.hosts.read=[this.applicationID+d].concat(f),this.hosts.write=[this.applicationID+".algolia.net"].concat(f)}this.hosts.read=u(this.hosts.read,n(p)),this.hosts.write=u(this.hosts.write,n(p)),this.extraHeaders={},this.cache=o._cache||{},this._ua=o._ua,this._useCache=!(void 0!==o._useCache&&!o._cache)||o._useCache,this._useFallback=void 0===o.useFallback||o.useFallback,this._setTimeout=o._setTimeout,i("init done, %j",this)}function n(e){return function(t){return e+"//"+t.toLowerCase()}}function i(e){if(void 0===Array.prototype.toJSON)return JSON.stringify(e);var t=Array.prototype.toJSON;delete Array.prototype.toJSON;var r=JSON.stringify(e);return Array.prototype.toJSON=t,r}function a(e){for(var t,r,o=e.length;0!==o;)r=Math.floor(Math.random()*o),o-=1,t=e[o],e[o]=e[r],e[r]=t;return e}function s(e){var t={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){var o;o="x-algolia-api-key"===r||"x-algolia-application-id"===r?"**hidden for security purposes**":e[r],t[r]=o}return t}t.exports=o;var c=e(23),u=e(24),l=e(14),p=e(29),f=500,d=r.env.RESET_APP_DATA_TIMER&&parseInt(r.env.RESET_APP_DATA_TIMER,10)||12e4;o.prototype.initIndex=function(e){return new l(this,e)},o.prototype.setExtraHeader=function(e,t){this.extraHeaders[e.toLowerCase()]=t},o.prototype.getExtraHeader=function(e){return this.extraHeaders[e.toLowerCase()]},o.prototype.unsetExtraHeader=function(e){delete this.extraHeaders[e.toLowerCase()]},o.prototype.addAlgoliaAgent=function(e){this._ua.indexOf(";"+e)===-1&&(this._ua+=";"+e)},o.prototype._jsonRequest=function(t){function r(e,u){function f(e){var t=e&&e.body&&e.body.message&&e.body.status||e.statusCode||e&&e.body&&200;a("received response: statusCode: %s, computed statusCode: %d, headers: %j",e.statusCode,t,e.headers);var r=2===Math.floor(t/100),i=new Date;if(g.push({currentHost:x,headers:s(n),content:o||null,contentLength:void 0!==o?o.length:null,method:u.method,timeouts:u.timeouts,url:u.url,startTime:T,endTime:i,duration:i-T,statusCode:t}),r)return d._useCache&&p&&(p[_]=e.responseText),e.body;var l=4!==Math.floor(t/100);if(l)return h+=1,b();a("unrecoverable error");var f=new c.AlgoliaSearchError(e.body&&e.body.message,{debugData:g,statusCode:t});return d._promise.reject(f)}function v(e){a("error: %s, stack: %s",e.message,e.stack);var r=new Date;return g.push({currentHost:x,headers:s(n),content:o||null,contentLength:void 0!==o?o.length:null,method:u.method,timeouts:u.timeouts,url:u.url,startTime:T,endTime:r,duration:r-T}),e instanceof c.AlgoliaSearchError||(e=new c.Unknown(e&&e.message,e)),h+=1,e instanceof c.Unknown||e instanceof c.UnparsableJSON||h>=d.hosts[t.hostType].length&&(y||!m)?(e.debugData=g,d._promise.reject(e)):e instanceof c.RequestTimeout?w():b()}function b(){return a("retrying request"),d._incrementHostIndex(t.hostType),r(e,u)}function w(){return a("retrying request with higher timeout"),d._incrementHostIndex(t.hostType),d._incrementTimeoutMultipler(),u.timeouts=d._getTimeoutsForRequest(t.hostType),r(e,u)}d._checkAppIdData();var _,T=new Date;if(d._useCache&&(_=t.url),d._useCache&&o&&(_+="_body_"+u.body),d._useCache&&p&&void 0!==p[_])return a("serving response from cache"),d._promise.resolve(JSON.parse(p[_]));if(h>=d.hosts[t.hostType].length)return!m||y?(a("could not get any response"),d._promise.reject(new c.AlgoliaSearchError("Cannot connect to the AlgoliaSearch API. Send an email to support@algolia.com to report and resolve the issue. Application id was: "+d.applicationID,{debugData:g}))):(a("switching to fallback"),h=0,u.method=t.fallback.method,u.url=t.fallback.url,u.jsonBody=t.fallback.body,u.jsonBody&&(u.body=i(u.jsonBody)),n=d._computeRequestHeaders({additionalUA:l,headers:t.headers}),u.timeouts=d._getTimeoutsForRequest(t.hostType),d._setHostIndexByType(0,t.hostType),y=!0,r(d._request.fallback,u));var x=d._getHostByType(t.hostType),S=x+u.url,A={body:u.body,jsonBody:u.jsonBody,method:u.method,headers:n,timeouts:u.timeouts,debug:a};return a("method: %s, url: %s, headers: %j, timeouts: %d",A.method,S,A.headers,A.timeouts),e===d._request.fallback&&a("using fallback"),e.call(d,S,A).then(f,v)}this._checkAppIdData();var o,n,a=e(1)("algoliasearch:"+t.url),l=t.additionalUA||"",p=t.cache,d=this,h=0,y=!1,m=d._useFallback&&d._request.fallback&&t.fallback;this.apiKey.length>f&&void 0!==t.body&&(void 0!==t.body.params||void 0!==t.body.requests)?(t.body.apiKey=this.apiKey,n=this._computeRequestHeaders({additionalUA:l,withApiKey:!1,headers:t.headers})):n=this._computeRequestHeaders({additionalUA:l,headers:t.headers}),void 0!==t.body&&(o=i(t.body)),a("request start");var g=[],v=r(d._request,{url:t.url,method:t.method,body:o,jsonBody:t.body,timeouts:d._getTimeoutsForRequest(t.hostType)});return"function"!=typeof t.callback?v:void v.then(function(e){u(function(){t.callback(null,e)},d._setTimeout||setTimeout)},function(e){u(function(){t.callback(e)},d._setTimeout||setTimeout)})},o.prototype._getSearchParams=function(e,t){if(void 0===e||null===e)return t;for(var r in e)null!==r&&void 0!==e[r]&&e.hasOwnProperty(r)&&(t+=""===t?"":"&",t+=r+"="+encodeURIComponent("[object Array]"===Object.prototype.toString.call(e[r])?i(e[r]):e[r]));return t},o.prototype._computeRequestHeaders=function(t){var r=e(4),o=t.additionalUA?this._ua+";"+t.additionalUA:this._ua,n={"x-algolia-agent":o,"x-algolia-application-id":this.applicationID};return t.withApiKey!==!1&&(n["x-algolia-api-key"]=this.apiKey),this.userToken&&(n["x-algolia-usertoken"]=this.userToken),this.securityTags&&(n["x-algolia-tagfilters"]=this.securityTags),r(this.extraHeaders,function(e,t){n[t]=e}),t.headers&&r(t.headers,function(e,t){n[t]=e}),n},o.prototype.search=function(t,r,o){var n=e(7),i=e(25),a="Usage: client.search(arrayOfQueries[, callback])";if(!n(t))throw new Error(a);"function"==typeof r?(o=r,r={}):void 0===r&&(r={});var s=this,c={requests:i(t,function(e){var t="";return void 0!==e.query&&(t+="query="+encodeURIComponent(e.query)),{indexName:e.indexName,params:s._getSearchParams(e.params,t)}})},u=i(c.requests,function(e,t){return t+"="+encodeURIComponent("/1/indexes/"+encodeURIComponent(e.indexName)+"?"+e.params)}).join("&"),l="/1/indexes/*/queries";return void 0!==r.strategy&&(l+="?strategy="+r.strategy),this._jsonRequest({cache:this.cache,method:"POST",url:l,body:c,hostType:"read",fallback:{method:"GET",url:"/1/indexes/*",body:{params:u}},callback:o})},o.prototype.searchForFacetValues=function(t){var r=e(7),o=e(25),n="Usage: client.searchForFacetValues([{indexName, params: {facetName, facetQuery, ...params}}, ...queries])";if(!r(t))throw new Error(n);var i=this;return i._promise.all(o(t,function(t){if(!t||void 0===t.indexName||void 0===t.params.facetName||void 0===t.params.facetQuery)throw new Error(n);var r=e(20),o=e(27),a=t.indexName,s=t.params,c=s.facetName,u=o(r(s),function(e){return"facetName"===e}),l=i._getSearchParams(u,"");return i._jsonRequest({cache:i.cache,method:"POST",url:"/1/indexes/"+encodeURIComponent(a)+"/facets/"+encodeURIComponent(c)+"/query",hostType:"read",body:{params:l}})}))},o.prototype.setSecurityTags=function(e){if("[object Array]"===Object.prototype.toString.call(e)){for(var t=[],r=0;r<e.length;++r)if("[object Array]"===Object.prototype.toString.call(e[r])){for(var o=[],n=0;n<e[r].length;++n)o.push(e[r][n]);t.push("("+o.join(",")+")")}else t.push(e[r]);e=t.join(",")}this.securityTags=e},o.prototype.setUserToken=function(e){this.userToken=e},o.prototype.clearCache=function(){this.cache={}},o.prototype.setRequestTimeout=function(e){e&&(this._timeouts.connect=this._timeouts.read=this._timeouts.write=e)},o.prototype.setTimeouts=function(e){this._timeouts=e},o.prototype.getTimeouts=function(){return this._timeouts},o.prototype._getAppIdData=function(){var e=p.get(this.applicationID);return null!==e&&this._cacheAppIdData(e),e},o.prototype._setAppIdData=function(e){return e.lastChange=(new Date).getTime(),this._cacheAppIdData(e),p.set(this.applicationID,e)},o.prototype._checkAppIdData=function(){var e=this._getAppIdData(),t=(new Date).getTime();return null===e||t-e.lastChange>d?this._resetInitialAppIdData(e):e},o.prototype._resetInitialAppIdData=function(e){var t=e||{};return t.hostIndexes={read:0,write:0},t.timeoutMultiplier=1,t.shuffleResult=t.shuffleResult||a([1,2,3]),this._setAppIdData(t)},o.prototype._cacheAppIdData=function(e){this._hostIndexes=e.hostIndexes,this._timeoutMultiplier=e.timeoutMultiplier,this._shuffleResult=e.shuffleResult},o.prototype._partialAppIdDataUpdate=function(t){var r=e(4),o=this._getAppIdData();return r(t,function(e,t){o[t]=e}),this._setAppIdData(o)},o.prototype._getHostByType=function(e){return this.hosts[e][this._getHostIndexByType(e)]},o.prototype._getTimeoutMultiplier=function(){return this._timeoutMultiplier},o.prototype._getHostIndexByType=function(e){return this._hostIndexes[e]},o.prototype._setHostIndexByType=function(t,r){var o=e(20),n=o(this._hostIndexes);return n[r]=t,this._partialAppIdDataUpdate({hostIndexes:n}),t},o.prototype._incrementHostIndex=function(e){return this._setHostIndexByType((this._getHostIndexByType(e)+1)%this.hosts[e].length,e)},o.prototype._incrementTimeoutMultipler=function(){var e=Math.max(this._timeoutMultiplier+1,4);return this._partialAppIdDataUpdate({timeoutMultiplier:e})},o.prototype._getTimeoutsForRequest=function(e){return{connect:this._timeouts.connect*this._timeoutMultiplier,complete:this._timeouts[e]*this._timeoutMultiplier}}}).call(this,e(11))},{1:1,11:11,14:14,20:20,23:23,24:24,25:25,27:27,29:29,4:4,7:7}],14:[function(e,t,r){function o(e,t){this.indexName=t,this.as=e,this.typeAheadArgs=null,this.typeAheadValueOption=null,this.cache={}}var n=e(19),i=e(21),a=e(22);t.exports=o,o.prototype.clearCache=function(){this.cache={}},o.prototype.search=n("query"),o.prototype.similarSearch=n("similarQuery"),o.prototype.browse=function(t,r,o){var n,i,a=e(26),s=this;0===arguments.length||1===arguments.length&&"function"==typeof arguments[0]?(n=0,o=arguments[0],t=void 0):"number"==typeof arguments[0]?(n=arguments[0],"number"==typeof arguments[1]?i=arguments[1]:"function"==typeof arguments[1]&&(o=arguments[1],i=void 0),t=void 0,r=void 0):"object"==typeof arguments[0]?("function"==typeof arguments[1]&&(o=arguments[1]),r=arguments[0],t=void 0):"string"==typeof arguments[0]&&"function"==typeof arguments[1]&&(o=arguments[1],r=void 0),r=a({},r||{},{page:n,hitsPerPage:i,query:t});var c=this.as._getSearchParams(r,"");return this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(s.indexName)+"/browse",body:{params:c},hostType:"read",callback:o})},o.prototype.browseFrom=function(e,t){return this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/browse",body:{cursor:e},hostType:"read",callback:t})},o.prototype.searchForFacetValues=function(t,r){var o=e(20),n=e(27),i="Usage: index.searchForFacetValues({facetName, facetQuery, ...params}[, callback])";if(void 0===t.facetName||void 0===t.facetQuery)throw new Error(i);var a=t.facetName,s=n(o(t),function(e){return"facetName"===e}),c=this.as._getSearchParams(s,"");return this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/facets/"+encodeURIComponent(a)+"/query",hostType:"read",body:{params:c},callback:r})},o.prototype.searchFacet=i(function(e,t){return this.searchForFacetValues(e,t)},a("index.searchFacet(params[, callback])","index.searchForFacetValues(params[, callback])")),o.prototype._search=function(e,t,r,o){return this.as._jsonRequest({cache:this.cache,method:"POST",url:t||"/1/indexes/"+encodeURIComponent(this.indexName)+"/query",body:{params:e},hostType:"read",fallback:{method:"GET",url:"/1/indexes/"+encodeURIComponent(this.indexName),body:{params:e}},callback:r,additionalUA:o})},o.prototype.getObject=function(e,t,r){var o=this;1!==arguments.length&&"function"!=typeof t||(r=t,t=void 0);var n="";if(void 0!==t){n="?attributes=";for(var i=0;i<t.length;++i)0!==i&&(n+=","),n+=t[i]}return this.as._jsonRequest({method:"GET",url:"/1/indexes/"+encodeURIComponent(o.indexName)+"/"+encodeURIComponent(e)+n,hostType:"read",callback:r})},o.prototype.getObjects=function(t,r,o){var n=e(7),i=e(25),a="Usage: index.getObjects(arrayOfObjectIDs[, callback])";if(!n(t))throw new Error(a);var s=this;1!==arguments.length&&"function"!=typeof r||(o=r,r=void 0);var c={requests:i(t,function(e){var t={indexName:s.indexName,objectID:e};return r&&(t.attributesToRetrieve=r.join(",")),t})};return this.as._jsonRequest({method:"POST",url:"/1/indexes/*/objects",hostType:"read",body:c,callback:o})},o.prototype.as=null,o.prototype.indexName=null,o.prototype.typeAheadArgs=null,o.prototype.typeAheadValueOption=null},{19:19,20:20,21:21,22:22,25:25,26:26,27:27,7:7}],15:[function(e,t,r){"use strict";var o=e(13),n=e(16);t.exports=n(o,"(lite) ")},{13:13,16:16}],16:[function(e,t,r){(function(r){"use strict";var o=e(5),n=o.Promise||e(3).Promise;t.exports=function(t,i){function a(t,r,o){var n=e(20);return o=n(o||{}),o._ua=o._ua||a.ua,new s(t,r,o)}function s(){t.apply(this,arguments)}var c=e(6),u=e(23),l=e(17),p=e(18),f=e(28);i=i||"","debug"===r.env.NODE_ENV&&e(1).enable("algoliasearch*"),a.version=e(30),a.ua="Algolia for vanilla JavaScript "+i+a.version,a.initPlaces=f(a),o.__algolia={debug:e(1),algoliasearch:a};var d={hasXMLHttpRequest:"XMLHttpRequest"in o,hasXDomainRequest:"XDomainRequest"in o};return d.hasXMLHttpRequest&&(d.cors="withCredentials"in new XMLHttpRequest),c(s,t),s.prototype._request=function(e,t){return new n(function(r,o){function n(){if(!h){clearTimeout(f);var e;try{e={body:JSON.parse(m.responseText),responseText:m.responseText,statusCode:m.status,headers:m.getAllResponseHeaders&&m.getAllResponseHeaders()||{}}}catch(t){e=new u.UnparsableJSON({more:m.responseText})}e instanceof u.UnparsableJSON?o(e):r(e)}}function i(e){h||(clearTimeout(f),o(new u.Network({more:e})))}function a(){h=!0,m.abort(),o(new u.RequestTimeout)}function s(){g=!0,clearTimeout(f),
3
+ f=setTimeout(a,t.timeouts.complete)}function c(){g||s()}function p(){!g&&m.readyState>1&&s()}if(!d.cors&&!d.hasXDomainRequest)return void o(new u.Network("CORS not supported"));e=l(e,t.headers);var f,h,y=t.body,m=d.cors?new XMLHttpRequest:new XDomainRequest,g=!1;f=setTimeout(a,t.timeouts.connect),m.onprogress=c,"onreadystatechange"in m&&(m.onreadystatechange=p),m.onload=n,m.onerror=i,m instanceof XMLHttpRequest?m.open(t.method,e,!0):m.open(t.method,e),d.cors&&(y&&("POST"===t.method?m.setRequestHeader("content-type","application/x-www-form-urlencoded"):m.setRequestHeader("content-type","application/json")),m.setRequestHeader("accept","application/json")),m.send(y)})},s.prototype._request.fallback=function(e,t){return e=l(e,t.headers),new n(function(r,o){p(e,t,function(e,t){return e?void o(e):void r(t)})})},s.prototype._promise={reject:function(e){return n.reject(e)},resolve:function(e){return n.resolve(e)},delay:function(e){return new n(function(t){setTimeout(t,e)})},all:function(e){return n.all(e)}},a}}).call(this,e(11))},{1:1,11:11,17:17,18:18,20:20,23:23,28:28,3:3,30:30,5:5,6:6}],17:[function(e,t,r){"use strict";function o(e,t){return e+=/\?/.test(e)?"&":"?",e+n(t)}t.exports=o;var n=e(12)},{12:12}],18:[function(e,t,r){"use strict";function o(e,t,r){function o(){t.debug("JSONP: success"),m||f||(m=!0,p||(t.debug("JSONP: Fail. Script loaded but did not call the callback"),s(),r(new n.JSONPScriptFail)))}function a(){"loaded"!==this.readyState&&"complete"!==this.readyState||o()}function s(){clearTimeout(g),h.onload=null,h.onreadystatechange=null,h.onerror=null,d.removeChild(h)}function c(){try{delete window[y],delete window[y+"_loaded"]}catch(e){window[y]=window[y+"_loaded"]=void 0}}function u(){t.debug("JSONP: Script timeout"),f=!0,s(),r(new n.RequestTimeout)}function l(){t.debug("JSONP: Script error"),m||f||(s(),r(new n.JSONPScriptError))}if("GET"!==t.method)return void r(new Error("Method "+t.method+" "+e+" is not supported by JSONP."));t.debug("JSONP: start");var p=!1,f=!1;i+=1;var d=document.getElementsByTagName("head")[0],h=document.createElement("script"),y="algoliaJSONP_"+i,m=!1;window[y]=function(e){return c(),f?void t.debug("JSONP: Late answer, ignoring"):(p=!0,s(),void r(null,{body:e}))},e+="&callback="+y,t.jsonBody&&t.jsonBody.params&&(e+="&"+t.jsonBody.params);var g=setTimeout(u,t.timeouts.complete);h.onreadystatechange=a,h.onload=o,h.onerror=l,h.async=!0,h.defer=!0,h.src=e,d.appendChild(h)}t.exports=o;var n=e(23),i=0},{23:23}],19:[function(e,t,r){function o(e,t){return function(r,o,i){if("function"==typeof r&&"object"==typeof o||"object"==typeof i)throw new n.AlgoliaSearchError("index.search usage is index.search(query, params, cb)");0===arguments.length||"function"==typeof r?(i=r,r=""):1!==arguments.length&&"function"!=typeof o||(i=o,o=void 0),"object"==typeof r&&null!==r?(o=r,r=void 0):void 0!==r&&null!==r||(r="");var a="";void 0!==r&&(a+=e+"="+encodeURIComponent(r));var s;return void 0!==o&&(o.additionalUA&&(s=o.additionalUA,delete o.additionalUA),a=this.as._getSearchParams(o,a)),this._search(a,t,i,s)}}t.exports=o;var n=e(23)},{23:23}],20:[function(e,t,r){t.exports=function(e){return JSON.parse(JSON.stringify(e))}},{}],21:[function(e,t,r){t.exports=function(e,t){function r(){return o||(console.warn(t),o=!0),e.apply(this,arguments)}var o=!1;return r}},{}],22:[function(e,t,r){t.exports=function(e,t){var r=e.toLowerCase().replace(/[\.\(\)]/g,"");return"algoliasearch: `"+e+"` was replaced by `"+t+"`. Please see https://github.com/algolia/algoliasearch-client-javascript/wiki/Deprecated#"+r}},{}],23:[function(e,t,r){"use strict";function o(t,r){var o=e(4),n=this;"function"==typeof Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):n.stack=(new Error).stack||"Cannot get a stacktrace, browser is too old",this.name="AlgoliaSearchError",this.message=t||"Unknown error",r&&o(r,function(e,t){n[t]=e})}function n(e,t){function r(){var r=Array.prototype.slice.call(arguments,0);"string"!=typeof r[0]&&r.unshift(t),o.apply(this,r),this.name="AlgoliaSearch"+e+"Error"}return i(r,o),r}var i=e(6);i(o,Error),t.exports={AlgoliaSearchError:o,UnparsableJSON:n("UnparsableJSON","Could not parse the incoming response as JSON, see err.more for details"),RequestTimeout:n("RequestTimeout","Request timedout before getting a response"),Network:n("Network","Network issue, see err.more for details"),JSONPScriptFail:n("JSONPScriptFail","<script> was loaded but did not call our provided callback"),JSONPScriptError:n("JSONPScriptError","<script> unable to load due to an `error` event on it"),Unknown:n("Unknown","Unknown error occured")}},{4:4,6:6}],24:[function(e,t,r){t.exports=function(e,t){t(e,0)}},{}],25:[function(e,t,r){var o=e(4);t.exports=function(e,t){var r=[];return o(e,function(o,n){r.push(t(o,n,e))}),r}},{4:4}],26:[function(e,t,r){var o=e(4);t.exports=function n(e){var t=Array.prototype.slice.call(arguments);return o(t,function(t){for(var r in t)t.hasOwnProperty(r)&&("object"==typeof e[r]&&"object"==typeof t[r]?e[r]=n({},e[r],t[r]):void 0!==t[r]&&(e[r]=t[r]))}),e}},{4:4}],27:[function(e,t,r){t.exports=function(t,r){var o=e(9),n=e(4),i={};return n(o(t),function(e){r(e)!==!0&&(i[e]=t[e])}),i}},{4:4,9:9}],28:[function(e,t,r){function o(t){return function(r,o,i){var a=e(20);i=i&&a(i)||{},i.hosts=i.hosts||["places-dsn.algolia.net","places-1.algolianet.com","places-2.algolianet.com","places-3.algolianet.com"],0!==arguments.length&&"object"!=typeof r&&void 0!==r||(r="",o="",i._allowEmptyCredentials=!0);var s=t(r,o,i),c=s.initIndex("places");return c.search=n("query","/1/places/query"),c.getObject=function(e,t){return this.as._jsonRequest({method:"GET",url:"/1/places/"+encodeURIComponent(e),hostType:"read",callback:t})},c}}t.exports=o;var n=e(19)},{19:19,20:20}],29:[function(e,t,r){(function(r){function o(e,t){return c("localStorage failed with",t),a(),s=l,s.get(e)}function n(e,t){return 1===arguments.length?s.get(e):s.set(e,t)}function i(){try{return"localStorage"in r&&null!==r.localStorage&&(r.localStorage[u]||r.localStorage.setItem(u,JSON.stringify({})),!0)}catch(e){return!1}}function a(){try{r.localStorage.removeItem(u)}catch(e){}}var s,c=e(1)("algoliasearch:src/hostIndexState.js"),u="algoliasearch-client-js",l={state:{},set:function(e,t){return this.state[e]=t,this.state[e]},get:function(e){return this.state[e]||null}},p={set:function(e,t){l.set(e,t);try{var n=JSON.parse(r.localStorage[u]);return n[e]=t,r.localStorage[u]=JSON.stringify(n),n[e]}catch(i){return o(e,i)}},get:function(e){try{return JSON.parse(r.localStorage[u])[e]||null}catch(t){return o(e,t)}}};s=i()?p:l,t.exports={get:n,set:n,supportsLocalStorage:i}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{1:1}],30:[function(e,t,r){"use strict";t.exports="3.27.1"},{}]},{},[15])(15)});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "algoliasearch",
3
- "version": "3.25.0",
3
+ "version": "3.27.1",
4
4
  "description": "AlgoliaSearch API JavaScript client",
5
5
  "main": "index.js",
6
6
  "jsdelivr": "./dist/algoliasearch.min.js",
@@ -30,9 +30,13 @@
30
30
  "maxSize": "18 kB"
31
31
  },
32
32
  {
33
- "path": "./dist/algoliasearch.?(jquery|angular|parse).js",
33
+ "path": "./dist/algoliasearch.?(jquery|parse).js",
34
34
  "maxSize": "46 kB"
35
35
  },
36
+ {
37
+ "path": "./dist/algoliasearch.angular.js",
38
+ "maxSize": "46.5 kB"
39
+ },
36
40
  {
37
41
  "path": "./dist/algoliasearchLite.min.js",
38
42
  "maxSize": "13 kB"
@@ -263,7 +263,7 @@ AlgoliaSearch.prototype.addUserKey = deprecate(function(acls, params, callback)
263
263
  * content: the server answer with the added API key
264
264
  * @return {Promise|undefined} Returns a promise if no callback given
265
265
  * @example
266
- * client.addUserKey(['search'], {
266
+ * client.addApiKey(['search'], {
267
267
  * validity: 300,
268
268
  * maxQueriesPerIPPerHour: 2000,
269
269
  * maxHitsPerQuery: 3,
@@ -64,7 +64,6 @@ function AlgoliaSearchCore(applicationID, apiKey, opts) {
64
64
 
65
65
  opts = opts || {};
66
66
 
67
- var protocol = opts.protocol || 'https:';
68
67
  this._timeouts = opts.timeouts || {
69
68
  connect: 1 * 1000, // 500ms connect is GPRS latency
70
69
  read: 2 * 1000,
@@ -76,13 +75,14 @@ function AlgoliaSearchCore(applicationID, apiKey, opts) {
76
75
  this._timeouts.connect = this._timeouts.read = this._timeouts.write = opts.timeout;
77
76
  }
78
77
 
78
+ var protocol = opts.protocol || 'https:';
79
79
  // while we advocate for colon-at-the-end values: 'http:' for `opts.protocol`
80
80
  // we also accept `http` and `https`. It's a common error.
81
81
  if (!/:$/.test(protocol)) {
82
82
  protocol = protocol + ':';
83
83
  }
84
84
 
85
- if (opts.protocol !== 'http:' && opts.protocol !== 'https:') {
85
+ if (protocol !== 'http:' && protocol !== 'https:') {
86
86
  throw new errors.AlgoliaSearchError('protocol must be `http:` or `https:` (was `' + opts.protocol + '`)');
87
87
  }
88
88
 
@@ -94,7 +94,8 @@ function AlgoliaSearchCore(applicationID, apiKey, opts) {
94
94
  });
95
95
 
96
96
  // no hosts given, compute defaults
97
- this.hosts.read = [this.applicationID + '-dsn.algolia.net'].concat(defaultHosts);
97
+ var mainSuffix = (opts.dsn === false ? '' : '-dsn') + '.algolia.net';
98
+ this.hosts.read = [this.applicationID + mainSuffix].concat(defaultHosts);
98
99
  this.hosts.write = [this.applicationID + '.algolia.net'].concat(defaultHosts);
99
100
  } else if (isArray(opts.hosts)) {
100
101
  // when passing custom hosts, we need to have a different host index if the number
@@ -608,6 +609,70 @@ AlgoliaSearchCore.prototype.search = function(queries, opts, callback) {
608
609
  });
609
610
  };
610
611
 
612
+ /**
613
+ * Search for facet values
614
+ * https://www.algolia.com/doc/rest-api/search#search-for-facet-values
615
+ * This is the top-level API for SFFV.
616
+ *
617
+ * @param {object[]} queries An array of queries to run.
618
+ * @param {string} queries[].indexName Index name, name of the index to search.
619
+ * @param {object} queries[].params Query parameters.
620
+ * @param {string} queries[].params.facetName Facet name, name of the attribute to search for values in.
621
+ * Must be declared as a facet
622
+ * @param {string} queries[].params.facetQuery Query for the facet search
623
+ * @param {string} [queries[].params.*] Any search parameter of Algolia,
624
+ * see https://www.algolia.com/doc/api-client/javascript/search#search-parameters
625
+ * Pagination is not supported. The page and hitsPerPage parameters will be ignored.
626
+ */
627
+ AlgoliaSearchCore.prototype.searchForFacetValues = function(queries) {
628
+ var isArray = require('isarray');
629
+ var map = require('./map.js');
630
+
631
+ var usage = 'Usage: client.searchForFacetValues([{indexName, params: {facetName, facetQuery, ...params}}, ...queries])'; // eslint-disable-line max-len
632
+
633
+ if (!isArray(queries)) {
634
+ throw new Error(usage);
635
+ }
636
+
637
+ var client = this;
638
+
639
+ return client._promise.all(map(queries, function performQuery(query) {
640
+ if (
641
+ !query ||
642
+ query.indexName === undefined ||
643
+ query.params.facetName === undefined ||
644
+ query.params.facetQuery === undefined
645
+ ) {
646
+ throw new Error(usage);
647
+ }
648
+
649
+ var clone = require('./clone.js');
650
+ var omit = require('./omit.js');
651
+
652
+ var indexName = query.indexName;
653
+ var params = query.params;
654
+
655
+ var facetName = params.facetName;
656
+ var filteredParams = omit(clone(params), function(keyName) {
657
+ return keyName === 'facetName';
658
+ });
659
+ var searchParameters = client._getSearchParams(filteredParams, '');
660
+
661
+ return client._jsonRequest({
662
+ cache: client.cache,
663
+ method: 'POST',
664
+ url:
665
+ '/1/indexes/' +
666
+ encodeURIComponent(indexName) +
667
+ '/facets/' +
668
+ encodeURIComponent(facetName) +
669
+ '/query',
670
+ hostType: 'read',
671
+ body: {params: searchParameters}
672
+ });
673
+ }));
674
+ };
675
+
611
676
  /**
612
677
  * Set the extra security tagFilters header
613
678
  * @param {string|array} tags The list of tags defining the current security filters
package/src/Index.js CHANGED
@@ -799,6 +799,7 @@ Index.prototype.searchRules = function(params, callback) {
799
799
  * Retrieve all the query rules in an index
800
800
  * @param [number=100] hitsPerPage The amount of query rules to retrieve per batch
801
801
  * @param [function] callback will be called after all query rules are retrieved
802
+ * error: null or Error('message')
802
803
  */
803
804
  Index.prototype.exportRules = function(hitsPerPage, callback) {
804
805
  return exportData(this.searchRules.bind(this), hitsPerPage, callback);
@@ -812,6 +813,10 @@ Index.prototype.saveRule = function(rule, opts, callback) {
812
813
  opts = {};
813
814
  }
814
815
 
816
+ if (!rule.objectID) {
817
+ throw new errors.AlgoliaSearchError('Missing or empty objectID field for rule');
818
+ }
819
+
815
820
  var forwardToReplicas = opts.forwardToReplicas === true ? 'true' : 'false';
816
821
 
817
822
  return this.as._jsonRequest({
@@ -984,11 +989,11 @@ Index.prototype.setSettings = function(settings, opts, callback) {
984
989
  };
985
990
 
986
991
  /*
987
- @deprecated see index.listApiKeys
988
- */
992
+ * @deprecated see client.listApiKeys()
993
+ */
989
994
  Index.prototype.listUserKeys = deprecate(function(callback) {
990
995
  return this.listApiKeys(callback);
991
- }, deprecatedMessage('index.listUserKeys()', 'index.listApiKeys()'));
996
+ }, deprecatedMessage('index.listUserKeys()', 'client.listApiKeys()'));
992
997
 
993
998
  /*
994
999
  * List all existing API keys to this index
@@ -996,8 +1001,10 @@ Index.prototype.listUserKeys = deprecate(function(callback) {
996
1001
  * @param callback the result callback called with two arguments
997
1002
  * error: null or Error('message')
998
1003
  * content: the server answer with API keys belonging to the index
1004
+ *
1005
+ * @deprecated see client.listApiKeys()
999
1006
  */
1000
- Index.prototype.listApiKeys = function(callback) {
1007
+ Index.prototype.listApiKeys = deprecate(function(callback) {
1001
1008
  var indexObj = this;
1002
1009
  return this.as._jsonRequest({
1003
1010
  method: 'GET',
@@ -1005,14 +1012,14 @@ Index.prototype.listApiKeys = function(callback) {
1005
1012
  hostType: 'read',
1006
1013
  callback: callback
1007
1014
  });
1008
- };
1015
+ }, deprecatedMessage('index.listApiKeys()', 'client.listApiKeys()'));
1009
1016
 
1010
1017
  /*
1011
- @deprecated see index.getApiKey
1012
- */
1018
+ * @deprecated see client.getApiKey()
1019
+ */
1013
1020
  Index.prototype.getUserKeyACL = deprecate(function(key, callback) {
1014
1021
  return this.getApiKey(key, callback);
1015
- }, deprecatedMessage('index.getUserKeyACL()', 'index.getApiKey()'));
1022
+ }, deprecatedMessage('index.getUserKeyACL()', 'client.getApiKey()'));
1016
1023
 
1017
1024
 
1018
1025
  /*
@@ -1022,8 +1029,10 @@ Index.prototype.getUserKeyACL = deprecate(function(key, callback) {
1022
1029
  * @param callback the result callback called with two arguments
1023
1030
  * error: null or Error('message')
1024
1031
  * content: the server answer with the right API key
1032
+ *
1033
+ * @deprecated see client.getApiKey()
1025
1034
  */
1026
- Index.prototype.getApiKey = function(key, callback) {
1035
+ Index.prototype.getApiKey = deprecate(function(key, callback) {
1027
1036
  var indexObj = this;
1028
1037
  return this.as._jsonRequest({
1029
1038
  method: 'GET',
@@ -1031,14 +1040,14 @@ Index.prototype.getApiKey = function(key, callback) {
1031
1040
  hostType: 'read',
1032
1041
  callback: callback
1033
1042
  });
1034
- };
1043
+ }, deprecatedMessage('index.getApiKey()', 'client.getApiKey()'));
1035
1044
 
1036
1045
  /*
1037
- @deprecated see index.deleteApiKey
1038
- */
1046
+ * @deprecated see client.deleteApiKey()
1047
+ */
1039
1048
  Index.prototype.deleteUserKey = deprecate(function(key, callback) {
1040
1049
  return this.deleteApiKey(key, callback);
1041
- }, deprecatedMessage('index.deleteUserKey()', 'index.deleteApiKey()'));
1050
+ }, deprecatedMessage('index.deleteUserKey()', 'client.deleteApiKey()'));
1042
1051
 
1043
1052
  /*
1044
1053
  * Delete an existing API key associated to this index
@@ -1047,8 +1056,10 @@ Index.prototype.deleteUserKey = deprecate(function(key, callback) {
1047
1056
  * @param callback the result callback called with two arguments
1048
1057
  * error: null or Error('message')
1049
1058
  * content: the server answer with the deletion date
1059
+ *
1060
+ * @deprecated see client.deleteApiKey()
1050
1061
  */
1051
- Index.prototype.deleteApiKey = function(key, callback) {
1062
+ Index.prototype.deleteApiKey = deprecate(function(key, callback) {
1052
1063
  var indexObj = this;
1053
1064
  return this.as._jsonRequest({
1054
1065
  method: 'DELETE',
@@ -1056,14 +1067,14 @@ Index.prototype.deleteApiKey = function(key, callback) {
1056
1067
  hostType: 'write',
1057
1068
  callback: callback
1058
1069
  });
1059
- };
1070
+ }, deprecatedMessage('index.deleteApiKey()', 'client.deleteApiKey()'));
1060
1071
 
1061
1072
  /*
1062
- @deprecated see index.addApiKey
1063
- */
1073
+ * @deprecated see client.addApiKey()
1074
+ */
1064
1075
  Index.prototype.addUserKey = deprecate(function(acls, params, callback) {
1065
1076
  return this.addApiKey(acls, params, callback);
1066
- }, deprecatedMessage('index.addUserKey()', 'index.addApiKey()'));
1077
+ }, deprecatedMessage('index.addUserKey()', 'client.addApiKey()'));
1067
1078
 
1068
1079
  /*
1069
1080
  * Add a new API key to this index
@@ -1100,8 +1111,10 @@ Index.prototype.addUserKey = deprecate(function(acls, params, callback) {
1100
1111
  * }
1101
1112
  * })
1102
1113
  * @see {@link https://www.algolia.com/doc/rest_api#AddIndexKey|Algolia REST API Documentation}
1114
+ *
1115
+ * @deprecated see client.addApiKey()
1103
1116
  */
1104
- Index.prototype.addApiKey = function(acls, params, callback) {
1117
+ Index.prototype.addApiKey = deprecate(function(acls, params, callback) {
1105
1118
  var isArray = require('isarray');
1106
1119
  var usage = 'Usage: index.addApiKey(arrayOfAcls[, params, callback])';
1107
1120
 
@@ -1138,21 +1151,21 @@ Index.prototype.addApiKey = function(acls, params, callback) {
1138
1151
  hostType: 'write',
1139
1152
  callback: callback
1140
1153
  });
1141
- };
1154
+ }, deprecatedMessage('index.addApiKey()', 'client.addApiKey()'));
1142
1155
 
1143
1156
  /**
1144
- * @deprecated use index.addApiKey()
1157
+ * @deprecated use client.addApiKey()
1145
1158
  */
1146
1159
  Index.prototype.addUserKeyWithValidity = deprecate(function deprecatedAddUserKeyWithValidity(acls, params, callback) {
1147
1160
  return this.addApiKey(acls, params, callback);
1148
- }, deprecatedMessage('index.addUserKeyWithValidity()', 'index.addApiKey()'));
1161
+ }, deprecatedMessage('index.addUserKeyWithValidity()', 'client.addApiKey()'));
1149
1162
 
1150
1163
  /*
1151
- @deprecated see index.updateApiKey
1152
- */
1164
+ * @deprecated see client.updateApiKey()
1165
+ */
1153
1166
  Index.prototype.updateUserKey = deprecate(function(key, acls, params, callback) {
1154
1167
  return this.updateApiKey(key, acls, params, callback);
1155
- }, deprecatedMessage('index.updateUserKey()', 'index.updateApiKey()'));
1168
+ }, deprecatedMessage('index.updateUserKey()', 'client.updateApiKey()'));
1156
1169
 
1157
1170
  /**
1158
1171
  * Update an existing API key of this index
@@ -1189,8 +1202,10 @@ Index.prototype.updateUserKey = deprecate(function(key, acls, params, callback)
1189
1202
  * }
1190
1203
  * })
1191
1204
  * @see {@link https://www.algolia.com/doc/rest_api#UpdateIndexKey|Algolia REST API Documentation}
1205
+ *
1206
+ * @deprecated see client.updateApiKey()
1192
1207
  */
1193
- Index.prototype.updateApiKey = function(key, acls, params, callback) {
1208
+ Index.prototype.updateApiKey = deprecate(function(key, acls, params, callback) {
1194
1209
  var isArray = require('isarray');
1195
1210
  var usage = 'Usage: index.updateApiKey(key, arrayOfAcls[, params, callback])';
1196
1211
 
@@ -1227,4 +1242,4 @@ Index.prototype.updateApiKey = function(key, acls, params, callback) {
1227
1242
  hostType: 'write',
1228
1243
  callback: callback
1229
1244
  });
1230
- };
1245
+ }, deprecatedMessage('index.updateApiKey()', 'client.updateApiKey()'));
@@ -185,6 +185,9 @@ window.angular.module('algoliasearch', [])
185
185
  $timeout(resolve, ms);
186
186
 
187
187
  return deferred.promise;
188
+ },
189
+ all: function(promises) {
190
+ return $q.all(promises);
188
191
  }
189
192
  };
190
193
 
@@ -140,5 +140,8 @@ AlgoliaSearchJQuery.prototype._promise = {
140
140
  deferred.resolve();
141
141
  }, ms);
142
142
  }).promise();
143
+ },
144
+ all: function all(promises) {
145
+ return $.when.apply(null, promises);
143
146
  }
144
147
  };
@@ -206,6 +206,9 @@ module.exports = function createAlgoliasearch(AlgoliaSearch, uaSuffix) {
206
206
  return new Promise(function resolveOnTimeout(resolve/* , reject*/) {
207
207
  setTimeout(resolve, ms);
208
208
  });
209
+ },
210
+ all: function all(promises) {
211
+ return Promise.all(promises);
209
212
  }
210
213
  };
211
214
 
@@ -168,5 +168,8 @@ AlgoliaSearchReactNative.prototype._promise = {
168
168
  return new Promise(function resolveOnTimeout(resolve/* , reject*/) {
169
169
  setTimeout(resolve, ms);
170
170
  });
171
+ },
172
+ all: function all(promises) {
173
+ return Promise.all(promises);
171
174
  }
172
175
  };
@@ -257,6 +257,9 @@ AlgoliaSearchNodeJS.prototype._promise = {
257
257
  return new Promise(function resolveOnTimeout(resolve/* , reject */) {
258
258
  setTimeout(resolve, ms);
259
259
  });
260
+ },
261
+ all: function all(promises) {
262
+ return Promise.all(promises);
260
263
  }
261
264
  };
262
265
 
@@ -116,6 +116,9 @@ AlgoliaSearchParse.prototype._promise = {
116
116
  _setTimeout(promise.resolve.bind(promise), ms);
117
117
 
118
118
  return promise;
119
+ },
120
+ all: function all(promises) {
121
+ return Parse.Promise.all(promises);
119
122
  }
120
123
  };
121
124
 
package/src/version.js CHANGED
@@ -1,3 +1,3 @@
1
1
  'use strict';
2
2
 
3
- module.exports = '3.25.0';
3
+ module.exports = '3.27.1';