-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathfrom.js
66 lines (66 loc) · 32.3 KB
/
from.js
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
(function(){function I(a,c,b){if(a.length==c)return b;a=a.substr(c);return/^[0-9]+$/.exec(a)?b+"["+a+"]":b+"."+a}function t(a,c,b){var d;N.lastIndex=0;var e=N.exec(a);e?(d=[e[1]],a=e[2],c=Array(1)):(O.lastIndex=0,e=O.exec(a))?(d=e[1].split(/\s*,\s*/),a=e[2],c=Array(d.length)):c=Array(c);for(var e=0,g=c.length;e<g;++e)c[e]=0;var g=0,h="";if(d)for(B.lastIndex=0;e=B.exec(a);)for(var p=e[0],k=0,l=d.length;k<l;++k){if(p==d[k]){++c[k];b&&(b.push(a.substring(g,e.index)),b.push(k),g=e.index+p.length);break}}else{d=
"";for(B.lastIndex=0;e=B.exec(a);)p=e[0],l=p.charAt(0),k=null,"$"==l?(l=p.length,2<=l&&"$"==p.charAt(1)?(++c[1],b&&(k=1,d=I(p,2,""))):(++c[0],b&&(k=0,d=I(p,1,"")))):"@"==l?(l=c.length-1,++c[l],b&&(k=l,d=I(p,1,""))):"#"==l&&(l=parseInt(p.substr(1)),++c[l],b&&(k=l,d="")),b&&null!==k&&(b.push(h+a.substring(g,e.index)),b.push(k),g=e.index+p.length,h=d,d="")}b&&b.push(h+a.substring(g,a.length));return c}function n(a,c,b){var d;N.lastIndex=0;var e=N.exec(a);if(e)d=[e[1]],a=e[2];else if(O.lastIndex=0,e=
O.exec(a))d=e[1].split(/\s*,\s*/),a=e[2];var g=arguments,h=0<g.length?g[g.length-1]:"";if(d)return B.lastIndex=0,a.replace(B,function(a){for(var b=0,c=d.length;b<c;++b)if(a==d[b])return g[b+1];return a});B.lastIndex=0;return a.replace(B,function(a){var d=a.charAt(0);return"$"==d?2<=a.length&&"$"==a.charAt(1)?I(a,2,b):I(a,1,c):"@"==d?I(a,1,h):"#"==d?g[parseInt(a.substr(1))+1]:a})}function u(a,c,b){for(var d=1,e=a.length;d<e;d+=2){var g=a[d];"number"==typeof g&&(a[d]=arguments[g+1])}return a.join("")}
function K(a,c){if(!a)return null;if("function"==typeof a)return a;var b,d=/^\s*(\w+)\s*=>(.+)$/.exec(a);if(d)b=[d[1]],a=d[2];else if(d=/^\s*\(\s*([\w\s,]*)\s*\)\s*=>(.+)$/.exec(a))b=d[1].split(/\s*,\s*/),a=d[2];if(!b){b=[];for(d=0;d<c;++d)b.push("$"+d);d=[a].concat(b);a=n.apply(null,d)}b.push("return "+a+";");return Function.apply(null,b)}function P(a){X.lastIndex=0;return X.exec(a)[1].split(",").length}function C(a){var c=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
b={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"};return c.test(a)?'"'+a.replace(c,function(a){var c=b[a];return c?c:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}function D(a,c){var b=function(){};b.prototype=a.prototype;c.prototype=new b;c.prototype.constructor=c}function Y(a,c){var b=a?a+"=":"";if("boolean"==typeof c)return b+(c?"1":"0");if("string"==typeof c)return b+encodeURIComponent(c);if("number"==typeof c)return b+c.toString();if("object"==
typeof c){var d=[];r(c).each(function(b,c){c=encodeURIComponent(c);d.push(Y(a?a+"["+c+"]":c,b))});return d.join("&")}return""}function Z(a,c,b){var d,e;!a||a instanceof Array?(d=!a?Q:a,a=$):a instanceof f?(d=Q,a=aa):"string"==typeof a&&(a=n(a,"$","$$","@.a"));!c||c instanceof Array?(e=!c?Q:c,c=$):c instanceof f?(e=Q,c=aa):"string"==typeof c&&(c=n(c,"$","$$","@.a"));return{left:a,leftArg:{t:d,a:b},right:c,rightArg:{t:e,a:b}}}function L(a,c,b,d){for(var e={},g=[],h=0,p=a.length;h<p;++h){var k=2*h+1;
if(c=arguments[k])if(b=arguments[k+1],b instanceof Array){if(0==a[h])for(var k=0,f=b.length;k<f;++k)b[k]="";e[c]=b}else 1>=a[h]?e[c]=b:(g.push("var "+c+"="+b+";"),e[c]=c)}e.decl=g.join("");return e}function M(a,c){this.$o=r(this.o=[]);this.c=a;this.a=c}function ba(a){var c=U[a];c||(c=U[a]={});return c}function f(a){this.each=a}function s(a){this.data=a;this.rev=!1}function F(a){s.call(this,a)}function z(a){s.call(this,a)}function x(a){this.data=a}function R(a){this.data=a}function v(a){this.it=a;
this.keyRequired=!1}function S(a){v.call(this,a)}function J(a,c){this._r=a;this._str=c}function r(a,c){return a?a instanceof f?a:a instanceof RegExp?c?new J(a,c):{match:function(b){return new J(a,b)}}:a.$iterable?r(a.$iterable()):a.$each?new f(function(b,c){this.broken=!1===a.$each(b,c);return this}):"string"==typeof a?new F(a):a instanceof Array?new z(a):new x(a):new f(function(){return this})}var V,ca={nodejs:function(){return"undefined"!==typeof module&&module.exports},web:function(){return!0}},
W;for(W in ca)if(ca[W]()){V=W;break}var A="from",Q=[void 0,null,!1,0," ","\n","\t"],$="from(@t).contains($)",aa="@t.contains($)",N=/^\s*(\w+)\s*=>(.+)$/,O=/^\s*\(\s*([\w\s,]*)\s*\)\s*=>(.+)$/,B=/"(?:[^"]|\\")*"|'(?:[^']|\\')*'|[\$@\w_#]+/g,X=/^\s*function(?:\s+[^(\s]+)?\s*\(\s*([^)]*)\s*\)/;M.prototype._getPrimitiveList=function(a,c){var b=this[a];b||(this[a]=b={});c=c.toString();var d=b[c];d||(b[c]=d=[],this.o.push({k:c,l:d}));return d};M.prototype._getList=function(a){var c=this.c,b;if(c)b="string"==
typeof c?n(c,"$k","@k","@a"):"@c($k,@k,@a)";else{switch(typeof a){case "string":return this._getPrimitiveList("s",a);case "number":return this._getPrimitiveList("n",a);case "boolean":return this._getPrimitiveList("b",a)}b="$k==@k"}if(c=this.$o.first(b,{k:a,c:c,a:this.a}))return c.l;c=[];this.o.push({k:a,l:c});return c};M.prototype.add=function(a,c){this._getList(a).push(c)};M.prototype.$each=function(a,c){return!this.$o.selectPair("from($l)","$k").each(a,c).broken};var U={},w=[],m={get:function(a,
c){var b=ba(a)[c];if(b&&2<w.length)for(var d=0,e=w.length;d<e;d+=2)if(w[d]==a&&w[d+1]==c){w.splice(d,2);w.push(a,c);break}return b},set:function(a,c,b){var d=ba(a);d[c]=b;if(!(c in d))for(w.push(a,c);32<w.length;)d=U[w[0]],delete d[w[1]],w.splice(0,2)}};f.prototype.broken=!1;f.prototype.mutable=!1;f.prototype.where=function(a,c){var b;"string"==typeof a?(b=m.get("($_$$_a0)",a),b||(b="("+n(a,"$","$$","@a0")+")",m.set("($_$$_a0)",a,b))):b="@pr($,$$,@a0)";var d=this;return new f(function(e,g){var h;
"string"==typeof e?(h=m.get("($_$$_a)",e),h||(h="("+n(e,"$","$$","@a")+")",m.set("($_$$_a)",e,h))):h="@p($,$$,@a)";this.broken=d.each(b+"?"+h+":0",{p:e,pr:a,a0:c,a:g}).broken;return this})};f.prototype.aggregate=function(a,c,b){var d;"string"==typeof c?(d=m.get("(c_$_$$_a)",c),d||(d="("+n(c,"@c","$","$$","@a")+")",m.set("(c_$_$$_a)",c,d))):d="@p(@c,$,$$,@a)";null===a?(a={p:c,f:!0,a:b},this.each("@f?(@f=false,@c=$,0):(@c="+d+",0)",a)):(a={c:a,a:b,p:c},this.each("(@c="+d+"),0",a));return a.c};f.prototype.all=
function(a,c){var b;"string"==typeof a?(b=m.get("($_$$_a)",a),b||(b="("+n(a,"$","$$","@a")+")",m.set("($_$$_a)",a,b))):b="@p($,$$,@a)";return!this.each("!"+b+"?false:0",{a:c,p:a}).broken};f.prototype.any=function(a,c){var b;a?("string"==typeof a?(b=m.get("($_$$_a)",a),b||(b="("+n(a,"$","$$","@a")+")",m.set("($_$$_a)",a,b))):b="@p($,$$,@a)",b+="?false:0"):b="false";return this.each(b,{a:c,p:a}).broken};f.prototype.at=function(a){return this.skip(a).first()};f.prototype.atOrDefault=function(a,c){var b=
this.at(a);return void 0===b?c:b};f.prototype.average=function(){var a={f:!0};this.each("@f?(@f=false,@s=$,@c=1,0):(@s+=$,++@c)",a);return a.s/a.c};f.prototype.concat=function(a){var c=this;return new f(function(b,d){if(c.each(b,d).broken)return this.broken=!0,this;this.broken=r(a).each(b,d).broken;return this})};f.prototype.contains=function(a,c,b){var d;c?"string"==typeof c?(d=m.get("(v_$_a)",c),d||(d="("+n(c,"@v","$","@a")+")",m.set("(v_$_a)",c,d))):d="@c(@v,$,@a)":d="$==@v";a={v:a,a:b,c:c,r:!1};
this.each(d+"?((@r=true),false):0",a);return a.r};f.prototype.count=function(a,c){var b;a?("string"==typeof a?(b=m.get("($_$$_a)",a),b||(b="("+n(a,"$","$$","@a")+")",m.set("($_$$_a)",a,b))):b="@p($,$$,@a)",b+="?++@c:0"):b="++@c,0";var d={a:c,p:a,c:0};this.each(b,d);return d.c};f.prototype.defaultIfEmpty=function(a){var c=this;return new f(function(b,d){c.each("false").broken?this.broken=c.each(b,d).broken:("string"==typeof b&&(b=K(b,3)),this.broken=!1===b(a,0,d));return this})};f.prototype.distinct=
function(a,c){var b=a?",@c,@a":"",d=[],e=this;return new f(function(c,h){var p;"string"==typeof c?(p=m.get("($_$$_a0)",c),p||(p="("+n(c,"$","$$","@a0")+")",m.set("($_$$_a0)",c,p))):p="@p($,$$,@a0)";this.broken=e.each("!from(@l).contains($"+b+")?(@l.push($),"+p+"):0",{c:a,l:d,p:c,a0:h}).broken;return this})};f.prototype.dump=function(){"nodejs"==V?this.each('console.log("key = " + $$ + ", value = " + $)'):this.each('document.writeln("key = " + $$ + ", value = " + $ + "<br/>")');return this};f.prototype.except=
function(a,c,b){var d;d=c?",@c,@a0":"";var e=this;return new f(function(g,h){this.broken="string"==typeof g?e.each("@s.contains($"+d+")?0:("+n(g,"$","$$","@a")+")",{c:c,a0:b,s:r(a),a:h}).broken:e.each("@s.contains($"+d+")?0:@p($,$$,@a)",{c:c,a0:b,p:g,s:r(a),a:h}).broken;return this})};f.prototype.first=function(a,c){if(a)"string"==typeof a?(b={a:c},this.each("("+n(a,"$","$$","@a")+")?(@r=$,false):0",b)):(b={a:c,p:a},this.each("@p($,$$,@a)?(@r=$,false):0",b));else{var b={};this.each("(@r=$),false",
b)}return b.r};f.prototype.firstOrDefault=function(a,c,b){if(1>=arguments.length){var d=this.first();return void 0===d?a:d}d=this.first(a,b);return void 0===d?c:d};f.prototype.groupBy=function(a,c,b){var d,e,g;a&&(d=a.value,e=a.key,g=a.result);d=d||"$";e=e||"$$";return g?(a="string"==typeof g?n(g,"$","$$","@a"):"@rs($,$$,@a)",this._getGroupIterable(d,e,c,b).selectPair(a,"$$",{rs:g,a:b})):this._getGroupIterable(d,e,c,b)};f.prototype._getGroupIterable=function(a,c,b,d){b=new M(b,d);var e=r(b),g;g="string"==
typeof c?"("+n(c,"$","$$","@a")+")":"@ks($,$$,@a)";var h;h="string"==typeof a?"("+n(a,"$","$$","@a")+")":"@vs($,$$,@a)";this.each("(@k="+g+"),(@v="+h+"),@g.add(@k,@v),0",{ks:c,vs:a,g:b,a:d});return e};f.prototype.groupJoin=function(a,c,b,d,e,g){a=r(a);c="string"==typeof c?"("+n(c,"$","$$","@a")+")":"@oks($,$$,@a)";b="string"==typeof b?"("+n(b,"$","$$","@a")+")":"@iks($,$$,@a)";b=e?"string"==typeof e?n(e,"@ok",b):"@c(@ok,"+b+")":"@ok=="+b;b=C(b);c="@i.where("+b+",{a:@a,ok:"+c+",c:@c})";if("string"==
typeof d)switch(b=[],t(d,3,b)[1]){case 0:case 1:c=u(b,"$",c,"@a");break;default:c="(@w="+c+"),("+u(b,"$","@w","@a")+")"}else c="@rs($,"+c+",@a)";return this.select(c,{rs:d,i:a,a:g,c:e})};f.prototype.indexOf=function(a,c){return this.where(a,c).select("$$").firstOrDefault(-1)};f.prototype.intersect=function(a,c,b){var d;d=c?"string"==typeof c?C(c):"@c":"null";return this.where("@t.contains($,"+d+",@a)",{t:r(a),a:b,c:c})};f.prototype.join=function(a,c,b,d,e,g){a=r(a);var h;h="string"==typeof c?"("+
n(c,"$","$$","@a")+")":"@oks($,$$,@a)";var p;p="string"==typeof b?"("+n(b,"$","$$","@a")+")":"@iks($,$$,@a)";var k;k=e?"string"==typeof e?n(e,"@ok",p):"@c(@ok,"+p+")":"@ok=="+p;k=C(k);var l;l="string"==typeof d?"("+n(d,"@ov","$","@a")+")":"@rs(@ov,$,@a)";var m=this;return new f(function(e,p){var f;if("string"==typeof e){f=[];var n=t(e,3,f),y=[],r;switch(n[0]){case 0:case 1:r=l;break;default:y.push("(@RS="+l+")"),r="@RS"}switch(n[1]){case 0:case 1:n="(@c++)";break;default:y.push("(@cc=@c++)"),n="@cc"}y.push("("+
u(f,r,n,"@a0")+")");f=y.join(",")}else f="@p("+l+",@c++,@a0)";this.broken=m.each("(@ok="+h+"),(@ov=$),@i.where("+k+",@).each("+C(f)+",@)",{i:a,oks:c,iks:b,rs:d,p:e,a:g,a0:p,c:0}).broken;return this})};f.prototype.last=function(a,c){if(a)"string"==typeof a?(b={a:c},this.each("("+n(a,"$","$$","@a")+")?@r=$:0",b)):(b={a:c,p:a},this.each("@p($,$$,@a)?@r=$:0",b));else{var b={};this.each("@r=$",b)}return b.r};f.prototype.lastOrDefault=function(a,c,b){if(1>=arguments.length){var d=this.last();return void 0===
d?a:d}d=this.last(a,b);return void 0===d?c:d};f.prototype.max=function(a,c){if(!a)return this.aggregate(null,"#0>#1?#0:#1");var b;b="string"==typeof a?"("+n(a,"$","$$","@a")+")":"@s($,$$,@a)";var d={f:!0,s:a,a:c};this.each("@f?((@f=false),(@r=$),(@m="+b+"),0):((@v="+b+"),(@v>@m?((@m=@v),(@r=$)):0),0)",d);return d.r};f.prototype.min=function(a,c){if(!a)return this.aggregate(null,"#0<#1?#0:#1");var b;b="string"==typeof a?"("+n(a,"$","$$","@a")+")":"@s($,$$,@a)";var d={f:!0,s:a,a:c};this.each("@f?((@f=false),(@r=$),(@m="+
b+"),0):((@v="+b+"),(@v<@m?((@m=@v),(@r=$)):0),0)",d);return d.r};f.prototype.orderBy=function(a,c,b){return(new v(this)).addCriteria(a,c,1,b)};f.prototype.orderByDesc=function(a,c,b){return(new v(this)).addCriteria(a,c,-1,b)};f.prototype.reverse=function(){var a=this;return new f(function(c,b){var d=[];a.each("@push($$),@push($),0",d);if("string"==typeof c){var e=[],g=t(c,3,e),h,f,k;switch(g[0]){case 0:case 1:h="";f="l[(i-1)*2+1]";break;default:h="var v=l[(i-1)*2+1];",f="v"}switch(g[1]){case 0:case 1:g=
"";k="l[(i-1)*2]";break;default:g="var k=l[(i-1)*2];",k="k"}this.broken=(new Function("l","a","for(var i=l.length/2;i>0;--i){"+g+h+"if(("+u(e,f,k,"a")+")===false){return true;}}return false;"))(d,b)}else{this.broken=!1;for(e=d.length/2;0<e;--e)if(!1===c(d[2*(e-1)+1],d[2*(e-1)],b)){this.broken=!0;break}}return this})};f.prototype.select=function(a,c){var b=this,d;"string"==typeof a?(d=m.get("($_$$_a0)",a),d||(d="("+n(a,"$","$$","@a0")+")",m.set("($_$$_a0)",a,d))):d="@s($,$$,@a0)";return new f(function(e,
g){if("string"==typeof e){var h=[],f=t(e,3,h),k=[],l;switch(f[0]){case 0:l="";break;case 1:l=d;break;default:k.push("(@v="+d+")"),l="@v"}switch(f[1]){case 0:f="";break;case 1:f="(@i++)";break;default:k.push("(@j=@i++)"),f="@j"}k.push(u(h,l,f,"@a"));this.broken=b.each(k.join(","),{s:a,a0:c,a:g,i:0}).broken}else this.broken=b.each("@p("+d+",@i++,@a)",{s:a,a0:c,a:g,i:0,p:e}).broken;return this})};f.prototype.selectMany=function(a,c){var b;b="string"==typeof a?n(a,"$","$$","@a"):"@s($,$$,@a)";var d=this;
return new f(function(e,g){var h;if("string"==typeof e)switch(h=[],t(e,3,h)[1]){case 0:case 1:h=u(h,"$","(@i++)","@a0");break;default:h="(@j=@i++),("+u(h,"$","@j","@a0")+")"}else h="@p($,@i++,@a0)";this.broken=d.each("from("+b+").each("+C(h)+",@)",{s:a,a:c,a0:g,i:0,p:e}).broken;return this})};f.prototype.selectPair=function(a,c,b){var d=this,e,g;"string"==typeof a?(e=m.get("($_$$_a0)",a),e||(e="("+n(a,"$","$$","@a0")+")",m.set("($_$$_a0)",a,e))):e="@vs($,$$,@a0)";"string"==typeof c?(g=m.get("($_$$_a0)",
c),g||(g="("+n(c,"$","$$","@a0")+")",m.set("($_$$_a0)",c,g))):g="@ks($,$$,@a0)";return new f(function(h,f){var k;if("string"==typeof h){k=[];var l=t(h,3,k),m,q=[];switch(l[0]){case 0:case 1:m=e;break;default:q.push("(@VS="+e+")"),m="@VS"}switch(l[1]){case 0:case 1:l=g;break;default:q.push("(@KS="+g+")"),l="@KS"}q.push(u(k,m,l,"@a"));k=q.join(",")}else k="@p("+e+","+g+",@a)";this.broken=d.each(k,{a0:b,a:f,p:h,vs:a,ks:c}).broken;return this})};f.prototype.sequenceEqual=function(a,c,b){var d;d=c?"string"==
typeof c?n(c,"#0","#1","@a"):"@c(#0,#1,@a)":"#0==#1";return this.zip(a,d,{a:b,c:c}).all("$==true")};f.prototype.single=function(a,c){var b=!a?this.take(2):this.where(a).take(2);if(1==b.count())return b.first()};f.prototype.singleOrDefault=function(a,c,b){var d;1>=arguments.length?(d=this.take(2),c=a):d=this.where(a,b).take(2);var e=d.count();if(0==e)return c;if(1==e)return d.first();throw Error("The sequence has more than one element satisfying the condition.");};f.prototype.skip=function(a){if(0==
a)return this;if(0>a)return this.reverse().skip(-a).reverse();var c=this;return new f(function(b,d){var e;"string"==typeof b?(e=m.get("($_$$_a)",b),e||(e="("+n(b,"$","$$","@a")+")",m.set("($_$$_a)",b,e))):e="@p($,$$,@a)";this.broken=c.each("@c==0?"+e+":--@c",{p:b,a:d,c:a}).broken;return this})};f.prototype.skipWhile=function(a,c){var b;"string"==typeof a?(b=m.get("($_$$_a)",a),b||(b="("+n(a,"$","$$","@a")+")",m.set("($_$$_a)",a,b))):b="@pr($,$$,@a)";var d=this;return new f(function(e,g){var h;"string"==
typeof e?(h=m.get("($_$$_a0)",e),h||(h="("+n(e,"$","$$","@a0")+")",m.set("($_$$_a0)",e,h))):h="@p($,$$,@a0)";this.broken=d.each("@f||(@f=!"+b+")?"+h+":0",{pr:a,f:!1,a:c,a0:g}).broken;return this})};f.prototype.sum=function(){return this.aggregate(null,"#0+#1")};f.prototype.take=function(a){if(0==a)return r();if(0>a)return this.reverse().take(-a).reverse();var c=this;return new f(function(b,d){var e;"string"==typeof b?(e=m.get("($_$$_a)",b),e||(e="("+n(b,"$","$$","@a")+")",m.set("($_$$_a)",b,e))):
e="@p($,$$,@a)";var g={i:0,p:b,a:d,b:!1};this.broken=c.each("(@i++<"+a+")?"+e+":(@b=true,false)",g).broken&&!g.b;return this})};f.prototype.takeWhile=function(a,c){var b;"string"==typeof a?(b=m.get("($_$$_a)",a),b||(b="("+n(a,"$","$$","@a")+")",m.set("($_$$_a)",a,b))):b="@pr($,$$,@a)";var d=this;return new f(function(e,g){var h;"string"==typeof e?(h=m.get("($_$$_a0)",e),h||(h="("+n(e,"$","$$","@a0")+")",m.set("($_$$_a0)",e,h))):h="@p($,$$,@a0)";var f={p:e,pr:a,a:c,a0:g,b:!1};this.broken=d.each(b+
"?"+h+":(@b=true,false)",f).broken&&!f.b;return this})};f.prototype.toArray=function(){var a=[];this.each("@push($)",a);return a};f.prototype.toDictionary=function(){var a={};this.each("@[$$]=$",a);return a};f.prototype.toJSON=function(a){function c(d){var e=typeof d;return"string"==e?C(d):"number"==e||"boolean"==e?d.toString():"function"==e?c(d()):b.contains(d)||(d instanceof z||d instanceof x)&&b.contains(d.data)?"null":r(d).toJSON(a)}a||(a=[]);var b=r(a),d="number"==typeof this.select("$$").first();
a.push(this);if(d){var e=[];this.each(function(a){e.push(c(a))});d="["+e.join(", ")+"]"}else e=[],this.each(function(a,b){e.push(C(b.toString())+": "+c(a))}),d="{"+e.join(", ")+"}";a.pop(this);return d};f.prototype.toString=function(a){return this.toArray().join(a||"")};f.prototype.toURLEncoded=function(){return Y(null,this)};f.prototype.trim=function(a,c,b){a=Z(a,c,b);return this.skipWhile(a.left,a.leftArg).reverse().skipWhile(a.right,a.rightArg).reverse()};f.prototype.union=function(a,c,b){var d=
[],e=this;return new f(function(g,h){var f;if("string"==typeof g)switch(f=[],t(g,3,f)[1]){case 0:case 1:f=u(f,"$","(@b.length-1)","@a0");break;default:f="(@[email protected]),("+u(f,"$","@bb","@a0")+")"}else f="@p($,@b.length-1,@a0)";f="from(@b).contains($,@c,@a)?0:(@b.push($),"+f+",0)";var k={c:c,b:d,p:g,a0:h,a:b};if(e.each(f,k).broken)return this.broken=!0,this;r(a).each(f,k).broken&&(this.broken=!0);return this})};f.prototype.zip=function(a,c,b){var d;if("string"==typeof c){var e=[],g=t(c,5,e),h,
p=[];switch(g[0]){case 0:case 1:h="@d[@i*2+1]";break;default:p.push("(@V=@d[@i*2+1])"),h="@V"}switch(g[2]){case 0:case 1:g="@d[@i*2]";break;default:p.push("(@K=@d[@i*2])"),g="@K"}p.push(u(e,h,"$",g,"$$","@a"));d="("+p.join(",")+")"}else d="@rs(@d[@i*2+1],$,@d[@i*2],$$,@a)";var k=this;return new f(function(e,g){var h=[];k.each("@push($$),@push($),0",h);var f;if("string"==typeof e){f=[];var p=t(e,3,f),m,n=[];switch(p[0]){case 0:case 1:m=d;break;default:n.push("(@RS="+d+")"),m="@RS"}switch(p[1]){case 0:case 1:p=
"(@k++)";break;default:n.push("(@kk=@k++)"),p="@kk"}n.push(u(f,m,p,"@a0"));f="("+n.join(",")+")"}else f="@p("+d+",@k++,@a0)";this.broken=r(a).each("@i>="+h.length/2+"?false:@r="+f+",++@i,@r",{a:b,a0:g,k:0,i:0,d:h,p:e,rs:c}).broken;return this})};D(f,s);s.prototype.initRegion=function(){var a=this.region;a||(this.region=a={queries:null,measured:!1,start:null,end:null,take:null,takeArg:null});return a};s.prototype.addRegionQuery=function(a,c,b){var d=this.initRegion(),e=d.queries;e||(d.queries=e=[]);
e.push(a);e.push(c);e.push(b);d.start=d.end=null;d.measured=!1;return this};s.prototype.clone=function(){var a=new this.constructor(this.data),c=this.region;if(c){var b=a.region={measured:c.measured,start:c.start,end:c.end,take:c.take,takeArg:c.takeArg};if(c=c.queries)for(var b=b.queries=[],d=0,e=c.length;d<e;++d)b.push(c[d])}a.rev=this.rev;return a};s.prototype.reverseRegion=function(){var a=this.initRegion();a&&(a.take&&(a.measured=!1),a.take=a.takeArg=null);this.rev=!this.rev;return this};s.prototype.measureRegion=
function(){var a=this.initRegion();if(!a.measured){var c=this.data,b=a.start,d=a.end;null==b&&(b=0);null===d&&(d=c.length);a.take=a.takeArg=null;var e=a.queries;if(e){for(var g=[],h=0,f=e.length;h<f;h+=3){var k=e[h],l=e[h+1],m=e[h+2];if("skipLeft"==k)if("number"==typeof l)b=Math.min(d,b+l);else if("string"==typeof l){var k=[],q=t(l,3,k),q=L(q,"v",this.lambdaGetItem("d","s"),null,null,"a","q["+(h+2)+"]");g.push("for(;s<e;++s){",q.decl,"if(!(",u(k,q.v,"s",q.a),")){break;}}")}else g.push("for(;s<e&&q[",
h+1,"](",this.lambdaGetItem("d","s"),",s,q[",h+2,"]);++s);");else"skipRight"==k?"number"==typeof l?d=Math.max(b,d-l):"string"==typeof l?(k=[],q=t(l,3,k),0==q[1]?(l="",m="e-1"):(l="var _i=e-1;",m="_i"),q=L(q,"v",this.lambdaGetItem("d",m),null,null,"a","q["+(h+2)+"]"),g.push("for(;s<e;--e){",l,q.decl,"if(!(",u(k,q.v,m,q.a),")){break;}}")):g.push("for(;s<e;--e){var _i=e-1;","if(!q[",h+1,"](",this.lambdaGetItem("d","_i"),",_i,q[",h+2,"])){break;}}"):"takeLeft"==k?"number"==typeof l?d=Math.min(d,b+l):
h==f-3&&!this.rev?(a.take=l,a.takeArg=m):"string"==typeof l?(k=[],q=t(l,3,k),q=L(q,"_v",this.lambdaGetItem("d","e"),null,null,"_a","q["+(h+2)+"]"),g.push("for(var _e2=e,e=s;e<_e2;++e){",q.decl,"if(!(",u(k,q._v,"e",q._a),")){break;}}")):g.push("for(var _e2=e,e=s;e<_e2;++e){","if(!q[",h+1,"](",this.lambdaGetItem("d","e"),",e,q[",h+2,"])){break;}}"):"takeRight"==k&&("number"==typeof l?b=Math.max(b,d-l):h==f-3&&this.rev?(a.take=l,a.takeArg=m):"string"==typeof l?(k=[],q=t(l,3,k),0==q[1]?(l="",m="s-1"):
(l="var _i=s-1;",m="_i"),q=L(q,"_v",this.lambdaGetItem("d",m),null,null,"_a","q["+(h+2)+"]"),g.push("for(var _s2=s,s=e;s>_s2;--s){",l,q.decl,"if(!(",u(k,q._v,m,q._a),")){break;}}")):g.push("for(var _s2=s,s=e;s>_s2;--s){var _i=s-1;","if(!q[",h+1,"](",this.lambdaGetItem("d","_i"),",_i,q[",h+2,"])){break;}}"))}0<g.length?(g.push("r.start=s;r.end=e;"),(new Function(A,"d","r","q","s","e",g.join("")))(r,c,a,e,b,d)):(a.start=b,a.end=d)}else a.start=b,a.end=d;a.measured=!0}return a};s.prototype.each=function(a,
c){var b=this.measureRegion(),d=b.start,e=b.end;if(d>=e)return this.broken=!1,this;var g=this.data,f=b.take,p=b.takeArg,k,d=typeof a,e=typeof f;if("function"==d&&(!f||"function"==e)){this.broken=!1;k=this.rev;d=b.start;for(e=b.end;d<e;!k?++d:--e){var b=!k?d:e-1,l=g[b];if(f&&!f(l,b,p))break;else if(!1===a(l,b,c)){this.broken=!0;break}}}else{"function"==d&&(k=a,a="_p($,$$,@)");f&&(a="string"==e?"!("+n(f,"$","$$","_tla")+")?_b=false:"+a:"!_tl($,$$,_tla)?_b=false:"+a);d=this.dataType+(this.rev?"_reversed":
"");e=m.get("each_"+d,a);if(!e){var e=[],s=t(a,3,e),q;this.rev?0==s[1]?(l="",q="_e-1"):(l="var _i=_e-1;",q="_i"):(l="",q="_s");var G;G=this.rev?"--_e":"++_s";s=L(s,"_v",this.lambdaGetItem("s",q,"_l"));e=new Function(A,"s","_l","_s","_e","a","_tl","_tla","_p",["var _b=true;for(;_s<_e;",G,"){",l,s.decl,"if((",u(e,s._v,q,"a"),")===false){return _b;}}return false;"].join(""));m.set("each_"+d,a,e)}this.broken=e(r,g,g.length,b.start,b.end,c,f,p,k)}return this};s.prototype.at=function(a){var c=this.measureRegion();
return this.rev?this.getItem(this.data,c.end-a):this.getItem(this.data,c.start+a)};s.prototype.count=function(a,c){if(!a){var b=this.measureRegion();if(!b.take)return b.end-b.start}return f.prototype.count.call(this,a,c)};s.prototype.any=function(a,c){if(!a){var b=this.measureRegion();if(!b.take)return b.start<b.end}return f.prototype.any.call(this,a,c)};s.prototype.first=function(a,c){if(!a){var b=this.measureRegion();if(!b.take){var d=b.start,b=b.end;if(d<b)return this.rev?this.getItem(this.data,
b-1):this.getItem(this.data,d);return}}return f.prototype.first.call(this,a,c)};s.prototype.last=function(a,c){if(!a){var b=this.measureRegion();if(!b.take){var d=b.start,b=b.end;if(d<b)return this.rev?this.getItem(this.data,d):this.getItem(this.data,b-1);return}}return f.prototype.last.call(this,a,c)};s.prototype.orderBy=function(a,c,b){return(new S(this)).addCriteria(a,c,1,b)};s.prototype.orderByDesc=function(a,c,b){return(new S(this)).addCriteria(a,c,-1,b)};s.prototype.reverse=function(){return this.clone().reverseRegion()};
s.prototype.skip=function(a){return 0>a?this.clone().addRegionQuery(!this.rev?"skipRight":"skipLeft",-a,null):0<a?this.clone().addRegionQuery(!this.rev?"skipLeft":"skipRight",a,null):this};s.prototype.skipWhile=function(a,c){return this.clone().addRegionQuery(!this.rev?"skipLeft":"skipRight",a,c)};s.prototype.take=function(a){return 0>a?this.clone().addRegionQuery(!this.rev?"takeRight":"takeLeft",-a,null):0<a?this.clone().addRegionQuery(!this.rev?"takeLeft":"takeRight",a,null):r()};s.prototype.takeWhile=
function(a,c){return this.clone().addRegionQuery(!this.rev?"takeLeft":"takeRight",a,c)};s.prototype.toArray=function(){var a=this.measureRegion();if(!a.take){var c=this.getItem,b=this.data,d=a.start,a=a.end,e=Array(a-d);if(this.rev)for(g=a;g>d;--g)e[a-g]=c(b,g-1);else for(var g=d;g<a;++g)e[g-d]=c(b,g);return e}return f.prototype.toArray.call(this)};s.prototype.trim=function(a,c,b){a=Z(a,c,b);c=this.clone();c.addRegionQuery(!this.rev?"skipLeft":"skipRight",a.left,a.leftArg);c.addRegionQuery(!this.rev?
"skipRight":"skipLeft",a.right,a.rightArg);return c};s.prototype.zip=function(a,c,b){var d,e=!this.rev?"@.s++":"[email protected]";d="string"==typeof c?"("+n(c,"@.v","$","@.i","$$","@a")+")":"@rs(@.v,$,@.i,$$,@a)";var g=this;return new f(function(f,m){var k=g.data,l=g.measureRegion(),s=l.start,q=l.end;if(s>=q)return this.broken=!1,this;var G=l.take,l=l.takeArg,H;if("string"==typeof f){var E=[],y=t(f,3,E),T=[];switch(y[0]){case 0:case 1:H=d;break;default:T.push("(@RS="+d+")"),H="@RS"}switch(y[1]){case 0:case 1:y=
"(@k++)";break;default:T.push("(@kk=@k++)"),y="@kk"}T.push(u(E,H,y,"@a0"));H="("+T.join(",")+")"}else H="@p("+d+",@k++,@a0)";E=["@.s>[email protected][email protected]=false:((@.i=",e,"),(@.v=",g.lambdaGetItem("@.d","@.i"),"),"];G?("string"==typeof G?E.push("!(",n(G,"@.v","@.i","@.ta"),")"):E.push("!@t(@.v,@.i,@.ta)"),E.push("[email protected]=false:(",H,"))")):E.push(H,")");k={a:b,a0:m,k:0,d:k,s:s,e:q,p:f,rs:c,b:!0,t:G,ta:l};this.broken=r(a).each(E.join(""),k).broken&&k.b;return this})};D(s,F);F.prototype.dataType="string";F.prototype.lambdaGetItem=
function(a,c){return a+".charAt("+c+")"};F.prototype.getItem=function(a,c){return a.charAt(c)};F.prototype.toString=function(a){if(!a&&!this.rev){var c=this.data,b=this.measureRegion();if(!b.take)return a=b.start,b=b.end,0==a&&b==c.length?c:c.substring(a,b)}return f.prototype.toString.call(this,a)};F.prototype.toJSON=function(){return C(this.data)};D(s,z);z.prototype.dataType="array";z.prototype.lambdaGetItem=function(a,c){return a+"["+c+"]"};z.prototype.getItem=function(a,c){return a[c]};z.prototype.toJSON=
function(a){a?a.push(this.data):a=[this.data];var c=f.prototype.toJSON.call(this,a);a.pop();return c};z.prototype.toArray=function(){if(this.mutable){if(!this.rev){var a=this.measureRegion();if(!a.take)return this.data.slice(a.start,a.end)}}else{if(this.rev)return s.prototype.toArray.call(this);a=this.measureRegion();if(!a.take)return this.data.slice(a.start,a.end)}return f.prototype.toArray.call(this)};D(f,x);x.prototype.each=function(a,c){var b=this.data;if("function"==typeof a){this.broken=!1;
for(var d in b)if(!1===a(b[d],d,c)){this.broken=!0;break}}else{d=m.get("each_o",a);if(!d){d=[];var e,g;switch(t(a,3,d)[0]){case 0:case 1:e="";g="d[k]";break;default:e="var v=d[k];",g="v"}d=new Function(A,"d","a","for(var k in d){"+e+"if(("+u(d,g,"k","a")+")===false){return true;}}return false;");m.set("each_o",a,d)}this.broken=d(r,b,c)}return this};x.prototype.at=function(a){return this.skip(a).first()};x.prototype.reverse=function(){return new R(this.data)};x.prototype.toJSON=z.prototype.toJSON;
D(x,R);R.prototype.each=function(a,c){var b=this.data,d=[],e;for(e in b)d.push(e),d.push(b[e]);if("string"==typeof a){b=m.get("each_or",a);if(!b){var b=[],g=t(a,3,b),f,p;switch(g[0]){case 0:case 1:e="";f="r[ii+1]";break;default:e="var v=r[ii+1];",f="v"}switch(g[1]){case 0:case 1:g="";p="r[ii]";break;default:g="var k=r[ii];",p="k"}b=new Function(A,"r","a","for(var i=r.length/2;i>0;--i){var ii=(i-1)*2;"+e+g+"if(("+u(b,f,p,"a")+")===false){return true;}}return false;");m.set("each_or",a,b)}this.broken=
b(r,d,c)}else{this.broken=!1;for(b=d.length/2;0<b;--b)if(e=2*(b-1),!1===a(d[e+1],d[e],c)){this.broken=!0;break}}return this};R.prototype.reverse=function(){return new x(this.data)};D(x,v);v.prototype.clone=function(){var a=new this.constructor(this.it),c=this.criteria;c&&(a.criteria=c.slice());return a};v.prototype.addCriteria=function(a,c,b,d){var e=this.criteria;e||(this.criteria=e=[]);e.push({keySelector:K(a||"$",3),comparer:K(c,3),asc:b,arg:d});a&&!this.keyRequired&&("string"==typeof a?(a=t(a,
3),this.keyRequired=0<a[1]):this.keyRequired=1<P(a));c&&!this.keyRequired&&("string"==typeof c?(a=t(c,3),this.keyRequired=0<a[1]):this.keyRequired=1<P(c));return this};v.prototype.each=function(a,c){var b,d,e=this.keyRequired;e||("string"==typeof a?(d=[],b=t(a,3,d),e=0<b[1]):e=1<P(a));if(e){var g=[];this.it.each("@push($$),@push($),0",g);var e=r.range(g.length/2).toArray(),f=this.criteria;e.sort(function(a,b){if(f)for(var c=0,d=f.length;c<d;++c){var e=f[c],k=e.keySelector(g[2*a+1],g[2*a],e.arg),l=
e.keySelector(g[2*b+1],g[2*b],e.arg),e=e.comparer?e.asc*e.comparer(k,l,e.arg):k==l?0:k<l?-e.asc:e.asc;if(0!=e)return e}return a==b?0:a<b?-1:1});if("string"==typeof a){var p=m.get("each_ordered_with_key",a);if(!p){b||(d=[],b=t(a,3,d));var k,l;switch(b[0]){case 0:case 1:p="";k="r[n+1]";break;default:p="var v=r[n+1];",k="v"}switch(b[1]){case 0:case 1:b="";l="r[n]";break;default:b="var k=r[n];",l="k"}p=new Function(A,"l","r","a","for(var i=0,c=l.length;i<c;++i){var n=l[i]*2;"+p+b+"if(("+u(d,k,l,"a")+
")===false)return true;}return false;");m.set("each_ordered_with_key",a,p)}this.broken=p(r,e,g,c)}else{this.broken=!1;d=0;for(b=e.length;d<b;++d)if(p=2*e[d],!1===a(g[p+1],g[p],c)){this.broken=!0;break}}}else this.iterateSortedWithoutKey(b,d,a,c);return this};v.prototype.iterateSortedWithoutKey=function(a,c,b,d){var e=this.it.toArray(),g=this.criteria;e.sort(function(a,b){if(g)for(var c=0,d=g.length;c<d;++c){var e=g[c],f=e.keySelector(a),h=e.keySelector(b),e=e.comparer?e.asc*e.comparer(f,h,e.arg):
f==h?0:f<h?-e.asc:e.asc;if(0!=e)return e}return a==b?0:a<b?-1:1});if("string"==typeof b){var f=m.get("each_ordered_without_key",b);if(!f){a||(c=[],a=t(b,3,c));switch(a[0]){case 0:case 1:a="";f="r[i]";break;default:a="var v=r[i];",f="v"}f=new Function(A,"r","a","for(var i=0,c=r.length;i<c;++i){"+a+"if(("+u(c,f,"null","a")+")===false)return true;}return false;");m.set("each_ordered_without_key",b,f)}this.broken=f(r,e,d)}else{this.broken=!1;c=0;for(a=e.length;c<a;++c)if(!1===b(e[c],null,d)){this.broken=
!0;break}}};v.prototype.thenBy=function(a,c,b){return this.clone().addCriteria(a,c,1,b)};v.prototype.thenByDesc=function(a,c,b){return this.clone().addCriteria(a,c,-1,b)};D(v,S);S.prototype.each=function(a,c){var b,d,e=this.keyRequired;e||("string"==typeof a?(d=[],b=t(a,3,d),e=0<b[1]):e=1<P(a));var f=this.it,h=f.data,p=this.criteria;if(e)if(e=this.it.select("$$").toArray(),e.sort(function(a,b){if(p)for(var c=0,d=p.length;c<d;++c){var e=p[c],k=e.keySelector(f.getItem(h,a),a,e.arg),l=e.keySelector(f.getItem(h,
b),b,e.arg),e=e.comparer?e.asc*e.comparer(k,l,e.arg):k==l?0:k<l?-e.asc:e.asc;if(0!=e)return e}return a==b?0:a<b?-1:1}),"string"==typeof a){var k=m.get("each_ordered_random_access_with_key",a);if(!k){b||(d=[],b=t(a,3,d));var l,n;switch(b[1]){case 0:k="";n="l[i]";break;default:k="var k=l[i];",n="k"}switch(b[0]){case 0:case 1:b="";l=f.lambdaGetItem("r",n);break;default:b="var v="+f.lambdaGetItem("r",n)+";",l="v"}k=new Function(A,"l","r","a","for(var i=0,c=l.length;i<c;++i){"+k+b+"if(("+u(d,l,n,"a")+
")===false)return true;}return false;");m.set("each_ordered_random_access_with_key",a,k)}this.broken=k(r,e,h,c)}else{this.broken=!1;d=0;for(b=e.length;d<b;++d)if(k=e[d],!1===a(f.getItem(h,k),k,c)){this.broken=!0;break}}else this.iterateSortedWithoutKey(b,d,a,c);return this};D(f,J);J.prototype.each=function(a,c){var b=this._r;b.lastIndex=0;if(b.global){var d;"function"==typeof a&&(d=a,a="_p($,$$,@)");b=m.get("each_regexp",a);if(!b){var b=[],e,f;0==t(a,3,b)[1]?f=e="":(e="var _i=0",f="++_i");b=new Function(A,
"_r","_s","_a","_p",["var _m;for(",e,";_m=_r.exec(_s);",f,"){if((",u(b,"_m","_i","_a"),")===false){return true;}}return false;"].join(""));m.set("each_regexp",a,b)}this.broken=b(r,this._r,this._str,c,d)}else"string"==typeof a&&(a=K(a,3)),this.broken=(d=b.exec(this._str))?!1===a(d,0,c):!1;return this};J.prototype.any=function(a,c){if(a)return f.prototype.any.call(this,a,c);var b=this._r;b.lastIndex=0;return b.test(this._str)};J.prototype.first=function(a,c){if(a)return f.prototype.first.call(this,
a,c);var b=this._r;b.lastIndex=0;return b.exec(this._str)};r.range=function(a,c,b){switch(arguments.length){case 1:c=a;a=0;b=1;break;case 2:b=c>a?1:-1}return new f(function(d,e){if("string"==typeof d){var f=0<b?"each_ru":"each_rd",h=m.get(f,d);h||(h=new Function("s","e","st","a","for(var i=s;i"+(0<b?"<":">")+"e;i+=st){if(("+n(d,"i","i","a")+")===false)return true;}return false;"),m.set(f,d,h));this.broken=h(a,c,b,e)}else if(this.broken=!1,0<b)for(f=a;f<c;f+=b){if(!1===d(f,f,e)){this.broken=!0;break}}else for(f=
a;f>c;f+=b)if(!1===d(f,f,e)){this.broken=!0;break}return this})};r.repeat=function(a,c){return new f(function(b,d){if("string"==typeof b){var e=m.get("each_rpt",b);e||(e=new Function("c","e","a","for(var i=0;i<c;++i){if(("+n(b,"e","i","a")+")===false)return true;}return false;"),m.set("each_rpt",b,e));this.broken=e(c,a,d)}else{this.broken=!1;for(e=0;e<c;++e)if(!1===b(a,e,d)){this.broken=!0;break}}return this})};r.setAlias=function(a){A=a};r.lambda={replace:n,parse:K,getUseCount:t,join:u};"nodejs"==
V?module.exports=r:window.from=r})();