aleph_analytics 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -143,7 +143,7 @@ o(g,m),u(e)}function f(){var e=na.mouse(this),t=Math.log(C.k)/Math.LN2;a(this,e,
143
143
  alpha:i})},s.nodes=function(e){return arguments.length?(v=e,s):v},s.links=function(e){return arguments.length?(_=e,s):_},s.size=function(e){return arguments.length?(u=e,s):u},s.linkDistance=function(e){return arguments.length?(d="function"==typeof e?e:+e,s):d},s.distance=s.linkDistance,s.linkStrength=function(e){return arguments.length?(h="function"==typeof e?e:+e,s):h},s.friction=function(e){return arguments.length?(c=+e,s):c},s.charge=function(e){return arguments.length?(p="function"==typeof e?e:+e,s):p},s.chargeDistance=function(e){return arguments.length?(f=e*e,s):Math.sqrt(f)},s.gravity=function(e){return arguments.length?(m=+e,s):m},s.theta=function(e){return arguments.length?(g=e*e,s):Math.sqrt(g)},s.alpha=function(e){return arguments.length?(e=+e,i?i=e>0?e:0:e>0&&(l.start({type:"start",alpha:i=e}),na.timer(s.tick)),s):i},s.start=function(){function e(e,i){if(!n){for(n=new Array(l),s=0;l>s;++s)n[s]=[];for(s=0;c>s;++s){var r=_[s];n[r.source.index].push(r.target),n[r.target.index].push(r.source)}}for(var o,a=n[t],s=-1,u=a.length;++s<u;)if(!isNaN(o=a[s][e]))return o;return Math.random()*i}var t,n,i,l=v.length,c=_.length,f=u[0],m=u[1];for(t=0;l>t;++t)(i=v[t]).index=t,i.weight=0;for(t=0;c>t;++t)i=_[t],"number"==typeof i.source&&(i.source=v[i.source]),"number"==typeof i.target&&(i.target=v[i.target]),++i.source.weight,++i.target.weight;for(t=0;l>t;++t)i=v[t],isNaN(i.x)&&(i.x=e("x",f)),isNaN(i.y)&&(i.y=e("y",m)),isNaN(i.px)&&(i.px=i.x),isNaN(i.py)&&(i.py=i.y);if(r=[],"function"==typeof d)for(t=0;c>t;++t)r[t]=+d.call(this,_[t],t);else for(t=0;c>t;++t)r[t]=d;if(o=[],"function"==typeof h)for(t=0;c>t;++t)o[t]=+h.call(this,_[t],t);else for(t=0;c>t;++t)o[t]=h;if(a=[],"function"==typeof p)for(t=0;l>t;++t)a[t]=+p.call(this,v[t],t);else for(t=0;l>t;++t)a[t]=p;return s.resume()},s.resume=function(){return s.alpha(.1)},s.stop=function(){return s.alpha(0)},s.drag=function(){return n||(n=na.behavior.drag().origin(y).on("dragstart.force",Vi).on("drag.force",t).on("dragend.force",Xi)),arguments.length?void this.on("mouseover.force",Gi).on("mouseout.force",Ki).call(n):n},na.rebind(s,l,"on")};var hl=20,pl=1,fl=1/0;na.layout.hierarchy=function(){function e(r){var o,a=[r],s=[];for(r.depth=0;null!=(o=a.pop());)if(s.push(o),(u=n.call(e,o,o.depth))&&(l=u.length)){for(var l,u,c;--l>=0;)a.push(c=u[l]),c.parent=o,c.depth=o.depth+1;i&&(o.value=0),o.children=u}else i&&(o.value=+i.call(e,o,o.depth)||0),delete o.children;return er(r,function(e){var n,r;t&&(n=e.children)&&n.sort(t),i&&(r=e.parent)&&(r.value+=e.value)}),s}var t=ir,n=tr,i=nr;return e.sort=function(n){return arguments.length?(t=n,e):t},e.children=function(t){return arguments.length?(n=t,e):n},e.value=function(t){return arguments.length?(i=t,e):i},e.revalue=function(t){return i&&(Zi(t,function(e){e.children&&(e.value=0)}),er(t,function(t){var n;t.children||(t.value=+i.call(e,t,t.depth)||0),(n=t.parent)&&(n.value+=t.value)})),t},e},na.layout.partition=function(){function e(t,n,i,r){var o=t.children;if(t.x=n,t.y=t.depth*r,t.dx=i,t.dy=r,o&&(a=o.length)){var a,s,l,u=-1;for(i=t.value?i/t.value:0;++u<a;)e(s=o[u],n,l=s.value*i,r),n+=l}}function t(e){var n=e.children,i=0;if(n&&(r=n.length))for(var r,o=-1;++o<r;)i=Math.max(i,t(n[o]));return 1+i}function n(n,o){var a=i.call(this,n,o);return e(a[0],0,r[0],r[1]/t(a[0])),a}var i=na.layout.hierarchy(),r=[1,1];return n.size=function(e){return arguments.length?(r=e,n):r},Qi(n,i)},na.layout.pie=function(){function e(a){var s,l=a.length,u=a.map(function(n,i){return+t.call(e,n,i)}),c=+("function"==typeof i?i.apply(this,arguments):i),d=("function"==typeof r?r.apply(this,arguments):r)-c,h=Math.min(Math.abs(d)/l,+("function"==typeof o?o.apply(this,arguments):o)),p=h*(0>d?-1:1),f=(d-l*p)/na.sum(u),m=na.range(l),g=[];return null!=n&&m.sort(n===ml?function(e,t){return u[t]-u[e]}:function(e,t){return n(a[e],a[t])}),m.forEach(function(e){g[e]={data:a[e],value:s=u[e],startAngle:c,endAngle:c+=s*f+p,padAngle:h}}),g}var t=Number,n=ml,i=0,r=Fa,o=0;return e.value=function(n){return arguments.length?(t=n,e):t},e.sort=function(t){return arguments.length?(n=t,e):n},e.startAngle=function(t){return arguments.length?(i=t,e):i},e.endAngle=function(t){return arguments.length?(r=t,e):r},e.padAngle=function(t){return arguments.length?(o=t,e):o},e};var ml={};na.layout.stack=function(){function e(s,l){if(!(h=s.length))return s;var u=s.map(function(n,i){return t.call(e,n,i)}),c=u.map(function(t){return t.map(function(t,n){return[o.call(e,t,n),a.call(e,t,n)]})}),d=n.call(e,c,l);u=na.permute(u,d),c=na.permute(c,d);var h,p,f,m,g=i.call(e,c,l),v=u[0].length;for(f=0;v>f;++f)for(r.call(e,u[0][f],m=g[f],c[0][f][1]),p=1;h>p;++p)r.call(e,u[p][f],m+=c[p-1][f][1],c[p][f][1]);return s}var t=y,n=lr,i=ur,r=sr,o=or,a=ar;return e.values=function(n){return arguments.length?(t=n,e):t},e.order=function(t){return arguments.length?(n="function"==typeof t?t:gl.get(t)||lr,e):n},e.offset=function(t){return arguments.length?(i="function"==typeof t?t:vl.get(t)||ur,e):i},e.x=function(t){return arguments.length?(o=t,e):o},e.y=function(t){return arguments.length?(a=t,e):a},e.out=function(t){return arguments.length?(r=t,e):r},e};var gl=na.map({"inside-out":function(e){var t,n,i=e.length,r=e.map(cr),o=e.map(dr),a=na.range(i).sort(function(e,t){return r[e]-r[t]}),s=0,l=0,u=[],c=[];for(t=0;i>t;++t)n=a[t],l>s?(s+=o[n],u.push(n)):(l+=o[n],c.push(n));return c.reverse().concat(u)},reverse:function(e){return na.range(e.length).reverse()},"default":lr}),vl=na.map({silhouette:function(e){var t,n,i,r=e.length,o=e[0].length,a=[],s=0,l=[];for(n=0;o>n;++n){for(t=0,i=0;r>t;t++)i+=e[t][n][1];i>s&&(s=i),a.push(i)}for(n=0;o>n;++n)l[n]=(s-a[n])/2;return l},wiggle:function(e){var t,n,i,r,o,a,s,l,u,c=e.length,d=e[0],h=d.length,p=[];for(p[0]=l=u=0,n=1;h>n;++n){for(t=0,r=0;c>t;++t)r+=e[t][n][1];for(t=0,o=0,s=d[n][0]-d[n-1][0];c>t;++t){for(i=0,a=(e[t][n][1]-e[t][n-1][1])/(2*s);t>i;++i)a+=(e[i][n][1]-e[i][n-1][1])/s;o+=a*e[t][n][1]}p[n]=l-=r?o/r*s:0,u>l&&(u=l)}for(n=0;h>n;++n)p[n]-=u;return p},expand:function(e){var t,n,i,r=e.length,o=e[0].length,a=1/r,s=[];for(n=0;o>n;++n){for(t=0,i=0;r>t;t++)i+=e[t][n][1];if(i)for(t=0;r>t;t++)e[t][n][1]/=i;else for(t=0;r>t;t++)e[t][n][1]=a}for(n=0;o>n;++n)s[n]=0;return s},zero:ur});na.layout.histogram=function(){function e(e,o){for(var a,s,l=[],u=e.map(n,this),c=i.call(this,u,o),d=r.call(this,c,u,o),o=-1,h=u.length,p=d.length-1,f=t?1:1/h;++o<p;)a=l[o]=[],a.dx=d[o+1]-(a.x=d[o]),a.y=0;if(p>0)for(o=-1;++o<h;)s=u[o],s>=c[0]&&s<=c[1]&&(a=l[na.bisect(d,s,1,p)-1],a.y+=f,a.push(e[o]));return l}var t=!0,n=Number,i=mr,r=pr;return e.value=function(t){return arguments.length?(n=t,e):n},e.range=function(t){return arguments.length?(i=Ae(t),e):i},e.bins=function(t){return arguments.length?(r="number"==typeof t?function(e){return fr(e,t)}:Ae(t),e):r},e.frequency=function(n){return arguments.length?(t=!!n,e):t},e},na.layout.pack=function(){function e(e,o){var a=n.call(this,e,o),s=a[0],l=r[0],u=r[1],c=null==t?Math.sqrt:"function"==typeof t?t:function(){return t};if(s.x=s.y=0,er(s,function(e){e.r=+c(e.value)}),er(s,br),i){var d=i*(t?1:Math.max(2*s.r/l,2*s.r/u))/2;er(s,function(e){e.r+=d}),er(s,br),er(s,function(e){e.r-=d})}return $r(s,l/2,u/2,t?1:1/Math.max(2*s.r/l,2*s.r/u)),a}var t,n=na.layout.hierarchy().sort(gr),i=0,r=[1,1];return e.size=function(t){return arguments.length?(r=t,e):r},e.radius=function(n){return arguments.length?(t=null==n||"function"==typeof n?n:+n,e):t},e.padding=function(t){return arguments.length?(i=+t,e):i},Qi(e,n)},na.layout.tree=function(){function e(e,r){var c=a.call(this,e,r),d=c[0],h=t(d);if(er(h,n),h.parent.m=-h.z,Zi(h,i),u)Zi(d,o);else{var p=d,f=d,m=d;Zi(d,function(e){e.x<p.x&&(p=e),e.x>f.x&&(f=e),e.depth>m.depth&&(m=e)});var g=s(p,f)/2-p.x,v=l[0]/(f.x+s(f,p)/2+g),y=l[1]/(m.depth||1);Zi(d,function(e){e.x=(e.x+g)*v,e.y=e.depth*y})}return c}function t(e){for(var t,n={A:null,children:[e]},i=[n];null!=(t=i.pop());)for(var r,o=t.children,a=0,s=o.length;s>a;++a)i.push((o[a]=r={_:o[a],parent:t,children:(r=o[a].children)&&r.slice()||[],A:null,a:null,z:0,m:0,c:0,s:0,t:null,i:a}).a=r);return n.children[0]}function n(e){var t=e.children,n=e.parent.children,i=e.i?n[e.i-1]:null;if(t.length){Sr(e);var o=(t[0].z+t[t.length-1].z)/2;i?(e.z=i.z+s(e._,i._),e.m=e.z-o):e.z=o}else i&&(e.z=i.z+s(e._,i._));e.parent.A=r(e,i,e.parent.A||n[0])}function i(e){e._.x=e.z+e.parent.m,e.m+=e.parent.m}function r(e,t,n){if(t){for(var i,r=e,o=e,a=t,l=r.parent.children[0],u=r.m,c=o.m,d=a.m,h=l.m;a=Mr(a),r=Ar(r),a&&r;)l=Ar(l),o=Mr(o),o.a=e,i=a.z+d-r.z-u+s(a._,r._),i>0&&(Tr(Dr(a,e,n),e,i),u+=i,c+=i),d+=a.m,u+=r.m,h+=l.m,c+=o.m;a&&!Mr(o)&&(o.t=a,o.m+=d-c),r&&!Ar(l)&&(l.t=r,l.m+=u-h,n=e)}return n}function o(e){e.x*=l[0],e.y=e.depth*l[1]}var a=na.layout.hierarchy().sort(null).value(null),s=Cr,l=[1,1],u=null;return e.separation=function(t){return arguments.length?(s=t,e):s},e.size=function(t){return arguments.length?(u=null==(l=t)?o:null,e):u?null:l},e.nodeSize=function(t){return arguments.length?(u=null==(l=t)?null:o,e):u?l:null},Qi(e,a)},na.layout.cluster=function(){function e(e,o){var a,s=t.call(this,e,o),l=s[0],u=0;er(l,function(e){var t=e.children;t&&t.length?(e.x=Lr(t),e.y=Er(t)):(e.x=a?u+=n(e,a):0,e.y=0,a=e)});var c=Fr(l),d=Or(l),h=c.x-n(c,d)/2,p=d.x+n(d,c)/2;return er(l,r?function(e){e.x=(e.x-l.x)*i[0],e.y=(l.y-e.y)*i[1]}:function(e){e.x=(e.x-h)/(p-h)*i[0],e.y=(1-(l.y?e.y/l.y:1))*i[1]}),s}var t=na.layout.hierarchy().sort(null).value(null),n=Cr,i=[1,1],r=!1;return e.separation=function(t){return arguments.length?(n=t,e):n},e.size=function(t){return arguments.length?(r=null==(i=t),e):r?null:i},e.nodeSize=function(t){return arguments.length?(r=null!=(i=t),e):r?i:null},Qi(e,t)},na.layout.treemap=function(){function e(e,t){for(var n,i,r=-1,o=e.length;++r<o;)i=(n=e[r]).value*(0>t?0:t),n.area=isNaN(i)||0>=i?0:i}function t(n){var o=n.children;if(o&&o.length){var a,s,l,u=d(n),c=[],h=o.slice(),f=1/0,m="slice"===p?u.dx:"dice"===p?u.dy:"slice-dice"===p?1&n.depth?u.dy:u.dx:Math.min(u.dx,u.dy);for(e(h,u.dx*u.dy/n.value),c.area=0;(l=h.length)>0;)c.push(a=h[l-1]),c.area+=a.area,"squarify"!==p||(s=i(c,m))<=f?(h.pop(),f=s):(c.area-=c.pop().area,r(c,m,u,!1),m=Math.min(u.dx,u.dy),c.length=c.area=0,f=1/0);c.length&&(r(c,m,u,!0),c.length=c.area=0),o.forEach(t)}}function n(t){var i=t.children;if(i&&i.length){var o,a=d(t),s=i.slice(),l=[];for(e(s,a.dx*a.dy/t.value),l.area=0;o=s.pop();)l.push(o),l.area+=o.area,null!=o.z&&(r(l,o.z?a.dx:a.dy,a,!s.length),l.length=l.area=0);i.forEach(n)}}function i(e,t){for(var n,i=e.area,r=0,o=1/0,a=-1,s=e.length;++a<s;)(n=e[a].area)&&(o>n&&(o=n),n>r&&(r=n));return i*=i,t*=t,i?Math.max(t*r*f/i,i/(t*o*f)):1/0}function r(e,t,n,i){var r,o=-1,a=e.length,s=n.x,u=n.y,c=t?l(e.area/t):0;if(t==n.dx){for((i||c>n.dy)&&(c=n.dy);++o<a;)r=e[o],r.x=s,r.y=u,r.dy=c,s+=r.dx=Math.min(n.x+n.dx-s,c?l(r.area/c):0);r.z=!0,r.dx+=n.x+n.dx-s,n.y+=c,n.dy-=c}else{for((i||c>n.dx)&&(c=n.dx);++o<a;)r=e[o],r.x=s,r.y=u,r.dx=c,u+=r.dy=Math.min(n.y+n.dy-u,c?l(r.area/c):0);r.z=!1,r.dy+=n.y+n.dy-u,n.x+=c,n.dx-=c}}function o(i){var r=a||s(i),o=r[0];return o.x=0,o.y=0,o.dx=u[0],o.dy=u[1],a&&s.revalue(o),e([o],o.dx*o.dy/o.value),(a?n:t)(o),h&&(a=r),r}var a,s=na.layout.hierarchy(),l=Math.round,u=[1,1],c=null,d=Rr,h=!1,p="squarify",f=.5*(1+Math.sqrt(5));return o.size=function(e){return arguments.length?(u=e,o):u},o.padding=function(e){function t(t){var n=e.call(o,t,t.depth);return null==n?Rr(t):Br(t,"number"==typeof n?[n,n,n,n]:n)}function n(t){return Br(t,e)}if(!arguments.length)return c;var i;return d=null==(c=e)?Rr:"function"==(i=typeof e)?t:"number"===i?(e=[e,e,e,e],n):n,o},o.round=function(e){return arguments.length?(l=e?Math.round:Number,o):l!=Number},o.sticky=function(e){return arguments.length?(h=e,a=null,o):h},o.ratio=function(e){return arguments.length?(f=e,o):f},o.mode=function(e){return arguments.length?(p=e+"",o):p},Qi(o,s)},na.random={normal:function(e,t){var n=arguments.length;return 2>n&&(t=1),1>n&&(e=0),function(){var n,i,r;do n=2*Math.random()-1,i=2*Math.random()-1,r=n*n+i*i;while(!r||r>1);return e+t*n*Math.sqrt(-2*Math.log(r)/r)}},logNormal:function(){var e=na.random.normal.apply(na,arguments);return function(){return Math.exp(e())}},bates:function(e){var t=na.random.irwinHall(e);return function(){return t()/e}},irwinHall:function(e){return function(){for(var t=0,n=0;e>n;n++)t+=Math.random();return t}}},na.scale={};var yl={floor:y,ceil:y};na.scale.linear=function(){return zr([0,1],[0,1],yi,!1)};var _l={s:1,g:1,p:1,r:1,e:1};na.scale.log=function(){return Jr(na.scale.linear().domain([0,1]),10,!0,[1,10])};var bl=na.format(".0e"),xl={floor:function(e){return-Math.ceil(-e)},ceil:function(e){return-Math.floor(-e)}};na.scale.pow=function(){return Qr(na.scale.linear(),1,[0,1])},na.scale.sqrt=function(){return na.scale.pow().exponent(.5)},na.scale.ordinal=function(){return eo([],{t:"range",a:[[]]})},na.scale.category10=function(){return na.scale.ordinal().range(wl)},na.scale.category20=function(){return na.scale.ordinal().range($l)},na.scale.category20b=function(){return na.scale.ordinal().range(kl)},na.scale.category20c=function(){return na.scale.ordinal().range(Cl)};var wl=[2062260,16744206,2924588,14034728,9725885,9197131,14907330,8355711,12369186,1556175].map(_e),$l=[2062260,11454440,16744206,16759672,2924588,10018698,14034728,16750742,9725885,12955861,9197131,12885140,14907330,16234194,8355711,13092807,12369186,14408589,1556175,10410725].map(_e),kl=[3750777,5395619,7040719,10264286,6519097,9216594,11915115,13556636,9202993,12426809,15186514,15190932,8666169,11356490,14049643,15177372,8077683,10834324,13528509,14589654].map(_e),Cl=[3244733,7057110,10406625,13032431,15095053,16616764,16625259,16634018,3253076,7652470,10607003,13101504,7695281,10394312,12369372,14342891,6513507,9868950,12434877,14277081].map(_e);na.scale.quantile=function(){return to([],[])},na.scale.quantize=function(){return no(0,1,[0,1])},na.scale.threshold=function(){return io([.5],[0,1])},na.scale.identity=function(){return ro([0,1])},na.svg={},na.svg.arc=function(){function e(){var e=Math.max(0,+n.apply(this,arguments)),u=Math.max(0,+i.apply(this,arguments)),c=a.apply(this,arguments)-Ra,d=s.apply(this,arguments)-Ra,h=Math.abs(d-c),p=c>d?0:1;if(e>u&&(f=u,u=e,e=f),h>=Oa)return t(u,p)+(e?t(e,1-p):"")+"Z";var f,m,g,v,y,_,b,x,w,$,k,C,A=0,M=0,T=[];if((v=(+l.apply(this,arguments)||0)/2)&&(g=o===Al?Math.sqrt(e*e+u*u):+o.apply(this,arguments),p||(M*=-1),u&&(M=te(g/u*Math.sin(v))),e&&(A=te(g/e*Math.sin(v)))),u){y=u*Math.cos(c+M),_=u*Math.sin(c+M),b=u*Math.cos(d-M),x=u*Math.sin(d-M);var S=Math.abs(d-c-2*M)<=La?0:1;if(M&&ho(y,_,b,x)===p^S){var D=(c+d)/2;y=u*Math.cos(D),_=u*Math.sin(D),b=x=null}}else y=_=0;if(e){w=e*Math.cos(d-A),$=e*Math.sin(d-A),k=e*Math.cos(c+A),C=e*Math.sin(c+A);var E=Math.abs(c-d+2*A)<=La?0:1;if(A&&ho(w,$,k,C)===1-p^E){var L=(c+d)/2;w=e*Math.cos(L),$=e*Math.sin(L),k=C=null}}else w=$=0;if((f=Math.min(Math.abs(u-e)/2,+r.apply(this,arguments)))>.001){m=u>e^p?0:1;var F=null==k?[w,$]:null==b?[y,_]:Fn([y,_],[k,C],[b,x],[w,$]),O=y-F[0],R=_-F[1],B=b-F[0],P=x-F[1],I=1/Math.sin(Math.acos((O*B+R*P)/(Math.sqrt(O*O+R*R)*Math.sqrt(B*B+P*P)))/2),Y=Math.sqrt(F[0]*F[0]+F[1]*F[1]);if(null!=b){var j=Math.min(f,(u-Y)/(I+1)),N=po(null==k?[w,$]:[k,C],[y,_],u,j,p),H=po([b,x],[w,$],u,j,p);f===j?T.push("M",N[0],"A",j,",",j," 0 0,",m," ",N[1],"A",u,",",u," 0 ",1-p^ho(N[1][0],N[1][1],H[1][0],H[1][1]),",",p," ",H[1],"A",j,",",j," 0 0,",m," ",H[0]):T.push("M",N[0],"A",j,",",j," 0 1,",m," ",H[0])}else T.push("M",y,",",_);if(null!=k){var z=Math.min(f,(e-Y)/(I-1)),q=po([y,_],[k,C],e,-z,p),W=po([w,$],null==b?[y,_]:[b,x],e,-z,p);f===z?T.push("L",W[0],"A",z,",",z," 0 0,",m," ",W[1],"A",e,",",e," 0 ",p^ho(W[1][0],W[1][1],q[1][0],q[1][1]),",",1-p," ",q[1],"A",z,",",z," 0 0,",m," ",q[0]):T.push("L",W[0],"A",z,",",z," 0 0,",m," ",q[0])}else T.push("L",w,",",$)}else T.push("M",y,",",_),null!=b&&T.push("A",u,",",u," 0 ",S,",",p," ",b,",",x),T.push("L",w,",",$),null!=k&&T.push("A",e,",",e," 0 ",E,",",1-p," ",k,",",C);return T.push("Z"),T.join("")}function t(e,t){return"M0,"+e+"A"+e+","+e+" 0 1,"+t+" 0,"+-e+"A"+e+","+e+" 0 1,"+t+" 0,"+e}var n=ao,i=so,r=oo,o=Al,a=lo,s=uo,l=co;return e.innerRadius=function(t){return arguments.length?(n=Ae(t),e):n},e.outerRadius=function(t){return arguments.length?(i=Ae(t),e):i},e.cornerRadius=function(t){return arguments.length?(r=Ae(t),e):r},e.padRadius=function(t){return arguments.length?(o=t==Al?Al:Ae(t),e):o},e.startAngle=function(t){return arguments.length?(a=Ae(t),e):a},e.endAngle=function(t){return arguments.length?(s=Ae(t),e):s},e.padAngle=function(t){return arguments.length?(l=Ae(t),e):l},e.centroid=function(){var e=(+n.apply(this,arguments)+ +i.apply(this,arguments))/2,t=(+a.apply(this,arguments)+ +s.apply(this,arguments))/2-Ra;return[Math.cos(t)*e,Math.sin(t)*e]},e};var Al="auto";na.svg.line=function(){return fo(y)};var Ml=na.map({linear:mo,"linear-closed":go,step:vo,"step-before":yo,"step-after":_o,basis:Co,"basis-open":Ao,"basis-closed":Mo,bundle:To,cardinal:wo,"cardinal-open":bo,"cardinal-closed":xo,monotone:Oo});Ml.forEach(function(e,t){t.key=e,t.closed=/-closed$/.test(e)});var Tl=[0,2/3,1/3,0],Sl=[0,1/3,2/3,0],Dl=[0,1/6,2/3,1/6];na.svg.line.radial=function(){var e=fo(Ro);return e.radius=e.x,delete e.x,e.angle=e.y,delete e.y,e},yo.reverse=_o,_o.reverse=yo,na.svg.area=function(){return Bo(y)},na.svg.area.radial=function(){var e=Bo(Ro);return e.radius=e.x,delete e.x,e.innerRadius=e.x0,delete e.x0,e.outerRadius=e.x1,delete e.x1,e.angle=e.y,delete e.y,e.startAngle=e.y0,delete e.y0,e.endAngle=e.y1,delete e.y1,e},na.svg.chord=function(){function e(e,s){var l=t(this,o,e,s),u=t(this,a,e,s);return"M"+l.p0+i(l.r,l.p1,l.a1-l.a0)+(n(l,u)?r(l.r,l.p1,l.r,l.p0):r(l.r,l.p1,u.r,u.p0)+i(u.r,u.p1,u.a1-u.a0)+r(u.r,u.p1,l.r,l.p0))+"Z"}function t(e,t,n,i){var r=t.call(e,n,i),o=s.call(e,r,i),a=l.call(e,r,i)-Ra,c=u.call(e,r,i)-Ra;return{r:o,a0:a,a1:c,p0:[o*Math.cos(a),o*Math.sin(a)],p1:[o*Math.cos(c),o*Math.sin(c)]}}function n(e,t){return e.a0==t.a0&&e.a1==t.a1}function i(e,t,n){return"A"+e+","+e+" 0 "+ +(n>La)+",1 "+t}function r(e,t,n,i){return"Q 0,0 "+i}var o=yn,a=_n,s=Po,l=lo,u=uo;return e.radius=function(t){return arguments.length?(s=Ae(t),e):s},e.source=function(t){return arguments.length?(o=Ae(t),e):o},e.target=function(t){return arguments.length?(a=Ae(t),e):a},e.startAngle=function(t){return arguments.length?(l=Ae(t),e):l},e.endAngle=function(t){return arguments.length?(u=Ae(t),e):u},e},na.svg.diagonal=function(){function e(e,r){var o=t.call(this,e,r),a=n.call(this,e,r),s=(o.y+a.y)/2,l=[o,{x:o.x,y:s},{x:a.x,y:s},a];return l=l.map(i),"M"+l[0]+"C"+l[1]+" "+l[2]+" "+l[3]}var t=yn,n=_n,i=Io;return e.source=function(n){return arguments.length?(t=Ae(n),e):t},e.target=function(t){return arguments.length?(n=Ae(t),e):n},e.projection=function(t){return arguments.length?(i=t,e):i},e},na.svg.diagonal.radial=function(){var e=na.svg.diagonal(),t=Io,n=e.projection;return e.projection=function(e){return arguments.length?n(Yo(t=e)):t},e},na.svg.symbol=function(){function e(e,i){return(El.get(t.call(this,e,i))||Ho)(n.call(this,e,i))}var t=No,n=jo;return e.type=function(n){return arguments.length?(t=Ae(n),e):t},e.size=function(t){return arguments.length?(n=Ae(t),e):n},e};var El=na.map({circle:Ho,cross:function(e){var t=Math.sqrt(e/5)/2;return"M"+-3*t+","+-t+"H"+-t+"V"+-3*t+"H"+t+"V"+-t+"H"+3*t+"V"+t+"H"+t+"V"+3*t+"H"+-t+"V"+t+"H"+-3*t+"Z"},diamond:function(e){var t=Math.sqrt(e/(2*Fl)),n=t*Fl;return"M0,"+-t+"L"+n+",0 0,"+t+" "+-n+",0Z"},square:function(e){var t=Math.sqrt(e)/2;return"M"+-t+","+-t+"L"+t+","+-t+" "+t+","+t+" "+-t+","+t+"Z"},"triangle-down":function(e){var t=Math.sqrt(e/Ll),n=t*Ll/2;return"M0,"+n+"L"+t+","+-n+" "+-t+","+-n+"Z"},"triangle-up":function(e){var t=Math.sqrt(e/Ll),n=t*Ll/2;return"M0,"+-n+"L"+t+","+n+" "+-t+","+n+"Z"}});na.svg.symbolTypes=El.keys();var Ll=Math.sqrt(3),Fl=Math.tan(30*Ba);$a.transition=function(e){for(var t,n,i=Ol||++Il,r=Vo(e),o=[],a=Rl||{time:Date.now(),ease:Ci,delay:0,duration:250},s=-1,l=this.length;++s<l;){o.push(t=[]);for(var u=this[s],c=-1,d=u.length;++c<d;)(n=u[c])&&Xo(n,c,r,i,a),t.push(n)}return qo(o,r,i)},$a.interrupt=function(e){return this.each(null==e?Bl:zo(Vo(e)))};var Ol,Rl,Bl=zo(Vo()),Pl=[],Il=0;Pl.call=$a.call,Pl.empty=$a.empty,Pl.node=$a.node,Pl.size=$a.size,na.transition=function(e,t){return e&&e.transition?Ol?e.transition(t):e:na.selection().transition(e)},na.transition.prototype=Pl,Pl.select=function(e){var t,n,i,r=this.id,o=this.namespace,a=[];e=T(e);for(var s=-1,l=this.length;++s<l;){a.push(t=[]);for(var u=this[s],c=-1,d=u.length;++c<d;)(i=u[c])&&(n=e.call(i,i.__data__,c,s))?("__data__"in i&&(n.__data__=i.__data__),Xo(n,c,o,r,i[o][r]),t.push(n)):t.push(null)}return qo(a,o,r)},Pl.selectAll=function(e){var t,n,i,r,o,a=this.id,s=this.namespace,l=[];e=S(e);for(var u=-1,c=this.length;++u<c;)for(var d=this[u],h=-1,p=d.length;++h<p;)if(i=d[h]){o=i[s][a],n=e.call(i,i.__data__,h,u),l.push(t=[]);for(var f=-1,m=n.length;++f<m;)(r=n[f])&&Xo(r,f,s,a,o),t.push(r)}return qo(l,s,a)},Pl.filter=function(e){var t,n,i,r=[];"function"!=typeof e&&(e=N(e));for(var o=0,a=this.length;a>o;o++){r.push(t=[]);for(var n=this[o],s=0,l=n.length;l>s;s++)(i=n[s])&&e.call(i,i.__data__,s,o)&&t.push(i)}return qo(r,this.namespace,this.id)},Pl.tween=function(e,t){var n=this.id,i=this.namespace;return arguments.length<2?this.node()[i][n].tween.get(e):z(this,null==t?function(t){t[i][n].tween.remove(e)}:function(r){r[i][n].tween.set(e,t)})},Pl.attr=function(e,t){function n(){this.removeAttribute(s)}function i(){this.removeAttributeNS(s.space,s.local)}function r(e){return null==e?n:(e+="",function(){var t,n=this.getAttribute(s);return n!==e&&(t=a(n,e),function(e){this.setAttribute(s,t(e))})})}function o(e){return null==e?i:(e+="",function(){var t,n=this.getAttributeNS(s.space,s.local);return n!==e&&(t=a(n,e),function(e){this.setAttributeNS(s.space,s.local,t(e))})})}if(arguments.length<2){for(t in e)this.attr(t,e[t]);return this}var a="transform"==e?Ni:yi,s=na.ns.qualify(e);return Wo(this,"attr."+e,t,s.local?o:r)},Pl.attrTween=function(e,t){function n(e,n){var i=t.call(this,e,n,this.getAttribute(r));return i&&function(e){this.setAttribute(r,i(e))}}function i(e,n){var i=t.call(this,e,n,this.getAttributeNS(r.space,r.local));return i&&function(e){this.setAttributeNS(r.space,r.local,i(e))}}var r=na.ns.qualify(e);return this.tween("attr."+e,r.local?i:n)},Pl.style=function(e,n,i){function r(){this.style.removeProperty(e)}function o(n){return null==n?r:(n+="",function(){var r,o=t(this).getComputedStyle(this,null).getPropertyValue(e);return o!==n&&(r=yi(o,n),function(t){this.style.setProperty(e,r(t),i)})})}var a=arguments.length;if(3>a){if("string"!=typeof e){2>a&&(n="");for(i in e)this.style(i,e[i],n);return this}i=""}return Wo(this,"style."+e,n,o)},Pl.styleTween=function(e,n,i){function r(r,o){var a=n.call(this,r,o,t(this).getComputedStyle(this,null).getPropertyValue(e));return a&&function(t){this.style.setProperty(e,a(t),i)}}return arguments.length<3&&(i=""),this.tween("style."+e,r)},Pl.text=function(e){return Wo(this,"text",e,Uo)},Pl.remove=function(){var e=this.namespace;return this.each("end.transition",function(){var t;this[e].count<2&&(t=this.parentNode)&&t.removeChild(this)})},Pl.ease=function(e){var t=this.id,n=this.namespace;return arguments.length<1?this.node()[n][t].ease:("function"!=typeof e&&(e=na.ease.apply(na,arguments)),z(this,function(i){i[n][t].ease=e}))},Pl.delay=function(e){var t=this.id,n=this.namespace;return arguments.length<1?this.node()[n][t].delay:z(this,"function"==typeof e?function(i,r,o){i[n][t].delay=+e.call(i,i.__data__,r,o)}:(e=+e,function(i){i[n][t].delay=e}))},Pl.duration=function(e){var t=this.id,n=this.namespace;return arguments.length<1?this.node()[n][t].duration:z(this,"function"==typeof e?function(i,r,o){i[n][t].duration=Math.max(1,e.call(i,i.__data__,r,o))}:(e=Math.max(1,e),function(i){i[n][t].duration=e}))},Pl.each=function(e,t){var n=this.id,i=this.namespace;if(arguments.length<2){var r=Rl,o=Ol;try{Ol=n,z(this,function(t,r,o){Rl=t[i][n],e.call(t,t.__data__,r,o)})}finally{Rl=r,Ol=o}}else z(this,function(r){var o=r[i][n];(o.event||(o.event=na.dispatch("start","end","interrupt"))).on(e,t)});return this},Pl.transition=function(){for(var e,t,n,i,r=this.id,o=++Il,a=this.namespace,s=[],l=0,u=this.length;u>l;l++){s.push(e=[]);for(var t=this[l],c=0,d=t.length;d>c;c++)(n=t[c])&&(i=n[a][r],Xo(n,c,a,o,{time:i.time,ease:i.ease,delay:i.delay+i.duration,duration:i.duration})),e.push(n)}return qo(s,a,o)},na.svg.axis=function(){function e(e){e.each(function(){var e,u=na.select(this),c=this.__chart__||n,d=this.__chart__=n.copy(),h=null==l?d.ticks?d.ticks.apply(d,s):d.domain():l,p=null==t?d.tickFormat?d.tickFormat.apply(d,s):y:t,f=u.selectAll(".tick").data(h,d),m=f.enter().insert("g",".domain").attr("class","tick").style("opacity",Da),g=na.transition(f.exit()).style("opacity",Da).remove(),v=na.transition(f.order()).style("opacity",1),_=Math.max(r,0)+a,b=Ir(d),x=u.selectAll(".domain").data([0]),w=(x.enter().append("path").attr("class","domain"),na.transition(x));m.append("line"),m.append("text");var $,k,C,A,M=m.select("line"),T=v.select("line"),S=f.select("text").text(p),D=m.select("text"),E=v.select("text"),L="top"===i||"left"===i?-1:1;if("bottom"===i||"top"===i?(e=Go,$="x",C="y",k="x2",A="y2",S.attr("dy",0>L?"0em":".71em").style("text-anchor","middle"),w.attr("d","M"+b[0]+","+L*o+"V0H"+b[1]+"V"+L*o)):(e=Ko,$="y",C="x",k="y2",A="x2",S.attr("dy",".32em").style("text-anchor",0>L?"end":"start"),w.attr("d","M"+L*o+","+b[0]+"H0V"+b[1]+"H"+L*o)),M.attr(A,L*r),D.attr(C,L*_),T.attr(k,0).attr(A,L*r),E.attr($,0).attr(C,L*_),d.rangeBand){var F=d,O=F.rangeBand()/2;c=d=function(e){return F(e)+O}}else c.rangeBand?c=d:g.call(e,d,c);m.call(e,c,d),v.call(e,d,d)})}var t,n=na.scale.linear(),i=Yl,r=6,o=6,a=3,s=[10],l=null;return e.scale=function(t){return arguments.length?(n=t,e):n},e.orient=function(t){return arguments.length?(i=t in jl?t+"":Yl,e):i},e.ticks=function(){return arguments.length?(s=arguments,e):s},e.tickValues=function(t){return arguments.length?(l=t,e):l},e.tickFormat=function(n){return arguments.length?(t=n,e):t},e.tickSize=function(t){var n=arguments.length;return n?(r=+t,o=+arguments[n-1],e):r},e.innerTickSize=function(t){return arguments.length?(r=+t,e):r},e.outerTickSize=function(t){return arguments.length?(o=+t,e):o},e.tickPadding=function(t){return arguments.length?(a=+t,e):a},e.tickSubdivide=function(){return arguments.length&&e},e};var Yl="bottom",jl={top:1,right:1,bottom:1,left:1};na.svg.brush=function(){function e(t){t.each(function(){var t=na.select(this).style("pointer-events","all").style("-webkit-tap-highlight-color","rgba(0,0,0,0)").on("mousedown.brush",o).on("touchstart.brush",o),a=t.selectAll(".background").data([0]);a.enter().append("rect").attr("class","background").style("visibility","hidden").style("cursor","crosshair"),t.selectAll(".extent").data([0]).enter().append("rect").attr("class","extent").style("cursor","move");var s=t.selectAll(".resize").data(m,y);s.exit().remove(),s.enter().append("g").attr("class",function(e){return"resize "+e}).style("cursor",function(e){return Nl[e]}).append("rect").attr("x",function(e){return/[ew]$/.test(e)?-3:null}).attr("y",function(e){return/^[ns]/.test(e)?-3:null}).attr("width",6).attr("height",6).style("visibility","hidden"),s.style("display",e.empty()?"none":null);var l,d=na.transition(t),h=na.transition(a);u&&(l=Ir(u),h.attr("x",l[0]).attr("width",l[1]-l[0]),i(d)),c&&(l=Ir(c),h.attr("y",l[0]).attr("height",l[1]-l[0]),r(d)),n(d)})}function n(e){e.selectAll(".resize").attr("transform",function(e){return"translate("+d[+/e$/.test(e)]+","+h[+/^s/.test(e)]+")"})}function i(e){e.select(".extent").attr("x",d[0]),e.selectAll(".extent,.n>rect,.s>rect").attr("width",d[1]-d[0])}function r(e){e.select(".extent").attr("y",h[0]),e.selectAll(".extent,.e>rect,.w>rect").attr("height",h[1]-h[0])}function o(){function o(){32==na.event.keyCode&&(S||(_=null,E[0]-=d[1],E[1]-=h[1],S=2),k())}function m(){32==na.event.keyCode&&2==S&&(E[0]+=d[1],E[1]+=h[1],S=0,k())}function g(){var e=na.mouse(x),t=!1;b&&(e[0]+=b[0],e[1]+=b[1]),S||(na.event.altKey?(_||(_=[(d[0]+d[1])/2,(h[0]+h[1])/2]),E[0]=d[+(e[0]<_[0])],E[1]=h[+(e[1]<_[1])]):_=null),M&&v(e,u,0)&&(i(C),t=!0),T&&v(e,c,1)&&(r(C),t=!0),t&&(n(C),$({type:"brush",mode:S?"move":"resize"}))}function v(e,t,n){var i,r,o=Ir(t),l=o[0],u=o[1],c=E[n],m=n?h:d,g=m[1]-m[0];return S&&(l-=c,u-=g+c),i=(n?f:p)?Math.max(l,Math.min(u,e[n])):e[n],S?r=(i+=c)+g:(_&&(c=Math.max(l,Math.min(u,2*_[n]-i))),i>c?(r=i,i=c):r=c),m[0]!=i||m[1]!=r?(n?s=null:a=null,m[0]=i,m[1]=r,!0):void 0}function y(){g(),C.style("pointer-events","all").selectAll(".resize").style("display",e.empty()?"none":null),na.select("body").style("cursor",null),L.on("mousemove.brush",null).on("mouseup.brush",null).on("touchmove.brush",null).on("touchend.brush",null).on("keydown.brush",null).on("keyup.brush",null),D(),$({type:"brushend"})}var _,b,x=this,w=na.select(na.event.target),$=l.of(x,arguments),C=na.select(x),A=w.datum(),M=!/^(n|s)$/.test(A)&&u,T=!/^(e|w)$/.test(A)&&c,S=w.classed("extent"),D=G(x),E=na.mouse(x),L=na.select(t(x)).on("keydown.brush",o).on("keyup.brush",m);if(na.event.changedTouches?L.on("touchmove.brush",g).on("touchend.brush",y):L.on("mousemove.brush",g).on("mouseup.brush",y),C.interrupt().selectAll("*").interrupt(),S)E[0]=d[0]-E[0],E[1]=h[0]-E[1];else if(A){var F=+/w$/.test(A),O=+/^n/.test(A);b=[d[1-F]-E[0],h[1-O]-E[1]],E[0]=d[F],E[1]=h[O]}else na.event.altKey&&(_=E.slice());C.style("pointer-events","none").selectAll(".resize").style("display",null),na.select("body").style("cursor",w.style("cursor")),$({type:"brushstart"}),g()}var a,s,l=A(e,"brushstart","brush","brushend"),u=null,c=null,d=[0,0],h=[0,0],p=!0,f=!0,m=Hl[0];return e.event=function(e){e.each(function(){var e=l.of(this,arguments),t={x:d,y:h,i:a,j:s},n=this.__chart__||t;this.__chart__=t,Ol?na.select(this).transition().each("start.brush",function(){a=n.i,s=n.j,d=n.x,h=n.y,e({type:"brushstart"})}).tween("brush:brush",function(){var n=_i(d,t.x),i=_i(h,t.y);return a=s=null,function(r){d=t.x=n(r),h=t.y=i(r),e({type:"brush",mode:"resize"})}}).each("end.brush",function(){a=t.i,s=t.j,e({type:"brush",mode:"resize"}),e({type:"brushend"})}):(e({type:"brushstart"}),e({type:"brush",mode:"resize"}),e({type:"brushend"}))})},e.x=function(t){return arguments.length?(u=t,m=Hl[!u<<1|!c],e):u},e.y=function(t){return arguments.length?(c=t,m=Hl[!u<<1|!c],e):c},e.clamp=function(t){return arguments.length?(u&&c?(p=!!t[0],f=!!t[1]):u?p=!!t:c&&(f=!!t),e):u&&c?[p,f]:u?p:c?f:null},e.extent=function(t){var n,i,r,o,l;return arguments.length?(u&&(n=t[0],i=t[1],c&&(n=n[0],i=i[0]),a=[n,i],u.invert&&(n=u(n),i=u(i)),n>i&&(l=n,n=i,i=l),(n!=d[0]||i!=d[1])&&(d=[n,i])),c&&(r=t[0],o=t[1],u&&(r=r[1],o=o[1]),s=[r,o],c.invert&&(r=c(r),o=c(o)),r>o&&(l=r,r=o,o=l),(r!=h[0]||o!=h[1])&&(h=[r,o])),e):(u&&(a?(n=a[0],i=a[1]):(n=d[0],i=d[1],u.invert&&(n=u.invert(n),i=u.invert(i)),n>i&&(l=n,n=i,i=l))),c&&(s?(r=s[0],o=s[1]):(r=h[0],o=h[1],c.invert&&(r=c.invert(r),o=c.invert(o)),r>o&&(l=r,r=o,o=l))),u&&c?[[n,r],[i,o]]:u?[n,i]:c&&[r,o])},e.clear=function(){return e.empty()||(d=[0,0],h=[0,0],a=s=null),e},e.empty=function(){return!!u&&d[0]==d[1]||!!c&&h[0]==h[1]},na.rebind(e,l,"on")};var Nl={n:"ns-resize",e:"ew-resize",s:"ns-resize",w:"ew-resize",nw:"nwse-resize",ne:"nesw-resize",se:"nwse-resize",sw:"nesw-resize"},Hl=[["n","e","s","w","nw","ne","se","sw"],["e","w"],["n","s"],[]],zl=ls.format=fs.timeFormat,ql=zl.utc,Wl=ql("%Y-%m-%dT%H:%M:%S.%LZ");zl.iso=Date.prototype.toISOString&&+new Date("2000-01-01T00:00:00.000Z")?Jo:Wl,Jo.parse=function(e){var t=new Date(e);return isNaN(t)?null:t},Jo.toString=Wl.toString,ls.second=Ye(function(e){return new us(1e3*Math.floor(e/1e3))},function(e,t){e.setTime(e.getTime()+1e3*Math.floor(t))},function(e){return e.getSeconds()}),ls.seconds=ls.second.range,ls.seconds.utc=ls.second.utc.range,ls.minute=Ye(function(e){return new us(6e4*Math.floor(e/6e4))},function(e,t){e.setTime(e.getTime()+6e4*Math.floor(t))},function(e){return e.getMinutes()}),ls.minutes=ls.minute.range,ls.minutes.utc=ls.minute.utc.range,ls.hour=Ye(function(e){var t=e.getTimezoneOffset()/60;return new us(36e5*(Math.floor(e/36e5-t)+t))},function(e,t){e.setTime(e.getTime()+36e5*Math.floor(t))},function(e){return e.getHours()}),ls.hours=ls.hour.range,ls.hours.utc=ls.hour.utc.range,ls.month=Ye(function(e){return e=ls.day(e),e.setDate(1),e},function(e,t){e.setMonth(e.getMonth()+t)},function(e){return e.getMonth()}),ls.months=ls.month.range,ls.months.utc=ls.month.utc.range;var Ul=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],Vl=[[ls.second,1],[ls.second,5],[ls.second,15],[ls.second,30],[ls.minute,1],[ls.minute,5],[ls.minute,15],[ls.minute,30],[ls.hour,1],[ls.hour,3],[ls.hour,6],[ls.hour,12],[ls.day,1],[ls.day,2],[ls.week,1],[ls.month,1],[ls.month,3],[ls.year,1]],Xl=zl.multi([[".%L",function(e){
144
144
  return e.getMilliseconds()}],[":%S",function(e){return e.getSeconds()}],["%I:%M",function(e){return e.getMinutes()}],["%I %p",function(e){return e.getHours()}],["%a %d",function(e){return e.getDay()&&1!=e.getDate()}],["%b %d",function(e){return 1!=e.getDate()}],["%B",function(e){return e.getMonth()}],["%Y",Tt]]),Gl={range:function(e,t,n){return na.range(Math.ceil(e/n)*n,+t,n).map(Zo)},floor:y,ceil:y};Vl.year=ls.year,ls.scale=function(){return Qo(na.scale.linear(),Vl,Xl)};var Kl=Vl.map(function(e){return[e[0].utc,e[1]]}),Jl=ql.multi([[".%L",function(e){return e.getUTCMilliseconds()}],[":%S",function(e){return e.getUTCSeconds()}],["%I:%M",function(e){return e.getUTCMinutes()}],["%I %p",function(e){return e.getUTCHours()}],["%a %d",function(e){return e.getUTCDay()&&1!=e.getUTCDate()}],["%b %d",function(e){return 1!=e.getUTCDate()}],["%B",function(e){return e.getUTCMonth()}],["%Y",Tt]]);Kl.year=ls.year.utc,ls.scale.utc=function(){return Qo(na.scale.linear(),Kl,Jl)},na.text=Me(function(e){return e.responseText}),na.json=function(e,t){return Te(e,"application/json",ea,t)},na.html=function(e,t){return Te(e,"text/html",ta,t)},na.xml=Me(function(e){return e.responseXML}),"function"==typeof define&&define.amd?define(na):"object"==typeof module&&module.exports&&(module.exports=na),this.d3=na}();var mod;mod=angular.module("infinite-scroll",[]),mod.value("THROTTLE_MILLISECONDS",null),mod.directive("infiniteScroll",["$rootScope","$window","$interval","THROTTLE_MILLISECONDS",function(e,t,n,i){return{scope:{infiniteScroll:"&",infiniteScrollContainer:"=",infiniteScrollDistance:"=",infiniteScrollDisabled:"=",infiniteScrollUseDocumentBottom:"=",infiniteScrollListenForEvent:"@"},link:function(r,o,a){var s,l,u,c,d,h,p,f,m,g,v,y,_,b,x,w,$,k;return k=angular.element(t),_=null,b=null,l=null,u=null,g=!0,$=!1,w=null,m=function(e){return e=e[0]||e,isNaN(e.offsetHeight)?e.document.documentElement.clientHeight:e.offsetHeight},v=function(e){return e[0].getBoundingClientRect&&!e.css("none")?e[0].getBoundingClientRect().top+y(e):void 0},y=function(e){return e=e[0]||e,isNaN(window.pageYOffset)?e.document.documentElement.scrollTop:e.ownerDocument.defaultView.pageYOffset},f=function(){var t,n,i,a,s;return u===k?(t=m(u)+y(u[0].document.documentElement),i=v(o)+m(o)):(t=m(u),n=0,void 0!==v(u)&&(n=v(u)),i=v(o)-n+m(o)),$&&(i=m((o[0].ownerDocument||o[0].document).documentElement)),a=i-t,s=a<=m(u)*_+1,s?(l=!0,b?r.$$phase||e.$$phase?r.infiniteScroll():r.$apply(r.infiniteScroll):void 0):l=!1},x=function(e,t){var i,r,o;return o=null,r=0,i=function(){var t;return r=(new Date).getTime(),n.cancel(o),o=null,e.call(),t=null},function(){var a,s;return a=(new Date).getTime(),s=t-(a-r),0>=s?(clearTimeout(o),n.cancel(o),o=null,r=a,e.call()):o?void 0:o=n(i,s,1)}},null!=i&&(f=x(f,i)),r.$on("$destroy",function(){return u.unbind("scroll",f),null!=w?(w(),w=null):void 0}),h=function(e){return _=parseFloat(e)||0},r.$watch("infiniteScrollDistance",h),h(r.infiniteScrollDistance),d=function(e){return b=!e,b&&l?(l=!1,f()):void 0},r.$watch("infiniteScrollDisabled",d),d(r.infiniteScrollDisabled),p=function(e){return $=e},r.$watch("infiniteScrollUseDocumentBottom",p),p(r.infiniteScrollUseDocumentBottom),s=function(e){return null!=u&&u.unbind("scroll",f),u=e,null!=e?u.bind("scroll",f):void 0},s(k),r.infiniteScrollListenForEvent&&(w=e.$on(r.infiniteScrollListenForEvent,f)),c=function(e){if(null!=e&&0!==e.length){if(e instanceof HTMLElement?e=angular.element(e):"function"==typeof e.append?e=angular.element(e[e.length-1]):"string"==typeof e&&(e=angular.element(document.querySelector(e))),null!=e)return s(e);throw new Exception("invalid infinite-scroll-container attribute.")}},r.$watch("infiniteScrollContainer",c),c(r.infiniteScrollContainer||[]),null!=a.infiniteScrollParent&&s(angular.element(o.parent())),null!=a.infiniteScrollImmediateCheck&&(g=r.$eval(a.infiniteScrollImmediateCheck)),n(function(){return g?f():void 0},0,1)}}}]),/*! ngTagsInput v2.3.0 License: MIT */
145
145
  !function(){"use strict";var e={backspace:8,tab:9,enter:13,escape:27,space:32,up:38,down:40,left:37,right:39,"delete":46,comma:188},t=9007199254740991,n=["text","email","url"],i=angular.module("ngTagsInput",[]);i.directive("tagsInput",["$timeout","$document","$window","tagsInputConfig","tiUtil",function(i,r,o,a,s){function l(e,t,n,i){var r,o,a,l={};return r=function(t){return s.safeToString(t[e.displayProperty])},o=function(t,n){t[e.displayProperty]=n},a=function(t){var i=r(t);return i&&i.length>=e.minLength&&i.length<=e.maxLength&&e.allowedTagsPattern.test(i)&&!s.findInObjectArray(l.items,t,e.keyProperty||e.displayProperty)&&n({$tag:t})},l.items=[],l.addText=function(e){var t={};return o(t,e),l.add(t)},l.add=function(n){var i=r(n);return e.replaceSpacesWithDashes&&(i=s.replaceSpacesWithDashes(i)),o(n,i),a(n)?(l.items.push(n),t.trigger("tag-added",{$tag:n})):i&&t.trigger("invalid-tag",{$tag:n}),n},l.remove=function(e){var n=l.items[e];return i({$tag:n})?(l.items.splice(e,1),l.clearSelection(),t.trigger("tag-removed",{$tag:n}),n):void 0},l.select=function(e){0>e?e=l.items.length-1:e>=l.items.length&&(e=0),l.index=e,l.selected=l.items[e]},l.selectPrior=function(){l.select(--l.index)},l.selectNext=function(){l.select(++l.index)},l.removeSelected=function(){return l.remove(l.index)},l.clearSelection=function(){l.selected=null,l.index=-1},l.clearSelection(),l}function u(e){return-1!==n.indexOf(e)}return{restrict:"E",require:"ngModel",scope:{tags:"=ngModel",onTagAdding:"&",onTagAdded:"&",onInvalidTag:"&",onTagRemoving:"&",onTagRemoved:"&"},replace:!1,transclude:!0,templateUrl:"ngTagsInput/tags-input.html",controller:["$scope","$attrs","$element",function(e,n,i){e.events=s.simplePubSub(),a.load("tagsInput",e,n,{template:[String,"ngTagsInput/tag-item.html"],type:[String,"text",u],placeholder:[String,"Add a tag"],tabindex:[Number,null],removeTagSymbol:[String,String.fromCharCode(215)],replaceSpacesWithDashes:[Boolean,!0],minLength:[Number,3],maxLength:[Number,t],addOnEnter:[Boolean,!0],addOnSpace:[Boolean,!1],addOnComma:[Boolean,!0],addOnBlur:[Boolean,!0],addOnPaste:[Boolean,!1],pasteSplitPattern:[RegExp,/,/],allowedTagsPattern:[RegExp,/.+/],enableEditingLastTag:[Boolean,!1],minTags:[Number,0],maxTags:[Number,t],displayProperty:[String,"text"],keyProperty:[String,""],allowLeftoverText:[Boolean,!1],addFromAutocompleteOnly:[Boolean,!1],spellcheck:[Boolean,!0]}),e.tagList=new l(e.options,e.events,s.handleUndefinedResult(e.onTagAdding,!0),s.handleUndefinedResult(e.onTagRemoving,!0)),this.registerAutocomplete=function(){var t=i.find("input");return{addTag:function(t){return e.tagList.add(t)},focusInput:function(){t[0].focus()},getTags:function(){return e.tags},getCurrentTagText:function(){return e.newTag.text},getOptions:function(){return e.options},on:function(t,n){return e.events.on(t,n),this}}},this.registerTagItem=function(){return{getOptions:function(){return e.options},removeTag:function(t){e.disabled||e.tagList.remove(t)}}}}],link:function(t,n,a,l){var u,c=[e.enter,e.comma,e.space,e.backspace,e["delete"],e.left,e.right],d=t.tagList,h=t.events,p=t.options,f=n.find("input"),m=["minTags","maxTags","allowLeftoverText"];u=function(){l.$setValidity("maxTags",t.tags.length<=p.maxTags),l.$setValidity("minTags",t.tags.length>=p.minTags),l.$setValidity("leftoverText",t.hasFocus||p.allowLeftoverText?!0:!t.newTag.text)},l.$isEmpty=function(e){return!e||!e.length},t.newTag={text:"",invalid:null,setText:function(e){this.text=e,h.trigger("input-change",e)}},t.track=function(e){return e[p.keyProperty||p.displayProperty]},t.$watch("tags",function(e){t.tags=s.makeObjectArray(e,p.displayProperty),d.items=t.tags}),t.$watch("tags.length",function(){u()}),a.$observe("disabled",function(e){t.disabled=e}),t.eventHandlers={input:{change:function(e){h.trigger("input-change",e)},keydown:function(e){h.trigger("input-keydown",e)},focus:function(){t.hasFocus||(t.hasFocus=!0,h.trigger("input-focus"))},blur:function(){i(function(){var e=r.prop("activeElement"),i=e===f[0],o=n[0].contains(e);(i||!o)&&(t.hasFocus=!1,h.trigger("input-blur"))})},paste:function(e){e.getTextData=function(){var t=e.clipboardData||e.originalEvent&&e.originalEvent.clipboardData;return t?t.getData("text/plain"):o.clipboardData.getData("Text")},h.trigger("input-paste",e)}},host:{click:function(){t.disabled||f[0].focus()}}},h.on("tag-added",t.onTagAdded).on("invalid-tag",t.onInvalidTag).on("tag-removed",t.onTagRemoved).on("tag-added",function(){t.newTag.setText("")}).on("tag-added tag-removed",function(){l.$setViewValue(t.tags)}).on("invalid-tag",function(){t.newTag.invalid=!0}).on("option-change",function(e){-1!==m.indexOf(e.name)&&u()}).on("input-change",function(){d.clearSelection(),t.newTag.invalid=null}).on("input-focus",function(){n.triggerHandler("focus"),l.$setValidity("leftoverText",!0)}).on("input-blur",function(){p.addOnBlur&&!p.addFromAutocompleteOnly&&d.addText(t.newTag.text),n.triggerHandler("blur"),u()}).on("input-keydown",function(n){var i,r,o,a,s=n.keyCode,l=n.shiftKey||n.altKey||n.ctrlKey||n.metaKey,u={};if(!l&&-1!==c.indexOf(s)){if(u[e.enter]=p.addOnEnter,u[e.comma]=p.addOnComma,u[e.space]=p.addOnSpace,i=!p.addFromAutocompleteOnly&&u[s],r=(s===e.backspace||s===e["delete"])&&d.selected,a=s===e.backspace&&0===t.newTag.text.length&&p.enableEditingLastTag,o=(s===e.backspace||s===e.left||s===e.right)&&0===t.newTag.text.length&&!p.enableEditingLastTag,i)d.addText(t.newTag.text);else if(a){var h;d.selectPrior(),h=d.removeSelected(),h&&t.newTag.setText(h[p.displayProperty])}else r?d.removeSelected():o&&(s===e.left||s===e.backspace?d.selectPrior():s===e.right&&d.selectNext());(i||o||r||a)&&n.preventDefault()}}).on("input-paste",function(e){if(p.addOnPaste){var t=e.getTextData(),n=t.split(p.pasteSplitPattern);n.length>1&&(n.forEach(function(e){d.addText(e)}),e.preventDefault())}})}}}]),i.directive("tiTagItem",["tiUtil",function(e){return{restrict:"E",require:"^tagsInput",template:'<ng-include src="$$template"></ng-include>',scope:{data:"="},link:function(t,n,i,r){var o=r.registerTagItem(),a=o.getOptions();t.$$template=a.template,t.$$removeTagSymbol=a.removeTagSymbol,t.$getDisplayText=function(){return e.safeToString(t.data[a.displayProperty])},t.$removeTag=function(){o.removeTag(t.$index)},t.$watch("$parent.$index",function(e){t.$index=e})}}}]),i.directive("autoComplete",["$document","$timeout","$sce","$q","tagsInputConfig","tiUtil",function(t,n,i,r,o,a){function s(e,t,n){var i,o,s,l={};return s=function(){return t.tagsInput.keyProperty||t.tagsInput.displayProperty},i=function(e,n){return e.filter(function(e){return!a.findInObjectArray(n,e,s(),function(e,n){return t.tagsInput.replaceSpacesWithDashes&&(e=a.replaceSpacesWithDashes(e),n=a.replaceSpacesWithDashes(n)),a.defaultComparer(e,n)})})},l.reset=function(){o=null,l.items=[],l.visible=!1,l.index=-1,l.selected=null,l.query=null},l.show=function(){t.selectFirstMatch?l.select(0):l.selected=null,l.visible=!0},l.load=a.debounce(function(n,u){l.query=n;var c=r.when(e({$query:n}));o=c,c.then(function(e){c===o&&(e=a.makeObjectArray(e.data||e,s()),e=i(e,u),l.items=e.slice(0,t.maxResultsToShow),l.items.length>0?l.show():l.reset())})},t.debounceDelay),l.selectNext=function(){l.select(++l.index)},l.selectPrior=function(){l.select(--l.index)},l.select=function(e){0>e?e=l.items.length-1:e>=l.items.length&&(e=0),l.index=e,l.selected=l.items[e],n.trigger("suggestion-selected",e)},l.reset(),l}function l(e,t){var n=e.find("li").eq(t),i=n.parent(),r=n.prop("offsetTop"),o=n.prop("offsetHeight"),a=i.prop("clientHeight"),s=i.prop("scrollTop");s>r?i.prop("scrollTop",r):r+o>a+s&&i.prop("scrollTop",r+o-a)}return{restrict:"E",require:"^tagsInput",scope:{source:"&"},templateUrl:"ngTagsInput/auto-complete.html",controller:["$scope","$element","$attrs",function(e,t,n){e.events=a.simplePubSub(),o.load("autoComplete",e,n,{template:[String,"ngTagsInput/auto-complete-match.html"],debounceDelay:[Number,100],minLength:[Number,3],highlightMatchedText:[Boolean,!0],maxResultsToShow:[Number,10],loadOnDownArrow:[Boolean,!1],loadOnEmpty:[Boolean,!1],loadOnFocus:[Boolean,!1],selectFirstMatch:[Boolean,!0],displayProperty:[String,""]}),e.suggestionList=new s(e.source,e.options,e.events),this.registerAutocompleteMatch=function(){return{getOptions:function(){return e.options},getQuery:function(){return e.suggestionList.query}}}}],link:function(t,n,i,r){var o,a=[e.enter,e.tab,e.escape,e.up,e.down],s=t.suggestionList,u=r.registerAutocomplete(),c=t.options,d=t.events;c.tagsInput=u.getOptions(),o=function(e){return e&&e.length>=c.minLength||!e&&c.loadOnEmpty},t.addSuggestionByIndex=function(e){s.select(e),t.addSuggestion()},t.addSuggestion=function(){var e=!1;return s.selected&&(u.addTag(angular.copy(s.selected)),s.reset(),u.focusInput(),e=!0),e},t.track=function(e){return e[c.tagsInput.keyProperty||c.tagsInput.displayProperty]},u.on("tag-added invalid-tag input-blur",function(){s.reset()}).on("input-change",function(e){o(e)?s.load(e,u.getTags()):s.reset()}).on("input-focus",function(){var e=u.getCurrentTagText();c.loadOnFocus&&o(e)&&s.load(e,u.getTags())}).on("input-keydown",function(n){var i=n.keyCode,r=!1;return-1!==a.indexOf(i)?(s.visible?i===e.down?(s.selectNext(),r=!0):i===e.up?(s.selectPrior(),r=!0):i===e.escape?(s.reset(),r=!0):(i===e.enter||i===e.tab)&&(r=t.addSuggestion()):i===e.down&&t.options.loadOnDownArrow&&(s.load(u.getCurrentTagText(),u.getTags()),r=!0),r?(n.preventDefault(),n.stopImmediatePropagation(),!1):void 0):void 0}),d.on("suggestion-selected",function(e){l(n,e)})}}}]),i.directive("tiAutocompleteMatch",["$sce","tiUtil",function(e,t){return{restrict:"E",require:"^autoComplete",template:'<ng-include src="$$template"></ng-include>',scope:{data:"="},link:function(n,i,r,o){var a=o.registerAutocompleteMatch(),s=a.getOptions();n.$$template=s.template,n.$index=n.$parent.$index,n.$highlight=function(n){return s.highlightMatchedText&&(n=t.safeHighlight(n,a.getQuery())),e.trustAsHtml(n)},n.$getDisplayText=function(){return t.safeToString(n.data[s.displayProperty||s.tagsInput.displayProperty])}}}}]),i.directive("tiTranscludeAppend",function(){return function(e,t,n,i,r){r(function(e){t.append(e)})}}),i.directive("tiAutosize",["tagsInputConfig",function(e){return{restrict:"A",require:"ngModel",link:function(t,n,i,r){var o,a,s=e.getTextAutosizeThreshold();o=angular.element('<span class="input"></span>'),o.css("display","none").css("visibility","hidden").css("width","auto").css("white-space","pre"),n.parent().append(o),a=function(e){var t,r=e;return angular.isString(r)&&0===r.length&&(r=i.placeholder),r&&(o.text(r),o.css("display",""),t=o.prop("offsetWidth"),o.css("display","none")),n.css("width",t?t+s+"px":""),e},r.$parsers.unshift(a),r.$formatters.unshift(a),i.$observe("placeholder",function(e){r.$modelValue||a(e)})}}}]),i.directive("tiBindAttrs",function(){return function(e,t,n){e.$watch(n.tiBindAttrs,function(e){angular.forEach(e,function(e,t){n.$set(t,e)})},!0)}}),i.provider("tagsInputConfig",function(){var e={},t={},n=3;this.setDefaults=function(t,n){return e[t]=n,this},this.setActiveInterpolation=function(e,n){return t[e]=n,this},this.setTextAutosizeThreshold=function(e){return n=e,this},this.$get=["$interpolate",function(i){var r={};return r[String]=function(e){return e},r[Number]=function(e){return parseInt(e,10)},r[Boolean]=function(e){return"true"===e.toLowerCase()},r[RegExp]=function(e){return new RegExp(e)},{load:function(n,o,a,s){var l=function(){return!0};o.options={},angular.forEach(s,function(s,u){var c,d,h,p,f,m;c=s[0],d=s[1],h=s[2]||l,p=r[c],f=function(){var t=e[n]&&e[n][u];return angular.isDefined(t)?t:d},m=function(e){o.options[u]=e&&h(e)?p(e):f()},t[n]&&t[n][u]?a.$observe(u,function(e){m(e),o.events.trigger("option-change",{name:u,newValue:e})}):m(a[u]&&i(a[u])(o.$parent))})},getTextAutosizeThreshold:function(){return n}}}]}),i.factory("tiUtil",["$timeout",function(e){var t={};return t.debounce=function(t,n){var i;return function(){var r=arguments;e.cancel(i),i=e(function(){t.apply(null,r)},n)}},t.makeObjectArray=function(e,t){return e=e||[],e.length>0&&!angular.isObject(e[0])&&e.forEach(function(n,i){e[i]={},e[i][t]=n}),e},t.findInObjectArray=function(e,n,i,r){var o=null;return r=r||t.defaultComparer,e.some(function(e){return r(e[i],n[i])?(o=e,!0):void 0}),o},t.defaultComparer=function(e,n){return t.safeToString(e).toLowerCase()===t.safeToString(n).toLowerCase()},t.safeHighlight=function(e,n){function i(e){return e.replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1")}if(!n)return e;e=t.encodeHTML(e),n=t.encodeHTML(n);var r=new RegExp("&[^;]+;|"+i(n),"gi");return e.replace(r,function(e){return e.toLowerCase()===n.toLowerCase()?"<em>"+e+"</em>":e})},t.safeToString=function(e){return angular.isUndefined(e)||null==e?"":e.toString().trim()},t.encodeHTML=function(e){return t.safeToString(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")},t.handleUndefinedResult=function(e,t){return function(){var n=e.apply(null,arguments);return angular.isUndefined(n)?t:n}},t.replaceSpacesWithDashes=function(e){return t.safeToString(e).replace(/\s/g,"-")},t.simplePubSub=function(){var e={};return{on:function(t,n){return t.split(" ").forEach(function(t){e[t]||(e[t]=[]),e[t].push(n)}),this},trigger:function(n,i){var r=e[n]||[];return r.every(function(e){return t.handleUndefinedResult(e,!0)(i)}),this}}},t}]),i.run(["$templateCache",function(e){e.put("ngTagsInput/tags-input.html",'<div class="host" tabindex="-1" ng-click="eventHandlers.host.click()" ti-transclude-append=""><div class="tags" ng-class="{focused: hasFocus}"><ul class="tag-list"><li class="tag-item" ng-repeat="tag in tagList.items track by track(tag)" ng-class="{ selected: tag == tagList.selected }"><ti-tag-item data="tag"></ti-tag-item></li></ul><input class="input" autocomplete="off" ng-model="newTag.text" ng-change="eventHandlers.input.change(newTag.text)" ng-keydown="eventHandlers.input.keydown($event)" ng-focus="eventHandlers.input.focus($event)" ng-blur="eventHandlers.input.blur($event)" ng-paste="eventHandlers.input.paste($event)" ng-trim="false" ng-class="{\'invalid-tag\': newTag.invalid}" ng-disabled="disabled" ti-bind-attrs="{type: options.type, placeholder: options.placeholder, tabindex: options.tabindex, spellcheck: options.spellcheck}" ti-autosize=""></div></div>'),e.put("ngTagsInput/tag-item.html",'<span ng-bind="$getDisplayText()"></span> <a class="remove-button" ng-click="$removeTag()" ng-bind="$$removeTagSymbol"></a>'),e.put("ngTagsInput/auto-complete.html",'<div class="autocomplete" ng-if="suggestionList.visible"><ul class="suggestion-list"><li class="suggestion-item" ng-repeat="item in suggestionList.items track by track(item)" ng-class="{selected: item == suggestionList.selected}" ng-click="addSuggestionByIndex($index)" ng-mouseenter="suggestionList.select($index)"><ti-autocomplete-match data="item"></ti-autocomplete-match></li></ul></div>'),e.put("ngTagsInput/auto-complete-match.html",'<span ng-bind-html="$highlight($getDisplayText())"></span>')}])}(),function(e,t){"function"==typeof require&&"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define(function(){return t()}):e.pluralize=t()}(this,function(){function e(e){return e.charAt(0).toUpperCase()+e.substr(1).toLowerCase()}function t(e){return"string"==typeof e?new RegExp("^"+e+"$","i"):e}function n(t,n){return t===t.toUpperCase()?n.toUpperCase():t[0]===t[0].toUpperCase()?e(n):n.toLowerCase()}function i(e,t){return e.replace(/\$(\d{1,2})/g,function(e,n){return t[n]||""})}function r(e,t,r){if(!e.length||u.hasOwnProperty(e))return t;for(var o=r.length;o--;){var a=r[o];if(a[0].test(t))return t.replace(a[0],function(e,t,r){var o=i(a[1],arguments);return""===e?n(r[t-1],o):n(e,o)})}return t}function o(e,t,i){return function(o){var a=o.toLowerCase();return t.hasOwnProperty(a)?n(o,a):e.hasOwnProperty(a)?n(o,e[a]):r(a,o,i)}}function a(e,t,n){var i=1===t?a.singular(e):a.plural(e);return(n?t+" ":"")+i}var s=[],l=[],u={},c={},d={};return a.plural=o(d,c,s),a.singular=o(c,d,l),a.addPluralRule=function(e,n){s.push([t(e),n])},a.addSingularRule=function(e,n){l.push([t(e),n])},a.addUncountableRule=function(e){return"string"==typeof e?void(u[e.toLowerCase()]=!0):(a.addPluralRule(e,"$0"),void a.addSingularRule(e,"$0"))},a.addIrregularRule=function(e,t){t=t.toLowerCase(),e=e.toLowerCase(),d[e]=t,c[t]=e},[["I","we"],["me","us"],["he","they"],["she","they"],["them","them"],["myself","ourselves"],["yourself","yourselves"],["itself","themselves"],["herself","themselves"],["himself","themselves"],["themself","themselves"],["is","are"],["this","these"],["that","those"],["echo","echoes"],["dingo","dingoes"],["volcano","volcanoes"],["tornado","tornadoes"],["torpedo","torpedoes"],["genus","genera"],["viscus","viscera"],["stigma","stigmata"],["stoma","stomata"],["dogma","dogmata"],["lemma","lemmata"],["schema","schemata"],["anathema","anathemata"],["ox","oxen"],["axe","axes"],["die","dice"],["yes","yeses"],["foot","feet"],["eave","eaves"],["goose","geese"],["tooth","teeth"],["quiz","quizzes"],["human","humans"],["proof","proofs"],["carve","carves"],["valve","valves"],["thief","thieves"],["genie","genies"],["groove","grooves"],["pickaxe","pickaxes"],["whiskey","whiskies"]].forEach(function(e){return a.addIrregularRule(e[0],e[1])}),[[/s?$/i,"s"],[/([^aeiou]ese)$/i,"$1"],[/(ax|test)is$/i,"$1es"],[/(alias|[^aou]us|tlas|gas|ris)$/i,"$1es"],[/(e[mn]u)s?$/i,"$1s"],[/([^l]ias|[aeiou]las|[emjzr]as|[iu]am)$/i,"$1"],[/(alumn|syllab|octop|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,"$1i"],[/(alumn|alg|vertebr)(?:a|ae)$/i,"$1ae"],[/(seraph|cherub)(?:im)?$/i,"$1im"],[/(her|at|gr)o$/i,"$1oes"],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i,"$1a"],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i,"$1a"],[/sis$/i,"ses"],[/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i,"$1$2ves"],[/([^aeiouy]|qu)y$/i,"$1ies"],[/([^ch][ieo][ln])ey$/i,"$1ies"],[/(x|ch|ss|sh|zz)$/i,"$1es"],[/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i,"$1ices"],[/(m|l)(?:ice|ouse)$/i,"$1ice"],[/(pe)(?:rson|ople)$/i,"$1ople"],[/(child)(?:ren)?$/i,"$1ren"],[/eaux$/i,"$0"],[/m[ae]n$/i,"men"],["thou","you"]].forEach(function(e){return a.addPluralRule(e[0],e[1])}),[[/s$/i,""],[/(ss)$/i,"$1"],[/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)(?:sis|ses)$/i,"$1sis"],[/(^analy)(?:sis|ses)$/i,"$1sis"],[/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i,"$1fe"],[/(ar|(?:wo|[ae])l|[eo][ao])ves$/i,"$1f"],[/([^aeiouy]|qu)ies$/i,"$1y"],[/(^[pl]|zomb|^(?:neck)?t|[aeo][lt]|cut)ies$/i,"$1ie"],[/(\b(?:mon|smil))ies$/i,"$1ey"],[/(m|l)ice$/i,"$1ouse"],[/(seraph|cherub)im$/i,"$1"],[/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|tlas|gas|(?:her|at|gr)o|ris)(?:es)?$/i,"$1"],[/(e[mn]u)s?$/i,"$1"],[/(movie|twelve)s$/i,"$1"],[/(cris|test|diagnos)(?:is|es)$/i,"$1is"],[/(alumn|syllab|octop|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,"$1us"],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i,"$1um"],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i,"$1on"],[/(alumn|alg|vertebr)ae$/i,"$1a"],[/(cod|mur|sil|vert|ind)ices$/i,"$1ex"],[/(matr|append)ices$/i,"$1ix"],[/(pe)(rson|ople)$/i,"$1rson"],[/(child)ren$/i,"$1"],[/(eau)x?$/i,"$1"],[/men$/i,"man"]].forEach(function(e){return a.addSingularRule(e[0],e[1])}),["advice","adulthood","agenda","aid","alcohol","ammo","athletics","bison","blood","bream","buffalo","butter","carp","cash","chassis","chess","clothing","commerce","cod","cooperation","corps","digestion","debris","diabetes","energy","equipment","elk","excretion","expertise","flounder","fun","gallows","garbage","graffiti","headquarters","health","herpes","highjinks","homework","housework","information","jeans","justice","kudos","labour","literature","machinery","mackerel","media","mews","moose","music","news","pike","plankton","pliers","pollution","premises","rain","research","rice","salmon","scissors","series","sewage","shambles","shrimp","species","staff","swine","trout","traffic","transporation","tuna","wealth","welfare","whiting","wildebeest","wildlife","you",/pox$/i,/ois$/i,/deer$/i,/fish$/i,/sheep$/i,/measles$/i,/[^aeiou]ese$/i].forEach(a.addUncountableRule),a}),function(){function e(e){function t(t,n,i,r,o,a){for(;o>=0&&a>o;o+=e){var s=r?r[o]:o;i=n(i,t[s],s,t)}return i}return function(n,i,r,o){i=_(i,o,4);var a=!A(n)&&y.keys(n),s=(a||n).length,l=e>0?0:s-1;return arguments.length<3&&(r=n[a?a[l]:l],l+=e),t(n,i,r,a,l,s)}}function t(e){return function(t,n,i){n=b(n,i);for(var r=C(t),o=e>0?0:r-1;o>=0&&r>o;o+=e)if(n(t[o],o,t))return o;return-1}}function n(e,t,n){return function(i,r,o){var a=0,s=C(i);if("number"==typeof o)e>0?a=o>=0?o:Math.max(o+s,a):s=o>=0?Math.min(o+1,s):o+s+1;else if(n&&o&&s)return o=n(i,r),i[o]===r?o:-1;if(r!==r)return o=t(c.call(i,a,s),y.isNaN),o>=0?o+a:-1;for(o=e>0?a:s-1;o>=0&&s>o;o+=e)if(i[o]===r)return o;return-1}}function i(e,t){var n=E.length,i=e.constructor,r=y.isFunction(i)&&i.prototype||s,o="constructor";for(y.has(e,o)&&!y.contains(t,o)&&t.push(o);n--;)o=E[n],o in e&&e[o]!==r[o]&&!y.contains(t,o)&&t.push(o)}var r=this,o=r._,a=Array.prototype,s=Object.prototype,l=Function.prototype,u=a.push,c=a.slice,d=s.toString,h=s.hasOwnProperty,p=Array.isArray,f=Object.keys,m=l.bind,g=Object.create,v=function(){},y=function(e){return e instanceof y?e:this instanceof y?void(this._wrapped=e):new y(e)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=y),exports._=y):r._=y,y.VERSION="1.8.3";var _=function(e,t,n){if(void 0===t)return e;switch(null==n?3:n){case 1:return function(n){return e.call(t,n)};case 2:return function(n,i){return e.call(t,n,i)};case 3:return function(n,i,r){return e.call(t,n,i,r)};case 4:return function(n,i,r,o){return e.call(t,n,i,r,o)}}return function(){return e.apply(t,arguments)}},b=function(e,t,n){return null==e?y.identity:y.isFunction(e)?_(e,t,n):y.isObject(e)?y.matcher(e):y.property(e)};y.iteratee=function(e,t){return b(e,t,1/0)};var x=function(e,t){return function(n){var i=arguments.length;if(2>i||null==n)return n;for(var r=1;i>r;r++)for(var o=arguments[r],a=e(o),s=a.length,l=0;s>l;l++){var u=a[l];t&&void 0!==n[u]||(n[u]=o[u])}return n}},w=function(e){if(!y.isObject(e))return{};if(g)return g(e);v.prototype=e;var t=new v;return v.prototype=null,t},$=function(e){return function(t){return null==t?void 0:t[e]}},k=Math.pow(2,53)-1,C=$("length"),A=function(e){var t=C(e);return"number"==typeof t&&t>=0&&k>=t};y.each=y.forEach=function(e,t,n){t=_(t,n);var i,r;if(A(e))for(i=0,r=e.length;r>i;i++)t(e[i],i,e);else{var o=y.keys(e);for(i=0,r=o.length;r>i;i++)t(e[o[i]],o[i],e)}return e},y.map=y.collect=function(e,t,n){t=b(t,n);for(var i=!A(e)&&y.keys(e),r=(i||e).length,o=Array(r),a=0;r>a;a++){var s=i?i[a]:a;o[a]=t(e[s],s,e)}return o},y.reduce=y.foldl=y.inject=e(1),y.reduceRight=y.foldr=e(-1),y.find=y.detect=function(e,t,n){var i;return i=A(e)?y.findIndex(e,t,n):y.findKey(e,t,n),void 0!==i&&-1!==i?e[i]:void 0},y.filter=y.select=function(e,t,n){var i=[];return t=b(t,n),y.each(e,function(e,n,r){t(e,n,r)&&i.push(e)}),i},y.reject=function(e,t,n){return y.filter(e,y.negate(b(t)),n)},y.every=y.all=function(e,t,n){t=b(t,n);for(var i=!A(e)&&y.keys(e),r=(i||e).length,o=0;r>o;o++){var a=i?i[o]:o;if(!t(e[a],a,e))return!1}return!0},y.some=y.any=function(e,t,n){t=b(t,n);for(var i=!A(e)&&y.keys(e),r=(i||e).length,o=0;r>o;o++){var a=i?i[o]:o;if(t(e[a],a,e))return!0}return!1},y.contains=y.includes=y.include=function(e,t,n,i){return A(e)||(e=y.values(e)),("number"!=typeof n||i)&&(n=0),y.indexOf(e,t,n)>=0},y.invoke=function(e,t){var n=c.call(arguments,2),i=y.isFunction(t);return y.map(e,function(e){var r=i?t:e[t];return null==r?r:r.apply(e,n)})},y.pluck=function(e,t){return y.map(e,y.property(t))},y.where=function(e,t){return y.filter(e,y.matcher(t))},y.findWhere=function(e,t){return y.find(e,y.matcher(t))},y.max=function(e,t,n){var i,r,o=-(1/0),a=-(1/0);if(null==t&&null!=e){e=A(e)?e:y.values(e);for(var s=0,l=e.length;l>s;s++)i=e[s],i>o&&(o=i)}else t=b(t,n),y.each(e,function(e,n,i){r=t(e,n,i),(r>a||r===-(1/0)&&o===-(1/0))&&(o=e,a=r)});return o},y.min=function(e,t,n){var i,r,o=1/0,a=1/0;if(null==t&&null!=e){e=A(e)?e:y.values(e);for(var s=0,l=e.length;l>s;s++)i=e[s],o>i&&(o=i)}else t=b(t,n),y.each(e,function(e,n,i){r=t(e,n,i),(a>r||r===1/0&&o===1/0)&&(o=e,a=r)});return o},y.shuffle=function(e){for(var t,n=A(e)?e:y.values(e),i=n.length,r=Array(i),o=0;i>o;o++)t=y.random(0,o),t!==o&&(r[o]=r[t]),r[t]=n[o];return r},y.sample=function(e,t,n){return null==t||n?(A(e)||(e=y.values(e)),e[y.random(e.length-1)]):y.shuffle(e).slice(0,Math.max(0,t))},y.sortBy=function(e,t,n){return t=b(t,n),y.pluck(y.map(e,function(e,n,i){return{value:e,index:n,criteria:t(e,n,i)}}).sort(function(e,t){var n=e.criteria,i=t.criteria;if(n!==i){if(n>i||void 0===n)return 1;if(i>n||void 0===i)return-1}return e.index-t.index}),"value")};var M=function(e){return function(t,n,i){var r={};return n=b(n,i),y.each(t,function(i,o){var a=n(i,o,t);e(r,i,a)}),r}};y.groupBy=M(function(e,t,n){y.has(e,n)?e[n].push(t):e[n]=[t]}),y.indexBy=M(function(e,t,n){e[n]=t}),y.countBy=M(function(e,t,n){y.has(e,n)?e[n]++:e[n]=1}),y.toArray=function(e){return e?y.isArray(e)?c.call(e):A(e)?y.map(e,y.identity):y.values(e):[]},y.size=function(e){return null==e?0:A(e)?e.length:y.keys(e).length},y.partition=function(e,t,n){t=b(t,n);var i=[],r=[];return y.each(e,function(e,n,o){(t(e,n,o)?i:r).push(e)}),[i,r]},y.first=y.head=y.take=function(e,t,n){return null==e?void 0:null==t||n?e[0]:y.initial(e,e.length-t)},y.initial=function(e,t,n){return c.call(e,0,Math.max(0,e.length-(null==t||n?1:t)))},y.last=function(e,t,n){return null==e?void 0:null==t||n?e[e.length-1]:y.rest(e,Math.max(0,e.length-t))},y.rest=y.tail=y.drop=function(e,t,n){return c.call(e,null==t||n?1:t)},y.compact=function(e){return y.filter(e,y.identity)};var T=function(e,t,n,i){for(var r=[],o=0,a=i||0,s=C(e);s>a;a++){var l=e[a];if(A(l)&&(y.isArray(l)||y.isArguments(l))){t||(l=T(l,t,n));var u=0,c=l.length;for(r.length+=c;c>u;)r[o++]=l[u++]}else n||(r[o++]=l)}return r};y.flatten=function(e,t){return T(e,t,!1)},y.without=function(e){return y.difference(e,c.call(arguments,1))},y.uniq=y.unique=function(e,t,n,i){y.isBoolean(t)||(i=n,n=t,t=!1),null!=n&&(n=b(n,i));for(var r=[],o=[],a=0,s=C(e);s>a;a++){var l=e[a],u=n?n(l,a,e):l;t?(a&&o===u||r.push(l),o=u):n?y.contains(o,u)||(o.push(u),r.push(l)):y.contains(r,l)||r.push(l)}return r},y.union=function(){return y.uniq(T(arguments,!0,!0))},y.intersection=function(e){for(var t=[],n=arguments.length,i=0,r=C(e);r>i;i++){var o=e[i];if(!y.contains(t,o)){for(var a=1;n>a&&y.contains(arguments[a],o);a++);a===n&&t.push(o)}}return t},y.difference=function(e){var t=T(arguments,!0,!0,1);return y.filter(e,function(e){return!y.contains(t,e)})},y.zip=function(){return y.unzip(arguments)},y.unzip=function(e){for(var t=e&&y.max(e,C).length||0,n=Array(t),i=0;t>i;i++)n[i]=y.pluck(e,i);return n},y.object=function(e,t){for(var n={},i=0,r=C(e);r>i;i++)t?n[e[i]]=t[i]:n[e[i][0]]=e[i][1];return n},y.findIndex=t(1),y.findLastIndex=t(-1),y.sortedIndex=function(e,t,n,i){n=b(n,i,1);for(var r=n(t),o=0,a=C(e);a>o;){var s=Math.floor((o+a)/2);n(e[s])<r?o=s+1:a=s}return o},y.indexOf=n(1,y.findIndex,y.sortedIndex),y.lastIndexOf=n(-1,y.findLastIndex),y.range=function(e,t,n){null==t&&(t=e||0,e=0),n=n||1;for(var i=Math.max(Math.ceil((t-e)/n),0),r=Array(i),o=0;i>o;o++,e+=n)r[o]=e;return r};var S=function(e,t,n,i,r){if(!(i instanceof t))return e.apply(n,r);var o=w(e.prototype),a=e.apply(o,r);return y.isObject(a)?a:o};y.bind=function(e,t){if(m&&e.bind===m)return m.apply(e,c.call(arguments,1));if(!y.isFunction(e))throw new TypeError("Bind must be called on a function");var n=c.call(arguments,2),i=function(){return S(e,i,t,this,n.concat(c.call(arguments)))};return i},y.partial=function(e){var t=c.call(arguments,1),n=function(){for(var i=0,r=t.length,o=Array(r),a=0;r>a;a++)o[a]=t[a]===y?arguments[i++]:t[a];for(;i<arguments.length;)o.push(arguments[i++]);return S(e,n,this,this,o)};return n},y.bindAll=function(e){var t,n,i=arguments.length;if(1>=i)throw new Error("bindAll must be passed function names");for(t=1;i>t;t++)n=arguments[t],e[n]=y.bind(e[n],e);return e},y.memoize=function(e,t){var n=function(i){var r=n.cache,o=""+(t?t.apply(this,arguments):i);return y.has(r,o)||(r[o]=e.apply(this,arguments)),r[o]};return n.cache={},n},y.delay=function(e,t){var n=c.call(arguments,2);return setTimeout(function(){return e.apply(null,n)},t)},y.defer=y.partial(y.delay,y,1),y.throttle=function(e,t,n){var i,r,o,a=null,s=0;n||(n={});var l=function(){s=n.leading===!1?0:y.now(),a=null,o=e.apply(i,r),a||(i=r=null)};return function(){var u=y.now();s||n.leading!==!1||(s=u);var c=t-(u-s);return i=this,r=arguments,0>=c||c>t?(a&&(clearTimeout(a),a=null),s=u,o=e.apply(i,r),a||(i=r=null)):a||n.trailing===!1||(a=setTimeout(l,c)),o}},y.debounce=function(e,t,n){var i,r,o,a,s,l=function(){var u=y.now()-a;t>u&&u>=0?i=setTimeout(l,t-u):(i=null,n||(s=e.apply(o,r),i||(o=r=null)))};return function(){o=this,r=arguments,a=y.now();var u=n&&!i;return i||(i=setTimeout(l,t)),u&&(s=e.apply(o,r),o=r=null),s}},y.wrap=function(e,t){return y.partial(t,e)},y.negate=function(e){return function(){return!e.apply(this,arguments)}},y.compose=function(){var e=arguments,t=e.length-1;return function(){for(var n=t,i=e[t].apply(this,arguments);n--;)i=e[n].call(this,i);return i}},y.after=function(e,t){return function(){return--e<1?t.apply(this,arguments):void 0}},y.before=function(e,t){var n;return function(){return--e>0&&(n=t.apply(this,arguments)),1>=e&&(t=null),n}},y.once=y.partial(y.before,2);var D=!{toString:null}.propertyIsEnumerable("toString"),E=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"];y.keys=function(e){if(!y.isObject(e))return[];if(f)return f(e);var t=[];for(var n in e)y.has(e,n)&&t.push(n);return D&&i(e,t),t},y.allKeys=function(e){if(!y.isObject(e))return[];var t=[];for(var n in e)t.push(n);return D&&i(e,t),t},y.values=function(e){for(var t=y.keys(e),n=t.length,i=Array(n),r=0;n>r;r++)i[r]=e[t[r]];return i},y.mapObject=function(e,t,n){t=b(t,n);for(var i,r=y.keys(e),o=r.length,a={},s=0;o>s;s++)i=r[s],a[i]=t(e[i],i,e);return a},y.pairs=function(e){for(var t=y.keys(e),n=t.length,i=Array(n),r=0;n>r;r++)i[r]=[t[r],e[t[r]]];return i},y.invert=function(e){for(var t={},n=y.keys(e),i=0,r=n.length;r>i;i++)t[e[n[i]]]=n[i];return t},y.functions=y.methods=function(e){var t=[];for(var n in e)y.isFunction(e[n])&&t.push(n);return t.sort()},y.extend=x(y.allKeys),y.extendOwn=y.assign=x(y.keys),y.findKey=function(e,t,n){t=b(t,n);for(var i,r=y.keys(e),o=0,a=r.length;a>o;o++)if(i=r[o],t(e[i],i,e))return i},y.pick=function(e,t,n){var i,r,o={},a=e;if(null==a)return o;y.isFunction(t)?(r=y.allKeys(a),i=_(t,n)):(r=T(arguments,!1,!1,1),i=function(e,t,n){return t in n},a=Object(a));for(var s=0,l=r.length;l>s;s++){var u=r[s],c=a[u];i(c,u,a)&&(o[u]=c)}return o},y.omit=function(e,t,n){if(y.isFunction(t))t=y.negate(t);else{var i=y.map(T(arguments,!1,!1,1),String);t=function(e,t){return!y.contains(i,t)}}return y.pick(e,t,n)},y.defaults=x(y.allKeys,!0),y.create=function(e,t){var n=w(e);return t&&y.extendOwn(n,t),n},y.clone=function(e){return y.isObject(e)?y.isArray(e)?e.slice():y.extend({},e):e},y.tap=function(e,t){return t(e),e},y.isMatch=function(e,t){var n=y.keys(t),i=n.length;if(null==e)return!i;for(var r=Object(e),o=0;i>o;o++){var a=n[o];if(t[a]!==r[a]||!(a in r))return!1}return!0};var L=function(e,t,n,i){if(e===t)return 0!==e||1/e===1/t;if(null==e||null==t)return e===t;e instanceof y&&(e=e._wrapped),t instanceof y&&(t=t._wrapped);var r=d.call(e);if(r!==d.call(t))return!1;switch(r){case"[object RegExp]":case"[object String]":return""+e==""+t;case"[object Number]":return+e!==+e?+t!==+t:0===+e?1/+e===1/t:+e===+t;case"[object Date]":case"[object Boolean]":return+e===+t}var o="[object Array]"===r;if(!o){if("object"!=typeof e||"object"!=typeof t)return!1;var a=e.constructor,s=t.constructor;if(a!==s&&!(y.isFunction(a)&&a instanceof a&&y.isFunction(s)&&s instanceof s)&&"constructor"in e&&"constructor"in t)return!1}n=n||[],i=i||[];for(var l=n.length;l--;)if(n[l]===e)return i[l]===t;if(n.push(e),i.push(t),o){if(l=e.length,l!==t.length)return!1;for(;l--;)if(!L(e[l],t[l],n,i))return!1}else{var u,c=y.keys(e);if(l=c.length,y.keys(t).length!==l)return!1;for(;l--;)if(u=c[l],!y.has(t,u)||!L(e[u],t[u],n,i))return!1}return n.pop(),i.pop(),!0};y.isEqual=function(e,t){return L(e,t)},y.isEmpty=function(e){return null==e?!0:A(e)&&(y.isArray(e)||y.isString(e)||y.isArguments(e))?0===e.length:0===y.keys(e).length},y.isElement=function(e){
146
- return!(!e||1!==e.nodeType)},y.isArray=p||function(e){return"[object Array]"===d.call(e)},y.isObject=function(e){var t=typeof e;return"function"===t||"object"===t&&!!e},y.each(["Arguments","Function","String","Number","Date","RegExp","Error"],function(e){y["is"+e]=function(t){return d.call(t)==="[object "+e+"]"}}),y.isArguments(arguments)||(y.isArguments=function(e){return y.has(e,"callee")}),"function"!=typeof/./&&"object"!=typeof Int8Array&&(y.isFunction=function(e){return"function"==typeof e||!1}),y.isFinite=function(e){return isFinite(e)&&!isNaN(parseFloat(e))},y.isNaN=function(e){return y.isNumber(e)&&e!==+e},y.isBoolean=function(e){return e===!0||e===!1||"[object Boolean]"===d.call(e)},y.isNull=function(e){return null===e},y.isUndefined=function(e){return void 0===e},y.has=function(e,t){return null!=e&&h.call(e,t)},y.noConflict=function(){return r._=o,this},y.identity=function(e){return e},y.constant=function(e){return function(){return e}},y.noop=function(){},y.property=$,y.propertyOf=function(e){return null==e?function(){}:function(t){return e[t]}},y.matcher=y.matches=function(e){return e=y.extendOwn({},e),function(t){return y.isMatch(t,e)}},y.times=function(e,t,n){var i=Array(Math.max(0,e));t=_(t,n,1);for(var r=0;e>r;r++)i[r]=t(r);return i},y.random=function(e,t){return null==t&&(t=e,e=0),e+Math.floor(Math.random()*(t-e+1))},y.now=Date.now||function(){return(new Date).getTime()};var F={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"},O=y.invert(F),R=function(e){var t=function(t){return e[t]},n="(?:"+y.keys(e).join("|")+")",i=RegExp(n),r=RegExp(n,"g");return function(e){return e=null==e?"":""+e,i.test(e)?e.replace(r,t):e}};y.escape=R(F),y.unescape=R(O),y.result=function(e,t,n){var i=null==e?void 0:e[t];return void 0===i&&(i=n),y.isFunction(i)?i.call(e):i};var B=0;y.uniqueId=function(e){var t=++B+"";return e?e+t:t},y.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var P=/(.)^/,I={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},Y=/\\|'|\r|\n|\u2028|\u2029/g,j=function(e){return"\\"+I[e]};y.template=function(e,t,n){!t&&n&&(t=n),t=y.defaults({},t,y.templateSettings);var i=RegExp([(t.escape||P).source,(t.interpolate||P).source,(t.evaluate||P).source].join("|")+"|$","g"),r=0,o="__p+='";e.replace(i,function(t,n,i,a,s){return o+=e.slice(r,s).replace(Y,j),r=s+t.length,n?o+="'+\n((__t=("+n+"))==null?'':_.escape(__t))+\n'":i?o+="'+\n((__t=("+i+"))==null?'':__t)+\n'":a&&(o+="';\n"+a+"\n__p+='"),t}),o+="';\n",t.variable||(o="with(obj||{}){\n"+o+"}\n"),o="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+o+"return __p;\n";try{var a=new Function(t.variable||"obj","_",o)}catch(s){throw s.source=o,s}var l=function(e){return a.call(this,e,y)},u=t.variable||"obj";return l.source="function("+u+"){\n"+o+"}",l},y.chain=function(e){var t=y(e);return t._chain=!0,t};var N=function(e,t){return e._chain?y(t).chain():t};y.mixin=function(e){y.each(y.functions(e),function(t){var n=y[t]=e[t];y.prototype[t]=function(){var e=[this._wrapped];return u.apply(e,arguments),N(this,n.apply(y,e))}})},y.mixin(y),y.each(["pop","push","reverse","shift","sort","splice","unshift"],function(e){var t=a[e];y.prototype[e]=function(){var n=this._wrapped;return t.apply(n,arguments),"shift"!==e&&"splice"!==e||0!==n.length||delete n[0],N(this,n)}}),y.each(["concat","join","slice"],function(e){var t=a[e];y.prototype[e]=function(){return N(this,t.apply(this._wrapped,arguments))}}),y.prototype.value=function(){return this._wrapped},y.prototype.valueOf=y.prototype.toJSON=y.prototype.value,y.prototype.toString=function(){return""+this._wrapped},"function"==typeof define&&define.amd&&define("underscore",[],function(){return y})}.call(this),KeyBinding.prototype.withKeyFn=function(e){return{name:this.name,bindKey:this.bindKey,keyFn:e,aceKeyCmd:{name:this.name,bindKey:this.bindKey,exec:e},hotKey:{combo:_.toArray(this.bindKey),description:this.name,callback:e}}};var SerializedStorage={set:function(e,t){localStorage.setItem(e,JSON.stringify(t))},get:function(e){return JSON.parse(localStorage.getItem(e))},storage:localStorage},slice=Array.prototype.slice,existy=function(e){return null!=e};_.mixin({cat:function(){return _.flatten(arguments,!0)},cons:function(e,t){return _.cat([e],t)},chunk:function(e,t,n){var i=function(e){if(null==e)return[];var r=_.take(e,t);return t===_.size(r)?_.cons(r,i(_.drop(e,t))):n?[_.take(_.cat(r,n),t)]:[]};return i(e)},chunkAll:function(e,t,n){n=null!=n?n:t;var i=function(e,t,n){return _.isEmpty(e)?[]:_.cons(_.take(e,t),i(_.drop(e,n),t,n))};return i(e,t,n)},mapcat:function(e,t){return _.flatten(_.map(e,t),!0)},interpose:function(e,t){if(!_.isArray(e))throw new TypeError;var n=_.size(e);return 0===n?e:1===n?e:slice.call(_.mapcat(e,function(e){return _.cons(e,[t])}),0,-1)},weave:function(){return _.some(arguments)?1==arguments.length?arguments[0]:_.filter(_.flatten(_.zip.apply(null,arguments),!0),function(e){return null!=e}):[]},interleave:_.weave,repeat:function(e,t){return _.times(e,function(){return t})},cycle:function(e,t){return _.flatten(_.times(e,function(){return t}),!0)},splitAt:function(e,t){return[_.take(e,t),_.drop(e,t)]},iterateUntil:function(e,t,n){for(var i=[],r=e(n);t(r);)i.push(r),r=e(r);return i},takeSkipping:function(e,t){var n=[],i=_.size(e);if(0>=t)return[];if(1===t)return e;for(var r=0;i>r;r+=t)n.push(e[r]);return n},reductions:function(e,t,n){var i=[],r=n;return _.each(e,function(n,o){r=t(r,e[o]),i.push(r)}),i},keepIndexed:function(e,t){return _.filter(_.map(_.range(_.size(e)),function(n){return t(n,e[n])}),existy)},reverseOrder:function(e){if("string"==typeof e)throw new TypeError("Strings cannot be reversed by _.reverseOrder");return slice.call(e).reverse()},combinations:function(){return _.reduce(slice.call(arguments,1),function(e,t){return _.reduce(e,function(e,n){return e.concat(_.map(t,function(e){return n.concat([e])}))},[])},_.map(arguments[0],function(e){return[e]}))}}),_.mixin({isInstanceOf:function(e,t){return e instanceof t},isAssociative:function(e){return _.isArray(e)||_.isObject(e)||_.isArguments(e)},isIndexed:function(e){return _.isArray(e)||_.isString(e)||_.isArguments(e)},isSequential:function(e){return _.isArray(e)||_.isArguments(e)},isPlainObject:function(e){return _.isObject(e)&&e.constructor===Object},isZero:function(e){return 0===e},isEven:function(e){return _.isFinite(e)&&0===(1&e)},isOdd:function(e){return _.isFinite(e)&&!_.isEven(e)},isPositive:function(e){return e>0},isNegative:function(e){return 0>e},isValidDate:function(e){return _.isDate(e)&&!_.isNaN(e.getTime())},isNumeric:function(e){return!isNaN(parseFloat(e))&&isFinite(e)},isInteger:function(e){return _.isNumeric(e)&&e%1===0},isFloat:function(e){return _.isNumeric(e)&&!_.isInteger(e)},isJSON:function(e){try{JSON.parse(e)}catch(t){return!1}return!0},isIncreasing:function(){var e=_.size(arguments);if(1===e)return!0;if(2===e)return arguments[0]<arguments[1];for(var t=1;e>t;t++)if(arguments[t-1]>=arguments[t])return!1;return!0},isDecreasing:function(){var e=_.size(arguments);if(1===e)return!0;if(2===e)return arguments[0]>arguments[1];for(var t=1;e>t;t++)if(arguments[t-1]<=arguments[t])return!1;return!0}});var slice=Array.prototype.slice,concat=Array.prototype.concat,existy=function(e){return null!=e},truthy=function(e){return e!==!1&&existy(e)},isAssociative=function(e){return _.isArray(e)||_.isObject(e)},curry2=function(e){return function(t){return function(n){return e(n,t)}}};_.mixin({merge:function(){var e=_.some(arguments)?{}:null;return truthy(e)&&_.extend.apply(null,concat.call([e],_.toArray(arguments))),e},renameKeys:function(e,t){return _.reduce(t,function(t,n,i){return existy(e[i])?(t[n]=e[i],t):t},_.omit.apply(null,concat.call([e],_.keys(t))))},snapshot:function(e){if(null==e||"object"!=typeof e)return e;var t=new e.constructor;for(var n in e)e.hasOwnProperty(n)&&(t[n]=_.snapshot(e[n]));return t},updatePath:function(e,t,n,i){if(!isAssociative(e))throw new TypeError("Attempted to update a non-associative object.");if(!existy(n))return t(e);var r=_.isArray(n),o=r?n:[n],a=r?_.snapshot(e):_.clone(e),s=_.last(o),l=a;return _.each(_.initial(o),function(e){i&&!_.has(l,e)&&(l[e]=_.clone(i)),l=l[e]}),l[s]=t(l[s]),a},setPath:function(e,t,n,i){if(!existy(n))throw new TypeError("Attempted to set a property at a null path.");return _.updatePath(e,function(){return t},n,i)},frequencies:curry2(_.countBy)(_.identity)});var concat=Array.prototype.concat,ArrayProto=Array.prototype,slice=ArrayProto.slice;_.mixin({accessor:function(e){return function(t){return t&&t[e]}},dictionary:function(e){return function(t){return e&&t&&e[t]}},selectKeys:function(e,t){return _.pick.apply(null,concat.call([e],t))},kv:function(e,t){return _.has(e,t)?[t,e[t]]:void 0},getPath:function(e,t){t="string"==typeof t?keysFromPath(t):t;for(var n=-1,i=t.length;++n<i&&null!=e;)e=e[t[n]];return n===i?e:void 0},hasPath:function(e,t){t="string"==typeof t?keysFromPath(t):t;for(var n=-1,i=t.length;++n<i&&_.isObject(e);){if(!(t[n]in e))return!1;e=e[t[n]]}return n===i},keysFromPath:keysFromPath,pickWhen:function(e,t){var n={};return _.each(e,function(i,r){t(e[r])&&(n[r]=e[r])}),n},omitWhen:function(e,t){return _.pickWhen(e,function(e){return!t(e)})}}),_.mixin({exists:function(e){return null!=e},truthy:function(e){return e!==!1&&_.exists(e)},falsey:function(e){return!_.truthy(e)},not:function(e){return!e},firstExisting:function(){for(var e=0;e<arguments.length;e++)if(null!=arguments[e])return arguments[e]}});var Utils=Utils||{};Utils.arrayHelpers={removeItem:function(e,t){var n=_.findIndex(e,t);return e.splice(n,1),e},compare:function(e,t,n){return e.length===t.length&&_.every(e,function(e){return _.some(t,function(t){return _.exists(n)?n(e)===n(t):e===t})})}},Utils.stringHelpers={isPresent:function(e){return!(e||"").match(/^\s*$/)}},!function(e){"use strict";e.module("aleph",["alephControllers","alephDirectives","alephServices","alephFilters","ngAnimate","angular-clipboard","ui.bootstrap","infinite-scroll","ngTagsInput","cfp.hotkeys","angular.filter","selectionModel","treasure-overlay-spinner"]).run(["AceCompleters",function(e){e.setCompleters()}]).run(["$rootScope","PageTitleManager",function(e,t){e.pageTitleManager=t}]).value("KeyBindings",{saveQuery:new KeyBinding("Save Query",{mac:"command+shift+s",win:"ctrl+shift+s"}),runQuery:new KeyBinding("Run Query",{mac:"shift+enter",win:"shift+enter"}),detectParameters:new KeyBinding("Detect Parameters",{mac:"command+shift+p",win:"ctrl+shift+p"})}).config(["$locationProvider",function(e){e.html5Mode(!0)}]).config(["$animateProvider",function(e){e.classNameFilter(/ng-animate-enabled/)}]).config(["$routeProvider",function(e){e.when("/queries/:query_id",{redirectTo:"/queries/:query_id/query_versions/latest"}).when("/queries",{templateUrl:"queryIndex",controller:"QueryIndexController",controllerAs:"queryIdxCtrl",reloadOnSearch:!1}).when("/schemas/:schemaName",{templateUrl:"schemaShow",controller:"SchemaShowController"}).when("/schemas",{title:"Schemas",templateUrl:"schemaIndex",controller:"SchemaIndexController",controllerAs:"schemaIdxCtrl",reloadOnSearch:!1}).when("/queries/:query_id/query_versions/:query_version_id",{templateUrl:"showQuery",controller:"QueryShowController",controllerAs:"queryShowCtrl"}).when("/alerts",{title:"Alerts",templateUrl:"alertIndex",controller:"AlertIndexController",controllerAs:"alertIdxCtrl",reloadOnSearch:!1}).when("/alerts/:alertId",{templateUrl:"alertShow",controller:"AlertShowController",controllerAs:"alertShowCtrl"}).when("/results/query/:queryId/query_version/:queryVersionId/result/:resultId",{templateUrl:"singleResultShow",controller:"SingleResultShowController",controllerAs:"singleResultShowCtrl"}).when("/snippets",{title:"Snippets",templateUrl:"snippetIndex",controller:"SnippetIndexController",controllerAs:"snippetIdxCtrl"}).otherwise("/queries")}])}(angular),!function(e){"use strict";var t={tableRestrictionMet:function(e,t){return 0===t.tableRestrict.length||_.contains(t.tableRestrict,e.table)},schemaRestrictionMet:function(e,t){return 0===t.schemaRestrict.length||_.contains(t.schemaRestrict,e.schema)}};e.module("aleph.schemaCompleterConfig",[]).constant("SCHEMA_MATCHERS",[{nameProperty:"schema",meta:"schema",contextRelevance:{from:1e3}},{nameProperty:"column",meta:"column",contextRelevance:{select:1e3,from:500,where:1e3},contextItemFilters:{select:[t.schemaRestrictionMet,t.tableRestrictionMet],from:[t.schemaRestrictionMet,t.tableRestrictionMet],where:[t.schemaRestrictionMet,t.tableRestrictionMet]}},{nameProperty:"table",meta:"table",contextRelevance:{select:500,from:1e3,where:500},contextItemFilters:{select:[t.schemaRestrictionMet,t.tableRestrictionMet],from:[t.schemaRestrictionMet],where:[t.schemaRestrictionMet,t.tableRestrictionMet]}}])}(angular),!function(e){"use strict";var t=function n(e,t,i,r){_classCallCheck(this,n),this.pagination=new t("Paginated Queries",e.index,i),this.defaultDateFormat=r};t.$inject=["AlertResource","PaginationComponents","Alert","defaultDateFormat"],e.module("alephControllers.alertIndexController",["alephServices"]).controller("AlertIndexController",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";var t=function(){function e(t,n,i,r,o,a,s,l){var u=this;_classCallCheck(this,e),this._openReplService=o,this._$location=l,this.aceLoaded=function(e){new n(e).readOnlyConfig()},this.alert=new r,this.query=new i,"new"===s.alertId?this.alert.initItem().then(this.query.initItem.bind(this.query,null)).then(this._openReplService.open.bind(this._openReplService,{skipSave:!0})).then(function(e){u.query=e,u.alert.item.query_title=e.item.title,u.query.item.tags.push("alert-query")}):this.alert.initItem(s.alertId).then(function(e){return u.query.initItem(e.query_id,"latest")}),this._navigationGuard=new a(t).registerLocationChangeStart(function(e){if(u.alert.isDirty()){var t=confirm("Your alert has not been saved. Are you sure you want to leave this page?");t||e.preventDefault()}}).registerOnBeforeUnload(function(){return u.alert.isDirty()?"Alert has unsaved changes!":void 0})}return _createClass(e,[{key:"togglePaused",value:function(){"Paused"===this.alert.item.status?this.alert.item.status="Pending":this.alert.item.status="Paused",this.alert.save()}},{key:"editAlert",value:function(){var e=this;this._openReplService.open({query:this.query}).then(function(t){return e.query=t,e.query.save()}).then(this.alert.save.bind(this.alert))}},{key:"deleteAlert",value:function(){var e=this;this.alert.destroy().then(function(){return e._$location.path("/alerts")})}},{key:"saveAlert",value:function(){var e=this;this.isPersisted()?this.alert.save():this.query.save().then(function(t){e.alert.item.query_id=t.id,e.alert.save()})}},{key:"isPersisted",value:function(){return this.alert.isPersisted()&&this.query.isPersisted()}}]),e}();t.$inject=["$scope","DefaultAceConfigurator","Query","Alert","OpenReplService","NavigationGuard","$routeParams","$location"],e.module("alephControllers.alertShowController",["alephServices"]).controller("AlertShowController",t)}(angular),!function(e){"use strict";e.module("alephControllers",["alephControllers.schemaIndexController","alephControllers.queryIndexController","alephControllers.queryShowController","alephControllers.queryReplController","alephControllers.alertIndexController","alephControllers.alertShowController","alephControllers.snippetIndexController","alephControllers.singleResultShowController","alephServices","ui.ace","ngRoute","ui.bootstrap.alert"]).controller("BodyController",["$scope","SpinnerState","ServerConfigurations",function(e,t,n){e.SpinnerState=t,e.ServerConfigurations=n}]).controller("NavBarController",["$scope","$window","$location",function(e,t,n){e.pathIncludes=function(e){return n.path().indexOf(e)>-1},e.signOut=function(){t.location.href="/sign_out"}}]).controller("AlertBarController",["$scope","$rootScope",function(e,t){e.alerts=[],e.dismiss=function(){e.alerts.length=0},t.$on("$routeChangeSuccess",function(){e.scheduledAlert?(e.alerts.push(e.scheduledAlert),e.scheduledAlert=null):e.dismiss()}),t.$on("scheduleAlert",function(t,n){e.scheduledAlert=n}),t.$on("setAlert",function(t,n){e.alerts.push(n)})}])}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";var t=function(){function e(t,n,i,r,o,a,s,l,u,c){_classCallCheck(this,e),this.selectedQueries=[],this.defaultDateFormat=r,this._handler=i,this.tagsSelectionInput=new u({items:this.selectedQueries,itemField:"tags"}),this.rolesSelectionInput=new u({items:this.selectedQueries,itemField:"roles"}),this.pagination=new a("Paginated Queries",t.index,n),this._roleModel=l,this._tagResource=s,this._$q=c,this._repl=o,l.initCollection()}return _createClass(e,[{key:"loadTags",value:function(e){return this._tagResource.index({search:e}).$promise}},{key:"loadRoles",value:function(){return this._roleModel.collection}},{key:"onSelection",value:function(){this.tagsSelectionInput.onSelection(),this.rolesSelectionInput.onSelection()}},{key:"deselectAll",value:function(){_.each(this.selectedQueries,function(e){e.selected=!1}),this.selectedQueries.length=0,this.onSelection()}},{key:"save",value:function(){var e=this;this.pagination.save().then(function(){e.deselectAll(),e.pagination.reload()})}},{key:"revert",value:function(){this.pagination.revert(),this.onSelection()}},{key:"openRepl",value:function(){this._repl.open().then(this._handler.navigateToLatestVersion.bind(this._handler)).then(this._handler.success.bind(this._handler,"create",!0))["catch"](this._handler.handleReplExit.bind(this._handler))}}]),e}();t.$inject=["QueryResource","Query","QueryHandler","defaultDateFormat","OpenReplService","PaginationComponents","TagResource","RoleModel","SelectionTagInput","$q"],e.module("alephControllers.queryIndexController",["alephServices"]).controller("QueryIndexController",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";var t=function(){function t(e,n,i,r,o,a,s,l,u,c,d){var h=this;_classCallCheck(this,t),this._initQuery(c,o),this._modalInstance=e,this.results=new a,this.resultRunner=new r(this.query,this.results,{sandbox:!0,enablePolling:!0}),this._queryBodyState=this._queryBody(),this._getResultCsv=n,d.$on("$destroy",function(){_.each(h.results.collection,function(e){e.poller.unPoll()})}),this._initKeyBindings(l,u,d),this._navigationGuard=new s(d).registerLocationChangeStart(s.defaultPreventer()).registerOnBeforeUnload(function(){return h._queryBodyState===h._queryBody()||h.downloadFlag?void(h.downloadFlag=!1):"Query has unsaved changes!"});var p={save:this._saveKb,detectParameters:this._detectParametersKb,run:this._runKb};this.aceLoaded=function(e){new i(e).snippetsConfig(),e.focus(),e.commands.addCommand(p.save.aceKeyCmd),e.commands.addCommand(p.detectParameters.aceKeyCmd),e.commands.bindKey(p.run.bindKey,p.run.keyFn),e.setOptions({maxLines:500,minLines:2})}}return _createClass(t,[{key:"runQuery",value:function(){this.resultRunner.run()}},{key:"validToRun",value:function(){var e=this.results.collection[0];return!e||"complete"===e.item.status||"failed"===e.item.status}},{key:"validToSave",value:function(){return""!==this.query.item.title}},{key:"saveToolTipText",value:function(){return""===this.query.item.title?"Please enter a query title":""}},{key:"save",value:function(){this._navigationGuard.disable(),this._setParameterDefaultValues(this.query.item.version.parameters,this.resultRunner.substitutionValues);var t=this.results.collection.shift();this._options.skipSave?this._toModelAndClose(e.copy(this.query.item)):this.query.save(_.exists(t)?{result_id:t.item.id}:{}).then(this._toModelAndClose.bind(this))["catch"](function(e){console.error("query save failed",e),alert("Query save failed!")})}},{key:"exit",value:function(){this._navigationGuard.disable(),this._modalInstance.dismiss("QueryReplExit")}},{key:"getCsv",value:function(e){return this.downloadFlag=!0,this._getResultCsv(e)}},{key:"_toModelAndClose",value:function(e){var t=new this._Query;t.internalize(e),this._modalInstance.close(t)}},{key:"_queryBody",value:function(){return this.query.item.version.body}},{key:"_setParameterDefaultValues",value:function(e,t){e.forEach(function(e){var n=t[e.name];_.exists(n)&&(e["default"]=n)})}},{key:"_initQuery",value:function(t,n){this._Query=n,this._options=t,this.query=new n,_.exists(t.query)?this.query.internalize(e.copy(t.query.item)):this.query.initItem()}},{key:"_initKeyBindings",value:function(e,t,n){var i=this;this._saveKb=e.saveQuery.withKeyFn(function(){i.validToSave()&&i.save()}),this._runKb=e.runQuery.withKeyFn(function(){i.validToRun()&&i.runQuery()}),this._detectParametersKb=e.detectParameters.withKeyFn(function(){i.query.detectParameters(),n.$digest()}),t.bindTo(n).add(this._saveKb.hotKey).add(this._runKb.hotKey).add(this._detectParametersKb.hotKey)}}]),t}();t.$inject=["$uibModalInstance","getResultCsv","DefaultAceConfigurator","ResultRunner","Query","Results","NavigationGuard","KeyBindings","hotkeys","options","$scope"],e.module("alephControllers.queryReplController",["alephServices"]).controller("QueryReplController",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";var t=function(){function e(t,n,i,r,o){var a=this;_classCallCheck(this,e),this._tabs=r,this._tabs.setActiveTabFromUrl(),this.componentCallbacks=[],this._loader=n,this._loader.initialize(),this._loader.load().then(function(e){i.title=e.query.title,i.onDestroy(t),a.resultRunner=new o(a.query,a.results,{enableAlert:!0}),_.each(a.componentCallbacks,function(t){t(e)})})}return _createClass(e,[{key:"setTabInUrl",value:function(e){e!==this._tabs.getTab()&&this._tabs.setTab(e)}},{key:"query",get:function(){return this._loader.query}},{key:"queryVersions",get:function(){return this._loader.queryVersions}},{key:"results",get:function(){return this._loader.results}},{key:"queryId",get:function(){return this._loader.queryId}},{key:"queryVersionId",get:function(){return this._loader.queryVersionId}},{key:"tabs",get:function(){return this._tabs.state}}]),e}();t.$inject=["$scope","QueryLoader","PageTitleManager","QueryTab","ResultRunner"],e.module("alephControllers.queryShowController",["alephServices"]).controller("QueryShowController",t)}(angular),!function(e){"use strict";var t=function n(e,t,i,r){var o=this;_classCallCheck(this,n),this.resultId=e.resultId,this.queryId=e.queryId,this.queryVersionId=e.queryVersionId,this.query=new t,this.query.initItem(this.queryId,this.queryVersionId).then(function(e){o.panelTitle="Result id="+o.resultId+' for "'+e.title+'"',r.title=o.panelTitle}),this.result=new i,this.result.initItem(this.resultId)};t.$inject=["$routeParams","Query","Result","PageTitleManager"],e.module("alephControllers.singleResultShowController",["alephServices"]).controller("SingleResultShowController",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";var t=function(){function e(t,n,i,r,o){_classCallCheck(this,e),this.pagination=new r("Paginated Schema",t.index,n,{additionalParams:{with_comments:!0},limit:150}),this.columns=new i;var a=o.withContext("SchemaColumns");a.on(),this.columns.initCollection().then(a.off.bind(a))}return _createClass(e,[{key:"directory",value:function(){return _.chain(this.columns.schemaTables).pairs().reduce(function(e,t){return e.concat(_.map(t[1],function(e){return{schema:t[0],table:e}}))},[]).value()}},{key:"typeAheadValues",value:function(e){var t=this,n=/^[A-z]+$/,i=/^[A-z]+\.[A-z]*$/;if(n.test(e))return _.filter(this.columns.uniqueSchemas,function(t){return t.indexOf(e)>-1});if(!i.test(e))return[];var r=function(){var n=e.split(".")[0],i=t.columns.schemaTables[n];return{v:_.chain(i).map(function(e){return n+"."+e}).filter(function(t){return t.indexOf(e)>-1}).value()}}();return"object"==typeof r?r.v:void 0}}]),e}();t.$inject=["SchemaColumnResource","SchemaColumn","SchemaColumns","PaginationComponents","SpinnerState"],e.module("alephControllers.schemaIndexController",["alephServices"]).controller("SchemaIndexController",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";var t=function(){function e(t,n,i,r){var o=this;_classCallCheck(this,e),this._snippetModelClasses=n.forModelName("snippet"),this._Snippet=n.forModelName("snippet").modelClass(),this._Snippets=n.forModelName("snippet").collectionClass(this._Snippet),this.snippets=new this._Snippets,this._loadSnippets(),this.aceLoaded=function(e){new i(e).autoCompleteConfig(),e.setOptions({maxLines:10,minLines:10})},this._navigationGuard=new r(t).registerOnBeforeUnload(function(){return o.revertableSnippetsExist()?"There are unsaved changes":void 0}).registerLocationChangeStart(function(e){o.revertableSnippetsExist()&&!confirm("There are unsaved changes. Leave the page?")&&e.preventDefault()})}return _createClass(e,[{key:"addNewSnippet",value:function(){var e=new this._Snippet;e.initItem(),this.snippets.collection.unshift(e)}},{key:"isValidForSave",value:function(e){return e.isValidForSave()&&""!==e.item.name&&""!==e.item.content}},{key:"savableSnippetsExist",value:function(){var e=this;return _.some(this.snippets.collection,function(t){return e.isValidForSave(t)})}},{key:"revertableSnippetsExist",value:function(){return _.some(this.snippets.collection,function(e){return e.isDirty()||!e.isPersisted()})}},{key:"updatedAt",value:function(e){return _.exists(e.item.updated_at)?Date.parse(e.item.updated_at):Number.MAX_SAFE_INTEGER}},{key:"shouldGrayout",value:function(e){return!_.every(this.snippets.collection,function(e){return e.isPersisted()})&&e.isPersisted()}},{key:"deleteSnippet",value:function(e){e.destroy().then(this._loadSnippets.bind(this))}},{key:"_loadSnippets",value:function(){this.snippets.initCollection()}}]),e}();t.$inject=["$scope","ModelManager","DefaultAceConfigurator","NavigationGuard"],e.module("alephControllers.snippetIndexController",["alephServices"]).controller("SnippetIndexController",t)}(angular),!function(e){"use strict";e.module("alephDirectives",["alephDirectives.visualization","alephDirectives.result","alephDirectives.results","alephDirectives.queryVersionSidebar","alephDirectives.queryDetails"]).directive("ngConfirmClick",[function(){return{priority:-1,restrict:"A",link:function(e,t,n){t.bind("click",function(e){var t=n.ngConfirmClick;t&&!confirm(t)&&(e.stopImmediatePropagation(),e.preventDefault())})}}}])}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";function t(){return{restrict:"E",scope:{resultRunner:"=",query:"="},templateUrl:"queryDetails",controller:"QueryDetailsController",controllerAs:"queryDetailsCtrl",bindToController:!0}}var n=function(){function e(t,n,i,r,o,a,s){_classCallCheck(this,e),this._handler=t,this._repl=a,this._tags=i,this._roles=s,this._tabs=n,this.dateFormat=r,this.aceLoaded=function(e){return new o(e).readOnlyConfig()},s.initCollection(),this._closeCommentDialog()}return _createClass(e,[{key:"openRepl",value:function(){this._repl.open({query:this.query}).then(this._handler.navigateToLatestVersion.bind(this._handler)).then(this._handler.success.bind(this._handler,"update",!1))["catch"](this._handler.handleReplExit.bind(this._handler))["finally"](this._closeCommentDialog.bind(this))}},{key:"updateQuery",value:function(){this.query.save().then(this._setPristine.bind(this)).then(this._handler.success.bind(this._handler,"update",!1))["finally"](this._closeCommentDialog.bind(this))}},{key:"runQuery",value:function(){this.resultRunner.run().then(this._tabs.navigateToTab.bind(this._tabs,"results"))}},{key:"deleteQuery",value:function(){this.query.destroy().then(this._handler.navigateToIndex.bind(this._handler))}},{key:"loadTags",value:function(e){return this._tags.index({search:e}).$promise}},{key:"loadRoles",value:function(){return this._roles.collection}},{key:"toggleCommentDialog",value:function(){this.commentDialogOpen=!this.commentDialogOpen}},{key:"_closeCommentDialog",value:function(){this.commentDialogOpen=!1}},{key:"_setPristine",value:function(e){return this.form.$setPristine(),e}}]),e}();n.$inject=["QueryHandler","QueryTab","TagResource","defaultDateFormat","DefaultAceConfigurator","OpenReplService","RoleModel"],e.module("alephDirectives.queryDetails",["alephServices"]).controller("QueryDetailsController",n).directive("queryDetails",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";function t(){return{restrict:"E",scope:{query:"=",versions:"=",componentCallbacks:"="},templateUrl:"query-version-sidebar",controller:"QueryVersionSidebarController",controllerAs:"qvSidebarCtrl",bindToController:!0}}var n=function(){function e(t,n){var i=this;_classCallCheck(this,e),this._gitUrl=t,this._$location=n,this.selectedVersions=[],this.componentCallbacks.unshift(function(e){var t=_.map(e.queryVersions,function(e){return e.item});i.currentVersion=_.findWhere(t,{id:i.query.item.version.id}),i.currentVersion.selected=!0,i.currentVersionCommitUrl=i._gitUrl.commit(i.currentVersion),i.githubHistory=i._gitUrl.commits(i.query.item.id)})}return _createClass(e,[{key:"figureGithubUrl",value:function(){if(2===this.selectedVersions.length){var e=_.sortBy(this.selectedVersions,"id");this._githubCompareUrl=this._gitUrl.compare(e[0],e[1])}else 1===this.selectedVersions.length&&(this._githubCommitUrl=this._gitUrl.commit(this.selectedVersions[0]))}},{key:"loadQueryByVersion",value:function(e){this._$location.path("/queries/"+this.query.item.id+"/query_versions/"+e)}},{key:"hasComment",value:function(e){return Utils.stringHelpers.isPresent(e.comment)}},{key:"githubIsEnabled",value:function(){return this._gitUrl.isValid()}},{key:"githubCommit",get:function(){return this._githubCommitUrl||this.currentVersionCommitUrl}},{key:"githubCompare",get:function(){return this._githubCompareUrl}}]),e}();n.$inject=["GithubUrlService","$location"],e.module("alephDirectives.queryVersionSidebar",["alephServices"]).controller("QueryVersionSidebarController",n).directive("queryVersionSidebar",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";function t(){return{restrict:"E",scope:{result:"=",results:"="},templateUrl:"result",controller:"ResultController",controllerAs:"resultCtrl",bindToController:!0}}var n=function(){function e(t,n,i,r){var o=this;_classCallCheck(this,e),this._alertFlash=i,this._$window=r,this.getCsv=function(){return n(o.result.item.id)},this.result.poller.poll(),t.$on("$destroy",function(){o.result.poller.unPoll()})}return _createClass(e,[{key:"resultHasParameters",value:function(){return this.result.item.parameters?_.keys(this.result.item.parameters).length>0:!1}},{key:"deleteResult",value:function(){var e=this;return this.result.destroy().then(function(t){return e._alertFlash.emitInfo("Result id = "+t.id+" has be deleted!"),e.results?void e.results.remove(t):t;
147
- })}}]),e}();n.$inject=["$scope","getResultCsv","AlertFlash","$window"],e.module("alephDirectives.result",["alephServices"]).controller("ResultController",n).directive("result",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";function t(){return{restrict:"E",scope:{query:"=",results:"=",resultRunner:"="},templateUrl:"results",controller:"ResultsController",controllerAs:"resultsCtrl",bindToController:!0}}var n=function(){function t(n){_classCallCheck(this,t),this._alertFlash=n,this._hostname=e.copy(location.host)}return _createClass(t,[{key:"runQuery",value:function(){this.resultRunner.run()}},{key:"generateResultLink",value:function(e){return this._hostname+"/results/query/"+this.query.item.id+"/query_version/"+this.query.item.version.id+"/result/"+e.item.id}},{key:"alertCopied",value:function(){this._alertFlash.emitSuccess("Result link copied to clipboard!")}}]),t}();n.$inject=["AlertFlash"],e.module("alephDirectives.results",["alephServices"]).controller("ResultsController",n).directive("results",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";function t(){return{restrict:"E",scope:{queryId:"=",queryVersionId:"=",results:"="},templateUrl:"visualization",controller:"VisualizationController",controllerAs:"vizShowCtrl",bindToController:!0}}var n=function(){function e(t,n,i){_classCallCheck(this,e),n.initService(),this.visualization=n.visualization,this.visualizations=n.visualizations,this.sourceRenderer=n.sourceRenderer,n.sourceRenderer.setResults(this.results),this.presetDisplayList=function(){return n.presetDisplayList},this._service=n;var r=this;this.aceLoaded=function(e){new i(e),e.setOptions({maxLines:40,minLines:2}),r.aceEditor=e},this._$sce=t}return _createClass(e,[{key:"toggleEditor",value:function(){this.editorSelected=!this.editorSelected,this.editorSelected&&this.aceEditor.setValue(this.visualization.item.html_source,-1)}},{key:"renderedSource",value:function(){return this.sourceRenderer.isValid()?this._$sce.trustAsHtml(this.sourceRenderer.rendered()):""}},{key:"save",value:function(){var e=this;if(!this.visualization.hasTitle()){var t=prompt("Please enter a title for this visualization:");if(null===t||""===t)return;this.visualization.item.title=t}this.visualization.save(this.queryId,this.queryVersionId).then(function(){e.visualizations.initCollection({query_id:e.queryId,query_version_id:e.queryVersionId})})}},{key:"destroy",value:function(){var e=this;this.visualization.destroy().then(function(){e._service.load(e.queryId,e.queryVersionId)})}},{key:"selectVisualization",value:function(e){this.visualization.internalize(e)}},{key:"selectPreset",value:function(e){var t=this;if(this.visualization.isDirty()){var n=confirm("You are about to overwrite some unsaved changes, proceed?");if(!n)return}this.visualization.initItem().then(function(){t.visualization.item.html_source=t._service.presets[e]})}}]),e}();n.$inject=["$sce","VisualizationService","DefaultAceConfigurator"],e.module("alephDirectives.visualization",["alephServices"]).controller("VisualizationController",n).directive("visualization",t)}(angular),!function(e){"use strict";e.module("alephFilters",[]).filter("objectDotKeys",function(){return function(e){return Object.keys(e)}}).filter("humanReadableDuration",function(){return function(e){var t=3600,n=60,i=Math.floor(e/t),r=Math.floor(e%t/n),o=Math.round(e%n);return(e>t?i+" hours ":"")+(e>n?r+" minutes ":"")+o+" seconds"}})}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),_get=function(e,t,n){for(var i=!0;i;){var r=e,o=t,a=n;s=u=l=void 0,i=!1,null===r&&(r=Function.prototype);var s=Object.getOwnPropertyDescriptor(r,o);if(void 0!==s){if("value"in s)return s.value;var l=s.get;return void 0===l?void 0:l.call(a)}var u=Object.getPrototypeOf(r);if(null===u)return void 0;e=u,t=o,n=a,i=!0}};!function(e){"use strict";function t(e,t,n){return function(t){function i(){_classCallCheck(this,i),_get(Object.getPrototypeOf(i.prototype),"constructor",this).call(this,"alert",e,{email:"",query_title:"",target:NaN,comparator:"",status:"",description:""},["email","comparator","target","description","query_title"]),this._pollItemKey="alertItem_"+(new Date).getTime()}return _inherits(i,t),_createClass(i,[{key:"save",value:function(){return"Paused"!==this.item.status&&(this.item.status="Pending"),_get(Object.getPrototypeOf(i.prototype),"save",this).call(this).then(this._pollItem.bind(this))}},{key:"_pollItem",value:function(e){return n.unPoll(this._pollItemKey),n.poll(e,this._pollItemKey,function(){return"Pending"!==e.status}),e}}]),i}(t)}t.$inject=["AlertResource","StandardModel","PollService"],e.module("alephServices.alert",[]).service("Alert",t)}(angular),!function(e){"use strict";function t(e){return e.make("/alerts/:id.json",{id:"@id"})}t.$inject=["ResourceFactory"],e.module("alephServices.alertResource",[]).service("AlertResource",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";var t=function(){function e(t,n){_classCallCheck(this,e),this.langTools=ace.require("ace/ext/language_tools"),this.schemaCompleter=new t,this.keywordCompleter=new n}return _createClass(e,[{key:"ensureSchemasData",value:function(){return this.schemaCompleter.isLoaded()?void 0:this.schemaCompleter.loadColumnData()}},{key:"setCompleters",value:function(){this.langTools.setCompleters([this.schemaCompleter,this.keywordCompleter,this.langTools.textCompleter,this.langTools.snippetCompleter])}}]),e}();t.$inject=["SchemaCompleter","KeywordCompleter"],e.module("alephServices.aceCompleters",[]).service("AceCompleters",t)}(angular),!function(e){"use strict";function t(e,t){function n(e){return h.set({needle:e,start:t,wholeWord:!0,backwards:!0,wrap:!1}),r(e)}function i(e){return h.set({needle:e,start:t,wholeWord:!0,backwards:!1,wrap:!1}),r(e)}function r(t){var n=h.find(e);return _.exists(n)?_.merge(n,{type:t}):void 0}function o(e){return e.sort(function(e,t){var n=e.start.row,i=t.start.row,r=e.start.column,o=t.start.column;return n===i?o>r?-1:r>o?1:0:i>n?-1:1})}function a(){_.each(["select","from","where"],function(e){f.push(n(e)),m.push(i(e))}),f=_.compact(f),m=_.compact(m),g=!0}function s(){if(g===!1&&a(),0===f.length)return!1;var e=_.union(f,[{start:t,type:"cursor"}]),n=o(e),i=_.findIndex(n,{type:"cursor"}),r=n[i-1];return y=r.type}function l(){g===!1&&a(),_.exists(y)||s();var t=void 0,n=void 0,i=v[y];_.exists(i)&&(t=_.findWhere(i.start.location,{type:i.start.type}),n=_.findWhere(i.end.location,{type:i.end.type})||_.findWhere(m,{type:"select"})),_.exists(t)||(t=u()),_.exists(n)||(n=c());var r=new p(t.end.row,t.end.column,n.start.row,n.start.column);return e.getTextRange(r)}function u(){return{end:{row:0,column:0}}}function c(){var t=e.getDocument(),n=t.getLength(),i=t.getLine(n-1),r=i.length;return{start:{row:n,column:r}}}var d=ace.require("ace/search").Search,h=new d,p=ace.require("ace/range").Range,f=[],m=[],g=!1,v={select:{start:{location:m,type:"from"},end:{location:m,type:"where"}},from:{start:{location:f,type:"from"},end:{location:m,type:"where"}},where:{start:{location:f,type:"from"},end:{location:f,type:"where"}}},y=void 0;return{currentClause:s(),fromClause:l()}}e.module("alephServices.aceSqlParse",[]).service("aceSqlParse",function(){return t})}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";function t(e,t,n){return function(){function i(e){var t=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];_classCallCheck(this,i);var n=function(){return void 0};this._modelName=e,this._modelItem=t.modelItem||n,this._modelCollection=t.modelCollection||n,this.wrapFetch=_.partial(this.wrapAction,"fetching"),this.wrapUpdate=_.partial(this.wrapAction,"updating"),this.wrapCreate=_.partial(this.wrapAction,"creating"),this.wrapDestroy=_.partial(this.wrapAction,"deleting"),this.wrapInitCollection=_.partial(this.wrapAction,"loading"),this.wrapCollectionSave=_.partial(this.wrapAction,"saving")}return _createClass(i,[{key:"wrapAction",value:function(e,n){var i=t.withContext(this._modelName+"."+e);return i.on(),n().then(this.onSuccess.bind(this,e))["catch"](this.onError.bind(this,e))["finally"](i.off.bind(i))}},{key:"onError",value:function(t,i){return e.emitDanger(this._msg("Failed",t)),n.reject(i)}},{key:"onSuccess",value:function(e,t){return t}},{key:"_msg",value:function(e,t){return e+" "+t+" "+this._modelName+this._itemSuffix()}},{key:"_itemSuffix",value:function(){var e=this._modelItem(),t=this._modelCollection(),n="";return _.exists(e)?_.exists(e.title)&&0!==e.title.length?n=", title = "+e.title:_.exists(e.id)&&e.id>0&&(n=", id = "+e.id):_.exists(t)&&(n=", count = "+t.length),n}}]),i}()}t.$inject=["AlertFlash","SpinnerState","$q"],e.module("alephServices.actionHandler",[]).service("ActionHandler",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";var t=function(){function e(t){_classCallCheck(this,e),this._$rootScope=t,this.emitSuccess=_.partial(this.emit,"success"),this.emitInfo=_.partial(this.emit,"info"),this.emitWarning=_.partial(this.emit,"warning"),this.emitDanger=_.partial(this.emit,"danger")}return _createClass(e,[{key:"emit",value:function(e,t,n){this._$rootScope.$broadcast(n?"scheduleAlert":"setAlert",{type:e,message:t})}},{key:"emitError",value:function(e,t){var n=" => "+(_.exists(t)?t:"");this.emitDanger(e+n)}}]),e}();t.$inject=["$rootScope"],e.module("alephServices.alertFlash",[]).service("AlertFlash",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";function t(e,t){return function(){function n(t){_classCallCheck(this,n),this._editor=t,this._defaultConfig(),this._Snippet=e.forModelName("snippet").modelClass(),this._Snippets=e.forModelName("snippet").collectionClass(this._Snippet),this._snippets=new this._Snippets}return _createClass(n,[{key:"readOnlyConfig",value:function(){return this._editor.setReadOnly(!0),this._editor.renderer.$cursorLayer.element.style.opacity=0,this._editor.setOptions({highlightActiveLine:!1,highlightGutterLine:!1,maxLines:25,minLines:2}),this}},{key:"autoCompleteConfig",value:function(){return this._editor.setOptions({enableSnippets:!0,enableBasicAutocompletion:!0,enableLiveAutocompletion:!0}),this}},{key:"snippetsConfig",value:function(){return t.reset(),this._snippets.initCollection().then(function(e){_.each(e,function(e){t.add(e.item.name,e.item.content)})}),this.autoCompleteConfig(),this}},{key:"_defaultConfig",value:function(){var e=this._editor.getSession();e.setTabSize(2),e.setUseSoftTabs(!0),this._editor.setPrintMarginColumn(100),this._editor.setShowPrintMargin(!0),this._editor.setBehavioursEnabled(!0),this._editor.$blockScrolling=1/0,this._editor.setOptions({maxLines:25,minLines:2})}}]),n}()}t.$inject=["ModelManager","AceSnippetManager"],e.module("alephServices.defaultAceConfigurator",[]).service("DefaultAceConfigurator",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";var t=function(){function e(t){_classCallCheck(this,e),this._isValid=_.exists(t.configurations.github_owner)&&_.exists(t.configurations.github_repo)&&_.exists(t.configurations.github_ref),this._isValid&&(this._branch=t.configurations.github_ref.split("/")[1],this._githubRoot=["https://github.com",t.configurations.github_owner,t.configurations.github_repo].join("/"))}return _createClass(e,[{key:"commits",value:function(e){return[this._githubRoot,"commits",this._branch,"query_"+e].join("/")}},{key:"commit",value:function(e){return[this._githubRoot,"commit",e.commit_sha].join("/")}},{key:"compare",value:function(e,t){return[this._githubRoot,"compare",e.commit_sha+"..."+t.commit_sha].join("/")}},{key:"isValid",value:function(){return this._isValid}}]),e}();t.$inject=["ServerConfigurations"],e.module("alephServices.githubUrlService",[]).service("GithubUrlService",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";function t(e,t){return function(){function n(){_classCallCheck(this,n);var i=[{meta:"keyword",contextRelevance:{all:1e3}}],r=this;(new t).get("keyword_config.json").then(function(t){r._matcherRunner=new e(i,t.data)})}return _createClass(n,[{key:"getCompletions",value:function(e,t,n,i,r){if(0===i.length)return void r(null,[]);if(_.exists(this._matcherRunner)){var o=this._matcherRunner.execute("all",{},i.toUpperCase());r(null,o)}}}]),n}()}t.$inject=["MatcherRunner","LocalResource"],e.module("alephServices.keywordCompleter",[]).service("KeywordCompleter",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";function t(e){return function(){function t(){_classCallCheck(this,t);for(var e=arguments.length,n=Array(e),i=0;e>i;i++)n[i]=arguments[i];this.path=["resources"].concat(n)}return _createClass(t,[{key:"get",value:function(t){return e.get(this.path.concat([t]).join("/"))}}]),t}()}t.$inject=["$http"],e.module("alephServices.localResource",[]).service("LocalResource",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";var t=function(){function e(){_classCallCheck(this,e),this._locks={}}return _createClass(e,[{key:"attemptAcquire",value:function(e){return this._locks[e]?!1:(this._locks[e]=!0,!0)}},{key:"release",value:function(e){delete this._locks[e]}},{key:"tryWithLockAsync",value:function(e,t){if(this.attemptAcquire(e))try{return this._locks[e]=!0,t(this.release.bind(this,e))}catch(n){throw this.release(e),n}}},{key:"tryWithLock",value:function(e,t){if(this.attemptAcquire(e))try{return this._locks[e]=!0,t()}finally{this.release(e)}}}]),e}();e.module("alephServices.lockService",[]).service("$lock",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";var t=function(){function e(t,n){_classCallCheck(this,e),this._intervalPromises={},this._$lock=t,this._$interval=n,this.poll=_.wrap(this.pollWithFunction.bind(this),function(e,t,n,i){return e(function(){return t.$get()},n,i)})}return _createClass(e,[{key:"unPoll",value:function(e){this._$interval.cancel(this._intervalPromises[e]),delete this._intervalPromises[e]}},{key:"pollWithFunction",value:function(e,t,n){var i=this;this._intervalPromises[t]=this._$interval(function(){n()?i.unPoll(t):i._$lock.tryWithLockAsync(t,function(t){e().then(t)})},5e3)}}]),e}();t.$inject=["$lock","$interval"],e.module("alephServices.pollService",[]).service("PollService",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";var t=function(){function e(t,n){_classCallCheck(this,e),this._matchers=t,this._items=n}return _createClass(e,[{key:"execute",value:function(e,t,n){var i=this,r=[];return _.each(this._matchers,function(o){if(i._isMatcherRelevant(o,e)){var a=i._uniqueFilteredMatches(o,e,t,n);_.each(a,function(t){r.push({name:t,value:t,score:o.contextRelevance[e],meta:o.meta})})}}),r}},{key:"_uniqueFilteredMatches",value:function(e,t,n,i){var r=this,o=_.map(this._items,function(o){if(!r._matcherFiltersForContext(e,t)||r._itemSatisfiesFilters(e.contextItemFilters[t],o,n)){var a=_.exists(e.nameProperty)?o[e.nameProperty]:o;if(0===a.indexOf(i))return a}});return _.compact(_.uniq(o))}},{key:"_itemSatisfiesFilters",value:function(e,t,n){return _.all(e,function(e){return e(t,n)})}},{key:"_matcherFiltersForContext",value:function(e,t){return _.getPath(e,"contextItemFilters."+t)}},{key:"_isMatcherRelevant",value:function(e,t){return _.any(_.keys(e.contextRelevance),function(e){return e===t})}}]),e}();e.module("alephServices.matcherRunner",[]).service("MatcherRunner",function(){return t})}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";function t(e){return function(){function t(n){var i=this;_classCallCheck(this,t),this._$scope=n,this._disabled=!1,this._previousOnBeforeUnload=e.onbeforeunload,n.$on("$destroy",function(){e.onbeforeunload=i._previousOnBeforeUnload})}return _createClass(t,[{key:"registerOnBeforeUnload",value:function(t){var n=this;return e.onbeforeunload=function(){return n._disabled?n._previousOnBeforeUnload():t()},this}},{key:"registerLocationChangeStart",value:function(e){var t=this;return this._$scope.$on("$locationChangeStart",function(n){return t._disabled?void 0:e(n)}),this}},{key:"disable",value:function(){this._disabled=!0}}],[{key:"defaultPreventer",value:function(){return function(e){e.preventDefault()}}}]),t}()}t.$inject=["$window"],e.module("alephServices.navigationGuard",[]).service("NavigationGuard",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";var t=function(){function e(t,n){_classCallCheck(this,e),this._$modal=t,this._AceCompleters=n}return _createClass(e,[{key:"open",value:function(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];this._AceCompleters.ensureSchemasData();var t=this._$modal.open({animation:!0,templateUrl:"queryRepl",controller:"QueryReplController",controllerAs:"queryRepl",bindToController:!0,windowClass:"query-repl-dialog",backdrop:"static",keyboard:!1,resolve:{options:function(){return e}}});return t.result}}]),e}();t.$inject=["$uibModal","AceCompleters"],e.module("alephServices.openReplService",[]).service("OpenReplService",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";var t=function(){function e(t,n){_classCallCheck(this,e),this._defaultTitle=t,this._$route=n}return _createClass(e,[{key:"onDestroy",value:function(e){var t=this;e.$on("$destroy",this.unset.bind(t))}},{key:"unset",value:function(){this.title=void 0}},{key:"title",set:function(e){this._title=e},get:function(){return Utils.stringHelpers.isPresent(this._title)?this._title:this._$route.current&&Utils.stringHelpers.isPresent(this._$route.current.title)?this._$route.current.title:this._defaultTitle}}]),e}();t.$inject=["ApplicationTitle","$route"],e.module("alephServices.pageTitleManager",[]).service("PageTitleManager",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";function t(e,t,n){return function(){function i(e,t,r){var o=arguments.length<=3||void 0===arguments[3]?{}:arguments[3];_classCallCheck(this,i),this.search=o.initialSearch,this.sortBy=o.initialSort,this._Model=r,this._resourceAction=t,this._lockKey=e,this._limit=o.limit||30,this._sortDescending=o.sortDescending===!1?!1:!0,this._spinnerOn=_.partial(this._optionalCall,o.spinnerOn),this._spinnerOff=_.partial(this._optionalCall,o.spinnerOff),this._additionalParams=o.additionalParams||{},this._$q=n,this._init()}return _createClass(i,[{key:"reload",value:function(){this._init(),this._fetch()}},{key:"toggleSortOrder",value:function(){this._sortDescending=!this._sortDescending}},{key:"fetch",value:function(){this._done||this._fetch()}},{key:"save",value:function(e){return this._$q.all(_.map(this.dirtyItems(),function(t){return t.save(e)}))}},{key:"dirtyItems",value:function(){return this._collectionDirtyAwareness.dirtyItems()}},{key:"isDirty",value:function(){return this._collectionDirtyAwareness.isDirty()}},{key:"isPristine",value:function(){return this._collectionDirtyAwareness.isPristine()}},{key:"revert",value:function(){return this._collectionDirtyAwareness.revert()}},{key:"_init",value:function(){var e=this;this.collection=[],this._collectionDirtyAwareness=new t(function(){return e.collection}),this._offset=0,this._done=!1,this._spinnerOn()}},{key:"_optionalCall",value:function(e){if(_.exists(e)&&_.isFunction(e)){for(var t=arguments.length,n=Array(t>1?t-1:0),i=1;t>i;i++)n[i-1]=arguments[i];e.apply(n)}}},{key:"_fetch",value:function(){var t=this;e.tryWithLockAsync(this._lockKey,function(e){var n=_.merge({offset:t._offset,limit:t._limit,search:t.search,sort_by:t.sortBy,sort_descending:t._sortDescending},t._additionalParams);t._resourceAction(n,function(n){return 0===n.length?t._done=!0:_.each(n,function(e){var n=new t._Model;n.internalize(e),t.collection.push(n)}),t._offset++,t._spinnerOff(),e(),n},function(n){return t._spinnerOff(),e(),n})})}}]),i}()}t.$inject=["$lock","CollectionDirtyAwareness","$q"],e.module("alephServices.pagination",["models"]).service("Pagination",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";function t(e,t,n){return function(){function i(e,r,o){var a=arguments.length<=3||void 0===arguments[3]?{}:arguments[3];_classCallCheck(this,i),this._spinner=n.withContext(e),this.searchText=this._intialSearch();var s=a.additionalParams||{},l=a.sortBy||"updated_at",u=a.limit;this._pagination=new t(e,r,o,{initialSearch:this.searchText,initialSort:l,limit:u,spinnerOn:this._spinner.on.bind(this._spinner),spinnerOff:this._spinner.off.bind(this._spinner),additionalParams:s}),this.reload=this._pagination.reload.bind(this._pagination),this.toggleSortOrder=this._pagination.toggleSortOrder.bind(this._pagination),this.loadMore=this._pagination.fetch.bind(this._pagination),this.dirtyItems=this._pagination.dirtyItems.bind(this._pagination),this.isDirty=this._pagination.isDirty.bind(this._pagination),this.isPristine=this._pagination.isPristine.bind(this._pagination),this.revert=this._pagination.revert.bind(this._pagination),this.save=this._pagination.save.bind(this._pagination)}return _createClass(i,[{key:"items",value:function(){return _.map(this.collection(),function(e){return e.item})}},{key:"collection",value:function(){return this._pagination.collection}},{key:"clearSearch",value:function(){this.searchText&&""!==this.searchText&&(this.searchText=null),this.triggerSearch()}},{key:"setSearch",value:function(e,t){t?this.searchText='"'+e+'"':this.searchText=e,this.triggerSearch()}},{key:"setSort",value:function(e){e===this._pagination.sortBy?this._pagination.toggleSortOrder():this._pagination.sortBy=e,this._pagination.reload()}},{key:"triggerSearch",value:function(){e.search("search",this.searchText),this._pagination.search=this.searchText,this._pagination.reload()}},{key:"_intialSearch",value:function(){var t=e.search();return _.isEmpty(t)?void 0:t.search}}]),i}()}t.$inject=["$location","Pagination","SpinnerState"],e.module("alephServices.paginationComponents",[]).service("PaginationComponents",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";var t=function(){function e(){_classCallCheck(this,e),this._parameterRegex=function(){return/\{\s*([^{}]+?)\s*}/g}}return _createClass(e,[{key:"constructParameter",value:function(e){return{name:e,type:"raw"}}},{key:"detectParameters",value:function(e,t){var n=this,i=e.match(this._parameterRegex());_.exists(i)&&i.forEach(function(e){var i=n._parameterRegex().exec(e)[1];n._parameterExists(t,i)&&t.push(n.constructParameter(i))})}},{key:"_parameterExists",value:function(e,t){return-1===_.findIndex(e,function(e){return e.name===t})}}]),e}();e.module("alephServices.parameterMethods",[]).service("ParameterMethods",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";var t=function(){function e(t){_classCallCheck(this,e),this.collection=[],this._resource=t("/roles.json")}return _createClass(e,[{key:"initCollection",value:function(){var e=this;return this._resource.query().$promise.then(function(t){return e.collection=t,t})}}]),e}();t.$inject=["$resource"],e.module("alephServices.roleModel",[]).service("RoleModel",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";function t(e,t,n,i){return function(){function r(){_classCallCheck(this,r),this._columns=new t,this.loadColumnData()}return _createClass(r,[{key:"loadColumnData",value:function(){var e=this;this._columns.initCollection().then(function(t){e._rawColumnsData=t,e._matcherRunner=new n(i,_.map(t,function(e){return e.item}))})}},{key:"isLoaded",value:function(){return _.exists(this._rawColumnsData)&&this._rawColumnsData.length>0}},{key:"getCompletions",value:function(t,n,i,r,o){if(0===r.length)return void o(null,[]);var a=e(n,i),s=a.currentClause,l=this._makeIsSubstringFn(a.fromClause),u=_(this._columns.uniqueTables).filter(l),c=_(this._columns.uniqueSchemas).filter(l);if(_.exists(this._matcherRunner)){var d=this._matcherRunner.execute(s,{tableRestrict:u,schemaRestrict:c},r);o(null,d)}}},{key:"_makeIsSubstringFn",value:function(e){return function(t){return _.exists(e)?e.indexOf(t)>-1:!1}}}]),r}()}t.$inject=["aceSqlParse","SchemaColumns","MatcherRunner","SCHEMA_MATCHERS"],e.module("alephServices.schemaCompleter",["aleph.schemaCompleterConfig"]).service("SchemaCompleter",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";var t=function(){function e(t){_classCallCheck(this,e),this._items=this._makeItemsFn(t.items,t.iteratee),this._itemField=t.itemField,this.selectedTags=[]}return _createClass(e,[{key:"add",value:function(e){var t=this;_.each(this._items(),function(n){n[t._itemField].unshift(e.text)})}},{key:"remove",value:function(e){var t=this;_.each(this._items(),function(n){n[t._itemField]=_.reject(n[t._itemField],function(t){return e.text===t})})}},{key:"onSelection",value:function(){var e=this;this.selectedTags=_.reduce(this._items(),function(t,n){return _.uniq(t.concat(n[e._itemField]))},[])}},{key:"_makeItemsFn",value:function(e,t){var n=_.isFunction(e)?e:function(){return e},i=t;return _.isFunction(i)?function(){return _.map(n(),i)}:n}}]),e}();e.module("alephServices.selectionTagInput",[]).service("SelectionTagInput",function(){return t})}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";var t=function(){function e(){_classCallCheck(this,e),this.configurations={}}return _createClass(e,[{key:"setConfigs",value:function(e){this.configurations=JSON.parse(e)}}]),e}();e.module("alephServices.serverConfigurations",[]).service("ServerConfigurations",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";var t=function(){function e(t){_classCallCheck(this,e),this.context=t,this.active=!1}return _createClass(e,[{key:"on",value:function(){this.active=!0}},{key:"off",value:function(){this.active=!1}}]),e}(),n=function(){function e(){_classCallCheck(this,e),this._spinnersMap={}}return _createClass(e,[{key:"withContext",value:function(e){return _.has(this._spinnersMap,e)||(this._spinnersMap[e]=new t(e)),this._spinnersMap[e]}},{key:"isActive",value:function(){return _.some(this._spinners(),function(e){return e.active})}},{key:"_spinners",value:function(){return _.values(this._spinnersMap)}}]),e}();e.module("alephServices.spinnerState",[]).service("SpinnerState",n)}(angular),function(e){"use strict";e.module("alephServices.tagResource",[]).factory("TagResource",["$resource",function(e){return e("/tags/:id.json",{id:"@id"},{index:{method:"GET",isArray:!0,responseType:"json"}})}])}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";var t=function(){function e(t){_classCallCheck(this,e),this._models=t}return _createClass(e,[{key:"dirtyItems",value:function(){return _.filter(this._models(),function(e){return e.isDirty()})}},{key:"isDirty",value:function(){return this.dirtyItems().length>0}},{key:"isPristine",value:function(){return!this.isDirty()}},{key:"revert",value:function(){_.each(this._models(),function(e){e.revert()})}}]),e}();e.module("models.collectionDirtyAwareness",[]).service("CollectionDirtyAwareness",function(){return t})}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";function t(e){
148
- return function(){function t(e,n){_classCallCheck(this,t),this.collection=[],this._resource=e,this._Model=n}return _createClass(t,[{key:"internalize",value:function(e){_.exists(e)&&_.isArray(e)&&e.length>0?this.collection=_.map(e,this._toModel.bind(this)):this.collection=[]}},{key:"initCollection",value:function(e){var t=this;return this._resource.index(e).$promise.then(function(e){return t.internalize(e),t.collection})}},{key:"save",value:function(e,t){return this._saveCollection(e,t,this.collection)}},{key:"add",value:function(e){var t=this._toModel(e);return this.collection.unshift(t),t}},{key:"remove",value:function(e){var t=_.map(this.collection,function(e){return e.item.id}).indexOf(e.id);return this.collection.splice(t,1)[0]}},{key:"items",value:function(){return _.map(this.collection,function(e){return e.item})}},{key:"_saveCollection",value:function(t,n,i){return e.all(_.map(i,function(e){return e.save(t)})).then(this.initCollection.bind(this,n))}},{key:"_toModel",value:function(e){var t=new this._Model;return t.internalize(e),t}},{key:"Model",get:function(){return this._Model}}]),t}()}t.$inject=["$q"],e.module("models.collectionModelBase",[]).service("CollectionModelBase",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),_get=function(e,t,n){for(var i=!0;i;){var r=e,o=t,a=n;s=u=l=void 0,i=!1,null===r&&(r=Function.prototype);var s=Object.getOwnPropertyDescriptor(r,o);if(void 0!==s){if("value"in s)return s.value;var l=s.get;return void 0===l?void 0:l.call(a)}var u=Object.getPrototypeOf(r);if(null===u)return void 0;e=u,t=o,n=a,i=!0}};!function(e){"use strict";function t(e,t){return function(t){function n(t,i){var r=this;_classCallCheck(this,n),_get(Object.getPrototypeOf(n.prototype),"constructor",this).call(this,t,i),this._collectionDirtyAwareness=new e(function(){return r.collection}),this.dirtyItems=this._collectionDirtyAwareness.dirtyItems.bind(this._collectionDirtyAwareness),this.isDirty=this._collectionDirtyAwareness.isDirty.bind(this._collectionDirtyAwareness),this.isPristine=this._collectionDirtyAwareness.isPristine.bind(this._collectionDirtyAwareness),this.revert=this._collectionDirtyAwareness.revert.bind(this._collectionDirtyAwareness)}return _inherits(n,t),_createClass(n,[{key:"save",value:function(e,t){return this._saveCollection(e,t,this.dirtyItems())}}]),n}(t)}t.$inject=["CollectionDirtyAwareness","CollectionModelBase"],e.module("models.dirtyAwareCollectionModel",[]).service("DirtyAwareCollectionModel",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),_get=function(e,t,n){for(var i=!0;i;){var r=e,o=t,a=n;s=u=l=void 0,i=!1,null===r&&(r=Function.prototype);var s=Object.getOwnPropertyDescriptor(r,o);if(void 0!==s){if("value"in s)return s.value;var l=s.get;return void 0===l?void 0:l.call(a)}var u=Object.getPrototypeOf(r);if(null===u)return void 0;e=u,t=o,n=a,i=!0}};!function(e){"use strict";function t(e,t){return function(e){function n(e,i,r){_classCallCheck(this,n),_get(Object.getPrototypeOf(n.prototype),"constructor",this).call(this,e),this.modelState=new t(i,r)}return _inherits(n,e),_createClass(n,[{key:"isPristine",value:function(){return this.isNew()?!0:this.isPersisted()?this.modelState.isPristine(this.item):!1}},{key:"isDirty",value:function(){return!this.isPristine()}},{key:"revert",value:function(){this._item=this.modelState.snapshot}},{key:"isValidForSave",value:function(){return this.isNew()||!this.isPersisted()||this.modelState.isDirty(this.item)}},{key:"item",set:function(e){this._item=e,this.modelState&&this.modelState.snapshotItem(this._item)},get:function(){return this._item}}]),n}(e)}t.$inject=["ModelBase","ModelState"],e.module("models.dirtyAwareModel",[]).service("DirtyAwareModel",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";function t(e){return function(){function t(e){_classCallCheck(this,t),this._resource=e,this.item={}}return _createClass(t,[{key:"internalize",value:function(e){e?this.item=e:this.item={}}},{key:"initItem",value:function(t){return t?this.fetch({id:t}):(this.item=this._newItem(),e.when(this.item))}},{key:"save",value:function(e){return this.isPersisted()?this.update(_.merge(this.item,e)):this.create(_.merge(this.item,e))}},{key:"destroy",value:function(){return this._resource.destroy({id:this.item.id}).$promise.then(function(e){return e})}},{key:"fetch",value:function(e){var t=this;return this._resource.show(e).$promise.then(function(e){return t.item=e,t.item})}},{key:"update",value:function(e){var t=this;return this._resource.update(e).$promise.then(function(e){return t.item=e,t.item})}},{key:"create",value:function(e){var t=this;return this._resource.create(e).$promise.then(function(e){return t.item=e,t.item})}},{key:"isPersisted",value:function(){return _.exists(this.item.id)}},{key:"isNew",value:function(){return JSON.stringify(this.item)===JSON.stringify(this._newItem())}},{key:"_newItem",value:function(){throw"#_newItem must be implemented in subclasses!"}}]),t}()}t.$inject=["$q"],e.module("models.modelBase",[]).service("ModelBase",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";var t=function(){function t(e){var n=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];_classCallCheck(this,t),this._fields=e,this._comparators=this._defaultComparators(e,n)}return _createClass(t,[{key:"snapshotItem",value:function(t){this._snapshot=e.copy(t)}},{key:"isPristine",value:function(e){var t=this;return _.every(this._fields,function(n){return t._comparators[n](t._resolve(n,e),t._resolve(n,t._snapshot))})}},{key:"isDirty",value:function(e){return!this.isPristine(e)}},{key:"_resolve",value:function(e,t){var n=arguments.length<=2||void 0===arguments[2]?!0:arguments[2];return e.split(".").reduce(function(e,t){return n?e?e[t]:void 0:e[t]},t||this)}},{key:"_defaultComparators",value:function(e,t){var n={};return _.each(e,function(e){n[e]=t[e]||function(e,t){return JSON.stringify(e)===JSON.stringify(t)}}),n}},{key:"snapshot",get:function(){return e.copy(this._snapshot)}}]),t}();e.module("models.modelState",[]).service("ModelState",function(){return t})}(angular),!function(e){"use strict";e.module("models",["models.collectionDirtyAwareness","models.dirtyAwareCollectionModel","models.dirtyAwareModel","models.modelState","models.collectionModelBase","models.modelBase","models.unpersistedModel"])}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";var t=function(){function e(){_classCallCheck(this,e),this.item={}}return _createClass(e,[{key:"internalize",value:function(e){this.item=e}},{key:"save",value:function(){throw"Cannot save an unpersisted model"}}]),e}();e.module("models.unpersistedModel",[]).service("UnpersistedModel",function(){return t})}(angular);var _get=function(e,t,n){for(var i=!0;i;){var r=e,o=t,a=n;s=u=l=void 0,i=!1,null===r&&(r=Function.prototype);var s=Object.getOwnPropertyDescriptor(r,o);if(void 0!==s){if("value"in s)return s.value;var l=s.get;return void 0===l?void 0:l.call(a)}var u=Object.getPrototypeOf(r);if(null===u)return void 0;e=u,t=o,n=a,i=!0}};!function(e){"use strict";function t(e,t){this.makeCollectionModel=function(e,n,i){return function(t){function r(){_classCallCheck(this,r),_get(Object.getPrototypeOf(r.prototype),"constructor",this).call(this,e,i,n)}return _inherits(r,t),r}(t)},this.makeModel=function(t,n,i){var r=arguments.length<=3||void 0===arguments[3]?{}:arguments[3],o=r.dirtyAwareFields||_.keys(n),a=r.dirtyAwareComparators;return function(e){function r(){_classCallCheck(this,r),_get(Object.getPrototypeOf(r.prototype),"constructor",this).call(this,t,i,n,o,a)}return _inherits(r,e),r}(e)}}t.$inject=["StandardModel","StandardCollectionModel"],e.module("modelGeneration.modelFactory",[]).service("ModelFactory",t)}(angular),!function(e){"use strict";e.module("modelGeneration",["modelGeneration.modelFactory","modelGeneration.modelManager","modelGeneration.resourceFactory","modelGeneration.standardModel","modelGeneration.standardCollectionModel"])}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";var t=function(){function e(t,n,i){_classCallCheck(this,e),this._ModelFactory=t,this._ResourceFactory=n,this._definitions=i,this._resources={},this._modelClasses={},this._collectionModelClasses={}}return _createClass(e,[{key:"forModelName",value:function(e){var t=this,n=this._definitions[e],i=this._loadResource(e,n.resource);return{resource:function(){return i},modelClass:function(){return t._loadModelClass(e,n.newItem,i,n.options)},collectionClass:function(n){return t._loadCollectionModelClass(pluralize.plural(e),n,i)}}}},{key:"_loadCollectionModelClass",value:function(e,t,n){return this._load(this._collectionModelClasses,e,this._ModelFactory.makeCollectionModel,this._ModelFactory,e,t,n)}},{key:"_loadModelClass",value:function(e,t,n,i){return this._load(this._modelClasses,e,this._ModelFactory.makeModel,this._ModelFactory,e,t,n,i)}},{key:"_loadResource",value:function(e,t){var n=this._capitalize(e)+"Resource";return this._load(this._resources,n,this._ResourceFactory.make,this._ResourceFactory,t.path,t.parameters,t.actions)}},{key:"_load",value:function(e,t,n,i){var r=e[t];if(!_.exists(r)){for(var o=arguments.length,a=Array(o>4?o-4:0),s=4;o>s;s++)a[s-4]=arguments[s];r=n.apply(i,a),e[t]=r}return r}},{key:"_capitalize",value:function(e){return e.charAt(0).toUpperCase()+e.slice(1)}}]),e}();t.$inject=["ModelFactory","ResourceFactory","ModelDefinitions"],e.module("modelGeneration.modelManager",[]).service("ModelManager",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";var t=function(){function e(t){_classCallCheck(this,e),this._defaultActions={update:{method:"PUT"},create:{method:"POST"},show:{method:"GET"},index:{method:"GET",isArray:!0,responseType:"json"},destroy:{method:"DELETE"}},this._$resource=t}return _createClass(e,[{key:"make",value:function(e,t){var n=arguments.length<=2||void 0===arguments[2]?{}:arguments[2];return this._$resource(e,t,_.merge(this._defaultActions,n))}}]),e}();t.$inject=["$resource"],e.module("modelGeneration.resourceFactory",[]).service("ResourceFactory",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),_get=function(e,t,n){for(var i=!0;i;){var r=e,o=t,a=n;s=u=l=void 0,i=!1,null===r&&(r=Function.prototype);var s=Object.getOwnPropertyDescriptor(r,o);if(void 0!==s){if("value"in s)return s.value;var l=s.get;return void 0===l?void 0:l.call(a)}var u=Object.getPrototypeOf(r);if(null===u)return void 0;e=u,t=o,n=a,i=!0}};!function(e){"use strict";function t(e,t){return function(e){function n(e,i,r){var o=this;_classCallCheck(this,n),_get(Object.getPrototypeOf(n.prototype),"constructor",this).call(this,i,r),this._handler=new t(e,{modelCollection:function(){return o.collection}})}return _inherits(n,e),_createClass(n,[{key:"initCollection",value:function(e){return this._handler.wrapInitCollection(_get(Object.getPrototypeOf(n.prototype),"initCollection",this).bind(this,e))}},{key:"save",value:function(e,t){return this._handler.wrapCollectionSave(_get(Object.getPrototypeOf(n.prototype),"save",this).bind(this,e,t))}}]),n}(e)}t.$inject=["DirtyAwareCollectionModel","ActionHandler"],e.module("modelGeneration.standardCollectionModel",["models"]).service("StandardCollectionModel",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),_get=function(e,t,n){for(var i=!0;i;){var r=e,o=t,a=n;s=u=l=void 0,i=!1,null===r&&(r=Function.prototype);var s=Object.getOwnPropertyDescriptor(r,o);if(void 0!==s){if("value"in s)return s.value;var l=s.get;return void 0===l?void 0:l.call(a)}var u=Object.getPrototypeOf(r);if(null===u)return void 0;e=u,t=o,n=a,i=!0}};!function(e){"use strict";function t(t,n){return function(t){function i(e,t,r,o,a){var s=this;_classCallCheck(this,i),_get(Object.getPrototypeOf(i.prototype),"constructor",this).call(this,t,o,a),this._handler=new n(e,{modelItem:function(){return s.item}}),this._newItemObj=r}return _inherits(i,t),_createClass(i,[{key:"fetch",value:function(e){return this._handler.wrapFetch(_get(Object.getPrototypeOf(i.prototype),"fetch",this).bind(this,e))}},{key:"destroy",value:function(){return this._handler.wrapDestroy(_get(Object.getPrototypeOf(i.prototype),"destroy",this).bind(this))}},{key:"update",value:function(e){return this._handler.wrapUpdate(_get(Object.getPrototypeOf(i.prototype),"update",this).bind(this,e))}},{key:"create",value:function(e){return this._handler.wrapCreate(_get(Object.getPrototypeOf(i.prototype),"create",this).bind(this,e))}},{key:"_newItem",value:function(){return e.copy(this._newItemObj)}}]),i}(t)}t.$inject=["DirtyAwareModel","ActionHandler"],e.module("modelGeneration.standardModel",["models"]).service("StandardModel",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),_get=function(e,t,n){for(var i=!0;i;){var r=e,o=t,a=n;s=u=l=void 0,i=!1,null===r&&(r=Function.prototype);var s=Object.getOwnPropertyDescriptor(r,o);if(void 0!==s){if("value"in s)return s.value;var l=s.get;return void 0===l?void 0:l.call(a)}var u=Object.getPrototypeOf(r);if(null===u)return void 0;e=u,t=o,n=a,i=!0}};!function(e){"use strict";function t(e,t,n,i){return function(n){function r(){_classCallCheck(this,r),_get(Object.getPrototypeOf(r.prototype),"constructor",this).call(this,"query",e,{title:"",tags:[],version:{body:"",parameters:[]}},["title","version.body","roles","tags"])}return _inherits(r,n),_createClass(r,[{key:"initItem",value:function(e,t){return e&&t?_get(Object.getPrototypeOf(r.prototype),"fetch",this).call(this,{id:e,version_id:t}):(this.item=this._newItem(),i.when(this.item))}},{key:"detectParameters",value:function(){t.detectParameters(this.item.version.body,this.item.version.parameters)}},{key:"addParameter",value:function(e){var n=t.constructParameter(e);this.item.version.parameters.push(n)}}]),r}(n)}t.$inject=["QueryResource","ParameterMethods","StandardModel","$q"],e.module("alephServices.query",[]).service("Query",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";var t=function(){function e(t,n,i){_classCallCheck(this,e),this._alertFlash=n,this._$location=t,this._$q=i}return _createClass(e,[{key:"success",value:function(e,t,n){var i=e||"action",r=_.exists(t)?t:!1;return this._alertFlash.emitSuccess('Query "'+n.item.title+'" '+i+"d!",r),n}},{key:"handleReplExit",value:function(e){return"QueryReplExit"!==e?this._$q.reject(e):void this._alertFlash.emitInfo("Exited editing REPL without saving",!1)}},{key:"navigateToLatestVersion",value:function(e){return this._$location.path("/queries/"+e.item.id+"/query_versions/"+e.item.version.id),e}},{key:"navigateToIndex",value:function(){this._$location.path("/queries")}}]),e}();t.$inject=["$location","AlertFlash","$q"],e.module("alephServices.queryHandler",[]).service("QueryHandler",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";var t=function(){function e(t,n,i,r,o){_classCallCheck(this,e),this._Query=n,this._QueryVersion=i,this._Results=r,this._VisualizationService=o,this._$routeParams=t}return _createClass(e,[{key:"initialize",value:function(){this.query=new this._Query,this.queryVersions=new this._QueryVersion,this.results=new this._Results,this.queryId=this._$routeParams.query_id,this.queryVersionId=this._$routeParams.query_version_id||"latest"}},{key:"load",value:function(){return this.query.initItem(this.queryId,this.queryVersionId).then(this.loadQueryVersions.bind(this)).then(this.loadResults.bind(this)).then(this.loadVisualizations.bind(this))}},{key:"loadQueryVersions",value:function(e){return this.queryVersions.initCollection(e.id).then(function(t){return{query:e,queryVersions:t}})}},{key:"loadResults",value:function(e){var t=e.query;return this.results.initCollection({query_id:t.id,query_version_id:t.version.id}).then(function(t){return _.merge(e,{results:t})})}},{key:"loadVisualizations",value:function(e){var t=e.query;return this._VisualizationService.load(t.id,t.version.id).then(function(t){return _.merge(e,{visualizations:t})})}}]),e}();t.$inject=["$routeParams","Query","QueryVersions","Results","VisualizationService"],e.module("alephServices.queryLoader",[]).service("QueryLoader",t)}(angular),!function(e){"use strict";function t(){function t(e,t){var n=t[e];return _.exists(n)&&(t[e]=_.map(n,function(e){return _.exists(e.text)?e.text:e})),t}var n=["id","title","body","tags","result_id","version","roles"];return[function(e){return t("tags",e)},function(e){return t("roles",e)},function(e){return{query:_.selectKeys(e,n)}},e.toJson]}e.module("alephServices.queryRequestTransformers",[]).service("QueryRequestTransformers",t)}(angular),!function(e){"use strict";function t(e,t){return e.make("/queries/:id.json",{id:"@id"},{update:{method:"PUT",transformRequest:t},create:{method:"POST",transformRequest:t}})}t.$inject=["ResourceFactory","QueryRequestTransformers"],e.module("alephServices.queryResource",[]).service("QueryResource",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";var t=function(){function e(t){_classCallCheck(this,e),this._initTabs(),this.$location=t,this._defaultTab="query"}return _createClass(e,[{key:"setActiveTabFromUrl",value:function(){this._activateTab(this.getTab())}},{key:"navigateToTab",value:function(e){this._activateTab(e),this.setTab(e)}},{key:"setTab",value:function(e){this.$location.search("tab",e)}},{key:"getTab",value:function(){var e=this.$location.search().tab;return"visualizations"===e||"results"===e?e:"query"}},{key:"_initTabs",value:function(){this.state={query:{active:!1},results:{active:!1},visualizations:{active:!1}}}},{key:"_activateTab",value:function(e){this._initTabs(),this.state[e].active=!0}},{key:"defaultTag",set:function(e){this._defaultTab=e},get:function(){return this._defaultTab}}]),e}();t.$inject=["$location"],e.module("alephServices.queryTab",[]).service("QueryTab",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),_get=function(e,t,n){for(var i=!0;i;){var r=e,o=t,a=n;s=u=l=void 0,i=!1,null===r&&(r=Function.prototype);var s=Object.getOwnPropertyDescriptor(r,o);if(void 0!==s){if("value"in s)return s.value;var l=s.get;return void 0===l?void 0:l.call(a)}var u=Object.getPrototypeOf(r);if(null===u)return void 0;e=u,t=o,n=a,i=!0}};!function(e){"use strict";function t(e,t,n){return function(t){function i(){_classCallCheck(this,i),_get(Object.getPrototypeOf(i.prototype),"constructor",this).call(this,{index:e("/queries/:id/query_versions/:query_version_id.json").query},n)}return _inherits(i,t),_createClass(i,[{key:"initCollection",value:function(e){return _get(Object.getPrototypeOf(i.prototype),"initCollection",this).call(this,{id:e})}}]),i}(t)}t.$inject=["$resource","CollectionModelBase","UnpersistedModel"],e.module("alephServices.queryVersions",[]).service("QueryVersions",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),_get=function(e,t,n){for(var i=!0;i;){var r=e,o=t,a=n;s=u=l=void 0,i=!1,null===r&&(r=Function.prototype);var s=Object.getOwnPropertyDescriptor(r,o);if(void 0!==s){if("value"in s)return s.value;var l=s.get;return void 0===l?void 0:l.call(a)}var u=Object.getPrototypeOf(r);if(null===u)return void 0;e=u,t=o,n=a,i=!0}};!function(e){"use strict";function t(e,t){var n=e.forModelName("result").modelClass();return function(e){function n(){_classCallCheck(this,n),_get(Object.getPrototypeOf(n.prototype),"constructor",this).call(this),this.poller=new t(this)}return _inherits(n,e),_createClass(n,[{key:"save",value:function(e,t,i){var r=_.merge({query_id:e,query_version_id:t},i||{});return _get(Object.getPrototypeOf(n.prototype),"create",this).call(this,r)}}]),n}(n)}t.$inject=["ModelManager","ResultPoller"],e.module("alephServices.result",[]).service("Result",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";function t(e){return function(){function t(e){_classCallCheck(this,t),this._result=e}return _createClass(t,[{key:"poll",value:function(){var t=this._result.item;this.pollingKey="result_"+t.id+"_"+(new Date).getTime(),e.poll(t,this.pollingKey,function(){return"complete"===t.status||"failed"===t.status?!0:!1})}},{key:"unPoll",value:function(){e.unPoll(this.pollingKey)}}]),t}()}t.$inject=["PollService"],e.module("alephServices.resultPoller",[]).service("ResultPoller",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";function t(e){return function(){function t(e,n){var i=arguments.length<=2||void 0===arguments[2]?{}:arguments[2];_classCallCheck(this,t),this.sandbox=i.sandbox,this.substitutionValues=i.substitutionValues||{},this.results=n,this.query=e,this.enableAlert=i.enableAlert||!1,this.enablePolling=i.enablePolling||!1}return _createClass(t,[{key:"run",value:function(){var t=this,n=this.results.Model,i=new n;return i.save(this.queryId,this.queryVersionId,{substitution_values:this.substitutionValues,body:this.body,parameters:this.parameters,sandbox:this.sandbox}).then(function(n){t.enableAlert&&e.emitInfo("Started running result, id = "+n.id);var i=t.results.add(n);return t.enablePolling&&i.poller.poll(),n})}},{key:"queryId",get:function(){return this.sandbox?void 0:this.query.item.id}},{key:"queryVersionId",get:function(){return this.sandbox?void 0:this.query.item.version.id}},{key:"body",get:function(){return this.sandbox?this.query.item.version.body:void 0}},{key:"parameters",get:function(){return this.sandbox?this.query.item.version.parameters:void 0}}]),t}()}t.$inject=["AlertFlash"],e.module("alephServices.resultRunner",[]).service("ResultRunner",t)}(angular),!function(e){"use strict";function t(e,t){return t.forModelName("result").collectionClass(e)}t.$inject=["Result","ModelManager"],e.module("alephServices.results",[]).service("Results",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";function t(e,t,n){return function(){function i(){_classCallCheck(this,i),this.modelState=new t(["comment_text"]),this.item={}}return _createClass(i,[{key:"internalize",value:function(e){this.item=e}},{key:"isPersisted",value:function(){return _.exists(this.item.comment_id)}},{key:"isNew",value:function(){return!_.exists(this.item.comment_text)||0===this.item.comment_text.length}},{key:"isPristine",value:function(){return this.isNew()?!0:this.isPersisted()?this.modelState.isPristine(this.item):!1}},{key:"isDirty",value:function(){return!this.isPristine()}},{key:"isValidForSave",value:function(){return!this.isPersisted()||this.modelState.isDirty(this.item)}},{key:"save",value:function(){var t=this._toCommentObject(),i=n.emitError.bind(n,"Failed to save comment, id = "+t.id);return this.isPersisted()?e.update(t).$promise.then(this._internalizeCommentInfo.bind(this))["catch"](i):this.modelState.isDirty(this.item)?e.create(t).$promise.then(this._internalizeCommentInfo.bind(this))["catch"](i):void 0}},{key:"_internalizeCommentInfo",value:function(e){return this._item.comment_id=e.id,this._item.comment_text=e.text,this.modelState.snapshotItem(this._item),e}},{key:"_toCommentObject",value:function(){return{id:this.item.comment_id,text:this.item.comment_text,schema:this.item.schema,table:this.item.table,column:this.item.column,target_type:this.item.type}}},{key:"item",set:function(e){this._item=e,this.modelState.snapshotItem(this._item)},get:function(){return this._item}}]),i}()}t.$inject=["SchemaCommentResource","ModelState","AlertFlash"],e.module("alephServices.schema.column",[]).service("SchemaColumn",t)}(angular),!function(e){"use strict";function t(e){return e.make("/columns/:id.json",{id:"@id"})}t.$inject=["ResourceFactory"],e.module("alephServices.schema.columnResource",[]).service("SchemaColumnResource",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),_get=function(e,t,n){for(var i=!0;i;){var r=e,o=t,a=n;s=u=l=void 0,i=!1,null===r&&(r=Function.prototype);var s=Object.getOwnPropertyDescriptor(r,o);if(void 0!==s){if("value"in s)return s.value;var l=s.get;return void 0===l?void 0:l.call(a)}var u=Object.getPrototypeOf(r);if(null===u)return void 0;e=u,t=o,n=a,i=!0}};!function(e){"use strict";function t(e,t,n){return function(t){function i(){_classCallCheck(this,i),_get(Object.getPrototypeOf(i.prototype),"constructor",this).call(this,e,n),this.uniqueSchemas=[],this.uniqueTables=[],this.uniqueColumns=[],this.schemaTables={}}return _inherits(i,t),_createClass(i,[{key:"initCollection",value:function(){return _get(Object.getPrototypeOf(i.prototype),"initCollection",this).call(this).then(this._processUniqueAttributes.bind(this))}},{key:"_processUniqueAttributes",value:function(e){var t=this,n=[],i=[],r=[];return _.each(e,function(e){n.push(e.item.column),i.push(e.item.table),r.push(e.item.schema),t._addToSchemaTables(e)}),this.uniqueColumns=_.uniq(n),this.uniqueTables=_.uniq(i),this.uniqueSchemas=_.uniq(r),e}},{key:"_addToSchemaTables",value:function(e){var t=this.schemaTables[e.item.schema];t||(t=[],this.schemaTables[e.item.schema]=t),_.contains(t,e.item.table)||t.push(e.item.table)}}]),i}(t)}t.$inject=["SchemaColumnResource","CollectionModelBase","UnpersistedModel"],e.module("alephServices.schema.columns",[]).service("SchemaColumns",t)}(angular),!function(e){"use strict";function t(e){return e.make("/schema_comments/:id.json",{id:"@id"})}t.$inject=["ResourceFactory"],e.module("alephServices.schema.commentResource",[]).service("SchemaCommentResource",t)}(angular),!function(e){"use strict";e.module("alephServices",["ngResource","alephServices.queryRequestTransformers","alephServices.queryResource","alephServices.queryHandler","alephServices.queryVersions","alephServices.queryTab","alephServices.query","alephServices.queryLoader","alephServices.visualizationService","alephServices.visualization","alephServices.visualizations","alephServices.sourceRenderer","alephServices.results","alephServices.result","alephServices.resultRunner","alephServices.resultPoller","alephServices.alertResource","alephServices.alert","alephServices.aceSnippetManager","models","modelGeneration","alephServices.schema.columns","alephServices.schema.columnResource","alephServices.schema.column","alephServices.schema.commentResource","alephServices.roleModel","alephServices.schemaCompleter","alephServices.alertFlash","alephServices.pageTitleManager","alephServices.navigationGuard","alephServices.aceCompleters","alephServices.selectionTagInput","alephServices.paginationComponents","alephServices.pagination","alephServices.openReplService","alephServices.matcherRunner","alephServices.actionHandler","alephServices.aceSqlParse","alephServices.pollService","alephServices.lockService","alephServices.localResource","alephServices.githubUrlService","alephServices.defaultAceConfigurator","alephServices.parameterMethods","alephServices.tagResource","alephServices.keywordCompleter","alephServices.spinnerState","alephServices.serverConfigurations"]).constant("defaultDateFormat","yyyy-MM-dd").constant("ApplicationTitle","Aleph").constant("ModelDefinitions",{result:{newItem:{sample_data:[],row_count:0,parameters:[],headers:[]},resource:{path:"/results/:id.json",parameters:{id:"@id"},actions:{index:{method:"GET",isArray:!0,url:"/queries/:query_id/query_versions/:query_version_id/results.json"}}}},snippet:{newItem:{name:"",content:""},resource:{path:"/snippets/:id.json",parameters:{id:"@id"}}},visualization:{newItem:{html_source:"",title:""},resource:{path:"/visualizations/:id.json",parameters:{id:"@id"},actions:{index:{method:"GET",isArray:!0,url:"/queries/:query_id/query_versions/:query_version_id/visualizations.json"}}}}}).service("getResultCsv",["$http","$window",function(e,t){return function(n){var i=arguments.length<=1||void 0===arguments[1]?"The CSV file for this result was not found.":arguments[1];e.get("/result_csvs/"+n+".json").success(function(e){return t.open(e.url,"_self",""),e}).error(function(){t.alert(i)})}}])}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";var t=function(){function e(){_classCallCheck(this,e),this._context="pgsql",this._aceSnippetManager=ace.require("ace/snippets").snippetManager}return _createClass(e,[{key:"add",value:function(e,t){this._aceSnippetManager.register(this._parseSnippet(e,t),this._context)}},{key:"remove",value:function(e,t){this._aceSnippetManager.unregister(this._parseSnippet(e,t),this._context)}},{key:"reset",value:function(){this._aceSnippetManager.snippetMap={},this._aceSnippetManager.snippetNameMap={}}},{key:"_parseSnippet",value:function(e,t){var n="snippet "+e+" \n "+this._transformNewlines(t);return this._aceSnippetManager.parseSnippetFile(n)}},{key:"_transformNewlines",
149
- value:function(e){return e.replace(/(\r\n|\n|\r)/gm,"\n ")}},{key:"context",set:function(e){this._context=e},get:function(){return this._context}}]),e}();e.module("alephServices.aceSnippetManager",[]).service("AceSnippetManager",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";var t=function(){function e(t){_classCallCheck(this,e),this._visualization=t}return _createClass(e,[{key:"setTemplate",value:function(e){this._compiledTemplate=_.template(e)}},{key:"setResults",value:function(e){this.results=e}},{key:"latestResult",value:function t(){var t=void 0;return _(this.results.items()).sortBy("id").reverse().forEach(function(e){_.exists(t)||"complete"!==e.status||(t=e)}),t}},{key:"isValid",value:function(){return this._visualization.hasSource()&&this.latestResult()&&_.exists(this._compiledTemplate)}},{key:"rendered",value:function(){var e=this.latestResult();return this._visualization.hasSource()&&e&&_.exists(this._compiledTemplate)?(this._internalizeToLocalStorage(e),this._compiledTemplate({result_id:e.id,panel:"#chart-panel",body:this._visualization.item.html_source})):null}},{key:"_internalizeToLocalStorage",value:function(e){SerializedStorage.set("DATASET",e.sample_data),SerializedStorage.set("COLUMNS",this._toColumns(e.headers,e.sample_data)),SerializedStorage.set("HEADERS",e.headers)}},{key:"_toColumns",value:function(e,t){var n=[];return e.forEach(function(e,i){n.push([e].concat(t.map(function(e){return e[i]})))}),n}}]),e}();e.module("alephServices.sourceRenderer",[]).service("SourceRenderer",function(){return t})}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),_get=function(e,t,n){for(var i=!0;i;){var r=e,o=t,a=n;s=u=l=void 0,i=!1,null===r&&(r=Function.prototype);var s=Object.getOwnPropertyDescriptor(r,o);if(void 0!==s){if("value"in s)return s.value;var l=s.get;return void 0===l?void 0:l.call(a)}var u=Object.getPrototypeOf(r);if(null===u)return void 0;e=u,t=o,n=a,i=!0}};!function(e){"use strict";function t(e){var t=e.forModelName("visualization").modelClass();return function(e){function t(){_classCallCheck(this,t),_get(Object.getPrototypeOf(t.prototype),"constructor",this).call(this),this.hasSource=this.itemHas.bind(this,"html_source"),this.hasTitle=this.itemHas.bind(this,"title")}return _inherits(t,e),_createClass(t,[{key:"itemHas",value:function(e){return Utils.stringHelpers.isPresent(this.item[e])}},{key:"save",value:function(e,t){return this._save(e,t)}},{key:"destroy",value:function(){var e=this;return _get(Object.getPrototypeOf(t.prototype),"destroy",this).call(this).then(function(){return e.initItem()})}},{key:"_save",value:function(e,n){if(this.isPersisted())return _get(Object.getPrototypeOf(t.prototype),"update",this).call(this,this.item);var i=_.merge({query_id:e,query_version_id:n},this.item);return _get(Object.getPrototypeOf(t.prototype),"create",this).call(this,i)}}]),t}(t)}t.$inject=["ModelManager"],e.module("alephServices.visualization",[]).service("Visualization",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";var t=function(){function e(t,n,i,r,o){_classCallCheck(this,e),this.visualization=new n,this.visualizations=new i,this.sourceRenderer=new t(this.visualization),this.setResults=this.sourceRenderer.setResults.bind(this.sourceRenderer),this.presetDisplayList=[],this.presets={},this._localResource=new r("visualization"),this._$q=o}return _createClass(e,[{key:"load",value:function(e,t){var n=this;return this.visualizations.initCollection({query_id:e,query_version_id:t}).then(function(e){return _.exists(e[0])?n.visualization.internalize(e[0].item):n.visualization.initItem(),e})}},{key:"initService",value:function(){return this._loadPresets().then(this._loadTemplate.bind(this))}},{key:"_loadTemplate",value:function(){var e=this;return this._localResource.get("template.json").then(function(t){e.sourceRenderer.setTemplate(t.data.template.join("\n"))})}},{key:"_loadPresets",value:function(){var e=this;return this._localResource.get("presets.json").then(function(t){return e.presetDisplayList=_.keys(t.data),t.data}).then(function(t){return e._$q.all(_.mapObject(t,function(t,n){e._localResource.get(t).then(function(t){return e.presets[n]=t.data,t.data})}))})}}]),e}();t.$inject=["SourceRenderer","Visualization","Visualizations","LocalResource","$q"],e.module("alephServices.visualizationService",[]).service("VisualizationService",t)}(angular),!function(e){"use strict";function t(e,t){return t.forModelName("visualization").collectionClass(e)}t.$inject=["Visualization","ModelManager"],e.module("alephServices.visualizations",[]).service("Visualizations",t)}(angular);
146
+ return!(!e||1!==e.nodeType)},y.isArray=p||function(e){return"[object Array]"===d.call(e)},y.isObject=function(e){var t=typeof e;return"function"===t||"object"===t&&!!e},y.each(["Arguments","Function","String","Number","Date","RegExp","Error"],function(e){y["is"+e]=function(t){return d.call(t)==="[object "+e+"]"}}),y.isArguments(arguments)||(y.isArguments=function(e){return y.has(e,"callee")}),"function"!=typeof/./&&"object"!=typeof Int8Array&&(y.isFunction=function(e){return"function"==typeof e||!1}),y.isFinite=function(e){return isFinite(e)&&!isNaN(parseFloat(e))},y.isNaN=function(e){return y.isNumber(e)&&e!==+e},y.isBoolean=function(e){return e===!0||e===!1||"[object Boolean]"===d.call(e)},y.isNull=function(e){return null===e},y.isUndefined=function(e){return void 0===e},y.has=function(e,t){return null!=e&&h.call(e,t)},y.noConflict=function(){return r._=o,this},y.identity=function(e){return e},y.constant=function(e){return function(){return e}},y.noop=function(){},y.property=$,y.propertyOf=function(e){return null==e?function(){}:function(t){return e[t]}},y.matcher=y.matches=function(e){return e=y.extendOwn({},e),function(t){return y.isMatch(t,e)}},y.times=function(e,t,n){var i=Array(Math.max(0,e));t=_(t,n,1);for(var r=0;e>r;r++)i[r]=t(r);return i},y.random=function(e,t){return null==t&&(t=e,e=0),e+Math.floor(Math.random()*(t-e+1))},y.now=Date.now||function(){return(new Date).getTime()};var F={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"},O=y.invert(F),R=function(e){var t=function(t){return e[t]},n="(?:"+y.keys(e).join("|")+")",i=RegExp(n),r=RegExp(n,"g");return function(e){return e=null==e?"":""+e,i.test(e)?e.replace(r,t):e}};y.escape=R(F),y.unescape=R(O),y.result=function(e,t,n){var i=null==e?void 0:e[t];return void 0===i&&(i=n),y.isFunction(i)?i.call(e):i};var B=0;y.uniqueId=function(e){var t=++B+"";return e?e+t:t},y.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var P=/(.)^/,I={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},Y=/\\|'|\r|\n|\u2028|\u2029/g,j=function(e){return"\\"+I[e]};y.template=function(e,t,n){!t&&n&&(t=n),t=y.defaults({},t,y.templateSettings);var i=RegExp([(t.escape||P).source,(t.interpolate||P).source,(t.evaluate||P).source].join("|")+"|$","g"),r=0,o="__p+='";e.replace(i,function(t,n,i,a,s){return o+=e.slice(r,s).replace(Y,j),r=s+t.length,n?o+="'+\n((__t=("+n+"))==null?'':_.escape(__t))+\n'":i?o+="'+\n((__t=("+i+"))==null?'':__t)+\n'":a&&(o+="';\n"+a+"\n__p+='"),t}),o+="';\n",t.variable||(o="with(obj||{}){\n"+o+"}\n"),o="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+o+"return __p;\n";try{var a=new Function(t.variable||"obj","_",o)}catch(s){throw s.source=o,s}var l=function(e){return a.call(this,e,y)},u=t.variable||"obj";return l.source="function("+u+"){\n"+o+"}",l},y.chain=function(e){var t=y(e);return t._chain=!0,t};var N=function(e,t){return e._chain?y(t).chain():t};y.mixin=function(e){y.each(y.functions(e),function(t){var n=y[t]=e[t];y.prototype[t]=function(){var e=[this._wrapped];return u.apply(e,arguments),N(this,n.apply(y,e))}})},y.mixin(y),y.each(["pop","push","reverse","shift","sort","splice","unshift"],function(e){var t=a[e];y.prototype[e]=function(){var n=this._wrapped;return t.apply(n,arguments),"shift"!==e&&"splice"!==e||0!==n.length||delete n[0],N(this,n)}}),y.each(["concat","join","slice"],function(e){var t=a[e];y.prototype[e]=function(){return N(this,t.apply(this._wrapped,arguments))}}),y.prototype.value=function(){return this._wrapped},y.prototype.valueOf=y.prototype.toJSON=y.prototype.value,y.prototype.toString=function(){return""+this._wrapped},"function"==typeof define&&define.amd&&define("underscore",[],function(){return y})}.call(this),KeyBinding.prototype.withKeyFn=function(e){return{name:this.name,bindKey:this.bindKey,keyFn:e,aceKeyCmd:{name:this.name,bindKey:this.bindKey,exec:e},hotKey:{combo:_.toArray(this.bindKey),description:this.name,callback:e}}};var SerializedStorage={set:function(e,t){localStorage.setItem(e,JSON.stringify(t))},get:function(e){return JSON.parse(localStorage.getItem(e))},storage:localStorage},slice=Array.prototype.slice,existy=function(e){return null!=e};_.mixin({cat:function(){return _.flatten(arguments,!0)},cons:function(e,t){return _.cat([e],t)},chunk:function(e,t,n){var i=function(e){if(null==e)return[];var r=_.take(e,t);return t===_.size(r)?_.cons(r,i(_.drop(e,t))):n?[_.take(_.cat(r,n),t)]:[]};return i(e)},chunkAll:function(e,t,n){n=null!=n?n:t;var i=function(e,t,n){return _.isEmpty(e)?[]:_.cons(_.take(e,t),i(_.drop(e,n),t,n))};return i(e,t,n)},mapcat:function(e,t){return _.flatten(_.map(e,t),!0)},interpose:function(e,t){if(!_.isArray(e))throw new TypeError;var n=_.size(e);return 0===n?e:1===n?e:slice.call(_.mapcat(e,function(e){return _.cons(e,[t])}),0,-1)},weave:function(){return _.some(arguments)?1==arguments.length?arguments[0]:_.filter(_.flatten(_.zip.apply(null,arguments),!0),function(e){return null!=e}):[]},interleave:_.weave,repeat:function(e,t){return _.times(e,function(){return t})},cycle:function(e,t){return _.flatten(_.times(e,function(){return t}),!0)},splitAt:function(e,t){return[_.take(e,t),_.drop(e,t)]},iterateUntil:function(e,t,n){for(var i=[],r=e(n);t(r);)i.push(r),r=e(r);return i},takeSkipping:function(e,t){var n=[],i=_.size(e);if(0>=t)return[];if(1===t)return e;for(var r=0;i>r;r+=t)n.push(e[r]);return n},reductions:function(e,t,n){var i=[],r=n;return _.each(e,function(n,o){r=t(r,e[o]),i.push(r)}),i},keepIndexed:function(e,t){return _.filter(_.map(_.range(_.size(e)),function(n){return t(n,e[n])}),existy)},reverseOrder:function(e){if("string"==typeof e)throw new TypeError("Strings cannot be reversed by _.reverseOrder");return slice.call(e).reverse()},combinations:function(){return _.reduce(slice.call(arguments,1),function(e,t){return _.reduce(e,function(e,n){return e.concat(_.map(t,function(e){return n.concat([e])}))},[])},_.map(arguments[0],function(e){return[e]}))}}),_.mixin({isInstanceOf:function(e,t){return e instanceof t},isAssociative:function(e){return _.isArray(e)||_.isObject(e)||_.isArguments(e)},isIndexed:function(e){return _.isArray(e)||_.isString(e)||_.isArguments(e)},isSequential:function(e){return _.isArray(e)||_.isArguments(e)},isPlainObject:function(e){return _.isObject(e)&&e.constructor===Object},isZero:function(e){return 0===e},isEven:function(e){return _.isFinite(e)&&0===(1&e)},isOdd:function(e){return _.isFinite(e)&&!_.isEven(e)},isPositive:function(e){return e>0},isNegative:function(e){return 0>e},isValidDate:function(e){return _.isDate(e)&&!_.isNaN(e.getTime())},isNumeric:function(e){return!isNaN(parseFloat(e))&&isFinite(e)},isInteger:function(e){return _.isNumeric(e)&&e%1===0},isFloat:function(e){return _.isNumeric(e)&&!_.isInteger(e)},isJSON:function(e){try{JSON.parse(e)}catch(t){return!1}return!0},isIncreasing:function(){var e=_.size(arguments);if(1===e)return!0;if(2===e)return arguments[0]<arguments[1];for(var t=1;e>t;t++)if(arguments[t-1]>=arguments[t])return!1;return!0},isDecreasing:function(){var e=_.size(arguments);if(1===e)return!0;if(2===e)return arguments[0]>arguments[1];for(var t=1;e>t;t++)if(arguments[t-1]<=arguments[t])return!1;return!0}});var slice=Array.prototype.slice,concat=Array.prototype.concat,existy=function(e){return null!=e},truthy=function(e){return e!==!1&&existy(e)},isAssociative=function(e){return _.isArray(e)||_.isObject(e)},curry2=function(e){return function(t){return function(n){return e(n,t)}}};_.mixin({merge:function(){var e=_.some(arguments)?{}:null;return truthy(e)&&_.extend.apply(null,concat.call([e],_.toArray(arguments))),e},renameKeys:function(e,t){return _.reduce(t,function(t,n,i){return existy(e[i])?(t[n]=e[i],t):t},_.omit.apply(null,concat.call([e],_.keys(t))))},snapshot:function(e){if(null==e||"object"!=typeof e)return e;var t=new e.constructor;for(var n in e)e.hasOwnProperty(n)&&(t[n]=_.snapshot(e[n]));return t},updatePath:function(e,t,n,i){if(!isAssociative(e))throw new TypeError("Attempted to update a non-associative object.");if(!existy(n))return t(e);var r=_.isArray(n),o=r?n:[n],a=r?_.snapshot(e):_.clone(e),s=_.last(o),l=a;return _.each(_.initial(o),function(e){i&&!_.has(l,e)&&(l[e]=_.clone(i)),l=l[e]}),l[s]=t(l[s]),a},setPath:function(e,t,n,i){if(!existy(n))throw new TypeError("Attempted to set a property at a null path.");return _.updatePath(e,function(){return t},n,i)},frequencies:curry2(_.countBy)(_.identity)});var concat=Array.prototype.concat,ArrayProto=Array.prototype,slice=ArrayProto.slice;_.mixin({accessor:function(e){return function(t){return t&&t[e]}},dictionary:function(e){return function(t){return e&&t&&e[t]}},selectKeys:function(e,t){return _.pick.apply(null,concat.call([e],t))},kv:function(e,t){return _.has(e,t)?[t,e[t]]:void 0},getPath:function(e,t){t="string"==typeof t?keysFromPath(t):t;for(var n=-1,i=t.length;++n<i&&null!=e;)e=e[t[n]];return n===i?e:void 0},hasPath:function(e,t){t="string"==typeof t?keysFromPath(t):t;for(var n=-1,i=t.length;++n<i&&_.isObject(e);){if(!(t[n]in e))return!1;e=e[t[n]]}return n===i},keysFromPath:keysFromPath,pickWhen:function(e,t){var n={};return _.each(e,function(i,r){t(e[r])&&(n[r]=e[r])}),n},omitWhen:function(e,t){return _.pickWhen(e,function(e){return!t(e)})}}),_.mixin({exists:function(e){return null!=e},truthy:function(e){return e!==!1&&_.exists(e)},falsey:function(e){return!_.truthy(e)},not:function(e){return!e},firstExisting:function(){for(var e=0;e<arguments.length;e++)if(null!=arguments[e])return arguments[e]}});var Utils=Utils||{};Utils.arrayHelpers={removeItem:function(e,t){var n=_.findIndex(e,t);return e.splice(n,1),e},compare:function(e,t,n){return e.length===t.length&&_.every(e,function(e){return _.some(t,function(t){return _.exists(n)?n(e)===n(t):e===t})})}},Utils.stringHelpers={isPresent:function(e){return!(e||"").match(/^\s*$/)}},!function(e){"use strict";e.module("aleph",["alephControllers","alephDirectives","alephServices","alephFilters","ngAnimate","angular-clipboard","ui.bootstrap","infinite-scroll","ngTagsInput","cfp.hotkeys","angular.filter","selectionModel","treasure-overlay-spinner"]).run(["AceCompleters",function(e){e.setCompleters()}]).run(["$rootScope","PageTitleManager",function(e,t){e.pageTitleManager=t}]).value("KeyBindings",{saveQuery:new KeyBinding("Save Query",{mac:"command+shift+s",win:"ctrl+shift+s"}),runQuery:new KeyBinding("Run Query",{mac:"shift+enter",win:"shift+enter"}),detectParameters:new KeyBinding("Detect Parameters",{mac:"command+shift+p",win:"ctrl+shift+p"})}).config(["$locationProvider",function(e){e.html5Mode(!0)}]).config(["$animateProvider",function(e){e.classNameFilter(/ng-animate-enabled/)}]).config(["$routeProvider",function(e){e.when("/queries/:query_id",{redirectTo:"/queries/:query_id/query_versions/latest"}).when("/queries",{templateUrl:"queryIndex",controller:"QueryIndexController",controllerAs:"queryIdxCtrl",reloadOnSearch:!1}).when("/schemas/:schemaName",{templateUrl:"schemaShow",controller:"SchemaShowController"}).when("/schemas",{title:"Schemas",templateUrl:"schemaIndex",controller:"SchemaIndexController",controllerAs:"schemaIdxCtrl",reloadOnSearch:!1}).when("/queries/:query_id/query_versions/:query_version_id",{templateUrl:"showQuery",controller:"QueryShowController",controllerAs:"queryShowCtrl"}).when("/alerts",{title:"Alerts",templateUrl:"alertIndex",controller:"AlertIndexController",controllerAs:"alertIdxCtrl",reloadOnSearch:!1}).when("/alerts/:alertId",{templateUrl:"alertShow",controller:"AlertShowController",controllerAs:"alertShowCtrl"}).when("/results/query/:queryId/query_version/:queryVersionId/result/:resultId",{templateUrl:"singleResultShow",controller:"SingleResultShowController",controllerAs:"singleResultShowCtrl"}).when("/snippets",{title:"Snippets",templateUrl:"snippetIndex",controller:"SnippetIndexController",controllerAs:"snippetIdxCtrl"}).otherwise("/queries")}])}(angular),!function(e){"use strict";var t={tableRestrictionMet:function(e,t){return 0===t.tableRestrict.length||_.contains(t.tableRestrict,e.table)},schemaRestrictionMet:function(e,t){return 0===t.schemaRestrict.length||_.contains(t.schemaRestrict,e.schema)}};e.module("aleph.schemaCompleterConfig",[]).constant("SCHEMA_MATCHERS",[{nameProperty:"schema",meta:"schema",contextRelevance:{from:1e3}},{nameProperty:"column",meta:"column",contextRelevance:{select:1e3,from:500,where:1e3},contextItemFilters:{select:[t.schemaRestrictionMet,t.tableRestrictionMet],from:[t.schemaRestrictionMet,t.tableRestrictionMet],where:[t.schemaRestrictionMet,t.tableRestrictionMet]}},{nameProperty:"table",meta:"table",contextRelevance:{select:500,from:1e3,where:500},contextItemFilters:{select:[t.schemaRestrictionMet,t.tableRestrictionMet],from:[t.schemaRestrictionMet],where:[t.schemaRestrictionMet,t.tableRestrictionMet]}}])}(angular),!function(e){"use strict";var t=function n(e,t,i,r){_classCallCheck(this,n),this.pagination=new t("Paginated Queries",e.index,i),this.defaultDateFormat=r};t.$inject=["AlertResource","PaginationComponents","Alert","defaultDateFormat"],e.module("alephControllers.alertIndexController",["alephServices"]).controller("AlertIndexController",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";var t=function(){function e(t,n,i,r,o,a,s,l){var u=this;_classCallCheck(this,e),this._openReplService=o,this._$location=l,this.aceLoaded=function(e){new n(e).readOnlyConfig()},this.alert=new r,this.query=new i,"new"===s.alertId?this.alert.initItem().then(this.query.initItem.bind(this.query,null)).then(this._openReplService.open.bind(this._openReplService,{skipSave:!0})).then(function(e){u.query=e,u.alert.item.query_title=e.item.title,u.query.item.tags.push("alert-query")}):this.alert.initItem(s.alertId).then(function(e){return u.query.initItem(e.query_id,"latest")}),this._navigationGuard=new a(t).registerLocationChangeStart(function(e){if(u.alert.isDirty()){var t=confirm("Your alert has not been saved. Are you sure you want to leave this page?");t||e.preventDefault()}}).registerOnBeforeUnload(function(){return u.alert.isDirty()?"Alert has unsaved changes!":void 0})}return _createClass(e,[{key:"togglePaused",value:function(){"Paused"===this.alert.item.status?this.alert.item.status="Pending":this.alert.item.status="Paused",this.alert.save()}},{key:"editAlert",value:function(){var e=this;this._openReplService.open({query:this.query}).then(function(t){return e.query=t,e.query.save()}).then(this.alert.save.bind(this.alert))}},{key:"deleteAlert",value:function(){var e=this;this.alert.destroy().then(function(){return e._$location.path("/alerts")})}},{key:"saveAlert",value:function(){var e=this;this.isPersisted()?this.alert.save():this.query.save().then(function(t){e.alert.item.query_id=t.id,e.alert.save()})}},{key:"isPersisted",value:function(){return this.alert.isPersisted()&&this.query.isPersisted()}}]),e}();t.$inject=["$scope","DefaultAceConfigurator","Query","Alert","OpenReplService","NavigationGuard","$routeParams","$location"],e.module("alephControllers.alertShowController",["alephServices"]).controller("AlertShowController",t)}(angular),!function(e){"use strict";e.module("alephControllers",["alephControllers.schemaIndexController","alephControllers.queryIndexController","alephControllers.queryShowController","alephControllers.queryReplController","alephControllers.alertIndexController","alephControllers.alertShowController","alephControllers.snippetIndexController","alephControllers.singleResultShowController","alephServices","ui.ace","ngRoute","ui.bootstrap.alert"]).controller("BodyController",["$scope","SpinnerState","ServerConfigurations",function(e,t,n){e.SpinnerState=t,e.ServerConfigurations=n}]).controller("NavBarController",["$scope","$window","$location",function(e,t,n){e.pathIncludes=function(e){return n.path().indexOf(e)>-1},e.signOut=function(){t.location.href="/sign_out"}}]).controller("AlertBarController",["$scope","$rootScope",function(e,t){e.alerts=[],e.dismiss=function(){e.alerts.length=0},t.$on("$routeChangeSuccess",function(){e.scheduledAlert?(e.alerts.push(e.scheduledAlert),e.scheduledAlert=null):e.dismiss()}),t.$on("scheduleAlert",function(t,n){e.scheduledAlert=n}),t.$on("setAlert",function(t,n){e.alerts.push(n)})}])}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";var t=function(){function e(t,n,i,r,o,a,s,l,u,c){_classCallCheck(this,e),this.selectedQueries=[],this.defaultDateFormat=r,this._handler=i,this.tagsSelectionInput=new u({items:this.selectedQueries,itemField:"tags"}),this.rolesSelectionInput=new u({items:this.selectedQueries,itemField:"roles"}),this.pagination=new a("Paginated Queries",t.index,n),this._roleModel=l,this._tagResource=s,this._$q=c,this._repl=o,l.initCollection()}return _createClass(e,[{key:"loadTags",value:function(e){return this._tagResource.index({search:e}).$promise}},{key:"loadRoles",value:function(){return this._roleModel.collection}},{key:"onSelection",value:function(){this.tagsSelectionInput.onSelection(),this.rolesSelectionInput.onSelection()}},{key:"deselectAll",value:function(){_.each(this.selectedQueries,function(e){e.selected=!1}),this.selectedQueries.length=0,this.onSelection()}},{key:"save",value:function(){var e=this;this.pagination.save().then(function(){e.deselectAll(),e.pagination.reload()})}},{key:"revert",value:function(){this.pagination.revert(),this.onSelection()}},{key:"openRepl",value:function(){this._repl.open().then(this._handler.navigateToLatestVersion.bind(this._handler)).then(this._handler.success.bind(this._handler,"create",!0))["catch"](this._handler.handleReplExit.bind(this._handler))}}]),e}();t.$inject=["QueryResource","Query","QueryHandler","defaultDateFormat","OpenReplService","PaginationComponents","TagResource","RoleModel","SelectionTagInput","$q"],e.module("alephControllers.queryIndexController",["alephServices"]).controller("QueryIndexController",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";var t=function(){function t(e,n,i,r,o,a,s,l,u,c,d){var h=this;_classCallCheck(this,t),this._initQuery(c,o),this._modalInstance=e,this.results=new a,this.resultRunner=new r(this.query,this.results,{sandbox:!0,enablePolling:!0}),this._queryBodyState=this._queryBody(),this._getResultCsv=n,d.$on("$destroy",function(){_.each(h.results.collection,function(e){e.poller.unPoll()})}),this._initKeyBindings(l,u,d),this._navigationGuard=new s(d).registerLocationChangeStart(s.defaultPreventer()).registerOnBeforeUnload(function(){return h._queryBodyState===h._queryBody()||h.downloadFlag?void(h.downloadFlag=!1):"Query has unsaved changes!"});var p={save:this._saveKb,detectParameters:this._detectParametersKb,run:this._runKb};this.aceLoaded=function(e){new i(e).snippetsConfig(),e.focus(),e.commands.addCommand(p.save.aceKeyCmd),e.commands.addCommand(p.detectParameters.aceKeyCmd),e.commands.bindKey(p.run.bindKey,p.run.keyFn),e.setOptions({maxLines:500,minLines:2})}}return _createClass(t,[{key:"runQuery",value:function(){this.resultRunner.run()}},{key:"validToRun",value:function(){var e=this.results.collection[0];return!e||"complete"===e.item.status||"failed"===e.item.status}},{key:"validToSave",value:function(){return""!==this.query.item.title}},{key:"saveToolTipText",value:function(){return""===this.query.item.title?"Please enter a query title":""}},{key:"save",value:function(){this._navigationGuard.disable(),this._setParameterDefaultValues(this.query.item.version.parameters,this.resultRunner.substitutionValues);var t=this.results.collection[0];this._options.skipSave?this._toModelAndClose(e.copy(this.query.item)):this.query.save(_.exists(t)?{result_id:t.item.id}:{}).then(this._toModelAndClose.bind(this))["catch"](function(e){console.error("query save failed",e),alert("Query save failed!")})}},{key:"exit",value:function(){this._navigationGuard.disable(),this._modalInstance.dismiss("QueryReplExit")}},{key:"getCsv",value:function(e){return this.downloadFlag=!0,this._getResultCsv(e)}},{key:"_toModelAndClose",value:function(e){var t=new this._Query;t.internalize(e),this._modalInstance.close(t)}},{key:"_queryBody",value:function(){return this.query.item.version.body}},{key:"_setParameterDefaultValues",value:function(e,t){e.forEach(function(e){var n=t[e.name];_.exists(n)&&(e["default"]=n)})}},{key:"_initQuery",value:function(t,n){this._Query=n,this._options=t,this.query=new n,_.exists(t.query)?this.query.internalize(e.copy(t.query.item)):this.query.initItem()}},{key:"_initKeyBindings",value:function(e,t,n){var i=this;this._saveKb=e.saveQuery.withKeyFn(function(){i.validToSave()&&i.save()}),this._runKb=e.runQuery.withKeyFn(function(){i.validToRun()&&i.runQuery()}),this._detectParametersKb=e.detectParameters.withKeyFn(function(){i.query.detectParameters(),n.$digest()}),t.bindTo(n).add(this._saveKb.hotKey).add(this._runKb.hotKey).add(this._detectParametersKb.hotKey)}}]),t}();t.$inject=["$uibModalInstance","getResultCsv","DefaultAceConfigurator","ResultRunner","Query","Results","NavigationGuard","KeyBindings","hotkeys","options","$scope"],e.module("alephControllers.queryReplController",["alephServices"]).controller("QueryReplController",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";var t=function(){function e(t,n,i,r,o){var a=this;_classCallCheck(this,e),this._tabs=r,this._tabs.setActiveTabFromUrl(),this.componentCallbacks=[],this._loader=n,this._loader.initialize(),this._loader.load().then(function(e){i.title=e.query.title,i.onDestroy(t),a.resultRunner=new o(a.query,a.results,{enableAlert:!0}),_.each(a.componentCallbacks,function(t){t(e)})})}return _createClass(e,[{key:"setTabInUrl",value:function(e){e!==this._tabs.getTab()&&this._tabs.setTab(e)}},{key:"query",get:function(){return this._loader.query}},{key:"queryVersions",get:function(){return this._loader.queryVersions}},{key:"results",get:function(){return this._loader.results}},{key:"queryId",get:function(){return this._loader.queryId}},{key:"queryVersionId",get:function(){return this._loader.queryVersionId}},{key:"tabs",get:function(){return this._tabs.state}}]),e}();t.$inject=["$scope","QueryLoader","PageTitleManager","QueryTab","ResultRunner"],e.module("alephControllers.queryShowController",["alephServices"]).controller("QueryShowController",t)}(angular),!function(e){"use strict";var t=function n(e,t,i,r){var o=this;_classCallCheck(this,n),this.resultId=e.resultId,this.queryId=e.queryId,this.queryVersionId=e.queryVersionId,this.query=new t,this.query.initItem(this.queryId,this.queryVersionId).then(function(e){o.panelTitle="Result id="+o.resultId+' for "'+e.title+'"',r.title=o.panelTitle}),this.result=new i,this.result.initItem(this.resultId)};t.$inject=["$routeParams","Query","Result","PageTitleManager"],e.module("alephControllers.singleResultShowController",["alephServices"]).controller("SingleResultShowController",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";var t=function(){function e(t,n,i,r,o){_classCallCheck(this,e),this.pagination=new r("Paginated Schema",t.index,n,{additionalParams:{with_comments:!0},limit:150}),this.columns=new i;var a=o.withContext("SchemaColumns");a.on(),this.columns.initCollection().then(a.off.bind(a))}return _createClass(e,[{key:"directory",value:function(){return _.chain(this.columns.schemaTables).pairs().reduce(function(e,t){return e.concat(_.map(t[1],function(e){return{schema:t[0],table:e}}))},[]).value()}},{key:"typeAheadValues",value:function(e){var t=this,n=/^[A-z]+$/,i=/^[A-z]+\.[A-z]*$/;if(n.test(e))return _.filter(this.columns.uniqueSchemas,function(t){return t.indexOf(e)>-1});if(!i.test(e))return[];var r=function(){var n=e.split(".")[0],i=t.columns.schemaTables[n];return{v:_.chain(i).map(function(e){return n+"."+e}).filter(function(t){return t.indexOf(e)>-1}).value()}}();return"object"==typeof r?r.v:void 0}}]),e}();t.$inject=["SchemaColumnResource","SchemaColumn","SchemaColumns","PaginationComponents","SpinnerState"],e.module("alephControllers.schemaIndexController",["alephServices"]).controller("SchemaIndexController",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";var t=function(){function e(t,n,i,r){var o=this;_classCallCheck(this,e),this._snippetModelClasses=n.forModelName("snippet"),this._Snippet=n.forModelName("snippet").modelClass(),this._Snippets=n.forModelName("snippet").collectionClass(this._Snippet),this.snippets=new this._Snippets,this._loadSnippets(),this.aceLoaded=function(e){new i(e).autoCompleteConfig(),e.setOptions({maxLines:10,minLines:10})},this._navigationGuard=new r(t).registerOnBeforeUnload(function(){return o.revertableSnippetsExist()?"There are unsaved changes":void 0}).registerLocationChangeStart(function(e){o.revertableSnippetsExist()&&!confirm("There are unsaved changes. Leave the page?")&&e.preventDefault()})}return _createClass(e,[{key:"addNewSnippet",value:function(){var e=new this._Snippet;e.initItem(),this.snippets.collection.unshift(e)}},{key:"isValidForSave",value:function(e){return e.isValidForSave()&&""!==e.item.name&&""!==e.item.content}},{key:"savableSnippetsExist",value:function(){var e=this;return _.some(this.snippets.collection,function(t){return e.isValidForSave(t)})}},{key:"revertableSnippetsExist",value:function(){return _.some(this.snippets.collection,function(e){return e.isDirty()||!e.isPersisted()})}},{key:"updatedAt",value:function(e){return _.exists(e.item.updated_at)?Date.parse(e.item.updated_at):Number.MAX_SAFE_INTEGER}},{key:"shouldGrayout",value:function(e){return!_.every(this.snippets.collection,function(e){return e.isPersisted()})&&e.isPersisted()}},{key:"deleteSnippet",value:function(e){e.destroy().then(this._loadSnippets.bind(this))}},{key:"_loadSnippets",value:function(){this.snippets.initCollection()}}]),e}();t.$inject=["$scope","ModelManager","DefaultAceConfigurator","NavigationGuard"],e.module("alephControllers.snippetIndexController",["alephServices"]).controller("SnippetIndexController",t)}(angular),!function(e){"use strict";e.module("alephDirectives",["alephDirectives.visualization","alephDirectives.result","alephDirectives.results","alephDirectives.queryVersionSidebar","alephDirectives.queryDetails"]).directive("ngConfirmClick",[function(){return{priority:-1,restrict:"A",link:function(e,t,n){t.bind("click",function(e){var t=n.ngConfirmClick;t&&!confirm(t)&&(e.stopImmediatePropagation(),e.preventDefault())})}}}])}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";function t(){return{restrict:"E",scope:{resultRunner:"=",query:"="},templateUrl:"queryDetails",controller:"QueryDetailsController",controllerAs:"queryDetailsCtrl",bindToController:!0}}var n=function(){function e(t,n,i,r,o,a,s,l){_classCallCheck(this,e),this._handler=t,this._repl=a,this._tags=i,this._roles=s,this._tabs=n,this.dateFormat=r,this.aceLoaded=function(e){return new o(e).readOnlyConfig()},this._Query=l,s.initCollection(),this._closeCommentDialog()}return _createClass(e,[{key:"openRepl",value:function(){this._repl.open({query:this.query}).then(this._handler.navigateToLatestVersion.bind(this._handler)).then(this._handler.success.bind(this._handler,"update",!1))["catch"](this._handler.handleReplExit.bind(this._handler))["finally"](this._closeCommentDialog.bind(this))}},{key:"updateQuery",value:function(){this.query.save().then(this._setPristine.bind(this)).then(this._handler.success.bind(this._handler,"update",!1))["finally"](this._closeCommentDialog.bind(this))}},{key:"runQuery",value:function(){this.resultRunner.run().then(this._tabs.navigateToTab.bind(this._tabs,"results"))}},{key:"cloneQuery",value:function(){var e=this.query.clone();e._item.title="Copy of "+e._item.title,e.save().then(this._internalizeQueryItem.bind(this)).then(this._handler.navigateToLatestVersion.bind(this._handler))}},{key:"deleteQuery",value:function(){this.query.destroy().then(this._handler.navigateToIndex.bind(this._handler))}},{key:"loadTags",value:function(e){return this._tags.index({search:e}).$promise}},{key:"loadRoles",value:function(){return this._roles.collection}},{key:"toggleCommentDialog",value:function(){this.commentDialogOpen=!this.commentDialogOpen}},{key:"_closeCommentDialog",value:function(){this.commentDialogOpen=!1}},{key:"_setPristine",value:function(e){return this.form.$setPristine(),e}},{key:"_internalizeQueryItem",value:function(e){var t=new this._Query;return t.internalize(e),t}}]),e}();n.$inject=["QueryHandler","QueryTab","TagResource","defaultDateFormat","DefaultAceConfigurator","OpenReplService","RoleModel","Query"],e.module("alephDirectives.queryDetails",["alephServices"]).controller("QueryDetailsController",n).directive("queryDetails",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";function t(){return{restrict:"E",scope:{query:"=",versions:"=",componentCallbacks:"="},templateUrl:"query-version-sidebar",controller:"QueryVersionSidebarController",controllerAs:"qvSidebarCtrl",bindToController:!0}}var n=function(){function e(t,n){var i=this;_classCallCheck(this,e),this._gitUrl=t,this._$location=n,this.selectedVersions=[],this.componentCallbacks.unshift(function(e){var t=_.map(e.queryVersions,function(e){return e.item});i.currentVersion=_.findWhere(t,{id:i.query.item.version.id}),i.currentVersion.selected=!0,i.currentVersionCommitUrl=i._gitUrl.commit(i.currentVersion),i.githubHistory=i._gitUrl.commits(i.query.item.id)})}return _createClass(e,[{key:"figureGithubUrl",value:function(){if(2===this.selectedVersions.length){var e=_.sortBy(this.selectedVersions,"id");this._githubCompareUrl=this._gitUrl.compare(e[0],e[1])}else 1===this.selectedVersions.length&&(this._githubCommitUrl=this._gitUrl.commit(this.selectedVersions[0]))}},{key:"loadQueryByVersion",value:function(e){this._$location.path("/queries/"+this.query.item.id+"/query_versions/"+e)}},{key:"hasComment",value:function(e){return Utils.stringHelpers.isPresent(e.comment)}},{key:"githubIsEnabled",value:function(){return this._gitUrl.isValid()}},{key:"githubCommit",get:function(){return this._githubCommitUrl||this.currentVersionCommitUrl}},{key:"githubCompare",get:function(){return this._githubCompareUrl}}]),e}();n.$inject=["GithubUrlService","$location"],e.module("alephDirectives.queryVersionSidebar",["alephServices"]).controller("QueryVersionSidebarController",n).directive("queryVersionSidebar",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";function t(){return{restrict:"E",scope:{result:"=",results:"="},templateUrl:"result",controller:"ResultController",controllerAs:"resultCtrl",bindToController:!0}}var n=function(){function e(t,n,i,r){var o=this;_classCallCheck(this,e),this._alertFlash=i,this._$window=r,this.getCsv=function(){return n(o.result.item.id)},this.result.poller.poll(),t.$on("$destroy",function(){o.result.poller.unPoll()})}return _createClass(e,[{
147
+ key:"resultHasParameters",value:function(){return this.result.item.parameters?_.keys(this.result.item.parameters).length>0:!1}},{key:"deleteResult",value:function(){var e=this;return this.result.destroy().then(function(t){return e._alertFlash.emitInfo("Result id = "+t.id+" has be deleted!"),e.results?void e.results.remove(t):t})}}]),e}();n.$inject=["$scope","getResultCsv","AlertFlash","$window"],e.module("alephDirectives.result",["alephServices"]).controller("ResultController",n).directive("result",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";function t(){return{restrict:"E",scope:{query:"=",results:"=",resultRunner:"="},templateUrl:"results",controller:"ResultsController",controllerAs:"resultsCtrl",bindToController:!0}}var n=function(){function t(n){_classCallCheck(this,t),this._alertFlash=n,this._hostname=e.copy(location.host)}return _createClass(t,[{key:"runQuery",value:function(){this.resultRunner.run()}},{key:"generateResultLink",value:function(e){return this._hostname+"/results/query/"+this.query.item.id+"/query_version/"+this.query.item.version.id+"/result/"+e.item.id}},{key:"alertCopied",value:function(){this._alertFlash.emitSuccess("Result link copied to clipboard!")}}]),t}();n.$inject=["AlertFlash"],e.module("alephDirectives.results",["alephServices"]).controller("ResultsController",n).directive("results",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";function t(){return{restrict:"E",scope:{queryId:"=",queryVersionId:"=",results:"="},templateUrl:"visualization",controller:"VisualizationController",controllerAs:"vizShowCtrl",bindToController:!0}}var n=function(){function e(t,n,i){_classCallCheck(this,e),n.initService(),this.visualization=n.visualization,this.visualizations=n.visualizations,this.sourceRenderer=n.sourceRenderer,n.sourceRenderer.setResults(this.results),this.presetDisplayList=function(){return n.presetDisplayList},this._service=n;var r=this;this.aceLoaded=function(e){new i(e),e.setOptions({maxLines:40,minLines:2}),r.aceEditor=e},this._$sce=t}return _createClass(e,[{key:"toggleEditor",value:function(){this.editorSelected=!this.editorSelected,this.editorSelected&&this.aceEditor.setValue(this.visualization.item.html_source,-1)}},{key:"renderedSource",value:function(){return this.sourceRenderer.isValid()?this._$sce.trustAsHtml(this.sourceRenderer.rendered()):""}},{key:"save",value:function(){var e=this;if(!this.visualization.hasTitle()){var t=prompt("Please enter a title for this visualization:");if(null===t||""===t)return;this.visualization.item.title=t}this.visualization.save(this.queryId,this.queryVersionId).then(function(){e.visualizations.initCollection({query_id:e.queryId,query_version_id:e.queryVersionId})})}},{key:"destroy",value:function(){var e=this;this.visualization.destroy().then(function(){e._service.load(e.queryId,e.queryVersionId)})}},{key:"selectVisualization",value:function(e){this.visualization.internalize(e)}},{key:"selectPreset",value:function(e){var t=this;if(this.visualization.isDirty()){var n=confirm("You are about to overwrite some unsaved changes, proceed?");if(!n)return}this.visualization.initItem().then(function(){t.visualization.item.html_source=t._service.presets[e]})}}]),e}();n.$inject=["$sce","VisualizationService","DefaultAceConfigurator"],e.module("alephDirectives.visualization",["alephServices"]).controller("VisualizationController",n).directive("visualization",t)}(angular),!function(e){"use strict";e.module("alephFilters",[]).filter("objectDotKeys",function(){return function(e){return Object.keys(e)}}).filter("humanReadableDuration",function(){return function(e){var t=3600,n=60,i=Math.floor(e/t),r=Math.floor(e%t/n),o=Math.round(e%n);return(e>t?i+" hours ":"")+(e>n?r+" minutes ":"")+o+" seconds"}})}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),_get=function(e,t,n){for(var i=!0;i;){var r=e,o=t,a=n;s=u=l=void 0,i=!1,null===r&&(r=Function.prototype);var s=Object.getOwnPropertyDescriptor(r,o);if(void 0!==s){if("value"in s)return s.value;var l=s.get;return void 0===l?void 0:l.call(a)}var u=Object.getPrototypeOf(r);if(null===u)return void 0;e=u,t=o,n=a,i=!0}};!function(e){"use strict";function t(e,t,n){return function(t){function i(){_classCallCheck(this,i),_get(Object.getPrototypeOf(i.prototype),"constructor",this).call(this,"alert",e,{email:"",query_title:"",target:NaN,comparator:"",status:"",description:""},["email","comparator","target","description","query_title"]),this._pollItemKey="alertItem_"+(new Date).getTime()}return _inherits(i,t),_createClass(i,[{key:"save",value:function(){return"Paused"!==this.item.status&&(this.item.status="Pending"),_get(Object.getPrototypeOf(i.prototype),"save",this).call(this).then(this._pollItem.bind(this))}},{key:"_pollItem",value:function(e){return n.unPoll(this._pollItemKey),n.poll(e,this._pollItemKey,function(){return"Pending"!==e.status}),e}}]),i}(t)}t.$inject=["AlertResource","StandardModel","PollService"],e.module("alephServices.alert",[]).service("Alert",t)}(angular),!function(e){"use strict";function t(e){return e.make("/alerts/:id.json",{id:"@id"})}t.$inject=["ResourceFactory"],e.module("alephServices.alertResource",[]).service("AlertResource",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";var t=function(){function e(t,n){_classCallCheck(this,e),this.langTools=ace.require("ace/ext/language_tools"),this.schemaCompleter=new t,this.keywordCompleter=new n}return _createClass(e,[{key:"ensureSchemasData",value:function(){return this.schemaCompleter.isLoaded()?void 0:this.schemaCompleter.loadColumnData()}},{key:"setCompleters",value:function(){this.langTools.setCompleters([this.schemaCompleter,this.keywordCompleter,this.langTools.textCompleter,this.langTools.snippetCompleter])}}]),e}();t.$inject=["SchemaCompleter","KeywordCompleter"],e.module("alephServices.aceCompleters",[]).service("AceCompleters",t)}(angular),!function(e){"use strict";function t(e,t){function n(e){return h.set({needle:e,start:t,wholeWord:!0,backwards:!0,wrap:!1}),r(e)}function i(e){return h.set({needle:e,start:t,wholeWord:!0,backwards:!1,wrap:!1}),r(e)}function r(t){var n=h.find(e);return _.exists(n)?_.merge(n,{type:t}):void 0}function o(e){return e.sort(function(e,t){var n=e.start.row,i=t.start.row,r=e.start.column,o=t.start.column;return n===i?o>r?-1:r>o?1:0:i>n?-1:1})}function a(){_.each(["select","from","where"],function(e){f.push(n(e)),m.push(i(e))}),f=_.compact(f),m=_.compact(m),g=!0}function s(){if(g===!1&&a(),0===f.length)return!1;var e=_.union(f,[{start:t,type:"cursor"}]),n=o(e),i=_.findIndex(n,{type:"cursor"}),r=n[i-1];return y=r.type}function l(){g===!1&&a(),_.exists(y)||s();var t=void 0,n=void 0,i=v[y];_.exists(i)&&(t=_.findWhere(i.start.location,{type:i.start.type}),n=_.findWhere(i.end.location,{type:i.end.type})||_.findWhere(m,{type:"select"})),_.exists(t)||(t=u()),_.exists(n)||(n=c());var r=new p(t.end.row,t.end.column,n.start.row,n.start.column);return e.getTextRange(r)}function u(){return{end:{row:0,column:0}}}function c(){var t=e.getDocument(),n=t.getLength(),i=t.getLine(n-1),r=i.length;return{start:{row:n,column:r}}}var d=ace.require("ace/search").Search,h=new d,p=ace.require("ace/range").Range,f=[],m=[],g=!1,v={select:{start:{location:m,type:"from"},end:{location:m,type:"where"}},from:{start:{location:f,type:"from"},end:{location:m,type:"where"}},where:{start:{location:f,type:"from"},end:{location:f,type:"where"}}},y=void 0;return{currentClause:s(),fromClause:l()}}e.module("alephServices.aceSqlParse",[]).service("aceSqlParse",function(){return t})}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";function t(e,t,n){return function(){function i(e){var t=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];_classCallCheck(this,i);var n=function(){return void 0};this._modelName=e,this._modelItem=t.modelItem||n,this._modelCollection=t.modelCollection||n,this.wrapFetch=_.partial(this.wrapAction,"fetching"),this.wrapUpdate=_.partial(this.wrapAction,"updating"),this.wrapCreate=_.partial(this.wrapAction,"creating"),this.wrapDestroy=_.partial(this.wrapAction,"deleting"),this.wrapInitCollection=_.partial(this.wrapAction,"loading"),this.wrapCollectionSave=_.partial(this.wrapAction,"saving")}return _createClass(i,[{key:"wrapAction",value:function(e,n){var i=t.withContext(this._modelName+"."+e);return i.on(),n().then(this.onSuccess.bind(this,e))["catch"](this.onError.bind(this,e))["finally"](i.off.bind(i))}},{key:"onError",value:function(t,i){return e.emitDanger(this._msg("Failed",t)),n.reject(i)}},{key:"onSuccess",value:function(e,t){return t}},{key:"_msg",value:function(e,t){return e+" "+t+" "+this._modelName+this._itemSuffix()}},{key:"_itemSuffix",value:function(){var e=this._modelItem(),t=this._modelCollection(),n="";return _.exists(e)?_.exists(e.title)&&0!==e.title.length?n=", title = "+e.title:_.exists(e.id)&&e.id>0&&(n=", id = "+e.id):_.exists(t)&&(n=", count = "+t.length),n}}]),i}()}t.$inject=["AlertFlash","SpinnerState","$q"],e.module("alephServices.actionHandler",[]).service("ActionHandler",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";var t=function(){function e(t){_classCallCheck(this,e),this._$rootScope=t,this.emitSuccess=_.partial(this.emit,"success"),this.emitInfo=_.partial(this.emit,"info"),this.emitWarning=_.partial(this.emit,"warning"),this.emitDanger=_.partial(this.emit,"danger")}return _createClass(e,[{key:"emit",value:function(e,t,n){this._$rootScope.$broadcast(n?"scheduleAlert":"setAlert",{type:e,message:t})}},{key:"emitError",value:function(e,t){var n=" => "+(_.exists(t)?t:"");this.emitDanger(e+n)}}]),e}();t.$inject=["$rootScope"],e.module("alephServices.alertFlash",[]).service("AlertFlash",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";function t(e,t){return function(){function n(t){_classCallCheck(this,n),this._editor=t,this._defaultConfig(),this._Snippet=e.forModelName("snippet").modelClass(),this._Snippets=e.forModelName("snippet").collectionClass(this._Snippet),this._snippets=new this._Snippets}return _createClass(n,[{key:"readOnlyConfig",value:function(){return this._editor.setReadOnly(!0),this._editor.renderer.$cursorLayer.element.style.opacity=0,this._editor.setOptions({highlightActiveLine:!1,highlightGutterLine:!1,maxLines:25,minLines:2}),this}},{key:"autoCompleteConfig",value:function(){return this._editor.setOptions({enableSnippets:!0,enableBasicAutocompletion:!0,enableLiveAutocompletion:!0}),this}},{key:"snippetsConfig",value:function(){return t.reset(),this._snippets.initCollection().then(function(e){_.each(e,function(e){t.add(e.item.name,e.item.content)})}),this.autoCompleteConfig(),this}},{key:"_defaultConfig",value:function(){var e=this._editor.getSession();e.setTabSize(2),e.setUseSoftTabs(!0),this._editor.setPrintMarginColumn(100),this._editor.setShowPrintMargin(!0),this._editor.setBehavioursEnabled(!0),this._editor.$blockScrolling=1/0,this._editor.setOptions({maxLines:25,minLines:2})}}]),n}()}t.$inject=["ModelManager","AceSnippetManager"],e.module("alephServices.defaultAceConfigurator",[]).service("DefaultAceConfigurator",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";var t=function(){function e(t){_classCallCheck(this,e),this._isValid=_.exists(t.configurations.github_owner)&&_.exists(t.configurations.github_repo)&&_.exists(t.configurations.github_ref),this._isValid&&(this._branch=t.configurations.github_ref.split("/")[1],this._githubRoot=["https://github.com",t.configurations.github_owner,t.configurations.github_repo].join("/"))}return _createClass(e,[{key:"commits",value:function(e){return[this._githubRoot,"commits",this._branch,"query_"+e].join("/")}},{key:"commit",value:function(e){return[this._githubRoot,"commit",e.commit_sha].join("/")}},{key:"compare",value:function(e,t){return[this._githubRoot,"compare",e.commit_sha+"..."+t.commit_sha].join("/")}},{key:"isValid",value:function(){return this._isValid}}]),e}();t.$inject=["ServerConfigurations"],e.module("alephServices.githubUrlService",[]).service("GithubUrlService",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";function t(e,t){return function(){function n(){_classCallCheck(this,n);var i=[{meta:"keyword",contextRelevance:{all:1e3}}],r=this;(new t).get("keyword_config.json").then(function(t){r._matcherRunner=new e(i,t.data)})}return _createClass(n,[{key:"getCompletions",value:function(e,t,n,i,r){if(0===i.length)return void r(null,[]);if(_.exists(this._matcherRunner)){var o=this._matcherRunner.execute("all",{},i.toUpperCase());r(null,o)}}}]),n}()}t.$inject=["MatcherRunner","LocalResource"],e.module("alephServices.keywordCompleter",[]).service("KeywordCompleter",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";function t(e){return function(){function t(){_classCallCheck(this,t);for(var e=arguments.length,n=Array(e),i=0;e>i;i++)n[i]=arguments[i];this.path=["resources"].concat(n)}return _createClass(t,[{key:"get",value:function(t){return e.get(this.path.concat([t]).join("/"))}}]),t}()}t.$inject=["$http"],e.module("alephServices.localResource",[]).service("LocalResource",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";var t=function(){function e(){_classCallCheck(this,e),this._locks={}}return _createClass(e,[{key:"attemptAcquire",value:function(e){return this._locks[e]?!1:(this._locks[e]=!0,!0)}},{key:"release",value:function(e){delete this._locks[e]}},{key:"tryWithLockAsync",value:function(e,t){if(this.attemptAcquire(e))try{return this._locks[e]=!0,t(this.release.bind(this,e))}catch(n){throw this.release(e),n}}},{key:"tryWithLock",value:function(e,t){if(this.attemptAcquire(e))try{return this._locks[e]=!0,t()}finally{this.release(e)}}}]),e}();e.module("alephServices.lockService",[]).service("$lock",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";var t=function(){function e(t,n){_classCallCheck(this,e),this._intervalPromises={},this._$lock=t,this._$interval=n,this.poll=_.wrap(this.pollWithFunction.bind(this),function(e,t,n,i){return e(function(){return t.$get()},n,i)})}return _createClass(e,[{key:"unPoll",value:function(e){this._$interval.cancel(this._intervalPromises[e]),delete this._intervalPromises[e]}},{key:"pollWithFunction",value:function(e,t,n){var i=this;this._intervalPromises[t]=this._$interval(function(){n()?i.unPoll(t):i._$lock.tryWithLockAsync(t,function(t){e().then(t)})},5e3)}}]),e}();t.$inject=["$lock","$interval"],e.module("alephServices.pollService",[]).service("PollService",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";var t=function(){function e(t,n){_classCallCheck(this,e),this._matchers=t,this._items=n}return _createClass(e,[{key:"execute",value:function(e,t,n){var i=this,r=[];return _.each(this._matchers,function(o){if(i._isMatcherRelevant(o,e)){var a=i._uniqueFilteredMatches(o,e,t,n);_.each(a,function(t){r.push({name:t,value:t,score:o.contextRelevance[e],meta:o.meta})})}}),r}},{key:"_uniqueFilteredMatches",value:function(e,t,n,i){var r=this,o=_.map(this._items,function(o){if(!r._matcherFiltersForContext(e,t)||r._itemSatisfiesFilters(e.contextItemFilters[t],o,n)){var a=_.exists(e.nameProperty)?o[e.nameProperty]:o;if(0===a.indexOf(i))return a}});return _.compact(_.uniq(o))}},{key:"_itemSatisfiesFilters",value:function(e,t,n){return _.all(e,function(e){return e(t,n)})}},{key:"_matcherFiltersForContext",value:function(e,t){return _.getPath(e,"contextItemFilters."+t)}},{key:"_isMatcherRelevant",value:function(e,t){return _.any(_.keys(e.contextRelevance),function(e){return e===t})}}]),e}();e.module("alephServices.matcherRunner",[]).service("MatcherRunner",function(){return t})}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";function t(e){return function(){function t(n){var i=this;_classCallCheck(this,t),this._$scope=n,this._disabled=!1,this._previousOnBeforeUnload=e.onbeforeunload,n.$on("$destroy",function(){e.onbeforeunload=i._previousOnBeforeUnload})}return _createClass(t,[{key:"registerOnBeforeUnload",value:function(t){var n=this;return e.onbeforeunload=function(){return n._disabled?n._previousOnBeforeUnload():t()},this}},{key:"registerLocationChangeStart",value:function(e){var t=this;return this._$scope.$on("$locationChangeStart",function(n){return t._disabled?void 0:e(n)}),this}},{key:"disable",value:function(){this._disabled=!0}}],[{key:"defaultPreventer",value:function(){return function(e){e.preventDefault()}}}]),t}()}t.$inject=["$window"],e.module("alephServices.navigationGuard",[]).service("NavigationGuard",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";var t=function(){function e(t,n){_classCallCheck(this,e),this._$modal=t,this._AceCompleters=n}return _createClass(e,[{key:"open",value:function(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];this._AceCompleters.ensureSchemasData();var t=this._$modal.open({animation:!0,templateUrl:"queryRepl",controller:"QueryReplController",controllerAs:"queryRepl",bindToController:!0,windowClass:"query-repl-dialog",backdrop:"static",keyboard:!1,resolve:{options:function(){return e}}});return t.result}}]),e}();t.$inject=["$uibModal","AceCompleters"],e.module("alephServices.openReplService",[]).service("OpenReplService",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";var t=function(){function e(t,n){_classCallCheck(this,e),this._defaultTitle=t,this._$route=n}return _createClass(e,[{key:"onDestroy",value:function(e){var t=this;e.$on("$destroy",this.unset.bind(t))}},{key:"unset",value:function(){this.title=void 0}},{key:"title",set:function(e){this._title=e},get:function(){return Utils.stringHelpers.isPresent(this._title)?this._title:this._$route.current&&Utils.stringHelpers.isPresent(this._$route.current.title)?this._$route.current.title:this._defaultTitle}}]),e}();t.$inject=["ApplicationTitle","$route"],e.module("alephServices.pageTitleManager",[]).service("PageTitleManager",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";function t(e,t,n){return function(){function i(e,t,r){var o=arguments.length<=3||void 0===arguments[3]?{}:arguments[3];_classCallCheck(this,i),this.search=o.initialSearch,this.sortBy=o.initialSort,this._Model=r,this._resourceAction=t,this._lockKey=e,this._limit=o.limit||30,this._sortDescending=o.sortDescending===!1?!1:!0,this._spinnerOn=_.partial(this._optionalCall,o.spinnerOn),this._spinnerOff=_.partial(this._optionalCall,o.spinnerOff),this._additionalParams=o.additionalParams||{},this._$q=n,this._init()}return _createClass(i,[{key:"reload",value:function(){this._init(),this._fetch()}},{key:"toggleSortOrder",value:function(){this._sortDescending=!this._sortDescending}},{key:"fetch",value:function(){this._done||this._fetch()}},{key:"save",value:function(e){return this._$q.all(_.map(this.dirtyItems(),function(t){return t.save(e)}))}},{key:"dirtyItems",value:function(){return this._collectionDirtyAwareness.dirtyItems()}},{key:"isDirty",value:function(){return this._collectionDirtyAwareness.isDirty()}},{key:"isPristine",value:function(){return this._collectionDirtyAwareness.isPristine()}},{key:"revert",value:function(){return this._collectionDirtyAwareness.revert()}},{key:"_init",value:function(){var e=this;this.collection=[],this._collectionDirtyAwareness=new t(function(){return e.collection}),this._offset=0,this._done=!1,this._spinnerOn()}},{key:"_optionalCall",value:function(e){if(_.exists(e)&&_.isFunction(e)){for(var t=arguments.length,n=Array(t>1?t-1:0),i=1;t>i;i++)n[i-1]=arguments[i];e.apply(n)}}},{key:"_fetch",value:function(){var t=this;e.tryWithLockAsync(this._lockKey,function(e){var n=_.merge({offset:t._offset,limit:t._limit,search:t.search,sort_by:t.sortBy,sort_descending:t._sortDescending},t._additionalParams);t._resourceAction(n,function(n){return 0===n.length?t._done=!0:_.each(n,function(e){var n=new t._Model;n.internalize(e),t.collection.push(n)}),t._offset++,t._spinnerOff(),e(),n},function(n){return t._spinnerOff(),e(),n})})}}]),i}()}t.$inject=["$lock","CollectionDirtyAwareness","$q"],e.module("alephServices.pagination",["models"]).service("Pagination",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";function t(e,t,n){return function(){function i(e,r,o){var a=arguments.length<=3||void 0===arguments[3]?{}:arguments[3];_classCallCheck(this,i),this._spinner=n.withContext(e),this.searchText=this._intialSearch();var s=a.additionalParams||{},l=a.sortBy||"updated_at",u=a.limit;this._pagination=new t(e,r,o,{initialSearch:this.searchText,initialSort:l,limit:u,spinnerOn:this._spinner.on.bind(this._spinner),spinnerOff:this._spinner.off.bind(this._spinner),additionalParams:s}),this.reload=this._pagination.reload.bind(this._pagination),this.toggleSortOrder=this._pagination.toggleSortOrder.bind(this._pagination),this.loadMore=this._pagination.fetch.bind(this._pagination),this.dirtyItems=this._pagination.dirtyItems.bind(this._pagination),this.isDirty=this._pagination.isDirty.bind(this._pagination),this.isPristine=this._pagination.isPristine.bind(this._pagination),this.revert=this._pagination.revert.bind(this._pagination),this.save=this._pagination.save.bind(this._pagination)}return _createClass(i,[{key:"items",value:function(){return _.map(this.collection(),function(e){return e.item})}},{key:"collection",value:function(){return this._pagination.collection}},{key:"clearSearch",value:function(){this.searchText&&""!==this.searchText&&(this.searchText=null),this.triggerSearch()}},{key:"setSearch",value:function(e,t){t?this.searchText='"'+e+'"':this.searchText=e,this.triggerSearch()}},{key:"setSort",value:function(e){e===this._pagination.sortBy?this._pagination.toggleSortOrder():this._pagination.sortBy=e,this._pagination.reload()}},{key:"triggerSearch",value:function(){e.search("search",this.searchText),this._pagination.search=this.searchText,this._pagination.reload()}},{key:"_intialSearch",value:function(){var t=e.search();return _.isEmpty(t)?void 0:t.search}}]),i}()}t.$inject=["$location","Pagination","SpinnerState"],e.module("alephServices.paginationComponents",[]).service("PaginationComponents",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";var t=function(){function e(){_classCallCheck(this,e),this._parameterRegex=function(){return/\{\s*([^{}]+?)\s*}/g}}return _createClass(e,[{key:"constructParameter",value:function(e){return{name:e,type:"raw"}}},{key:"detectParameters",value:function(e,t){var n=this,i=e.match(this._parameterRegex());_.exists(i)&&i.forEach(function(e){var i=n._parameterRegex().exec(e)[1];n._parameterExists(t,i)&&t.push(n.constructParameter(i))})}},{key:"_parameterExists",value:function(e,t){return-1===_.findIndex(e,function(e){return e.name===t})}}]),e}();e.module("alephServices.parameterMethods",[]).service("ParameterMethods",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";var t=function(){function e(t){_classCallCheck(this,e),this.collection=[],this._resource=t("/roles.json")}return _createClass(e,[{key:"initCollection",value:function(){var e=this;return this._resource.query().$promise.then(function(t){return e.collection=t,t})}}]),e}();t.$inject=["$resource"],e.module("alephServices.roleModel",[]).service("RoleModel",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";function t(e,t,n,i){return function(){function r(){_classCallCheck(this,r),this._columns=new t,this.loadColumnData()}return _createClass(r,[{key:"loadColumnData",value:function(){var e=this;this._columns.initCollection().then(function(t){e._rawColumnsData=t,e._matcherRunner=new n(i,_.map(t,function(e){return e.item}))})}},{key:"isLoaded",value:function(){return _.exists(this._rawColumnsData)&&this._rawColumnsData.length>0}},{key:"getCompletions",value:function(t,n,i,r,o){if(0===r.length)return void o(null,[]);var a=e(n,i),s=a.currentClause,l=this._makeIsSubstringFn(a.fromClause),u=_(this._columns.uniqueTables).filter(l),c=_(this._columns.uniqueSchemas).filter(l);if(_.exists(this._matcherRunner)){var d=this._matcherRunner.execute(s,{tableRestrict:u,schemaRestrict:c},r);o(null,d)}}},{key:"_makeIsSubstringFn",value:function(e){return function(t){return _.exists(e)?e.indexOf(t)>-1:!1}}}]),r}()}t.$inject=["aceSqlParse","SchemaColumns","MatcherRunner","SCHEMA_MATCHERS"],e.module("alephServices.schemaCompleter",["aleph.schemaCompleterConfig"]).service("SchemaCompleter",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";var t=function(){function e(t){_classCallCheck(this,e),this._items=this._makeItemsFn(t.items,t.iteratee),this._itemField=t.itemField,this.selectedTags=[]}return _createClass(e,[{key:"add",value:function(e){var t=this;_.each(this._items(),function(n){n[t._itemField].unshift(e.text)})}},{key:"remove",value:function(e){var t=this;_.each(this._items(),function(n){n[t._itemField]=_.reject(n[t._itemField],function(t){return e.text===t})})}},{key:"onSelection",value:function(){var e=this;this.selectedTags=_.reduce(this._items(),function(t,n){return _.uniq(t.concat(n[e._itemField]))},[])}},{key:"_makeItemsFn",value:function(e,t){var n=_.isFunction(e)?e:function(){return e},i=t;return _.isFunction(i)?function(){return _.map(n(),i)}:n}}]),e}();e.module("alephServices.selectionTagInput",[]).service("SelectionTagInput",function(){return t})}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";var t=function(){function e(){_classCallCheck(this,e),this.configurations={}}return _createClass(e,[{key:"setConfigs",value:function(e){this.configurations=JSON.parse(e)}}]),e}();e.module("alephServices.serverConfigurations",[]).service("ServerConfigurations",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";var t=function(){function e(t){_classCallCheck(this,e),this.context=t,this.active=!1}return _createClass(e,[{key:"on",value:function(){this.active=!0}},{key:"off",value:function(){this.active=!1}}]),e}(),n=function(){function e(){_classCallCheck(this,e),this._spinnersMap={}}return _createClass(e,[{key:"withContext",value:function(e){return _.has(this._spinnersMap,e)||(this._spinnersMap[e]=new t(e)),this._spinnersMap[e]}},{key:"isActive",value:function(){return _.some(this._spinners(),function(e){return e.active})}},{key:"_spinners",value:function(){return _.values(this._spinnersMap)}}]),e}();e.module("alephServices.spinnerState",[]).service("SpinnerState",n)}(angular),function(e){"use strict";e.module("alephServices.tagResource",[]).factory("TagResource",["$resource",function(e){return e("/tags/:id.json",{id:"@id"},{index:{method:"GET",isArray:!0,responseType:"json"}})}])}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";var t=function(){function e(t){_classCallCheck(this,e),this._models=t}return _createClass(e,[{key:"dirtyItems",value:function(){return _.filter(this._models(),function(e){return e.isDirty()})}},{key:"isDirty",value:function(){return this.dirtyItems().length>0}},{key:"isPristine",value:function(){return!this.isDirty()}},{key:"revert",value:function(){_.each(this._models(),function(e){e.revert()})}}]),e}();e.module("models.collectionDirtyAwareness",[]).service("CollectionDirtyAwareness",function(){
148
+ return t})}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";function t(e){return function(){function t(e,n){_classCallCheck(this,t),this.collection=[],this._resource=e,this._Model=n}return _createClass(t,[{key:"internalize",value:function(e){_.exists(e)&&_.isArray(e)&&e.length>0?this.collection=_.map(e,this._toModel.bind(this)):this.collection=[]}},{key:"initCollection",value:function(e){var t=this;return this._resource.index(e).$promise.then(function(e){return t.internalize(e),t.collection})}},{key:"save",value:function(e,t){return this._saveCollection(e,t,this.collection)}},{key:"add",value:function(e){var t=this._toModel(e);return this.collection.unshift(t),t}},{key:"remove",value:function(e){var t=_.map(this.collection,function(e){return e.item.id}).indexOf(e.id);return this.collection.splice(t,1)[0]}},{key:"items",value:function(){return _.map(this.collection,function(e){return e.item})}},{key:"_saveCollection",value:function(t,n,i){return e.all(_.map(i,function(e){return e.save(t)})).then(this.initCollection.bind(this,n))}},{key:"_toModel",value:function(e){var t=new this._Model;return t.internalize(e),t}},{key:"Model",get:function(){return this._Model}}]),t}()}t.$inject=["$q"],e.module("models.collectionModelBase",[]).service("CollectionModelBase",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),_get=function(e,t,n){for(var i=!0;i;){var r=e,o=t,a=n;s=u=l=void 0,i=!1,null===r&&(r=Function.prototype);var s=Object.getOwnPropertyDescriptor(r,o);if(void 0!==s){if("value"in s)return s.value;var l=s.get;return void 0===l?void 0:l.call(a)}var u=Object.getPrototypeOf(r);if(null===u)return void 0;e=u,t=o,n=a,i=!0}};!function(e){"use strict";function t(e,t){return function(t){function n(t,i){var r=this;_classCallCheck(this,n),_get(Object.getPrototypeOf(n.prototype),"constructor",this).call(this,t,i),this._collectionDirtyAwareness=new e(function(){return r.collection}),this.dirtyItems=this._collectionDirtyAwareness.dirtyItems.bind(this._collectionDirtyAwareness),this.isDirty=this._collectionDirtyAwareness.isDirty.bind(this._collectionDirtyAwareness),this.isPristine=this._collectionDirtyAwareness.isPristine.bind(this._collectionDirtyAwareness),this.revert=this._collectionDirtyAwareness.revert.bind(this._collectionDirtyAwareness)}return _inherits(n,t),_createClass(n,[{key:"save",value:function(e,t){return this._saveCollection(e,t,this.dirtyItems())}}]),n}(t)}t.$inject=["CollectionDirtyAwareness","CollectionModelBase"],e.module("models.dirtyAwareCollectionModel",[]).service("DirtyAwareCollectionModel",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),_get=function(e,t,n){for(var i=!0;i;){var r=e,o=t,a=n;s=u=l=void 0,i=!1,null===r&&(r=Function.prototype);var s=Object.getOwnPropertyDescriptor(r,o);if(void 0!==s){if("value"in s)return s.value;var l=s.get;return void 0===l?void 0:l.call(a)}var u=Object.getPrototypeOf(r);if(null===u)return void 0;e=u,t=o,n=a,i=!0}};!function(e){"use strict";function t(e,t){return function(e){function n(e,i,r){_classCallCheck(this,n),_get(Object.getPrototypeOf(n.prototype),"constructor",this).call(this,e),this.modelState=new t(i,r)}return _inherits(n,e),_createClass(n,[{key:"isPristine",value:function(){return this.isNew()?!0:this.isPersisted()?this.modelState.isPristine(this.item):!1}},{key:"isDirty",value:function(){return!this.isPristine()}},{key:"revert",value:function(){this._item=this.modelState.snapshot}},{key:"isValidForSave",value:function(){return this.isNew()||!this.isPersisted()||this.modelState.isDirty(this.item)}},{key:"item",set:function(e){this._item=e,this.modelState&&this.modelState.snapshotItem(this._item)},get:function(){return this._item}}]),n}(e)}t.$inject=["ModelBase","ModelState"],e.module("models.dirtyAwareModel",[]).service("DirtyAwareModel",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";function t(t){return function(){function n(e){_classCallCheck(this,n),this._resource=e,this.item={}}return _createClass(n,[{key:"internalize",value:function(e){e?this.item=e:this.item={}}},{key:"initItem",value:function(e){return e?this.fetch({id:e}):(this.item=this._newItem(),t.when(this.item))}},{key:"save",value:function(e){return this.isPersisted()?this.update(_.merge(this.item,e)):this.create(_.merge(this.item,e))}},{key:"destroy",value:function(){return this._resource.destroy({id:this.item.id}).$promise.then(function(e){return e})}},{key:"clone",value:function i(){var i=e.copy(this);return i._item.id=void 0,i}},{key:"fetch",value:function(e){var t=this;return this._resource.show(e).$promise.then(function(e){return t.item=e,t.item})}},{key:"update",value:function(e){var t=this;return this._resource.update(e).$promise.then(function(e){return t.item=e,t.item})}},{key:"create",value:function(e){var t=this;return this._resource.create(e).$promise.then(function(e){return t.item=e,t.item})}},{key:"isPersisted",value:function(){return _.exists(this.item.id)}},{key:"isNew",value:function(){return JSON.stringify(this.item)===JSON.stringify(this._newItem())}},{key:"_newItem",value:function(){throw"#_newItem must be implemented in subclasses!"}}]),n}()}t.$inject=["$q"],e.module("models.modelBase",[]).service("ModelBase",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";var t=function(){function t(e){var n=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];_classCallCheck(this,t),this._fields=e,this._comparators=this._defaultComparators(e,n)}return _createClass(t,[{key:"snapshotItem",value:function(t){this._snapshot=e.copy(t)}},{key:"isPristine",value:function(e){var t=this;return _.every(this._fields,function(n){return t._comparators[n](t._resolve(n,e),t._resolve(n,t._snapshot))})}},{key:"isDirty",value:function(e){return!this.isPristine(e)}},{key:"_resolve",value:function(e,t){var n=arguments.length<=2||void 0===arguments[2]?!0:arguments[2];return e.split(".").reduce(function(e,t){return n?e?e[t]:void 0:e[t]},t||this)}},{key:"_defaultComparators",value:function(e,t){var n={};return _.each(e,function(e){n[e]=t[e]||function(e,t){return JSON.stringify(e)===JSON.stringify(t)}}),n}},{key:"snapshot",get:function(){return e.copy(this._snapshot)}}]),t}();e.module("models.modelState",[]).service("ModelState",function(){return t})}(angular),!function(e){"use strict";e.module("models",["models.collectionDirtyAwareness","models.dirtyAwareCollectionModel","models.dirtyAwareModel","models.modelState","models.collectionModelBase","models.modelBase","models.unpersistedModel"])}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";var t=function(){function e(){_classCallCheck(this,e),this.item={}}return _createClass(e,[{key:"internalize",value:function(e){this.item=e}},{key:"save",value:function(){throw"Cannot save an unpersisted model"}}]),e}();e.module("models.unpersistedModel",[]).service("UnpersistedModel",function(){return t})}(angular);var _get=function(e,t,n){for(var i=!0;i;){var r=e,o=t,a=n;s=u=l=void 0,i=!1,null===r&&(r=Function.prototype);var s=Object.getOwnPropertyDescriptor(r,o);if(void 0!==s){if("value"in s)return s.value;var l=s.get;return void 0===l?void 0:l.call(a)}var u=Object.getPrototypeOf(r);if(null===u)return void 0;e=u,t=o,n=a,i=!0}};!function(e){"use strict";function t(e,t){this.makeCollectionModel=function(e,n,i){return function(t){function r(){_classCallCheck(this,r),_get(Object.getPrototypeOf(r.prototype),"constructor",this).call(this,e,i,n)}return _inherits(r,t),r}(t)},this.makeModel=function(t,n,i){var r=arguments.length<=3||void 0===arguments[3]?{}:arguments[3],o=r.dirtyAwareFields||_.keys(n),a=r.dirtyAwareComparators;return function(e){function r(){_classCallCheck(this,r),_get(Object.getPrototypeOf(r.prototype),"constructor",this).call(this,t,i,n,o,a)}return _inherits(r,e),r}(e)}}t.$inject=["StandardModel","StandardCollectionModel"],e.module("modelGeneration.modelFactory",[]).service("ModelFactory",t)}(angular),!function(e){"use strict";e.module("modelGeneration",["modelGeneration.modelFactory","modelGeneration.modelManager","modelGeneration.resourceFactory","modelGeneration.standardModel","modelGeneration.standardCollectionModel"])}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";var t=function(){function e(t,n,i){_classCallCheck(this,e),this._ModelFactory=t,this._ResourceFactory=n,this._definitions=i,this._resources={},this._modelClasses={},this._collectionModelClasses={}}return _createClass(e,[{key:"forModelName",value:function(e){var t=this,n=this._definitions[e],i=this._loadResource(e,n.resource);return{resource:function(){return i},modelClass:function(){return t._loadModelClass(e,n.newItem,i,n.options)},collectionClass:function(n){return t._loadCollectionModelClass(pluralize.plural(e),n,i)}}}},{key:"_loadCollectionModelClass",value:function(e,t,n){return this._load(this._collectionModelClasses,e,this._ModelFactory.makeCollectionModel,this._ModelFactory,e,t,n)}},{key:"_loadModelClass",value:function(e,t,n,i){return this._load(this._modelClasses,e,this._ModelFactory.makeModel,this._ModelFactory,e,t,n,i)}},{key:"_loadResource",value:function(e,t){var n=this._capitalize(e)+"Resource";return this._load(this._resources,n,this._ResourceFactory.make,this._ResourceFactory,t.path,t.parameters,t.actions)}},{key:"_load",value:function(e,t,n,i){var r=e[t];if(!_.exists(r)){for(var o=arguments.length,a=Array(o>4?o-4:0),s=4;o>s;s++)a[s-4]=arguments[s];r=n.apply(i,a),e[t]=r}return r}},{key:"_capitalize",value:function(e){return e.charAt(0).toUpperCase()+e.slice(1)}}]),e}();t.$inject=["ModelFactory","ResourceFactory","ModelDefinitions"],e.module("modelGeneration.modelManager",[]).service("ModelManager",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";var t=function(){function e(t){_classCallCheck(this,e),this._defaultActions={update:{method:"PUT"},create:{method:"POST"},show:{method:"GET"},index:{method:"GET",isArray:!0,responseType:"json"},destroy:{method:"DELETE"}},this._$resource=t}return _createClass(e,[{key:"make",value:function(e,t){var n=arguments.length<=2||void 0===arguments[2]?{}:arguments[2];return this._$resource(e,t,_.merge(this._defaultActions,n))}}]),e}();t.$inject=["$resource"],e.module("modelGeneration.resourceFactory",[]).service("ResourceFactory",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),_get=function(e,t,n){for(var i=!0;i;){var r=e,o=t,a=n;s=u=l=void 0,i=!1,null===r&&(r=Function.prototype);var s=Object.getOwnPropertyDescriptor(r,o);if(void 0!==s){if("value"in s)return s.value;var l=s.get;return void 0===l?void 0:l.call(a)}var u=Object.getPrototypeOf(r);if(null===u)return void 0;e=u,t=o,n=a,i=!0}};!function(e){"use strict";function t(e,t){return function(e){function n(e,i,r){var o=this;_classCallCheck(this,n),_get(Object.getPrototypeOf(n.prototype),"constructor",this).call(this,i,r),this._handler=new t(e,{modelCollection:function(){return o.collection}})}return _inherits(n,e),_createClass(n,[{key:"initCollection",value:function(e){return this._handler.wrapInitCollection(_get(Object.getPrototypeOf(n.prototype),"initCollection",this).bind(this,e))}},{key:"save",value:function(e,t){return this._handler.wrapCollectionSave(_get(Object.getPrototypeOf(n.prototype),"save",this).bind(this,e,t))}}]),n}(e)}t.$inject=["DirtyAwareCollectionModel","ActionHandler"],e.module("modelGeneration.standardCollectionModel",["models"]).service("StandardCollectionModel",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),_get=function(e,t,n){for(var i=!0;i;){var r=e,o=t,a=n;s=u=l=void 0,i=!1,null===r&&(r=Function.prototype);var s=Object.getOwnPropertyDescriptor(r,o);if(void 0!==s){if("value"in s)return s.value;var l=s.get;return void 0===l?void 0:l.call(a)}var u=Object.getPrototypeOf(r);if(null===u)return void 0;e=u,t=o,n=a,i=!0}};!function(e){"use strict";function t(t,n){return function(t){function i(e,t,r,o,a){var s=this;_classCallCheck(this,i),_get(Object.getPrototypeOf(i.prototype),"constructor",this).call(this,t,o,a),this._handler=new n(e,{modelItem:function(){return s.item}}),this._newItemObj=r}return _inherits(i,t),_createClass(i,[{key:"fetch",value:function(e){return this._handler.wrapFetch(_get(Object.getPrototypeOf(i.prototype),"fetch",this).bind(this,e))}},{key:"destroy",value:function(){return this._handler.wrapDestroy(_get(Object.getPrototypeOf(i.prototype),"destroy",this).bind(this))}},{key:"update",value:function(e){return this._handler.wrapUpdate(_get(Object.getPrototypeOf(i.prototype),"update",this).bind(this,e))}},{key:"create",value:function(e){return this._handler.wrapCreate(_get(Object.getPrototypeOf(i.prototype),"create",this).bind(this,e))}},{key:"_newItem",value:function(){return e.copy(this._newItemObj)}}]),i}(t)}t.$inject=["DirtyAwareModel","ActionHandler"],e.module("modelGeneration.standardModel",["models"]).service("StandardModel",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),_get=function(e,t,n){for(var i=!0;i;){var r=e,o=t,a=n;s=u=l=void 0,i=!1,null===r&&(r=Function.prototype);var s=Object.getOwnPropertyDescriptor(r,o);if(void 0!==s){if("value"in s)return s.value;var l=s.get;return void 0===l?void 0:l.call(a)}var u=Object.getPrototypeOf(r);if(null===u)return void 0;e=u,t=o,n=a,i=!0}};!function(e){"use strict";function t(e,t,n,i){return function(n){function r(){_classCallCheck(this,r),_get(Object.getPrototypeOf(r.prototype),"constructor",this).call(this,"query",e,{title:"",tags:[],version:{body:"",parameters:[]}},["title","version.body","roles","tags"])}return _inherits(r,n),_createClass(r,[{key:"initItem",value:function(e,t){return e&&t?_get(Object.getPrototypeOf(r.prototype),"fetch",this).call(this,{id:e,version_id:t}):(this.item=this._newItem(),i.when(this.item))}},{key:"detectParameters",value:function(){t.detectParameters(this.item.version.body,this.item.version.parameters)}},{key:"addParameter",value:function(e){var n=t.constructParameter(e);this.item.version.parameters.push(n)}}]),r}(n)}t.$inject=["QueryResource","ParameterMethods","StandardModel","$q"],e.module("alephServices.query",[]).service("Query",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";var t=function(){function e(t,n,i){_classCallCheck(this,e),this._alertFlash=n,this._$location=t,this._$q=i}return _createClass(e,[{key:"success",value:function(e,t,n){var i=e||"action",r=_.exists(t)?t:!1;return this._alertFlash.emitSuccess('Query "'+n.item.title+'" '+i+"d!",r),n}},{key:"handleReplExit",value:function(e){return"QueryReplExit"!==e?this._$q.reject(e):void this._alertFlash.emitInfo("Exited editing REPL without saving",!1)}},{key:"navigateToLatestVersion",value:function(e){return this._$location.path("/queries/"+e.item.id+"/query_versions/"+e.item.version.id),e}},{key:"navigateToIndex",value:function(){this._$location.path("/queries")}}]),e}();t.$inject=["$location","AlertFlash","$q"],e.module("alephServices.queryHandler",[]).service("QueryHandler",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";var t=function(){function e(t,n,i,r,o){_classCallCheck(this,e),this._Query=n,this._QueryVersion=i,this._Results=r,this._VisualizationService=o,this._$routeParams=t}return _createClass(e,[{key:"initialize",value:function(){this.query=new this._Query,this.queryVersions=new this._QueryVersion,this.results=new this._Results,this.queryId=this._$routeParams.query_id,this.queryVersionId=this._$routeParams.query_version_id||"latest"}},{key:"load",value:function(){return this.query.initItem(this.queryId,this.queryVersionId).then(this.loadQueryVersions.bind(this)).then(this.loadResults.bind(this)).then(this.loadVisualizations.bind(this))}},{key:"loadQueryVersions",value:function(e){return this.queryVersions.initCollection(e.id).then(function(t){return{query:e,queryVersions:t}})}},{key:"loadResults",value:function(e){var t=e.query;return this.results.initCollection({query_id:t.id,query_version_id:t.version.id}).then(function(t){return _.merge(e,{results:t})})}},{key:"loadVisualizations",value:function(e){var t=e.query;return this._VisualizationService.load(t.id,t.version.id).then(function(t){return _.merge(e,{visualizations:t})})}}]),e}();t.$inject=["$routeParams","Query","QueryVersions","Results","VisualizationService"],e.module("alephServices.queryLoader",[]).service("QueryLoader",t)}(angular),!function(e){"use strict";function t(){function t(e,t){var n=t[e];return _.exists(n)&&(t[e]=_.map(n,function(e){return _.exists(e.text)?e.text:e})),t}var n=["id","title","body","tags","result_id","version","roles"];return[function(e){return t("tags",e)},function(e){return t("roles",e)},function(e){return{query:_.selectKeys(e,n)}},e.toJson]}e.module("alephServices.queryRequestTransformers",[]).service("QueryRequestTransformers",t)}(angular),!function(e){"use strict";function t(e,t){return e.make("/queries/:id.json",{id:"@id"},{update:{method:"PUT",transformRequest:t},create:{method:"POST",transformRequest:t}})}t.$inject=["ResourceFactory","QueryRequestTransformers"],e.module("alephServices.queryResource",[]).service("QueryResource",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";var t=function(){function e(t){_classCallCheck(this,e),this._initTabs(),this.$location=t,this._defaultTab="query"}return _createClass(e,[{key:"setActiveTabFromUrl",value:function(){this._activateTab(this.getTab())}},{key:"navigateToTab",value:function(e){this._activateTab(e),this.setTab(e)}},{key:"setTab",value:function(e){this.$location.search("tab",e)}},{key:"getTab",value:function(){var e=this.$location.search().tab;return"visualizations"===e||"results"===e?e:"query"}},{key:"_initTabs",value:function(){this.state={query:{active:!1},results:{active:!1},visualizations:{active:!1}}}},{key:"_activateTab",value:function(e){this._initTabs(),this.state[e].active=!0}},{key:"defaultTag",set:function(e){this._defaultTab=e},get:function(){return this._defaultTab}}]),e}();t.$inject=["$location"],e.module("alephServices.queryTab",[]).service("QueryTab",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),_get=function(e,t,n){for(var i=!0;i;){var r=e,o=t,a=n;s=u=l=void 0,i=!1,null===r&&(r=Function.prototype);var s=Object.getOwnPropertyDescriptor(r,o);if(void 0!==s){if("value"in s)return s.value;var l=s.get;return void 0===l?void 0:l.call(a)}var u=Object.getPrototypeOf(r);if(null===u)return void 0;e=u,t=o,n=a,i=!0}};!function(e){"use strict";function t(e,t,n){return function(t){function i(){_classCallCheck(this,i),_get(Object.getPrototypeOf(i.prototype),"constructor",this).call(this,{index:e("/queries/:id/query_versions/:query_version_id.json").query},n)}return _inherits(i,t),_createClass(i,[{key:"initCollection",value:function(e){return _get(Object.getPrototypeOf(i.prototype),"initCollection",this).call(this,{id:e})}}]),i}(t)}t.$inject=["$resource","CollectionModelBase","UnpersistedModel"],e.module("alephServices.queryVersions",[]).service("QueryVersions",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),_get=function(e,t,n){for(var i=!0;i;){var r=e,o=t,a=n;s=u=l=void 0,i=!1,null===r&&(r=Function.prototype);var s=Object.getOwnPropertyDescriptor(r,o);if(void 0!==s){if("value"in s)return s.value;var l=s.get;return void 0===l?void 0:l.call(a)}var u=Object.getPrototypeOf(r);if(null===u)return void 0;e=u,t=o,n=a,i=!0}};!function(e){"use strict";function t(e,t){var n=e.forModelName("result").modelClass();return function(e){function n(){_classCallCheck(this,n),_get(Object.getPrototypeOf(n.prototype),"constructor",this).call(this),this.poller=new t(this)}return _inherits(n,e),_createClass(n,[{key:"save",value:function(e,t,i){var r=_.merge({query_id:e,query_version_id:t},i||{});return _get(Object.getPrototypeOf(n.prototype),"create",this).call(this,r)}}]),n}(n)}t.$inject=["ModelManager","ResultPoller"],e.module("alephServices.result",[]).service("Result",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";function t(e){return function(){function t(e){_classCallCheck(this,t),this._result=e}return _createClass(t,[{key:"poll",value:function(){var t=this._result.item;this.pollingKey="result_"+t.id+"_"+(new Date).getTime(),e.poll(t,this.pollingKey,function(){return"complete"===t.status||"failed"===t.status?!0:!1})}},{key:"unPoll",value:function(){e.unPoll(this.pollingKey)}}]),t}()}t.$inject=["PollService"],e.module("alephServices.resultPoller",[]).service("ResultPoller",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";function t(e){return function(){function t(e,n){var i=arguments.length<=2||void 0===arguments[2]?{}:arguments[2];_classCallCheck(this,t),this.sandbox=i.sandbox,this.substitutionValues=i.substitutionValues||{},this.results=n,this.query=e,this.enableAlert=i.enableAlert||!1,this.enablePolling=i.enablePolling||!1}return _createClass(t,[{key:"run",value:function(){var t=this,n=this.results.Model,i=new n;return i.save(this.queryId,this.queryVersionId,{substitution_values:this.substitutionValues,body:this.body,parameters:this.parameters,sandbox:this.sandbox}).then(function(n){t.enableAlert&&e.emitInfo("Started running result, id = "+n.id);var i=t.results.add(n);return t.enablePolling&&i.poller.poll(),n})}},{key:"queryId",get:function(){return this.sandbox?void 0:this.query.item.id}},{key:"queryVersionId",get:function(){return this.sandbox?void 0:this.query.item.version.id}},{key:"body",get:function(){return this.sandbox?this.query.item.version.body:void 0}},{key:"parameters",get:function(){return this.sandbox?this.query.item.version.parameters:void 0}}]),t}()}t.$inject=["AlertFlash"],e.module("alephServices.resultRunner",[]).service("ResultRunner",t)}(angular),!function(e){"use strict";function t(e,t){return t.forModelName("result").collectionClass(e)}t.$inject=["Result","ModelManager"],e.module("alephServices.results",[]).service("Results",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";function t(e,t,n){return function(){function i(){_classCallCheck(this,i),this.modelState=new t(["comment_text"]),this.item={}}return _createClass(i,[{key:"internalize",value:function(e){this.item=e}},{key:"isPersisted",value:function(){return _.exists(this.item.comment_id)}},{key:"isNew",value:function(){return!_.exists(this.item.comment_text)||0===this.item.comment_text.length}},{key:"isPristine",value:function(){return this.isNew()?!0:this.isPersisted()?this.modelState.isPristine(this.item):!1}},{key:"isDirty",value:function(){return!this.isPristine()}},{key:"isValidForSave",value:function(){return!this.isPersisted()||this.modelState.isDirty(this.item)}},{key:"save",value:function(){var t=this._toCommentObject(),i=n.emitError.bind(n,"Failed to save comment, id = "+t.id);return this.isPersisted()?e.update(t).$promise.then(this._internalizeCommentInfo.bind(this))["catch"](i):this.modelState.isDirty(this.item)?e.create(t).$promise.then(this._internalizeCommentInfo.bind(this))["catch"](i):void 0}},{key:"_internalizeCommentInfo",value:function(e){return this._item.comment_id=e.id,this._item.comment_text=e.text,this.modelState.snapshotItem(this._item),e}},{key:"_toCommentObject",value:function(){return{id:this.item.comment_id,text:this.item.comment_text,schema:this.item.schema,table:this.item.table,column:this.item.column,target_type:this.item.type}}},{key:"item",set:function(e){this._item=e,this.modelState.snapshotItem(this._item)},get:function(){return this._item}}]),i}()}t.$inject=["SchemaCommentResource","ModelState","AlertFlash"],e.module("alephServices.schema.column",[]).service("SchemaColumn",t)}(angular),!function(e){"use strict";function t(e){return e.make("/columns/:id.json",{id:"@id"})}t.$inject=["ResourceFactory"],e.module("alephServices.schema.columnResource",[]).service("SchemaColumnResource",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),_get=function(e,t,n){for(var i=!0;i;){var r=e,o=t,a=n;s=u=l=void 0,i=!1,null===r&&(r=Function.prototype);var s=Object.getOwnPropertyDescriptor(r,o);if(void 0!==s){if("value"in s)return s.value;var l=s.get;return void 0===l?void 0:l.call(a)}var u=Object.getPrototypeOf(r);if(null===u)return void 0;e=u,t=o,n=a,i=!0}};!function(e){"use strict";function t(e,t,n){return function(t){function i(){_classCallCheck(this,i),_get(Object.getPrototypeOf(i.prototype),"constructor",this).call(this,e,n),this.uniqueSchemas=[],this.uniqueTables=[],this.uniqueColumns=[],this.schemaTables={}}return _inherits(i,t),_createClass(i,[{key:"initCollection",value:function(){return _get(Object.getPrototypeOf(i.prototype),"initCollection",this).call(this).then(this._processUniqueAttributes.bind(this))}},{key:"_processUniqueAttributes",value:function(e){var t=this,n=[],i=[],r=[];return _.each(e,function(e){n.push(e.item.column),i.push(e.item.table),r.push(e.item.schema),t._addToSchemaTables(e)}),this.uniqueColumns=_.uniq(n),this.uniqueTables=_.uniq(i),this.uniqueSchemas=_.uniq(r),e}},{key:"_addToSchemaTables",value:function(e){var t=this.schemaTables[e.item.schema];t||(t=[],this.schemaTables[e.item.schema]=t),_.contains(t,e.item.table)||t.push(e.item.table)}}]),i}(t)}t.$inject=["SchemaColumnResource","CollectionModelBase","UnpersistedModel"],e.module("alephServices.schema.columns",[]).service("SchemaColumns",t)}(angular),!function(e){"use strict";function t(e){return e.make("/schema_comments/:id.json",{id:"@id"})}t.$inject=["ResourceFactory"],e.module("alephServices.schema.commentResource",[]).service("SchemaCommentResource",t)}(angular),!function(e){"use strict";e.module("alephServices",["ngResource","alephServices.queryRequestTransformers","alephServices.queryResource","alephServices.queryHandler","alephServices.queryVersions","alephServices.queryTab","alephServices.query","alephServices.queryLoader","alephServices.visualizationService","alephServices.visualization","alephServices.visualizations","alephServices.sourceRenderer","alephServices.results","alephServices.result","alephServices.resultRunner","alephServices.resultPoller","alephServices.alertResource","alephServices.alert","alephServices.aceSnippetManager","models","modelGeneration","alephServices.schema.columns","alephServices.schema.columnResource","alephServices.schema.column","alephServices.schema.commentResource","alephServices.roleModel","alephServices.schemaCompleter","alephServices.alertFlash","alephServices.pageTitleManager","alephServices.navigationGuard","alephServices.aceCompleters","alephServices.selectionTagInput","alephServices.paginationComponents","alephServices.pagination","alephServices.openReplService","alephServices.matcherRunner","alephServices.actionHandler","alephServices.aceSqlParse","alephServices.pollService","alephServices.lockService","alephServices.localResource","alephServices.githubUrlService","alephServices.defaultAceConfigurator","alephServices.parameterMethods","alephServices.tagResource","alephServices.keywordCompleter","alephServices.spinnerState","alephServices.serverConfigurations"]).constant("defaultDateFormat","yyyy-MM-dd").constant("ApplicationTitle","Aleph").constant("ModelDefinitions",{result:{newItem:{sample_data:[],row_count:0,parameters:[],headers:[]},resource:{path:"/results/:id.json",parameters:{id:"@id"},actions:{index:{method:"GET",isArray:!0,url:"/queries/:query_id/query_versions/:query_version_id/results.json"}}}},snippet:{newItem:{name:"",content:""},resource:{path:"/snippets/:id.json",parameters:{id:"@id"}}},visualization:{newItem:{html_source:"",title:""},resource:{path:"/visualizations/:id.json",parameters:{id:"@id"},actions:{index:{method:"GET",isArray:!0,url:"/queries/:query_id/query_versions/:query_version_id/visualizations.json"}}}}}).service("getResultCsv",["$http","$window",function(e,t){return function(n){var i=arguments.length<=1||void 0===arguments[1]?"The CSV file for this result was not found.":arguments[1];e.get("/result_csvs/"+n+".json").success(function(e){return t.open(e.url,"_self",""),e}).error(function(){t.alert(i)})}}])}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";var t=function(){function e(){_classCallCheck(this,e),this._context="pgsql",this._aceSnippetManager=ace.require("ace/snippets").snippetManager}return _createClass(e,[{key:"add",value:function(e,t){this._aceSnippetManager.register(this._parseSnippet(e,t),this._context);
149
+ }},{key:"remove",value:function(e,t){this._aceSnippetManager.unregister(this._parseSnippet(e,t),this._context)}},{key:"reset",value:function(){this._aceSnippetManager.snippetMap={},this._aceSnippetManager.snippetNameMap={}}},{key:"_parseSnippet",value:function(e,t){var n="snippet "+e+" \n "+this._transformNewlines(t);return this._aceSnippetManager.parseSnippetFile(n)}},{key:"_transformNewlines",value:function(e){return e.replace(/(\r\n|\n|\r)/gm,"\n ")}},{key:"context",set:function(e){this._context=e},get:function(){return this._context}}]),e}();e.module("alephServices.aceSnippetManager",[]).service("AceSnippetManager",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";var t=function(){function e(t){_classCallCheck(this,e),this._visualization=t}return _createClass(e,[{key:"setTemplate",value:function(e){this._compiledTemplate=_.template(e)}},{key:"setResults",value:function(e){this.results=e}},{key:"latestResult",value:function t(){var t=void 0;return _(this.results.items()).sortBy("id").reverse().forEach(function(e){_.exists(t)||"complete"!==e.status||(t=e)}),t}},{key:"isValid",value:function(){return this._visualization.hasSource()&&this.latestResult()&&_.exists(this._compiledTemplate)}},{key:"rendered",value:function(){var e=this.latestResult();return this._visualization.hasSource()&&e&&_.exists(this._compiledTemplate)?(this._internalizeToLocalStorage(e),this._compiledTemplate({result_id:e.id,panel:"#chart-panel",body:this._visualization.item.html_source})):null}},{key:"_internalizeToLocalStorage",value:function(e){SerializedStorage.set("DATASET",e.sample_data),SerializedStorage.set("COLUMNS",this._toColumns(e.headers,e.sample_data)),SerializedStorage.set("HEADERS",e.headers)}},{key:"_toColumns",value:function(e,t){var n=[];return e.forEach(function(e,i){n.push([e].concat(t.map(function(e){return e[i]})))}),n}}]),e}();e.module("alephServices.sourceRenderer",[]).service("SourceRenderer",function(){return t})}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),_get=function(e,t,n){for(var i=!0;i;){var r=e,o=t,a=n;s=u=l=void 0,i=!1,null===r&&(r=Function.prototype);var s=Object.getOwnPropertyDescriptor(r,o);if(void 0!==s){if("value"in s)return s.value;var l=s.get;return void 0===l?void 0:l.call(a)}var u=Object.getPrototypeOf(r);if(null===u)return void 0;e=u,t=o,n=a,i=!0}};!function(e){"use strict";function t(e){var t=e.forModelName("visualization").modelClass();return function(e){function t(){_classCallCheck(this,t),_get(Object.getPrototypeOf(t.prototype),"constructor",this).call(this),this.hasSource=this.itemHas.bind(this,"html_source"),this.hasTitle=this.itemHas.bind(this,"title")}return _inherits(t,e),_createClass(t,[{key:"itemHas",value:function(e){return Utils.stringHelpers.isPresent(this.item[e])}},{key:"save",value:function(e,t){return this._save(e,t)}},{key:"destroy",value:function(){var e=this;return _get(Object.getPrototypeOf(t.prototype),"destroy",this).call(this).then(function(){return e.initItem()})}},{key:"_save",value:function(e,n){if(this.isPersisted())return _get(Object.getPrototypeOf(t.prototype),"update",this).call(this,this.item);var i=_.merge({query_id:e,query_version_id:n},this.item);return _get(Object.getPrototypeOf(t.prototype),"create",this).call(this,i)}}]),t}(t)}t.$inject=["ModelManager"],e.module("alephServices.visualization",[]).service("Visualization",t)}(angular);var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!function(e){"use strict";var t=function(){function e(t,n,i,r,o){_classCallCheck(this,e),this.visualization=new n,this.visualizations=new i,this.sourceRenderer=new t(this.visualization),this.setResults=this.sourceRenderer.setResults.bind(this.sourceRenderer),this.presetDisplayList=[],this.presets={},this._localResource=new r("visualization"),this._$q=o}return _createClass(e,[{key:"load",value:function(e,t){var n=this;return this.visualizations.initCollection({query_id:e,query_version_id:t}).then(function(e){return _.exists(e[0])?n.visualization.internalize(e[0].item):n.visualization.initItem(),e})}},{key:"initService",value:function(){return this._loadPresets().then(this._loadTemplate.bind(this))}},{key:"_loadTemplate",value:function(){var e=this;return this._localResource.get("template.json").then(function(t){e.sourceRenderer.setTemplate(t.data.template.join("\n"))})}},{key:"_loadPresets",value:function(){var e=this;return this._localResource.get("presets.json").then(function(t){return e.presetDisplayList=_.keys(t.data),t.data}).then(function(t){return e._$q.all(_.mapObject(t,function(t,n){e._localResource.get(t).then(function(t){return e.presets[n]=t.data,t.data})}))})}}]),e}();t.$inject=["SourceRenderer","Visualization","Visualizations","LocalResource","$q"],e.module("alephServices.visualizationService",[]).service("VisualizationService",t)}(angular),!function(e){"use strict";function t(e,t){return t.forModelName("visualization").collectionClass(e)}t.$inject=["Visualization","ModelManager"],e.module("alephServices.visualizations",[]).service("Visualizations",t)}(angular);