-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsolr-jsx.min.js
1 lines (1 loc) · 24.2 KB
/
solr-jsx.min.js
1
!function(u){Solr={version:"0.16.2",Management:function(e){u.extend(!0,this,u.common(e,this)),this.listeners={},this.response=null,this.error=null,this.pendingRequests=[],this.inRequest=!1,e&&e.username&&e.password&&(e=btoa(e.username+":"+e.password),this.ajaxSettings.headers={Authorization:"Basic "+e})}},Solr.Management.prototype={__expects:["prepareQuery","parseQuery"],connector:null,serverUrl:"",servlet:"select",onPrepare:null,onError:null,onSuccess:null,ajaxSettings:{async:!0,dataType:"json",method:"GET",processData:!1},doRequest:function(n,a){var i=this,t=null,s={};if(this.inRequest)this.pendingRequests.push(arguments);else{this.inRequest=!0,"function"==typeof n&&(a=n,n=i.servlet);var e=i.serverUrl+(n||i.servlet),s=u.extend(s,i.ajaxSettings,i.prepareQuery());if(0<e.indexOf("?")&&s.url&&s.url.startsWith("?")&&(s.url="&"+s.url.substr(1)),s.url=e+(s.url||""),"function"==typeof a||(u.each(i.listeners,function(e){!1===u.act(e,e.beforeRequest,s,i)&&(t=e)}),null===t))return s.error=function(t,e,r){"function"==typeof a?a(null,t):(u.each(i.listeners,function(e){u.act(e,e.afterFailure,t,s,i)}),u.act(i,i.onError,t,s))},s.success=function(e,t,r){i.response=i.parseQuery(e),"function"==typeof a?a(i.response,r):(u.each(i.listeners,function(e){u.act(e,e.afterRequest,i.response,s,r,i)}),u.act(i,i.parseResponse,i.response,n),u.act(i,i.onSuccess,i.response,r,s))},s.complete=function(){i.inRequest=!1,0<i.pendingRequests.length&&i.doRequest.apply(i,i.pendingRequests.shift())},u.broadcast(i,"onPrepare",s),u.act(i,i.onPrepare,s),i.connector.ajax(s);u.act(t,i.onError,null,"Request cancelled",t,i)}},init:function(){var t=this;u.pass(t,Solr.Management,"init"),u.each(this.listeners,function(e){u.act(e,e.init,t)})},addListeners:function(e){for(var t,r=e,n=0,a=(r=1<arguments.length?arguments:Array.isArray(e)?e:[e]).length;n<a;++n)t=r[n],this.listeners[t.id]=t;return this},removeListener:function(e){return"objcet"==typeof e&&(e=e.id),delete this.listeners[e],this},removeManyListeners:function(r){if("function"!=typeof r)throw{name:"Enumeration error",message:"Attempt to select-remove listeners with non-function 'selector': "+r};var n=this;return u.each(n.listeners,function(e,t){r(e,t,n)&&delete n.listeners[t]}),n},enumerateListeners:function(r,n){if("function"!=typeof r)throw{name:"Enumeration error",message:"Attempt to enumerate listeners with non-function 'selector': "+r};u.each(this.listeners,function(e,t){r.call(e,e,t,n)})},getListener:function(e){return this.listeners[e]}},Solr.escapeValue=function(e){return"string"!=typeof e&&(e=e.toString()),!e.match(/[ :\/"]/)||e.match(/[\[\{]\S+ TO \S+[\]\}]/)||e.match(/^["\(].*["\)]$/)?e:'"'+e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')+'"'},Solr.escapeField=function(e){return e.replace(/\s/g,"\\$&")},Solr.parseParameter=function(e){var t,r={},n=e.match(/^([^=]+)=(?:\{!([^\}]*)\})?(.*)$/);if(n){if(null!=n[2])for(;t=/([^\s=]+)=?(\S*)?/g.exec(n[2]);)r.domain===undefined&&(r.domain={}),null==t[2]?r.domain.type=t[1]:r.domain[t[1]]=t[2],n[2]=n[2].replace(t[0],"");r.name=n[1];e=n[3].split(",");r.value=1<e.length?e:n[3]}return r},Solr.Configuring=function(e){this.parameterHistory=[],u.extend(!0,this,u.common(e,this)),this.resetParameters(),this.mergeParameters(e&&e.parameters)};var e,t,i=function(e){return e.match(/^(?:bf|bq|facet\.date|facet\.date\.other|facet\.date\.include|facet\.field|facet\.pivot|facet\.range|facet\.range\.other|facet\.range\.include|facet\.query|fq|fl|json\.query|json\.filter|group\.field|group\.func|group\.query|pf|qf|stats\.field)$/)};Solr.Configuring.prototype={addParameter:function(t,e,r){var n;if("object"!=typeof t?(t={name:n=t,value:e},null!=r&&(t.domain=r)):n=t.name,i(n))if(this.parameterStore[n]===undefined)this.parameterStore[n]=[t];else{var a=!1;if(u.each(this.parameterStore[n],function(e){a=a||u.equal(!0,t,e)}),a)return!1;this.parameterStore[n].push(t)}else this.parameterStore[n]=t;return t},findParameters:function(e,r){var t,n=[];return this.parameterStore[e]!==undefined&&(t="function"==typeof r?function(e,t){r(e,t)&&n.push(t)}:null==r?function(e,t){n.push(t)}:(("object"!=typeof r||r instanceof RegExp||Array.isArray(r))&&(r={value:r}),function(e,t){u.similar(e,r)&&n.push(t)}),u.each(i(e)?this.parameterStore[e]:[this.parameterStore[e]],t)),n},removeParameters:function(e,t){if(this.parameterStore[e]===undefined)return!1;if("number"==typeof t?t=[t]:Array.isArray(t)||(t=this.findParameters(e,t)),i(e)&&t.length!=this.parameterStore[e].length){t.sort(function(e,t){return e<t?-1:t<e?1:0});for(var r=t.length-1;0<=r;--r)this.parameterStore[e].splice(t[r],1)}else delete this.parameterStore[e];return t.length},getParameter:function(e,t){var r=i(e);return this.parameterStore[e]===undefined?r&&null==t?[]:{name:e}:null!=t&&r?this.parameterStore[e][t]:this.parameterStore[e]},getAllValues:function(e){var t=null;return this.parameterStore[e]!==undefined&&(t=i(e)?this.parameterStore[e].map(function(e){return e.value}):this.parameterStore[e].value),t},exportParameters:function(e,t){var r={},n=this.parameterStore;return u.each(e,function(e){n[e]&&(r[e]="function"==typeof t?t(e,n[e]):n[e])}),r},importParameters:function(e){this.parameterStore=u.extend(this.parameterStore,e)},mergeParameters:function(e){var r=this;u.each(e,function(e,t){"string"==typeof e?r.addParameter(Solr.parseParameter(t+"="+e)):r.addParameter(t,e)})},enumerateParameters:function(t,r){"boolean"!=typeof t&&(r=t,t=!0),u.each(this.parameterStore,function(e){t&&Array.isArray(e)?u.each(e,r):e!==undefined&&r(e)})},resetParameters:function(){this.parameterStore={}},pushParameters:function(e){this.parameterHistory.push(this.parameterStore),this.parameterStore="object"==typeof e?e:!1===e?{}:u.extend(!0,{},this.parameterStore)},popParameters:function(){var e=this.parameterStore;return this.parameterStore=this.parameterHistory.pop(),e}},e=Solr,t=asSys,e.Compatibility=function(e){t.extend(!0,this,e),this.store.root=this},e.Compatibility.prototype={store:{addByValue:function(e,t,r){return this.root.addParameter(e,t,r)},removeByValue:function(e,t){return this.root.removeParameters(e,indices)},find:function(e,t){return this.root.findParameters(e,neddle)}}},Solr.stringifyDomain=function(e){var r=[];return u.each(e.domain,function(e,t){r.push(("type"!==t?t+"=":"")+e)}),0<r.length?"{!"+r.join(" ")+"}":""},Solr.stringifyValue=function(e){e=e.value||"";if(Array.isArray(e))return e.join(",");if("object"!=typeof e)return e.toString();var r=[];return u.each(e,function(e,t){r.push(Solr.escapeField(t)+":"+Solr.escapeValue(e))}),r.join(" ")},Solr.stringifyParameter=function(e){var t=Solr.stringifyDomain(e);return e.value||t?e.name+"="+encodeURIComponent(t+Solr.stringifyValue(e)):null},Solr.QueryingURL=function(e){},Solr.QueryingURL.prototype={__expects:["enumerateParameters"],prepareQuery:function(){var t=[];return this.enumerateParameters(function(e){e=Solr.stringifyParameter(e);null!=e&&t.push(e)}),{url:"?"+t.join("&")}},parseQuery:function(e){return e}};Solr.QueryingJson=function(e){this.useBody=!e||"false"!==e.useBody},Solr.QueryingJson.prototype={__expects:["enumerateParameters"],useBody:!0,prepareQuery:function(){var t=[],n={params:{}},a=function(e){if(!e.name.match(/^(json\.nl|json\.wrf|json2.+|q|wt|start)$/))return"string"==typeof e.value?Solr.stringifyDomain(e)+e.value:e.domain!==undefined?u.extend({},e.value,{domain:e.domain}):e.value;t.push(Solr.stringifyParameter(e))};return this.enumerateParameters(!1,function(e){var t=Array.isArray(e)?e.map(a):a(e),r=(Array.isArray(e)?e[0]:e).name,e=function(e){e=e.match(/^json(\.|$)(.*)/);return e&&e[2]}(r);t!=undefined&&(""===e?u.extend(n,t):null!==e?u.path(n,e,t):n.params[r]=t)}),n=JSON.stringify(n),this.useBody?{url:"?"+t.join("&"),data:n,contentType:"application/json",type:"POST",method:"POST"}:(t.push(encodeURIComponent(n)),{url:"?"+t.join("&")})},parseQuery:function(e){var t;return e.responseHeader.params&&null!=e.responseHeader.params.json&&(t=JSON.parse(e.responseHeader.params.json),u.extend(e.responseHeader.params,t,t.params),delete e.responseHeader.params.json),e}},Solr.UrlPersistency=function(e){u.extend(!0,this,u.common(e,this)),this.id=e.id},Solr.UrlPersistency.prototype={urlParam:"sel",storedParams:[],init:function(e){u.pass(this,Solr.UrlPersistency,"init",e),this.manager=e},restore:function(e){(e=e||this.getUrlParam(document.location.href,this.urlParam))&&this.manager.importParameters(e)},addUrlParam:function(e,t,r){r=JSON.stringify(r);var n=document.createElement("a"),r=r?t+"="+encodeURIComponent(r):"";if(n.href=e,t=(e=n.search).match(new RegExp(t+"=[\\S^&]+")))e=e.replace(t[0],r);else{if(!r)return;"?"==e.charAt(0)?e="?"+r:e+=("&"==e.slice(-1)?"":"&")+r}return n.search=e,n.href},getUrlParam:function(e,t){var o=document.createElement("a");o.href=e;t=function(){for(var e,t,r,n={},a=o.search.replace(/^\?/,"").split("&"),i=a.length,s=0;s<i;s++)a[s]&&(t=1<(e=a[s].split("=")).length?decodeURIComponent(e[1].replace(/\+/g," ")):"",e[0].indexOf("[]")==e[0].length-2?(r=n[e[0].slice(0,-2)])===undefined?n[e[0].slice(0,-2)]=[t]:r.push(t):n[e[0]]=t);return n}()[t];return t&&JSON.parse(t)},pushToHistory:function(e){return window.history.pushState(e,document.title,this.addUrlParam(window.location.href,this.urlParam,e))},afterRequest:function(){this.pushToHistory(this.manager.exportParameters(this.storedParams))}},Solr.Paging=function(e){u.extend(!0,this,u.common(e,this)),this.manager=null,this.currentPage=this.totalPages=this.totalEntries=null},Solr.Paging.prototype={pageSize:20,domain:null,init:function(e){this.manager=e,this.manager.addParameter("rows",this.pageSize)},setPage:function(e){return null!=this.totalPages&&("next"===e||">"===e?e=this.currentPage+1:"prev"===e||"previous"===e||"<"===e?e=this.currentPage-1:"first"===e||"start"===e?e=1:"last"===e||"end"===e?e=this.totalPages:"number"!=typeof e&&(e=parseInt(e)),!(e>this.totalPages||e<1||e===this.currentPage)&&(this.currentPage=e,this.manager.addParameter("start",(e-1)*this.pageSize,this.domain)))},page:function(e){return e!==undefined&&this.setPage(e),this.currentPage},previousPage:function(){return 1<this.currentPage?this.currentPage-1:null},nextPage:function(){return this.currentPage<this.totalPages?this.currentPage+1:null},afterRequest:function(){var e=parseInt(this.manager.response.responseHeader&&this.manager.response.responseHeader.params&&this.manager.response.responseHeader.params.start||this.manager.getParameter("start").value||0);this.pageSize=parseInt(this.manager.response.responseHeader&&this.manager.response.responseHeader.params&&this.manager.response.responseHeader.params.rows||this.manager.getParameter("rows").value||this.pageSize),this.totalEntries=parseInt(this.manager.response.response.numFound),this.currentPage=Math.floor(e/this.pageSize)+1,this.totalPages=Math.ceil(this.totalEntries/this.pageSize)},clickHandler:function(e){var t=this;return function(){return t.setPage(e)&&t.manager.doRequest(),!1}}},Solr.Requesting=function(e){u.extend(!0,this,u.common(e,this)),this.manager=null},Solr.Requesting.prototype={resetPage:!0,customResponse:null,init:function(e){u.pass(this,Solr.Requesting,"init",e),this.manager=e},doRequest:function(){this.resetPage&&this.manager.addParameter("start",0),this.manager.doRequest(self.customResponse)},updateHandler:function(){var t=this;return function(){var e=t.addValue.apply(t,arguments);return e&&t.doRequest(),e}},clickHandler:function(t,r,n,a){var i=this;return function(e){return i.addValue(t,r,n,a)&&i.doRequest(),!1}},unclickHandler:function(t,r,n,a){var i=this;return function(e){return i.removeValue(t,r,n,a)&&i.doRequest(),!1}}},Solr.Spying=function(e){u.extend(!0,this,u.common(e,this)),this.manager=null},Solr.Spying.prototype={servlet:null,init:function(e){u.pass(this,Solr.Spying,"init",e),this.manager=e},doSpying:function(e,t){var r=this.manager;r.pushParameters(!0),"function"==typeof e?e(r):u.each(e,function(e,t){null==e?r.removeParameters(t):Array.isArray(e)?u.each(e,function(e){r.addParameter(t,e)}):"object"==typeof e?r.addParameter(e):r.addParameter(t,e)}),r.doRequest(this.servlet,t||this.onSpyResponse),r.popParameters()}},Solr.Delaying=function(e){this.delayTimer=null,this.delayed=e&&e.delayed||this.delayed},Solr.Delaying.prototype={delayed:300,doRequest:function(){var e=this,t=function(){u.pass(e,Solr.Delaying,"doRequest"),e.delayTimer=null};if(null==this.delayed||this.delayed<10)return t();null!=this.delayTimer&&clearTimeout(this.delayTimer),this.delayTimer=setTimeout(t,this.delayed)}},Solr.Patterning=function(e){this.valuePattern=e&&e.valuePattern||this.valuePattern;e=this.fqRegExp.toString().replace(/^\/\^?|\$?\/$/g,""),e="^"+this.escapeRegExp(this.valuePattern.replace(/\{\{!?-\}\}/g,"-?").replace("{{v}}","__v__")).replace("__v__",e).replace("--?","-?").replace("--","");this.fqRegExp=new RegExp(e)},Solr.Patterning.prototype={valuePattern:"{{-}}{{v}}",escapeRegExp:function(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},fqValue:function(e,t){return this.valuePattern.replace("{{-}}",t?"-":"").replace("{{!-}}",t?"":"-").replace("{{v}}",u.pass(this,Solr.Patterning,"fqValue",e,t)).replace("--","")}},Solr.Texting=function(e){u.extend(!0,this,u.common(e,this)),this.manager=null},Solr.Texting.prototype={__expects:["doRequest"],domain:null,customResponse:null,escapeNeedle:!1,init:function(e){u.pass(this,Solr.Texting,"init",e),this.manager=e},addValue:function(e){var t=this.escapeNeedle&&e?e.replace(/\s+/g,"\\ "):e,e=this.manager.getParameter("q"),t=this.manager.addParameter("q",t,this.domain);return after=this.manager.getParameter("q"),t&&!u.equal(e,after)},clear:function(){return this.manager.removeParameters("q")},removeValue:function(){this.clear()},clickHandler:function(e){var t=this;return function(){return el=el||this,t.addValue("function"==typeof el.val?el.val():el.value)&&t.doRequest(),!1}}};var a={prefix:null,sort:null,limit:null,offset:null,mincount:null,missing:null,method:null,"enum.cache.minDf":null},s=/^\s*\(\s*|\s*\)\s*$/g,o=/^([^()]+)\(([^)]+)\)$/g;Solr.facetValue=function(e){return Array.isArray(e)?1==e.length?Solr.escapeValue(e[0]):"("+e.map(function(e){return Solr.escapeValue(e)}).join(" ")+")":Solr.escapeValue(e)},Solr.parseFacet=function(e){var t=e.length>(e=e.replace(s,"")).length,r=e.replace(/\\"/g,"%0022").match(/[^\s:\/"]+|"[^"]+"/g);if(!t&&1<r.length)return null;for(var n=0,a=r.length;n<a;++n)r[n]=r[n].replace(/^"|"$/g,"").replace("%0022",'"');return r},Solr.facetStats=function(r,a,e){r.addParameter("stats",!0);var i={};u.each(e,function(e,t){var r,n=e.match(o);n&&(r=n[2],e=n[1],(n=i[r])===undefined&&(i[r]=n={},n.tag=a),n[e]=!0,n.key=t)}),u.each(i,function(e,t){r.addParameter("stats.field",t,e)})},Solr.Faceting=function(e){this.id=this.field=null,u.extend(!0,this,u.common(e,this)),this.manager=null,this.multivalue||(this.aggregate=!1),this.jsonLocation||(this.jsonLocation="json.facet."+this.id),this.facet=e&&e.facet||{},this.fqRegExp=new RegExp("^-?"+Solr.escapeField(this.field).replace("\\","\\\\")+":([^]+)$")},Solr.Faceting.prototype={multivalue:!1,aggregate:!1,exclusion:!1,domain:null,nesting:null,useJson:!1,jsonLocation:null,statistics:null,init:function(e){u.pass(this,Solr.Faceting,"init",e),this.manager=e;var r,t,n=null;this.nesting&&(this.facet.domain=u.extend({blockChildren:this.nesting},this.facet.domain)),this.exclusion&&(this.domain=u.extend(this.domain,{tag:this.id+"_tag"}),n=this.id+"_tag"),this.useJson?(t={type:"terms",field:this.field,mincount:1},this.statistics&&(t.facet=this.statistics),null!=n&&(t.domain={excludeTags:n}),this.fqName="json.filter",this.manager.addParameter(this.jsonLocation,u.extend(!0,t,this.facet))):(r=this,e=u.extend(!0,{},a),t={key:this.id},null!=n&&(t.ex=n),this.fqName="fq",this.manager.addParameter("facet",!0),this.facet.date!==undefined?(this.manager.addParameter("facet.date",this.field,t),u.extend(e,{"date.start":null,"date.end":null,"date.gap":null,"date.hardend":null,"date.other":null,"date.include":null})):this.facet.range!==undefined?(this.manager.addParameter("facet.range",this.field,t),u.extend(e,{"range.start":null,"range.end":null,"range.gap":null,"range.hardend":null,"range.other":null,"range.include":null})):(this.facet.field=!0,this.statistics&&(t.stats=this.id+"_stats",Solr.facetStats(this.manager,t.stats,this.statistics)),this.manager.addParameter("facet.field",this.field,t)),e=u.common(this.facet,e),u.each(e,function(e,t){r.manager.addParameter("f."+Solr.escapeField(r.field)+".facet."+t,e)}))},addValue:function(e,t){if(this.multivalue||this.clearValues(),!this.aggregate||!(r=this.manager.findParameters(this.fqName,this.fqRegExp)).length)return this.manager.addParameter(this.fqName,this.fqValue(e,t),this.domain);var r=this.manager.getParameter(this.fqName,r[0]),n=this.fqParse(r.value),a=!1;Array.isArray(e)||(e=[e]);for(var i,s=0,o=e.length;s<o;++s)i=e[s],-1<n.indexOf(i)||(n.push(i),a=!0);return!!a&&(r.value=this.fqValue(n,t),!0)},removeValue:function(r){if(this.multivalue){var n=this,a=!1;return this.manager.removeParameters(this.fqName,function(e){if(!e.value.match(n.fqRegExp))return!1;if(!n.aggregate)return a=a||(t=0<=e.value.indexOf(Solr.facetValue(r))),t;Array.isArray(r)||(r=[r]);var t=n.fqParse(e.value).filter(function(e){return-1==r.indexOf(e)||!(a=!0)});return!t.length||(1==t.length&&(t=t[0]),e.value=n.fqValue(t),!1)}),a}return this.clearValues()},hasValue:function(e){for(var t,r=this.manager.findParameters(this.fqName,this.fqRegExp),n=0,a=r.length;n<a;++n)if(t=this.manager.getParameter(this.fqName,r[n]),-1<this.fqParse(t.value).indexOf(e))return!0;return!1},getValues:function(){for(var e,t=this.manager.findParameters(this.fqName,this.fqRegExp),r=[],n=0,a=t.length;n<a;++n)e=this.manager.getParameter(this.fqName,t[n]),Array.prototype.push.apply(r,v=this.fqParse(e.value));return r},clearValues:function(){return this.manager.removeParameters(this.fqName,this.fqRegExp)},getFacetCounts:function(e){var t;if(!0===this.useJson)return null==e&&(e=this.manager.response.facets),0<e.count?e[this.id].buckets:[];if(null==e&&(e=this.manager.response.facet_counts),this.facet.field!==undefined?t="facet_fields":this.facet.date!==undefined?t="facet_dates":this.facet.range!==undefined&&(t="facet_ranges"),t!==undefined)switch(this.manager.getParameter("json.nl").value){case"map":return this.getFacetCountsMap(e,t);case"arrarr":return this.getFacetCountsArrarr(e);default:return this.getFacetCountsFlat(e)}throw'Cannot get facet counts unless one of the following properties is set to "true" on widget "'+this.id+'": "facet.field", "facet.date", or "facet.range".'},getFacetCountsMap:function(e,t){var r,n=[];for(r in e[t][this.id])n.push({val:r,count:parseInt(e[t][this.id][r])});return n},getFacetCountsArrarr:function(e,t){for(var r=[],n=0,a=e[t][this.id].length;n<a;n++)r.push({val:e[t][this.id][n][0],count:parseInt(e[t][this.id][n][1])});return r},getFacetCountsFlat:function(e,t){for(var r=[],n=0,a=e[t][this.id].length;n<a;n+=2)r.push({val:e[t][this.id][n],count:parseInt(e[t][this.id][n+1])});return r},fqValue:function(e,t){return(t?"-":"")+Solr.escapeField(this.field)+":"+Solr.facetValue(e)},fqParse:function(e){e=e.match(this.fqRegExp);return null!=e?Solr.parseFacet(e[1]):null}},Solr.rangeValue=function(e){return Array.isArray(e)?"["+Solr.escapeValue(e[0]||"*")+" TO "+Solr.escapeValue(e[1]||"*")+"]":Solr.escapeValue(e)},Solr.parseRange=function(e){e=e.match(/(-?)([^\s:]+):\s*\[\s*([^\s]+)\s+TO\s+([^\s]+)\s*\]/);return e?{field:e[2],exclude:!!e[1],value:[e[3],e[4]]}:null},Solr.Ranging=function(e){this.field=this.id=null,u.extend(!0,this,u.common(e,this)),this.manager=null,this.fqRegExp=new RegExp("^-?"+Solr.escapeField(this.field).replace("\\","\\\\")+":\\s*\\[\\s*([^\\s])+\\s+TO\\s+([^\\s])+\\s*\\]"),this.fqName=this.useJson?"json.filter":"fq",this.exclusion&&(this.domain=u.extend(!0,this.domain,{tag:this.id+"_tag"}))},Solr.Ranging.prototype={multirange:!1,exclusion:!1,domain:null,useJson:!1,init:function(e){u.pass(this,Solr.Ranging,"init",e),this.manager=e},addValue:function(e,t){return this.clearValues(),this.manager.addParameter(this.fqName,this.fqValue(e,t),this.domain)},removeValue:function(e){return this.clearValues()},hasValue:function(e){return null!=this.manager.findParameters(this.fqName,this.fqRegExp)},clearValues:function(){return this.manager.removeParameters(this.fqName,this.fqRegExp)},fqValue:function(e,t){return(t?"-":"")+Solr.escapeField(this.field)+":"+Solr.rangeValue(e)},fqParse:function(e){e=e.match(this.fqRegExp);return e?(e.shift(),e):null}};var r=u(Solr.Faceting);Solr.Pivoting=function(e){u.extend(!0,this,u.common(e,this)),this.manager=null,this.faceters={},this.id=e.id,this.settings=e,this.rootId=null},Solr.Pivoting.prototype={pivot:null,useJson:!1,statistics:null,domain:null,addFaceter:function(e,t){return new r(e)},init:function(e){u.pass(this,Solr.Pivoting,"init",e),this.manager=e;var t,r=this.statistics;this.useJson||(t={},r&&(t.stats=this.id+"_stats",Solr.facetStats(this.manager,t.stats,r),r=null),this.exclusion&&(t.ex=this.id+"_tag"),this.manager.addParameter("facet.pivot",this.pivot.map(function(e){return"string"==typeof e?e:e.field}).join(","),t));for(var n="json",a=0,i=this.pivot.length;a<i;++a){var s=this.pivot[a],o=u.extend(!0,{},this.settings,"string"==typeof s?{id:s,field:s,disabled:!0}:s);n+=".facet."+o.id,this.useJson&&(o.jsonLocation=n),null==this.rootId&&(this.rootId=o.id),o.exclusion=!1,null==s.nesting&&0<a&&delete o.nesting,o.statistics=r,(this.faceters[o.id]=this.addFaceter(o,a)).init(e)}},getPivotEntry:function(e){e=this.pivot[e];return e===undefined?null:"object"==typeof e?e:{id:e,field:e}},getFaceterEntry:function(e){e=this.pivot[e];return this.faceters["string"==typeof e?e:e.id]},getPivotCounts:function(e){if(!0===this.useJson)return null==e&&(e=this.manager.response.facets),0<e.count?e[this.rootId].buckets:[];throw null==e&&(e=this.manager.response.pivot),{error:"Not supported for now!"}},addValue:function(e,t){e=this.parseValue(e);return this.faceters[e.id].addValue(e.value,t)},removeValue:function(e){e=this.parseValue(e);return this.faceters[e.id].removeValue(e.value)},clearValues:function(){u.each(this.faceters,function(e){e.clearValues()})},hasValue:function(e){e=this.parseValue(e);return null!=e.id&&this.faceters[e.id].hasValue(e.value)},parseValue:function(e){var t=e.match(/^(\w+):(.+)$/);return t&&this.faceters[t[1]]!==undefined?{value:t[2],id:t[1]}:{value:e}},fqParse:function(e){var t=this.parseValue(e),r=null;if(null!=t.id)r=this.faceters[t.id].fqParse(t.value);else for(var n in this.faceters)if(r=this.faceters[n].fqParse(t.value)){t.id=n;break}return Array.isArray(r)?r=r.map(function(e){return t.id+":"+e}):null!=r&&(r=t.id+":"+r),r}},Solr.Listing=function(e){u.extend(!0,this,u.common(e,this)),this.manager=null},Solr.Listing.prototype={nestingRules:null,nestingField:null,nestLevel:null,listingFields:["*"],init:function(t){var e,r,n;u.pass(this,Solr.Listing,"init",t),null!=this.nestLevel&&(r=(e=this.nestingRules[this.nestLevel]).field||this.nestingField,n=this.nestingRules[e.parent]&&this.nestingRules[e.parent].field||this.nestingField,t.addParameter("fl","[child parentFilter="+n+":"+e.parent+" childFilter="+r+":"+this.nestLevel+" limit="+e.limit+"]")),u.each(this.listingFields,function(e){t.addParameter("fl",e)})}};var n={facet:!0,rows:0,fl:"id","facet.limit":-1,"facet.mincount":1,echoParams:"none"};Solr.FacetListing=function(e){u.extend(!0,this,u.common(e,this)),this.id=e.id,this.parameters=u.extend(!0,{},n),this.facetPath=this.useJson?"facets":"facet_counts.facet_fields",this.useJson||(this.parameters["json.nl"]="map")},Solr.FacetListing.prototype={__expects:["addValue","doSpying","resetValue","onFound"],servlet:"select",urlFeed:null,useJson:!1,maxResults:30,activeFacets:null,init:function(e){u.pass(this,Solr.FacetListing,"init",e),this.manager=e,this.urlFeed&&(e=$.url().param(this.urlFeed),this.addValue(e),this.resetValue(e))},onChange:function(e){e="string"==typeof e?this.addValue(e):this.manager.getListener(e.id).addValue(e.value);return e&&this.manager.doRequest(),e},doRequest:function(t){var r=this;this.doSpying(function(e){e.removeParameters("fl"),e.mergeParameters(r.parameters),r.addValue(t||"")},function(e){r.onResponse(e)})},onResponse:function(e){var n=this,a=[];_.each(_.get(e,this.facetPath),function(e,r){a.length>=n.maxResults||"object"!=typeof e||n.activeFacets&&!1===n.activeFacets[r]||_.each(n.useJson?e.buckets:e,function(e,t){a.length>=n.maxResults||(n.useJson||(e={val:t,count:e}),a.push({id:r,value:e.val,label:(n.lookupMap[e.val]||e.val)+" ("+e.count+") - "+r}))})}),this.onFound(a)},afterRequest:function(){var e=this.manager.getParameter("q").value||"";this.resetValue("*:*"!=e&&0<e.length?e:"")}},"object"==typeof module&&module&&"object"==typeof module.exports?module.exports=Solr:(this.Solr=Solr,"function"==typeof define&&define.amd&&define(Solr))}(asSys);