Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

algoliasearch

Package Overview
Dependencies
Maintainers
1
Versions
385
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

algoliasearch - npm Package Compare versions

Comparing version 2.5.4 to 2.6.0

ChangeLog~

4

dist/algoliasearch.min.js
/*!
* algoliasearch 2.5.4
* algoliasearch 2.6.0
* https://github.com/algolia/algoliasearch-client-js

@@ -7,2 +7,2 @@ * Copyright 2014 Algolia SAS; Licensed MIT

function AlgoliaExplainResults(a,b,c){function d(a,b){var c=[];if("object"==typeof a&&"matchedWords"in a&&"value"in a){for(var e=!1,f=0;f<a.matchedWords.length;++f){var g=a.matchedWords[f];g in b||(b[g]=1,e=!0)}e&&c.push(a.value)}else if("[object Array]"===Object.prototype.toString.call(a))for(var h=0;h<a.length;++h){var i=d(a[h],b);c=c.concat(i)}else if("object"==typeof a)for(var j in a)a.hasOwnProperty(j)&&(c=c.concat(d(a[j],b)));return c}function e(a,b,c){var f=a._highlightResult||a;if(-1===c.indexOf("."))return c in f?d(f[c],b):[];for(var g=c.split("."),h=f,i=0;i<g.length;++i){if("[object Array]"===Object.prototype.toString.call(h)){for(var j=[],k=0;k<h.length;++k)j=j.concat(e(h[k],b,g.slice(i).join(".")));return j}if(!(g[i]in h))return[];h=h[g[i]]}return d(h,b)}var f={},g={},h=e(a,g,b);if(f.title=h.length>0?h[0]:"",f.subtitles=[],"undefined"!=typeof c)for(var i=0;i<c.length;++i)for(var j=e(a,g,c[i]),k=0;k<j.length;++k)f.subtitles.push({attr:c[i],value:j[k]});return f}var ALGOLIA_VERSION="2.5.4",AlgoliaSearch=function(a,b,c,d,e){var f=this;this.applicationID=a,this.apiKey=b,this._isUndefined(e)&&(e=[a+"-1.algolia.io",a+"-2.algolia.io",a+"-3.algolia.io"]),this.hosts=[];for(var g=0;g<e.length;++g)Math.random()>.5&&this.hosts.reverse(),this._isUndefined(c)||null===c?this.hosts.push(("https:"==document.location.protocol?"https":"http")+"://"+e[g]):"https"===c||"HTTPS"===c?this.hosts.push("https://"+e[g]):this.hosts.push("http://"+e[g]);Math.random()>.5&&this.hosts.reverse(),this.jsonp=null,this.jsonpWait=0,this._jsonRequest({method:"GET",url:"/1/isalive",callback:function(a){f.jsonp=!a},removeCustomHTTPHeaders:!0}),this.extraHeaders=[]};AlgoliaSearch.prototype={deleteIndex:function(a,b){this._jsonRequest({method:"DELETE",url:"/1/indexes/"+encodeURIComponent(a),callback:b})},moveIndex:function(a,b,c){var d={operation:"move",destination:b};this._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(a)+"/operation",body:d,callback:c})},copyIndex:function(a,b,c){var d={operation:"copy",destination:b};this._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(a)+"/operation",body:d,callback:c})},getLogs:function(a,b,c){this._isUndefined(b)&&(b=0),this._isUndefined(c)&&(c=10),this._jsonRequest({method:"GET",url:"/1/logs?offset="+b+"&length="+c,callback:a})},listIndexes:function(a,b){var c=b?"?page="+b:"";this._jsonRequest({method:"GET",url:"/1/indexes"+c,callback:a})},initIndex:function(a){return new this.Index(this,a)},listUserKeys:function(a){this._jsonRequest({method:"GET",url:"/1/keys",callback:a})},getUserKeyACL:function(a,b){this._jsonRequest({method:"GET",url:"/1/keys/"+a,callback:b})},deleteUserKey:function(a,b){this._jsonRequest({method:"DELETE",url:"/1/keys/"+a,callback:b})},addUserKey:function(a,b){var c={};c.acl=a,this._jsonRequest({method:"POST",url:"/1/keys",body:c,callback:b})},addUserKeyWithValidity:function(a,b,c,d,e){var f=this,g={};g.acl=a,g.validity=b,g.maxQueriesPerIPPerHour=c,g.maxHitsPerQuery=d,this._jsonRequest({method:"POST",url:"/1/indexes/"+f.indexName+"/keys",body:g,callback:e})},setSecurityTags:function(a){if("[object Array]"===Object.prototype.toString.call(a)){for(var b=[],c=0;c<a.length;++c)if("[object Array]"===Object.prototype.toString.call(a[c])){for(var d=[],e=0;e<a[c].length;++e)d.push(a[c][e]);b.push("("+d.join(",")+")")}else b.push(a[c]);a=b.join(",")}this.tagFilters=a},setUserToken:function(a){this.userToken=a},startQueriesBatch:function(){this.batch=[]},addQueryInBatch:function(a,b,c){var d="query="+encodeURIComponent(b);this._isUndefined(c)||null===c||(d=this._getSearchParams(c,d)),this.batch.push({indexName:a,params:d})},clearCache:function(){this.cache={}},sendQueriesBatch:function(a,b){var c=this,d={requests:[],apiKey:this.apiKey,appID:this.applicationID};this.userToken&&(d["X-Algolia-UserToken"]=this.userToken),this.tagFilters&&(d["X-Algolia-TagFilters"]=this.tagFilters);for(var e=0;e<c.batch.length;++e)d.requests.push(c.batch[e]);if(window.clearTimeout(c.onDelayTrigger),!this._isUndefined(b)&&null!==b&&b>0){var f=window.setTimeout(function(){c._sendQueriesBatch(d,a)},b);c.onDelayTrigger=f}else this._sendQueriesBatch(d,a)},Index:function(a,b){this.indexName=b,this.as=a,this.typeAheadArgs=null,this.typeAheadValueOption=null},setExtraHeader:function(a,b){this.extraHeaders.push({key:a,value:b})},_sendQueriesBatch:function(a,b){if(null===this.jsonp){var c=this;return this._waitReady(function(){c._sendQueriesBatch(a,b)}),void 0}if(this.jsonp){for(var d="",e=0;e<a.requests.length;++e){var f="/1/indexes/"+encodeURIComponent(a.requests[e].indexName)+"?"+a.requests[e].params;d+=e+"="+encodeURIComponent(f)+"&"}this._jsonRequest({cache:this.cache,method:"GET",jsonp:!0,url:"/1/indexes/*",body:{params:d},callback:b})}else this._jsonRequest({cache:this.cache,method:"POST",url:"/1/indexes/*/queries",body:a,callback:b,removeCustomHTTPHeaders:!0})},_jsonRequest:function(a){var b=this,c=a.callback,d=null,e=a.url;if(this._isUndefined(a.body)||(e=a.url+"_body_"+JSON.stringify(a.body)),!this._isUndefined(a.cache)&&(d=a.cache,!this._isUndefined(d[e])))return this._isUndefined(c)||setTimeout(function(){c(!0,d[e])},1),void 0;var f=function(g){var h=0;return b._isUndefined(g)||(h=g),b.hosts.length<=h?(b._isUndefined(c)||c(!1,{message:"Cannot contact server"}),void 0):(a.callback=function(g,i,j,k){i||b._isUndefined(k)||window.console&&console.log("Error: "+k.message),i&&!b._isUndefined(a.cache)&&(d[e]=k),!i&&g&&h+1<b.hosts.length?f(h+1):b._isUndefined(c)||c(i,k)},a.hostname=b.hosts[h],b._jsonRequestByHost(a),void 0)};f()},_jsonRequestByHost:function(a){var b=this,c=a.hostname+a.url;if(this.jsonp){if(!a.jsonp)return a.callback(!0,!1,null,{message:"Method "+a.method+" "+c+" is not supported by JSONP."}),void 0;this.jsonpCounter=this.jsonpCounter||0,this.jsonpCounter+=1;var d="algoliaJSONP_"+this.jsonpCounter;window[d]=function(b){a.callback(!1,!0,null,b);try{delete window[d]}catch(c){window[d]=void 0}};var e=document.createElement("script");e.type="text/javascript",e.src=c+"?callback="+d+","+this.applicationID+","+this.apiKey,a["X-Algolia-TagFilters"]&&(e.src+="&X-Algolia-TagFilters="+a["X-Algolia-TagFilters"]),a["X-Algolia-UserToken"]&&(e.src+="&X-Algolia-UserToken="+a["X-Algolia-UserToken"]),a.body&&a.body.params&&(e.src+="&"+a.body.params);var f=document.getElementsByTagName("head")[0];e.onerror=function(){a.callback(!0,!1,null,{message:"Failed to load JSONP script."}),f.removeChild(e);try{delete window[d]}catch(b){window[d]=void 0}};var g=!1;e.onload=e.onreadystatechange=function(){if(!(g||this.readyState&&"loaded"!=this.readyState&&"complete"!=this.readyState)){if(g=!0,"undefined"==typeof window[d+"_loaded"]){a.callback(!0,!1,null,{message:"Failed to load JSONP script."});try{delete window[d]}catch(b){window[d]=void 0}}else try{delete window[d+"_loaded"]}catch(b){window[d+"_loaded"]=void 0}e.onload=e.onreadystatechange=null,f.removeChild(e)}},f.appendChild(e)}else{var h=null;this._isUndefined(a.body)||(h=JSON.stringify(a.body));var i=window.XMLHttpRequest?new XMLHttpRequest:{};if("withCredentials"in i){i.open(a.method,c,!0),(this._isUndefined(a.removeCustomHTTPHeaders)||!a.removeCustomHTTPHeaders)&&(i.setRequestHeader("X-Algolia-API-Key",this.apiKey),i.setRequestHeader("X-Algolia-Application-Id",this.applicationID));for(var j=0;j<this.extraHeaders.length;++j)i.setRequestHeader(this.extraHeaders[j].key,this.extraHeaders[j].value);null!==h&&i.setRequestHeader("Content-type","application/json")}else{if("undefined"==typeof XDomainRequest)return window.console&&console.log("Your browser is too old to support CORS requests"),a.callback(!1,!1,null,{message:"CORS not supported"}),void 0;i=new XDomainRequest,i.open(a.method,c)}i.send(h),i.onload=function(c){if(b._isUndefined(c)||null===c.target)a.callback(!1,!0,c,JSON.parse(i.responseText));else{var d=0===c.target.status||503===c.target.status,e=200===c.target.status||201===c.target.status;a.callback(d,e,c.target,null!==c.target.response?JSON.parse(c.target.response):null)}},i.onerror=function(b){a.callback(!0,!1,null,{message:"Could not connect to host",error:b})}}},_waitReady:function(a){null===this.jsonp&&(this.jsonpWait+=100,this.jsonpWait>2e3&&(this.jsonp=!0),setTimeout(a,100))},_getSearchParams:function(a,b){if(this._isUndefined(a)||null===a)return b;for(var c in a)null!==c&&a.hasOwnProperty(c)&&(b+=0===b.length?"?":"&",b+=c+"="+encodeURIComponent("[object Array]"===Object.prototype.toString.call(a[c])?JSON.stringify(a[c]):a[c]));return b},_isUndefined:function(a){return void 0===a},applicationID:null,apiKey:null,tagFilters:null,userToken:null,hosts:[],cache:{},extraHeaders:[]},AlgoliaSearch.prototype.Index.prototype={clearCache:function(){this.cache={}},addObject:function(a,b,c){var d=this;this.as._isUndefined(c)?this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(d.indexName),body:a,callback:b}):this.as._jsonRequest({method:"PUT",url:"/1/indexes/"+encodeURIComponent(d.indexName)+"/"+encodeURIComponent(c),body:a,callback:b})},addObjects:function(a,b){for(var c=this,d={requests:[]},e=0;e<a.length;++e){var f={action:"addObject",body:a[e]};d.requests.push(f)}this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(c.indexName)+"/batch",body:d,callback:b})},getObject:function(a,b,c){if(null===this.as.jsonp){var d=this;return this.as._waitReady(function(){d.getObject(a,b,c)}),void 0}var e=this,f="";if(!this.as._isUndefined(c)){f="?attributes=";for(var g=0;g<c.length;++g)0!==g&&(f+=","),f+=c[g]}this.as._jsonRequest({method:"GET",jsonp:!0,url:"/1/indexes/"+encodeURIComponent(e.indexName)+"/"+encodeURIComponent(a)+f,callback:b})},partialUpdateObject:function(a,b){var c=this;this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(c.indexName)+"/"+encodeURIComponent(a.objectID)+"/partial",body:a,callback:b})},partialUpdateObjects:function(a,b){for(var c=this,d={requests:[]},e=0;e<a.length;++e){var f={action:"partialUpdateObject",objectID:a[e].objectID,body:a[e]};d.requests.push(f)}this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(c.indexName)+"/batch",body:d,callback:b})},saveObject:function(a,b){var c=this;this.as._jsonRequest({method:"PUT",url:"/1/indexes/"+encodeURIComponent(c.indexName)+"/"+encodeURIComponent(a.objectID),body:a,callback:b})},saveObjects:function(a,b){for(var c=this,d={requests:[]},e=0;e<a.length;++e){var f={action:"updateObject",objectID:a[e].objectID,body:a[e]};d.requests.push(f)}this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(c.indexName)+"/batch",body:d,callback:b})},deleteObject:function(a,b){if(null===a||0===a.length)return b(!1,{message:"empty objectID"}),void 0;var c=this;this.as._jsonRequest({method:"DELETE",url:"/1/indexes/"+encodeURIComponent(c.indexName)+"/"+encodeURIComponent(a),callback:b})},search:function(a,b,c,d){var e=this,f="query="+encodeURIComponent(a);if(this.as._isUndefined(c)||null===c||(f=this.as._getSearchParams(c,f)),window.clearTimeout(e.onDelayTrigger),!this.as._isUndefined(d)&&null!==d&&d>0){var g=window.setTimeout(function(){e._search(f,b)},d);e.onDelayTrigger=g}else this._search(f,b)},browse:function(a,b,c){var d=this,e="?page="+a;_.isUndefined(c)||(e+="&hitsPerPage="+c),this.as._jsonRequest({method:"GET",url:"/1/indexes/"+encodeURIComponent(d.indexName)+"/browse"+e,callback:b})},ttAdapter:function(a){var b=this;return function(c,d){b.search(c,function(a,b){a&&d(b.hits)},a)}},waitTask:function(a,b){var c=this;this.as._jsonRequest({method:"GET",url:"/1/indexes/"+encodeURIComponent(c.indexName)+"/task/"+a,callback:function(d,e){d?"published"===e.status?b(!0,e):setTimeout(function(){c.waitTask(a,b)},100):b(!1,e)}})},clearIndex:function(a){var b=this;this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(b.indexName)+"/clear",callback:a})},getSettings:function(a){var b=this;this.as._jsonRequest({method:"GET",url:"/1/indexes/"+encodeURIComponent(b.indexName)+"/settings",callback:a})},setSettings:function(a,b){var c=this;this.as._jsonRequest({method:"PUT",url:"/1/indexes/"+encodeURIComponent(c.indexName)+"/settings",body:a,callback:b})},listUserKeys:function(a){var b=this;this.as._jsonRequest({method:"GET",url:"/1/indexes/"+encodeURIComponent(b.indexName)+"/keys",callback:a})},getUserKeyACL:function(a,b){var c=this;this.as._jsonRequest({method:"GET",url:"/1/indexes/"+encodeURIComponent(c.indexName)+"/keys/"+a,callback:b})},deleteUserKey:function(a,b){var c=this;this.as._jsonRequest({method:"DELETE",url:"/1/indexes/"+encodeURIComponent(c.indexName)+"/keys/"+a,callback:b})},addUserKey:function(a,b){var c=this,d={};d.acl=a,this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(c.indexName)+"/keys",body:d,callback:b})},addUserKeyWithValidity:function(a,b,c,d,e){var f=this,g={};g.acl=a,g.validity=b,g.maxQueriesPerIPPerHour=c,g.maxHitsPerQuery=d,this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(f.indexName)+"/keys",body:g,callback:e})},_search:function(a,b){if(null===this.as.jsonp){var c=this;return this.as._waitReady(function(){c._search(a,b)}),void 0}var d={params:a,apiKey:this.as.apiKey,appID:this.as.applicationID};this.as.tagFilters&&(d["X-Algolia-TagFilters"]=this.as.tagFilters),this.as.userToken&&(d["X-Algolia-UserToken"]=this.as.userToken),this.as.jsonp?this.as._jsonRequest({cache:this.cache,method:"GET",jsonp:!0,url:"/1/indexes/"+encodeURIComponent(this.indexName),body:d,callback:b}):this.as._jsonRequest({cache:this.cache,method:"POST",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/query",body:d,callback:b,removeCustomHTTPHeaders:!0})},as:null,indexName:null,cache:{},typeAheadArgs:null,typeAheadValueOption:null,emptyConstructor:function(){}},function(){var a=function(a){a=a||{};for(var b=1;b<arguments.length;b++)if(arguments[b])for(var c in arguments[b])arguments[b].hasOwnProperty(c)&&(a[c]=arguments[b][c]);return a};window.AlgoliaSearchHelper=function(b,c,d){var e={facets:[],disjunctiveFacets:[],hitsPerPage:20};this.init(b,c,a({},e,d))},AlgoliaSearchHelper.prototype={init:function(a,b,c){this.client=a,this.index=b,this.options=c,this.page=0,this.refinements={},this.disjunctiveRefinements={}},search:function(a,b,c){this.q=a,this.searchCallback=b,this.searchParams=c||{},this.page=this.page||0,this.refinements=this.refinements||{},this.disjunctiveRefinements=this.disjunctiveRefinements||{},this._search()},clearRefinements:function(){this.disjunctiveRefinements={},this.refinements={}},addDisjunctiveRefine:function(a,b){this.disjunctiveRefinements=this.disjunctiveRefinements||{},this.disjunctiveRefinements[a]=this.disjunctiveRefinements[a]||{},this.disjunctiveRefinements[a][b]=!0},removeDisjunctiveRefine:function(a,b){this.disjunctiveRefinements=this.disjunctiveRefinements||{},this.disjunctiveRefinements[a]=this.disjunctiveRefinements[a]||{};try{delete this.disjunctiveRefinements[a][b]}catch(c){this.disjunctiveRefinements[a][b]=void 0}},addRefine:function(a,b){var c=a+":"+b;this.refinements=this.refinements||{},this.refinements[c]=!0},removeRefine:function(a,b){var c=a+":"+b;this.refinements=this.refinements||{},this.refinements[c]=!1},toggleRefine:function(a,b){for(var c=0;c<this.options.facets.length;++c)if(this.options.facets[c]==a){var d=a+":"+b;return this.refinements[d]=!this.refinements[d],this.page=0,this._search(),!0}this.disjunctiveRefinements[a]=this.disjunctiveRefinements[a]||{};for(var e=0;e<this.options.disjunctiveFacets.length;++e)if(this.options.disjunctiveFacets[e]==a)return this.disjunctiveRefinements[a][b]=!this.disjunctiveRefinements[a][b],this.page=0,this._search(),!0;return!1},isRefined:function(a,b){var c=a+":"+b;return this.refinements[c]?!0:this.disjunctiveRefinements[a]&&this.disjunctiveRefinements[a][b]?!0:!1},nextPage:function(){this._gotoPage(this.page+1)},previousPage:function(){this.page>0&&this._gotoPage(this.page-1)},gotoPage:function(a){this._gotoPage(a)},setPage:function(a){this.page=a},setIndex:function(a){this.index=a},getIndex:function(){return this.index},_gotoPage:function(a){this.page=a,this._search()},_search:function(){this.client.startQueriesBatch(),this.client.addQueryInBatch(this.index,this.q,this._getHitsSearchParams());for(var a=0;a<this.options.disjunctiveFacets.length;++a)this.client.addQueryInBatch(this.index,this.q,this._getDisjunctiveFacetSearchParams(this.options.disjunctiveFacets[a]));var b=this;this.client.sendQueriesBatch(function(a,c){if(!a)return b.searchCallback(!1,c),void 0;var d=c.results[0];d.disjunctiveFacets={},d.facetStats={};for(var e=1;e<c.results.length;++e){for(var f in c.results[e].facets)if(d.disjunctiveFacets[f]=c.results[e].facets[f],b.disjunctiveRefinements[f])for(var g in b.disjunctiveRefinements[f])!d.disjunctiveFacets[f][g]&&b.disjunctiveRefinements[f][g]&&(d.disjunctiveFacets[f][g]=0);for(var h in c.results[e].facets_stats)d.facetStats[h]=c.results[e].facets_stats[h]}b.searchCallback(!0,d)})},_getHitsSearchParams:function(){return a({},{hitsPerPage:this.options.hitsPerPage,page:this.page,facets:this.options.facets,facetFilters:this._getFacetFilters()},this.searchParams)},_getDisjunctiveFacetSearchParams:function(b){return a({},this.searchParams,{hitsPerPage:1,page:0,facets:b,facetFilters:this._getFacetFilters(b)})},_getFacetFilters:function(a){var b=[];for(var c in this.refinements)this.refinements[c]&&b.push(c);for(var d in this.disjunctiveRefinements)if(d!=a){var e=[];for(var f in this.disjunctiveRefinements[d])this.disjunctiveRefinements[d][f]&&e.push(d+":"+f);e.length>0&&b.push(e)}return b}}}(),function(){window.AlgoliaPlaces=function(a,b){this.init(a,b)},AlgoliaPlaces.prototype={init:function(a,b){this.client=new AlgoliaSearch(a,b,"http",!0,["places-1.algolia.io","places-2.algolia.io","places-3.algolia.io"]),this.cache={}},search:function(a,b,c){var d="query="+encodeURIComponent(a);this.client._isUndefined(c)||null==c||(d=this.client._getSearchParams(c,d)),this.client._jsonRequest({cache:this.cache,method:"GET",url:"/1/places?"+d,callback:b})}}}(),"object"!=typeof JSON&&(JSON={}),function(){"use strict";function f(a){return 10>a?"0"+a:a}function quote(a){return escapable.lastIndex=0,escapable.test(a)?'"'+a.replace(escapable,function(a){var b=meta[a];return"string"==typeof b?b:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}function str(a,b){var c,d,e,f,g,h=gap,i=b[a];switch(i&&"object"==typeof i&&"function"==typeof i.toJSON&&(i=i.toJSON(a)),"function"==typeof rep&&(i=rep.call(b,a,i)),typeof i){case"string":return quote(i);case"number":return isFinite(i)?String(i):"null";case"boolean":case"null":return String(i);case"object":if(!i)return"null";if(gap+=indent,g=[],"[object Array]"===Object.prototype.toString.apply(i)){for(f=i.length,c=0;f>c;c+=1)g[c]=str(c,i)||"null";return e=0===g.length?"[]":gap?"[\n"+gap+g.join(",\n"+gap)+"\n"+h+"]":"["+g.join(",")+"]",gap=h,e}if(rep&&"object"==typeof rep)for(f=rep.length,c=0;f>c;c+=1)"string"==typeof rep[c]&&(d=rep[c],e=str(d,i),e&&g.push(quote(d)+(gap?": ":":")+e));else for(d in i)Object.prototype.hasOwnProperty.call(i,d)&&(e=str(d,i),e&&g.push(quote(d)+(gap?": ":":")+e));return e=0===g.length?"{}":gap?"{\n"+gap+g.join(",\n"+gap)+"\n"+h+"}":"{"+g.join(",")+"}",gap=h,e}}"function"!=typeof Date.prototype.toJSON&&(Date.prototype.toJSON=function(){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z":null},String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(){return this.valueOf()});var cx,escapable,gap,indent,meta,rep;"function"!=typeof JSON.stringify&&(escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,meta={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},JSON.stringify=function(a,b,c){var d;if(gap="",indent="","number"==typeof c)for(d=0;c>d;d+=1)indent+=" ";else"string"==typeof c&&(indent=c);if(rep=b,b&&"function"!=typeof b&&("object"!=typeof b||"number"!=typeof b.length))throw new Error("JSON.stringify");return str("",{"":a})}),"function"!=typeof JSON.parse&&(cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,JSON.parse=function(text,reviver){function walk(a,b){var c,d,e=a[b];if(e&&"object"==typeof e)for(c in e)Object.prototype.hasOwnProperty.call(e,c)&&(d=walk(e,c),void 0!==d?e[c]=d:delete e[c]);return reviver.call(a,b,e)}var j;if(text=String(text),cx.lastIndex=0,cx.test(text)&&(text=text.replace(cx,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})),/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return j=eval("("+text+")"),"function"==typeof reviver?walk({"":j},""):j;throw new SyntaxError("JSON.parse")})}();
function AlgoliaExplainResults(a,b,c){function d(a,b){var c=[];if("object"==typeof a&&"matchedWords"in a&&"value"in a){for(var e=!1,f=0;f<a.matchedWords.length;++f){var g=a.matchedWords[f];g in b||(b[g]=1,e=!0)}e&&c.push(a.value)}else if("[object Array]"===Object.prototype.toString.call(a))for(var h=0;h<a.length;++h){var i=d(a[h],b);c=c.concat(i)}else if("object"==typeof a)for(var j in a)a.hasOwnProperty(j)&&(c=c.concat(d(a[j],b)));return c}function e(a,b,c){var f=a._highlightResult||a;if(-1===c.indexOf("."))return c in f?d(f[c],b):[];for(var g=c.split("."),h=f,i=0;i<g.length;++i){if("[object Array]"===Object.prototype.toString.call(h)){for(var j=[],k=0;k<h.length;++k)j=j.concat(e(h[k],b,g.slice(i).join(".")));return j}if(!(g[i]in h))return[];h=h[g[i]]}return d(h,b)}var f={},g={},h=e(a,g,b);if(f.title=h.length>0?h[0]:"",f.subtitles=[],"undefined"!=typeof c)for(var i=0;i<c.length;++i)for(var j=e(a,g,c[i]),k=0;k<j.length;++k)f.subtitles.push({attr:c[i],value:j[k]});return f}var ALGOLIA_VERSION="2.6.0",AlgoliaSearch=function(a,b,c,d,e){var f=this;this.applicationID=a,this.apiKey=b,this.hosts=[],this._isUndefined(e)&&(e=[a+"-1.algolia.io",a+"-2.algolia.io",a+"-3.algolia.io"]),this.hosts=[];for(var g=0;g<e.length;++g)Math.random()>.5&&this.hosts.reverse(),this._isUndefined(c)||null===c?this.hosts.push(("https:"==document.location.protocol?"https":"http")+"://"+e[g]):"https"===c||"HTTPS"===c?this.hosts.push("https://"+e[g]):this.hosts.push("http://"+e[g]);Math.random()>.5&&this.hosts.reverse(),this.requestTimeoutInMs=2e3,this.currentHostIndex=0,this.jsonp=null,this.jsonpWait=0,this._jsonRequest({method:"GET",url:"/1/isalive",callback:function(a){f.jsonp=!a},removeCustomHTTPHeaders:!0}),this.extraHeaders=[]};AlgoliaSearch.prototype={deleteIndex:function(a,b){this._jsonRequest({method:"DELETE",url:"/1/indexes/"+encodeURIComponent(a),callback:b})},moveIndex:function(a,b,c){var d={operation:"move",destination:b};this._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(a)+"/operation",body:d,callback:c})},copyIndex:function(a,b,c){var d={operation:"copy",destination:b};this._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(a)+"/operation",body:d,callback:c})},getLogs:function(a,b,c){this._isUndefined(b)&&(b=0),this._isUndefined(c)&&(c=10),this._jsonRequest({method:"GET",url:"/1/logs?offset="+b+"&length="+c,callback:a})},listIndexes:function(a,b){var c=b?"?page="+b:"";this._jsonRequest({method:"GET",url:"/1/indexes"+c,callback:a})},initIndex:function(a){return new this.Index(this,a)},listUserKeys:function(a){this._jsonRequest({method:"GET",url:"/1/keys",callback:a})},getUserKeyACL:function(a,b){this._jsonRequest({method:"GET",url:"/1/keys/"+a,callback:b})},deleteUserKey:function(a,b){this._jsonRequest({method:"DELETE",url:"/1/keys/"+a,callback:b})},addUserKey:function(a,b){var c={};c.acl=a,this._jsonRequest({method:"POST",url:"/1/keys",body:c,callback:b})},addUserKeyWithValidity:function(a,b,c,d,e){var f=this,g={};g.acl=a,g.validity=b,g.maxQueriesPerIPPerHour=c,g.maxHitsPerQuery=d,this._jsonRequest({method:"POST",url:"/1/indexes/"+f.indexName+"/keys",body:g,callback:e})},setSecurityTags:function(a){if("[object Array]"===Object.prototype.toString.call(a)){for(var b=[],c=0;c<a.length;++c)if("[object Array]"===Object.prototype.toString.call(a[c])){for(var d=[],e=0;e<a[c].length;++e)d.push(a[c][e]);b.push("("+d.join(",")+")")}else b.push(a[c]);a=b.join(",")}this.tagFilters=a},setUserToken:function(a){this.userToken=a},startQueriesBatch:function(){this.batch=[]},addQueryInBatch:function(a,b,c){var d="query="+encodeURIComponent(b);this._isUndefined(c)||null===c||(d=this._getSearchParams(c,d)),this.batch.push({indexName:a,params:d})},clearCache:function(){this.cache={}},sendQueriesBatch:function(a,b){var c=this,d={requests:[],apiKey:this.apiKey,appID:this.applicationID};this.userToken&&(d["X-Algolia-UserToken"]=this.userToken),this.tagFilters&&(d["X-Algolia-TagFilters"]=this.tagFilters);for(var e=0;e<c.batch.length;++e)d.requests.push(c.batch[e]);if(window.clearTimeout(c.onDelayTrigger),!this._isUndefined(b)&&null!==b&&b>0){var f=window.setTimeout(function(){c._sendQueriesBatch(d,a)},b);c.onDelayTrigger=f}else this._sendQueriesBatch(d,a)},setRequestTimeout:function(a){a&&(this.requestTimeoutInMs=parseInt(a,10))},Index:function(a,b){this.indexName=b,this.as=a,this.typeAheadArgs=null,this.typeAheadValueOption=null},setExtraHeader:function(a,b){this.extraHeaders.push({key:a,value:b})},_sendQueriesBatch:function(a,b){if(null===this.jsonp){var c=this;return this._waitReady(function(){c._sendQueriesBatch(a,b)}),void 0}if(this.jsonp){for(var d="",e=0;e<a.requests.length;++e){var f="/1/indexes/"+encodeURIComponent(a.requests[e].indexName)+"?"+a.requests[e].params;d+=e+"="+encodeURIComponent(f)+"&"}this._jsonRequest({cache:this.cache,method:"GET",jsonp:!0,url:"/1/indexes/*",body:{params:d},callback:b})}else this._jsonRequest({cache:this.cache,method:"POST",url:"/1/indexes/*/queries",body:a,callback:b,removeCustomHTTPHeaders:!0})},_jsonRequest:function(a){var b=0,c=this,d=a.callback,e=null,f=a.url;if(this._isUndefined(a.body)||(f=a.url+"_body_"+JSON.stringify(a.body)),!this._isUndefined(a.cache)&&(e=a.cache,!this._isUndefined(e[f])))return this._isUndefined(d)||setTimeout(function(){d(!0,e[f])},1),void 0;var g=function(){return b>=c.hosts.length?(console&&console.log("Cannot connect the Algolia's InstantSearch API. Please send an email to support@algolia.com to report the issue."),void 0):(a.callback=function(h,i,j,k){i||c._isUndefined(k)||console&&console.log("Error: "+k.message),i&&!c._isUndefined(a.cache)&&(e[f]=k),!i&&h&&c.currentHostIndex<=c.hosts.length?(c.currentHostIndex=++c.currentHostIndex%c.hosts.length,b+=1,console&&console.log("self.currentHostIndex",c.currentHostIndex,b),g()):c._isUndefined(d)||(b=0,d(i,k))},a.hostname=c.hosts[c.currentHostIndex],c._jsonRequestByHost(a),void 0)};g()},_jsonRequestByHost:function(a){var b=a.hostname+a.url;this.jsonp?this._makeJsonpRequestByHost(b,a):this._makeXmlHttpRequestByHost(b,a)},_makeJsonpRequestByHost:function(a,b){if(!b.jsonp)return b.callback(!0,!1,null,{message:"Method "+b.method+" "+a+" is not supported by JSONP."}),void 0;this.jsonpCounter=this.jsonpCounter||0,this.jsonpCounter+=1;var c=document.getElementsByTagName("head")[0],d=document.createElement("script"),e="algoliaJSONP_"+this.jsonpCounter,f=!1,g=null;window[e]=function(a){b.callback(!1,!0,null,a);try{delete window[e]}catch(c){window[e]=void 0}},d.type="text/javascript",d.src=a+"?callback="+e+","+this.applicationID+","+this.apiKey,b["X-Algolia-TagFilters"]&&(d.src+="&X-Algolia-TagFilters="+b["X-Algolia-TagFilters"]),b["X-Algolia-UserToken"]&&(d.src+="&X-Algolia-UserToken="+b["X-Algolia-UserToken"]),b.body&&b.body.params&&(d.src+="&"+b.body.params),g=setTimeout(function(){d.onload=d.onreadystatechange=d.onerror=null,window[e]=function(){try{delete window[e]}catch(a){window[e]=void 0}},b.callback(!0,!1,null,{message:"Timeout - Failed to load JSONP script."}),c.removeChild(d),clearTimeout(g),g=null},this.requestTimeoutInMs),d.onload=d.onreadystatechange=function(){if(clearTimeout(g),g=null,!(f||this.readyState&&"loaded"!=this.readyState&&"complete"!=this.readyState)){if(f=!0,"undefined"==typeof window[e+"_loaded"]){b.callback(!0,!1,null,{message:"Failed to load JSONP script."});try{delete window[e]}catch(a){window[e]=void 0}}else try{delete window[e+"_loaded"]}catch(a){window[e+"_loaded"]=void 0}d.onload=d.onreadystatechange=null,c.removeChild(d)}},d.onerror=function(){clearTimeout(g),g=null,b.callback(!0,!1,null,{message:"Failed to load JSONP script."}),c.removeChild(d);try{delete window[e]}catch(a){window[e]=void 0}},c.appendChild(d)},_makeXmlHttpRequestByHost:function(a,b){var c=this,d=window.XMLHttpRequest?new XMLHttpRequest:{},e=null,f=null;if(this._isUndefined(b.body)||(e=JSON.stringify(b.body)),"withCredentials"in d){d.open(b.method,a,!0),(this._isUndefined(b.removeCustomHTTPHeaders)||!b.removeCustomHTTPHeaders)&&(d.setRequestHeader("X-Algolia-API-Key",this.apiKey),d.setRequestHeader("X-Algolia-Application-Id",this.applicationID)),d.timeout=this.requestTimeoutInMs;for(var g=0;g<this.extraHeaders.length;++g)d.setRequestHeader(this.extraHeaders[g].key,this.extraHeaders[g].value);null!==e&&d.setRequestHeader("Content-type","application/json")}else{if("undefined"==typeof XDomainRequest)return console&&console.log("Your browser is too old to support CORS requests"),b.callback(!1,!1,null,{message:"CORS not supported"}),void 0;d=new XDomainRequest,d.open(b.method,a)}f=setTimeout(function(){return d.abort(),d.aborted===!0?(stopLoadAnimation(),void 0):(b.callback(!0,!1,null,{message:"Timeout - Could not connect to endpoint "+a}),clearTimeout(f),f=null,void 0)},this.requestTimeoutInMs),d.onload=function(a){if(clearTimeout(f),f=null,c._isUndefined(a)||null===a.target)b.callback(!1,!0,a,JSON.parse(d.responseText));else{var e=0===a.target.status||503===a.target.status,g=200===a.target.status||201===a.target.status;b.callback(e,g,a.target,null!==a.target.response?JSON.parse(a.target.response):null)}},d.ontimeout=function(){},d.onerror=function(a){clearTimeout(f),f=null,b.callback(!0,!1,null,{message:"Could not connect to host",error:a})},d.send(e)},_waitReady:function(a){null===this.jsonp&&(this.jsonpWait+=100,this.jsonpWait>2e3&&(this.jsonp=!0),setTimeout(a,100))},_getSearchParams:function(a,b){if(this._isUndefined(a)||null===a)return b;for(var c in a)null!==c&&a.hasOwnProperty(c)&&(b+=0===b.length?"?":"&",b+=c+"="+encodeURIComponent("[object Array]"===Object.prototype.toString.call(a[c])?JSON.stringify(a[c]):a[c]));return b},_isUndefined:function(a){return void 0===a},applicationID:null,apiKey:null,tagFilters:null,userToken:null,hosts:[],cache:{},extraHeaders:[]},AlgoliaSearch.prototype.Index.prototype={clearCache:function(){this.cache={}},addObject:function(a,b,c){var d=this;this.as._isUndefined(c)?this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(d.indexName),body:a,callback:b}):this.as._jsonRequest({method:"PUT",url:"/1/indexes/"+encodeURIComponent(d.indexName)+"/"+encodeURIComponent(c),body:a,callback:b})},addObjects:function(a,b){for(var c=this,d={requests:[]},e=0;e<a.length;++e){var f={action:"addObject",body:a[e]};d.requests.push(f)}this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(c.indexName)+"/batch",body:d,callback:b})},getObject:function(a,b,c){if(null===this.as.jsonp){var d=this;return this.as._waitReady(function(){d.getObject(a,b,c)}),void 0}var e=this,f="";if(!this.as._isUndefined(c)){f="?attributes=";for(var g=0;g<c.length;++g)0!==g&&(f+=","),f+=c[g]}this.as._jsonRequest({method:"GET",jsonp:!0,url:"/1/indexes/"+encodeURIComponent(e.indexName)+"/"+encodeURIComponent(a)+f,callback:b})},partialUpdateObject:function(a,b){var c=this;this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(c.indexName)+"/"+encodeURIComponent(a.objectID)+"/partial",body:a,callback:b})},partialUpdateObjects:function(a,b){for(var c=this,d={requests:[]},e=0;e<a.length;++e){var f={action:"partialUpdateObject",objectID:a[e].objectID,body:a[e]};d.requests.push(f)}this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(c.indexName)+"/batch",body:d,callback:b})},saveObject:function(a,b){var c=this;this.as._jsonRequest({method:"PUT",url:"/1/indexes/"+encodeURIComponent(c.indexName)+"/"+encodeURIComponent(a.objectID),body:a,callback:b})},saveObjects:function(a,b){for(var c=this,d={requests:[]},e=0;e<a.length;++e){var f={action:"updateObject",objectID:a[e].objectID,body:a[e]};d.requests.push(f)}this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(c.indexName)+"/batch",body:d,callback:b})},deleteObject:function(a,b){if(null===a||0===a.length)return b(!1,{message:"empty objectID"}),void 0;var c=this;this.as._jsonRequest({method:"DELETE",url:"/1/indexes/"+encodeURIComponent(c.indexName)+"/"+encodeURIComponent(a),callback:b})},search:function(a,b,c,d){var e=this,f="query="+encodeURIComponent(a);if(this.as._isUndefined(c)||null===c||(f=this.as._getSearchParams(c,f)),window.clearTimeout(e.onDelayTrigger),!this.as._isUndefined(d)&&null!==d&&d>0){var g=window.setTimeout(function(){e._search(f,b)},d);e.onDelayTrigger=g}else this._search(f,b)},browse:function(a,b,c){var d=this,e="?page="+a;_.isUndefined(c)||(e+="&hitsPerPage="+c),this.as._jsonRequest({method:"GET",url:"/1/indexes/"+encodeURIComponent(d.indexName)+"/browse"+e,callback:b})},ttAdapter:function(a){var b=this;return function(c,d){b.search(c,function(a,b){a&&d(b.hits)},a)}},waitTask:function(a,b){var c=this;this.as._jsonRequest({method:"GET",url:"/1/indexes/"+encodeURIComponent(c.indexName)+"/task/"+a,callback:function(d,e){d?"published"===e.status?b(!0,e):setTimeout(function(){c.waitTask(a,b)},100):b(!1,e)}})},clearIndex:function(a){var b=this;this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(b.indexName)+"/clear",callback:a})},getSettings:function(a){var b=this;this.as._jsonRequest({method:"GET",url:"/1/indexes/"+encodeURIComponent(b.indexName)+"/settings",callback:a})},setSettings:function(a,b){var c=this;this.as._jsonRequest({method:"PUT",url:"/1/indexes/"+encodeURIComponent(c.indexName)+"/settings",body:a,callback:b})},listUserKeys:function(a){var b=this;this.as._jsonRequest({method:"GET",url:"/1/indexes/"+encodeURIComponent(b.indexName)+"/keys",callback:a})},getUserKeyACL:function(a,b){var c=this;this.as._jsonRequest({method:"GET",url:"/1/indexes/"+encodeURIComponent(c.indexName)+"/keys/"+a,callback:b})},deleteUserKey:function(a,b){var c=this;this.as._jsonRequest({method:"DELETE",url:"/1/indexes/"+encodeURIComponent(c.indexName)+"/keys/"+a,callback:b})},addUserKey:function(a,b){var c=this,d={};d.acl=a,this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(c.indexName)+"/keys",body:d,callback:b})},addUserKeyWithValidity:function(a,b,c,d,e){var f=this,g={};g.acl=a,g.validity=b,g.maxQueriesPerIPPerHour=c,g.maxHitsPerQuery=d,this.as._jsonRequest({method:"POST",url:"/1/indexes/"+encodeURIComponent(f.indexName)+"/keys",body:g,callback:e})},_search:function(a,b){if(null===this.as.jsonp){var c=this;return this.as._waitReady(function(){c._search(a,b)}),void 0}var d={params:a,apiKey:this.as.apiKey,appID:this.as.applicationID};this.as.tagFilters&&(d["X-Algolia-TagFilters"]=this.as.tagFilters),this.as.userToken&&(d["X-Algolia-UserToken"]=this.as.userToken),this.as.jsonp?this.as._jsonRequest({cache:this.cache,method:"GET",jsonp:!0,url:"/1/indexes/"+encodeURIComponent(this.indexName),body:d,callback:b}):this.as._jsonRequest({cache:this.cache,method:"POST",url:"/1/indexes/"+encodeURIComponent(this.indexName)+"/query",body:d,callback:b,removeCustomHTTPHeaders:!0})},as:null,indexName:null,cache:{},typeAheadArgs:null,typeAheadValueOption:null,emptyConstructor:function(){}},function(){var a=function(a){a=a||{};for(var b=1;b<arguments.length;b++)if(arguments[b])for(var c in arguments[b])arguments[b].hasOwnProperty(c)&&(a[c]=arguments[b][c]);return a};window.AlgoliaSearchHelper=function(b,c,d){var e={facets:[],disjunctiveFacets:[],hitsPerPage:20};this.init(b,c,a({},e,d))},AlgoliaSearchHelper.prototype={init:function(a,b,c){this.client=a,this.index=b,this.options=c,this.page=0,this.refinements={},this.disjunctiveRefinements={}},search:function(a,b,c){this.q=a,this.searchCallback=b,this.searchParams=c||{},this.page=this.page||0,this.refinements=this.refinements||{},this.disjunctiveRefinements=this.disjunctiveRefinements||{},this._search()},clearRefinements:function(){this.disjunctiveRefinements={},this.refinements={}},addDisjunctiveRefine:function(a,b){this.disjunctiveRefinements=this.disjunctiveRefinements||{},this.disjunctiveRefinements[a]=this.disjunctiveRefinements[a]||{},this.disjunctiveRefinements[a][b]=!0},removeDisjunctiveRefine:function(a,b){this.disjunctiveRefinements=this.disjunctiveRefinements||{},this.disjunctiveRefinements[a]=this.disjunctiveRefinements[a]||{};try{delete this.disjunctiveRefinements[a][b]}catch(c){this.disjunctiveRefinements[a][b]=void 0}},addRefine:function(a,b){var c=a+":"+b;this.refinements=this.refinements||{},this.refinements[c]=!0},removeRefine:function(a,b){var c=a+":"+b;this.refinements=this.refinements||{},this.refinements[c]=!1},toggleRefine:function(a,b){for(var c=0;c<this.options.facets.length;++c)if(this.options.facets[c]==a){var d=a+":"+b;return this.refinements[d]=!this.refinements[d],this.page=0,this._search(),!0}this.disjunctiveRefinements[a]=this.disjunctiveRefinements[a]||{};for(var e=0;e<this.options.disjunctiveFacets.length;++e)if(this.options.disjunctiveFacets[e]==a)return this.disjunctiveRefinements[a][b]=!this.disjunctiveRefinements[a][b],this.page=0,this._search(),!0;return!1},isRefined:function(a,b){var c=a+":"+b;return this.refinements[c]?!0:this.disjunctiveRefinements[a]&&this.disjunctiveRefinements[a][b]?!0:!1},nextPage:function(){this._gotoPage(this.page+1)},previousPage:function(){this.page>0&&this._gotoPage(this.page-1)},gotoPage:function(a){this._gotoPage(a)},setPage:function(a){this.page=a},setIndex:function(a){this.index=a},getIndex:function(){return this.index},_gotoPage:function(a){this.page=a,this._search()},_search:function(){this.client.startQueriesBatch(),this.client.addQueryInBatch(this.index,this.q,this._getHitsSearchParams());for(var a=0;a<this.options.disjunctiveFacets.length;++a)this.client.addQueryInBatch(this.index,this.q,this._getDisjunctiveFacetSearchParams(this.options.disjunctiveFacets[a]));var b=this;this.client.sendQueriesBatch(function(a,c){if(!a)return b.searchCallback(!1,c),void 0;var d=c.results[0];d.disjunctiveFacets={},d.facetStats={};for(var e=1;e<c.results.length;++e){for(var f in c.results[e].facets)if(d.disjunctiveFacets[f]=c.results[e].facets[f],b.disjunctiveRefinements[f])for(var g in b.disjunctiveRefinements[f])!d.disjunctiveFacets[f][g]&&b.disjunctiveRefinements[f][g]&&(d.disjunctiveFacets[f][g]=0);for(var h in c.results[e].facets_stats)d.facetStats[h]=c.results[e].facets_stats[h]}b.searchCallback(!0,d)})},_getHitsSearchParams:function(){return a({},{hitsPerPage:this.options.hitsPerPage,page:this.page,facets:this.options.facets,facetFilters:this._getFacetFilters()},this.searchParams)},_getDisjunctiveFacetSearchParams:function(b){return a({},this.searchParams,{hitsPerPage:1,page:0,facets:b,facetFilters:this._getFacetFilters(b)})},_getFacetFilters:function(a){var b=[];for(var c in this.refinements)this.refinements[c]&&b.push(c);for(var d in this.disjunctiveRefinements)if(d!=a){var e=[];for(var f in this.disjunctiveRefinements[d])this.disjunctiveRefinements[d][f]&&e.push(d+":"+f);e.length>0&&b.push(e)}return b}}}(),function(){window.AlgoliaPlaces=function(a,b){this.init(a,b)},AlgoliaPlaces.prototype={init:function(a,b){this.client=new AlgoliaSearch(a,b,"http",!0,["places-1.algolia.io","places-2.algolia.io","places-3.algolia.io"]),this.cache={}},search:function(a,b,c){var d="query="+encodeURIComponent(a);this.client._isUndefined(c)||null==c||(d=this.client._getSearchParams(c,d));var e={params:d,apiKey:this.client.apiKey,appID:this.client.applicationID};this.client._jsonRequest({cache:this.cache,method:"POST",url:"/1/places/query",body:e,callback:b,removeCustomHTTPHeaders:!0})}}}(),"object"!=typeof JSON&&(JSON={}),function(){"use strict";function f(a){return 10>a?"0"+a:a}function quote(a){return escapable.lastIndex=0,escapable.test(a)?'"'+a.replace(escapable,function(a){var b=meta[a];return"string"==typeof b?b:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}function str(a,b){var c,d,e,f,g,h=gap,i=b[a];switch(i&&"object"==typeof i&&"function"==typeof i.toJSON&&(i=i.toJSON(a)),"function"==typeof rep&&(i=rep.call(b,a,i)),typeof i){case"string":return quote(i);case"number":return isFinite(i)?String(i):"null";case"boolean":case"null":return String(i);case"object":if(!i)return"null";if(gap+=indent,g=[],"[object Array]"===Object.prototype.toString.apply(i)){for(f=i.length,c=0;f>c;c+=1)g[c]=str(c,i)||"null";return e=0===g.length?"[]":gap?"[\n"+gap+g.join(",\n"+gap)+"\n"+h+"]":"["+g.join(",")+"]",gap=h,e}if(rep&&"object"==typeof rep)for(f=rep.length,c=0;f>c;c+=1)"string"==typeof rep[c]&&(d=rep[c],e=str(d,i),e&&g.push(quote(d)+(gap?": ":":")+e));else for(d in i)Object.prototype.hasOwnProperty.call(i,d)&&(e=str(d,i),e&&g.push(quote(d)+(gap?": ":":")+e));return e=0===g.length?"{}":gap?"{\n"+gap+g.join(",\n"+gap)+"\n"+h+"}":"{"+g.join(",")+"}",gap=h,e}}"function"!=typeof Date.prototype.toJSON&&(Date.prototype.toJSON=function(){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z":null},String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(){return this.valueOf()});var cx,escapable,gap,indent,meta,rep;"function"!=typeof JSON.stringify&&(escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,meta={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},JSON.stringify=function(a,b,c){var d;if(gap="",indent="","number"==typeof c)for(d=0;c>d;d+=1)indent+=" ";else"string"==typeof c&&(indent=c);if(rep=b,b&&"function"!=typeof b&&("object"!=typeof b||"number"!=typeof b.length))throw new Error("JSON.stringify");return str("",{"":a})}),"function"!=typeof JSON.parse&&(cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,JSON.parse=function(text,reviver){function walk(a,b){var c,d,e=a[b];if(e&&"object"==typeof e)for(c in e)Object.prototype.hasOwnProperty.call(e,c)&&(d=walk(e,c),void 0!==d?e[c]=d:delete e[c]);return reviver.call(a,b,e)}var j;if(text=String(text),cx.lastIndex=0,cx.test(text)&&(text=text.replace(cx,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})),/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return j=eval("("+text+")"),"function"==typeof reviver?walk({"":j},""):j;throw new SyntaxError("JSON.parse")})}();

@@ -7,3 +7,3 @@ var semver = require('semver'),

'src/algoliasearch.helper.js',
'src/algoliasearch.place.js',
'src/algoliasearch.places.js',
'vendor/json2.js'

@@ -10,0 +10,0 @@ ];

@@ -46,3 +46,3 @@ {

},
"version": "2.5.4"
"version": "2.6.0"
}

@@ -37,7 +37,10 @@ /*

this.apiKey = apiKey;
this.hosts = [];
if (this._isUndefined(hostsArray)) {
hostsArray = [applicationID + '-1.algolia.io',
applicationID + '-2.algolia.io',
applicationID + '-3.algolia.io'];
hostsArray = [
applicationID + '-1.algolia.io',
applicationID + '-2.algolia.io',
applicationID + '-3.algolia.io'
];
}

@@ -63,2 +66,4 @@ this.hosts = [];

// resolve DNS + check CORS support (JSONP fallback)
this.requestTimeoutInMs = 2000;
this.currentHostIndex = 0;
this.jsonp = null;

@@ -429,2 +434,15 @@ this.jsonpWait = 0;

},
/**
* Set the number of milliseconds a request can take before automatically being terminated.
*
* @param {Number} milliseconds
*/
setRequestTimeout: function(milliseconds)
{
if (milliseconds) {
this.requestTimeoutInMs = parseInt(milliseconds, 10);
}
},
/*

@@ -440,3 +458,8 @@ * Index class constructor.

},
/**
* Add an extra field to the HTTP request
*
* @param key the header field name
* @param value the header field value
*/
setExtraHeader: function(key, value) {

@@ -476,2 +499,3 @@ this.extraHeaders.push({ key: key, value: value});

_jsonRequest: function(opts) {
var successiveRetryCount = 0;
var self = this;

@@ -494,11 +518,5 @@ var callback = opts.callback;

var impl = function(position) {
var idx = 0;
if (!self._isUndefined(position)) {
idx = position;
}
if (self.hosts.length <= idx) {
if (!self._isUndefined(callback)) {
callback(false, { message: 'Cannot contact server'});
}
var impl = function() {
if (successiveRetryCount >= self.hosts.length) {
console && console.log('Cannot connect the Algolia\'s InstantSearch API. Please send an email to support@algolia.com to report the issue.');
return;

@@ -508,3 +526,3 @@ }

if (!success && !self._isUndefined(body)) {
if (window.console) { console.log('Error: ' + body.message); }
console && console.log('Error: ' + body.message);
}

@@ -514,6 +532,10 @@ if (success && !self._isUndefined(opts.cache)) {

}
if (!success && retry && (idx + 1) < self.hosts.length) {
impl(idx + 1);
if (!success && retry && self.currentHostIndex <= self.hosts.length) {
self.currentHostIndex = ++self.currentHostIndex % self.hosts.length;
successiveRetryCount += 1;
console && console.log('self.currentHostIndex', self.currentHostIndex, successiveRetryCount);
impl();
} else {
if (!self._isUndefined(callback)) {
successiveRetryCount = 0;
callback(success, body);

@@ -523,3 +545,3 @@ }

};
opts.hostname = self.hosts[idx];
opts.hostname = self.hosts[self.currentHostIndex];
self._jsonRequestByHost(opts);

@@ -535,89 +557,169 @@ };

if (this.jsonp) {
if (!opts.jsonp) {
opts.callback(true, false, null, { 'message': 'Method ' + opts.method + ' ' + url + ' is not supported by JSONP.' });
return;
}
this.jsonpCounter = this.jsonpCounter || 0;
this.jsonpCounter += 1;
var cb = 'algoliaJSONP_' + this.jsonpCounter;
this._makeJsonpRequestByHost(url, opts);
} else {
this._makeXmlHttpRequestByHost(url, opts);
}
},
/**
* Make a JSONP request
*
* @param url request url (includes endpoint and path)
* @param opts all request options
*/
_makeJsonpRequestByHost: function(url, opts) {
if (!opts.jsonp) {
opts.callback(true, false, null, { 'message': 'Method ' + opts.method + ' ' + url + ' is not supported by JSONP.' });
return;
}
this.jsonpCounter = this.jsonpCounter || 0;
this.jsonpCounter += 1;
var head = document.getElementsByTagName('head')[0];
var script = document.createElement('script');
var cb = 'algoliaJSONP_' + this.jsonpCounter;
var done = false;
var ontimeout = null;
window[cb] = function(data) {
opts.callback(false, true, null, data);
try { delete window[cb]; } catch (e) { window[cb] = undefined; }
};
script.type = 'text/javascript';
script.src = url + '?callback=' + cb + ',' + this.applicationID + ',' + this.apiKey;
if (opts['X-Algolia-TagFilters']) {
script.src += '&X-Algolia-TagFilters=' + opts['X-Algolia-TagFilters'];
}
if (opts['X-Algolia-UserToken']) {
script.src += '&X-Algolia-UserToken=' + opts['X-Algolia-UserToken'];
}
if (opts.body && opts.body.params) {
script.src += '&' + opts.body.params;
}
ontimeout = setTimeout(function() {
script.onload = script.onreadystatechange = script.onerror = null;
window[cb] = function(data) {
opts.callback(false, true, null, data);
try { delete window[cb]; } catch (e) { window[cb] = undefined; }
};
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = url + '?callback=' + cb + ',' + this.applicationID + ',' + this.apiKey;
if (opts['X-Algolia-TagFilters']) {
script.src += '&X-Algolia-TagFilters=' + opts['X-Algolia-TagFilters'];
opts.callback(true, false, null, { 'message': 'Timeout - Failed to load JSONP script.' });
head.removeChild(script);
clearTimeout(ontimeout);
ontimeout = null;
}, this.requestTimeoutInMs);
script.onload = script.onreadystatechange = function() {
clearTimeout(ontimeout);
ontimeout = null;
if (!done && (!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete')) {
done = true;
if (typeof window[cb + '_loaded'] === 'undefined') {
opts.callback(true, false, null, { 'message': 'Failed to load JSONP script.' });
try { delete window[cb]; } catch (e) { window[cb] = undefined; }
} else {
try { delete window[cb + '_loaded']; } catch (e) { window[cb + '_loaded'] = undefined; }
}
script.onload = script.onreadystatechange = null; // Handle memory leak in IE
head.removeChild(script);
}
if (opts['X-Algolia-UserToken']) {
script.src += '&X-Algolia-UserToken=' + opts['X-Algolia-UserToken'];
};
script.onerror = function() {
clearTimeout(ontimeout);
ontimeout = null;
opts.callback(true, false, null, { 'message': 'Failed to load JSONP script.' });
head.removeChild(script);
try { delete window[cb]; } catch (e) { window[cb] = undefined; }
};
head.appendChild(script);
},
/**
* Make a XmlHttpRequest
*
* @param url request url (includes endpoint and path)
* @param opts all request opts
*/
_makeXmlHttpRequestByHost: function(url, opts) {
var self = this;
var xmlHttp = window.XMLHttpRequest ? new XMLHttpRequest() : {};
var body = null;
var ontimeout = null;
if (!this._isUndefined(opts.body)) {
body = JSON.stringify(opts.body);
}
if ('withCredentials' in xmlHttp) {
xmlHttp.open(opts.method, url , true);
if (this._isUndefined(opts.removeCustomHTTPHeaders) || !opts.removeCustomHTTPHeaders) {
xmlHttp.setRequestHeader('X-Algolia-API-Key', this.apiKey);
xmlHttp.setRequestHeader('X-Algolia-Application-Id', this.applicationID);
}
if (opts.body && opts.body.params) {
script.src += '&' + opts.body.params;
xmlHttp.timeout = this.requestTimeoutInMs;
for (var i = 0; i < this.extraHeaders.length; ++i) {
xmlHttp.setRequestHeader(this.extraHeaders[i].key, this.extraHeaders[i].value);
}
var head = document.getElementsByTagName('head')[0];
script.onerror = function() {
opts.callback(true, false, null, { 'message': 'Failed to load JSONP script.' });
head.removeChild(script);
try { delete window[cb]; } catch (e) { window[cb] = undefined; }
};
var done = false;
script.onload = script.onreadystatechange = function() {
if (!done && (!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete')) {
done = true;
if (typeof window[cb + '_loaded'] === 'undefined') {
opts.callback(true, false, null, { 'message': 'Failed to load JSONP script.' });
try { delete window[cb]; } catch (e) { window[cb] = undefined; }
} else {
try { delete window[cb + '_loaded']; } catch (e) { window[cb + '_loaded'] = undefined; }
}
script.onload = script.onreadystatechange = null; // Handle memory leak in IE
head.removeChild(script);
}
};
head.appendChild(script);
if (body !== null) {
xmlHttp.setRequestHeader('Content-type', 'application/json');
}
} else if (typeof XDomainRequest != 'undefined') {
// Handle IE8/IE9
// XDomainRequest only exists in IE, and is IE's way of making CORS requests.
xmlHttp = new XDomainRequest();
xmlHttp.open(opts.method, url);
} else {
var body = null;
if (!this._isUndefined(opts.body)) {
body = JSON.stringify(opts.body);
// very old browser, not supported
console && console.log('Your browser is too old to support CORS requests');
opts.callback(false, false, null, { 'message': 'CORS not supported' });
return;
}
ontimeout = setTimeout(function() {
xmlHttp.abort();
// Prevent Internet Explorer 9, JScript Error c00c023f
if (xmlHttp.aborted === true) {
stopLoadAnimation();
return;
}
var xmlHttp = window.XMLHttpRequest ? new XMLHttpRequest() : {};
if ('withCredentials' in xmlHttp) {
xmlHttp.open(opts.method, url , true);
if (this._isUndefined(opts.removeCustomHTTPHeaders) || !opts.removeCustomHTTPHeaders) {
xmlHttp.setRequestHeader('X-Algolia-API-Key', this.apiKey);
xmlHttp.setRequestHeader('X-Algolia-Application-Id', this.applicationID);
}
for (var i = 0; i < this.extraHeaders.length; ++i) {
xmlHttp.setRequestHeader(this.extraHeaders[i].key, this.extraHeaders[i].value);
}
if (body !== null) {
xmlHttp.setRequestHeader('Content-type', 'application/json');
}
} else if (typeof XDomainRequest != 'undefined') {
// Handle IE8/IE9
// XDomainRequest only exists in IE, and is IE's way of making CORS requests.
xmlHttp = new XDomainRequest();
xmlHttp.open(opts.method, url);
opts.callback(true, false, null, { 'message': 'Timeout - Could not connect to endpoint ' + url } );
clearTimeout(ontimeout);
ontimeout = null;
}, this.requestTimeoutInMs);
xmlHttp.onload = function(event) {
clearTimeout(ontimeout);
ontimeout = null;
if (!self._isUndefined(event) && event.target !== null) {
var retry = (event.target.status === 0 || event.target.status === 503);
var success = (event.target.status === 200 || event.target.status === 201);
opts.callback(retry, success, event.target, event.target.response !== null ? JSON.parse(event.target.response) : null);
} else {
// very old browser, not supported
if (window.console) { console.log('Your browser is too old to support CORS requests'); }
opts.callback(false, false, null, { 'message': 'CORS not supported' });
return;
opts.callback(false, true, event, JSON.parse(xmlHttp.responseText));
}
xmlHttp.send(body);
xmlHttp.onload = function(event) {
if (!self._isUndefined(event) && event.target !== null) {
var retry = (event.target.status === 0 || event.target.status === 503);
var success = (event.target.status === 200 || event.target.status === 201);
opts.callback(retry, success, event.target, event.target.response !== null ? JSON.parse(event.target.response) : null);
} else {
opts.callback(false, true, event, JSON.parse(xmlHttp.responseText));
}
};
xmlHttp.onerror = function(event) {
opts.callback(true, false, null, { 'message': 'Could not connect to host', 'error': event } );
};
};
xmlHttp.ontimeout = function(event) { // stop the network call but rely on ontimeout to call opt.callback
}
xmlHttp.onerror = function(event) {
clearTimeout(ontimeout);
ontimeout = null;
opts.callback(true, false, null, { 'message': 'Could not connect to host', 'error': event } );
};
xmlHttp.send(body);
},

@@ -624,0 +726,0 @@

Sorry, the diff of this file is not supported yet

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc