*/(function(a){"use strict",Object.defineProperty(a,"ComplexQueries",{configurable:!1,enumerable:!1,writable:!1,value:{}}),Object.defineProperty(a.ComplexQueries,"parse",{configurable:!1,enumerable:!1,writable:!1,value:function(a){functiond(a){c+=a+"\n"}functione(a){varb=0,c=-1,d=0,e=0,f=a.offset+1;do{f--,b=0,c=-2,e=f;if(a.src.length<=e)return19;do{switch(b){case0:a.src.charCodeAt(f)>=0&&a.src.charCodeAt(f)<=8||a.src.charCodeAt(f)>=10&&a.src.charCodeAt(f)<=31||a.src.charCodeAt(f)==33||a.src.charCodeAt(f)>=35&&a.src.charCodeAt(f)<=39||a.src.charCodeAt(f)>=42&&a.src.charCodeAt(f)<=57||a.src.charCodeAt(f)==59||a.src.charCodeAt(f)>=63&&a.src.charCodeAt(f)<=64||a.src.charCodeAt(f)>=66&&a.src.charCodeAt(f)<=77||a.src.charCodeAt(f)>=80&&a.src.charCodeAt(f)<=254?b=1:a.src.charCodeAt(f)==9?b=2:a.src.charCodeAt(f)==40?b=3:a.src.charCodeAt(f)==41?b=4:a.src.charCodeAt(f)==60||a.src.charCodeAt(f)==62?b=5:a.src.charCodeAt(f)==34?b=11:a.src.charCodeAt(f)==79?b=12:a.src.charCodeAt(f)==32?b=13:a.src.charCodeAt(f)==61?b=14:a.src.charCodeAt(f)==65?b=18:a.src.charCodeAt(f)==78?b=19:b=-1;break;case1:a.src.charCodeAt(f)>=0&&a.src.charCodeAt(f)<=31||a.src.charCodeAt(f)==33||a.src.charCodeAt(f)>=35&&a.src.charCodeAt(f)<=39||a.src.charCodeAt(f)>=42&&a.src.charCodeAt(f)<=57||a.src.charCodeAt(f)>=59&&a.src.charCodeAt(f)<=254?b=1:a.src.charCodeAt(f)==58?b=6:b=-1,c=10,d=f;break;case2:a.src.charCodeAt(f)>=0&&a.src.charCodeAt(f)<=31||a.src.charCodeAt(f)==33||a.src.charCodeAt(f)>=35&&a.src.charCodeAt(f)<=39||a.src.charCodeAt(f)>=42&&a.src.charCodeAt(f)<=57||a.src.charCodeAt(f)>=59&&a.src.charCodeAt(f)<=254?b=1:a.src.charCodeAt(f)==58?b=6:b=-1,c=1,d=f;break;case3:b=-1,c=3,d=f;break;case4:b=-1,c=4,d=f;break;case5:a.src.charCodeAt(f)==61?b=14:b=-1,c=11,d=f;break;case6:b=-1,c=8,d=f;break;case7:b=-1,c=9,d=f;break;case8:a.src.charCodeAt(f)>=0&&a.src.charCodeAt(f)<=31||a.src.charCodeAt(f)==33||a.src.charCodeAt(f)>=35&&a.src.charCodeAt(f)<=39||a.src.charCodeAt(f)>=42&&a.src.charCodeAt(f)<=57||a.src.charCodeAt(f)>=59&&a.src.charCodeAt(f)<=254?b=1:a.src.charCodeAt(f)==58?b=6:b=-1,c=6,d=f;break;case9:a.src.charCodeAt(f)>=0&&a.src.charCodeAt(f)<=31||a.src.charCodeAt(f)==33||a.src.charCodeAt(f)>=35&&a.src.charCodeAt(f)<=39||a.src.charCodeAt(f)>=42&&a.src.charCodeAt(f)<=57||a.src.charCodeAt(f)>=59&&a.src.charCodeAt(f)<=254?b=1:a.src.charCodeAt(f)==58?b=6:b=-1,c=5,d=f;break;case10:a.src.charCodeAt(f)>=0&&a.src.charCodeAt(f)<=31||a.src.charCodeAt(f)==33||a.src.charCodeAt(f)>=35&&a.src.charCodeAt(f)<=39||a.src.charCodeAt(f)>=42&&a.src.charCodeAt(f)<=57||a.src.charCodeAt(f)>=59&&a.src.charCodeAt(f)<=254?b=1:a.src.charCodeAt(f)==58?b=6:b=-1,c=7,d=f;break;case11:a.src.charCodeAt(f)==34?b=7:a.src.charCodeAt(f)>=0&&a.src.charCodeAt(f)<=33||a.src.charCodeAt(f)>=35&&a.src.charCodeAt(f)<=91||a.src.charCodeAt(f)>=93&&a.src.charCodeAt(f)<=254?b=11:a.src.charCodeAt(f)==92?b=15:b=-1;break;case12:a.src.charCodeAt(f)>=0&&a.src.charCodeAt(f)<=31||a.src.charCodeAt(f)==33||a.src.charCodeAt(f)>=35&&a.src.charCodeAt(f)<=39||a.src.charCodeAt(f)>=42&&a.src.charCodeAt(f)<=57||a.src.charCodeAt(f)>=59&&a.src.charCodeAt(f)<=81||a.src.charCodeAt(f)>=83&&a.src.charCodeAt(f)<=254?b=1:a.src.charCodeAt(f)==58?b=6:a.src.charCodeAt(f)==82?b=8:b=-1,c=10,d=f;break;case13:b=-1,c=1,d=f;break;case14:b=-1,c=11,d=f;break;case15:a.src.charCodeAt(f)>=0&&a.src.charCodeAt(f)<=254?b=11:b=-1;break;case16:a.src.charCodeAt(f)>=0&&a.src.charCodeAt(f)<=31||a.src.charCodeAt(f)==33||a.src.charCodeAt(f)>=35&&a.src.charCodeAt(f)<=39||a.src.charCodeAt(f)>=42&&a.src.charCodeAt(f)<=57||a.src.charCodeAt(f)>=59&&a.src.charCodeAt(f)<=67||a.src.charCodeAt(f)>=69&&a.src.charCodeAt(f)<=254?b=1:a.src.charCodeAt(f)==58?b=6:a.src.charCodeAt(f)==68?b=9:b=-1,c=10,d=f;break;case17:a.src.charCodeAt(f)>=0&&a.src.charCodeAt(f)<=31||a.src.charCodeAt(f)==33||a.src.charCodeAt(f)>=35&&a.src.charCodeAt(f)<=39||a.src.charCodeAt(f)>=42&&a.src.charCodeAt(f)<=57||a.src.charCodeAt(f)>=59&&a.src.charCodeAt(f)<=83||a.src.charCodeAt(f)>=85&&a.src.charCodeAt(f)<=254?b=1:a.src.charCodeAt(f)==58?b=6:a.src.charCodeAt(f)==84?b=10:b=-1,c=10,d=f;break;case18:a.src.charCodeAt(f)>=0&&a.src.charCodeAt(f)<=31||a.src.charCodeAt(f)==33||a.src.charCodeAt(f)>=35&&a.src.charCodeAt(f)<=39||a.src.charCodeAt(f)>=42&&a.src.charCodeAt(f)<=57||a.src.charCodeAt(f)>=59&&a.src.charCodeAt(f)<=77||a.src.charCodeAt(f)>=79&&a.src.charCodeAt(f)<=254?b=1:a.src.charCodeAt(f)==58?b=6:a.src.charCodeAt(f)==78?b=16:b=-1,c=10,d=f;break;case19:a.src.charCodeAt(f)>=0&&a.src.charCodeAt(f)<=31||a.src.charCodeAt(f)==33||a.src.charCodeAt(f)>=35&&a.src.charCodeAt(f)<=39||a.src.charCodeAt(f)>=42&&a.src.charCodeAt(f)<=57||a.src.charCodeAt(f)>=59&&a.src.charCodeAt(f)<=78||a.src.charCodeAt(f)>=80&&a.src.charCodeAt(f)<=254?b=1:a.src.charCodeAt(f)==58?b=6:a.src.charCodeAt(f)==79?b=17:b=-1,c=10,d=f}f++}while(b>-1)}while(c==1);returnc>-1?(a.att=a.src.substr(e,d-e),a.offset=d):(a.att=newString,c=-1),c}functionf(a,f,g){varl=newArray,m=newArray,n=0,p,q,r,s,t=newFunction("","var offset; var src; var att;"),u=newt,v=newArray(newArray(0,1),newArray(13,1),newArray(12,1),newArray(12,2),newArray(12,3),newArray(14,1),newArray(14,3),newArray(15,2),newArray(15,1),newArray(16,3),newArray(16,2),newArray(16,1),newArray(17,2),newArray(17,1),newArray(18,1),newArray(18,1)),w=newArray(newArray(7,5,3,7,8,8,11,10,10,12,9,13),newArray(19,0),newArray(19,-1),newArray(6,14,7,5,3,7,8,8,11,10,10,12,9,13,19,-2,4,-2),newArray(5,16,19,-5,7,-5,3,-5,8,-5,11,-5,10,-5,9,-5,6,-5,4,-5),newArray(3,7,8,8,11,10,10,12,9,13),newArray(19,-8,7,-8,3,-8,8,-8,11,-8,10,-8,9,-8,6,-8,5,-8,4,-8),newArray(7,5,3,7,8,8,11,10,10,12,9,13),newArray(3,7,8,8,11,10,10,12,9,13),newArray(19,-11,7,-11,3,-11,8,-11,11,-11,10,-11,9,-11,6,-11,5,-11,4,-11),newArray(10,12,9,13),newArray(19,-13,7,-13,3,-13,8,-13,11,-13,10,-13,9,-13,6,-13,5,-13,4,-13),newArray(19,-14,7,-14,3,-14,8,-14,11,-14,10,-14,9,-14,6,-14,5,-14,4,-14),newArray(19,-15,7,-15,3,-15,8,-15,11,-15,10,-15,9,-15,6,-15,5,-15,4,-15),newArray(7,5,3,7,8,8,11,10,10,12,9,13),newArray(19,-3,4,-3),newArray(7,5,3,7,8,8,11,10,10,12,9,13),newArray(19,-7,7,-7,3,-7,8,-7,11,-7,10,-7,9,-7,6,-7,5,-7,4,-7),newArray(4,23),newArray(19,-10,7,-10,3,-10,8,-10,11,-10,10,-10,9,-10,6,-10,5,-10,4,-10),newArray(19,-12,7,-12,3,-12,8,-12,11,-12,10,-12,9,-12,6,-12,5,-12,4,-12),newArray(19,-4,4,-4),newArray(19,-6,7,-6,3,-6,8,-6,11,-6,10,-6,9,-6,6,-6,4,-6),newArray(19,-9,7,-9,3,-9,8,-9,11,-9,10,-9,9,-9,6,-9,5,-9,4,-9)),x=newArray(newArray(13,1,12,2,14,3,15,4,16,6,17,9,18,11),newArray,newArray,newArray(12,15,14,3,15,4,16,6,17,9,18,11),newArray,newArray(16,17,17,9,18,11),newArray,newArray(12,18,14,3,15,4,16,6,17,9,18,11),newArray(16,19,17,9,18,11),newArray,newArray(18,20),newArray,newArray,newArray,newArray(12,21,14,3,15,4,16,6,17,9,18,11),newArray,newArray(14,22,15,4,16,6,17,9,18,11),newArray,newArray,newArray,newArray,newArray,newArray,newArray),y=newArray("begin'","WHITESPACE","WHITESPACE","LEFT_PARENTHESE","RIGHT_PARENTHESE","AND","OR","NOT","COLUMN","STRING","WORD","OPERATOR","search_text","begin","and_expression","boolean_expression","expression","value","string","$");u.offset=0,u.src=a,u.att=newString,f||(f=newArray),g||(g=newArray),l.push(0),m.push(0),r=e(u);for(;;){p=25;for(varz=0;z<w[l[l.length-1]].length;z+=2)if(w[l[l.length-1]][z]==r){p=w[l[l.length-1]][z+1];break}b&&l.length>0&&d("\nState "+l[l.length-1]+"\n"+"\tLookahead: "+y[r]+' ("'+u.att+'")\n'+"\tAction: "+p+"\n"+'\tSource: "'+u.src.substr(u.offset,30)+(u.offset+30<u.src.length?"...":"")+'"\n'+"\tStack: "+l.join()+"\n"+"\tValue stack: "+m.join()+"\n");if(p==25){b&&d("Error detected: There is no reduce or shift on the symbol "+y[r]),n++,f.push(u.offset-u.att.length),g.push(newArray);for(varz=0;z<w[l[l.length-1]].length;z+=2)g[g.length-1].push(y[w[l[l.length-1]][z]]);varA=newArray,B=newArray;for(varz=0;z<l.length;z++)A[z]=l[z],B[z]=m[z];while(p==25&&r!=19){b&&d("\tError recovery\nCurrent lookahead: "+y[r]+" ("+u.att+")\n"+"Action: "+p+"\n\n"),r==-1&&u.offset++;while(p==25&&l.length>0){l.pop(),m.pop();if(l.length==0)break;p=25;for(varz=0;z<w[l[l.length-1]].length;z+=2)if(w[l[l.length-1]][z]==r){p=w[l[l.length-1]][z+1];break}}if(p!=25)break;for(varz=0;z<A.length;z++)l.push(A[z]),m.push(B[z]);r=e(u)}if(p==25){b&&d("\tError recovery failed, terminating parse process...");break}b&&d("\tError recovery succeeded, continuing")}if(p>0)b&&d("Shifting symbol: "+y[r]+" ("+u.att+")"),l.push(p),m.push(u.att),r=e(u),b&&d("\tNew lookahead symbol: "+y[r]+" ("+u.att+")");else{p*=-1,b&&d("Reducing by producution: "+p),s=void0,b&&d("\tPerforming semantic action...");switch(p){case0:s=m[m.length-1];break;case1:o=m[m.length-1];break;case2:s=m[m.length-1];break;case3:s=j("OR",[m[m.length-2],m[m.length-1]]);break;case4:s=j("OR",[m[m.length-3],m[m.length-1]]);break;case5:s=m[m.length-1];break;case6:s=j("AND",[m[m.length-3],m[m.length-1]]);break;case7:s=i(m[m.length-1]);break;case8:s=m[m.length-1];break;case9:s=m[m.length-2];break;case10:k(m[m.length-1],m[m.length-2].split(":").slice(0,-1).join(":")),s=m[m.length-1];break;case11:s=m[m.length-1];break;case12:m[m.length-1].operator=m[m.length-2],s=m[m.length-1];break;case13:s=m[m.length-1];break;case14:s=h("",m[m.length-1]);break;case15:s=h("",m[m.length-1].split('"').slice(1,-1).join('"'))}b&&d("\tPopping "+v[p][1]+" off the stack...");for(varz=0;z<v[p][1];z++)l.pop(),m.pop();q=-1;for(varz=0;z<x[l[l.length-1]].length;z+=2)if(x[l[l.length-1]][z]==v[p][0]){q=x[l[l.length-1]][z+1];break}if(p==0)break;b&&d("\tPushing non-terminal "+y[v[p][0]]),l.push(q),m.push(s)}b&&(alert(c),c=newString)}returnb&&(d("\nParse complete."),alert(c)),n}varb=!1,c=newString,g=function(){vara,b,c=[],d=arguments;for(a=0;a<d.length;++a)for(b=0;b<d[a].length;++b)c.push(d[a][b]);returnc},h=function(a,b,c){return{type:"simple",operator:"=",id:a,value:b}},i=function(a){returna.operator==="NOT"?a.query_list[0]:{type:"complex",operator:"NOT",query_list:[a]}},j=function(a,b){varc,d=[];for(c=0;c<b.length;++c)b[c].operator===a?d=g(d,b[c].query_list):d.push(b[c]);return{type:"complex",operator:a,query_list:d}},k=function(a,b){varc;if(a.type==="complex"){for(c=0;c<a.query_list.length;++c)k(a.query_list[c],b);return!0}returna.type==="simple"&&!a.id?(a.id=b,!0):!1},l=[],m=[],n=0,o;if((n=f(a,l,m))>0){varp;for(p=0;p<n;++p)thrownewError('Parse error near "'+a.substr(l[p])+'", expecting "'+m[p].join()+'"')}returno}}),Object.defineProperty(a.ComplexQueries,"serialize",{configurable:!1,enumerable:!1,writable:!1,value:function(b){varc=[],d;if(b.type==="complex"){c.push("(");for(d=0;d<b.query_list.length;++d)c.push(a.ComplexQueries.serialize(b.query_list[d])),c.push(b.operator);returnc.length--,c.push(")"),c.join("")}returnb.type==="simple"?b.id+(b.id?": ":"")+b.operator+' "'+b.value+'"':b}}),Object.defineProperty(a.ComplexQueries,"query",{configurable:!1,enumerable:!1,writable:!1,value:function(b,c){vard=typeofb.wildcard_character=="string"?b.wildcard_character:"%",e={"=":function(a,b){returna=""+a,a.match(f(b,d))||!1},"!=":function(a,b){returna=""+a,!a.match(f(b,d))},"<":function(a,b){returna<b},"<=":function(a,b){returna<=b},">":function(a,b){returna>b},">=":function(a,b){returna>=b},AND:function(a,b){varc;for(c=0;c<b.length;++c)if(!h(a,b[c]))return!1;return!0},OR:function(a,b){varc;for(c=0;c<b.length;++c)if(h(a,b[c]))return!0;return!1},NOT:function(a,b){return!h(a,b[0])}},f=function(a){returng("^"+a.replace(newRegExp("([\\{\\}\\(\\)\\^\\$\\&\\.\\*\\?\\/\\+\\|\\[\\]\\-\\\\])".replace(d?"\\"+d:undefined,""),"g"),"\\$1")+"$",d||undefined,".*")},g=function(a,b,c){vard="",e=0;if(b===undefined)returna;for(;;){varf=a.indexOf(b,e);if(f===-1)break;for(;e<f;++e)d+=a[e];d+=c,e+=b.length}for(;e<a.length;++e)d+=a[e];returnd},h=function(a,b){varc;returnb.type==="complex"?e[b.operator](a,b.query_list):b.id?typeofa[b.id]!="undefined"?e[b.operator](a[b.id],b.value):!1:!0},i=function(a,b){varc;if(b.length===0)return;for(c=0;c<a.length;++c){vard={},e;for(e=0;e<b.length;++e)d[b[e]]=a[c][b[e]];a[c]=d}},j=function(a,b){returnb==="descending"?function(b,c){returnb[a]<c[a]?1:b[a]>c[a]?-1:0}:function(b,c){returnb[a]>c[a]?1:b[a]<c[a]?-1:0}},k=function(a,b,c){vard,e;for(d=c,e=0;d<b.length+c;++d,++e)a[d]=b[e]},l=function(a,b){varc,d,e,f,g=function(){l(d,b.slice(1)),k(a,d,c-d.length),d=[a[c]]};if(a.length<2)return;if(b.length===0)return;e=b[0][0],f=b[0][1],a.sort(j(e,f)),d=[a[0]];for(c=1;c<a.length;++c)d[0][e]===a[c][e]?d.push(a[c]):g();g()},m=function(a,b){varc;typeofb[0]!="undefined"&&(typeofb[1]!="undefined"?(a.length>b[1]+b[0]&&(a.length=b[1]+b[0]),a.splice(0,b[0])):a.length=b[0])},n=[],o=[],p;c=c||[];for(p=0;p<c.length;++p)h(c[p],a.ComplexQueries.parse(b.query))&&n.push(c[p]);returnb.filter&&(i(n,b.filter.select_list||[]),l(n,b.filter.sort_on||[]),m(n,b.filter.limit||[])),n}})})(jIO);