Repository: AlaSQL/alasql (JavaScript)

Issue:
Converting the syntax tree back to SQL does not convert order by properly
When you convert the alasql AST back into SQL the ORDER BY columns lose their specified sort direction.  See linked jsfiddle: http://jsfiddle.net/nizzlenitz/p1s11tc0/


Discussion:
Does @agershun have a quick input on where to look for a solution?




Patch:
diff --git a/dist/alasql-worker.js b/dist/alasql-worker.js
old mode 100755
new mode 100644
index f8c983073d..bacf5a12fa
--- a/dist/alasql-worker.js
+++ b/dist/alasql-worker.js
@@ -1,7 +1,7 @@
-//! AlaSQL v0.4.4-develop-1566 | © 2014-2016 Andrey Gershun & Mathias Rangel Wulff | License: MIT
+//! AlaSQL v0.4.4-develop-1567 | © 2014-2016 Andrey Gershun & Mathias Rangel Wulff | License: MIT
 /*
 @module alasql
-@version 0.4.4-develop-1566
+@version 0.4.4-develop-1567
 
 AlaSQL - JavaScript SQL database
 © 2014-2016	Andrey Gershun & Mathias Rangel Wulff
diff --git a/dist/alasql-worker.min.js b/dist/alasql-worker.min.js
old mode 100755
new mode 100644
index bdb119276d..1c6cb2e6c6
--- a/dist/alasql-worker.min.js
+++ b/dist/alasql-worker.min.js
@@ -1,2 +1,2 @@
-//! AlaSQL v0.4.4-develop-1566 | © 2014-2016 Andrey Gershun & Mathias Rangel Wulff | License: MIT
+//! AlaSQL v0.4.4-develop-1567 | © 2014-2016 Andrey Gershun & Mathias Rangel Wulff | License: MIT
 !function(r,e){"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?module.exports=e():r.alasql=e()}(this,function(){function r(e,t,o){t=t||[],"function"==typeof t&&(scope=o,o=t,t=[]),"object"!=typeof t&&(t=[t]);var n=r.lastid++;r.buffer[n]=o,r.webworker.postMessage({id:n,sql:e,params:t})}if(r.options={},r.options.progress=function(){},isArray=function(r){return"[object Array]"===Object.prototype.toString.call(r)},r.promise=function(){throw new Error("Please include a Promise/A+ library")},"undefined"!=typeof Promise){var e=function(e,t,o,n){return new Promise(function(s,i){r(e,t,function(e,t){t?i(t):(o&&n&&!1!==r.options.progress&&r.options.progress(o,n),s(e))})})},t=function(r){if(!(r.length<1)){for(var t,o,n,s=[],i=0;i<r.length;i++){if(t=r[i],"string"==typeof t&&(t=[t]),!isArray(t)||t.length<1||2<t.length)throw new Error("Error in .promise parameter");o=t[0],n=t[1]||void 0,s.push(e(o,n,i,r.length))}return Promise.all(s)}};r.promise=function(r,o){if("undefined"==typeof Promise)throw new Error("Please include a Promise/A+ library");if("string"==typeof r)return e(r,o);if(!isArray(r)||r.length<1||void 0!==o)throw new Error("Error in .promise parameters");return t(r)}}if(!(r=r||!1))throw new Error("alasql was not found");return r.worker=function(){throw new Error("Can find webworker in this enviroment")},"undefined"!=typeof Worker&&(r.worker=function(e,t,o){if(!0===e&&(e=void 0),void 0===e)for(var n=document.getElementsByTagName("script"),s=0;s<n.length;s++){if("alasql-worker.js"===n[s].src.substr(-16).toLowerCase()){e=n[s].src.substr(0,n[s].src.length-16)+"alasql.js";break}if("alasql-worker.min.js"===n[s].src.substr(-20).toLowerCase()){e=n[s].src.substr(0,n[s].src.length-20)+"alasql.min.js";break}if("alasql.js"===n[s].src.substr(-9).toLowerCase()){e=n[s].src;break}if("alasql.min.js"===n[s].src.substr(-13).toLowerCase()){e=n[s].src.substr(0,n[s].src.length-13)+"alasql.min.js";break}}if(void 0===e)throw new Error("Path to alasql.js is not specified");if(!1!==e){var i="importScripts('";i+=e,i+="');self.onmessage = function(event) {alasql(event.data.sql,event.data.params, function(data){postMessage({id:event.data.id, data:data});});}";var a=new Blob([i],{type:"text/plain"});if(r.webworker=new Worker(URL.createObjectURL(a)),r.webworker.onmessage=function(e){var t=e.data.id;r.buffer[t](e.data.data),delete r.buffer[t]},r.webworker.onerror=function(r){throw r},arguments.length>1){r("REQUIRE "+t.map(function(r){return'"'+r+'"'}).join(","),[],o)}}else if(!1===e)return void delete r.webworker}),r.lastid=0,r.buffer={},r.worker(),r});
\ No newline at end of file
diff --git a/dist/alasql.fs.js b/dist/alasql.fs.js
index 24c1bbb820..2e37ed6296 100755
--- a/dist/alasql.fs.js
+++ b/dist/alasql.fs.js
@@ -1,7 +1,7 @@
-//! AlaSQL v0.4.4-develop-1566 | © 2014-2016 Andrey Gershun & Mathias Rangel Wulff | License: MIT
+//! AlaSQL v0.4.4-develop-1567 | © 2014-2016 Andrey Gershun & Mathias Rangel Wulff | License: MIT
 /*
 @module alasql
-@version 0.4.4-develop-1566
+@version 0.4.4-develop-1567
 
 AlaSQL - JavaScript SQL database
 © 2014-2016	Andrey Gershun & Mathias Rangel Wulff
@@ -137,7 +137,7 @@ var alasql = function(sql, params, cb, scope) {
 	Current version of alasql 
  	@constant {string} 
 */
-alasql.version = '0.4.4-develop-1566';
+alasql.version = '0.4.4-develop-1567';
 
 /**
 	Debug flag
@@ -10524,6 +10524,9 @@ yy.Expression.prototype.toString = function(dontas) {
 	if (this.nocase) {
 		s += ' COLLATE NOCASE';
 	}
+	if (this.direction) {
+		s += ' ' + this.direction;
+	}
 	return s;
 };
 
diff --git a/dist/alasql.js b/dist/alasql.js
index 36ea9262cb..436894df8b 100755
--- a/dist/alasql.js
+++ b/dist/alasql.js
@@ -1,7 +1,7 @@
-//! AlaSQL v0.4.4-develop-1566 | © 2014-2016 Andrey Gershun & Mathias Rangel Wulff | License: MIT
+//! AlaSQL v0.4.4-develop-1567 | © 2014-2016 Andrey Gershun & Mathias Rangel Wulff | License: MIT
 /*
 @module alasql
-@version 0.4.4-develop-1566
+@version 0.4.4-develop-1567
 
 AlaSQL - JavaScript SQL database
 © 2014-2016	Andrey Gershun & Mathias Rangel Wulff
@@ -137,7 +137,7 @@ var alasql = function(sql, params, cb, scope) {
 	Current version of alasql 
  	@constant {string} 
 */
-alasql.version = '0.4.4-develop-1566';
+alasql.version = '0.4.4-develop-1567';
 
 /**
 	Debug flag
@@ -10519,6 +10519,9 @@ yy.Expression.prototype.toString = function(dontas) {
 	if (this.nocase) {
 		s += ' COLLATE NOCASE';
 	}
+	if (this.direction) {
+		s += ' ' + this.direction;
+	}
 	return s;
 };
 
diff --git a/dist/alasql.min.js b/dist/alasql.min.js
index 2e11c3bb1e..7174d5cb32 100755
--- a/dist/alasql.min.js
+++ b/dist/alasql.min.js
@@ -1,5 +1,5 @@
-//! AlaSQL v0.4.4-develop-1566 | © 2014-2016 Andrey Gershun & Mathias Rangel Wulff | License: MIT
-!function(e,t){"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?module.exports=t():e.alasql=t()}(this,function(){function e(e){return"(y="+e+",y===y?y:undefined)"}function t(e,t){return"(y="+e+',typeof y=="undefined"?undefined:'+t+")"}function r(){return!0}function n(){}function a(){var e=navigator.userAgent.toLowerCase();return-1!==e.indexOf("msie")&&parseInt(e.split("msie")[1])}function i(e,t,r){function n(e,r,a){var o,u,c,l=e[r];if(l.selid){if("PATH"===l.selid){for(var h=[{node:a,stack:[]}],d={},f=A.databases[A.useid].objects;h.length>0;){var p=h.shift(),b=p.node,E=p.stack,c=n(l.args,0,b);if(c.length>0){if(r+1+1>e.length)return E;var g=[];return E&&E.length>0&&E.forEach(function(t){g=g.concat(n(e,r+1,t))}),g}void 0===d[b.$id]&&(d[b.$id]=!0,b.$out&&b.$out.length>0&&b.$out.forEach(function(e){var t=f[e],r=E.concat(t);r.push(f[t.$out[0]]),h.push({node:f[t.$out[0]],stack:r})}))}return[]}if("NOT"===l.selid){var u=n(l.args,0,a);return u.length>0?[]:r+1+1>e.length?[a]:n(e,r+1,a)}if("DISTINCT"===l.selid){var u;if(u=void 0===l.args||0===l.args.length?q(a):n(l.args,0,a),0===u.length)return[];var m=q(u);return r+1+1>e.length?m:n(e,r+1,m)}if("AND"===l.selid){var m=!0;return l.args.forEach(function(e){m=m&&n(e,0,a).length>0}),m?r+1+1>e.length?[a]:n(e,r+1,a):[]}if("OR"===l.selid){var m=!1;return l.args.forEach(function(e){m=m||n(e,0,a).length>0}),m?r+1+1>e.length?[a]:n(e,r+1,a):[]}if("ALL"===l.selid){var u=n(l.args[0],0,a);return 0===u.length?[]:r+1+1>e.length?u:n(e,r+1,u)}if("ANY"===l.selid){var u=n(l.args[0],0,a);return 0===u.length?[]:r+1+1>e.length?[u[0]]:n(e,r+1,[u[0]])}if("UNIONALL"===l.selid){var u=[];return l.args.forEach(function(e){u=u.concat(n(e,0,a))}),0===u.length?[]:r+1+1>e.length?u:n(e,r+1,u)}if("UNION"===l.selid){var u=[];l.args.forEach(function(e){u=u.concat(n(e,0,a))});var u=q(u);return 0===u.length?[]:r+1+1>e.length?u:n(e,r+1,u)}if("IF"===l.selid){var u=n(l.args,0,a);return 0===u.length?[]:r+1+1>e.length?[a]:n(e,r+1,a)}if("REPEAT"===l.selid){var v,S,T=l.args[0].value;S=l.args[1]?l.args[1].value:T,l.args[2]&&(v=l.args[2].variable);var y=[];if(0===T&&(r+1+1>e.length?y=[a]:(v&&(A.vars[v]=0),y=y.concat(n(e,r+1,a)))),S>0)for(var N=[{value:a,lvl:1}],C=0;N.length>0;){var u=N[0];if(N.shift(),u.lvl<=S){v&&(A.vars[v]=u.lvl);var R=n(l.sels,0,u.value);R.forEach(function(e){N.push({value:e,lvl:u.lvl+1})}),u.lvl>=T&&(r+1+1>e.length?y=y.concat(R):R.forEach(function(t){y=y.concat(n(e,r+1,t))}))}if(++C>1e5)throw new Error("Security brake. Number of iterations = "+C)}return y}if("OF"===l.selid){if(r+1+1>e.length)return[a];var O=[];return Object.keys(a).forEach(function(t){A.vars[l.args[0].variable]=t,O=O.concat(n(e,r+1,a[t]))}),O}if("TO"===l.selid){var w=A.vars[l.args[0]],I=[];if(I=void 0!==w?w.slice(0):[],I.push(a),r+1+1>e.length)return[a];A.vars[l.args[0]]=I;var O=n(e,r+1,a);return A.vars[l.args[0]]=w,O}if("ARRAY"===l.selid){var u=n(l.args,0,a);return u.length>0?(o=u,r+1+1>e.length?[o]:n(e,r+1,o)):[]}if("SUM"===l.selid){var u=n(l.args,0,a);if(!(u.length>0))return[];var o=u.reduce(function(e,t){return e+t},0);return r+1+1>e.length?[o]:n(e,r+1,o)}if("AVG"===l.selid)return u=n(l.args,0,a),u.length>0?(o=u.reduce(function(e,t){return e+t},0)/u.length,r+1+1>e.length?[o]:n(e,r+1,o)):[];if("COUNT"===l.selid)return u=n(l.args,0,a),u.length>0?(o=u.length,r+1+1>e.length?[o]:n(e,r+1,o)):[];if("FIRST"===l.selid)return u=n(l.args,0,a),u.length>0?(o=u[0],r+1+1>e.length?[o]:n(e,r+1,o)):[];if("LAST"===l.selid)return u=n(l.args,0,a),u.length>0?(o=u[u.length-1],r+1+1>e.length?[o]:n(e,r+1,o)):[];if("MIN"===l.selid){if(u=n(l.args,0,a),0===u.length)return[];var o=u.reduce(function(e,t){return Math.min(e,t)},1/0);return r+1+1>e.length?[o]:n(e,r+1,o)}if("MAX"===l.selid){var u=n(l.args,0,a);if(0===u.length)return[];var o=u.reduce(function(e,t){return Math.max(e,t)},-1/0);return r+1+1>e.length?[o]:n(e,r+1,o)}if("PLUS"===l.selid){var y=[],N=n(l.args,0,a).slice();r+1+1>e.length?y=y.concat(N):N.forEach(function(t){y=y.concat(n(e,r+1,t))});for(var C=0;N.length>0;){var u=N.shift();if(u=n(l.args,0,u),N=N.concat(u),r+1+1>e.length?y=y.concat(u):u.forEach(function(t){var a=n(e,r+1,t);y=y.concat(a)}),++C>1e5)throw new Error("Security brake. Number of iterations = "+C)}return y}if("STAR"===l.selid){var y=[];y=n(e,r+1,a);var N=n(l.args,0,a).slice();r+1+1>e.length?y=y.concat(N):N.forEach(function(t){y=y.concat(n(e,r+1,t))});for(var C=0;N.length>0;){var u=N[0];if(N.shift(),u=n(l.args,0,u),N=N.concat(u),r+1+1<=e.length&&u.forEach(function(t){y=y.concat(n(e,r+1,t))}),++C>1e5)throw new Error("Loop brake. Number of iterations = "+C)}return y}if("QUESTION"===l.selid){var y=[];y=y.concat(n(e,r+1,a));var u=n(l.args,0,a);return r+1+1<=e.length&&u.forEach(function(t){y=y.concat(n(e,r+1,t))}),y}if("WITH"!==l.selid){if("ROOT"===l.selid)return r+1+1>e.length?[a]:n(e,r+1,s);throw new Error("Wrong selector "+l.selid)}var u=n(l.args,0,a);if(0===u.length)return[];var c={status:1,values:u}}else{if(!l.srchid)throw new Error("Selector not found");var c=A.srch[l.srchid.toUpperCase()](a,l.args,i,t)}void 0===c&&(c={status:1,values:[a]});var m=[];if(1===c.status){var x=c.values;if(r+1+1>e.length)m=x;else for(var C=0;C<c.values.length;C++)m=m.concat(n(e,r+1,x[C]))}return m}var a,s,i={},o=F(this.selectors);if(void 0!==o&&o.length>0&&(o&&o[0]&&"PROP"===o[0].srchid&&o[0].args&&o[0].args[0]&&("XML"===o[0].args[0].toUpperCase()?(i.mode="XML",o.shift()):"HTML"===o[0].args[0].toUpperCase()?(i.mode="HTML",o.shift()):"JSON"===o[0].args[0].toUpperCase()&&(i.mode="JSON",o.shift())),o.length>0&&"VALUE"===o[0].srchid&&(i.value=!0,o.shift())),this.from instanceof K.Column){var u=this.from.databaseid||e;s=A.databases[u].tables[this.from.columnid].data}else if(this.from instanceof K.FuncValue&&A.from[this.from.funcid.toUpperCase()]){var c=this.from.args.map(function(e){var r=e.toJS();return new Function("params,alasql","var y;return "+r).bind(this)(t,A)});s=A.from[this.from.funcid.toUpperCase()].apply(this,c)}else if(void 0===this.from)s=A.databases[e].objects;else{var l=new Function("params,alasql","var y;return "+this.from.toJS());s=l(t,A),"object"==typeof Mongo&&"object"!=typeof Mongo.Collection&&s instanceof Mongo.Collection&&(s=s.find().fetch())}if(a=void 0!==o&&o.length>0?n(o,0,s):s,this.into){var h,d;void 0!==this.into.args[0]&&(h=new Function("params,alasql","var y;return "+this.into.args[0].toJS())(t,A)),void 0!==this.into.args[1]&&(d=new Function("params,alasql","var y;return "+this.into.args[1].toJS())(t,A)),a=A.into[this.into.funcid.toUpperCase()](h,d,a,[],r)}else i.value&&a.length>0&&(a=a[0]),r&&(a=r(a));return a}function o(e,t,r,n,a){e.sources.length;e.sourceslen=e.sources.length;var s=e.sourceslen;e.query=e,e.A=n,e.B=a,e.cb=r,e.oldscope=t,e.queriesfn&&(e.sourceslen+=e.queriesfn.length,s+=e.queriesfn.length,e.queriesdata=[],e.queriesfn.forEach(function(t,r){t.query.params=e.params,u([],-r-1,e)}));var i;i=t?F(t):{},e.scope=i;var o;return e.sources.forEach(function(t,r){t.query=e;var n=t.datafn(e,e.params,u,r,A);void 0!==n&&((e.intofn||e.intoallfn)&&Array.isArray(n)&&(n=n.length),o=n),t.queriesdata=e.queriesdata}),0!=e.sources.length&&0!==s||(o=c(e)),o}function u(e,t,r){if(t>=0){var n=r.sources[t];n.data=e,"function"==typeof n.data&&(n.getfn=n.data,n.dontcache=n.getfn.dontcache,"OUTER"!=n.joinmode&&"RIGHT"!=n.joinmode&&"ANTI"!=n.joinmode||(n.dontcache=!1),n.data={})}else r.queriesdata[-t-1]=V(e);if(!(--r.sourceslen>0))return c(r)}function c(e){var t,r=e.scope;Z(e),e.data=[],e.xgroups={},e.groups=[];if(d(e,r,0),e.groupfn){if(e.data=[],0===e.groups.length){var n={};e.selectGroup.length>0&&e.selectGroup.forEach(function(e){"COUNT"==e.aggregatorid||"SUM"==e.aggregatorid?n[e.nick]=0:n[e.nick]=void 0}),e.groups=[n]}if(e.aggrKeys.length>0){var a="";e.aggrKeys.forEach(function(e){a+="g['"+e.nick+"']=alasql.aggr['"+e.funcid+"'](undefined,g['"+e.nick+"'],3);"});var s=new Function("g,params,alasql","var y;"+a)}for(var i=0,o=e.groups.length;i<o;i++){var n=e.groups[i];if(s&&s(n,e.params,A),!e.havingfn||e.havingfn(n,e.params,A)){var u=e.selectgfn(n,e.params,A);e.data.push(u)}}}if(h(e),e.unionallfn){var c,f;if(e.corresponding)e.unionallfn.query.modifier||(e.unionallfn.query.modifier=void 0),c=e.unionallfn(e.params);else{e.unionallfn.query.modifier||(e.unionallfn.query.modifier="RECORDSET"),f=e.unionallfn(e.params),c=[],o=f.data.length;for(var i=0;i<o;i++){for(var p={},b=Math.min(e.columns.length,f.columns.length)-1;0<=b;b--)p[e.columns[b].columnid]=f.data[i][f.columns[b].columnid];c.push(p)}}e.data=e.data.concat(c)}else if(e.unionfn){if(e.corresponding)e.unionfn.query.modifier||(e.unionfn.query.modifier="ARRAY"),c=e.unionfn(e.params);else{e.unionfn.query.modifier||(e.unionfn.query.modifier="RECORDSET"),f=e.unionfn(e.params),c=[],o=f.data.length;for(var i=0;i<o;i++){p={},t=Math.min(e.columns.length,f.columns.length);for(var b=0;b<t;b++)p[e.columns[b].columnid]=f.data[i][f.columns[b].columnid];c.push(p)}}e.data=M(e.data,c)}else if(e.exceptfn){if(e.corresponding){e.exceptfn.query.modifier||(e.exceptfn.query.modifier="ARRAY");var c=e.exceptfn(e.params)}else{e.exceptfn.query.modifier||(e.exceptfn.query.modifier="RECORDSET");for(var f=e.exceptfn(e.params),c=[],i=0,o=f.data.length;i<o;i++){for(var p={},b=Math.min(e.columns.length,f.columns.length)-1;0<=b;b--)p[e.columns[b].columnid]=f.data[i][f.columns[b].columnid];c.push(p)}}e.data=U(e.data,c)}else if(e.intersectfn){if(e.corresponding)e.intersectfn.query.modifier||(e.intersectfn.query.modifier=void 0),c=e.intersectfn(e.params);else for(e.intersectfn.query.modifier||(e.intersectfn.query.modifier="RECORDSET"),f=e.intersectfn(e.params),c=[],o=f.data.length,i=0;i<o;i++){for(p={},t=Math.min(e.columns.length,f.columns.length),b=0;b<t;b++)p[e.columns[b].columnid]=f.data[i][f.columns[b].columnid];c.push(p)}e.data=_(e.data,c)}if(e.orderfn){if(e.explain)var E=Date.now();e.data=e.data.sort(e.orderfn),e.explain&&e.explaination.push({explid:e.explid++,description:"QUERY BY",ms:Date.now()-E})}if(l(e),"undefined"!=typeof angular&&e.removeKeys.push("$$hashKey"),e.removeKeys.length>0){var g=e.removeKeys;if((t=g.length)>0)for(o=e.data.length,i=0;i<o;i++)for(b=0;b<t;b++)delete e.data[i][g[b]];e.columns.length>0&&(e.columns=e.columns.filter(function(e){var t=!1;return g.forEach(function(r){e.columnid==r&&(t=!0)}),!t}))}if(void 0!==e.removeLikeKeys&&e.removeLikeKeys.length>0){for(var m=e.removeLikeKeys,i=0,o=e.data.length;i<o;i++){p=e.data[i];for(var v in p)for(b=0;b<e.removeLikeKeys.length;b++)A.utils.like(e.removeLikeKeys[b],v)&&delete p[v]}e.columns.length>0&&(e.columns=e.columns.filter(function(e){var t=!1;return m.forEach(function(r){A.utils.like(r,e.columnid)&&(t=!0)}),!t}))}if(e.pivotfn&&e.pivotfn(),e.unpivotfn&&e.unpivotfn(),e.intoallfn){var S=e.intoallfn(e.columns,e.cb,e.params,e.alasql);return S}if(e.intofn){for(o=e.data.length,i=0;i<o;i++)e.intofn(e.data[i],i,e.params,e.alasql);return e.cb&&e.cb(e.data.length,e.A,e.B),e.data.length}return S=e.data,e.cb&&(S=e.cb(e.data,e.A,e.B)),S}function l(e){if(e.limit){var t=0;e.offset&&(t=0|e.offset||0,t=t<0?0:t);var r;r=e.percent?(e.data.length*e.limit/100|0)+t:(0|e.limit)+t,e.data=e.data.slice(t,r)}}function h(e){if(e.distinct){for(var t={},r=Object.keys(e.data[0]||[]),n=0,a=e.data.length;n<a;n++){t[r.map(function(t){return e.data[n][t]}).join("`")]=e.data[n]}e.data=[];for(var s in t)e.data.push(t[s])}}function d(e,t,r){if(r>=e.sources.length)e.wherefn(t,e.params,A)&&(e.groupfn?e.groupfn(t,e.params,A):e.data.push(e.selectfn(t,e.params,A)));else if(e.sources[r].applyselect){var n=e.sources[r];n.applyselect(e.params,function(a){if(a.length>0)for(var s=0;s<a.length;s++)t[n.alias]=a[s],d(e,t,r+1);else"OUTER"==n.applymode&&(t[n.alias]={},d(e,t,r+1))},t)}else{var n=e.sources[r],a=e.sources[r+1],s=n.alias||n.tableid,i=!1,o=n.data,u=!1;(!n.getfn||n.getfn&&!n.dontcache)&&"RIGHT"!=n.joinmode&&"OUTER"!=n.joinmode&&"ANTI"!=n.joinmode&&"ix"==n.optimization&&(o=n.ix[n.onleftfn(t,e.params,A)]||[],u=!0);var c=0;if(void 0===o)throw new Error("Data source number "+r+" in undefined");for(var l,h=o.length;(l=o[c])||!u&&n.getfn&&(l=n.getfn(c))||c<h;)u||!n.getfn||n.dontcache||(o[c]=l),t[s]=l,n.onleftfn&&n.onleftfn(t,e.params,A)!=n.onrightfn(t,e.params,A)||n.onmiddlefn(t,e.params,A)&&("SEMI"!=n.joinmode&&"ANTI"!=n.joinmode&&d(e,t,r+1),"LEFT"!=n.joinmode&&"INNER"!=n.joinmode&&(l._rightjoin=!0),i=!0),c++;if("LEFT"!=n.joinmode&&"OUTER"!=n.joinmode&&"SEMI"!=n.joinmode||i||(t[s]={},d(e,t,r+1)),r+1<e.sources.length&&("OUTER"==a.joinmode||"RIGHT"==a.joinmode||"ANTI"==a.joinmode)){t[n.alias]={};for(var l,f=0,p=a.data.length;(l=a.data[f])||a.getfn&&(l=a.getfn(f))||f<p;)a.getfn&&!a.dontcache&&(a.data[f]=l),l._rightjoin?delete l._rightjoin:0==r&&(t[a.alias]=l,d(e,t,r+2)),f++}t[s]=void 0}}function f(e,t){if(void 0===t||"number"==typeof t||"string"==typeof t||"boolean"==typeof t)return t;var r=e.modifier||A.options.modifier,n=e.columns;if(void 0===n||0==n.length)if(t.length>0){for(var a={},s=Math.min(t.length,A.options.columnlookup||10)-1;0<=s;s--)for(var i in t[s])a[i]=!0;n=Object.keys(a).map(function(e){return{columnid:e}})}else n=[];if("VALUE"===r)if(t.length>0){var i;i=n&&n.length>0?n[0].columnid:Object.keys(t[0])[0],t=t[0][i]}else t=void 0;else if("ROW"===r)if(t.length>0){var i,o=[];for(var i in t[0])o.push(t[0][i]);t=o}else t=void 0;else if("COLUMN"===r){var u=[];if(t.length>0){var i;i=n&&n.length>0?n[0].columnid:Object.keys(t[0])[0];for(var s=0,c=t.length;s<c;s++)u.push(t[s][i])}t=u}else if("MATRIX"===r){for(var u=[],s=0;s<t.length;s++){for(var o=[],l=t[s],h=0;h<n.length;h++)o.push(l[n[h].columnid]);u.push(o)}t=u}else if("INDEX"===r){var i,d,u={};if(n&&n.length>0)i=n[0].columnid,d=n[1].columnid;else{var f=Object.keys(t[0]);i=f[0],d=f[1]}for(var s=0,c=t.length;s<c;s++)u[t[s][i]]=t[s][d];t=u}else if("RECORDSET"===r)t=new A.Recordset({columns:n,data:t});else if("TEXTSTRING"===r){var i;i=n&&n.length>0?n[0].columnid:Object.keys(t[0])[0];for(var s=0,c=t.length;s<c;s++)t[s]=t[s][i];t=t.join("\n")}return t}function p(e,t,r){var n="",a=[];e.ixsources={},e.sources.forEach(function(t){e.ixsources[t.alias]=t});var s;if(e.ixsources[t])var s=e.ixsources[t].columns;return r&&"json"==A.options.joinstar&&(n+="r['"+t+"']={};"),s&&s.length>0?s.forEach(function(s){r&&"underscore"==A.options.joinstar?a.push("'"+t+"_"+s.columnid+"':p['"+t+"']['"+s.columnid+"']"):r&&"json"==A.options.joinstar?n+="r['"+t+"']['"+s.columnid+"']=p['"+t+"']['"+s.columnid+"'];":a.push("'"+s.columnid+"':p['"+t+"']['"+s.columnid+"']"),e.selectColumns[R(s.columnid)]=!0;var i={columnid:s.columnid,dbtypeid:s.dbtypeid,dbsize:s.dbsize,dbprecision:s.dbprecision,dbenum:s.dbenum};e.columns.push(i),e.xcolumns[i.columnid]=i}):(n+='var w=p["'+t+'"];for(var k in w){r[k]=w[k]};',e.dirtyColumns=!0),{s:a.join(","),sp:n}}function b(e,t){if(Array.isArray(e)){for(var r=[[]],n=0;n<e.length;n++)if(e[n]instanceof K.Column)e[n].nick=R(e[n].columnid),t.groupColumns[e[n].nick]=e[n].nick,r=r.map(function(r){return r.concat(e[n].nick+"\t"+e[n].toJS("p",t.sources[0].alias,t.defcols))});else if(e[n]instanceof K.FuncValue)t.groupColumns[R(e[n].toString())]=R(e[n].toString()),r=r.map(function(r){return r.concat(R(e[n].toString())+"\t"+e[n].toJS("p",t.sources[0].alias,t.defcols))});else if(e[n]instanceof K.GroupExpression)if("ROLLUP"==e[n].type)r=ne(r,ee(e[n].group,t));else if("CUBE"==e[n].type)r=ne(r,te(e[n].group,t));else{if("GROUPING SETS"!=e[n].type)throw new Error("Unknown grouping function");r=ne(r,re(e[n].group,t))}else r=""===e[n]?[["1\t1"]]:r.map(function(r){return t.groupColumns[R(e[n].toString())]=R(e[n].toString()),r.concat(R(e[n].toString())+"\t"+e[n].toJS("p",t.sources[0].alias,t.defcols))});return r}return e instanceof K.FuncValue?(t.groupColumns[R(e.toString())]=R(e.toString()),[e.toString()+"\t"+e.toJS("p",t.sources[0].alias,t.defcols)]):e instanceof K.Column?(e.nick=R(e.columnid),t.groupColumns[e.nick]=e.nick,[e.nick+"\t"+e.toJS("p",t.sources[0].alias,t.defcols)]):(t.groupColumns[R(e.toString())]=R(e.toString()),[R(e.toString())+"\t"+e.toJS("p",t.sources[0].alias,t.defcols)])}function E(e,t,r,n){var a="";if("string"==typeof e)a='"'+e+'"';else if("number"==typeof e)a="("+e+")";else if("boolean"==typeof e)a=e;else{if("object"!=typeof e)throw new Error("2Can not parse JSON object "+JSON.stringify(e));if(Array.isArray(e))a+="["+e.map(function(e){return E(e,t,r,n)}).join(",")+"]";else if(!e.toJS||e instanceof K.Json){a="{";var s=[];for(var i in e){var o="";if("string"==typeof i)o+='"'+i+'"';else if("number"==typeof i)o+=i;else{if("boolean"!=typeof i)throw new Error("THis is not ES6... no expressions on left side yet");o+=i}o+=":"+E(e[i],t,r,n),s.push(o)}a+=s.join(",")+"}"}else{if(!e.toJS)throw new Error("1Can not parse JSON object "+JSON.stringify(e));a=e.toJS(t,r,n)}}return a}function g(e){var t="";if(void 0===e)t+="undefined";else if(Array.isArray(e)){t+="<style>",t+="table {border:1px black solid; border-collapse: collapse; border-spacing: 0px;}",t+="td,th {border:1px black solid; padding-left:5px; padding-right:5px}",t+="th {background-color: #EEE}",t+="</style>",t+="<table>";var r=[];for(var n in e[0])r.push(n);t+="<tr><th>#",r.forEach(function(e){t+="<th>"+e});for(var a=0,s=e.length;a<s;a++)t+="<tr><th>"+(a+1),r.forEach(function(r){t+="<td> ",e[a][r]==+e[a][r]?(t+='<div style="text-align:right">',void 0===e[a][r]?t+="NULL":t+=e[a][r],t+="</div>"):void 0===e[a][r]?t+="NULL":"string"==typeof e[a][r]?t+=e[a][r]:t+=ue(e[a][r])});t+="</table>"}else t+="<p>"+ue(e)+"</p>";return t}function m(e,t,r){if(!(r<=0)){var n=t-e.scrollTop,a=n/r*10;setTimeout(function(){e.scrollTop!==t&&(e.scrollTop=e.scrollTop+a,m(e,t,r-10))},10)}}function S(e,t,r,n,a,s){function i(e){for(var t="",r=0,n=10240;r<e.byteLength/n;++r)t+=String.fromCharCode.apply(null,new Uint8Array(e.slice(r*n,r*n+n)));return t+=String.fromCharCode.apply(null,new Uint8Array(e.slice(r*n)))}function o(e){return e&&!1===A.options.casesensitive?e.toLowerCase():e}var u={};r=r||{},A.utils.extend(u,r),void 0===u.headers&&(u.headers=!0);t=A.utils.autoExtFilename(t,"xls",r),A.utils.loadBinaryFile(t,!!n,function(t){if(t instanceof ArrayBuffer)var r=i(t),c=e.read(btoa(r),{type:"base64"});else var c=e.read(t,{type:"binary"});var l;l=void 0===u.sheetid?c.SheetNames[0]:u.sheetid;var h,d=[];if(void 0===u.range?h=c.Sheets[l]["!ref"]:(h=u.range,c.Sheets[l][h]&&(h=c.Sheets[l][h])),h){for(var f=h.split(":"),p=f[0].match(/[A-Z]+/)[0],b=+f[0].match(/[0-9]+/)[0],E=f[1].match(/[A-Z]+/)[0],g=+f[1].match(/[0-9]+/)[0],m={},v=A.utils.xlscn(p),S=A.utils.xlscn(E),T=v;T<=S;T++){var y=A.utils.xlsnc(T);u.headers?c.Sheets[l][y+""+b]?m[y]=o(c.Sheets[l][y+""+b].v):m[y]=o(y):m[y]=y}u.headers&&b++;for(var N=b;N<=g;N++){for(var C={},T=v;T<=S;T++){var y=A.utils.xlsnc(T);c.Sheets[l][y+""+N]&&(C[m[y]]=c.Sheets[l][y+""+N].v)}d.push(C)}}else d.push([]);d.length>0&&d[d.length-1]&&0==Object.keys(d[d.length-1]).length&&d.pop(),n&&(d=n(d,a,s))},function(e){throw e})}function T(e){function t(){if(i(/^<\?xml\s*/)){for(var e={attributes:{}};!o()&&!u("?>");){var t=a();if(!t)return e;e.attributes[t.name]=t.value}return i(/\?>\s*/),e}}function r(){var e=i(/^<([\w-:.]+)\s*/);if(e){for(var t={name:e[1],attributes:{},children:[]};!(o()||u(">")||u("?>")||u("/>"));){var s=a();if(!s)return t;t.attributes[s.name]=s.value}if(i(/^\s*\/>\s*/))return t;i(/\??>\s*/),t.content=n();for(var c;c=r();)t.children.push(c);return i(/^<\/[\w-:.]+>\s*/),t}}function n(){var e=i(/^([^<]*)/);return e?e[1]:""}function a(){var e=i(/([\w:-]+)\s*=\s*("[^"]*"|'[^']*'|\w+)\s*/);if(e)return{name:e[1],value:s(e[2])}}function s(e){return e.replace(/^['"]|['"]$/g,"")}function i(t){var r=e.match(t);if(r)return e=e.slice(r[0].length),r}function o(){return 0==e.length}function u(t){return 0==e.indexOf(t)}return e=e.trim(),e=e.replace(/<!--[\s\S]*?-->/g,""),function(){return{declaration:t(),root:r()}}()}var A=function(e,t,r,n){if(t=t||[],"function"!=typeof importScripts&&A.webworker){var a=A.lastid++;return A.buffer[a]=r,void A.webworker.postMessage({id:a,sql:e,params:t})}return 0===arguments.length?new K.Select({columns:[new K.Column({columnid:"*"})],from:[new K.ParamValue({param:0})]}):1===arguments.length&&e.constructor===Array?A.promise(e):("function"==typeof t&&(n=r,r=t,t=[]),"object"!=typeof t&&(t=[t]),"string"==typeof e&&"#"===e[0]&&"object"==typeof document?e=document.querySelector(e).textContent:"object"==typeof e&&e instanceof HTMLElement?e=e.textContent:"function"==typeof e&&(e=e.toString().slice(14,-3)),A.exec(e,t,r,n))};A.version="0.4.4-develop-1566",A.debug=void 0;var y=function(){return null},N=function(){function e(){this.yy={}}var t=function(e,t,r,n){for(r=r||{},n=e.length;n--;r[e[n]]=t);return r
+//! AlaSQL v0.4.4-develop-1567 | © 2014-2016 Andrey Gershun & Mathias Rangel Wulff | License: MIT
+!function(e,t){"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?module.exports=t():e.alasql=t()}(this,function(){function e(e){return"(y="+e+",y===y?y:undefined)"}function t(e,t){return"(y="+e+',typeof y=="undefined"?undefined:'+t+")"}function r(){return!0}function n(){}function a(){var e=navigator.userAgent.toLowerCase();return-1!==e.indexOf("msie")&&parseInt(e.split("msie")[1])}function i(e,t,r){function n(e,r,a){var o,u,c,l=e[r];if(l.selid){if("PATH"===l.selid){for(var h=[{node:a,stack:[]}],d={},f=A.databases[A.useid].objects;h.length>0;){var p=h.shift(),b=p.node,E=p.stack,c=n(l.args,0,b);if(c.length>0){if(r+1+1>e.length)return E;var g=[];return E&&E.length>0&&E.forEach(function(t){g=g.concat(n(e,r+1,t))}),g}void 0===d[b.$id]&&(d[b.$id]=!0,b.$out&&b.$out.length>0&&b.$out.forEach(function(e){var t=f[e],r=E.concat(t);r.push(f[t.$out[0]]),h.push({node:f[t.$out[0]],stack:r})}))}return[]}if("NOT"===l.selid){var u=n(l.args,0,a);return u.length>0?[]:r+1+1>e.length?[a]:n(e,r+1,a)}if("DISTINCT"===l.selid){var u;if(u=void 0===l.args||0===l.args.length?q(a):n(l.args,0,a),0===u.length)return[];var m=q(u);return r+1+1>e.length?m:n(e,r+1,m)}if("AND"===l.selid){var m=!0;return l.args.forEach(function(e){m=m&&n(e,0,a).length>0}),m?r+1+1>e.length?[a]:n(e,r+1,a):[]}if("OR"===l.selid){var m=!1;return l.args.forEach(function(e){m=m||n(e,0,a).length>0}),m?r+1+1>e.length?[a]:n(e,r+1,a):[]}if("ALL"===l.selid){var u=n(l.args[0],0,a);return 0===u.length?[]:r+1+1>e.length?u:n(e,r+1,u)}if("ANY"===l.selid){var u=n(l.args[0],0,a);return 0===u.length?[]:r+1+1>e.length?[u[0]]:n(e,r+1,[u[0]])}if("UNIONALL"===l.selid){var u=[];return l.args.forEach(function(e){u=u.concat(n(e,0,a))}),0===u.length?[]:r+1+1>e.length?u:n(e,r+1,u)}if("UNION"===l.selid){var u=[];l.args.forEach(function(e){u=u.concat(n(e,0,a))});var u=q(u);return 0===u.length?[]:r+1+1>e.length?u:n(e,r+1,u)}if("IF"===l.selid){var u=n(l.args,0,a);return 0===u.length?[]:r+1+1>e.length?[a]:n(e,r+1,a)}if("REPEAT"===l.selid){var v,S,T=l.args[0].value;S=l.args[1]?l.args[1].value:T,l.args[2]&&(v=l.args[2].variable);var y=[];if(0===T&&(r+1+1>e.length?y=[a]:(v&&(A.vars[v]=0),y=y.concat(n(e,r+1,a)))),S>0)for(var N=[{value:a,lvl:1}],C=0;N.length>0;){var u=N[0];if(N.shift(),u.lvl<=S){v&&(A.vars[v]=u.lvl);var R=n(l.sels,0,u.value);R.forEach(function(e){N.push({value:e,lvl:u.lvl+1})}),u.lvl>=T&&(r+1+1>e.length?y=y.concat(R):R.forEach(function(t){y=y.concat(n(e,r+1,t))}))}if(++C>1e5)throw new Error("Security brake. Number of iterations = "+C)}return y}if("OF"===l.selid){if(r+1+1>e.length)return[a];var O=[];return Object.keys(a).forEach(function(t){A.vars[l.args[0].variable]=t,O=O.concat(n(e,r+1,a[t]))}),O}if("TO"===l.selid){var w=A.vars[l.args[0]],I=[];if(I=void 0!==w?w.slice(0):[],I.push(a),r+1+1>e.length)return[a];A.vars[l.args[0]]=I;var O=n(e,r+1,a);return A.vars[l.args[0]]=w,O}if("ARRAY"===l.selid){var u=n(l.args,0,a);return u.length>0?(o=u,r+1+1>e.length?[o]:n(e,r+1,o)):[]}if("SUM"===l.selid){var u=n(l.args,0,a);if(!(u.length>0))return[];var o=u.reduce(function(e,t){return e+t},0);return r+1+1>e.length?[o]:n(e,r+1,o)}if("AVG"===l.selid)return u=n(l.args,0,a),u.length>0?(o=u.reduce(function(e,t){return e+t},0)/u.length,r+1+1>e.length?[o]:n(e,r+1,o)):[];if("COUNT"===l.selid)return u=n(l.args,0,a),u.length>0?(o=u.length,r+1+1>e.length?[o]:n(e,r+1,o)):[];if("FIRST"===l.selid)return u=n(l.args,0,a),u.length>0?(o=u[0],r+1+1>e.length?[o]:n(e,r+1,o)):[];if("LAST"===l.selid)return u=n(l.args,0,a),u.length>0?(o=u[u.length-1],r+1+1>e.length?[o]:n(e,r+1,o)):[];if("MIN"===l.selid){if(u=n(l.args,0,a),0===u.length)return[];var o=u.reduce(function(e,t){return Math.min(e,t)},1/0);return r+1+1>e.length?[o]:n(e,r+1,o)}if("MAX"===l.selid){var u=n(l.args,0,a);if(0===u.length)return[];var o=u.reduce(function(e,t){return Math.max(e,t)},-1/0);return r+1+1>e.length?[o]:n(e,r+1,o)}if("PLUS"===l.selid){var y=[],N=n(l.args,0,a).slice();r+1+1>e.length?y=y.concat(N):N.forEach(function(t){y=y.concat(n(e,r+1,t))});for(var C=0;N.length>0;){var u=N.shift();if(u=n(l.args,0,u),N=N.concat(u),r+1+1>e.length?y=y.concat(u):u.forEach(function(t){var a=n(e,r+1,t);y=y.concat(a)}),++C>1e5)throw new Error("Security brake. Number of iterations = "+C)}return y}if("STAR"===l.selid){var y=[];y=n(e,r+1,a);var N=n(l.args,0,a).slice();r+1+1>e.length?y=y.concat(N):N.forEach(function(t){y=y.concat(n(e,r+1,t))});for(var C=0;N.length>0;){var u=N[0];if(N.shift(),u=n(l.args,0,u),N=N.concat(u),r+1+1<=e.length&&u.forEach(function(t){y=y.concat(n(e,r+1,t))}),++C>1e5)throw new Error("Loop brake. Number of iterations = "+C)}return y}if("QUESTION"===l.selid){var y=[];y=y.concat(n(e,r+1,a));var u=n(l.args,0,a);return r+1+1<=e.length&&u.forEach(function(t){y=y.concat(n(e,r+1,t))}),y}if("WITH"!==l.selid){if("ROOT"===l.selid)return r+1+1>e.length?[a]:n(e,r+1,s);throw new Error("Wrong selector "+l.selid)}var u=n(l.args,0,a);if(0===u.length)return[];var c={status:1,values:u}}else{if(!l.srchid)throw new Error("Selector not found");var c=A.srch[l.srchid.toUpperCase()](a,l.args,i,t)}void 0===c&&(c={status:1,values:[a]});var m=[];if(1===c.status){var x=c.values;if(r+1+1>e.length)m=x;else for(var C=0;C<c.values.length;C++)m=m.concat(n(e,r+1,x[C]))}return m}var a,s,i={},o=F(this.selectors);if(void 0!==o&&o.length>0&&(o&&o[0]&&"PROP"===o[0].srchid&&o[0].args&&o[0].args[0]&&("XML"===o[0].args[0].toUpperCase()?(i.mode="XML",o.shift()):"HTML"===o[0].args[0].toUpperCase()?(i.mode="HTML",o.shift()):"JSON"===o[0].args[0].toUpperCase()&&(i.mode="JSON",o.shift())),o.length>0&&"VALUE"===o[0].srchid&&(i.value=!0,o.shift())),this.from instanceof K.Column){var u=this.from.databaseid||e;s=A.databases[u].tables[this.from.columnid].data}else if(this.from instanceof K.FuncValue&&A.from[this.from.funcid.toUpperCase()]){var c=this.from.args.map(function(e){var r=e.toJS();return new Function("params,alasql","var y;return "+r).bind(this)(t,A)});s=A.from[this.from.funcid.toUpperCase()].apply(this,c)}else if(void 0===this.from)s=A.databases[e].objects;else{var l=new Function("params,alasql","var y;return "+this.from.toJS());s=l(t,A),"object"==typeof Mongo&&"object"!=typeof Mongo.Collection&&s instanceof Mongo.Collection&&(s=s.find().fetch())}if(a=void 0!==o&&o.length>0?n(o,0,s):s,this.into){var h,d;void 0!==this.into.args[0]&&(h=new Function("params,alasql","var y;return "+this.into.args[0].toJS())(t,A)),void 0!==this.into.args[1]&&(d=new Function("params,alasql","var y;return "+this.into.args[1].toJS())(t,A)),a=A.into[this.into.funcid.toUpperCase()](h,d,a,[],r)}else i.value&&a.length>0&&(a=a[0]),r&&(a=r(a));return a}function o(e,t,r,n,a){e.sources.length;e.sourceslen=e.sources.length;var s=e.sourceslen;e.query=e,e.A=n,e.B=a,e.cb=r,e.oldscope=t,e.queriesfn&&(e.sourceslen+=e.queriesfn.length,s+=e.queriesfn.length,e.queriesdata=[],e.queriesfn.forEach(function(t,r){t.query.params=e.params,u([],-r-1,e)}));var i;i=t?F(t):{},e.scope=i;var o;return e.sources.forEach(function(t,r){t.query=e;var n=t.datafn(e,e.params,u,r,A);void 0!==n&&((e.intofn||e.intoallfn)&&Array.isArray(n)&&(n=n.length),o=n),t.queriesdata=e.queriesdata}),0!=e.sources.length&&0!==s||(o=c(e)),o}function u(e,t,r){if(t>=0){var n=r.sources[t];n.data=e,"function"==typeof n.data&&(n.getfn=n.data,n.dontcache=n.getfn.dontcache,"OUTER"!=n.joinmode&&"RIGHT"!=n.joinmode&&"ANTI"!=n.joinmode||(n.dontcache=!1),n.data={})}else r.queriesdata[-t-1]=V(e);if(!(--r.sourceslen>0))return c(r)}function c(e){var t,r=e.scope;Z(e),e.data=[],e.xgroups={},e.groups=[];if(d(e,r,0),e.groupfn){if(e.data=[],0===e.groups.length){var n={};e.selectGroup.length>0&&e.selectGroup.forEach(function(e){"COUNT"==e.aggregatorid||"SUM"==e.aggregatorid?n[e.nick]=0:n[e.nick]=void 0}),e.groups=[n]}if(e.aggrKeys.length>0){var a="";e.aggrKeys.forEach(function(e){a+="g['"+e.nick+"']=alasql.aggr['"+e.funcid+"'](undefined,g['"+e.nick+"'],3);"});var s=new Function("g,params,alasql","var y;"+a)}for(var i=0,o=e.groups.length;i<o;i++){var n=e.groups[i];if(s&&s(n,e.params,A),!e.havingfn||e.havingfn(n,e.params,A)){var u=e.selectgfn(n,e.params,A);e.data.push(u)}}}if(h(e),e.unionallfn){var c,f;if(e.corresponding)e.unionallfn.query.modifier||(e.unionallfn.query.modifier=void 0),c=e.unionallfn(e.params);else{e.unionallfn.query.modifier||(e.unionallfn.query.modifier="RECORDSET"),f=e.unionallfn(e.params),c=[],o=f.data.length;for(var i=0;i<o;i++){for(var p={},b=Math.min(e.columns.length,f.columns.length)-1;0<=b;b--)p[e.columns[b].columnid]=f.data[i][f.columns[b].columnid];c.push(p)}}e.data=e.data.concat(c)}else if(e.unionfn){if(e.corresponding)e.unionfn.query.modifier||(e.unionfn.query.modifier="ARRAY"),c=e.unionfn(e.params);else{e.unionfn.query.modifier||(e.unionfn.query.modifier="RECORDSET"),f=e.unionfn(e.params),c=[],o=f.data.length;for(var i=0;i<o;i++){p={},t=Math.min(e.columns.length,f.columns.length);for(var b=0;b<t;b++)p[e.columns[b].columnid]=f.data[i][f.columns[b].columnid];c.push(p)}}e.data=M(e.data,c)}else if(e.exceptfn){if(e.corresponding){e.exceptfn.query.modifier||(e.exceptfn.query.modifier="ARRAY");var c=e.exceptfn(e.params)}else{e.exceptfn.query.modifier||(e.exceptfn.query.modifier="RECORDSET");for(var f=e.exceptfn(e.params),c=[],i=0,o=f.data.length;i<o;i++){for(var p={},b=Math.min(e.columns.length,f.columns.length)-1;0<=b;b--)p[e.columns[b].columnid]=f.data[i][f.columns[b].columnid];c.push(p)}}e.data=U(e.data,c)}else if(e.intersectfn){if(e.corresponding)e.intersectfn.query.modifier||(e.intersectfn.query.modifier=void 0),c=e.intersectfn(e.params);else for(e.intersectfn.query.modifier||(e.intersectfn.query.modifier="RECORDSET"),f=e.intersectfn(e.params),c=[],o=f.data.length,i=0;i<o;i++){for(p={},t=Math.min(e.columns.length,f.columns.length),b=0;b<t;b++)p[e.columns[b].columnid]=f.data[i][f.columns[b].columnid];c.push(p)}e.data=_(e.data,c)}if(e.orderfn){if(e.explain)var E=Date.now();e.data=e.data.sort(e.orderfn),e.explain&&e.explaination.push({explid:e.explid++,description:"QUERY BY",ms:Date.now()-E})}if(l(e),"undefined"!=typeof angular&&e.removeKeys.push("$$hashKey"),e.removeKeys.length>0){var g=e.removeKeys;if((t=g.length)>0)for(o=e.data.length,i=0;i<o;i++)for(b=0;b<t;b++)delete e.data[i][g[b]];e.columns.length>0&&(e.columns=e.columns.filter(function(e){var t=!1;return g.forEach(function(r){e.columnid==r&&(t=!0)}),!t}))}if(void 0!==e.removeLikeKeys&&e.removeLikeKeys.length>0){for(var m=e.removeLikeKeys,i=0,o=e.data.length;i<o;i++){p=e.data[i];for(var v in p)for(b=0;b<e.removeLikeKeys.length;b++)A.utils.like(e.removeLikeKeys[b],v)&&delete p[v]}e.columns.length>0&&(e.columns=e.columns.filter(function(e){var t=!1;return m.forEach(function(r){A.utils.like(r,e.columnid)&&(t=!0)}),!t}))}if(e.pivotfn&&e.pivotfn(),e.unpivotfn&&e.unpivotfn(),e.intoallfn){var S=e.intoallfn(e.columns,e.cb,e.params,e.alasql);return S}if(e.intofn){for(o=e.data.length,i=0;i<o;i++)e.intofn(e.data[i],i,e.params,e.alasql);return e.cb&&e.cb(e.data.length,e.A,e.B),e.data.length}return S=e.data,e.cb&&(S=e.cb(e.data,e.A,e.B)),S}function l(e){if(e.limit){var t=0;e.offset&&(t=0|e.offset||0,t=t<0?0:t);var r;r=e.percent?(e.data.length*e.limit/100|0)+t:(0|e.limit)+t,e.data=e.data.slice(t,r)}}function h(e){if(e.distinct){for(var t={},r=Object.keys(e.data[0]||[]),n=0,a=e.data.length;n<a;n++){t[r.map(function(t){return e.data[n][t]}).join("`")]=e.data[n]}e.data=[];for(var s in t)e.data.push(t[s])}}function d(e,t,r){if(r>=e.sources.length)e.wherefn(t,e.params,A)&&(e.groupfn?e.groupfn(t,e.params,A):e.data.push(e.selectfn(t,e.params,A)));else if(e.sources[r].applyselect){var n=e.sources[r];n.applyselect(e.params,function(a){if(a.length>0)for(var s=0;s<a.length;s++)t[n.alias]=a[s],d(e,t,r+1);else"OUTER"==n.applymode&&(t[n.alias]={},d(e,t,r+1))},t)}else{var n=e.sources[r],a=e.sources[r+1],s=n.alias||n.tableid,i=!1,o=n.data,u=!1;(!n.getfn||n.getfn&&!n.dontcache)&&"RIGHT"!=n.joinmode&&"OUTER"!=n.joinmode&&"ANTI"!=n.joinmode&&"ix"==n.optimization&&(o=n.ix[n.onleftfn(t,e.params,A)]||[],u=!0);var c=0;if(void 0===o)throw new Error("Data source number "+r+" in undefined");for(var l,h=o.length;(l=o[c])||!u&&n.getfn&&(l=n.getfn(c))||c<h;)u||!n.getfn||n.dontcache||(o[c]=l),t[s]=l,n.onleftfn&&n.onleftfn(t,e.params,A)!=n.onrightfn(t,e.params,A)||n.onmiddlefn(t,e.params,A)&&("SEMI"!=n.joinmode&&"ANTI"!=n.joinmode&&d(e,t,r+1),"LEFT"!=n.joinmode&&"INNER"!=n.joinmode&&(l._rightjoin=!0),i=!0),c++;if("LEFT"!=n.joinmode&&"OUTER"!=n.joinmode&&"SEMI"!=n.joinmode||i||(t[s]={},d(e,t,r+1)),r+1<e.sources.length&&("OUTER"==a.joinmode||"RIGHT"==a.joinmode||"ANTI"==a.joinmode)){t[n.alias]={};for(var l,f=0,p=a.data.length;(l=a.data[f])||a.getfn&&(l=a.getfn(f))||f<p;)a.getfn&&!a.dontcache&&(a.data[f]=l),l._rightjoin?delete l._rightjoin:0==r&&(t[a.alias]=l,d(e,t,r+2)),f++}t[s]=void 0}}function f(e,t){if(void 0===t||"number"==typeof t||"string"==typeof t||"boolean"==typeof t)return t;var r=e.modifier||A.options.modifier,n=e.columns;if(void 0===n||0==n.length)if(t.length>0){for(var a={},s=Math.min(t.length,A.options.columnlookup||10)-1;0<=s;s--)for(var i in t[s])a[i]=!0;n=Object.keys(a).map(function(e){return{columnid:e}})}else n=[];if("VALUE"===r)if(t.length>0){var i;i=n&&n.length>0?n[0].columnid:Object.keys(t[0])[0],t=t[0][i]}else t=void 0;else if("ROW"===r)if(t.length>0){var i,o=[];for(var i in t[0])o.push(t[0][i]);t=o}else t=void 0;else if("COLUMN"===r){var u=[];if(t.length>0){var i;i=n&&n.length>0?n[0].columnid:Object.keys(t[0])[0];for(var s=0,c=t.length;s<c;s++)u.push(t[s][i])}t=u}else if("MATRIX"===r){for(var u=[],s=0;s<t.length;s++){for(var o=[],l=t[s],h=0;h<n.length;h++)o.push(l[n[h].columnid]);u.push(o)}t=u}else if("INDEX"===r){var i,d,u={};if(n&&n.length>0)i=n[0].columnid,d=n[1].columnid;else{var f=Object.keys(t[0]);i=f[0],d=f[1]}for(var s=0,c=t.length;s<c;s++)u[t[s][i]]=t[s][d];t=u}else if("RECORDSET"===r)t=new A.Recordset({columns:n,data:t});else if("TEXTSTRING"===r){var i;i=n&&n.length>0?n[0].columnid:Object.keys(t[0])[0];for(var s=0,c=t.length;s<c;s++)t[s]=t[s][i];t=t.join("\n")}return t}function p(e,t,r){var n="",a=[];e.ixsources={},e.sources.forEach(function(t){e.ixsources[t.alias]=t});var s;if(e.ixsources[t])var s=e.ixsources[t].columns;return r&&"json"==A.options.joinstar&&(n+="r['"+t+"']={};"),s&&s.length>0?s.forEach(function(s){r&&"underscore"==A.options.joinstar?a.push("'"+t+"_"+s.columnid+"':p['"+t+"']['"+s.columnid+"']"):r&&"json"==A.options.joinstar?n+="r['"+t+"']['"+s.columnid+"']=p['"+t+"']['"+s.columnid+"'];":a.push("'"+s.columnid+"':p['"+t+"']['"+s.columnid+"']"),e.selectColumns[R(s.columnid)]=!0;var i={columnid:s.columnid,dbtypeid:s.dbtypeid,dbsize:s.dbsize,dbprecision:s.dbprecision,dbenum:s.dbenum};e.columns.push(i),e.xcolumns[i.columnid]=i}):(n+='var w=p["'+t+'"];for(var k in w){r[k]=w[k]};',e.dirtyColumns=!0),{s:a.join(","),sp:n}}function b(e,t){if(Array.isArray(e)){for(var r=[[]],n=0;n<e.length;n++)if(e[n]instanceof K.Column)e[n].nick=R(e[n].columnid),t.groupColumns[e[n].nick]=e[n].nick,r=r.map(function(r){return r.concat(e[n].nick+"\t"+e[n].toJS("p",t.sources[0].alias,t.defcols))});else if(e[n]instanceof K.FuncValue)t.groupColumns[R(e[n].toString())]=R(e[n].toString()),r=r.map(function(r){return r.concat(R(e[n].toString())+"\t"+e[n].toJS("p",t.sources[0].alias,t.defcols))});else if(e[n]instanceof K.GroupExpression)if("ROLLUP"==e[n].type)r=ne(r,ee(e[n].group,t));else if("CUBE"==e[n].type)r=ne(r,te(e[n].group,t));else{if("GROUPING SETS"!=e[n].type)throw new Error("Unknown grouping function");r=ne(r,re(e[n].group,t))}else r=""===e[n]?[["1\t1"]]:r.map(function(r){return t.groupColumns[R(e[n].toString())]=R(e[n].toString()),r.concat(R(e[n].toString())+"\t"+e[n].toJS("p",t.sources[0].alias,t.defcols))});return r}return e instanceof K.FuncValue?(t.groupColumns[R(e.toString())]=R(e.toString()),[e.toString()+"\t"+e.toJS("p",t.sources[0].alias,t.defcols)]):e instanceof K.Column?(e.nick=R(e.columnid),t.groupColumns[e.nick]=e.nick,[e.nick+"\t"+e.toJS("p",t.sources[0].alias,t.defcols)]):(t.groupColumns[R(e.toString())]=R(e.toString()),[R(e.toString())+"\t"+e.toJS("p",t.sources[0].alias,t.defcols)])}function E(e,t,r,n){var a="";if("string"==typeof e)a='"'+e+'"';else if("number"==typeof e)a="("+e+")";else if("boolean"==typeof e)a=e;else{if("object"!=typeof e)throw new Error("2Can not parse JSON object "+JSON.stringify(e));if(Array.isArray(e))a+="["+e.map(function(e){return E(e,t,r,n)}).join(",")+"]";else if(!e.toJS||e instanceof K.Json){a="{";var s=[];for(var i in e){var o="";if("string"==typeof i)o+='"'+i+'"';else if("number"==typeof i)o+=i;else{if("boolean"!=typeof i)throw new Error("THis is not ES6... no expressions on left side yet");o+=i}o+=":"+E(e[i],t,r,n),s.push(o)}a+=s.join(",")+"}"}else{if(!e.toJS)throw new Error("1Can not parse JSON object "+JSON.stringify(e));a=e.toJS(t,r,n)}}return a}function g(e){var t="";if(void 0===e)t+="undefined";else if(Array.isArray(e)){t+="<style>",t+="table {border:1px black solid; border-collapse: collapse; border-spacing: 0px;}",t+="td,th {border:1px black solid; padding-left:5px; padding-right:5px}",t+="th {background-color: #EEE}",t+="</style>",t+="<table>";var r=[];for(var n in e[0])r.push(n);t+="<tr><th>#",r.forEach(function(e){t+="<th>"+e});for(var a=0,s=e.length;a<s;a++)t+="<tr><th>"+(a+1),r.forEach(function(r){t+="<td> ",e[a][r]==+e[a][r]?(t+='<div style="text-align:right">',void 0===e[a][r]?t+="NULL":t+=e[a][r],t+="</div>"):void 0===e[a][r]?t+="NULL":"string"==typeof e[a][r]?t+=e[a][r]:t+=ue(e[a][r])});t+="</table>"}else t+="<p>"+ue(e)+"</p>";return t}function m(e,t,r){if(!(r<=0)){var n=t-e.scrollTop,a=n/r*10;setTimeout(function(){e.scrollTop!==t&&(e.scrollTop=e.scrollTop+a,m(e,t,r-10))},10)}}function S(e,t,r,n,a,s){function i(e){for(var t="",r=0,n=10240;r<e.byteLength/n;++r)t+=String.fromCharCode.apply(null,new Uint8Array(e.slice(r*n,r*n+n)));return t+=String.fromCharCode.apply(null,new Uint8Array(e.slice(r*n)))}function o(e){return e&&!1===A.options.casesensitive?e.toLowerCase():e}var u={};r=r||{},A.utils.extend(u,r),void 0===u.headers&&(u.headers=!0);t=A.utils.autoExtFilename(t,"xls",r),A.utils.loadBinaryFile(t,!!n,function(t){if(t instanceof ArrayBuffer)var r=i(t),c=e.read(btoa(r),{type:"base64"});else var c=e.read(t,{type:"binary"});var l;l=void 0===u.sheetid?c.SheetNames[0]:u.sheetid;var h,d=[];if(void 0===u.range?h=c.Sheets[l]["!ref"]:(h=u.range,c.Sheets[l][h]&&(h=c.Sheets[l][h])),h){for(var f=h.split(":"),p=f[0].match(/[A-Z]+/)[0],b=+f[0].match(/[0-9]+/)[0],E=f[1].match(/[A-Z]+/)[0],g=+f[1].match(/[0-9]+/)[0],m={},v=A.utils.xlscn(p),S=A.utils.xlscn(E),T=v;T<=S;T++){var y=A.utils.xlsnc(T);u.headers?c.Sheets[l][y+""+b]?m[y]=o(c.Sheets[l][y+""+b].v):m[y]=o(y):m[y]=y}u.headers&&b++;for(var N=b;N<=g;N++){for(var C={},T=v;T<=S;T++){var y=A.utils.xlsnc(T);c.Sheets[l][y+""+N]&&(C[m[y]]=c.Sheets[l][y+""+N].v)}d.push(C)}}else d.push([]);d.length>0&&d[d.length-1]&&0==Object.keys(d[d.length-1]).length&&d.pop(),n&&(d=n(d,a,s))},function(e){throw e})}function T(e){function t(){if(i(/^<\?xml\s*/)){for(var e={attributes:{}};!o()&&!u("?>");){var t=a();if(!t)return e;e.attributes[t.name]=t.value}return i(/\?>\s*/),e}}function r(){var e=i(/^<([\w-:.]+)\s*/);if(e){for(var t={name:e[1],attributes:{},children:[]};!(o()||u(">")||u("?>")||u("/>"));){var s=a();if(!s)return t;t.attributes[s.name]=s.value}if(i(/^\s*\/>\s*/))return t;i(/\??>\s*/),t.content=n();for(var c;c=r();)t.children.push(c);return i(/^<\/[\w-:.]+>\s*/),t}}function n(){var e=i(/^([^<]*)/);return e?e[1]:""}function a(){var e=i(/([\w:-]+)\s*=\s*("[^"]*"|'[^']*'|\w+)\s*/);if(e)return{name:e[1],value:s(e[2])}}function s(e){return e.replace(/^['"]|['"]$/g,"")}function i(t){var r=e.match(t);if(r)return e=e.slice(r[0].length),r}function o(){return 0==e.length}function u(t){return 0==e.indexOf(t)}return e=e.trim(),e=e.replace(/<!--[\s\S]*?-->/g,""),function(){return{declaration:t(),root:r()}}()}var A=function(e,t,r,n){if(t=t||[],"function"!=typeof importScripts&&A.webworker){var a=A.lastid++;return A.buffer[a]=r,void A.webworker.postMessage({id:a,sql:e,params:t})}return 0===arguments.length?new K.Select({columns:[new K.Column({columnid:"*"})],from:[new K.ParamValue({param:0})]}):1===arguments.length&&e.constructor===Array?A.promise(e):("function"==typeof t&&(n=r,r=t,t=[]),"object"!=typeof t&&(t=[t]),"string"==typeof e&&"#"===e[0]&&"object"==typeof document?e=document.querySelector(e).textContent:"object"==typeof e&&e instanceof HTMLElement?e=e.textContent:"function"==typeof e&&(e=e.toString().slice(14,-3)),A.exec(e,t,r,n))};A.version="0.4.4-develop-1567",A.debug=void 0;var y=function(){return null},N=function(){function e(){this.yy={}}var t=function(e,t,r,n){for(r=r||{},n=e.length;n--;r[e[n]]=t);return r
 },r=[2,13],n=[1,104],a=[1,102],s=[1,103],i=[1,6],o=[1,42],u=[1,79],c=[1,76],l=[1,94],h=[1,93],d=[1,69],f=[1,101],p=[1,85],b=[1,64],E=[1,71],g=[1,84],m=[1,66],v=[1,70],S=[1,68],T=[1,61],y=[1,74],N=[1,62],C=[1,67],R=[1,83],O=[1,77],I=[1,86],x=[1,87],D=[1,81],k=[1,82],L=[1,80],$=[1,88],M=[1,89],U=[1,90],_=[1,91],F=[1,92],P=[1,98],q=[1,65],G=[1,78],V=[1,72],B=[1,96],j=[1,97],H=[1,63],J=[1,73],Y=[1,108],W=[1,107],X=[10,306,602,764],K=[10,306,310,602,764],Q=[1,115],z=[1,116],Z=[1,117],ee=[1,118],te=[1,119],re=[130,353,410],ne=[1,127],ae=[1,126],se=[1,134],ie=[1,164],oe=[1,175],ue=[1,178],ce=[1,173],le=[1,181],he=[1,185],de=[1,160],fe=[1,182],pe=[1,169],be=[1,171],Ee=[1,174],ge=[1,183],me=[1,166],ve=[1,193],Se=[1,188],Te=[1,189],Ae=[1,194],ye=[1,195],Ne=[1,196],Ce=[1,197],Re=[1,198],Oe=[1,199],we=[1,200],Ie=[1,201],xe=[1,202],De=[1,176],ke=[1,177],Le=[1,179],$e=[1,180],Me=[1,186],Ue=[1,192],_e=[1,184],Fe=[1,187],Pe=[1,172],qe=[1,170],Ge=[1,191],Ve=[1,203],Be=[2,4,5],je=[2,471],He=[1,206],Je=[1,211],Ye=[1,220],We=[1,216],Xe=[10,72,78,93,98,118,128,162,168,169,183,198,232,245,247,306,310,602,764],Ke=[2,4,5,10,72,76,77,78,112,115,116,118,122,123,124,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,145,146,148,149,150,152,154,156,162,164,166,168,169,170,171,172,173,175,183,185,187,198,280,281,282,283,284,285,286,287,288,306,310,420,424,602,764],Qe=[2,4,5,10,53,72,74,76,77,78,89,93,95,98,99,107,112,115,116,118,122,123,124,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,145,146,148,149,150,152,154,156,162,164,166,168,169,170,171,172,173,175,179,180,181,183,185,187,189,198,206,208,222,223,224,225,226,227,228,229,232,239,242,243,245,247,266,267,280,281,282,283,284,285,286,287,288,290,296,300,306,308,309,310,311,312,313,314,315,316,317,318,319,320,321,322,323,324,325,326,330,331,332,333,335,338,339,396,400,401,404,406,408,409,417,418,420,424,434,436,437,439,440,441,442,443,447,448,451,452,464,470,505,507,508,517,602,764],ze=[1,249],Ze=[1,256],et=[1,265],tt=[1,270],rt=[1,269],nt=[2,4,5,10,72,77,78,93,98,107,118,128,131,132,137,143,145,149,152,154,156,162,168,169,179,180,181,183,198,232,245,247,265,266,270,271,273,280,281,282,283,284,285,286,287,288,290,291,292,293,294,295,296,297,298,299,302,303,306,310,312,317,420,424,602,764],at=[2,162],st=[1,281],it=[10,74,78,306,310,505,602,764],ot=[2,4,5,10,53,72,74,76,77,78,89,93,95,98,99,107,112,115,116,118,122,123,124,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,145,146,148,149,150,152,154,156,162,164,166,168,169,170,171,172,173,175,179,180,181,183,185,187,189,193,198,206,208,222,223,224,225,226,227,228,229,230,231,232,239,242,243,245,247,266,267,280,281,282,283,284,285,286,287,288,290,296,297,300,302,306,308,309,310,311,312,313,314,315,316,317,318,319,320,321,322,323,324,325,326,330,331,332,333,335,338,339,343,344,356,368,369,370,373,374,386,389,396,400,401,402,403,404,405,406,408,409,417,418,420,424,426,433,434,436,437,439,440,441,442,443,447,448,451,452,464,470,505,507,508,514,515,516,517,602,764],ut=[2,4,5,10,53,72,89,124,146,156,189,266,267,290,306,335,338,339,396,400,401,404,406,408,409,417,418,434,436,437,439,440,441,442,443,447,448,451,452,505,507,508,517,602,764],ct=[1,562],lt=[1,564],ht=[2,503],dt=[1,569],ft=[1,580],pt=[1,583],bt=[1,584],Et=[10,78,89,132,137,146,189,296,306,310,470,602,764],gt=[10,74,306,310,602,764],mt=[2,567],vt=[1,602],St=[2,4,5,156],Tt=[1,640],At=[1,612],yt=[1,646],Nt=[1,647],Ct=[1,620],Rt=[1,631],Ot=[1,618],wt=[1,626],It=[1,619],xt=[1,627],Dt=[1,629],kt=[1,621],Lt=[1,622],$t=[1,641],Mt=[1,638],Ut=[1,639],_t=[1,615],Ft=[1,617],Pt=[1,609],qt=[1,610],Gt=[1,611],Vt=[1,613],Bt=[1,614],jt=[1,616],Ht=[1,623],Jt=[1,624],Yt=[1,628],Wt=[1,630],Xt=[1,632],Kt=[1,633],Qt=[1,634],zt=[1,635],Zt=[1,636],er=[1,642],tr=[1,643],rr=[1,644],nr=[1,645],ar=[2,287],sr=[2,4,5,10,53,72,74,76,77,78,89,93,95,98,99,107,112,115,116,118,122,123,124,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,145,146,148,149,150,152,154,156,162,164,166,168,169,170,171,172,173,175,179,180,181,183,185,187,189,198,206,208,222,223,224,225,226,227,228,229,230,231,232,239,242,243,245,247,266,267,280,281,282,283,284,285,286,287,288,290,296,297,300,306,308,309,310,311,312,313,314,315,316,317,318,319,320,321,322,323,324,325,326,330,331,332,333,335,338,339,343,356,368,369,373,374,396,400,401,404,406,408,409,417,418,420,424,426,434,436,437,439,440,441,442,443,447,448,451,452,464,470,505,507,508,517,602,764],ir=[2,359],or=[1,668],ur=[1,678],cr=[2,4,5,10,53,72,74,76,77,78,89,93,95,98,99,107,112,115,116,118,122,123,124,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,145,146,148,149,150,152,154,156,162,164,166,168,169,170,171,172,173,175,179,180,181,183,185,187,189,198,206,208,222,223,224,225,226,227,228,229,230,231,232,239,242,243,245,247,266,267,280,281,282,283,284,285,286,287,288,290,296,300,306,308,309,310,311,312,313,314,315,316,317,318,319,320,321,322,323,324,325,326,330,331,332,333,335,338,339,396,400,401,404,406,408,409,417,418,420,424,426,434,436,437,439,440,441,442,443,447,448,451,452,464,470,505,507,508,517,602,764],lr=[1,694],hr=[1,703],dr=[1,702],fr=[2,4,5,10,72,74,78,93,98,118,128,162,168,169,206,208,222,223,224,225,226,227,228,229,230,231,232,245,247,306,310,602,764],pr=[10,72,74,78,93,98,118,128,162,168,169,206,208,222,223,224,225,226,227,228,229,230,231,232,245,247,306,310,602,764],br=[2,202],Er=[1,725],gr=[10,72,78,93,98,118,128,162,168,169,183,232,245,247,306,310,602,764],mr=[2,163],vr=[1,728],Sr=[2,4,5,112],Tr=[1,741],Ar=[1,760],yr=[1,740],Nr=[1,739],Cr=[1,734],Rr=[1,735],Or=[1,737],wr=[1,738],Ir=[1,742],xr=[1,743],Dr=[1,744],kr=[1,745],Lr=[1,746],$r=[1,747],Mr=[1,748],Ur=[1,749],_r=[1,750],Fr=[1,751],Pr=[1,752],qr=[1,753],Gr=[1,754],Vr=[1,755],Br=[1,756],jr=[1,757],Hr=[1,759],Jr=[1,761],Yr=[1,762],Wr=[1,763],Xr=[1,764],Kr=[1,765],Qr=[1,766],zr=[1,767],Zr=[1,770],en=[1,771],tn=[1,772],rn=[1,773],nn=[1,774],an=[1,775],sn=[1,776],on=[1,777],un=[1,778],cn=[1,779],ln=[1,780],hn=[1,781],dn=[74,89,189],fn=[10,74,78,154,187,230,297,306,310,343,356,368,369,373,374,602,764],pn=[1,798],bn=[10,74,78,300,306,310,602,764],En=[1,799],gn=[1,805],mn=[1,806],vn=[1,810],Sn=[10,74,78,306,310,602,764],Tn=[2,4,5,77,131,132,137,143,145,149,152,154,156,179,180,181,265,266,270,271,273,280,281,282,283,284,285,286,287,288,290,291,292,293,294,295,296,297,298,299,302,303,312,317,420,424],An=[10,72,78,93,98,107,118,128,162,168,169,183,198,232,245,247,306,310,602,764],yn=[2,4,5,10,72,77,78,93,98,107,118,128,131,132,137,143,145,149,152,154,156,162,164,168,169,179,180,181,183,185,187,195,198,232,245,247,265,266,270,271,273,280,281,282,283,284,285,286,287,288,290,291,292,293,294,295,296,297,298,299,302,303,306,310,312,317,420,424,602,764],Nn=[2,4,5,132,296],Cn=[1,844],Rn=[10,74,76,78,306,310,602,764],On=[2,738],wn=[10,74,76,78,132,139,141,145,152,306,310,420,424,602,764],In=[2,1161],xn=[10,74,76,78,139,141,145,152,306,310,420,424,602,764],Dn=[10,74,76,78,139,141,145,306,310,420,424,602,764],kn=[10,74,78,139,141,306,310,602,764],Ln=[10,78,89,132,146,189,296,306,310,470,602,764],$n=[335,338,339],Mn=[2,764],Un=[1,869],_n=[1,870],Fn=[1,871],Pn=[1,872],qn=[1,881],Gn=[1,880],Vn=[164,166,334],Bn=[2,444],jn=[1,936],Hn=[2,4,5,77,131,156,290,291,292,293],Jn=[1,951],Yn=[2,4,5,10,53,72,74,76,77,78,89,93,95,98,99,107,112,118,122,124,128,129,130,131,132,134,135,137,139,140,141,142,143,145,146,148,149,150,152,154,156,162,164,166,168,169,170,171,172,173,175,179,181,183,185,187,189,198,206,208,222,223,224,225,226,227,228,229,232,239,242,243,245,247,266,267,280,281,282,283,284,285,286,287,288,290,296,300,306,308,309,310,311,313,314,315,317,318,319,320,321,322,323,324,325,326,330,331,332,333,335,338,339,396,400,401,404,406,408,409,417,418,420,424,434,436,437,439,440,441,442,443,447,448,451,452,464,470,505,507,508,517,602,764],Wn=[2,4,5,10,53,72,74,76,77,78,89,93,95,98,99,107,112,115,116,118,122,123,124,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,145,146,148,149,150,152,154,156,162,164,166,168,169,170,171,172,173,175,179,180,181,183,185,187,189,198,206,208,222,223,224,225,226,227,228,229,232,239,242,243,245,247,266,267,280,281,282,283,284,285,286,287,288,290,296,300,306,308,309,310,311,312,313,314,315,317,318,319,320,321,322,323,324,325,326,330,331,332,333,335,338,339,396,400,401,404,406,408,409,417,418,420,424,434,436,437,439,440,441,442,443,447,448,451,452,464,470,505,507,508,517,602,764],Xn=[2,375],Kn=[1,958],Qn=[306,308,310],zn=[74,300],Zn=[74,300,426],ea=[1,965],ta=[2,4,5,10,53,72,74,76,78,89,93,95,98,99,107,112,115,116,118,122,123,124,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,145,146,148,149,150,152,154,156,162,164,166,168,169,170,171,172,173,175,179,180,181,183,185,187,189,198,206,208,222,223,224,225,226,227,228,229,232,239,242,243,245,247,266,267,280,281,282,283,284,285,286,287,288,290,296,300,306,308,309,310,311,312,313,314,315,316,317,318,319,320,321,322,323,324,325,326,330,331,332,333,335,338,339,396,400,401,404,406,408,409,417,418,420,424,434,436,437,439,440,441,442,443,447,448,451,452,464,470,505,507,508,517,602,764],ra=[74,426],na=[1,978],aa=[1,977],sa=[1,984],ia=[10,72,78,93,98,118,128,162,168,169,232,245,247,306,310,602,764],oa=[1,1010],ua=[10,72,78,306,310,602,764],ca=[1,1016],la=[1,1017],ha=[1,1018],da=[2,4,5,10,72,74,76,77,78,112,115,116,118,122,123,124,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,145,146,148,149,150,152,154,156,162,164,166,168,169,170,171,172,173,175,179,180,181,183,185,187,198,280,281,282,283,284,285,286,287,288,306,310,420,424,602,764],fa=[1,1068],pa=[1,1067],ba=[1,1081],Ea=[1,1080],ga=[1,1088],ma=[10,72,74,78,93,98,107,118,128,162,168,169,183,198,232,245,247,306,310,602,764],va=[1,1119],Sa=[10,78,89,146,189,306,310,470,602,764],Ta=[1,1139],Aa=[1,1138],ya=[1,1137],Na=[2,4,5,10,53,72,74,76,77,78,89,93,95,98,99,107,112,115,116,118,122,123,124,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,145,146,148,149,150,152,154,156,162,164,166,168,169,170,171,172,173,175,179,180,181,183,185,187,189,198,206,208,222,223,224,225,226,227,228,229,230,232,239,242,243,245,247,266,267,280,281,282,283,284,285,286,287,288,290,296,297,300,306,308,309,310,311,312,313,314,315,316,317,318,319,320,321,322,323,324,325,326,330,331,332,333,335,338,339,343,356,368,369,373,374,396,400,401,404,406,408,409,417,418,420,424,434,436,437,439,440,441,442,443,447,448,451,452,464,470,505,507,508,517,602,764],Ca=[1,1153],Ra=[2,4,5,10,53,72,74,76,77,78,89,93,95,98,99,107,112,118,122,124,128,129,130,131,132,134,135,137,139,140,143,145,146,148,149,150,152,154,156,162,164,166,168,169,170,171,172,173,175,181,183,185,187,189,198,206,208,222,223,224,225,226,227,228,229,232,239,242,243,245,247,266,267,280,281,282,283,284,285,286,287,288,290,296,300,306,308,309,310,311,313,314,315,320,321,322,323,324,325,326,330,331,332,333,335,338,339,396,400,401,404,406,408,409,417,418,420,424,434,436,437,439,440,441,442,443,447,448,451,452,464,470,505,507,508,517,602,764],Oa=[2,4,5,10,53,72,74,76,77,78,89,93,95,98,99,107,112,118,122,124,128,129,130,131,132,134,135,137,139,140,143,145,146,148,149,150,152,154,156,162,164,166,168,169,170,171,172,173,175,181,183,185,187,189,198,206,208,222,223,224,225,226,227,228,229,232,239,242,243,245,247,266,267,280,281,282,283,284,285,286,287,288,290,296,300,306,308,309,310,311,313,315,320,321,322,323,324,325,326,330,331,332,333,335,338,339,396,400,401,404,406,408,409,417,418,420,424,434,436,437,439,440,441,442,443,447,448,451,452,464,470,505,507,508,517,602,764],wa=[2,4,5,10,53,72,74,76,77,78,89,93,95,98,99,107,112,118,122,124,128,129,130,131,132,133,134,135,137,138,139,140,141,142,143,145,146,148,149,150,152,154,156,162,164,166,168,169,170,171,172,173,175,179,180,181,183,185,187,189,198,206,208,222,223,224,225,226,227,228,229,232,239,242,243,245,247,266,267,280,281,282,283,284,285,286,287,288,290,296,300,306,308,309,310,311,313,314,315,317,318,319,320,321,322,323,324,325,326,330,331,332,333,335,338,339,396,400,401,404,406,408,409,417,418,420,424,434,436,437,439,440,441,442,443,447,448,451,452,464,470,505,507,508,517,602,764],Ia=[2,4,5,10,53,72,74,76,77,78,89,93,95,98,99,107,112,118,122,124,128,129,130,131,132,134,135,137,139,140,141,142,143,145,146,148,149,150,152,154,156,162,164,166,168,169,170,171,172,173,175,181,183,185,187,189,198,206,208,222,223,224,225,226,227,228,229,232,239,242,243,245,247,266,267,280,281,282,283,284,285,286,287,288,290,296,300,306,308,309,310,311,313,314,315,318,319,320,321,322,323,324,325,326,330,331,332,333,335,338,339,396,400,401,404,406,408,409,417,418,420,424,434,436,437,439,440,441,442,443,447,448,451,452,464,470,505,507,508,517,602,764],xa=[2,4,5,10,53,72,74,76,77,78,89,93,95,98,99,107,118,122,124,128,129,130,131,132,134,135,137,139,140,143,145,146,148,149,150,152,154,156,162,164,166,168,169,170,171,172,173,175,181,183,185,187,189,198,206,208,222,223,224,225,226,227,228,229,232,239,242,243,245,247,266,267,280,281,282,283,284,285,286,287,288,290,296,300,306,308,309,310,314,320,321,322,323,324,325,326,330,331,333,335,338,339,396,400,401,404,406,408,409,417,418,420,424,434,436,437,439,440,441,442,443,447,448,451,452,464,470,505,507,508,517,602,764],Da=[2,406],ka=[2,4,5,10,53,72,74,76,77,78,89,93,95,98,107,118,122,128,129,130,131,132,134,135,137,143,145,146,148,149,150,152,156,162,164,166,168,169,170,171,172,173,175,181,183,185,187,189,198,206,208,222,223,224,225,226,227,228,229,232,239,242,243,245,247,266,267,280,281,282,283,284,285,286,287,288,290,296,300,306,308,309,310,314,330,331,333,335,338,339,396,400,401,404,406,408,409,417,418,420,424,434,436,437,439,440,441,442,443,447,448,451,452,464,470,505,507,508,517,602,764],La=[2,285],$a=[2,4,5,10,53,72,74,76,77,78,89,93,95,98,99,107,112,115,116,118,122,123,124,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,145,146,148,149,150,152,154,156,162,164,166,168,169,170,171,172,173,175,179,180,181,183,185,187,189,198,206,208,222,223,224,225,226,227,228,229,232,239,242,243,245,247,266,267,280,281,282,283,284,285,286,287,288,290,296,300,306,308,309,310,311,312,313,314,315,316,317,318,319,320,321,322,323,324,325,326,330,331,332,333,335,338,339,396,400,401,404,406,408,409,417,418,420,424,426,434,436,437,439,440,441,442,443,447,448,451,452,464,470,505,507,508,517,602,764],Ma=[10,78,306,310,602,764],Ua=[1,1189],_a=[10,77,78,143,145,152,181,302,306,310,420,424,602,764],Fa=[10,74,78,306,308,310,464,602,764],Pa=[1,1200],qa=[10,72,78,118,128,162,168,169,232,245,247,306,310,602,764],Ga=[10,72,74,78,93,98,118,128,162,168,169,183,198,232,245,247,306,310,602,764],Va=[2,4,5,72,76,77,78,112,115,116,118,122,123,124,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,145,146,148,149,150,152,154,156,162,164,166,168,169,170,171,172,173,175,185,187,280,281,282,283,284,285,286,287,288,420,424],Ba=[2,4,5,72,74,76,77,78,112,115,116,118,122,123,124,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,145,146,148,149,150,152,154,156,162,164,166,168,169,170,171,172,173,175,185,187,280,281,282,283,284,285,286,287,288,420,424],ja=[2,1085],Ha=[2,4,5,72,74,76,77,112,115,116,118,122,123,124,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,145,146,148,149,150,152,154,156,162,164,166,168,169,170,171,172,173,175,185,187,280,281,282,283,284,285,286,287,288,420,424],Ja=[1,1252],Ya=[10,74,78,128,306,308,310,464,602,764],Wa=[115,116,124],Xa=[2,584],Ka=[1,1280],Qa=[76,139],za=[2,724],Za=[1,1297],es=[1,1298],ts=[2,4,5,10,53,72,76,89,124,146,156,189,230,266,267,290,306,310,335,338,339,396,400,401,404,406,408,409,417,418,434,436,437,439,440,441,442,443,447,448,451,452,505,507,508,517,602,764],rs=[2,330],ns=[1,1322],as=[1,1336],ss=[1,1338],is=[2,487],os=[74,78],us=[10,306,308,310,464,602,764],cs=[10,72,78,118,162,168,169,232,245,247,306,310,602,764],ls=[1,1354],hs=[1,1358],ds=[1,1359],fs=[1,1361],ps=[1,1362],bs=[1,1363],Es=[1,1364],gs=[1,1365],ms=[1,1366],vs=[1,1367],Ss=[1,1368],Ts=[10,72,74,78,93,98,118,128,162,168,169,206,208,222,223,224,225,226,227,228,229,232,245,247,306,310,602,764],As=[1,1393],ys=[10,72,78,118,162,168,169,245,247,306,310,602,764],Ns=[10,72,78,93,98,118,128,162,168,169,206,208,222,223,224,225,226,227,228,229,232,245,247,306,310,602,764],Cs=[1,1490],Rs=[1,1492],Os=[2,4,5,77,143,145,152,156,181,290,291,292,293,302,420,424],ws=[1,1506],Is=[10,72,74,78,162,168,169,245,247,306,310,602,764],xs=[1,1524],Ds=[1,1526],ks=[1,1527],Ls=[1,1523],$s=[1,1522],Ms=[1,1521],Us=[1,1528],_s=[1,1518],Fs=[1,1519],Ps=[1,1520],qs=[1,1545],Gs=[2,4,5,10,53,72,89,124,146,156,189,266,267,290,306,310,335,338,339,396,400,401,404,406,408,409,417,418,434,436,437,439,440,441,442,443,447,448,451,452,505,507,508,517,602,764],Vs=[1,1556],Bs=[1,1564],js=[1,1563],Hs=[10,72,78,162,168,169,245,247,306,310,602,764],Js=[10,72,78,93,98,118,128,162,168,169,206,208,222,223,224,225,226,227,228,229,230,231,232,245,247,306,310,602,764],Ys=[2,4,5,10,72,78,93,98,118,128,162,168,169,206,208,222,223,224,225,226,227,228,229,230,231,232,245,247,306,310,602,764],Ws=[1,1621],Xs=[1,1623],Ks=[1,1620],Qs=[1,1622],zs=[187,193,368,369,370,373],Zs=[2,515],ei=[1,1628],ti=[1,1647],ri=[10,72,78,162,168,169,306,310,602,764],ni=[1,1657],ai=[1,1658],si=[1,1659],ii=[1,1678],oi=[4,10,243,306,310,343,356,602,764],ui=[1,1726],ci=[10,72,74,78,118,162,168,169,239,245,247,306,310,602,764],li=[2,4,5,77],hi=[1,1820],di=[1,1832],fi=[1,1851],pi=[10,72,78,162,168,169,306,310,415,602,764],bi=[10,74,78,230,306,310,602,764],Ei={trace:function(){},yy:{},symbols_:{error:2,Literal:3,LITERAL:4,BRALITERAL:5,NonReserved:6,LiteralWithSpaces:7,main:8,Statements:9,EOF:10,Statements_group0:11,AStatement:12,ExplainStatement:13,EXPLAIN:14,QUERY:15,PLAN:16,Statement:17,AlterTable:18,AttachDatabase:19,Call:20,CreateDatabase:21,CreateIndex:22,CreateGraph:23,CreateTable:24,CreateView:25,CreateEdge:26,CreateVertex:27,Declare:28,Delete:29,DetachDatabase:30,DropDatabase:31,DropIndex:32,DropTable:33,DropView:34,If:35,Insert:36,Merge:37,Reindex:38,RenameTable:39,Select:40,ShowCreateTable:41,ShowColumns:42,ShowDatabases:43,ShowIndex:44,ShowTables:45,TruncateTable:46,WithSelect:47,CreateTrigger:48,DropTrigger:49,BeginTransaction:50,CommitTransaction:51,RollbackTransaction:52,EndTransaction:53,UseDatabase:54,Update:55,JavaScript:56,Source:57,Assert:58,While:59,Continue:60,Break:61,BeginEnd:62,Print:63,Require:64,SetVariable:65,ExpressionStatement:66,AddRule:67,Query:68,Echo:69,CreateFunction:70,CreateAggregate:71,WITH:72,WithTablesList:73,COMMA:74,WithTable:75,AS:76,LPAR:77,RPAR:78,SelectClause:79,Select_option0:80,IntoClause:81,FromClause:82,Select_option1:83,WhereClause:84,GroupClause:85,OrderClause:86,LimitClause:87,UnionClause:88,SEARCH:89,Select_repetition0:90,Select_option2:91,PivotClause:92,PIVOT:93,Expression:94,FOR:95,PivotClause_option0:96,PivotClause_option1:97,UNPIVOT:98,IN:99,ColumnsList:100,PivotClause_option2:101,PivotClause2:102,AsList:103,AsLiteral:104,AsPart:105,RemoveClause:106,REMOVE:107,RemoveClause_option0:108,RemoveColumnsList:109,RemoveColumn:110,Column:111,LIKE:112,StringValue:113,ArrowDot:114,ARROW:115,DOT:116,SearchSelector:117,ORDER:118,BY:119,OrderExpressionsList:120,SearchSelector_option0:121,DOTDOT:122,CARET:123,EQ:124,SearchSelector_repetition_plus0:125,SearchSelector_repetition_plus1:126,SearchSelector_option1:127,WHERE:128,OF:129,CLASS:130,NUMBER:131,STRING:132,SLASH:133,VERTEX:134,EDGE:135,EXCLAMATION:136,SHARP:137,MODULO:138,GT:139,LT:140,GTGT:141,LTLT:142,DOLLAR:143,Json:144,AT:145,SET:146,SetColumnsList:147,TO:148,VALUE:149,ROW:150,ExprList:151,COLON:152,PlusStar:153,NOT:154,SearchSelector_repetition2:155,IF:156,SearchSelector_repetition3:157,Aggregator:158,SearchSelector_repetition4:159,SearchSelector_group0:160,SearchSelector_repetition5:161,UNION:162,SearchSelectorList:163,ALL:164,SearchSelector_repetition6:165,ANY:166,SearchSelector_repetition7:167,INTERSECT:168,EXCEPT:169,AND:170,OR:171,PATH:172,RETURN:173,ResultColumns:174,REPEAT:175,SearchSelector_repetition8:176,SearchSelectorList_repetition0:177,SearchSelectorList_repetition1:178,PLUS:179,STAR:180,QUESTION:181,SearchFrom:182,FROM:183,SelectModifier:184,DISTINCT:185,TopClause:186,UNIQUE:187,SelectClause_option0:188,SELECT:189,COLUMN:190,MATRIX:191,TEXTSTRING:192,INDEX:193,RECORDSET:194,TOP:195,NumValue:196,TopClause_option0:197,INTO:198,Table:199,FuncValue:200,ParamValue:201,VarValue:202,FromTablesList:203,JoinTablesList:204,ApplyClause:205,CROSS:206,APPLY:207,OUTER:208,FromTable:209,FromTable_option0:210,FromTable_option1:211,INDEXED:212,INSERTED:213,FromString:214,JoinTable:215,JoinMode:216,JoinTableAs:217,OnClause:218,JoinTableAs_option0:219,JoinTableAs_option1:220,JoinModeMode:221,NATURAL:222,JOIN:223,INNER:224,LEFT:225,RIGHT:226,FULL:227,SEMI:228,ANTI:229,ON:230,USING:231,GROUP:232,GroupExpressionsList:233,HavingClause:234,GroupExpression:235,GROUPING:236,ROLLUP:237,CUBE:238,HAVING:239,CORRESPONDING:240,OrderExpression:241,DIRECTION:242,COLLATE:243,NOCASE:244,LIMIT:245,OffsetClause:246,OFFSET:247,LimitClause_option0:248,FETCH:249,LimitClause_option1:250,LimitClause_option2:251,LimitClause_option3:252,ResultColumn:253,Star:254,AggrValue:255,Op:256,LogicValue:257,NullValue:258,ExistsValue:259,CaseValue:260,CastClause:261,ArrayValue:262,NewClause:263,Expression_group0:264,CURRENT_TIMESTAMP:265,JAVASCRIPT:266,CREATE:267,FUNCTION:268,AGGREGATE:269,NEW:270,CAST:271,ColumnType:272,CONVERT:273,PrimitiveValue:274,OverClause:275,OVER:276,OverPartitionClause:277,OverOrderByClause:278,PARTITION:279,SUM:280,COUNT:281,MIN:282,MAX:283,AVG:284,FIRST:285,LAST:286,AGGR:287,ARRAY:288,FuncValue_option0:289,REPLACE:290,DATEADD:291,DATEDIFF:292,INTERVAL:293,TRUE:294,FALSE:295,NSTRING:296,NULL:297,EXISTS:298,ARRAYLBRA:299,RBRA:300,ParamValue_group0:301,BRAQUESTION:302,CASE:303,WhensList:304,ElseClause:305,END:306,When:307,WHEN:308,THEN:309,ELSE:310,REGEXP:311,TILDA:312,GLOB:313,ESCAPE:314,NOT_LIKE:315,BARBAR:316,MINUS:317,AMPERSAND:318,BAR:319,GE:320,LE:321,EQEQ:322,EQEQEQ:323,NE:324,NEEQEQ:325,NEEQEQEQ:326,CondOp:327,AllSome:328,ColFunc:329,BETWEEN:330,NOT_BETWEEN:331,IS:332,DOUBLECOLON:333,SOME:334,UPDATE:335,SetColumn:336,SetColumn_group0:337,DELETE:338,INSERT:339,Into:340,Values:341,ValuesListsList:342,DEFAULT:343,VALUES:344,ValuesList:345,Value:346,DateValue:347,TemporaryClause:348,TableClass:349,IfNotExists:350,CreateTableDefClause:351,CreateTableOptionsClause:352,TABLE:353,CreateTableOptions:354,CreateTableOption:355,IDENTITY:356,TEMP:357,ColumnDefsList:358,ConstraintsList:359,Constraint:360,ConstraintName:361,PrimaryKey:362,ForeignKey:363,UniqueKey:364,IndexKey:365,Check:366,CONSTRAINT:367,CHECK:368,PRIMARY:369,KEY:370,PrimaryKey_option0:371,ColsList:372,FOREIGN:373,REFERENCES:374,ForeignKey_option0:375,OnForeignKeyClause:376,ParColsList:377,OnDeleteClause:378,OnUpdateClause:379,NO:380,ACTION:381,UniqueKey_option0:382,UniqueKey_option1:383,ColumnDef:384,ColumnConstraintsClause:385,ColumnConstraints:386,SingularColumnType:387,NumberMax:388,ENUM:389,MAXNUM:390,ColumnConstraintsList:391,ColumnConstraint:392,ParLiteral:393,ColumnConstraint_option0:394,ColumnConstraint_option1:395,DROP:396,DropTable_group0:397,IfExists:398,TablesList:399,ALTER:400,RENAME:401,ADD:402,MODIFY:403,ATTACH:404,DATABASE:405,DETACH:406,AsClause:407,USE:408,SHOW:409,VIEW:410,CreateView_option0:411,CreateView_option1:412,SubqueryRestriction:413,READ:414,ONLY:415,OPTION:416,SOURCE:417,ASSERT:418,JsonObject:419,ATLBRA:420,JsonArray:421,JsonValue:422,JsonPrimitiveValue:423,LCUR:424,JsonPropertiesList:425,RCUR:426,JsonElementsList:427,JsonProperty:428,OnOff:429,SetPropsList:430,AtDollar:431,SetProp:432,OFF:433,COMMIT:434,TRANSACTION:435,ROLLBACK:436,BEGIN:437,ElseStatement:438,WHILE:439,CONTINUE:440,BREAK:441,PRINT:442,REQUIRE:443,StringValuesList:444,PluginsList:445,Plugin:446,ECHO:447,DECLARE:448,DeclaresList:449,DeclareItem:450,TRUNCATE:451,MERGE:452,MergeInto:453,MergeUsing:454,MergeOn:455,MergeMatchedList:456,OutputClause:457,MergeMatched:458,MergeNotMatched:459,MATCHED:460,MergeMatchedAction:461,MergeNotMatchedAction:462,TARGET:463,OUTPUT:464,CreateVertex_option0:465,CreateVertex_option1:466,CreateVertex_option2:467,CreateVertexSet:468,SharpValue:469,CONTENT:470,CreateEdge_option0:471,GRAPH:472,GraphList:473,GraphVertexEdge:474,GraphElement:475,GraphVertexEdge_option0:476,GraphVertexEdge_option1:477,GraphElementVar:478,GraphVertexEdge_option2:479,GraphVertexEdge_option3:480,GraphVertexEdge_option4:481,GraphVar:482,GraphAsClause:483,GraphAtClause:484,GraphElement2:485,GraphElement2_option0:486,GraphElement2_option1:487,GraphElement2_option2:488,GraphElement2_option3:489,GraphElement_option0:490,GraphElement_option1:491,GraphElement_option2:492,SharpLiteral:493,GraphElement_option3:494,GraphElement_option4:495,GraphElement_option5:496,ColonLiteral:497,DeleteVertex:498,DeleteVertex_option0:499,DeleteEdge:500,DeleteEdge_option0:501,DeleteEdge_option1:502,DeleteEdge_option2:503,Term:504,COLONDASH:505,TermsList:506,QUESTIONDASH:507,CALL:508,TRIGGER:509,BeforeAfter:510,InsertDeleteUpdate:511,CreateTrigger_option0:512,CreateTrigger_option1:513,BEFORE:514,AFTER:515,INSTEAD:516,REINDEX:517,A:518,ABSENT:519,ABSOLUTE:520,ACCORDING:521,ADA:522,ADMIN:523,ALWAYS:524,ASC:525,ASSERTION:526,ASSIGNMENT:527,ATTRIBUTE:528,ATTRIBUTES:529,BASE64:530,BERNOULLI:531,BLOCKED:532,BOM:533,BREADTH:534,C:535,CASCADE:536,CATALOG:537,CATALOG_NAME:538,CHAIN:539,CHARACTERISTICS:540,CHARACTERS:541,CHARACTER_SET_CATALOG:542,CHARACTER_SET_NAME:543,CHARACTER_SET_SCHEMA:544,CLASS_ORIGIN:545,COBOL:546,COLLATION:547,COLLATION_CATALOG:548,COLLATION_NAME:549,COLLATION_SCHEMA:550,COLUMNS:551,COLUMN_NAME:552,COMMAND_FUNCTION:553,COMMAND_FUNCTION_CODE:554,COMMITTED:555,CONDITION_NUMBER:556,CONNECTION:557,CONNECTION_NAME:558,CONSTRAINTS:559,CONSTRAINT_CATALOG:560,CONSTRAINT_NAME:561,CONSTRAINT_SCHEMA:562,CONSTRUCTOR:563,CONTROL:564,CURSOR_NAME:565,DATA:566,DATETIME_INTERVAL_CODE:567,DATETIME_INTERVAL_PRECISION:568,DB:569,DEFAULTS:570,DEFERRABLE:571,DEFERRED:572,DEFINED:573,DEFINER:574,DEGREE:575,DEPTH:576,DERIVED:577,DESC:578,DESCRIPTOR:579,DIAGNOSTICS:580,DISPATCH:581,DOCUMENT:582,DOMAIN:583,DYNAMIC_FUNCTION:584,DYNAMIC_FUNCTION_CODE:585,EMPTY:586,ENCODING:587,ENFORCED:588,EXCLUDE:589,EXCLUDING:590,EXPRESSION:591,FILE:592,FINAL:593,FLAG:594,FOLLOWING:595,FORTRAN:596,FOUND:597,FS:598,G:599,GENERAL:600,GENERATED:601,GO:602,GOTO:603,GRANTED:604,HEX:605,HIERARCHY:606,ID:607,IGNORE:608,IMMEDIATE:609,IMMEDIATELY:610,IMPLEMENTATION:611,INCLUDING:612,INCREMENT:613,INDENT:614,INITIALLY:615,INPUT:616,INSTANCE:617,INSTANTIABLE:618,INTEGRITY:619,INVOKER:620,ISOLATION:621,K:622,KEY_MEMBER:623,KEY_TYPE:624,LENGTH:625,LEVEL:626,LIBRARY:627,LINK:628,LOCATION:629,LOCATOR:630,M:631,MAP:632,MAPPING:633,MAXVALUE:634,MESSAGE_LENGTH:635,MESSAGE_OCTET_LENGTH:636,MESSAGE_TEXT:637,MINVALUE:638,MORE:639,MUMPS:640,NAME:641,NAMES:642,NAMESPACE:643,NESTING:644,NEXT:645,NFC:646,NFD:647,NFKC:648,NFKD:649,NIL:650,NORMALIZED:651,NULLABLE:652,NULLS:653,OBJECT:654,OCTETS:655,OPTIONS:656,ORDERING:657,ORDINALITY:658,OTHERS:659,OVERRIDING:660,P:661,PAD:662,PARAMETER_MODE:663,PARAMETER_NAME:664,PARAMETER_ORDINAL_POSITION:665,PARAMETER_SPECIFIC_CATALOG:666,PARAMETER_SPECIFIC_NAME:667,PARAMETER_SPECIFIC_SCHEMA:668,PARTIAL:669,PASCAL:670,PASSING:671,PASSTHROUGH:672,PERMISSION:673,PLACING:674,PLI:675,PRECEDING:676,PRESERVE:677,PRIOR:678,PRIVILEGES:679,PUBLIC:680,RECOVERY:681,RELATIVE:682,REPEATABLE:683,REQUIRING:684,RESPECT:685,RESTART:686,RESTORE:687,RESTRICT:688,RETURNED_CARDINALITY:689,RETURNED_LENGTH:690,RETURNED_OCTET_LENGTH:691,RETURNED_SQLSTATE:692,RETURNING:693,ROLE:694,ROUTINE:695,ROUTINE_CATALOG:696,ROUTINE_NAME:697,ROUTINE_SCHEMA:698,ROW_COUNT:699,SCALE:700,SCHEMA:701,SCHEMA_NAME:702,SCOPE_CATALOG:703,SCOPE_NAME:704,SCOPE_SCHEMA:705,SECTION:706,SECURITY:707,SELECTIVE:708,SELF:709,SEQUENCE:710,SERIALIZABLE:711,SERVER:712,SERVER_NAME:713,SESSION:714,SETS:715,SIMPLE:716,SIZE:717,SPACE:718,SPECIFIC_NAME:719,STANDALONE:720,STATE:721,STATEMENT:722,STRIP:723,STRUCTURE:724,STYLE:725,SUBCLASS_ORIGIN:726,T:727,TABLE_NAME:728,TEMPORARY:729,TIES:730,TOKEN:731,TOP_LEVEL_COUNT:732,TRANSACTIONS_COMMITTED:733,TRANSACTIONS_ROLLED_BACK:734,TRANSACTION_ACTIVE:735,TRANSFORM:736,TRANSFORMS:737,TRIGGER_CATALOG:738,TRIGGER_NAME:739,TRIGGER_SCHEMA:740,TYPE:741,UNBOUNDED:742,UNCOMMITTED:743,UNDER:744,UNLINK:745,UNNAMED:746,UNTYPED:747,URI:748,USAGE:749,USER_DEFINED_TYPE_CATALOG:750,USER_DEFINED_TYPE_CODE:751,USER_DEFINED_TYPE_NAME:752,USER_DEFINED_TYPE_SCHEMA:753,VALID:754,VERSION:755,WHITESPACE:756,WORK:757,WRAPPER:758,WRITE:759,XMLDECLARATION:760,XMLSCHEMA:761,YES:762,ZONE:763,SEMICOLON:764,PERCENT:765,ROWS:766,FuncValue_option0_group0:767,$accept:0,$end:1},terminals_:{2:"error",4:"LITERAL",5:"BRALITERAL",10:"EOF",14:"EXPLAIN",15:"QUERY",16:"PLAN",53:"EndTransaction",72:"WITH",74:"COMMA",76:"AS",77:"LPAR",78:"RPAR",89:"SEARCH",93:"PIVOT",95:"FOR",98:"UNPIVOT",99:"IN",107:"REMOVE",112:"LIKE",115:"ARROW",116:"DOT",118:"ORDER",119:"BY",122:"DOTDOT",123:"CARET",124:"EQ",128:"WHERE",129:"OF",130:"CLASS",131:"NUMBER",132:"STRING",133:"SLASH",134:"VERTEX",135:"EDGE",136:"EXCLAMATION",137:"SHARP",138:"MODULO",139:"GT",140:"LT",141:"GTGT",142:"LTLT",143:"DOLLAR",145:"AT",146:"SET",148:"TO",149:"VALUE",150:"ROW",152:"COLON",154:"NOT",156:"IF",162:"UNION",164:"ALL",166:"ANY",168:"INTERSECT",169:"EXCEPT",170:"AND",171:"OR",172:"PATH",173:"RETURN",175:"REPEAT",179:"PLUS",180:"STAR",181:"QUESTION",183:"FROM",185:"DISTINCT",187:"UNIQUE",189:"SELECT",190:"COLUMN",191:"MATRIX",192:"TEXTSTRING",193:"INDEX",194:"RECORDSET",195:"TOP",198:"INTO",206:"CROSS",207:"APPLY",208:"OUTER",212:"INDEXED",213:"INSERTED",222:"NATURAL",223:"JOIN",224:"INNER",225:"LEFT",226:"RIGHT",227:"FULL",228:"SEMI",229:"ANTI",230:"ON",231:"USING",232:"GROUP",236:"GROUPING",237:"ROLLUP",238:"CUBE",239:"HAVING",240:"CORRESPONDING",242:"DIRECTION",243:"COLLATE",244:"NOCASE",245:"LIMIT",247:"OFFSET",249:"FETCH",265:"CURRENT_TIMESTAMP",266:"JAVASCRIPT",267:"CREATE",268:"FUNCTION",269:"AGGREGATE",270:"NEW",271:"CAST",273:"CONVERT",276:"OVER",279:"PARTITION",280:"SUM",281:"COUNT",282:"MIN",283:"MAX",284:"AVG",285:"FIRST",286:"LAST",287:"AGGR",288:"ARRAY",290:"REPLACE",291:"DATEADD",292:"DATEDIFF",293:"INTERVAL",294:"TRUE",295:"FALSE",296:"NSTRING",297:"NULL",298:"EXISTS",299:"ARRAYLBRA",300:"RBRA",302:"BRAQUESTION",303:"CASE",306:"END",308:"WHEN",309:"THEN",310:"ELSE",311:"REGEXP",312:"TILDA",313:"GLOB",314:"ESCAPE",315:"NOT_LIKE",316:"BARBAR",317:"MINUS",318:"AMPERSAND",319:"BAR",320:"GE",321:"LE",322:"EQEQ",323:"EQEQEQ",324:"NE",325:"NEEQEQ",326:"NEEQEQEQ",330:"BETWEEN",331:"NOT_BETWEEN",332:"IS",333:"DOUBLECOLON",334:"SOME",335:"UPDATE",338:"DELETE",339:"INSERT",343:"DEFAULT",344:"VALUES",347:"DateValue",353:"TABLE",356:"IDENTITY",357:"TEMP",367:"CONSTRAINT",368:"CHECK",369:"PRIMARY",370:"KEY",373:"FOREIGN",374:"REFERENCES",380:"NO",381:"ACTION",386:"ColumnConstraints",389:"ENUM",390:"MAXNUM",396:"DROP",400:"ALTER",401:"RENAME",402:"ADD",403:"MODIFY",404:"ATTACH",405:"DATABASE",406:"DETACH",408:"USE",409:"SHOW",410:"VIEW",414:"READ",415:"ONLY",416:"OPTION",417:"SOURCE",418:"ASSERT",420:"ATLBRA",424:"LCUR",426:"RCUR",433:"OFF",434:"COMMIT",435:"TRANSACTION",436:"ROLLBACK",437:"BEGIN",439:"WHILE",440:"CONTINUE",441:"BREAK",442:"PRINT",443:"REQUIRE",447:"ECHO",448:"DECLARE",451:"TRUNCATE",452:"MERGE",460:"MATCHED",463:"TARGET",464:"OUTPUT",470:"CONTENT",472:"GRAPH",505:"COLONDASH",507:"QUESTIONDASH",508:"CALL",509:"TRIGGER",514:"BEFORE",515:"AFTER",516:"INSTEAD",517:"REINDEX",518:"A",519:"ABSENT",520:"ABSOLUTE",521:"ACCORDING",522:"ADA",523:"ADMIN",524:"ALWAYS",525:"ASC",526:"ASSERTION",527:"ASSIGNMENT",528:"ATTRIBUTE",529:"ATTRIBUTES",530:"BASE64",531:"BERNOULLI",532:"BLOCKED",533:"BOM",534:"BREADTH",535:"C",536:"CASCADE",537:"CATALOG",538:"CATALOG_NAME",539:"CHAIN",540:"CHARACTERISTICS",541:"CHARACTERS",542:"CHARACTER_SET_CATALOG",543:"CHARACTER_SET_NAME",544:"CHARACTER_SET_SCHEMA",545:"CLASS_ORIGIN",546:"COBOL",547:"COLLATION",548:"COLLATION_CATALOG",549:"COLLATION_NAME",550:"COLLATION_SCHEMA",551:"COLUMNS",552:"COLUMN_NAME",
 553:"COMMAND_FUNCTION",554:"COMMAND_FUNCTION_CODE",555:"COMMITTED",556:"CONDITION_NUMBER",557:"CONNECTION",558:"CONNECTION_NAME",559:"CONSTRAINTS",560:"CONSTRAINT_CATALOG",561:"CONSTRAINT_NAME",562:"CONSTRAINT_SCHEMA",563:"CONSTRUCTOR",564:"CONTROL",565:"CURSOR_NAME",566:"DATA",567:"DATETIME_INTERVAL_CODE",568:"DATETIME_INTERVAL_PRECISION",569:"DB",570:"DEFAULTS",571:"DEFERRABLE",572:"DEFERRED",573:"DEFINED",574:"DEFINER",575:"DEGREE",576:"DEPTH",577:"DERIVED",578:"DESC",579:"DESCRIPTOR",580:"DIAGNOSTICS",581:"DISPATCH",582:"DOCUMENT",583:"DOMAIN",584:"DYNAMIC_FUNCTION",585:"DYNAMIC_FUNCTION_CODE",586:"EMPTY",587:"ENCODING",588:"ENFORCED",589:"EXCLUDE",590:"EXCLUDING",591:"EXPRESSION",592:"FILE",593:"FINAL",594:"FLAG",595:"FOLLOWING",596:"FORTRAN",597:"FOUND",598:"FS",599:"G",600:"GENERAL",601:"GENERATED",602:"GO",603:"GOTO",604:"GRANTED",605:"HEX",606:"HIERARCHY",607:"ID",608:"IGNORE",609:"IMMEDIATE",610:"IMMEDIATELY",611:"IMPLEMENTATION",612:"INCLUDING",613:"INCREMENT",614:"INDENT",615:"INITIALLY",616:"INPUT",617:"INSTANCE",618:"INSTANTIABLE",619:"INTEGRITY",620:"INVOKER",621:"ISOLATION",622:"K",623:"KEY_MEMBER",624:"KEY_TYPE",625:"LENGTH",626:"LEVEL",627:"LIBRARY",628:"LINK",629:"LOCATION",630:"LOCATOR",631:"M",632:"MAP",633:"MAPPING",634:"MAXVALUE",635:"MESSAGE_LENGTH",636:"MESSAGE_OCTET_LENGTH",637:"MESSAGE_TEXT",638:"MINVALUE",639:"MORE",640:"MUMPS",641:"NAME",642:"NAMES",643:"NAMESPACE",644:"NESTING",645:"NEXT",646:"NFC",647:"NFD",648:"NFKC",649:"NFKD",650:"NIL",651:"NORMALIZED",652:"NULLABLE",653:"NULLS",654:"OBJECT",655:"OCTETS",656:"OPTIONS",657:"ORDERING",658:"ORDINALITY",659:"OTHERS",660:"OVERRIDING",661:"P",662:"PAD",663:"PARAMETER_MODE",664:"PARAMETER_NAME",665:"PARAMETER_ORDINAL_POSITION",666:"PARAMETER_SPECIFIC_CATALOG",667:"PARAMETER_SPECIFIC_NAME",668:"PARAMETER_SPECIFIC_SCHEMA",669:"PARTIAL",670:"PASCAL",671:"PASSING",672:"PASSTHROUGH",673:"PERMISSION",674:"PLACING",675:"PLI",676:"PRECEDING",677:"PRESERVE",678:"PRIOR",679:"PRIVILEGES",680:"PUBLIC",681:"RECOVERY",682:"RELATIVE",683:"REPEATABLE",684:"REQUIRING",685:"RESPECT",686:"RESTART",687:"RESTORE",688:"RESTRICT",689:"RETURNED_CARDINALITY",690:"RETURNED_LENGTH",691:"RETURNED_OCTET_LENGTH",692:"RETURNED_SQLSTATE",693:"RETURNING",694:"ROLE",695:"ROUTINE",696:"ROUTINE_CATALOG",697:"ROUTINE_NAME",698:"ROUTINE_SCHEMA",699:"ROW_COUNT",700:"SCALE",701:"SCHEMA",702:"SCHEMA_NAME",703:"SCOPE_CATALOG",704:"SCOPE_NAME",705:"SCOPE_SCHEMA",706:"SECTION",707:"SECURITY",708:"SELECTIVE",709:"SELF",710:"SEQUENCE",711:"SERIALIZABLE",712:"SERVER",713:"SERVER_NAME",714:"SESSION",715:"SETS",716:"SIMPLE",717:"SIZE",718:"SPACE",719:"SPECIFIC_NAME",720:"STANDALONE",721:"STATE",722:"STATEMENT",723:"STRIP",724:"STRUCTURE",725:"STYLE",726:"SUBCLASS_ORIGIN",727:"T",728:"TABLE_NAME",729:"TEMPORARY",730:"TIES",731:"TOKEN",732:"TOP_LEVEL_COUNT",733:"TRANSACTIONS_COMMITTED",734:"TRANSACTIONS_ROLLED_BACK",735:"TRANSACTION_ACTIVE",736:"TRANSFORM",737:"TRANSFORMS",738:"TRIGGER_CATALOG",739:"TRIGGER_NAME",740:"TRIGGER_SCHEMA",741:"TYPE",742:"UNBOUNDED",743:"UNCOMMITTED",744:"UNDER",745:"UNLINK",746:"UNNAMED",747:"UNTYPED",748:"URI",749:"USAGE",750:"USER_DEFINED_TYPE_CATALOG",751:"USER_DEFINED_TYPE_CODE",752:"USER_DEFINED_TYPE_NAME",753:"USER_DEFINED_TYPE_SCHEMA",754:"VALID",755:"VERSION",756:"WHITESPACE",757:"WORK",758:"WRAPPER",759:"WRITE",760:"XMLDECLARATION",761:"XMLSCHEMA",762:"YES",763:"ZONE",764:"SEMICOLON",765:"PERCENT",766:"ROWS"},productions_:[0,[3,1],[3,1],[3,2],[7,1],[7,2],[8,2],[9,3],[9,1],[9,1],[13,2],[13,4],[12,1],[17,0],[17,1],[17,1],[17,1],[17,1],[17,1],[17,1],[17,1],[17,1],[17,1],[17,1],[17,1],[17,1],[17,1],[17,1],[17,1],[17,1],[17,1],[17,1],[17,1],[17,1],[17,1],[17,1],[17,1],[17,1],[17,1],[17,1],[17,1],[17,1],[17,1],[17,1],[17,1],[17,1],[17,1],[17,1],[17,1],[17,1],[17,1],[17,1],[17,1],[17,1],[17,1],[17,1],[17,1],[17,1],[17,1],[17,1],[17,1],[17,1],[17,1],[17,1],[17,1],[17,1],[17,1],[17,1],[47,3],[73,3],[73,1],[75,5],[40,10],[40,4],[92,8],[92,11],[102,4],[104,2],[104,1],[103,3],[103,1],[105,1],[105,3],[106,3],[109,3],[109,1],[110,1],[110,2],[114,1],[114,1],[117,1],[117,5],[117,5],[117,1],[117,2],[117,1],[117,2],[117,2],[117,3],[117,4],[117,4],[117,4],[117,4],[117,4],[117,1],[117,1],[117,1],[117,1],[117,1],[117,1],[117,2],[117,2],[117,2],[117,1],[117,1],[117,1],[117,1],[117,1],[117,1],[117,2],[117,3],[117,4],[117,3],[117,1],[117,4],[117,2],[117,2],[117,4],[117,4],[117,4],[117,4],[117,4],[117,5],[117,4],[117,4],[117,4],[117,4],[117,4],[117,4],[117,4],[117,4],[117,6],[163,3],[163,1],[153,1],[153,1],[153,1],[182,2],[79,4],[79,4],[79,4],[79,3],[184,1],[184,2],[184,2],[184,2],[184,2],[184,2],[184,2],[184,2],[186,3],[186,4],[186,0],[81,0],[81,2],[81,2],[81,2],[81,2],[81,2],[82,2],[82,3],[82,5],[82,0],[205,6],[205,7],[205,6],[205,7],[203,1],[203,3],[209,4],[209,5],[209,3],[209,3],[209,2],[209,3],[209,1],[209,3],[209,2],[209,3],[209,1],[209,1],[209,2],[209,3],[209,1],[209,1],[209,2],[209,3],[209,1],[209,2],[209,3],[214,1],[199,3],[199,1],[204,2],[204,2],[204,1],[204,1],[215,3],[217,1],[217,2],[217,3],[217,3],[217,2],[217,3],[217,4],[217,5],[217,1],[217,2],[217,3],[217,1],[217,2],[217,3],[216,1],[216,2],[221,1],[221,2],[221,2],[221,3],[221,2],[221,3],[221,2],[221,3],[221,2],[221,2],[221,2],[218,2],[218,2],[218,0],[84,0],[84,2],[85,0],[85,4],[233,1],[233,3],[235,5],[235,4],[235,4],[235,1],[234,0],[234,2],[88,0],[88,2],[88,3],[88,2],[88,2],[88,3],[88,4],[88,3],[88,3],[86,0],[86,3],[120,1],[120,3],[241,1],[241,2],[241,3],[241,4],[87,0],[87,3],[87,8],[246,0],[246,2],[174,3],[174,1],[253,3],[253,2],[253,3],[253,2],[253,3],[253,2],[253,1],[254,5],[254,3],[254,1],[111,5],[111,3],[111,3],[111,1],[94,1],[94,1],[94,1],[94,1],[94,1],[94,1],[94,1],[94,1],[94,1],[94,1],[94,1],[94,1],[94,1],[94,1],[94,1],[94,1],[94,1],[94,1],[94,3],[94,3],[94,3],[94,1],[94,1],[56,1],[70,5],[71,5],[263,2],[263,2],[261,6],[261,8],[261,6],[261,8],[274,1],[274,1],[274,1],[274,1],[274,1],[274,1],[274,1],[255,5],[255,6],[255,6],[275,0],[275,4],[275,4],[275,5],[277,3],[278,3],[158,1],[158,1],[158,1],[158,1],[158,1],[158,1],[158,1],[158,1],[158,1],[200,5],[200,3],[200,4],[200,4],[200,8],[200,8],[200,8],[200,8],[200,3],[151,1],[151,3],[196,1],[257,1],[257,1],[113,1],[113,1],[258,1],[202,2],[259,4],[262,3],[201,2],[201,2],[201,1],[201,1],[260,5],[260,4],[304,2],[304,1],[307,4],[305,2],[305,0],[256,3],[256,3],[256,3],[256,3],[256,5],[256,3],[256,5],[256,3],[256,3],[256,3],[256,3],[256,3],[256,3],[256,3],[256,3],[256,3],[256,3],[256,3],[256,3],[256,3],[256,5],[256,3],[256,3],[256,3],[256,5],[256,3],[256,3],[256,3],[256,3],[256,3],[256,3],[256,3],[256,3],[256,3],[256,3],[256,3],[256,6],[256,6],[256,3],[256,3],[256,2],[256,2],[256,2],[256,2],[256,2],[256,3],[256,5],[256,6],[256,5],[256,6],[256,4],[256,5],[256,3],[256,4],[256,3],[256,4],[256,3],[256,3],[256,3],[256,3],[256,3],[329,1],[329,1],[329,4],[327,1],[327,1],[327,1],[327,1],[327,1],[327,1],[328,1],[328,1],[328,1],[55,6],[55,4],[147,1],[147,3],[336,3],[336,4],[29,5],[29,3],[36,5],[36,4],[36,7],[36,6],[36,5],[36,4],[36,5],[36,8],[36,7],[36,4],[36,6],[36,7],[341,1],[341,1],[340,0],[340,1],[342,3],[342,1],[342,1],[342,5],[342,3],[342,3],[345,1],[345,3],[346,1],[346,1],[346,1],[346,1],[346,1],[346,1],[100,1],[100,3],[24,9],[24,5],[349,1],[349,1],[352,0],[352,1],[354,2],[354,1],[355,1],[355,3],[355,3],[355,3],[348,0],[348,1],[350,0],[350,3],[351,3],[351,1],[351,2],[359,1],[359,3],[360,2],[360,2],[360,2],[360,2],[360,2],[361,0],[361,2],[366,4],[362,6],[363,9],[377,3],[376,0],[376,2],[378,4],[379,4],[364,6],[365,5],[365,5],[372,1],[372,1],[372,3],[372,3],[358,1],[358,3],[384,3],[384,2],[384,1],[387,6],[387,4],[387,1],[387,4],[272,2],[272,1],[388,1],[388,1],[385,0],[385,1],[391,2],[391,1],[393,3],[392,2],[392,5],[392,3],[392,6],[392,1],[392,2],[392,4],[392,2],[392,1],[392,2],[392,1],[392,1],[392,3],[392,5],[33,4],[399,3],[399,1],[398,0],[398,2],[18,6],[18,6],[18,6],[18,8],[18,6],[39,5],[19,4],[19,7],[19,6],[19,9],[30,3],[21,4],[21,6],[21,9],[21,6],[407,0],[407,2],[54,3],[54,2],[31,4],[31,5],[31,5],[22,8],[22,9],[32,3],[43,2],[43,4],[43,3],[43,5],[45,2],[45,4],[45,4],[45,6],[42,4],[42,6],[44,4],[44,6],[41,4],[41,6],[25,11],[25,8],[413,3],[413,3],[413,5],[34,4],[66,2],[57,2],[58,2],[58,2],[58,4],[144,4],[144,2],[144,2],[144,2],[144,2],[144,1],[144,2],[144,2],[422,1],[422,1],[423,1],[423,1],[423,1],[423,1],[423,1],[423,1],[423,1],[423,3],[419,3],[419,4],[419,2],[421,2],[421,3],[421,1],[425,3],[425,1],[428,3],[428,3],[428,3],[427,3],[427,1],[65,4],[65,3],[65,4],[65,5],[65,5],[65,6],[431,1],[431,1],[430,3],[430,2],[432,1],[432,1],[432,3],[429,1],[429,1],[51,2],[52,2],[50,2],[35,4],[35,3],[438,2],[59,3],[60,1],[61,1],[62,3],[63,2],[63,2],[64,2],[64,2],[446,1],[446,1],[69,2],[444,3],[444,1],[445,3],[445,1],[28,2],[449,1],[449,3],[450,3],[450,4],[450,5],[450,6],[46,3],[37,6],[453,1],[453,2],[454,2],[455,2],[456,2],[456,2],[456,1],[456,1],[458,4],[458,6],[461,1],[461,3],[459,5],[459,7],[459,7],[459,9],[459,7],[459,9],[462,3],[462,6],[462,3],[462,6],[457,0],[457,2],[457,5],[457,4],[457,7],[27,6],[469,2],[468,0],[468,2],[468,2],[468,1],[26,8],[23,3],[23,4],[473,3],[473,1],[474,3],[474,7],[474,6],[474,3],[474,4],[478,1],[478,1],[482,2],[483,3],[484,2],[485,4],[475,4],[475,3],[475,2],[475,1],[497,2],[493,2],[493,2],[498,4],[500,6],[67,3],[67,2],[506,3],[506,1],[504,1],[504,4],[68,2],[20,2],[48,9],[48,8],[48,9],[510,0],[510,1],[510,1],[510,1],[510,2],[511,1],[511,1],[511,1],[49,3],[38,2],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[11,1],[11,1],[80,0],[80,1],[83,0],[83,1],[90,0],[90,2],[91,0],[91,1],[96,0],[96,1],[97,0],[97,1],[101,0],[101,1],[108,0],[108,1],[121,0],[121,1],[125,1],[125,2],[126,1],[126,2],[127,0],[127,1],[155,0],[155,2],[157,0],[157,2],[159,0],[159,2],[160,1],[160,1],[161,0],[161,2],[165,0],[165,2],[167,0],[167,2],[176,0],[176,2],[177,0],[177,2],[178,0],[178,2],[188,0],[188,1],[197,0],[197,1],[210,0],[210,1],[211,0],[211,1],[219,0],[219,1],[220,0],[220,1],[248,0],[248,1],[250,0],[250,1],[251,0],[251,1],[252,0],[252,1],[264,1],[264,1],[767,1],[767,1],[289,0],[289,1],[301,1],[301,1],[337,1],[337,1],[371,0],[371,1],[375,0],[375,1],[382,0],[382,1],[383,0],[383,1],[394,0],[394,1],[395,0],[395,1],[397,1],[397,1],[411,0],[411,1],[412,0],[412,1],[465,0],[465,1],[466,0],[466,1],[467,0],[467,1],[471,0],[471,1],[476,0],[476,1],[477,0],[477,1],[479,0],[479,1],[480,0],[480,1],[481,0],[481,1],[486,0],[486,1],[487,0],[487,1],[488,0],[488,1],[489,0],[489,1],[490,0],[490,1],[491,0],[491,1],[492,0],[492,1],[494,0],[494,1],[495,0],[495,1],[496,0],[496,1],[499,0],[499,2],[501,0],[501,2],[502,0],[502,2],[503,0],[503,2],[512,0],[512,1],[513,0],[513,1]],performAction:function(e,t,r,n,a,s,i){var o=s.length-1;switch(a){case 1:A.options.casesensitive?this.$=s[o]:this.$=s[o].toLowerCase();break;case 2:this.$=w(s[o].substr(1,s[o].length-2));break;case 3:this.$=s[o].toLowerCase();break;case 4:this.$=s[o];break;case 5:this.$=s[o]?s[o-1]+" "+s[o]:s[o-1];break;case 6:return new n.Statements({statements:s[o-1]});case 7:this.$=s[o-2],s[o]&&s[o-2].push(s[o]);break;case 8:case 9:case 70:case 80:case 85:case 143:case 177:case 205:case 206:case 242:case 261:case 273:case 354:case 372:case 451:case 474:case 475:case 479:case 487:case 528:case 529:case 566:case 649:case 659:case 683:case 685:case 687:case 701:case 702:case 732:case 756:this.$=[s[o]];break;case 10:case 11:this.$=s[o],s[o].explain=!0;break;case 12:this.$=s[o],n.exists&&(this.$.exists=n.exists),delete n.exists,n.queries&&(this.$.queries=n.queries),delete n.queries;break;case 13:case 162:case 172:case 237:case 238:case 240:case 248:case 250:case 259:case 267:case 270:case 375:case 491:case 501:case 503:case 515:case 521:case 522:case 567:this.$=void 0;break;case 68:this.$=new n.WithSelect({withs:s[o-1],select:s[o]});break;case 69:case 565:s[o-2].push(s[o]),this.$=s[o-2];break;case 71:this.$={name:s[o-4],select:s[o-1]};break;case 72:n.extend(this.$,s[o-9]),n.extend(this.$,s[o-8]),n.extend(this.$,s[o-7]),n.extend(this.$,s[o-6]),n.extend(this.$,s[o-5]),n.extend(this.$,s[o-4]),n.extend(this.$,s[o-3]),n.extend(this.$,s[o-2]),n.extend(this.$,s[o-1]),n.extend(this.$,s[o]),this.$=s[o-9];break;case 73:this.$=new n.Search({selectors:s[o-2],from:s[o]}),n.extend(this.$,s[o-1]);break;case 74:this.$={pivot:{expr:s[o-5],columnid:s[o-3],inlist:s[o-2],as:s[o]}};break;case 75:this.$={unpivot:{tocolumnid:s[o-8],forcolumnid:s[o-6],inlist:s[o-3],as:s[o]}};break;case 76:case 520:case 549:case 585:case 619:case 636:case 637:case 640:case 662:this.$=s[o-1];break;case 77:case 78:case 86:case 147:case 185:case 247:case 280:case 288:case 289:case 290:case 291:case 292:case 293:case 294:case 295:case 296:case 297:case 298:case 299:case 300:case 301:case 304:case 305:case 320:case 321:case 322:case 323:case 324:case 325:case 374:case 440:case 441:case 442:case 443:case 444:case 445:case 516:case 542:case 546:case 548:case 623:case 624:case 625:case 626:case 627:case 628:case 632:case 634:case 635:case 644:case 660:case 661:case 723:case 738:case 739:case 741:case 742:case 748:case 749:this.$=s[o];break;case 79:case 84:case 731:case 755:this.$=s[o-2],this.$.push(s[o]);break;case 81:this.$={expr:s[o]};break;case 82:this.$={expr:s[o-2],as:s[o]};break;case 83:this.$={removecolumns:s[o]};break;case 87:this.$={like:s[o]};break;case 90:case 104:this.$={srchid:"PROP",args:[s[o]]};break;case 91:this.$={srchid:"ORDERBY",args:s[o-1]};break;case 92:var u=s[o-1];u||(u="ASC"),this.$={srchid:"ORDERBY",args:[{expression:new n.Column({columnid:"_"}),direction:u}]};break;case 93:this.$={srchid:"PARENT"};break;case 94:this.$={srchid:"APROP",args:[s[o]]};break;case 95:this.$={selid:"ROOT"};break;case 96:this.$={srchid:"EQ",args:[s[o]]};break;case 97:this.$={srchid:"LIKE",args:[s[o]]};break;case 98:case 99:this.$={selid:"WITH",args:s[o-1]};break;case 100:this.$={srchid:s[o-3].toUpperCase(),args:s[o-1]};break;case 101:this.$={srchid:"WHERE",args:[s[o-1]]};break;case 102:this.$={selid:"OF",args:[s[o-1]]};break;case 103:this.$={srchid:"CLASS",args:[s[o-1]]};break;case 105:this.$={srchid:"NAME",args:[s[o].substr(1,s[o].length-2)]};break;case 106:this.$={srchid:"CHILD"};break;case 107:this.$={srchid:"VERTEX"};break;case 108:this.$={srchid:"EDGE"};break;case 109:this.$={srchid:"REF"};break;case 110:this.$={srchid:"SHARP",args:[s[o]]};break;case 111:this.$={srchid:"ATTR",args:void 0===s[o]?void 0:[s[o]]};break;case 112:this.$={srchid:"ATTR"};break;case 113:this.$={srchid:"OUT"};break;case 114:this.$={srchid:"IN"};break;case 115:this.$={srchid:"OUTOUT"};break;case 116:this.$={srchid:"ININ"};break;case 117:this.$={srchid:"CONTENT"};break;case 118:this.$={srchid:"EX",args:[new n.Json({value:s[o]})]};break;case 119:this.$={srchid:"AT",args:[s[o]]};break;case 120:this.$={srchid:"AS",args:[s[o]]};break;case 121:this.$={srchid:"SET",args:s[o-1]};break;case 122:this.$={selid:"TO",args:[s[o]]};break;case 123:this.$={srchid:"VALUE"};break;case 124:this.$={srchid:"ROW",args:s[o-1]};break;case 125:this.$={srchid:"CLASS",args:[s[o]]};break;case 126:this.$={selid:s[o],args:[s[o-1]]};break;case 127:this.$={selid:"NOT",args:s[o-1]};break;case 128:this.$={selid:"IF",args:s[o-1]};break;case 129:this.$={selid:s[o-3],args:s[o-1]};break;case 130:this.$={selid:"DISTINCT",args:s[o-1]};break;case 131:this.$={selid:"UNION",args:s[o-1]};break;case 132:this.$={selid:"UNIONALL",args:s[o-1]};break;case 133:this.$={selid:"ALL",args:[s[o-1]]};break;case 134:this.$={selid:"ANY",args:[s[o-1]]};break;case 135:this.$={selid:"INTERSECT",args:s[o-1]};break;case 136:this.$={selid:"EXCEPT",args:s[o-1]};break;case 137:this.$={selid:"AND",args:s[o-1]};break;case 138:this.$={selid:"OR",args:s[o-1]};break;case 139:this.$={selid:"PATH",args:[s[o-1]]};break;case 140:this.$={srchid:"RETURN",args:s[o-1]};break;case 141:this.$={selid:"REPEAT",sels:s[o-3],args:s[o-1]};break;case 142:this.$=s[o-2],this.$.push(s[o]);break;case 144:this.$="PLUS";break;case 145:this.$="STAR";break;case 146:this.$="QUESTION";break;case 148:case 149:this.$=new n.Select({columns:s[o],distinct:!0}),n.extend(this.$,s[o-3]),n.extend(this.$,s[o-1]);break;case 150:this.$=new n.Select({columns:s[o],all:!0}),n.extend(this.$,s[o-3]),n.extend(this.$,s[o-1]);break;case 151:s[o]?(this.$=new n.Select({columns:s[o]}),n.extend(this.$,s[o-2]),n.extend(this.$,s[o-1])):this.$=new n.Select({columns:[new n.Column({columnid:"_"})],modifier:"COLUMN"});break;case 152:"SELECT"==s[o]?this.$=void 0:this.$={modifier:s[o]};break;case 153:this.$={modifier:"VALUE"};break;case 154:this.$={modifier:"ROW"};break;case 155:this.$={modifier:"COLUMN"};break;case 156:this.$={modifier:"MATRIX"};break;case 157:this.$={modifier:"TEXTSTRING"};break;case 158:this.$={modifier:"INDEX"};break;case 159:this.$={modifier:"RECORDSET"};break;case 160:this.$={top:s[o-1],percent:void 0!==s[o]||void 0};break;case 161:this.$={top:s[o-1]};break;case 163:case 330:case 523:case 524:case 724:this.$=void 0;break;case 164:case 165:case 166:case 167:this.$={into:s[o]};break;case 168:var c=s[o];c=c.substr(1,c.length-2);var l=c.substr(-3).toUpperCase(),h=c.substr(-4).toUpperCase();"#"==c[0]?this.$={into:new n.FuncValue({funcid:"HTML",args:[new n.StringValue({value:c}),new n.Json({value:{headers:!0}})]})}:"XLS"==l||"CSV"==l||"TAB"==l?this.$={into:new n.FuncValue({funcid:l,args:[new n.StringValue({value:c}),new n.Json({value:{headers:!0}})]})}:"XLSX"!=h&&"JSON"!=h||(this.$={into:new n.FuncValue({funcid:h,args:[new n.StringValue({value:c}),new n.Json({value:{headers:!0}})]})});break;case 169:this.$={from:s[o]};break;case 170:this.$={from:s[o-1],joins:s[o]};break;case 171:this.$={from:s[o-2],joins:s[o-1]};break;case 173:this.$=new n.Apply({select:s[o-2],applymode:"CROSS",as:s[o]});break;case 174:this.$=new n.Apply({select:s[o-3],applymode:"CROSS",as:s[o]});break;case 175:this.$=new n.Apply({select:s[o-2],applymode:"OUTER",as:s[o]});break;case 176:this.$=new n.Apply({select:s[o-3],applymode:"OUTER",as:s[o]});break;case 178:case 243:case 452:case 530:case 531:this.$=s[o-2],s[o-2].push(s[o]);break;case 179:this.$=s[o-2],this.$.as=s[o];break;case 180:this.$=s[o-3],this.$.as=s[o];break;case 181:this.$=s[o-1],this.$.as="default";break;case 182:this.$=new n.Json({value:s[o-2]}),s[o-2].as=s[o];break;case 183:this.$=s[o-1],s[o-1].as=s[o];break;case 184:this.$=s[o-2],s[o-2].as=s[o];break;case 186:case 638:case 641:this.$=s[o-2];break;case 187:case 191:case 195:case 198:this.$=s[o-1],s[o-1].as=s[o];break;case 188:case 192:case 196:case 199:this.$=s[o-2],s[o-2].as=s[o];break;case 189:case 190:case 194:case 197:this.$=s[o],s[o].as="default";break;case 193:this.$={inserted:!0},s[o].as="default";break;case 200:var c=s[o];c=c.substr(1,c.length-2);var d,l=c.substr(-3).toUpperCase(),h=c.substr(-4).toUpperCase();if("#"==c[0])d=new n.FuncValue({funcid:"HTML",args:[new n.StringValue({value:c}),new n.Json({value:{headers:!0}})]});else if("XLS"==l||"CSV"==l||"TAB"==l)d=new n.FuncValue({funcid:l,args:[new n.StringValue({value:c}),new n.Json({value:{headers:!0}})]});else{if("XLSX"!=h&&"JSON"!=h)throw new Error("Unknown string in FROM clause");d=new n.FuncValue({funcid:h,args:[new n.StringValue({value:c}),new n.Json({value:{headers:!0}})]})}this.$=d;break;case 201:"INFORMATION_SCHEMA"==s[o-2]?this.$=new n.FuncValue({funcid:s[o-2],args:[new n.StringValue({value:s[o]})]}):this.$=new n.Table({databaseid:s[o-2],tableid:s[o]});break;case 202:this.$=new n.Table({tableid:s[o]});break;case 203:case 204:this.$=s[o-1],s[o-1].push(s[o]);break;case 207:this.$=new n.Join(s[o-2]),n.extend(this.$,s[o-1]),n.extend(this.$,s[o]);break;case 208:this.$={table:s[o]};break;case 209:this.$={table:s[o-1],as:s[o]};break;case 210:this.$={table:s[o-2],as:s[o]};break;case 211:this.$={json:new n.Json({value:s[o-2],as:s[o]})};break;case 212:this.$={param:s[o-1],as:s[o]};break;case 213:this.$={param:s[o-2],as:s[o]};break;case 214:this.$={select:s[o-2],as:s[o]};break;case 215:this.$={select:s[o-3],as:s[o]};break;case 216:this.$={funcid:s[o],as:"default"};break;case 217:this.$={funcid:s[o-1],as:s[o]};break;case 218:this.$={funcid:s[o-2],as:s[o]};break;case 219:this.$={variable:s[o],as:"default"};break;case 220:this.$={variable:s[o-1],as:s[o]};break;case 221:this.$={variable:s[o-2],as:s[o]};break;case 222:this.$={joinmode:s[o]};break;case 223:this.$={joinmode:s[o-1],natural:!0};break;case 224:case 225:this.$="INNER";break;case 226:case 227:this.$="LEFT";break;case 228:case 229:this.$="RIGHT";break;case 230:case 231:this.$="OUTER";break;case 232:this.$="SEMI";break;case 233:this.$="ANTI";break;case 234:this.$="CROSS";break;case 235:this.$={on:s[o]};break;case 236:case 697:this.$={using:s[o]};break;case 239:this.$={where:new n.Expression({expression:s[o]})};break;case 241:this.$={group:s[o-1]},n.extend(this.$,s[o]);break;case 244:this.$=new n.GroupExpression({type:"GROUPING SETS",group:s[o-1]});break;case 245:this.$=new n.GroupExpression({type:"ROLLUP",group:s[o-1]});break;case 246:this.$=new n.GroupExpression({type:"CUBE",group:s[o-1]});break;case 249:this.$={having:s[o]};break;case 251:this.$={union:s[o]};break;case 252:this.$={unionall:s[o]};break;case 253:this.$={except:s[o]};break;case 254:this.$={intersect:s[o]};break;case 255:this.$={union:s[o],corresponding:!0};break;case 256:this.$={unionall:s[o],corresponding:!0};break;case 257:this.$={except:s[o],corresponding:!0};break;case 258:this.$={intersect:s[o],corresponding:!0};break;case 260:this.$={order:s[o]};break;case 262:this.$=s[o-2],s[o-2].push(s[o]);break;case 263:this.$=new n.Expression({expression:s[o],direction:"ASC"});break;case 264:this.$=new n.Expression({expression:s[o-1],direction:s[o].toUpperCase()});break;case 265:this.$=new n.Expression({expression:s[o-2],direction:"ASC",nocase:!0});break;case 266:this.$=new n.Expression({expression:s[o-3],direction:s[o].toUpperCase(),nocase:!0});break;case 268:this.$={limit:s[o-1]},n.extend(this.$,s[o]);break;case 269:this.$={limit:s[o-2],offset:s[o-6]};break;case 271:this.$={offset:s[o]};break;case 272:case 509:case 533:case 648:case 658:case 682:case 684:case 688:s[o-2].push(s[o]),this.$=s[o-2];break;case 274:case 276:case 278:s[o-2].as=s[o],this.$=s[o-2];break;case 275:case 277:case 279:s[o-1].as=s[o],this.$=s[o-1];break;case 281:this.$=new n.Column({columid:s[o],tableid:s[o-2],databaseid:s[o-4]});break;case 282:this.$=new n.Column({columnid:s[o],tableid:s[o-2]});break;case 283:this.$=new n.Column({columnid:s[o]});break;case 284:this.$=new n.Column({columnid:s[o],tableid:s[o-2],databaseid:s[o-4]});break;case 285:case 286:this.$=new n.Column({columnid:s[o],tableid:s[o-2]});break;case 287:this.$=new n.Column({columnid:s[o]});break;case 302:this.$=new n.DomainValueValue;break;case 303:this.$=new n.Json({value:s[o]});break;case 306:case 307:case 308:n.queries||(n.queries=[]),n.queries.push(s[o-1]),s[o-1].queriesidx=n.queries.length,this.$=s[o-1];break;case 309:this.$=s[o];break;case 310:this.$=new n.FuncValue({funcid:"CURRENT_TIMESTAMP"});break;case 311:this.$=new n.JavaScript({value:s[o].substr(2,s[o].length-4)});break;case 312:this.$=new n.JavaScript({value:'alasql.fn["'+s[o-2]+'"] = '+s[o].substr(2,s[o].length-4)});break;case 313:this.$=new n.JavaScript({value:'alasql.aggr["'+s[o-2]+'"] = '+s[o].substr(2,s[o].length-4)});break;case 314:this.$=new n.FuncValue({funcid:s[o],newid:!0});break;case 315:this.$=s[o],n.extend(this.$,{newid:!0});break;case 316:this.$=new n.Convert({expression:s[o-3]}),n.extend(this.$,s[o-1]);break;case 317:this.$=new n.Convert({expression:s[o-5],style:s[o-1]}),n.extend(this.$,s[o-3]);break;case 318:this.$=new n.Convert({expression:s[o-1]}),n.extend(this.$,s[o-3]);break;case 319:this.$=new n.Convert({expression:s[o-3],style:s[o-1]}),n.extend(this.$,s[o-5]);break;case 326:this.$=new n.FuncValue({funcid:"CURRENT_TIMESTAMP"});break;case 327:s[o-2].length>1&&("MAX"==s[o-4].toUpperCase()||"MIN"==s[o-4].toUpperCase())?this.$=new n.FuncValue({funcid:s[o-4],args:s[o-2]}):this.$=new n.AggrValue({aggregatorid:s[o-4].toUpperCase(),expression:s[o-2].pop(),over:s[o]});break;case 328:this.$=new n.AggrValue({aggregatorid:s[o-5].toUpperCase(),expression:s[o-2],distinct:!0,over:s[o]});break;case 329:this.$=new n.AggrValue({aggregatorid:s[o-5].toUpperCase(),expression:s[o-2],over:s[o]});break;case 331:case 332:this.$=new n.Over,n.extend(this.$,s[o-1]);break;case 333:this.$=new n.Over,n.extend(this.$,s[o-2]),n.extend(this.$,s[o-1]);break;case 334:this.$={partition:s[o]};break;case 335:this.$={order:s[o]};break;case 336:this.$="SUM";break;case 337:this.$="COUNT";break;case 338:this.$="MIN";break;case 339:case 544:this.$="MAX";break;case 340:this.$="AVG";break;case 341:this.$="FIRST";break;case 342:this.$="LAST";break;case 343:this.$="AGGR";break;case 344:this.$="ARRAY";break;case 345:var f=s[o-4],p=s[o-1];p.length>1&&("MIN"==f.toUpperCase()||"MAX"==f.toUpperCase())?this.$=new n.FuncValue({funcid:f,args:p}):A.aggr[s[o-4]]?this.$=new n.AggrValue({aggregatorid:"REDUCE",funcid:f,expression:p.pop(),distinct:"DISTINCT"==s[o-2]}):this.$=new n.FuncValue({funcid:f,args:p});break;case 346:this.$=new n.FuncValue({funcid:s[o-2]});break;case 347:this.$=new n.FuncValue({funcid:"IIF",args:s[o-1]});break;case 348:this.$=new n.FuncValue({funcid:"REPLACE",args:s[o-1]});break;case 349:this.$=new n.FuncValue({funcid:"DATEADD",args:[new n.StringValue({value:s[o-5]}),s[o-3],s[o-1]]});break;case 350:this.$=new n.FuncValue({funcid:"DATEADD",args:[s[o-5],s[o-3],s[o-1]]});break;case 351:this.$=new n.FuncValue({funcid:"DATEDIFF",args:[new n.StringValue({value:s[o-5]}),s[o-3],s[o-1]]});break;case 352:this.$=new n.FuncValue({funcid:"DATEDIFF",args:[s[o-5],s[o-3],s[o-1]]});break;case 353:this.$=new n.FuncValue({funcid:"INTERVAL",args:[s[o-1],new n.StringValue({value:s[o].toLowerCase()})]});break;case 355:s[o-2].push(s[o]),this.$=s[o-2];break;case 356:this.$=new n.NumValue({value:+s[o]});break;case 357:this.$=new n.LogicValue({value:!0});break;case 358:this.$=new n.LogicValue({value:!1});break;case 359:this.$=new n.StringValue({value:s[o].substr(1,s[o].length-2).replace(/(\\\')/g,"'").replace(/(\'\')/g,"'")});break;case 360:this.$=new n.StringValue({value:s[o].substr(2,s[o].length-3).replace(/(\\\')/g,"'").replace(/(\'\')/g,"'")});break;case 361:this.$=new n.NullValue({value:void 0});break;case 362:this.$=new n.VarValue({variable:s[o]});break;case 363:n.exists||(n.exists=[]),this.$=new n.ExistsValue({value:s[o-1],existsidx:n.exists.length}),n.exists.push(s[o-1]);break;case 364:this.$=new n.ArrayValue({value:s[o-1]});break;case 365:case 366:this.$=new n.ParamValue({param:s[o]});break;case 367:void 0===n.question&&(n.question=0),this.$=new n.ParamValue({param:n.question++});break;case 368:void 0===n.question&&(n.question=0),this.$=new n.ParamValue({param:n.question++,array:!0});break;case 369:this.$=new n.CaseValue({expression:s[o-3],whens:s[o-2],elses:s[o-1]});break;case 370:this.$=new n.CaseValue({whens:s[o-2],elses:s[o-1]});break;case 371:case 699:case 700:this.$=s[o-1],this.$.push(s[o]);break;case 373:this.$={when:s[o-2],then:s[o]};break;case 376:case 377:this.$=new n.Op({left:s[o-2],op:"REGEXP",right:s[o]});break;case 378:this.$=new n.Op({left:s[o-2],op:"GLOB",right:s[o]});break;case 379:this.$=new n.Op({left:s[o-2],op:"LIKE",right:s[o]});break;case 380:this.$=new n.Op({left:s[o-4],op:"LIKE",right:s[o-2],escape:s[o]});break;case 381:this.$=new n.Op({left:s[o-2],op:"NOT LIKE",right:s[o]});break;case 382:this.$=new n.Op({left:s[o-4],op:"NOT LIKE",right:s[o-2],escape:s[o]});break;case 383:this.$=new n.Op({left:s[o-2],op:"||",right:s[o]});break;case 384:this.$=new n.Op({left:s[o-2],op:"+",right:s[o]});break;case 385:this.$=new n.Op({left:s[o-2],op:"-",right:s[o]});break;case 386:this.$=new n.Op({left:s[o-2],op:"*",right:s[o]});break;case 387:this.$=new n.Op({left:s[o-2],op:"/",right:s[o]});break;case 388:this.$=new n.Op({left:s[o-2],op:"%",right:s[o]});break;case 389:this.$=new n.Op({left:s[o-2],op:"^",right:s[o]});break;case 390:this.$=new n.Op({left:s[o-2],op:">>",right:s[o]});break;case 391:this.$=new n.Op({left:s[o-2],op:"<<",right:s[o]});break;case 392:this.$=new n.Op({left:s[o-2],op:"&",right:s[o]});break;case 393:this.$=new n.Op({left:s[o-2],op:"|",right:s[o]});break;case 394:case 395:case 397:this.$=new n.Op({left:s[o-2],op:"->",right:s[o]});break;case 396:this.$=new n.Op({left:s[o-4],op:"->",right:s[o-1]});break;case 398:case 399:case 401:this.$=new n.Op({left:s[o-2],op:"!",right:s[o]});break;case 400:this.$=new n.Op({left:s[o-4],op:"!",right:s[o-1]});break;case 402:this.$=new n.Op({left:s[o-2],op:">",right:s[o]});break;case 403:this.$=new n.Op({left:s[o-2],op:">=",right:s[o]});break;case 404:this.$=new n.Op({left:s[o-2],op:"<",right:s[o]});break;case 405:this.$=new n.Op({left:s[o-2],op:"<=",right:s[o]});break;case 406:this.$=new n.Op({left:s[o-2],op:"=",right:s[o]});break;case 407:this.$=new n.Op({left:s[o-2],op:"==",right:s[o]});break;case 408:this.$=new n.Op({left:s[o-2],op:"===",right:s[o]});break;case 409:this.$=new n.Op({left:s[o-2],op:"!=",right:s[o]});break;case 410:this.$=new n.Op({left:s[o-2],op:"!==",right:s[o]});break;case 411:this.$=new n.Op({left:s[o-2],op:"!===",right:s[o]});break;case 412:n.queries||(n.queries=[]),this.$=new n.Op({left:s[o-5],op:s[o-4],allsome:s[o-3],right:s[o-1],queriesidx:n.queries.length}),n.queries.push(s[o-1]);break;case 413:this.$=new n.Op({left:s[o-5],op:s[o-4],allsome:s[o-3],right:s[o-1]});break;case 414:"BETWEEN1"==s[o-2].op?"AND"==s[o-2].left.op?this.$=new n.Op({left:s[o-2].left.left,op:"AND",right:new n.Op({left:s[o-2].left.right,op:"BETWEEN",right1:s[o-2].right,right2:s[o]})}):this.$=new n.Op({left:s[o-2].left,op:"BETWEEN",right1:s[o-2].right,right2:s[o]}):"NOT BETWEEN1"==s[o-2].op?"AND"==s[o-2].left.op?this.$=new n.Op({left:s[o-2].left.left,op:"AND",right:new n.Op({left:s[o-2].left.right,op:"NOT BETWEEN",right1:s[o-2].right,right2:s[o]})}):this.$=new n.Op({left:s[o-2].left,op:"NOT BETWEEN",right1:s[o-2].right,right2:s[o]}):this.$=new n.Op({left:s[o-2],op:"AND",right:s[o]});break;case 415:this.$=new n.Op({left:s[o-2],op:"OR",right:s[o]});break;case 416:this.$=new n.UniOp({op:"NOT",right:s[o]});break;case 417:this.$=new n.UniOp({op:"-",right:s[o]});break;case 418:this.$=new n.UniOp({op:"+",right:s[o]});break;case 419:this.$=new n.UniOp({op:"~",right:s[o]});break;case 420:this.$=new n.UniOp({op:"#",right:s[o]});break;case 421:this.$=new n.UniOp({right:s[o-1]});break;case 422:n.queries||(n.queries=[]),this.$=new n.Op({left:s[o-4],op:"IN",right:s[o-1],queriesidx:n.queries.length}),n.queries.push(s[o-1]);break;case 423:n.queries||(n.queries=[]),this.$=new n.Op({left:s[o-5],op:"NOT IN",right:s[o-1],
 queriesidx:n.queries.length}),n.queries.push(s[o-1]);break;case 424:this.$=new n.Op({left:s[o-4],op:"IN",right:s[o-1]});break;case 425:this.$=new n.Op({left:s[o-5],op:"NOT IN",right:s[o-1]});break;case 426:this.$=new n.Op({left:s[o-3],op:"IN",right:[]});break;case 427:this.$=new n.Op({left:s[o-4],op:"NOT IN",right:[]});break;case 428:case 430:this.$=new n.Op({left:s[o-2],op:"IN",right:s[o]});break;case 429:case 431:this.$=new n.Op({left:s[o-3],op:"NOT IN",right:s[o]});break;case 432:this.$=new n.Op({left:s[o-2],op:"BETWEEN1",right:s[o]});break;case 433:this.$=new n.Op({left:s[o-2],op:"NOT BETWEEN1",right:s[o]});break;case 434:this.$=new n.Op({op:"IS",left:s[o-2],right:s[o]});break;case 435:this.$=new n.Op({op:"IS",left:s[o-2],right:new n.UniOp({op:"NOT",right:new n.NullValue({value:void 0})})});break;case 436:this.$=new n.Convert({expression:s[o-2]}),n.extend(this.$,s[o]);break;case 437:case 438:this.$=s[o];break;case 439:this.$=s[o-1];break;case 446:this.$="ALL";break;case 447:this.$="SOME";break;case 448:this.$="ANY";break;case 449:this.$=new n.Update({table:s[o-4],columns:s[o-2],where:s[o]});break;case 450:this.$=new n.Update({table:s[o-2],columns:s[o]});break;case 453:this.$=new n.SetColumn({column:s[o-2],expression:s[o]});break;case 454:this.$=new n.SetColumn({variable:s[o-2],expression:s[o],method:s[o-3]});break;case 455:this.$=new n.Delete({table:s[o-2],where:s[o]});break;case 456:this.$=new n.Delete({table:s[o]});break;case 457:this.$=new n.Insert({into:s[o-2],values:s[o]});break;case 458:this.$=new n.Insert({into:s[o-1],values:s[o]});break;case 459:case 461:this.$=new n.Insert({into:s[o-2],values:s[o],orreplace:!0});break;case 460:case 462:this.$=new n.Insert({into:s[o-1],values:s[o],orreplace:!0});break;case 463:this.$=new n.Insert({into:s[o-2],default:!0});break;case 464:this.$=new n.Insert({into:s[o-5],columns:s[o-3],values:s[o]});break;case 465:this.$=new n.Insert({into:s[o-4],columns:s[o-2],values:s[o]});break;case 466:this.$=new n.Insert({into:s[o-1],select:s[o]});break;case 467:this.$=new n.Insert({into:s[o-1],select:s[o],orreplace:!0});break;case 468:this.$=new n.Insert({into:s[o-4],columns:s[o-2],select:s[o]});break;case 473:this.$=[s[o-1]];break;case 476:this.$=s[o-4],s[o-4].push(s[o-1]);break;case 477:case 478:case 480:case 488:this.$=s[o-2],s[o-2].push(s[o]);break;case 489:this.$=new n.CreateTable({table:s[o-4]}),n.extend(this.$,s[o-7]),n.extend(this.$,s[o-6]),n.extend(this.$,s[o-5]),n.extend(this.$,s[o-2]),n.extend(this.$,s[o]);break;case 490:this.$=new n.CreateTable({table:s[o]}),n.extend(this.$,s[o-3]),n.extend(this.$,s[o-2]),n.extend(this.$,s[o-1]);break;case 492:this.$={class:!0};break;case 502:this.$={temporary:!0};break;case 504:this.$={ifnotexists:!0};break;case 505:this.$={columns:s[o-2],constraints:s[o]};break;case 506:this.$={columns:s[o]};break;case 507:this.$={as:s[o]};break;case 508:case 532:this.$=[s[o]];break;case 510:case 511:case 512:case 513:case 514:s[o].constraintid=s[o-1],this.$=s[o];break;case 517:this.$={type:"CHECK",expression:s[o-1]};break;case 518:this.$={type:"PRIMARY KEY",columns:s[o-1],clustered:(s[o-3]+"").toUpperCase()};break;case 519:this.$={type:"FOREIGN KEY",columns:s[o-5],fktable:s[o-2],fkcolumns:s[o-1]};break;case 525:this.$={type:"UNIQUE",columns:s[o-1],clustered:(s[o-3]+"").toUpperCase()};break;case 534:this.$=new n.ColumnDef({columnid:s[o-2]}),n.extend(this.$,s[o-1]),n.extend(this.$,s[o]);break;case 535:this.$=new n.ColumnDef({columnid:s[o-1]}),n.extend(this.$,s[o]);break;case 536:this.$=new n.ColumnDef({columnid:s[o],dbtypeid:""});break;case 537:this.$={dbtypeid:s[o-5],dbsize:s[o-3],dbprecision:+s[o-1]};break;case 538:this.$={dbtypeid:s[o-3],dbsize:s[o-1]};break;case 539:this.$={dbtypeid:s[o]};break;case 540:this.$={dbtypeid:"ENUM",enumvalues:s[o-1]};break;case 541:this.$=s[o-1],s[o-1].dbtypeid+="["+s[o]+"]";break;case 543:case 750:this.$=+s[o];break;case 545:this.$=void 0;break;case 547:n.extend(s[o-1],s[o]),this.$=s[o-1];break;case 550:this.$={primarykey:!0};break;case 551:case 552:this.$={foreignkey:{table:s[o-1],columnid:s[o]}};break;case 553:this.$={identity:{value:s[o-3],step:s[o-1]}};break;case 554:this.$={identity:{value:1,step:1}};break;case 555:case 557:this.$={default:s[o]};break;case 556:this.$={default:s[o-1]};break;case 558:this.$={null:!0};break;case 559:this.$={notnull:!0};break;case 560:this.$={check:s[o]};break;case 561:this.$={unique:!0};break;case 562:this.$={onupdate:s[o]};break;case 563:this.$={onupdate:s[o-1]};break;case 564:this.$=new n.DropTable({tables:s[o],type:s[o-2]}),n.extend(this.$,s[o-1]);break;case 568:this.$={ifexists:!0};break;case 569:this.$=new n.AlterTable({table:s[o-3],renameto:s[o]});break;case 570:this.$=new n.AlterTable({table:s[o-3],addcolumn:s[o]});break;case 571:this.$=new n.AlterTable({table:s[o-3],modifycolumn:s[o]});break;case 572:this.$=new n.AlterTable({table:s[o-5],renamecolumn:s[o-2],to:s[o]});break;case 573:this.$=new n.AlterTable({table:s[o-3],dropcolumn:s[o]});break;case 574:this.$=new n.AlterTable({table:s[o-2],renameto:s[o]});break;case 575:this.$=new n.AttachDatabase({databaseid:s[o],engineid:s[o-2].toUpperCase()});break;case 576:this.$=new n.AttachDatabase({databaseid:s[o-3],engineid:s[o-5].toUpperCase(),args:s[o-1]});break;case 577:this.$=new n.AttachDatabase({databaseid:s[o-2],engineid:s[o-4].toUpperCase(),as:s[o]});break;case 578:this.$=new n.AttachDatabase({databaseid:s[o-5],engineid:s[o-7].toUpperCase(),as:s[o],args:s[o-3]});break;case 579:this.$=new n.DetachDatabase({databaseid:s[o]});break;case 580:this.$=new n.CreateDatabase({databaseid:s[o]}),n.extend(this.$,s[o]);break;case 581:this.$=new n.CreateDatabase({engineid:s[o-4].toUpperCase(),databaseid:s[o-1],as:s[o]}),n.extend(this.$,s[o-2]);break;case 582:this.$=new n.CreateDatabase({engineid:s[o-7].toUpperCase(),databaseid:s[o-4],args:s[o-2],as:s[o]}),n.extend(this.$,s[o-5]);break;case 583:this.$=new n.CreateDatabase({engineid:s[o-4].toUpperCase(),as:s[o],args:[s[o-1]]}),n.extend(this.$,s[o-2]);break;case 584:this.$=void 0;break;case 586:case 587:this.$=new n.UseDatabase({databaseid:s[o]});break;case 588:this.$=new n.DropDatabase({databaseid:s[o]}),n.extend(this.$,s[o-1]);break;case 589:case 590:this.$=new n.DropDatabase({databaseid:s[o],engineid:s[o-3].toUpperCase()}),n.extend(this.$,s[o-1]);break;case 591:this.$=new n.CreateIndex({indexid:s[o-5],table:s[o-3],columns:s[o-1]});break;case 592:this.$=new n.CreateIndex({indexid:s[o-5],table:s[o-3],columns:s[o-1],unique:!0});break;case 593:this.$=new n.DropIndex({indexid:s[o]});break;case 594:this.$=new n.ShowDatabases;break;case 595:this.$=new n.ShowDatabases({like:s[o]});break;case 596:this.$=new n.ShowDatabases({engineid:s[o-1].toUpperCase()});break;case 597:this.$=new n.ShowDatabases({engineid:s[o-3].toUpperCase(),like:s[o]});break;case 598:this.$=new n.ShowTables;break;case 599:this.$=new n.ShowTables({like:s[o]});break;case 600:this.$=new n.ShowTables({databaseid:s[o]});break;case 601:this.$=new n.ShowTables({like:s[o],databaseid:s[o-2]});break;case 602:this.$=new n.ShowColumns({table:s[o]});break;case 603:this.$=new n.ShowColumns({table:s[o-2],databaseid:s[o]});break;case 604:this.$=new n.ShowIndex({table:s[o]});break;case 605:this.$=new n.ShowIndex({table:s[o-2],databaseid:s[o]});break;case 606:this.$=new n.ShowCreateTable({table:s[o]});break;case 607:this.$=new n.ShowCreateTable({table:s[o-2],databaseid:s[o]});break;case 608:this.$=new n.CreateTable({table:s[o-6],view:!0,select:s[o-1],viewcolumns:s[o-4]}),n.extend(this.$,s[o-9]),n.extend(this.$,s[o-7]);break;case 609:this.$=new n.CreateTable({table:s[o-3],view:!0,select:s[o-1]}),n.extend(this.$,s[o-6]),n.extend(this.$,s[o-4]);break;case 613:this.$=new n.DropTable({tables:s[o],view:!0}),n.extend(this.$,s[o-1]);break;case 614:case 760:this.$=new n.ExpressionStatement({expression:s[o]});break;case 615:this.$=new n.Source({url:s[o].value});break;case 616:this.$=new n.Assert({value:s[o]});break;case 617:this.$=new n.Assert({value:s[o].value});break;case 618:this.$=new n.Assert({value:s[o],message:s[o-2]});break;case 620:case 631:case 633:this.$=s[o].value;break;case 621:case 629:this.$=+s[o].value;break;case 622:this.$=!!s[o].value;break;case 630:this.$=""+s[o].value;break;case 639:this.$={};break;case 642:this.$=[];break;case 643:n.extend(s[o-2],s[o]),this.$=s[o-2];break;case 645:this.$={},this.$[s[o-2].substr(1,s[o-2].length-2)]=s[o];break;case 646:case 647:this.$={},this.$[s[o-2]]=s[o];break;case 650:this.$=new n.SetVariable({variable:s[o-2].toLowerCase(),value:s[o]});break;case 651:this.$=new n.SetVariable({variable:s[o-1].toLowerCase(),value:s[o]});break;case 652:this.$=new n.SetVariable({variable:s[o-2],expression:s[o]});break;case 653:this.$=new n.SetVariable({variable:s[o-3],props:s[o-2],expression:s[o]});break;case 654:this.$=new n.SetVariable({variable:s[o-2],expression:s[o],method:s[o-3]});break;case 655:this.$=new n.SetVariable({variable:s[o-3],props:s[o-2],expression:s[o],method:s[o-4]});break;case 656:this.$="@";break;case 657:this.$="$";break;case 663:this.$=!0;break;case 664:this.$=!1;break;case 665:this.$=new n.CommitTransaction;break;case 666:this.$=new n.RollbackTransaction;break;case 667:this.$=new n.BeginTransaction;break;case 668:this.$=new n.If({expression:s[o-2],thenstat:s[o-1],elsestat:s[o]}),s[o-1].exists&&(this.$.exists=s[o-1].exists),s[o-1].queries&&(this.$.queries=s[o-1].queries);break;case 669:this.$=new n.If({expression:s[o-1],thenstat:s[o]}),s[o].exists&&(this.$.exists=s[o].exists),s[o].queries&&(this.$.queries=s[o].queries);break;case 670:this.$=s[o];break;case 671:this.$=new n.While({expression:s[o-1],loopstat:s[o]}),s[o].exists&&(this.$.exists=s[o].exists),s[o].queries&&(this.$.queries=s[o].queries);break;case 672:this.$=new n.Continue;break;case 673:this.$=new n.Break;break;case 674:this.$=new n.BeginEnd({statements:s[o-1]});break;case 675:this.$=new n.Print({exprs:s[o]});break;case 676:this.$=new n.Print({select:s[o]});break;case 677:this.$=new n.Require({paths:s[o]});break;case 678:this.$=new n.Require({plugins:s[o]});break;case 679:case 680:this.$=s[o].toUpperCase();break;case 681:this.$=new n.Echo({expr:s[o]});break;case 686:this.$=new n.Declare({declares:s[o]});break;case 689:this.$={variable:s[o-1]},n.extend(this.$,s[o]);break;case 690:this.$={variable:s[o-2]},n.extend(this.$,s[o]);break;case 691:this.$={variable:s[o-3],expression:s[o]},n.extend(this.$,s[o-2]);break;case 692:this.$={variable:s[o-4],expression:s[o]},n.extend(this.$,s[o-2]);break;case 693:this.$=new n.TruncateTable({table:s[o]});break;case 694:this.$=new n.Merge,n.extend(this.$,s[o-4]),n.extend(this.$,s[o-3]),n.extend(this.$,s[o-2]),n.extend(this.$,{matches:s[o-1]}),n.extend(this.$,s[o]);break;case 695:case 696:this.$={into:s[o]};break;case 698:this.$={on:s[o]};break;case 703:this.$={matched:!0,action:s[o]};break;case 704:this.$={matched:!0,expr:s[o-2],action:s[o]};break;case 705:this.$={delete:!0};break;case 706:this.$={update:s[o]};break;case 707:case 708:this.$={matched:!1,bytarget:!0,action:s[o]};break;case 709:case 710:this.$={matched:!1,bytarget:!0,expr:s[o-2],action:s[o]};break;case 711:this.$={matched:!1,bysource:!0,action:s[o]};break;case 712:this.$={matched:!1,bysource:!0,expr:s[o-2],action:s[o]};break;case 713:this.$={insert:!0,values:s[o]};break;case 714:this.$={insert:!0,values:s[o],columns:s[o-3]};break;case 715:this.$={insert:!0,defaultvalues:!0};break;case 716:this.$={insert:!0,defaultvalues:!0,columns:s[o-3]};break;case 718:this.$={output:{columns:s[o]}};break;case 719:this.$={output:{columns:s[o-3],intovar:s[o],method:s[o-1]}};break;case 720:this.$={output:{columns:s[o-2],intotable:s[o]}};break;case 721:this.$={output:{columns:s[o-5],intotable:s[o-3],intocolumns:s[o-1]}};break;case 722:this.$=new n.CreateVertex({class:s[o-3],sharp:s[o-2],name:s[o-1]}),n.extend(this.$,s[o]);break;case 725:this.$={sets:s[o]};break;case 726:this.$={content:s[o]};break;case 727:this.$={select:s[o]};break;case 728:this.$=new n.CreateEdge({from:s[o-3],to:s[o-1],name:s[o-5]}),n.extend(this.$,s[o]);break;case 729:this.$=new n.CreateGraph({graph:s[o]});break;case 730:this.$=new n.CreateGraph({from:s[o]});break;case 733:this.$=s[o-2],s[o-1]&&(this.$.json=new n.Json({value:s[o-1]})),s[o]&&(this.$.as=s[o]);break;case 734:this.$={source:s[o-6],target:s[o]},s[o-3]&&(this.$.json=new n.Json({value:s[o-3]})),s[o-2]&&(this.$.as=s[o-2]),n.extend(this.$,s[o-4]);break;case 735:this.$={source:s[o-5],target:s[o]},s[o-2]&&(this.$.json=new n.Json({value:s[o-3]})),s[o-1]&&(this.$.as=s[o-2]);break;case 736:this.$={source:s[o-2],target:s[o]};break;case 740:this.$={vars:s[o],method:s[o-1]};break;case 743:case 744:var b=s[o-1];this.$={prop:s[o-3],sharp:s[o-2],name:void 0===b?void 0:b.substr(1,b.length-2),class:s[o]};break;case 745:var E=s[o-1];this.$={sharp:s[o-2],name:void 0===E?void 0:E.substr(1,E.length-2),class:s[o]};break;case 746:var g=s[o-1];this.$={name:void 0===g?void 0:g.substr(1,g.length-2),class:s[o]};break;case 747:this.$={class:s[o]};break;case 753:this.$=new n.AddRule({left:s[o-2],right:s[o]});break;case 754:this.$=new n.AddRule({right:s[o]});break;case 757:this.$=new n.Term({termid:s[o]});break;case 758:this.$=new n.Term({termid:s[o-3],args:s[o-1]});break;case 761:this.$=new n.CreateTrigger({trigger:s[o-6],when:s[o-5],action:s[o-4],table:s[o-2],statement:s[o]}),s[o].exists&&(this.$.exists=s[o].exists),s[o].queries&&(this.$.queries=s[o].queries);break;case 762:this.$=new n.CreateTrigger({trigger:s[o-5],when:s[o-4],action:s[o-3],table:s[o-1],funcid:s[o]});break;case 763:this.$=new n.CreateTrigger({trigger:s[o-6],when:s[o-4],action:s[o-3],table:s[o-5],statement:s[o]}),s[o].exists&&(this.$.exists=s[o].exists),s[o].queries&&(this.$.queries=s[o].queries);break;case 764:case 765:case 767:this.$="AFTER";break;case 766:this.$="BEFORE";break;case 768:this.$="INSTEADOF";break;case 769:this.$="INSERT";break;case 770:this.$="DELETE";break;case 771:this.$="UPDATE";break;case 772:this.$=new n.DropTrigger({trigger:s[o]});break;case 773:this.$=new n.Reindex({indexid:s[o]});break;case 1047:case 1067:case 1069:case 1071:case 1075:case 1077:case 1079:case 1081:case 1083:case 1085:this.$=[];break;case 1048:case 1062:case 1064:case 1068:case 1070:case 1072:case 1076:case 1078:case 1080:case 1082:case 1084:case 1086:s[o-1].push(s[o]);break;case 1061:case 1063:this.$=[s[o]]}},table:[t([10,602,764],r,{8:1,9:2,12:3,13:4,17:5,18:7,19:8,20:9,21:10,22:11,23:12,24:13,25:14,26:15,27:16,28:17,29:18,30:19,31:20,32:21,33:22,34:23,35:24,36:25,37:26,38:27,39:28,40:29,41:30,42:31,43:32,44:33,45:34,46:35,47:36,48:37,49:38,50:39,51:40,52:41,54:43,55:44,56:45,57:46,58:47,59:48,60:49,61:50,62:51,63:52,64:53,65:54,66:55,67:56,68:57,69:58,70:59,71:60,79:75,504:95,184:99,3:100,2:n,4:a,5:s,14:i,53:o,72:u,89:c,124:l,146:h,156:d,189:f,266:p,267:b,290:E,335:g,338:m,339:v,396:S,400:T,401:y,404:N,406:C,408:R,409:O,417:I,418:x,434:D,436:k,437:L,439:$,440:M,441:U,442:_,443:F,447:P,448:q,451:G,452:V,505:B,507:j,508:H,517:J}),{1:[3]},{10:[1,105],11:106,602:Y,764:W},t(X,[2,8]),t(X,[2,9]),t(K,[2,12]),t(X,r,{17:5,18:7,19:8,20:9,21:10,22:11,23:12,24:13,25:14,26:15,27:16,28:17,29:18,30:19,31:20,32:21,33:22,34:23,35:24,36:25,37:26,38:27,39:28,40:29,41:30,42:31,43:32,44:33,45:34,46:35,47:36,48:37,49:38,50:39,51:40,52:41,54:43,55:44,56:45,57:46,58:47,59:48,60:49,61:50,62:51,63:52,64:53,65:54,66:55,67:56,68:57,69:58,70:59,71:60,79:75,504:95,184:99,3:100,12:109,2:n,4:a,5:s,15:[1,110],53:o,72:u,89:c,124:l,146:h,156:d,189:f,266:p,267:b,290:E,335:g,338:m,339:v,396:S,400:T,401:y,404:N,406:C,408:R,409:O,417:I,418:x,434:D,436:k,437:L,439:$,440:M,441:U,442:_,443:F,447:P,448:q,451:G,452:V,505:B,507:j,508:H,517:J}),t(K,[2,14]),t(K,[2,15]),t(K,[2,16]),t(K,[2,17]),t(K,[2,18]),t(K,[2,19]),t(K,[2,20]),t(K,[2,21]),t(K,[2,22]),t(K,[2,23]),t(K,[2,24]),t(K,[2,25]),t(K,[2,26]),t(K,[2,27]),t(K,[2,28]),t(K,[2,29]),t(K,[2,30]),t(K,[2,31]),t(K,[2,32]),t(K,[2,33]),t(K,[2,34]),t(K,[2,35]),t(K,[2,36]),t(K,[2,37]),t(K,[2,38]),t(K,[2,39]),t(K,[2,40]),t(K,[2,41]),t(K,[2,42]),t(K,[2,43]),t(K,[2,44]),t(K,[2,45]),t(K,[2,46]),t(K,[2,47]),t(K,[2,48]),t(K,[2,49]),t(K,[2,50]),t(K,[2,51]),t(K,[2,52]),t(K,[2,53]),t(K,[2,54]),t(K,[2,55]),t(K,[2,56]),t(K,[2,57]),t(K,[2,58]),t(K,[2,59]),t(K,[2,60]),t(K,[2,61]),t(K,[2,62]),t(K,[2,63]),t(K,[2,64]),t(K,[2,65]),t(K,[2,66]),t(K,[2,67]),{353:[1,111]},{2:n,3:112,4:a,5:s},{2:n,3:114,4:a,5:s,156:Q,200:113,290:z,291:Z,292:ee,293:te},t(re,[2,501],{3:121,348:125,2:n,4:a,5:s,134:ne,135:ae,187:[1,123],193:[1,122],268:[1,129],269:[1,130],357:[1,131],405:[1,120],472:[1,124],509:[1,128]}),{145:se,449:132,450:133},{183:[1,135]},{405:[1,136]},{2:n,3:138,4:a,5:s,130:[1,144],193:[1,139],353:[1,143],397:140,405:[1,137],410:[1,141],509:[1,142]},{2:n,3:168,4:a,5:s,56:165,77:ie,94:145,111:149,113:153,131:oe,132:ue,137:ce,143:le,144:161,145:he,149:de,152:fe,154:pe,156:Q,158:167,179:be,180:Ee,181:ge,196:151,200:147,201:155,202:156,254:150,255:146,256:148,257:152,258:154,259:157,260:158,261:159,262:162,263:163,265:me,266:p,270:ve,271:Se,273:Te,280:Ae,281:ye,282:Ne,283:Ce,284:Re,285:Oe,286:we,287:Ie,288:xe,290:z,291:Z,292:ee,293:te,294:De,295:ke,296:Le,297:$e,298:Me,299:Ue,302:_e,303:Fe,312:Pe,317:qe,419:190,420:Ge,424:Ve},t(Be,je,{340:204,171:[1,205],198:He}),t(Be,je,{340:207,198:He}),{2:n,3:219,4:a,5:s,77:Je,132:Ye,143:le,144:212,145:he,152:fe,156:Q,181:ge,198:[1,210],199:213,200:215,201:214,202:217,209:209,213:We,214:218,290:z,291:Z,292:ee,293:te,302:_e,419:190,420:Ge,424:Ve,453:208},{2:n,3:221,4:a,5:s},{353:[1,222]},t(Xe,[2,1043],{80:223,106:224,107:[1,225]}),t(Ke,[2,1047],{90:226}),{2:n,3:230,4:a,5:s,190:[1,228],193:[1,231],267:[1,227],353:[1,232],405:[1,229]},{353:[1,233]},{2:n,3:236,4:a,5:s,73:234,75:235},t([306,602,764],r,{12:3,13:4,17:5,18:7,19:8,20:9,21:10,22:11,23:12,24:13,25:14,26:15,27:16,28:17,29:18,30:19,31:20,32:21,33:22,34:23,35:24,36:25,37:26,38:27,39:28,40:29,41:30,42:31,43:32,44:33,45:34,46:35,47:36,48:37,49:38,50:39,51:40,52:41,54:43,55:44,56:45,57:46,58:47,59:48,60:49,61:50,62:51,63:52,64:53,65:54,66:55,67:56,68:57,69:58,70:59,71:60,79:75,504:95,184:99,3:100,9:238,2:n,4:a,5:s,14:i,53:o,72:u,89:c,124:l,146:h,156:d,189:f,266:p,267:b,290:E,335:g,338:m,339:v,396:S,400:T,401:y,404:N,406:C,408:R,409:O,417:I,418:x,434:D,435:[1,237],436:k,437:L,439:$,440:M,441:U,442:_,443:F,447:P,448:q,451:G,452:V,505:B,507:j,508:H,517:J}),{435:[1,239]},{435:[1,240]},{2:n,3:242,4:a,5:s,405:[1,241]},{2:n,3:244,4:a,5:s,199:243},t(Qe,[2,311]),{113:245,132:ue,296:Le},{2:n,3:114,4:a,5:s,113:251,131:oe,132:[1,248],143:le,144:246,145:ze,152:fe,156:Q,181:ge,196:250,200:255,201:254,257:252,258:253,265:Ze,274:247,290:z,291:Z,292:ee,293:te,294:De,295:ke,296:Le,297:$e,302:_e,419:190,420:Ge,424:Ve},{2:n,3:168,4:a,5:s,56:165,77:ie,94:257,111:149,113:153,131:oe,132:ue,137:ce,143:le,144:161,145:he,149:de,152:fe,154:pe,156:Q,158:167,179:be,180:Ee,181:ge,196:151,200:147,201:155,202:156,254:150,255:146,256:148,257:152,258:154,259:157,260:158,261:159,262:162,263:163,265:me,266:p,270:ve,271:Se,273:Te,280:Ae,281:ye,282:Ne,283:Ce,284:Re,285:Oe,286:we,287:Ie,288:xe,290:z,291:Z,292:ee,293:te,294:De,295:ke,296:Le,297:$e,298:Me,299:Ue,302:_e,303:Fe,312:Pe,317:qe,419:190,420:Ge,424:Ve},t(K,[2,672]),t(K,[2,673]),{2:n,3:168,4:a,5:s,40:259,56:165,77:ie,79:75,89:c,94:260,111:149,113:153,131:oe,132:ue,137:ce,143:le,144:161,145:he,149:de,151:258,152:fe,154:pe,156:Q,158:167,179:be,180:Ee,181:ge,184:99,189:f,196:151,200:147,201:155,202:156,254:150,255:146,256:148,257:152,258:154,259:157,260:158,261:159,262:162,263:163,265:me,266:p,270:ve,271:Se,273:Te,280:Ae,281:ye,282:Ne,283:Ce,284:Re,285:Oe,286:we,287:Ie,288:xe,290:z,291:Z,292:ee,293:te,294:De,295:ke,296:Le,297:$e,298:Me,299:Ue,302:_e,303:Fe,312:Pe,317:qe,419:190,420:Ge,424:Ve},{2:n,3:266,4:a,5:s,113:263,132:ue,296:Le,444:261,445:262,446:264,447:et},{2:n,3:267,4:a,5:s,143:tt,145:rt,431:268},{2:n,3:168,4:a,5:s,56:165,77:ie,94:271,111:149,113:153,131:oe,132:ue,137:ce,143:le,144:161,145:he,149:de,152:fe,154:pe,156:Q,158:167,179:be,180:Ee,181:ge,196:151,200:147,201:155,202:156,254:150,255:146,256:148,257:152,258:154,259:157,260:158,261:159,262:162,263:163,265:me,266:p,270:ve,271:Se,273:Te,280:Ae,281:ye,282:Ne,283:Ce,284:Re,285:Oe,286:we,287:Ie,288:xe,290:z,291:Z,292:ee,293:te,294:De,295:ke,296:Le,297:$e,298:Me,299:Ue,302:_e,303:Fe,312:Pe,317:qe,419:190,420:Ge,424:Ve},{505:[1,272]},{2:n,3:100,4:a,5:s,504:274,506:273},{2:n,3:114,4:a,5:s,156:Q,200:275,290:z,291:Z,292:ee,293:te},{2:n,3:168,4:a,5:s,56:165,77:ie,94:276,111:149,113:153,131:oe,132:ue,137:ce,143:le,144:161,145:he,149:de,152:fe,154:pe,156:Q,158:167,179:be,180:Ee,181:ge,196:151,200:147,201:155,202:156,254:150,255:146,256:148,257:152,258:154,259:157,260:158,261:159,262:162,263:163,265:me,266:p,270:ve,271:Se,273:Te,280:Ae,281:ye,282:Ne,283:Ce,284:Re,285:Oe,286:we,287:Ie,288:xe,290:z,291:Z,292:ee,293:te,294:De,295:ke,296:Le,297:$e,298:Me,299:Ue,302:_e,303:Fe,312:Pe,317:qe,419:190,420:Ge,424:Ve},t(nt,at,{186:280,164:[1,279],185:[1,277],187:[1,278],195:st}),t(it,[2,757],{77:[1,282]}),t([2,4,5,10,72,77,78,93,98,107,118,128,131,132,137,143,145,152,154,156,162,164,168,169,179,180,181,183,185,187,195,198,232,245,247,265,266,270,271,273,280,281,282,283,284,285,286,287,288,290,291,292,293,294,295,296,297,298,299,302,303,306,310,312,317,420,424,602,764],[2,152],{149:[1,283],150:[1,284],190:[1,285],191:[1,286],192:[1,287],193:[1,288],194:[1,289]}),t(ot,[2,1]),t(ot,[2,2]),{6:290,131:[1,439],172:[1,462],245:[1,411],285:[1,373],286:[1,407],370:[1,404],381:[1,295],402:[1,297],410:[1,549],414:[1,471],416:[1,443],417:[1,509],433:[1,442],435:[1,525],440:[1,342],460:[1,418],464:[1,448],470:[1,341],514:[1,307],515:[1,299],516:[1,399],518:[1,291],519:[1,292],520:[1,293],521:[1,294],522:[1,296],523:[1,298],524:[1,300],525:[1,301],526:[1,302],527:[1,303],528:[1,304],529:[1,305],530:[1,306],531:[1,308],532:[1,309],533:[1,310],534:[1,311],535:[1,312],536:[1,313],537:[1,314],538:[1,315],539:[1,316],540:[1,317],541:[1,318],542:[1,319],543:[1,320],544:[1,321],545:[1,322],546:[1,323],547:[1,324],548:[1,325],549:[1,326],550:[1,327],551:[1,328],552:[1,329],553:[1,330],554:[1,331],555:[1,332],556:[1,333],557:[1,334],558:[1,335],559:[1,336],560:[1,337],561:[1,338],562:[1,339],563:[1,340],564:[1,343],565:[1,344],566:[1,345],567:[1,346],568:[1,347],569:[1,348],570:[1,349],571:[1,350],572:[1,351],573:[1,352],574:[1,353],575:[1,354],576:[1,355],577:[1,356],578:[1,357],579:[1,358],580:[1,359],581:[1,360],582:[1,361],583:[1,362],584:[1,363],585:[1,364],586:[1,365],587:[1,366],588:[1,367],589:[1,368],590:[1,369],591:[1,370],592:[1,371],593:[1,372],594:[1,374],595:[1,375],596:[1,376],597:[1,377],598:[1,378],599:[1,379],600:[1,380],601:[1,381],602:[1,382],603:[1,383],604:[1,384],605:[1,385],606:[1,386],607:[1,387],608:[1,388],609:[1,389],610:[1,390],611:[1,391],612:[1,392],613:[1,393],614:[1,394],615:[1,395],616:[1,396],617:[1,397],618:[1,398],619:[1,400],620:[1,401],621:[1,402],622:[1,403],623:[1,405],624:[1,406],625:[1,408],626:[1,409],627:[1,410],628:[1,412],629:[1,413],630:[1,414],631:[1,415],632:[1,416],633:[1,417],634:[1,419],635:[1,420],636:[1,421],637:[1,422],638:[1,423],639:[1,424],640:[1,425],641:[1,426],642:[1,427],643:[1,428],644:[1,429],645:[1,430],646:[1,431],647:[1,432],648:[1,433],649:[1,434],650:[1,435],651:[1,436],652:[1,437],653:[1,438],654:[1,440],655:[1,441],656:[1,444],657:[1,445],658:[1,446],659:[1,447],660:[1,449],661:[1,450],662:[1,451],663:[1,452],664:[1,453],665:[1,454],666:[1,455],667:[1,456],668:[1,457],669:[1,458],670:[1,459],671:[1,460],672:[1,461],673:[1,463],674:[1,464],675:[1,465],676:[1,466],677:[1,467],678:[1,468],679:[1,469],680:[1,470],681:[1,472],682:[1,473],683:[1,474],684:[1,475],685:[1,476],686:[1,477],687:[1,478],688:[1,479],689:[1,480],690:[1,481],691:[1,482],692:[1,483],693:[1,484],694:[1,485],695:[1,486],696:[1,487],697:[1,488],698:[1,489],699:[1,490],700:[1,491],701:[1,492],702:[1,493],703:[1,494],704:[1,495],705:[1,496],706:[1,497],707:[1,498],708:[1,499],709:[1,500],710:[1,501],711:[1,502],712:[1,503],713:[1,504],714:[1,505],715:[1,506],716:[1,507],717:[1,508],718:[1,510],719:[1,511],720:[1,512],721:[1,513],722:[1,514],723:[1,515],724:[1,516],725:[1,517],726:[1,518],727:[1,519],728:[1,520],729:[1,521],730:[1,522],731:[1,523],732:[1,524],733:[1,526],734:[1,527],735:[1,528],736:[1,529],737:[1,530],738:[1,531],739:[1,532],740:[1,533],741:[1,534],742:[1,535],743:[1,536],744:[1,537],745:[1,538],746:[1,539],747:[1,540],748:[1,541],749:[1,542],750:[1,543],751:[1,544],752:[1,545],753:[1,546],754:[1,547],755:[1,548],756:[1,550],757:[1,551],758:[1,552],759:[1,553],760:[1,554],761:[1,555],762:[1,556],763:[1,557]},{1:[2,6]},t(X,r,{17:5,18:7,19:8,20:9,21:10,22:11,23:12,24:13,25:14,26:15,27:16,28:17,29:18,30:19,31:20,32:21,33:22,34:23,35:24,36:25,37:26,38:27,39:28,40:29,41:30,42:31,43:32,44:33,45:34,46:35,47:36,48:37,49:38,50:39,51:40,52:41,54:43,55:44,56:45,57:46,58:47,59:48,60:49,61:50,62:51,63:52,64:53,65:54,66:55,67:56,68:57,69:58,70:59,71:60,79:75,504:95,184:99,3:100,12:558,2:n,4:a,5:s,53:o,72:u,89:c,124:l,146:h,156:d,189:f,266:p,267:b,290:E,335:g,338:m,339:v,396:S,400:T,401:y,404:N,406:C,408:R,409:O,417:I,418:x,434:D,436:k,437:L,439:$,440:M,441:U,442:_,443:F,447:P,448:q,451:G,452:V,505:B,507:j,508:H,517:J}),t(ut,[2,1041]),t(ut,[2,1042]),t(X,[2,10]),{16:[1,559]},{2:n,3:244,4:a,5:s,199:560},{405:[1,561]},t(K,[2,760]),{77:ct},{77:[1,563]},{77:lt},{77:[1,565]},{77:[1,566]},{2:n,3:168,4:a,5:s,56:165,77:ie,94:567,111:149,113:153,131:oe,132:ue,137:ce,143:le,144:161,145:he,149:de,152:fe,154:pe,156:Q,158:167,179:be,180:Ee,181:ge,196:151,200:147,201:155,202:156,254:150,255:146,256:148,257:152,258:154,259:157,260:158,261:159,262:162,263:163,265:me,266:p,270:ve,271:Se,273:Te,280:Ae,281:ye,282:Ne,283:Ce,284:Re,285:Oe,286:we,287:Ie,288:xe,290:z,291:Z,292:ee,293:te,294:De,295:ke,296:Le,297:$e,298:Me,299:Ue,302:_e,303:Fe,312:Pe,317:qe,419:190,420:Ge,424:Ve},t(Be,ht,{350:568,156:dt}),{405:[1,570]},{2:n,3:571,4:a,5:s},{193:[1,572]},{2:n,3:578,4:a,5:s,132:ft,137:pt,143:tt,145:rt,152:bt,183:[1,574],431:585,473:573,474:575,475:576,478:577,482:582,493:579,497:581},{130:[1,589],349:586,353:[1,588],410:[1,587]},{113:591,132:ue,183:[2,1141],296:Le,471:590},t(Et,[2,1135],{465:592,3:593,2:n,4:a,5:s}),{2:n,3:594,4:a,5:s},{4:[1,595]},{4:[1,596]},t(re,[2,502]),t(K,[2,686],{74:[1,597]}),t(gt,[2,687]),{2:n,3:598,4:a,5:s},{2:n,3:244,4:a,5:s,199:599},{2:n,3:600,4:a,5:s},t(Be,mt,{398:601,156:vt}),{405:[1,603]},{2:n,3:604,4:a,5:s},t(Be,mt,{398:605,156:vt}),t(Be,mt,{398:606,156:vt}),{2:n,3:607,4:a,5:s},t(St,[2,1129]),t(St,[2,1130]),t(K,r,{17:5,18:7,19:8,20:9,21:10,22:11,23:12,24:13,25:14,26:15,27:16,28:17,29:18,30:19,31:20,32:21,33:22,34:23,35:24,36:25,37:26,38:27,39:28,40:29,41:30,42:31,43:32,44:33,45:34,46:35,47:36,48:37,49:38,50:39,51:40,52:41,54:43,55:44,56:45,57:46,58:47,59:48,60:49,61:50,62:51,63:52,64:53,65:54,66:55,67:56,68:57,69:58,70:59,71:60,79:75,504:95,184:99,3:100,12:608,114:625,327:637,2:n,4:a,5:s,53:o,72:u,89:c,99:Tt,112:At,115:yt,116:Nt,123:Ct,124:Rt,133:Ot,136:wt,138:It,139:xt,140:Dt,141:kt,142:Lt,146:h,154:$t,156:d,170:Mt,171:Ut,179:_t,180:Ft,189:f,266:p,267:b,290:E,311:Pt,312:qt,313:Gt,315:Vt,316:Bt,317:jt,318:Ht,319:Jt,320:Yt,321:Wt,322:Xt,323:Kt,324:Qt,325:zt,326:Zt,330:er,331:tr,332:rr,333:nr,335:g,338:m,339:v,396:S,400:T,401:y,404:N,406:C,408:R,409:O,417:I,418:x,434:D,436:k,437:L,439:$,440:M,441:U,442:_,443:F,447:P,448:q,451:G,452:V,505:B,507:j,508:H,517:J}),t(Qe,[2,288]),t(Qe,[2,289]),t(Qe,[2,290]),t(Qe,[2,291]),t(Qe,[2,292]),t(Qe,[2,293]),t(Qe,[2,294]),t(Qe,[2,295]),t(Qe,[2,296]),t(Qe,[2,297]),t(Qe,[2,298]),t(Qe,[2,299]),t(Qe,[2,300]),t(Qe,[2,301]),t(Qe,[2,302]),t(Qe,[2,303]),t(Qe,[2,304]),t(Qe,[2,305]),{2:n,3:168,4:a,5:s,26:654,27:653,36:649,40:648,56:165,77:ie,79:75,89:c,94:651,111:149,113:153,131:oe,132:ue,137:ce,143:le,144:161,145:he,149:de,152:fe,154:pe,156:Q,158:167,179:be,180:Ee,181:ge,184:99,189:f,196:151,200:147,201:155,202:156,254:150,255:146,256:148,257:152,258:154,259:157,260:158,261:159,262:162,263:163,264:650,265:me,266:p,267:[1,655],270:ve,271:Se,273:Te,280:Ae,281:ye,282:Ne,283:Ce,284:Re,285:Oe,286:we,287:Ie,288:xe,290:[1,652],291:Z,292:ee,293:te,294:De,295:ke,296:Le,297:$e,298:Me,299:Ue,302:_e,303:Fe,312:Pe,317:qe,339:v,419:190,420:Ge,424:Ve},t(Qe,[2,309]),t(Qe,[2,310]),{77:[1,656]},t([2,4,5,10,53,72,74,76,78,89,93,95,98,99,107,112,115,118,122,123,124,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,145,146,148,149,150,152,154,156,162,164,166,168,169,170,171,172,173,175,179,180,181,183,185,187,189,198,206,208,222,223,224,225,226,227,228,229,232,239,242,243,245,247,266,267,280,281,282,283,284,285,286,287,288,290,296,300,306,308,309,310,311,312,313,314,315,316,317,318,319,320,321,322,323,324,325,326,330,331,332,333,335,338,339,396,400,401,404,406,408,409,417,418,420,424,434,436,437,439,440,441,442,443,447,448,451,452,464,470,505,507,508,517,602,764],ar,{77:ct,116:[1,657]}),{2:n,3:168,4:a,5:s,56:165,77:ie,94:658,111:149,113:153,131:oe,132:ue,137:ce,143:le,144:161,145:he,149:de,152:fe,154:pe,156:Q,158:167,179:be,180:Ee,181:ge,196:151,200:147,201:155,202:156,254:150,255:146,256:148,257:152,258:154,259:157,260:158,261:159,262:162,263:163,265:me,266:p,270:ve,271:Se,273:Te,280:Ae,281:ye,282:Ne,283:Ce,284:Re,285:Oe,286:we,287:Ie,288:xe,290:z,291:Z,292:ee,293:te,294:De,295:ke,296:Le,297:$e,298:Me,299:Ue,302:_e,303:Fe,312:Pe,317:qe,419:190,420:Ge,424:Ve},{2:n,3:168,4:a,5:s,56:165,77:ie,94:659,111:149,113:153,131:oe,132:ue,137:ce,143:le,144:161,145:he,149:de,152:fe,154:pe,156:Q,158:167,179:be,180:Ee,181:ge,196:151,200:147,201:155,202:156,254:150,255:146,256:148,257:152,258:154,259:157,260:158,261:159,262:162,263:163,265:me,266:p,270:ve,271:Se,273:Te,280:Ae,281:ye,282:Ne,283:Ce,284:Re,285:Oe,286:we,287:Ie,288:xe,290:z,291:Z,292:ee,293:te,294:De,295:ke,296:Le,297:$e,298:Me,299:Ue,302:_e,303:Fe,312:Pe,317:qe,419:190,420:Ge,424:Ve},{2:n,3:168,4:a,5:s,56:165,77:ie,94:660,111:149,113:153,131:oe,132:ue,137:ce,143:le,144:161,145:he,149:de,152:fe,154:pe,156:Q,158:167,179:be,180:Ee,181:ge,196:151,200:147,201:155,202:156,254:150,255:146,256:148,257:152,258:154,259:157,260:158,261:159,262:162,263:163,265:me,266:p,270:ve,271:Se,273:Te,280:Ae,281:ye,282:Ne,283:Ce,284:Re,285:Oe,286:we,287:Ie,288:xe,290:z,291:Z,292:ee,293:te,294:De,295:ke,296:Le,297:$e,298:Me,299:Ue,302:_e,303:Fe,312:Pe,317:qe,419:190,420:Ge,424:Ve},{2:n,3:168,4:a,5:s,56:165,77:ie,94:661,111:149,113:153,131:oe,132:ue,137:ce,143:le,144:161,145:he,149:de,152:fe,154:pe,156:Q,158:167,179:be,180:Ee,181:ge,196:151,200:147,201:155,202:156,254:150,255:146,256:148,257:152,258:154,259:157,260:158,261:159,262:162,263:163,265:me,266:p,270:ve,271:Se,273:Te,280:Ae,281:ye,282:Ne,283:Ce,284:Re,285:Oe,286:we,287:Ie,288:xe,290:z,291:Z,292:ee,293:te,294:De,295:ke,296:Le,297:$e,298:Me,299:Ue,302:_e,303:Fe,312:Pe,317:qe,419:190,420:Ge,424:Ve},{2:n,3:168,4:a,5:s,56:165,77:ie,94:662,111:149,113:153,131:oe,132:ue,137:ce,143:le,144:161,145:he,149:de,152:fe,154:pe,156:Q,158:167,179:be,180:Ee,181:ge,196:151,200:147,201:155,202:156,254:150,255:146,256:148,257:152,258:154,259:157,260:158,261:159,262:162,263:163,265:me,266:p,270:ve,271:Se,273:Te,280:Ae,281:ye,282:Ne,283:Ce,284:Re,285:Oe,286:we,287:Ie,288:xe,290:z,291:Z,292:ee,293:te,294:De,295:ke,296:Le,297:$e,298:Me,299:Ue,302:_e,303:Fe,312:Pe,317:qe,419:190,420:Ge,424:Ve
@@ -10,7 +10,7 @@ queriesidx:n.queries.length}),n.queries.push(s[o-1]);break;case 424:this.$=new n
 317:jt,318:Ht,319:Jt,320:Yt,321:Wt,322:Xt,323:Kt,324:Qt,325:zt,326:Zt,327:637,330:er,331:tr,332:rr,333:nr},t(fn,[2,562]),{2:n,3:168,4:a,5:s,56:165,77:ie,94:1743,111:149,113:153,131:oe,132:ue,137:ce,143:le,144:161,145:he,149:de,152:fe,154:pe,156:Q,158:167,179:be,180:Ee,181:ge,196:151,200:147,201:155,202:156,254:150,255:146,256:148,257:152,258:154,259:157,260:158,261:159,262:162,263:163,265:me,266:p,270:ve,271:Se,273:Te,280:Ae,281:ye,282:Ne,283:Ce,284:Re,285:Oe,286:we,287:Ie,288:xe,290:z,291:Z,292:ee,293:te,294:De,295:ke,296:Le,297:$e,298:Me,299:Ue,302:_e,303:Fe,312:Pe,317:qe,419:190,420:Ge,424:Ve},{78:[1,1744],99:Tt,112:At,114:625,115:yt,116:Nt,123:Ct,124:En,133:Ot,136:wt,138:It,139:xt,140:Dt,141:kt,142:Lt,154:$t,170:Mt,171:Ut,179:_t,180:Ft,311:Pt,312:qt,313:Gt,315:Vt,316:Bt,317:jt,318:Ht,319:Jt,320:Yt,321:Wt,322:Xt,323:Kt,324:Qt,325:zt,326:Zt,327:637,330:er,331:tr,332:rr,333:nr},t(oi,[2,495]),{2:n,3:1745,4:a,5:s},{131:oe,196:1746},{2:n,3:1747,4:a,5:s},t(zs,Zs,{361:1627,360:1748,367:ei}),t(Sn,[2,510]),t(Sn,[2,511]),t(Sn,[2,512]),t(Sn,[2,513]),t(Sn,[2,514]),{370:[1,1749]},{370:[1,1750]},t(li,[2,1121],{382:1751,370:[1,1752]}),{2:n,3:1753,4:a,5:s},{2:n,3:1754,4:a,5:s},t(zs,[2,516]),t(K,[2,1131],{411:1755,413:1756,72:qs}),t(K,[2,610]),t(K,[2,611],{367:[1,1757]}),t(Qe,[2,333]),t([78,118],[2,334],{74:ui}),{74:ws,78:[2,335]},t(K,[2,719]),{2:n,3:1011,4:a,5:s,100:1758,111:1440},t(us,[2,706],{74:Ja}),t(us,[2,704]),{77:sa,143:le,144:979,145:ze,152:fe,181:ge,201:980,302:_e,342:1759,419:190,420:Ge,424:Ve},{2:n,3:1011,4:a,5:s,100:1760,111:1440},{344:[1,1761]},{339:ti,462:1762},{2:n,3:168,4:a,5:s,56:165,77:ie,94:1763,111:149,113:153,131:oe,132:ue,137:ce,143:le,144:161,145:he,149:de,152:fe,154:pe,156:Q,158:167,179:be,180:Ee,181:ge,196:151,200:147,201:155,202:156,254:150,255:146,256:148,257:152,258:154,259:157,260:158,261:159,262:162,263:163,265:me,266:p,270:ve,271:Se,273:Te,280:Ae,281:ye,282:Ne,283:Ce,284:Re,285:Oe,286:we,287:Ie,288:xe,290:z,291:Z,292:ee,293:te,294:De,295:ke,296:Le,297:$e,298:Me,299:Ue,302:_e,303:Fe,312:Pe,317:qe,419:190,420:Ge,424:Ve},{339:ti,462:1764},{2:n,3:168,4:a,5:s,56:165,77:ie,94:1765,111:149,113:153,131:oe,132:ue,137:ce,143:le,144:161,145:he,149:de,152:fe,154:pe,156:Q,158:167,179:be,180:Ee,181:ge,196:151,200:147,201:155,202:156,254:150,255:146,256:148,257:152,258:154,259:157,260:158,261:159,262:162,263:163,265:me,266:p,270:ve,271:Se,273:Te,280:Ae,281:ye,282:Ne,283:Ce,284:Re,285:Oe,286:we,287:Ie,288:xe,290:z,291:Z,292:ee,293:te,294:De,295:ke,296:Le,297:$e,298:Me,299:Ue,302:_e,303:Fe,312:Pe,317:qe,419:190,420:Ge,424:Ve},{339:ti,462:1766},t(ua,[2,72]),{40:1767,79:75,89:c,164:[1,1768],184:99,189:f,240:[1,1769]},{40:1770,79:75,89:c,184:99,189:f,240:[1,1771]},{40:1772,79:75,89:c,184:99,189:f,240:[1,1773]},t(ri,[2,270],{246:1774,247:[1,1775]}),{248:1776,249:[2,1099],766:[1,1777]},t(Hs,[2,260],{74:ws}),t(ys,[2,241]),{2:n,3:168,4:a,5:s,56:165,77:ie,94:1660,111:149,113:153,131:oe,132:ue,137:ce,143:le,144:161,145:he,149:de,152:fe,154:pe,156:Q,158:167,179:be,180:Ee,181:ge,196:151,200:147,201:155,202:156,235:1778,236:ni,237:ai,238:si,254:150,255:146,256:148,257:152,258:154,259:157,260:158,261:159,262:162,263:163,265:me,266:p,270:ve,271:Se,273:Te,280:Ae,281:ye,282:Ne,283:Ce,284:Re,285:Oe,286:we,287:Ie,288:xe,290:z,291:Z,292:ee,293:te,294:De,295:ke,296:Le,297:$e,298:Me,299:Ue,302:_e,303:Fe,312:Pe,317:qe,419:190,420:Ge,424:Ve},{2:n,3:168,4:a,5:s,56:165,77:ie,94:1779,111:149,113:153,131:oe,132:ue,137:ce,143:le,144:161,145:he,149:de,152:fe,154:pe,156:Q,158:167,179:be,180:Ee,181:ge,196:151,200:147,201:155,202:156,254:150,255:146,256:148,257:152,258:154,259:157,260:158,261:159,262:162,263:163,265:me,266:p,270:ve,271:Se,273:Te,280:Ae,281:ye,282:Ne,283:Ce,284:Re,285:Oe,286:we,287:Ie,288:xe,290:z,291:Z,292:ee,293:te,294:De,295:ke,296:Le,297:$e,298:Me,299:Ue,302:_e,303:Fe,312:Pe,317:qe,419:190,420:Ge,424:Ve},{77:[1,1780]},{2:n,3:168,4:a,5:s,56:165,77:ie,94:1660,111:149,113:153,131:oe,132:ue,137:ce,143:le,144:161,145:he,149:de,152:fe,154:pe,156:Q,158:167,179:be,180:Ee,181:ge,196:151,200:147,201:155,202:156,233:1781,235:1656,236:ni,237:ai,238:si,254:150,255:146,256:148,257:152,258:154,259:157,260:158,261:159,262:162,263:163,265:me,266:p,270:ve,271:Se,273:Te,280:Ae,281:ye,282:Ne,283:Ce,284:Re,285:Oe,286:we,287:Ie,288:xe,290:z,291:Z,292:ee,293:te,294:De,295:ke,296:Le,297:$e,298:Me,299:Ue,302:_e,303:Fe,312:Pe,317:qe,419:190,420:Ge,424:Ve},{2:n,3:168,4:a,5:s,56:165,77:ie,94:1660,111:149,113:153,131:oe,132:ue,137:ce,143:le,144:161,145:he,149:de,152:fe,154:pe,156:Q,158:167,179:be,180:Ee,181:ge,196:151,200:147,201:155,202:156,233:1782,235:1656,236:ni,237:ai,238:si,254:150,255:146,256:148,257:152,258:154,259:157,260:158,261:159,262:162,263:163,265:me,266:p,270:ve,271:Se,273:Te,280:Ae,281:ye,282:Ne,283:Ce,284:Re,285:Oe,286:we,287:Ie,288:xe,290:z,291:Z,292:ee,293:te,294:De,295:ke,296:Le,297:$e,298:Me,299:Ue,302:_e,303:Fe,312:Pe,317:qe,419:190,420:Ge,424:Ve},{78:[1,1783]},{78:[2,1052]},{77:[1,1784]},{77:[1,1785]},t(Js,[2,214]),{2:n,3:1786,4:a,5:s},{2:n,3:1787,4:a,5:s,76:[1,1788]},{2:n,3:1789,4:a,5:s,76:[1,1790]},t(fn,[2,1125],{394:1791,393:1792,77:ii}),{78:[1,1793]},{131:oe,196:1794},t(fn,[2,556]),{78:[1,1795],99:Tt,112:At,114:625,115:yt,116:Nt,123:Ct,124:En,133:Ot,136:wt,138:It,139:xt,140:Dt,141:kt,142:Lt,154:$t,170:Mt,171:Ut,179:_t,180:Ft,311:Pt,312:qt,313:Gt,315:Vt,316:Bt,317:jt,318:Ht,319:Jt,320:Yt,321:Wt,322:Xt,323:Kt,324:Qt,325:zt,326:Zt,327:637,330:er,331:tr,332:rr,333:nr},t(fn,[2,517]),t(oi,[2,498]),t(oi,[2,499]),t(oi,[2,500]),t(os,[2,509]),{2:n,3:1797,4:a,5:s,77:[2,1117],371:1796},{77:[1,1798]},{2:n,3:1800,4:a,5:s,77:[2,1123],383:1799},t(li,[2,1122]),{77:[1,1801]},{77:[1,1802]},t(K,[2,608]),t(K,[2,1132]),t(zs,Zs,{361:1627,360:1803,367:ei}),{74:as,78:[1,1804]},t(us,[2,713],{74:Ua}),{74:as,78:[1,1805]},t(us,[2,715]),t(us,[2,708]),{99:Tt,112:At,114:625,115:yt,116:Nt,123:Ct,124:En,133:Ot,136:wt,138:It,139:xt,140:Dt,141:kt,142:Lt,154:$t,170:Mt,171:Ut,179:_t,180:Ft,309:[1,1806],311:Pt,312:qt,313:Gt,315:Vt,316:Bt,317:jt,318:Ht,319:Jt,320:Yt,321:Wt,322:Xt,323:Kt,324:Qt,325:zt,326:Zt,327:637,330:er,331:tr,332:rr,333:nr},t(us,[2,711]),{99:Tt,112:At,114:625,115:yt,116:Nt,123:Ct,124:En,133:Ot,136:wt,138:It,139:xt,140:Dt,141:kt,142:Lt,154:$t,170:Mt,171:Ut,179:_t,180:Ft,309:[1,1807],311:Pt,312:qt,313:Gt,315:Vt,316:Bt,317:jt,318:Ht,319:Jt,320:Yt,321:Wt,322:Xt,323:Kt,324:Qt,325:zt,326:Zt,327:637,330:er,331:tr,332:rr,333:nr},t(us,[2,709]),t(ua,[2,251]),{40:1808,79:75,89:c,184:99,189:f,240:[1,1809]},{40:1810,79:75,89:c,184:99,189:f},t(ua,[2,253]),{40:1811,79:75,89:c,184:99,189:f},t(ua,[2,254]),{40:1812,79:75,89:c,184:99,189:f},t(ri,[2,268]),{131:oe,196:1813},{249:[1,1814]},{249:[2,1100]},t(ci,[2,243]),t(ys,[2,249],{114:625,327:637,99:Tt,112:At,115:yt,116:Nt,123:Ct,124:En,133:Ot,136:wt,138:It,139:xt,140:Dt,141:kt,142:Lt,154:$t,170:Mt,171:Ut,179:_t,180:Ft,311:Pt,312:qt,313:Gt,315:Vt,316:Bt,317:jt,318:Ht,319:Jt,320:Yt,321:Wt,322:Xt,323:Kt,324:Qt,325:zt,326:Zt,330:er,331:tr,332:rr,333:nr}),{2:n,3:168,4:a,5:s,56:165,77:ie,94:1660,111:149,113:153,131:oe,132:ue,137:ce,143:le,144:161,145:he,149:de,152:fe,154:pe,156:Q,158:167,179:be,180:Ee,181:ge,196:151,200:147,201:155,202:156,233:1815,235:1656,236:ni,237:ai,238:si,254:150,255:146,256:148,257:152,258:154,259:157,260:158,261:159,262:162,263:163,265:me,266:p,270:ve,271:Se,273:Te,280:Ae,281:ye,282:Ne,283:Ce,284:Re,285:Oe,286:we,287:Ie,288:xe,290:z,291:Z,292:ee,293:te,294:De,295:ke,296:Le,297:$e,298:Me,299:Ue,302:_e,303:Fe,312:Pe,317:qe,419:190,420:Ge,424:Ve},{74:ui,78:[1,1816]},{74:ui,78:[1,1817]},t(qa,[2,1053],{97:1818,104:1819,3:1821,2:n,4:a,5:s,76:hi}),{2:n,3:168,4:a,5:s,56:165,77:ie,94:1824,103:1822,105:1823,111:149,113:153,131:oe,132:ue,137:ce,143:le,144:161,145:he,149:de,152:fe,154:pe,156:Q,158:167,179:be,180:Ee,181:ge,196:151,200:147,201:155,202:156,254:150,255:146,256:148,257:152,258:154,259:157,260:158,261:159,262:162,263:163,265:me,266:p,270:ve,271:Se,273:Te,280:Ae,281:ye,282:Ne,283:Ce,284:Re,285:Oe,286:we,287:Ie,288:xe,290:z,291:Z,292:ee,293:te,294:De,295:ke,296:Le,297:$e,298:Me,299:Ue,302:_e,303:Fe,312:Pe,317:qe,419:190,420:Ge,424:Ve},{2:n,3:1011,4:a,5:s,100:1825,111:1440},t(Js,[2,215]),t(Ns,[2,173]),{2:n,3:1826,4:a,5:s},t(Ns,[2,175]),{2:n,3:1827,4:a,5:s},t(fn,[2,551]),t(fn,[2,1126]),t(fn,[2,549]),{78:[1,1828]},t(fn,[2,563]),{77:[1,1829]},{77:[2,1118]},{2:n,3:1831,4:a,5:s,132:di,372:1830},{77:[1,1833]},{77:[2,1124]},{2:n,3:1011,4:a,5:s,100:1834,111:1440},{2:n,3:1011,4:a,5:s,100:1835,111:1440},t(K,[2,612]),t(K,[2,721]),{343:[1,1837],344:[1,1836]},{339:ti,462:1838},{335:Bs,338:js,461:1839},t(ua,[2,252]),{40:1840,79:75,89:c,184:99,189:f},t(ua,[2,255]),t(ua,[2,257]),t(ua,[2,258]),t(ri,[2,271]),{131:[2,1101],250:1841,645:[1,1842]},{74:ui,78:[1,1843]},t(ci,[2,245]),t(ci,[2,246]),t(qa,[2,74]),t(qa,[2,1054]),{2:n,3:1844,4:a,5:s},t(qa,[2,78]),{74:[1,1846],78:[1,1845]},t(os,[2,80]),t(os,[2,81],{114:625,327:637,76:[1,1847],99:Tt,112:At,115:yt,116:Nt,123:Ct,124:En,133:Ot,136:wt,138:It,139:xt,140:Dt,141:kt,142:Lt,154:$t,170:Mt,171:Ut,179:_t,180:Ft,311:Pt,312:qt,313:Gt,315:Vt,316:Bt,317:jt,318:Ht,319:Jt,320:Yt,321:Wt,322:Xt,323:Kt,324:Qt,325:zt,326:Zt,330:er,331:tr,332:rr,333:nr}),{74:as,78:[1,1848]},t(Ns,[2,174]),t(Ns,[2,176]),t(fn,[2,553]),{2:n,3:1831,4:a,5:s,132:di,372:1849},{74:fi,78:[1,1850]},t(os,[2,528]),t(os,[2,529]),{2:n,3:1011,4:a,5:s,100:1852,111:1440},{74:as,78:[1,1853]},{74:as,78:[1,1854]},{77:sa,143:le,144:979,145:ze,152:fe,181:ge,201:980,302:_e,342:1855,419:190,420:Ge,424:Ve},{344:[1,1856]},t(us,[2,710]),t(us,[2,712]),t(ua,[2,256]),{131:oe,196:1857},{131:[2,1102]},t(ci,[2,244]),t(qa,[2,77]),{78:[2,76]},{2:n,3:168,4:a,5:s,56:165,77:ie,94:1824,105:1858,111:149,113:153,131:oe,132:ue,137:ce,143:le,144:161,145:he,149:de,152:fe,154:pe,156:Q,158:167,179:be,180:Ee,181:ge,196:151,200:147,201:155,202:156,254:150,255:146,256:148,257:152,258:154,259:157,260:158,261:159,262:162,263:163,265:me,266:p,270:ve,271:Se,273:Te,280:Ae,281:ye,282:Ne,283:Ce,284:Re,285:Oe,286:we,287:Ie,288:xe,290:z,291:Z,292:ee,293:te,294:De,295:ke,296:Le,297:$e,298:Me,299:Ue,302:_e,303:Fe,312:Pe,317:qe,419:190,420:Ge,424:Ve},{2:n,3:1859,4:a,5:s},{78:[1,1860]},{74:fi,78:[1,1861]},{374:[1,1862]},{2:n,3:1863,4:a,5:s,132:[1,1864]},{74:as,78:[1,1865]},t(Sn,[2,526]),t(Sn,[2,527]),t(us,[2,714],{74:Ua}),t(us,[2,716]),t(pi,[2,1103],{251:1866,766:[1,1867]}),t(os,[2,79]),t(os,[2,82]),t(qa,[2,1055],{3:1821,101:1868,104:1869,2:n,4:a,5:s,76:hi}),t(Sn,[2,518]),{2:n,3:244,4:a,5:s,199:1870},t(os,[2,530]),t(os,[2,531]),t(Sn,[2,525]),t(ri,[2,1105],{252:1871,415:[1,1872]}),t(pi,[2,1104]),t(qa,[2,75]),t(qa,[2,1056]),t(bi,[2,1119],{375:1873,377:1874,77:[1,1875]}),t(ri,[2,269]),t(ri,[2,1106]),t(Sn,[2,521],{376:1876,378:1877,230:[1,1878]}),t(bi,[2,1120]),{2:n,3:1831,4:a,5:s,132:di,372:1879},t(Sn,[2,519]),{230:[1,1881],379:1880},{338:[1,1882]},{74:fi,78:[1,1883]},t(Sn,[2,522]),{335:[1,1884]},{380:[1,1885]},t(bi,[2,520]),{380:[1,1886]},{381:[1,1887]},{381:[1,1888]},{230:[2,523]},t(Sn,[2,524])],defaultActions:{105:[2,6],194:[2,336],195:[2,337],196:[2,338],197:[2,339],198:[2,340],199:[2,341],200:[2,342],201:[2,343],202:[2,344],209:[2,695],591:[2,1142],653:[2,1107],654:[2,1108],710:[2,696],780:[2,1073],781:[2,1074],926:[2,446],927:[2,447],928:[2,448],987:[2,697],1288:[2,1152],1375:[2,1060],1433:[2,1150],1541:[2,507],1732:[2,1052],1777:[2,1100],1797:[2,1118],1800:[2,1124],1842:[2,1102],1845:[2,76],1887:[2,523]},parseError:function(e,t){if(!t.recoverable){var r=new Error(e);throw r.hash=t,r}this.trace(e)},parse:function(e){function t(e){for(var t=n.length-1,r=0;;){if(h.toString()in i[e])return r;if(0===e||t<2)return!1;t-=2,e=n[t],++r}}var r=this,n=[0],a=[null],s=[],i=this.table,o="",u=0,c=0,l=0,h=2,d=s.slice.call(arguments,1),f=Object.create(this.lexer),p={yy:{}};for(var b in this.yy)Object.prototype.hasOwnProperty.call(this.yy,b)&&(p.yy[b]=this.yy[b]);f.setInput(e,p.yy),p.yy.lexer=f,p.yy.parser=this,void 0===f.yylloc&&(f.yylloc={});var E=f.yylloc;s.push(E);var g=f.options&&f.options.ranges;"function"==typeof p.yy.parseError?this.parseError=p.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;for(var m,v,S,T,A,y,N,C,R,O=function(){var e;return e=f.lex()||1,"number"!=typeof e&&(e=r.symbols_[e]||e),e},w={};;){if(S=n[n.length-1],this.defaultActions[S]?T=this.defaultActions[S]:(null!==m&&void 0!==m||(m=O()),T=i[S]&&i[S][m]),void 0===T||!T.length||!T[0]){var I,x="";if(l)1!==v&&(I=t(S));else{I=t(S),R=[];for(y in i[S])this.terminals_[y]&&y>h&&R.push("'"+this.terminals_[y]+"'");x=f.showPosition?"Parse error on line "+(u+1)+":\n"+f.showPosition()+"\nExpecting "+R.join(", ")+", got '"+(this.terminals_[m]||m)+"'":"Parse error on line "+(u+1)+": Unexpected "+(1==m?"end of input":"'"+(this.terminals_[m]||m)+"'"),this.parseError(x,{text:f.match,token:this.terminals_[m]||m,line:f.yylineno,loc:E,expected:R,recoverable:!1!==I})}if(3==l){if(1===m||1===v)throw new Error(x||"Parsing halted while starting to recover from another error.");c=f.yyleng,o=f.yytext,u=f.yylineno,E=f.yylloc,m=O()}if(!1===I)throw new Error(x||"Parsing halted. No suitable error recovery rule available.");!function(e){n.length=n.length-2*e,a.length=a.length-e,s.length=s.length-e}(I),v=m==h?null:m,m=h,S=n[n.length-1],T=i[S]&&i[S][h],l=3}if(T[0]instanceof Array&&T.length>1)throw new Error("Parse Error: multiple actions possible at state: "+S+", token: "+m);switch(T[0]){case 1:n.push(m),a.push(f.yytext),s.push(f.yylloc),n.push(T[1]),m=null,v?(m=v,v=null):(c=f.yyleng,o=f.yytext,u=f.yylineno,E=f.yylloc,l>0&&l--);break;case 2:if(N=this.productions_[T[1]][1],w.$=a[a.length-N],w._$={first_line:s[s.length-(N||1)].first_line,last_line:s[s.length-1].last_line,first_column:s[s.length-(N||1)].first_column,last_column:s[s.length-1].last_column},g&&(w._$.range=[s[s.length-(N||1)].range[0],s[s.length-1].range[1]]),void 0!==(A=this.performAction.apply(w,[o,c,u,p.yy,T[1],a,s].concat(d))))return A;N&&(n=n.slice(0,-1*N*2),a=a.slice(0,-1*N),s=s.slice(0,-1*N)),n.push(this.productions_[T[1]][0]),a.push(w.$),s.push(w._$),C=i[n[n.length-2]][n[n.length-1]],n.push(C);break;case 3:return!0}}return!0}},gi=["A","ABSENT","ABSOLUTE","ACCORDING","ACTION","ADA","ADD","ADMIN","AFTER","ALWAYS","ASC","ASSERTION","ASSIGNMENT","ATTRIBUTE","ATTRIBUTES","BASE64","BEFORE","BERNOULLI","BLOCKED","BOM","BREADTH","C","CASCADE","CATALOG","CATALOG_NAME","CHAIN","CHARACTERISTICS","CHARACTERS","CHARACTER_SET_CATALOG","CHARACTER_SET_NAME","CHARACTER_SET_SCHEMA","CLASS_ORIGIN","COBOL","COLLATION","COLLATION_CATALOG","COLLATION_NAME","COLLATION_SCHEMA","COLUMNS","COLUMN_NAME","COMMAND_FUNCTION","COMMAND_FUNCTION_CODE","COMMITTED","CONDITION_NUMBER","CONNECTION","CONNECTION_NAME","CONSTRAINTS","CONSTRAINT_CATALOG","CONSTRAINT_NAME","CONSTRAINT_SCHEMA","CONSTRUCTOR","CONTENT","CONTINUE","CONTROL","CURSOR_NAME","DATA","DATETIME_INTERVAL_CODE","DATETIME_INTERVAL_PRECISION","DB","DEFAULTS","DEFERRABLE","DEFERRED","DEFINED","DEFINER","DEGREE","DEPTH","DERIVED","DESC","DESCRIPTOR","DIAGNOSTICS","DISPATCH","DOCUMENT","DOMAIN","DYNAMIC_FUNCTION","DYNAMIC_FUNCTION_CODE","EMPTY","ENCODING","ENFORCED","EXCLUDE","EXCLUDING","EXPRESSION","FILE","FINAL","FIRST","FLAG","FOLLOWING","FORTRAN","FOUND","FS","G","GENERAL","GENERATED","GO","GOTO","GRANTED","HEX","HIERARCHY","ID","IGNORE","IMMEDIATE","IMMEDIATELY","IMPLEMENTATION","INCLUDING","INCREMENT","INDENT","INITIALLY","INPUT","INSTANCE","INSTANTIABLE","INSTEAD","INTEGRITY","INVOKER","ISOLATION","K","KEY","KEY_MEMBER","KEY_TYPE","LAST","LENGTH","LEVEL","LIBRARY","LIMIT","LINK","LOCATION","LOCATOR","M","MAP","MAPPING","MATCHED","MAXVALUE","MESSAGE_LENGTH","MESSAGE_OCTET_LENGTH","MESSAGE_TEXT","MINVALUE","MORE","MUMPS","NAME","NAMES","NAMESPACE","NESTING","NEXT","NFC","NFD","NFKC","NFKD","NIL","NORMALIZED","NULLABLE","NULLS","NUMBER","OBJECT","OCTETS","OFF","OPTION","OPTIONS","ORDERING","ORDINALITY","OTHERS","OUTPUT","OVERRIDING","P","PAD","PARAMETER_MODE","PARAMETER_NAME","PARAMETER_ORDINAL_POSITION","PARAMETER_SPECIFIC_CATALOG","PARAMETER_SPECIFIC_NAME","PARAMETER_SPECIFIC_SCHEMA","PARTIAL","PASCAL","PASSING","PASSTHROUGH","PATH","PERMISSION","PLACING","PLI","PRECEDING","PRESERVE","PRIOR","PRIVILEGES","PUBLIC","READ","RECOVERY","RELATIVE","REPEATABLE","REQUIRING","RESPECT","RESTART","RESTORE","RESTRICT","RETURNED_CARDINALITY","RETURNED_LENGTH","RETURNED_OCTET_LENGTH","RETURNED_SQLSTATE","RETURNING","ROLE","ROUTINE","ROUTINE_CATALOG","ROUTINE_NAME","ROUTINE_SCHEMA","ROW_COUNT","SCALE","SCHEMA","SCHEMA_NAME","SCOPE_CATALOG","SCOPE_NAME","SCOPE_SCHEMA","SECTION","SECURITY","SELECTIVE","SELF","SEQUENCE","SERIALIZABLE","SERVER","SERVER_NAME","SESSION","SETS","SIMPLE","SIZE","SOURCE","SPACE","SPECIFIC_NAME","STANDALONE","STATE","STATEMENT","STRIP","STRUCTURE","STYLE","SUBCLASS_ORIGIN","T","TABLE_NAME","TEMPORARY","TIES","TOKEN","TOP_LEVEL_COUNT","TRANSACTION","TRANSACTIONS_COMMITTED","TRANSACTIONS_ROLLED_BACK","TRANSACTION_ACTIVE","TRANSFORM","TRANSFORMS","TRIGGER_CATALOG","TRIGGER_NAME","TRIGGER_SCHEMA","TYPE","UNBOUNDED","UNCOMMITTED","UNDER","UNLINK","UNNAMED","UNTYPED","URI","USAGE","USER_DEFINED_TYPE_CATALOG","USER_DEFINED_TYPE_CODE","USER_DEFINED_TYPE_NAME","USER_DEFINED_TYPE_SCHEMA","VALID","VERSION","VIEW","WHITESPACE","WORK","WRAPPER","WRITE","XMLDECLARATION","XMLSCHEMA","YES","ZONE"];Ei.parseError=function(e,t){if(!(t.expected&&t.expected.indexOf("'LITERAL'")>-1&&/[a-zA-Z_][a-zA-Z_0-9]*/.test(t.token)&&gi.indexOf(t.token)>-1))throw new SyntaxError(e)};var mi=function(){return{EOF:1,parseError:function(e,t){if(!this.yy.parser)throw new Error(e);this.yy.parser.parseError(e,t)},setInput:function(e,t){return this.yy=t||this.yy||{},this._input=e,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var e=this._input[0];return this.yytext+=e,this.yyleng++,this.offset++,this.match+=e,this.matched+=e,e.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),e},unput:function(e){var t=e.length,r=e.split(/(?:\r\n?|\n)/g);this._input=e+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-t),this.offset-=t;var n=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),r.length-1&&(this.yylineno-=r.length-1);var a=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:r?(r.length===n.length?this.yylloc.first_column:0)+n[n.length-r.length].length-r[0].length:this.yylloc.first_column-t},this.options.ranges&&(this.yylloc.range=[a[0],a[0]+this.yyleng-t]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(e){this.unput(this.match.slice(e))},pastInput:function(){var e=this.matched.substr(0,this.matched.length-this.match.length);return(e.length>20?"...":"")+e.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var e=this.match;return e.length<20&&(e+=this._input.substr(0,20-e.length)),(e.substr(0,20)+(e.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var e=this.pastInput(),t=new Array(e.length+1).join("-");return e+this.upcomingInput()+"\n"+t+"^"},test_match:function(e,t){var r,n,a;if(this.options.backtrack_lexer&&(a={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(a.yylloc.range=this.yylloc.range.slice(0))),n=e[0].match(/(?:\r\n?|\n).*/g),n&&(this.yylineno+=n.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:n?n[n.length-1].length-n[n.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+e[0].length},this.yytext+=e[0],this.match+=e[0],this.matches=e,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(e[0].length),this.matched+=e[0],r=this.performAction.call(this,this.yy,this,t,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),r)return r;if(this._backtrack){for(var s in a)this[s]=a[s];return!1}return!1},next:function(){if(this.done)return this.EOF;this._input||(this.done=!0);var e,t,r,n;this._more||(this.yytext="",this.match="");for(var a=this._currentRules(),s=0;s<a.length;s++)if((r=this._input.match(this.rules[a[s]]))&&(!t||r[0].length>t[0].length)){if(t=r,n=s,this.options.backtrack_lexer){if(!1!==(e=this.test_match(r,a[s])))return e;if(this._backtrack){t=!1;continue}return!1}if(!this.options.flex)break}return t?!1!==(e=this.test_match(t,a[n]))&&e:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var e=this.next();return e||this.lex()},begin:function(e){this.conditionStack.push(e)},popState:function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(e){return e=this.conditionStack.length-1-Math.abs(e||0),e>=0?this.conditionStack[e]:"INITIAL"},pushState:function(e){this.begin(e)},stateStackSize:function(){return this.conditionStack.length},options:{"case-insensitive":!0},performAction:function(e,t,r,n){switch(r){case 0:return 266;case 1:return 302;case 2:return 420;case 3:return 299;case 4:case 5:return 5;case 6:case 7:return 296;case 8:case 9:return 132;case 10:return;case 11:break;case 12:return 316;case 13:return 319;case 14:return t.yytext="VALUE",89;case 15:return t.yytext="VALUE",189;case 16:return t.yytext="ROW",189;case 17:return t.yytext="COLUMN",189;case 18:return t.yytext="MATRIX",189;case 19:return t.yytext="INDEX",189;case 20:return t.yytext="RECORDSET",189;case 21:return t.yytext="TEXT",189;case 22:return t.yytext="SELECT",189;case 23:return 520;case 24:return 381;case 25:return 402;case 26:return 515;case 27:return 287;case 28:case 29:return 269;case 30:return 164;case 31:return 400;case 32:return 170;case 33:return 229;case 34:return 166;case 35:return 207;case 36:return 288;case 37:return 76;case 38:return 418;case 39:return 242;case 40:return 404;case 41:return 356;case 42:return 284;case 43:return 514;case 44:return 437;case 45:return 330;case 46:return 441;case 47:return 331;case 48:return 315;case 49:return 119;case 50:return 112;case 51:return 315;case 52:return 112;case 53:return 315;case 54:return 112;case 55:return 315;case 56:return 508;case 57:return 303;case 58:return 271;case 59:return 368;case 60:return 130;case 61:return"CLOSE";case 62:return 243;case 63:case 64:return 190;case 65:return 434;case 66:return 367;case 67:return 470;case 68:return 440;case 69:return 273;case 70:return 240;case 71:return 281;case 72:return 267;case 73:return 206;case 74:return 238;case 75:return 265;case 76:return"CURSOR";case 77:return 405;case 78:return 291;case 79:return 292;case 80:return 448;case 81:return 343;case 82:return 338;case 83:return"DELETED";case 84:return 242;case 85:return 406;case 86:return 185;case 87:return 396;case 88:return 447;case 89:return 135;case 90:return 306;case 91:return 389;case 92:return 310;case 93:return 314;case 94:return 169;case 95:case 96:return 508;case 97:return 298;case 98:return 14;case 99:return 295;case 100:return 249;case 101:return 285;case 102:return 95;case 103:return 373;case 104:return 183;case 105:return 227;case 106:return 268;case 107:return 313;case 108:return 602;case 109:return 472;case 110:return 232;case 111:return 236;case 112:return 239;case 113:return 156;case 114:return 356;case 115:return 332;case 116:return 99;case 117:return 193;case 118:return 212;case 119:return 224;case 120:return 516;case 121:return 339;case 122:return 213;case 123:return 168;case 124:return 293;case 125:return 198;case 126:return 223;case 127:return 370;case 128:return 286;case 129:return"LET";case 130:return 225;case 131:return 112;case 132:return 245;case 133:return 460;case 134:return 191;case 135:return 283;case 136:return 390;case 137:return 282;case 138:return 452;case 139:return 169;case 140:return 403;case 141:return 222;case 142:return 645;case 143:return 270;case 144:return 244;case 145:return 380;case 146:return 154;case 147:return 297;case 148:return 433;case 149:return 230;case 150:return 415;case 151:return 129;case 152:return 247;case 153:return"OPEN";case 154:return 416;case 155:return 171;case 156:return 118;case 157:return 208;case 158:return 276;case 159:return 172;case 160:return 279;case 161:return 765;case 162:return 93;case 163:return 16;case 164:return 369;case 165:return 442;case 166:return 678;case 167:return 15;case 168:return 414;case 169:return 194;case 170:return"REDUCE";case 171:return 374;case 172:return 311;case 173:return 517;case 174:return 682;case 175:return 107;case 176:return 401;case 177:return 175;case 178:return 290;case 179:return 443;case 180:return 687;case 181:case 182:return 173;case 183:return 226;case 184:return 436;case 185:return 237;case 186:return 150;case 187:return 766;case 188:return 405;case 189:return 89;case 190:return 228;case 191:case 192:return 146;case 193:return 409;case 194:return 334;case 195:return 417;case 196:return"STRATEGY";case 197:return"STORE";case 198:return 280;case 199:case 200:return 353;case 201:return 463;case 202:case 203:return 357;case 204:return 192;case 205:return 309;case 206:return"TIMEOUT";case 207:return 148;case 208:return 195;case 209:case 210:return 435;case 211:return 509;case 212:return 294;case 213:return 451;case 214:return 162;case 215:return 187;case 216:return 98;case 217:return 335;case 218:return 408;case 219:return 231;case 220:return 149;case 221:return 344;case 222:return 134;case 223:return 410;case 224:return 308;case 225:return 128;case 226:return 439;case 227:return 72;case 228:return 435;case 229:case 230:return 131;case 231:return 115;case 232:return 137;case 233:return 179;case 234:return 317;case 235:return 180;case 236:return 133;case 237:return 138;case 238:return 326;case 239:return 323;case 240:return 325;case 241:return 322;case 242:return 320;case 243:return 318;case 244:return 319;case 245:return 142;case 246:return 141;case 247:return 139;case 248:return 321;case 249:return 324;case 250:return 140;case 251:return 124;case 252:return 324;case 253:return 77;case 254:return 78;case 255:return 145;case 256:return 424;case 257:return 426;case 258:return 300;case 259:return 505;case 260:return 507;case 261:return 122;case 262:return 116;case 263:return 74;case 264:return 333;case 265:return 152;case 266:return 764;case 267:return 143;case 268:return 181;case 269:return 136;case 270:return 123;case 271:return 312;case 272:return 4;case 273:return 10;case 274:return"INVALID"}},
 rules:[/^(?:``([^\`])+``)/i,/^(?:\[\?\])/i,/^(?:@\[)/i,/^(?:ARRAY\[)/i,/^(?:\[([^\]])*?\])/i,/^(?:`([^\`])*?`)/i,/^(?:N(['](\\.|[^']|\\')*?['])+)/i,/^(?:X(['](\\.|[^']|\\')*?['])+)/i,/^(?:(['](\\.|[^']|\\')*?['])+)/i,/^(?:(["](\\.|[^"]|\\")*?["])+)/i,/^(?:--(.*?)($|\r\n|\r|\n))/i,/^(?:\s+)/i,/^(?:\|\|)/i,/^(?:\|)/i,/^(?:VALUE\s+OF\s+SEARCH\b)/i,/^(?:VALUE\s+OF\s+SELECT\b)/i,/^(?:ROW\s+OF\s+SELECT\b)/i,/^(?:COLUMN\s+OF\s+SELECT\b)/i,/^(?:MATRIX\s+OF\s+SELECT\b)/i,/^(?:INDEX\s+OF\s+SELECT\b)/i,/^(?:RECORDSET\s+OF\s+SELECT\b)/i,/^(?:TEXT\s+OF\s+SELECT\b)/i,/^(?:SELECT\b)/i,/^(?:ABSOLUTE\b)/i,/^(?:ACTION\b)/i,/^(?:ADD\b)/i,/^(?:AFTER\b)/i,/^(?:AGGR\b)/i,/^(?:AGGREGATE\b)/i,/^(?:AGGREGATOR\b)/i,/^(?:ALL\b)/i,/^(?:ALTER\b)/i,/^(?:AND\b)/i,/^(?:ANTI\b)/i,/^(?:ANY\b)/i,/^(?:APPLY\b)/i,/^(?:ARRAY\b)/i,/^(?:AS\b)/i,/^(?:ASSERT\b)/i,/^(?:ASC\b)/i,/^(?:ATTACH\b)/i,/^(?:AUTO(_)?INCREMENT\b)/i,/^(?:AVG\b)/i,/^(?:BEFORE\b)/i,/^(?:BEGIN\b)/i,/^(?:BETWEEN\b)/i,/^(?:BREAK\b)/i,/^(?:NOT\s+BETWEEN\b)/i,/^(?:NOT\s+LIKE\b)/i,/^(?:BY\b)/i,/^(?:~~\*)/i,/^(?:!~~\*)/i,/^(?:~~)/i,/^(?:!~~)/i,/^(?:ILIKE\b)/i,/^(?:NOT\s+ILIKE\b)/i,/^(?:CALL\b)/i,/^(?:CASE\b)/i,/^(?:CAST\b)/i,/^(?:CHECK\b)/i,/^(?:CLASS\b)/i,/^(?:CLOSE\b)/i,/^(?:COLLATE\b)/i,/^(?:COLUMN\b)/i,/^(?:COLUMNS\b)/i,/^(?:COMMIT\b)/i,/^(?:CONSTRAINT\b)/i,/^(?:CONTENT\b)/i,/^(?:CONTINUE\b)/i,/^(?:CONVERT\b)/i,/^(?:CORRESPONDING\b)/i,/^(?:COUNT\b)/i,/^(?:CREATE\b)/i,/^(?:CROSS\b)/i,/^(?:CUBE\b)/i,/^(?:CURRENT_TIMESTAMP\b)/i,/^(?:CURSOR\b)/i,/^(?:DATABASE(S)?)/i,/^(?:DATEADD\b)/i,/^(?:DATEDIFF\b)/i,/^(?:DECLARE\b)/i,/^(?:DEFAULT\b)/i,/^(?:DELETE\b)/i,/^(?:DELETED\b)/i,/^(?:DESC\b)/i,/^(?:DETACH\b)/i,/^(?:DISTINCT\b)/i,/^(?:DROP\b)/i,/^(?:ECHO\b)/i,/^(?:EDGE\b)/i,/^(?:END\b)/i,/^(?:ENUM\b)/i,/^(?:ELSE\b)/i,/^(?:ESCAPE\b)/i,/^(?:EXCEPT\b)/i,/^(?:EXEC\b)/i,/^(?:EXECUTE\b)/i,/^(?:EXISTS\b)/i,/^(?:EXPLAIN\b)/i,/^(?:FALSE\b)/i,/^(?:FETCH\b)/i,/^(?:FIRST\b)/i,/^(?:FOR\b)/i,/^(?:FOREIGN\b)/i,/^(?:FROM\b)/i,/^(?:FULL\b)/i,/^(?:FUNCTION\b)/i,/^(?:GLOB\b)/i,/^(?:GO\b)/i,/^(?:GRAPH\b)/i,/^(?:GROUP\b)/i,/^(?:GROUPING\b)/i,/^(?:HAVING\b)/i,/^(?:IF\b)/i,/^(?:IDENTITY\b)/i,/^(?:IS\b)/i,/^(?:IN\b)/i,/^(?:INDEX\b)/i,/^(?:INDEXED\b)/i,/^(?:INNER\b)/i,/^(?:INSTEAD\b)/i,/^(?:INSERT\b)/i,/^(?:INSERTED\b)/i,/^(?:INTERSECT\b)/i,/^(?:INTERVAL\b)/i,/^(?:INTO\b)/i,/^(?:JOIN\b)/i,/^(?:KEY\b)/i,/^(?:LAST\b)/i,/^(?:LET\b)/i,/^(?:LEFT\b)/i,/^(?:LIKE\b)/i,/^(?:LIMIT\b)/i,/^(?:MATCHED\b)/i,/^(?:MATRIX\b)/i,/^(?:MAX(\s+)?(?=\())/i,/^(?:MAX(\s+)?(?=(,|\))))/i,/^(?:MIN(\s+)?(?=\())/i,/^(?:MERGE\b)/i,/^(?:MINUS\b)/i,/^(?:MODIFY\b)/i,/^(?:NATURAL\b)/i,/^(?:NEXT\b)/i,/^(?:NEW\b)/i,/^(?:NOCASE\b)/i,/^(?:NO\b)/i,/^(?:NOT\b)/i,/^(?:NULL\b)/i,/^(?:OFF\b)/i,/^(?:ON\b)/i,/^(?:ONLY\b)/i,/^(?:OF\b)/i,/^(?:OFFSET\b)/i,/^(?:OPEN\b)/i,/^(?:OPTION\b)/i,/^(?:OR\b)/i,/^(?:ORDER\b)/i,/^(?:OUTER\b)/i,/^(?:OVER\b)/i,/^(?:PATH\b)/i,/^(?:PARTITION\b)/i,/^(?:PERCENT\b)/i,/^(?:PIVOT\b)/i,/^(?:PLAN\b)/i,/^(?:PRIMARY\b)/i,/^(?:PRINT\b)/i,/^(?:PRIOR\b)/i,/^(?:QUERY\b)/i,/^(?:READ\b)/i,/^(?:RECORDSET\b)/i,/^(?:REDUCE\b)/i,/^(?:REFERENCES\b)/i,/^(?:REGEXP\b)/i,/^(?:REINDEX\b)/i,/^(?:RELATIVE\b)/i,/^(?:REMOVE\b)/i,/^(?:RENAME\b)/i,/^(?:REPEAT\b)/i,/^(?:REPLACE\b)/i,/^(?:REQUIRE\b)/i,/^(?:RESTORE\b)/i,/^(?:RETURN\b)/i,/^(?:RETURNS\b)/i,/^(?:RIGHT\b)/i,/^(?:ROLLBACK\b)/i,/^(?:ROLLUP\b)/i,/^(?:ROW\b)/i,/^(?:ROWS\b)/i,/^(?:SCHEMA(S)?)/i,/^(?:SEARCH\b)/i,/^(?:SEMI\b)/i,/^(?:SET\b)/i,/^(?:SETS\b)/i,/^(?:SHOW\b)/i,/^(?:SOME\b)/i,/^(?:SOURCE\b)/i,/^(?:STRATEGY\b)/i,/^(?:STORE\b)/i,/^(?:SUM\b)/i,/^(?:TABLE\b)/i,/^(?:TABLES\b)/i,/^(?:TARGET\b)/i,/^(?:TEMP\b)/i,/^(?:TEMPORARY\b)/i,/^(?:TEXTSTRING\b)/i,/^(?:THEN\b)/i,/^(?:TIMEOUT\b)/i,/^(?:TO\b)/i,/^(?:TOP\b)/i,/^(?:TRAN\b)/i,/^(?:TRANSACTION\b)/i,/^(?:TRIGGER\b)/i,/^(?:TRUE\b)/i,/^(?:TRUNCATE\b)/i,/^(?:UNION\b)/i,/^(?:UNIQUE\b)/i,/^(?:UNPIVOT\b)/i,/^(?:UPDATE\b)/i,/^(?:USE\b)/i,/^(?:USING\b)/i,/^(?:VALUE\b)/i,/^(?:VALUES\b)/i,/^(?:VERTEX\b)/i,/^(?:VIEW\b)/i,/^(?:WHEN\b)/i,/^(?:WHERE\b)/i,/^(?:WHILE\b)/i,/^(?:WITH\b)/i,/^(?:WORK\b)/i,/^(?:(\d*[.])?\d+[eE]\d+)/i,/^(?:(\d*[.])?\d+)/i,/^(?:->)/i,/^(?:#)/i,/^(?:\+)/i,/^(?:-)/i,/^(?:\*)/i,/^(?:\/)/i,/^(?:%)/i,/^(?:!===)/i,/^(?:===)/i,/^(?:!==)/i,/^(?:==)/i,/^(?:>=)/i,/^(?:&)/i,/^(?:\|)/i,/^(?:<<)/i,/^(?:>>)/i,/^(?:>)/i,/^(?:<=)/i,/^(?:<>)/i,/^(?:<)/i,/^(?:=)/i,/^(?:!=)/i,/^(?:\()/i,/^(?:\))/i,/^(?:@)/i,/^(?:\{)/i,/^(?:\})/i,/^(?:\])/i,/^(?::-)/i,/^(?:\?-)/i,/^(?:\.\.)/i,/^(?:\.)/i,/^(?:,)/i,/^(?:::)/i,/^(?::)/i,/^(?:;)/i,/^(?:\$)/i,/^(?:\?)/i,/^(?:!)/i,/^(?:\^)/i,/^(?:~)/i,/^(?:[a-zA-Z_][a-zA-Z_0-9]*)/i,/^(?:$)/i,/^(?:.)/i],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,258,259,260,261,262,263,264,265,266,267,268,269,270,271,272,273,274],inclusive:!0}}}}();return Ei.lexer=mi,e.prototype=Ei,Ei.Parser=e,new e}();void 0!==y&&"undefined"!=typeof exports&&(exports.parser=N,exports.Parser=N.Parser,exports.parse=function(){return N.parse.apply(N,arguments)},exports.main=function(e){e[1]||(console.log("Usage: "+e[0]+" FILE"),process.exit(1));var t=y("fs").readFileSync(y("path").normalize(e[1]),"utf8");return exports.parser.parse(t)},"undefined"!=typeof module&&y.main===module&&exports.main(process.argv.slice(1))),A.prettyflag=!1,A.pretty=function(e,t){var r=A.prettyflag;A.prettyflag=!t;var n=A.parse(e).toString();return A.prettyflag=r,n};var C=A.utils={},R=C.escapeq=function(e){return(""+e).replace(/["'\\\n\r\u2028\u2029]/g,function(e){switch(e){case'"':case"'":case"\\":return"\\"+e;case"\n":return"\\n";case"\r":return"\\r";case"\u2028":return"\\u2028";case"\u2029":return"\\u2029"}})},O=C.undoubleq=function(e){return e.replace(/(\')/g,"''")},w=C.doubleq=function(e){return e.replace(/(\'\')/g,"\\'")},I=(C.doubleqq=function(e){return e.replace(/\'/g,"'")},function(e){return e[0]===String.fromCharCode(65279)&&(e=e.substr(1)),e});C.global=function(){try{return Function("return this")()}catch(t){var e=self||window||e;if(e)return e;throw new Error("Unable to locate global object")}}();C.isNativeFunction=function(e){return"function"==typeof e&&!!~e.toString().indexOf("[native code]")};C.isWebWorker=function(){try{var e=C.global.importScripts;return C.isNativeFunction(e)}catch(e){return!1}}(),C.isNode=function(){try{return C.isNativeFunction(C.global.process.reallyExit)}catch(e){return!1}}(),C.isBrowser=function(){try{return C.isNativeFunction(C.global.location.reload)}catch(e){return!1}}(),C.isBrowserify=function(){return C.isBrowser&&"undefined"!=typeof process&&process.browser}(),C.isRequireJS=function(){return C.isBrowser&&"function"==typeof y&&"function"==typeof y.specified}(),C.isMeteor=function(){return"undefined"!=typeof Meteor&&Meteor.release}(),C.isMeteorClient=C.isMeteorClient=function(){return C.isMeteor&&Meteor.isClient}(),C.isMeteorServer=function(){return C.isMeteor&&Meteor.isServer}(),C.isCordova=function(){return"object"==typeof cordova}(),C.isReactNative=function(){return!1}(),C.hasIndexedDB=function(){return!!C.global.indexedDB}(),C.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)};var x=C.loadFile=function(e,t,r,n){var a;if(C.isNode||C.isMeteorServer);else if(C.isCordova)C.global.requestFileSystem(LocalFileSystem.PERSISTENT,0,function(t){t.root.getFile(e,{create:!1},function(e){e.file(function(e){var t=new FileReader;t.onloadend=function(e){r(I(this.result))},t.readAsText(e)})})});else if("string"==typeof e)if("#"===e.substr(0,1)&&"undefined"!=typeof document)a=document.querySelector(e).textContent,r(a);else{var s=new XMLHttpRequest;s.onreadystatechange=function(){4===s.readyState&&(200===s.status?r&&r(I(s.responseText)):n&&n(s))},s.open("GET",e,t),s.responseType="text",s.send()}else if(e instanceof Event){var i=e.target.files,o=new FileReader;i[0].name;o.onload=function(e){var t=e.target.result;r(I(t))},o.readAsText(i[0])}};C.loadBinaryFile=function(e,t,r,n){if(C.isNode||C.isMeteorServer);else if("string"==typeof e){var a=new XMLHttpRequest;a.open("GET",e,t),a.responseType="arraybuffer",a.onload=function(){for(var e=new Uint8Array(a.response),t=[],n=0;n<e.length;++n)t[n]=String.fromCharCode(e[n]);r(t.join(""))},a.send()}else if(e instanceof Event){var s=e.target.files,i=new FileReader;s[0].name;i.onload=function(e){var t=e.target.result;r(t)},i.readAsArrayBuffer(s[0])}else e instanceof Blob&&r(e)},C.removeFile=function(e,t){if(!C.isNode)throw new Error("You can remove files only in Node.js and Apache Cordova")},C.deleteFile=function(e,t){};C.autoExtFilename=function(e,t,r){return r=r||{},"string"!=typeof e||e.match(/^[A-z]+:\/\/|\n|\..{2,4}$/)||0===r.autoExt||!1===r.autoExt?e:e+"."+t};var D=(C.fileExists=function(e,t){if(!C.isNode)throw new Error("You can use exists() only in Node.js or Apach Cordova")},C.saveFile=function(e,t,r,n){var s=1;if(void 0===e)s=t,r&&(s=r(s));else if(C.isNode);else if(9===a()){var i=t.replace(/\r\n/g,"&#A;&#D;");i=i.replace(/\n/g,"&#D;"),i=i.replace(/\t/g,"&#9;");var o=C.global.open("about:blank","_blank");o.document.write(i),o.document.close(),o.document.execCommand("SaveAs",!1,e),o.close()}else{var u={disableAutoBom:!1};A.utils.extend(u,n);var c=new Blob([t],{type:"text/plain;charset=utf-8"});be(c,e,u.disableAutoBom),r&&(s=r(s))}return s},C.hash=function(e){for(var t=2166136261,r=e.length;r;)t^=e.charCodeAt(--r),t+=(t<<1)+(t<<4)+(t<<7)+(t<<8)+(t<<24);return t}),k=C.arrayUnion=function(e,t){var r=t.slice(0);return e.forEach(function(e){r.indexOf(e)<0&&r.push(e)}),r},L=C.arrayDiff=function(e,t){return e.filter(function(e){return t.indexOf(e)<0})},$=C.arrayIntersect=function(e,t){var r=[];return e.forEach(function(e){var n=!1;t.forEach(function(t){n=n||e===t}),n&&r.push(e)}),r},M=C.arrayUnionDeep=function(e,t){var r=t.slice(0);return e.forEach(function(e){var t=!1;r.forEach(function(r){t=t||P(e,r)}),t||r.push(e)}),r},U=C.arrayExceptDeep=function(e,t){var r=[];return e.forEach(function(e){var n=!1;t.forEach(function(t){n=n||P(e,t)}),n||r.push(e)}),r},_=C.arrayIntersectDeep=function(e,t){var r=[];return e.forEach(function(e){var n=!1;t.forEach(function(t){n=n||P(e,t,!0)}),n&&r.push(e)}),r},F=C.cloneDeep=function e(t){if(null===t||"object"!=typeof t)return t;if(t instanceof Date)return new Date(t);var r=t.constructor();for(var n in t)t.hasOwnProperty(n)&&(r[n]=e(t[n]));return r},P=C.deepEqual=function(e,t){if(e===t)return!0;if("object"==typeof e&&null!==e&&"object"==typeof t&&null!==t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(var r in e)if(!P(e[r],t[r]))return!1;return!0}return!1},q=C.distinctArray=function(e){for(var t={},r=0,n=e.length;r<n;r++){var a;a="object"==typeof e[r]?Object.keys(e[r]).sort().map(function(t){return t+"`"+e[r][t]}).join("`"):e[r],t[a]=e[r]}var s=[];for(var i in t)s.push(t[i]);return s},G=C.extend=function(e,t){e=e||{};for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r]);return e},V=C.flatArray=function(e){if(!e||0===e.length)return[];if("object"==typeof e&&e instanceof A.Recordset)return e.data.map(function(t){return t[e.columns[0].columnid]});var t=Object.keys(e[0])[0];return void 0===t?[]:e.map(function(e){return e[t]})};C.arrayOfArrays=function(e){return e.map(function(e){var t=[];for(var r in e)t.push(e[r]);return t})};Array.isArray||(Array.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)});C.xlsnc=function(e){var t=String.fromCharCode(65+e%26);return e>=26&&(e=(e/26|0)-1,t=String.fromCharCode(65+e%26)+t,e>26&&(e=(e/26|0)-1,t=String.fromCharCode(65+e%26)+t)),t},C.xlscn=function(e){var t=e.charCodeAt(0)-65;return e.length>1&&(t=26*(t+1)+e.charCodeAt(1)-65,e.length>2&&(t=26*(t+1)+e.charCodeAt(2)-65)),t},C.domEmptyChildren=function(e){for(var t=e.childNodes.length;t--;)e.removeChild(e.lastChild)},C.like=function(e,t,r){r||(r="");for(var n=0,a="^";n<e.length;){var s=e[n],i="";n<e.length-1&&(i=e[n+1]),s===r?(a+="\\"+i,n++):"["===s&&"^"===i?(a+="[^",n++):"["===s||"]"===s?a+=s:"%"===s?a+=".*":"_"===s?a+=".":"/.*+?|(){}".indexOf(s)>-1?a+="\\"+s:a+=s,n++}return a+="$",(""+(t||"")).toUpperCase().search(RegExp(a.toUpperCase()))>-1};C.glob=function(e,t){for(var r=0,n="^";r<t.length;){var a=t[r],s="";r<t.length-1&&(s=t[r+1]),"["===a&&"^"===s?(n+="[^",r++):"["===a||"]"===a?n+=a:"*"===a?n+=".*":"?"===a?n+=".":"/.*+?|(){}".indexOf(a)>-1?n+="\\"+a:n+=a,r++}return n+="$",(""+(e||"")).toUpperCase().search(RegExp(n.toUpperCase()))>-1},C.findAlaSQLPath=function(){if(C.isWebWorker)return"";if(C.isMeteorClient)return"/packages/dist/";if(C.isMeteorServer)return"assets/packages/dist/";if(C.isNode)return"";if(C.isBrowser)for(var e=document.getElementsByTagName("script"),t=0;t<e.length;t++){if("alasql-worker.js"===e[t].src.substr(-16).toLowerCase())return e[t].src.substr(0,e[t].src.length-16);if("alasql-worker.min.js"===e[t].src.substr(-20).toLowerCase())return e[t].src.substr(0,e[t].src.length-20);if("alasql.js"===e[t].src.substr(-9).toLowerCase())return e[t].src.substr(0,e[t].src.length-9);if("alasql.min.js"===e[t].src.substr(-13).toLowerCase())return e[t].src.substr(0,e[t].src.length-13)}return""};var B=function(){var e=null;if(C.isNode||C.isBrowserify||C.isMeteorServer||(e=C.global.XLSX||null),null===e)throw new Error("Please include the xlsx.js library");return e};A.path=A.utils.findAlaSQLPath(),A.utils.uncomment=function(e){e=("__"+e+"__").split("");for(var t,r=!1,n=!1,a=!1,s=0,i=e.length;s<i;s++){var o="\\"!==e[s-1]||"\\"===e[s-2];r?e[s]===t&&o&&(r=!1):n?"*"===e[s]&&"/"===e[s+1]?(e[s]=e[s+1]="",n=!1,s++):e[s]="":a?("\n"!==e[s+1]&&"\r"!==e[s+1]||(a=!1),e[s]=""):'"'===e[s]||"'"===e[s]?(r=!0,t=e[s]):"["===e[s]&&"@"!==e[s-1]?(r=!0,t="]"):"/"===e[s]&&"*"===e[s+1]&&(e[s]="",n=!0)}return e=e.join("").slice(2,-2)},A.parser=N,A.parser.parseError=function(e,t){throw new Error("Have you used a reserved keyword without `escaping` it?\n"+e)},A.parse=function(e){return N.parse(A.utils.uncomment(e))},A.engines={},A.databases={},A.databasenum=0,A.options={},A.options.errorlog=!1,A.options.valueof=!1,A.options.dropifnotexists=!1,A.options.datetimeformat="sql",A.options.casesensitive=!0,A.options.logtarget="output",A.options.logprompt=!0,A.options.progress=!1,A.options.modifier=void 0,A.options.columnlookup=10,A.options.autovertex=!0,A.options.usedbo=!0,A.options.autocommit=!0,A.options.cache=!0,A.options.tsql=!0,A.options.mysql=!0,A.options.postgres=!0,A.options.oracle=!0,A.options.sqlite=!0,A.options.orientdb=!0,A.options.nocount=!1,A.options.nan=!1,A.options.joinstar="overwrite",A.vars={},A.declares={},A.prompthistory=[],A.plugins={},A.from={},A.into={},A.fn={},A.aggr={},A.busy=0,A.MAXSQLCACHESIZE=1e4,A.DEFAULTDATABASEID="alasql",A.lastid=0,A.buffer={},A.use=function(e){if(e||(e=A.DEFAULTDATABASEID),A.useid!==e){A.useid=e;var t=A.databases[A.useid];A.tables=t.tables,t.resetSqlCache(),A.options.usedbo&&(A.databases.dbo=t)}},A.autoval=function(e,t,r,n){var a=n?A.databases[n]:A.databases[A.useid];if(!a.tables[e])throw new Error("Tablename not found: "+e);if(!a.tables[e].identities[t])throw new Error("Colname not found: "+t);return r?a.tables[e].identities[t].value||null:a.tables[e].identities[t].value-a.tables[e].identities[t].step||null},A.exec=function(e,t,r,n){if("function"==typeof t&&(n=r,r=t,t={}),delete A.error,t=t||{},!A.options.errorlog)return A.dexec(A.useid,e,t,r,n);try{return A.dexec(A.useid,e,t,r,n)}catch(e){A.error=e,r&&r(null,A.error)}},A.dexec=function(e,t,r,n,a){var s,i=A.databases[e];if(A.options.cache){s=D(t);var o=i.sqlCache[s];if(o&&i.dbversion===o.dbversion)return o(r,n)}var u=A.parse(t);if(u.statements){if(0===u.statements.length)return 0;if(1===u.statements.length){if(u.statements[0].compile){var o=u.statements[0].compile(e,r);if(!o)return;o.sql=t,o.dbversion=i.dbversion,A.options.cache&&(i.sqlCacheSize>A.MAXSQLCACHESIZE&&i.resetSqlCache(),i.sqlCacheSize++,i.sqlCache[s]=o);var c=A.res=o(r,n,a);return c}A.precompile(u.statements[0],A.useid,r);var c=A.res=u.statements[0].execute(e,r,n,a);return c}if(!n)return A.drun(e,u,r,n,a);A.adrun(e,u,r,n,a)}},A.drun=function(e,t,r,n,a){var s=A.useid;s!==e&&A.use(e);for(var i=[],o=0,u=t.statements.length;o<u;o++)if(t.statements[o])if(t.statements[o].compile){var c=t.statements[o].compile(A.useid);i.push(A.res=c(r,null,a))}else A.precompile(t.statements[o],A.useid,r),i.push(A.res=t.statements[o].execute(A.useid,r));return s!==e&&A.use(s),n&&n(i),A.res=i,i},A.adrun=function(e,t,r,n,a){function s(l){void 0!==l&&c.push(l);var h=t.statements.shift();if(h)if(h.compile){var d=h.compile(A.useid);d(r,s,a),!1!==A.options.progress&&A.options.progress(o,i++)}else A.precompile(t.statements[0],A.useid,r),h.execute(A.useid,r,s),!1!==A.options.progress&&A.options.progress(o,i++);else u!==e&&A.use(u),n(c)}var i=0,o=t.statements.length;!1!==A.options.progress&&A.options.progress(o,i++);var u=A.useid;u!==e&&A.use(e);var c=[];s()},A.compile=function(e,t){t=t||A.useid;var r=A.parse(e);if(1===r.statements.length){var n=r.statements[0].compile(t);return n.promise=function(e){return new Promise(function(t,r){n(e,function(e,n){n?r(n):t(e)})})},n}throw new Error("Cannot compile, because number of statements in SQL is not equal to 1")},C.global.Promise||C.isNode||function(){"use strict";function e(e){return"function"==typeof e||"object"==typeof e&&null!==e}function t(e){return"function"==typeof e}function r(e){G=e}function n(e){H=e}function a(){return function(){q(i)}}function s(){return function(){setTimeout(i,1)}}function i(){for(var e=0;j>e;e+=2){(0,Q[e])(Q[e+1]),Q[e]=void 0,Q[e+1]=void 0}j=0}function o(e,t){var r=this,n=new this.constructor(c);void 0===n[ee]&&I(n);var a=r._state;if(a){var s=arguments[a-1];H(function(){R(a,n,s,r._result)})}else T(r,n,e,t);return n}function u(e){var t=this;if(e&&"object"==typeof e&&e.constructor===t)return e;var r=new t(c);return g(r,e),r}function c(){}function l(){return new TypeError("You cannot resolve a promise with itself")}function h(){return new TypeError("A promises callback cannot return that same promise.")}function d(e){try{return e.then}catch(e){return ae.error=e,ae}}function f(e,t,r,n){try{e.call(t,r,n)}catch(e){return e}}function p(e,t,r){H(function(e){var n=!1,a=f(r,t,function(r){n||(n=!0,t!==r?g(e,r):v(e,r))},function(t){n||(n=!0,S(e,t))},"Settle: "+(e._label||" unknown promise"));!n&&a&&(n=!0,S(e,a))},e)}function b(e,t){t._state===re?v(e,t._result):t._state===ne?S(e,t._result):T(t,void 0,function(t){g(e,t)},function(t){S(e,t)})}function E(e,r,n){r.constructor===e.constructor&&n===z&&constructor.resolve===Z?b(e,r):n===ae?S(e,ae.error):void 0===n?v(e,r):t(n)?p(e,r,n):v(e,r)}function g(t,r){t===r?S(t,l()):e(r)?E(t,r,d(r)):v(t,r)}function m(e){e._onerror&&e._onerror(e._result),A(e)}function v(e,t){e._state===te&&(e._result=t,e._state=re,0!==e._subscribers.length&&H(A,e))}function S(e,t){e._state===te&&(e._state=ne,e._result=t,H(m,e))}function T(e,t,r,n){var a=e._subscribers,s=a.length;e._onerror=null,a[s]=t,a[s+re]=r,a[s+ne]=n,0===s&&e._state&&H(A,e)}function A(e){var t=e._subscribers,r=e._state;if(0!==t.length){for(var n,a,s=e._result,i=0;i<t.length;i+=3)n=t[i],a=t[i+r],n?R(r,n,a,s):a(s);e._subscribers.length=0}}function N(){this.error=null}function C(e,t){try{return e(t)}catch(e){return se.error=e,se}}function R(e,r,n,a){var s,i,o,u,c=t(n);if(c){if(s=C(n,a),s===se?(u=!0,i=s.error,s=null):o=!0,r===s)return void S(r,h())}else s=a,o=!0;r._state!==te||(c&&o?g(r,s):u?S(r,i):e===re?v(r,s):e===ne&&S(r,s))}function O(e,t){try{t(function(t){g(e,t)},function(t){S(e,t)})}catch(t){S(e,t)}}function w(){return ie++}function I(e){e[ee]=ie++,e._state=void 0,e._result=void 0,e._subscribers=[]}function x(e){return new he(this,e).promise}function D(e){var t=this;return new t(B(e)?function(r,n){for(var a=e.length,s=0;a>s;s++)t.resolve(e[s]).then(r,n)}:function(e,t){t(new TypeError("You must pass an array to race."))})}function k(e){var t=this,r=new t(c);return S(r,e),r}function L(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function $(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}function M(e){this[ee]=w(),this._result=this._state=void 0,this._subscribers=[],c!==e&&("function"!=typeof e&&L(),this instanceof M?O(this,e):$())}function U(e,t){this._instanceConstructor=e,this.promise=new e(c),this.promise[ee]||I(this.promise),Array.isArray(t)?(this._input=t,this.length=t.length,this._remaining=t.length,this._result=new Array(this.length),0===this.length?v(this.promise,this._result):(this.length=this.length||0,this._enumerate(),0===this._remaining&&v(this.promise,this._result))):S(this.promise,_())}function _(){return new Error("Array Methods must be provided an Array")}function F(){var e;if("undefined"!=typeof global)e=global;else if("undefined"!=typeof self)e=self;else try{e=Function("return this")()}catch(e){throw new Error("polyfill failed because global object is unavailable in this environment")}var t=e.Promise;(!t||"[object Promise]"!==Object.prototype.toString.call(t.resolve())||t.cast)&&(e.Promise=le)}var P;P=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)};var q,G,V,B=P,j=0,H=function(e,t){Q[j]=e,Q[j+1]=t,2===(j+=2)&&(G?G(i):V())},J="undefined"!=typeof window?window:void 0,Y=J||{},W=Y.MutationObserver||Y.WebKitMutationObserver,X="undefined"==typeof self&&"undefined"!=typeof process&&"[object process]"==={}.toString.call(process),K="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel,Q=new Array(1e3);V=X?function(){return function(){process.nextTick(i)}}():W?function(){var e=0,t=new W(i),r=document.createTextNode("");return t.observe(r,{characterData:!0}),function(){r.data=e=++e%2}}():K?function(){var e=new MessageChannel;return e.port1.onmessage=i,function(){e.port2.postMessage(0)}}():void 0===J&&"function"==typeof y?function(){try{var e=y,t=e("vertx");return q=t.runOnLoop||t.runOnContext,a()}catch(e){return s()}}():s();var z=o,Z=u,ee=Math.random().toString(36).substring(16),te=void 0,re=1,ne=2,ae=new N,se=new N,ie=0,oe=x,ue=D,ce=k,le=M;M.all=oe,M.race=ue,M.resolve=Z,M.reject=ce,M._setScheduler=r,M._setAsap=n,M._asap=H,M.prototype={constructor:M,then:z,catch:function(e){return this.then(null,e)}};var he=U;U.prototype._enumerate=function(){for(var e=this.length,t=this._input,r=0;this._state===te&&e>r;r++)this._eachEntry(t[r],r)},U.prototype._eachEntry=function(e,t){var r=this._instanceConstructor,n=r.resolve;if(n===Z){var a=d(e);if(a===z&&e._state!==te)this._settledAt(e._state,t,e._result);else if("function"!=typeof a)this._remaining--,this._result[t]=e;else if(r===le){var s=new r(c);E(s,e,a),this._willSettleAt(s,t)}else this._willSettleAt(new r(function(t){t(e)}),t)}else this._willSettleAt(n(e),t)},U.prototype._settledAt=function(e,t,r){var n=this.promise;n._state===te&&(this._remaining--,e===ne?S(n,r):this._result[t]=r),0===this._remaining&&v(n,this._result)},U.prototype._willSettleAt=function(e,t){var r=this;T(e,void 0,function(e){r._settledAt(re,t,e)},function(e){r._settledAt(ne,t,e)})};var de=F,fe={Promise:le,polyfill:de};"function"==typeof define&&define.amd?define(function(){return fe}):"undefined"!=typeof module&&module.exports?module.exports=fe:void 0!==this&&(this.ES6Promise=fe),de()}.call(this);var j=function(e,t,r,n){return new C.global.Promise(function(a,s){A(e,t,function(e,t){t?s(t):(r&&n&&!1!==A.options.progress&&A.options.progress(r,n),a(e))})})},H=function(e){if(!(e.length<1)){for(var t,r,n,a=[],s=0;s<e.length;s++){if(t=e[s],"string"==typeof t&&(t=[t]),!C.isArray(t)||t.length<1||2<t.length)throw new Error("Error in .promise parameter");r=t[0],n=t[1]||void 0,a.push(j(r,n,s,e.length))}return C.global.Promise.all(a)}};A.promise=function(e,t){if("undefined"==typeof Promise)throw new Error("Please include a Promise/A+ library");if("string"==typeof e)return j(e,t);if(!C.isArray(e)||e.length<1||void 0!==t)throw new Error("Error in .promise parameters");return H(e)};var J=A.Database=function(e){var t=this;if(t===A)if(e){if(t=A.databases[e],A.databases[e]=t,!t)throw new Error('Database "'+e+'" not found')}else t=A.databases.alasql,A.options.tsql&&(A.databases.tempdb=A.databases.alasql);return e||(e="db"+A.databasenum++),t.databaseid=e,A.databases[e]=t,t.dbversion=0,t.tables={},t.views={},t.triggers={},t.indices={},t.objects={},t.counter=0,t.resetSqlCache(),t};J.prototype.resetSqlCache=function(){this.sqlCache={},this.sqlCacheSize=0},J.prototype.exec=function(e,t,r){return A.dexec(this.databaseid,e,t,r)},J.prototype.autoval=function(e,t,r){return A.autoval(e,t,r,this.databaseid)},J.prototype.transaction=function(e){return e(new A.Transaction(this.databaseid))};var Y=A.Transaction=function(e){return this.transactionid=Date.now(),this.databaseid=e,this.commited=!1,this.dbversion=A.databases[e].dbversion,this.bank=JSON.stringify(A.databases[e]),this};Y.prototype.commit=function(){this.commited=!0,A.databases[this.databaseid].dbversion=Date.now(),delete this.bank},Y.prototype.rollback=function(){if(this.commited)throw new Error("Transaction already commited");A.databases[this.databaseid]=JSON.parse(this.bank),delete this.bank},Y.prototype.exec=function(e,t,r){return A.dexec(this.databaseid,e,t,r)},Y.prototype.executeSQL=Y.prototype.exec;var W=A.Table=function(e){this.data=[],this.columns=[],this.xcolumns={},this.inddefs={},this.indices={},this.uniqs={},this.uniqdefs={},this.identities={},this.checks=[],this.checkfns=[],this.beforeinsert={},this.afterinsert={},this.insteadofinsert={},this.beforedelete={},this.afterdelete={},this.insteadofdelete={},this.beforeupdate={},this.afterupdate={},this.insteadofupdate={},G(this,e)};W.prototype.indexColumns=function(){var e=this;e.xcolumns={},e.columns.forEach(function(t){e.xcolumns[t.columnid]=t})};var X=(A.View=function(e){this.columns=[],this.xcolumns={},this.query=[],G(this,e)},A.Query=function(e){this.alasql=A,this.columns=[],this.xcolumns={},this.selectGroup=[],this.groupColumns={},G(this,e)}),K=(A.Recordset=function(e){G(this,e)},N.yy=A.yy={});K.extend=G,K.casesensitive=A.options.casesensitive;var Q=K.Base=function(e){return K.extend(this,e)};Q.prototype.toString=function(){},Q.prototype.toType=function(){},Q.prototype.toJS=function(){},Q.prototype.compile=n,Q.prototype.exec=function(){},Q.prototype.compile=n,Q.prototype.exec=function(){},K.Statements=function(e){return K.extend(this,e)},K.Statements.prototype.toString=function(){return this.statements.map(function(e){return e.toString()}).join("; ")},K.Statements.prototype.compile=function(e){var t=this.statements.map(function(t){return t.compile(e)});return 1===t.length?t[0]:function(e,r){var n=t.map(function(t){return t(e)});return r&&r(n),n}},K.Search=function(e){return K.extend(this,e)},K.Search.prototype.toString=function(){var e="SEARCH ";return this.selectors&&(e+=this.selectors.toString()),this.from&&(e+="FROM "+this.from.toString()),e},K.Search.prototype.toJS=function(e){return"this.queriesfn["+(this.queriesidx-1)+"](this.params,null,"+e+")"},K.Search.prototype.compile=function(e){var t=e,r=this,n=function(e,a){var s;return i.bind(r)(t,e,function(e){s=f(n.query,e),a&&(s=a(s))}),s};return n.query={},n},A.srch={},A.srch.PROP=function(e,t,r){if("XML"===r.mode){var n=[];return e.children.forEach(function(e){e.name.toUpperCase()===t[0].toUpperCase()&&n.push(e)}),n.length>0?{status:1,values:n}:{status:-1,values:[]}}return"object"!=typeof e||null===e||"object"!=typeof t||void 0===e[t[0]]?{status:-1,values:[]}:{status:1,values:[e[t[0]]]}},A.srch.APROP=function(e,t){return"object"!=typeof e||null===e||"object"!=typeof t||void 0===e[t[0]]?{status:1,values:[void 0]}:{status:1,values:[e[t[0]]]}},A.srch.EQ=function(e,t,r,n){var a=t[0].toJS("x","");return e===new Function("x,alasql,params","return "+a)(e,A,n)?{status:1,values:[e]}:{status:-1,values:[]}},A.srch.LIKE=function(e,t,r,n){var a=t[0].toJS("x",""),s=new Function("x,alasql,params","return "+a);return e.toUpperCase().match(new RegExp("^"+s(e,A,n).toUpperCase().replace(/%/g,".*").replace(/\?|_/g,".")+"$"),"g")?{status:1,values:[e]}:{status:-1,values:[]}},A.srch.ATTR=function(e,t,r){if("XML"===r.mode)return void 0===t?{status:1,values:[e.attributes]}:"object"==typeof e&&"object"==typeof e.attributes&&void 0!==e.attributes[t[0]]?{status:1,values:[e.attributes[t[0]]]}:{status:-1,values:[]};throw new Error("ATTR is not using in usual mode")},A.srch.CONTENT=function(e,t,r){if("XML"===r.mode)return{status:1,values:[e.content]};throw new Error("ATTR is not using in usual mode")},A.srch.SHARP=function(e,t){var r=A.databases[A.useid].objects[t[0]];return void 0!==e&&e===r?{status:1,values:[e]}:{status:-1,values:[]}},A.srch.PARENT=function(){return console.log("PARENT not implemented",arguments),{status:-1,values:[]}},A.srch.CHILD=function(e,t,r){return"object"==typeof e?Array.isArray(e)?{status:1,values:e}:"XML"===r.mode?{status:1,values:Object.keys(e.children).map(function(t){return e.children[t]})}:{status:1,values:Object.keys(e).map(function(t){return e[t]})}:{status:1,values:[]}},A.srch.KEYS=function(e){return"object"==typeof e&&null!==e?{status:1,values:Object.keys(e)}:{status:1,values:[]}},A.srch.WHERE=function(e,t,r,n){var a=t[0].toJS("x","");return new Function("x,alasql,params","return "+a)(e,A,n)?{status:1,values:[e]}:{status:-1,values:[]}},A.srch.NAME=function(e,t){return e.name===t[0]?{status:1,values:[e]}:{status:-1,values:[]}},A.srch.CLASS=function(e,t){return e.$class==t?{status:1,values:[e]}:{status:-1,values:[]}},A.srch.VERTEX=function(e){return"VERTEX"===e.$node?{status:1,values:[e]}:{status:-1,values:[]}},A.srch.INSTANCEOF=function(e,t){return e instanceof A.fn[t[0]]?{status:1,values:[e]}:{status:-1,values:[]}},A.srch.EDGE=function(e){return"EDGE"===e.$node?{status:1,values:[e]}:{status:-1,values:[]}},A.srch.EX=function(e,t,r,n){var a=t[0].toJS("x","");return{status:1,values:[new Function("x,alasql,params","return "+a)(e,A,n)]}},A.srch.RETURN=function(e,t,r,n){var a={};return t&&t.length>0&&t.forEach(function(t){var r=t.toJS("x",""),s=new Function("x,alasql,params","return "+r);void 0===t.as&&(t.as=t.toString()),a[t.as]=s(e,A,n)}),{status:1,values:[a]}},A.srch.REF=function(e){return{status:1,values:[A.databases[A.useid].objects[e]]}},A.srch.OUT=function(e){if(e.$out&&e.$out.length>0){return{status:1,values:e.$out.map(function(e){return A.databases[A.useid].objects[e]})}}return{status:-1,values:[]}},A.srch.OUTOUT=function(e){if(e.$out&&e.$out.length>0){var t=[];return e.$out.forEach(function(e){var r=A.databases[A.useid].objects[e];r&&r.$out&&r.$out.length>0&&r.$out.forEach(function(e){t=t.concat(A.databases[A.useid].objects[e])})}),{status:1,values:t}}return{status:-1,values:[]}},A.srch.IN=function(e){if(e.$in&&e.$in.length>0){return{status:1,values:e.$in.map(function(e){return A.databases[A.useid].objects[e]})}}return{status:-1,values:[]}},A.srch.ININ=function(e){if(e.$in&&e.$in.length>0){var t=[];return e.$in.forEach(function(e){var r=A.databases[A.useid].objects[e];r&&r.$in&&r.$in.length>0&&r.$in.forEach(function(e){t=t.concat(A.databases[A.useid].objects[e])})}),{status:1,values:t}}return{status:-1,values:[]}},A.srch.AS=function(e,t){return A.vars[t[0]]=e,{status:1,values:[e]}},A.srch.AT=function(e,t){return{status:1,values:[A.vars[t[0]]]}},
 A.srch.CLONEDEEP=function(e){return{status:1,values:[F(e)]}},A.srch.SET=function(e,t,r,n){var a=t.map(function(e){return"@"===e.method?"alasql.vars['"+e.variable+"']="+e.expression.toJS("x",""):"$"===e.method?"params['"+e.variable+"']="+e.expression.toJS("x",""):"x['"+e.column.columnid+"']="+e.expression.toJS("x","")}).join(";");return new Function("x,params,alasql",a)(e,n,A),{status:1,values:[e]}},A.srch.ROW=function(e,t,r,n){var a="var y;return [";return a+=t.map(function(e){return e.toJS("x","")}).join(","),a+="]",{status:1,values:[new Function("x,params,alasql",a)(e,n,A)]}},A.srch.D3=function(e){return"VERTEX"!==e.$node&&"EDGE"===e.$node&&(e.source=e.$in[0],e.target=e.$out[0]),{status:1,values:[e]}};var z=function(e){if(e){if(e&&1===e.length&&e[0].expression&&"function"==typeof e[0].expression){var t=e[0].expression;return function(e,r){var n=t(e),a=t(r);return n>a?1:n===a?0:-1}}var r="",n="";return e.forEach(function(e){var t="";if(e.expression instanceof K.NumValue&&(e.expression=self.columns[e.expression.value-1]),e.expression instanceof K.Column){var a=e.expression.columnid;A.options.valueof&&(t=".valueOf()"),e.nocase&&(t+=".toUpperCase()"),"_"===a?(r+="if(a"+t+("ASC"===e.direction?">":"<")+"b"+t+")return 1;",r+="if(a"+t+"==b"+t+"){"):(r+="if((a['"+a+"']||'')"+t+("ASC"===e.direction?">":"<")+"(b['"+a+"']||'')"+t+")return 1;",r+="if((a['"+a+"']||'')"+t+"==(b['"+a+"']||'')"+t+"){")}else t=".valueOf()",e.nocase&&(t+=".toUpperCase()"),r+="if(("+e.toJS("a","")+"||'')"+t+("ASC"===e.direction?">(":"<(")+e.toJS("b","")+"||'')"+t+")return 1;",r+="if(("+e.toJS("a","")+"||'')"+t+"==("+e.toJS("b","")+"||'')"+t+"){";n+="}"}),r+="return 0;",r+=n+"return -1",new Function("a,b",r)}};A.srch.ORDERBY=function(e,t){return{status:1,values:e.sort(z(t))}};var Z=function(e){for(var t=0,r=e.sources.length;t<r;t++){var n=e.sources[t];if(delete n.ix,t>0&&"ix"==n.optimization&&n.onleftfn&&n.onrightfn){if(n.databaseid&&A.databases[n.databaseid].tables[n.tableid]){A.databases[n.databaseid].tables[n.tableid].indices||(e.database.tables[n.tableid].indices={});var a=A.databases[n.databaseid].tables[n.tableid].indices[D(n.onrightfns+"`"+n.srcwherefns)];!A.databases[n.databaseid].tables[n.tableid].dirty&&a&&(n.ix=a)}if(!n.ix){n.ix={};for(var s,i={},o=0,u=n.data.length;(s=n.data[o])||n.getfn&&(s=n.getfn(o))||o<u;){if(n.getfn&&!n.dontcache&&(n.data[o]=s),i[n.alias||n.tableid]=s,n.srcwherefn(i,e.params,A)){var c=n.onrightfn(i,e.params,A),l=n.ix[c];l||(l=n.ix[c]=[]),l.push(s)}o++}n.databaseid&&A.databases[n.databaseid].tables[n.tableid]&&(A.databases[n.databaseid].tables[n.tableid].indices[D(n.onrightfns+"`"+n.srcwherefns)]=n.ix)}}else if(n.wxleftfn){if(A.databases[n.databaseid].engineid||(a=A.databases[n.databaseid].tables[n.tableid].indices[D(n.wxleftfns+"`")]),!A.databases[n.databaseid].tables[n.tableid].dirty&&a)n.ix=a,n.data=n.ix[n.wxrightfn(null,e.params,A)];else{for(n.ix={},i={},o=0,u=n.data.length;(s=n.data[o])||n.getfn&&(s=n.getfn(o))||o<u;)n.getfn&&!n.dontcache&&(n.data[o]=s),i[n.alias||n.tableid]=n.data[o],c=n.wxleftfn(i,e.params,A),l=n.ix[c],l||(l=n.ix[c]=[]),l.push(n.data[o]),o++;A.databases[n.databaseid].engineid||(A.databases[n.databaseid].tables[n.tableid].indices[D(n.wxleftfns+"`")]=n.ix)}n.srcwherefns&&(n.data?(i={},n.data=n.data.filter(function(t){return i[n.alias]=t,n.srcwherefn(i,e.params,A)})):n.data=[])}else if(n.srcwherefns&&!n.dontcache)if(n.data){var i={};n.data=n.data.filter(function(t){return i[n.alias]=t,n.srcwherefn(i,e.params,A)}),i={},o=0,u=n.data.length;for(var h=[];(s=n.data[o])||n.getfn&&(s=n.getfn(o))||o<u;)n.getfn&&!n.dontcache&&(n.data[o]=s),i[n.alias]=s,n.srcwherefn(i,e.params,A)&&h.push(s),o++;n.data=h}else n.data=[];n.databaseid&&A.databases[n.databaseid].tables[n.tableid]}};K.Select=function(e){return K.extend(this,e)},K.Select.prototype.toString=function(){var e;return e="",this.explain&&(e+="EXPLAIN "),e+="SELECT ",this.modifier&&(e+=this.modifier+" "),this.distinct&&(e+="DISTINCT "),this.top&&(e+="TOP "+this.top.value+" ",this.percent&&(e+="PERCENT ")),e+=this.columns.map(function(e){var t;return t=e.toString(),void 0!==e.as&&(t+=" AS "+e.as),t}).join(", "),this.from&&(e+=" FROM "+this.from.map(function(e){var t;return t=e.toString(),e.as&&(t+=" AS "+e.as),t}).join(",")),this.joins&&(e+=this.joins.map(function(e){var t;if(t=" ",e.joinmode&&(t+=e.joinmode+" "),e.table)t+="JOIN "+e.table.toString();else if(e.select)t+="JOIN ("+e.select.toString()+")";else{if(!(e instanceof A.yy.Apply))throw new Error("Wrong type in JOIN mode");t+=e.toString()}return e.as&&(t+=" AS "+e.as),e.using&&(t+=" USING "+e.using.toString()),e.on&&(t+=" ON "+e.on.toString()),t})),this.where&&(e+=" WHERE "+this.where.toString()),this.group&&this.group.length>0&&(e+=" GROUP BY "+this.group.map(function(e){return e.toString()}).join(", ")),this.having&&(e+=" HAVING "+this.having.toString()),this.order&&this.order.length>0&&(e+=" ORDER BY "+this.order.map(function(e){return e.toString()}).join(", ")),this.limit&&(e+=" LIMIT "+this.limit.value),this.offset&&(e+=" OFFSET "+this.offset.value),this.union&&(e+=" UNION "+(this.corresponding?"CORRESPONDING ":"")+this.union.toString()),this.unionall&&(e+=" UNION ALL "+(this.corresponding?"CORRESPONDING ":"")+this.unionall.toString()),this.except&&(e+=" EXCEPT "+(this.corresponding?"CORRESPONDING ":"")+this.except.toString()),this.intersect&&(e+=" INTERSECT "+(this.corresponding?"CORRESPONDING ":"")+this.intersect.toString()),e},K.Select.prototype.toJS=function(e){return"alasql.utils.flatArray(this.queriesfn["+(this.queriesidx-1)+"](this.params,null,"+e+"))[0]"},K.Select.prototype.compile=function(e,t){var r=A.databases[e],n=new X;if(n.removeKeys=[],n.aggrKeys=[],n.explain=this.explain,n.explaination=[],n.explid=1,n.modifier=this.modifier,n.database=r,this.compileWhereExists(n),this.compileQueries(n),n.defcols=this.compileDefCols(n,e),n.fromfn=this.compileFrom(n),this.joins&&this.compileJoins(n),n.rownums=[],this.compileSelectGroup0(n),this.group||n.selectGroup.length>0?n.selectgfns=this.compileSelectGroup1(n):n.selectfns=this.compileSelect1(n,t),this.compileRemoveColumns(n),this.where&&this.compileWhereJoins(n),n.wherefn=this.compileWhere(n),(this.group||n.selectGroup.length>0)&&(n.groupfn=this.compileGroup(n)),this.having&&(n.havingfn=this.compileHaving(n)),this.order&&(n.orderfn=this.compileOrder(n)),this.group||n.selectGroup.length>0?n.selectgfn=this.compileSelectGroup2(n):n.selectfn=this.compileSelect2(n),n.distinct=this.distinct,this.pivot&&(n.pivotfn=this.compilePivot(n)),this.unpivot&&(n.pivotfn=this.compileUnpivot(n)),this.top?n.limit=this.top.value:this.limit&&(n.limit=this.limit.value,this.offset&&(n.offset=this.offset.value)),n.percent=this.percent,n.corresponding=this.corresponding,this.union?(n.unionfn=this.union.compile(e),this.union.order?n.orderfn=this.union.compileOrder(n):n.orderfn=null):this.unionall?(n.unionallfn=this.unionall.compile(e),this.unionall.order?n.orderfn=this.unionall.compileOrder(n):n.orderfn=null):this.except?(n.exceptfn=this.except.compile(e),this.except.order?n.orderfn=this.except.compileOrder(n):n.orderfn=null):this.intersect&&(n.intersectfn=this.intersect.compile(e),this.intersect.order?n.intersectfn=this.intersect.compileOrder(n):n.orderfn=null),this.into){if(this.into instanceof K.Table)A.options.autocommit&&A.databases[this.into.databaseid||e].engineid?n.intoallfns='return alasql.engines["'+A.databases[this.into.databaseid||e].engineid+'"].intoTable("'+(this.into.databaseid||e)+'","'+this.into.tableid+'",this.data, columns, cb);':n.intofns="alasql.databases['"+(this.into.databaseid||e)+"'].tables['"+this.into.tableid+"'].data.push(r);";else if(this.into instanceof K.VarValue)n.intoallfns='alasql.vars["'+this.into.variable+'"]=this.data;res=this.data.length;if(cb)res=cb(res);return res;';else if(this.into instanceof K.FuncValue){var a="return alasql.into['"+this.into.funcid.toUpperCase()+"'](";this.into.args&&this.into.args.length>0?(a+=this.into.args[0].toJS()+",",this.into.args.length>1?a+=this.into.args[1].toJS()+",":a+="undefined,"):a+="undefined, undefined,",n.intoallfns=a+"this.data,columns,cb)"}else this.into instanceof K.ParamValue&&(n.intofns="params['"+this.into.param+"'].push(r)");n.intofns?n.intofn=new Function("r,i,params,alasql","var y;"+n.intofns):n.intoallfns&&(n.intoallfn=new Function("columns,cb,params,alasql","var y;"+n.intoallfns))}var s=function(e,t,r){return n.params=e,o(n,r,function(e){if(n.rownums.length>0)for(var r=0,a=e.length;r<a;r++)for(var s=0,i=n.rownums.length;s<i;s++)e[r][n.rownums[s]]=r+1;var o=f(n,e);return t&&t(o),o})};return s.query=n,s},K.Select.prototype.execute=function(e,t,r){return this.compile(e)(t,r)},K.ExistsValue=function(e){return K.extend(this,e)},K.ExistsValue.prototype.toString=function(){return"EXISTS("+this.value.toString()+")"},K.ExistsValue.prototype.toType=function(){return"boolean"},K.ExistsValue.prototype.toJS=function(e,t,r){return"this.existsfn["+this.existsidx+"](params,null,"+e+").data.length"},K.Select.prototype.compileWhereExists=function(e){this.exists&&(e.existsfn=this.exists.map(function(t){var r=t.compile(e.database.databaseid);return r.query.modifier="RECORDSET",r}))},K.Select.prototype.compileQueries=function(e){this.queries&&(e.queriesfn=this.queries.map(function(t){var r=t.compile(e.database.databaseid);return r.query.modifier="RECORDSET",r}))},A.precompile=function(e,t,r){e&&(e.params=r,e.queries&&(e.queriesfn=e.queries.map(function(r){var n=r.compile(t||e.database.databaseid);return n.query.modifier="RECORDSET",n})),e.exists&&(e.existsfn=e.exists.map(function(r){var n=r.compile(t||e.database.databaseid);return n.query.modifier="RECORDSET",n})))},K.Select.prototype.compileFrom=function(e){var t=this;e.sources=[],e.aliases={},t.from&&(t.from.forEach(function(t){var n=t.as||t.tableid;if(t instanceof K.Table)e.aliases[n]={tableid:t.tableid,databaseid:t.databaseid||e.database.databaseid,type:"table"};else if(t instanceof K.Select)e.aliases[n]={type:"subquery"};else if(t instanceof K.Search)e.aliases[n]={type:"subsearch"};else if(t instanceof K.ParamValue)e.aliases[n]={type:"paramvalue"};else if(t instanceof K.FuncValue)e.aliases[n]={type:"funcvalue"};else if(t instanceof K.VarValue)e.aliases[n]={type:"varvalue"};else if(t instanceof K.FromData)e.aliases[n]={type:"fromdata"};else if(t instanceof K.Json)e.aliases[n]={type:"json"};else{if(!t.inserted)throw new Error("Wrong table at FROM");e.aliases[n]={type:"inserted"}}var a={alias:n,databaseid:t.databaseid||e.database.databaseid,tableid:t.tableid,joinmode:"INNER",onmiddlefn:r,srcwherefns:"",srcwherefn:r};if(t instanceof K.Table)a.columns=A.databases[a.databaseid].tables[a.tableid].columns,A.options.autocommit&&A.databases[a.databaseid].engineid&&!A.databases[a.databaseid].tables[a.tableid].view?a.datafn=function(e,t,r,n,s){return s.engines[s.databases[a.databaseid].engineid].fromTable(a.databaseid,a.tableid,r,n,e)}:A.databases[a.databaseid].tables[a.tableid].view?a.datafn=function(e,t,r,n,s){var i=s.databases[a.databaseid].tables[a.tableid].select(t);return r&&(i=r(i,n,e)),i}:a.datafn=function(e,t,r,n,s){var i=s.databases[a.databaseid].tables[a.tableid].data;return r&&(i=r(i,n,e)),i};else if(t instanceof K.Select)a.subquery=t.compile(e.database.databaseid),void 0===a.subquery.query.modifier&&(a.subquery.query.modifier="RECORDSET"),a.columns=a.subquery.query.columns,a.datafn=function(e,t,r,n,s){var i;return a.subquery(e.params,function(t){return i=t.data,r&&(i=r(i,n,e)),i}),i};else if(t instanceof K.Search)a.subsearch=t,a.columns=[],a.datafn=function(e,t,r,n,s){var i;return a.subsearch.execute(e.database.databaseid,e.params,function(t){return i=t,r&&(i=r(i,n,e)),i}),i};else if(t instanceof K.ParamValue){var s="var res = alasql.prepareFromData(params['"+t.param+"']";t.array&&(s+=",true"),s+=");if(cb)res=cb(res,idx,query);return res",a.datafn=new Function("query,params,cb,idx,alasql",s)}else if(t.inserted){var s="var res = alasql.prepareFromData(alasql.inserted";t.array&&(s+=",true"),s+=");if(cb)res=cb(res,idx,query);return res",a.datafn=new Function("query,params,cb,idx,alasql",s)}else if(t instanceof K.Json){var s="var res = alasql.prepareFromData("+t.toJS();t.array&&(s+=",true"),s+=");if(cb)res=cb(res,idx,query);return res",a.datafn=new Function("query,params,cb,idx,alasql",s)}else if(t instanceof K.VarValue){var s="var res = alasql.prepareFromData(alasql.vars['"+t.variable+"']";t.array&&(s+=",true"),s+=");if(cb)res=cb(res,idx,query);return res",a.datafn=new Function("query,params,cb,idx,alasql",s)}else if(t instanceof K.FuncValue){var i="var res=alasql.from['"+t.funcid.toUpperCase()+"'](";t.args&&t.args.length>0?(t.args[0]?i+=t.args[0].toJS("query.oldscope")+",":i+="null,",t.args[1]?i+=t.args[1].toJS("query.oldscope")+",":i+="null,"):i+="null,null,",i+="cb,idx,query",i+=");/*if(cb)res=cb(res,idx,query);*/return res",a.datafn=new Function("query, params, cb, idx, alasql",i)}else{if(!(t instanceof K.FromData))throw new Error("Wrong table at FROM");a.datafn=function(e,r,n,a,s){var i=t.data;return n&&(i=n(i,a,e)),i}}e.sources.push(a)}),e.defaultTableid=e.sources[0].alias)},A.prepareFromData=function(e,t){var r=e;if("string"==typeof e){if(r=e.split(/\r?\n/),t)for(var n=0,a=r.length;n<a;n++)r[n]=[r[n]]}else if(t){r=[];for(var n=0,a=e.length;n<a;n++)r.push([e[n]])}else if("object"==typeof e&&!Array.isArray(e))if("undefined"!=typeof Mongo&&void 0!==Mongo.Collection&&e instanceof Mongo.Collection)r=e.find().fetch();else{r=[];for(var s in e)e.hasOwnProperty(s)&&r.push([s,e[s]])}return r},K.Select.prototype.compileJoins=function(e){this.joins.forEach(function(t){if("CROSS"==t.joinmode){if(t.using||t.on)throw new Error("CROSS JOIN cannot have USING or ON clauses");t.joinmode}var n,a;if(t instanceof K.Apply)n={alias:t.as,applymode:t.applymode,onmiddlefn:r,srcwherefns:"",srcwherefn:r,columns:[]},n.applyselect=t.select.compile(e.database.databaseid),n.columns=n.applyselect.query.columns,n.datafn=function(e,t,r,n,a){var s;return r&&(s=r(s,n,e)),s},e.sources.push(n);else{if(t.table){if(a=t.table,n={alias:t.as||a.tableid,databaseid:a.databaseid||e.database.databaseid,tableid:a.tableid,joinmode:t.joinmode,onmiddlefn:r,srcwherefns:"",srcwherefn:r,columns:[]},!A.databases[n.databaseid].tables[n.tableid])throw new Error("Table '"+n.tableid+"' is not exists in database '"+n.databaseid)+"'";n.columns=A.databases[n.databaseid].tables[n.tableid].columns,A.options.autocommit&&A.databases[n.databaseid].engineid?n.datafn=function(e,t,r,a,s){return s.engines[s.databases[n.databaseid].engineid].fromTable(n.databaseid,n.tableid,r,a,e)}:A.databases[n.databaseid].tables[n.tableid].view?n.datafn=function(e,t,r,a,s){var i=s.databases[n.databaseid].tables[n.tableid].select(t);return r&&(i=r(i,a,e)),i}:n.datafn=function(e,t,r,a,s){var i=s.databases[n.databaseid].tables[n.tableid].data;return r&&(i=r(i,a,e)),i},e.aliases[n.alias]={tableid:a.tableid,databaseid:a.databaseid||e.database.databaseid}}else if(t.select){var a=t.select;n={alias:t.as,joinmode:t.joinmode,onmiddlefn:r,srcwherefns:"",srcwherefn:r,columns:[]},n.subquery=a.compile(e.database.databaseid),void 0===n.subquery.query.modifier&&(n.subquery.query.modifier="RECORDSET"),n.columns=n.subquery.query.columns,n.datafn=function(e,t,r,a,s){return n.subquery(e.params,null,r,a).data},e.aliases[n.alias]={type:"subquery"}}else if(t.param){n={alias:t.as,joinmode:t.joinmode,onmiddlefn:r,srcwherefns:"",srcwherefn:r};var s=t.param.param,i="var res=alasql.prepareFromData(params['"+s+"']";t.array&&(i+=",true"),i+=");if(cb)res=cb(res, idx, query);return res",n.datafn=new Function("query,params,cb,idx, alasql",i),e.aliases[n.alias]={type:"paramvalue"}}else if(t.variable){n={alias:t.as,joinmode:t.joinmode,onmiddlefn:r,srcwherefns:"",srcwherefn:r};var i="var res=alasql.prepareFromData(alasql.vars['"+t.variable+"']";t.array&&(i+=",true"),i+=");if(cb)res=cb(res, idx, query);return res",n.datafn=new Function("query,params,cb,idx, alasql",i),e.aliases[n.alias]={type:"varvalue"}}else if(t.funcid){n={alias:t.as,joinmode:t.joinmode,onmiddlefn:r,srcwherefns:"",srcwherefn:r};var o="var res=alasql.from['"+js.funcid.toUpperCase()+"'](";t.args&&t.args.length>0?(t.args[0]?o+=t.args[0].toJS("query.oldscope")+",":o+="null,",t.args[1]?o+=t.args[1].toJS("query.oldscope")+",":o+="null,"):o+="null,null,",o+="cb,idx,query",o+=");/*if(cb)res=cb(res,idx,query);*/return res",n.datafn=new Function("query, params, cb, idx, alasql",o),e.aliases[n.alias]={type:"funcvalue"}}var u=n.alias;if(t.natural){if(t.using||t.on)throw new Error("NATURAL JOIN cannot have USING or ON clauses");if(e.sources.length>0){var c=e.sources[e.sources.length-1],l=A.databases[c.databaseid].tables[c.tableid],h=A.databases[n.databaseid].tables[n.tableid];if(!l||!h)throw new Error("In this version of Alasql NATURAL JOIN works for tables with predefined columns only");var d=l.columns.map(function(e){return e.columnid}),f=h.columns.map(function(e){return e.columnid});t.using=$(d,f).map(function(e){return{columnid:e}})}}if(t.using){var c=e.sources[e.sources.length-1];n.onleftfns=t.using.map(function(e){return"p['"+(c.alias||c.tableid)+"']['"+e.columnid+"']"}).join('+"`"+'),n.onleftfn=new Function("p,params,alasql","var y;return "+n.onleftfns),n.onrightfns=t.using.map(function(e){return"p['"+(n.alias||n.tableid)+"']['"+e.columnid+"']"}).join('+"`"+'),n.onrightfn=new Function("p,params,alasql","var y;return "+n.onrightfns),n.optimization="ix"}else if(t.on)if(t.on instanceof K.Op&&"="==t.on.op&&!t.on.allsome){n.optimization="ix";var p="",b="",E="",g=!1,m=t.on.left.toJS("p",e.defaultTableid,e.defcols),v=t.on.right.toJS("p",e.defaultTableid,e.defcols);m.indexOf("p['"+u+"']")>-1&&!(v.indexOf("p['"+u+"']")>-1)?(m.match(/p\[\'.*?\'\]/g)||[]).every(function(e){return e=="p['"+u+"']"})?b=m:g=!0:!(m.indexOf("p['"+u+"']")>-1)&&v.indexOf("p['"+u+"']")>-1&&(v.match(/p\[\'.*?\'\]/g)||[]).every(function(e){return e=="p['"+u+"']"})?p=m:g=!0,v.indexOf("p['"+u+"']")>-1&&!(m.indexOf("p['"+u+"']")>-1)?(v.match(/p\[\'.*?\'\]/g)||[]).every(function(e){return e=="p['"+u+"']"})?b=v:g=!0:!(v.indexOf("p['"+u+"']")>-1)&&m.indexOf("p['"+u+"']")>-1&&(m.match(/p\[\'.*?\'\]/g)||[]).every(function(e){return e=="p['"+u+"']"})?p=v:g=!0,g&&(b="",p="",E=t.on.toJS("p",e.defaultTableid,e.defcols),n.optimization="no"),n.onleftfns=p,n.onrightfns=b,n.onmiddlefns=E||"true",n.onleftfn=new Function("p,params,alasql","var y;return "+n.onleftfns),n.onrightfn=new Function("p,params,alasql","var y;return "+n.onrightfns),n.onmiddlefn=new Function("p,params,alasql","var y;return "+n.onmiddlefns)}else n.optimization="no",n.onmiddlefns=t.on.toJS("p",e.defaultTableid,e.defcols),n.onmiddlefn=new Function("p,params,alasql","var y;return "+t.on.toJS("p",e.defaultTableid,e.defcols));e.sources.push(n)}})},K.Select.prototype.compileWhere=function(e){if(this.where){if("function"==typeof this.where)return this.where;var t=this.where.toJS("p",e.defaultTableid,e.defcols);return e.wherefns=t,new Function("p,params,alasql","var y;return "+t)}return function(){return!0}},K.Select.prototype.compileWhereJoins=function(e){},K.Select.prototype.compileGroup=function(e){if(e.sources.length>0)var t=e.sources[0].alias;else var t="";var r=e.defcols,n=[[]];this.group&&(n=b(this.group,e));var a=[];n.forEach(function(e){a=k(a,e)}),e.allgroups=a,e.ingroup=[];var s="";return n.forEach(function(n){s+="var g=this.xgroups[";var i=n.map(function(t){var r=t.split("\t")[0],n=t.split("\t")[1];return""===r?"1":(e.ingroup.push(r),n)});0===i.length&&(i=["''"]),s+=i.join('+"`"+'),s+="];if(!g) {this.groups.push((g=this.xgroups[",s+=i.join('+"`"+'),s+="] = {",s+=n.map(function(e){var t=e.split("\t")[0],r=e.split("\t")[1];return""===t?"":"'"+t+"':"+r+","}).join("");var o=L(a,n);s+=o.map(function(e){return"'"+e.split("\t")[0]+"':null,"}).join("");var u="",c="";void 0!==e.groupStar&&(c+="for(var f in p['"+e.groupStar+"']) {g[f]=p['"+e.groupStar+"'][f];};"),s+=e.selectGroup.map(function(n){var a=n.expression.toJS("p",t,r),s=n.nick;return n instanceof K.AggrValue?(n.distinct&&(u+=",g['$$_VALUES_"+s+"']={},g['$$_VALUES_"+s+"']["+a+"]=true"),"SUM"===n.aggregatorid?"'"+s+"':("+a+")||0,":"MIN"===n.aggregatorid||"MAX"===n.aggregatorid||"FIRST"===n.aggregatorid||"LAST"===n.aggregatorid?"'"+s+"':"+a+",":"ARRAY"===n.aggregatorid?"'"+s+"':["+a+"],":"COUNT"===n.aggregatorid?"*"===n.expression.columnid?"'"+s+"':1,":"'"+s+"':(typeof "+a+' != "undefined")?1:0,':"AVG"===n.aggregatorid?(e.removeKeys.push("_SUM_"+s),e.removeKeys.push("_COUNT_"+s),"'"+s+"':"+a+",'_SUM_"+s+"':("+a+")||0,'_COUNT_"+s+"':(typeof "+a+' != "undefined")?1:0,'):"AGGR"===n.aggregatorid?(u+=",g['"+s+"']="+n.expression.toJS("g",-1),""):"REDUCE"===n.aggregatorid?(e.aggrKeys.push(n),"'"+s+"':alasql.aggr['"+n.funcid+"']("+a+",undefined,1),"):""):""}).join(""),s+="}"+u+",g));"+c+"} else {",s+=e.selectGroup.map(function(e){var n=e.nick,a=e.expression.toJS("p",t,r);if(e instanceof K.AggrValue){var s="",i="";if(e.distinct)var s="if(typeof "+a+'!="undefined" && (!g[\'$$_VALUES_'+n+"']["+a+"])) \t\t\t\t \t\t {",i="g['$$_VALUES_"+n+"']["+a+"]=true;}";return"SUM"===e.aggregatorid?s+"g['"+n+"']+=("+a+"||0);"+i:"COUNT"===e.aggregatorid?"*"===e.expression.columnid?s+"g['"+n+"']++;"+i:s+"if(typeof "+a+'!="undefined") g[\''+n+"']++;"+i:"ARRAY"===e.aggregatorid?s+"g['"+n+"'].push("+a+");"+i:"MIN"===e.aggregatorid?s+"g['"+n+"']=Math.min(g['"+n+"'],"+a+");"+i:"MAX"===e.aggregatorid?s+"g['"+n+"']=Math.max(g['"+n+"'],"+a+");"+i:"FIRST"===e.aggregatorid?"":"LAST"===e.aggregatorid?s+"g['"+n+"']="+a+";"+i:"AVG"===e.aggregatorid?s+"g['_SUM_"+n+"']+=(y="+a+")||0;g['_COUNT_"+n+"']+=(typeof y!=\"undefined\")?1:0;g['"+n+"']=g['_SUM_"+n+"']/g['_COUNT_"+n+"'];"+i:"AGGR"===e.aggregatorid?s+"g['"+n+"']="+e.expression.toJS("g",-1)+";"+i:"REDUCE"===e.aggregatorid?s+"g['"+n+"']=alasql.aggr."+e.funcid+"("+a+",g['"+n+"'],2);"+i:""}return""}).join(""),s+="}"}),new Function("p,params,alasql","var y;"+s)},K.Select.prototype.compileSelect1=function(t,r){var n=this;t.columns=[],t.xcolumns={},t.selectColumns={},t.dirtyColumns=!1;var a="var r={",s="",i=[];return this.columns.forEach(function(a){if(a instanceof K.Column)if("*"===a.columnid)if(a.func)s+="r=params['"+a.param+"'](p['"+t.sources[0].alias+"'],p,params,alasql);";else if(a.tableid){var o=p(t,a.tableid,!1);o.s&&(i=i.concat(o.s)),s+=o.sp}else for(var u in t.aliases){var o=p(t,u,!0);o.s&&(i=i.concat(o.s)),s+=o.sp}else{var c=a.tableid,l=a.databaseid||t.sources[0].databaseid||t.database.databaseid;if(c||(c=t.defcols[a.columnid]),c||(c=t.defaultTableid),"_"!==a.columnid){var h=r&&r.length>1&&Array.isArray(r[0])&&r[0].length>=1&&r[0][0].hasOwnProperty("sheetid");h?s='var r={};var w=p["'+c+'"];var cols=['+n.columns.map(function(e){return"'"+e.columnid+"'"}).join(",")+"];var colas=["+n.columns.map(function(e){return"'"+(e.as||e.columnid)+"'"}).join(",")+"];for (var i=0;i<Object.keys(p['"+c+"']).length;i++) for(var k=0;k<cols.length;k++){if (!r.hasOwnProperty(i)) r[i]={}; r[i][colas[k]]=w[i][cols[k]];}":i.push("'"+R(a.as||a.columnid)+"':p['"+c+"']['"+a.columnid+"']")}else i.push("'"+R(a.as||a.columnid)+"':p['"+c+"']");if(t.selectColumns[R(a.as||a.columnid)]=!0,t.aliases[c]&&"table"===t.aliases[c].type){if(!A.databases[l].tables[t.aliases[c].tableid])throw new Error("Table '"+c+"' does not exists in database");var d=A.databases[l].tables[t.aliases[c].tableid].columns,f=A.databases[l].tables[t.aliases[c].tableid].xcolumns;if(f&&d.length>0){var b=f[a.columnid];if(void 0===b)throw new Error("Column does not exists: "+a.columnid);var E={columnid:a.as||a.columnid,dbtypeid:b.dbtypeid,dbsize:b.dbsize,dbpecision:b.dbprecision,dbenum:b.dbenum};t.columns.push(E),t.xcolumns[E.columnid]=E}else{var E={columnid:a.as||a.columnid};t.columns.push(E),t.xcolumns[E.columnid]=E,t.dirtyColumns=!0}}else{var E={columnid:a.as||a.columnid};t.columns.push(E),t.xcolumns[E.columnid]=E}}else if(a instanceof K.AggrValue){n.group||(n.group=[""]),a.as||(a.as=R(a.toString())),"SUM"===a.aggregatorid||"MAX"===a.aggregatorid||"MIN"===a.aggregatorid||"FIRST"===a.aggregatorid||"LAST"===a.aggregatorid||"AVG"===a.aggregatorid||"ARRAY"===a.aggregatorid||"REDUCE"===a.aggregatorid?i.push("'"+R(a.as)+"':"+e(a.expression.toJS("p",t.defaultTableid,t.defcols))):"COUNT"===a.aggregatorid&&i.push("'"+R(a.as)+"':1");var E={columnid:a.as||a.columnid||a.toString()};t.columns.push(E),t.xcolumns[E.columnid]=E}else{i.push("'"+R(a.as||a.columnid||a.toString())+"':"+e(a.toJS("p",t.defaultTableid,t.defcols))),t.selectColumns[R(a.as||a.columnid||a.toString())]=!0;var E={columnid:a.as||a.columnid||a.toString()};t.columns.push(E),t.xcolumns[E.columnid]=E}}),a+=i.join(",")+"};"+s},K.Select.prototype.compileSelect2=function(e){var t=e.selectfns;return this.orderColumns&&this.orderColumns.length>0&&this.orderColumns.forEach(function(r,n){var a="$$$"+n;r instanceof K.Column&&e.xcolumns[r.columnid]?t+="r['"+a+"']=r['"+r.columnid+"'];":t+="r['"+a+"']="+r.toJS("p",e.defaultTableid,e.defcols)+";",e.removeKeys.push(a)}),new Function("p,params,alasql","var y;"+t+"return r")},K.Select.prototype.compileSelectGroup0=function(e){var t=this;t.columns.forEach(function(r,n){if(r instanceof K.Column&&"*"===r.columnid)e.groupStar=r.tableid||"default";else{var a;a=R(r instanceof K.Column?r.columnid:r.toString(!0));for(var s=0;s<n;s++)if(a===t.columns[s].nick){a=t.columns[s].nick+":"+n;break}r.nick=a,!r.funcid||"ROWNUM"!==r.funcid.toUpperCase()&&"ROW_NUMBER"!==r.funcid.toUpperCase()||e.rownums.push(r.as)}}),this.columns.forEach(function(t){t.findAggregator&&t.findAggregator(e)}),this.having&&this.having.findAggregator&&this.having.findAggregator(e)},K.Select.prototype.compileSelectGroup1=function(t){var r=this,n="var r = {};";return r.columns.forEach(function(r){if(r instanceof K.Column&&"*"===r.columnid)return n+="for(var k in g) {r[k]=g[k]};","";var a=r.as;void 0===a&&(a=r instanceof K.Column?R(r.columnid):r.nick),t.groupColumns[a]=r.nick,n+="r['"+a+"']=",n+=e(r.toJS("g",""))+";";for(var s=0;s<t.removeKeys.length;s++)if(t.removeKeys[s]===a){t.removeKeys.splice(s,1);break}}),n},K.Select.prototype.compileSelectGroup2=function(e){var t=this,r=e.selectgfns;return t.columns.forEach(function(t){e.ingroup.indexOf(t.nick)>-1&&(r+="r['"+(t.as||t.nick)+"']=g['"+t.nick+"'];")}),this.orderColumns&&this.orderColumns.length>0&&this.orderColumns.forEach(function(t,n){var a="$$$"+n;t instanceof K.Column&&e.groupColumns[t.columnid]?r+="r['"+a+"']=r['"+t.columnid+"'];":r+="r['"+a+"']="+t.toJS("g","")+";",e.removeKeys.push(a)}),new Function("g,params,alasql","var y;"+r+"return r")},K.Select.prototype.compileRemoveColumns=function(e){void 0!==this.removecolumns&&(e.removeKeys=e.removeKeys.concat(this.removecolumns.filter(function(e){return void 0===e.like}).map(function(e){return e.columnid})),e.removeLikeKeys=this.removecolumns.filter(function(e){return void 0!==e.like}).map(function(e){return e.like.value}))},K.Select.prototype.compileHaving=function(e){return this.having?(s=this.having.toJS("g",-1),e.havingfns=s,new Function("g,params,alasql","var y;return "+s)):function(){return!0}},K.Select.prototype.compileOrder=function(e){var t=this;if(t.orderColumns=[],this.order){if(this.order&&1==this.order.length&&this.order[0].expression&&"function"==typeof this.order[0].expression){var r=this.order[0].expression;return function(e,t){var n=r(e),a=r(t);return n>a?1:n==a?0:-1}}var n="",a="";return this.order.forEach(function(r,s){if(r.expression instanceof K.NumValue)var i=t.columns[r.expression.value-1];else var i=r.expression;t.orderColumns.push(i);var o="$$$"+s,u="";if(r.expression instanceof K.Column){var c=r.expression.columnid;if(e.xcolumns[c]){var l=e.xcolumns[c].dbtypeid;"DATE"!=l&&"DATETIME"!=l&&"DATETIME2"!=l||(u=".valueOf()")}else A.options.valueof&&(u=".valueOf()")}r.nocase&&(u+=".toUpperCase()"),n+="if((a['"+o+"']||'')"+u+("ASC"==r.direction?">":"<")+"(b['"+o+"']||'')"+u+")return 1;",n+="if((a['"+o+"']||'')"+u+"==(b['"+o+"']||'')"+u+"){",a+="}"}),n+="return 0;",n+=a+"return -1",e.orderfns=n,new Function("a,b","var y;"+n)}},K.Select.prototype.compilePivot=function(e){var t=this,r=t.pivot.columnid,n=t.pivot.expr.expression.columnid,a=t.pivot.expr.aggregatorid,s=t.pivot.inlist;return s&&(s=s.map(function(e){return e.expr.columnid})),function(){var e=this,t=e.columns.filter(function(e){return e.columnid!=r&&e.columnid!=n}).map(function(e){return e.columnid}),i=[],o={},u={},c={},l=[];if(e.data.forEach(function(e){if(!s||s.indexOf(e[r])>-1){var h=t.map(function(t){return e[t]}).join("`"),d=u[h];if(d||(d={},u[h]=d,l.push(d),t.forEach(function(t){d[t]=e[t]})),c[h]||(c[h]={}),c[h][e[r]]?c[h][e[r]]++:c[h][e[r]]=1,o[e[r]]||(o[e[r]]=!0,i.push(e[r])),"SUM"==a||"AVG"==a)void 0===d[e[r]]&&(d[e[r]]=0),d[e[r]]+=e[n];else if("COUNT"==a)void 0===d[e[r]]&&(d[e[r]]=0),d[e[r]]++;else if("MIN"==a)void 0===d[e[r]]&&(d[e[r]]=1/0),e[n]<d[e[r]]&&(d[e[r]]=e[n]);else if("MAX"==a)void 0===d[e[r]]&&(d[e[r]]=-1/0),e[n]>d[e[r]]&&(d[e[r]]=e[n]);else if("FIRST"==a)void 0===d[e[r]]&&(d[e[r]]=e[n]);else if("LAST"==a)d[e[r]]=e[n];else{if(!A.aggr[a])throw new Error("Wrong aggregator in PIVOT clause");A.aggr[a](d[e[r]],e[n])}}}),"AVG"==a)for(var h in u){var d=u[h];for(var f in d)-1==t.indexOf(f)&&f!=n&&(d[f]=d[f]/c[h][f])}e.data=l,s&&(i=s);var p=e.columns.filter(function(e){return e.columnid==n})[0];e.columns=e.columns.filter(function(e){return!(e.columnid==r||e.columnid==n)}),i.forEach(function(t){var r=F(p);r.columnid=t,e.columns.push(r)})}},K.Select.prototype.compileUnpivot=function(e){var t=this,r=t.unpivot.tocolumnid,n=t.unpivot.forcolumnid,a=t.unpivot.inlist.map(function(e){return e.columnid});return function(){var t=[],s=e.columns.map(function(e){return e.columnid}).filter(function(e){return-1==a.indexOf(e)&&e!=n&&e!=r});e.data.forEach(function(e){a.forEach(function(a){var i={};s.forEach(function(t){i[t]=e[t]}),i[n]=a,i[r]=e[a],t.push(i)})}),e.data=t}};var ee=function(e,t){for(var r=[],n=0,a=e.length,s=0;s<a+1;s++){for(var i=[],o=0;o<a;o++){if(e[o]instanceof K.Column){e[o].nick=R(e[o].columnid),t.groupColumns[R(e[o].columnid)]=e[o].nick;var u=e[o].nick+"\t"+e[o].toJS("p",t.sources[0].alias,t.defcols)}else{t.groupColumns[R(e[o].toString())]=R(e[o].toString());var u=R(e[o].toString())+"\t"+e[o].toJS("p",t.sources[0].alias,t.defcols)}n&1<<o&&i.push(u)}r.push(i),n=1+(n<<1)}return r},te=function(e,t){for(var r=[],n=e.length,a=1<<n,s=0;s<a;s++){for(var i=[],o=0;o<n;o++)s&1<<o&&(i=i.concat(b(e[o],t)));r.push(i)}return r},re=function(e,t){return e.reduce(function(e,r){return e=e.concat(b(r,t))},[])},ne=function(e,t){for(var r=[],n=0;n<e.length;n++)for(var a=0;a<t.length;a++)r.push(e[n].concat(t[a]));return r};K.Select.prototype.compileDefCols=function(e,t){var r={".":{}};return this.from&&this.from.forEach(function(e){if(r["."][e.as||e.tableid]=!0,e instanceof K.Table){var n=e.as||e.tableid,a=A.databases[e.databaseid||t].tables[e.tableid];if(void 0===a)throw new Error("Table does not exists: "+e.tableid);a.columns&&a.columns.forEach(function(e){r[e.columnid]?r[e.columnid]="-":r[e.columnid]=n})}else if(e instanceof K.Select);else if(e instanceof K.Search);else if(e instanceof K.ParamValue);else if(e instanceof K.VarValue);else if(e instanceof K.FuncValue);else if(e instanceof K.FromData);else if(e instanceof K.Json);else if(!e.inserted)throw new Error("Unknown type of FROM clause")}),this.joins&&this.joins.forEach(function(e){if(r["."][e.as||e.table.tableid]=!0,e.table){var n=e.table.tableid;e.as&&(n=e.as);var n=e.as||e.table.tableid,a=A.databases[e.table.databaseid||t].tables[e.table.tableid];a.columns&&a.columns.forEach(function(e){r[e.columnid]?r[e.columnid]="-":r[e.columnid]=n})}else if(e.select);else if(e.param);else if(!e.func)throw new Error("Unknown type of FROM clause")}),r},K.Union=function(e){return K.extend(this,e)},K.Union.prototype.toString=function(){return"UNION"},K.Union.prototype.compile=function(e){return null},K.Apply=function(e){return K.extend(this,e)},K.Apply.prototype.toString=function(){var e=this.applymode+" APPLY ("+this.select.toString()+")";return this.as&&(e+=" AS "+this.as),e},K.Over=function(e){
-return K.extend(this,e)},K.Over.prototype.toString=function(){var e="OVER (";return this.partition&&(e+="PARTITION BY "+this.partition.toString(),this.order&&(e+=" ")),this.order&&(e+="ORDER BY "+this.order.toString()),e+=")"},K.ExpressionStatement=function(e){return K.extend(this,e)},K.ExpressionStatement.prototype.toString=function(){return this.expression.toString()},K.ExpressionStatement.prototype.execute=function(e,t,r){if(this.expression){A.precompile(this,e,t);var n=new Function("params,alasql,p","var y;return "+this.expression.toJS("({})","",null)).bind(this),a=n(t,A);return r&&(a=r(a)),a}},K.Expression=function(e){return K.extend(this,e)},K.Expression.prototype.toString=function(e){var t=this.expression.toString(e);return this.order&&(t+=" "+this.order.toString()),this.nocase&&(t+=" COLLATE NOCASE"),t},K.Expression.prototype.findAggregator=function(e){this.expression.findAggregator&&this.expression.findAggregator(e)},K.Expression.prototype.toJS=function(e,t,r){return this.expression.reduced?"true":this.expression.toJS(e,t,r)},K.Expression.prototype.compile=function(e,t,r){return!!this.reduced||new Function("p","var y;return "+this.toJS(e,t,r))},K.JavaScript=function(e){return K.extend(this,e)},K.JavaScript.prototype.toString=function(){return"``"+this.value+"``"},K.JavaScript.prototype.toJS=function(){return"("+this.value+")"},K.JavaScript.prototype.execute=function(e,t,r){var n=1;return new Function("params,alasql,p",this.value)(t,A),r&&(n=r(n)),n},K.Literal=function(e){return K.extend(this,e)},K.Literal.prototype.toString=function(e){var t=this.value;return this.value1&&(t=this.value1+"."+t),this.alias&&!e&&(t+=" AS "+this.alias),t},K.Join=function(e){return K.extend(this,e)},K.Join.prototype.toString=function(){var e=" ";return this.joinmode&&(e+=this.joinmode+" "),e+="JOIN "+this.table.toString()},K.Table=function(e){return K.extend(this,e)},K.Table.prototype.toString=function(){var e=this.tableid;return this.databaseid&&(e=this.databaseid+"."+e),e},K.View=function(e){return K.extend(this,e)},K.View.prototype.toString=function(){var e=this.viewid;return this.databaseid&&(e=this.databaseid+"."+e),e},K.Op=function(e){return K.extend(this,e)},K.Op.prototype.toString=function(){if("IN"===this.op||"NOT IN"===this.op)return this.left.toString()+" "+this.op+" ("+this.right.toString()+")";if(this.allsome)return this.left.toString()+" "+this.op+" "+this.allsome+" ("+this.right.toString()+")";if("->"===this.op||"!"===this.op){var e=this.left.toString()+this.op;return"string"!=typeof this.right&&"number"!=typeof this.right&&(e+="("),e+=this.right.toString(),"string"!=typeof this.right&&"number"!=typeof this.right&&(e+=")"),e}return this.left.toString()+" "+this.op+" "+(this.allsome?this.allsome+" ":"")+this.right.toString()},K.Op.prototype.findAggregator=function(e){this.left&&this.left.findAggregator&&this.left.findAggregator(e),this.right&&this.right.findAggregator&&!this.allsome&&this.right.findAggregator(e)},K.Op.prototype.toType=function(e){if(["-","*","/","%","^"].indexOf(this.op)>-1)return"number";if(["||"].indexOf(this.op)>-1)return"string";if("+"===this.op){if("string"===this.left.toType(e)||"string"===this.right.toType(e))return"string";if("number"===this.left.toType(e)||"number"===this.right.toType(e))return"number"}return["AND","OR","NOT","=","==","===","!=","!==","!===",">",">=","<","<=","IN","NOT IN","LIKE","NOT LIKE","REGEXP","GLOB"].indexOf(this.op)>-1?"boolean":"BETWEEN"===this.op||"NOT BETWEEN"===this.op||"IS NULL"===this.op||"IS NOT NULL"===this.op?"boolean":this.allsome?"boolean":this.op?"unknown":this.left.toType()},K.Op.prototype.toJS=function(e,t,r){var n,a=[],s=this.op,i=this,o=function(n){return n.toJS&&(n=n.toJS(e,t,r)),"y["+(a.push(n)-1)+"]"},u=function(){return o(i.left)},c=function(){return o(i.right)};if("="===this.op?s="===":"<>"===this.op?s="!=":"OR"===this.op&&(s="||"),"->"===this.op){var l="("+u()+"||{})";if("string"==typeof this.right)n=l+'["'+this.right+'"]';else if("number"==typeof this.right)n=l+"["+this.right+"]";else if(this.right instanceof K.FuncValue){var h=[];if(this.right.args&&0!==this.right.args.length)var h=this.right.args.map(o);n=l+"['"+this.right.funcid+"']("+h.join(",")+")"}else n=l+"["+c()+"]"}if("!"===this.op&&"string"==typeof this.right&&(n="alasql.databases[alasql.useid].objects["+u()+']["'+this.right+'"]'),"IS"===this.op&&(n="(("+u()+"==null) === ("+c()+"==null))"),"=="===this.op&&(n="alasql.utils.deepEqual("+u()+","+c()+")"),"==="!==this.op&&"!==="!==this.op||(n="("+("!==="===this.op?"!":"")+"(("+u()+").valueOf()===("+c()+").valueOf()))"),"!=="===this.op&&(n="(!alasql.utils.deepEqual("+u()+","+c()+"))"),"||"===this.op&&(n="(''+("+u()+"||'')+("+c()+'||""))'),"LIKE"===this.op||"NOT LIKE"===this.op){var n="("+("NOT LIKE"===this.op?"!":"")+"alasql.utils.like("+c()+","+u();this.escape&&(n+=","+o(this.escape)),n+="))"}if("REGEXP"===this.op&&(n="alasql.stdfn.REGEXP_LIKE("+u()+","+c()+")"),"GLOB"===this.op&&(n="alasql.utils.glob("+u()+","+c()+")"),"BETWEEN"===this.op||"NOT BETWEEN"===this.op){var d=u();n="("+("NOT BETWEEN"===this.op?"!":"")+"(("+o(this.right1)+"<="+d+") && ("+d+"<="+o(this.right2)+")))"}if("IN"===this.op&&(this.right instanceof K.Select?(n="(",n+="alasql.utils.flatArray(this.queriesfn["+this.queriesidx+"](params,null,"+e+"))",n+=".indexOf(",n+=u()+")>-1)"):n=Array.isArray(this.right)?"(["+this.right.map(o).join(",")+"].indexOf("+u()+")>-1)":"("+c()+".indexOf("+u()+")>-1)"),"NOT IN"===this.op&&(this.right instanceof K.Select?(n="(",n+="alasql.utils.flatArray(this.queriesfn["+this.queriesidx+"](params,null,p))",n+=".indexOf(",n+=u()+")<0)"):Array.isArray(this.right)?(n="(["+this.right.map(o).join(",")+"].indexOf(",n+=u()+")<0)"):(n="("+c()+".indexOf(",n+=u()+")==-1)")),"ALL"===this.allsome){var n;if(this.right instanceof K.Select)n="alasql.utils.flatArray(this.query.queriesfn["+this.queriesidx+"](params,null,p))",n+=".every(function(b){return (",n+=u()+")"+s+"b})";else{if(!Array.isArray(this.right))throw new Error("NOT IN operator without SELECT");n=""+(1==this.right.length?o(this.right[0]):"["+this.right.map(o).join(",")+"]"),n+=".every(function(b){return (",n+=u()+")"+s+"b})"}}if("SOME"===this.allsome||"ANY"===this.allsome){var n;if(this.right instanceof K.Select)n="alasql.utils.flatArray(this.query.queriesfn["+this.queriesidx+"](params,null,p))",n+=".some(function(b){return (",n+=u()+")"+s+"b})";else{if(!Array.isArray(this.right))throw new Error("SOME/ANY operator without SELECT");n=""+(1==this.right.length?o(this.right[0]):"["+this.right.map(o).join(",")+"]"),n+=".some(function(b){return (",n+=u()+")"+s+"b})"}}if("AND"===this.op){if(this.left.reduced){if(this.right.reduced)return"true";n=c()}else this.right.reduced&&(n=u());s="&&"}var f=n||"("+u()+s+c()+")",p="y=[("+a.join("), (")+")]";return"&&"==s||"||"==s||"IS"==s||"IS NULL"==s||"IS NOT NULL"==s?"("+p+", "+f+")":"("+p+", y.some(function(e){return e == null}) ? void 0 : "+f+")"},K.VarValue=function(e){return K.extend(this,e)},K.VarValue.prototype.toString=function(){return"@"+this.variable},K.VarValue.prototype.toType=function(){return"unknown"},K.VarValue.prototype.toJS=function(){return"alasql.vars['"+this.variable+"']"},K.NumValue=function(e){return K.extend(this,e)},K.NumValue.prototype.toString=function(){return this.value.toString()},K.NumValue.prototype.toType=function(){return"number"},K.NumValue.prototype.toJS=function(){return""+this.value},K.StringValue=function(e){return K.extend(this,e)},K.StringValue.prototype.toString=function(){return"'"+this.value.toString()+"'"},K.StringValue.prototype.toType=function(){return"string"},K.StringValue.prototype.toJS=function(){return"'"+R(this.value)+"'"},K.DomainValueValue=function(e){return K.extend(this,e)},K.DomainValueValue.prototype.toString=function(){return"VALUE"},K.DomainValueValue.prototype.toType=function(){return"object"},K.DomainValueValue.prototype.toJS=function(e,t,r){return e},K.ArrayValue=function(e){return K.extend(this,e)},K.ArrayValue.prototype.toString=function(){return"ARRAY[]"},K.ArrayValue.prototype.toType=function(){return"object"},K.ArrayValue.prototype.toJS=function(e,t,r){return"[("+this.value.map(function(n){return n.toJS(e,t,r)}).join("), (")+")]"},K.LogicValue=function(e){return K.extend(this,e)},K.LogicValue.prototype.toString=function(){return this.value?"TRUE":"FALSE"},K.LogicValue.prototype.toType=function(){return"boolean"},K.LogicValue.prototype.toJS=function(){return this.value?"true":"false"},K.NullValue=function(e){return K.extend(this,e)},K.NullValue.prototype.toString=function(){return"NULL"},K.NullValue.prototype.toJS=function(){return"undefined"},K.ParamValue=function(e){return K.extend(this,e)},K.ParamValue.prototype.toString=function(){return"$"+this.param},K.ParamValue.prototype.toJS=function(){return"string"==typeof this.param?"params['"+this.param+"']":"params["+this.param+"]"},K.UniOp=function(e){return K.extend(this,e)},K.UniOp.prototype.toString=function(){var e;return e=void 0,"~"===this.op&&(e=this.op+this.right.toString()),"-"===this.op&&(e=this.op+this.right.toString()),"+"===this.op&&(e=this.op+this.right.toString()),"#"===this.op&&(e=this.op+this.right.toString()),"NOT"===this.op&&(e=this.op+"("+this.right.toString()+")"),null===this.op&&(e="("+this.right.toString()+")"),e||(e="("+this.right.toString()+")"),e},K.UniOp.prototype.findAggregator=function(e){this.right.findAggregator&&this.right.findAggregator(e)},K.UniOp.prototype.toType=function(){return"-"===this.op?"number":"+"===this.op?"number":"NOT"===this.op?"boolean":void 0},K.UniOp.prototype.toJS=function(e,t,r){return"~"===this.op?"(~("+this.right.toJS(e,t,r)+"))":"-"===this.op?"(-("+this.right.toJS(e,t,r)+"))":"+"===this.op?"("+this.right.toJS(e,t,r)+")":"NOT"===this.op?"!("+this.right.toJS(e,t,r)+")":"#"===this.op?this.right instanceof K.Column?"(alasql.databases[alasql.useid].objects['"+this.right.columnid+"'])":"(alasql.databases[alasql.useid].objects["+this.right.toJS(e,t,r)+"])":null==this.op?"("+this.right.toJS(e,t,r)+")":void 0},K.Column=function(e){return K.extend(this,e)},K.Column.prototype.toString=function(e){var t;return t=this.columnid==+this.columnid?"["+this.columnid+"]":this.columnid,this.tableid&&(t=+this.columnid===this.columnid?this.tableid+t:this.tableid+"."+t,this.databaseid&&(t=this.databaseid+"."+t)),this.alias&&!e&&(t+=" AS "+this.alias),t},K.Column.prototype.toJS=function(e,t,r){var n="";if(this.tableid||""!==t||r)if("g"===e)n="g['"+this.nick+"']";else if(this.tableid)n="_"!==this.columnid?e+"['"+this.tableid+"']['"+this.columnid+"']":"g"===e?"g['_']":e+"['"+this.tableid+"']";else if(r){var a=r[this.columnid];if("-"===a)throw new Error('Cannot resolve column "'+this.columnid+'" because it exists in two source tables');n=a?"_"!==this.columnid?e+"['"+a+"']['"+this.columnid+"']":e+"['"+a+"']":"_"!==this.columnid?e+"['"+(this.tableid||t)+"']['"+this.columnid+"']":e+"['"+(this.tableid||t)+"']"}else n=-1===t?e+"['"+this.columnid+"']":"_"!==this.columnid?e+"['"+(this.tableid||t)+"']['"+this.columnid+"']":e+"['"+(this.tableid||t)+"']";else n="_"!==this.columnid?e+"['"+this.columnid+"']":"g"===e?"g['_']":e;return n},K.AggrValue=function(e){return K.extend(this,e)},K.AggrValue.prototype.toString=function(e){var t="";return"REDUCE"===this.aggregatorid?t+=this.funcid+"(":t+=this.aggregatorid+"(",this.distinct&&(t+="DISTINCT "),this.expression&&(t+=this.expression.toString()),t+=")",this.over&&(t+=" "+this.over.toString()),this.alias&&!e&&(t+=" AS "+this.alias),t},K.AggrValue.prototype.findAggregator=function(e){var t=R(this.toString())+":"+e.selectGroup.length,r=!1;if(!r){if(!this.nick){this.nick=t;for(var r=!1,n=0;n<e.removeKeys.length;n++)if(e.removeKeys[n]===t){r=!0;break}r||e.removeKeys.push(t)}e.selectGroup.push(this)}},K.AggrValue.prototype.toType=function(){return["SUM","COUNT","AVG","MIN","MAX","AGGR","VAR","STDDEV"].indexOf(this.aggregatorid)>-1?"number":["ARRAY"].indexOf(this.aggregatorid)>-1?"array":["FIRST","LAST"].indexOf(this.aggregatorid)>-1?this.expression.toType():void 0},K.AggrValue.prototype.toJS=function(){var e=this.nick;return void 0===e&&(e=this.toString()),"g['"+e+"']"},K.OrderExpression=function(e){return K.extend(this,e)},K.OrderExpression.prototype.toString=K.Expression.prototype.toString,K.GroupExpression=function(e){return K.extend(this,e)},K.GroupExpression.prototype.toString=function(){return this.type+"("+this.group.toString()+")"},K.FromData=function(e){return K.extend(this,e)},K.FromData.prototype.toString=function(){return this.data?"DATA("+(1e16*Math.random()|0)+")":"?"},K.FromData.prototype.toJS=function(){},K.Select.prototype.exec=function(e,t){this.preparams&&(e=this.preparams.concat(e));var r=A.useid;db=A.databases[r];var n=this.toString(),a=D(n),s=this.compile(r);if(s){s.sql=n,s.dbversion=db.dbversion,db.sqlCacheSize>A.MAXSQLCACHESIZE&&db.resetSqlCache(),db.sqlCacheSize++,db.sqlCache[a]=s;return A.res=s(e,t)}},K.Select.prototype.Select=function(){var e=this;if(arguments.length>1)args=Array.prototype.slice.call(arguments);else{if(1!=arguments.length)throw new Error("Wrong number of arguments of Select() function");Array.isArray(arguments[0])?args=arguments[0]:args=[arguments[0]]}return e.columns=[],args.forEach(function(t){if("string"==typeof t)e.columns.push(new K.Column({columnid:t}));else if("function"==typeof t){var r=0;e.preparams?r=e.preparams.length:e.preparams=[],e.preparams.push(t),e.columns.push(new K.Column({columnid:"*",func:t,param:r}))}}),e},K.Select.prototype.From=function(e){var t=this;if(t.from||(t.from=[]),Array.isArray(e)){var r=0;t.preparams?r=t.preparams.length:t.preparams=[],t.preparams.push(e),t.from.push(new K.ParamValue({param:r}))}else{if("string"!=typeof e)throw new Error("Unknown arguments in From() function");t.from.push(new K.Table({tableid:e}))}return t},K.Select.prototype.OrderBy=function(){var e=this;if(e.order=[],0==arguments.length)args=["_"];else if(arguments.length>1)args=Array.prototype.slice.call(arguments);else{if(1!=arguments.length)throw new Error("Wrong number of arguments of Select() function");Array.isArray(arguments[0])?args=arguments[0]:args=[arguments[0]]}return args.length>0&&args.forEach(function(t){var r=new K.Column({columnid:t});"function"==typeof t&&(r=t),e.order.push(new K.OrderExpression({expression:r,direction:"ASC"}))}),e},K.Select.prototype.Top=function(e){var t=this;return t.top=new K.NumValue({value:e}),t},K.Select.prototype.GroupBy=function(){var e=this;if(arguments.length>1)args=Array.prototype.slice.call(arguments);else{if(1!=arguments.length)throw new Error("Wrong number of arguments of Select() function");Array.isArray(arguments[0])?args=arguments[0]:args=[arguments[0]]}return e.group=[],args.forEach(function(t){var r=new K.Column({columnid:t});e.group.push(r)}),e},K.Select.prototype.Where=function(e){var t=this;return"function"==typeof e&&(t.where=e),t},K.FuncValue=function(e){return K.extend(this,e)},K.FuncValue.prototype.toString=function(e){var t="";return A.fn[this.funcid]?t+=this.funcid:A.aggr[this.funcid]?t+=this.funcid:(A.stdlib[this.funcid.toUpperCase()]||A.stdfn[this.funcid.toUpperCase()])&&(t+=this.funcid.toUpperCase()),t+="(",this.args&&this.args.length>0&&(t+=this.args.map(function(e){return e.toString()}).join(",")),t+=")",this.as&&!e&&(t+=" AS "+this.as.toString()),t},K.FuncValue.prototype.execute=function(e,t,r){var n=1;return A.precompile(this,e,t),new Function("params,alasql","var y;return "+this.toJS("","",null))(t,A),r&&(n=r(n)),n},K.FuncValue.prototype.findAggregator=function(e){this.args&&this.args.length>0&&this.args.forEach(function(t){t.findAggregator&&t.findAggregator(e)})},K.FuncValue.prototype.toJS=function(e,t,r){var n="",a=this.funcid;return!A.fn[a]&&A.stdlib[a.toUpperCase()]?this.args&&this.args.length>0?n+=A.stdlib[a.toUpperCase()].apply(this,this.args.map(function(r){return r.toJS(e,t)})):n+=A.stdlib[a.toUpperCase()]():!A.fn[a]&&A.stdfn[a.toUpperCase()]?(this.newid&&(n+="new "),n+="alasql.stdfn."+this.funcid.toUpperCase()+"(",this.args&&this.args.length>0&&(n+=this.args.map(function(n){return n.toJS(e,t,r)}).join(",")),n+=")"):(this.newid&&(n+="new "),n+="alasql.fn."+this.funcid+"(",this.args&&this.args.length>0&&(n+=this.args.map(function(n){return n.toJS(e,t,r)}).join(",")),n+=")"),n};var ae=A.stdlib={},se=A.stdfn={};ae.ABS=function(e){return"Math.abs("+e+")"},ae.CLONEDEEP=function(e){return"alasql.utils.cloneDeep("+e+")"},se.CONCAT=function(){return Array.prototype.slice.call(arguments).join("")},ae.EXP=function(e){return"Math.pow(Math.E,"+e+")"},ae.IIF=function(e,t,r){if(3==arguments.length)return"(("+e+")?("+t+"):("+r+"))";throw new Error("Number of arguments of IFF is not equals to 3")},ae.IFNULL=function(e,t){return"("+e+"||"+t+")"},ae.INSTR=function(e,t){return"(("+e+").indexOf("+t+")+1)"},ae.LEN=ae.LENGTH=function(e){return t(e,"y.length")},ae.LOWER=ae.LCASE=function(e){return t(e,"String(y).toLowerCase()")},ae.LTRIM=function(e){return t(e,'y.replace(/^[ ]+/,"")')},ae.RTRIM=function(e){return t(e,'y.replace(/[ ]+$/,"")')},ae.MAX=ae.GREATEST=function(){return"Math.max("+Array.prototype.join.call(arguments,",")+")"},ae.MIN=ae.LEAST=function(){return"Math.min("+Array.prototype.join.call(arguments,",")+")"},ae.SUBSTRING=ae.SUBSTR=ae.MID=function(e,r,n){return 2==arguments.length?t(e,"y.substr("+r+"-1)"):3==arguments.length?t(e,"y.substr("+r+"-1,"+n+")"):void 0},se.REGEXP_LIKE=function(e,t,r){return(e||"").search(RegExp(t,r))>-1},ae.ISNULL=ae.NULLIF=function(e,t){return"("+e+"=="+t+"?undefined:"+e+")"},ae.POWER=function(e,t){return"Math.pow("+e+","+t+")"},ae.RANDOM=function(e){return 0==arguments.length?"Math.random()":"(Math.random()*("+e+")|0)"},ae.ROUND=function(e,t){return 2==arguments.length?"Math.round(("+e+")*Math.pow(10,("+t+")))/Math.pow(10,("+t+"))":"Math.round("+e+")"},ae.CEIL=ae.CEILING=function(e){return"Math.ceil("+e+")"},ae.FLOOR=function(e){return"Math.floor("+e+")"},ae.ROWNUM=function(){return"1"},ae.ROW_NUMBER=function(){return"1"},ae.SQRT=function(e){return"Math.sqrt("+e+")"},ae.TRIM=function(e){return t(e,"y.trim()")},ae.UPPER=ae.UCASE=function(e){return t(e,"String(y).toUpperCase()")},se.CONCAT_WS=function(){return args=Array.prototype.slice.call(arguments),args.slice(1,args.length).join(args[0])},A.aggr.GROUP_CONCAT=function(e,t,r){return 1==r?e:2==r?t+","+e:void 0},A.aggr.MEDIAN=function(e,t,r){if(2===r)return null!==e&&t.push(e),t;if(1===r)return null===e?[]:[e];if(!t.length)return t;var n=t.sort(),a=(n.length+1)/2;return Number.isInteger(a)?n[a-1]:(n[Math.floor(a-1)]+n[Math.ceil(a-1)])/2},A.aggr.QUART=function(e,t,r,n){if(2===r)return null!==e&&t.push(e),t;if(1===r)return null===e?[]:[e];if(!t.length)return t;n=n||1;var a=t.sort(),s=n*(a.length+1)/4;return Number.isInteger(s)?a[s-1]:a[Math.floor(s)]},A.aggr.QUART2=function(e,t,r){return A.aggr.QUART(e,t,r,2)},A.aggr.QUART3=function(e,t,r){return A.aggr.QUART(e,t,r,3)},A.aggr.VAR=function(e,t,r){if(1===r)return null===e?{arr:[],sum:0}:{arr:[e],sum:e};if(2===r)return null===e?t:(t.arr.push(e),t.sum+=e,t);for(var n=t.arr.length,a=t.sum/n,s=0,i=0;i<n;i++)s+=(t.arr[i]-a)*(t.arr[i]-a);return s/=n-1},A.aggr.STDEV=function(e,t,r){return 1===r||2===r?A.aggr.VAR(e,t,r):Math.sqrt(A.aggr.VAR(e,t,r))},A.aggr.VARP=function(e,t,r){if(1==r)return{arr:[e],sum:e};if(2==r)return t.arr.push(e),t.sum+=e,t;for(var n=t.arr.length,a=t.sum/n,s=0,i=0;i<n;i++)s+=(t.arr[i]-a)*(t.arr[i]-a);return s/=n},A.aggr.STD=A.aggr.STDDEV=A.aggr.STDEVP=function(e,t,r){return 1==r||2==r?A.aggr.VARP(e,t,r):Math.sqrt(A.aggr.VARP(e,t,r))},A._aggrOriginal=A.aggr,A.aggr={},Object.keys(A._aggrOriginal).forEach(function(e){A.aggr[e]=function(t,r,n){if(3!==n||void 0!==r)return A._aggrOriginal[e].apply(null,arguments)}}),se.REPLACE=function(e,t,r){return(e||"").split(t).join(r)};for(var ie=[],oe=0;oe<256;oe++)ie[oe]=(oe<16?"0":"")+oe.toString(16);se.NEWID=se.UUID=se.GEN_RANDOM_UUID=function(){var e=4294967295*Math.random()|0,t=4294967295*Math.random()|0,r=4294967295*Math.random()|0,n=4294967295*Math.random()|0;return ie[255&e]+ie[e>>8&255]+ie[e>>16&255]+ie[e>>24&255]+"-"+ie[255&t]+ie[t>>8&255]+"-"+ie[t>>16&15|64]+ie[t>>24&255]+"-"+ie[63&r|128]+ie[r>>8&255]+"-"+ie[r>>16&255]+ie[r>>24&255]+ie[255&n]+ie[n>>8&255]+ie[n>>16&255]+ie[n>>24&255]},K.CaseValue=function(e){return K.extend(this,e)},K.CaseValue.prototype.toString=function(){var e="CASE ";return this.expression&&(e+=this.expression.toString()),this.whens&&(e+=this.whens.map(function(e){return" WHEN "+e.when.toString()+" THEN "+e.then.toString()}).join()),e+=" END"},K.CaseValue.prototype.findAggregator=function(e){this.expression&&this.expression.findAggregator&&this.expression.findAggregator(e),this.whens&&this.whens.length>0&&this.whens.forEach(function(t){t.when.findAggregator&&t.when.findAggregator(e),t.then.findAggregator&&t.then.findAggregator(e)}),this.elses&&this.elses.findAggregator&&this.elses.findAggregator(e)},K.CaseValue.prototype.toJS=function(e,t,r){var n="((function("+e+",params,alasql){var y,r;";return this.expression?(n+="v="+this.expression.toJS(e,t,r)+";",n+=(this.whens||[]).map(function(n){return" if(v=="+n.when.toJS(e,t,r)+") {r="+n.then.toJS(e,t,r)+"}"}).join(" else "),this.elses&&(n+=" else {r="+this.elses.toJS(e,t,r)+"}")):(n+=(this.whens||[]).map(function(n){return" if("+n.when.toJS(e,t,r)+") {r="+n.then.toJS(e,t,r)+"}"}).join(" else "),this.elses&&(n+=" else {r="+this.elses.toJS(e,t,r)+"}")),n+=";return r;}).bind(this))("+e+",params,alasql)"},K.Json=function(e){return K.extend(this,e)},K.Json.prototype.toString=function(){var e="";return e+=ue(this.value),e+=""};var ue=A.utils.JSONtoString=function(e){var t="";if("string"==typeof e)t='"'+e+'"';else if("number"==typeof e)t=e;else if("boolean"==typeof e)t=e;else{if("object"!=typeof e)throw new Error("2Can not show JSON object "+JSON.stringify(e));if(Array.isArray(e))t+="["+e.map(function(e){return ue(e)}).join(",")+"]";else if(!e.toJS||e instanceof K.Json){t="{";var r=[];for(var n in e){var a="";if("string"==typeof n)a+='"'+n+'"';else if("number"==typeof n)a+=n;else{if("boolean"!=typeof n)throw new Error("THis is not ES6... no expressions on left side yet");a+=n}a+=":"+ue(e[n]),r.push(a)}t+=r.join(",")+"}"}else{if(!e.toString)throw new Error("1Can not show JSON object "+JSON.stringify(e));t=e.toString()}}return t};K.Json.prototype.toJS=function(e,t,r){return E(this.value,e,t,r)},K.Convert=function(e){return K.extend(this,e)},K.Convert.prototype.toString=function(){var e="CONVERT(";return e+=this.dbtypeid,void 0!==this.dbsize&&(e+="("+this.dbsize,this.dbprecision&&(e+=","+dbprecision),e+=")"),e+=","+this.expression.toString(),this.style&&(e+=","+this.style),e+=")"},K.Convert.prototype.toJS=function(e,t,r){return"alasql.stdfn.CONVERT("+this.expression.toJS(e,t,r)+',{dbtypeid:"'+this.dbtypeid+'",dbsize:'+this.dbsize+",style:"+this.style+"})"},A.stdfn.CONVERT=function(e,t){var r=e;if(t.style){var n;switch(n=/\d{8}/.test(r)?new Date(+r.substr(0,4),+r.substr(4,2)-1,+r.substr(6,2)):new Date(r),t.style){case 1:r=("0"+(n.getMonth()+1)).substr(-2)+"/"+("0"+n.getDate()).substr(-2)+"/"+("0"+n.getYear()).substr(-2);break;case 2:r=("0"+n.getYear()).substr(-2)+"."+("0"+(n.getMonth()+1)).substr(-2)+"."+("0"+n.getDate()).substr(-2);break;case 3:r=("0"+n.getDate()).substr(-2)+"/"+("0"+(n.getMonth()+1)).substr(-2)+"/"+("0"+n.getYear()).substr(-2);break;case 4:r=("0"+n.getDate()).substr(-2)+"."+("0"+(n.getMonth()+1)).substr(-2)+"."+("0"+n.getYear()).substr(-2);break;case 5:r=("0"+n.getDate()).substr(-2)+"-"+("0"+(n.getMonth()+1)).substr(-2)+"-"+("0"+n.getYear()).substr(-2);break;case 6:r=("0"+n.getDate()).substr(-2)+" "+n.toString().substr(4,3).toLowerCase()+" "+("0"+n.getYear()).substr(-2);break;case 7:r=n.toString().substr(4,3)+" "+("0"+n.getDate()).substr(-2)+","+("0"+n.getYear()).substr(-2);break;case 8:case 108:r=("0"+n.getHours()).substr(-2)+":"+("0"+n.getMinutes()).substr(-2)+":"+("0"+n.getSeconds()).substr(-2);break;case 10:r=("0"+(n.getMonth()+1)).substr(-2)+"-"+("0"+n.getDate()).substr(-2)+"-"+("0"+n.getYear()).substr(-2);break;case 11:r=("0"+n.getYear()).substr(-2)+"/"+("0"+(n.getMonth()+1)).substr(-2)+"/"+("0"+n.getDate()).substr(-2);break;case 12:r=("0"+n.getYear()).substr(-2)+("0"+(n.getMonth()+1)).substr(-2)+("0"+n.getDate()).substr(-2);break;case 101:r=("0"+(n.getMonth()+1)).substr(-2)+"/"+("0"+n.getDate()).substr(-2)+"/"+n.getFullYear();break;case 102:r=n.getFullYear()+"."+("0"+(n.getMonth()+1)).substr(-2)+"."+("0"+n.getDate()).substr(-2);break;case 103:r=("0"+n.getDate()).substr(-2)+"/"+("0"+(n.getMonth()+1)).substr(-2)+"/"+n.getFullYear();break;case 104:r=("0"+n.getDate()).substr(-2)+"."+("0"+(n.getMonth()+1)).substr(-2)+"."+n.getFullYear();break;case 105:r=("0"+n.getDate()).substr(-2)+"-"+("0"+(n.getMonth()+1)).substr(-2)+"-"+n.getFullYear();break;case 106:r=("0"+n.getDate()).substr(-2)+" "+n.toString().substr(4,3).toLowerCase()+" "+n.getFullYear();break;case 107:r=n.toString().substr(4,3)+" "+("0"+n.getDate()).substr(-2)+","+n.getFullYear();break;case 110:r=("0"+(n.getMonth()+1)).substr(-2)+"-"+("0"+n.getDate()).substr(-2)+"-"+n.getFullYear();break;case 111:r=n.getFullYear()+"/"+("0"+(n.getMonth()+1)).substr(-2)+"/"+("0"+n.getDate()).substr(-2);break;case 112:r=n.getFullYear()+("0"+(n.getMonth()+1)).substr(-2)+("0"+n.getDate()).substr(-2);break;default:throw new Error("The CONVERT style "+t.style+" is not realized yet.")}}var a=t.dbtypeid.toUpperCase();if("Date"==t.dbtypeid)return new Date(r);if("DATE"==a){var s=new Date(r),i=s.getFullYear()+"."+("0"+(s.getMonth()+1)).substr(-2)+"."+("0"+s.getDate()).substr(-2);return i}if("DATETIME"==a||"DATETIME2"==a){var s=new Date(r),i=s.getFullYear()+"."+("0"+(s.getMonth()+1)).substr(-2)+"."+("0"+s.getDate()).substr(-2);return i+=" "+("0"+s.getHours()).substr(-2)+":"+("0"+s.getMinutes()).substr(-2)+":"+("0"+s.getSeconds()).substr(-2),i+="."+("00"+s.getMilliseconds()).substr(-3)}if(["MONEY"].indexOf(a)>-1){var o=+r;return(0|o)+100*o%100/100}if(["BOOLEAN"].indexOf(a)>-1)return!!r;if(["INT","INTEGER","SMALLINT","BIGINT","SERIAL","SMALLSERIAL","BIGSERIAL"].indexOf(t.dbtypeid.toUpperCase())>-1)return 0|r;if(["STRING","VARCHAR","NVARCHAR","CHARACTER VARIABLE"].indexOf(t.dbtypeid.toUpperCase())>-1)return t.dbsize?(""+r).substr(0,t.dbsize):""+r;if(["CHAR","CHARACTER","NCHAR"].indexOf(a)>-1)return(r+new Array(t.dbsize+1).join(" ")).substr(0,t.dbsize);if(["NUMBER","FLOAT"].indexOf(a)>-1){if(void 0!==t.dbprecision){var o=+r,u=Math.pow(10,t.dbprecision);return(0|o)+o*u%u/u}return+r}if(["DECIMAL","NUMERIC"].indexOf(a)>-1){var o=+r,u=Math.pow(10,t.dbprecision);return(0|o)+o*u%u/u}if(["JSON"].indexOf(a)>-1){if("object"==typeof r)return r;try{return JSON.parse(r)}catch(e){throw new Error("Cannot convert string to JSON")}}return r},K.ColumnDef=function(e){return K.extend(this,e)},K.ColumnDef.prototype.toString=function(){var e=this.columnid;return this.dbtypeid&&(e+=" "+this.dbtypeid),this.dbsize&&(e+="("+this.dbsize,this.dbprecision&&(e+=","+this.dbprecision),e+=")"),this.primarykey&&(e+=" PRIMARY KEY"),this.notnull&&(e+=" NOT NULL"),e},K.CreateTable=function(e){return K.extend(this,e)},K.CreateTable.prototype.toString=function(){var e="CREATE";if(this.temporary&&(e+=" TEMPORARY"),this.view?e+=" VIEW":e+=" "+(this.class?"CLASS":"TABLE"),this.ifnotexists&&(e+=" IF  NOT EXISTS"),e+=" "+this.table.toString(),this.viewcolumns&&(e+="("+this.viewcolumns.map(function(e){return e.toString()}).join(",")+")"),this.as)e+=" AS "+this.as;else{e+=" ("+this.columns.map(function(e){return e.toString()}).join(",")+")"}return this.view&&this.select&&(e+=" AS "+this.select.toString()),e},K.CreateTable.prototype.execute=function(e,t,r){var n=A.databases[this.table.databaseid||e],a=this.table.tableid;if(!a)throw new Error("Table name is not defined");var s=this.columns,i=this.constraints||[];if(this.ifnotexists&&n.tables[a])return r?r(0):0;if(n.tables[a])throw new Error("Can not create table '"+a+"', because it already exists in the database '"+n.databaseid+"'");var o=n.tables[a]=new A.Table;this.class&&(o.isclass=!0);var u=[],c=[];if(s&&s.forEach(function(t){var r=t.dbtypeid;A.fn[r]||(r=r.toUpperCase()),["SERIAL","SMALLSERIAL","BIGSERIAL"].indexOf(r)>-1&&(t.identity={value:1,step:1});var n={columnid:t.columnid,dbtypeid:r,dbsize:t.dbsize,dbprecision:t.dbprecision,notnull:t.notnull,identity:t.identity};if(t.identity&&(o.identities[t.columnid]={value:+t.identity.value,step:+t.identity.step}),t.check&&o.checks.push({id:t.check.constrantid,fn:new Function("r","var y;return "+t.check.expression.toJS("r",""))}),t.default&&u.push("'"+t.columnid+"':"+t.default.toJS("r","")),t.primarykey){var a=o.pk={};a.columns=[t.columnid],a.onrightfns="r['"+t.columnid+"']",a.onrightfn=new Function("r","var y;return "+a.onrightfns),a.hh=D(a.onrightfns),o.uniqs[a.hh]={}}if(t.unique){var s={};o.uk=o.uk||[],o.uk.push(s),s.columns=[t.columnid],s.onrightfns="r['"+t.columnid+"']",s.onrightfn=new Function("r","var y;return "+s.onrightfns),s.hh=D(s.onrightfns),o.uniqs[s.hh]={}}if(t.foreignkey){var i=t.foreignkey.table,l=A.databases[i.databaseid||e].tables[i.tableid];if(void 0===i.columnid){if(!(l.pk.columns&&l.pk.columns.length>0))throw new Error("FOREIGN KEY allowed only to tables with PRIMARY KEYs");i.columnid=l.pk.columns[0]}var h=function(e){var r={};if(void 0===e[t.columnid])return!0;r[i.columnid]=e[t.columnid];var n=l.pk.onrightfn(r);if(!l.uniqs[l.pk.hh][n])throw new Error('Foreign key "'+e[t.columnid]+'" is not found in table '+l.tableid);return!0};o.checks.push({fn:h})}t.onupdate&&c.push("r['"+t.columnid+"']="+t.onupdate.toJS("r","")),o.columns.push(n),o.xcolumns[n.columnid]=n}),o.defaultfns=u.join(","),o.onupdatefns=c.join(";"),i.forEach(function(t){var r;if("PRIMARY KEY"===t.type){if(o.pk)throw new Error("Primary key already exists");var n=o.pk={};n.columns=t.columns,n.onrightfns=n.columns.map(function(e){return"r['"+e+"']"}).join("+'`'+"),n.onrightfn=new Function("r","var y;return "+n.onrightfns),n.hh=D(n.onrightfns),o.uniqs[n.hh]={}}else if("CHECK"===t.type)r=new Function("r","var y;return "+t.expression.toJS("r",""));else if("UNIQUE"===t.type){var a={};o.uk=o.uk||[],o.uk.push(a),a.columns=t.columns,a.onrightfns=a.columns.map(function(e){return"r['"+e+"']"}).join("+'`'+"),a.onrightfn=new Function("r","var y;return "+a.onrightfns),a.hh=D(a.onrightfns),o.uniqs[a.hh]={}}else if("FOREIGN KEY"===t.type){var s=o.xcolumns[t.columns[0]],i=t.fktable;t.fkcolumns&&t.fkcolumns.length>0&&(i.columnid=t.fkcolumns[0]);var u=A.databases[i.databaseid||e].tables[i.tableid];void 0===i.columnid&&(i.columnid=u.pk.columns[0]),r=function(e){var t={};if(void 0===e[s.columnid])return!0;t[i.columnid]=e[s.columnid];var r=u.pk.onrightfn(t);if(!u.uniqs[u.pk.hh][r])throw new Error('Foreign key "'+e[s.columnid]+'" is not found in table '+u.tableid);return!0}}r&&o.checks.push({fn:r,id:t.constraintid,fk:"FOREIGN KEY"===t.type})}),this.view&&this.viewcolumns){var l=this;this.viewcolumns.forEach(function(e,t){l.select.columns[t].as=e.columnid})}if(this.view&&this.select&&(o.view=!0,o.select=this.select.compile(this.table.databaseid||e)),n.engineid)return A.engines[n.engineid].createTable(this.table.databaseid||e,a,this.ifnotexists,r);o.insert=function(r,n){var a=A.inserted;A.inserted=[r];var s=this,i=!1,o=!1;for(var u in s.beforeinsert){var c=s.beforeinsert[u];c&&(c.funcid?!1===A.fn[c.funcid](r)&&(o=o||!0):c.statement&&!1===c.statement.execute(e)&&(o=o||!0))}if(!o){var l=!1;for(var u in s.insteadofinsert){l=!0;var c=s.insteadofinsert[u];c&&(c.funcid?A.fn[c.funcid](r):c.statement&&c.statement.execute(e))}if(!l){for(var h in s.identities){var d=s.identities[h];r[h]=d.value}if(s.checks&&s.checks.length>0&&s.checks.forEach(function(e){if(!e.fn(r))throw new Error("Violation of CHECK constraint "+(e.id||""))}),s.columns.forEach(function(e){if(e.notnull&&void 0===r[e.columnid])throw new Error("Wrong NULL value in NOT NULL column "+e.columnid)}),s.pk){var f=s.pk,p=f.onrightfn(r);if(void 0!==s.uniqs[f.hh][p]){if(!n)throw new Error("Cannot insert record, because it already exists in primary key index");i=s.uniqs[f.hh][p]}}
-if(s.uk&&s.uk.length&&s.uk.forEach(function(e){var t=e.onrightfn(r);if(void 0!==s.uniqs[e.hh][t]){if(!n)throw new Error("Cannot insert record, because it already exists in unique index");i=s.uniqs[e.hh][t]}}),i)s.update(function(e){for(var t in r)e[t]=r[t]},s.data.indexOf(i),t);else{s.data.push(r);for(var h in s.identities){var d=s.identities[h];d.value+=d.step}if(s.pk){var f=s.pk,p=f.onrightfn(r);s.uniqs[f.hh][p]=r}s.uk&&s.uk.length&&s.uk.forEach(function(e){var t=e.onrightfn(r);s.uniqs[e.hh][t]=r})}for(var u in s.afterinsert){var c=s.afterinsert[u];c&&(c.funcid?A.fn[c.funcid](r):c.statement&&c.statement.execute(e))}A.inserted=a}}},o.delete=function(t){var r=this,n=r.data[t],a=!1;for(var s in r.beforedelete){var i=r.beforedelete[s];i&&(i.funcid?!1===A.fn[i.funcid](n)&&(a=a||!0):i.statement&&!1===i.statement.execute(e)&&(a=a||!0))}if(a)return!1;var o=!1;for(var s in r.insteadofdelete){o=!0;var i=r.insteadofdelete[s];i&&(i.funcid?A.fn[i.funcid](n):i.statement&&i.statement.execute(e))}if(!o){if(this.pk){var u=this.pk,c=u.onrightfn(n);if(void 0===this.uniqs[u.hh][c])throw new Error("Something wrong with primary key index on table");this.uniqs[u.hh][c]=void 0}r.uk&&r.uk.length&&r.uk.forEach(function(e){var t=e.onrightfn(n);if(void 0===r.uniqs[e.hh][t])throw new Error("Something wrong with unique index on table");r.uniqs[e.hh][t]=void 0})}},o.deleteall=function(){this.data.length=0,this.pk&&(this.uniqs[this.pk.hh]={}),o.uk&&o.uk.length&&o.uk.forEach(function(e){o.uniqs[e.hh]={}})},o.update=function(t,r,n){var a,s=F(this.data[r]);if(this.pk&&(a=this.pk,a.pkaddr=a.onrightfn(s,n),void 0===this.uniqs[a.hh][a.pkaddr]))throw new Error("Something wrong with index on table");o.uk&&o.uk.length&&o.uk.forEach(function(e){if(e.ukaddr=e.onrightfn(s),void 0===o.uniqs[e.hh][e.ukaddr])throw new Error("Something wrong with unique index on table")}),t(s,n,A);var i=!1;for(var u in o.beforeupdate){var c=o.beforeupdate[u];c&&(c.funcid?!1===A.fn[c.funcid](this.data[r],s)&&(i=i||!0):c.statement&&!1===c.statement.execute(e)&&(i=i||!0))}if(i)return!1;var l=!1;for(var u in o.insteadofupdate){l=!0;var c=o.insteadofupdate[u];c&&(c.funcid?A.fn[c.funcid](this.data[r],s):c.statement&&c.statement.execute(e))}if(!l){if(o.checks&&o.checks.length>0&&o.checks.forEach(function(e){if(!e.fn(s))throw new Error("Violation of CHECK constraint "+(e.id||""))}),o.columns.forEach(function(e){if(e.notnull&&void 0===s[e.columnid])throw new Error("Wrong NULL value in NOT NULL column "+e.columnid)}),this.pk&&(a.newpkaddr=a.onrightfn(s),void 0!==this.uniqs[a.hh][a.newpkaddr]&&a.newpkaddr!==a.pkaddr))throw new Error("Record already exists");o.uk&&o.uk.length&&o.uk.forEach(function(e){if(e.newukaddr=e.onrightfn(s),void 0!==o.uniqs[e.hh][e.newukaddr]&&e.newukaddr!==e.ukaddr)throw new Error("Record already exists")}),this.pk&&(this.uniqs[a.hh][a.pkaddr]=void 0,this.uniqs[a.hh][a.newpkaddr]=s),o.uk&&o.uk.length&&o.uk.forEach(function(e){o.uniqs[e.hh][e.ukaddr]=void 0,o.uniqs[e.hh][e.newukaddr]=s}),this.data[r]=s;for(var u in o.afterupdate){var c=o.afterupdate[u];c&&(c.funcid?A.fn[c.funcid](this.data[r],s):c.statement&&c.statement.execute(e))}}};var h;return A.options.nocount||(h=1),r&&(h=r(h)),h},A.fn.Date=Object,A.fn.Date=Date,A.fn.Number=Number,A.fn.String=String,A.fn.Boolean=Boolean,se.EXTEND=A.utils.extend,se.CHAR=String.fromCharCode.bind(String),se.ASCII=function(e){return e.charCodeAt(0)},se.COALESCE=function(){for(var e=0;e<arguments.length;e++)if(void 0!==arguments[e]&&("number"!=typeof arguments[e]||!isNaN(arguments[e])))return arguments[e]},se.USER=function(){return"alasql"},se.OBJECT_ID=function(e){return!!A.tables[e]},se.DATE=function(e){return/\d{8}/.test(e)?new Date(+e.substr(0,4),+e.substr(4,2)-1,+e.substr(6,2)):new Date(e)},se.NOW=function(){var e=new Date,t=e.getFullYear()+"."+("0"+(e.getMonth()+1)).substr(-2)+"."+("0"+e.getDate()).substr(-2);return t+=" "+("0"+e.getHours()).substr(-2)+":"+("0"+e.getMinutes()).substr(-2)+":"+("0"+e.getSeconds()).substr(-2),t+="."+("00"+e.getMilliseconds()).substr(-3)},se.GETDATE=se.NOW,se.CURRENT_TIMESTAMP=se.NOW,se.SECOND=function(e){var e=new Date(e);return e.getSeconds()},se.MINUTE=function(e){var e=new Date(e);return e.getMinutes()},se.HOUR=function(e){var e=new Date(e);return e.getHours()},se.DAYOFWEEK=se.WEEKDAY=function(e){var e=new Date(e);return e.getDay()},se.DAY=se.DAYOFMONTH=function(e){var e=new Date(e);return e.getDate()},se.MONTH=function(e){var e=new Date(e);return e.getMonth()+1},se.YEAR=function(e){var e=new Date(e);return e.getFullYear()};var ce={year:31536e6,quarter:7884e6,month:2592e6,week:6048e5,day:864e5,dayofyear:864e5,weekday:864e5,hour:36e5,minute:6e4,second:1e3,millisecond:1,microsecond:.001};A.stdfn.DATEDIFF=function(e,t,r){return(new Date(r).getTime()-new Date(t).getTime())/ce[e.toLowerCase()]},A.stdfn.DATEADD=function(e,t,r){var n=new Date(r).getTime()+t*ce[e.toLowerCase()];return new Date(n)},A.stdfn.INTERVAL=function(e,t){return e*ce[t.toLowerCase()]},A.stdfn.DATE_ADD=A.stdfn.ADDDATE=function(e,t){var r=new Date(e).getTime()+t;return new Date(r)},A.stdfn.DATE_SUB=A.stdfn.SUBDATE=function(e,t){var r=new Date(e).getTime()-t;return new Date(r)},K.DropTable=function(e){return K.extend(this,e)},K.DropTable.prototype.toString=function(){var e="DROP ";return this.view?e+="VIEW":e+="TABLE",this.ifexists&&(e+=" IF EXISTS"),e+=" "+this.tables.toString()},K.DropTable.prototype.execute=function(e,t,r){var n=this.ifexists,a=0,s=0,i=this.tables.length;return this.tables.forEach(function(t){var o=A.databases[t.databaseid||e],u=t.tableid;if(!n||n&&o.tables[u]){if(o.tables[u])o.engineid?A.engines[o.engineid].dropTable(t.databaseid||e,u,n,function(e){delete o.tables[u],a+=e,++s==i&&r&&r(a)}):(delete o.tables[u],a++,++s==i&&r&&r(a));else if(!A.options.dropifnotexists)throw new Error("Can not drop table '"+t.tableid+"', because it does not exist in the database.")}else++s==i&&r&&r(a)}),a},K.TruncateTable=function(e){return K.extend(this,e)},K.TruncateTable.prototype.toString=function(){var e="TRUNCATE TABLE";return e+=" "+this.table.toString()},K.TruncateTable.prototype.execute=function(e,t,r){var n=A.databases[this.table.databaseid||e],a=this.table.tableid;if(n.engineid)return A.engines[n.engineid].truncateTable(this.table.databaseid||e,a,this.ifexists,r);if(!n.tables[a])throw new Error("Cannot truncate table becaues it does not exist");return n.tables[a].data=[],r?r(0):0},K.CreateVertex=function(e){return K.extend(this,e)},K.CreateVertex.prototype.toString=function(){var e="CREATE VERTEX ";return this.class&&(e+=this.class+" "),this.sharp&&(e+="#"+this.sharp+" "),this.sets?e+=this.sets.toString():this.content?e+=this.content.toString():this.select&&(e+=this.select.toString()),e},K.CreateVertex.prototype.toJS=function(e){return"this.queriesfn["+(this.queriesidx-1)+"](this.params,null,"+e+")"},K.CreateVertex.prototype.compile=function(e){var t=e,r=this.sharp;if(void 0!==this.name)var n="x.name="+this.name.toJS(),a=new Function("x",n);if(this.sets&&this.sets.length>0)var n=this.sets.map(function(e){return"x['"+e.column.columnid+"']="+e.expression.toJS("x","")}).join(";"),s=new Function("x,params,alasql",n);return function(e,n){var i,o,u=A.databases[t];o=void 0!==r?r:u.counter++;var c={$id:o,$node:"VERTEX"};return u.objects[c.$id]=c,i=c,a&&a(c),s&&s(c,e,A),n&&(i=n(i)),i}},K.CreateEdge=function(e){return K.extend(this,e)},K.CreateEdge.prototype.toString=function(){var e="CREATE EDGE ";return this.class&&(e+=this.class+" "),e},K.CreateEdge.prototype.toJS=function(e){return"this.queriesfn["+(this.queriesidx-1)+"](this.params,null,"+e+")"},K.CreateEdge.prototype.compile=function(e){var t=e,r=new Function("params,alasql","var y;return "+this.from.toJS()),n=new Function("params,alasql","var y;return "+this.to.toJS());if(void 0!==this.name)var a="x.name="+this.name.toJS(),s=new Function("x",a);if(this.sets&&this.sets.length>0)var a=this.sets.map(function(e){return"x['"+e.column.columnid+"']="+e.expression.toJS("x","")}).join(";"),i=new Function("x,params,alasql","var y;"+a);return function(e,a){var o=0,u=A.databases[t],c={$id:u.counter++,$node:"EDGE"},l=r(e,A),h=n(e,A);return c.$in=[l.$id],c.$out=[h.$id],void 0===l.$out&&(l.$out=[]),l.$out.push(c.$id),void 0===typeof h.$in&&(h.$in=[]),h.$in.push(c.$id),u.objects[c.$id]=c,o=c,s&&s(c),i&&i(c,e,A),a&&(o=a(o)),o}},K.CreateGraph=function(e){return K.extend(this,e)},K.CreateGraph.prototype.toString=function(){var e="CREATE GRAPH ";return this.class&&(e+=this.class+" "),e},K.CreateGraph.prototype.execute=function(e,t,r){function n(e){var t=A.databases[A.useid].objects;for(var r in t)if(t[r].name===e)return t[r]}function a(r){var n={};void 0!==r.as&&(A.vars[r.as]=n),void 0!==r.prop&&(n.$id=r.prop,n.name=r.prop),void 0!==r.sharp&&(n.$id=r.sharp),void 0!==r.name&&(n.name=r.name),void 0!==r.class&&(n.$class=r.class);var a=A.databases[e];if(void 0===n.$id&&(n.$id=a.counter++),n.$node="VERTEX",void 0!==r.json&&G(n,new Function("params,alasql","var y;return "+r.json.toJS())(t,A)),a.objects[n.$id]=n,void 0!==n.$class){if(void 0===A.databases[e].tables[n.$class])throw new Error("No such class. Pleace use CREATE CLASS");A.databases[e].tables[n.$class].data.push(n)}return s.push(n.$id),n}var s=[];return this.from&&A.from[this.from.funcid]&&(this.graph=A.from[this.from.funcid.toUpperCase()]),this.graph.forEach(function(r){if(r.source){var i={};void 0!==r.as&&(A.vars[r.as]=i),void 0!==r.prop&&(i.name=r.prop),void 0!==r.sharp&&(i.$id=r.sharp),void 0!==r.name&&(i.name=r.name),void 0!==r.class&&(i.$class=r.class);var o=A.databases[e];void 0===i.$id&&(i.$id=o.counter++),i.$node="EDGE",void 0!==r.json&&G(i,new Function("params,alasql","var y;return "+r.json.toJS())(t,A));var u;if(r.source.vars){var c=A.vars[r.source.vars];u="object"==typeof c?c:o.objects[c]}else{var l=r.source.sharp;void 0===l&&(l=r.source.prop),u=A.databases[e].objects[l],void 0!==u||!A.options.autovertex||void 0===r.source.prop&&void 0===r.source.name||void 0===(u=n(r.source.prop||r.source.name))&&(u=a(r.source))}var h;if(r.source.vars){var c=A.vars[r.target.vars];h="object"==typeof c?c:o.objects[c]}else{var d=r.target.sharp;void 0===d&&(d=r.target.prop),h=A.databases[e].objects[d],void 0!==h||!A.options.autovertex||void 0===r.target.prop&&void 0===r.target.name||void 0===(h=n(r.target.prop||r.target.name))&&(h=a(r.target))}if(i.$in=[u.$id],i.$out=[h.$id],void 0===u.$out&&(u.$out=[]),u.$out.push(i.$id),void 0===h.$in&&(h.$in=[]),h.$in.push(i.$id),o.objects[i.$id]=i,void 0!==i.$class){if(void 0===A.databases[e].tables[i.$class])throw new Error("No such class. Pleace use CREATE CLASS");A.databases[e].tables[i.$class].data.push(i)}s.push(i.$id)}else a(r)}),r&&(s=r(s)),s},K.CreateGraph.prototype.compile1=function(e){var t=e,r=new Function("params,alasql","var y;return "+this.from.toJS()),n=new Function("params,alasql","var y;return "+this.to.toJS());if(void 0!==this.name)var a="x.name="+this.name.toJS(),s=new Function("x",a);if(this.sets&&this.sets.length>0)var a=this.sets.map(function(e){return"x['"+e.column.columnid+"']="+e.expression.toJS("x","")}).join(";"),i=new Function("x,params,alasql","var y;"+a);return function(e,a){var o=0,u=A.databases[t],c={$id:u.counter++,$node:"EDGE"},l=r(e,A),h=n(e,A);return c.$in=[l.$id],c.$out=[h.$id],void 0===l.$out&&(l.$out=[]),l.$out.push(c.$id),void 0===h.$in&&(h.$in=[]),h.$in.push(c.$id),u.objects[c.$id]=c,o=c,s&&s(c),i&&i(c,e,A),a&&(o=a(o)),o}},K.AlterTable=function(e){return K.extend(this,e)},K.AlterTable.prototype.toString=function(){var e="ALTER TABLE "+this.table.toString();return this.renameto&&(e+=" RENAME TO "+this.renameto),e},K.AlterTable.prototype.execute=function(e,t,r){var n=A.databases[e];if(n.dbversion=Date.now(),this.renameto){var a=this.table.tableid,s=this.renameto,i=1;if(n.tables[s])throw new Error("Can not rename a table '"+a+"' to '"+s+"', because the table with this name already exists");if(s==a)throw new Error("Can not rename a table '"+a+"' to itself");return n.tables[s]=n.tables[a],delete n.tables[a],i=1,r&&r(i),i}if(this.addcolumn){var n=A.databases[this.table.databaseid||e];n.dbversion++;var o=this.table.tableid,u=n.tables[o],c=this.addcolumn.columnid;if(u.xcolumns[c])throw new Error('Cannot add column "'+c+'", because it already exists in the table "'+o+'"');var l={columnid:c,dbtypeid:this.dbtypeid,dbsize:this.dbsize,dbprecision:this.dbprecision,dbenum:this.dbenum,defaultfns:null};u.columns.push(l),u.xcolumns[c]=l;for(var h=0,d=u.data.length;h<d;h++)u.data[h][c]=void 0;return r?r(1):1}if(this.modifycolumn){var n=A.databases[this.table.databaseid||e];n.dbversion++;var o=this.table.tableid,u=n.tables[o],c=this.modifycolumn.columnid;if(!u.xcolumns[c])throw new Error('Cannot modify column "'+c+'", because it was not found in the table "'+o+'"');var l=u.xcolumns[c];return l.dbtypeid=this.dbtypeid,l.dbsize=this.dbsize,l.dbprecision=this.dbprecision,l.dbenum=this.dbenum,r?r(1):1}if(this.renamecolumn){var n=A.databases[this.table.databaseid||e];n.dbversion++;var l,o=this.table.tableid,u=n.tables[o],c=this.renamecolumn,f=this.to;if(!u.xcolumns[c])throw new Error('Column "'+c+'" is not found in the table "'+o+'"');if(u.xcolumns[f])throw new Error('Column "'+f+'" already exists in the table "'+o+'"');if(c!=f){for(var p=0;p<u.columns.length;p++)u.columns[p].columnid==c&&(u.columns[p].columnid=f);u.xcolumns[f]=u.xcolumns[c],delete u.xcolumns[c];for(var h=0,d=u.data.length;h<d;h++)u.data[h][f]=u.data[h][c],delete u.data[h][c];return u.data.length}return r?r(0):0}if(this.dropcolumn){var n=A.databases[this.table.databaseid||e];n.dbversion++;for(var o=this.table.tableid,u=n.tables[o],c=this.dropcolumn,b=!1,p=0;p<u.columns.length;p++)if(u.columns[p].columnid==c){b=!0,u.columns.splice(p,1);break}if(!b)throw new Error('Cannot drop column "'+c+'", because it was not found in the table "'+o+'"');delete u.xcolumns[c];for(var h=0,d=u.data.length;h<d;h++)delete u.data[h][c];return r?r(u.data.length):u.data.length}throw Error("Unknown ALTER TABLE method")},K.CreateIndex=function(e){return K.extend(this,e)},K.CreateIndex.prototype.toString=function(){var e="CREATE";return this.unique&&(e+=" UNIQUE"),e+=" INDEX "+this.indexid+" ON "+this.table.toString(),e+="("+this.columns.toString()+")"},K.CreateIndex.prototype.execute=function(e,t,r){var n=A.databases[e],a=this.table.tableid,s=n.tables[a],i=this.indexid;n.indices[i]=a;var o=this.columns.map(function(e){return e.expression.toJS("r","")}).join("+'`'+"),u=new Function("r,params,alasql","return "+o);if(this.unique){s.uniqdefs[i]={rightfns:o};var c=s.uniqs[i]={};if(s.data.length>0)for(var l=0,h=s.data.length;l<h;l++){var d=o(s.data[l]);c[d]||(c[d]={num:0}),c[d].num++}}else{var f=D(o);s.inddefs[i]={rightfns:o,hh:f},s.indices[f]={};var p=s.indices[f]={};if(s.data.length>0)for(var l=0,h=s.data.length;l<h;l++){var d=u(s.data[l],t,A);p[d]||(p[d]=[]),p[d].push(s.data[l])}}var b=1;return r&&(b=r(b)),b},K.Reindex=function(e){return K.extend(this,e)},K.Reindex.prototype.toString=function(){return"REINDEX "+this.indexid},K.Reindex.prototype.execute=function(e,t,r){var n=A.databases[e],a=this.indexid,s=n.indices[a];n.tables[s].indexColumns();var i=1;return r&&(i=r(i)),i},K.DropIndex=function(e){return K.extend(this,e)},K.DropIndex.prototype.toString=function(){return"DROP INDEX"+this.indexid},K.DropIndex.prototype.compile=function(e){this.indexid;return function(){return 1}},K.WithSelect=function(e){return K.extend(this,e)},K.WithSelect.prototype.toString=function(){var e="WITH ";return e+=this.withs.map(function(e){return e.name+" AS ("+e.select.toString()+")"}).join(",")+" ",e+=this.select.toString()},K.WithSelect.prototype.execute=function(e,t,r){var n=this,a=[];n.withs.forEach(function(r){a.push(A.databases[e].tables[r.name]),(A.databases[e].tables[r.name]=new W({tableid:r.name})).data=r.select.execute(e,t)});return this.select.execute(e,t,function(t){return n.withs.forEach(function(t,r){a[r]?A.databases[e].tables[t.name]=a[r]:delete A.databases[e].tables[t.name]}),r&&(t=r(t)),t})},K.If=function(e){return K.extend(this,e)},K.If.prototype.toString=function(){var e="IF ";return e+=this.expression.toString(),e+=" "+this.thenstat.toString(),this.elsestat&&(e+=" ELSE "+this.thenstat.toString()),e},K.If.prototype.execute=function(e,t,r){var n;return new Function("params,alasql,p","var y;return "+this.expression.toJS("({})","",null)).bind(this)(t,A)?n=this.thenstat.execute(e,t,r):this.elsestat?n=this.elsestat.execute(e,t,r):r&&(n=r(n)),n},K.While=function(e){return K.extend(this,e)},K.While.prototype.toString=function(){var e="WHILE ";return e+=this.expression.toString(),e+=" "+this.loopstat.toString()},K.While.prototype.execute=function(e,t,r){function n(u){o?s.push(u):o=!0,setTimeout(function(){i(t,A)?a.loopstat.execute(e,t,n):s=r(s)},0)}var a=this,s=[],i=new Function("params,alasql,p","var y;return "+this.expression.toJS());if(r){var o=!1;n()}else for(;i(t,A);){var u=a.loopstat.execute(e,t);s.push(u)}return s},K.Break=function(e){return K.extend(this,e)},K.Break.prototype.toString=function(){return"BREAK"},K.Break.prototype.execute=function(e,t,r,n){var a=1;return r&&(a=r(a)),a},K.Continue=function(e){return K.extend(this,e)},K.Continue.prototype.toString=function(){return"CONTINUE"},K.Continue.prototype.execute=function(e,t,r,n){var a=1;return r&&(a=r(a)),a},K.BeginEnd=function(e){return K.extend(this,e)},K.BeginEnd.prototype.toString=function(){return"BEGIN "+this.statements.toString()+" END"},K.BeginEnd.prototype.execute=function(e,t,r,n){function a(){s.statements[o].execute(e,t,function(e){if(i.push(e),++o<s.statements.length)return a();r&&(i=r(i))})}var s=this,i=[],o=0;return a(),i},K.Insert=function(e){return K.extend(this,e)},K.Insert.prototype.toString=function(){var e="INSERT ";return this.orreplace&&(e+="OR REPLACE "),this.replaceonly&&(e="REPLACE "),e+="INTO "+this.into.toString(),this.columns&&(e+="("+this.columns.toString()+")"),this.values&&(e+=" VALUES "+this.values.toString()),this.select&&(e+=" "+this.select.toString()),e},K.Insert.prototype.toJS=function(e,t,r){return"this.queriesfn["+(this.queriesidx-1)+"](this.params,null,"+e+")"},K.Insert.prototype.compile=function(e){var t=this;e=t.into.databaseid||e;var r=A.databases[e],n=t.into.tableid,a=r.tables[n];if(!a)throw"Table '"+n+"' could not be found";var s,i="",o="",i="db.tables['"+n+"'].dirty=true;",u="var a,aa=[],x;";if(this.values){this.exists&&(this.existsfn=this.exists.map(function(t){var r=t.compile(e);return r.query.modifier="RECORDSET",r})),this.queries&&(this.queriesfn=this.queries.map(function(t){var r=t.compile(e);return r.query.modifier="RECORDSET",r})),t.values.forEach(function(s){var u=[];t.columns?t.columns.forEach(function(e,t){var r="'"+e.columnid+"':";a.xcolumns&&a.xcolumns[e.columnid]?["INT","FLOAT","NUMBER","MONEY"].indexOf(a.xcolumns[e.columnid].dbtypeid)>=0?r+="(x="+s[t].toJS()+",x==undefined?undefined:+x)":A.fn[a.xcolumns[e.columnid].dbtypeid]?(r+="(new "+a.xcolumns[e.columnid].dbtypeid+"(",r+=s[t].toJS(),r+="))"):r+=s[t].toJS():r+=s[t].toJS(),u.push(r)}):Array.isArray(s)&&a.columns&&a.columns.length>0?a.columns.forEach(function(e,t){var r="'"+e.columnid+"':";["INT","FLOAT","NUMBER","MONEY"].indexOf(e.dbtypeid)>=0?r+="+"+s[t].toJS():A.fn[e.dbtypeid]?(r+="(new "+e.dbtypeid+"(",r+=s[t].toJS(),r+="))"):r+=s[t].toJS(),u.push(r)}):o=E(s),r.tables[n].defaultfns&&u.unshift(r.tables[n].defaultfns),i+=o?"a="+o+";":"a={"+u.join(",")+"};",r.tables[n].isclass&&(i+="var db=alasql.databases['"+e+"'];",i+='a.$class="'+n+'";',i+="a.$id=db.counter++;",i+="db.objects[a.$id]=a;"),r.tables[n].insert?(i+="var db=alasql.databases['"+e+"'];",i+="db.tables['"+n+"'].insert(a,"+(t.orreplace?"true":"false")+");"):i+="aa.push(a);"}),s=u+i,r.tables[n].insert||(i+="alasql.databases['"+e+"'].tables['"+n+"'].data=alasql.databases['"+e+"'].tables['"+n+"'].data.concat(aa);"),r.tables[n].insert&&r.tables[n].isclass?i+="return a.$id;":i+="return "+t.values.length;var c=new Function("db, params, alasql","var y;"+u+i).bind(this)}else if(this.select){this.select.modifier="RECORDSET";var l=this.select.compile(e);if(r.engineid&&A.engines[r.engineid].intoTable){var h=function(e,t){var a=l(e);return A.engines[r.engineid].intoTable(r.databaseid,n,a.data,null,t)};return h}var d="return alasql.utils.extend(r,{"+a.defaultfns+"})",f=new Function("r,db,params,alasql",d),c=function(e,r,a){var s=l(r).data;if(e.tables[n].insert)for(var i=0,o=s.length;i<o;i++){var u=F(s[i]);f(u,e,r,a),e.tables[n].insert(u,t.orreplace)}else e.tables[n].data=e.tables[n].data.concat(s);return a.options.nocount?void 0:s.length}}else{if(!this.default)throw new Error("Wrong INSERT parameters");var p="db.tables['"+n+"'].data.push({"+a.defaultfns+"});return 1;",c=new Function("db,params,alasql",p)}if(r.engineid&&A.engines[r.engineid].intoTable&&A.options.autocommit)var h=function(e,t){var a=new Function("db,params","var y;"+s+"return aa;")(r,e);return A.engines[r.engineid].intoTable(r.databaseid,n,a,null,t)};else var h=function(t,r){var a=A.databases[e];A.options.autocommit&&a.engineid&&A.engines[a.engineid].loadTableData(e,n);var s=c(a,t,A);return A.options.autocommit&&a.engineid&&A.engines[a.engineid].saveTableData(e,n),A.options.nocount&&(s=void 0),r&&r(s),s};return h},K.Insert.prototype.execute=function(e,t,r){return this.compile(e)(t,r)},K.CreateTrigger=function(e){return K.extend(this,e)},K.CreateTrigger.prototype.toString=function(){var e="CREATE TRIGGER "+this.trigger+" ";return this.when&&(e+=this.when+" "),e+=this.action+" ON ",this.table.databaseid&&(e+=this.table.databaseid+"."),e+=this.table.tableid+" ",e+=this.statement.toString()},K.CreateTrigger.prototype.execute=function(e,t,r){var n=1,a=this.trigger;e=this.table.databaseid||e;var s=A.databases[e],i=this.table.tableid,o={action:this.action,when:this.when,statement:this.statement,funcid:this.funcid};return s.triggers[a]=o,"INSERT"==o.action&&"BEFORE"==o.when?s.tables[i].beforeinsert[a]=o:"INSERT"==o.action&&"AFTER"==o.when?s.tables[i].afterinsert[a]=o:"INSERT"==o.action&&"INSTEADOF"==o.when?s.tables[i].insteadofinsert[a]=o:"DELETE"==o.action&&"BEFORE"==o.when?s.tables[i].beforedelete[a]=o:"DELETE"==o.action&&"AFTER"==o.when?s.tables[i].afterdelete[a]=o:"DELETE"==o.action&&"INSTEADOF"==o.when?s.tables[i].insteadofdelete[a]=o:"UPDATE"==o.action&&"BEFORE"==o.when?s.tables[i].beforeupdate[a]=o:"UPDATE"==o.action&&"AFTER"==o.when?s.tables[i].afterupdate[a]=o:"UPDATE"==o.action&&"INSTEADOF"==o.when&&(s.tables[i].insteadofupdate[a]=o),r&&(n=r(n)),n},K.DropTrigger=function(e){return K.extend(this,e)},K.DropTrigger.prototype.toString=function(){return"DROP TRIGGER "+this.trigger},K.DropTrigger.prototype.execute=function(e,t,r){var n=0,a=A.databases[e],s=this.trigger,i=a.triggers[s];if(!i)throw new Error("Trigger not found");return n=1,delete a.tables[i].beforeinsert[s],delete a.tables[i].afterinsert[s],delete a.tables[i].insteadofinsert[s],delete a.tables[i].beforedelte[s],delete a.tables[i].afterdelete[s],delete a.tables[i].insteadofdelete[s],delete a.tables[i].beforeupdate[s],delete a.tables[i].afterupdate[s],delete a.tables[i].insteadofupdate[s],delete a.triggers[s],r&&(n=r(n)),n},K.Delete=function(e){return K.extend(this,e)},K.Delete.prototype.toString=function(){var e="DELETE FROM "+this.table.toString();return this.where&&(e+=" WHERE "+this.where.toString()),e},K.Delete.prototype.compile=function(e){e=this.table.databaseid||e;var t,r=this.table.tableid,n=A.databases[e];if(this.where){this.exists&&(this.existsfn=this.exists.map(function(t){var r=t.compile(e);return r.query.modifier="RECORDSET",r})),this.queries&&(this.queriesfn=this.queries.map(function(t){var r=t.compile(e);return r.query.modifier="RECORDSET",r}));var a=new Function("r,params,alasql","var y;return ("+this.where.toJS("r","")+")").bind(this);t=function(t,s){if(n.engineid&&A.engines[n.engineid].deleteFromTable)return A.engines[n.engineid].deleteFromTable(e,r,a,t,s);A.options.autocommit&&n.engineid&&"LOCALSTORAGE"==n.engineid&&A.engines[n.engineid].loadTableData(e,r);for(var i=n.tables[r],o=i.data.length,u=[],c=0,l=i.data.length;c<l;c++)a(i.data[c],t,A)?i.delete&&i.delete(c,t,A):u.push(i.data[c]);i.data=u;for(var h in i.afterdelete){var d=i.afterdelete[h];d&&(d.funcid?A.fn[d.funcid]():d.statement&&d.statement.execute(e))}var f=o-i.data.length;return A.options.autocommit&&n.engineid&&"LOCALSTORAGE"==n.engineid&&A.engines[n.engineid].saveTableData(e,r),s&&s(f),f}}else t=function(t,a){A.options.autocommit&&n.engineid&&A.engines[n.engineid].loadTableData(e,r),n.tables[r].dirty=!0;var s=n.tables[r].data.length;n.tables[r].data.length=0;for(var i in n.tables[r].uniqs)n.tables[r].uniqs[i]={};for(var i in n.tables[r].indices)n.tables[r].indices[i]={};return A.options.autocommit&&n.engineid&&A.engines[n.engineid].saveTableData(e,r),a&&a(s),s};return t},K.Delete.prototype.execute=function(e,t,r){return this.compile(e)(t,r)},K.Update=function(e){return K.extend(this,e)},K.Update.prototype.toString=function(){var e="UPDATE "+this.table.toString();return this.columns&&(e+=" SET "+this.columns.toString()),this.where&&(e+=" WHERE "+this.where.toString()),e},K.SetColumn=function(e){return K.extend(this,e)},K.SetColumn.prototype.toString=function(){return this.column.toString()+"="+this.expression.toString()},K.Update.prototype.compile=function(e){e=this.table.databaseid||e;var t=this.table.tableid;if(this.where){this.exists&&(this.existsfn=this.exists.map(function(t){var r=t.compile(e);return r.query.modifier="RECORDSET",r})),this.queries&&(this.queriesfn=this.queries.map(function(t){var r=t.compile(e);return r.query.modifier="RECORDSET",r}));var r=new Function("r,params,alasql","var y;return "+this.where.toJS("r","")).bind(this)}var n=A.databases[e].tables[t].onupdatefns||"";n+=";",this.columns.forEach(function(e){n+="r['"+e.column.columnid+"']="+e.expression.toJS("r","")+";"});var a=new Function("r,params,alasql","var y;"+n);return function(n,s){var i=A.databases[e];if(i.engineid&&A.engines[i.engineid].updateTable)return A.engines[i.engineid].updateTable(e,t,a,r,n,s);A.options.autocommit&&i.engineid&&A.engines[i.engineid].loadTableData(e,t);var o=i.tables[t];if(!o)throw new Error("Table '"+t+"' not exists");for(var u=0,c=0,l=o.data.length;c<l;c++)r&&!r(o.data[c],n,A)||(o.update?o.update(a,c,n):a(o.data[c],n,A),u++);return A.options.autocommit&&i.engineid&&A.engines[i.engineid].saveTableData(e,t),s&&s(u),u}},K.Update.prototype.execute=function(e,t,r){return this.compile(e)(t,r)},K.Merge=function(e){return K.extend(this,e)},K.Merge.prototype.toString=function(){var e="MERGE ";return e+=this.into.tableid+" ",this.into.as&&(e+="AS "+this.into.as+" "),e+="USING "+this.using.tableid+" ",this.using.as&&(e+="AS "+this.using.as+" "),e+="ON "+this.on.toString()+" ",this.matches.forEach(function(t){e+="WHEN ",t.matched||(e+="NOT "),e+="MATCHED ",t.bytarget&&(e+="BY TARGET "),t.bysource&&(e+="BY SOURCE "),t.expr&&(e+="AND "+t.expr.toString()+" "),e+="THEN ",t.action.delete&&(e+="DELETE "),t.action.insert&&(e+="INSERT ",t.action.columns&&(e+="("+t.action.columns.toString()+") "),t.action.values&&(e+="VALUES ("+t.action.values.toString()+") "),t.action.defaultvalues&&(e+="DEFAULT VALUES ")),t.action.update&&(e+="UPDATE ",e+=t.action.update.map(function(e){return e.toString()}).join(",")+" ")}),e},K.Merge.prototype.execute=function(e,t,r){var n=1;return r&&(n=r(n)),n},K.CreateDatabase=function(e){return K.extend(this,e)},K.CreateDatabase.prototype.toString=function(){var e="CREATE";return this.engineid&&(e+=" "+this.engineid),e+=" DATABASE",this.ifnotexists&&(e+=" IF NOT EXISTS"),e+=" "+this.databaseid,this.args&&this.args.length>0&&(e+="("+this.args.map(function(e){return e.toString()}).join(", ")+")"),this.as&&(e+=" AS "+this.as),e},K.CreateDatabase.prototype.execute=function(e,t,r){if(this.args&&this.args.length>0&&this.args.map(function(e){return new Function("params,alasql","var y;return "+e.toJS())(t,A)}),this.engineid){var n=A.engines[this.engineid].createDatabase(this.databaseid,this.args,this.ifnotexists,this.as,r);return n}var a=this.databaseid;if(A.databases[a])throw new Error("Database '"+a+"' already exists");var n=(new A.Database(a),1);return r?r(n):n},K.AttachDatabase=function(e){return K.extend(this,e)},K.AttachDatabase.prototype.toString=function(){var e="ATTACH";return this.engineid&&(e+=" "+this.engineid),e+=" DATABASE "+this.databaseid,args&&(e+="(",args.length>0&&(e+=args.map(function(e){return e.toString()}).join(", ")),e+=")"),this.as&&(e+=" AS "+this.as),e},K.AttachDatabase.prototype.execute=function(e,t,r){if(!A.engines[this.engineid])throw new Error('Engine "'+this.engineid+'" is not defined.');return A.engines[this.engineid].attachDatabase(this.databaseid,this.as,this.args,t,r)},K.DetachDatabase=function(e){return K.extend(this,e)},K.DetachDatabase.prototype.toString=function(){var e="DETACH";return e+=" DATABASE "+this.databaseid},K.DetachDatabase.prototype.execute=function(e,t,r){if(!A.databases[this.databaseid].engineid)throw new Error('Cannot detach database "'+this.engineid+'", because it was not attached.');var n,a=this.databaseid;if(a==A.DEFAULTDATABASEID)throw new Error("Drop of default database is prohibited");if(A.databases[a])delete A.databases[a],a==A.useid&&A.use(),n=1;else{if(!this.ifexists)throw new Error("Database '"+a+"' does not exist");n=0}return r&&r(n),n},K.UseDatabase=function(e){return K.extend(this,e)},K.UseDatabase.prototype.toString=function(){return"USE DATABASE "+this.databaseid},K.UseDatabase.prototype.execute=function(e,t,r){var n=this.databaseid;if(!A.databases[n])throw new Error("Database '"+n+"' does not exist");A.use(n);return r&&r(1),1},K.DropDatabase=function(e){return K.extend(this,e)},K.DropDatabase.prototype.toString=function(){var e="DROP";return this.ifexists&&(e+=" IF EXISTS"),e+=" DATABASE "+this.databaseid},K.DropDatabase.prototype.execute=function(e,t,r){if(this.engineid)return A.engines[this.engineid].dropDatabase(this.databaseid,this.ifexists,r);var n,a=this.databaseid;if(a==A.DEFAULTDATABASEID)throw new Error("Drop of default database is prohibited");if(A.databases[a]){if(A.databases[a].engineid)throw new Error("Cannot drop database '"+a+"', because it is attached. Detach it.");delete A.databases[a],a==A.useid&&A.use(),n=1}else{if(!this.ifexists)throw new Error("Database '"+a+"' does not exist");n=0}return r&&r(n),n},K.Declare=function(e){return K.extend(this,e)},K.Declare.prototype.toString=function(){var e="DECLARE ";return this.declares&&this.declares.length>0&&(e=this.declares.map(function(e){var t="";return t+="@"+e.variable+" ",t+=e.dbtypeid,this.dbsize&&(t+="("+this.dbsize,this.dbprecision&&(t+=","+this.dbprecision),t+=")"),e.expression&&(t+=" = "+e.expression.toString()),t}).join(",")),e},K.Declare.prototype.execute=function(e,t,r){var n=1;return this.declares&&this.declares.length>0&&this.declares.map(function(e){var r=e.dbtypeid;A.fn[r]||(r=r.toUpperCase()),A.declares[e.variable]={dbtypeid:r,dbsize:e.dbsize,dbprecision:e.dbprecision},e.expression&&(A.vars[e.variable]=new Function("params,alasql","return "+e.expression.toJS("({})","",null))(t,A),A.declares[e.variable]&&(A.vars[e.variable]=A.stdfn.CONVERT(A.vars[e.variable],A.declares[e.variable])))}),r&&(n=r(n)),n},K.ShowDatabases=function(e){return K.extend(this,e)},K.ShowDatabases.prototype.toString=function(){var e="SHOW DATABASES";return this.like&&(e+="LIKE "+this.like.toString()),e},K.ShowDatabases.prototype.execute=function(e,t,r){if(this.engineid)return A.engines[this.engineid].showDatabases(this.like,r);var n=this,a=[];for(dbid in A.databases)a.push({databaseid:dbid});return n.like&&a&&a.length>0&&(a=a.filter(function(e){return A.utils.like(n.like.value,e.databaseid)})),r&&r(a),a},K.ShowTables=function(e){return K.extend(this,e)},K.ShowTables.prototype.toString=function(){var e="SHOW TABLES";return this.databaseid&&(e+=" FROM "+this.databaseid),this.like&&(e+=" LIKE "+this.like.toString()),e},K.ShowTables.prototype.execute=function(e,t,r){var n=A.databases[this.databaseid||e],a=this,s=[];for(tableid in n.tables)s.push({tableid:tableid})
+return K.extend(this,e)},K.Over.prototype.toString=function(){var e="OVER (";return this.partition&&(e+="PARTITION BY "+this.partition.toString(),this.order&&(e+=" ")),this.order&&(e+="ORDER BY "+this.order.toString()),e+=")"},K.ExpressionStatement=function(e){return K.extend(this,e)},K.ExpressionStatement.prototype.toString=function(){return this.expression.toString()},K.ExpressionStatement.prototype.execute=function(e,t,r){if(this.expression){A.precompile(this,e,t);var n=new Function("params,alasql,p","var y;return "+this.expression.toJS("({})","",null)).bind(this),a=n(t,A);return r&&(a=r(a)),a}},K.Expression=function(e){return K.extend(this,e)},K.Expression.prototype.toString=function(e){var t=this.expression.toString(e);return this.order&&(t+=" "+this.order.toString()),this.nocase&&(t+=" COLLATE NOCASE"),this.direction&&(t+=" "+this.direction),t},K.Expression.prototype.findAggregator=function(e){this.expression.findAggregator&&this.expression.findAggregator(e)},K.Expression.prototype.toJS=function(e,t,r){return this.expression.reduced?"true":this.expression.toJS(e,t,r)},K.Expression.prototype.compile=function(e,t,r){return!!this.reduced||new Function("p","var y;return "+this.toJS(e,t,r))},K.JavaScript=function(e){return K.extend(this,e)},K.JavaScript.prototype.toString=function(){return"``"+this.value+"``"},K.JavaScript.prototype.toJS=function(){return"("+this.value+")"},K.JavaScript.prototype.execute=function(e,t,r){var n=1;return new Function("params,alasql,p",this.value)(t,A),r&&(n=r(n)),n},K.Literal=function(e){return K.extend(this,e)},K.Literal.prototype.toString=function(e){var t=this.value;return this.value1&&(t=this.value1+"."+t),this.alias&&!e&&(t+=" AS "+this.alias),t},K.Join=function(e){return K.extend(this,e)},K.Join.prototype.toString=function(){var e=" ";return this.joinmode&&(e+=this.joinmode+" "),e+="JOIN "+this.table.toString()},K.Table=function(e){return K.extend(this,e)},K.Table.prototype.toString=function(){var e=this.tableid;return this.databaseid&&(e=this.databaseid+"."+e),e},K.View=function(e){return K.extend(this,e)},K.View.prototype.toString=function(){var e=this.viewid;return this.databaseid&&(e=this.databaseid+"."+e),e},K.Op=function(e){return K.extend(this,e)},K.Op.prototype.toString=function(){if("IN"===this.op||"NOT IN"===this.op)return this.left.toString()+" "+this.op+" ("+this.right.toString()+")";if(this.allsome)return this.left.toString()+" "+this.op+" "+this.allsome+" ("+this.right.toString()+")";if("->"===this.op||"!"===this.op){var e=this.left.toString()+this.op;return"string"!=typeof this.right&&"number"!=typeof this.right&&(e+="("),e+=this.right.toString(),"string"!=typeof this.right&&"number"!=typeof this.right&&(e+=")"),e}return this.left.toString()+" "+this.op+" "+(this.allsome?this.allsome+" ":"")+this.right.toString()},K.Op.prototype.findAggregator=function(e){this.left&&this.left.findAggregator&&this.left.findAggregator(e),this.right&&this.right.findAggregator&&!this.allsome&&this.right.findAggregator(e)},K.Op.prototype.toType=function(e){if(["-","*","/","%","^"].indexOf(this.op)>-1)return"number";if(["||"].indexOf(this.op)>-1)return"string";if("+"===this.op){if("string"===this.left.toType(e)||"string"===this.right.toType(e))return"string";if("number"===this.left.toType(e)||"number"===this.right.toType(e))return"number"}return["AND","OR","NOT","=","==","===","!=","!==","!===",">",">=","<","<=","IN","NOT IN","LIKE","NOT LIKE","REGEXP","GLOB"].indexOf(this.op)>-1?"boolean":"BETWEEN"===this.op||"NOT BETWEEN"===this.op||"IS NULL"===this.op||"IS NOT NULL"===this.op?"boolean":this.allsome?"boolean":this.op?"unknown":this.left.toType()},K.Op.prototype.toJS=function(e,t,r){var n,a=[],s=this.op,i=this,o=function(n){return n.toJS&&(n=n.toJS(e,t,r)),"y["+(a.push(n)-1)+"]"},u=function(){return o(i.left)},c=function(){return o(i.right)};if("="===this.op?s="===":"<>"===this.op?s="!=":"OR"===this.op&&(s="||"),"->"===this.op){var l="("+u()+"||{})";if("string"==typeof this.right)n=l+'["'+this.right+'"]';else if("number"==typeof this.right)n=l+"["+this.right+"]";else if(this.right instanceof K.FuncValue){var h=[];if(this.right.args&&0!==this.right.args.length)var h=this.right.args.map(o);n=l+"['"+this.right.funcid+"']("+h.join(",")+")"}else n=l+"["+c()+"]"}if("!"===this.op&&"string"==typeof this.right&&(n="alasql.databases[alasql.useid].objects["+u()+']["'+this.right+'"]'),"IS"===this.op&&(n="(("+u()+"==null) === ("+c()+"==null))"),"=="===this.op&&(n="alasql.utils.deepEqual("+u()+","+c()+")"),"==="!==this.op&&"!==="!==this.op||(n="("+("!==="===this.op?"!":"")+"(("+u()+").valueOf()===("+c()+").valueOf()))"),"!=="===this.op&&(n="(!alasql.utils.deepEqual("+u()+","+c()+"))"),"||"===this.op&&(n="(''+("+u()+"||'')+("+c()+'||""))'),"LIKE"===this.op||"NOT LIKE"===this.op){var n="("+("NOT LIKE"===this.op?"!":"")+"alasql.utils.like("+c()+","+u();this.escape&&(n+=","+o(this.escape)),n+="))"}if("REGEXP"===this.op&&(n="alasql.stdfn.REGEXP_LIKE("+u()+","+c()+")"),"GLOB"===this.op&&(n="alasql.utils.glob("+u()+","+c()+")"),"BETWEEN"===this.op||"NOT BETWEEN"===this.op){var d=u();n="("+("NOT BETWEEN"===this.op?"!":"")+"(("+o(this.right1)+"<="+d+") && ("+d+"<="+o(this.right2)+")))"}if("IN"===this.op&&(this.right instanceof K.Select?(n="(",n+="alasql.utils.flatArray(this.queriesfn["+this.queriesidx+"](params,null,"+e+"))",n+=".indexOf(",n+=u()+")>-1)"):n=Array.isArray(this.right)?"(["+this.right.map(o).join(",")+"].indexOf("+u()+")>-1)":"("+c()+".indexOf("+u()+")>-1)"),"NOT IN"===this.op&&(this.right instanceof K.Select?(n="(",n+="alasql.utils.flatArray(this.queriesfn["+this.queriesidx+"](params,null,p))",n+=".indexOf(",n+=u()+")<0)"):Array.isArray(this.right)?(n="(["+this.right.map(o).join(",")+"].indexOf(",n+=u()+")<0)"):(n="("+c()+".indexOf(",n+=u()+")==-1)")),"ALL"===this.allsome){var n;if(this.right instanceof K.Select)n="alasql.utils.flatArray(this.query.queriesfn["+this.queriesidx+"](params,null,p))",n+=".every(function(b){return (",n+=u()+")"+s+"b})";else{if(!Array.isArray(this.right))throw new Error("NOT IN operator without SELECT");n=""+(1==this.right.length?o(this.right[0]):"["+this.right.map(o).join(",")+"]"),n+=".every(function(b){return (",n+=u()+")"+s+"b})"}}if("SOME"===this.allsome||"ANY"===this.allsome){var n;if(this.right instanceof K.Select)n="alasql.utils.flatArray(this.query.queriesfn["+this.queriesidx+"](params,null,p))",n+=".some(function(b){return (",n+=u()+")"+s+"b})";else{if(!Array.isArray(this.right))throw new Error("SOME/ANY operator without SELECT");n=""+(1==this.right.length?o(this.right[0]):"["+this.right.map(o).join(",")+"]"),n+=".some(function(b){return (",n+=u()+")"+s+"b})"}}if("AND"===this.op){if(this.left.reduced){if(this.right.reduced)return"true";n=c()}else this.right.reduced&&(n=u());s="&&"}var f=n||"("+u()+s+c()+")",p="y=[("+a.join("), (")+")]";return"&&"==s||"||"==s||"IS"==s||"IS NULL"==s||"IS NOT NULL"==s?"("+p+", "+f+")":"("+p+", y.some(function(e){return e == null}) ? void 0 : "+f+")"},K.VarValue=function(e){return K.extend(this,e)},K.VarValue.prototype.toString=function(){return"@"+this.variable},K.VarValue.prototype.toType=function(){return"unknown"},K.VarValue.prototype.toJS=function(){return"alasql.vars['"+this.variable+"']"},K.NumValue=function(e){return K.extend(this,e)},K.NumValue.prototype.toString=function(){return this.value.toString()},K.NumValue.prototype.toType=function(){return"number"},K.NumValue.prototype.toJS=function(){return""+this.value},K.StringValue=function(e){return K.extend(this,e)},K.StringValue.prototype.toString=function(){return"'"+this.value.toString()+"'"},K.StringValue.prototype.toType=function(){return"string"},K.StringValue.prototype.toJS=function(){return"'"+R(this.value)+"'"},K.DomainValueValue=function(e){return K.extend(this,e)},K.DomainValueValue.prototype.toString=function(){return"VALUE"},K.DomainValueValue.prototype.toType=function(){return"object"},K.DomainValueValue.prototype.toJS=function(e,t,r){return e},K.ArrayValue=function(e){return K.extend(this,e)},K.ArrayValue.prototype.toString=function(){return"ARRAY[]"},K.ArrayValue.prototype.toType=function(){return"object"},K.ArrayValue.prototype.toJS=function(e,t,r){return"[("+this.value.map(function(n){return n.toJS(e,t,r)}).join("), (")+")]"},K.LogicValue=function(e){return K.extend(this,e)},K.LogicValue.prototype.toString=function(){return this.value?"TRUE":"FALSE"},K.LogicValue.prototype.toType=function(){return"boolean"},K.LogicValue.prototype.toJS=function(){return this.value?"true":"false"},K.NullValue=function(e){return K.extend(this,e)},K.NullValue.prototype.toString=function(){return"NULL"},K.NullValue.prototype.toJS=function(){return"undefined"},K.ParamValue=function(e){return K.extend(this,e)},K.ParamValue.prototype.toString=function(){return"$"+this.param},K.ParamValue.prototype.toJS=function(){return"string"==typeof this.param?"params['"+this.param+"']":"params["+this.param+"]"},K.UniOp=function(e){return K.extend(this,e)},K.UniOp.prototype.toString=function(){var e;return e=void 0,"~"===this.op&&(e=this.op+this.right.toString()),"-"===this.op&&(e=this.op+this.right.toString()),"+"===this.op&&(e=this.op+this.right.toString()),"#"===this.op&&(e=this.op+this.right.toString()),"NOT"===this.op&&(e=this.op+"("+this.right.toString()+")"),null===this.op&&(e="("+this.right.toString()+")"),e||(e="("+this.right.toString()+")"),e},K.UniOp.prototype.findAggregator=function(e){this.right.findAggregator&&this.right.findAggregator(e)},K.UniOp.prototype.toType=function(){return"-"===this.op?"number":"+"===this.op?"number":"NOT"===this.op?"boolean":void 0},K.UniOp.prototype.toJS=function(e,t,r){return"~"===this.op?"(~("+this.right.toJS(e,t,r)+"))":"-"===this.op?"(-("+this.right.toJS(e,t,r)+"))":"+"===this.op?"("+this.right.toJS(e,t,r)+")":"NOT"===this.op?"!("+this.right.toJS(e,t,r)+")":"#"===this.op?this.right instanceof K.Column?"(alasql.databases[alasql.useid].objects['"+this.right.columnid+"'])":"(alasql.databases[alasql.useid].objects["+this.right.toJS(e,t,r)+"])":null==this.op?"("+this.right.toJS(e,t,r)+")":void 0},K.Column=function(e){return K.extend(this,e)},K.Column.prototype.toString=function(e){var t;return t=this.columnid==+this.columnid?"["+this.columnid+"]":this.columnid,this.tableid&&(t=+this.columnid===this.columnid?this.tableid+t:this.tableid+"."+t,this.databaseid&&(t=this.databaseid+"."+t)),this.alias&&!e&&(t+=" AS "+this.alias),t},K.Column.prototype.toJS=function(e,t,r){var n="";if(this.tableid||""!==t||r)if("g"===e)n="g['"+this.nick+"']";else if(this.tableid)n="_"!==this.columnid?e+"['"+this.tableid+"']['"+this.columnid+"']":"g"===e?"g['_']":e+"['"+this.tableid+"']";else if(r){var a=r[this.columnid];if("-"===a)throw new Error('Cannot resolve column "'+this.columnid+'" because it exists in two source tables');n=a?"_"!==this.columnid?e+"['"+a+"']['"+this.columnid+"']":e+"['"+a+"']":"_"!==this.columnid?e+"['"+(this.tableid||t)+"']['"+this.columnid+"']":e+"['"+(this.tableid||t)+"']"}else n=-1===t?e+"['"+this.columnid+"']":"_"!==this.columnid?e+"['"+(this.tableid||t)+"']['"+this.columnid+"']":e+"['"+(this.tableid||t)+"']";else n="_"!==this.columnid?e+"['"+this.columnid+"']":"g"===e?"g['_']":e;return n},K.AggrValue=function(e){return K.extend(this,e)},K.AggrValue.prototype.toString=function(e){var t="";return"REDUCE"===this.aggregatorid?t+=this.funcid+"(":t+=this.aggregatorid+"(",this.distinct&&(t+="DISTINCT "),this.expression&&(t+=this.expression.toString()),t+=")",this.over&&(t+=" "+this.over.toString()),this.alias&&!e&&(t+=" AS "+this.alias),t},K.AggrValue.prototype.findAggregator=function(e){var t=R(this.toString())+":"+e.selectGroup.length,r=!1;if(!r){if(!this.nick){this.nick=t;for(var r=!1,n=0;n<e.removeKeys.length;n++)if(e.removeKeys[n]===t){r=!0;break}r||e.removeKeys.push(t)}e.selectGroup.push(this)}},K.AggrValue.prototype.toType=function(){return["SUM","COUNT","AVG","MIN","MAX","AGGR","VAR","STDDEV"].indexOf(this.aggregatorid)>-1?"number":["ARRAY"].indexOf(this.aggregatorid)>-1?"array":["FIRST","LAST"].indexOf(this.aggregatorid)>-1?this.expression.toType():void 0},K.AggrValue.prototype.toJS=function(){var e=this.nick;return void 0===e&&(e=this.toString()),"g['"+e+"']"},K.OrderExpression=function(e){return K.extend(this,e)},K.OrderExpression.prototype.toString=K.Expression.prototype.toString,K.GroupExpression=function(e){return K.extend(this,e)},K.GroupExpression.prototype.toString=function(){return this.type+"("+this.group.toString()+")"},K.FromData=function(e){return K.extend(this,e)},K.FromData.prototype.toString=function(){return this.data?"DATA("+(1e16*Math.random()|0)+")":"?"},K.FromData.prototype.toJS=function(){},K.Select.prototype.exec=function(e,t){this.preparams&&(e=this.preparams.concat(e));var r=A.useid;db=A.databases[r];var n=this.toString(),a=D(n),s=this.compile(r);if(s){s.sql=n,s.dbversion=db.dbversion,db.sqlCacheSize>A.MAXSQLCACHESIZE&&db.resetSqlCache(),db.sqlCacheSize++,db.sqlCache[a]=s;return A.res=s(e,t)}},K.Select.prototype.Select=function(){var e=this;if(arguments.length>1)args=Array.prototype.slice.call(arguments);else{if(1!=arguments.length)throw new Error("Wrong number of arguments of Select() function");Array.isArray(arguments[0])?args=arguments[0]:args=[arguments[0]]}return e.columns=[],args.forEach(function(t){if("string"==typeof t)e.columns.push(new K.Column({columnid:t}));else if("function"==typeof t){var r=0;e.preparams?r=e.preparams.length:e.preparams=[],e.preparams.push(t),e.columns.push(new K.Column({columnid:"*",func:t,param:r}))}}),e},K.Select.prototype.From=function(e){var t=this;if(t.from||(t.from=[]),Array.isArray(e)){var r=0;t.preparams?r=t.preparams.length:t.preparams=[],t.preparams.push(e),t.from.push(new K.ParamValue({param:r}))}else{if("string"!=typeof e)throw new Error("Unknown arguments in From() function");t.from.push(new K.Table({tableid:e}))}return t},K.Select.prototype.OrderBy=function(){var e=this;if(e.order=[],0==arguments.length)args=["_"];else if(arguments.length>1)args=Array.prototype.slice.call(arguments);else{if(1!=arguments.length)throw new Error("Wrong number of arguments of Select() function");Array.isArray(arguments[0])?args=arguments[0]:args=[arguments[0]]}return args.length>0&&args.forEach(function(t){var r=new K.Column({columnid:t});"function"==typeof t&&(r=t),e.order.push(new K.OrderExpression({expression:r,direction:"ASC"}))}),e},K.Select.prototype.Top=function(e){var t=this;return t.top=new K.NumValue({value:e}),t},K.Select.prototype.GroupBy=function(){var e=this;if(arguments.length>1)args=Array.prototype.slice.call(arguments);else{if(1!=arguments.length)throw new Error("Wrong number of arguments of Select() function");Array.isArray(arguments[0])?args=arguments[0]:args=[arguments[0]]}return e.group=[],args.forEach(function(t){var r=new K.Column({columnid:t});e.group.push(r)}),e},K.Select.prototype.Where=function(e){var t=this;return"function"==typeof e&&(t.where=e),t},K.FuncValue=function(e){return K.extend(this,e)},K.FuncValue.prototype.toString=function(e){var t="";return A.fn[this.funcid]?t+=this.funcid:A.aggr[this.funcid]?t+=this.funcid:(A.stdlib[this.funcid.toUpperCase()]||A.stdfn[this.funcid.toUpperCase()])&&(t+=this.funcid.toUpperCase()),t+="(",this.args&&this.args.length>0&&(t+=this.args.map(function(e){return e.toString()}).join(",")),t+=")",this.as&&!e&&(t+=" AS "+this.as.toString()),t},K.FuncValue.prototype.execute=function(e,t,r){var n=1;return A.precompile(this,e,t),new Function("params,alasql","var y;return "+this.toJS("","",null))(t,A),r&&(n=r(n)),n},K.FuncValue.prototype.findAggregator=function(e){this.args&&this.args.length>0&&this.args.forEach(function(t){t.findAggregator&&t.findAggregator(e)})},K.FuncValue.prototype.toJS=function(e,t,r){var n="",a=this.funcid;return!A.fn[a]&&A.stdlib[a.toUpperCase()]?this.args&&this.args.length>0?n+=A.stdlib[a.toUpperCase()].apply(this,this.args.map(function(r){return r.toJS(e,t)})):n+=A.stdlib[a.toUpperCase()]():!A.fn[a]&&A.stdfn[a.toUpperCase()]?(this.newid&&(n+="new "),n+="alasql.stdfn."+this.funcid.toUpperCase()+"(",this.args&&this.args.length>0&&(n+=this.args.map(function(n){return n.toJS(e,t,r)}).join(",")),n+=")"):(this.newid&&(n+="new "),n+="alasql.fn."+this.funcid+"(",this.args&&this.args.length>0&&(n+=this.args.map(function(n){return n.toJS(e,t,r)}).join(",")),n+=")"),n};var ae=A.stdlib={},se=A.stdfn={};ae.ABS=function(e){return"Math.abs("+e+")"},ae.CLONEDEEP=function(e){return"alasql.utils.cloneDeep("+e+")"},se.CONCAT=function(){return Array.prototype.slice.call(arguments).join("")},ae.EXP=function(e){return"Math.pow(Math.E,"+e+")"},ae.IIF=function(e,t,r){if(3==arguments.length)return"(("+e+")?("+t+"):("+r+"))";throw new Error("Number of arguments of IFF is not equals to 3")},ae.IFNULL=function(e,t){return"("+e+"||"+t+")"},ae.INSTR=function(e,t){return"(("+e+").indexOf("+t+")+1)"},ae.LEN=ae.LENGTH=function(e){return t(e,"y.length")},ae.LOWER=ae.LCASE=function(e){return t(e,"String(y).toLowerCase()")},ae.LTRIM=function(e){return t(e,'y.replace(/^[ ]+/,"")')},ae.RTRIM=function(e){return t(e,'y.replace(/[ ]+$/,"")')},ae.MAX=ae.GREATEST=function(){return"Math.max("+Array.prototype.join.call(arguments,",")+")"},ae.MIN=ae.LEAST=function(){return"Math.min("+Array.prototype.join.call(arguments,",")+")"},ae.SUBSTRING=ae.SUBSTR=ae.MID=function(e,r,n){return 2==arguments.length?t(e,"y.substr("+r+"-1)"):3==arguments.length?t(e,"y.substr("+r+"-1,"+n+")"):void 0},se.REGEXP_LIKE=function(e,t,r){return(e||"").search(RegExp(t,r))>-1},ae.ISNULL=ae.NULLIF=function(e,t){return"("+e+"=="+t+"?undefined:"+e+")"},ae.POWER=function(e,t){return"Math.pow("+e+","+t+")"},ae.RANDOM=function(e){return 0==arguments.length?"Math.random()":"(Math.random()*("+e+")|0)"},ae.ROUND=function(e,t){return 2==arguments.length?"Math.round(("+e+")*Math.pow(10,("+t+")))/Math.pow(10,("+t+"))":"Math.round("+e+")"},ae.CEIL=ae.CEILING=function(e){return"Math.ceil("+e+")"},ae.FLOOR=function(e){return"Math.floor("+e+")"},ae.ROWNUM=function(){return"1"},ae.ROW_NUMBER=function(){return"1"},ae.SQRT=function(e){return"Math.sqrt("+e+")"},ae.TRIM=function(e){return t(e,"y.trim()")},ae.UPPER=ae.UCASE=function(e){return t(e,"String(y).toUpperCase()")},se.CONCAT_WS=function(){return args=Array.prototype.slice.call(arguments),args.slice(1,args.length).join(args[0])},A.aggr.GROUP_CONCAT=function(e,t,r){return 1==r?e:2==r?t+","+e:void 0},A.aggr.MEDIAN=function(e,t,r){if(2===r)return null!==e&&t.push(e),t;if(1===r)return null===e?[]:[e];if(!t.length)return t;var n=t.sort(),a=(n.length+1)/2;return Number.isInteger(a)?n[a-1]:(n[Math.floor(a-1)]+n[Math.ceil(a-1)])/2},A.aggr.QUART=function(e,t,r,n){if(2===r)return null!==e&&t.push(e),t;if(1===r)return null===e?[]:[e];if(!t.length)return t;n=n||1;var a=t.sort(),s=n*(a.length+1)/4;return Number.isInteger(s)?a[s-1]:a[Math.floor(s)]},A.aggr.QUART2=function(e,t,r){return A.aggr.QUART(e,t,r,2)},A.aggr.QUART3=function(e,t,r){return A.aggr.QUART(e,t,r,3)},A.aggr.VAR=function(e,t,r){if(1===r)return null===e?{arr:[],sum:0}:{arr:[e],sum:e};if(2===r)return null===e?t:(t.arr.push(e),t.sum+=e,t);for(var n=t.arr.length,a=t.sum/n,s=0,i=0;i<n;i++)s+=(t.arr[i]-a)*(t.arr[i]-a);return s/=n-1},A.aggr.STDEV=function(e,t,r){return 1===r||2===r?A.aggr.VAR(e,t,r):Math.sqrt(A.aggr.VAR(e,t,r))},A.aggr.VARP=function(e,t,r){if(1==r)return{arr:[e],sum:e};if(2==r)return t.arr.push(e),t.sum+=e,t;for(var n=t.arr.length,a=t.sum/n,s=0,i=0;i<n;i++)s+=(t.arr[i]-a)*(t.arr[i]-a);return s/=n},A.aggr.STD=A.aggr.STDDEV=A.aggr.STDEVP=function(e,t,r){return 1==r||2==r?A.aggr.VARP(e,t,r):Math.sqrt(A.aggr.VARP(e,t,r))},A._aggrOriginal=A.aggr,A.aggr={},Object.keys(A._aggrOriginal).forEach(function(e){A.aggr[e]=function(t,r,n){if(3!==n||void 0!==r)return A._aggrOriginal[e].apply(null,arguments)}}),se.REPLACE=function(e,t,r){return(e||"").split(t).join(r)};for(var ie=[],oe=0;oe<256;oe++)ie[oe]=(oe<16?"0":"")+oe.toString(16);se.NEWID=se.UUID=se.GEN_RANDOM_UUID=function(){var e=4294967295*Math.random()|0,t=4294967295*Math.random()|0,r=4294967295*Math.random()|0,n=4294967295*Math.random()|0;return ie[255&e]+ie[e>>8&255]+ie[e>>16&255]+ie[e>>24&255]+"-"+ie[255&t]+ie[t>>8&255]+"-"+ie[t>>16&15|64]+ie[t>>24&255]+"-"+ie[63&r|128]+ie[r>>8&255]+"-"+ie[r>>16&255]+ie[r>>24&255]+ie[255&n]+ie[n>>8&255]+ie[n>>16&255]+ie[n>>24&255]},K.CaseValue=function(e){return K.extend(this,e)},K.CaseValue.prototype.toString=function(){var e="CASE ";return this.expression&&(e+=this.expression.toString()),this.whens&&(e+=this.whens.map(function(e){return" WHEN "+e.when.toString()+" THEN "+e.then.toString()}).join()),e+=" END"},K.CaseValue.prototype.findAggregator=function(e){this.expression&&this.expression.findAggregator&&this.expression.findAggregator(e),this.whens&&this.whens.length>0&&this.whens.forEach(function(t){t.when.findAggregator&&t.when.findAggregator(e),t.then.findAggregator&&t.then.findAggregator(e)}),this.elses&&this.elses.findAggregator&&this.elses.findAggregator(e)},K.CaseValue.prototype.toJS=function(e,t,r){var n="((function("+e+",params,alasql){var y,r;";return this.expression?(n+="v="+this.expression.toJS(e,t,r)+";",n+=(this.whens||[]).map(function(n){return" if(v=="+n.when.toJS(e,t,r)+") {r="+n.then.toJS(e,t,r)+"}"}).join(" else "),this.elses&&(n+=" else {r="+this.elses.toJS(e,t,r)+"}")):(n+=(this.whens||[]).map(function(n){return" if("+n.when.toJS(e,t,r)+") {r="+n.then.toJS(e,t,r)+"}"}).join(" else "),this.elses&&(n+=" else {r="+this.elses.toJS(e,t,r)+"}")),n+=";return r;}).bind(this))("+e+",params,alasql)"},K.Json=function(e){return K.extend(this,e)},K.Json.prototype.toString=function(){var e="";return e+=ue(this.value),e+=""};var ue=A.utils.JSONtoString=function(e){var t="";if("string"==typeof e)t='"'+e+'"';else if("number"==typeof e)t=e;else if("boolean"==typeof e)t=e;else{if("object"!=typeof e)throw new Error("2Can not show JSON object "+JSON.stringify(e));if(Array.isArray(e))t+="["+e.map(function(e){return ue(e)}).join(",")+"]";else if(!e.toJS||e instanceof K.Json){t="{";var r=[];for(var n in e){var a="";if("string"==typeof n)a+='"'+n+'"';else if("number"==typeof n)a+=n;else{if("boolean"!=typeof n)throw new Error("THis is not ES6... no expressions on left side yet");a+=n}a+=":"+ue(e[n]),r.push(a)}t+=r.join(",")+"}"}else{if(!e.toString)throw new Error("1Can not show JSON object "+JSON.stringify(e));t=e.toString()}}return t};K.Json.prototype.toJS=function(e,t,r){return E(this.value,e,t,r)},K.Convert=function(e){return K.extend(this,e)},K.Convert.prototype.toString=function(){var e="CONVERT(";return e+=this.dbtypeid,void 0!==this.dbsize&&(e+="("+this.dbsize,this.dbprecision&&(e+=","+dbprecision),e+=")"),e+=","+this.expression.toString(),this.style&&(e+=","+this.style),e+=")"},K.Convert.prototype.toJS=function(e,t,r){return"alasql.stdfn.CONVERT("+this.expression.toJS(e,t,r)+',{dbtypeid:"'+this.dbtypeid+'",dbsize:'+this.dbsize+",style:"+this.style+"})"},A.stdfn.CONVERT=function(e,t){var r=e;if(t.style){var n;switch(n=/\d{8}/.test(r)?new Date(+r.substr(0,4),+r.substr(4,2)-1,+r.substr(6,2)):new Date(r),t.style){case 1:r=("0"+(n.getMonth()+1)).substr(-2)+"/"+("0"+n.getDate()).substr(-2)+"/"+("0"+n.getYear()).substr(-2);break;case 2:r=("0"+n.getYear()).substr(-2)+"."+("0"+(n.getMonth()+1)).substr(-2)+"."+("0"+n.getDate()).substr(-2);break;case 3:r=("0"+n.getDate()).substr(-2)+"/"+("0"+(n.getMonth()+1)).substr(-2)+"/"+("0"+n.getYear()).substr(-2);break;case 4:r=("0"+n.getDate()).substr(-2)+"."+("0"+(n.getMonth()+1)).substr(-2)+"."+("0"+n.getYear()).substr(-2);break;case 5:r=("0"+n.getDate()).substr(-2)+"-"+("0"+(n.getMonth()+1)).substr(-2)+"-"+("0"+n.getYear()).substr(-2);break;case 6:r=("0"+n.getDate()).substr(-2)+" "+n.toString().substr(4,3).toLowerCase()+" "+("0"+n.getYear()).substr(-2);break;case 7:r=n.toString().substr(4,3)+" "+("0"+n.getDate()).substr(-2)+","+("0"+n.getYear()).substr(-2);break;case 8:case 108:r=("0"+n.getHours()).substr(-2)+":"+("0"+n.getMinutes()).substr(-2)+":"+("0"+n.getSeconds()).substr(-2);break;case 10:r=("0"+(n.getMonth()+1)).substr(-2)+"-"+("0"+n.getDate()).substr(-2)+"-"+("0"+n.getYear()).substr(-2);break;case 11:r=("0"+n.getYear()).substr(-2)+"/"+("0"+(n.getMonth()+1)).substr(-2)+"/"+("0"+n.getDate()).substr(-2);break;case 12:r=("0"+n.getYear()).substr(-2)+("0"+(n.getMonth()+1)).substr(-2)+("0"+n.getDate()).substr(-2);break;case 101:r=("0"+(n.getMonth()+1)).substr(-2)+"/"+("0"+n.getDate()).substr(-2)+"/"+n.getFullYear();break;case 102:r=n.getFullYear()+"."+("0"+(n.getMonth()+1)).substr(-2)+"."+("0"+n.getDate()).substr(-2);break;case 103:r=("0"+n.getDate()).substr(-2)+"/"+("0"+(n.getMonth()+1)).substr(-2)+"/"+n.getFullYear();break;case 104:r=("0"+n.getDate()).substr(-2)+"."+("0"+(n.getMonth()+1)).substr(-2)+"."+n.getFullYear();break;case 105:r=("0"+n.getDate()).substr(-2)+"-"+("0"+(n.getMonth()+1)).substr(-2)+"-"+n.getFullYear();break;case 106:r=("0"+n.getDate()).substr(-2)+" "+n.toString().substr(4,3).toLowerCase()+" "+n.getFullYear();break;case 107:r=n.toString().substr(4,3)+" "+("0"+n.getDate()).substr(-2)+","+n.getFullYear();break;case 110:r=("0"+(n.getMonth()+1)).substr(-2)+"-"+("0"+n.getDate()).substr(-2)+"-"+n.getFullYear();break;case 111:r=n.getFullYear()+"/"+("0"+(n.getMonth()+1)).substr(-2)+"/"+("0"+n.getDate()).substr(-2);break;case 112:r=n.getFullYear()+("0"+(n.getMonth()+1)).substr(-2)+("0"+n.getDate()).substr(-2);break;default:throw new Error("The CONVERT style "+t.style+" is not realized yet.")}}var a=t.dbtypeid.toUpperCase();if("Date"==t.dbtypeid)return new Date(r);if("DATE"==a){var s=new Date(r),i=s.getFullYear()+"."+("0"+(s.getMonth()+1)).substr(-2)+"."+("0"+s.getDate()).substr(-2);return i}if("DATETIME"==a||"DATETIME2"==a){var s=new Date(r),i=s.getFullYear()+"."+("0"+(s.getMonth()+1)).substr(-2)+"."+("0"+s.getDate()).substr(-2);return i+=" "+("0"+s.getHours()).substr(-2)+":"+("0"+s.getMinutes()).substr(-2)+":"+("0"+s.getSeconds()).substr(-2),i+="."+("00"+s.getMilliseconds()).substr(-3)}if(["MONEY"].indexOf(a)>-1){var o=+r;return(0|o)+100*o%100/100}if(["BOOLEAN"].indexOf(a)>-1)return!!r;if(["INT","INTEGER","SMALLINT","BIGINT","SERIAL","SMALLSERIAL","BIGSERIAL"].indexOf(t.dbtypeid.toUpperCase())>-1)return 0|r;if(["STRING","VARCHAR","NVARCHAR","CHARACTER VARIABLE"].indexOf(t.dbtypeid.toUpperCase())>-1)return t.dbsize?(""+r).substr(0,t.dbsize):""+r;if(["CHAR","CHARACTER","NCHAR"].indexOf(a)>-1)return(r+new Array(t.dbsize+1).join(" ")).substr(0,t.dbsize);if(["NUMBER","FLOAT"].indexOf(a)>-1){if(void 0!==t.dbprecision){var o=+r,u=Math.pow(10,t.dbprecision);return(0|o)+o*u%u/u}return+r}if(["DECIMAL","NUMERIC"].indexOf(a)>-1){var o=+r,u=Math.pow(10,t.dbprecision);return(0|o)+o*u%u/u}if(["JSON"].indexOf(a)>-1){if("object"==typeof r)return r;try{return JSON.parse(r)}catch(e){throw new Error("Cannot convert string to JSON")}}return r},K.ColumnDef=function(e){return K.extend(this,e)},K.ColumnDef.prototype.toString=function(){var e=this.columnid;return this.dbtypeid&&(e+=" "+this.dbtypeid),this.dbsize&&(e+="("+this.dbsize,this.dbprecision&&(e+=","+this.dbprecision),e+=")"),this.primarykey&&(e+=" PRIMARY KEY"),this.notnull&&(e+=" NOT NULL"),e},K.CreateTable=function(e){return K.extend(this,e)},K.CreateTable.prototype.toString=function(){var e="CREATE";if(this.temporary&&(e+=" TEMPORARY"),this.view?e+=" VIEW":e+=" "+(this.class?"CLASS":"TABLE"),this.ifnotexists&&(e+=" IF  NOT EXISTS"),e+=" "+this.table.toString(),this.viewcolumns&&(e+="("+this.viewcolumns.map(function(e){return e.toString()}).join(",")+")"),this.as)e+=" AS "+this.as;else{e+=" ("+this.columns.map(function(e){return e.toString()}).join(",")+")"}return this.view&&this.select&&(e+=" AS "+this.select.toString()),e},K.CreateTable.prototype.execute=function(e,t,r){var n=A.databases[this.table.databaseid||e],a=this.table.tableid;if(!a)throw new Error("Table name is not defined");var s=this.columns,i=this.constraints||[];if(this.ifnotexists&&n.tables[a])return r?r(0):0;if(n.tables[a])throw new Error("Can not create table '"+a+"', because it already exists in the database '"+n.databaseid+"'");var o=n.tables[a]=new A.Table;this.class&&(o.isclass=!0);var u=[],c=[];if(s&&s.forEach(function(t){var r=t.dbtypeid;A.fn[r]||(r=r.toUpperCase()),["SERIAL","SMALLSERIAL","BIGSERIAL"].indexOf(r)>-1&&(t.identity={value:1,step:1});var n={columnid:t.columnid,dbtypeid:r,dbsize:t.dbsize,dbprecision:t.dbprecision,notnull:t.notnull,identity:t.identity};if(t.identity&&(o.identities[t.columnid]={value:+t.identity.value,step:+t.identity.step}),t.check&&o.checks.push({id:t.check.constrantid,fn:new Function("r","var y;return "+t.check.expression.toJS("r",""))}),t.default&&u.push("'"+t.columnid+"':"+t.default.toJS("r","")),t.primarykey){var a=o.pk={};a.columns=[t.columnid],a.onrightfns="r['"+t.columnid+"']",a.onrightfn=new Function("r","var y;return "+a.onrightfns),a.hh=D(a.onrightfns),o.uniqs[a.hh]={}}if(t.unique){var s={};o.uk=o.uk||[],o.uk.push(s),s.columns=[t.columnid],s.onrightfns="r['"+t.columnid+"']",s.onrightfn=new Function("r","var y;return "+s.onrightfns),s.hh=D(s.onrightfns),o.uniqs[s.hh]={}}if(t.foreignkey){var i=t.foreignkey.table,l=A.databases[i.databaseid||e].tables[i.tableid];if(void 0===i.columnid){if(!(l.pk.columns&&l.pk.columns.length>0))throw new Error("FOREIGN KEY allowed only to tables with PRIMARY KEYs");i.columnid=l.pk.columns[0]}var h=function(e){var r={};if(void 0===e[t.columnid])return!0;r[i.columnid]=e[t.columnid];var n=l.pk.onrightfn(r);if(!l.uniqs[l.pk.hh][n])throw new Error('Foreign key "'+e[t.columnid]+'" is not found in table '+l.tableid);return!0};o.checks.push({fn:h})}t.onupdate&&c.push("r['"+t.columnid+"']="+t.onupdate.toJS("r","")),o.columns.push(n),o.xcolumns[n.columnid]=n}),o.defaultfns=u.join(","),o.onupdatefns=c.join(";"),i.forEach(function(t){var r;if("PRIMARY KEY"===t.type){if(o.pk)throw new Error("Primary key already exists");var n=o.pk={};n.columns=t.columns,n.onrightfns=n.columns.map(function(e){return"r['"+e+"']"}).join("+'`'+"),n.onrightfn=new Function("r","var y;return "+n.onrightfns),n.hh=D(n.onrightfns),o.uniqs[n.hh]={}}else if("CHECK"===t.type)r=new Function("r","var y;return "+t.expression.toJS("r",""));else if("UNIQUE"===t.type){var a={};o.uk=o.uk||[],o.uk.push(a),a.columns=t.columns,a.onrightfns=a.columns.map(function(e){return"r['"+e+"']"}).join("+'`'+"),a.onrightfn=new Function("r","var y;return "+a.onrightfns),a.hh=D(a.onrightfns),o.uniqs[a.hh]={}}else if("FOREIGN KEY"===t.type){var s=o.xcolumns[t.columns[0]],i=t.fktable;t.fkcolumns&&t.fkcolumns.length>0&&(i.columnid=t.fkcolumns[0]);var u=A.databases[i.databaseid||e].tables[i.tableid];void 0===i.columnid&&(i.columnid=u.pk.columns[0]),r=function(e){var t={};if(void 0===e[s.columnid])return!0;t[i.columnid]=e[s.columnid];var r=u.pk.onrightfn(t);if(!u.uniqs[u.pk.hh][r])throw new Error('Foreign key "'+e[s.columnid]+'" is not found in table '+u.tableid);return!0}}r&&o.checks.push({fn:r,id:t.constraintid,fk:"FOREIGN KEY"===t.type})}),this.view&&this.viewcolumns){var l=this;this.viewcolumns.forEach(function(e,t){l.select.columns[t].as=e.columnid})}if(this.view&&this.select&&(o.view=!0,o.select=this.select.compile(this.table.databaseid||e)),n.engineid)return A.engines[n.engineid].createTable(this.table.databaseid||e,a,this.ifnotexists,r);o.insert=function(r,n){var a=A.inserted;A.inserted=[r];var s=this,i=!1,o=!1;for(var u in s.beforeinsert){var c=s.beforeinsert[u];c&&(c.funcid?!1===A.fn[c.funcid](r)&&(o=o||!0):c.statement&&!1===c.statement.execute(e)&&(o=o||!0))}if(!o){var l=!1;for(var u in s.insteadofinsert){l=!0;var c=s.insteadofinsert[u];c&&(c.funcid?A.fn[c.funcid](r):c.statement&&c.statement.execute(e))}if(!l){for(var h in s.identities){var d=s.identities[h];r[h]=d.value}if(s.checks&&s.checks.length>0&&s.checks.forEach(function(e){if(!e.fn(r))throw new Error("Violation of CHECK constraint "+(e.id||""))}),s.columns.forEach(function(e){if(e.notnull&&void 0===r[e.columnid])throw new Error("Wrong NULL value in NOT NULL column "+e.columnid)}),s.pk){var f=s.pk,p=f.onrightfn(r);if(void 0!==s.uniqs[f.hh][p]){if(!n)throw new Error("Cannot insert record, because it already exists in primary key index")
+;i=s.uniqs[f.hh][p]}}if(s.uk&&s.uk.length&&s.uk.forEach(function(e){var t=e.onrightfn(r);if(void 0!==s.uniqs[e.hh][t]){if(!n)throw new Error("Cannot insert record, because it already exists in unique index");i=s.uniqs[e.hh][t]}}),i)s.update(function(e){for(var t in r)e[t]=r[t]},s.data.indexOf(i),t);else{s.data.push(r);for(var h in s.identities){var d=s.identities[h];d.value+=d.step}if(s.pk){var f=s.pk,p=f.onrightfn(r);s.uniqs[f.hh][p]=r}s.uk&&s.uk.length&&s.uk.forEach(function(e){var t=e.onrightfn(r);s.uniqs[e.hh][t]=r})}for(var u in s.afterinsert){var c=s.afterinsert[u];c&&(c.funcid?A.fn[c.funcid](r):c.statement&&c.statement.execute(e))}A.inserted=a}}},o.delete=function(t){var r=this,n=r.data[t],a=!1;for(var s in r.beforedelete){var i=r.beforedelete[s];i&&(i.funcid?!1===A.fn[i.funcid](n)&&(a=a||!0):i.statement&&!1===i.statement.execute(e)&&(a=a||!0))}if(a)return!1;var o=!1;for(var s in r.insteadofdelete){o=!0;var i=r.insteadofdelete[s];i&&(i.funcid?A.fn[i.funcid](n):i.statement&&i.statement.execute(e))}if(!o){if(this.pk){var u=this.pk,c=u.onrightfn(n);if(void 0===this.uniqs[u.hh][c])throw new Error("Something wrong with primary key index on table");this.uniqs[u.hh][c]=void 0}r.uk&&r.uk.length&&r.uk.forEach(function(e){var t=e.onrightfn(n);if(void 0===r.uniqs[e.hh][t])throw new Error("Something wrong with unique index on table");r.uniqs[e.hh][t]=void 0})}},o.deleteall=function(){this.data.length=0,this.pk&&(this.uniqs[this.pk.hh]={}),o.uk&&o.uk.length&&o.uk.forEach(function(e){o.uniqs[e.hh]={}})},o.update=function(t,r,n){var a,s=F(this.data[r]);if(this.pk&&(a=this.pk,a.pkaddr=a.onrightfn(s,n),void 0===this.uniqs[a.hh][a.pkaddr]))throw new Error("Something wrong with index on table");o.uk&&o.uk.length&&o.uk.forEach(function(e){if(e.ukaddr=e.onrightfn(s),void 0===o.uniqs[e.hh][e.ukaddr])throw new Error("Something wrong with unique index on table")}),t(s,n,A);var i=!1;for(var u in o.beforeupdate){var c=o.beforeupdate[u];c&&(c.funcid?!1===A.fn[c.funcid](this.data[r],s)&&(i=i||!0):c.statement&&!1===c.statement.execute(e)&&(i=i||!0))}if(i)return!1;var l=!1;for(var u in o.insteadofupdate){l=!0;var c=o.insteadofupdate[u];c&&(c.funcid?A.fn[c.funcid](this.data[r],s):c.statement&&c.statement.execute(e))}if(!l){if(o.checks&&o.checks.length>0&&o.checks.forEach(function(e){if(!e.fn(s))throw new Error("Violation of CHECK constraint "+(e.id||""))}),o.columns.forEach(function(e){if(e.notnull&&void 0===s[e.columnid])throw new Error("Wrong NULL value in NOT NULL column "+e.columnid)}),this.pk&&(a.newpkaddr=a.onrightfn(s),void 0!==this.uniqs[a.hh][a.newpkaddr]&&a.newpkaddr!==a.pkaddr))throw new Error("Record already exists");o.uk&&o.uk.length&&o.uk.forEach(function(e){if(e.newukaddr=e.onrightfn(s),void 0!==o.uniqs[e.hh][e.newukaddr]&&e.newukaddr!==e.ukaddr)throw new Error("Record already exists")}),this.pk&&(this.uniqs[a.hh][a.pkaddr]=void 0,this.uniqs[a.hh][a.newpkaddr]=s),o.uk&&o.uk.length&&o.uk.forEach(function(e){o.uniqs[e.hh][e.ukaddr]=void 0,o.uniqs[e.hh][e.newukaddr]=s}),this.data[r]=s;for(var u in o.afterupdate){var c=o.afterupdate[u];c&&(c.funcid?A.fn[c.funcid](this.data[r],s):c.statement&&c.statement.execute(e))}}};var h;return A.options.nocount||(h=1),r&&(h=r(h)),h},A.fn.Date=Object,A.fn.Date=Date,A.fn.Number=Number,A.fn.String=String,A.fn.Boolean=Boolean,se.EXTEND=A.utils.extend,se.CHAR=String.fromCharCode.bind(String),se.ASCII=function(e){return e.charCodeAt(0)},se.COALESCE=function(){for(var e=0;e<arguments.length;e++)if(void 0!==arguments[e]&&("number"!=typeof arguments[e]||!isNaN(arguments[e])))return arguments[e]},se.USER=function(){return"alasql"},se.OBJECT_ID=function(e){return!!A.tables[e]},se.DATE=function(e){return/\d{8}/.test(e)?new Date(+e.substr(0,4),+e.substr(4,2)-1,+e.substr(6,2)):new Date(e)},se.NOW=function(){var e=new Date,t=e.getFullYear()+"."+("0"+(e.getMonth()+1)).substr(-2)+"."+("0"+e.getDate()).substr(-2);return t+=" "+("0"+e.getHours()).substr(-2)+":"+("0"+e.getMinutes()).substr(-2)+":"+("0"+e.getSeconds()).substr(-2),t+="."+("00"+e.getMilliseconds()).substr(-3)},se.GETDATE=se.NOW,se.CURRENT_TIMESTAMP=se.NOW,se.SECOND=function(e){var e=new Date(e);return e.getSeconds()},se.MINUTE=function(e){var e=new Date(e);return e.getMinutes()},se.HOUR=function(e){var e=new Date(e);return e.getHours()},se.DAYOFWEEK=se.WEEKDAY=function(e){var e=new Date(e);return e.getDay()},se.DAY=se.DAYOFMONTH=function(e){var e=new Date(e);return e.getDate()},se.MONTH=function(e){var e=new Date(e);return e.getMonth()+1},se.YEAR=function(e){var e=new Date(e);return e.getFullYear()};var ce={year:31536e6,quarter:7884e6,month:2592e6,week:6048e5,day:864e5,dayofyear:864e5,weekday:864e5,hour:36e5,minute:6e4,second:1e3,millisecond:1,microsecond:.001};A.stdfn.DATEDIFF=function(e,t,r){return(new Date(r).getTime()-new Date(t).getTime())/ce[e.toLowerCase()]},A.stdfn.DATEADD=function(e,t,r){var n=new Date(r).getTime()+t*ce[e.toLowerCase()];return new Date(n)},A.stdfn.INTERVAL=function(e,t){return e*ce[t.toLowerCase()]},A.stdfn.DATE_ADD=A.stdfn.ADDDATE=function(e,t){var r=new Date(e).getTime()+t;return new Date(r)},A.stdfn.DATE_SUB=A.stdfn.SUBDATE=function(e,t){var r=new Date(e).getTime()-t;return new Date(r)},K.DropTable=function(e){return K.extend(this,e)},K.DropTable.prototype.toString=function(){var e="DROP ";return this.view?e+="VIEW":e+="TABLE",this.ifexists&&(e+=" IF EXISTS"),e+=" "+this.tables.toString()},K.DropTable.prototype.execute=function(e,t,r){var n=this.ifexists,a=0,s=0,i=this.tables.length;return this.tables.forEach(function(t){var o=A.databases[t.databaseid||e],u=t.tableid;if(!n||n&&o.tables[u]){if(o.tables[u])o.engineid?A.engines[o.engineid].dropTable(t.databaseid||e,u,n,function(e){delete o.tables[u],a+=e,++s==i&&r&&r(a)}):(delete o.tables[u],a++,++s==i&&r&&r(a));else if(!A.options.dropifnotexists)throw new Error("Can not drop table '"+t.tableid+"', because it does not exist in the database.")}else++s==i&&r&&r(a)}),a},K.TruncateTable=function(e){return K.extend(this,e)},K.TruncateTable.prototype.toString=function(){var e="TRUNCATE TABLE";return e+=" "+this.table.toString()},K.TruncateTable.prototype.execute=function(e,t,r){var n=A.databases[this.table.databaseid||e],a=this.table.tableid;if(n.engineid)return A.engines[n.engineid].truncateTable(this.table.databaseid||e,a,this.ifexists,r);if(!n.tables[a])throw new Error("Cannot truncate table becaues it does not exist");return n.tables[a].data=[],r?r(0):0},K.CreateVertex=function(e){return K.extend(this,e)},K.CreateVertex.prototype.toString=function(){var e="CREATE VERTEX ";return this.class&&(e+=this.class+" "),this.sharp&&(e+="#"+this.sharp+" "),this.sets?e+=this.sets.toString():this.content?e+=this.content.toString():this.select&&(e+=this.select.toString()),e},K.CreateVertex.prototype.toJS=function(e){return"this.queriesfn["+(this.queriesidx-1)+"](this.params,null,"+e+")"},K.CreateVertex.prototype.compile=function(e){var t=e,r=this.sharp;if(void 0!==this.name)var n="x.name="+this.name.toJS(),a=new Function("x",n);if(this.sets&&this.sets.length>0)var n=this.sets.map(function(e){return"x['"+e.column.columnid+"']="+e.expression.toJS("x","")}).join(";"),s=new Function("x,params,alasql",n);return function(e,n){var i,o,u=A.databases[t];o=void 0!==r?r:u.counter++;var c={$id:o,$node:"VERTEX"};return u.objects[c.$id]=c,i=c,a&&a(c),s&&s(c,e,A),n&&(i=n(i)),i}},K.CreateEdge=function(e){return K.extend(this,e)},K.CreateEdge.prototype.toString=function(){var e="CREATE EDGE ";return this.class&&(e+=this.class+" "),e},K.CreateEdge.prototype.toJS=function(e){return"this.queriesfn["+(this.queriesidx-1)+"](this.params,null,"+e+")"},K.CreateEdge.prototype.compile=function(e){var t=e,r=new Function("params,alasql","var y;return "+this.from.toJS()),n=new Function("params,alasql","var y;return "+this.to.toJS());if(void 0!==this.name)var a="x.name="+this.name.toJS(),s=new Function("x",a);if(this.sets&&this.sets.length>0)var a=this.sets.map(function(e){return"x['"+e.column.columnid+"']="+e.expression.toJS("x","")}).join(";"),i=new Function("x,params,alasql","var y;"+a);return function(e,a){var o=0,u=A.databases[t],c={$id:u.counter++,$node:"EDGE"},l=r(e,A),h=n(e,A);return c.$in=[l.$id],c.$out=[h.$id],void 0===l.$out&&(l.$out=[]),l.$out.push(c.$id),void 0===typeof h.$in&&(h.$in=[]),h.$in.push(c.$id),u.objects[c.$id]=c,o=c,s&&s(c),i&&i(c,e,A),a&&(o=a(o)),o}},K.CreateGraph=function(e){return K.extend(this,e)},K.CreateGraph.prototype.toString=function(){var e="CREATE GRAPH ";return this.class&&(e+=this.class+" "),e},K.CreateGraph.prototype.execute=function(e,t,r){function n(e){var t=A.databases[A.useid].objects;for(var r in t)if(t[r].name===e)return t[r]}function a(r){var n={};void 0!==r.as&&(A.vars[r.as]=n),void 0!==r.prop&&(n.$id=r.prop,n.name=r.prop),void 0!==r.sharp&&(n.$id=r.sharp),void 0!==r.name&&(n.name=r.name),void 0!==r.class&&(n.$class=r.class);var a=A.databases[e];if(void 0===n.$id&&(n.$id=a.counter++),n.$node="VERTEX",void 0!==r.json&&G(n,new Function("params,alasql","var y;return "+r.json.toJS())(t,A)),a.objects[n.$id]=n,void 0!==n.$class){if(void 0===A.databases[e].tables[n.$class])throw new Error("No such class. Pleace use CREATE CLASS");A.databases[e].tables[n.$class].data.push(n)}return s.push(n.$id),n}var s=[];return this.from&&A.from[this.from.funcid]&&(this.graph=A.from[this.from.funcid.toUpperCase()]),this.graph.forEach(function(r){if(r.source){var i={};void 0!==r.as&&(A.vars[r.as]=i),void 0!==r.prop&&(i.name=r.prop),void 0!==r.sharp&&(i.$id=r.sharp),void 0!==r.name&&(i.name=r.name),void 0!==r.class&&(i.$class=r.class);var o=A.databases[e];void 0===i.$id&&(i.$id=o.counter++),i.$node="EDGE",void 0!==r.json&&G(i,new Function("params,alasql","var y;return "+r.json.toJS())(t,A));var u;if(r.source.vars){var c=A.vars[r.source.vars];u="object"==typeof c?c:o.objects[c]}else{var l=r.source.sharp;void 0===l&&(l=r.source.prop),u=A.databases[e].objects[l],void 0!==u||!A.options.autovertex||void 0===r.source.prop&&void 0===r.source.name||void 0===(u=n(r.source.prop||r.source.name))&&(u=a(r.source))}var h;if(r.source.vars){var c=A.vars[r.target.vars];h="object"==typeof c?c:o.objects[c]}else{var d=r.target.sharp;void 0===d&&(d=r.target.prop),h=A.databases[e].objects[d],void 0!==h||!A.options.autovertex||void 0===r.target.prop&&void 0===r.target.name||void 0===(h=n(r.target.prop||r.target.name))&&(h=a(r.target))}if(i.$in=[u.$id],i.$out=[h.$id],void 0===u.$out&&(u.$out=[]),u.$out.push(i.$id),void 0===h.$in&&(h.$in=[]),h.$in.push(i.$id),o.objects[i.$id]=i,void 0!==i.$class){if(void 0===A.databases[e].tables[i.$class])throw new Error("No such class. Pleace use CREATE CLASS");A.databases[e].tables[i.$class].data.push(i)}s.push(i.$id)}else a(r)}),r&&(s=r(s)),s},K.CreateGraph.prototype.compile1=function(e){var t=e,r=new Function("params,alasql","var y;return "+this.from.toJS()),n=new Function("params,alasql","var y;return "+this.to.toJS());if(void 0!==this.name)var a="x.name="+this.name.toJS(),s=new Function("x",a);if(this.sets&&this.sets.length>0)var a=this.sets.map(function(e){return"x['"+e.column.columnid+"']="+e.expression.toJS("x","")}).join(";"),i=new Function("x,params,alasql","var y;"+a);return function(e,a){var o=0,u=A.databases[t],c={$id:u.counter++,$node:"EDGE"},l=r(e,A),h=n(e,A);return c.$in=[l.$id],c.$out=[h.$id],void 0===l.$out&&(l.$out=[]),l.$out.push(c.$id),void 0===h.$in&&(h.$in=[]),h.$in.push(c.$id),u.objects[c.$id]=c,o=c,s&&s(c),i&&i(c,e,A),a&&(o=a(o)),o}},K.AlterTable=function(e){return K.extend(this,e)},K.AlterTable.prototype.toString=function(){var e="ALTER TABLE "+this.table.toString();return this.renameto&&(e+=" RENAME TO "+this.renameto),e},K.AlterTable.prototype.execute=function(e,t,r){var n=A.databases[e];if(n.dbversion=Date.now(),this.renameto){var a=this.table.tableid,s=this.renameto,i=1;if(n.tables[s])throw new Error("Can not rename a table '"+a+"' to '"+s+"', because the table with this name already exists");if(s==a)throw new Error("Can not rename a table '"+a+"' to itself");return n.tables[s]=n.tables[a],delete n.tables[a],i=1,r&&r(i),i}if(this.addcolumn){var n=A.databases[this.table.databaseid||e];n.dbversion++;var o=this.table.tableid,u=n.tables[o],c=this.addcolumn.columnid;if(u.xcolumns[c])throw new Error('Cannot add column "'+c+'", because it already exists in the table "'+o+'"');var l={columnid:c,dbtypeid:this.dbtypeid,dbsize:this.dbsize,dbprecision:this.dbprecision,dbenum:this.dbenum,defaultfns:null};u.columns.push(l),u.xcolumns[c]=l;for(var h=0,d=u.data.length;h<d;h++)u.data[h][c]=void 0;return r?r(1):1}if(this.modifycolumn){var n=A.databases[this.table.databaseid||e];n.dbversion++;var o=this.table.tableid,u=n.tables[o],c=this.modifycolumn.columnid;if(!u.xcolumns[c])throw new Error('Cannot modify column "'+c+'", because it was not found in the table "'+o+'"');var l=u.xcolumns[c];return l.dbtypeid=this.dbtypeid,l.dbsize=this.dbsize,l.dbprecision=this.dbprecision,l.dbenum=this.dbenum,r?r(1):1}if(this.renamecolumn){var n=A.databases[this.table.databaseid||e];n.dbversion++;var l,o=this.table.tableid,u=n.tables[o],c=this.renamecolumn,f=this.to;if(!u.xcolumns[c])throw new Error('Column "'+c+'" is not found in the table "'+o+'"');if(u.xcolumns[f])throw new Error('Column "'+f+'" already exists in the table "'+o+'"');if(c!=f){for(var p=0;p<u.columns.length;p++)u.columns[p].columnid==c&&(u.columns[p].columnid=f);u.xcolumns[f]=u.xcolumns[c],delete u.xcolumns[c];for(var h=0,d=u.data.length;h<d;h++)u.data[h][f]=u.data[h][c],delete u.data[h][c];return u.data.length}return r?r(0):0}if(this.dropcolumn){var n=A.databases[this.table.databaseid||e];n.dbversion++;for(var o=this.table.tableid,u=n.tables[o],c=this.dropcolumn,b=!1,p=0;p<u.columns.length;p++)if(u.columns[p].columnid==c){b=!0,u.columns.splice(p,1);break}if(!b)throw new Error('Cannot drop column "'+c+'", because it was not found in the table "'+o+'"');delete u.xcolumns[c];for(var h=0,d=u.data.length;h<d;h++)delete u.data[h][c];return r?r(u.data.length):u.data.length}throw Error("Unknown ALTER TABLE method")},K.CreateIndex=function(e){return K.extend(this,e)},K.CreateIndex.prototype.toString=function(){var e="CREATE";return this.unique&&(e+=" UNIQUE"),e+=" INDEX "+this.indexid+" ON "+this.table.toString(),e+="("+this.columns.toString()+")"},K.CreateIndex.prototype.execute=function(e,t,r){var n=A.databases[e],a=this.table.tableid,s=n.tables[a],i=this.indexid;n.indices[i]=a;var o=this.columns.map(function(e){return e.expression.toJS("r","")}).join("+'`'+"),u=new Function("r,params,alasql","return "+o);if(this.unique){s.uniqdefs[i]={rightfns:o};var c=s.uniqs[i]={};if(s.data.length>0)for(var l=0,h=s.data.length;l<h;l++){var d=o(s.data[l]);c[d]||(c[d]={num:0}),c[d].num++}}else{var f=D(o);s.inddefs[i]={rightfns:o,hh:f},s.indices[f]={};var p=s.indices[f]={};if(s.data.length>0)for(var l=0,h=s.data.length;l<h;l++){var d=u(s.data[l],t,A);p[d]||(p[d]=[]),p[d].push(s.data[l])}}var b=1;return r&&(b=r(b)),b},K.Reindex=function(e){return K.extend(this,e)},K.Reindex.prototype.toString=function(){return"REINDEX "+this.indexid},K.Reindex.prototype.execute=function(e,t,r){var n=A.databases[e],a=this.indexid,s=n.indices[a];n.tables[s].indexColumns();var i=1;return r&&(i=r(i)),i},K.DropIndex=function(e){return K.extend(this,e)},K.DropIndex.prototype.toString=function(){return"DROP INDEX"+this.indexid},K.DropIndex.prototype.compile=function(e){this.indexid;return function(){return 1}},K.WithSelect=function(e){return K.extend(this,e)},K.WithSelect.prototype.toString=function(){var e="WITH ";return e+=this.withs.map(function(e){return e.name+" AS ("+e.select.toString()+")"}).join(",")+" ",e+=this.select.toString()},K.WithSelect.prototype.execute=function(e,t,r){var n=this,a=[];n.withs.forEach(function(r){a.push(A.databases[e].tables[r.name]),(A.databases[e].tables[r.name]=new W({tableid:r.name})).data=r.select.execute(e,t)});return this.select.execute(e,t,function(t){return n.withs.forEach(function(t,r){a[r]?A.databases[e].tables[t.name]=a[r]:delete A.databases[e].tables[t.name]}),r&&(t=r(t)),t})},K.If=function(e){return K.extend(this,e)},K.If.prototype.toString=function(){var e="IF ";return e+=this.expression.toString(),e+=" "+this.thenstat.toString(),this.elsestat&&(e+=" ELSE "+this.thenstat.toString()),e},K.If.prototype.execute=function(e,t,r){var n;return new Function("params,alasql,p","var y;return "+this.expression.toJS("({})","",null)).bind(this)(t,A)?n=this.thenstat.execute(e,t,r):this.elsestat?n=this.elsestat.execute(e,t,r):r&&(n=r(n)),n},K.While=function(e){return K.extend(this,e)},K.While.prototype.toString=function(){var e="WHILE ";return e+=this.expression.toString(),e+=" "+this.loopstat.toString()},K.While.prototype.execute=function(e,t,r){function n(u){o?s.push(u):o=!0,setTimeout(function(){i(t,A)?a.loopstat.execute(e,t,n):s=r(s)},0)}var a=this,s=[],i=new Function("params,alasql,p","var y;return "+this.expression.toJS());if(r){var o=!1;n()}else for(;i(t,A);){var u=a.loopstat.execute(e,t);s.push(u)}return s},K.Break=function(e){return K.extend(this,e)},K.Break.prototype.toString=function(){return"BREAK"},K.Break.prototype.execute=function(e,t,r,n){var a=1;return r&&(a=r(a)),a},K.Continue=function(e){return K.extend(this,e)},K.Continue.prototype.toString=function(){return"CONTINUE"},K.Continue.prototype.execute=function(e,t,r,n){var a=1;return r&&(a=r(a)),a},K.BeginEnd=function(e){return K.extend(this,e)},K.BeginEnd.prototype.toString=function(){return"BEGIN "+this.statements.toString()+" END"},K.BeginEnd.prototype.execute=function(e,t,r,n){function a(){s.statements[o].execute(e,t,function(e){if(i.push(e),++o<s.statements.length)return a();r&&(i=r(i))})}var s=this,i=[],o=0;return a(),i},K.Insert=function(e){return K.extend(this,e)},K.Insert.prototype.toString=function(){var e="INSERT ";return this.orreplace&&(e+="OR REPLACE "),this.replaceonly&&(e="REPLACE "),e+="INTO "+this.into.toString(),this.columns&&(e+="("+this.columns.toString()+")"),this.values&&(e+=" VALUES "+this.values.toString()),this.select&&(e+=" "+this.select.toString()),e},K.Insert.prototype.toJS=function(e,t,r){return"this.queriesfn["+(this.queriesidx-1)+"](this.params,null,"+e+")"},K.Insert.prototype.compile=function(e){var t=this;e=t.into.databaseid||e;var r=A.databases[e],n=t.into.tableid,a=r.tables[n];if(!a)throw"Table '"+n+"' could not be found";var s,i="",o="",i="db.tables['"+n+"'].dirty=true;",u="var a,aa=[],x;";if(this.values){this.exists&&(this.existsfn=this.exists.map(function(t){var r=t.compile(e);return r.query.modifier="RECORDSET",r})),this.queries&&(this.queriesfn=this.queries.map(function(t){var r=t.compile(e);return r.query.modifier="RECORDSET",r})),t.values.forEach(function(s){var u=[];t.columns?t.columns.forEach(function(e,t){var r="'"+e.columnid+"':";a.xcolumns&&a.xcolumns[e.columnid]?["INT","FLOAT","NUMBER","MONEY"].indexOf(a.xcolumns[e.columnid].dbtypeid)>=0?r+="(x="+s[t].toJS()+",x==undefined?undefined:+x)":A.fn[a.xcolumns[e.columnid].dbtypeid]?(r+="(new "+a.xcolumns[e.columnid].dbtypeid+"(",r+=s[t].toJS(),r+="))"):r+=s[t].toJS():r+=s[t].toJS(),u.push(r)}):Array.isArray(s)&&a.columns&&a.columns.length>0?a.columns.forEach(function(e,t){var r="'"+e.columnid+"':";["INT","FLOAT","NUMBER","MONEY"].indexOf(e.dbtypeid)>=0?r+="+"+s[t].toJS():A.fn[e.dbtypeid]?(r+="(new "+e.dbtypeid+"(",r+=s[t].toJS(),r+="))"):r+=s[t].toJS(),u.push(r)}):o=E(s),r.tables[n].defaultfns&&u.unshift(r.tables[n].defaultfns),i+=o?"a="+o+";":"a={"+u.join(",")+"};",r.tables[n].isclass&&(i+="var db=alasql.databases['"+e+"'];",i+='a.$class="'+n+'";',i+="a.$id=db.counter++;",i+="db.objects[a.$id]=a;"),r.tables[n].insert?(i+="var db=alasql.databases['"+e+"'];",i+="db.tables['"+n+"'].insert(a,"+(t.orreplace?"true":"false")+");"):i+="aa.push(a);"}),s=u+i,r.tables[n].insert||(i+="alasql.databases['"+e+"'].tables['"+n+"'].data=alasql.databases['"+e+"'].tables['"+n+"'].data.concat(aa);"),r.tables[n].insert&&r.tables[n].isclass?i+="return a.$id;":i+="return "+t.values.length;var c=new Function("db, params, alasql","var y;"+u+i).bind(this)}else if(this.select){this.select.modifier="RECORDSET";var l=this.select.compile(e);if(r.engineid&&A.engines[r.engineid].intoTable){var h=function(e,t){var a=l(e);return A.engines[r.engineid].intoTable(r.databaseid,n,a.data,null,t)};return h}var d="return alasql.utils.extend(r,{"+a.defaultfns+"})",f=new Function("r,db,params,alasql",d),c=function(e,r,a){var s=l(r).data;if(e.tables[n].insert)for(var i=0,o=s.length;i<o;i++){var u=F(s[i]);f(u,e,r,a),e.tables[n].insert(u,t.orreplace)}else e.tables[n].data=e.tables[n].data.concat(s);return a.options.nocount?void 0:s.length}}else{if(!this.default)throw new Error("Wrong INSERT parameters");var p="db.tables['"+n+"'].data.push({"+a.defaultfns+"});return 1;",c=new Function("db,params,alasql",p)}if(r.engineid&&A.engines[r.engineid].intoTable&&A.options.autocommit)var h=function(e,t){var a=new Function("db,params","var y;"+s+"return aa;")(r,e);return A.engines[r.engineid].intoTable(r.databaseid,n,a,null,t)};else var h=function(t,r){var a=A.databases[e];A.options.autocommit&&a.engineid&&A.engines[a.engineid].loadTableData(e,n);var s=c(a,t,A);return A.options.autocommit&&a.engineid&&A.engines[a.engineid].saveTableData(e,n),A.options.nocount&&(s=void 0),r&&r(s),s};return h},K.Insert.prototype.execute=function(e,t,r){return this.compile(e)(t,r)},K.CreateTrigger=function(e){return K.extend(this,e)},K.CreateTrigger.prototype.toString=function(){var e="CREATE TRIGGER "+this.trigger+" ";return this.when&&(e+=this.when+" "),e+=this.action+" ON ",this.table.databaseid&&(e+=this.table.databaseid+"."),e+=this.table.tableid+" ",e+=this.statement.toString()},K.CreateTrigger.prototype.execute=function(e,t,r){var n=1,a=this.trigger;e=this.table.databaseid||e;var s=A.databases[e],i=this.table.tableid,o={action:this.action,when:this.when,statement:this.statement,funcid:this.funcid};return s.triggers[a]=o,"INSERT"==o.action&&"BEFORE"==o.when?s.tables[i].beforeinsert[a]=o:"INSERT"==o.action&&"AFTER"==o.when?s.tables[i].afterinsert[a]=o:"INSERT"==o.action&&"INSTEADOF"==o.when?s.tables[i].insteadofinsert[a]=o:"DELETE"==o.action&&"BEFORE"==o.when?s.tables[i].beforedelete[a]=o:"DELETE"==o.action&&"AFTER"==o.when?s.tables[i].afterdelete[a]=o:"DELETE"==o.action&&"INSTEADOF"==o.when?s.tables[i].insteadofdelete[a]=o:"UPDATE"==o.action&&"BEFORE"==o.when?s.tables[i].beforeupdate[a]=o:"UPDATE"==o.action&&"AFTER"==o.when?s.tables[i].afterupdate[a]=o:"UPDATE"==o.action&&"INSTEADOF"==o.when&&(s.tables[i].insteadofupdate[a]=o),r&&(n=r(n)),n},K.DropTrigger=function(e){return K.extend(this,e)},K.DropTrigger.prototype.toString=function(){return"DROP TRIGGER "+this.trigger},K.DropTrigger.prototype.execute=function(e,t,r){var n=0,a=A.databases[e],s=this.trigger,i=a.triggers[s];if(!i)throw new Error("Trigger not found");return n=1,delete a.tables[i].beforeinsert[s],delete a.tables[i].afterinsert[s],delete a.tables[i].insteadofinsert[s],delete a.tables[i].beforedelte[s],delete a.tables[i].afterdelete[s],delete a.tables[i].insteadofdelete[s],delete a.tables[i].beforeupdate[s],delete a.tables[i].afterupdate[s],delete a.tables[i].insteadofupdate[s],delete a.triggers[s],r&&(n=r(n)),n},K.Delete=function(e){return K.extend(this,e)},K.Delete.prototype.toString=function(){var e="DELETE FROM "+this.table.toString();return this.where&&(e+=" WHERE "+this.where.toString()),e},K.Delete.prototype.compile=function(e){e=this.table.databaseid||e;var t,r=this.table.tableid,n=A.databases[e];if(this.where){this.exists&&(this.existsfn=this.exists.map(function(t){var r=t.compile(e);return r.query.modifier="RECORDSET",r})),this.queries&&(this.queriesfn=this.queries.map(function(t){var r=t.compile(e);return r.query.modifier="RECORDSET",r}));var a=new Function("r,params,alasql","var y;return ("+this.where.toJS("r","")+")").bind(this);t=function(t,s){if(n.engineid&&A.engines[n.engineid].deleteFromTable)return A.engines[n.engineid].deleteFromTable(e,r,a,t,s);A.options.autocommit&&n.engineid&&"LOCALSTORAGE"==n.engineid&&A.engines[n.engineid].loadTableData(e,r);for(var i=n.tables[r],o=i.data.length,u=[],c=0,l=i.data.length;c<l;c++)a(i.data[c],t,A)?i.delete&&i.delete(c,t,A):u.push(i.data[c]);i.data=u;for(var h in i.afterdelete){var d=i.afterdelete[h];d&&(d.funcid?A.fn[d.funcid]():d.statement&&d.statement.execute(e))}var f=o-i.data.length;return A.options.autocommit&&n.engineid&&"LOCALSTORAGE"==n.engineid&&A.engines[n.engineid].saveTableData(e,r),s&&s(f),f}}else t=function(t,a){A.options.autocommit&&n.engineid&&A.engines[n.engineid].loadTableData(e,r),n.tables[r].dirty=!0;var s=n.tables[r].data.length;n.tables[r].data.length=0;for(var i in n.tables[r].uniqs)n.tables[r].uniqs[i]={};for(var i in n.tables[r].indices)n.tables[r].indices[i]={};return A.options.autocommit&&n.engineid&&A.engines[n.engineid].saveTableData(e,r),a&&a(s),s};return t},K.Delete.prototype.execute=function(e,t,r){return this.compile(e)(t,r)},K.Update=function(e){return K.extend(this,e)},K.Update.prototype.toString=function(){var e="UPDATE "+this.table.toString();return this.columns&&(e+=" SET "+this.columns.toString()),this.where&&(e+=" WHERE "+this.where.toString()),e},K.SetColumn=function(e){return K.extend(this,e)},K.SetColumn.prototype.toString=function(){return this.column.toString()+"="+this.expression.toString()},K.Update.prototype.compile=function(e){e=this.table.databaseid||e;var t=this.table.tableid;if(this.where){this.exists&&(this.existsfn=this.exists.map(function(t){var r=t.compile(e);return r.query.modifier="RECORDSET",r})),this.queries&&(this.queriesfn=this.queries.map(function(t){var r=t.compile(e);return r.query.modifier="RECORDSET",r}));var r=new Function("r,params,alasql","var y;return "+this.where.toJS("r","")).bind(this)}var n=A.databases[e].tables[t].onupdatefns||"";n+=";",this.columns.forEach(function(e){n+="r['"+e.column.columnid+"']="+e.expression.toJS("r","")+";"});var a=new Function("r,params,alasql","var y;"+n);return function(n,s){var i=A.databases[e];if(i.engineid&&A.engines[i.engineid].updateTable)return A.engines[i.engineid].updateTable(e,t,a,r,n,s);A.options.autocommit&&i.engineid&&A.engines[i.engineid].loadTableData(e,t);var o=i.tables[t];if(!o)throw new Error("Table '"+t+"' not exists");for(var u=0,c=0,l=o.data.length;c<l;c++)r&&!r(o.data[c],n,A)||(o.update?o.update(a,c,n):a(o.data[c],n,A),u++);return A.options.autocommit&&i.engineid&&A.engines[i.engineid].saveTableData(e,t),s&&s(u),u}},K.Update.prototype.execute=function(e,t,r){return this.compile(e)(t,r)},K.Merge=function(e){return K.extend(this,e)},K.Merge.prototype.toString=function(){var e="MERGE ";return e+=this.into.tableid+" ",this.into.as&&(e+="AS "+this.into.as+" "),e+="USING "+this.using.tableid+" ",this.using.as&&(e+="AS "+this.using.as+" "),e+="ON "+this.on.toString()+" ",this.matches.forEach(function(t){e+="WHEN ",t.matched||(e+="NOT "),e+="MATCHED ",t.bytarget&&(e+="BY TARGET "),t.bysource&&(e+="BY SOURCE "),t.expr&&(e+="AND "+t.expr.toString()+" "),e+="THEN ",t.action.delete&&(e+="DELETE "),t.action.insert&&(e+="INSERT ",t.action.columns&&(e+="("+t.action.columns.toString()+") "),t.action.values&&(e+="VALUES ("+t.action.values.toString()+") "),t.action.defaultvalues&&(e+="DEFAULT VALUES ")),t.action.update&&(e+="UPDATE ",e+=t.action.update.map(function(e){return e.toString()}).join(",")+" ")}),e},K.Merge.prototype.execute=function(e,t,r){var n=1;return r&&(n=r(n)),n},K.CreateDatabase=function(e){return K.extend(this,e)},K.CreateDatabase.prototype.toString=function(){var e="CREATE";return this.engineid&&(e+=" "+this.engineid),e+=" DATABASE",this.ifnotexists&&(e+=" IF NOT EXISTS"),e+=" "+this.databaseid,this.args&&this.args.length>0&&(e+="("+this.args.map(function(e){return e.toString()}).join(", ")+")"),this.as&&(e+=" AS "+this.as),e},K.CreateDatabase.prototype.execute=function(e,t,r){if(this.args&&this.args.length>0&&this.args.map(function(e){return new Function("params,alasql","var y;return "+e.toJS())(t,A)}),this.engineid){var n=A.engines[this.engineid].createDatabase(this.databaseid,this.args,this.ifnotexists,this.as,r);return n}var a=this.databaseid;if(A.databases[a])throw new Error("Database '"+a+"' already exists");var n=(new A.Database(a),1);return r?r(n):n},K.AttachDatabase=function(e){return K.extend(this,e)},K.AttachDatabase.prototype.toString=function(){var e="ATTACH";return this.engineid&&(e+=" "+this.engineid),e+=" DATABASE "+this.databaseid,args&&(e+="(",args.length>0&&(e+=args.map(function(e){return e.toString()}).join(", ")),e+=")"),this.as&&(e+=" AS "+this.as),e},K.AttachDatabase.prototype.execute=function(e,t,r){if(!A.engines[this.engineid])throw new Error('Engine "'+this.engineid+'" is not defined.');return A.engines[this.engineid].attachDatabase(this.databaseid,this.as,this.args,t,r)},K.DetachDatabase=function(e){return K.extend(this,e)},K.DetachDatabase.prototype.toString=function(){var e="DETACH";return e+=" DATABASE "+this.databaseid},K.DetachDatabase.prototype.execute=function(e,t,r){if(!A.databases[this.databaseid].engineid)throw new Error('Cannot detach database "'+this.engineid+'", because it was not attached.');var n,a=this.databaseid;if(a==A.DEFAULTDATABASEID)throw new Error("Drop of default database is prohibited");if(A.databases[a])delete A.databases[a],a==A.useid&&A.use(),n=1;else{if(!this.ifexists)throw new Error("Database '"+a+"' does not exist");n=0}return r&&r(n),n},K.UseDatabase=function(e){return K.extend(this,e)},K.UseDatabase.prototype.toString=function(){return"USE DATABASE "+this.databaseid},K.UseDatabase.prototype.execute=function(e,t,r){var n=this.databaseid;if(!A.databases[n])throw new Error("Database '"+n+"' does not exist");A.use(n);return r&&r(1),1},K.DropDatabase=function(e){return K.extend(this,e)},K.DropDatabase.prototype.toString=function(){var e="DROP";return this.ifexists&&(e+=" IF EXISTS"),e+=" DATABASE "+this.databaseid},K.DropDatabase.prototype.execute=function(e,t,r){if(this.engineid)return A.engines[this.engineid].dropDatabase(this.databaseid,this.ifexists,r);var n,a=this.databaseid;if(a==A.DEFAULTDATABASEID)throw new Error("Drop of default database is prohibited");if(A.databases[a]){if(A.databases[a].engineid)throw new Error("Cannot drop database '"+a+"', because it is attached. Detach it.");delete A.databases[a],a==A.useid&&A.use(),n=1}else{if(!this.ifexists)throw new Error("Database '"+a+"' does not exist");n=0}return r&&r(n),n},K.Declare=function(e){return K.extend(this,e)},K.Declare.prototype.toString=function(){var e="DECLARE ";return this.declares&&this.declares.length>0&&(e=this.declares.map(function(e){var t="";return t+="@"+e.variable+" ",t+=e.dbtypeid,this.dbsize&&(t+="("+this.dbsize,this.dbprecision&&(t+=","+this.dbprecision),t+=")"),e.expression&&(t+=" = "+e.expression.toString()),t}).join(",")),e},K.Declare.prototype.execute=function(e,t,r){var n=1;return this.declares&&this.declares.length>0&&this.declares.map(function(e){var r=e.dbtypeid;A.fn[r]||(r=r.toUpperCase()),A.declares[e.variable]={dbtypeid:r,dbsize:e.dbsize,dbprecision:e.dbprecision},e.expression&&(A.vars[e.variable]=new Function("params,alasql","return "+e.expression.toJS("({})","",null))(t,A),A.declares[e.variable]&&(A.vars[e.variable]=A.stdfn.CONVERT(A.vars[e.variable],A.declares[e.variable])))}),r&&(n=r(n)),n},K.ShowDatabases=function(e){return K.extend(this,e)},K.ShowDatabases.prototype.toString=function(){var e="SHOW DATABASES";return this.like&&(e+="LIKE "+this.like.toString()),e},K.ShowDatabases.prototype.execute=function(e,t,r){if(this.engineid)return A.engines[this.engineid].showDatabases(this.like,r);var n=this,a=[];for(dbid in A.databases)a.push({databaseid:dbid});return n.like&&a&&a.length>0&&(a=a.filter(function(e){return A.utils.like(n.like.value,e.databaseid)})),r&&r(a),a},K.ShowTables=function(e){return K.extend(this,e)},K.ShowTables.prototype.toString=function(){var e="SHOW TABLES";return this.databaseid&&(e+=" FROM "+this.databaseid),this.like&&(e+=" LIKE "+this.like.toString()),e},K.ShowTables.prototype.execute=function(e,t,r){var n=A.databases[this.databaseid||e],a=this,s=[];for(tableid in n.tables)s.push({tableid:tableid})
 ;return a.like&&s&&s.length>0&&(s=s.filter(function(e){return A.utils.like(a.like.value,e.tableid)})),r&&r(s),s},K.ShowColumns=function(e){return K.extend(this,e)},K.ShowColumns.prototype.toString=function(){var e="SHOW COLUMNS";return this.table.tableid&&(e+=" FROM "+this.table.tableid),this.databaseid&&(e+=" FROM "+this.databaseid),e},K.ShowColumns.prototype.execute=function(e,t,r){var n=A.databases[this.databaseid||e],a=n.tables[this.table.tableid];if(a&&a.columns){var s=a.columns.map(function(e){return{columnid:e.columnid,dbtypeid:e.dbtypeid,dbsize:e.dbsize}});return r&&r(s),s}return r&&r([]),[]},K.ShowIndex=function(e){return K.extend(this,e)},K.ShowIndex.prototype.toString=function(){var e="SHOW INDEX";return this.table.tableid&&(e+=" FROM "+this.table.tableid),this.databaseid&&(e+=" FROM "+this.databaseid),e},K.ShowIndex.prototype.execute=function(e,t,r){var n=A.databases[this.databaseid||e],a=n.tables[this.table.tableid],s=[];if(a&&a.indices)for(var i in a.indices)s.push({hh:i,len:Object.keys(a.indices[i]).length});return r&&r(s),s},K.ShowCreateTable=function(e){return K.extend(this,e)},K.ShowCreateTable.prototype.toString=function(){var e="SHOW CREATE TABLE "+this.table.tableid;return this.databaseid&&(e+=" FROM "+this.databaseid),e},K.ShowCreateTable.prototype.execute=function(e){var t=A.databases[this.databaseid||e],r=t.tables[this.table.tableid];if(r){var n="CREATE TABLE "+this.table.tableid+" (",a=[];return r.columns&&(r.columns.forEach(function(e){var t=e.columnid+" "+e.dbtypeid;e.dbsize&&(t+="("+e.dbsize+")"),e.primarykey&&(t+=" PRIMARY KEY"),a.push(t)}),n+=a.join(", ")),n+=")"}throw new Error('There is no such table "'+this.table.tableid+'"')},K.SetVariable=function(e){return K.extend(this,e)},K.SetVariable.prototype.toString=function(){var e="SET ";return void 0!==this.value&&(e+=this.variable.toUpperCase()+" "+(this.value?"ON":"OFF")),this.expression&&(e+=this.method+this.variable+" = "+this.expression.toString()),e},K.SetVariable.prototype.execute=function(e,t,r){if(void 0!==this.value){var n=this.value;"ON"==n?n=!0:"OFF"==n&&(n=!1),A.options[this.variable]=n}else if(this.expression){this.exists&&(this.existsfn=this.exists.map(function(t){var r=t.compile(e);return r.query&&!r.query.modifier&&(r.query.modifier="RECORDSET"),r})),this.queries&&(this.queriesfn=this.queries.map(function(t){var r=t.compile(e);return r.query&&!r.query.modifier&&(r.query.modifier="RECORDSET"),r}));var a=new Function("params,alasql","return "+this.expression.toJS("({})","",null)).bind(this)(t,A);if(A.declares[this.variable]&&(a=A.stdfn.CONVERT(a,A.declares[this.variable])),this.props&&this.props.length>0){if("@"==this.method)var s="alasql.vars['"+this.variable+"']";else var s="params['"+this.variable+"']";s+=this.props.map(function(e){return"string"==typeof e?"['"+e+"']":"number"==typeof e?"["+e+"]":"["+e.toJS()+"]"}).join(),new Function("value,params,alasql","var y;"+s+"=value")(a,t,A)}else"@"==this.method?A.vars[this.variable]=a:t[this.variable]=a}var a=1;return r&&(a=r(a)),a},A.test=function(e,t,r){if(0===arguments.length)return void A.log(A.con.results);if(1===arguments.length){var n=Date.now();return r(),void A.con.log(Date.now()-n)}2===arguments.length&&(r=t,t=1);for(var n=Date.now(),a=0;a<t;a++)r();A.con.results[e]=Date.now()-n},A.log=function(e,t){var r=A.useid,n=A.options.logtarget;C.isNode&&(n="console");var a;if(a="string"==typeof e?A(e,t):e,"console"===n||C.isNode)"string"==typeof e&&A.options.logprompt&&console.log(r+">",e),Array.isArray(a)&&console.table?console.table(a):console.log(ue(a));else{var s;s="output"===n?document.getElementsByTagName("output")[0]:"string"==typeof n?document.getElementById(n):n;var i="";if("string"==typeof e&&A.options.logprompt&&(i+="<pre><code>"+A.pretty(e)+"</code></pre>"),Array.isArray(a))if(0===a.length)i+="<p>[ ]</p>";else if("object"!=typeof a[0]||Array.isArray(a[0]))for(var o=0,u=a.length;o<u;o++)i+="<p>"+g(a[o])+"</p>";else i+=g(a);else i+=g(a);s.innerHTML+=i}},A.clear=function(){var e=A.options.logtarget;if(C.isNode||C.isMeteorServer)console.clear&&console.clear();else{var t;t="output"===e?document.getElementsByTagName("output")[0]:"string"==typeof e?document.getElementById(e):e,t.innerHTML=""}},A.write=function(e){var t=A.options.logtarget;if(C.isNode||C.isMeteorServer)console.log&&console.log(e);else{var r;r="output"===t?document.getElementsByTagName("output")[0]:"string"==typeof t?document.getElementById(t):t,r.innerHTML+=e}},A.prompt=function(e,t,r){if(C.isNode)throw new Error("The prompt not realized for Node.js");var n=0;if("string"==typeof e&&(e=document.getElementById(e)),"string"==typeof t&&(t=document.getElementById(t)),t.textContent=A.useid,r){A.prompthistory.push(r),n=A.prompthistory.length;try{var a=Date.now();A.log(r),A.write('<p style="color:blue">'+(Date.now()-a)+" ms</p>")}catch(e){A.write("<p>"+olduseid+"&gt;&nbsp;<b>"+sql+"</b></p>"),A.write('<p style="color:red">'+e+"<p>")}}var s=e.getBoundingClientRect().top+document.getElementsByTagName("body")[0].scrollTop;m(document.getElementsByTagName("body")[0],s,500),e.onkeydown=function(r){if(13===r.which){var a=e.value,s=A.useid;e.value="",A.prompthistory.push(a),n=A.prompthistory.length;try{var i=Date.now();A.log(a),A.write('<p style="color:blue">'+(Date.now()-i)+" ms</p>")}catch(e){A.write("<p>"+s+"&gt;&nbsp;"+A.pretty(a,!1)+"</p>"),A.write('<p style="color:red">'+e+"<p>")}e.focus(),t.textContent=A.useid;var o=e.getBoundingClientRect().top+document.getElementsByTagName("body")[0].scrollTop;m(document.getElementsByTagName("body")[0],o,500)}else 38===r.which?(n--,n<0&&(n=0),A.prompthistory[n]&&(e.value=A.prompthistory[n],r.preventDefault())):40===r.which&&(n++,n>=A.prompthistory.length?(n=A.prompthistory.length,e.value=""):A.prompthistory[n]&&(e.value=A.prompthistory[n],r.preventDefault()))}},K.BeginTransaction=function(e){return K.extend(this,e)},K.BeginTransaction.prototype.toString=function(){return"BEGIN TRANSACTION"},K.BeginTransaction.prototype.execute=function(e,t,r){return A.databases[e].engineid?A.engines[A.databases[A.useid].engineid].begin(e,r):(r&&r(1),1)},K.CommitTransaction=function(e){return K.extend(this,e)},K.CommitTransaction.prototype.toString=function(){return"COMMIT TRANSACTION"},K.CommitTransaction.prototype.execute=function(e,t,r){return A.databases[e].engineid?A.engines[A.databases[A.useid].engineid].commit(e,r):(r&&r(1),1)},K.RollbackTransaction=function(e){return K.extend(this,e)},K.RollbackTransaction.prototype.toString=function(){return"ROLLBACK TRANSACTION"},K.RollbackTransaction.prototype.execute=function(e,t,r){return A.databases[e].engineid?A.engines[A.databases[e].engineid].rollback(e,r):(r&&r(1),1)},A.options.tsql&&(A.stdfn.OBJECT_ID=function(e,t){void 0===t&&(t="T"),t=t.toUpperCase();var r=e.split("."),n=A.useid,a=r[0];2==r.length&&(n=r[0],a=r[1]);var s=A.databases[n].tables;n=A.databases[n].databaseid;for(var i in s)if(i==a){if(s[i].view&&"V"==t)return n+"."+i;if(!s[i].view&&"T"==t)return n+"."+i;return}}),A.options.mysql,(A.options.mysql||A.options.sqlite)&&(A.from.INFORMATION_SCHEMA=function(e,t,r,n,a){if("VIEWS"==e||"TABLES"==e){var s=[];for(var i in A.databases){var o=A.databases[i].tables;for(var u in o)(o[u].view&&"VIEWS"==e||!o[u].view&&"TABLES"==e)&&s.push({TABLE_CATALOG:i,TABLE_NAME:u})}return r&&(s=r(s,n,a)),s}throw new Error("Unknown INFORMATION_SCHEMA table")}),A.options.postgres,A.options.oracle,A.options.sqlite,A.into.SQL=function(e,t,r,n,a){var s;"object"==typeof e&&(t=e,e=void 0);var i={};if(A.utils.extend(i,t),void 0===i.tableid)throw new Error("Table for INSERT TO is not defined.");var o="";0===n.length&&"object"==typeof r[0]&&(n=Object.keys(r[0]).map(function(e){return{columnid:e}}));for(var u=0,c=r.length;u<c;u++)o+="INSERT INTO "+t.tableid+"(",o+=n.map(function(e){return e.columnid}).join(","),o+=") VALUES (",o+=n.map(function(e){var t=r[u][e.columnid];return e.typeid?"STRING"!==e.typeid&&"VARCHAR"!==e.typeid&&"NVARCHAR"!==e.typeid&&"CHAR"!==e.typeid&&"NCHAR"!==e.typeid||(t="'"+O(t)+"'"):"string"==typeof t&&(t="'"+O(t)+"'"),t}),o+=");\n";return e=A.utils.autoExtFilename(e,"sql",t),s=A.utils.saveFile(e,o),a&&(s=a(s)),s},A.into.HTML=function(e,t,r,n,a){var s=1;if("object"!=typeof exports){var i={headers:!0};A.utils.extend(i,t);var o=document.querySelector(e);if(!o)throw new Error("Selected HTML element is not found");0===n.length&&"object"==typeof r[0]&&(n=Object.keys(r[0]).map(function(e){return{columnid:e}}));var u=document.createElement("table"),c=document.createElement("thead");if(u.appendChild(c),i.headers){for(var l=document.createElement("tr"),h=0;h<n.length;h++){var d=document.createElement("th");d.textContent=n[h].columnid,l.appendChild(d)}c.appendChild(l)}var f=document.createElement("tbody");u.appendChild(f);for(var p=0;p<r.length;p++){for(var l=document.createElement("tr"),h=0;h<n.length;h++){var d=document.createElement("td");d.textContent=r[p][n[h].columnid],l.appendChild(d)}f.appendChild(l)}A.utils.domEmptyChildren(o),o.appendChild(u)}return a&&(s=a(s)),s},A.into.JSON=function(e,t,r,n,a){var s=1;"object"==typeof e&&(t=e,e=void 0);var i=JSON.stringify(r);return e=A.utils.autoExtFilename(e,"json",t),s=A.utils.saveFile(e,i),a&&(s=a(s)),s},A.into.TXT=function(e,t,r,n,a){0===n.length&&r.length>0&&(n=Object.keys(r[0]).map(function(e){return{columnid:e}})),"object"==typeof e&&(t=e,e=void 0);var s=r.length,i="";if(r.length>0){var o=n[0].columnid;i+=r.map(function(e){return e[o]}).join("\n")}return e=A.utils.autoExtFilename(e,"txt",t),s=A.utils.saveFile(e,i),a&&(s=a(s)),s},A.into.TAB=A.into.TSV=function(e,t,r,n,a){var s={};return A.utils.extend(s,t),s.separator="\t",e=A.utils.autoExtFilename(e,"tab",t),s.autoExt=!1,A.into.CSV(e,s,r,n,a)},A.into.CSV=function(e,t,r,n,a){0===n.length&&r.length>0&&(n=Object.keys(r[0]).map(function(e){return{columnid:e}})),"object"==typeof e&&(t=e,e=void 0);var s={headers:!0};s.separator=";",s.quote='"',s.utf8Bom=!0,t&&!t.headers&&void 0!==t.headers&&(s.utf8Bom=!1),A.utils.extend(s,t);var i=r.length,o=s.utf8Bom?"\ufeff":"";return s.headers&&(o+=s.quote+n.map(function(e){return e.columnid.trim()}).join(s.quote+s.separator+s.quote)+s.quote+"\r\n"),r.forEach(function(e){o+=n.map(function(t){var r=e[t.columnid];return""!==s.quote&&(r=(r+"").replace(new RegExp("\\"+s.quote,"g"),s.quote+s.quote)),+r!=r&&(r=s.quote+r+s.quote),r}).join(s.separator)+"\r\n"}),e=A.utils.autoExtFilename(e,"csv",t),i=A.utils.saveFile(e,o,null,{disableAutoBom:!0}),a&&(i=a(i)),i},A.into.XLS=function(e,t,r,n,a){"object"==typeof e&&(t=e,e=void 0);var s={};t&&t.sheets&&(s=t.sheets);var i={headers:!0};void 0!==s.Sheet1?i=s[0]:void 0!==t&&(i=t),void 0===i.sheetid&&(i.sheetid="Sheet1");var o=function(){var e='<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" \t\txmlns="http://www.w3.org/TR/REC-html40"><head> \t\t<meta charset="utf-8" /> \t\t\x3c!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets> ';if(e+=" <x:ExcelWorksheet><x:Name>"+i.sheetid+"</x:Name><x:WorksheetOptions><x:DisplayGridlines/>     </x:WorksheetOptions> \t\t</x:ExcelWorksheet>",e+="</x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--\x3e</head>",e+="<body",void 0!==i.style&&(e+=' style="',"function"==typeof i.style?e+=i.style(i):e+=i.style,e+='"'),e+=">",e+="<table>",void 0!==i.caption){var a=i.caption;"string"==typeof a&&(a={title:a}),e+="<caption",void 0!==a.style&&(e+=' style="',"function"==typeof a.style?e+=a.style(i,a):e+=a.style,e+='" '),e+=">",e+=a.title,e+="</caption>"}return void 0!==i.columns?n=i.columns:0==n.length&&r.length>0&&"object"==typeof r[0]&&(n=Array.isArray(r[0])?r[0].map(function(e,t){return{columnid:t}}):Object.keys(r[0]).map(function(e){return{columnid:e}})),n.forEach(function(e,t){void 0!==i.column&&G(e,i.column),void 0===e.width&&(i.column&&"undefined"!=i.column.width?e.width=i.column.width:e.width="120px"),"number"==typeof e.width&&(e.width=e.width+"px"),void 0===e.columnid&&(e.columnid=t),void 0===e.title&&(e.title=""+e.columnid.trim()),i.headers&&Array.isArray(i.headers)&&(e.title=i.headers[t])}),e+="<colgroups>",n.forEach(function(t){e+='<col style="width: '+t.width+'"></col>'}),e+="</colgroups>",i.headers&&(e+="<thead>",e+="<tr>",n.forEach(function(t,r){e+="<th ",void 0!==t.style&&(e+=' style="',"function"==typeof t.style?e+=t.style(i,t,r):e+=t.style,e+='" '),e+=">",void 0!==t.title&&("function"==typeof t.title?e+=t.title(i,t,r):e+=t.title),e+="</th>"}),e+="</tr>",e+="</thead>"),e+="<tbody>",r&&r.length>0&&r.forEach(function(r,a){if(!(a>i.limit)){e+="<tr";var s={};G(s,i.row),i.rows&&i.rows[a]&&G(s,i.rows[a]),void 0!==s&&void 0!==s.style&&(e+=' style="',"function"==typeof s.style?e+=s.style(i,r,a):e+=s.style,e+='" '),e+=">",n.forEach(function(n,o){var u={};G(u,i.cell),G(u,s.cell),void 0!==i.column&&G(u,i.column.cell),G(u,n.cell),i.cells&&i.cells[a]&&i.cells[a][o]&&G(u,i.cells[a][o]);var c=r[n.columnid];"function"==typeof u.value&&(c=u.value(c,i,r,n,u,a,o));var l=u.typeid;"function"==typeof l&&(l=l(c,i,r,n,u,a,o)),void 0===l&&("number"==typeof c?l="number":"string"==typeof c?l="string":"boolean"==typeof c?l="boolean":"object"==typeof c&&c instanceof Date&&(l="date"));var h="";"money"==l?h='mso-number-format:"\\#\\,\\#\\#0\\\\ _р_\\.";white-space:normal;':"number"==l?h=" ":"date"==l?h='mso-number-format:"Short Date";':t.types&&t.types[l]&&t.types[l].typestyle&&(h=t.types[l].typestyle),h=h||'mso-number-format:"\\@";',e+="<td style='"+h+"' ",void 0!==u.style&&(e+=' style="',"function"==typeof u.style?e+=u.style(c,i,r,n,a,o):e+=u.style,e+='" '),e+=">";var d=u.format;if(void 0===c)e+="";else if(void 0!==d)if("function"==typeof d)e+=d(c);else{if("string"!=typeof d)throw new Error("Unknown format type. Should be function or string");e+=c}else e+="number"==l||"date"==l?c.toString():"money"==l?(+c).toFixed(2):c;e+="</td>"}),e+="</tr>"}}),e+="</tbody>",e+="</table>",e+="</body>",e+="</html>"}();e=A.utils.autoExtFilename(e,"xls",t);var u=A.utils.saveFile(e,o);return a&&(u=a(u)),u},A.into.XLSXML=function(e,t,r,n,a){t=t||{},"object"==typeof e&&(t=e,e=void 0);var s={};t&&t.sheets?s=t.sheets:s.Sheet1=t,e=A.utils.autoExtFilename(e,"xls",t);var i=A.utils.saveFile(e,function(){function e(e){var t="";for(var r in e){t+="<"+r;for(var n in e[r])t+=" ","x:"==n.substr(0,2)?t+=n:t+="ss:",t+=n+'="'+e[r][n]+'"';t+="/>"}var s=D(t);return o[s]||(o[s]={styleid:u},a+='<Style ss:ID="s'+u+'">',a+=t,a+="</Style>",u++),"s"+o[s].styleid}var a="",i=" </Styles>",o={},u=62;for(var c in s){var l=s[c];void 0!==l.columns?n=l.columns:0==n.length&&r.length>0&&"object"==typeof r[0]&&(n=Array.isArray(r[0])?r[0].map(function(e,t){return{columnid:t}}):Object.keys(r[0]).map(function(e){return{columnid:e}})),n.forEach(function(e,t){void 0!==l.column&&G(e,l.column),void 0===e.width&&(l.column&&void 0!==l.column.width?e.width=l.column.width:e.width=120),"number"==typeof e.width&&(e.width=e.width),void 0===e.columnid&&(e.columnid=t),void 0===e.title&&(e.title=""+e.columnid.trim()),l.headers&&Array.isArray(l.headers)&&(e.title=l.headers[idx])}),i+='<Worksheet ss:Name="'+c+'"> \t  \t\t\t<Table ss:ExpandedColumnCount="'+n.length+'" ss:ExpandedRowCount="'+((l.headers?1:0)+Math.min(r.length,l.limit||r.length))+'" x:FullColumns="1" \t   \t\t\tx:FullRows="1" ss:DefaultColumnWidth="65" ss:DefaultRowHeight="15">',n.forEach(function(e,t){i+='<Column ss:Index="'+(t+1)+'" ss:AutoFitWidth="0" ss:Width="'+e.width+'"/>'}),l.headers&&(i+='<Row ss:AutoFitHeight="0">',n.forEach(function(t,r){if(i+="<Cell ",void 0!==t.style){var n={};"function"==typeof t.style?G(n,t.style(l,t,r)):G(n,t.style),i+='ss:StyleID="'+e(n)+'"'}i+='><Data ss:Type="String">',void 0!==t.title&&("function"==typeof t.title?i+=t.title(l,t,r):i+=t.title),i+="</Data></Cell>"}),i+="</Row>"),r&&r.length>0&&r.forEach(function(r,a){if(!(a>l.limit)){var s={};if(G(s,l.row),l.rows&&l.rows[a]&&G(s,l.rows[a]),i+="<Row ",void 0!==s){var o={};void 0!==s.style&&("function"==typeof s.style?G(o,s.style(l,r,a)):G(o,s.style),i+='ss:StyleID="'+e(o)+'"')}i+=">",n.forEach(function(n,o){var u={};G(u,l.cell),G(u,s.cell),void 0!==l.column&&G(u,l.column.cell),G(u,n.cell),l.cells&&l.cells[a]&&l.cells[a][o]&&G(u,l.cells[a][o]);var c=r[n.columnid];"function"==typeof u.value&&(c=u.value(c,l,r,n,u,a,o));var h=u.typeid;"function"==typeof h&&(h=h(c,l,r,n,u,a,o)),void 0===h&&("number"==typeof c?h="number":"string"==typeof c?h="string":"boolean"==typeof c?h="boolean":"object"==typeof c&&c instanceof Date&&(h="date"));var d="String";"number"==h?d="Number":"date"==h&&(d="Date");var f="";"money"==h?f='mso-number-format:"\\#\\,\\#\\#0\\\\ _р_\\.";white-space:normal;':"number"==h?f=" ":"date"==h?f='mso-number-format:"Short Date";':t.types&&t.types[h]&&t.types[h].typestyle&&(f=t.types[h].typestyle),f=f||'mso-number-format:"\\@";',i+="<Cell ";var p={};void 0!==u.style&&("function"==typeof u.style?G(p,u.style(c,l,r,n,a,o)):G(p,u.style),i+='ss:StyleID="'+e(p)+'"'),i+=">",i+='<Data ss:Type="'+d+'">';var b=u.format;if(void 0===c)i+="";else if(void 0!==b)if("function"==typeof b)i+=b(c);else{if("string"!=typeof b)throw new Error("Unknown format type. Should be function or string");i+=c}else i+="number"==h||"date"==h?c.toString():"money"==h?(+c).toFixed(2):c;i+="</Data></Cell>"}),i+="</Row>"}}),i+="</Table></Worksheet>"}return i+="</Workbook>",'<?xml version="1.0"?> \t\t<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" \t\t xmlns:o="urn:schemas-microsoft-com:office:office" \t\t xmlns:x="urn:schemas-microsoft-com:office:excel" \t\t xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" \t\t xmlns:html="http://www.w3.org/TR/REC-html40"> \t\t <DocumentProperties xmlns="urn:schemas-microsoft-com:office:office"> \t\t </DocumentProperties> \t\t <OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office"> \t\t  <AllowPNG/> \t\t </OfficeDocumentSettings> \t\t <ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel"> \t\t  <ActiveSheet>0</ActiveSheet> \t\t </ExcelWorkbook> \t\t <Styles> \t\t  <Style ss:ID="Default" ss:Name="Normal"> \t\t   <Alignment ss:Vertical="Bottom"/> \t\t   <Borders/> \t\t   <Font ss:FontName="Calibri" x:Family="Swiss" ss:Size="12" ss:Color="#000000"/> \t\t   <Interior/> \t\t   <NumberFormat/> \t\t   <Protection/> \t\t  </Style>'+a+i}());return a&&(i=a(i)),i},A.into.XLSX=function(e,t,r,n,s){function i(){"object"==typeof t&&Array.isArray(t)?r&&r.length>0&&r.forEach(function(e,r){o(t[r],e,void 0,r+1)}):o(t,r,n,1),u(s)}function o(e,t,r,n){var a={sheetid:"Sheet "+n,headers:!0};A.utils.extend(a,e);var s=Object.keys(t).length;(!r||0==r.length)&&s>0&&(r=Object.keys(t[0]).map(function(e){return{columnid:e}}));var i={};h.SheetNames.indexOf(a.sheetid)>-1?i=h.Sheets[a.sheetid]:(h.SheetNames.push(a.sheetid),h.Sheets[a.sheetid]={},i=h.Sheets[a.sheetid]);var o="A1";a.range&&(o=a.range);var u=A.utils.xlscn(o.match(/[A-Z]+/)[0]),c=+o.match(/[0-9]+/)[0]-1;if(h.Sheets[a.sheetid]["!ref"])var l=h.Sheets[a.sheetid]["!ref"],d=A.utils.xlscn(l.match(/[A-Z]+/)[0]),f=+l.match(/[0-9]+/)[0]-1;else var d=1,f=1;var p=Math.max(u+r.length,d),b=Math.max(c+s+2,f),E=c+1;h.Sheets[a.sheetid]["!ref"]="A1:"+A.utils.xlsnc(p)+b,a.headers&&(r.forEach(function(e,t){i[A.utils.xlsnc(u+t)+""+E]={v:e.columnid.trim()}}),E++);for(var g=0;g<s;g++)r.forEach(function(e,r){var n={v:t[g][e.columnid]};"number"==typeof t[g][e.columnid]?n.t="n":"string"==typeof t[g][e.columnid]?n.t="s":"boolean"==typeof t[g][e.columnid]?n.t="b":"object"==typeof t[g][e.columnid]&&t[g][e.columnid]instanceof Date&&(n.t="d"),i[A.utils.xlsnc(u+r)+""+E]=n}),E++}function u(t){var r;if(void 0===e)c=h;else if(r=B(),C.isNode||C.isMeteorServer)r.writeFile(h,e);else{var n={bookType:"xlsx",bookSST:!1,type:"binary"},s=r.write(h,n);if(9==a())throw new Error("Cannot save XLSX files in IE9. Please use XLS() export function");be(new Blob([function(e){for(var t=new ArrayBuffer(e.length),r=new Uint8Array(t),n=0;n!=e.length;++n)r[n]=255&e.charCodeAt(n);return t}(s)],{type:"application/octet-stream"}),e)}}var c=1;P(n,[{columnid:"_"}])&&(r=r.map(function(e){return e._}),n=void 0),e=A.utils.autoExtFilename(e,"xlsx",t);var l=B();"object"==typeof e&&(t=e,e=void 0);var h={SheetNames:[],Sheets:{}};return t.sourcefilename?A.utils.loadBinaryFile(t.sourcefilename,!!s,function(e){h=l.read(e,{type:"binary"}),i()}):i(),s&&(c=s(c)),c},A.from.METEOR=function(e,t,r,n,a){var s=e.find(t).fetch();return r&&(s=r(s,n,a)),s},A.from.TABLETOP=function(e,t,r,n,a){var s=[],i={headers:!0,simpleSheet:!0,key:e};return A.utils.extend(i,t),i.callback=function(e){s=e,r&&(s=r(s,n,a))},Tabletop.init(i),null},A.from.HTML=function(e,t,r,n,a){var s={};A.utils.extend(s,t);var i=document.querySelector(e);if(!i&&"TABLE"!==i.tagName)throw new Error("Selected HTML element is not a TABLE");var o=[],u=s.headers;if(u&&!Array.isArray(u)){u=[];for(var c=i.querySelector("thead tr").children,l=0;l<c.length;l++)c.item(l).style&&"none"===c.item(l).style.display&&s.skipdisplaynone?u.push(void 0):u.push(c.item(l).textContent)}for(var h=i.querySelectorAll("tbody tr"),d=0;d<h.length;d++){for(var f=h.item(d).children,p={},l=0;l<f.length;l++)f.item(l).style&&"none"===f.item(l).style.display&&s.skipdisplaynone||(u?p[u[l]]=f.item(l).textContent:p[l]=f.item(l).textContent);o.push(p)}return r&&(o=r(o,n,a)),o},A.from.RANGE=function(e,t,r,n,a){for(var s=[],i=e;i<=t;i++)s.push(i);return r&&(s=r(s,n,a)),s},A.from.FILE=function(e,t,r,n,a){var s;if("string"==typeof e)s=e;else{if(!(e instanceof Event))throw new Error("Wrong usage of FILE() function");s=e.target.files[0].name}var i=s.split("."),o=i[i.length-1].toUpperCase();if(A.from[o])return A.from[o](e,t,r,n,a);throw new Error("Cannot recognize file type for loading")},A.from.JSON=function(e,t,r,n,a){var s;return e=A.utils.autoExtFilename(e,"json",t),A.utils.loadFile(e,!!r,function(e){s=JSON.parse(e),r&&(s=r(s,n,a))}),s},A.from.TXT=function(e,t,r,n,a){var s;return e=A.utils.autoExtFilename(e,"txt",t),A.utils.loadFile(e,!!r,function(e){s=e.split(/\r?\n/),""===s[s.length-1]&&s.pop();for(var t=0,i=s.length;t<i;t++)s[t]==+s[t]&&(s[t]=+s[t]),s[t]=[s[t]];r&&(s=r(s,n,a))}),s},A.from.TAB=A.from.TSV=function(e,t,r,n,a){return t=t||{},t.separator="\t",e=A.utils.autoExtFilename(e,"tab",t),t.autoext=!1,A.from.CSV(e,t,r,n,a)},A.from.CSV=function(e,t,r,n,a){function s(e){function t(){if(E>=b)return f;if(c)return c=!1,d;var t=E;if(e.charCodeAt(t)===h){for(var r=t;r++<b;)if(e.charCodeAt(r)===h){if(e.charCodeAt(r+1)!==h)break;++r}E=r+2;var n=e.charCodeAt(r+1);return 13===n?(c=!0,10===e.charCodeAt(r+2)&&++E):10===n&&(c=!0),e.substring(t+1,r).replace(/""/g,'"')}for(;E<b;){var n=e.charCodeAt(E++),a=1;if(10===n)c=!0;else if(13===n)c=!0,10===e.charCodeAt(E)&&(++E,++a);else if(n!==l)continue;return e.substring(t,E-a)}return e.substring(t)}for(var s,c,l=i.separator.charCodeAt(0),h=i.quote.charCodeAt(0),d={},f={},p=[],b=e.length,E=0,g=0;(s=t())!==f;){for(var m=[];s!==d&&s!==f;)m.push(s.trim()),s=t();if(i.headers){if(0===g){if("boolean"==typeof i.headers)u=m;else if(Array.isArray(i.headers)){u=i.headers;var v={};u.forEach(function(e,t){v[e]=m[t],void 0!==v[e]&&0!==v[e].length&&v[e].trim()==+v[e]&&(v[e]=+v[e])}),p.push(v)}}else{var v={};u.forEach(function(e,t){v[e]=m[t],void 0!==v[e]&&0!==v[e].length&&v[e].trim()==+v[e]&&(v[e]=+v[e])}),p.push(v)}g++}else p.push(m)}if(o=p,i.headers&&a&&a.sources&&a.sources[n]){var S=a.sources[n].columns=[];u.forEach(function(e){S.push({columnid:e})})}r&&(o=r(o,n,a))}var i={separator:",",quote:'"',headers:!0};A.utils.extend(i,t);var o,u=[];return new RegExp("\n").test(e)?s(e):(e=A.utils.autoExtFilename(e,"csv",t),A.utils.loadFile(e,!!r,s)),o},A.from.XLS=function(e,t,r,n,a){return t=t||{},e=A.utils.autoExtFilename(e,"xls",t),t.autoExt=!1,S(B(),e,t,r,n,a)},A.from.XLSX=function(e,t,r,n,a){return t=t||{},e=A.utils.autoExtFilename(e,"xlsx",t),t.autoExt=!1,S(B(),e,t,r,n,a)},A.from.ODS=function(e,t,r,n,a){return t=t||{},e=A.utils.autoExtFilename(e,"ods",t),t.autoExt=!1,S(B(),e,t,r,n,a)},A.from.XML=function(e,t,r,n,a){var s;return A.utils.loadFile(e,!!r,function(e){s=T(e).root,r&&(s=r(s,n,a))}),s},A.from.GEXF=function(e,t,r,n,a){var s;return A("SEARCH FROM XML("+e+")",[],function(e){s=e,console.log(s),r&&(s=r(s))}),s},K.Print=function(e){return K.extend(this,e)},K.Print.prototype.toString=function(){var e="PRINT";return this.statement&&(e+=" "+this.statement.toString()),e},K.Print.prototype.execute=function(e,t,r){var n=this,a=1;if(A.precompile(this,e,t),this.exprs&&this.exprs.length>0){var s=this.exprs.map(function(e){var r=new Function("params,alasql,p","var y;return "+e.toJS("({})","",null)).bind(n),a=r(t,A);return ue(a)});console.log.apply(console,s)}else if(this.select){var i=this.select.execute(e,t);console.log(ue(i))}else console.log();return r&&(a=r(a)),a},K.Source=function(e){return K.extend(this,e)},K.Source.prototype.toString=function(){var e="SOURCE";return this.url&&(e+=" '"+this.url+" '"),e},K.Source.prototype.execute=function(e,t,r){var n;return x(this.url,!!r,function(e){return n=A(e),r&&(n=r(n)),n},function(e){throw e}),n},K.Require=function(e){return K.extend(this,e)},K.Require.prototype.toString=function(){var e="REQUIRE";return this.paths&&this.paths.length>0&&(e+=this.paths.map(function(e){return e.toString()}).join(",")),this.plugins&&this.plugins.length>0&&(e+=this.plugins.map(function(e){return e.toUpperCase()}).join(",")),e},K.Require.prototype.execute=function(e,t,r){var n=this,a=0,s="";return this.paths&&this.paths.length>0?this.paths.forEach(function(e){x(e.value,!!r,function(e){a++,s+=e,a<n.paths.length||(new Function("params,alasql",s)(t,A),r&&(a=r(a)))})}):this.plugins&&this.plugins.length>0?this.plugins.forEach(function(e){A.plugins[e]||x(A.path+"/alasql-"+e.toLowerCase()+".js",!!r,function(i){a++,s+=i,a<n.plugins.length||(new Function("params,alasql",s)(t,A),A.plugins[e]=!0,r&&(a=r(a)))})}):r&&(a=r(a)),a},K.Assert=function(e){return K.extend(this,e)},K.Source.prototype.toString=function(){var e="ASSERT";return this.value&&(e+=" "+JSON.stringify(this.value)),e},K.Assert.prototype.execute=function(e){if(!P(A.res,this.value))throw new Error((this.message||"Assert wrong")+": "+JSON.stringify(A.res)+" == "+JSON.stringify(this.value));return 1};var le=A.engines.WEBSQL=function(){};le.createDatabase=function(e,t,r,n){var a=openDatabase(e,t[0],t[1],t[2]);if(this.dbid){var s=A.createDatabase(this.dbid);s.engineid="WEBSQL",s.wdbid=e,sb.wdb=s}if(!a)throw new Error('Cannot create WebSQL database "'+databaseid+'"');return n&&n(1),1},le.dropDatabase=function(e){throw new Error("This is impossible to drop WebSQL database.")},le.attachDatabase=function(e,t,r,n,a){if(A.databases[t])throw new Error('Unable to attach database as "'+t+'" because it already exists');return alasqlopenDatabase(e,r[0],r[1],r[2]),1};var he=A.engines.INDEXEDDB=function(){};C.hasIndexedDB&&("function"==typeof C.global.indexedDB.webkitGetDatabaseNames?he.getDatabaseNames=C.global.indexedDB.webkitGetDatabaseNames.bind(C.global.indexedDB):(he.getDatabaseNames=function(){var e={},t={contains:function(e){return!0},notsupported:!0};return setTimeout(function(){var r={target:{result:t}};e.onsuccess(r)},0),e},he.getDatabaseNamesNotSupported=!0)),he.showDatabases=function(e,t){he.getDatabaseNames().onsuccess=function(r){var n=r.target.result;if(he.getDatabaseNamesNotSupported)throw new Error("SHOW DATABASE is not supported in this browser");var a=[];if(e)var s=new RegExp(e.value.replace(/\%/g,".*"),"g");for(var i=0;i<n.length;i++)e&&!n[i].match(s)||a.push({databaseid:n[i]});t(a)}},he.createDatabase=function(e,t,r,n,a){console.log(arguments);var s=C.global.indexedDB;if(r){s.open(e,1).onsuccess=function(e){e.target.result.close(),a&&a(1)}}else{var i=s.open(e,1);i.onupgradeneeded=function(e){console.log("abort"),e.target.transaction.abort()},i.onsuccess=function(t){if(console.log("success"),!r)throw new Error('IndexedDB: Cannot create new database "'+e+'" because it already exists');a&&a(0)}}},he.createDatabase=function(e,t,r,n,a){var s=C.global.indexedDB;if(he.getDatabaseNamesNotSupported)if(r){var i=!0,o=s.open(e);o.onupgradeneeded=function(e){i=!1},o.onsuccess=function(e){e.target.result.close(),i?a&&a(0):a&&a(1)}}else{var u=s.open(e);u.onupgradeneeded=function(e){e.target.transaction.abort()},u.onabort=function(e){a&&a(1)},u.onsuccess=function(t){throw t.target.result.close(),new Error('IndexedDB: Cannot create new database "'+e+'" because it already exists')}}else{var u=he.getDatabaseNames();u.onsuccess=function(t){if(t.target.result.contains(e)){if(r)return void(a&&a(0));throw new Error('IndexedDB: Cannot create new database "'+e+'" because it already exists')}s.open(e,1).onsuccess=function(e){e.target.result.close(),a&&a(1)}}}},he.dropDatabase=function(e,t,r){var n=C.global.indexedDB;he.getDatabaseNames().onsuccess=function(a){if(!a.target.result.contains(e)){if(t)return void(r&&r(0));throw new Error('IndexedDB: Cannot drop new database "'+e+'" because it does not exist')}n.deleteDatabase(e).onsuccess=function(e){r&&r(1)}}},he.attachDatabase=function(e,t,r,n,a){if(!C.hasIndexedDB)throw new Error("The current browser does not support IndexedDB");var s=C.global.indexedDB;he.getDatabaseNames().onsuccess=function(r){if(!r.target.result.contains(e))throw new Error('IndexedDB: Cannot attach database "'+e+'" because it does not exist');s.open(e).onsuccess=function(r){var n=r.target.result,s=new A.Database(t||e);s.engineid="INDEXEDDB",s.ixdbid=e,s.tables=[];for(var i=n.objectStoreNames,o=0;o<i.length;o++)s.tables[i[o]]={};r.target.result.close(),a&&a(1)}}},he.createTable=function(e,t,r,n){var a=C.global.indexedDB,s=A.databases[e].ixdbid;he.getDatabaseNames().onsuccess=function(r){if(!r.target.result.contains(s))throw new Error('IndexedDB: Cannot create table in database "'+s+'" because it does not exist');var i=a.open(s);i.onversionchange=function(e){e.target.result.close()},i.onsuccess=function(r){var i=r.target.result.version;r.target.result.close();var o=a.open(s,i+1);o.onupgradeneeded=function(e){e.target.result.createObjectStore(t,{autoIncrement:!0})},o.onsuccess=function(e){e.target.result.close(),n&&n(1)},o.onerror=function(e){throw e},o.onblocked=function(r){throw new Error('Cannot create table "'+t+'" because database "'+e+'"  is blocked')}}}},he.dropTable=function(e,t,r,n){var a=C.global.indexedDB,s=A.databases[e].ixdbid;he.getDatabaseNames().onsuccess=function(i){if(!i.target.result.contains(s))throw new Error('IndexedDB: Cannot drop table in database "'+s+'" because it does not exist');var o=a.open(s);o.onversionchange=function(e){e.target.result.close()},o.onsuccess=function(i){var o=i.target.result.version;i.target.result.close();var u=a.open(s,o+1);u.onupgradeneeded=function(n){var a=n.target.result;if(a.objectStoreNames.contains(t))a.deleteObjectStore(t),delete A.databases[e].tables[t];else if(!r)throw new Error('IndexedDB: Cannot drop table "'+t+'" because it does not exist')},u.onsuccess=function(e){e.target.result.close(),n&&n(1)},u.onerror=function(e){throw e},u.onblocked=function(r){throw new Error('Cannot drop table "'+t+'" because database "'+e+'" is blocked')}}}},he.intoTable=function(e,t,r,n,a){var s=C.global.indexedDB,i=A.databases[e].ixdbid;s.open(i).onsuccess=function(e){for(var n=e.target.result,s=n.transaction([t],"readwrite"),i=s.objectStore(t),o=0,u=r.length;o<u;o++)i.add(r[o]);s.oncomplete=function(){n.close(),a&&a(u)}}},he.fromTable=function(e,t,r,n,a){var s=C.global.indexedDB,i=A.databases[e].ixdbid;s.open(i).onsuccess=function(e){var s=[],i=e.target.result,o=i.transaction([t]),u=o.objectStore(t),c=u.openCursor();c.onblocked=function(e){},c.onerror=function(e){},c.onsuccess=function(e){var t=e.target.result;t?(s.push(t.value),t.continue()):(i.close(),r&&r(s,n,a))}}},he.deleteFromTable=function(e,t,r,n,a){var s=C.global.indexedDB,i=A.databases[e].ixdbid;s.open(i).onsuccess=function(e){var s=e.target.result,i=s.transaction([t],"readwrite"),o=i.objectStore(t),u=o.openCursor(),c=0;u.onblocked=function(e){},u.onerror=function(e){},u.onsuccess=function(e){var t=e.target.result;t?(r&&!r(t.value,n)||(t.delete(),c++),t.continue()):(s.close(),a&&a(c))}}},
 he.updateTable=function(e,t,r,n,a,s){var i=C.global.indexedDB,o=A.databases[e].ixdbid;i.open(o).onsuccess=function(e){var i=e.target.result,o=i.transaction([t],"readwrite"),u=o.objectStore(t),c=u.openCursor(),l=0;c.onblocked=function(e){},c.onerror=function(e){},c.onsuccess=function(e){var t=e.target.result;if(t){if(!n||n(t.value,a)){var o=t.value;r(o,a),t.update(o),l++}t.continue()}else i.close(),s&&s(l)}}};var de=A.engines.LOCALSTORAGE=function(){};de.get=function(e){var t=localStorage.getItem(e);if(void 0!==t){var r=void 0;try{r=JSON.parse(t)}catch(e){throw new Error("Cannot parse JSON object from localStorage"+t)}return r}},de.set=function(e,t){void 0===t?localStorage.removeItem(e):localStorage.setItem(e,JSON.stringify(t))},de.storeTable=function(e,t){var r=A.databases[e],n=r.tables[t],a={};a.columns=n.columns,a.data=n.data,a.identities=n.identities,de.set(r.lsdbid+"."+t,a)},de.restoreTable=function(e,t){var r=A.databases[e],n=de.get(r.lsdbid+"."+t),a=new A.Table;for(var s in n)a[s]=n[s];return r.tables[t]=a,a.indexColumns(),a},de.removeTable=function(e,t){var r=A.databases[e];localStorage.removeItem(r.lsdbid+"."+t)},de.createDatabase=function(e,t,r,n,a){var s=1,i=de.get("alasql");if(r&&i&&i.databases&&i.databases[e])s=0;else{if(i||(i={databases:{}}),i.databases&&i.databases[e])throw new Error('localStorage: Cannot create new database "'+e+'" because it already exists');i.databases[e]=!0,de.set("alasql",i),de.set(e,{databaseid:e,tables:{}})}return a&&(s=a(s)),s},de.dropDatabase=function(e,t,r){var n=1,a=de.get("alasql");if(t&&a&&a.databases&&!a.databases[e])n=0;else{if(!a){if(t)return r?r(0):0;throw new Error("There is no any AlaSQL databases in localStorage")}if(a.databases&&!a.databases[e])throw new Error('localStorage: Cannot drop database "'+e+'" because there is no such database');delete a.databases[e],de.set("alasql",a);var s=de.get(e);for(var i in s.tables)localStorage.removeItem(e+"."+i);localStorage.removeItem(e)}return r&&(n=r(n)),n},de.attachDatabase=function(e,t,r,n,a){var s=1;if(A.databases[t])throw new Error('Unable to attach database as "'+t+'" because it already exists');t||(t=e);var i=new A.Database(t);if(i.engineid="LOCALSTORAGE",i.lsdbid=e,i.tables=de.get(e).tables,!A.options.autocommit&&i.tables)for(var o in i.tables)de.restoreTable(t,o);return a&&(s=a(s)),s},de.showDatabases=function(e,t){var r=[],n=de.get("alasql");if(e)var a=new RegExp(e.value.replace(/\%/g,".*"),"g");if(n&&n.databases){for(dbid in n.databases)r.push({databaseid:dbid});e&&r&&r.length>0&&(r=r.filter(function(e){return e.databaseid.match(a)}))}return t&&(r=t(r)),r},de.createTable=function(e,t,r,n){var a=1,s=A.databases[e].lsdbid;if(de.get(s+"."+t)&&!r)throw new Error('Table "'+t+'" alsready exists in localStorage database "'+s+'"');var i=de.get(s);A.databases[e].tables[t];return i.tables[t]=!0,de.set(s,i),de.storeTable(e,t),n&&(a=n(a)),a},de.truncateTable=function(e,t,r,n){var a=1,s=A.databases[e].lsdbid;if(A.options.autocommit)var i=de.get(s);else var i=A.databases[e];if(!r&&!i.tables[t])throw new Error('Cannot truncate table "'+t+'" in localStorage, because it does not exist');return de.restoreTable(e,t).data=[],de.storeTable(e,t),n&&(a=n(a)),a},de.dropTable=function(e,t,r,n){var a=1,s=A.databases[e].lsdbid;if(A.options.autocommit)var i=de.get(s);else var i=A.databases[e];if(!r&&!i.tables[t])throw new Error('Cannot drop table "'+t+'" in localStorage, because it does not exist');return delete i.tables[t],de.set(s,i),de.removeTable(e,t),n&&(a=n(a)),a},de.fromTable=function(e,t,r,n,a){var s=(A.databases[e].lsdbid,de.restoreTable(e,t).data);return r&&(s=r(s,n,a)),s},de.intoTable=function(e,t,r,n,a){var s=(A.databases[e].lsdbid,r.length),i=de.restoreTable(e,t);return i.data||(i.data=[]),i.data=i.data.concat(r),de.storeTable(e,t),a&&(s=a(s)),s},de.loadTableData=function(e,t){A.databases[e],A.databases[e].lsdbid;de.restoreTable(e,t)},de.saveTableData=function(e,t){var r=A.databases[e],n=A.databases[e].lsdbid;de.storeTable(n,t),r.tables[t].data=void 0},de.commit=function(e,t){var r=A.databases[e],n=A.databases[e].lsdbid,a={databaseid:n,tables:{}};if(r.tables)for(var s in r.tables)a.tables[s]=!0,de.storeTable(e,s);return de.set(n,a),t?t(1):1},de.begin=de.commit,de.rollback=function(e,t){return};var fe=A.engines.SQLITE=function(){};fe.createDatabase=function(e,t,r,n,a){throw new Error("Connot create SQLITE database in memory. Attach it.")},fe.dropDatabase=function(e){throw new Error("This is impossible to drop SQLite database. Detach it.")},fe.attachDatabase=function(e,t,r,n,a){if(A.databases[t])throw new Error('Unable to attach database as "'+t+'" because it already exists');if(r[0]&&r[0]instanceof K.StringValue||r[0]instanceof K.ParamValue){if(r[0]instanceof K.StringValue)var s=r[0].value;else if(r[0]instanceof K.ParamValue)var s=n[r[0].param];return A.utils.loadBinaryFile(s,!0,function(r){var n=new A.Database(t||e);n.engineid="SQLITE",n.sqldbid=e;var s=n.sqldb=new SQL.Database(r);n.tables=[],s.exec("SELECT * FROM sqlite_master WHERE type='table'")[0].values.forEach(function(e){n.tables[e[1]]={};var t=n.tables[e[1]].columns=[],r=A.parse(e[4]),a=r.statements[0].columns;a&&a.length>0&&a.forEach(function(e){t.push(e)})}),a(1)},function(e){throw new Error('Cannot open SQLite database file "'+r[0].value+'"')}),1}throw new Error("Cannot attach SQLite database without a file")},fe.fromTable=function(e,t,r,n,a){var s=A.databases[e].sqldb.exec("SELECT * FROM "+t),i=a.sources[n].columns=[];s[0].columns.length>0&&s[0].columns.forEach(function(e){i.push({columnid:e})});var o=[];s[0].values.length>0&&s[0].values.forEach(function(e){var t={};i.forEach(function(r,n){t[r.columnid]=e[n]}),o.push(t)}),r&&r(o,n,a)},fe.intoTable=function(e,t,r,n,a){for(var s=A.databases[e].sqldb,i=0,o=r.length;i<o;i++){var u="INSERT INTO "+t+" (",c=r[i],l=Object.keys(c);u+=l.join(","),u+=") VALUES (",u+=l.map(function(e){return v=c[e],"string"==typeof v&&(v="'"+v+"'"),v}).join(","),u+=")",s.exec(u)}var h=o;return a&&a(h),h};var pe=A.engines.FILESTORAGE=A.engines.FILE=function(){};if(pe.createDatabase=function(e,t,r,n,a){var s=1,i=t[0].value;return A.utils.fileExists(i,function(e){if(e){if(r)return s=0,a&&(s=a(s)),s;throw new Error("Cannot create new database file, because it alreagy exists")}var t={tables:{}};A.utils.saveFile(i,JSON.stringify(t),function(e){a&&(s=a(s))})}),s},pe.dropDatabase=function(e,t,r){var n,a=e.value;return A.utils.fileExists(a,function(e){if(e)n=1,A.utils.deleteFile(a,function(){n=1,r&&(n=r(n))});else{if(!t)throw new Error("Cannot drop database file, because it does not exist");n=0,r&&(n=r(n))}}),n},pe.attachDatabase=function(e,t,r,n,a){var s=1;if(A.databases[t])throw new Error('Unable to attach database as "'+t+'" because it already exists');var i=new A.Database(t||e);return i.engineid="FILESTORAGE",i.filename=r[0].value,x(i.filename,!!a,function(e){try{i.data=JSON.parse(e)}catch(e){throw new Error("Data in FileStorage database are corrupted")}if(i.tables=i.data.tables,!A.options.autocommit&&i.tables)for(var t in i.tables)i.tables[t].data=i.data[t];a&&(s=a(s))}),s},pe.createTable=function(e,t,r,n){var a=A.databases[e],s=a.data[t];if(s&&!r)throw new Error('Table "'+t+'" alsready exists in the database "'+fsdbid+'"');var i=A.databases[e].tables[t];return a.data.tables[t]={columns:i.columns},a.data[t]=[],pe.updateFile(e),n&&n(1),1},pe.updateFile=function(e){var t=A.databases[e];if(t.issaving)return void(t.postsave=!0);t.issaving=!0,t.postsave=!1,A.utils.saveFile(t.filename,JSON.stringify(t.data),function(){t.issaving=!1,t.postsave&&setTimeout(function(){pe.updateFile(e)},50)})},pe.dropTable=function(e,t,r,n){var a=A.databases[e];if(!r&&!a.tables[t])throw new Error('Cannot drop table "'+t+'" in fileStorage, because it does not exist');return delete a.tables[t],delete a.data.tables[t],delete a.data[t],pe.updateFile(e),n&&n(1),1},pe.fromTable=function(e,t,r,n,a){var s=A.databases[e],i=s.data[t];return r&&(i=r(i,n,a)),i},pe.intoTable=function(e,t,r,n,a){var s=A.databases[e],i=r.length,o=s.data[t];return o||(o=[]),s.data[t]=o.concat(r),pe.updateFile(e),a&&a(i),i},pe.loadTableData=function(e,t){var r=A.databases[e];r.tables[t].data=r.data[t]},pe.saveTableData=function(e,t){var r=A.databases[e];r.data[t]=r.tables[t].data,r.tables[t].data=null,pe.updateFile(e)},pe.commit=function(e,t){var r=A.databases[e];if(r.tables)for(var n in r.tables)r.data.tables[n]={columns:r.tables[n].columns},r.data[n]=r.tables[n].data;return pe.updateFile(e),t?t(1):1},pe.begin=pe.commit,pe.rollback=function(e,t){function r(){setTimeout(function(){if(a.issaving)return r();A.loadFile(a.filename,!!t,function(r){a.data=r,a.tables={};for(var s in a.data.tables){var i=new A.Table({columns:a.data.tables[s].columns});G(i,a.data.tables[s]),a.tables[s]=i,A.options.autocommit||(a.tables[s].data=a.data[s]),a.tables[s].indexColumns()}delete A.databases[e],A.databases[e]=new A.Database(e),G(A.databases[e],a),A.databases[e].engineid="FILESTORAGE",A.databases[e].filename=a.filename,t&&(n=t(n))})},100)}var n=1,a=A.databases[e];a.dbversion++,r()},C.isBrowser&&!C.isWebWorker){if(!(A=A||!1))throw new Error("alasql was not found");A.worker=function(){throw new Error("Can find webworker in this enviroment")},"undefined"!=typeof Worker&&(A.worker=function(e,t,r){if(!0===e&&(e=void 0),void 0===e)for(var n=document.getElementsByTagName("script"),a=0;a<n.length;a++){if("alasql-worker.js"===n[a].src.substr(-16).toLowerCase()){e=n[a].src.substr(0,n[a].src.length-16)+"alasql.js";break}if("alasql-worker.min.js"===n[a].src.substr(-20).toLowerCase()){e=n[a].src.substr(0,n[a].src.length-20)+"alasql.min.js";break}if("alasql.js"===n[a].src.substr(-9).toLowerCase()){e=n[a].src;break}if("alasql.min.js"===n[a].src.substr(-13).toLowerCase()){e=n[a].src.substr(0,n[a].src.length-13)+"alasql.min.js";break}}if(void 0===e)throw new Error("Path to alasql.js is not specified");if(!1!==e){var s="importScripts('";s+=e,s+="');self.onmessage = function(event) {alasql(event.data.sql,event.data.params, function(data){postMessage({id:event.data.id, data:data});});}";var i=new Blob([s],{type:"text/plain"});if(A.webworker=new Worker(URL.createObjectURL(i)),A.webworker.onmessage=function(e){var t=e.data.id;A.buffer[t](e.data.data),delete A.buffer[t]},A.webworker.onerror=function(e){throw e},arguments.length>1){var o="REQUIRE "+t.map(function(e){return'"'+e+'"'}).join(",");A(o,[],r)}}else if(!1===e)return void delete A.webworker});var be=be||function(e){"use strict";if(!(void 0===e||"undefined"!=typeof navigator&&/MSIE [1-9]\./.test(navigator.userAgent))){var t=e.document,r=function(){return e.URL||e.webkitURL||e},n=t.createElementNS("http://www.w3.org/1999/xhtml","a"),a="download"in n,s=function(e){var t=new MouseEvent("click");e.dispatchEvent(t)},i=/constructor/i.test(e.HTMLElement)||e.safari,o=/CriOS\/[\d]+/.test(navigator.userAgent),u=function(t){(e.setImmediate||e.setTimeout)(function(){throw t},0)},c=function(e){var t=function(){"string"==typeof e?r().revokeObjectURL(e):e.remove()};setTimeout(t,4e4)},l=function(e,t,r){t=[].concat(t);for(var n=t.length;n--;){var a=e["on"+t[n]];if("function"==typeof a)try{a.call(e,r||e)}catch(e){u(e)}}},h=function(e){return/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob([String.fromCharCode(65279),e],{type:e.type}):e},d=function(t,u,d){d||(t=h(t));var f,p=this,b=t.type,E="application/octet-stream"===b,g=function(){l(p,"writestart progress write writeend".split(" "))};if(p.readyState=p.INIT,a)return f=r().createObjectURL(t),void setTimeout(function(){n.href=f,n.download=u,s(n),g(),c(f),p.readyState=p.DONE});!function(){if((o||E&&i)&&e.FileReader){var n=new FileReader;return n.onloadend=function(){var t=o?n.result:n.result.replace(/^data:[^;]*;/,"data:attachment/file;");e.open(t,"_blank")||(e.location.href=t),t=void 0,p.readyState=p.DONE,g()},n.readAsDataURL(t),void(p.readyState=p.INIT)}if(f||(f=r().createObjectURL(t)),E)e.location.href=f;else{e.open(f,"_blank")||(e.location.href=f)}p.readyState=p.DONE,g(),c(f)}()},f=d.prototype,p=function(e,t,r){return new d(e,t||e.name||"download",r)};return"undefined"!=typeof navigator&&navigator.msSaveOrOpenBlob?function(e,t,r){return t=t||e.name||"download",r||(e=h(e)),navigator.msSaveOrOpenBlob(e,t)}:(f.abort=function(){},f.readyState=f.INIT=0,f.WRITING=1,f.DONE=2,f.error=f.onwritestart=f.onprogress=f.onwrite=f.onabort=f.onerror=f.onwriteend=null,p)}}("undefined"!=typeof self&&self||"undefined"!=typeof window&&window||this.content);"undefined"!=typeof module&&module.exports?module.exports.saveAs=be:"undefined"!=typeof define&&null!==define&&null!==define.amd&&define("FileSaver.js",function(){return be}),(C.isCordova||C.isMeteorServer||C.isNode)&&console.warn("It looks like you are using the browser version of AlaSQL. Please use the alasql.fs.js file instead."),A.utils.saveAs=be}return new J("alasql"),A.use("alasql"),A});
\ No newline at end of file
diff --git a/src/50expression.js b/src/50expression.js
index 7b9a09b82c..07bb4ef328 100755
--- a/src/50expression.js
+++ b/src/50expression.js
@@ -72,6 +72,9 @@ yy.Expression.prototype.toString = function(dontas) {
 	if (this.nocase) {
 		s += ' COLLATE NOCASE';
 	}
+	if (this.direction) {
+		s += ' ' + this.direction;
+	}
 	return s;
 };
 


Test patch:
diff --git a/test/test620.js b/test/test620.js
new file mode 100644
index 0000000000..470a1656d5
--- /dev/null
+++ b/test/test620.js
@@ -0,0 +1,17 @@
+if(typeof exports === 'object') {
+  var assert = require("assert");
+  var alasql = require('..');
+};
+
+/*
+  Test for issue #965
+*/
+
+var test = 620;
+
+describe('Test '+test+' ORDER BY direction when converting AST to string', function() {
+  it('1. Should preserve the direction', function(){
+    var sql = "SELECT * FROM cities WHERE population < 3500000 ORDER BY population DESC" 
+    assert.equal(sql, alasql.parse(sql).toString());
+  })
+});
\ No newline at end of file