diff --git a/app-public.bundle.js.download b/app-public.bundle.js.download new file mode 100644 index 0000000..1998e72 --- /dev/null +++ b/app-public.bundle.js.download @@ -0,0 +1,109851 @@ +/*! + * /* + * * This file is subject to the terms and conditions defined in + * * file 'LICENSE.txt', which is part of this source code package. + * * / + * + */ +/******/ (function() { // webpackBootstrap +/******/ var __webpack_modules__ = ({ + +/***/ "../cljs/cljs.core.js": +/*!****************************!*\ + !*** ../cljs/cljs.core.js ***! + \****************************/ +/***/ (function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +var window=__webpack_require__.g;var $CLJS=__webpack_require__(/*! ./cljs_env */ "../cljs/cljs_env.js");__webpack_require__(/*! ./goog.base.js */ "../cljs/goog.base.js");__webpack_require__(/*! ./goog.string.string.js */ "../cljs/goog.string.string.js"); +var Na,Qa,$a,hb,ib,jb,lb,mb,nb,ob,pb,rb,ub,vb,wb,xb,yb,zb,Ab,Bb,Fb,Gb,Hb,Jb,Kb,Nb,Ob,Pb,Qb,Rb,Sb,Tb,Ub,Vb,Wb,Xb,Yb,$b,cc,ec,fc,gc,hc,kc,lc,mc,nc,pc,qc,sc,tc,uc,xc,Ac,Cc,Ic,Jc,Kc,Fc,Lc,Pc,Qc,Rc,Sc,Tc,Uc,Vc,Wc,$c,ad,bd,cd,hd,Zc,id,sd,Fd,Dd,Ed,Id,Jd,Od,Pd,Qd,Rd,Ud,Xd,be,ce,ee,fe,Bd,je,ke,le,ne,me,oe,pe,ve,Ee,Me,Oe,Qe,Re,Se,Te,Ue,Ve,We,Xe,Ye,$e,Ze,hf,lf,jf,kf,of,pf,qf,rf,sf,tf,vf,xf,zf,Af,Bf,Cf,Ef,Hf,If,Jf,Kf,Lf,Mf,Nf,Of,Pf,Qf,Rf,Sf,Tf,Wf,Uf,Vf,Yf,ag,Zf,$f,bg,eg,cg,dg,fg,ig,jg,kg,df,mg,ef,og,sg,wg,Dg, +Fg,Gg,Lg,Pg,Sg,Ug,Vg,Kg,Xg,Yg,Zg,ih,mh,nh,rh,Ja,wh,yh,Xa,Za,Gh,Hh,Wa,Mg,Va,Og,Bg,Mh,Ya;$CLJS.Ia="cljs.core";$CLJS.Ka=function(a){return function(){return Ja[a].apply(this,arguments)}};$CLJS.La=function(a,b){return Ja[a]=b};$CLJS.Ma=function(a,b){return a>b?1:a>>-15,461845907)}; +tc=function(a,b){a=(a|0)^(b|0);return rc(a<<13|a>>>-13,5)+-430675100|0};uc=function(a,b){a=(a|0)^b;a=rc(a^a>>>16,-2048144789);a=rc(a^a>>>13,-1028477387);return a^a>>>16};xc=function(a){255>2)};$CLJS.r=function(a,b,c,d,e){this.Pa=a;this.name=b;this.rb=c;this.Kb=d;this.Za=e;this.o=2154168321;this.K=4096};$CLJS.Bc=function(a,b,c){this.m=a;this.Ib=b;this.Za=c;this.o=6717441;this.K=0}; +Cc=function(a){return null!=a?a.K&131072||$CLJS.yc===a.Qd?!0:a.K?!1:$CLJS.cb(nc,a):$CLJS.cb(nc,a)};$CLJS.t=function(a){if(null==a)return null;if(null!=a&&(a.o&8388608||$CLJS.yc===a.fd))return a.Y(null);if($CLJS.ab(a)||"string"===typeof a)return 0===a.length?null:new $CLJS.Dc(a,0,null);if(null!=a&&null!=a[Ec])return a=$CLJS.Sa(a,Ec).call(a),Fc.b?Fc.b(a):Fc.call(null,a);if($CLJS.cb(Sb,a))return Tb(a);throw Error([$CLJS.gb.b(a)," is not ISeqable"].join(""));}; +$CLJS.v=function(a){if(null==a)return null;if(null!=a&&(a.o&64||$CLJS.yc===a.Z))return a.Ja(null);a=$CLJS.t(a);return null==a?null:$CLJS.tb(a)};$CLJS.Hc=function(a){return null!=a?null!=a&&(a.o&64||$CLJS.yc===a.Z)?a.Na(null):(a=$CLJS.t(a))?a.Na(null):$CLJS.Gc:$CLJS.Gc};$CLJS.B=function(a){return null==a?null:null!=a&&(a.o&128||$CLJS.yc===a.Yb)?a.Fa(null):$CLJS.t($CLJS.Hc(a))};Ic=function(a){this.ca=a};Jc=function(a){return new Ic($CLJS.t(a))}; +Kc=function(a,b){this.value=a;this.Tb=b;this.qc=null;this.o=8388672;this.K=0};Fc=function(a){var b=a.next();return $CLJS.q(b.done)?null:new Kc(b.value,a)};Lc=function(a){var b=0,c=1;for(a=$CLJS.t(a);;)if(null!=a)b+=1,c=rc(31,c)+$CLJS.zc($CLJS.v(a))|0,a=$CLJS.B(a);else return uc(tc(0,sc(c)),b)};$CLJS.Mc=function(a){var b=0,c=0;for(a=$CLJS.t(a);;)if(null!=a)b+=1,c=c+$CLJS.zc($CLJS.v(a))|0,a=$CLJS.B(a);else return uc(tc(0,sc(c)),b)};$CLJS.Nc=function(a){this.m=a;this.o=32768;this.K=0}; +$CLJS.Oc=function(a){return a instanceof $CLJS.Nc};Pc=function(a){return $CLJS.Ib(a)};Qc=function(a,b){var c=a.aa(null);if(0===c)return b.l?b.l():b.call(null);for(var d=a.ea(null,0),e=1;;)if(e=d)return-1;!(0c&&(c+=d,c=0>c?0:c);for(;;)if(cc?d+c:c;for(;;)if(0<=c){if($CLJS.Xc.a($CLJS.Yc?$CLJS.Yc(a,c):Zc.call(null,a,c),b))return c;--c}else return-1};bd=function(a,b){this.h=a;this.G=b};$CLJS.Dc=function(a,b,c){this.h=a;this.G=b;this.M=c;this.o=166592766;this.K=139264};$CLJS.F=function(a){return 0b)throw Error("Index out of bounds");a:for(;;){if(null== +a)throw Error("Index out of bounds");if(0===b){if($CLJS.t(a)){a=$CLJS.v(a);break a}throw Error("Index out of bounds");}if(Wc(a)){a=$CLJS.gd(a,b);break a}if($CLJS.t(a))a=$CLJS.B(a),--b;else throw Error("Index out of bounds");}return a}if($CLJS.cb(rb,a))return $CLJS.gd(a,b);throw Error(["nth not supported on this type ",$CLJS.gb.b(hb($CLJS.db(a)))].join(""));}; +$CLJS.G=function(a,b,c){if("number"!==typeof b)throw Error("Index argument to nth must be a number.");if(null==a)return c;if(null!=a&&(a.o&16||$CLJS.yc===a.Hc))return a.Ca(null,b,c);if($CLJS.ab(a))return-1b?c:hd(a,b,c);if($CLJS.cb(rb,a))return $CLJS.gd(a,b,c);throw Error(["nth not supported on this type ",$CLJS.gb.b(hb($CLJS.db(a)))].join("")); +};id=function(a,b){this.A=a;this.M=b;this.o=393217;this.K=0};$CLJS.J=function(a,b){return"function"==$CLJS.Ea(a)?new id(a,b):null==a?null:$CLJS.Mb(a,b)};$CLJS.jd=function(a){return null!=a&&(null!=a?a.o&131072||$CLJS.yc===a.bd||(a.o?0:$CLJS.cb(Jb,a)):$CLJS.cb(Jb,a))?Kb(a):null};$CLJS.kd=function(a){return null==a||$CLJS.bb($CLJS.t(a))};$CLJS.ld=function(a){return null==a?!1:null!=a?a.o&8||$CLJS.yc===a.Ld?!0:a.o?!1:$CLJS.cb(pb,a):$CLJS.cb(pb,a)}; +$CLJS.md=function(a){return null==a?!1:null!=a?a.o&4096||$CLJS.yc===a.Xd?!0:a.o?!1:$CLJS.cb(Fb,a):$CLJS.cb(Fb,a)};$CLJS.nd=function(a){return null!=a?a.o&16777216||$CLJS.yc===a.Ic?!0:a.o?!1:$CLJS.cb(Ub,a):$CLJS.cb(Ub,a)};$CLJS.od=function(a){return null==a?!1:null!=a?a.o&1024||$CLJS.yc===a.Td?!0:a.o?!1:$CLJS.cb(Bb,a):$CLJS.cb(Bb,a)};$CLJS.pd=function(a){return null!=a?a.o&67108864||$CLJS.yc===a.Vd?!0:a.o?!1:$CLJS.cb(Wb,a):$CLJS.cb(Wb,a)}; +$CLJS.qd=function(a){return null!=a?a.o&16384||$CLJS.yc===a.Yd?!0:a.o?!1:$CLJS.cb(Gb,a):$CLJS.cb(Gb,a)};$CLJS.rd=function(a){return null!=a?a.K&512||$CLJS.yc===a.Kd?!0:!1:!1};sd=function(a,b,c,d,e){for(;0!==e;)c[d]=a[b],d+=1,--e,b+=1};$CLJS.td=function(a){return null==a?!1:!1===a?!1:!0};$CLJS.vd=function(a,b){return $CLJS.N.c(a,b,ud)===ud?!1:!0}; +$CLJS.xd=function(a,b){if(null!=a?$CLJS.yc===a.Vb||(a.lc?0:$CLJS.cb(zb,a)):$CLJS.cb(zb,a))a=Ab(a,b);else{var c;if(c=null!=a)c=null!=a?a.o&512||$CLJS.yc===a.Tc?!0:a.o?!1:$CLJS.cb(xb,a):$CLJS.cb(xb,a);a=c&&$CLJS.vd(a,b)?new $CLJS.wd(b,$CLJS.N.a(a,b)):null}return a}; +$CLJS.yd=function(a,b){if(a===b)return 0;if(null==a)return-1;if(null==b)return 1;if("number"===typeof a){if("number"===typeof b)return $CLJS.Ma(a,b);throw Error(["Cannot compare ",$CLJS.gb.b(a)," to ",$CLJS.gb.b(b)].join(""));}if(null!=a?a.K&2048||$CLJS.yc===a.Lb||(a.K?0:$CLJS.cb(fc,a)):$CLJS.cb(fc,a))return gc(a,b);if("string"!==typeof a&&!$CLJS.ab(a)&&!0!==a&&!1!==a||$CLJS.db(a)!==$CLJS.db(b))throw Error(["Cannot compare ",$CLJS.gb.b(a)," to ",$CLJS.gb.b(b)].join(""));return $CLJS.Ma(a,b)}; +$CLJS.zd=function(a,b){var c=$CLJS.D(a),d=$CLJS.D(b);if(cd)a=1;else if(0===c)a=0;else a:for(d=0;;){var e=$CLJS.yd($CLJS.Yc(a,d),$CLJS.Yc(b,d));if(0===e&&d+1>1&1431655765;a=(a&858993459)+(a>>2&858993459);return 16843009*(a+(a>>4)&252645135)>>24};Rd=function(a,b){if($CLJS.nd(b))if(Vc(a)&&Vc(b)&&$CLJS.D(a)!==$CLJS.D(b))a=!1;else a:for(a=$CLJS.t(a),b=$CLJS.t(b);;){if(null==a){a=null==b;break a}if(null!=b&&$CLJS.Xc.a($CLJS.v(a),$CLJS.v(b)))a=$CLJS.B(a),b=$CLJS.B(b);else{a=!1;break a}}else a=null;return $CLJS.td(a)};$CLJS.Sd=function(a,b,c,d,e){this.M=a;this.first=b;this.wb=c;this.count=d;this.v=e;this.o=65937646;this.K=8192}; +$CLJS.Td=function(a){return null!=a?a.o&33554432||$CLJS.yc===a.Sd?!0:a.o?!1:$CLJS.cb(Vb,a):$CLJS.cb(Vb,a)};Ud=function(a){this.M=a;this.o=65937614;this.K=8192};$CLJS.Wd=function(a){return(null!=a?a.o&134217728||$CLJS.yc===a.Wd||(a.o?0:$CLJS.cb(Xb,a)):$CLJS.cb(Xb,a))?(a=Yb(a))?a:$CLJS.Gc:$CLJS.Gd($CLJS.Vd,$CLJS.Gc,a)};Xd=function(a,b,c,d){this.M=a;this.first=b;this.wb=c;this.v=d;this.o=65929452;this.K=8192}; +$CLJS.Yd=function(a,b){return null==b?new $CLJS.Sd(null,a,null,1,null):null!=b&&(b.o&64||$CLJS.yc===b.Z)?new Xd(null,a,b,null):new Xd(null,a,$CLJS.t(b),null)};$CLJS.P=function(a,b,c,d){this.Pa=a;this.name=b;this.ga=c;this.Kb=d;this.o=2153775105;this.K=4096};$CLJS.Zd=function(a,b){return a===b?!0:a instanceof $CLJS.P&&b instanceof $CLJS.P?a.ga===b.ga:!1}; +$CLJS.$d=function(a){if(null!=a&&(a.K&4096||$CLJS.yc===a.cd))return a.Xb(null);throw Error(["Doesn't support namespace: ",$CLJS.gb.b(a)].join(""));};$CLJS.ae=function(a,b,c){this.M=a;this.bc=b;this.ca=null;this.v=c;this.o=32374988;this.K=1};be=function(a){null!=a.bc&&(a.ca=a.bc.l?a.bc.l():a.bc.call(null),a.bc=null);return a.ca};ce=function(a){this.sc=a;this.end=0;this.o=2;this.K=0};$CLJS.de=function(a){return new ce(Array(a))}; +ee=function(a,b,c){this.h=a;this.Ia=b;this.end=c;this.o=524306;this.K=0};fe=function(a,b,c,d){this.sb=a;this.hb=b;this.M=c;this.v=d;this.o=31850732;this.K=1536};$CLJS.ge=function(a,b){return 0===mb(a)?b:new fe(a,b,null,null)};$CLJS.he=function(a,b){a.add(b)};$CLJS.ie=function(a){return a.sb()};Bd=function(a){var b=[];for(a=$CLJS.t(a);;)if(null!=a)b.push($CLJS.v(a)),a=$CLJS.B(a);else return b}; +je=function(a,b){if(Vc(b))return $CLJS.D(b);var c=0;for(b=$CLJS.t(b);;)if(null!=b&&ca?0:a-1>>>5<<5};Te=function(a,b,c){for(;;){if(0===b)return c;var d=Re(a);d.h[0]=c;c=d;b-=5}};Ue=function(a,b){throw Error(["No item ",$CLJS.gb.b(a)," in vector of length ",$CLJS.gb.b(b)].join(""));}; +Ve=function(a,b){if(b>=Se(a))return a.Qa;var c=a.root;for(a=a.shift;;)if(0>>a&31];a=d}else return c.h};We=function(a,b){return 0<=b&&bc)return new $CLJS.R(null,c,5,$CLJS.U,a,null);b=32;for(var d=(new $CLJS.R(null,32,5,$CLJS.U,a.slice(0,32),null)).Mb(null);;)if(bc||d$CLJS.D(b))throw Error("Index out of bounds");return new $CLJS.mf(a,b,c,d,e)}};of=function(a,b){return a===b.ha?b:new Qe(a,ib(b.h))};pf=function(a){return new Qe({},ib(a.h))}; +qf=function(a){var b=[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null];sd(a,0,b,0,a.length);return b};rf=function(a,b,c,d){this.D=a;this.shift=b;this.root=c;this.Qa=d;this.K=88;this.o=275}; +sf=function(a,b,c){if(a.root.ha){if(0<=b&&b>>f&31;f=k(f-5,g.h[l]);g.h[l]=f}return g}(a.shift,a.root);a.root=d}return a}if(b===a.D)return a.Qb(null,c);throw Error(["Index ",$CLJS.gb.b(b)," out of bounds for TransientVector of length",$CLJS.gb.b(a.D)].join(""));}throw Error("assoc! after persistent!");};tf=function(){this.o=2097152;this.K=0}; +vf=function(a,b){return $CLJS.td($CLJS.od(b)&&!$CLJS.pd(b)?$CLJS.D(a)===$CLJS.D(b)?(null!=a?a.o&1048576||$CLJS.yc===a.Rd||(a.o?0:$CLJS.cb(Ob,a)):$CLJS.cb(Ob,a))?$CLJS.Md(function(c,d,e){return $CLJS.Xc.a($CLJS.N.c(b,d,uf),e)?!0:new $CLJS.Nc(!1)},!0,a):$CLJS.Fe(function(c){return $CLJS.Xc.a($CLJS.N.c(b,$CLJS.v(c),uf),$CLJS.dd(c))},a):null:null)};$CLJS.wf=function(a,b,c,d){this.G=0;this.wd=a;this.Bc=b;this.pd=c;this.Lc=d};xf=function(a){this.ca=a};zf=function(a){this.ca=a}; +Af=function(a,b){if(b instanceof $CLJS.P)a:{var c=a.length;b=b.ga;for(var d=0;;){if(c<=d){a=-1;break a}if(a[d]instanceof $CLJS.P&&b===a[d].ga){a=d;break a}d+=2}}else if("string"==typeof b||"number"===typeof b)a:for(c=a.length,d=0;;){if(c<=d){a=-1;break a}if(b===a[d]){a=d;break a}d+=2}else if(b instanceof $CLJS.r)a:for(c=a.length,b=b.rb,d=0;;){if(c<=d){a=-1;break a}if(a[d]instanceof $CLJS.r&&b===a[d].rb){a=d;break a}d+=2}else if(null==b)a:for(b=a.length,c=0;;){if(b<=c){a=-1;break a}if(null==a[c]){a= +c;break a}c+=2}else a:for(c=a.length,d=0;;){if(c<=d){a=-1;break a}if($CLJS.Xc.a(b,a[d])){a=d;break a}d+=2}return a};$CLJS.wd=function(a,b){this.key=a;this.m=b;this.v=null;this.o=166619935;this.K=0};$CLJS.cf=function(a){return null!=a?a.o&2048||$CLJS.yc===a.Ud?!0:!1:!1};Bf=function(a,b,c){this.h=a;this.G=b;this.Za=c;this.o=32374990;this.K=0};Cf=function(a,b){this.h=a;this.G=0;this.D=b};$CLJS.n=function(a,b,c,d){this.M=a;this.D=b;this.h=c;this.v=d;this.o=16647951;this.K=139268}; +$CLJS.Df=function(a){for(var b=[],c=0;;)if(cAg)return $CLJS.Zb(a,"#");$CLJS.Zb(a,c);if(0===Za.b(f))$CLJS.t(g)&&$CLJS.Zb(a,function(){var y=Bg.b(f);return $CLJS.q(y)?y:"..."}());else{if($CLJS.t(g)){var l=$CLJS.v(g);b.c?b.c(l,a,f):b.call(null,l,a,f)}for(var m=$CLJS.B(g),p=Za.b(f)-1;;)if(!m||null!=p&&0===p){$CLJS.t(m)&&0===p&&($CLJS.Zb(a,d),$CLJS.Zb(a,function(){var y=Bg.b(f);return $CLJS.q(y)?y:"..."}()));break}else{$CLJS.Zb(a,d);var w=$CLJS.v(m);c=a;g=f;b.c?b.c(w, +c,g):b.call(null,w,c,g);var x=$CLJS.B(m);c=p-1;m=x;p=c}}return $CLJS.Zb(a,e)}finally{Ag=k}};Dg=function(a,b){b=$CLJS.t(b);for(var c=null,d=0,e=0;;)if(e>>16&65535)*d+c*(b>>>16&65535)<<16>>>0)|0},wc={},vc=0;$CLJS.h=$CLJS.r.prototype;$CLJS.h.toString=function(){return this.rb};$CLJS.h.S=function(a,b){return b instanceof $CLJS.r?this.rb===b.rb:!1}; +$CLJS.h.call=function(){function a(d,e,f){return $CLJS.N.c?$CLJS.N.c(e,this,f):$CLJS.N.call(null,e,this,f)}function b(d,e){return $CLJS.N.a?$CLJS.N.a(e,this):$CLJS.N.call(null,e,this)}var c=null;c=function(d,e,f){switch(arguments.length){case 2:return b.call(this,d,e);case 3:return a.call(this,d,e,f)}throw Error("Invalid arity: "+(arguments.length-1));};c.a=b;c.c=a;return c}();$CLJS.h.apply=function(a,b){return this.call.apply(this,[this].concat(ib(b)))}; +$CLJS.h.b=function(a){return $CLJS.N.a?$CLJS.N.a(a,this):$CLJS.N.call(null,a,this)};$CLJS.h.a=function(a,b){return $CLJS.N.c?$CLJS.N.c(a,this,b):$CLJS.N.call(null,a,this,b)};$CLJS.h.X=function(){return this.Za};$CLJS.h.$=function(a,b){return new $CLJS.r(this.Pa,this.name,this.rb,this.Kb,b)};$CLJS.h.T=function(){var a=this.Kb;return null!=a?a:this.Kb=a=Ac(this)};$CLJS.h.Wb=function(){return this.name};$CLJS.h.Xb=function(){return this.Pa};$CLJS.h.O=function(a,b){return $CLJS.Zb(b,this.rb)}; +$CLJS.Rg=function Rg(a){switch(arguments.length){case 1:return Rg.b(arguments[0]);case 2:return Rg.a(arguments[0],arguments[1]);default:throw Error(["Invalid arity: ",$CLJS.gb.b(arguments.length)].join(""));}}; +$CLJS.Rg.b=function(a){for(;;){if(a instanceof $CLJS.r)return a;if("string"===typeof a){var b=a.indexOf("/");return 1>b?$CLJS.Rg.a(null,a):$CLJS.Rg.a(a.substring(0,b),a.substring(b+1,a.length))}if(a instanceof $CLJS.Bc)return a.Ib;if(a instanceof $CLJS.P)a=a.ga;else throw Error("no conversion to symbol");}};$CLJS.Rg.a=function(a,b){var c=null!=a?[$CLJS.gb.b(a),"/",$CLJS.gb.b(b)].join(""):b;return new $CLJS.r(a,b,c,null,null)};$CLJS.Rg.I=2;$CLJS.h=$CLJS.Bc.prototype; +$CLJS.h.toString=function(){return["#'",$CLJS.gb.b(this.Ib)].join("")};$CLJS.h.Bb=function(){return this.m.l?this.m.l():this.m.call(null)};$CLJS.h.X=function(){return this.Za};$CLJS.h.$=function(a,b){return new $CLJS.Bc(this.m,this.Ib,b)};$CLJS.h.S=function(a,b){return b instanceof $CLJS.Bc?(a=this.Ib,b=b.Ib,$CLJS.Xc.a?$CLJS.Xc.a(a,b):$CLJS.Xc.call(null,a,b)):!1};$CLJS.h.T=function(){return Ac(this.Ib)};$CLJS.h.Dc=$CLJS.yc; +$CLJS.h.call=function(){function a(u,A,C,E,H,I,K,O,Q,T,Y,ba,da,ma,pa,ya,Fa,Da,Ta,eb,sb,Lb){u=this;u=u.m.l?u.m.l():u.m.call(null);return ve.Ob?ve.Ob(u,A,C,E,H,I,K,O,Q,T,Y,ba,da,ma,pa,ya,Fa,Da,Ta,eb,sb,Lb):ve.call(null,u,A,C,E,H,I,K,O,Q,T,Y,ba,da,ma,pa,ya,Fa,Da,Ta,eb,sb,Lb)}function b(u,A,C,E,H,I,K,O,Q,T,Y,ba,da,ma,pa,ya,Fa,Da,Ta,eb){u=this;u=u.m.l?u.m.l():u.m.call(null);return u.va?u.va(A,C,E,H,I,K,O,Q,T,Y,ba,da,ma,pa,ya,Fa,Da,Ta,eb):u.call(null,A,C,E,H,I,K,O,Q,T,Y,ba,da,ma,pa,ya,Fa,Da,Ta,eb)}function c(u, +A,C,E,H,I,K,O,Q,T,Y,ba,da,ma,pa,ya,Fa,Da,Ta){u=this;u=u.m.l?u.m.l():u.m.call(null);return u.ua?u.ua(A,C,E,H,I,K,O,Q,T,Y,ba,da,ma,pa,ya,Fa,Da,Ta):u.call(null,A,C,E,H,I,K,O,Q,T,Y,ba,da,ma,pa,ya,Fa,Da,Ta)}function d(u,A,C,E,H,I,K,O,Q,T,Y,ba,da,ma,pa,ya,Fa,Da){u=this;u=u.m.l?u.m.l():u.m.call(null);return u.ta?u.ta(A,C,E,H,I,K,O,Q,T,Y,ba,da,ma,pa,ya,Fa,Da):u.call(null,A,C,E,H,I,K,O,Q,T,Y,ba,da,ma,pa,ya,Fa,Da)}function e(u,A,C,E,H,I,K,O,Q,T,Y,ba,da,ma,pa,ya,Fa){u=this;u=u.m.l?u.m.l():u.m.call(null);return u.sa? +u.sa(A,C,E,H,I,K,O,Q,T,Y,ba,da,ma,pa,ya,Fa):u.call(null,A,C,E,H,I,K,O,Q,T,Y,ba,da,ma,pa,ya,Fa)}function f(u,A,C,E,H,I,K,O,Q,T,Y,ba,da,ma,pa,ya){u=this;u=u.m.l?u.m.l():u.m.call(null);return u.ra?u.ra(A,C,E,H,I,K,O,Q,T,Y,ba,da,ma,pa,ya):u.call(null,A,C,E,H,I,K,O,Q,T,Y,ba,da,ma,pa,ya)}function g(u,A,C,E,H,I,K,O,Q,T,Y,ba,da,ma,pa){u=this;u=u.m.l?u.m.l():u.m.call(null);return u.qa?u.qa(A,C,E,H,I,K,O,Q,T,Y,ba,da,ma,pa):u.call(null,A,C,E,H,I,K,O,Q,T,Y,ba,da,ma,pa)}function k(u,A,C,E,H,I,K,O,Q,T,Y,ba,da, +ma){u=this;u=u.m.l?u.m.l():u.m.call(null);return u.pa?u.pa(A,C,E,H,I,K,O,Q,T,Y,ba,da,ma):u.call(null,A,C,E,H,I,K,O,Q,T,Y,ba,da,ma)}function l(u,A,C,E,H,I,K,O,Q,T,Y,ba,da){u=this;u=u.m.l?u.m.l():u.m.call(null);return u.oa?u.oa(A,C,E,H,I,K,O,Q,T,Y,ba,da):u.call(null,A,C,E,H,I,K,O,Q,T,Y,ba,da)}function m(u,A,C,E,H,I,K,O,Q,T,Y,ba){u=this;u=u.m.l?u.m.l():u.m.call(null);return u.na?u.na(A,C,E,H,I,K,O,Q,T,Y,ba):u.call(null,A,C,E,H,I,K,O,Q,T,Y,ba)}function p(u,A,C,E,H,I,K,O,Q,T,Y){u=this;u=u.m.l?u.m.l(): +u.m.call(null);return u.ma?u.ma(A,C,E,H,I,K,O,Q,T,Y):u.call(null,A,C,E,H,I,K,O,Q,T,Y)}function w(u,A,C,E,H,I,K,O,Q,T){u=this;u=u.m.l?u.m.l():u.m.call(null);return u.ya?u.ya(A,C,E,H,I,K,O,Q,T):u.call(null,A,C,E,H,I,K,O,Q,T)}function x(u,A,C,E,H,I,K,O,Q){u=this;u=u.m.l?u.m.l():u.m.call(null);return u.la?u.la(A,C,E,H,I,K,O,Q):u.call(null,A,C,E,H,I,K,O,Q)}function y(u,A,C,E,H,I,K,O){u=this;u=u.m.l?u.m.l():u.m.call(null);return u.xa?u.xa(A,C,E,H,I,K,O):u.call(null,A,C,E,H,I,K,O)}function z(u,A,C,E,H,I, +K){u=this;u=u.m.l?u.m.l():u.m.call(null);return u.ia?u.ia(A,C,E,H,I,K):u.call(null,A,C,E,H,I,K)}function M(u,A,C,E,H,I){u=this;u=u.m.l?u.m.l():u.m.call(null);return u.V?u.V(A,C,E,H,I):u.call(null,A,C,E,H,I)}function S(u,A,C,E,H){u=this;u=u.m.l?u.m.l():u.m.call(null);return u.N?u.N(A,C,E,H):u.call(null,A,C,E,H)}function la(u,A,C,E){u=this;u=u.m.l?u.m.l():u.m.call(null);return u.c?u.c(A,C,E):u.call(null,A,C,E)}function xa(u,A,C){u=this;u=u.m.l?u.m.l():u.m.call(null);return u.a?u.a(A,C):u.call(null, +A,C)}function Oa(u,A){u=this;u=u.m.l?u.m.l():u.m.call(null);return u.b?u.b(A):u.call(null,A)}function Pa(u){u=this;u=u.m.l?u.m.l():u.m.call(null);return u.l?u.l():u.call(null)}var ca=null;ca=function(u,A,C,E,H,I,K,O,Q,T,Y,ba,da,ma,pa,ya,Fa,Da,Ta,eb,sb,Lb){switch(arguments.length){case 1:return Pa.call(this,u);case 2:return Oa.call(this,u,A);case 3:return xa.call(this,u,A,C);case 4:return la.call(this,u,A,C,E);case 5:return S.call(this,u,A,C,E,H);case 6:return M.call(this,u,A,C,E,H,I);case 7:return z.call(this, +u,A,C,E,H,I,K);case 8:return y.call(this,u,A,C,E,H,I,K,O);case 9:return x.call(this,u,A,C,E,H,I,K,O,Q);case 10:return w.call(this,u,A,C,E,H,I,K,O,Q,T);case 11:return p.call(this,u,A,C,E,H,I,K,O,Q,T,Y);case 12:return m.call(this,u,A,C,E,H,I,K,O,Q,T,Y,ba);case 13:return l.call(this,u,A,C,E,H,I,K,O,Q,T,Y,ba,da);case 14:return k.call(this,u,A,C,E,H,I,K,O,Q,T,Y,ba,da,ma);case 15:return g.call(this,u,A,C,E,H,I,K,O,Q,T,Y,ba,da,ma,pa);case 16:return f.call(this,u,A,C,E,H,I,K,O,Q,T,Y,ba,da,ma,pa,ya);case 17:return e.call(this, +u,A,C,E,H,I,K,O,Q,T,Y,ba,da,ma,pa,ya,Fa);case 18:return d.call(this,u,A,C,E,H,I,K,O,Q,T,Y,ba,da,ma,pa,ya,Fa,Da);case 19:return c.call(this,u,A,C,E,H,I,K,O,Q,T,Y,ba,da,ma,pa,ya,Fa,Da,Ta);case 20:return b.call(this,u,A,C,E,H,I,K,O,Q,T,Y,ba,da,ma,pa,ya,Fa,Da,Ta,eb);case 21:var yf=this.m.l?this.m.l():this.m.call(null);return yf.wa?yf.wa(A,C,E,H,I,K,O,Q,T,Y,ba,da,ma,pa,ya,Fa,Da,Ta,eb,sb):yf.call(null,A,C,E,H,I,K,O,Q,T,Y,ba,da,ma,pa,ya,Fa,Da,Ta,eb,sb);case 22:return a.call(this,u,A,C,E,H,I,K,O,Q,T,Y,ba, +da,ma,pa,ya,Fa,Da,Ta,eb,sb,Lb)}throw Error("Invalid arity: "+(arguments.length-1));};ca.b=Pa;ca.a=Oa;ca.c=xa;ca.N=la;ca.V=S;ca.ia=M;ca.xa=z;ca.la=y;ca.ya=x;ca.ma=w;ca.na=p;ca.oa=m;ca.pa=l;ca.qa=k;ca.ra=g;ca.sa=f;ca.ta=e;ca.ua=d;ca.va=c;ca.wa=b;ca.Ob=a;return ca}();$CLJS.h.apply=function(a,b){return this.call.apply(this,[this].concat(ib(b)))};$CLJS.h.l=function(){var a=this.m.l?this.m.l():this.m.call(null);return a.l?a.l():a.call(null)}; +$CLJS.h.b=function(a){var b=this.m.l?this.m.l():this.m.call(null);return b.b?b.b(a):b.call(null,a)};$CLJS.h.a=function(a,b){var c=this.m.l?this.m.l():this.m.call(null);return c.a?c.a(a,b):c.call(null,a,b)};$CLJS.h.c=function(a,b,c){var d=this.m.l?this.m.l():this.m.call(null);return d.c?d.c(a,b,c):d.call(null,a,b,c)};$CLJS.h.N=function(a,b,c,d){var e=this.m.l?this.m.l():this.m.call(null);return e.N?e.N(a,b,c,d):e.call(null,a,b,c,d)}; +$CLJS.h.V=function(a,b,c,d,e){var f=this.m.l?this.m.l():this.m.call(null);return f.V?f.V(a,b,c,d,e):f.call(null,a,b,c,d,e)};$CLJS.h.ia=function(a,b,c,d,e,f){var g=this.m.l?this.m.l():this.m.call(null);return g.ia?g.ia(a,b,c,d,e,f):g.call(null,a,b,c,d,e,f)};$CLJS.h.xa=function(a,b,c,d,e,f,g){var k=this.m.l?this.m.l():this.m.call(null);return k.xa?k.xa(a,b,c,d,e,f,g):k.call(null,a,b,c,d,e,f,g)}; +$CLJS.h.la=function(a,b,c,d,e,f,g,k){var l=this.m.l?this.m.l():this.m.call(null);return l.la?l.la(a,b,c,d,e,f,g,k):l.call(null,a,b,c,d,e,f,g,k)};$CLJS.h.ya=function(a,b,c,d,e,f,g,k,l){var m=this.m.l?this.m.l():this.m.call(null);return m.ya?m.ya(a,b,c,d,e,f,g,k,l):m.call(null,a,b,c,d,e,f,g,k,l)};$CLJS.h.ma=function(a,b,c,d,e,f,g,k,l,m){var p=this.m.l?this.m.l():this.m.call(null);return p.ma?p.ma(a,b,c,d,e,f,g,k,l,m):p.call(null,a,b,c,d,e,f,g,k,l,m)}; +$CLJS.h.na=function(a,b,c,d,e,f,g,k,l,m,p){var w=this.m.l?this.m.l():this.m.call(null);return w.na?w.na(a,b,c,d,e,f,g,k,l,m,p):w.call(null,a,b,c,d,e,f,g,k,l,m,p)};$CLJS.h.oa=function(a,b,c,d,e,f,g,k,l,m,p,w){var x=this.m.l?this.m.l():this.m.call(null);return x.oa?x.oa(a,b,c,d,e,f,g,k,l,m,p,w):x.call(null,a,b,c,d,e,f,g,k,l,m,p,w)}; +$CLJS.h.pa=function(a,b,c,d,e,f,g,k,l,m,p,w,x){var y=this.m.l?this.m.l():this.m.call(null);return y.pa?y.pa(a,b,c,d,e,f,g,k,l,m,p,w,x):y.call(null,a,b,c,d,e,f,g,k,l,m,p,w,x)};$CLJS.h.qa=function(a,b,c,d,e,f,g,k,l,m,p,w,x,y){var z=this.m.l?this.m.l():this.m.call(null);return z.qa?z.qa(a,b,c,d,e,f,g,k,l,m,p,w,x,y):z.call(null,a,b,c,d,e,f,g,k,l,m,p,w,x,y)}; +$CLJS.h.ra=function(a,b,c,d,e,f,g,k,l,m,p,w,x,y,z){var M=this.m.l?this.m.l():this.m.call(null);return M.ra?M.ra(a,b,c,d,e,f,g,k,l,m,p,w,x,y,z):M.call(null,a,b,c,d,e,f,g,k,l,m,p,w,x,y,z)};$CLJS.h.sa=function(a,b,c,d,e,f,g,k,l,m,p,w,x,y,z,M){var S=this.m.l?this.m.l():this.m.call(null);return S.sa?S.sa(a,b,c,d,e,f,g,k,l,m,p,w,x,y,z,M):S.call(null,a,b,c,d,e,f,g,k,l,m,p,w,x,y,z,M)}; +$CLJS.h.ta=function(a,b,c,d,e,f,g,k,l,m,p,w,x,y,z,M,S){var la=this.m.l?this.m.l():this.m.call(null);return la.ta?la.ta(a,b,c,d,e,f,g,k,l,m,p,w,x,y,z,M,S):la.call(null,a,b,c,d,e,f,g,k,l,m,p,w,x,y,z,M,S)};$CLJS.h.ua=function(a,b,c,d,e,f,g,k,l,m,p,w,x,y,z,M,S,la){var xa=this.m.l?this.m.l():this.m.call(null);return xa.ua?xa.ua(a,b,c,d,e,f,g,k,l,m,p,w,x,y,z,M,S,la):xa.call(null,a,b,c,d,e,f,g,k,l,m,p,w,x,y,z,M,S,la)}; +$CLJS.h.va=function(a,b,c,d,e,f,g,k,l,m,p,w,x,y,z,M,S,la,xa){var Oa=this.m.l?this.m.l():this.m.call(null);return Oa.va?Oa.va(a,b,c,d,e,f,g,k,l,m,p,w,x,y,z,M,S,la,xa):Oa.call(null,a,b,c,d,e,f,g,k,l,m,p,w,x,y,z,M,S,la,xa)};$CLJS.h.wa=function(a,b,c,d,e,f,g,k,l,m,p,w,x,y,z,M,S,la,xa,Oa){var Pa=this.m.l?this.m.l():this.m.call(null);return Pa.wa?Pa.wa(a,b,c,d,e,f,g,k,l,m,p,w,x,y,z,M,S,la,xa,Oa):Pa.call(null,a,b,c,d,e,f,g,k,l,m,p,w,x,y,z,M,S,la,xa,Oa)}; +$CLJS.Xc=function Xc(a){switch(arguments.length){case 1:return Xc.b(arguments[0]);case 2:return Xc.a(arguments[0],arguments[1]);default:for(var c=[],d=arguments.length,e=0;;)if(ea?0:a};$CLJS.h.Zb=function(){var a=this.aa(null);return 0>>b&31;5===b?f.h[g]=d:(c=c.h[g],null!=c?(b-=5,a=di.N?di.N(a,b,c,d):di.call(null,a,b,c,d)):a=Te(null,b-5,d),f.h[g]=a);return f},ei=function ei(a,b,c,d,e){var g=new Qe(c.ha,ib(c.h));if(0===b)g.h[d&31]=e;else{var k=d>>>b&31;b-=5;c=c.h[k];a=ei.V?ei.V(a,b,c,d,e):ei.call(null,a,b,c,d,e);g.h[k]=a}return g};Xe.prototype.Da=function(){return this.G=this.D)return new $CLJS.Dc(this.Qa,0,null);a:{var a=this.root;for(var b=this.shift;;)if(0this.D-Se(this)){a=this.Qa.length;for(var c=Array(a+1),d=0;;)if(d>>5>1<b)return null;a=this.start+b;return ab||this.end<=this.start+b?Ue(b,this.end-this.start):$CLJS.gd(this.fa,this.start+b)};$CLJS.h.Ca=function(a,b,c){return 0>b||this.end<=this.start+b?c:$CLJS.gd(this.fa,this.start+b,c)}; +$CLJS.h.Cb=function(a,b,c){a=this.start+b;if(0>b||this.end+1<=a)throw Error(["Index ",$CLJS.gb.b(b)," out of bounds [0,",$CLJS.gb.b(this.aa(null)),"]"].join(""));b=this.M;c=$CLJS.Ng.c(this.fa,a,c);var d=this.start,e=this.end;a+=1;a=e>a?e:a;return $CLJS.nf.V?$CLJS.nf.V(b,c,d,a,null):$CLJS.nf.call(null,b,c,d,a,null)};$CLJS.h.ja=function(){return null!=this.fa&&$CLJS.yc===this.fa.tc?Ye(this.fa,this.start,this.end):new Ee(this)};$CLJS.h.X=function(){return this.M}; +$CLJS.h.aa=function(){return this.end-this.start};$CLJS.h.Zb=function(){return this.start!==this.end?new cd(this,this.end-this.start-1,null):null};$CLJS.h.T=function(){var a=this.v;return null!=a?a:this.v=a=Lc(this)};$CLJS.h.S=function(a,b){return Rd(this,b)};$CLJS.h.Aa=function(){return $CLJS.Mb($CLJS.ff,this.M)};$CLJS.h.Ga=function(a,b){return null!=this.fa&&$CLJS.yc===this.fa.tc?$e(this.fa,b,this.start,this.end):Qc(this,b)}; +$CLJS.h.Ha=function(a,b,c){return null!=this.fa&&$CLJS.yc===this.fa.tc?Ze(this.fa,b,c,this.start,this.end):Rc(this,b,c)};$CLJS.h.U=function(a,b,c){if("number"===typeof b)return this.Cb(null,b,c);throw Error("Subvec's key for assoc must be a number.");};$CLJS.h.Y=function(){var a=this;return function d(c){return c===a.end?null:$CLJS.Yd($CLJS.gd(a.fa,c),new $CLJS.ae(null,function(){return d(c+1)},null))}(a.start)}; +$CLJS.h.$=function(a,b){return b===this.M?this:$CLJS.nf.V?$CLJS.nf.V(b,this.fa,this.start,this.end,this.v):$CLJS.nf.call(null,b,this.fa,this.start,this.end,this.v)};$CLJS.h.ba=function(a,b){a=this.M;b=Hb(this.fa,this.end,b);var c=this.start,d=this.end+1;return $CLJS.nf.V?$CLJS.nf.V(a,b,c,d,null):$CLJS.nf.call(null,a,b,c,d,null)}; +$CLJS.h.call=function(){var a=null;a=function(b,c,d){switch(arguments.length){case 2:return this.ea(null,c);case 3:return this.Ca(null,c,d)}throw Error("Invalid arity: "+(arguments.length-1));};a.a=function(b,c){return this.ea(null,c)};a.c=function(b,c,d){return this.Ca(null,c,d)};return a}();$CLJS.h.apply=function(a,b){return this.call.apply(this,[this].concat(ib(b)))};$CLJS.h.b=function(a){return this.ea(null,a)};$CLJS.h.a=function(a,b){return this.Ca(null,a,b)};$CLJS.mf.prototype[Ec]=function(){return Jc(this)}; +var fi=function fi(a,b,c,d){c=of(a.root.ha,c);var f=a.D-1>>>b&31;if(5===b)a=d;else{var g=c.h[f];null!=g?(b-=5,a=fi.N?fi.N(a,b,g,d):fi.call(null,a,b,g,d)):a=Te(a.root.ha,b-5,d)}c.h[f]=a;return c};$CLJS.h=rf.prototype; +$CLJS.h.Qb=function(a,b){if(this.root.ha){if(32>this.D-Se(this))this.Qa[this.D&31]=b;else{a=new Qe(this.root.ha,this.Qa);var c=[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null];c[0]=b;this.Qa=c;this.D>>>5>1<=a)return new $CLJS.n(this.M,this.D-1,c,null);$CLJS.Xc.a(b,this.h[d])?d+=2:(c[e]=this.h[d],c[e+1]=this.h[d+1],e+=2,d+=2)}}else return this}; +$CLJS.h.U=function(a,b,c){a=Af(this.h,b);if(-1===a){if(this.Db?4:2*(b+1));sd(this.h,0,c,0,2*b);return new Pf(a,this.ka,c)}; +$CLJS.h.dc=function(){return Zf?Zf(this.h):ag.call(null,this.h)};$CLJS.h.fc=function(a,b){return Nf(this.h,a,b)};$CLJS.h.Eb=function(a,b,c,d){var e=1<<(b>>>a&31);if(0===(this.ka&e))return d;var f=Qd(this.ka&e-1);e=this.h[2*f];f=this.h[2*f+1];return null==e?f.Eb(a+5,b,c,d):Jf(c,e)?f:d}; +$CLJS.h.fb=function(a,b,c,d,e,f){var g=1<<(c>>>b&31),k=Qd(this.ka&g-1);if(0===(this.ka&g)){var l=Qd(this.ka);if(2*l>>b&31]=Xf.fb(a,b+5,c,d,e,f);for(e=d=0;;)if(32>d)0===(this.ka>>> +d&1)?d+=1:(k[d]=null!=this.h[e]?Xf.fb(a,b+5,$CLJS.zc(this.h[e]),this.h[e],this.h[e+1],f):this.h[e+1],e+=2,d+=1);else break;return new Rf(a,l+1,k)}b=Array(2*(l+4));sd(this.h,0,b,0,2*k);b[2*k]=d;b[2*k+1]=e;sd(this.h,2*k,b,2*(k+1),2*(l-k));f.m=!0;a=this.Db(a);a.h=b;a.ka|=g;return a}l=this.h[2*k];g=this.h[2*k+1];if(null==l)return l=g.fb(a,b+5,c,d,e,f),l===g?this:Mf(this,a,2*k+1,l);if(Jf(d,l))return e===g?this:Mf(this,a,2*k+1,e);f.m=!0;f=b+5;d=Vf?Vf(a,f,l,g,c,d,e):Wf.call(null,a,f,l,g,c,d,e);e=2*k;k=2* +k+1;a=this.Db(a);a.h[e]=null;a.h[k]=d;return a}; +$CLJS.h.eb=function(a,b,c,d,e){var f=1<<(b>>>a&31),g=Qd(this.ka&f-1);if(0===(this.ka&f)){var k=Qd(this.ka);if(16<=k){g=[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null];g[b>>>a&31]=Xf.eb(a+5,b,c,d,e);for(d=c=0;;)if(32>c)0===(this.ka>>>c&1)?c+=1:(g[c]=null!=this.h[d]?Xf.eb(a+5,$CLJS.zc(this.h[d]),this.h[d],this.h[d+1],e):this.h[d+1],d+=2,c+=1);else break;return new Rf(null,k+1,g)}a=Array(2* +(k+1));sd(this.h,0,a,0,2*g);a[2*g]=c;a[2*g+1]=d;sd(this.h,2*g,a,2*(g+1),2*(k-g));e.m=!0;return new Pf(null,this.ka|f,a)}var l=this.h[2*g];f=this.h[2*g+1];if(null==l)return k=f.eb(a+5,b,c,d,e),k===f?this:new Pf(null,this.ka,Kf(this.h,2*g+1,k));if(Jf(c,l))return d===f?this:new Pf(null,this.ka,Kf(this.h,2*g+1,d));e.m=!0;e=this.ka;k=this.h;a+=5;a=Uf?Uf(a,l,f,b,c,d):Wf.call(null,a,l,f,b,c,d);c=2*g;g=2*g+1;d=ib(k);d[c]=null;d[g]=a;return new Pf(null,e,d)}; +$CLJS.h.cc=function(a,b,c,d){var e=1<<(b>>>a&31);if(0===(this.ka&e))return d;var f=Qd(this.ka&e-1);e=this.h[2*f];f=this.h[2*f+1];return null==e?f.cc(a+5,b,c,d):Jf(c,e)?new $CLJS.wd(e,f):d}; +$CLJS.h.ec=function(a,b,c){var d=1<<(b>>>a&31);if(0===(this.ka&d))return this;var e=Qd(this.ka&d-1),f=this.h[2*e],g=this.h[2*e+1];return null==f?(a=g.ec(a+5,b,c),a===g?this:null!=a?new Pf(null,this.ka,Kf(this.h,2*e+1,a)):this.ka===d?null:new Pf(null,this.ka^d,Lf(this.h,e))):Jf(c,f)?new Pf(null,this.ka^d,Lf(this.h,e)):this};$CLJS.h.ja=function(){return new Of(this.h)};var Xf=new Pf(null,0,[]); +Qf.prototype.Da=function(){for(var a=this.h.length;;){if(null!=this.ib&&this.ib.Da())return!0;if(this.G>>a&31];return null!=e?e.Eb(a+5,b,c,d):d};$CLJS.h.fb=function(a,b,c,d,e,f){var g=c>>>b&31,k=this.h[g];if(null==k)return a=Mf(this,a,g,Xf.fb(a,b+5,c,d,e,f)),a.D+=1,a;b=k.fb(a,b+5,c,d,e,f);return b===k?this:Mf(this,a,g,b)}; +$CLJS.h.eb=function(a,b,c,d,e){var f=b>>>a&31,g=this.h[f];if(null==g)return new Rf(null,this.D+1,Kf(this.h,f,Xf.eb(a+5,b,c,d,e)));a=g.eb(a+5,b,c,d,e);return a===g?this:new Rf(null,this.D,Kf(this.h,f,a))};$CLJS.h.cc=function(a,b,c,d){var e=this.h[b>>>a&31];return null!=e?e.cc(a+5,b,c,d):d}; +$CLJS.h.ec=function(a,b,c){var d=b>>>a&31,e=this.h[d];if(null!=e){a=e.ec(a+5,b,c);if(a===e)d=this;else if(null==a)if(8>=this.D)a:{e=this.h;a=e.length;b=Array(2*(this.D-1));c=0;for(var f=1,g=0;;)if(ca?d:Jf(c,this.h[a])?this.h[a+1]:d}; +$CLJS.h.fb=function(a,b,c,d,e,f){if(c===this.tb){b=Sf(this.h,this.D,d);if(-1===b){if(this.h.length>2*this.D)return b=2*this.D,c=2*this.D+1,a=this.Db(a),a.h[b]=d,a.h[c]=e,f.m=!0,a.D+=1,a;c=this.h.length;b=Array(c+2);sd(this.h,0,b,0,c);b[c]=d;b[c+1]=e;f.m=!0;d=this.D+1;a===this.ha?(this.h=b,this.D=d,a=this):a=new Tf(this.ha,this.tb,d,b);return a}return this.h[b+1]===e?this:Mf(this,a,b+1,e)}return(new Pf(a,1<<(this.tb>>>b&31),[null,this,null,null])).fb(a,b,c,d,e,f)}; +$CLJS.h.eb=function(a,b,c,d,e){return b===this.tb?(a=Sf(this.h,this.D,c),-1===a?(a=2*this.D,b=Array(a+2),sd(this.h,0,b,0,a),b[a]=c,b[a+1]=d,e.m=!0,new Tf(null,this.tb,this.D+1,b)):$CLJS.Xc.a(this.h[a+1],d)?this:new Tf(null,this.tb,this.D,Kf(this.h,a+1,d))):(new Pf(null,1<<(this.tb>>>a&31),[null,this])).eb(a,b,c,d,e)};$CLJS.h.cc=function(a,b,c,d){a=Sf(this.h,this.D,c);return 0>a?d:Jf(c,this.h[a])?new $CLJS.wd(this.h[a],this.h[a+1]):d}; +$CLJS.h.ec=function(a,b,c){a=Sf(this.h,this.D,c);return-1===a?this:1===this.D?null:new Tf(null,this.tb,this.D-1,Lf(this.h,Pd(a)))};$CLJS.h.ja=function(){return new Of(this.h)};$CLJS.h=Yf.prototype;$CLJS.h.toString=function(){return qc(this)}; +$CLJS.h.indexOf=function(){var a=null;a=function(b,c){switch(arguments.length){case 1:return $c(this,b,0);case 2:return $c(this,b,c)}throw Error("Invalid arity: "+arguments.length);};a.b=function(b){return $c(this,b,0)};a.a=function(b,c){return $c(this,b,c)};return a}(); +$CLJS.h.lastIndexOf=function(){function a(c){return ad(this,c,$CLJS.D(this))}var b=null;b=function(c,d){switch(arguments.length){case 1:return a.call(this,c);case 2:return ad(this,c,d)}throw Error("Invalid arity: "+arguments.length);};b.b=a;b.a=function(c,d){return ad(this,c,d)};return b}();$CLJS.h.X=function(){return this.M}; +$CLJS.h.Fa=function(){if(null==this.ca){var a=this.jb,b=this.G+2;return $f?$f(a,b,null):ag.call(null,a,b,null)}a=this.jb;b=this.G;var c=$CLJS.B(this.ca);return $f?$f(a,b,c):ag.call(null,a,b,c)};$CLJS.h.T=function(){var a=this.v;return null!=a?a:this.v=a=Lc(this)};$CLJS.h.S=function(a,b){return Rd(this,b)};$CLJS.h.Aa=function(){return $CLJS.Gc};$CLJS.h.Ga=function(a,b){return Dd(b,this)};$CLJS.h.Ha=function(a,b,c){return Ed(b,c,this)}; +$CLJS.h.Ja=function(){return null==this.ca?new $CLJS.wd(this.jb[this.G],this.jb[this.G+1]):$CLJS.v(this.ca)};$CLJS.h.Na=function(){var a=this,b=null==a.ca?function(){var c=a.jb,d=a.G+2;return $f?$f(c,d,null):ag.call(null,c,d,null)}():function(){var c=a.jb,d=a.G,e=$CLJS.B(a.ca);return $f?$f(c,d,e):ag.call(null,c,d,e)}();return null!=b?b:$CLJS.Gc};$CLJS.h.Y=function(){return this};$CLJS.h.$=function(a,b){return b===this.M?this:new Yf(b,this.jb,this.G,this.ca,this.v)}; +$CLJS.h.ba=function(a,b){return $CLJS.Yd(b,this)};Yf.prototype[Ec]=function(){return Jc(this)};$CLJS.h=bg.prototype;$CLJS.h.toString=function(){return qc(this)};$CLJS.h.indexOf=function(){var a=null;a=function(b,c){switch(arguments.length){case 1:return $c(this,b,0);case 2:return $c(this,b,c)}throw Error("Invalid arity: "+arguments.length);};a.b=function(b){return $c(this,b,0)};a.a=function(b,c){return $c(this,b,c)};return a}(); +$CLJS.h.lastIndexOf=function(){function a(c){return ad(this,c,$CLJS.D(this))}var b=null;b=function(c,d){switch(arguments.length){case 1:return a.call(this,c);case 2:return ad(this,c,d)}throw Error("Invalid arity: "+arguments.length);};b.b=a;b.a=function(c,d){return ad(this,c,d)};return b}();$CLJS.h.X=function(){return this.M};$CLJS.h.Fa=function(){var a=this.jb,b=this.G,c=$CLJS.B(this.ca);return dg?dg(a,b,c):eg.call(null,a,b,c)};$CLJS.h.T=function(){var a=this.v;return null!=a?a:this.v=a=Lc(this)}; +$CLJS.h.S=function(a,b){return Rd(this,b)};$CLJS.h.Aa=function(){return $CLJS.Gc};$CLJS.h.Ga=function(a,b){return Dd(b,this)};$CLJS.h.Ha=function(a,b,c){return Ed(b,c,this)};$CLJS.h.Ja=function(){return $CLJS.v(this.ca)};$CLJS.h.Na=function(){var a=this.jb;var b=this.G,c=$CLJS.B(this.ca);a=dg?dg(a,b,c):eg.call(null,a,b,c);return null!=a?a:$CLJS.Gc};$CLJS.h.Y=function(){return this};$CLJS.h.$=function(a,b){return b===this.M?this:new bg(b,this.jb,this.G,this.ca,this.v)}; +$CLJS.h.ba=function(a,b){return $CLJS.Yd(b,this)};bg.prototype[Ec]=function(){return Jc(this)};fg.prototype.Da=function(){return!this.zc||this.Nc.Da()};fg.prototype.next=function(){if(this.zc)return this.Nc.next();this.zc=!0;return new $CLJS.wd(null,this.Ka)};fg.prototype.remove=function(){return Error("Unsupported operation")};$CLJS.h=$CLJS.gg.prototype;$CLJS.h.Vb=$CLJS.yc; +$CLJS.h.Nb=function(a,b){return null==b?this.Oa?new $CLJS.wd(null,this.Ka):null:null==this.root?null:this.root.cc(0,$CLJS.zc(b),b,null)};$CLJS.h.toString=function(){return qc(this)};$CLJS.h.keys=function(){return Jc($CLJS.lg.b?$CLJS.lg.b(this):$CLJS.lg.call(null,this))};$CLJS.h.entries=function(){return new xf($CLJS.t($CLJS.t(this)))};$CLJS.h.values=function(){return Jc($CLJS.ng.b?$CLJS.ng.b(this):$CLJS.ng.call(null,this))};$CLJS.h.has=function(a){return $CLJS.vd(this,a)}; +$CLJS.h.get=function(a,b){return this.J(null,a,b)};$CLJS.h.forEach=function(a){for(var b=$CLJS.t(this),c=null,d=0,e=0;;)if(e>>0);$CLJS.ha=Date.now||function(){return+new Date};$CLJS.ea=__webpack_require__.g; + +/***/ }), + +/***/ "../cljs/goog.debug.debugwindow.js": +/*!*****************************************!*\ + !*** ../cljs/goog.debug.debugwindow.js ***! + \*****************************************/ +/***/ (function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +var window=__webpack_require__.g;var $CLJS=__webpack_require__(/*! ./cljs_env */ "../cljs/cljs_env.js");__webpack_require__(/*! ./goog.base.js */ "../cljs/goog.base.js");__webpack_require__(/*! ./goog.useragent.useragent.js */ "../cljs/goog.useragent.useragent.js");__webpack_require__(/*! ./goog.html.safehtml.js */ "../cljs/goog.html.safehtml.js"); +(0,$CLJS.ha)(); + +/***/ }), + +/***/ "../cljs/goog.dom.tagname.js": +/*!***********************************!*\ + !*** ../cljs/goog.dom.tagname.js ***! + \***********************************/ +/***/ (function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +var window=__webpack_require__.g;var $CLJS=__webpack_require__(/*! ./cljs_env */ "../cljs/cljs_env.js");__webpack_require__(/*! ./goog.base.js */ "../cljs/goog.base.js"); +var ia=function(a){this.yd=a};ia.prototype.toString=function(){return this.yd};$CLJS.ja=new ia("APPLET");$CLJS.ka=new ia("BASE");$CLJS.na=new ia("EMBED");$CLJS.oa=new ia("IFRAME");$CLJS.qa=new ia("LINK");$CLJS.ra=new ia("MATH");$CLJS.sa=new ia("META");$CLJS.ta=new ia("OBJECT");$CLJS.ua=new ia("SCRIPT");$CLJS.va=new ia("STYLE");$CLJS.wa=new ia("SVG");$CLJS.za=new ia("TEMPLATE"); + +/***/ }), + +/***/ "../cljs/goog.html.safehtml.js": +/*!*************************************!*\ + !*** ../cljs/goog.html.safehtml.js ***! + \*************************************/ +/***/ (function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +var window=__webpack_require__.g;var $CLJS=__webpack_require__(/*! ./cljs_env */ "../cljs/cljs_env.js");__webpack_require__(/*! ./goog.base.js */ "../cljs/goog.base.js");__webpack_require__(/*! ./goog.dom.tagname.js */ "../cljs/goog.dom.tagname.js");__webpack_require__(/*! ./goog.labs.useragent.util.js */ "../cljs/goog.labs.useragent.util.js"); +var Ga; +$CLJS.Ea=function(a){var b=typeof a;if("object"==b)if(a){if(a instanceof Array)return"array";if(a instanceof Object)return b;var c=Object.prototype.toString.call(a);if("[object Window]"==c)return"object";if("[object Array]"==c||"number"==typeof a.length&&"undefined"!=typeof a.splice&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("splice"))return"array";if("[object Function]"==c||"undefined"!=typeof a.call&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("call"))return"function"}else return"null";else if("function"== +b&&"undefined"==typeof a.call)return"object";return b};Ga=function(a){var b=arguments.length;if(1==b&&"array"==$CLJS.Ea(arguments[0]))return Ga.apply(null,arguments[0]);for(var c={},d=0;d=Number(c)?a:a=-1Number(a)?"-":0<=b.indexOf("+")?"+":0<=b.indexOf(" ")?" ":"";0<=Number(a)&&(d=f+d);if(isNaN(c)||d.length>=Number(c))return d;d=isNaN(e)?Math.abs(Number(a)).toString():Math.abs(Number(a)).toFixed(e);a=Number(c)-d.length-f.length;0<=b.indexOf("-",0)?d=f+d+(0,$CLJS.Ha)(" ",a):(b=0<=b.indexOf("0",0)?"0":" ",d=f+(0,$CLJS.Ha)(b,a)+d);return d}; +$CLJS.ul.ub.d=function(a,b,c,d,e,f,g,k){return $CLJS.ul.ub.f(parseInt(a,10),b,c,d,0,f,g,k)};$CLJS.ul.ub.i=$CLJS.ul.ub.d;$CLJS.ul.ub.u=$CLJS.ul.ub.d; + +/***/ }), + +/***/ "../cljs/goog.useragent.useragent.js": +/*!*******************************************!*\ + !*** ../cljs/goog.useragent.useragent.js ***! + \*******************************************/ +/***/ (function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +var window=__webpack_require__.g;var $CLJS=__webpack_require__(/*! ./cljs_env */ "../cljs/cljs_env.js");__webpack_require__(/*! ./goog.base.js */ "../cljs/goog.base.js");__webpack_require__(/*! ./goog.labs.useragent.util.js */ "../cljs/goog.labs.useragent.util.js");__webpack_require__(/*! ./goog.string.string.js */ "../cljs/goog.string.string.js"); +var XC=function(a){return-1!=$CLJS.Aa.toLowerCase().indexOf(a.toLowerCase())},YC=function(a){return-1!=$CLJS.Aa.indexOf(a)},ZC=function(){return YC("iPhone")&&!YC("iPod")&&!YC("iPad")};YC("Opera");YC("Trident")||YC("MSIE");YC("Edge");!YC("Gecko")||XC("WebKit")&&!YC("Edge")||YC("Trident")||YC("MSIE")||YC("Edge");XC("WebKit")&&!YC("Edge")&&YC("Mobile");YC("Macintosh");YC("Windows");YC("Linux")||YC("CrOS");var $C=$CLJS.ea.navigator||null;$C&&($C.appVersion||"").indexOf("X11");YC("Android");ZC();YC("iPad"); +YC("iPod");ZC()||YC("iPad")||YC("iPod");XC("KaiOS");XC("GAFP"); + +/***/ }), + +/***/ "../cljs/lambdaisland.glogi.console.js": +/*!*********************************************!*\ + !*** ../cljs/lambdaisland.glogi.console.js ***! + \*********************************************/ +/***/ (function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +/* provided dependency */ var console = __webpack_require__(/*! console-browserify */ "../../../node_modules/console-browserify/index.js"); +var window=__webpack_require__.g;var $CLJS=__webpack_require__(/*! ./cljs_env */ "../cljs/cljs_env.js");__webpack_require__(/*! ./goog.base.js */ "../cljs/goog.base.js");__webpack_require__(/*! ./cljs.core.js */ "../cljs/cljs.core.js");__webpack_require__(/*! ./lambdaisland.glogi.js */ "../cljs/lambdaisland.glogi.js");__webpack_require__(/*! ./lambdaisland.glogi.print.js */ "../cljs/lambdaisland.glogi.print.js");__webpack_require__(/*! ./goog.useragent.useragent.js */ "../cljs/goog.useragent.useragent.js");__webpack_require__(/*! ./goog.html.safehtml.js */ "../cljs/goog.html.safehtml.js"); +var RD=function(){},TD=function(a,b){return $CLJS.ki(1,SD.a(new $CLJS.Ne(null,-1,a,null),b))},UD=function(a){return $CLJS.N.a($CLJS.eD,a).value},WD=function(a){var b=UD(a);return $CLJS.q(function(){var c=UD($CLJS.rD);return VD.a?VD.a(c,b):VD.call(null,c,b)}())?$CLJS.MD:$CLJS.q(function(){var c=UD($CLJS.sD);return VD.a?VD.a(c,b):VD.call(null,c,b)}())?$CLJS.OD:$CLJS.q(function(){var c=UD($CLJS.ni);return VD.a?VD.a(c,b):VD.call(null,c,b)}())?$CLJS.CD:$CLJS.q(function(){var c=UD($CLJS.yD);return VD.a? +VD.a(c,b):VD.call(null,c,b)}())?$CLJS.JD:$CLJS.q(function(){var c=UD($CLJS.oD);return VD.a?VD.a(c,b):VD.call(null,c,b)}())?$CLJS.LD:$CLJS.q(function(){var c=UD($CLJS.nD);return VD.a?VD.a(c,b):VD.call(null,c,b)}())?$CLJS.ED:$CLJS.q(function(){var c=UD($CLJS.qD);return VD.a?VD.a(c,b):VD.call(null,c,b)}())?$CLJS.HD:$CLJS.FD},XD=function(a){var b=$CLJS.G(a,0,null);a=$CLJS.G(a,1,null);return new $CLJS.R(null,2,5,$CLJS.U,[[$CLJS.gb.b(b),$CLJS.gb.b(" ")].join(""),a],null)},YD=function(a,b,c){var d=$CLJS.G(a, +0,null);a=$CLJS.G(a,1,null);return new $CLJS.R(null,2,5,$CLJS.U,[[$CLJS.gb.b(d),"%c",$CLJS.gb.b(b),"%c"].join(""),$CLJS.Vd.j(a,["color:",$CLJS.gb.b($CLJS.N.a($CLJS.QD,c))].join(""),$CLJS.F(["color:black"]))],null)},ZD=function(a,b,c){var d=$CLJS.G(a,0,null);a=$CLJS.G(a,1,null);return new $CLJS.R(null,2,5,$CLJS.U,[[$CLJS.gb.b(d),"%c",$CLJS.gb.b(b),"%c"].join(""),$CLJS.Vd.j(a,["color:",$CLJS.gb.b($CLJS.N.a($CLJS.QD,$CLJS.BD)),";background-color:",$CLJS.gb.b($CLJS.N.a($CLJS.QD,c))].join(""),$CLJS.F(["color:black;background-color:inherit"]))], +null)},$D=function(a){function b(c,d){return d>=c}a=UD(a);if(b(UD($CLJS.rD),a))return"error";if(b(UD($CLJS.sD),a))return"warn";if(b(UD($CLJS.ni),a))return"info";b(UD($CLJS.yD),a);return"log"},aE=function(a){return function(b){var c=null!=b&&(b.o&64||$CLJS.yc===b.Z)?$CLJS.qe($CLJS.Yh,b):b,d=$CLJS.N.a(c,$CLJS.xD),e=$CLJS.N.a(c,$CLJS.jD);b=$CLJS.N.a(c,$CLJS.lD);e=$D(e);e=$CLJS.Sa(console,e);e=$CLJS.q(e)?e:console.log;$CLJS.qe(e,a.b?a.b(c):a.call(null,c));return $CLJS.q(b)?(c=["[",$CLJS.gb.b(d),"]"].join(""), +d=$CLJS.gb.b(b),b=b.stack,e.N?e.N(c,d,"\n",b):e.call(null,c,d,"\n",b)):null}},VD=function VD(a){switch(arguments.length){case 1:return VD.b(arguments[0]);case 2:return VD.a(arguments[0],arguments[1]);default:for(var c=[],d=arguments.length,e=0;;)if(ea};Ho=function(a,b,c,d){this.qb=a;this.C=b;this.g=c;this.v=d;this.o=2230716170;this.K=139264};$CLJS.Io=function(a){return new Ho(a,null,null,null)};$CLJS.Wl.prototype.Gb=$CLJS.La(12,function(){return $CLJS.Ie(this.R)}); +$CLJS.bm.prototype.Gb=$CLJS.La(11,function(){var a=this;return $CLJS.Zh.a($CLJS.Ie(a.R),$CLJS.qe($CLJS.$h,function(){return function d(c){return new $CLJS.ae(null,function(){for(;;){var e=$CLJS.t(c);if(e){if($CLJS.rd(e)){var f=$CLJS.ic(e),g=$CLJS.D(f),k=$CLJS.de(g);a:for(var l=0;;)if(l=b},"max-results-bare-rows must be less or equal to than max-results"); +IA=$CLJS.Df([gp(as),$CLJS.Bo,gp(zx),$CLJS.Bo,gp(Mw),$CLJS.Bo,gp(Rv),$CLJS.pp($CLJS.Bo),gp(iq),$CLJS.pp($CLJS.Bo),gp(Zv),$CLJS.pp($CLJS.Bo),$CLJS.Eo,$CLJS.zo]);JA=ip.j($CLJS.F([gq,$s,jq,yu,cq,dt,Js,Lu,Tu,ms,Ip,ir,yw])); +KA=$CLJS.hg([gp(rw),gp(Sx),gp($CLJS.Tt),gp(gw),gp(Mr),gp(gr),gp(zr),gp($CLJS.Qw),gp(px)],[$CLJS.pp($CLJS.Jo),$CLJS.pp($CLJS.Mo),$CLJS.pp(new $CLJS.R(null,1,5,$CLJS.U,[$CLJS.Df([$CLJS.zo,$CLJS.zo])],null)),$CLJS.pp($CLJS.Mo),$CLJS.pp($CLJS.Mo),$CLJS.pp($CLJS.zo),$CLJS.pp($CLJS.Mo),$CLJS.pp(JA),$CLJS.pp($CLJS.Bo)]);LA=$CLJS.Io($CLJS.F([$CLJS.Om(-1337),$CLJS.Mo])); +$CLJS.MA=$CLJS.Um($CLJS.Um($CLJS.Um($CLJS.hg([$CLJS.Eo,gp($CLJS.Dw),gp(Cv),gp($CLJS.ni),gp(bu),gp(uv),$CLJS.Mn,gp($CLJS.Xw),Ox,gp($CLJS.hr)],[$CLJS.zo,pA,$CLJS.pp(GA),$CLJS.pp(KA),$CLJS.pp(HA),$CLJS.pp(IA),ip.j($CLJS.F([$CLJS.Xw,$CLJS.Dw])),$CLJS.qA,LA,FA]),$CLJS.Zh.a($CLJS.$h.a($CLJS.Dw,$CLJS.Xw),$CLJS.Ie($CLJS.Zh.a($CLJS.Dw,$CLJS.Xw))),"Query must specify either `:native` or `:query`, but not both."),function(a){var b=null!=a&&(a.o&64||$CLJS.yc===a.Z)?$CLJS.qe($CLJS.Yh,a):a;a=$CLJS.N.a(b,$CLJS.Dw); +var c=$CLJS.N.a(b,$CLJS.Xw);b=$CLJS.N.a(b,$CLJS.Mn);b=b instanceof $CLJS.P?b.ga:null;switch(b){case "native":return a;case "query":return c;default:throw Error(["No matching clause: ",$CLJS.gb.b(b)].join(""));}},"Native queries must specify `:native`; MBQL queries must specify `:query`."),$CLJS.Ie($CLJS.ys),"`:source-metadata` should be added in the same level as `:source-query` (i.e., the 'inner' MBQL query.)"); +(function(a){var b=qp(a);return function(c){var d=b(c);if($CLJS.q(d))throw $CLJS.Yo($CLJS.vl("Value does not match schema: %s",$CLJS.F([$CLJS.Qg($CLJS.F([d]))])),new $CLJS.n(null,4,[$CLJS.Mn,$CLJS.En,$CLJS.Pl,a,$CLJS.oo,c,$CLJS.li,d],null));return c}})($CLJS.MA); + +/***/ }), + +/***/ "../cljs/metabase.mbql.util.js": +/*!*************************************!*\ + !*** ../cljs/metabase.mbql.util.js ***! + \*************************************/ +/***/ (function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { + +var window=__webpack_require__.g;var $CLJS=__webpack_require__(/*! ./cljs_env */ "../cljs/cljs_env.js");__webpack_require__(/*! ./goog.base.js */ "../cljs/goog.base.js");__webpack_require__(/*! ./cljs.core.js */ "../cljs/cljs.core.js");__webpack_require__(/*! ./clojure.string.js */ "../cljs/clojure.string.js");__webpack_require__(/*! ./metabase.mbql.schema.js */ "../cljs/metabase.mbql.schema.js");__webpack_require__(/*! ./metabase.mbql.schema.helpers.js */ "../cljs/metabase.mbql.schema.helpers.js");__webpack_require__(/*! ./cljs.core.match.js */ "../cljs/cljs.core.match.js");__webpack_require__(/*! ./shadow.js.shim.module$ttag.js */ "../cljs/shadow.js.shim.module$ttag.js");__webpack_require__(/*! ./schema.core.js */ "../cljs/schema.core.js"); +var PA,QA,RA,SA,VA,XA,YA,ZA,$A,aB,eB,iB,lB,mB,nB,oB,pB,qB,rB,sB,uB,WA,vB,wB,yB,zB,AB,BB,CB,DB,EB,FB,GB,HB,IB,JB,KB,LB,MB,NB,OB,PB,QB,RB,SB,TB,UB,VB,XB,YB,ZB,$B,aC,bC,cC,dC,eC;$CLJS.OA=function(a,b,c){$CLJS.jh.N(a.oc,$CLJS.Ng,b,c);$CLJS.kh(a.nc,a.oc,a.ic,a.mc)};PA=function(a){return a+1};QA=function(a,b){a.schema$utils$schema=b};RA=function(a){return $CLJS.dc($CLJS.Gd(function(b,c){return $CLJS.q($CLJS.So.b?$CLJS.So.b(c):$CLJS.So.call(null,c))?$CLJS.af.a(b,c):b},$CLJS.bc($CLJS.ff),a))}; +SA=function(){return function(){function a(f,g,k){f=null==f?0:f;return PA.c?PA.c(f,g,k):PA.call(null,f,g,k)}function b(f,g){f=null==f?0:f;return PA.a?PA.a(f,g):PA.call(null,f,g)}function c(f){f=null==f?0:f;return PA.b?PA.b(f):PA.call(null,f)}var d=null,e=function(){function f(k,l,m,p){var w=null;if(3p)try{y=$CLJS.Yc(d,4);if($CLJS.q($CLJS.Bx.b(y)))return k=$CLJS.Yc(d,2),g=$CLJS.Yc(d,1),l=$CLJS.Yc(d,3),new $CLJS.R(null,4,5,$CLJS.U,[$CLJS.Xq,oB(g,l),new $CLJS.R(null,3,5,$CLJS.U,[$CLJS.Eu,k,l],null),new $CLJS.R(null,3,5,$CLJS.U,[$CLJS.Eu,0,l],null)],null);throw $CLJS.Z;}catch(C){if(C instanceof +Error){var S=C;if(S===$CLJS.Z)return k=$CLJS.Yc(d,2),g=$CLJS.Yc(d,1),l=$CLJS.Yc(d,3),new $CLJS.R(null,4,5,$CLJS.U,[$CLJS.Xq,oB(g,l),new $CLJS.R(null,3,5,$CLJS.U,[$CLJS.Eu,k,l],null),new $CLJS.R(null,3,5,$CLJS.U,[$CLJS.Eu,-1,l],null)],null);throw S;}throw C;}else throw $CLJS.Z;}catch(C){if(C instanceof Error)if(S=C,S===$CLJS.Z)try{y=$CLJS.Yc(d,4);if($CLJS.q($CLJS.Bx.b(y)))return k=$CLJS.Yc(d,2),g=$CLJS.Yc(d,1),l=$CLJS.Yc(d,3),new $CLJS.R(null,4,5,$CLJS.U,[$CLJS.Xq,oB(g,l),new $CLJS.R(null,3,5,$CLJS.U, +[$CLJS.Eu,0,l],null),new $CLJS.R(null,3,5,$CLJS.U,[$CLJS.Eu,k,l],null)],null);throw $CLJS.Z;}catch(E){if(E instanceof Error){y=E;if(y===$CLJS.Z)return k=$CLJS.Yc(d,2),g=$CLJS.Yc(d,1),l=$CLJS.Yc(d,3),new $CLJS.R(null,4,5,$CLJS.U,[$CLJS.Xq,oB(g,l),new $CLJS.R(null,3,5,$CLJS.U,[$CLJS.Eu,1,l],null),new $CLJS.R(null,3,5,$CLJS.U,[$CLJS.Eu,k,l],null)],null);throw y;}throw E;}else throw S;else throw C;}else throw z;else throw A;}else throw M;else throw u;}else throw z;else throw ca;}else throw w;else throw Pa; +}else throw m;else throw Oa;}else throw x;}else throw xa;}else throw $CLJS.Z;}catch(xa){if(xa instanceof Error){x=xa;if(x===$CLJS.Z)throw $CLJS.Z;throw x;}throw xa;}else throw $CLJS.Z;}catch(xa){if(xa instanceof Error){x=xa;if(x===$CLJS.Z)return $CLJS.dB(e,c,d);throw x;}throw xa;}else throw f;else throw la;}}($CLJS.ff,a)}; +qB=function(a){return function e(c,d){try{if($CLJS.qd(d)&&1<=$CLJS.D(d))try{var f=$CLJS.TA(d,0,1);if($CLJS.qd(f)&&1===$CLJS.D(f))try{var g=$CLJS.Yc(f,0);if($CLJS.Zd(g,$CLJS.ru)){var k=$CLJS.UA(d,1);return new $CLJS.R(null,2,5,$CLJS.U,[$CLJS.Dt,$CLJS.bi.a(new $CLJS.R(null,1,5,$CLJS.U,[$CLJS.fw],null),k)],null)}throw $CLJS.Z;}catch(m){if(m instanceof Error){var l=m;if(l===$CLJS.Z)throw $CLJS.Z;throw l;}throw m;}else throw $CLJS.Z;}catch(m){if(m instanceof Error){l=m;if(l===$CLJS.Z)throw $CLJS.Z;throw l; +}throw m;}else throw $CLJS.Z;}catch(m){if(m instanceof Error){l=m;if(l===$CLJS.Z)return $CLJS.dB(e,c,d);throw l;}throw m;}}($CLJS.ff,a)}; +rB=function(a){return function e(c,d){try{if($CLJS.qd(d)&&4<=$CLJS.D(d))try{var f=$CLJS.TA(d,0,4);if($CLJS.qd(f)&&4===$CLJS.D(f))try{var g=$CLJS.Yc(f,0);if($CLJS.Zd(g,$CLJS.qu)){var k=$CLJS.Yc(f,1),l=$CLJS.Yc(f,2),m=$CLJS.Yc(f,3),p=$CLJS.UA(d,4);return $CLJS.re(jB,$CLJS.Gq,function(){return function z(y){return new $CLJS.ae(null,function(){for(;;){var M=$CLJS.t(y);if(M){if($CLJS.rd(M)){var S=$CLJS.ic(M),la=$CLJS.D(S),xa=$CLJS.de(la);a:for(var Oa=0;;)if(Oa(a.b?a.b(c):a.call(null,c))?b:c};Ri.j=function(a,b,c,d){return $CLJS.Gd(function(e,f){return Ri.c(a,e,f)},Ri.c(a,b,c),d)};Ri.H=function(a){var b=$CLJS.v(a),c=$CLJS.B(a);a=$CLJS.v(c);var d=$CLJS.B(c);c=$CLJS.v(d);d=$CLJS.B(d);return this.j(b,a,c,d)};Ri.I=3;var $i=function $i(a){for(var c=[],d=arguments.length,e=0;;)if(e$CLJS.D(a)))throw Error($CLJS.vl("More than one non-optional/required key schemata: %s",$CLJS.F([$CLJS.gf(a)])));return $CLJS.v(a)};en=function(a){return Zm(a)?a instanceof $CLJS.P?a:new $CLJS.Sd(null,Wm(a)?cn:a instanceof $CLJS.Xm?dn:null,new $CLJS.Sd(null,Ym(a),null,1,null),2,null):$CLJS.Jm(a)}; +gn=function(a){var b=bn(a),c=$CLJS.ci.a(en,$CLJS.qe($CLJS.Wh,$CLJS.Pe(function(e){return 1<$CLJS.D(e)},$CLJS.ng($CLJS.$g(Ym,$CLJS.lg($CLJS.Vh.a(a,b)))))));if(!$CLJS.kd(c))throw Error($CLJS.vl("Schema has multiple variants of the same explicit key: %s",$CLJS.F([c])));var d=$CLJS.Vh.a(a,b);return $CLJS.Wh.a(function(){return function g(f){return new $CLJS.ae(null,function(){for(;;){var k=$CLJS.t(f);if(k){var l=k;if($CLJS.rd(l)){var m=$CLJS.ic(l),p=$CLJS.D(m),w=$CLJS.de(p);return function(){for(var M= +0;;)if(M=$CLJS.D(d)&&$CLJS.Fe(function(e){return!(e instanceof $CLJS.nn)},d)))throw Error($CLJS.vl("%s is not a valid sequence schema; %s%s%s",$CLJS.F([a,"a valid sequence schema consists of zero or more `one` elements, ","followed by zero or more `optional` elements, followed by an optional ", +"schema that will match the remaining elements."])));return new $CLJS.R(null,2,5,$CLJS.U,[$CLJS.Wh.a(c,b),$CLJS.v(d)],null)};$CLJS.r.prototype.Xa=$CLJS.La(4,function(a,b){if(b instanceof $CLJS.r)return xm(this,b);throw Error(["Cannot compare ",$CLJS.gb.b(this)," to ",$CLJS.gb.b(b)].join(""));});$CLJS.P.prototype.Xa=$CLJS.La(3,function(a,b){if(b instanceof $CLJS.P)return ym(this,b);throw Error(["Cannot compare ",$CLJS.gb.b(this)," to ",$CLJS.gb.b(b)].join(""));}); +$CLJS.mf.prototype.Xa=$CLJS.La(2,function(a,b){if($CLJS.qd(b))return $CLJS.zd(this,b);throw Error(["Cannot compare ",$CLJS.gb.b(this)," to ",$CLJS.gb.b(b)].join(""));});$CLJS.R.prototype.Xa=$CLJS.La(1,function(a,b){if($CLJS.qd(b))return $CLJS.zd(this,b);throw Error(["Cannot compare ",$CLJS.gb.b(this)," to ",$CLJS.gb.b(b)].join(""));}); +$CLJS.wd.prototype.Xa=$CLJS.La(0,function(a,b){if($CLJS.qd(b))return $CLJS.zd(this,b);throw Error(["Cannot compare ",$CLJS.gb.b(this)," to ",$CLJS.gb.b(b)].join(""));});$CLJS.h=Fm.prototype;$CLJS.h.ld=$CLJS.yc;$CLJS.h.toString=function(){return this.Jb};$CLJS.h.S=function(a,b){return b instanceof Fm&&this.Jb===b.Jb};$CLJS.h.O=function(a,b){return $CLJS.Zb(b,['#uuid "',$CLJS.gb.b(this.Jb),'"'].join(""))};$CLJS.h.T=function(){null==this.v&&(this.v=$CLJS.zc(this.Jb));return this.v}; +$CLJS.h.Xa=function(a,b){return $CLJS.Ma(this.Jb,b.Jb)};pn=new $CLJS.r(null,"Symbol","Symbol",716452869,null);qn=new $CLJS.r(null,"string?","string?",-1129175764,null);rn=new $CLJS.r(null,"invalid-key","invalid-key",-1461682245,null);sn=new $CLJS.r(null,"has-extra-elts?","has-extra-elts?",-1376562869,null);hn=new $CLJS.r(null,"disallowed-key","disallowed-key",-1877785633,null);tn=new $CLJS.P(null,"p?","p?",-1172161701);$CLJS.un=new $CLJS.r(null,"optional","optional",-600484260,null); +$CLJS.vn=new $CLJS.P(null,"input-schemas","input-schemas",-982154805);$CLJS.wn=new $CLJS.P(null,"preds-and-schemas","preds-and-schemas",-1306766355);$CLJS.xn=new $CLJS.r(null,"maybe","maybe",1326133967,null);$CLJS.yn=new $CLJS.r(null,"\x3d\x3e","\x3d\x3e",-813269641,null);zn=new $CLJS.P(null,"postcondition","postcondition",-737101222);$CLJS.An=new $CLJS.r(null,"recursive","recursive",-1935549897,null);Bn=new $CLJS.P(null,"pred-name","pred-name",-3677451);$CLJS.Cn=new $CLJS.P(null,"vs","vs",-2022097090); +Dn=new $CLJS.r(null,"Str","Str",907970895,null);$CLJS.En=new $CLJS.P($CLJS.wm,"error","schema.core/error",1991454308);Fn=new $CLJS.r(null,"sequential?","sequential?",1102351463,null);Gn=new $CLJS.r(null,"pred","pred",-727012372,null);Hn=new $CLJS.r(null,"one","one",-1719427865,null);dn=new $CLJS.r(null,"optional-key","optional-key",988406145,null);In=new $CLJS.r(null,"set?","set?",1636014792,null);Jn=new $CLJS.r(null,"keyword?","keyword?",1917797069,null); +$CLJS.Kn=new $CLJS.r(null,"matches-some-precondition?","matches-some-precondition?",2123072832,null);Ln=new $CLJS.r(null,"symbol?","symbol?",1820680511,null);$CLJS.Mn=new $CLJS.P(null,"type","type",1174270348);$CLJS.Nn=new $CLJS.r(null,"cond-pre","cond-pre",-923707731,null);On=new $CLJS.r(null,"map-entry","map-entry",329617471,null);Pn=new $CLJS.r(null,"integer?","integer?",1303791671,null);Qn=new $CLJS.P(null,"post-name","post-name",491455269); +$CLJS.Rn=new $CLJS.r(null,"conditional","conditional",-1212542970,null);Sn=new $CLJS.r(null,"Num","Num",-2044934708,null);Tn=new $CLJS.r(null,"Inst","Inst",292408622,null);Km=new $CLJS.r(null,"instance?","instance?",1075939923,null);cn=new $CLJS.r(null,"required-key","required-key",1624616412,null);Un=new $CLJS.P(null,"optional?","optional?",1184638129);Vn=new $CLJS.r(null,"constrained","constrained",-2057147788,null);$CLJS.Wn=new $CLJS.P(null,"output-schema","output-schema",272504137); +$CLJS.Xn=new $CLJS.P(null,"schemas","schemas",575070579);$CLJS.Yn=new $CLJS.P(null,"else","else",-1508377146);Zn=new $CLJS.r(null,"re-find","re-find",1143444147,null);$CLJS.$n=new $CLJS.r(null,"enum","enum",-975417337,null);ao=new $CLJS.r(null,"present?","present?",-1810613791,null);$CLJS.bo=new $CLJS.r(null,"\x3d\x3e*","\x3d\x3e*",1909690043,null);$CLJS.co=new $CLJS.r(null,"...","...",-1926939749,null);eo=new $CLJS.r(null,"eq","eq",1021992460,null); +$CLJS.fo=new $CLJS.r(null,"some-matching-condition?","some-matching-condition?",1512398506,null);$CLJS.go=new $CLJS.r(null,"\x3d","\x3d",-1501502141,null);ho=new $CLJS.r(null,"Any","Any",1277492269,null);io=new $CLJS.r("js","RegExp","js/RegExp",1778210562,null);jo=new $CLJS.P(null,"key-schema","key-schema",-1096660726);ko=new $CLJS.P(null,"k","k",-2146297393);lo=new $CLJS.P($CLJS.wm,"missing","schema.core/missing",1420181325);mo=new $CLJS.P(null,"_","_",1453416199);no=new $CLJS.P(null,"v","v",21465059); +$CLJS.oo=new $CLJS.P(null,"value","value",305978217);$CLJS.po=new $CLJS.P(null,"derefable","derefable",377265868);$CLJS.qo=new $CLJS.r(null,"ifn?","ifn?",-2106461064,null);ro=new $CLJS.r(null,"Regex","Regex",205914413,null);so=new $CLJS.r(null,"Bool","Bool",195910502,null);to=new $CLJS.P(null,"val-schema","val-schema",-2014773619);uo=new $CLJS.r(null,"Int","Int",-2116888740,null);vo=new $CLJS.r(null,"Uuid","Uuid",-1866694318,null);kn=new $CLJS.r(null,"map?","map?",-1780568534,null); +$CLJS.wo=new $CLJS.P(null,"error-symbol","error-symbol",-823480428);xo=new $CLJS.r(null,"Keyword","Keyword",-850065993,null);fn=new $CLJS.r(null,"missing-required-key","missing-required-key",709961446,null);var yo;$CLJS.Im["function"]=function(a){var b=Lm(a,a);a=$CLJS.Sa(a,"schema$utils$schema");return $CLJS.q(a)?$CLJS.dm(b,new $CLJS.R(null,1,5,$CLJS.U,[new $CLJS.n(null,1,[$CLJS.Pl,a],null)],null)):$CLJS.Xl(b)}; +$CLJS.Jm["function"]=function(a){var b=$CLJS.Sa(a,"schema$utils$schema");return $CLJS.q(b)?$CLJS.Jm(b):$CLJS.q($CLJS.Xc.a?$CLJS.Xc.a(null,a):$CLJS.Xc.call(null,null,a))?Dn:$CLJS.q($CLJS.Xc.a?$CLJS.Xc.a(Boolean,a):$CLJS.Xc.call(null,Boolean,a))?so:$CLJS.q($CLJS.Xc.a?$CLJS.Xc.a(Number,a):$CLJS.Xc.call(null,Number,a))?Sn:$CLJS.q($CLJS.Xc.a?$CLJS.Xc.a(null,a):$CLJS.Xc.call(null,null,a))?ro:$CLJS.q($CLJS.Xc.a?$CLJS.Xc.a(Date,a):$CLJS.Xc.call(null,Date,a))?Tn:$CLJS.q($CLJS.Xc.a?$CLJS.Xc.a(Fm,a):$CLJS.Xc.call(null, +Fm,a))?vo:a};$CLJS.h=Mm.prototype;$CLJS.h.W=function(a,b){return this.J(null,b,null)};$CLJS.h.J=function(a,b,c){switch(b instanceof $CLJS.P?b.ga:null){case "_":return this.yb;default:return $CLJS.N.c(this.g,b,c)}};$CLJS.h.Ba=function(a,b,c){return $CLJS.Gd(function(d,e){var f=$CLJS.G(e,0,null);e=$CLJS.G(e,1,null);return b.c?b.c(d,f,e):b.call(null,d,f,e)},c,this)}; +$CLJS.h.O=function(a,b,c){return $CLJS.Cg(b,function(d){return $CLJS.Cg(b,$CLJS.Hg,""," ","",c,d)},"#schema.core.AnythingSchema{",", ","}",c,$CLJS.Wh.a(new $CLJS.R(null,1,5,$CLJS.U,[new $CLJS.R(null,2,5,$CLJS.U,[mo,this.yb],null)],null),this.g))};$CLJS.h.ja=function(){return new $CLJS.wf(this,1,new $CLJS.R(null,1,5,$CLJS.U,[mo],null),$CLJS.q(this.g)?$CLJS.oc(this.g):$CLJS.Ce())};$CLJS.h.X=function(){return this.C};$CLJS.h.aa=function(){return 1+$CLJS.D(this.g)}; +$CLJS.h.T=function(){var a=this.v;return null!=a?a:this.v=a=-1432036169^$CLJS.Mc(this)};$CLJS.h.S=function(a,b){return null!=b&&this.constructor===b.constructor&&$CLJS.Xc.a(this.yb,b.yb)&&$CLJS.Xc.a(this.g,b.g)};$CLJS.h.Ea=function(a,b){return $CLJS.vd(new $CLJS.pg(null,new $CLJS.n(null,1,[mo,null],null),null),b)?$CLJS.Vh.a($CLJS.Mb($CLJS.bi.a($CLJS.Be,this),this.C),b):new Mm(this.yb,this.C,$CLJS.xe($CLJS.Vh.a(this.g,b)),null)}; +$CLJS.h.U=function(a,b,c){return $CLJS.q($CLJS.Zd.a?$CLJS.Zd.a(mo,b):$CLJS.Zd.call(null,mo,b))?new Mm(c,this.C,this.g,null):new Mm(this.yb,this.C,$CLJS.Ng.c(this.g,b,c),null)};$CLJS.h.Y=function(){return $CLJS.t($CLJS.Wh.a(new $CLJS.R(null,1,5,$CLJS.U,[new $CLJS.wd(mo,this.yb)],null),this.g))};$CLJS.h.$=function(a,b){return new Mm(this.yb,b,this.g,this.v)};$CLJS.h.ba=function(a,b){return $CLJS.qd(b)?this.U(null,$CLJS.gd(b,0),$CLJS.gd(b,1)):$CLJS.Gd($CLJS.qb,this,b)};$CLJS.h.Ma=function(){return $CLJS.Xl($CLJS.Em)}; +$CLJS.h.La=function(){return ho};$CLJS.zo=new Mm(null,null,null,null);$CLJS.h=Nm.prototype;$CLJS.h.W=function(a,b){return this.J(null,b,null)};$CLJS.h.J=function(a,b,c){switch(b instanceof $CLJS.P?b.ga:null){case "v":return this.fa;default:return $CLJS.N.c(this.g,b,c)}};$CLJS.h.Ba=function(a,b,c){return $CLJS.Gd(function(d,e){var f=$CLJS.G(e,0,null);e=$CLJS.G(e,1,null);return b.c?b.c(d,f,e):b.call(null,d,f,e)},c,this)}; +$CLJS.h.O=function(a,b,c){return $CLJS.Cg(b,function(d){return $CLJS.Cg(b,$CLJS.Hg,""," ","",c,d)},"#schema.core.EqSchema{",", ","}",c,$CLJS.Wh.a(new $CLJS.R(null,1,5,$CLJS.U,[new $CLJS.R(null,2,5,$CLJS.U,[no,this.fa],null)],null),this.g))};$CLJS.h.ja=function(){return new $CLJS.wf(this,1,new $CLJS.R(null,1,5,$CLJS.U,[no],null),$CLJS.q(this.g)?$CLJS.oc(this.g):$CLJS.Ce())};$CLJS.h.X=function(){return this.C};$CLJS.h.aa=function(){return 1+$CLJS.D(this.g)}; +$CLJS.h.T=function(){var a=this.v;return null!=a?a:this.v=a=-907989292^$CLJS.Mc(this)};$CLJS.h.S=function(a,b){return null!=b&&this.constructor===b.constructor&&$CLJS.Xc.a(this.fa,b.fa)&&$CLJS.Xc.a(this.g,b.g)};$CLJS.h.Ea=function(a,b){return $CLJS.vd(new $CLJS.pg(null,new $CLJS.n(null,1,[no,null],null),null),b)?$CLJS.Vh.a($CLJS.Mb($CLJS.bi.a($CLJS.Be,this),this.C),b):new Nm(this.fa,this.C,$CLJS.xe($CLJS.Vh.a(this.g,b)),null)}; +$CLJS.h.U=function(a,b,c){return $CLJS.q($CLJS.Zd.a?$CLJS.Zd.a(no,b):$CLJS.Zd.call(null,no,b))?new Nm(c,this.C,this.g,null):new Nm(this.fa,this.C,$CLJS.Ng.c(this.g,b,c),null)};$CLJS.h.Y=function(){return $CLJS.t($CLJS.Wh.a(new $CLJS.R(null,1,5,$CLJS.U,[new $CLJS.wd(no,this.fa)],null),this.g))};$CLJS.h.$=function(a,b){return new Nm(this.fa,b,this.g,this.v)};$CLJS.h.ba=function(a,b){return $CLJS.qd(b)?this.U(null,$CLJS.gd(b,0),$CLJS.gd(b,1)):$CLJS.Gd($CLJS.qb,this,b)}; +$CLJS.h.Ma=function(){var a=this;return $CLJS.Xl($CLJS.Ml(this,function(b){return $CLJS.Xc.a(a.fa,b)},function(b){return new $CLJS.Sd(null,$CLJS.go,new $CLJS.Sd(null,a.fa,new $CLJS.Sd(null,b,null,1,null),2,null),3,null)}))};$CLJS.h.La=function(){return new $CLJS.Sd(null,eo,new $CLJS.Sd(null,this.fa,null,1,null),2,null)};$CLJS.h=Pm.prototype;$CLJS.h.W=function(a,b){return this.J(null,b,null)}; +$CLJS.h.J=function(a,b,c){switch(b instanceof $CLJS.P?b.ga:null){case "p?":return this.Va;case "pred-name":return this.mb;default:return $CLJS.N.c(this.g,b,c)}};$CLJS.h.Ba=function(a,b,c){return $CLJS.Gd(function(d,e){var f=$CLJS.G(e,0,null);e=$CLJS.G(e,1,null);return b.c?b.c(d,f,e):b.call(null,d,f,e)},c,this)}; +$CLJS.h.O=function(a,b,c){return $CLJS.Cg(b,function(d){return $CLJS.Cg(b,$CLJS.Hg,""," ","",c,d)},"#schema.core.Predicate{",", ","}",c,$CLJS.Wh.a(new $CLJS.R(null,2,5,$CLJS.U,[new $CLJS.R(null,2,5,$CLJS.U,[tn,this.Va],null),new $CLJS.R(null,2,5,$CLJS.U,[Bn,this.mb],null)],null),this.g))};$CLJS.h.ja=function(){return new $CLJS.wf(this,2,new $CLJS.R(null,2,5,$CLJS.U,[tn,Bn],null),$CLJS.q(this.g)?$CLJS.oc(this.g):$CLJS.Ce())};$CLJS.h.X=function(){return this.C};$CLJS.h.aa=function(){return 2+$CLJS.D(this.g)}; +$CLJS.h.T=function(){var a=this.v;return null!=a?a:this.v=a=2041221968^$CLJS.Mc(this)};$CLJS.h.S=function(a,b){return null!=b&&this.constructor===b.constructor&&$CLJS.Xc.a(this.Va,b.Va)&&$CLJS.Xc.a(this.mb,b.mb)&&$CLJS.Xc.a(this.g,b.g)};$CLJS.h.Ea=function(a,b){return $CLJS.vd(new $CLJS.pg(null,new $CLJS.n(null,2,[Bn,null,tn,null],null),null),b)?$CLJS.Vh.a($CLJS.Mb($CLJS.bi.a($CLJS.Be,this),this.C),b):new Pm(this.Va,this.mb,this.C,$CLJS.xe($CLJS.Vh.a(this.g,b)),null)}; +$CLJS.h.U=function(a,b,c){return $CLJS.q($CLJS.Zd.a?$CLJS.Zd.a(tn,b):$CLJS.Zd.call(null,tn,b))?new Pm(c,this.mb,this.C,this.g,null):$CLJS.q($CLJS.Zd.a?$CLJS.Zd.a(Bn,b):$CLJS.Zd.call(null,Bn,b))?new Pm(this.Va,c,this.C,this.g,null):new Pm(this.Va,this.mb,this.C,$CLJS.Ng.c(this.g,b,c),null)};$CLJS.h.Y=function(){return $CLJS.t($CLJS.Wh.a(new $CLJS.R(null,2,5,$CLJS.U,[new $CLJS.wd(tn,this.Va),new $CLJS.wd(Bn,this.mb)],null),this.g))};$CLJS.h.$=function(a,b){return new Pm(this.Va,this.mb,b,this.g,this.v)}; +$CLJS.h.ba=function(a,b){return $CLJS.qd(b)?this.U(null,$CLJS.gd(b,0),$CLJS.gd(b,1)):$CLJS.Gd($CLJS.qb,this,b)};$CLJS.h.Ma=function(){var a=this;return $CLJS.Xl($CLJS.Ml(this,a.Va,function(b){return new $CLJS.Sd(null,a.mb,new $CLJS.Sd(null,b,null,1,null),2,null)}))};$CLJS.h.La=function(){return $CLJS.Xc.a(this.Va,$CLJS.Dm)?uo:$CLJS.Xc.a(this.Va,$CLJS.Gm)?xo:$CLJS.Xc.a(this.Va,Hm)?pn:$CLJS.Xc.a(this.Va,$CLJS.zm)?Dn:new $CLJS.Sd(null,Gn,new $CLJS.Sd(null,this.mb,null,1,null),2,null)}; +RegExp.prototype.Ma=function(){var a=this;return $CLJS.Xl($CLJS.$h.a($CLJS.Ml(a,$CLJS.zm,function(b){return new $CLJS.Sd(null,qn,new $CLJS.Sd(null,b,null,1,null),2,null)}),$CLJS.Ml(a,function(b){return $CLJS.zg(a,b)},function(b){return new $CLJS.Sd(null,Zn,new $CLJS.Sd(null,$CLJS.Jm(a),new $CLJS.Sd(null,b,null,1,null),2,null),3,null)})))};RegExp.prototype.La=function(){return $CLJS.Rg.b(['#"',$CLJS.gb.b($CLJS.gb.b(this).slice(1,-1)),'"'].join(""))};$CLJS.Ao=$CLJS.Qm($CLJS.zm,qn);$CLJS.Bo=Boolean; +$CLJS.Co=Number;$CLJS.Do=$CLJS.Qm($CLJS.Dm,Pn);$CLJS.Eo=$CLJS.Qm($CLJS.Gm,Jn);$CLJS.Qm(Hm,Ln); +"undefined"===typeof yo&&(yo=function(a){this.rd=a;this.o=393216;this.K=0},yo.prototype.$=function(a,b){return new yo(b)},yo.prototype.X=function(){return this.rd},yo.prototype.Ma=function(){return $CLJS.Xl($CLJS.Ml(this,function(a){return a instanceof RegExp},function(a){return new $CLJS.Sd(null,Km,new $CLJS.Sd(null,io,new $CLJS.Sd(null,a,null,1,null),2,null),3,null)}))},yo.prototype.La=function(){return ro},yo.xc=!0,yo.ac="schema.core/t_schema$core12944",yo.Kc=function(a){return $CLJS.Zb(a,"schema.core/t_schema$core12944")}); +new yo($CLJS.Be);$CLJS.h=Rm.prototype;$CLJS.h.W=function(a,b){return this.J(null,b,null)};$CLJS.h.J=function(a,b,c){switch(b instanceof $CLJS.P?b.ga:null){case "schema":return this.P;case "name":return this.name;default:return $CLJS.N.c(this.g,b,c)}};$CLJS.h.Ba=function(a,b,c){return $CLJS.Gd(function(d,e){var f=$CLJS.G(e,0,null);e=$CLJS.G(e,1,null);return b.c?b.c(d,f,e):b.call(null,d,f,e)},c,this)}; +$CLJS.h.O=function(a,b,c){return $CLJS.Cg(b,function(d){return $CLJS.Cg(b,$CLJS.Hg,""," ","",c,d)},"#schema.core.NamedSchema{",", ","}",c,$CLJS.Wh.a(new $CLJS.R(null,2,5,$CLJS.U,[new $CLJS.R(null,2,5,$CLJS.U,[$CLJS.Pl,this.P],null),new $CLJS.R(null,2,5,$CLJS.U,[$CLJS.V,this.name],null)],null),this.g))};$CLJS.h.ja=function(){return new $CLJS.wf(this,2,new $CLJS.R(null,2,5,$CLJS.U,[$CLJS.Pl,$CLJS.V],null),$CLJS.q(this.g)?$CLJS.oc(this.g):$CLJS.Ce())};$CLJS.h.X=function(){return this.C}; +$CLJS.h.aa=function(){return 2+$CLJS.D(this.g)};$CLJS.h.T=function(){var a=this.v;return null!=a?a:this.v=a=456601728^$CLJS.Mc(this)};$CLJS.h.S=function(a,b){return null!=b&&this.constructor===b.constructor&&$CLJS.Xc.a(this.P,b.P)&&$CLJS.Xc.a(this.name,b.name)&&$CLJS.Xc.a(this.g,b.g)}; +$CLJS.h.Ea=function(a,b){return $CLJS.vd(new $CLJS.pg(null,new $CLJS.n(null,2,[$CLJS.Pl,null,$CLJS.V,null],null),null),b)?$CLJS.Vh.a($CLJS.Mb($CLJS.bi.a($CLJS.Be,this),this.C),b):new Rm(this.P,this.name,this.C,$CLJS.xe($CLJS.Vh.a(this.g,b)),null)}; +$CLJS.h.U=function(a,b,c){return $CLJS.q($CLJS.Zd.a?$CLJS.Zd.a($CLJS.Pl,b):$CLJS.Zd.call(null,$CLJS.Pl,b))?new Rm(c,this.name,this.C,this.g,null):$CLJS.q($CLJS.Zd.a?$CLJS.Zd.a($CLJS.V,b):$CLJS.Zd.call(null,$CLJS.V,b))?new Rm(this.P,c,this.C,this.g,null):new Rm(this.P,this.name,this.C,$CLJS.Ng.c(this.g,b,c),null)};$CLJS.h.Y=function(){return $CLJS.t($CLJS.Wh.a(new $CLJS.R(null,2,5,$CLJS.U,[new $CLJS.wd($CLJS.Pl,this.P),new $CLJS.wd($CLJS.V,this.name)],null),this.g))}; +$CLJS.h.$=function(a,b){return new Rm(this.P,this.name,b,this.g,this.v)};$CLJS.h.ba=function(a,b){return $CLJS.qd(b)?this.U(null,$CLJS.gd(b,0),$CLJS.gd(b,1)):$CLJS.Gd($CLJS.qb,this,b)};$CLJS.h.Ma=function(){var a=this;return $CLJS.dm($CLJS.Em,new $CLJS.R(null,1,5,$CLJS.U,[new $CLJS.n(null,2,[$CLJS.Pl,a.P,$CLJS.$l,function(b){return new $CLJS.El(a.name,b)}],null)],null))}; +$CLJS.h.La=function(){return new $CLJS.Sd(null,$CLJS.Fl,new $CLJS.Sd(null,$CLJS.Jm(this.P),new $CLJS.Sd(null,this.name,null,1,null),2,null),3,null)};$CLJS.Wl.prototype.Gb=$CLJS.Ka(12);$CLJS.bm.prototype.Gb=$CLJS.Ka(11);$CLJS.nm.prototype.Gb=$CLJS.Ka(10);$CLJS.h=Tm.prototype;$CLJS.h.W=function(a,b){return this.J(null,b,null)}; +$CLJS.h.J=function(a,b,c){switch(b instanceof $CLJS.P?b.ga:null){case "schema":return this.P;case "postcondition":return this.lb;case "post-name":return this.bb;default:return $CLJS.N.c(this.g,b,c)}};$CLJS.h.Ba=function(a,b,c){return $CLJS.Gd(function(d,e){var f=$CLJS.G(e,0,null);e=$CLJS.G(e,1,null);return b.c?b.c(d,f,e):b.call(null,d,f,e)},c,this)}; +$CLJS.h.O=function(a,b,c){return $CLJS.Cg(b,function(d){return $CLJS.Cg(b,$CLJS.Hg,""," ","",c,d)},"#schema.core.Constrained{",", ","}",c,$CLJS.Wh.a(new $CLJS.R(null,3,5,$CLJS.U,[new $CLJS.R(null,2,5,$CLJS.U,[$CLJS.Pl,this.P],null),new $CLJS.R(null,2,5,$CLJS.U,[zn,this.lb],null),new $CLJS.R(null,2,5,$CLJS.U,[Qn,this.bb],null)],null),this.g))};$CLJS.h.ja=function(){return new $CLJS.wf(this,3,new $CLJS.R(null,3,5,$CLJS.U,[$CLJS.Pl,zn,Qn],null),$CLJS.q(this.g)?$CLJS.oc(this.g):$CLJS.Ce())}; +$CLJS.h.X=function(){return this.C};$CLJS.h.aa=function(){return 3+$CLJS.D(this.g)};$CLJS.h.T=function(){var a=this.v;return null!=a?a:this.v=a=725895648^$CLJS.Mc(this)};$CLJS.h.S=function(a,b){return null!=b&&this.constructor===b.constructor&&$CLJS.Xc.a(this.P,b.P)&&$CLJS.Xc.a(this.lb,b.lb)&&$CLJS.Xc.a(this.bb,b.bb)&&$CLJS.Xc.a(this.g,b.g)}; +$CLJS.h.Ea=function(a,b){return $CLJS.vd(new $CLJS.pg(null,new $CLJS.n(null,3,[$CLJS.Pl,null,Qn,null,zn,null],null),null),b)?$CLJS.Vh.a($CLJS.Mb($CLJS.bi.a($CLJS.Be,this),this.C),b):new Tm(this.P,this.lb,this.bb,this.C,$CLJS.xe($CLJS.Vh.a(this.g,b)),null)}; +$CLJS.h.U=function(a,b,c){return $CLJS.q($CLJS.Zd.a?$CLJS.Zd.a($CLJS.Pl,b):$CLJS.Zd.call(null,$CLJS.Pl,b))?new Tm(c,this.lb,this.bb,this.C,this.g,null):$CLJS.q($CLJS.Zd.a?$CLJS.Zd.a(zn,b):$CLJS.Zd.call(null,zn,b))?new Tm(this.P,c,this.bb,this.C,this.g,null):$CLJS.q($CLJS.Zd.a?$CLJS.Zd.a(Qn,b):$CLJS.Zd.call(null,Qn,b))?new Tm(this.P,this.lb,c,this.C,this.g,null):new Tm(this.P,this.lb,this.bb,this.C,$CLJS.Ng.c(this.g,b,c),null)}; +$CLJS.h.Y=function(){return $CLJS.t($CLJS.Wh.a(new $CLJS.R(null,3,5,$CLJS.U,[new $CLJS.wd($CLJS.Pl,this.P),new $CLJS.wd(zn,this.lb),new $CLJS.wd(Qn,this.bb)],null),this.g))};$CLJS.h.$=function(a,b){return new Tm(this.P,this.lb,this.bb,b,this.g,this.v)};$CLJS.h.ba=function(a,b){return $CLJS.qd(b)?this.U(null,$CLJS.gd(b,0),$CLJS.gd(b,1)):$CLJS.Gd($CLJS.qb,this,b)}; +$CLJS.h.Ma=function(){var a=this;return $CLJS.em($CLJS.Em,new $CLJS.R(null,1,5,$CLJS.U,[new $CLJS.n(null,1,[$CLJS.Pl,a.P],null)],null),null,$CLJS.Ml(this,a.lb,function(b){return new $CLJS.Sd(null,a.bb,new $CLJS.Sd(null,b,null,1,null),2,null)}))};$CLJS.h.La=function(){return new $CLJS.Sd(null,Vn,new $CLJS.Sd(null,$CLJS.Jm(this.P),new $CLJS.Sd(null,this.bb,null,1,null),2,null),3,null)};$CLJS.h=$CLJS.Xm.prototype;$CLJS.h.W=function(a,b){return this.J(null,b,null)}; +$CLJS.h.J=function(a,b,c){switch(b instanceof $CLJS.P?b.ga:null){case "k":return this.k;default:return $CLJS.N.c(this.g,b,c)}};$CLJS.h.Ba=function(a,b,c){return $CLJS.Gd(function(d,e){var f=$CLJS.G(e,0,null);e=$CLJS.G(e,1,null);return b.c?b.c(d,f,e):b.call(null,d,f,e)},c,this)}; +$CLJS.h.O=function(a,b,c){return $CLJS.Cg(b,function(d){return $CLJS.Cg(b,$CLJS.Hg,""," ","",c,d)},"#schema.core.OptionalKey{",", ","}",c,$CLJS.Wh.a(new $CLJS.R(null,1,5,$CLJS.U,[new $CLJS.R(null,2,5,$CLJS.U,[ko,this.k],null)],null),this.g))};$CLJS.h.ja=function(){return new $CLJS.wf(this,1,new $CLJS.R(null,1,5,$CLJS.U,[ko],null),$CLJS.q(this.g)?$CLJS.oc(this.g):$CLJS.Ce())};$CLJS.h.X=function(){return this.C};$CLJS.h.aa=function(){return 1+$CLJS.D(this.g)}; +$CLJS.h.T=function(){var a=this.v;return null!=a?a:this.v=a=-1508333161^$CLJS.Mc(this)};$CLJS.h.S=function(a,b){return null!=b&&this.constructor===b.constructor&&$CLJS.Xc.a(this.k,b.k)&&$CLJS.Xc.a(this.g,b.g)};$CLJS.h.Ea=function(a,b){return $CLJS.vd(new $CLJS.pg(null,new $CLJS.n(null,1,[ko,null],null),null),b)?$CLJS.Vh.a($CLJS.Mb($CLJS.bi.a($CLJS.Be,this),this.C),b):new $CLJS.Xm(this.k,this.C,$CLJS.xe($CLJS.Vh.a(this.g,b)),null)}; +$CLJS.h.U=function(a,b,c){return $CLJS.q($CLJS.Zd.a?$CLJS.Zd.a(ko,b):$CLJS.Zd.call(null,ko,b))?new $CLJS.Xm(c,this.C,this.g,null):new $CLJS.Xm(this.k,this.C,$CLJS.Ng.c(this.g,b,c),null)};$CLJS.h.Y=function(){return $CLJS.t($CLJS.Wh.a(new $CLJS.R(null,1,5,$CLJS.U,[new $CLJS.wd(ko,this.k)],null),this.g))};$CLJS.h.$=function(a,b){return new $CLJS.Xm(this.k,b,this.g,this.v)};$CLJS.h.ba=function(a,b){return $CLJS.qd(b)?this.U(null,$CLJS.gd(b,0),$CLJS.gd(b,1)):$CLJS.Gd($CLJS.qb,this,b)};$CLJS.h=an.prototype; +$CLJS.h.W=function(a,b){return this.J(null,b,null)};$CLJS.h.J=function(a,b,c){switch(b instanceof $CLJS.P?b.ga:null){case "key-schema":return this.gb;case "val-schema":return this.nb;default:return $CLJS.N.c(this.g,b,c)}};$CLJS.h.Ba=function(a,b,c){return $CLJS.Gd(function(d,e){var f=$CLJS.G(e,0,null);e=$CLJS.G(e,1,null);return b.c?b.c(d,f,e):b.call(null,d,f,e)},c,this)}; +$CLJS.h.O=function(a,b,c){return $CLJS.Cg(b,function(d){return $CLJS.Cg(b,$CLJS.Hg,""," ","",c,d)},"#schema.core.MapEntry{",", ","}",c,$CLJS.Wh.a(new $CLJS.R(null,2,5,$CLJS.U,[new $CLJS.R(null,2,5,$CLJS.U,[jo,this.gb],null),new $CLJS.R(null,2,5,$CLJS.U,[to,this.nb],null)],null),this.g))};$CLJS.h.ja=function(){return new $CLJS.wf(this,2,new $CLJS.R(null,2,5,$CLJS.U,[jo,to],null),$CLJS.q(this.g)?$CLJS.oc(this.g):$CLJS.Ce())};$CLJS.h.X=function(){return this.C};$CLJS.h.aa=function(){return 2+$CLJS.D(this.g)}; +$CLJS.h.T=function(){var a=this.v;return null!=a?a:this.v=a=-804356212^$CLJS.Mc(this)};$CLJS.h.S=function(a,b){return null!=b&&this.constructor===b.constructor&&$CLJS.Xc.a(this.gb,b.gb)&&$CLJS.Xc.a(this.nb,b.nb)&&$CLJS.Xc.a(this.g,b.g)};$CLJS.h.Ea=function(a,b){return $CLJS.vd(new $CLJS.pg(null,new $CLJS.n(null,2,[jo,null,to,null],null),null),b)?$CLJS.Vh.a($CLJS.Mb($CLJS.bi.a($CLJS.Be,this),this.C),b):new an(this.gb,this.nb,this.C,$CLJS.xe($CLJS.Vh.a(this.g,b)),null)}; +$CLJS.h.U=function(a,b,c){return $CLJS.q($CLJS.Zd.a?$CLJS.Zd.a(jo,b):$CLJS.Zd.call(null,jo,b))?new an(c,this.nb,this.C,this.g,null):$CLJS.q($CLJS.Zd.a?$CLJS.Zd.a(to,b):$CLJS.Zd.call(null,to,b))?new an(this.gb,c,this.C,this.g,null):new an(this.gb,this.nb,this.C,$CLJS.Ng.c(this.g,b,c),null)};$CLJS.h.Y=function(){return $CLJS.t($CLJS.Wh.a(new $CLJS.R(null,2,5,$CLJS.U,[new $CLJS.wd(jo,this.gb),new $CLJS.wd(to,this.nb)],null),this.g))};$CLJS.h.$=function(a,b){return new an(this.gb,this.nb,b,this.g,this.v)}; +$CLJS.h.ba=function(a,b){return $CLJS.qd(b)?this.U(null,$CLJS.gd(b,0),$CLJS.gd(b,1)):$CLJS.Gd($CLJS.qb,this,b)}; +$CLJS.h.Ma=function(){return $CLJS.om($CLJS.Em,$m,new $CLJS.R(null,2,5,$CLJS.U,[$CLJS.rm(!0,this.gb,function(a,b){var c=$CLJS.Db(b);a.b?a.b(c):a.call(null,c);return b}),$CLJS.rm(!0,this.nb,function(a,b){b=$CLJS.Eb(b);a.b?a.b(b):a.call(null,b);return null})],null),function(a,b){a=$CLJS.G(a,0,null);var c=$CLJS.G(b,0,null);b=$CLJS.G(b,1,null);c=$CLJS.Kl(c);return $CLJS.q(c)?new $CLJS.R(null,2,5,$CLJS.U,[c,rn],null):new $CLJS.R(null,2,5,$CLJS.U,[a,$CLJS.Kl(b)],null)})}; +$CLJS.h.La=function(){return new $CLJS.Sd(null,On,new $CLJS.Sd(null,$CLJS.Jm(this.gb),new $CLJS.Sd(null,$CLJS.Jm(this.nb),null,1,null),2,null),3,null)};$CLJS.n.prototype.Ma=function(){return ln(this)};$CLJS.n.prototype.La=function(){return mn(this)};$CLJS.gg.prototype.Ma=function(){return ln(this)};$CLJS.gg.prototype.La=function(){return mn(this)}; +$CLJS.pg.prototype.Ma=function(){if(!$CLJS.Xc.a($CLJS.D(this),1))throw Error($CLJS.wl("Set schema must have exactly one element"));return $CLJS.om($CLJS.Ml(this,$CLJS.md,function(a){return new $CLJS.Sd(null,In,new $CLJS.Sd(null,a,null,1,null),2,null)}),$CLJS.tg,new $CLJS.R(null,1,5,$CLJS.U,[$CLJS.pm($CLJS.v(this))],null),function(a,b){return $CLJS.tg($CLJS.Je($CLJS.Kl,b))})};$CLJS.pg.prototype.La=function(){return $CLJS.tg(new $CLJS.R(null,1,5,$CLJS.U,[$CLJS.Jm($CLJS.v(this))],null))};$CLJS.h=$CLJS.nn.prototype; +$CLJS.h.W=function(a,b){return this.J(null,b,null)};$CLJS.h.J=function(a,b,c){switch(b instanceof $CLJS.P?b.ga:null){case "schema":return this.P;case "optional?":return this.Ra;case "name":return this.name;default:return $CLJS.N.c(this.g,b,c)}};$CLJS.h.Ba=function(a,b,c){return $CLJS.Gd(function(d,e){var f=$CLJS.G(e,0,null);e=$CLJS.G(e,1,null);return b.c?b.c(d,f,e):b.call(null,d,f,e)},c,this)}; +$CLJS.h.O=function(a,b,c){return $CLJS.Cg(b,function(d){return $CLJS.Cg(b,$CLJS.Hg,""," ","",c,d)},"#schema.core.One{",", ","}",c,$CLJS.Wh.a(new $CLJS.R(null,3,5,$CLJS.U,[new $CLJS.R(null,2,5,$CLJS.U,[$CLJS.Pl,this.P],null),new $CLJS.R(null,2,5,$CLJS.U,[Un,this.Ra],null),new $CLJS.R(null,2,5,$CLJS.U,[$CLJS.V,this.name],null)],null),this.g))};$CLJS.h.ja=function(){return new $CLJS.wf(this,3,new $CLJS.R(null,3,5,$CLJS.U,[$CLJS.Pl,Un,$CLJS.V],null),$CLJS.q(this.g)?$CLJS.oc(this.g):$CLJS.Ce())}; +$CLJS.h.X=function(){return this.C};$CLJS.h.aa=function(){return 3+$CLJS.D(this.g)};$CLJS.h.T=function(){var a=this.v;return null!=a?a:this.v=a=-197981045^$CLJS.Mc(this)};$CLJS.h.S=function(a,b){return null!=b&&this.constructor===b.constructor&&$CLJS.Xc.a(this.P,b.P)&&$CLJS.Xc.a(this.Ra,b.Ra)&&$CLJS.Xc.a(this.name,b.name)&&$CLJS.Xc.a(this.g,b.g)}; +$CLJS.h.Ea=function(a,b){return $CLJS.vd(new $CLJS.pg(null,new $CLJS.n(null,3,[$CLJS.Pl,null,$CLJS.V,null,Un,null],null),null),b)?$CLJS.Vh.a($CLJS.Mb($CLJS.bi.a($CLJS.Be,this),this.C),b):new $CLJS.nn(this.P,this.Ra,this.name,this.C,$CLJS.xe($CLJS.Vh.a(this.g,b)),null)}; +$CLJS.h.U=function(a,b,c){return $CLJS.q($CLJS.Zd.a?$CLJS.Zd.a($CLJS.Pl,b):$CLJS.Zd.call(null,$CLJS.Pl,b))?new $CLJS.nn(c,this.Ra,this.name,this.C,this.g,null):$CLJS.q($CLJS.Zd.a?$CLJS.Zd.a(Un,b):$CLJS.Zd.call(null,Un,b))?new $CLJS.nn(this.P,c,this.name,this.C,this.g,null):$CLJS.q($CLJS.Zd.a?$CLJS.Zd.a($CLJS.V,b):$CLJS.Zd.call(null,$CLJS.V,b))?new $CLJS.nn(this.P,this.Ra,c,this.C,this.g,null):new $CLJS.nn(this.P,this.Ra,this.name,this.C,$CLJS.Ng.c(this.g,b,c),null)}; +$CLJS.h.Y=function(){return $CLJS.t($CLJS.Wh.a(new $CLJS.R(null,3,5,$CLJS.U,[new $CLJS.wd($CLJS.Pl,this.P),new $CLJS.wd(Un,this.Ra),new $CLJS.wd($CLJS.V,this.name)],null),this.g))};$CLJS.h.$=function(a,b){return new $CLJS.nn(this.P,this.Ra,this.name,b,this.g,this.v)};$CLJS.h.ba=function(a,b){return $CLJS.qd(b)?this.U(null,$CLJS.gd(b,0),$CLJS.gd(b,1)):$CLJS.Gd($CLJS.qb,this,b)}; +$CLJS.R.prototype.Ma=function(){var a=this;return $CLJS.om($CLJS.Ml(a,function(b){return null==b||$CLJS.nd(b)},function(b){return new $CLJS.Sd(null,Fn,new $CLJS.Sd(null,b,null,1,null),2,null)}),$CLJS.gf,function(){var b=on(a),c=$CLJS.G(b,0,null);b=$CLJS.G(b,1,null);return $CLJS.Gd(function(d,e){return $CLJS.bb(e.Ra)?$CLJS.Yd($CLJS.rm(!0,$CLJS.Sm(e.P,e.name),function(f,g){if(g=$CLJS.t(g)){var k=$CLJS.v(g);f.b?f.b(k):f.call(null,k);return $CLJS.Hc(g)}g=$CLJS.Il($CLJS.Dl(e.P,lo,new $CLJS.Wg(function(){return new $CLJS.Sd(null, +ao,new $CLJS.Sd(null,e.name,null,1,null),2,null)}),null));f.b?f.b(g):f.call(null,g);return null}),d):new $CLJS.R(null,1,5,$CLJS.U,[$CLJS.sm($CLJS.Sm(e.P,e.name),function(f,g){if(g=$CLJS.t(g)){var k=$CLJS.v(g);f.b?f.b(k):f.call(null,k);return $CLJS.Hc(g)}return null},d)],null)},$CLJS.q(b)?new $CLJS.R(null,1,5,$CLJS.U,[$CLJS.pm(b)],null):null,$CLJS.Wd(c))}(),function(b,c,d){b=$CLJS.ci.a($CLJS.Kl,c);return $CLJS.t(d)?$CLJS.Vd.a(b,$CLJS.Kl($CLJS.Il($CLJS.Dl(null,d,new $CLJS.Wg(function(){return new $CLJS.Sd(null, +sn,new $CLJS.Sd(null,$CLJS.D(d),null,1,null),2,null)}),null)))):b})}; +$CLJS.R.prototype.La=function(){var a=on(this),b=$CLJS.G(a,0,null);a=$CLJS.G(a,1,null);return $CLJS.gf($CLJS.Wh.a(function(){return function e(d){return new $CLJS.ae(null,function(){for(;;){var f=$CLJS.t(d);if(f){if($CLJS.rd(f)){var g=$CLJS.ic(f),k=$CLJS.D(g),l=$CLJS.de(k);a:for(var m=0;;)if(m= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-nocheck + + + + + + + + +/** + * A dimension option returned by the query_metadata API + */ + +/* Heirarchy: + * + * - Dimension (abstract) + * - FieldDimension + * - ExpressionDimension + * - AggregationDimension + * - TemplateTagDimension + */ + +/** + * Dimension base class, represents an MBQL field reference. + * + * Used for displaying fields (like Created At) and their "sub-dimensions" (like Created At by Day) + * in field lists and active value widgets for filters, aggregations and breakouts. + * + * @abstract + */ +var Dimension = /*#__PURE__*/function () { + // Display names provided by the backend + + /** + * Dimension constructor + */ + function Dimension(parent, args, metadata, query) { + _classCallCheck(this, Dimension); + + this._parent = parent; + this._args = args; + this._metadata = metadata || parent && parent._metadata; + this._query = query || parent && parent._query; + } + /** + * Parses an MBQL expression into an appropriate Dimension subclass, if possible. + * Metadata should be provided if you intend to use the display name or render methods. + */ + + + _createClass(Dimension, [{ + key: "parseMBQL", + value: function parseMBQL(mbql) { + return Dimension.parseMBQL(mbql, this._metadata, this._query); + } + /** + * Returns true if these two dimensions are identical to one another. + */ + + }, { + key: Symbol.toStringTag, + get: // for nice debugging/console output. + function get() { + return "mbql = " + JSON.stringify(this.mbql()); + } + /** + * Sub-dimensions for the provided dimension of this type. + * @abstract + */ + // TODO Atte Keinänen 5/21/17: Rename either this or the instance method with the same name + // Also making it clear in the method name that we're working with sub-dimensions would be good + + }, { + key: "dimensions", + value: + /** + * Returns "sub-dimensions" of this dimension. + * @abstract + */ + // TODO Atte Keinänen 5/21/17: Rename either this or the static method with the same name + // Also making it clear in the method name that we're working with sub-dimensions would be good + function dimensions(DimensionTypes) { + var _this = this; + + var dimensionOptions = this.field().dimension_options; + + if (!DimensionTypes && dimensionOptions) { + return dimensionOptions.map(function (option) { + return _this._dimensionForOption(option); + }); + } else { + var _ref; + + return (_ref = []).concat.apply(_ref, _toConsumableArray((DimensionTypes || []).map(function (DimensionType) { + return DimensionType.dimensions(_this); + }))); + } + } + /** + * Returns the default sub-dimension of this dimension, if any. + * @abstract + */ + + }, { + key: "defaultDimension", + value: function defaultDimension() { + var DimensionTypes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DIMENSION_TYPES; + var defaultDimensionOption = this.field().default_dimension_option; + + if (defaultDimensionOption) { + var dimension = this._dimensionForOption(defaultDimensionOption); // NOTE: temporarily disable for DatetimeFieldDimension until backend automatically picks appropriate bucketing + + + if (!(isFieldDimension(dimension) && dimension.temporalUnit())) { + return dimension; + } + } + + var _iterator = _createForOfIteratorHelper(DimensionTypes), + _step; + + try { + for (_iterator.s(); !(_step = _iterator.n()).done;) { + var DimensionType = _step.value; + var defaultDimension = DimensionType.defaultDimension(this); + + if (defaultDimension) { + return defaultDimension; + } + } + } catch (err) { + _iterator.e(err); + } finally { + _iterator.f(); + } + + return null; + } + /** + * Internal method gets a Dimension from a DimensionOption + */ + + }, { + key: "_dimensionForOption", + value: function _dimensionForOption(option) { + // fill in the parent field ref + var fieldRef = this.baseDimension().mbql(); + var mbql = option.mbql; + + if (mbql) { + mbql = [mbql[0], fieldRef].concat(_toConsumableArray(mbql.slice(2))); + } else { + mbql = fieldRef; + } + + var dimension = this.parseMBQL(mbql); + + if (dimension && option.name) { + dimension._subDisplayName = option.name; + dimension._subTriggerDisplayName = option.name; + } + + return dimension; + } + /** + * Is this dimension idential to another dimension or MBQL clause + */ + + }, { + key: "isEqual", + value: function isEqual(other) { + if (other == null) { + return false; + } + + var otherDimension = other instanceof Dimension ? other : this.parseMBQL(other); + + if (!otherDimension) { + return false; + } // assumes .mbql() returns canonical form + + + return underscore__WEBPACK_IMPORTED_MODULE_1__.default.isEqual(this.mbql(), otherDimension.mbql()); + } + /** + * Does this dimension have the same underlying base dimension, typically a field + */ + + }, { + key: "isSameBaseDimension", + value: function isSameBaseDimension(other) { + if (other == null) { + return false; + } + + var otherDimension = other instanceof Dimension ? other : this.parseMBQL(other); + var baseDimensionA = this.baseDimension(); + var baseDimensionB = otherDimension && otherDimension.baseDimension(); + return !!baseDimensionA && !!baseDimensionB && baseDimensionA.isEqual(baseDimensionB); + } + /** + * The base dimension of this dimension, typically a field. May return itself. + */ + + }, { + key: "baseDimension", + value: function baseDimension() { + return this; + } + }, { + key: "foreign", + value: function foreign(dimension) { + return null; + } + }, { + key: "datetime", + value: function datetime(unit) { + return null; + } + /** + * The underlying field for this dimension + */ + + }, { + key: "field", + value: function field() { + return new _metadata_Field__WEBPACK_IMPORTED_MODULE_5__.default(); + } + /** + * The `name` appearing in the column object (except duplicates would normally be suffxied) + */ + + }, { + key: "columnName", + value: function columnName() { + return this.field().name; + } // FILTERS + + /** + * Valid filter operators on this dimension + */ + + }, { + key: "filterOperators", + value: function filterOperators(selected) { + return this.field().filterOperators(selected); + } + /** + * The operator with the provided operator name (e.x. `=`, `<`, etc) + */ + + }, { + key: "filterOperator", + value: function filterOperator(operatorName) { + return this.field().filterOperator(operatorName); + } + /** + * The default filter operator for this dimension + */ + + }, { + key: "defaultFilterOperator", + value: function defaultFilterOperator() { + // let the DatePicker choose the default operator, otherwise use the first one + // TODO: replace with a defaultFilter()- or similar which includes arguments + return this.field().isDate() ? null : this.filterOperators()[0]; + } // AGGREGATIONS + + /** + * Valid aggregation operators on this dimension + */ + + }, { + key: "aggregationOperators", + value: function aggregationOperators() { + return this.field().aggregationOperators(); + } + /** + * Valid filter operators on this dimension + */ + + }, { + key: "aggregationOperator", + value: function aggregationOperator(operatorName) { + return this.field().aggregationOperator(operatorName); + } + }, { + key: "defaultAggregationOperator", + value: function defaultAggregationOperator() { + return this.aggregationOperators()[0]; + } + }, { + key: "defaultAggregation", + value: function defaultAggregation() { + var aggregation = this.defaultAggregationOperator(); + + if (aggregation) { + return [aggregation.short, this.mbql()]; + } + + return null; + } // BREAKOUTS + + /** + * Returns MBQL for the default breakout + * + * Tries to look up a default subdimension (like "Created At: Day" for "Created At" field) + * and if it isn't found, uses the plain field id dimension (like "Product ID") as a fallback. + */ + + }, { + key: "defaultBreakout", + value: function defaultBreakout() { + var defaultSubDimension = this.defaultDimension(); + + if (defaultSubDimension) { + return defaultSubDimension.mbql(); + } else { + return this.mbql(); + } + } + /** + * The display name of this dimension, e.x. the field's display_name + * @abstract + */ + + }, { + key: "displayName", + value: function displayName() { + return ""; + } + }, { + key: "column", + value: function column() { + var extra = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + var field = this.baseDimension().field(); + return _objectSpread({ + id: field.id, + base_type: field.base_type, + semantic_type: field.semantic_type, + name: this.columnName(), + display_name: this.displayName(), + field_ref: this.mbql() + }, extra); + } + /** + * The name to be shown when this dimension is being displayed as a sub-dimension of another. + * + * Example: a temporal bucketing option such as 'by Day' or 'by Month'. + * @abstract + */ + + }, { + key: "subDisplayName", + value: function subDisplayName() { + return this._subDisplayName || ""; + } + /** + * A shorter version of subDisplayName, e.x. to be shown in the dimension picker trigger (e.g. the list of temporal + * bucketing options like 'Day' or 'Month') + * @abstract + */ + + }, { + key: "subTriggerDisplayName", + value: function subTriggerDisplayName() { + return this._subTriggerDisplayName || ""; + } + /** + * An icon name representing this dimension's type, to be used in the component. + * @abstract + */ + + }, { + key: "icon", + value: function icon() { + return null; + } + }, { + key: "query", + value: function query() { + return this._query; + } + }, { + key: "sourceDimension", + value: function sourceDimension() { + return this._query && this._query.dimensionForSourceQuery(this); + } + /** + * Renders a dimension to a string for display in query builders + */ + + }, { + key: "render", + value: function render() { + return this._parent ? this._parent.render() : this.displayName(); + } + }, { + key: "mbql", + value: function mbql() { + throw new Error("Abstract method `mbql` not implemented"); + } + }, { + key: "key", + value: function key() { + return JSON.stringify(this.mbql()); + } + }], [{ + key: "parseMBQL", + value: function parseMBQL(mbql, metadata, query) { + var _iterator2 = _createForOfIteratorHelper(DIMENSION_TYPES), + _step2; + + try { + for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { + var D = _step2.value; + var dimension = D.parseMBQL(mbql, metadata, query); + + if (dimension != null) { + return Object.freeze(dimension); + } + } + } catch (err) { + _iterator2.e(err); + } finally { + _iterator2.f(); + } + + return null; + } + }, { + key: "isEqual", + value: function isEqual(a, b) { + var dimensionA = a instanceof Dimension ? a : Dimension.parseMBQL(a); + var dimensionB = b instanceof Dimension ? b : Dimension.parseMBQL(b); + return !!dimensionA && !!dimensionB && dimensionA.isEqual(dimensionB); + } + }, { + key: "dimensions", + value: function dimensions(parent) { + return []; + } + /** + * The default sub-dimension for the provided dimension of this type, if any. + * @abstract + */ + + }, { + key: "defaultDimension", + value: function defaultDimension(parent) { + return null; + } + }]); + + return Dimension; +}(); +/** + * `:field` clause e.g. `["field", fieldIdOrName, options]` + */ + + + +var FieldDimension = /*#__PURE__*/function (_Dimension) { + _inherits(FieldDimension, _Dimension); + + var _super = _createSuper(FieldDimension); + + function FieldDimension(fieldIdOrName) { + var _this2; + + var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; + var metadata = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; + var query = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; + var additionalProperties = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null; + + _classCallCheck(this, FieldDimension); + + _this2 = _super.call(this, null, [fieldIdOrName, options], metadata, query); + _this2._fieldIdOrName = fieldIdOrName; + _this2._options = Object.freeze(FieldDimension.normalizeOptions(options)); + + if (additionalProperties) { + Object.keys(additionalProperties).forEach(function (k) { + _this2[k] = additionalProperties[k]; + }); + } + + Object.freeze(_assertThisInitialized(_this2)); + return _this2; + } + + _createClass(FieldDimension, [{ + key: "isEqual", + value: function isEqual(somethingElse) { + if (isFieldDimension(somethingElse)) { + return somethingElse._fieldIdOrName === this._fieldIdOrName && underscore__WEBPACK_IMPORTED_MODULE_1__.default.isEqual(somethingElse._options, this._options); + } // this should be considered equivalent to an equivalent MBQL clause + + + if (FieldDimension.isFieldClause(somethingElse)) { + var dimension = FieldDimension.parseMBQL(somethingElse, this._metadata, this._query); + return dimension ? this.isEqual(dimension) : false; + } + + return false; + } + }, { + key: "mbql", + value: function mbql() { + return ["field", this._fieldIdOrName, this._options]; + } + /** + * Get an option from the field options map, if there is one. + */ + + }, { + key: "getOption", + value: function getOption(k) { + return this._options && this._options[k]; + } + /** + * Return integer ID *or* string name of the Field this `field` clause refers to. + */ + + }, { + key: "fieldIdOrName", + value: function fieldIdOrName() { + return this._fieldIdOrName; + } + /** + * Whether this Field clause has an integer Field ID (as opposed to a string Field name). + */ + + }, { + key: "isIntegerFieldId", + value: function isIntegerFieldId() { + return typeof this._fieldIdOrName === "number"; + } + /** + * Whether this Field clause has a string Field name (as opposed to an integer Field ID). This generally means the + * Field comes from a native query. + */ + + }, { + key: "isStringFieldName", + value: function isStringFieldName() { + return typeof this._fieldIdOrName === "string"; + } + }, { + key: "field", + value: function field() { + if (this.isIntegerFieldId()) { + var _this$_metadata, _this$query; + + var field = (_this$_metadata = this._metadata) === null || _this$_metadata === void 0 ? void 0 : _this$_metadata.field(this.fieldIdOrName()); + + if (field) { + return field; + } // if the field isn't in metadata, there _might_ be a card tied to this Dimension + // if so, check the card's result_metadata + + + var question = (_this$query = this.query()) === null || _this$query === void 0 ? void 0 : _this$query.question(); + + if (question != null) { + var _field = underscore__WEBPACK_IMPORTED_MODULE_1__.default.findWhere(question.getResultMetadata(), { + id: this.fieldIdOrName() + }); + + if (_field) { + return new _metadata_Field__WEBPACK_IMPORTED_MODULE_5__.default(_objectSpread(_objectSpread({}, _field), {}, { + metadata: this._metadata, + query: this._query + })); + } + } + + return new _metadata_Field__WEBPACK_IMPORTED_MODULE_5__.default({ + id: this._fieldIdOrName, + metadata: this._metadata, + query: this._query + }); + } // look for a "virtual" field on the query's table or question + // for example, fields from a question based on a nested question have fields + // that show up in a card's `result_metadata` + + + if (this.query()) { + var table = this.query().table(); + + if (table != null) { + var _field2 = underscore__WEBPACK_IMPORTED_MODULE_1__.default.findWhere(table.fields, { + name: this.fieldIdOrName() + }); + + if (_field2) { + return _field2; + } + } + + var _question = this.query().question(); + + if (_question != null) { + var _field3 = underscore__WEBPACK_IMPORTED_MODULE_1__.default.findWhere(_question.getResultMetadata(), { + name: this.fieldIdOrName() + }); + + if (_field3) { + return new _metadata_Field__WEBPACK_IMPORTED_MODULE_5__.default(_objectSpread(_objectSpread({}, _field3), {}, { + metadata: this._metadata, + query: this._query + })); + } + } + } // despite being unable to find a field, we _might_ still have enough data to know a few things about it + // for example, if we have an mbql field reference, it might contain a `base-type` + + + return new _metadata_Field__WEBPACK_IMPORTED_MODULE_5__.default({ + id: this.mbql(), + name: this._fieldIdOrName, + // NOTE: this display_name will likely be incorrect + // if a `FieldDimension` isn't associated with a query then we don't know which table it belongs to + display_name: this._fieldIdOrName, + base_type: this.getOption("base-type"), + query: this._query, + metadata: this._metadata + }); + } + }, { + key: "tableId", + value: function tableId() { + var _this$field, _this$field$table; + + return (_this$field = this.field()) === null || _this$field === void 0 ? void 0 : (_this$field$table = _this$field.table) === null || _this$field$table === void 0 ? void 0 : _this$field$table.id; + } + /** + * Return a copy of this FieldDimension that excludes `options`. + */ + + }, { + key: "withoutOptions", + value: function withoutOptions() { + // optimization: if we don't have any options, we can return ourself as-is + if (!this._options) { + return this; + } + + for (var _len = arguments.length, options = new Array(_len), _key = 0; _key < _len; _key++) { + options[_key] = arguments[_key]; + } + + return new FieldDimension(this._fieldIdOrName, underscore__WEBPACK_IMPORTED_MODULE_1__.default.omit.apply(underscore__WEBPACK_IMPORTED_MODULE_1__.default, [this._options].concat(options)), this._metadata, this._query); + } + /** + * Return a copy of this FieldDimension with any temporal bucketing options removed. + */ + + }, { + key: "withoutTemporalBucketing", + value: function withoutTemporalBucketing() { + return this.withoutOptions("temporal-unit"); + } + /** + * Return a copy of this FieldDimension with any binning options removed. + */ + + }, { + key: "withoutBinning", + value: function withoutBinning() { + return this.withoutOptions("binning"); + } + /** + * Return a copy of this FieldDimension with any temporal bucketing or binning options removed. + */ + + }, { + key: "baseDimension", + value: function baseDimension() { + return this.withoutTemporalBucketing().withoutBinning(); + } + /** + * Return a copy of this FieldDimension that includes the specified `options`. + */ + + }, { + key: "withOptions", + value: function withOptions(options) { + // optimization : if options is empty return self as-is + if (!options || !Object.entries(options).length) { + return this; + } + + return new FieldDimension(this._fieldIdOrName, _objectSpread(_objectSpread({}, this._options), options), this._metadata, this._query); + } + /** + * Return a copy of this FieldDimension with option `key` set to `value`. + */ + + }, { + key: "withOption", + value: function withOption(key, value) { + return this.withOptions(_defineProperty({}, key, value)); + } + /** + * Return a copy of this FieldDimension, bucketed by the specified temporal unit. + */ + + }, { + key: "withTemporalUnit", + value: function withTemporalUnit(unit) { + return this.withOptions({ + "temporal-unit": unit + }); + } // no idea what this does or if it's even used anywhere. + + }, { + key: "foreign", + value: function foreign(dimension) { + if (isFieldDimension(dimension)) { + return dimension.withSourceField(this._fieldIdOrName); + } + } + }, { + key: "columnName", + value: function columnName() { + return this.isIntegerFieldId() ? _get(_getPrototypeOf(FieldDimension.prototype), "columnName", this).call(this) : this._fieldIdOrName; + } + }, { + key: "displayName", + value: function displayName() { + var _this$field2; + + return (_this$field2 = this.field()).displayName.apply(_this$field2, arguments); + } + }, { + key: "subDisplayName", + value: function subDisplayName() { + if (this._subDisplayName) { + return this._subDisplayName; + } + + if (this.temporalUnit()) { + return (0,metabase_lib_query_time__WEBPACK_IMPORTED_MODULE_6__.formatBucketing)(this.temporalUnit()); + } + + if (this.binningStrategy()) { + return this.describeBinning(); + } // honestly, I have no idea why we do something totally random if we have a FK source field compared to everything + // else, but that's how the tests are written + + + if (this.sourceField()) { + return this.displayName(); + } + + return "Default"; + } + }, { + key: "icon", + value: function icon() { + return this.field().icon(); + } + /** + * Short string that describes the binning options used. Used for both subTriggerDisplayName() and render() + */ + + }, { + key: "describeBinning", + value: function describeBinning() { + if (!this.binningOptions()) { + return ""; + } + + if (this.binningStrategy() === "num-bins") { + var n = this.getBinningOption("num-bins"); + return (0,ttag__WEBPACK_IMPORTED_MODULE_0__.ngettext)((0,ttag__WEBPACK_IMPORTED_MODULE_0__.msgid)(_templateObject || (_templateObject = _taggedTemplateLiteral(["", " bin"])), n), "".concat(n, " bins"), n); + } + + if (this.binningStrategy() === "bin-width") { + var binWidth = this.getBinningOption("bin-width"); + var units = this.field().isCoordinate() ? "°" : ""; + return "".concat(binWidth).concat(units); + } else { + return (0,ttag__WEBPACK_IMPORTED_MODULE_0__.t)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["Auto binned"]))); + } + } + /** + * Whether this is a numeric Field that can be binned + */ + + }, { + key: "isBinnable", + value: function isBinnable() { + var defaultDimension = this.defaultDimension(); + return isFieldDimension(defaultDimension) && defaultDimension.binningOptions(); + } + }, { + key: "dimensions", + value: function dimensions(DimensionTypes) { + var _this3 = this; + + var dimensions = _get(_getPrototypeOf(FieldDimension.prototype), "dimensions", this).call(this, DimensionTypes); + + var joinAlias = this.joinAlias(); + + if (joinAlias) { + return dimensions.map(function (d) { + return d.withJoinAlias(joinAlias); + }); + } + + var sourceField = this.sourceField(); + + if (sourceField) { + return dimensions.map(function (d) { + return d.withSourceField(sourceField); + }); + } + + var field = this.field(); // Add FK dimensions if this field is an FK + + if (field.target && field.target.table && field.target.table.fields) { + var fkDimensions = field.target.table.fields.map(function (field) { + return new FieldDimension(field.id, { + "source-field": _this3._fieldIdOrName + }, _this3._metadata, _this3._query); + }); + dimensions = [].concat(_toConsumableArray(dimensions), _toConsumableArray(fkDimensions)); + } // Add temporal dimensions + + + if (field.isDate() && !this.isIntegerFieldId()) { + var temporalDimensions = underscore__WEBPACK_IMPORTED_MODULE_1__.default.difference(metabase_lib_query_time__WEBPACK_IMPORTED_MODULE_6__.DATETIME_UNITS, dimensions.map(function (dim) { + return dim.temporalUnit(); + })).map(function (unit) { + return _this3.withTemporalUnit(unit); + }); + + dimensions = [].concat(_toConsumableArray(dimensions), _toConsumableArray(temporalDimensions)); + } + + var baseType = this.getOption("base-type"); + + if (baseType) { + dimensions = dimensions.map(function (dimension) { + return dimension.withOption("base-type", baseType); + }); + } + + return dimensions; + } + }, { + key: "defaultDimension", + value: function defaultDimension() { + var dimensionTypes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; + var field = this.field(); + + if (field && field.isDate()) { + return this.withTemporalUnit(field.getDefaultDateTimeUnit()); + } + + var dimension = _get(_getPrototypeOf(FieldDimension.prototype), "defaultDimension", this).call(this, dimensionTypes); + + if (!dimension) { + return null; + } + + var sourceField = this.sourceField(); + + if (sourceField) { + dimension = dimension.withSourceField(sourceField); + } + + var joinAlias = this.joinAlias(); + + if (joinAlias) { + dimension = dimension.withJoinAlias(joinAlias); + } + + var baseType = this.getOption("base-type"); + + if (baseType) { + dimension = dimension.withOption("base-type", baseType); + } + + return dimension; + } + }, { + key: "_dimensionForOption", + value: function _dimensionForOption(option) { + var dimension = option.mbql ? FieldDimension.parseMBQLOrWarn(option.mbql, this._metadata, this._query) : this; + + if (!dimension) { + console.warn("Don't know how to create Dimension for option", this, option); + return null; + } + + var additionalProperties = { + _fieldIdOrName: this._fieldIdOrName + }; + + if (option.name) { + additionalProperties._subDisplayName = option.name; + additionalProperties._subTriggerDisplayName = option.name; + } + + return new FieldDimension(dimension._fieldIdOrName, dimension._options, this._metadata, this._query, additionalProperties); + } + }, { + key: "subTriggerDisplayName", + value: function subTriggerDisplayName() { + if (this._subTriggerDisplayName) { + return this._subTriggerDisplayName; + } // binned field + + + if (this.binningOptions()) { + return this.describeBinning(); + } // temporal bucketed field + + + if (this.temporalUnit()) { + return (0,ttag__WEBPACK_IMPORTED_MODULE_0__.t)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["by ", ""])), (0,metabase_lib_query_time__WEBPACK_IMPORTED_MODULE_6__.formatBucketing)(this.temporalUnit()).toLowerCase()); + } // if the field is a binnable number, we should return 'Unbinned' here + + + if (this.isBinnable()) { + return "Unbinned"; + } + + return ""; + } + }, { + key: "render", + value: function render() { + var displayName = this.displayName(); + + if (this.fk()) { + var fkDisplayName = this.fk() && (0,metabase_lib_formatting__WEBPACK_IMPORTED_MODULE_2__.stripId)(this.fk().field().displayName()); + displayName = "".concat(fkDisplayName, " ").concat(metabase_lib_formatting__WEBPACK_IMPORTED_MODULE_2__.FK_SYMBOL, " ").concat(displayName); + } else if (this.joinAlias()) { + displayName = "".concat(this.joinAlias(), " ").concat(metabase_lib_formatting__WEBPACK_IMPORTED_MODULE_2__.FK_SYMBOL, " ").concat(displayName); + } + + if (this.temporalUnit()) { + displayName = "".concat(displayName, ": ").concat((0,metabase_lib_query_time__WEBPACK_IMPORTED_MODULE_6__.formatBucketing)(this.temporalUnit())); + } + + if (this.binningOptions()) { + displayName = "".concat(displayName, ": ").concat(this.describeBinning()); + } + + return displayName; + } + }, { + key: "column", + value: function column() { + var extra = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + var more = {}; + + if (typeof this.sourceField() === "number") { + more.fk_field_id = this.sourceField(); + } + + if (this.temporalUnit()) { + more.unit = this.temporalUnit(); + } + + return _objectSpread(_objectSpread(_objectSpread({}, _get(_getPrototypeOf(FieldDimension.prototype), "column", this).call(this)), more), extra); + } + /** + * For `:field` clauses with an FK source field, returns a new Dimension for the source field. + */ + + }, { + key: "fk", + value: function fk() { + var sourceFieldIdOrName = this.sourceField(); + + if (!sourceFieldIdOrName) { + return null; + } + + return new FieldDimension(sourceFieldIdOrName, null, this._metadata, this._query); + } + /* + * The temporal unit that is being used to bucket this Field, if any. + */ + + }, { + key: "temporalUnit", + value: function temporalUnit() { + return this.getOption("temporal-unit"); + } + /** + * Whether temporal bucketing is being applied, *and* the bucketing is a truncation operation such as "month" or + * "quarter"; + */ + + }, { + key: "isTemporalExtraction", + value: function isTemporalExtraction() { + return this.temporalUnit() && /-of-/.test(this.temporalUnit()); + } + /** + * Whether temporal bucketing is being applied, *and* the bucketing is an truncation operation such as "day of month"; + */ + + }, { + key: "isTemporalTruncation", + value: function isTemporalTruncation() { + return this.temporalUnit() && !this.isTemporalExtraction(); + } + }, { + key: "sourceField", + value: function sourceField() { + return this.getOption("source-field"); + } + }, { + key: "withSourceField", + value: function withSourceField(sourceField) { + return this.withOptions({ + "source-field": sourceField + }); + } + /** + * Return the join alias associated with this field, if any. + */ + + }, { + key: "joinAlias", + value: function joinAlias() { + return this.getOption("join-alias"); + } + /** + * Return a copy of this field with join alias set to `newAlias`. + */ + + }, { + key: "withJoinAlias", + value: function withJoinAlias(newAlias) { + return this.withOptions({ + "join-alias": newAlias + }); + } + }, { + key: "join", + value: function join() { + return this.joinAlias() ? underscore__WEBPACK_IMPORTED_MODULE_1__.default.findWhere(this._query && this._query.joins(), { + alias: this.joinAlias() + }) : null; + } // binning-strategy stuff + + }, { + key: "binningOptions", + value: function binningOptions() { + return this.getOption("binning"); + } + }, { + key: "withBinningOptions", + value: function withBinningOptions(newBinningOptions) { + return this.withOptions({ + binning: newBinningOptions + }); + } + }, { + key: "getBinningOption", + value: function getBinningOption(option) { + return this.binningOptions() && this.binningOptions()[option]; + } + }, { + key: "binningStrategy", + value: function binningStrategy() { + return this.getBinningOption("strategy"); + } + }], [{ + key: "isFieldClause", + value: + /** + * Whether `clause` is an array, and a valid `:field` clause + */ + function isFieldClause(clause) { + return Array.isArray(clause) && clause.length === 3 && clause[0] === "field"; + } + }, { + key: "parseMBQL", + value: function parseMBQL(mbql) { + var metadata = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; + var query = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; + + if (FieldDimension.isFieldClause(mbql)) { + return Object.freeze(new FieldDimension(mbql[1], mbql[2], metadata, query)); + } + + return null; + } + /** + * Parse MBQL field clause or log a warning message if it could not be parsed. Use this when you expect the clause to + * be a `:field` clause + */ + + }, { + key: "parseMBQLOrWarn", + value: function parseMBQLOrWarn(mbql) { + var metadata = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; + var query = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; + + // if some some reason someone passes in a raw integer ID instead of a proper Field form, go ahead and parse it + // anyway -- there seems to be a lot of code that does this -- but log an error message so we can fix it. + if (typeof mbql === "number") { + console.error("FieldDimension.parseMBQLOrWarn() called with a raw integer Field ID. This is an error. Fixme!", mbql); + return FieldDimension.parseMBQLOrWarn(["field", mbql, null], metadata, query); + } + + var dimension = FieldDimension.parseMBQL(mbql, metadata, query); + + if (!dimension) { + console.warn("Unknown MBQL Field clause", mbql); + } + + return dimension; + } + /** + * Canonically the field clause should use `null` instead of empty options. Keys with null values should get removed. + */ + + }, { + key: "normalizeOptions", + value: function normalizeOptions(options) { + var _this4 = this; + + if (!options) { + return null; + } // recursively normalize maps inside options. + + + options = underscore__WEBPACK_IMPORTED_MODULE_1__.default.mapObject(options, function (val) { + return _typeof(val) === "object" ? _this4.normalizeOptions(val) : val; + }); // remove null/undefined options from map. + + options = underscore__WEBPACK_IMPORTED_MODULE_1__.default.omit(options, function (value) { + return value == null; + }); + return underscore__WEBPACK_IMPORTED_MODULE_1__.default.isEmpty(options) ? null : options; + } + }]); + + return FieldDimension; +}(Dimension); + +var isFieldDimension = function isFieldDimension(dimension) { + return dimension instanceof FieldDimension; +}; +/** + * Expression reference, `["expression", expression-name]` + */ + + +var ExpressionDimension = /*#__PURE__*/function (_Dimension2) { + _inherits(ExpressionDimension, _Dimension2); + + var _super2 = _createSuper(ExpressionDimension); + + function ExpressionDimension() { + var _this5; + + _classCallCheck(this, ExpressionDimension); + + for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } + + _this5 = _super2.call.apply(_super2, [this].concat(args)); + + _defineProperty(_assertThisInitialized(_this5), "tag", "Custom"); + + return _this5; + } + + _createClass(ExpressionDimension, [{ + key: "mbql", + value: function mbql() { + return ["expression", this._args[0]]; + } + }, { + key: "name", + value: function name() { + return this._args[0]; + } + }, { + key: "displayName", + value: function displayName() { + return this._args[0]; + } + }, { + key: "columnName", + value: function columnName() { + return this._args[0]; + } + }, { + key: "field", + value: function field() { + var _this6 = this; + + var query = this._query; + var table = query ? query.table() : null; + var type = metabase_lib_expressions_typeinferencer__WEBPACK_IMPORTED_MODULE_7__.MONOTYPE.Number; // fallback + + if (query) { + var _datasetQuery$express; + + var datasetQuery = query.query(); + var expressions = (_datasetQuery$express = datasetQuery === null || datasetQuery === void 0 ? void 0 : datasetQuery.expressions) !== null && _datasetQuery$express !== void 0 ? _datasetQuery$express : {}; + + var env = function env(mbql) { + var dimension = Dimension.parseMBQL(mbql, _this6._metadata, _this6._query); + return dimension.field().base_type; + }; + + type = (0,metabase_lib_expressions_typeinferencer__WEBPACK_IMPORTED_MODULE_7__.infer)(expressions[this.name()], env); + } else { + type = (0,metabase_lib_expressions_typeinferencer__WEBPACK_IMPORTED_MODULE_7__.infer)(this._args[0]); + } + + var base_type = type; + + if (!type.startsWith("type/")) { + base_type = "type/Float"; // fallback + + switch (type) { + case metabase_lib_expressions_typeinferencer__WEBPACK_IMPORTED_MODULE_7__.MONOTYPE.String: + base_type = "type/Text"; + break; + + case metabase_lib_expressions_typeinferencer__WEBPACK_IMPORTED_MODULE_7__.MONOTYPE.Boolean: + base_type = "type/Boolean"; + break; + + default: + break; + } + } + + return new _metadata_Field__WEBPACK_IMPORTED_MODULE_5__.default({ + id: this.mbql(), + name: this.name(), + display_name: this.displayName(), + semantic_type: null, + base_type: base_type, + query: query, + table: table + }); + } + }, { + key: "icon", + value: function icon() { + var _this$field3 = this.field(), + base_type = _this$field3.base_type; + + switch (base_type) { + case "type/Text": + return "string"; + + default: + break; + } + + return "int"; + } + }], [{ + key: "parseMBQL", + value: function parseMBQL(mbql, metadata, query) { + if (Array.isArray(mbql) && mbql[0] === "expression") { + return new ExpressionDimension(null, mbql.slice(1), metadata, query); + } + } + }]); + + return ExpressionDimension; +}(Dimension); // These types aren't aggregated. e.g. if you take the distinct count of a FK +// column, you now have a normal integer and should see relevant filters for +// that type. + +var UNAGGREGATED_SEMANTIC_TYPES = new Set([metabase_lib_types__WEBPACK_IMPORTED_MODULE_3__.TYPE.FK, metabase_lib_types__WEBPACK_IMPORTED_MODULE_3__.TYPE.PK]); +/** + * Aggregation reference, `["aggregation", aggregation-index]` + */ + +var AggregationDimension = /*#__PURE__*/function (_Dimension3) { + _inherits(AggregationDimension, _Dimension3); + + var _super3 = _createSuper(AggregationDimension); + + function AggregationDimension() { + _classCallCheck(this, AggregationDimension); + + return _super3.apply(this, arguments); + } + + _createClass(AggregationDimension, [{ + key: "aggregationIndex", + value: function aggregationIndex() { + return this._args[0]; + } + }, { + key: "column", + value: function column() { + var extra = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + return _objectSpread(_objectSpread({}, _get(_getPrototypeOf(AggregationDimension.prototype), "column", this).call(this)), {}, { + source: "aggregation" + }, extra); + } + }, { + key: "field", + value: function field() { + var aggregation = this.aggregation(); + + if (!aggregation) { + return _get(_getPrototypeOf(AggregationDimension.prototype), "field", this).call(this); + } + + var dimension = aggregation.dimension(); + var field = dimension && dimension.field(); + + var _ref2 = field || {}, + semantic_type = _ref2.semantic_type; + + return new _metadata_Field__WEBPACK_IMPORTED_MODULE_5__.default(_objectSpread(_objectSpread({ + name: aggregation.columnName(), + display_name: aggregation.displayName(), + base_type: aggregation.baseType() + }, !UNAGGREGATED_SEMANTIC_TYPES.has(semantic_type) && { + semantic_type: semantic_type + }), {}, { + query: this._query, + metadata: this._metadata + })); + } + /** + * Raw aggregation + */ + + }, { + key: "_aggregation", + value: function _aggregation() { + return this._query && this._query.aggregations()[this.aggregationIndex()]; + } + /** + * Underlying aggregation, with aggregation-options removed + */ + + }, { + key: "aggregation", + value: function aggregation() { + var aggregation = this._aggregation(); + + if (aggregation) { + return aggregation.aggregation(); + } + + return null; + } + }, { + key: "displayName", + value: function displayName() { + var aggregation = this._aggregation(); + + if (aggregation) { + return aggregation.displayName(); + } + + return null; + } + }, { + key: "columnName", + value: function columnName() { + var aggregation = this._aggregation(); + + if (aggregation) { + return aggregation.columnName(); + } + + return null; + } + }, { + key: "mbql", + value: function mbql() { + return ["aggregation", this._args[0]]; + } + }, { + key: "icon", + value: function icon() { + return "int"; + } + }], [{ + key: "parseMBQL", + value: function parseMBQL(mbql, metadata, query) { + if (Array.isArray(mbql) && mbql[0] === "aggregation") { + return new AggregationDimension(null, mbql.slice(1), metadata, query); + } + } + }]); + + return AggregationDimension; +}(Dimension); +var TemplateTagDimension = /*#__PURE__*/function (_FieldDimension) { + _inherits(TemplateTagDimension, _FieldDimension); + + var _super4 = _createSuper(TemplateTagDimension); + + function TemplateTagDimension(tagName, metadata, query) { + _classCallCheck(this, TemplateTagDimension); + + return _super4.call(this, null, null, metadata, query, { + _tagName: tagName + }); + } + + _createClass(TemplateTagDimension, [{ + key: "isDimensionType", + value: function isDimensionType() { + var maybeTag = this.tag(); + return (maybeTag === null || maybeTag === void 0 ? void 0 : maybeTag.type) === "dimension"; + } + }, { + key: "isVariableType", + value: function isVariableType() { + var maybeTag = this.tag(); + return ["text", "number", "date"].includes(maybeTag === null || maybeTag === void 0 ? void 0 : maybeTag.type); + } + }, { + key: "dimension", + value: function dimension() { + if (this.isDimensionType()) { + var tag = this.tag(); + return Dimension.parseMBQL(tag.dimension, this._metadata, this._query); + } + + return null; + } + }, { + key: "variable", + value: function variable() { + if (this.isVariableType()) { + var tag = this.tag(); + return new _Variable__WEBPACK_IMPORTED_MODULE_4__.TemplateTagVariable([tag.name], this._metadata, this._query); + } + + return null; + } + }, { + key: "tag", + value: function tag() { + var _this$_query$template, _this$_query; + + var templateTagMap = (_this$_query$template = (_this$_query = this._query) === null || _this$_query === void 0 ? void 0 : _this$_query.templateTagsMap()) !== null && _this$_query$template !== void 0 ? _this$_query$template : {}; + return templateTagMap[this.tagName()]; + } + }, { + key: "field", + value: function field() { + if (this.isDimensionType()) { + return this.dimension().field(); + } + + return null; + } + }, { + key: "name", + value: function name() { + return this.isDimensionType() ? this.field().name : this.tagName(); + } + }, { + key: "tagName", + value: function tagName() { + return this._tagName; + } + }, { + key: "displayName", + value: function displayName() { + var tag = this.tag(); + return tag && tag["display-name"] || _get(_getPrototypeOf(TemplateTagDimension.prototype), "displayName", this).call(this); + } + }, { + key: "mbql", + value: function mbql() { + return ["template-tag", this.tagName()]; + } + }, { + key: "icon", + value: function icon() { + if (this.isDimensionType()) { + return this.dimension().icon(); + } else if (this.isVariableType()) { + return this.variable().icon(); + } + + return "label"; + } + }], [{ + key: "parseMBQL", + value: function parseMBQL(mbql) { + var metadata = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; + var query = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; + return TemplateTagDimension.isTemplateTagClause(mbql) ? Object.freeze(new TemplateTagDimension(mbql[1], metadata, query)) : null; + } + }, { + key: "isTemplateTagClause", + value: function isTemplateTagClause(clause) { + return Array.isArray(clause) && clause[0] === "template-tag"; + } + }]); + + return TemplateTagDimension; +}(FieldDimension); +var DIMENSION_TYPES = [FieldDimension, ExpressionDimension, AggregationDimension, TemplateTagDimension]; + +/***/ }), + +/***/ "../metabase-lib/lib/DimensionOptions.ts": +/*!***********************************************!*\ + !*** ../metabase-lib/lib/DimensionOptions.ts ***! + \***********************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* binding */ DimensionOptions; } +/* harmony export */ }); +/* provided dependency */ var console = __webpack_require__(/*! console-browserify */ "../../../node_modules/console-browserify/index.js"); +function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-nocheck +var DimensionOptions = /*#__PURE__*/function () { + function DimensionOptions(o) { + _classCallCheck(this, DimensionOptions); + + _defineProperty(this, "count", 0); + + _defineProperty(this, "dimensions", []); + + _defineProperty(this, "fks", []); + + Object.assign(this, o); + } + + _createClass(DimensionOptions, [{ + key: "all", + value: function all() { + var _ref; + + return (_ref = []).concat.apply(_ref, [this.dimensions].concat(_toConsumableArray(this.fks.map(function (fk) { + return fk.dimensions; + })))); + } + }, { + key: "hasDimension", + value: function hasDimension(dimension) { + if (!dimension) { + console.error("attempted to call FieldDimension.hasDimension() with null dimension", dimension); + return false; + } + + var _iterator = _createForOfIteratorHelper(this.all()), + _step; + + try { + for (_iterator.s(); !(_step = _iterator.n()).done;) { + var d = _step.value; + + if (dimension.isSameBaseDimension(d)) { + return true; + } + } + } catch (err) { + _iterator.e(err); + } finally { + _iterator.f(); + } + + return false; + } + }, { + key: "sections", + value: function sections() { + var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, + _ref2$extraItems = _ref2.extraItems, + extraItems = _ref2$extraItems === void 0 ? [] : _ref2$extraItems; + + var table = this.dimensions[0] && this.dimensions[0].field().table; + var tableName = table && !table.isSavedQuestion() ? table.objectName() : null; + var mainSection = { + name: this.name || tableName, + icon: this.icon || "table2", + items: [].concat(_toConsumableArray(extraItems), _toConsumableArray(this.dimensions.map(function (dimension) { + return { + dimension: dimension + }; + }))) + }; + var fkSections = this.fks.map(function (fk) { + return { + name: fk.name || fk.field && fk.field.targetObjectName(), + icon: fk.icon || "connections", + items: fk.dimensions.map(function (dimension) { + return { + dimension: dimension + }; + }) + }; + }); + var sections = []; + + if (mainSection.items.length > 0) { + sections.push(mainSection); + } + + sections.push.apply(sections, _toConsumableArray(fkSections)); + return sections; + } + }]); + + return DimensionOptions; +}(); + + + +/***/ }), + +/***/ "../metabase-lib/lib/Mode.ts": +/*!***********************************!*\ + !*** ../metabase-lib/lib/Mode.ts ***! + \***********************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* binding */ Mode; } +/* harmony export */ }); +/* harmony import */ var metabase_modes_lib_modes__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! metabase/modes/lib/modes */ "./modes/lib/modes.js"); +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-nocheck + + +var Mode = /*#__PURE__*/function () { + function Mode(question, queryMode) { + _classCallCheck(this, Mode); + + this._question = question; + this._queryMode = queryMode; + } + + _createClass(Mode, [{ + key: "queryMode", + value: function queryMode() { + return this._queryMode; + } + }, { + key: "name", + value: function name() { + return this._queryMode.name; + } + }, { + key: "actionsForClick", + value: function actionsForClick(clicked, settings, extraData) { + var _this = this; + + return this._queryMode.drills().flatMap(function (actionCreator) { + return actionCreator({ + question: _this._question, + settings: settings, + clicked: clicked, + extraData: extraData + }); + }); + } + }], [{ + key: "forQuestion", + value: function forQuestion(question) { + // TODO Atte Keinänen 6/22/17: Move getMode here and refactor it after writing tests + var queryMode = (0,metabase_modes_lib_modes__WEBPACK_IMPORTED_MODULE_0__.getMode)(question); + + if (queryMode) { + return new Mode(question, queryMode); + } else { + return null; + } + } + }]); + + return Mode; +}(); + + + +/***/ }), + +/***/ "../metabase-lib/lib/Question.ts": +/*!***************************************!*\ + !*** ../metabase-lib/lib/Question.ts ***! + \***************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* binding */ Question; } +/* harmony export */ }); +/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! underscore */ "../../../node_modules/underscore/modules/index-all.js"); +/* harmony import */ var icepick__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! icepick */ "../../../node_modules/icepick/icepick.min.js"); +/* harmony import */ var icepick__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(icepick__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var metabase_lib_lib_queries_StructuredQuery__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase-lib/lib/queries/StructuredQuery */ "../metabase-lib/lib/queries/StructuredQuery.ts"); +/* harmony import */ var metabase_lib_lib_queries_NativeQuery__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase-lib/lib/queries/NativeQuery */ "../metabase-lib/lib/queries/NativeQuery.ts"); +/* harmony import */ var metabase_lib_lib_queries_AtomicQuery__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! metabase-lib/lib/queries/AtomicQuery */ "../metabase-lib/lib/queries/AtomicQuery.ts"); +/* harmony import */ var _queries_InternalQuery__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./queries/InternalQuery */ "../metabase-lib/lib/queries/InternalQuery.ts"); +/* harmony import */ var metabase_lib_lib_metadata_Metadata__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! metabase-lib/lib/metadata/Metadata */ "../metabase-lib/lib/metadata/Metadata.ts"); +/* harmony import */ var metabase_lib_lib_Dimension__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! metabase-lib/lib/Dimension */ "../metabase-lib/lib/Dimension.ts"); +/* harmony import */ var metabase_lib_lib_Mode__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! metabase-lib/lib/Mode */ "../metabase-lib/lib/Mode.ts"); +/* harmony import */ var metabase_lib_query_filter__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! metabase/lib/query/filter */ "./lib/query/filter.js"); +/* harmony import */ var metabase_lib_lib_utils__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! metabase-lib/lib/utils */ "../metabase-lib/lib/utils.ts"); +/* harmony import */ var metabase_lib_urls__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! metabase/lib/urls */ "./lib/urls.js"); +/* harmony import */ var metabase_lib_dataset__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! metabase/lib/dataset */ "./lib/dataset.js"); +/* harmony import */ var metabase_meta_Card__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! metabase/meta/Card */ "./meta/Card.js"); +/* harmony import */ var metabase_parameters_utils_cards__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! metabase/parameters/utils/cards */ "./parameters/utils/cards.js"); +/* harmony import */ var metabase_parameters_utils_mbql__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! metabase/parameters/utils/mbql */ "./parameters/utils/mbql.js"); +/* harmony import */ var metabase_parameters_utils_parameter_values__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! metabase/parameters/utils/parameter-values */ "./parameters/utils/parameter-values.js"); +/* harmony import */ var metabase_modes_lib_actions__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! metabase/modes/lib/actions */ "./modes/lib/actions.js"); +/* harmony import */ var metabase_services__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! metabase/services */ "./services.js"); +/* harmony import */ var metabase_entities_questions__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! metabase/entities/questions */ "./entities/questions.js"); +/* harmony import */ var metabase_lib_lib_Alert__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! metabase-lib/lib/Alert */ "../metabase-lib/lib/Alert.ts"); +/* harmony import */ var metabase_lib_encoding__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! metabase/lib/encoding */ "./lib/encoding.js"); +var _class; + +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } + +function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } + +function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } + +function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } + +function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; } + +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-nocheck + + // NOTE: the order of these matters due to circular dependency issues + + + + + + + + + + // TODO: remove these dependencies + + + + + + + + + + + + + +/** + * This is a wrapper around a question/card object, which may contain one or more Query objects + */ +var Question = (_class = /*#__PURE__*/function () { + /** + * The plain object presentation of this question, equal to the format that Metabase REST API understands. + * It is called `card` for both historical reasons and to make a clear distinction to this class. + */ + + /** + * The Question wrapper requires a metadata object because the queries it contains (like {@link StructuredQuery}) + * need metadata for accessing databases, tables and metrics. + */ + + /** + * Parameter values mean either the current values of dashboard filters or SQL editor template parameters. + * They are in the grey area between UI state and question state, but having them in Question wrapper is convenient. + */ + + /** + * Bound update function, if any + */ + + /** + * Question constructor + */ + function Question(card, metadata, parameterValues, update) { + _classCallCheck(this, Question); + + this._card = card; + this._metadata = metadata || new metabase_lib_lib_metadata_Metadata__WEBPACK_IMPORTED_MODULE_6__.default({ + databases: {}, + tables: {}, + fields: {}, + metrics: {}, + segments: {} + }); + this._parameterValues = parameterValues || {}; + this._update = update; + } + + _createClass(Question, [{ + key: "clone", + value: function clone() { + return new Question(this._card, this._metadata, this._parameterValues, this._update); + } + /** + * TODO Atte Keinänen 6/13/17: Discussed with Tom that we could use the default Question constructor instead, + * but it would require changing the constructor signature so that `card` is an optional parameter and has a default value + */ + + }, { + key: "metadata", + value: function metadata() { + return this._metadata; + } + }, { + key: "card", + value: function card() { + return this._card; + } + }, { + key: "setCard", + value: function setCard(card) { + var q = this.clone(); + q._card = card; + return q; + } + /** + * calls the passed in update function (useful for chaining) or bound update function with the question + * NOTE: this passes Question instead of card, unlike how Query passes dataset_query + */ + + }, { + key: "update", + value: function update(_update) { + for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } + + // TODO: if update returns a new card, create a new Question based on that and return it + if (_update) { + _update.apply(void 0, [this].concat(args)); + } else if (this._update) { + this._update.apply(this, [this].concat(args)); + } else { + throw new Error("Question update function not provided or bound"); + } + } + }, { + key: "bindUpdate", + value: function bindUpdate(update) { + var q = this.clone(); + q._update = update; + return q; + } + }, { + key: "withoutNameAndId", + value: function withoutNameAndId() { + return this.setCard((0,icepick__WEBPACK_IMPORTED_MODULE_1__.chain)(this.card()).dissoc("id").dissoc("name").dissoc("description").value()); + } + }, { + key: "omitTransientCardIds", + value: function omitTransientCardIds() { + var question = this; + var card = question.card(); + var id = card.id, + original_card_id = card.original_card_id; + + if ((0,metabase_meta_Card__WEBPACK_IMPORTED_MODULE_13__.isTransientId)(id)) { + question = question.setCard(underscore__WEBPACK_IMPORTED_MODULE_0__.default.omit(question.card(), "id")); + } + + if ((0,metabase_meta_Card__WEBPACK_IMPORTED_MODULE_13__.isTransientId)(original_card_id)) { + question = question.setCard(underscore__WEBPACK_IMPORTED_MODULE_0__.default.omit(question.card(), "original_card_id")); + } + + return question; + } + /** + * A question contains either a: + * - StructuredQuery for queries written in MBQL + * - NativeQuery for queries written in data source's native query language + * + * This is just a wrapper object, the data is stored in `this._card.dataset_query` in a format specific to the query type. + */ + + }, { + key: "query", + value: function query() { + var datasetQuery = this._card.dataset_query; + + for (var _i = 0, _arr = [metabase_lib_lib_queries_StructuredQuery__WEBPACK_IMPORTED_MODULE_2__.default, metabase_lib_lib_queries_NativeQuery__WEBPACK_IMPORTED_MODULE_3__.default, _queries_InternalQuery__WEBPACK_IMPORTED_MODULE_5__.default]; _i < _arr.length; _i++) { + var QueryClass = _arr[_i]; + + if (QueryClass.isDatasetQueryType(datasetQuery)) { + return new QueryClass(this, datasetQuery); + } + } + + throw new Error("Unknown query type: " + datasetQuery.type); + } + }, { + key: "isNative", + value: function isNative() { + return this.query() instanceof metabase_lib_lib_queries_NativeQuery__WEBPACK_IMPORTED_MODULE_3__.default; + } + }, { + key: "isStructured", + value: function isStructured() { + return this.query() instanceof metabase_lib_lib_queries_StructuredQuery__WEBPACK_IMPORTED_MODULE_2__.default; + } + /** + * Returns a new Question object with an updated query. + * The query is saved to the `dataset_query` field of the Card object. + */ + + }, { + key: "setQuery", + value: function setQuery(newQuery) { + if (this._card.dataset_query !== newQuery.datasetQuery()) { + return this.setCard((0,icepick__WEBPACK_IMPORTED_MODULE_1__.assoc)(this.card(), "dataset_query", newQuery.datasetQuery())); + } + + return this; + } + }, { + key: "datasetQuery", + value: function datasetQuery() { + return this.card().dataset_query; + } + }, { + key: "setDatasetQuery", + value: function setDatasetQuery(newDatasetQuery) { + return this.setCard((0,icepick__WEBPACK_IMPORTED_MODULE_1__.assoc)(this.card(), "dataset_query", newDatasetQuery)); + } + /** + * Returns a list of atomic queries (NativeQuery or StructuredQuery) contained in this question + */ + + }, { + key: "atomicQueries", + value: function atomicQueries() { + var query = this.query(); + + if (query instanceof metabase_lib_lib_queries_AtomicQuery__WEBPACK_IMPORTED_MODULE_4__.default) { + return [query]; + } + + return []; + } + /** + * The visualization type of the question + */ + + }, { + key: "display", + value: function display() { + return this._card && this._card.display; + } + }, { + key: "setDisplay", + value: function setDisplay(display) { + return this.setCard((0,icepick__WEBPACK_IMPORTED_MODULE_1__.assoc)(this.card(), "display", display)); + } + }, { + key: "isDataset", + value: function isDataset() { + return this._card && this._card.dataset; + } + }, { + key: "setDataset", + value: function setDataset(dataset) { + return this.setCard((0,icepick__WEBPACK_IMPORTED_MODULE_1__.assoc)(this.card(), "dataset", dataset)); + } // locking the display prevents auto-selection + + }, { + key: "lockDisplay", + value: function lockDisplay() { + return this.setDisplayIsLocked(true); + } + }, { + key: "setDisplayIsLocked", + value: function setDisplayIsLocked(locked) { + return this.setCard((0,icepick__WEBPACK_IMPORTED_MODULE_1__.assoc)(this.card(), "displayIsLocked", locked)); + } + }, { + key: "displayIsLocked", + value: function displayIsLocked() { + return this._card && this._card.displayIsLocked; + } // If we're locked to a display that is no longer "sensible", unlock it + // unless it was locked in unsensible + + }, { + key: "maybeUnlockDisplay", + value: function maybeUnlockDisplay(sensibleDisplays, previousSensibleDisplays) { + var wasSensible = previousSensibleDisplays == null || previousSensibleDisplays.includes(this.display()); + var isSensible = sensibleDisplays.includes(this.display()); + var shouldUnlock = wasSensible && !isSensible; + var locked = this.displayIsLocked() && !shouldUnlock; + return this.setDisplayIsLocked(locked); + } // Switches display based on data shape. For 1x1 data, we show a scalar. If + // our display was a 1x1 type, but the data isn't 1x1, we show a table. + + }, { + key: "switchTableScalar", + value: function switchTableScalar(_ref) { + var _ref$rows = _ref.rows, + rows = _ref$rows === void 0 ? [] : _ref$rows, + cols = _ref.cols; + + if (this.displayIsLocked()) { + return this; + } + + var display = this.display(); + var isScalar = ["scalar", "progress", "gauge"].includes(display); + var isOneByOne = rows.length === 1 && cols.length === 1; + var newDisplay = !isScalar && isOneByOne // if we have a 1x1 data result then this should always be viewed as a scalar + ? "scalar" : isScalar && !isOneByOne // any time we were a scalar and now have more than 1x1 data switch to table view + ? "table" // otherwise leave the display unchanged + : display; + return this.setDisplay(newDisplay); + } + }, { + key: "setDefaultDisplay", + value: function setDefaultDisplay() { + if (this.displayIsLocked()) { + return this; + } + + var query = this.query(); + + if (query instanceof metabase_lib_lib_queries_StructuredQuery__WEBPACK_IMPORTED_MODULE_2__.default) { + // TODO: move to StructuredQuery? + var aggregations = query.aggregations(); + var breakouts = query.breakouts(); + var breakoutDimensions = breakouts.map(function (b) { + return b.dimension(); + }); + var breakoutFields = breakoutDimensions.map(function (d) { + return d.field(); + }); + + if (aggregations.length === 0 && breakouts.length === 0) { + return this.setDisplay("table"); + } + + if (aggregations.length === 1 && breakouts.length === 0) { + return this.setDisplay("scalar"); + } + + if (aggregations.length === 1 && breakouts.length === 1) { + if (breakoutFields[0].isState()) { + return this.setDisplay("map").updateSettings({ + "map.type": "region", + "map.region": "us_states" + }); + } else if (breakoutFields[0].isCountry()) { + return this.setDisplay("map").updateSettings({ + "map.type": "region", + "map.region": "world_countries" + }); + } + } + + if (aggregations.length >= 1 && breakouts.length === 1) { + if (breakoutFields[0].isDate()) { + if (breakoutDimensions[0] instanceof metabase_lib_lib_Dimension__WEBPACK_IMPORTED_MODULE_7__.FieldDimension && breakoutDimensions[0].temporalUnit() && breakoutDimensions[0].isTemporalExtraction()) { + return this.setDisplay("bar"); + } else { + return this.setDisplay("line"); + } + } + + if (breakoutDimensions[0] instanceof metabase_lib_lib_Dimension__WEBPACK_IMPORTED_MODULE_7__.FieldDimension && breakoutDimensions[0].binningStrategy()) { + return this.setDisplay("bar"); + } + + if (breakoutFields[0].isCategory()) { + return this.setDisplay("bar"); + } + } + + if (aggregations.length === 1 && breakouts.length === 2) { + if (underscore__WEBPACK_IMPORTED_MODULE_0__.default.any(breakoutFields, function (f) { + return f.isDate(); + })) { + return this.setDisplay("line"); + } + + if (breakoutFields[0].isCoordinate() && breakoutFields[1].isCoordinate()) { + return this.setDisplay("map").updateSettings({ + "map.type": "grid" + }); + } + + if (underscore__WEBPACK_IMPORTED_MODULE_0__.default.all(breakoutFields, function (f) { + return f.isCategory(); + })) { + return this.setDisplay("bar"); + } + } + } + + return this.setDisplay("table"); + } + }, { + key: "setDefaultQuery", + value: function setDefaultQuery() { + return this.query().setDefaultQuery().question(); + } + }, { + key: "settings", + value: function settings() { + return this._card && this._card.visualization_settings || {}; + } + }, { + key: "setting", + value: function setting(settingName) { + var defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined; + var value = this.settings()[settingName]; + return value === undefined ? defaultValue : value; + } + }, { + key: "setSettings", + value: function setSettings(settings) { + return this.setCard((0,icepick__WEBPACK_IMPORTED_MODULE_1__.assoc)(this.card(), "visualization_settings", settings)); + } + }, { + key: "updateSettings", + value: function updateSettings(settings) { + return this.setSettings(_objectSpread(_objectSpread({}, this.settings()), settings)); + } + }, { + key: "type", + value: function type() { + return this.datasetQuery().type; + } + }, { + key: "creationType", + value: function creationType() { + return this.card().creationType; + } + }, { + key: "isEmpty", + value: function isEmpty() { + return this.query().isEmpty(); + } + /** + * Question is valid (as far as we know) and can be executed + */ + + }, { + key: "canRun", + value: function canRun() { + return this.query().canRun(); + } + }, { + key: "canWrite", + value: function canWrite() { + return this._card && this._card.can_write; + } + }, { + key: "canAutoRun", + value: function canAutoRun() { + var db = this.database(); + return db && db.auto_run_queries || false; + } + /** + * Returns the type of alert that current question supports + * + * The `visualization_settings` in card object doesn't contain default settings, + * so you can provide the complete visualization settings object to `alertType` + * for taking those into account + */ + + }, { + key: "alertType", + value: function alertType(visualizationSettings) { + var display = this.display(); + + if (!this.canRun()) { + return null; + } + + var isLineAreaBar = display === "line" || display === "area" || display === "bar"; + + if (display === "progress") { + return metabase_lib_lib_Alert__WEBPACK_IMPORTED_MODULE_20__.ALERT_TYPE_PROGRESS_BAR_GOAL; + } else if (isLineAreaBar) { + var vizSettings = visualizationSettings ? visualizationSettings : this.card().visualization_settings; + var goalEnabled = vizSettings["graph.show_goal"]; + var hasSingleYAxisColumn = vizSettings["graph.metrics"] && vizSettings["graph.metrics"].length === 1; // We don't currently support goal alerts for multiseries question + + if (goalEnabled && hasSingleYAxisColumn) { + return metabase_lib_lib_Alert__WEBPACK_IMPORTED_MODULE_20__.ALERT_TYPE_TIMESERIES_GOAL; + } else { + return metabase_lib_lib_Alert__WEBPACK_IMPORTED_MODULE_20__.ALERT_TYPE_ROWS; + } + } else { + return metabase_lib_lib_Alert__WEBPACK_IMPORTED_MODULE_20__.ALERT_TYPE_ROWS; + } + } + /** + * Visualization drill-through and action widget actions + * + * Although most of these are essentially a way to modify the current query, having them as a part + * of Question interface instead of Query interface makes it more convenient to also change the current visualization + */ + + }, { + key: "aggregate", + value: function aggregate(a) { + return (0,metabase_modes_lib_actions__WEBPACK_IMPORTED_MODULE_17__.aggregate)(this, a) || this; + } + }, { + key: "breakout", + value: function breakout(b) { + return (0,metabase_modes_lib_actions__WEBPACK_IMPORTED_MODULE_17__.breakout)(this, b) || this; + } + }, { + key: "filter", + value: function filter(operator, column, value) { + return (0,metabase_modes_lib_actions__WEBPACK_IMPORTED_MODULE_17__.filter)(this, operator, column, value) || this; + } + }, { + key: "pivot", + value: function pivot() { + var breakouts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; + var dimensions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; + return (0,metabase_modes_lib_actions__WEBPACK_IMPORTED_MODULE_17__.pivot)(this, breakouts, dimensions) || this; + } + }, { + key: "drillUnderlyingRecords", + value: function drillUnderlyingRecords(dimensions) { + return (0,metabase_modes_lib_actions__WEBPACK_IMPORTED_MODULE_17__.drillUnderlyingRecords)(this, dimensions) || this; + } + }, { + key: "toUnderlyingRecords", + value: function toUnderlyingRecords() { + return (0,metabase_modes_lib_actions__WEBPACK_IMPORTED_MODULE_17__.toUnderlyingRecords)(this) || this; + } + }, { + key: "toUnderlyingData", + value: function toUnderlyingData() { + return this.setDisplay("table"); + } + }, { + key: "distribution", + value: function distribution(column) { + return (0,metabase_modes_lib_actions__WEBPACK_IMPORTED_MODULE_17__.distribution)(this, column) || this; + } + }, { + key: "composeThisQuery", + value: function composeThisQuery() { + if (this.id()) { + var card = { + display: "table", + dataset_query: { + type: "query", + database: this.databaseId(), + query: { + "source-table": "card__" + this.id() + } + } + }; + return this.setCard(card); + } + } + }, { + key: "composeDataset", + value: function composeDataset() { + if (!this.isDataset()) { + return this; + } + + return this.setDatasetQuery({ + type: "query", + database: this.databaseId(), + query: { + "source-table": "card__" + this.id() + } + }); + } + }, { + key: "drillPK", + value: function drillPK(field, value) { + var _query$filters; + + var query = this.query(); + + if (!(query instanceof metabase_lib_lib_queries_StructuredQuery__WEBPACK_IMPORTED_MODULE_2__.default)) { + return; + } + + var otherPKFilters = (_query$filters = query.filters()) === null || _query$filters === void 0 ? void 0 : _query$filters.filter(function (filter) { + var filterField = filter === null || filter === void 0 ? void 0 : filter.field(); + + if (!filterField) { + return false; + } + + var isNotSameField = filterField.id !== field.id; + var isPKEqualsFilter = filterField.isPK() && filter.operatorName() === "="; + var isFromSameTable = filterField.table.id === field.table.id; + return isPKEqualsFilter && isNotSameField && isFromSameTable; + }).map(function (filter) { + return filter.raw(); + }); + var filtersToApply = [["=", ["field", field.id, null], value]].concat(_toConsumableArray(otherPKFilters)); + var resultedQuery = filtersToApply.reduce(function (query, filter) { + return query.addFilter(filter); + }, query.reset().setTable(field.table)); + return resultedQuery.question(); + } + }, { + key: "_syncStructuredQueryColumnsAndSettings", + value: function _syncStructuredQueryColumnsAndSettings(previousQuestion, previousQuery) { + var query = this.query(); + + if (!underscore__WEBPACK_IMPORTED_MODULE_0__.default.isEqual(previousQuestion.setting("table.columns"), this.setting("table.columns"))) { + return (0,metabase_lib_dataset__WEBPACK_IMPORTED_MODULE_12__.syncTableColumnsToQuery)(this); + } + + var addedColumnNames = underscore__WEBPACK_IMPORTED_MODULE_0__.default.difference(query.columnNames(), previousQuery.columnNames()); + + var removedColumnNames = underscore__WEBPACK_IMPORTED_MODULE_0__.default.difference(previousQuery.columnNames(), query.columnNames()); + + if (this.setting("graph.metrics") && addedColumnNames.length > 0 && removedColumnNames.length === 0) { + var addedMetricColumnNames = addedColumnNames.filter(function (name) { + return query.columnDimensionWithName(name) instanceof metabase_lib_lib_Dimension__WEBPACK_IMPORTED_MODULE_7__.AggregationDimension; + }); + + if (addedMetricColumnNames.length > 0) { + return this.updateSettings({ + "graph.metrics": [].concat(_toConsumableArray(this.setting("graph.metrics")), _toConsumableArray(addedMetricColumnNames)) + }); + } + } + + if (this.setting("table.columns") && addedColumnNames.length > 0 && removedColumnNames.length === 0) { + return this.updateSettings({ + "table.columns": [].concat(_toConsumableArray(this.setting("table.columns")), _toConsumableArray(addedColumnNames.map(function (name) { + var dimension = query.columnDimensionWithName(name); + return { + name: name, + field_ref: dimension.baseDimension().mbql(), + enabled: true + }; + }))) + }); + } + + return this; + } + }, { + key: "_syncNativeQuerySettings", + value: function _syncNativeQuerySettings(_ref2) { + var _ref2$data = _ref2.data; + _ref2$data = _ref2$data === void 0 ? {} : _ref2$data; + var _ref2$data$cols = _ref2$data.cols, + cols = _ref2$data$cols === void 0 ? [] : _ref2$data$cols; + var vizSettings = this.setting("table.columns") || []; // "table.columns" receive a value only if there are custom settings + // e.g. some columns are hidden. If it's empty, it means everything is visible + + var isUsingDefaultSettings = vizSettings.length === 0; + + if (isUsingDefaultSettings) { + return this; + } + + var addedColumns = cols.filter(function (col) { + var hasVizSettings = (0,metabase_lib_dataset__WEBPACK_IMPORTED_MODULE_12__.findColumnSettingIndexForColumn)(vizSettings, col) >= 0; + return !hasVizSettings; + }); + var validVizSettings = vizSettings.filter(function (colSetting) { + var hasColumn = (0,metabase_lib_dataset__WEBPACK_IMPORTED_MODULE_12__.findColumnIndexForColumnSetting)(cols, colSetting) >= 0; + var isMutatingColumn = (0,metabase_lib_dataset__WEBPACK_IMPORTED_MODULE_12__.findColumnIndexForColumnSetting)(addedColumns, colSetting) >= 0; + return hasColumn && !isMutatingColumn; + }); + var noColumnsRemoved = validVizSettings.length === vizSettings.length; + + if (noColumnsRemoved && addedColumns.length === 0) { + return this; + } + + addedColumns = addedColumns.map(function (col) { + return { + name: col.name, + fieldRef: col.field_ref, + enabled: true + }; + }); + return this.updateSettings({ + "table.columns": [].concat(_toConsumableArray(validVizSettings), _toConsumableArray(addedColumns)) + }); + } + }, { + key: "syncColumnsAndSettings", + value: function syncColumnsAndSettings(previous, queryResults) { + var query = this.query(); + var isQueryResultValid = queryResults && !queryResults.error; + + if (query instanceof metabase_lib_lib_queries_NativeQuery__WEBPACK_IMPORTED_MODULE_3__.default && isQueryResultValid) { + return this._syncNativeQuerySettings(queryResults); + } + + var previousQuery = previous && previous.query(); + + if (query instanceof metabase_lib_lib_queries_StructuredQuery__WEBPACK_IMPORTED_MODULE_2__.default && previousQuery instanceof metabase_lib_lib_queries_StructuredQuery__WEBPACK_IMPORTED_MODULE_2__.default) { + return this._syncStructuredQueryColumnsAndSettings(previous, previousQuery); + } + + return this; + } + /** + * returns the "top-level" {Question} for a nested structured query, e.x. with post-aggregation filters removed + */ + + }, { + key: "topLevelQuestion", + value: function topLevelQuestion() { + var query = this.query(); + + if (query instanceof metabase_lib_lib_queries_StructuredQuery__WEBPACK_IMPORTED_MODULE_2__.default && query !== query.topLevelQuery()) { + return this.setQuery(query.topLevelQuery()); + } else { + return this; + } + } + /** + * returns the {ClickObject} with all columns transformed to be relative to the "top-level" query + */ + + }, { + key: "topLevelClicked", + value: function topLevelClicked(clicked) { + var query = this.query(); + + if (query instanceof metabase_lib_lib_queries_StructuredQuery__WEBPACK_IMPORTED_MODULE_2__.default && query !== query.topLevelQuery()) { + return _objectSpread(_objectSpread({}, clicked), {}, { + column: clicked.column && query.topLevelColumn(clicked.column), + dimensions: clicked.dimensions && clicked.dimensions.map(function (dimension) { + return _objectSpread(_objectSpread({}, dimension), {}, { + column: dimension.column && query.topLevelColumn(dimension.column) + }); + }) + }); + } else { + return clicked; + } + } + }, { + key: "mode", + value: function mode() { + return metabase_lib_lib_Mode__WEBPACK_IMPORTED_MODULE_8__.default.forQuestion(this); + } + /** + * Returns true if, based on filters and table columns, the expected result is a single row. + * However, it might not be true when a PK column is not unique, leading to multiple rows. + * Because of that, always check query results in addition to this property. + */ + + }, { + key: "isObjectDetail", + value: function isObjectDetail() { + var mode = this.mode(); + return mode ? mode.name() === "object" : false; + } + }, { + key: "objectDetailPK", + value: function objectDetailPK() { + var query = this.query(); + + if (this.isObjectDetail() && query instanceof metabase_lib_lib_queries_StructuredQuery__WEBPACK_IMPORTED_MODULE_2__.default) { + var filters = query.filters(); + + if (filters[0] && (0,metabase_lib_query_filter__WEBPACK_IMPORTED_MODULE_9__.isStandard)(filters[0])) { + return filters[0][2]; + } + } + } + /** + * A user-defined name for the question + */ + + }, { + key: "displayName", + value: function displayName() { + return this._card && this._card.name; + } + }, { + key: "setDisplayName", + value: function setDisplayName(name) { + return this.setCard((0,icepick__WEBPACK_IMPORTED_MODULE_1__.assoc)(this.card(), "name", name)); + } + }, { + key: "collectionId", + value: function collectionId() { + return this._card && this._card.collection_id; + } + }, { + key: "setCollectionId", + value: function setCollectionId(collectionId) { + return this.setCard((0,icepick__WEBPACK_IMPORTED_MODULE_1__.assoc)(this.card(), "collection_id", collectionId)); + } + }, { + key: "id", + value: function id() { + return this._card && this._card.id; + } + }, { + key: "markDirty", + value: function markDirty() { + return this.setCard((0,icepick__WEBPACK_IMPORTED_MODULE_1__.dissoc)((0,icepick__WEBPACK_IMPORTED_MODULE_1__.assoc)(this.card(), "original_card_id", this.id()), "id")); + } + }, { + key: "setDashboardId", + value: function setDashboardId(dashboardId) { + return this.setCard((0,icepick__WEBPACK_IMPORTED_MODULE_1__.assoc)(this.card(), "dashboardId", dashboardId)); + } + }, { + key: "description", + value: function description() { + return this._card && this._card.description; + } + }, { + key: "lastEditInfo", + value: function lastEditInfo() { + return this._card && this._card["last-edit-info"]; + } + }, { + key: "isSaved", + value: function isSaved() { + return !!this.id(); + } + }, { + key: "publicUUID", + value: function publicUUID() { + return this._card && this._card.public_uuid; + } + }, { + key: "database", + value: function database() { + var query = this.query(); + return query && typeof query.database === "function" ? query.database() : null; + } + }, { + key: "databaseId", + value: function databaseId() { + var db = this.database(); + return db ? db.id : null; + } + }, { + key: "table", + value: function table() { + var query = this.query(); + return query && typeof query.table === "function" ? query.table() : null; + } + }, { + key: "tableId", + value: function tableId() { + var table = this.table(); + return table ? table.id : null; + } + }, { + key: "getUrl", + value: function getUrl() { + var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, + originalQuestion = _ref3.originalQuestion, + _ref3$clean = _ref3.clean, + clean = _ref3$clean === void 0 ? true : _ref3$clean, + query = _ref3.query, + includeDisplayIsLocked = _ref3.includeDisplayIsLocked, + creationType = _ref3.creationType; + + var question = this.omitTransientCardIds(); + + if (!question.id() || originalQuestion && question.isDirtyComparedTo(originalQuestion)) { + return metabase_lib_urls__WEBPACK_IMPORTED_MODULE_11__.question(null, question._serializeForUrl({ + clean: clean, + includeDisplayIsLocked: includeDisplayIsLocked, + creationType: creationType + }), query); + } else { + return metabase_lib_urls__WEBPACK_IMPORTED_MODULE_11__.question(question.card(), "", query); + } + } + }, { + key: "getAutomaticDashboardUrl", + value: function getAutomaticDashboardUrl(filters + /*?: Filter[] = []*/ + ) { + var cellQuery = ""; + + if (filters.length > 0) { + var mbqlFilter = filters.length > 1 ? ["and"].concat(_toConsumableArray(filters)) : filters[0]; + cellQuery = "/cell/".concat((0,metabase_lib_encoding__WEBPACK_IMPORTED_MODULE_21__.utf8_to_b64url)(JSON.stringify(mbqlFilter))); + } + + var questionId = this.id(); + + if (questionId != null && !(0,metabase_meta_Card__WEBPACK_IMPORTED_MODULE_13__.isTransientId)(questionId)) { + return "/auto/dashboard/question/".concat(questionId).concat(cellQuery); + } else { + var adHocQuery = (0,metabase_lib_encoding__WEBPACK_IMPORTED_MODULE_21__.utf8_to_b64url)(JSON.stringify(this.card().dataset_query)); + return "/auto/dashboard/adhoc/".concat(adHocQuery).concat(cellQuery); + } + } + }, { + key: "getComparisonDashboardUrl", + value: function getComparisonDashboardUrl(filters + /*?: Filter[] = []*/ + ) { + var cellQuery = ""; + + if (filters.length > 0) { + var mbqlFilter = filters.length > 1 ? ["and"].concat(_toConsumableArray(filters)) : filters[0]; + cellQuery = "/cell/".concat((0,metabase_lib_encoding__WEBPACK_IMPORTED_MODULE_21__.utf8_to_b64url)(JSON.stringify(mbqlFilter))); + } + + var questionId = this.id(); + var query = this.query(); + + if (query instanceof metabase_lib_lib_queries_StructuredQuery__WEBPACK_IMPORTED_MODULE_2__.default) { + var tableId = query.tableId(); + + if (tableId) { + if (questionId != null && !(0,metabase_meta_Card__WEBPACK_IMPORTED_MODULE_13__.isTransientId)(questionId)) { + return "/auto/dashboard/question/".concat(questionId).concat(cellQuery, "/compare/table/").concat(tableId); + } else { + var adHocQuery = (0,metabase_lib_encoding__WEBPACK_IMPORTED_MODULE_21__.utf8_to_b64url)(JSON.stringify(this.card().dataset_query)); + return "/auto/dashboard/adhoc/".concat(adHocQuery).concat(cellQuery, "/compare/table/").concat(tableId); + } + } + } + } + }, { + key: "setResultsMetadata", + value: function setResultsMetadata(resultsMetadata) { + var metadataColumns = resultsMetadata && resultsMetadata.columns; + var metadataChecksum = resultsMetadata && resultsMetadata.checksum; + return this.setCard(_objectSpread(_objectSpread({}, this.card()), {}, { + result_metadata: metadataColumns, + metadata_checksum: metadataChecksum + })); + } + }, { + key: "getResultMetadata", + value: function getResultMetadata() { + var _this$card$result_met; + + return (_this$card$result_met = this.card().result_metadata) !== null && _this$card$result_met !== void 0 ? _this$card$result_met : []; + } + /** + * Returns true if the questions are equivalent (including id, card, and parameters) + */ + + }, { + key: "isEqual", + value: function isEqual(other) { + if (!other) { + return false; + } else if (this.id() !== other.id()) { + return false; + } else if (!underscore__WEBPACK_IMPORTED_MODULE_0__.default.isEqual(this.card(), other.card())) { + return false; + } else if (!underscore__WEBPACK_IMPORTED_MODULE_0__.default.isEqual(this.parameters(), other.parameters())) { + return false; + } + + return true; + } + /** + * Runs the query and returns an array containing results for each single query. + * + * If we have a saved and clean single-query question, we use `CardApi.query` instead of a ad-hoc dataset query. + * This way we benefit from caching and query optimizations done by Metabase backend. + */ + + }, { + key: "apiGetResults", + value: function () { + var _apiGetResults = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() { + var _this = this; + + var _ref4, + cancelDeferred, + _ref4$isDirty, + isDirty, + _ref4$ignoreCache, + ignoreCache, + canUseCardApiEndpoint, + parameters, + dashboardId, + queryParams, + getDatasetQueryResult, + datasetQueries, + _args = arguments; + + return regeneratorRuntime.wrap(function _callee$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + _ref4 = _args.length > 0 && _args[0] !== undefined ? _args[0] : {}, cancelDeferred = _ref4.cancelDeferred, _ref4$isDirty = _ref4.isDirty, isDirty = _ref4$isDirty === void 0 ? false : _ref4$isDirty, _ref4$ignoreCache = _ref4.ignoreCache, ignoreCache = _ref4$ignoreCache === void 0 ? false : _ref4$ignoreCache; + // TODO Atte Keinänen 7/5/17: Should we clean this query with Query.cleanQuery(query) before executing it? + canUseCardApiEndpoint = !isDirty && this.isSaved(); + parameters = this.parameters() // include only parameters that have a value applied + .filter(function (param) { + return underscore__WEBPACK_IMPORTED_MODULE_0__.default.has(param, "value"); + }) // only the superset of parameters object that API expects + .map(function (param) { + return underscore__WEBPACK_IMPORTED_MODULE_0__.default.pick(param, "type", "target", "value", "id"); + }).map(function (_ref5) { + var type = _ref5.type, + value = _ref5.value, + target = _ref5.target, + id = _ref5.id; + return { + type: type, + value: (0,metabase_parameters_utils_parameter_values__WEBPACK_IMPORTED_MODULE_16__.normalizeParameterValue)(type, value), + target: target, + id: id + }; + }); + + if (!canUseCardApiEndpoint) { + _context.next = 12; + break; + } + + dashboardId = this._card.dashboardId; + queryParams = { + cardId: this.id(), + dashboardId: dashboardId, + ignore_cache: ignoreCache, + parameters: parameters + }; + _context.next = 8; + return (0,metabase_services__WEBPACK_IMPORTED_MODULE_18__.maybeUsePivotEndpoint)(dashboardId ? metabase_services__WEBPACK_IMPORTED_MODULE_18__.DashboardApi.cardQuery : metabase_services__WEBPACK_IMPORTED_MODULE_18__.CardApi.query, this.card(), this.metadata())(queryParams, { + cancelled: cancelDeferred.promise + }); + + case 8: + _context.t0 = _context.sent; + return _context.abrupt("return", [_context.t0]); + + case 12: + getDatasetQueryResult = function getDatasetQueryResult(datasetQuery) { + var datasetQueryWithParameters = _objectSpread(_objectSpread({}, datasetQuery), {}, { + parameters: parameters + }); + + return (0,metabase_services__WEBPACK_IMPORTED_MODULE_18__.maybeUsePivotEndpoint)(metabase_services__WEBPACK_IMPORTED_MODULE_18__.MetabaseApi.dataset, _this.card(), _this.metadata())(datasetQueryWithParameters, cancelDeferred ? { + cancelled: cancelDeferred.promise + } : {}); + }; + + datasetQueries = this.atomicQueries().map(function (query) { + return query.datasetQuery(); + }); + return _context.abrupt("return", Promise.all(datasetQueries.map(getDatasetQueryResult))); + + case 15: + case "end": + return _context.stop(); + } + } + }, _callee, this); + })); + + function apiGetResults() { + return _apiGetResults.apply(this, arguments); + } + + return apiGetResults; + }() // NOTE: prefer `reduxCreate` so the store is automatically updated + + }, { + key: "apiCreate", + value: function () { + var _apiCreate = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() { + var createdCard; + return regeneratorRuntime.wrap(function _callee2$(_context2) { + while (1) { + switch (_context2.prev = _context2.next) { + case 0: + _context2.next = 2; + return metabase_entities_questions__WEBPACK_IMPORTED_MODULE_19__.default.api.create(this.card()); + + case 2: + createdCard = _context2.sent; + return _context2.abrupt("return", this.setCard(createdCard)); + + case 4: + case "end": + return _context2.stop(); + } + } + }, _callee2, this); + })); + + function apiCreate() { + return _apiCreate.apply(this, arguments); + } + + return apiCreate; + }() // NOTE: prefer `reduxUpdate` so the store is automatically updated + + }, { + key: "apiUpdate", + value: function () { + var _apiUpdate = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() { + var updatedCard; + return regeneratorRuntime.wrap(function _callee3$(_context3) { + while (1) { + switch (_context3.prev = _context3.next) { + case 0: + _context3.next = 2; + return metabase_entities_questions__WEBPACK_IMPORTED_MODULE_19__.default.api.update(this.card()); + + case 2: + updatedCard = _context3.sent; + return _context3.abrupt("return", this.setCard(updatedCard)); + + case 4: + case "end": + return _context3.stop(); + } + } + }, _callee3, this); + })); + + function apiUpdate() { + return _apiUpdate.apply(this, arguments); + } + + return apiUpdate; + }() + }, { + key: "reduxCreate", + value: function () { + var _reduxCreate = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(dispatch) { + var action; + return regeneratorRuntime.wrap(function _callee4$(_context4) { + while (1) { + switch (_context4.prev = _context4.next) { + case 0: + _context4.next = 2; + return dispatch(metabase_entities_questions__WEBPACK_IMPORTED_MODULE_19__.default.actions.create(this.card())); + + case 2: + action = _context4.sent; + return _context4.abrupt("return", this.setCard(metabase_entities_questions__WEBPACK_IMPORTED_MODULE_19__.default.HACK_getObjectFromAction(action))); + + case 4: + case "end": + return _context4.stop(); + } + } + }, _callee4, this); + })); + + function reduxCreate(_x) { + return _reduxCreate.apply(this, arguments); + } + + return reduxCreate; + }() + }, { + key: "reduxUpdate", + value: function () { + var _reduxUpdate = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5(dispatch) { + var _ref6, + _ref6$excludeDatasetQ, + excludeDatasetQuery, + fullCard, + card, + action, + _args5 = arguments; + + return regeneratorRuntime.wrap(function _callee5$(_context5) { + while (1) { + switch (_context5.prev = _context5.next) { + case 0: + _ref6 = _args5.length > 1 && _args5[1] !== undefined ? _args5[1] : {}, _ref6$excludeDatasetQ = _ref6.excludeDatasetQuery, excludeDatasetQuery = _ref6$excludeDatasetQ === void 0 ? false : _ref6$excludeDatasetQ; + fullCard = this.card(); + card = excludeDatasetQuery ? underscore__WEBPACK_IMPORTED_MODULE_0__.default.omit(fullCard, "dataset_query") : fullCard; + _context5.next = 5; + return dispatch(metabase_entities_questions__WEBPACK_IMPORTED_MODULE_19__.default.actions.update({ + id: this.id() + }, card)); + + case 5: + action = _context5.sent; + return _context5.abrupt("return", this.setCard(metabase_entities_questions__WEBPACK_IMPORTED_MODULE_19__.default.HACK_getObjectFromAction(action))); + + case 7: + case "end": + return _context5.stop(); + } + } + }, _callee5, this); + })); + + function reduxUpdate(_x2) { + return _reduxUpdate.apply(this, arguments); + } + + return reduxUpdate; + }() + }, { + key: "setParameters", + value: function setParameters(parameters) { + return this.setCard((0,icepick__WEBPACK_IMPORTED_MODULE_1__.assoc)(this.card(), "parameters", parameters)); + } + }, { + key: "setParameterValues", + value: function setParameterValues(parameterValues) { + var question = this.clone(); + question._parameterValues = parameterValues; + return question; + } // TODO: Fix incorrect Flow signature + + }, { + key: "parameters", + value: function parameters() { + return (0,metabase_parameters_utils_cards__WEBPACK_IMPORTED_MODULE_14__.getValueAndFieldIdPopulatedParametersFromCard)(this.card(), this.metadata(), this._parameterValues); + } // predicate function that dermines if the question is "dirty" compared to the given question + + }, { + key: "isDirtyComparedTo", + value: function isDirtyComparedTo(originalQuestion) { + if (!this.isSaved() && this.canRun() && originalQuestion == null) { + // if it's new, then it's dirty if it is runnable + return true; + } else { + // if it's saved, then it's dirty when the current card doesn't match the last saved version + var origCardSerialized = originalQuestion && originalQuestion._serializeForUrl({ + includeOriginalCardId: false + }); + + var currentCardSerialized = this._serializeForUrl({ + includeOriginalCardId: false + }); + + return currentCardSerialized !== origCardSerialized; + } + } + }, { + key: "isDirtyComparedToWithoutParameters", + value: function isDirtyComparedToWithoutParameters(originalQuestion) { + var _this2 = this; + + var _map = [this, originalQuestion].map(function (q) { + return q && new Question(q.card(), _this2.metadata()).setParameters([]).setDashboardId(undefined); + }), + _map2 = _slicedToArray(_map, 2), + a = _map2[0], + b = _map2[1]; + + return a.isDirtyComparedTo(b); + } // Internal methods + + }, { + key: "_serializeForUrl", + value: function _serializeForUrl() { + var _ref7 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, + _ref7$includeOriginal = _ref7.includeOriginalCardId, + includeOriginalCardId = _ref7$includeOriginal === void 0 ? true : _ref7$includeOriginal, + _ref7$clean = _ref7.clean, + clean = _ref7$clean === void 0 ? true : _ref7$clean, + _ref7$includeDisplayI = _ref7.includeDisplayIsLocked, + includeDisplayIsLocked = _ref7$includeDisplayI === void 0 ? false : _ref7$includeDisplayI, + creationType = _ref7.creationType; + + var query = clean ? this.query().clean() : this.query(); + + var cardCopy = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({ + name: this._card.name, + description: this._card.description, + collection_id: this._card.collection_id, + dataset_query: query.datasetQuery(), + display: this._card.display, + parameters: this._card.parameters + }, underscore__WEBPACK_IMPORTED_MODULE_0__.default.isEmpty(this._parameterValues) ? undefined : { + parameterValues: this._parameterValues + }), {}, { + // this is kinda wrong. these values aren't really part of the card, but this is a convenient place to put them + visualization_settings: this._card.visualization_settings + }, includeOriginalCardId ? { + original_card_id: this._card.original_card_id + } : {}), includeDisplayIsLocked ? { + displayIsLocked: this._card.displayIsLocked + } : {}), creationType ? { + creationType: creationType + } : {}), {}, { + dashboardId: this._card.dashboardId + }); + + return (0,metabase_lib_encoding__WEBPACK_IMPORTED_MODULE_21__.utf8_to_b64url)(JSON.stringify((0,metabase_lib_lib_utils__WEBPACK_IMPORTED_MODULE_10__.sortObject)(cardCopy))); + } + }, { + key: "convertParametersToFilters", + value: function convertParametersToFilters() { + var _this3 = this; + + if (!this.isStructured()) { + return this; + } + + var _this$parameters$redu = this.parameters().reduce(function (_ref8, parameter) { + var _ref9 = _slicedToArray(_ref8, 2), + query = _ref9[0], + isAltered = _ref9[1]; + + var filter = (0,metabase_parameters_utils_mbql__WEBPACK_IMPORTED_MODULE_15__.parameterToMBQLFilter)(parameter, _this3.metadata()); + return filter ? [query.filter(filter), true] : [query, isAltered]; + }, [this.query(), false]), + _this$parameters$redu2 = _slicedToArray(_this$parameters$redu, 2), + query = _this$parameters$redu2[0], + isAltered = _this$parameters$redu2[1]; + + var question = query.question().setParameters(undefined).setParameterValues(undefined); + return isAltered ? question.markDirty() : question; + } + }, { + key: "getUrlWithParameters", + value: function getUrlWithParameters(parameters, parameterValues) { + var includeDisplayIsLocked = true; + + if (this.isStructured()) { + var questionWithParameters = this.setParameters(parameters); + + if (this.query().isEditable()) { + return questionWithParameters.setParameterValues(parameterValues).convertParametersToFilters().getUrl({ + originalQuestion: this, + includeDisplayIsLocked: includeDisplayIsLocked + }); + } else { + var query = (0,metabase_parameters_utils_parameter_values__WEBPACK_IMPORTED_MODULE_16__.getParameterValuesBySlug)(parameters, parameterValues); + return questionWithParameters.markDirty().getUrl({ + query: query, + includeDisplayIsLocked: includeDisplayIsLocked + }); + } + } else { + return this.getUrl({ + query: (0,metabase_parameters_utils_cards__WEBPACK_IMPORTED_MODULE_14__.remapParameterValuesToTemplateTags)(this.query().templateTags(), parameters, parameterValues), + includeDisplayIsLocked: includeDisplayIsLocked + }); + } + } + }, { + key: "getModerationReviews", + value: function getModerationReviews() { + return (0,icepick__WEBPACK_IMPORTED_MODULE_1__.getIn)(this, ["_card", "moderation_reviews"]) || []; + } + }], [{ + key: "create", + value: function create() { + var _ref10 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, + databaseId = _ref10.databaseId, + tableId = _ref10.tableId, + collectionId = _ref10.collectionId, + metadata = _ref10.metadata, + parameterValues = _ref10.parameterValues, + _ref10$type = _ref10.type, + type = _ref10$type === void 0 ? "query" : _ref10$type, + name = _ref10.name, + _ref10$display = _ref10.display, + display = _ref10$display === void 0 ? "table" : _ref10$display, + _ref10$visualization_ = _ref10.visualization_settings, + visualization_settings = _ref10$visualization_ === void 0 ? {} : _ref10$visualization_, + _ref10$dataset_query = _ref10.dataset_query, + dataset_query = _ref10$dataset_query === void 0 ? type === "native" ? metabase_lib_lib_queries_NativeQuery__WEBPACK_IMPORTED_MODULE_3__.NATIVE_QUERY_TEMPLATE : metabase_lib_lib_queries_StructuredQuery__WEBPACK_IMPORTED_MODULE_2__.STRUCTURED_QUERY_TEMPLATE : _ref10$dataset_query; + + var card = { + name: name, + collection_id: collectionId, + display: display, + visualization_settings: visualization_settings, + dataset_query: dataset_query + }; + + if (tableId != null) { + card = (0,icepick__WEBPACK_IMPORTED_MODULE_1__.assocIn)(card, ["dataset_query", "query", "source-table"], tableId); + } + + if (databaseId != null) { + card = (0,icepick__WEBPACK_IMPORTED_MODULE_1__.assocIn)(card, ["dataset_query", "database"], databaseId); + } + + return new Question(card, metadata, parameterValues); + } + }]); + + return Question; +}(), (_applyDecoratedDescriptor(_class.prototype, "query", [metabase_lib_lib_utils__WEBPACK_IMPORTED_MODULE_10__.memoize], Object.getOwnPropertyDescriptor(_class.prototype, "query"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "mode", [metabase_lib_lib_utils__WEBPACK_IMPORTED_MODULE_10__.memoize], Object.getOwnPropertyDescriptor(_class.prototype, "mode"), _class.prototype)), _class); + +window.Question = Question; +window.NativeQuery = metabase_lib_lib_queries_NativeQuery__WEBPACK_IMPORTED_MODULE_3__.default; +window.StructuredQuery = metabase_lib_lib_queries_StructuredQuery__WEBPACK_IMPORTED_MODULE_2__.default; + +/***/ }), + +/***/ "../metabase-lib/lib/Variable.ts": +/*!***************************************!*\ + !*** ../metabase-lib/lib/Variable.ts ***! + \***************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* binding */ Variable; }, +/* harmony export */ "TemplateTagVariable": function() { return /* binding */ TemplateTagVariable; } +/* harmony export */ }); +/* harmony import */ var _queries_NativeQuery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./queries/NativeQuery */ "../metabase-lib/lib/queries/NativeQuery.ts"); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-nocheck + + +var Variable = function Variable(args, metadata, query) { + _classCallCheck(this, Variable); + + this._args = args; + this._metadata = metadata || query && query.metadata(); + this._query = query; +}; + + +var VARIABLE_ICONS = { + text: "string", + number: "int", + date: "calendar", + dimension: null +}; +var TemplateTagVariable = /*#__PURE__*/function (_Variable) { + _inherits(TemplateTagVariable, _Variable); + + var _super = _createSuper(TemplateTagVariable); + + function TemplateTagVariable() { + _classCallCheck(this, TemplateTagVariable); + + return _super.apply(this, arguments); + } + + _createClass(TemplateTagVariable, [{ + key: "tag", + value: function tag() { + if (this._query instanceof _queries_NativeQuery__WEBPACK_IMPORTED_MODULE_0__.default) { + return this._query.templateTagsMap()[this._args[0]]; + } + } + }, { + key: "displayName", + value: function displayName() { + var tag = this.tag(); + return tag && (tag["display-name"] || tag.name); + } + }, { + key: "icon", + value: function icon() { + var tag = this.tag(); + return tag && VARIABLE_ICONS[tag.type]; + } + }, { + key: "mbql", + value: function mbql() { + return ["template-tag", this._args[0]]; + } + }]); + + return TemplateTagVariable; +}(Variable); + +/***/ }), + +/***/ "../metabase-lib/lib/metadata/Base.ts": +/*!********************************************!*\ + !*** ../metabase-lib/lib/metadata/Base.ts ***! + \********************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* binding */ Base; } +/* harmony export */ }); +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-nocheck +var Base = /*#__PURE__*/function () { + function Base() { + var object = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + + _classCallCheck(this, Base); + + _defineProperty(this, "_plainObject", null); + + this._plainObject = object; + + for (var property in object) { + this[property] = object[property]; + } + } + /** + * Get the plain metadata object without hydrated fields. + * Useful for situations where you want serialize the metadata object. + */ + + + _createClass(Base, [{ + key: "getPlainObject", + value: function getPlainObject() { + return this._plainObject; + } + }]); + + return Base; +}(); + + + +/***/ }), + +/***/ "../metabase-lib/lib/metadata/Database.ts": +/*!************************************************!*\ + !*** ../metabase-lib/lib/metadata/Database.ts ***! + \************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* binding */ Database; } +/* harmony export */ }); +/* harmony import */ var _Question__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Question */ "../metabase-lib/lib/Question.ts"); +/* harmony import */ var _Base__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Base */ "../metabase-lib/lib/metadata/Base.ts"); +/* harmony import */ var metabase_lib_schema__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/lib/schema */ "./lib/schema/index.js"); +/* harmony import */ var metabase_lib_lib_utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase-lib/lib/utils */ "../metabase-lib/lib/utils.ts"); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +var _class; + +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; } + +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-nocheck + + + + +/** + * @typedef { import("./metadata").SchemaName } SchemaName + */ + +/** + * Wrapper class for database metadata objects. Contains {@link Schema}s, {@link Table}s, {@link Metric}s, {@link Segment}s. + * + * Backed by types/Database data structure which matches the backend API contract + */ + +var Database = (_class = /*#__PURE__*/function (_Base) { + _inherits(Database, _Base); + + var _super = _createSuper(Database); + + function Database() { + _classCallCheck(this, Database); + + return _super.apply(this, arguments); + } + + _createClass(Database, [{ + key: "displayName", + value: // TODO Atte Keinänen 6/11/17: List all fields here (currently only in types/Database) + function displayName() { + return this.name; + } // SCHEMAS + + /** + * @param {SchemaName} [schemaName] + */ + + }, { + key: "schema", + value: function schema(schemaName) { + return this.metadata.schema((0,metabase_lib_schema__WEBPACK_IMPORTED_MODULE_2__.generateSchemaId)(this.id, schemaName)); + } + }, { + key: "schemaNames", + value: function schemaNames() { + return this.schemas.map(function (s) { + return s.name; + }).sort(function (a, b) { + return a.localeCompare(b); + }); + } + }, { + key: "getSchemas", + value: function getSchemas() { + return this.schemas; + } + }, { + key: "schemasCount", + value: function schemasCount() { + return this.schemas.length; + } + }, { + key: "getTables", + value: function getTables() { + return this.tables; + } // TABLES + + }, { + key: "tablesLookup", + value: function tablesLookup() { + return (0,metabase_lib_lib_utils__WEBPACK_IMPORTED_MODULE_3__.createLookupByProperty)(this.tables, "id"); + } // @deprecated: use tablesLookup + + }, { + key: "tables_lookup", + get: function get() { + return this.tablesLookup(); + } // FEATURES + + /** + * @typedef {import("./metadata").DatabaseFeature} DatabaseFeature + * @typedef {"join"} VirtualDatabaseFeature + * @param {DatabaseFeature | VirtualDatabaseFeature} [feature] + */ + + }, { + key: "hasFeature", + value: function hasFeature(feature) { + if (!feature) { + return true; + } + + var set = new Set(this.features); + + if (feature === "join") { + return set.has("left-join") || set.has("right-join") || set.has("inner-join") || set.has("full-join"); + } else { + return set.has(feature); + } + } + }, { + key: "supportsPivots", + value: function supportsPivots() { + return this.hasFeature("expressions") && this.hasFeature("left-join"); + } // QUESTIONS + + }, { + key: "newQuestion", + value: function newQuestion() { + return this.question().setDefaultQuery().setDefaultDisplay(); + } + }, { + key: "question", + value: function question() { + var query = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { + "source-table": null + }; + return _Question__WEBPACK_IMPORTED_MODULE_0__.default.create({ + metadata: this.metadata, + dataset_query: { + database: this.id, + type: "query", + query: query + } + }); + } + }, { + key: "nativeQuestion", + value: function nativeQuestion() { + var native = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + return _Question__WEBPACK_IMPORTED_MODULE_0__.default.create({ + metadata: this.metadata, + dataset_query: { + database: this.id, + type: "native", + native: _objectSpread({ + query: "", + "template-tags": {} + }, native) + } + }); + } + }, { + key: "nativeQuery", + value: function nativeQuery(native) { + return this.nativeQuestion(native).query(); + } + /** Returns a database containing only the saved questions from the same database, if any */ + + }, { + key: "savedQuestionsDatabase", + value: function savedQuestionsDatabase() { + return this.metadata.databasesList().find(function (db) { + return db.is_saved_questions; + }); + } + /** + * @private + * @param {number} id + * @param {string} name + * @param {?string} description + * @param {Table[]} tables + * @param {Schema[]} schemas + * @param {Metadata} metadata + * @param {boolean} auto_run_queries + */ + + /* istanbul ignore next */ + + }, { + key: "_constructor", + value: function _constructor(id, name, description, tables, schemas, metadata, auto_run_queries) { + this.id = id; + this.name = name; + this.description = description; + this.tables = tables; + this.schemas = schemas; + this.metadata = metadata; + this.auto_run_queries = auto_run_queries; + } + }]); + + return Database; +}(_Base__WEBPACK_IMPORTED_MODULE_1__.default), (_applyDecoratedDescriptor(_class.prototype, "tablesLookup", [metabase_lib_lib_utils__WEBPACK_IMPORTED_MODULE_3__.memoize], Object.getOwnPropertyDescriptor(_class.prototype, "tablesLookup"), _class.prototype)), _class); + + +/***/ }), + +/***/ "../metabase-lib/lib/metadata/Field.ts": +/*!*********************************************!*\ + !*** ../metabase-lib/lib/metadata/Field.ts ***! + \*********************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* binding */ Field; } +/* harmony export */ }); +/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! underscore */ "../../../node_modules/underscore/modules/index-all.js"); +/* harmony import */ var moment__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! moment */ "../../../node_modules/moment/moment.js"); +/* harmony import */ var moment__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(moment__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var metabase_lib_lib_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase-lib/lib/utils */ "../metabase-lib/lib/utils.ts"); +/* harmony import */ var metabase_lib_formatting__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/lib/formatting */ "./lib/formatting.js"); +/* harmony import */ var metabase_lib_query_field__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! metabase/lib/query/field */ "./lib/query/field.js"); +/* harmony import */ var metabase_lib_schema_metadata__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! metabase/lib/schema_metadata */ "./lib/schema_metadata.js"); +/* harmony import */ var _Base__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Base */ "../metabase-lib/lib/metadata/Base.ts"); +/* harmony import */ var _Dimension__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Dimension */ "../metabase-lib/lib/Dimension.ts"); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +var _class; + +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; } + +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-nocheck + + + + + + + + +/** + * @typedef { import("./metadata").FieldValues } FieldValues + */ + +/** + * Wrapper class for field metadata objects. Belongs to a Table. + */ + +var Field = (_class = /*#__PURE__*/function (_Base) { + _inherits(Field, _Base); + + var _super = _createSuper(Field); + + function Field() { + _classCallCheck(this, Field); + + return _super.apply(this, arguments); + } + + _createClass(Field, [{ + key: "parent", + value: function parent() { + return this.metadata ? this.metadata.field(this.parent_id) : null; + } + }, { + key: "path", + value: function path() { + var path = []; + var field = this; + + do { + path.unshift(field); + } while (field = field.parent()); + + return path; + } + }, { + key: "displayName", + value: function displayName() { + var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, + includeSchema = _ref.includeSchema, + includeTable = _ref.includeTable, + _ref$includePath = _ref.includePath, + includePath = _ref$includePath === void 0 ? true : _ref$includePath; + + var displayName = ""; + + if (includeTable && this.table) { + displayName += this.table.displayName({ + includeSchema: includeSchema + }) + " → "; + } + + if (includePath) { + displayName += this.path().map(metabase_lib_formatting__WEBPACK_IMPORTED_MODULE_3__.formatField).join(": "); + } else { + displayName += (0,metabase_lib_formatting__WEBPACK_IMPORTED_MODULE_3__.formatField)(this); + } + + return displayName; + } + /** + * The name of the object type this field points to. + * Currently we try to guess this by stripping trailing `ID` from `display_name`, but ideally it would be configurable in metadata + * See also `table.objectName()` + */ + + }, { + key: "targetObjectName", + value: function targetObjectName() { + return (0,metabase_lib_formatting__WEBPACK_IMPORTED_MODULE_3__.stripId)(this.displayName()); + } + }, { + key: "isDate", + value: function isDate() { + return (0,metabase_lib_schema_metadata__WEBPACK_IMPORTED_MODULE_5__.isDate)(this); + } + }, { + key: "isTime", + value: function isTime() { + return (0,metabase_lib_schema_metadata__WEBPACK_IMPORTED_MODULE_5__.isTime)(this); + } + }, { + key: "isNumber", + value: function isNumber() { + return (0,metabase_lib_schema_metadata__WEBPACK_IMPORTED_MODULE_5__.isNumber)(this); + } + }, { + key: "isNumeric", + value: function isNumeric() { + return (0,metabase_lib_schema_metadata__WEBPACK_IMPORTED_MODULE_5__.isNumeric)(this); + } + }, { + key: "isBoolean", + value: function isBoolean() { + return (0,metabase_lib_schema_metadata__WEBPACK_IMPORTED_MODULE_5__.isBoolean)(this); + } + }, { + key: "isString", + value: function isString() { + return (0,metabase_lib_schema_metadata__WEBPACK_IMPORTED_MODULE_5__.isString)(this); + } + }, { + key: "isAddress", + value: function isAddress() { + return (0,metabase_lib_schema_metadata__WEBPACK_IMPORTED_MODULE_5__.isAddress)(this); + } + }, { + key: "isCity", + value: function isCity() { + return (0,metabase_lib_schema_metadata__WEBPACK_IMPORTED_MODULE_5__.isCity)(this); + } + }, { + key: "isZipCode", + value: function isZipCode() { + return (0,metabase_lib_schema_metadata__WEBPACK_IMPORTED_MODULE_5__.isZipCode)(this); + } + }, { + key: "isState", + value: function isState() { + return (0,metabase_lib_schema_metadata__WEBPACK_IMPORTED_MODULE_5__.isState)(this); + } + }, { + key: "isCountry", + value: function isCountry() { + return (0,metabase_lib_schema_metadata__WEBPACK_IMPORTED_MODULE_5__.isCountry)(this); + } + }, { + key: "isCoordinate", + value: function isCoordinate() { + return (0,metabase_lib_schema_metadata__WEBPACK_IMPORTED_MODULE_5__.isCoordinate)(this); + } + }, { + key: "isLocation", + value: function isLocation() { + return (0,metabase_lib_schema_metadata__WEBPACK_IMPORTED_MODULE_5__.isLocation)(this); + } + }, { + key: "isSummable", + value: function isSummable() { + return (0,metabase_lib_schema_metadata__WEBPACK_IMPORTED_MODULE_5__.isSummable)(this); + } + }, { + key: "isScope", + value: function isScope() { + return (0,metabase_lib_schema_metadata__WEBPACK_IMPORTED_MODULE_5__.isScope)(this); + } + }, { + key: "isCategory", + value: function isCategory() { + return (0,metabase_lib_schema_metadata__WEBPACK_IMPORTED_MODULE_5__.isCategory)(this); + } + }, { + key: "isMetric", + value: function isMetric() { + return (0,metabase_lib_schema_metadata__WEBPACK_IMPORTED_MODULE_5__.isMetric)(this); + } + /** + * Tells if this column can be used in a breakout + * Currently returns `true` for everything expect for aggregation columns + */ + + }, { + key: "isDimension", + value: function isDimension() { + return (0,metabase_lib_schema_metadata__WEBPACK_IMPORTED_MODULE_5__.isDimension)(this); + } + }, { + key: "isID", + value: function isID() { + return (0,metabase_lib_schema_metadata__WEBPACK_IMPORTED_MODULE_5__.isPK)(this) || (0,metabase_lib_schema_metadata__WEBPACK_IMPORTED_MODULE_5__.isFK)(this); + } + }, { + key: "isPK", + value: function isPK() { + return (0,metabase_lib_schema_metadata__WEBPACK_IMPORTED_MODULE_5__.isPK)(this); + } + }, { + key: "isFK", + value: function isFK() { + return (0,metabase_lib_schema_metadata__WEBPACK_IMPORTED_MODULE_5__.isFK)(this); + } + }, { + key: "isEntityName", + value: function isEntityName() { + return (0,metabase_lib_schema_metadata__WEBPACK_IMPORTED_MODULE_5__.isEntityName)(this); + } + /** + * @param {Field} field + */ + + }, { + key: "isCompatibleWith", + value: function isCompatibleWith(field) { + return this.isDate() === field.isDate() || this.isNumeric() === field.isNumeric() || this.id === field.id; + } + /** + * @returns {FieldValues} + */ + + }, { + key: "fieldValues", + value: function fieldValues() { + return (0,metabase_lib_query_field__WEBPACK_IMPORTED_MODULE_4__.getFieldValues)(this._plainObject); + } + }, { + key: "hasFieldValues", + value: function hasFieldValues() { + return !underscore__WEBPACK_IMPORTED_MODULE_0__.default.isEmpty(this.fieldValues()); + } + }, { + key: "icon", + value: function icon() { + return (0,metabase_lib_schema_metadata__WEBPACK_IMPORTED_MODULE_5__.getIconForField)(this); + } + }, { + key: "dimension", + value: function dimension() { + if (Array.isArray(this.id)) { + // if ID is an array, it's a MBQL field reference, typically "field" + return _Dimension__WEBPACK_IMPORTED_MODULE_7__.default.parseMBQL(this.id, this.metadata, this.query); + } else { + return _Dimension__WEBPACK_IMPORTED_MODULE_7__.default.parseMBQL(["field", this.id, null], this.metadata, this.query); + } + } + }, { + key: "sourceField", + value: function sourceField() { + var d = this.dimension().sourceDimension(); + return d && d.field(); + } // FILTERS + + }, { + key: "filterOperators", + value: function filterOperators(selected) { + return (0,metabase_lib_schema_metadata__WEBPACK_IMPORTED_MODULE_5__.getFilterOperators)(this, this.table, selected); + } + }, { + key: "filterOperatorsLookup", + value: function filterOperatorsLookup() { + return (0,metabase_lib_lib_utils__WEBPACK_IMPORTED_MODULE_2__.createLookupByProperty)(this.filterOperators(), "name"); + } + }, { + key: "filterOperator", + value: function filterOperator(operatorName) { + return this.filterOperatorsLookup()[operatorName]; + } // @deprecated: use filterOperators + + }, { + key: "filter_operators", + get: function get() { + return this.filterOperators(); + } // @deprecated: use filterOperatorsLookup + + }, { + key: "filter_operators_lookup", + get: function get() { + return this.filterOperatorsLookup(); + } // AGGREGATIONS + + }, { + key: "aggregationOperators", + value: function aggregationOperators() { + var _this = this; + + return this.table ? this.table.aggregationOperators().filter(function (aggregation) { + return aggregation.validFieldsFilters[0] && aggregation.validFieldsFilters[0]([_this]).length === 1; + }) : null; + } + }, { + key: "aggregationOperatorsLookup", + value: function aggregationOperatorsLookup() { + return (0,metabase_lib_lib_utils__WEBPACK_IMPORTED_MODULE_2__.createLookupByProperty)(this.aggregationOperators(), "short"); + } + }, { + key: "aggregationOperator", + value: function aggregationOperator(short) { + return this.aggregationOperatorsLookup()[short]; + } // @deprecated: use aggregationOperators + + }, { + key: "aggregation_operators", + get: function get() { + return this.aggregationOperators(); + } // @deprecated: use aggregationOperatorsLookup + + }, { + key: "aggregation_operators_lookup", + get: function get() { + return this.aggregationOperatorsLookup(); + } // BREAKOUTS + + /** + * Returns a default breakout MBQL clause for this field + */ + + }, { + key: "getDefaultBreakout", + value: function getDefaultBreakout() { + return this.dimension().defaultBreakout(); + } + /** + * Returns a default date/time unit for this field + */ + + }, { + key: "getDefaultDateTimeUnit", + value: function getDefaultDateTimeUnit() { + try { + var fingerprint = this.fingerprint.type["type/DateTime"]; + var days = moment__WEBPACK_IMPORTED_MODULE_1___default()(fingerprint.latest).diff(moment__WEBPACK_IMPORTED_MODULE_1___default()(fingerprint.earliest), "day"); + + if (days < 1) { + return "minute"; + } else if (days < 31) { + return "day"; + } else if (days < 365) { + return "week"; + } else { + return "month"; + } + } catch (e) { + return "day"; + } + } // REMAPPINGS + + /** + * Returns the remapped field, if any + * @return {?Field} + */ + + }, { + key: "remappedField", + value: function remappedField() { + var displayFieldId = this.dimensions && this.dimensions.human_readable_field_id; + + if (displayFieldId != null) { + return this.metadata.field(displayFieldId); + } // this enables "implicit" remappings from type/PK to type/Name on the same table, + // used in FieldValuesWidget, but not table/object detail listings + + + if (this.name_field) { + return this.name_field; + } + + return null; + } + /** + * Returns the human readable remapped value, if any + * @returns {?string} + */ + + }, { + key: "remappedValue", + value: function remappedValue(value) { + // TODO: Ugh. Should this be handled further up by the parameter widget? + if (this.isNumeric() && typeof value !== "number") { + value = parseFloat(value); + } + + return this.remapping && this.remapping.get(value); + } + /** + * Returns whether the field has a human readable remapped value for this value + * @returns {?string} + */ + + }, { + key: "hasRemappedValue", + value: function hasRemappedValue(value) { + // TODO: Ugh. Should this be handled further up by the parameter widget? + if (this.isNumeric() && typeof value !== "number") { + value = parseFloat(value); + } + + return this.remapping && this.remapping.has(value); + } + /** + * Returns true if this field can be searched, e.x. in filter or parameter widgets + * @returns {boolean} + */ + + }, { + key: "isSearchable", + value: function isSearchable() { + // TODO: ...? + return this.isString(); + } + }, { + key: "column", + value: function column() { + var extra = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + return this.dimension().column(_objectSpread({ + source: "fields" + }, extra)); + } + /** + * Returns a FKDimension for this field and the provided field + * @param {Field} foreignField + * @return {Dimension} + */ + + }, { + key: "foreign", + value: function foreign(foreignField) { + return this.dimension().foreign(foreignField.dimension()); + } + /** + * @private + * @param {number} id + * @param {string} name + * @param {string} display_name + * @param {string} description + * @param {Table} table + * @param {?Field} name_field + * @param {Metadata} metadata + */ + + /* istanbul ignore next */ + + }, { + key: "_constructor", + value: function _constructor(id, name, display_name, description, table, name_field, metadata) { + this.id = id; + this.name = name; + this.display_name = display_name; + this.description = description; + this.table = table; + this.name_field = name_field; + this.metadata = metadata; + } + }]); + + return Field; +}(_Base__WEBPACK_IMPORTED_MODULE_6__.default), (_applyDecoratedDescriptor(_class.prototype, "filterOperators", [metabase_lib_lib_utils__WEBPACK_IMPORTED_MODULE_2__.memoize], Object.getOwnPropertyDescriptor(_class.prototype, "filterOperators"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "filterOperatorsLookup", [metabase_lib_lib_utils__WEBPACK_IMPORTED_MODULE_2__.memoize], Object.getOwnPropertyDescriptor(_class.prototype, "filterOperatorsLookup"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "aggregationOperators", [metabase_lib_lib_utils__WEBPACK_IMPORTED_MODULE_2__.memoize], Object.getOwnPropertyDescriptor(_class.prototype, "aggregationOperators"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "aggregationOperatorsLookup", [metabase_lib_lib_utils__WEBPACK_IMPORTED_MODULE_2__.memoize], Object.getOwnPropertyDescriptor(_class.prototype, "aggregationOperatorsLookup"), _class.prototype)), _class); + + +/***/ }), + +/***/ "../metabase-lib/lib/metadata/Metadata.ts": +/*!************************************************!*\ + !*** ../metabase-lib/lib/metadata/Metadata.ts ***! + \************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* binding */ Metadata; } +/* harmony export */ }); +/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! underscore */ "../../../node_modules/underscore/modules/index-all.js"); +/* harmony import */ var _Base__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Base */ "../metabase-lib/lib/metadata/Base.ts"); +/* harmony import */ var _Question__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Question */ "../metabase-lib/lib/Question.ts"); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-nocheck + + + +/** + * @typedef { import("./metadata").DatabaseId } DatabaseId + * @typedef { import("./metadata").SchemaId } SchemaId + * @typedef { import("./metadata").TableId } TableId + * @typedef { import("./metadata").FieldId } FieldId + * @typedef { import("./metadata").MetricId } MetricId + * @typedef { import("./metadata").SegmentId } SegmentId + */ + +/** + * Wrapper class for the entire metadata store + */ + +var Metadata = /*#__PURE__*/function (_Base) { + _inherits(Metadata, _Base); + + var _super = _createSuper(Metadata); + + function Metadata() { + _classCallCheck(this, Metadata); + + return _super.apply(this, arguments); + } + + _createClass(Metadata, [{ + key: "databasesList", + value: + /** + * @deprecated this won't be sorted or filtered in a meaningful way + * @returns {Database[]} + */ + function databasesList() { + var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, + _ref$savedQuestions = _ref.savedQuestions, + savedQuestions = _ref$savedQuestions === void 0 ? true : _ref$savedQuestions; + + return underscore__WEBPACK_IMPORTED_MODULE_0__.default.chain(this.databases).values().filter(function (db) { + return savedQuestions || !db.is_saved_questions; + }).sortBy(function (db) { + return db.name; + }).value(); + } + /** + * @deprecated this won't be sorted or filtered in a meaningful way + * @returns {Table[]} + */ + + }, { + key: "tablesList", + value: function tablesList() { + return Object.values(this.tables); + } + /** + * @deprecated this won't be sorted or filtered in a meaningful way + * @returns {Metric[]} + */ + + }, { + key: "metricsList", + value: function metricsList() { + return Object.values(this.metrics); + } + /** + * @deprecated this won't be sorted or filtered in a meaningful way + * @returns {Segment[]} + */ + + }, { + key: "segmentsList", + value: function segmentsList() { + return Object.values(this.segments); + } + /** + * @param {SegmentId} segmentId + * @returns {?Segment} + */ + + }, { + key: "segment", + value: function segment(segmentId) { + return segmentId != null && this.segments[segmentId] || null; + } + /** + * @param {MetricId} metricId + * @returns {?Metric} + */ + + }, { + key: "metric", + value: function metric(metricId) { + return metricId != null && this.metrics[metricId] || null; + } + /** + * @param {DatabaseId} databaseId + * @returns {?Database} + */ + + }, { + key: "database", + value: function database(databaseId) { + return databaseId != null && this.databases[databaseId] || null; + } + /** + * @param {SchemaId} schemaId + * @returns {Schema} + */ + + }, { + key: "schema", + value: function schema(schemaId) { + return schemaId != null && this.schemas[schemaId] || null; + } + /** + * + * @param {TableId} tableId + * @returns {?Table} + */ + + }, { + key: "table", + value: function table(tableId) { + return tableId != null && this.tables[tableId] || null; + } + /** + * @param {FieldId} fieldId + * @returns {?Field} + */ + + }, { + key: "field", + value: function field(fieldId) { + return fieldId != null && this.fields[fieldId] || null; + } + }, { + key: "question", + value: function question(card) { + return new _Question__WEBPACK_IMPORTED_MODULE_2__.default(card, this); + } + /** + * @private + * @param {Object.} databases + * @param {Object.} tables + * @param {Object.} fields + * @param {Object.} metrics + * @param {Object.} segments + */ + + /* istanbul ignore next */ + + }, { + key: "_constructor", + value: function _constructor(databases, tables, fields, metrics, segments) { + this.databases = databases; + this.tables = tables; + this.fields = fields; + this.metrics = metrics; + this.segments = segments; + } + }]); + + return Metadata; +}(_Base__WEBPACK_IMPORTED_MODULE_1__.default); + + + +/***/ }), + +/***/ "../metabase-lib/lib/metadata/Metric.ts": +/*!**********************************************!*\ + !*** ../metabase-lib/lib/metadata/Metric.ts ***! + \**********************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* binding */ Metric; } +/* harmony export */ }); +/* harmony import */ var _Base__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Base */ "../metabase-lib/lib/metadata/Base.ts"); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-nocheck + +/** + * @typedef { import("./metadata").Aggregation } Aggregation + */ + +/** + * Wrapper class for a metric. Belongs to a {@link Database} and possibly a {@link Table} + */ + +var Metric = /*#__PURE__*/function (_Base) { + _inherits(Metric, _Base); + + var _super = _createSuper(Metric); + + function Metric() { + _classCallCheck(this, Metric); + + return _super.apply(this, arguments); + } + + _createClass(Metric, [{ + key: "displayName", + value: function displayName() { + return this.name; + } + /** + * @returns {Aggregation} + */ + + }, { + key: "aggregationClause", + value: function aggregationClause() { + return ["metric", this.id]; + } + /** Underlying query for this metric */ + + }, { + key: "definitionQuery", + value: function definitionQuery() { + return this.definition ? this.table.query().setQuery(this.definition) : null; + } + /** Underlying aggregation clause for this metric */ + + }, { + key: "aggregation", + value: function aggregation() { + var query = this.definitionQuery(); + + if (query) { + return query.aggregations()[0]; + } + } + /** Column name when this metric is used in a query */ + + }, { + key: "columnName", + value: function columnName() { + var aggregation = this.aggregation(); + + if (aggregation) { + return aggregation.columnName(); + } else if (typeof this.id === "string") { + // special case for Google Analytics metrics + return this.id; + } else { + return null; + } + } + }, { + key: "isActive", + value: function isActive() { + return !this.archived; + } + /** + * @private + * @param {string} name + * @param {string} description + * @param {Database} database + * @param {Table} table + * @param {number} id + * @param {StructuredQuery} definition + * @param {boolean} archived + */ + + /* istanbul ignore next */ + + }, { + key: "_constructor", + value: function _constructor(name, description, database, table, id, definition, archived) { + this.name = name; + this.description = description; + this.database = database; + this.table = table; + this.id = id; + this.definition = definition; + this.archived = archived; + } + }]); + + return Metric; +}(_Base__WEBPACK_IMPORTED_MODULE_0__.default); + + + +/***/ }), + +/***/ "../metabase-lib/lib/metadata/Schema.ts": +/*!**********************************************!*\ + !*** ../metabase-lib/lib/metadata/Schema.ts ***! + \**********************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* binding */ Schema; } +/* harmony export */ }); +/* harmony import */ var _Base__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Base */ "../metabase-lib/lib/metadata/Base.ts"); +/* harmony import */ var metabase_lib_formatting__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/lib/formatting */ "./lib/formatting.js"); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-nocheck + + +/** + * Wrapper class for a {@link Database} schema. Contains {@link Table}s. + */ + +var Schema = /*#__PURE__*/function (_Base) { + _inherits(Schema, _Base); + + var _super = _createSuper(Schema); + + function Schema() { + _classCallCheck(this, Schema); + + return _super.apply(this, arguments); + } + + _createClass(Schema, [{ + key: "displayName", + value: function displayName() { + return (0,metabase_lib_formatting__WEBPACK_IMPORTED_MODULE_1__.titleize)((0,metabase_lib_formatting__WEBPACK_IMPORTED_MODULE_1__.humanize)(this.name)); + } + }, { + key: "getTables", + value: function getTables() { + return this.tables; + } + /** + * @private + * @param {string} name + * @param {Database} database + * @param {Table[]} tables + */ + + /* istanbul ignore next */ + + }, { + key: "_constructor", + value: function _constructor(name, database, tables) { + this.name = name; + this.database = database; + this.tables = tables; + } + }]); + + return Schema; +}(_Base__WEBPACK_IMPORTED_MODULE_0__.default); + + + +/***/ }), + +/***/ "../metabase-lib/lib/metadata/Segment.ts": +/*!***********************************************!*\ + !*** ../metabase-lib/lib/metadata/Segment.ts ***! + \***********************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* binding */ Segment; } +/* harmony export */ }); +/* harmony import */ var _Base__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Base */ "../metabase-lib/lib/metadata/Base.ts"); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-nocheck + +/** + * @typedef { import("./metadata").FilterClause } FilterClause + */ + +/** + * Wrapper class for a segment. Belongs to a {@link Database} and possibly a {@link Table} + */ + +var Segment = /*#__PURE__*/function (_Base) { + _inherits(Segment, _Base); + + var _super = _createSuper(Segment); + + function Segment() { + _classCallCheck(this, Segment); + + return _super.apply(this, arguments); + } + + _createClass(Segment, [{ + key: "displayName", + value: function displayName() { + return this.name; + } + /** + * @returns {FilterClause} + */ + + }, { + key: "filterClause", + value: function filterClause() { + return ["segment", this.id]; + } + }, { + key: "isActive", + value: function isActive() { + return !this.archived; + } + /** + * @private + * @param {string} name + * @param {string} description + * @param {Database} database + * @param {Table} table + * @param {number} id + * @param {boolean} archived + */ + + /* istanbul ignore next */ + + }, { + key: "_constructor", + value: function _constructor(name, description, database, table, id, archived) { + this.name = name; + this.description = description; + this.database = database; + this.table = table; + this.id = id; + this.archived = archived; + } + }]); + + return Segment; +}(_Base__WEBPACK_IMPORTED_MODULE_0__.default); + + + +/***/ }), + +/***/ "../metabase-lib/lib/metadata/Table.ts": +/*!*********************************************!*\ + !*** ../metabase-lib/lib/metadata/Table.ts ***! + \*********************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* binding */ Table; } +/* harmony export */ }); +/* harmony import */ var _Question__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Question */ "../metabase-lib/lib/Question.ts"); +/* harmony import */ var _Base__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Base */ "../metabase-lib/lib/metadata/Base.ts"); +/* harmony import */ var metabase_lib_formatting__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/lib/formatting */ "./lib/formatting.js"); +/* harmony import */ var metabase_lib_schema_metadata__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/lib/schema_metadata */ "./lib/schema_metadata.js"); +/* harmony import */ var metabase_lib_lib_utils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! metabase-lib/lib/utils */ "../metabase-lib/lib/utils.ts"); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +var _class; + +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; } + +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-nocheck +// NOTE: this needs to be imported first due to some cyclical dependency nonsense + + + + + +/** + * @typedef { import("./metadata").SchemaName } SchemaName + * @typedef { import("./metadata").EntityType } EntityType + * @typedef { import("./metadata").StructuredQuery } StructuredQuery + */ + +/** This is the primary way people interact with tables */ + +var Table = (_class = /*#__PURE__*/function (_Base) { + _inherits(Table, _Base); + + var _super = _createSuper(Table); + + function Table() { + _classCallCheck(this, Table); + + return _super.apply(this, arguments); + } + + _createClass(Table, [{ + key: "hasSchema", + value: function hasSchema() { + return this.schema_name && this.db && this.db.schemas.length > 1 || false; + } // Could be replaced with hydrated database property in selectors/metadata.js (instead / in addition to `table.db`) + + }, { + key: "database", + get: function get() { + return this.db; + } + }, { + key: "newQuestion", + value: function newQuestion() { + return this.question().setDefaultQuery().setDefaultDisplay(); + } + }, { + key: "question", + value: function question() { + return _Question__WEBPACK_IMPORTED_MODULE_0__.default.create({ + databaseId: this.db && this.db.id, + tableId: this.id, + metadata: this.metadata + }); + } + }, { + key: "isSavedQuestion", + value: function isSavedQuestion() { + return this.savedQuestionId() !== null; + } + }, { + key: "savedQuestionId", + value: function savedQuestionId() { + var match = String(this.id).match(/card__(\d+)/); + return match ? parseInt(match[1]) : null; + } + /** + * @returns {StructuredQuery} + */ + + }, { + key: "query", + value: function query() { + var _query = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + + return this.question().query().updateQuery(function (q) { + return _objectSpread(_objectSpread({}, q), _query); + }); + } + }, { + key: "dimensions", + value: function dimensions() { + return this.fields.map(function (field) { + return field.dimension(); + }); + } + }, { + key: "displayName", + value: function displayName() { + var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, + includeSchema = _ref.includeSchema; + + return (includeSchema && this.schema ? this.schema.displayName() + "." : "") + this.display_name; + } + /** + * The singular form of the object type this table represents + * Currently we try to guess this by singularizing `display_name`, but ideally it would be configurable in metadata + * See also `field.targetObjectName()` + */ + + }, { + key: "objectName", + value: function objectName() { + return (0,metabase_lib_formatting__WEBPACK_IMPORTED_MODULE_2__.singularize)(this.displayName()); + } + }, { + key: "dateFields", + value: function dateFields() { + return this.fields.filter(function (field) { + return field.isDate(); + }); + } // AGGREGATIONS + + }, { + key: "aggregationOperators", + value: function aggregationOperators() { + return (0,metabase_lib_schema_metadata__WEBPACK_IMPORTED_MODULE_3__.getAggregationOperatorsWithFields)(this); + } + }, { + key: "aggregationOperatorsLookup", + value: function aggregationOperatorsLookup() { + return (0,metabase_lib_lib_utils__WEBPACK_IMPORTED_MODULE_4__.createLookupByProperty)(this.aggregationOperators(), "short"); + } + }, { + key: "aggregationOperator", + value: function aggregationOperator(short) { + return this.aggregation_operators_lookup[short]; + } // @deprecated: use aggregationOperators + + }, { + key: "aggregation_operators", + get: function get() { + return this.aggregationOperators(); + } // @deprecated: use aggregationOperatorsLookup + + }, { + key: "aggregation_operators_lookup", + get: function get() { + return this.aggregationOperatorsLookup(); + } // FIELDS + + }, { + key: "fieldsLookup", + value: function fieldsLookup() { + return (0,metabase_lib_lib_utils__WEBPACK_IMPORTED_MODULE_4__.createLookupByProperty)(this.fields, "id"); + } // @deprecated: use fieldsLookup + + }, { + key: "fields_lookup", + get: function get() { + return this.fieldsLookup(); + } + }, { + key: "numFields", + value: function numFields() { + var _this$fields; + + return ((_this$fields = this.fields) === null || _this$fields === void 0 ? void 0 : _this$fields.length) || 0; + } + }, { + key: "connectedTables", + value: function connectedTables() { + var fks = this.fks || []; + return fks.map(function (fk) { + return new Table(fk.origin.table); + }); + } + /** + * @private + * @param {string} description + * @param {Database} db + * @param {Schema?} schema + * @param {SchemaName} [schema_name] + * @param {Field[]} fields + * @param {EntityType} entity_type + */ + + /* istanbul ignore next */ + + }, { + key: "_constructor", + value: function _constructor(description, db, schema, schema_name, fields, entity_type) { + this.description = description; + this.db = db; + this.schema = schema; + this.schema_name = schema_name; + this.fields = fields; + this.entity_type = entity_type; + } + }]); + + return Table; +}(_Base__WEBPACK_IMPORTED_MODULE_1__.default), (_applyDecoratedDescriptor(_class.prototype, "aggregationOperators", [metabase_lib_lib_utils__WEBPACK_IMPORTED_MODULE_4__.memoize], Object.getOwnPropertyDescriptor(_class.prototype, "aggregationOperators"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "aggregationOperatorsLookup", [metabase_lib_lib_utils__WEBPACK_IMPORTED_MODULE_4__.memoize], Object.getOwnPropertyDescriptor(_class.prototype, "aggregationOperatorsLookup"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "fieldsLookup", [metabase_lib_lib_utils__WEBPACK_IMPORTED_MODULE_4__.memoize], Object.getOwnPropertyDescriptor(_class.prototype, "fieldsLookup"), _class.prototype)), _class); + + +/***/ }), + +/***/ "../metabase-lib/lib/queries/AtomicQuery.ts": +/*!**************************************************!*\ + !*** ../metabase-lib/lib/queries/AtomicQuery.ts ***! + \**************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* binding */ AtomicQuery; } +/* harmony export */ }); +/* harmony import */ var metabase_lib_lib_queries_Query__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! metabase-lib/lib/queries/Query */ "../metabase-lib/lib/queries/Query.ts"); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-nocheck + + +/** + * A query type for queries that are attached to a specific database table + * and form a single MBQL / native query clause + */ +var AtomicQuery = /*#__PURE__*/function (_Query) { + _inherits(AtomicQuery, _Query); + + var _super = _createSuper(AtomicQuery); + + function AtomicQuery() { + _classCallCheck(this, AtomicQuery); + + return _super.apply(this, arguments); + } + + _createClass(AtomicQuery, [{ + key: "tables", + value: + /** + * Tables this query could use, if the database is set + */ + function tables() { + return null; + } + }, { + key: "databaseId", + value: function databaseId() { + return null; + } + }, { + key: "database", + value: function database() { + return null; + } + }, { + key: "engine", + value: function engine() { + return null; + } + }]); + + return AtomicQuery; +}(metabase_lib_lib_queries_Query__WEBPACK_IMPORTED_MODULE_0__.default); + + + +/***/ }), + +/***/ "../metabase-lib/lib/queries/InternalQuery.ts": +/*!****************************************************!*\ + !*** ../metabase-lib/lib/queries/InternalQuery.ts ***! + \****************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* binding */ InternalQuery; } +/* harmony export */ }); +/* harmony import */ var metabase_lib_lib_queries_AtomicQuery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! metabase-lib/lib/queries/AtomicQuery */ "../metabase-lib/lib/queries/AtomicQuery.ts"); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-nocheck + // Internal queries call Clojure functions in the backend rather than querying a +// datastore. Here's an example query: +// { +// type: "internal", +// fn: "function goes here", +// args: [], +// } + +var InternalQuery = /*#__PURE__*/function (_AtomicQuery) { + _inherits(InternalQuery, _AtomicQuery); + + var _super = _createSuper(InternalQuery); + + function InternalQuery() { + _classCallCheck(this, InternalQuery); + + return _super.apply(this, arguments); + } + + _createClass(InternalQuery, null, [{ + key: "isDatasetQueryType", + value: function isDatasetQueryType(datasetQuery) { + return datasetQuery.type === "internal"; + } + }]); + + return InternalQuery; +}(metabase_lib_lib_queries_AtomicQuery__WEBPACK_IMPORTED_MODULE_0__.default); + + + +/***/ }), + +/***/ "../metabase-lib/lib/queries/NativeQuery.ts": +/*!**************************************************!*\ + !*** ../metabase-lib/lib/queries/NativeQuery.ts ***! + \**************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "NATIVE_QUERY_TEMPLATE": function() { return /* binding */ NATIVE_QUERY_TEMPLATE; }, +/* harmony export */ "default": function() { return /* binding */ NativeQuery; } +/* harmony export */ }); +/* harmony import */ var metabase_lib_string__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! metabase/lib/string */ "./lib/string.js"); +/* harmony import */ var metabase_lib_formatting__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/lib/formatting */ "./lib/formatting.js"); +/* harmony import */ var metabase_lib_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/lib/utils */ "./lib/utils.js"); +/* harmony import */ var metabase_lib_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/lib/engine */ "./lib/engine.js"); +/* harmony import */ var icepick__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! icepick */ "../../../node_modules/icepick/icepick.min.js"); +/* harmony import */ var icepick__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(icepick__WEBPACK_IMPORTED_MODULE_4__); +/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! underscore */ "../../../node_modules/underscore/modules/index-all.js"); +/* harmony import */ var metabase_lib_lib_queries_AtomicQuery__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! metabase-lib/lib/queries/AtomicQuery */ "../metabase-lib/lib/queries/AtomicQuery.ts"); +/* harmony import */ var _Dimension__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Dimension */ "../metabase-lib/lib/Dimension.ts"); +/* harmony import */ var _Variable__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Variable */ "../metabase-lib/lib/Variable.ts"); +/* harmony import */ var _DimensionOptions__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../DimensionOptions */ "../metabase-lib/lib/DimensionOptions.ts"); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-nocheck + + + + + + + + + + +var NATIVE_QUERY_TEMPLATE = { + database: null, + type: "native", + native: { + query: "", + "template-tags": {} + } +}; // This regex needs to match logic in replaceCardId and _getUpdatedTemplateTags. + +var CARD_TAG_REGEX = /^#([0-9]*)$/; + +function cardTagCardId(name) { + var match = name.match(CARD_TAG_REGEX); + + if (match && match[1].length > 0) { + return parseInt(match[1]); + } + + return null; +} + +function isCardQueryName(name) { + return CARD_TAG_REGEX.test(name); +} + +function snippetNameFromTagName(name) { + return name.slice("snippet:".length).trim(); +} + +function isSnippetName(name) { + return name.startsWith("snippet:"); +} + +var NativeQuery = /*#__PURE__*/function (_AtomicQuery) { + _inherits(NativeQuery, _AtomicQuery); + + var _super = _createSuper(NativeQuery); + + // For Flow type completion + function NativeQuery(question) { + var _this; + + var datasetQuery = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : NATIVE_QUERY_TEMPLATE; + + _classCallCheck(this, NativeQuery); + + _this = _super.call(this, question, datasetQuery); + _this._nativeDatasetQuery = datasetQuery; + return _this; + } + + _createClass(NativeQuery, [{ + key: "hasData", + value: + /* Query superclass methods */ + function hasData() { + return this.databaseId() != null && (!this.requiresTable() || this.collection()); + } + }, { + key: "canRun", + value: function canRun() { + return this.hasData() && this.queryText().length > 0 && this.allTemplateTagsAreValid(); + } + }, { + key: "isEmpty", + value: function isEmpty() { + return this.databaseId() == null || this.queryText().length === 0; + } + }, { + key: "clean", + value: function clean() { + return this.setDatasetQuery((0,icepick__WEBPACK_IMPORTED_MODULE_4__.updateIn)(this.datasetQuery(), ["native", "template-tags"], function (tt) { + return tt || {}; + })); + } + /* AtomicQuery superclass methods */ + + }, { + key: "tables", + value: function tables() { + var database = this.database(); + return database && database.tables || null; + } + }, { + key: "databaseId", + value: function databaseId() { + // same for both structured and native + return this._nativeDatasetQuery.database; + } + }, { + key: "database", + value: function database() { + var databaseId = this.databaseId(); + return databaseId != null ? this._metadata.database(databaseId) : null; + } + }, { + key: "engine", + value: function engine() { + var database = this.database(); + return database && database.engine; + } + /** + * Returns true if the database metadata (or lack thererof indicates the user can modify and run this query + */ + + }, { + key: "readOnly", + value: function readOnly() { + var database = this.database(); + return !database || database.native_permissions !== "write"; + } + /* Methods unique to this query type */ + + /** + * @returns a new query with the provided Database set. + */ + + }, { + key: "setDatabase", + value: function setDatabase(database) { + return this.setDatabaseId(database.id); + } + }, { + key: "setDatabaseId", + value: function setDatabaseId(databaseId) { + if (databaseId !== this.databaseId()) { + // TODO: this should reset the rest of the query? + return new NativeQuery(this._originalQuestion, (0,icepick__WEBPACK_IMPORTED_MODULE_4__.assoc)(this.datasetQuery(), "database", databaseId)); + } else { + return this; + } + } + }, { + key: "setDefaultCollection", + value: function setDefaultCollection() { + if (this.requiresTable()) { + var tables = this.tables(); + + if (tables && tables.length > 0) { + return this.setCollectionName(tables[0].name); + } + } + + return this; + } + }, { + key: "hasWritePermission", + value: function hasWritePermission() { + var database = this.database(); + return database != null && database.native_permissions === "write"; + } + }, { + key: "supportsNativeParameters", + value: function supportsNativeParameters() { + var database = this.database(); + return database != null && underscore__WEBPACK_IMPORTED_MODULE_5__.default.contains(database.features, "native-parameters"); + } + }, { + key: "table", + value: function table() { + var database = this.database(); + var collection = this.collection(); + + if (!database || !collection) { + return null; + } + + return underscore__WEBPACK_IMPORTED_MODULE_5__.default.findWhere(database.tables, { + name: collection + }) || null; + } + }, { + key: "queryText", + value: function queryText() { + return (0,icepick__WEBPACK_IMPORTED_MODULE_4__.getIn)(this.datasetQuery(), ["native", "query"]) || ""; + } + }, { + key: "setQueryText", + value: function setQueryText(newQueryText) { + return new NativeQuery(this._originalQuestion, (0,icepick__WEBPACK_IMPORTED_MODULE_4__.chain)(this._datasetQuery).assocIn(["native", "query"], newQueryText).assocIn(["native", "template-tags"], this._getUpdatedTemplateTags(newQueryText)).value()); + } + }, { + key: "collection", + value: function collection() { + return (0,icepick__WEBPACK_IMPORTED_MODULE_4__.getIn)(this.datasetQuery(), ["native", "collection"]); + } + }, { + key: "setCollectionName", + value: function setCollectionName(newCollection) { + return new NativeQuery(this._originalQuestion, (0,icepick__WEBPACK_IMPORTED_MODULE_4__.assocIn)(this._datasetQuery, ["native", "collection"], newCollection)); + } + }, { + key: "setParameterIndex", + value: function setParameterIndex(id, newIndex) { + // NOTE: currently all NativeQuery parameters are implicitly generated from + // template tags, and the order is determined by the key order + return new NativeQuery(this._originalQuestion, (0,icepick__WEBPACK_IMPORTED_MODULE_4__.updateIn)(this._datasetQuery, ["native", "template-tags"], function (templateTags) { + var entries = Array.from(Object.entries(templateTags)); + + var oldIndex = underscore__WEBPACK_IMPORTED_MODULE_5__.default.findIndex(entries, function (entry) { + return entry[1].id === id; + }); + + entries.splice(newIndex, 0, entries.splice(oldIndex, 1)[0]); + return underscore__WEBPACK_IMPORTED_MODULE_5__.default.object(entries); + })); + } + }, { + key: "lineCount", + value: function lineCount() { + var queryText = this.queryText(); + return queryText ? (0,metabase_lib_string__WEBPACK_IMPORTED_MODULE_0__.countLines)(queryText) : 0; + } + /** + * The ACE Editor mode name, e.g. 'ace/mode/json' + */ + + }, { + key: "aceMode", + value: function aceMode() { + return (0,metabase_lib_engine__WEBPACK_IMPORTED_MODULE_3__.getEngineNativeAceMode)(this.engine()); + } + /** + * Name used to describe the text written in that mode, e.g. 'JSON'. Used to fill in the blank in 'This question is written in _______'. + */ + + }, { + key: "nativeQueryLanguage", + value: function nativeQueryLanguage() { + return (0,metabase_lib_engine__WEBPACK_IMPORTED_MODULE_3__.getEngineNativeType)(this.engine()).toUpperCase(); + } + /** + * Whether the DB selector should be a DB + Table selector. Mongo needs both DB + Table. + */ + + }, { + key: "requiresTable", + value: function requiresTable() { + return (0,metabase_lib_engine__WEBPACK_IMPORTED_MODULE_3__.getEngineNativeRequiresTable)(this.engine()); + } + }, { + key: "templateTags", + value: function templateTags() { + return Object.values(this.templateTagsMap()); + } + }, { + key: "templateTagsWithoutSnippets", + value: function templateTagsWithoutSnippets() { + return this.templateTags().filter(function (t) { + return t.type !== "snippet"; + }); + } + }, { + key: "templateTagsMap", + value: function templateTagsMap() { + return (0,icepick__WEBPACK_IMPORTED_MODULE_4__.getIn)(this.datasetQuery(), ["native", "template-tags"]) || {}; + } + }, { + key: "allTemplateTagsAreValid", + value: function allTemplateTagsAreValid() { + return this.templateTags().every(function (t) { + if (["text", "number", "date", "card", "snippet"].includes(t.type)) { + return true; + } + + var isDimensionType = t.type === "dimension"; + var hasDefinedWidgetType = t["widget-type"] && t["widget-type"] !== "none"; + var hasDefinedDimension = t.dimension != null; + return isDimensionType && hasDefinedWidgetType && hasDefinedDimension; + }); + } + }, { + key: "setTemplateTag", + value: function setTemplateTag(name, tag) { + return this.setDatasetQuery((0,icepick__WEBPACK_IMPORTED_MODULE_4__.assocIn)(this.datasetQuery(), ["native", "template-tags", name], tag)); + } + }, { + key: "setDatasetQuery", + value: function setDatasetQuery(datasetQuery) { + return new NativeQuery(this._originalQuestion, datasetQuery); + } // `replaceCardId` updates the query text to reference a different card. + // Template tags are updated as a result of calling `setQueryText`. + + }, { + key: "replaceCardId", + value: function replaceCardId(oldId, newId) { + var re = new RegExp("{{\\s*#".concat(oldId, "\\s*}}"), "g"); + var newQueryText = this.queryText().replace(re, function () { + return "{{#".concat(newId, "}}"); + }); + return this.setQueryText(newQueryText); + } + }, { + key: "dimensionOptions", + value: function dimensionOptions() { + var _this2 = this; + + var dimensionFilter = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : underscore__WEBPACK_IMPORTED_MODULE_5__.default.identity; + var operatorFilter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : underscore__WEBPACK_IMPORTED_MODULE_5__.default.identity; + var dimensions = this.templateTags().filter(function (tag) { + return tag.type === "dimension" && operatorFilter(tag); + }).map(function (tag) { + return new _Dimension__WEBPACK_IMPORTED_MODULE_7__.TemplateTagDimension(tag.name, _this2.metadata(), _this2); + }).filter(function (dimension) { + return dimensionFilter(dimension); + }); + return new _DimensionOptions__WEBPACK_IMPORTED_MODULE_9__.default({ + dimensions: dimensions, + count: dimensions.length + }); + } + }, { + key: "variables", + value: function variables() { + var _this3 = this; + + var variableFilter = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function () { + return true; + }; + return this.templateTags().filter(function (tag) { + return tag.type !== "dimension"; + }).map(function (tag) { + return new _Variable__WEBPACK_IMPORTED_MODULE_8__.TemplateTagVariable([tag.name], _this3.metadata(), _this3); + }).filter(variableFilter); + } + }, { + key: "updateSnippetsWithIds", + value: function updateSnippetsWithIds(snippets) { + var tagsBySnippetName = underscore__WEBPACK_IMPORTED_MODULE_5__.default.chain(this.templateTags()).filter(function (tag) { + return tag.type === "snippet" && tag["snippet-id"] == null; + }).groupBy(function (tag) { + return tag["snippet-name"]; + }).value(); + + if (Object.keys(tagsBySnippetName).length === 0) { + // no need to check if there are no tags + return this; + } + + var query = this; + + var _iterator = _createForOfIteratorHelper(snippets), + _step; + + try { + for (_iterator.s(); !(_step = _iterator.n()).done;) { + var snippet = _step.value; + + var _iterator2 = _createForOfIteratorHelper(tagsBySnippetName[snippet.name] || []), + _step2; + + try { + for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { + var tag = _step2.value; + query = query.setTemplateTag(tag.name, _objectSpread(_objectSpread({}, tag), {}, { + "snippet-id": snippet.id + })); + } + } catch (err) { + _iterator2.e(err); + } finally { + _iterator2.f(); + } + } + } catch (err) { + _iterator.e(err); + } finally { + _iterator.f(); + } + + return query; + } + }, { + key: "updateQueryTextWithNewSnippetNames", + value: function updateQueryTextWithNewSnippetNames(snippets) { + var tagsBySnippetId = underscore__WEBPACK_IMPORTED_MODULE_5__.default.chain(this.templateTags()).filter(function (tag) { + return tag.type === "snippet"; + }).groupBy(function (tag) { + return tag["snippet-id"]; + }).value(); + + if (Object.keys(tagsBySnippetId).length === 0) { + // no need to check if there are no tags + return this; + } + + var queryText = this.queryText(); + + var _iterator3 = _createForOfIteratorHelper(snippets), + _step3; + + try { + for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) { + var snippet = _step3.value; + + var _iterator4 = _createForOfIteratorHelper(tagsBySnippetId[snippet.id] || []), + _step4; + + try { + for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) { + var tag = _step4.value; + + if (tag["snippet-name"] !== snippet.name) { + queryText = queryText.replace(new RegExp("{{\\s*".concat(tag.name, "\\s*}}"), "g"), "{{snippet: ".concat(snippet.name, "}}")); + } + } + } catch (err) { + _iterator4.e(err); + } finally { + _iterator4.f(); + } + } + } catch (err) { + _iterator3.e(err); + } finally { + _iterator3.f(); + } + + if (queryText !== this.queryText()) { + return this.setQueryText(queryText).updateSnippetsWithIds(snippets); + } + + return this; + } + /** + * special handling for NATIVE cards to automatically detect parameters ... {{varname}} + */ + + }, { + key: "_getUpdatedTemplateTags", + value: function _getUpdatedTemplateTags(queryText) { + if (queryText && this.supportsNativeParameters()) { + var tags = []; // look for variable usage in the query (like '{{varname}}'). we only allow alphanumeric characters for the variable name + // a variable name can optionally end with :start or :end which is not considered part of the actual variable name + // expected pattern is like mustache templates, so we are looking for something like {{category}} or {{date:start}} + // anything that doesn't match our rule is ignored, so {{&foo!}} would simply be ignored + // variables referencing other questions, by their card ID, are also supported: {{#123}} references question with ID 123 + + var match; + var re = /\{\{\s*((snippet:\s*[^}]+)|[A-Za-z0-9_]+?|#[0-9]*)\s*\}\}/g; + + while ((match = re.exec(queryText)) != null) { + tags.push(match[1]); + } // eliminate any duplicates since it's allowed for a user to reference the same variable multiple times + + + tags = underscore__WEBPACK_IMPORTED_MODULE_5__.default.uniq(tags); + var existingTemplateTags = this.templateTagsMap(); + var existingTags = Object.keys(existingTemplateTags); // if we ended up with any variables in the query then update the card parameters list accordingly + + if (tags.length > 0 || existingTags.length > 0) { + var newTags = underscore__WEBPACK_IMPORTED_MODULE_5__.default.difference(tags, existingTags); + + var oldTags = underscore__WEBPACK_IMPORTED_MODULE_5__.default.difference(existingTags, tags); + + var templateTags = _objectSpread({}, existingTemplateTags); + + if (oldTags.length === 1 && newTags.length === 1) { + // renaming + var newTag = _objectSpread({}, templateTags[oldTags[0]]); + + if (newTag["display-name"] === (0,metabase_lib_formatting__WEBPACK_IMPORTED_MODULE_1__.humanize)(oldTags[0])) { + newTag["display-name"] = (0,metabase_lib_formatting__WEBPACK_IMPORTED_MODULE_1__.humanize)(newTags[0]); + } + + newTag.name = newTags[0]; + + if (isCardQueryName(newTag.name)) { + newTag.type = "card"; + newTag["card-id"] = cardTagCardId(newTag.name); + } else if (isSnippetName(newTag.name)) { + newTag.type = "snippet"; + newTag["snippet-name"] = snippetNameFromTagName(newTag.name); + } + + templateTags[newTag.name] = newTag; + delete templateTags[oldTags[0]]; + } else { + // remove old vars + var _iterator5 = _createForOfIteratorHelper(oldTags), + _step5; + + try { + for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) { + var name = _step5.value; + delete templateTags[name]; + } // create new vars + + } catch (err) { + _iterator5.e(err); + } finally { + _iterator5.f(); + } + + var _iterator6 = _createForOfIteratorHelper(newTags), + _step6; + + try { + for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) { + var tagName = _step6.value; + templateTags[tagName] = { + id: metabase_lib_utils__WEBPACK_IMPORTED_MODULE_2__.default.uuid(), + name: tagName, + "display-name": (0,metabase_lib_formatting__WEBPACK_IMPORTED_MODULE_1__.humanize)(tagName), + type: "text" + }; // parse card ID from tag name for card query template tags + + if (isCardQueryName(tagName)) { + templateTags[tagName] = Object.assign(templateTags[tagName], { + type: "card", + "card-id": cardTagCardId(tagName) + }); + } else if (isSnippetName(tagName)) { + // extract snippet name from snippet tag + templateTags[tagName] = Object.assign(templateTags[tagName], { + type: "snippet", + "snippet-name": snippetNameFromTagName(tagName) + }); + } + } + } catch (err) { + _iterator6.e(err); + } finally { + _iterator6.f(); + } + } // ensure all tags have an id since we need it for parameter values to work + + + for (var _i = 0, _Object$values = Object.values(templateTags); _i < _Object$values.length; _i++) { + var tag = _Object$values[_i]; + + if (tag.id == null) { + tag.id = metabase_lib_utils__WEBPACK_IMPORTED_MODULE_2__.default.uuid(); + } + } + + return templateTags; + } + } + + return {}; + } + }, { + key: "dependentMetadata", + value: function dependentMetadata() { + var _this4 = this; + + var templateTags = this.templateTags(); + return templateTags.filter(function (tag) { + return tag.type === "dimension" && _Dimension__WEBPACK_IMPORTED_MODULE_7__.FieldDimension.isFieldClause(tag.dimension); + }).map(function (tag) { + var dimension = _Dimension__WEBPACK_IMPORTED_MODULE_7__.FieldDimension.parseMBQL(tag.dimension, _this4.metadata()); + return { + type: "field", + id: dimension.field().id + }; + }); + } + }], [{ + key: "isDatasetQueryType", + value: function isDatasetQueryType(datasetQuery) { + return datasetQuery && datasetQuery.type === NATIVE_QUERY_TEMPLATE.type; + } + }]); + + return NativeQuery; +}(metabase_lib_lib_queries_AtomicQuery__WEBPACK_IMPORTED_MODULE_6__.default); + + + +/***/ }), + +/***/ "../metabase-lib/lib/queries/Query.ts": +/*!********************************************!*\ + !*** ../metabase-lib/lib/queries/Query.ts ***! + \********************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* binding */ Query; } +/* harmony export */ }); +/* harmony import */ var metabase_lib_lib_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! metabase-lib/lib/utils */ "../metabase-lib/lib/utils.ts"); +/* harmony import */ var metabase_lib_lib_DimensionOptions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase-lib/lib/DimensionOptions */ "../metabase-lib/lib/DimensionOptions.ts"); +var _class; + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; } + +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-nocheck + + + +/** + * An abstract class for all query types (StructuredQuery & NativeQuery) + */ +var Query = (_class = /*#__PURE__*/function () { + /** + * Note that Question is not always in sync with _datasetQuery, + * calling question() will always merge the latest _datasetQuery to the question object + */ + function Query(question, datasetQuery) { + _classCallCheck(this, Query); + + this._metadata = question._metadata; + this._datasetQuery = datasetQuery; + this._originalQuestion = question; + } + /** + * Returns a question updated with the current dataset query. + * Can only be applied to query that is a direct child of the question. + */ + + + _createClass(Query, [{ + key: "question", + value: function question() { + return this._originalQuestion.setQuery(this); + } + /** + * Returns a "clean" version of this query with invalid parts removed + */ + + }, { + key: "clean", + value: function clean() { + return this; + } + /** + * Convenience method for accessing the global metadata + */ + + }, { + key: "metadata", + value: function metadata() { + return this._metadata; + } + /** + * Does this query have the sufficient metadata for editing it? + */ + + }, { + key: "isEditable", + value: function isEditable() { + return true; + } + /** + * Returns the dataset_query object underlying this Query + */ + + }, { + key: "datasetQuery", + value: function datasetQuery() { + return this._datasetQuery; + } + }, { + key: "setDatasetQuery", + value: function setDatasetQuery(datasetQuery) { + return this; + } + /** + * + * Query is considered empty, i.e. it is in a plain state with no properties / query clauses set + */ + + }, { + key: "isEmpty", + value: function isEmpty() { + return false; + } + /** + * Query is valid (as far as we know) and can be executed + */ + + }, { + key: "canRun", + value: function canRun() { + return false; + } + /** + * Returns true if the database metadata (or lack thererof indicates the user can modify and run this query + */ + + }, { + key: "readOnly", + value: function readOnly() { + return true; + } + /** + * Dimensions exposed by this query + * NOTE: Ideally we'd also have `dimensions()` that returns a flat list, but currently StructuredQuery has it's own `dimensions()` for another purpose. + */ + + }, { + key: "dimensionOptions", + value: function dimensionOptions(filter) { + return new metabase_lib_lib_DimensionOptions__WEBPACK_IMPORTED_MODULE_1__.default(); + } + /** + * Variables exposed by this query + */ + + }, { + key: "variables", + value: function variables(filter) { + return []; + } + /** + * Metadata this query needs to display correctly + */ + + }, { + key: "dependentMetadata", + value: function dependentMetadata() { + return []; + } + }, { + key: "setDefaultQuery", + value: function setDefaultQuery() { + return this; + } + /** + * Helper for updating with functions that expect a DatasetQuery object, or proxy to parent question + */ + + }, { + key: "update", + value: function update(_update) { + for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } + + if (_update) { + return _update.apply(void 0, [this.datasetQuery()].concat(args)); + } else { + var _this$question; + + return (_this$question = this.question()).update.apply(_this$question, [undefined].concat(args)); + } + } + }]); + + return Query; +}(), (_applyDecoratedDescriptor(_class.prototype, "question", [metabase_lib_lib_utils__WEBPACK_IMPORTED_MODULE_0__.memoize], Object.getOwnPropertyDescriptor(_class.prototype, "question"), _class.prototype)), _class); + + +/***/ }), + +/***/ "../metabase-lib/lib/queries/StructuredQuery.ts": +/*!******************************************************!*\ + !*** ../metabase-lib/lib/queries/StructuredQuery.ts ***! + \******************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "STRUCTURED_QUERY_TEMPLATE": function() { return /* binding */ STRUCTURED_QUERY_TEMPLATE; }, +/* harmony export */ "default": function() { return /* binding */ StructuredQuery; } +/* harmony export */ }); +/* harmony import */ var metabase_lib_query_query__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! metabase/lib/query/query */ "./lib/query/query.js"); +/* harmony import */ var metabase_lib_query_expression__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/lib/query/expression */ "./lib/query/expression.js"); +/* harmony import */ var metabase_lib_expressions_format__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/lib/expressions/format */ "./lib/expressions/format.js"); +/* harmony import */ var metabase_lib_schema_metadata__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/lib/schema_metadata */ "./lib/schema_metadata.js"); +/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! underscore */ "../../../node_modules/underscore/modules/index-all.js"); +/* harmony import */ var icepick__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! icepick */ "../../../node_modules/icepick/icepick.min.js"); +/* harmony import */ var icepick__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(icepick__WEBPACK_IMPORTED_MODULE_5__); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_6__); +/* harmony import */ var metabase_lib_lib_utils__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! metabase-lib/lib/utils */ "../metabase-lib/lib/utils.ts"); +/* harmony import */ var metabase_lib_lib_Dimension__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! metabase-lib/lib/Dimension */ "../metabase-lib/lib/Dimension.ts"); +/* harmony import */ var metabase_lib_lib_DimensionOptions__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! metabase-lib/lib/DimensionOptions */ "../metabase-lib/lib/DimensionOptions.ts"); +/* harmony import */ var _AtomicQuery__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./AtomicQuery */ "../metabase-lib/lib/queries/AtomicQuery.ts"); +/* harmony import */ var _structured_Aggregation__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./structured/Aggregation */ "../metabase-lib/lib/queries/structured/Aggregation.ts"); +/* harmony import */ var _structured_Breakout__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./structured/Breakout */ "../metabase-lib/lib/queries/structured/Breakout.ts"); +/* harmony import */ var _structured_Filter__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./structured/Filter */ "../metabase-lib/lib/queries/structured/Filter.ts"); +/* harmony import */ var _structured_Join__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./structured/Join */ "../metabase-lib/lib/queries/structured/Join.ts"); +/* harmony import */ var _structured_OrderBy__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./structured/OrderBy */ "../metabase-lib/lib/queries/structured/OrderBy.ts"); +/* harmony import */ var _metadata_Table__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../metadata/Table */ "../metabase-lib/lib/metadata/Table.ts"); +/* harmony import */ var _metadata_Field__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../metadata/Field */ "../metabase-lib/lib/metadata/Field.ts"); +/* harmony import */ var metabase_lib_types__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! metabase/lib/types */ "./lib/types.js"); +/* harmony import */ var metabase_lib_dataset__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! metabase/lib/dataset */ "./lib/dataset.js"); +/* provided dependency */ var console = __webpack_require__(/*! console-browserify */ "../../../node_modules/console-browserify/index.js"); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +var _excluded = ["quotes"]; + +var _class, _templateObject; + +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } + +function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } + +function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + +function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } + +function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } + +function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-nocheck + +/** + * Represents a structured MBQL query. + */ + + + + + + + + + + + + + + + + + + + + +var STRUCTURED_QUERY_TEMPLATE = { + database: null, + type: "query", + query: { + "source-table": null + } +}; +/** + * A wrapper around an MBQL (`query` type @type {DatasetQuery}) object + */ + +var StructuredQuery = (_class = /*#__PURE__*/function (_AtomicQuery) { + _inherits(StructuredQuery, _AtomicQuery); + + var _super2 = _createSuper(StructuredQuery); + + /** + * Creates a new StructuredQuery based on the provided DatasetQuery object + */ + function StructuredQuery(question) { + var _this2; + + var datasetQuery = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : STRUCTURED_QUERY_TEMPLATE; + + _classCallCheck(this, StructuredQuery); + + _this2 = _super2.call(this, question, datasetQuery); + _this2._structuredDatasetQuery = datasetQuery; + return _this2; + } + /* Query superclass methods */ + + /** + * @returns true if this is new query that hasn't been modified yet. + */ + + + _createClass(StructuredQuery, [{ + key: "isEmpty", + value: function isEmpty() { + return !this.databaseId(); + } + /** + * @returns true if this query is in a state where it can be run. + */ + + }, { + key: "canRun", + value: function canRun() { + return !!(this.sourceTableId() || this.sourceQuery()); + } + /** + * @returns true if we have metadata for the root source table loaded + */ + + }, { + key: "hasMetadata", + value: function hasMetadata() { + return this.metadata() && !!this.rootTable(); + } + /** + * @returns true if this query is in a state where it can be edited. Must have database and table set, and metadata for the table loaded. + */ + + }, { + key: "isEditable", + value: function isEditable() { + return this.hasMetadata(); + } + /* AtomicQuery superclass methods */ + + /** + * @returns all tables in the currently selected database that can be used. + */ + + }, { + key: "tables", + value: function tables() { + var database = this.database(); + return database && database.tables || null; + } + /** + * @returns the currently selected database ID, if any is selected. + */ + + }, { + key: "databaseId", + value: function databaseId() { + // same for both structured and native + return this._structuredDatasetQuery.database; + } + /** + * @returns the currently selected database metadata, if a database is selected and loaded. + */ + + }, { + key: "database", + value: function database() { + var databaseId = this.databaseId(); + return databaseId != null ? this._metadata.database(databaseId) : null; + } + /** + * @returns the database engine object, if a database is selected and loaded. + */ + + }, { + key: "engine", + value: function engine() { + var database = this.database(); + return database && database.engine; + } + /** + * Returns true if the database metadata (or lack thererof indicates the user can modify and run this query + */ + + }, { + key: "readOnly", + value: function readOnly() { + return !this.database(); + } + /* Methods unique to this query type */ + + /** + * @returns a new reset @type {StructuredQuery} with the same parent @type {Question} + */ + + }, { + key: "reset", + value: function reset() { + return new StructuredQuery(this._originalQuestion); + } + /** + * @returns the underlying MBQL query object + */ + + }, { + key: "query", + value: function query() { + return this._structuredDatasetQuery.query; + } + }, { + key: "setQuery", + value: function setQuery(query) { + return this._updateQuery(function () { + return query; + }, []); + } + }, { + key: "clearQuery", + value: function clearQuery() { + return this._updateQuery(function () { + return {}; + }); + } + }, { + key: "updateQuery", + value: function updateQuery(fn) { + return this._updateQuery(fn, []); + } + /** + * @returns a new query with the provided Database set. + */ + + }, { + key: "setDatabase", + value: function setDatabase(database) { + return this.setDatabaseId(database.id); + } + /** + * @returns a new query with the provided Database ID set. + */ + + }, { + key: "setDatabaseId", + value: function setDatabaseId(databaseId) { + if (databaseId !== this.databaseId()) { + // TODO: this should reset the rest of the query? + return new StructuredQuery(this._originalQuestion, (0,icepick__WEBPACK_IMPORTED_MODULE_5__.chain)(this.datasetQuery()).assoc("database", databaseId).assoc("query", {}).value()); + } else { + return this; + } + } + /** + * @returns the table ID, if a table is selected. + */ + + }, { + key: "sourceTableId", + value: function sourceTableId() { + return this.query()["source-table"]; + } + /** + * @returns a new query with the provided Table ID set. + */ + + }, { + key: "setSourceTableId", + value: function setSourceTableId(tableId) { + if (tableId !== this.sourceTableId()) { + return new StructuredQuery(this._originalQuestion, (0,icepick__WEBPACK_IMPORTED_MODULE_5__.chain)(this.datasetQuery()).assoc("database", this.metadata().table(tableId).database.id).assoc("query", { + "source-table": tableId + }).value()); + } else { + return this; + } + } + /** + * @deprecated: use sourceTableId + */ + + }, { + key: "tableId", + value: function tableId() { + return this.sourceTableId(); + } + /** + * @deprecated: use setSourceTableId + */ + + }, { + key: "setTableId", + value: function setTableId(tableId) { + return this.setSourceTableId(tableId); + } + /** + * @deprecated: use setSourceTableId + */ + + }, { + key: "setTable", + value: function setTable(table) { + return this.setSourceTableId(table.id); + } + /** + * + */ + + }, { + key: "setDefaultQuery", + value: function setDefaultQuery() { + var table = this.table(); // NOTE: special case for Google Analytics which doesn't allow raw queries: + + if (table && table.entity_type === "entity/GoogleAnalyticsTable" && !this.isEmpty() && !this.hasAnyClauses()) { + // NOTE: shold we check that a + var dateField = underscore__WEBPACK_IMPORTED_MODULE_4__.default.findWhere(table.fields, { + name: "ga:date" + }); + + if (dateField) { + return this.filter(["time-interval", ["field", dateField.id, null], -365, "day"]).aggregate(["metric", "ga:users"]).aggregate(["metric", "ga:pageviews"]).breakout(["field", dateField.id, { + "temporal-unit": "week" + }]); + } + } + + return this; + } + /** + * @returns the table object, if a table is selected and loaded. + */ + + }, { + key: "table", + value: function table() { + var _this3 = this; + + var sourceQuery = this.sourceQuery(); + + if (sourceQuery) { + return new _metadata_Table__WEBPACK_IMPORTED_MODULE_16__.default({ + name: "", + display_name: "", + db: sourceQuery.database(), + fields: sourceQuery.columns().map(function (column) { + return new _metadata_Field__WEBPACK_IMPORTED_MODULE_17__.default(_objectSpread(_objectSpread({}, column), {}, { + // TODO FIXME -- Do NOT use field-literal unless you're referring to a native query + id: ["field", column.name, { + "base-type": column.base_type + }], + source: "fields", + // HACK: need to thread the query through to this fake Field + query: _this3 + })); + }), + segments: [], + metrics: [] + }); + } else { + return this.metadata().table(this.sourceTableId()); + } + } + /** + * Removes invalid clauses from the query (and source-query, recursively) + */ + + }, { + key: "clean", + value: function clean() { + if (!this.hasMetadata()) { + console.warn("Warning: can't clean query without metadata!"); + return this; + } + + var query = this; // first clean the sourceQuery, if any, recursively + + var sourceQuery = query.sourceQuery(); + + if (sourceQuery) { + query = query.setSourceQuery(sourceQuery.clean()); + } + + return query.cleanJoins().cleanExpressions().cleanFilters().cleanAggregations().cleanBreakouts().cleanSorts().cleanLimit().cleanFields().cleanEmpty(); + } + /** + * Removes empty/useless layers of nesting (recursively) + */ + + }, { + key: "cleanNesting", + value: function cleanNesting() { + // first clean the sourceQuery, if any, recursively + var sourceQuery = this.sourceQuery(); + + if (sourceQuery) { + return this.setSourceQuery(sourceQuery.cleanNesting()).cleanEmpty(); + } else { + return this; + } + } + }, { + key: "cleanJoins", + value: function cleanJoins() { + var query = this; + this.joins().forEach(function (join, index) { + query = query.updateJoin(index, join.clean()); + }); + return query._cleanClauseList("joins"); + } + }, { + key: "cleanExpressions", + value: function cleanExpressions() { + return this; // TODO + } + }, { + key: "cleanFilters", + value: function cleanFilters() { + return this._cleanClauseList("filters"); + } + }, { + key: "cleanAggregations", + value: function cleanAggregations() { + return this._cleanClauseList("aggregations"); + } + }, { + key: "cleanBreakouts", + value: function cleanBreakouts() { + return this._cleanClauseList("breakouts"); + } + }, { + key: "cleanSorts", + value: function cleanSorts() { + return this._cleanClauseList("sorts"); + } + }, { + key: "cleanLimit", + value: function cleanLimit() { + return this; // TODO + } + }, { + key: "cleanFields", + value: function cleanFields() { + return this; // TODO + } + /** + * If this query is empty and there's a source-query, strip off this query, returning the source-query + */ + + }, { + key: "cleanEmpty", + value: function cleanEmpty() { + var sourceQuery = this.sourceQuery(); + + if (sourceQuery && !this.hasAnyClauses()) { + return sourceQuery; + } else { + return this; + } + } + }, { + key: "isValid", + value: function isValid() { + if (!this.hasData()) { + return false; + } + + var sourceQuery = this.sourceQuery(); + + if (sourceQuery && !sourceQuery.isValid()) { + return false; + } + + if (!this._isValidClauseList("joins") || !this._isValidClauseList("filters") || !this._isValidClauseList("aggregations") || !this._isValidClauseList("breakouts")) { + return false; + } + + var table = this.table(); // NOTE: special case for Google Analytics which requires an aggregation + + if (table.entity_type === "entity/GoogleAnalyticsTable") { + if (!this.hasAggregations()) { + return false; + } + } + + return true; + } + }, { + key: "_cleanClauseList", + value: function _cleanClauseList(listName) { + var query = this; + + for (var index = 0; index < query[listName]().length; index++) { + var clause = query[listName]()[index]; + + if (!this._validateClause(clause)) { + console.warn("Removing invalid MBQL clause", clause); + query = clause.remove(); // since we're removing them in order we need to decrement index when we remove one + + index -= 1; + } + } + + return query; + } + }, { + key: "_isValidClauseList", + value: function _isValidClauseList(listName) { + var _iterator = _createForOfIteratorHelper(this[listName]()), + _step; + + try { + for (_iterator.s(); !(_step = _iterator.n()).done;) { + var clause = _step.value; + + if (!this._validateClause(clause)) { + return false; + } + } + } catch (err) { + _iterator.e(err); + } finally { + _iterator.f(); + } + + return true; + } + }, { + key: "_validateClause", + value: function _validateClause(clause) { + try { + return clause.isValid(); + } catch (e) { + console.warn("Error thrown while validating clause", clause, e); + return false; + } + } + }, { + key: "hasData", + value: function hasData() { + return !!this.table(); + } + }, { + key: "hasAnyClauses", + value: function hasAnyClauses() { + return this.hasJoins() || this.hasExpressions() || this.hasFilters() || this.hasAggregations() || this.hasBreakouts() || this.hasSorts() || this.hasLimit() || this.hasFields(); + } + }, { + key: "hasJoins", + value: function hasJoins() { + return this.joins().length > 0; + } + }, { + key: "hasExpressions", + value: function hasExpressions() { + return Object.keys(this.expressions()).length > 0; + } + }, { + key: "hasFilters", + value: function hasFilters() { + return this.filters().length > 0; + } + }, { + key: "hasAggregations", + value: function hasAggregations() { + return this.aggregations().length > 0; + } + }, { + key: "hasBreakouts", + value: function hasBreakouts() { + return this.breakouts().length > 0; + } + }, { + key: "hasSorts", + value: function hasSorts() { + return this.sorts().length > 0; + } + }, { + key: "hasLimit", + value: function hasLimit() { + var limit = this.limit(); + return limit != null && limit > 0; + } + }, { + key: "hasFields", + value: function hasFields() { + return this.fields().length > 0; + } // ALIASES: allows + + /** + * @returns alias for addAggregation + */ + + }, { + key: "aggregate", + value: function aggregate(aggregation) { + return this.addAggregation(aggregation); + } + /** + * @returns alias for addBreakout + */ + + }, { + key: "breakout", + value: function breakout(_breakout) { + if (_breakout instanceof _metadata_Field__WEBPACK_IMPORTED_MODULE_17__.default) { + _breakout = _breakout.dimension(); + } + + if (_breakout instanceof metabase_lib_lib_Dimension__WEBPACK_IMPORTED_MODULE_8__.default) { + _breakout = _breakout.mbql(); + } + + return this.addBreakout(_breakout); + } + /** + * @returns alias for addFilter + */ + + }, { + key: "filter", + value: function (_filter) { + function filter(_x) { + return _filter.apply(this, arguments); + } + + filter.toString = function () { + return _filter.toString(); + }; + + return filter; + }(function (filter) { + return this.addFilter(filter); + } + /** + * @returns alias for addSort + */ + ) + }, { + key: "sort", + value: function sort(_sort) { + return this.addSort(_sort); + } + /** + * @returns alias for addJoin + */ + + }, { + key: "join", + value: function join(_join) { + return this.addJoin(_join); + } // JOINS + + /** + * @returns an array of MBQL @type {Join}s. + */ + + }, { + key: "joins", + value: function joins() { + var _this4 = this; + + return metabase_lib_query_query__WEBPACK_IMPORTED_MODULE_0__.getJoins(this.query()).map(function (join, index) { + return new _structured_Join__WEBPACK_IMPORTED_MODULE_14__.default(join, index, _this4); + }); + } + }, { + key: "addJoin", + value: function addJoin(join) { + return this._updateQuery(metabase_lib_query_query__WEBPACK_IMPORTED_MODULE_0__.addJoin, arguments); + } + }, { + key: "updateJoin", + value: function updateJoin(index, join) { + return this._updateQuery(metabase_lib_query_query__WEBPACK_IMPORTED_MODULE_0__.updateJoin, arguments); + } + }, { + key: "removeJoin", + value: function removeJoin(index) { + return this._updateQuery(metabase_lib_query_query__WEBPACK_IMPORTED_MODULE_0__.removeJoin, arguments); + } + }, { + key: "clearJoins", + value: function clearJoins() { + return this._updateQuery(metabase_lib_query_query__WEBPACK_IMPORTED_MODULE_0__.clearJoins, arguments); + } // AGGREGATIONS + + /** + * @returns an array of MBQL @type {Aggregation}s. + */ + + }, { + key: "aggregations", + value: function aggregations() { + var _this5 = this; + + return metabase_lib_query_query__WEBPACK_IMPORTED_MODULE_0__.getAggregations(this.query()).map(function (aggregation, index) { + return new _structured_Aggregation__WEBPACK_IMPORTED_MODULE_11__.default(aggregation, index, _this5); + }); + } + /** + * @returns an array of aggregation options for the currently selected table + */ + + }, { + key: "aggregationOperators", + value: function aggregationOperators() { + return this.table() && this.table().aggregationOperators() || []; + } + /** + * @returns an array of aggregation options for the currently selected table + */ + + }, { + key: "aggregationOperatorsWithoutRows", + value: function aggregationOperatorsWithoutRows() { + return this.aggregationOperators().filter(function (option) { + return option.short !== "rows"; + }); + } + /** + * @returns the field options for the provided aggregation + */ + + }, { + key: "aggregationFieldOptions", + value: function aggregationFieldOptions(agg) { + var aggregation = typeof agg === "string" ? this.table().aggregationOperator(agg) : agg; + + if (aggregation) { + var fieldOptions = this.fieldOptions(function (field) { + return aggregation.validFieldsFilters.length > 0 && aggregation.validFieldsFilters[0]([field]).length === 1; + }); // HACK Atte Keinänen 6/18/17: Using `fieldOptions` with a field filter function + // ends up often omitting all expressions because the field object of ExpressionDimension is empty. + // Expressions can be applied to all aggregations so we can simply add all expressions to the + // dimensions list in this hack. + // + // A real solution would have a `dimensionOptions` method instead of `fieldOptions` which would + // enable filtering based on dimension properties. + + var compatibleDimensions = this.expressionDimensions().filter(function (d) { + return (0,metabase_lib_schema_metadata__WEBPACK_IMPORTED_MODULE_3__.isCompatibleAggregationOperatorForField)(aggregation, d.field()); + }); + return new metabase_lib_lib_DimensionOptions__WEBPACK_IMPORTED_MODULE_9__.default(_objectSpread(_objectSpread({}, fieldOptions), {}, { + dimensions: underscore__WEBPACK_IMPORTED_MODULE_4__.default.uniq([].concat(_toConsumableArray(compatibleDimensions), _toConsumableArray(fieldOptions.dimensions.filter(function (d) { + return !(d instanceof metabase_lib_lib_Dimension__WEBPACK_IMPORTED_MODULE_8__.ExpressionDimension); + })))) + })); + } else { + return new metabase_lib_lib_DimensionOptions__WEBPACK_IMPORTED_MODULE_9__.default({ + count: 0, + fks: [], + dimensions: [] + }); + } + } + /** + * @returns true if the aggregation can be removed + */ + + }, { + key: "canRemoveAggregation", + value: function canRemoveAggregation() { + return this.aggregations().length > 1; + } + /** + * @returns true if the query has no aggregation + */ + + }, { + key: "isBareRows", + value: function isBareRows() { + return !this.hasAggregations(); + } + /** + * @returns true if the query has no aggregation or breakouts + */ + + }, { + key: "isRaw", + value: function isRaw() { + return !this.hasAggregations() && !this.hasBreakouts(); + } + }, { + key: "formatExpression", + value: function formatExpression(expression) { + var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, + _ref$quotes = _ref.quotes, + quotes = _ref$quotes === void 0 ? metabase_lib_expressions_format__WEBPACK_IMPORTED_MODULE_2__.DISPLAY_QUOTES : _ref$quotes, + options = _objectWithoutProperties(_ref, _excluded); + + return (0,metabase_lib_expressions_format__WEBPACK_IMPORTED_MODULE_2__.format)(expression, _objectSpread(_objectSpread({ + quotes: quotes + }, options), {}, { + query: this + })); + } + /** + * @returns {StructuredQuery} new query with the provided MBQL @type {Aggregation} added. + */ + + }, { + key: "addAggregation", + value: function addAggregation(aggregation) { + return this._updateQuery(metabase_lib_query_query__WEBPACK_IMPORTED_MODULE_0__.addAggregation, arguments); + } + /** + * @returns {StructuredQuery} new query with the MBQL @type {Aggregation} updated at the provided index. + */ + + }, { + key: "updateAggregation", + value: function updateAggregation(index, aggregation) { + return this._updateQuery(metabase_lib_query_query__WEBPACK_IMPORTED_MODULE_0__.updateAggregation, arguments); + } + /** + * @returns {StructuredQuery} new query with the aggregation at the provided index removed. + */ + + }, { + key: "removeAggregation", + value: function removeAggregation(index) { + return this._updateQuery(metabase_lib_query_query__WEBPACK_IMPORTED_MODULE_0__.removeAggregation, arguments); + } + /** + * @returns {StructuredQuery} new query with all aggregations removed. + */ + + }, { + key: "clearAggregations", + value: function clearAggregations() { + return this._updateQuery(metabase_lib_query_query__WEBPACK_IMPORTED_MODULE_0__.clearAggregations, arguments); + } // BREAKOUTS + + /** + * @returns An array of MBQL @type {Breakout}s. + */ + + }, { + key: "breakouts", + value: function breakouts() { + var _this6 = this; + + if (this.query() == null) { + return []; + } + + return metabase_lib_query_query__WEBPACK_IMPORTED_MODULE_0__.getBreakouts(this.query()).map(function (breakout, index) { + return new _structured_Breakout__WEBPACK_IMPORTED_MODULE_12__.default(breakout, index, _this6); + }); + } + /** + * @param includedBreakout The breakout to include even if it's already used + * @param fieldFilter An option @type {Field} predicate to filter out options + * @returns @type {DimensionOptions} that can be used as breakouts, excluding used breakouts, unless @param {breakout} is provided. + */ + + }, { + key: "breakoutOptions", + value: function breakoutOptions(includedBreakout) { + var fieldFilter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () { + return true; + }; + // the set of field ids being used by other breakouts + var usedFields = new Set(includedBreakout === true ? [] : this.breakouts().filter(function (breakout) { + return !underscore__WEBPACK_IMPORTED_MODULE_4__.default.isEqual(breakout, includedBreakout); + }).map(function (breakout) { + return breakout.field().id; + })); + return this.fieldOptions(function (field) { + return fieldFilter(field) && !usedFields.has(field.id); + }); + } + /** + * @returns whether a new breakout can be added or not + */ + + }, { + key: "canAddBreakout", + value: function canAddBreakout() { + return this.breakoutOptions().count > 0; + } + /** + * @returns whether the current query has a valid breakout + */ + + }, { + key: "hasValidBreakout", + value: function hasValidBreakout() { + var breakouts = this.breakouts(); + return breakouts.length > 0 && breakouts[0].isValid(); + } + /** + * @returns {StructuredQuery} new query with the provided MBQL @type {Breakout} added. + */ + + }, { + key: "addBreakout", + value: function addBreakout(breakout) { + return this._updateQuery(metabase_lib_query_query__WEBPACK_IMPORTED_MODULE_0__.addBreakout, arguments); + } + /** + * @returns {StructuredQuery} new query with the MBQL @type {Breakout} updated at the provided index. + */ + + }, { + key: "updateBreakout", + value: function updateBreakout(index, breakout) { + return this._updateQuery(metabase_lib_query_query__WEBPACK_IMPORTED_MODULE_0__.updateBreakout, arguments); + } + /** + * @returns {StructuredQuery} new query with the breakout at the provided index removed. + */ + + }, { + key: "removeBreakout", + value: function removeBreakout(index) { + return this._updateQuery(metabase_lib_query_query__WEBPACK_IMPORTED_MODULE_0__.removeBreakout, arguments); + } + /** + * @returns {StructuredQuery} new query with all breakouts removed. + */ + + }, { + key: "clearBreakouts", + value: function clearBreakouts() { + return this._updateQuery(metabase_lib_query_query__WEBPACK_IMPORTED_MODULE_0__.clearBreakouts, arguments); + } // FILTERS + + /** + * @returns An array of MBQL @type {Filter}s. + */ + + }, { + key: "filters", + value: function filters() { + var _this7 = this; + + return metabase_lib_query_query__WEBPACK_IMPORTED_MODULE_0__.getFilters(this.query()).map(function (filter, index) { + return new _structured_Filter__WEBPACK_IMPORTED_MODULE_13__.default(filter, index, _this7); + }); + } + /** + * @returns An array of MBQL @type {Filter}s from the last two query stages + */ + + }, { + key: "topLevelFilters", + value: function topLevelFilters() { + var _ref2; + + var stages = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 2; + var queries = this.queries().slice(-stages); + return (_ref2 = []).concat.apply(_ref2, _toConsumableArray(queries.map(function (q) { + return q.filters(); + }))); + } + }, { + key: "filterFieldOptionSections", + value: function filterFieldOptionSections(filter) { + var _this8 = this; + + var _ref3 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, + _ref3$includeSegments = _ref3.includeSegments, + includeSegments = _ref3$includeSegments === void 0 ? true : _ref3$includeSegments; + + var filterDimensionOptions = this.filterDimensionOptions(); + var filterSegmentOptions = includeSegments ? this.filterSegmentOptions(filter) : []; + return filterDimensionOptions.sections({ + extraItems: filterSegmentOptions.map(function (segment) { + return { + name: segment.name, + icon: "star_outline", + filter: ["segment", segment.id], + query: _this8 + }; + }) + }); + } + }, { + key: "topLevelFilterFieldOptionSections", + value: function topLevelFilterFieldOptionSections() { + var _ref4; + + var filter = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; + var stages = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2; + var queries = this.queries().slice(-stages); // allow post-aggregation filtering + + if (queries.length < stages && this.canNest() && this.hasBreakouts()) { + queries.push(queries[queries.length - 1].nest()); + } + + queries.reverse(); + + var sections = (_ref4 = []).concat.apply(_ref4, _toConsumableArray(queries.map(function (q) { + return q.filterFieldOptionSections(filter); + }))); // special logic to only show aggregation dimensions for post-aggregation dimensions + + + if (queries.length > 1) { + // set the section title to `Metrics` + sections[0].name = (0,ttag__WEBPACK_IMPORTED_MODULE_6__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["Metrics"]))); // only include aggregation dimensions + + sections[0].items = sections[0].items.filter(function (item) { + if (item.dimension) { + var sourceDimension = queries[0].dimensionForSourceQuery(item.dimension); + + if (sourceDimension) { + return sourceDimension instanceof metabase_lib_lib_Dimension__WEBPACK_IMPORTED_MODULE_8__.AggregationDimension; + } + } + + return true; + }); + } + + return sections; + } + /** + * @returns @type {DimensionOptions} that can be used in filters. + */ + + }, { + key: "filterDimensionOptions", + value: function filterDimensionOptions() { + return this.dimensionOptions(); + } + /** + * @returns @type {Segment}s that can be used as filters. + */ + + }, { + key: "filterSegmentOptions", + value: function filterSegmentOptions(filter) { + var _this9 = this; + + if (filter && !(filter instanceof _structured_Filter__WEBPACK_IMPORTED_MODULE_13__.default)) { + filter = new _structured_Filter__WEBPACK_IMPORTED_MODULE_13__.default(filter, null, this); + } + + var currentSegmentId = filter && filter.isSegment() && filter.segmentId(); + return this.table().segments.filter(function (segment) { + return currentSegmentId != null && currentSegmentId === segment.id || !segment.archived && !_this9.segments().includes(segment); + }); + } + /** + * @returns @type {Segment}s that are currently applied to the question + */ + + }, { + key: "segments", + value: function segments() { + return this.filters().filter(function (filter) { + return filter.isSegment(); + }).map(function (filter) { + return filter.segment(); + }); + } + /** + * @returns whether a new filter can be added or not + */ + + }, { + key: "canAddFilter", + value: function canAddFilter() { + return metabase_lib_query_query__WEBPACK_IMPORTED_MODULE_0__.canAddFilter(this.query()) && (this.filterDimensionOptions().count > 0 || this.filterSegmentOptions().length > 0); + } + /** + * @returns {StructuredQuery} new query with the provided MBQL @type {Filter} added. + */ + + }, { + key: "addFilter", + value: function addFilter(filter) { + return this._updateQuery(metabase_lib_query_query__WEBPACK_IMPORTED_MODULE_0__.addFilter, arguments); + } + /** + * @returns {StructuredQuery} new query with the MBQL @type {Filter} updated at the provided index. + */ + + }, { + key: "updateFilter", + value: function updateFilter(index, filter) { + return this._updateQuery(metabase_lib_query_query__WEBPACK_IMPORTED_MODULE_0__.updateFilter, arguments); + } + /** + * @returns {StructuredQuery} new query with the filter at the provided index removed. + */ + + }, { + key: "removeFilter", + value: function removeFilter(index) { + return this._updateQuery(metabase_lib_query_query__WEBPACK_IMPORTED_MODULE_0__.removeFilter, arguments); + } + /** + * @returns {StructuredQuery} new query with all filters removed. + */ + + }, { + key: "clearFilters", + value: function clearFilters() { + return this._updateQuery(metabase_lib_query_query__WEBPACK_IMPORTED_MODULE_0__.clearFilters, arguments); + } // SORTS + // TODO: standardize SORT vs ORDER_BY terminology + + }, { + key: "sorts", + value: function sorts() { + var _this10 = this; + + return metabase_lib_query_query__WEBPACK_IMPORTED_MODULE_0__.getOrderBys(this.query()).map(function (sort, index) { + return new _structured_OrderBy__WEBPACK_IMPORTED_MODULE_15__.default(sort, index, _this10); + }); + } + }, { + key: "sortOptions", + value: function sortOptions(includedSort) { + // in bare rows all fields are sortable, otherwise we only sort by our breakout columns + if (this.isBareRows()) { + var usedFields = new Set(this.sorts().filter(function (sort) { + return !underscore__WEBPACK_IMPORTED_MODULE_4__.default.isEqual(sort, includedSort); + }).map(function (sort) { + return sort.field().id; + })); + return this.fieldOptions(function (field) { + return !usedFields.has(field.id); + }); + } else if (this.hasValidBreakout()) { + var sortOptions = { + count: 0, + dimensions: [], + fks: [] + }; + + var _iterator2 = _createForOfIteratorHelper(this.breakouts()), + _step2; + + try { + for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { + var breakout = _step2.value; + sortOptions.dimensions.push(breakout.dimension()); + sortOptions.count++; + } + } catch (err) { + _iterator2.e(err); + } finally { + _iterator2.f(); + } + + if (this.hasBreakouts()) { + var _iterator3 = _createForOfIteratorHelper(this.aggregations()), + _step3; + + try { + for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) { + var aggregation = _step3.value; + sortOptions.dimensions.push(aggregation.aggregationDimension()); + sortOptions.count++; + } + } catch (err) { + _iterator3.e(err); + } finally { + _iterator3.f(); + } + } + + return new metabase_lib_lib_DimensionOptions__WEBPACK_IMPORTED_MODULE_9__.default(sortOptions); + } + } + }, { + key: "canAddSort", + value: function canAddSort() { + var sorts = this.sorts(); + return this.sortOptions().count > 0 && (sorts.length === 0 || sorts[sorts.length - 1][0] != null); + } + }, { + key: "addSort", + value: function addSort(orderBy) { + return this._updateQuery(metabase_lib_query_query__WEBPACK_IMPORTED_MODULE_0__.addOrderBy, arguments); + } + }, { + key: "updateSort", + value: function updateSort(index, orderBy) { + return this._updateQuery(metabase_lib_query_query__WEBPACK_IMPORTED_MODULE_0__.updateOrderBy, arguments); + } + }, { + key: "removeSort", + value: function removeSort(index) { + return this._updateQuery(metabase_lib_query_query__WEBPACK_IMPORTED_MODULE_0__.removeOrderBy, arguments); + } + }, { + key: "clearSort", + value: function clearSort() { + return this._updateQuery(metabase_lib_query_query__WEBPACK_IMPORTED_MODULE_0__.clearOrderBy, arguments); + } + }, { + key: "replaceSort", + value: function replaceSort(orderBy) { + return this.clearSort().addSort(orderBy); + } // LIMIT + + }, { + key: "limit", + value: function limit() { + return metabase_lib_query_query__WEBPACK_IMPORTED_MODULE_0__.getLimit(this.query()); + } + }, { + key: "updateLimit", + value: function updateLimit(limit) { + return this._updateQuery(metabase_lib_query_query__WEBPACK_IMPORTED_MODULE_0__.updateLimit, arguments); + } + }, { + key: "clearLimit", + value: function clearLimit() { + return this._updateQuery(metabase_lib_query_query__WEBPACK_IMPORTED_MODULE_0__.clearLimit, arguments); + } // EXPRESSIONS + + }, { + key: "expressions", + value: function expressions() { + return metabase_lib_query_query__WEBPACK_IMPORTED_MODULE_0__.getExpressions(this.query()); + } + }, { + key: "addExpression", + value: function addExpression(name, expression) { + var uniqueName = (0,metabase_lib_query_expression__WEBPACK_IMPORTED_MODULE_1__.getUniqueExpressionName)(this.expressions(), name); + + var query = this._updateQuery(metabase_lib_query_query__WEBPACK_IMPORTED_MODULE_0__.addExpression, [uniqueName, expression]); // extra logic for adding expressions in fields clause + // TODO: push into query/expression? + + + if (query.hasFields() && query.isRaw()) { + query = query.addField(["expression", uniqueName]); + } + + return query; + } + }, { + key: "updateExpression", + value: function updateExpression(name, expression, oldName) { + var isRename = oldName && oldName !== name; + var uniqueName = isRename ? (0,metabase_lib_query_expression__WEBPACK_IMPORTED_MODULE_1__.getUniqueExpressionName)(this.expressions(), name) : name; + + var query = this._updateQuery(metabase_lib_query_query__WEBPACK_IMPORTED_MODULE_0__.updateExpression, [uniqueName, expression, oldName]); // extra logic for renaming expressions in fields clause + // TODO: push into query/expression? + + + if (isRename) { + var index = query._indexOfField(["expression", oldName]); + + if (index >= 0) { + query = query.updateField(index, ["expression", uniqueName]); + } + } + + return query; + } + }, { + key: "removeExpression", + value: function removeExpression(name) { + var query = this._updateQuery(metabase_lib_query_query__WEBPACK_IMPORTED_MODULE_0__.removeExpression, arguments); // extra logic for removing expressions in fields clause + // TODO: push into query/expression? + + + var index = query._indexOfField(["expression", name]); + + if (index >= 0) { + query = query.removeField(index); + } + + return query; + } + }, { + key: "clearExpressions", + value: function clearExpressions() { + var query = this._updateQuery(metabase_lib_query_query__WEBPACK_IMPORTED_MODULE_0__.clearExpressions, arguments); // extra logic for removing expressions in fields clause + // TODO: push into query/expression? + + + for (var _i = 0, _Object$keys = Object.keys(this.expressions()); _i < _Object$keys.length; _i++) { + var name = _Object$keys[_i]; + + var index = query._indexOfField(["expression", name]); + + if (index >= 0) { + query = query.removeField(index); + } + } + + return query; + } + }, { + key: "_indexOfField", + value: function _indexOfField(fieldRef) { + return this.fields().findIndex(function (f) { + return underscore__WEBPACK_IMPORTED_MODULE_4__.default.isEqual(f, fieldRef); + }); + } // FIELDS + + }, { + key: "fields", + value: function fields() { + // FIMXE: implement field functions in query lib + return this.query().fields || []; + } + }, { + key: "addField", + value: function addField(name, expression) { + return this._updateQuery(metabase_lib_query_query__WEBPACK_IMPORTED_MODULE_0__.addField, arguments); + } + }, { + key: "updateField", + value: function updateField(index, field) { + return this._updateQuery(metabase_lib_query_query__WEBPACK_IMPORTED_MODULE_0__.updateField, arguments); + } + }, { + key: "removeField", + value: function removeField(name) { + return this._updateQuery(metabase_lib_query_query__WEBPACK_IMPORTED_MODULE_0__.removeField, arguments); + } + }, { + key: "clearFields", + value: function clearFields() { + return this._updateQuery(metabase_lib_query_query__WEBPACK_IMPORTED_MODULE_0__.clearFields, arguments); + } + }, { + key: "setFields", + value: function setFields(fields) { + return this._updateQuery(function (q) { + return _objectSpread(_objectSpread({}, q), {}, { + fields: fields + }); + }); + } + /** + * Returns dimension options that can appear in the `fields` clause + */ + + }, { + key: "fieldsOptions", + value: function fieldsOptions() { + var dimensionFilter = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function (dimension) { + return true; + }; + + if (this.isBareRows() && !this.hasBreakouts()) { + return this.dimensionOptions(dimensionFilter); + } // TODO: allow adding fields connected by broken out PKs? + + + return new metabase_lib_lib_DimensionOptions__WEBPACK_IMPORTED_MODULE_9__.default({ + count: 0, + dimensions: [], + fks: [] + }); + } // DIMENSION OPTIONS + + }, { + key: "_keyForFK", + value: function _keyForFK(source, destination) { + if (source && destination) { + return "".concat(source.id, ",").concat(destination.id); + } + + return null; + } + }, { + key: "_getExplicitJoinsSet", + value: function _getExplicitJoinsSet(joins) { + var _this11 = this; + + var joinDimensionPairs = joins.map(function (join) { + var dimensionPairs = join.getDimensions(); + return dimensionPairs.map(function (pair) { + var _pair = _slicedToArray(pair, 2), + parentDimension = _pair[0], + joinDimension = _pair[1]; + + return _this11._keyForFK(parentDimension && parentDimension.field(), joinDimension && joinDimension.field()); + }); + }); + + var flatJoinDimensions = underscore__WEBPACK_IMPORTED_MODULE_4__.default.flatten(joinDimensionPairs); + + var explicitJoins = new Set(flatJoinDimensions); + explicitJoins.delete(null); + return explicitJoins; + } // TODO Atte Keinänen 6/18/17: Refactor to dimensionOptions which takes a dimensionFilter + // See aggregationFieldOptions for an explanation why that covers more use cases + + }, { + key: "dimensionOptions", + value: function dimensionOptions() { + var dimensionFilter = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function (dimension) { + return true; + }; + var dimensionOptions = { + count: 0, + fks: [], + dimensions: [] + }; + var joins = this.joins(); + + var _iterator4 = _createForOfIteratorHelper(joins), + _step4; + + try { + for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) { + var join = _step4.value; + var joinedDimensionOptions = join.joinedDimensionOptions(dimensionFilter); + dimensionOptions.count += joinedDimensionOptions.count; + dimensionOptions.fks.push(joinedDimensionOptions); + } + } catch (err) { + _iterator4.e(err); + } finally { + _iterator4.f(); + } + + var table = this.table(); + + if (table) { + var dimensionIsFKReference = function dimensionIsFKReference(dimension) { + return dimension.field && dimension.field() && dimension.field().isFK(); + }; + + var filteredNonFKDimensions = this.dimensions().filter(dimensionFilter); // .filter(d => !dimensionIsFKReference(d)); + + var _iterator5 = _createForOfIteratorHelper(filteredNonFKDimensions), + _step5; + + try { + for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) { + var _dimension = _step5.value; + dimensionOptions.count++; + dimensionOptions.dimensions.push(_dimension); + } // de-duplicate explicit and implicit joined tables + + } catch (err) { + _iterator5.e(err); + } finally { + _iterator5.f(); + } + + var explicitJoins = this._getExplicitJoinsSet(joins); + + var fkDimensions = this.dimensions().filter(dimensionIsFKReference); + + var _iterator6 = _createForOfIteratorHelper(fkDimensions), + _step6; + + try { + for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) { + var _dimension2 = _step6.value; + + var field = _dimension2.field(); + + if (field && explicitJoins.has(this._keyForFK(field, field.target))) { + continue; + } + + var _fkDimensions = _dimension2.dimensions([metabase_lib_lib_Dimension__WEBPACK_IMPORTED_MODULE_8__.FieldDimension]).filter(dimensionFilter); + + if (_fkDimensions.length > 0) { + dimensionOptions.count += _fkDimensions.length; + dimensionOptions.fks.push({ + field: field, + dimension: _dimension2, + dimensions: _fkDimensions + }); + } + } + } catch (err) { + _iterator6.e(err); + } finally { + _iterator6.f(); + } + } + + return new metabase_lib_lib_DimensionOptions__WEBPACK_IMPORTED_MODULE_9__.default(dimensionOptions); + } // FIELD OPTIONS + + }, { + key: "fieldOptions", + value: function fieldOptions() { + var fieldFilter = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function (field) { + return true; + }; + + var dimensionFilter = function dimensionFilter(dimension) { + var field = dimension.field && dimension.field(); + return !field || field.isDimension() && fieldFilter(field); + }; + + return this.dimensionOptions(dimensionFilter); + } // DIMENSIONS + + }, { + key: "dimensions", + value: function dimensions() { + return [].concat(_toConsumableArray(this.expressionDimensions()), _toConsumableArray(this.tableDimensions())); + } + }, { + key: "tableDimensions", + value: function tableDimensions() { + var _this12 = this; + + var table = this.table(); + return table // HACK: ensure the dimensions are associated with this query + ? table.dimensions().map(function (d) { + return d._query ? d : _this12.parseFieldReference(d.mbql()); + }) : []; + } + }, { + key: "expressionDimensions", + value: function expressionDimensions() { + var _this13 = this; + + return Object.entries(this.expressions()).map(function (_ref5) { + var _ref6 = _slicedToArray(_ref5, 2), + expressionName = _ref6[0], + expression = _ref6[1]; + + return new metabase_lib_lib_Dimension__WEBPACK_IMPORTED_MODULE_8__.ExpressionDimension(null, [expressionName], _this13._metadata, _this13); + }); + } + }, { + key: "joinedDimensions", + value: function joinedDimensions() { + var _ref7; + + return (_ref7 = []).concat.apply(_ref7, _toConsumableArray(this.joins().map(function (join) { + return join.fieldsDimensions(); + }))); + } + }, { + key: "breakoutDimensions", + value: function breakoutDimensions() { + var _this14 = this; + + return this.breakouts().map(function (breakout) { + return _this14.parseFieldReference(breakout); + }); + } + }, { + key: "aggregationDimensions", + value: function aggregationDimensions() { + return this.aggregations().map(function (aggregation) { + return aggregation.aggregationDimension(); + }); + } + }, { + key: "fieldDimensions", + value: function fieldDimensions() { + var _this15 = this; + + return this.fields().map(function (fieldClause, index) { + return _this15.parseFieldReference(fieldClause); + }); + } // TODO: this replicates logic in the backend, we should have integration tests to ensure they match + // NOTE: these will not have the correct columnName() if there are duplicates + + }, { + key: "columnDimensions", + value: function columnDimensions() { + if (this.hasAggregations() || this.hasBreakouts()) { + var aggregations = this.aggregationDimensions(); + var breakouts = this.breakoutDimensions(); + return [].concat(_toConsumableArray(breakouts), _toConsumableArray(aggregations)); + } else if (this.hasFields()) { + var fields = this.fieldDimensions(); + var joined = this.joinedDimensions(); + return [].concat(_toConsumableArray(fields), _toConsumableArray(joined)); + } else { + var expressions = this.expressionDimensions(); + + var _joined = this.joinedDimensions(); + + var table = this.tableDimensions(); + + var sorted = underscore__WEBPACK_IMPORTED_MODULE_4__.default.chain(table).filter(function (d) { + var f = d.field(); + return f.active !== false && f.visibility_type !== "sensitive" && f.visibility_type !== "retired" && f.parent_id == null; + }).sortBy(function (d) { + return d.displayName().toLowerCase(); + }).sortBy(function (d) { + var type = d.field().semantic_type; + return type === metabase_lib_types__WEBPACK_IMPORTED_MODULE_18__.TYPE.PK ? 0 : type === metabase_lib_types__WEBPACK_IMPORTED_MODULE_18__.TYPE.Name ? 1 : 2; + }).sortBy(function (d) { + return d.field().position; + }).value(); + + return [].concat(_toConsumableArray(sorted), _toConsumableArray(expressions), _toConsumableArray(_joined)); + } + } // TODO: this replicates logic in the backend, we should have integration tests to ensure they match + + }, { + key: "columnNames", + value: function columnNames() { + // NOTE: dimension.columnName() doesn't include suffixes for duplicated column names so we need to do that here + var nameCounts = new Map(); + return this.columnDimensions().map(function (dimension) { + var name = dimension.columnName(); + + if (nameCounts.has(name)) { + var count = nameCounts.get(name) + 1; + nameCounts.set(name, count); + return "".concat(name, "_").concat(count); + } else { + nameCounts.set(name, 1); + return name; + } + }); + } + }, { + key: "columns", + value: function columns() { + var names = this.columnNames(); + return this.columnDimensions().map(function (dimension, index) { + return _objectSpread(_objectSpread({}, dimension.column()), {}, { + name: names[index] + }); + }); + } + }, { + key: "columnDimensionWithName", + value: function columnDimensionWithName(columnName) { + var index = this.columnNames().findIndex(function (n) { + return n === columnName; + }); + + if (index >= 0) { + return this.columnDimensions()[index]; + } + } + }, { + key: "fieldReferenceForColumn", + value: function fieldReferenceForColumn(column) { + return (0,metabase_lib_dataset__WEBPACK_IMPORTED_MODULE_19__.fieldRefForColumn)(column); + } // TODO: better name may be parseDimension? + + }, { + key: "parseFieldReference", + value: function parseFieldReference(fieldRef) { + return metabase_lib_lib_Dimension__WEBPACK_IMPORTED_MODULE_8__.default.parseMBQL(fieldRef, this._metadata, this); + } + }, { + key: "dimensionForColumn", + value: function dimensionForColumn(column) { + if (column) { + var fieldRef = this.fieldReferenceForColumn(column); + + if (fieldRef) { + return this.parseFieldReference(fieldRef); + } + } + + return null; + } + }, { + key: "setDatasetQuery", + value: function setDatasetQuery(datasetQuery) { + return new StructuredQuery(this._originalQuestion, datasetQuery); + } // NESTING + + }, { + key: "nest", + value: function nest() { + return this._updateQuery(function (query) { + return { + "source-query": query + }; + }); + } + }, { + key: "canNest", + value: function canNest() { + var db = this.database(); + return db && db.hasFeature("nested-queries"); + } + /** + * The (wrapped) source query, if any + */ + + }, { + key: "sourceQuery", + value: function sourceQuery() { + var sourceQuery = this.query()["source-query"]; + + if (sourceQuery) { + return new NestedStructuredQuery(this._originalQuestion, _objectSpread(_objectSpread({}, this.datasetQuery()), {}, { + query: sourceQuery + }), this); + } else { + return null; + } + } + /** + * Returns the "first" of the nested queries, or this query it not nested + */ + + }, { + key: "rootQuery", + value: function rootQuery() { + var sourceQuery = this.sourceQuery(); + return sourceQuery ? sourceQuery.rootQuery() : this; + } + /** + * Returns the "last" nested query that is already summarized, or `null` if none are + * */ + + }, { + key: "lastSummarizedQuery", + value: function lastSummarizedQuery() { + if (this.hasAggregations() || !this.canNest()) { + return this; + } else { + var sourceQuery = this.sourceQuery(); + return sourceQuery ? sourceQuery.lastSummarizedQuery() : null; + } + } + /** + * Returns the "last" nested query that is already summarized, or the query itself. + * Used in "view mode" to effectively ignore post-aggregation filter stages + */ + + }, { + key: "topLevelQuery", + value: function topLevelQuery() { + if (!this.canNest()) { + return this; + } else { + return this.lastSummarizedQuery() || this; + } + } + /** + * Returns the corresponding {Dimension} in the "top-level" {StructuredQuery} + */ + + }, { + key: "topLevelDimension", + value: function topLevelDimension(dimension) { + var topQuery = this.topLevelQuery(); + var query = this; + + while (query) { + if (query === topQuery) { + return dimension; + } else { + dimension = query.dimensionForSourceQuery(dimension); + query = query.sourceQuery(); + } + } + + return null; + } + /** + * Returns the corresponding {Column} in the "top-level" {StructuredQuery} + */ + + }, { + key: "topLevelColumn", + value: function topLevelColumn(column) { + var dimension = this.dimensionForColumn(column); + + if (dimension) { + var topDimension = this.topLevelDimension(dimension); + + if (topDimension) { + return topDimension.column(); + } + } + + return null; + } + /** + * returns the corresponding {Dimension} in the sourceQuery, if any + */ + + }, { + key: "dimensionForSourceQuery", + value: function dimensionForSourceQuery(dimension) { + if (dimension instanceof metabase_lib_lib_Dimension__WEBPACK_IMPORTED_MODULE_8__.FieldDimension && dimension.isStringFieldName()) { + var sourceQuery = this.sourceQuery(); + + if (sourceQuery) { + var index = sourceQuery.columnNames().indexOf(dimension.fieldIdOrName()); + + if (index >= 0) { + return sourceQuery.columnDimensions()[index]; + } + } + } + + return null; + } + /** + * returns the original Table object at the beginning of the nested queries + */ + + }, { + key: "rootTable", + value: function rootTable() { + return this.rootQuery().table(); + } + /** + * returns the original Table ID at the beginning of the nested queries + */ + + }, { + key: "rootTableId", + value: function rootTableId() { + return this.rootQuery().sourceTableId(); + } + }, { + key: "setSourceQuery", + value: function setSourceQuery(sourceQuery) { + if (sourceQuery instanceof StructuredQuery) { + if (this.sourceQuery() === sourceQuery) { + return this; + } + + sourceQuery = sourceQuery.query(); + } // TODO: if the source query is modified in ways that make the parent query invalid we should "clean" those clauses + + + return this._updateQuery(function (query) { + return (0,icepick__WEBPACK_IMPORTED_MODULE_5__.chain)(query).dissoc("source-table").assoc("source-query", sourceQuery).value(); + }); + } + }, { + key: "queries", + value: function queries() { + var queries = []; + + for (var _query = this; _query; _query = _query.sourceQuery()) { + queries.unshift(_query); + } + + return queries; + } + /** + * Metadata this query needs to display correctly + */ + + }, { + key: "dependentMetadata", + value: function dependentMetadata() { + var _ref8 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, + _ref8$foreignTables = _ref8.foreignTables, + foreignTables = _ref8$foreignTables === void 0 ? true : _ref8$foreignTables; + + var dependencies = []; + + function addDependency(dep) { + var existing = underscore__WEBPACK_IMPORTED_MODULE_4__.default.findWhere(dependencies, underscore__WEBPACK_IMPORTED_MODULE_4__.default.pick(dep, "type", "id")); + + if (existing) { + Object.assign(existing, dep); + } else { + dependencies.push(dep); + } + } // source-table, if set + + + var tableId = this.sourceTableId(); + + if (tableId) { + addDependency({ + type: "table", + id: tableId, + foreignTables: foreignTables + }); + } // any explicitly joined tables + + + var _iterator7 = _createForOfIteratorHelper(this.joins()), + _step7; + + try { + for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) { + var join = _step7.value; + join.dependentMetadata().forEach(addDependency); + } // parent query's table IDs + + } catch (err) { + _iterator7.e(err); + } finally { + _iterator7.f(); + } + + var sourceQuery = this.sourceQuery(); + + if (sourceQuery) { + sourceQuery.dependentMetadata({ + foreignTables: foreignTables + }).forEach(addDependency); + } + + return dependencies; + } // INTERNAL + + }, { + key: "_updateQuery", + value: function _updateQuery(updateFunction) { + var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; + return this.setDatasetQuery((0,icepick__WEBPACK_IMPORTED_MODULE_5__.updateIn)(this._datasetQuery, ["query"], function (query) { + return updateFunction.apply(void 0, [query].concat(_toConsumableArray(args))); + })); + } + }], [{ + key: "isDatasetQueryType", + value: function isDatasetQueryType(datasetQuery) { + return datasetQuery && datasetQuery.type === STRUCTURED_QUERY_TEMPLATE.type; + } // For Flow type completion + + }]); + + return StructuredQuery; +}(_AtomicQuery__WEBPACK_IMPORTED_MODULE_10__.default), (_applyDecoratedDescriptor(_class.prototype, "table", [metabase_lib_lib_utils__WEBPACK_IMPORTED_MODULE_7__.memoize], Object.getOwnPropertyDescriptor(_class.prototype, "table"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "filters", [metabase_lib_lib_utils__WEBPACK_IMPORTED_MODULE_7__.memoize], Object.getOwnPropertyDescriptor(_class.prototype, "filters"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "sorts", [metabase_lib_lib_utils__WEBPACK_IMPORTED_MODULE_7__.memoize], Object.getOwnPropertyDescriptor(_class.prototype, "sorts"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "tableDimensions", [metabase_lib_lib_utils__WEBPACK_IMPORTED_MODULE_7__.memoize], Object.getOwnPropertyDescriptor(_class.prototype, "tableDimensions"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "expressionDimensions", [metabase_lib_lib_utils__WEBPACK_IMPORTED_MODULE_7__.memoize], Object.getOwnPropertyDescriptor(_class.prototype, "expressionDimensions"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "joinedDimensions", [metabase_lib_lib_utils__WEBPACK_IMPORTED_MODULE_7__.memoize], Object.getOwnPropertyDescriptor(_class.prototype, "joinedDimensions"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "breakoutDimensions", [metabase_lib_lib_utils__WEBPACK_IMPORTED_MODULE_7__.memoize], Object.getOwnPropertyDescriptor(_class.prototype, "breakoutDimensions"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "aggregationDimensions", [metabase_lib_lib_utils__WEBPACK_IMPORTED_MODULE_7__.memoize], Object.getOwnPropertyDescriptor(_class.prototype, "aggregationDimensions"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "fieldDimensions", [metabase_lib_lib_utils__WEBPACK_IMPORTED_MODULE_7__.memoize], Object.getOwnPropertyDescriptor(_class.prototype, "fieldDimensions"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "columnDimensions", [metabase_lib_lib_utils__WEBPACK_IMPORTED_MODULE_7__.memoize], Object.getOwnPropertyDescriptor(_class.prototype, "columnDimensions"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "columnNames", [metabase_lib_lib_utils__WEBPACK_IMPORTED_MODULE_7__.memoize], Object.getOwnPropertyDescriptor(_class.prototype, "columnNames"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "sourceQuery", [metabase_lib_lib_utils__WEBPACK_IMPORTED_MODULE_7__.memoize], Object.getOwnPropertyDescriptor(_class.prototype, "sourceQuery"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "rootQuery", [metabase_lib_lib_utils__WEBPACK_IMPORTED_MODULE_7__.memoize], Object.getOwnPropertyDescriptor(_class.prototype, "rootQuery"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "lastSummarizedQuery", [metabase_lib_lib_utils__WEBPACK_IMPORTED_MODULE_7__.memoize], Object.getOwnPropertyDescriptor(_class.prototype, "lastSummarizedQuery"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "topLevelQuery", [metabase_lib_lib_utils__WEBPACK_IMPORTED_MODULE_7__.memoize], Object.getOwnPropertyDescriptor(_class.prototype, "topLevelQuery"), _class.prototype)), _class); + // subclass of StructuredQuery that's returned by query.sourceQuery() to allow manipulation of source-query + +var NestedStructuredQuery = /*#__PURE__*/function (_StructuredQuery) { + _inherits(NestedStructuredQuery, _StructuredQuery); + + var _super = _createSuper(NestedStructuredQuery); + + function NestedStructuredQuery(question, datasetQuery, parent) { + var _this; + + _classCallCheck(this, NestedStructuredQuery); + + _this = _super.call(this, question, datasetQuery); + _this._parent = parent; + return _this; + } + + _createClass(NestedStructuredQuery, [{ + key: "setDatasetQuery", + value: function setDatasetQuery(datasetQuery) { + return new NestedStructuredQuery(this._originalQuestion, datasetQuery, this._parent); + } + }, { + key: "parentQuery", + value: function parentQuery() { + return this._parent.setSourceQuery(this.query()); + } + }]); + + return NestedStructuredQuery; +}(StructuredQuery); + +/***/ }), + +/***/ "../metabase-lib/lib/queries/structured/Aggregation.ts": +/*!*************************************************************!*\ + !*** ../metabase-lib/lib/queries/structured/Aggregation.ts ***! + \*************************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* binding */ Aggregation; } +/* harmony export */ }); +/* harmony import */ var _MBQLClause__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./MBQLClause */ "../metabase-lib/lib/queries/structured/MBQLClause.ts"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var metabase_lib_types__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/lib/types */ "./lib/types.js"); +/* harmony import */ var metabase_lib_query_aggregation__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/lib/query/aggregation */ "./lib/query/aggregation.js"); +/* harmony import */ var _Dimension__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Dimension */ "../metabase-lib/lib/Dimension.ts"); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +var _templateObject; + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-nocheck + + + + + +var INTEGER_AGGREGATIONS = new Set(["count", "cum-count", "distinct"]); + +var Aggregation = /*#__PURE__*/function (_MBQLClause) { + _inherits(Aggregation, _MBQLClause); + + var _super = _createSuper(Aggregation); + + function Aggregation() { + _classCallCheck(this, Aggregation); + + return _super.apply(this, arguments); + } + + _createClass(Aggregation, [{ + key: "replace", + value: + /** + * Replaces the aggregation in the parent query and returns the new StructuredQuery + * or replaces itself in the parent query if no {aggregation} argument is provided. + */ + function replace(aggregation) { + if (aggregation != null) { + return this._query.updateAggregation(this._index, aggregation); + } else { + return this._query.updateAggregation(this._index, this); + } + } + /** + * Adds itself to the parent query and returns the new StructuredQuery + */ + + }, { + key: "add", + value: function add() { + return this._query.aggregate(this); + } + /** + * Removes the aggregation in the parent query and returns the new StructuredQuery + */ + + }, { + key: "remove", + value: function remove() { + return this._query.removeAggregation(this._index); + } + }, { + key: "canRemove", + value: function canRemove() { + return this.remove().clean().isValid(); + } + /** + * Returns the display name for the aggregation + */ + + }, { + key: "displayName", + value: function displayName() { + var displayName = this.options()["display-name"]; + + if (displayName) { + return displayName; + } + + var aggregation = this.aggregation(); + + if (aggregation.isCustom()) { + return aggregation._query.formatExpression(aggregation); + } else if (aggregation.isMetric()) { + var metric = aggregation.metric(); + + if (metric) { + return metric.displayName(); + } + } else if (aggregation.isStandard()) { + var option = aggregation.option(); + + if (option) { + var aggregationName = option.columnName || option.name.replace(" of ...", ""); + var dimension = aggregation.dimension(); + + if (dimension) { + return (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["", " of ", ""])), aggregationName, dimension.render()); + } else { + return aggregationName; + } + } + } + + return null; + } + /** + * Returns the column name (non-deduplicated) + */ + + }, { + key: "columnName", + value: function columnName() { + var displayName = this.options()["display-name"]; + + if (displayName) { + return displayName; + } + + var aggregation = this.aggregation(); + + if (aggregation.isCustom()) { + return "expression"; + } else if (aggregation.isMetric()) { + var metric = aggregation.metric(); + + if (metric) { + // delegate to the metric's definition + return metric.columnName(); + } + } else if (aggregation.isStandard()) { + var short = this.short(); + + if (short) { + // NOTE: special case for "distinct" + return short === "distinct" ? "count" : short; + } + } + + return null; + } + }, { + key: "short", + value: function short() { + var aggregation = this.aggregation(); // FIXME: if metric, this should be the underlying metric's short name? + + if (aggregation.isMetric()) { + var metric = aggregation.metric(); + + if (metric) { + // delegate to the metric's definition + return metric.aggregation().short(); + } + } else if (aggregation.isStandard()) { + return aggregation[0]; + } + } + }, { + key: "baseType", + value: function baseType() { + var short = this.short(); + return INTEGER_AGGREGATIONS.has(short) ? metabase_lib_types__WEBPACK_IMPORTED_MODULE_2__.TYPE.Integer : metabase_lib_types__WEBPACK_IMPORTED_MODULE_2__.TYPE.Float; + } + /** + * Predicate function to test if a given aggregation clause is valid + */ + + }, { + key: "isValid", + value: function isValid() { + if (this.hasOptions()) { + return this.aggregation().isValid(); + } else if (this.isStandard() && this.dimension()) { + var dimension = this.dimension(); + var aggregationOperator = this.query().table().aggregationOperator(this[0]); + return aggregationOperator && (!aggregationOperator.requiresField || this.query().aggregationFieldOptions(aggregationOperator).hasDimension(dimension)); + } else if (this.isMetric()) { + return !!this.metric(); + } else { + // FIXME: custom aggregation validation + return true; + } + } // There are currently 3 "classes" of aggregations that are handled differently, "standard", "segment", and "custom" + + /** + * Returns true if this is a "standard" metric + */ + + }, { + key: "isStandard", + value: function isStandard() { + return metabase_lib_query_aggregation__WEBPACK_IMPORTED_MODULE_3__.isStandard(this); + } + /** + * Returns true if this is a metric + */ + + }, { + key: "isMetric", + value: function isMetric() { + return metabase_lib_query_aggregation__WEBPACK_IMPORTED_MODULE_3__.isMetric(this); + } + /** + * Returns true if this is custom expression created with the expression editor + */ + + }, { + key: "isCustom", + value: function isCustom() { + return metabase_lib_query_aggregation__WEBPACK_IMPORTED_MODULE_3__.isCustom(this); + } // STANDARD AGGREGATION + + /** + * Gets the aggregation option matching this aggregation + * Returns `null` if the clause isn't a "standard" metric + */ + + }, { + key: "option", + value: function option() { + var operatorName = this.operatorName(); + + if (this._query == null || !operatorName) { + return null; + } + + return this._query.aggregationOperators().find(function (option) { + return option.short === operatorName; + }); + } + /** + * Get the operator from a standard aggregation clause + * Returns `null` if the clause isn't a "standard" metric + */ + + }, { + key: "operatorName", + value: function operatorName() { + if (this.isStandard()) { + return this[0]; + } + } + /** + * Get the fieldId from a standard aggregation clause + * Returns `null` if the clause isn't a "standard" metric + */ + + }, { + key: "getFieldReference", + value: function getFieldReference() { + if (this.isStandard()) { + return this[1]; + } + } + /** + * Gets the dimension for this this aggregation + * Returns `null` if the clause isn't a "standard" metric + */ + + }, { + key: "dimension", + value: function dimension() { + if (this.isStandard() && this.length > 1) { + return this._query.parseFieldReference(this.getFieldReference()); + } + } // METRIC AGGREGATION + + /** + * Get metricId from a metric aggregation clause + * Returns `null` if the clause doesn't represent a metric + */ + + }, { + key: "metricId", + value: function metricId() { + if (this.isMetric()) { + return this[1]; + } + } + }, { + key: "metric", + value: function metric() { + if (this.isMetric()) { + return this.metadata().metric(this.metricId()); + } + } // OPTIONS + + }, { + key: "hasOptions", + value: function hasOptions() { + return this[0] === "aggregation-options"; + } + }, { + key: "options", + value: function options() { + if (this.hasOptions()) { + return this[2] || {}; + } else { + return {}; + } + } + /** + * Returns the aggregation without "aggregation-options" clause, if any + */ + + }, { + key: "aggregation", + value: function aggregation() { + if (this.hasOptions()) { + return new Aggregation(this[1], this._index, this._query); + } else { + return this; + } + } // MISC + + }, { + key: "aggregationDimension", + value: function aggregationDimension() { + return new _Dimension__WEBPACK_IMPORTED_MODULE_4__.AggregationDimension(null, [this._index], this._query.metadata(), this._query); + } + }]); + + return Aggregation; +}(_MBQLClause__WEBPACK_IMPORTED_MODULE_0__.default); + + + +/***/ }), + +/***/ "../metabase-lib/lib/queries/structured/Breakout.ts": +/*!**********************************************************!*\ + !*** ../metabase-lib/lib/queries/structured/Breakout.ts ***! + \**********************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* binding */ Breakout; } +/* harmony export */ }); +/* harmony import */ var _MBQLClause__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./MBQLClause */ "../metabase-lib/lib/queries/structured/MBQLClause.ts"); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-nocheck + + +var Breakout = /*#__PURE__*/function (_MBQLClause) { + _inherits(Breakout, _MBQLClause); + + var _super = _createSuper(Breakout); + + function Breakout() { + _classCallCheck(this, Breakout); + + return _super.apply(this, arguments); + } + + _createClass(Breakout, [{ + key: "replace", + value: + /** + * Replaces the breakout in the parent query and returns the new StructuredQuery + * or replaces itself in the parent query if no {breakout} argument is provided. + */ + function replace(breakout) { + if (breakout != null) { + return this._query.updateBreakout(this._index, breakout); + } else { + return this._query.updateBreakout(this._index, this); + } + } + /** + * Adds itself to the parent query and returns the new StructuredQuery + */ + + }, { + key: "add", + value: function add() { + return this._query.breakout(this); + } + /** + * Removes the breakout in the parent query and returns the new StructuredQuery + */ + + }, { + key: "remove", + value: function remove() { + return this._query.removeBreakout(this._index); + } + /** + * Returns the display name for the breakout + */ + + }, { + key: "displayName", + value: function displayName() { + var dimension = this.dimension(); + return dimension && dimension.render(); + } + /** + * Predicate function to test if a given breakout clause is valid + */ + + }, { + key: "isValid", + value: function isValid() { + var query = this.query(); + return !query || query.breakoutOptions(this).hasDimension(this.dimension()); + } + /** + * Returns the breakout's Dimension + */ + + }, { + key: "dimension", + value: function dimension() { + return this._query.parseFieldReference(this); + } + /** + * Returns the breakout's Field + */ + + }, { + key: "field", + value: function field() { + return this.dimension().field(); + } + }]); + + return Breakout; +}(_MBQLClause__WEBPACK_IMPORTED_MODULE_0__.default); + + + +/***/ }), + +/***/ "../metabase-lib/lib/queries/structured/Filter.ts": +/*!********************************************************!*\ + !*** ../metabase-lib/lib/queries/structured/Filter.ts ***! + \********************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* binding */ Filter; } +/* harmony export */ }); +/* harmony import */ var _MBQLClause__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./MBQLClause */ "../metabase-lib/lib/queries/structured/MBQLClause.ts"); +/* harmony import */ var metabase_lib_query_time__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/lib/query_time */ "./lib/query_time.js"); +/* harmony import */ var metabase_lib_query_filter__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/lib/query/filter */ "./lib/query/filter.js"); +/* harmony import */ var metabase_lib_expressions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/lib/expressions */ "./lib/expressions/index.js"); +/* harmony import */ var metabase_lib_schema_metadata__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! metabase/lib/schema_metadata */ "./lib/schema_metadata.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_5__); +/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! underscore */ "../../../node_modules/underscore/modules/index-all.js"); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +var _templateObject, _templateObject2, _templateObject3; + +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } + +function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } + +function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-nocheck + + + + + + + + +var Filter = /*#__PURE__*/function (_MBQLClause) { + _inherits(Filter, _MBQLClause); + + var _super = _createSuper(Filter); + + function Filter() { + _classCallCheck(this, Filter); + + return _super.apply(this, arguments); + } + + _createClass(Filter, [{ + key: "replace", + value: + /** + * Replaces the filter in the parent query and returns the new StructuredQuery + * or replaces itself in the parent query if no {filter} argument is provided. + */ + function replace(filter) { + if (filter != null) { + return this._query.updateFilter(this._index, filter); + } else { + return this._query.updateFilter(this._index, this); + } + } + /** + * Adds itself to the parent query and returns the new StructuredQuery + */ + + }, { + key: "add", + value: function add() { + return this._query.filter(this); + } + /** + * Removes the filter in the parent query and returns the new StructuredQuery + */ + + }, { + key: "remove", + value: function remove() { + return this._query.removeFilter(this._index); + } + /** + * Returns the display name for the filter + */ + + }, { + key: "displayName", + value: function displayName() { + if (this.isSegment()) { + var segment = this.segment(); + return segment ? segment.displayName() : (0,ttag__WEBPACK_IMPORTED_MODULE_5__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["Unknown Segment"]))); + } else if (this.isStandard()) { + var dimension = this.dimension(); + var operator = this.operator(); + var dimensionName = dimension && dimension.displayName(); + var operatorName = operator && operator.moreVerboseName; + var argumentNames = this.formattedArguments().join(" "); + return "".concat(dimensionName || "", " ").concat(operatorName || "", " ").concat(argumentNames); + } else if (this.isCustom()) { + return this._query.formatExpression(this); + } else { + return (0,ttag__WEBPACK_IMPORTED_MODULE_5__.t)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["Unknown Filter"]))); + } + } + /** + * Returns true if the filter is valid + */ + + }, { + key: "isValid", + value: function isValid() { + if (this.isStandard()) { + // has an operator name and dimension or expression + var dimension = this.dimension(); + + if (!dimension && (0,metabase_lib_expressions__WEBPACK_IMPORTED_MODULE_3__.isExpression)(this[1])) { + return true; + } + + var query = this.query(); + + if (!dimension || !(query && query.filterDimensionOptions().hasDimension(dimension))) { + return false; + } + + var operator = this.operator(); + + if (operator) { + var args = this.arguments(); // has the mininum number of arguments + + if (args.length < operator.fields.length) { + return false; + } // arguments are non-null/undefined + + + if (!underscore__WEBPACK_IMPORTED_MODULE_6__.default.all(args, function (arg) { + return arg != null; + })) { + return false; + } + } + + return true; + } else if (this.isSegment()) { + return !!this.segment(); + } else if (this.isCustom()) { + return true; + } + + return false; + } // There are currently 3 "classes" of filters that are handled differently, "standard", "segment", and "custom" + + /** + * Returns true if this is a "standard" filter + */ + + }, { + key: "isStandard", + value: function isStandard() { + return (0,metabase_lib_query_filter__WEBPACK_IMPORTED_MODULE_2__.isStandard)(this); + } + /** + * Returns true if this is a segment + */ + + }, { + key: "isSegment", + value: function isSegment() { + return (0,metabase_lib_query_filter__WEBPACK_IMPORTED_MODULE_2__.isSegment)(this); + } + /** + * Returns true if this is custom filter created with the expression editor + */ + + }, { + key: "isCustom", + value: function isCustom() { + return (0,metabase_lib_query_filter__WEBPACK_IMPORTED_MODULE_2__.isCustom)(this); + } + /** + * Returns true for filters where the first argument is a field + */ + + }, { + key: "isFieldFilter", + value: function isFieldFilter() { + return (0,metabase_lib_query_filter__WEBPACK_IMPORTED_MODULE_2__.isFieldFilter)(this); + } // SEGMENT FILTERS + + }, { + key: "segmentId", + value: function segmentId() { + if (this.isSegment()) { + return this[1]; + } + } + }, { + key: "segment", + value: function segment() { + if (this.isSegment()) { + return this.metadata().segment(this.segmentId()); + } + } // FIELD FILTERS + + }, { + key: "dimension", + value: function dimension() { + if (this.isFieldFilter()) { + return this._query.parseFieldReference(this[1]); + } + } + }, { + key: "field", + value: function field() { + var dimension = this.dimension(); + return dimension && dimension.field(); + } + }, { + key: "operatorName", + value: function operatorName() { + return this[0]; + } + }, { + key: "operator", + value: function operator() { + var dimension = this.dimension(); + return dimension ? dimension.filterOperator(this.operatorName()) : null; + } + }, { + key: "setOperator", + value: function setOperator(operatorName) { + var dimension = this.dimension(); + var operator = dimension && dimension.filterOperator(operatorName); + var filter = [operatorName, dimension && dimension.mbql()]; + + if (operator) { + for (var i = 0; i < operator.fields.length; i++) { + if (operator.fields[i].default !== undefined) { + filter.push(operator.fields[i].default); + } else { + filter.push(undefined); + } + } + + if (operator.optionsDefaults) { + filter.push(operator.optionsDefaults); + } + + var oldOperator = this.operator(); + var oldFilter = this; + + if (oldOperator) { + // copy over values of the same type + for (var _i = 0; _i < oldFilter.length - 2; _i++) { + var field = operator.multi ? operator.fields[0] : operator.fields[_i]; + var oldField = oldOperator.multi ? oldOperator.fields[0] : oldOperator.fields[_i]; + + if (field && oldField && field.type === oldField.type && oldFilter[_i + 2] !== undefined) { + filter[_i + 2] = oldFilter[_i + 2]; + } + } + } + } + + return this.set(filter); + } + }, { + key: "setDimension", + value: function setDimension(fieldRef) { + var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, + _ref$useDefaultOperat = _ref.useDefaultOperator, + useDefaultOperator = _ref$useDefaultOperat === void 0 ? false : _ref$useDefaultOperat; + + if (!fieldRef) { + return this.set([]); + } + + var dimension = this._query.parseFieldReference(fieldRef); + + if (dimension && (!this.isFieldFilter() || !dimension.isEqual(this.dimension()))) { + var operator = // see if the new dimension supports the existing operator + dimension.filterOperator(this.operatorName()) || useDefaultOperator && dimension.defaultFilterOperator(); + var operatorName = operator && operator.name; + var filter = this.set(this.isFieldFilter() ? [this[0], dimension.mbql()].concat(_toConsumableArray(this.slice(2))) : [null, dimension.mbql()]); + + if (operatorName && filter.operatorName() !== operatorName) { + return filter.setOperator(operatorName); + } else { + return filter; + } + } + + return this; + } + }, { + key: "setArgument", + value: function setArgument(index, value) { + return this.set([].concat(_toConsumableArray(this.slice(0, index + 2)), [value], _toConsumableArray(this.slice(index + 3)))); + } + }, { + key: "setArguments", + value: function setArguments(values) { + return this.set([].concat(_toConsumableArray(this.slice(0, 2)), _toConsumableArray(values))); + } + }, { + key: "filterOperators", + value: function filterOperators(selected) { + var dimension = this.dimension(); + return dimension ? dimension.filterOperators(selected) : null; + } + }, { + key: "arguments", + value: function _arguments() { + return (0,metabase_lib_query_filter__WEBPACK_IMPORTED_MODULE_2__.hasFilterOptions)(this) ? this.slice(2, -1) : this.slice(2); + } + }, { + key: "formattedArguments", + value: function formattedArguments() { + var maxDisplayValues = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1; + var dimension = this.dimension(); + var operator = this.operator(); + var args = this.arguments(); + + if (operator && operator.multi && args.length > maxDisplayValues) { + var n = args.length; + return [(0,ttag__WEBPACK_IMPORTED_MODULE_5__.ngettext)((0,ttag__WEBPACK_IMPORTED_MODULE_5__.msgid)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["", " selection"])), n), "".concat(n, " selections"), n)]; + } else if (dimension && dimension.field().isDate() && !dimension.field().isTime()) { + return (0,metabase_lib_query_time__WEBPACK_IMPORTED_MODULE_1__.generateTimeFilterValuesDescriptions)(this); + } else { + return args.map(function (value, index) { + return [value, (0,metabase_lib_schema_metadata__WEBPACK_IMPORTED_MODULE_4__.getFilterArgumentFormatOptions)(operator, index)]; + }).filter(function (_ref2) { + var _ref3 = _slicedToArray(_ref2, 2), + value = _ref3[0], + options = _ref3[1]; + + return value !== undefined && !options.hide; + }).map(function (_ref4, index // FIXME: remapping + ) { + var _ref5 = _slicedToArray(_ref4, 2), + value = _ref5[0], + options = _ref5[1]; + + return value; + } // + ); + } + } + }, { + key: "isDimension", + value: function isDimension(otherDimension) { + var dimension = this.dimension(); + return dimension ? dimension.isEqual(otherDimension) : false; + } + }, { + key: "isOperator", + value: function isOperator(otherOperator) { + var operator = this.operator(); + var operatorName = typeof otherOperator === "string" ? otherOperator : otherOperator && otherOperator.name; + return operator && operator.name === operatorName; + } + }]); + + return Filter; +}(_MBQLClause__WEBPACK_IMPORTED_MODULE_0__.default); + + + +/***/ }), + +/***/ "../metabase-lib/lib/queries/structured/Join.ts": +/*!******************************************************!*\ + !*** ../metabase-lib/lib/queries/structured/Join.ts ***! + \******************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* binding */ Join; } +/* harmony export */ }); +/* harmony import */ var _MBQLClause__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./MBQLClause */ "../metabase-lib/lib/queries/structured/MBQLClause.ts"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var _StructuredQuery__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../StructuredQuery */ "../metabase-lib/lib/queries/StructuredQuery.ts"); +/* harmony import */ var metabase_lib_lib_Dimension__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase-lib/lib/Dimension */ "../metabase-lib/lib/Dimension.ts"); +/* harmony import */ var metabase_lib_lib_DimensionOptions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! metabase-lib/lib/DimensionOptions */ "../metabase-lib/lib/DimensionOptions.ts"); +/* harmony import */ var metabase_lib_formatting__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! metabase/lib/formatting */ "./lib/formatting.js"); +/* harmony import */ var metabase_lib_query_field_ref__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! metabase/lib/query/field_ref */ "./lib/query/field_ref.js"); +/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! underscore */ "../../../node_modules/underscore/modules/index-all.js"); +/* provided dependency */ var console = __webpack_require__(/*! console-browserify */ "../../../node_modules/console-browserify/index.js"); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +var _templateObject, _templateObject2, _templateObject3, _templateObject4; + +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } + +function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } + +function _toArray(arr) { return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest(); } + +function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); } + +function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-nocheck + + + + + + + + +var JOIN_STRATEGY_OPTIONS = [{ + value: "left-join", + name: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["Left outer join"]))), + icon: "join_left_outer" +}, // default +{ + value: "right-join", + name: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["Right outer join"]))), + icon: "join_right_outer" +}, { + value: "inner-join", + name: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["Inner join"]))), + icon: "join_inner" +}, { + value: "full-join", + name: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["Full outer join"]))), + icon: "join_full_outer" +}]; +var PARENT_DIMENSION_INDEX = 1; +var JOIN_DIMENSION_INDEX = 2; + +var Join = /*#__PURE__*/function (_MBQLObjectClause) { + _inherits(Join, _MBQLObjectClause); + + var _super = _createSuper(Join); + + function Join() { + _classCallCheck(this, Join); + + return _super.apply(this, arguments); + } + + _createClass(Join, [{ + key: "set", + value: // "source-query": ?StructuredQueryObject; + // "source-table": ?TableId; + function set(join) { + return _get(_getPrototypeOf(Join.prototype), "set", this).call(this, join); + } + }, { + key: "displayName", + value: function displayName() { + return this.alias; + } + /** + * Replaces the aggregation in the parent query and returns the new StructuredQuery + */ + + }, { + key: "replace", + value: function replace(join) { + return this._query.updateJoin(this._index, join); + } // SOURCE TABLE + + }, { + key: "joinSourceTableId", + value: function joinSourceTableId() { + return this["source-table"]; + } + }, { + key: "setJoinSourceTableId", + value: function setJoinSourceTableId(tableId) { + if (tableId !== this["source-table"]) { + var join = this.set(_objectSpread(_objectSpread({}, this), {}, { + "source-query": undefined, + "source-table": tableId, + condition: null + })); + + if (!join.alias) { + return join.setDefaultAlias(); + } else { + return join; + } + } else { + return this; + } + } // SOURCE QUERY + + }, { + key: "joinSourceQuery", + value: function joinSourceQuery() { + return this["source-query"]; + } + }, { + key: "setJoinSourceQuery", + value: function setJoinSourceQuery(query) { + return this.set(_objectSpread(_objectSpread({}, this), {}, { + "source-table": undefined, + "source-query": query, + condition: null + })); + } + }, { + key: "_uniqueAlias", + value: function _uniqueAlias(name) { + var _this = this; + + var usedAliases = new Set(this.query().joins().map(function (join) { + return join.alias; + }).filter(function (alias) { + return alias !== _this.alias; + })); // alias can't be same as parent table name either + + var parentTable = this.parentTable(); + + if (parentTable) { + usedAliases.add(parentTable.name); + } + + for (var index = 1;; index++) { + var alias = index === 1 ? name : "".concat(name, "_").concat(index); + + if (!usedAliases.has(alias)) { + return alias; + } + } + } // FIELDS + + }, { + key: "setFields", + value: function setFields(fields) { + return this.set(_objectSpread(_objectSpread({}, this), {}, { + fields: fields + })); + } + }, { + key: "addField", + value: function addField(field) { + if (Array.isArray(this.fields)) { + return this.setFields([].concat(_toConsumableArray(this.fields), [field])); + } else if (this.fields === "none") { + return this.setFields([field]); + } else { + return this; + } + } + }, { + key: "clearFields", + value: function clearFields() { + return this.setFields("none"); + } // ALIAS + + }, { + key: "setAlias", + value: function setAlias(alias) { + var _this2 = this; + + alias = this._uniqueAlias(alias); + + if (alias !== this.alias) { + var join = this.set(_objectSpread(_objectSpread({}, this), {}, { + alias: alias + })); // propagate alias change to join dimension + + var joinDimensions = join.joinDimensions(); + joinDimensions.forEach(function (joinDimension, i) { + if (joinDimension instanceof metabase_lib_lib_Dimension__WEBPACK_IMPORTED_MODULE_3__.FieldDimension && joinDimension.joinAlias() && joinDimension.joinAlias() === _this2.alias) { + var newDimension = joinDimension.withJoinAlias(alias); + join = join.setJoinDimension({ + index: i, + dimension: newDimension + }); + } + }); + return join; + } + + return this; + } + }, { + key: "_getParentDimensionForAlias", + value: function _getParentDimensionForAlias() { + return this.parentDimensions().find(function (dimension) { + return dimension && dimension.field().isFK(); + }); + } + }, { + key: "setDefaultAlias", + value: function setDefaultAlias() { + // The Join alias should be "Table - FK Field" if possible. We need both to disamiguate sitatutions where we have + // multiple FKs that point to the same Table -- see #8418 and #11452. + // + // The exception to this rule is cases where the the FK Field is basically the same as the Table name, e.g. a + // "Product[s]" Table and a "product_id" FK Field (displayed as "Product"). It looks rediculous having + // "Product[s] - Product". So in that case just show one or the other. + var table = this.joinedTable(); + + if (table && table.isSavedQuestion()) { + // NOTE: special case for "Saved Questions" tables + return this.setAlias("Question ".concat(table.savedQuestionId())); + } + + var tableName = table && table.display_name; + + var parentDimension = this._getParentDimensionForAlias(); + + var fieldName = parentDimension && parentDimension.field().targetObjectName(); + var similarTableAndFieldNames = tableName && fieldName && (tableName === fieldName || (0,metabase_lib_formatting__WEBPACK_IMPORTED_MODULE_5__.pluralize)(tableName) === fieldName || tableName === (0,metabase_lib_formatting__WEBPACK_IMPORTED_MODULE_5__.pluralize)(fieldName) || (0,metabase_lib_formatting__WEBPACK_IMPORTED_MODULE_5__.pluralize)(tableName) === (0,metabase_lib_formatting__WEBPACK_IMPORTED_MODULE_5__.pluralize)(fieldName)); // if for whatever reason we don't have both table *and* field name, fallback to either just field name or just + // table name; if the world has gone mad just use 'source' instead of nothing + + var alias = tableName && fieldName && !similarTableAndFieldNames && tableName + " - " + fieldName || tableName || fieldName || "source"; + return this.setAlias(alias); + } + }, { + key: "getConditions", + value: function getConditions() { + if (!this.condition) { + return []; + } + + if (this.isSingleConditionJoin()) { + return [this.condition]; + } + + var _this$condition = _toArray(this.condition), + conditions = _this$condition.slice(1); + + return conditions; + } // STRATEGY + + }, { + key: "setStrategy", + value: function setStrategy(strategy) { + return this.set(_objectSpread(_objectSpread({}, this), {}, { + strategy: strategy + })); + } + }, { + key: "strategyOption", + value: function strategyOption() { + return this.strategy ? underscore__WEBPACK_IMPORTED_MODULE_7__.default.findWhere(this.strategyOptions(), { + value: this.strategy + }) : JOIN_STRATEGY_OPTIONS[0]; + } + }, { + key: "strategyOptions", + value: function strategyOptions() { + var database = this.query().database(); + + if (!database) { + return []; + } + + return JOIN_STRATEGY_OPTIONS.filter(function (_ref) { + var value = _ref.value; + return database.hasFeature(value); + }); + } // CONDITIONS + + }, { + key: "isSingleConditionJoin", + value: function isSingleConditionJoin() { + var condition = this.condition; + return Array.isArray(condition) && condition[0] === "="; + } + }, { + key: "isMultipleConditionsJoin", + value: function isMultipleConditionsJoin() { + var condition = this.condition; + return Array.isArray(condition) && condition[0] === "and"; + } + }, { + key: "getConditionByIndex", + value: function getConditionByIndex(index) { + if (!this.condition) { + return null; + } + + if (this.isSingleConditionJoin() && !index) { + return this.condition; + } + + if (this.isMultipleConditionsJoin()) { + var _this$condition2 = _toArray(this.condition), + conditions = _this$condition2.slice(1); + + return conditions[index]; + } + + return null; + } + }, { + key: "setCondition", + value: function setCondition(condition) { + return this.set(_objectSpread(_objectSpread({}, this), {}, { + condition: condition + })); + } + }, { + key: "setConditionByIndex", + value: function setConditionByIndex(_ref2) { + var _ref2$index = _ref2.index, + index = _ref2$index === void 0 ? 0 : _ref2$index, + condition = _ref2.condition; + + if (!this.condition) { + return this.setCondition(condition); + } + + if (this.isSingleConditionJoin()) { + if (index === 0) { + return this.setCondition(condition); + } else { + return this.setCondition(["and", this.condition, condition]); + } + } + + var conditions = _toConsumableArray(this.condition); + + conditions[index + 1] = condition; + return this.setCondition(conditions); + } + }, { + key: "removeCondition", + value: function removeCondition(index) { + if (index == null || !this.getConditionByIndex(index)) { + return this; + } + + if (this.isSingleConditionJoin()) { + return this.setCondition(null); + } + + var filteredCondition = this.condition.filter(function (_, i) { + // Adding 1 because the first element of a condition is an operator ("and") + return i !== index + 1; + }); + + var _filteredCondition = _toArray(filteredCondition), + conditions = _filteredCondition.slice(1); + + var isSingleNewCondition = conditions.length === 1; + + if (isSingleNewCondition) { + return this.setCondition(conditions[0]); + } + + return this.setCondition(filteredCondition); + } + }, { + key: "setDefaultCondition", + value: function setDefaultCondition() { + var _this$parentDimension = this.parentDimensionOptions(), + dimensions = _this$parentDimension.dimensions; // look for foreign keys linking the two tables + + + var joinedTable = this.joinedTable(); + + if (joinedTable && joinedTable.id != null) { + var fk = underscore__WEBPACK_IMPORTED_MODULE_7__.default.find(dimensions, function (d) { + var _d$field = d.field(), + target = _d$field.target; + + return target && target.table && target.table.id === joinedTable.id; + }); + + if (fk) { + return this.setParentDimension({ + index: 0, + dimension: fk + }).setJoinDimension({ + index: 0, + dimension: this.joinedDimension(fk.field().target.dimension()) + }); + } + } + + return this; + } + }, { + key: "_convertDimensionIntoMBQL", + value: function _convertDimensionIntoMBQL(dimension) { + return dimension instanceof metabase_lib_lib_Dimension__WEBPACK_IMPORTED_MODULE_3__.default ? dimension.mbql() : dimension; + } + }, { + key: "_getJoinDimensionFromCondition", + value: function _getJoinDimensionFromCondition(condition) { + var _condition = _slicedToArray(condition, 3), + joinDimension = _condition[2]; + + var joinedQuery = this.joinedQuery(); + return joinedQuery && joinDimension && joinedQuery.parseFieldReference(joinDimension); + } + }, { + key: "_getJoinDimensionsFromMultipleConditions", + value: function _getJoinDimensionsFromMultipleConditions() { + var _this3 = this; + + var _this$condition3 = _toArray(this.condition), + conditions = _this$condition3.slice(1); + + return conditions.map(function (condition) { + return _this3._getJoinDimensionFromCondition(condition); + }); + } // simplified "=" join condition helpers: + // NOTE: parentDimension refers to the left-hand side of the join, + // and joinDimension refers to the right-hand side + // TODO: should we rename them to lhsDimension/rhsDimension etc? + + }, { + key: "_getParentDimensionFromCondition", + value: function _getParentDimensionFromCondition(condition) { + var _condition2 = _slicedToArray(condition, 2), + parentDimension = _condition2[1]; + + return parentDimension && this.query().parseFieldReference(parentDimension); + } + }, { + key: "_getParentDimensionsFromMultipleConditions", + value: function _getParentDimensionsFromMultipleConditions() { + var _this4 = this; + + var _this$condition4 = _toArray(this.condition), + conditions = _this$condition4.slice(1); + + return conditions.map(function (condition) { + return _this4._getParentDimensionFromCondition(condition); + }); + } + }, { + key: "parentDimensions", + value: function parentDimensions() { + if (!this.condition) { + return []; + } + + return this.isSingleConditionJoin() ? [this._getParentDimensionFromCondition(this.condition)] : this._getParentDimensionsFromMultipleConditions(); + } + }, { + key: "parentDimensionOptions", + value: function parentDimensionOptions() { + var query = this.query(); + var dimensions = query.dimensions(); + var options = { + count: dimensions.length, + dimensions: dimensions, + fks: [], + preventNumberSubDimensions: true + }; // add all previous joined fields + + var joins = query.joins(); + + for (var i = 0; i < this.index(); i++) { + var fkOptions = joins[i].joinedDimensionOptions(); + options.count += fkOptions.count; + options.fks.push(fkOptions); + } + + return new metabase_lib_lib_DimensionOptions__WEBPACK_IMPORTED_MODULE_4__.default(options); + } + }, { + key: "joinDimensions", + value: function joinDimensions() { + if (!this.condition) { + return []; + } + + return this.isSingleConditionJoin() ? [this._getJoinDimensionFromCondition(this.condition)] : this._getJoinDimensionsFromMultipleConditions(); + } + }, { + key: "addEmptyDimensionsPair", + value: function addEmptyDimensionsPair() { + if (!this.condition) { + return this.setCondition([]); + } + + if (this.isSingleConditionJoin()) { + return this.setCondition(["and", this.condition, []]); + } else { + return this.setCondition([].concat(_toConsumableArray(this.condition), [[]])); + } + } + }, { + key: "_isDateTimeDimensionsJoin", + value: function _isDateTimeDimensionsJoin(d1, d2) { + return d1 && d2 && (0,metabase_lib_query_field_ref__WEBPACK_IMPORTED_MODULE_6__.isDateTimeField)(d1) && (0,metabase_lib_query_field_ref__WEBPACK_IMPORTED_MODULE_6__.isDateTimeField)(d2); + } + }, { + key: "_getDateTimeFieldCondition", + value: function _getDateTimeFieldCondition(parentDimension, joinDimension, temporalUnitSource) { + var temporalUnit = (0,metabase_lib_query_field_ref__WEBPACK_IMPORTED_MODULE_6__.getDatetimeUnit)(temporalUnitSource === "parent" ? parentDimension : joinDimension); + var parent = setTemporalUnit(parentDimension, temporalUnit); + var join = setTemporalUnit(joinDimension, temporalUnit); + return ["=", parent, join]; + } + }, { + key: "setJoinDimension", + value: function setJoinDimension(_ref3) { + var _ref3$index = _ref3.index, + index = _ref3$index === void 0 ? 0 : _ref3$index, + dimension = _ref3.dimension, + _ref3$overwriteTempor = _ref3.overwriteTemporalUnit, + overwriteTemporalUnit = _ref3$overwriteTempor === void 0 ? false : _ref3$overwriteTempor; + var condition = this.getConditionByIndex(index); + + var join = this._convertDimensionIntoMBQL(dimension); + + var parent = condition ? condition[PARENT_DIMENSION_INDEX] : null; + var newCondition = this._isDateTimeDimensionsJoin(parent, join) ? this._getDateTimeFieldCondition(parent, join, overwriteTemporalUnit ? "join" : "parent") : ["=", parent, join]; + return this.setConditionByIndex({ + index: index, + condition: newCondition + }); + } + }, { + key: "setParentDimension", + value: function setParentDimension(_ref4) { + var _ref4$index = _ref4.index, + index = _ref4$index === void 0 ? 0 : _ref4$index, + dimension = _ref4.dimension, + _ref4$overwriteTempor = _ref4.overwriteTemporalUnit, + overwriteTemporalUnit = _ref4$overwriteTempor === void 0 ? false : _ref4$overwriteTempor; + var condition = this.getConditionByIndex(index); + + var parent = this._convertDimensionIntoMBQL(dimension); + + var join = condition ? condition[JOIN_DIMENSION_INDEX] : null; + var newCondition = this._isDateTimeDimensionsJoin(parent, join) ? this._getDateTimeFieldCondition(parent, join, overwriteTemporalUnit ? "parent" : "join") : ["=", parent, join]; + return this.setConditionByIndex({ + index: index, + condition: newCondition + }); + } + }, { + key: "joinDimensionOptions", + value: function joinDimensionOptions() { + var dimensions = this.joinedDimensions(); + return new metabase_lib_lib_DimensionOptions__WEBPACK_IMPORTED_MODULE_4__.default({ + count: dimensions.length, + dimensions: dimensions, + fks: [], + preventNumberSubDimensions: true + }); + } // HELPERS + + }, { + key: "getDimensions", + value: function getDimensions() { + var _this5 = this; + + var conditions = this.getConditions(); + return conditions.map(function (condition) { + var _condition3 = _slicedToArray(condition, 3), + parentDimension = _condition3[1], + joinDimension = _condition3[2]; + + return [parentDimension ? _this5.query().parseFieldReference(parentDimension) : null, joinDimension ? _this5.query().parseFieldReference(joinDimension) : null]; + }); + } + }, { + key: "joinedQuery", + value: function joinedQuery() { + var sourceTable = this.joinSourceTableId(); + var sourceQuery = this.joinSourceQuery(); + return sourceTable ? new _StructuredQuery__WEBPACK_IMPORTED_MODULE_2__.default(this.query().question(), { + type: "query", + query: { + "source-table": sourceTable + } + }) : sourceQuery ? new _StructuredQuery__WEBPACK_IMPORTED_MODULE_2__.default(this.query().question(), { + type: "query", + query: sourceQuery + }) : null; + } + }, { + key: "joinedTable", + value: function joinedTable() { + var joinedQuery = this.joinedQuery(); + return joinedQuery && joinedQuery.table(); + } + }, { + key: "parentQuery", + value: function parentQuery() { + return this.query(); + } + }, { + key: "parentTable", + value: function parentTable() { + var parentQuery = this.parentQuery(); + return parentQuery && parentQuery.table(); + } + /** + * All possible joined dimensions + */ + + }, { + key: "joinedDimensions", + value: function joinedDimensions() { + var _this6 = this; + + var table = this.joinedTable(); + return table ? table.dimensions().map(function (dimension) { + return _this6.joinedDimension(dimension); + }) : []; + } + /** + * Currently selected joined dimensions + */ + + }, { + key: "fieldsDimensions", + value: function fieldsDimensions() { + var _this7 = this; + + if (this.fields === "all") { + return this.joinedDimensions(); + } else if (Array.isArray(this.fields)) { + return this.fields.map(function (f) { + return _this7.query().parseFieldReference(f); + }); + } else { + return []; + } + } + }, { + key: "joinedDimensionOptions", + value: function joinedDimensionOptions() { + var dimensionFilter = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function () { + return true; + }; + var dimensions = this.joinedDimensions().filter(dimensionFilter); + return new metabase_lib_lib_DimensionOptions__WEBPACK_IMPORTED_MODULE_4__.default({ + name: this.displayName(), + icon: "join_left_outer", + dimensions: dimensions, + fks: [], + count: dimensions.length + }); + } + }, { + key: "joinedDimension", + value: function joinedDimension(dimension) { + if (dimension instanceof metabase_lib_lib_Dimension__WEBPACK_IMPORTED_MODULE_3__.FieldDimension) { + return dimension.withJoinAlias(this.alias); + } + + console.warn("Don't know how to create joined dimension with:", dimension); + return dimension; + } + }, { + key: "dependentMetadata", + value: function dependentMetadata() { + var joinedQuery = this.joinedQuery(); + return joinedQuery ? joinedQuery.dependentMetadata({ + foreignTables: false + }) : []; + } + /** + * Removes the aggregation in the parent query and returns the new StructuredQuery + */ + + }, { + key: "remove", + value: function remove() { + return this._query.removeJoin(this._index); + } + }, { + key: "hasGaps", + value: function hasGaps() { + var parentDimensions = this.parentDimensions(); + var joinDimensions = this.joinDimensions(); + return parentDimensions.length === 0 || joinDimensions.length === 0 || parentDimensions.length !== joinDimensions.length || parentDimensions.some(function (dimension) { + return dimension == null; + }) || joinDimensions.some(function (dimension) { + return dimension == null; + }); + } + }, { + key: "isValid", + value: function isValid() { + if (!this.condition || !this.joinedTable() || this.hasGaps()) { + return false; + } + + var dimensionOptions = this.parent().dimensionOptions(); + var dimensions = [].concat(_toConsumableArray(this.parentDimensions()), _toConsumableArray(this.joinDimensions())); + return dimensions.every(function (dimension) { + return dimensionOptions.hasDimension(dimension) || // For some GUI queries created in earlier versions of Metabase, + // some dimensions are described as field literals + // Usually it's [ "field", field_numeric_id, null|object ] + // And field literals look like [ "field", "PRODUCT_ID", {'base-type': 'type/Integer' } ] + // These literals are not present in dimension options, but still work + // As a workaround, we just skip field literals if they're not present in dimension options + (0,metabase_lib_query_field_ref__WEBPACK_IMPORTED_MODULE_6__.isFieldLiteral)(dimension.mbql()); + }); + } + }, { + key: "clean", + value: function clean() { + if (!this.condition || !this.hasGaps()) { + return this; + } + + var join = this; + var invalidDimensionIndex = this.parentDimensions().findIndex(function (dimension) { + return dimension == null; + }); + + if (invalidDimensionIndex >= 0) { + join = this.removeCondition(invalidDimensionIndex); + } + + invalidDimensionIndex = this.joinDimensions().findIndex(function (dimension) { + return dimension == null; + }); + + if (invalidDimensionIndex >= 0) { + join = this.removeCondition(invalidDimensionIndex); + } + + return join.clean(); + } + }]); + + return Join; +}(_MBQLClause__WEBPACK_IMPORTED_MODULE_0__.MBQLObjectClause); + + + +function setTemporalUnit(fieldRef, value) { + var _fieldRef = _slicedToArray(fieldRef, 3), + field = _fieldRef[0], + id = _fieldRef[1], + opts = _fieldRef[2]; + + return [field, id, _objectSpread(_objectSpread({}, opts), {}, { + "temporal-unit": value + })]; +} + +/***/ }), + +/***/ "../metabase-lib/lib/queries/structured/MBQLClause.ts": +/*!************************************************************!*\ + !*** ../metabase-lib/lib/queries/structured/MBQLClause.ts ***! + \************************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* binding */ MBQLArrayClause; }, +/* harmony export */ "MBQLObjectClause": function() { return /* binding */ MBQLObjectClause; } +/* harmony export */ }); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } + +function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } + +function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); } + +function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-nocheck +var MBQLArrayClause = /*#__PURE__*/function (_Array) { + _inherits(MBQLArrayClause, _Array); + + var _super = _createSuper(MBQLArrayClause); + + function MBQLArrayClause(mbql, index, query) { + var _this; + + _classCallCheck(this, MBQLArrayClause); + + _this = _super.call.apply(_super, [this].concat(_toConsumableArray(mbql))); + + _private(_assertThisInitialized(_this), "_index", index); + + _private(_assertThisInitialized(_this), "_query", query); + + return _this; + } // There is a mismatch between the constructor args for `MBQLArrayClause` and `Array` + // so we need to reconcile things in the MBQLArrayClause[Symbol.species] constructor function + // See https://stackoverflow.com/questions/54522949 + + + _createClass(MBQLArrayClause, [{ + key: "set", + value: function set(mbql) { + return new this.constructor(mbql, this._index, this._query); + } + }, { + key: "replace", + value: function replace(replacement) { + throw new Error("Abstract method `replace` not implemented"); + } + /** + * returns the parent query object + */ + + }, { + key: "query", + value: function query() { + return this._query; + } + }, { + key: "setQuery", + value: function setQuery(query) { + return new this.constructor(this, this._index, query); + } + }, { + key: "index", + value: function index() { + return this._index; + } + /** + * replaces the previous clause with this one and propagates an update, recursively + */ + + }, { + key: "update", + value: function update() { + var _this$replace; + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + return (_this$replace = this.replace(this)).update.apply(_this$replace, [undefined].concat(args)); + } + }, { + key: "parent", + value: function parent() { + return this.replace(this); + } + /** + * return the Metadata instance from the linked Query + */ + + }, { + key: "metadata", + value: function metadata() { + return this._query.metadata(); + } + }, { + key: "raw", + value: function raw() { + return _toConsumableArray(this); + } + }], [{ + key: Symbol.species, + get: function get() { + return Object.assign(function () { + for (var _len2 = arguments.length, items = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + items[_key2] = arguments[_key2]; + } + + return new MBQLArrayClause(_construct(Array, items), this._index, this._query); + }, MBQLArrayClause); + } + }]); + + return MBQLArrayClause; +}( /*#__PURE__*/_wrapNativeSuper(Array)); + + +var MBQLObjectClause = /*#__PURE__*/function () { + function MBQLObjectClause(mbql, index, query) { + _classCallCheck(this, MBQLObjectClause); + + Object.assign(this, mbql); + + _private(this, "_index", index); + + _private(this, "_query", query); + } + + _createClass(MBQLObjectClause, [{ + key: "set", + value: function set(mbql) { + return new this.constructor(mbql, this._index, this._query); + } + }, { + key: "replace", + value: function replace(replacement) { + throw new Error("Abstract method `replace` not implemented"); + } + /** + * returns the parent query object + */ + + }, { + key: "query", + value: function query() { + return this._query; + } + }, { + key: "setQuery", + value: function setQuery(query) { + return new this.constructor(this, this._index, query); + } + }, { + key: "index", + value: function index() { + return this._index; + } + /** + * replaces the previous clause with this one and propagates an update, recursively + */ + + }, { + key: "update", + value: function update() { + var _this$replace2; + + for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { + args[_key3] = arguments[_key3]; + } + + return (_this$replace2 = this.replace(this)).update.apply(_this$replace2, [undefined].concat(args)); + } + }, { + key: "parent", + value: function parent() { + return this.replace(this); + } + /** + * return the Metadata instance from the linked Query + */ + + }, { + key: "metadata", + value: function metadata() { + return this._query.metadata(); + } + }, { + key: "raw", + value: function raw() { + var entriesWithDefinedValue = Object.entries(this).filter(function (entry) { + var _entry = _slicedToArray(entry, 2), + value = _entry[1]; + + return value !== undefined; + }); + return Object.fromEntries(entriesWithDefinedValue); + } + }]); + + return MBQLObjectClause; +}(); + +function _private(object, key, value) { + // this prevents properties from being serialized + Object.defineProperty(object, key, { + value: value, + enumerable: false + }); +} + +/***/ }), + +/***/ "../metabase-lib/lib/queries/structured/OrderBy.ts": +/*!*********************************************************!*\ + !*** ../metabase-lib/lib/queries/structured/OrderBy.ts ***! + \*********************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* binding */ OrderBy; } +/* harmony export */ }); +/* harmony import */ var _MBQLClause__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./MBQLClause */ "../metabase-lib/lib/queries/structured/MBQLClause.ts"); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-nocheck + + +var OrderBy = /*#__PURE__*/function (_MBQLClause) { + _inherits(OrderBy, _MBQLClause); + + var _super = _createSuper(OrderBy); + + function OrderBy() { + _classCallCheck(this, OrderBy); + + return _super.apply(this, arguments); + } + + _createClass(OrderBy, [{ + key: "replace", + value: + /** + * Replaces the order-by clause in the parent query and returns the new StructuredQuery + * or replaces itself in the parent query if no {orderBy} argument is provided. + */ + function replace(orderBy) { + if (orderBy != null) { + return this._query.updateSort(this._index, orderBy); + } else { + return this._query.updateSort(this._index, this); + } + } + /** + * Adds itself to the parent query and returns the new StructuredQuery + */ + + }, { + key: "add", + value: function add() { + return this._query.addSort(this); + } + /** + * Removes the order-by in the parent query and returns the new StructuredQuery + */ + + }, { + key: "remove", + value: function remove() { + return this._query.removeSort(this._index); + } + /** + * Returns the display name for the order-by + */ + + }, { + key: "displayName", + value: function displayName() { + var dimension = this.dimension(); + return dimension && dimension.render(); + } + /** + * Predicate function to test if a given order-by clause is valid + */ + + }, { + key: "isValid", + value: function isValid() { + var query = this.query(); + return !query || query.sortOptions(this).hasDimension(this.dimension()); + } + /** + * Returns the order-by's Dimension + */ + + }, { + key: "dimension", + value: function dimension() { + return this._query.parseFieldReference(this[1]); + } + /** + * Returns the order-by's Field + */ + + }, { + key: "field", + value: function field() { + return this.dimension().field(); + } + }]); + + return OrderBy; +}(_MBQLClause__WEBPACK_IMPORTED_MODULE_0__.default); + + + +/***/ }), + +/***/ "../metabase-lib/lib/utils.ts": +/*!************************************!*\ + !*** ../metabase-lib/lib/utils.ts ***! + \************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "nyi": function() { return /* binding */ nyi; }, +/* harmony export */ "memoize": function() { return /* binding */ memoize; }, +/* harmony export */ "sortObject": function() { return /* binding */ sortObject; }, +/* harmony export */ "createLookupByProperty": function() { return /* binding */ createLookupByProperty; } +/* harmony export */ }); +/* provided dependency */ var console = __webpack_require__(/*! console-browserify */ "../../../node_modules/console-browserify/index.js"); +function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } + +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } + +function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } + +function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } + +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-nocheck +function nyi(target, key, descriptor) { + var method = descriptor.value; + + descriptor.value = function () { + console.warn("Method not yet implemented: " + target.constructor.name + "::" + key); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + return method.apply(this, args); + }; + + return descriptor; +} + +function getWithFallback(map, key, fallback) { + if (map.has(key)) { + return map.get(key); + } else { + var value = fallback(); + map.set(key, value); + return value; + } +} + +var memoized = new WeakMap(); +function memoize(target, name, descriptor) { + var method = target[name]; + + descriptor.value = function () { + var _this = this; + + for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } + + var path = [this, method, args.length].concat(args); + var last = path.pop(); + var map = path.reduce(function (map, key) { + return getWithFallback(map, key, createMap); + }, memoized); + return getWithFallback(map, last, function () { + return method.apply(_this, args); + }); + }; +} + +var createMap = function createMap() { + return new Map(); +}; // `sortObject`` copies objects for deterministic serialization. +// Objects that have equal keys and values don't necessarily serialize to the +// same string. JSON.strinify prints properties in inserted order. This function +// sorts keys before adding them to the duplicated object to ensure consistent +// serialization. + + +function sortObject(obj) { + if (obj === null || _typeof(obj) !== "object") { + return obj; + } + + if (Array.isArray(obj)) { + return obj.map(sortObject); + } + + var sortedKeyValues = Object.entries(obj).sort(function (_ref, _ref2) { + var _ref3 = _slicedToArray(_ref, 1), + keyA = _ref3[0]; + + var _ref4 = _slicedToArray(_ref2, 1), + keyB = _ref4[0]; + + return keyA.localeCompare(keyB); + }); + var o = {}; + + var _iterator = _createForOfIteratorHelper(sortedKeyValues), + _step; + + try { + for (_iterator.s(); !(_step = _iterator.n()).done;) { + var _step$value = _slicedToArray(_step.value, 2), + k = _step$value[0], + v = _step$value[1]; + + o[k] = sortObject(v); + } + } catch (err) { + _iterator.e(err); + } finally { + _iterator.f(); + } + + return o; +} +function createLookupByProperty(items, property) { + var lookup = {}; + + var _iterator2 = _createForOfIteratorHelper(items), + _step2; + + try { + for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { + var item = _step2.value; + lookup[item[property]] = item; + } + } catch (err) { + _iterator2.e(err); + } finally { + _iterator2.f(); + } + + return lookup; +} + +/***/ }), + +/***/ "./admin/databases/components/widgets/CacheFieldValuesScheduleWidget.jsx": +/*!*******************************************************************************!*\ + !*** ./admin/databases/components/widgets/CacheFieldValuesScheduleWidget.jsx ***! + \*******************************************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* binding */ CacheFieldValuesScheduleWidget; }, +/* harmony export */ "SyncOption": function() { return /* binding */ SyncOption; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! underscore */ "../../../node_modules/underscore/modules/index-all.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_2__); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! classnames */ "../../../node_modules/classnames/index.js"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_3__); +/* harmony import */ var metabase_lib_colors__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! metabase/lib/colors */ "./lib/colors.ts"); +/* harmony import */ var metabase_components_SchedulePicker__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! metabase/components/SchedulePicker */ "./components/SchedulePicker.jsx"); +var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5; + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + +/* eslint-disable react/prop-types */ + + + + + + +function CacheFieldValuesScheduleWidget(_ref) { + var field = _ref.field, + values = _ref.values, + onChangeField = _ref.onChangeField; + + var setIsFullSyncIsOnDemand = function setIsFullSyncIsOnDemand(isFullSync, isOnDemand) { + onChangeField("is_full_sync", isFullSync); + onChangeField("is_on_demand", isOnDemand); + }; + + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("ol", { + className: "bordered shadowed mt3" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("li", { + className: "border-bottom" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(SyncOption, { + selected: values.is_full_sync, + name: (0,ttag__WEBPACK_IMPORTED_MODULE_2__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["Regularly, on a schedule"]))), + select: function select() { + return setIsFullSyncIsOnDemand(true, false); + } + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "flex align-center" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_SchedulePicker__WEBPACK_IMPORTED_MODULE_5__.default, { + schedule: !underscore__WEBPACK_IMPORTED_MODULE_1__.default.isString(field.value) ? field.value : { + schedule_day: "mon", + schedule_frame: null, + schedule_hour: 0, + schedule_type: "daily" + }, + scheduleOptions: ["daily", "weekly", "monthly"], + onScheduleChange: field.onChange, + textBeforeInterval: (0,ttag__WEBPACK_IMPORTED_MODULE_2__.t)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["Scan"]))) + })))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("li", { + className: "border-bottom pr2" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(SyncOption, { + selected: !values.is_full_sync && values.is_on_demand, + name: (0,ttag__WEBPACK_IMPORTED_MODULE_2__.t)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["Only when adding a new filter widget"]))), + select: function select() { + return setIsFullSyncIsOnDemand(false, true); + } + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("p", { + className: "text-paragraph text-measure" + }, (0,ttag__WEBPACK_IMPORTED_MODULE_2__.t)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["When a user adds a new filter to a dashboard or a SQL question, Metabase will\n scan the field(s) mapped to that filter in order to show the list of selectable values."])))))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("li", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(SyncOption, { + selected: !values.is_full_sync && !values.is_on_demand, + name: (0,ttag__WEBPACK_IMPORTED_MODULE_2__.t)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["Never, I'll do this manually if I need to"]))), + select: function select() { + return setIsFullSyncIsOnDemand(false, false); + } + }))); +} +var SyncOption = function SyncOption(_ref2) { + var selected = _ref2.selected, + name = _ref2.name, + children = _ref2.children, + select = _ref2.select; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: classnames__WEBPACK_IMPORTED_MODULE_3___default()("py3 relative", { + "cursor-pointer": !selected + }), + onClick: function onClick() { + return select(name.toLowerCase()); + } + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: classnames__WEBPACK_IMPORTED_MODULE_3___default()("circle ml2 flex align-center justify-center absolute"), + style: { + width: 18, + height: 18, + borderWidth: 2, + borderColor: selected ? (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_4__.color)("brand") : (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_4__.color)("text-light"), + borderStyle: "solid" + } + }, selected && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "circle", + style: { + width: 8, + height: 8, + backgroundColor: selected ? (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_4__.color)("brand") : (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_4__.color)("text-light") + } + })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "ml4 pl2" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: classnames__WEBPACK_IMPORTED_MODULE_3___default()({ + "text-brand": selected + }) + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("h3", null, name)), selected && children && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "mt2" + }, children))); +}; + +/***/ }), + +/***/ "./admin/databases/components/widgets/EngineWidget/EngineWidget.jsx": +/*!**************************************************************************!*\ + !*** ./admin/databases/components/widgets/EngineWidget/EngineWidget.jsx ***! + \**************************************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prop-types */ "../../../node_modules/prop-types/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_2__); +/* harmony import */ var metabase_lib_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/lib/engine */ "./lib/engine.js"); +/* harmony import */ var metabase_lib_settings__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! metabase/lib/settings */ "./lib/settings.ts"); +/* harmony import */ var metabase_components_TextInput__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! metabase/components/TextInput */ "./components/TextInput/index.js"); +/* harmony import */ var metabase_components_ExternalLink__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! metabase/components/ExternalLink */ "./components/ExternalLink.tsx"); +/* harmony import */ var _EngineWidget_styled__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./EngineWidget.styled */ "./admin/databases/components/widgets/EngineWidget/EngineWidget.styled.jsx"); +var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7; + +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } + +function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } + +function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + + + + + + + + + +var DEFAULT_OPTIONS_COUNT = 6; + +var EngineWidget = function EngineWidget(_ref) { + var field = _ref.field, + options = _ref.options, + isHosted = _ref.isHosted; + + if (field.value) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(EngineInfo, { + field: field, + options: options + }); + } else { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(EngineSearch, { + field: field, + options: options, + isHosted: isHosted + }); + } +}; + +EngineWidget.propTypes = { + field: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().object.isRequired), + options: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().array.isRequired), + isHosted: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool) +}; + +var EngineInfo = function EngineInfo(_ref2) { + var field = _ref2.field, + options = _ref2.options; + var option = options.find(function (option) { + return option.value === field.value; + }); + var handleClick = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function () { + field.onChange(undefined); + }, [field]); + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_EngineWidget_styled__WEBPACK_IMPORTED_MODULE_7__.EngineInfoRoot, null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_EngineWidget_styled__WEBPACK_IMPORTED_MODULE_7__.EngineInfoTitle, null, option ? option.name : field.value), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_EngineWidget_styled__WEBPACK_IMPORTED_MODULE_7__.EngineInfoIcon, { + name: "close", + size: 18, + "aria-label": (0,ttag__WEBPACK_IMPORTED_MODULE_2__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["Remove database"]))), + onClick: handleClick + })); +}; + +EngineInfo.propTypes = { + field: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().object.isRequired), + options: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().array.isRequired) +}; + +var EngineSearch = function EngineSearch(_ref3) { + var field = _ref3.field, + options = _ref3.options, + isHosted = _ref3.isHosted; + + var _useState = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(""), + _useState2 = _slicedToArray(_useState, 2), + searchText = _useState2[0], + setSearchText = _useState2[1]; + + var _useState3 = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false), + _useState4 = _slicedToArray(_useState3, 2), + isExpanded = _useState4[0], + setIsExpanded = _useState4[1]; + + var isSearching = searchText.length > 0; + var hasMoreOptions = options.length > DEFAULT_OPTIONS_COUNT; + var sortedOptions = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(function () { + return getSortedOptions(options); + }, [options]); + var visibleOptions = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(function () { + return getVisibleOptions(sortedOptions, isExpanded, isSearching, searchText); + }, [sortedOptions, isExpanded, isSearching, searchText]); + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_EngineWidget_styled__WEBPACK_IMPORTED_MODULE_7__.EngineSearchRoot, null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_TextInput__WEBPACK_IMPORTED_MODULE_5__.default, { + value: searchText, + placeholder: (0,ttag__WEBPACK_IMPORTED_MODULE_2__.t)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["Search for a database\u2026"]))), + onChange: setSearchText + }), visibleOptions.length ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(EngineList, { + field: field, + options: visibleOptions + }) : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(EngineEmptyState, { + isHosted: isHosted + }), !isSearching && hasMoreOptions && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(EngineToggle, { + isExpanded: isExpanded, + onExpandedChange: setIsExpanded + })); +}; + +EngineSearch.propTypes = { + field: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().object.isRequired), + options: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().array.isRequired), + isHosted: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool) +}; + +var EngineList = function EngineList(_ref4) { + var field = _ref4.field, + options = _ref4.options; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_EngineWidget_styled__WEBPACK_IMPORTED_MODULE_7__.EngineListRoot, null, options.map(function (option) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(EngineCard, { + key: option.value, + field: field, + option: option + }); + })); +}; + +EngineList.propTypes = { + field: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().object), + options: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().array) +}; + +var EngineCard = function EngineCard(_ref5) { + var field = _ref5.field, + option = _ref5.option; + var logo = (0,metabase_lib_engine__WEBPACK_IMPORTED_MODULE_3__.getEngineLogo)(option.value); + var handleClick = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function () { + field.onChange(option.value); + }, [field, option]); + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_EngineWidget_styled__WEBPACK_IMPORTED_MODULE_7__.EngineCardRoot, { + key: option.value, + onClick: handleClick + }, logo ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_EngineWidget_styled__WEBPACK_IMPORTED_MODULE_7__.EngineCardImage, { + src: logo + }) : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_EngineWidget_styled__WEBPACK_IMPORTED_MODULE_7__.EngineCardIcon, { + name: "database" + }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_EngineWidget_styled__WEBPACK_IMPORTED_MODULE_7__.EngineCardTitle, null, option.name)); +}; + +EngineCard.propTypes = { + field: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().object), + option: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().object) +}; + +var EngineEmptyState = function EngineEmptyState(_ref6) { + var isHosted = _ref6.isHosted; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_EngineWidget_styled__WEBPACK_IMPORTED_MODULE_7__.EngineEmptyStateRoot, null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_EngineWidget_styled__WEBPACK_IMPORTED_MODULE_7__.EngineEmptyIcon, { + name: "search", + size: 32 + }), isHosted ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_EngineWidget_styled__WEBPACK_IMPORTED_MODULE_7__.EngineEmptyText, null, (0,ttag__WEBPACK_IMPORTED_MODULE_2__.t)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["Didn\u2019t find anything"])))) : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_EngineWidget_styled__WEBPACK_IMPORTED_MODULE_7__.EngineEmptyText, null, (0,ttag__WEBPACK_IMPORTED_MODULE_2__.jt)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["Don\u2019t see your database? Check out our ", " page to see if it\u2019s available for self-hosting."])), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_ExternalLink__WEBPACK_IMPORTED_MODULE_6__.default, { + href: metabase_lib_settings__WEBPACK_IMPORTED_MODULE_4__.default.docsUrl("developers-guide-drivers") + }, (0,ttag__WEBPACK_IMPORTED_MODULE_2__.t)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["Community Drivers"]))))))); +}; + +EngineEmptyState.propTypes = { + isHosted: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool) +}; + +var EngineToggle = function EngineToggle(_ref7) { + var isExpanded = _ref7.isExpanded, + onExpandedChange = _ref7.onExpandedChange; + var handleClick = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function () { + onExpandedChange(!isExpanded); + }, [isExpanded, onExpandedChange]); + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_EngineWidget_styled__WEBPACK_IMPORTED_MODULE_7__.EngineExpandButton, { + primary: true, + iconRight: isExpanded ? "chevronup" : "chevrondown", + onClick: handleClick + }, isExpanded ? (0,ttag__WEBPACK_IMPORTED_MODULE_2__.t)(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["Show less options"]))) : (0,ttag__WEBPACK_IMPORTED_MODULE_2__.t)(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["Show more options"])))); +}; + +EngineToggle.propTypes = { + isExpanded: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), + onExpandedChange: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func) +}; + +var getSortedOptions = function getSortedOptions(options) { + return options.sort(function (a, b) { + if (a.index >= 0 && b.index >= 0) { + return a.index - b.index; + } else if (a.index >= 0) { + return -1; + } else if (b.index >= 0) { + return 1; + } else { + return a.name.localeCompare(b.name); + } + }); +}; + +var getVisibleOptions = function getVisibleOptions(options, isExpanded, isSearching, searchText) { + if (isSearching) { + return options.filter(function (e) { + return includesIgnoreCase(e.name, searchText); + }); + } else if (isExpanded) { + return options; + } else { + return options.slice(0, DEFAULT_OPTIONS_COUNT); + } +}; + +var includesIgnoreCase = function includesIgnoreCase(sourceText, searchText) { + return sourceText.toLowerCase().includes(searchText.toLowerCase()); +}; + +/* harmony default export */ __webpack_exports__["default"] = (EngineWidget); + +/***/ }), + +/***/ "./admin/databases/components/widgets/EngineWidget/EngineWidget.styled.jsx": +/*!*********************************************************************************!*\ + !*** ./admin/databases/components/widgets/EngineWidget/EngineWidget.styled.jsx ***! + \*********************************************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "EngineSearchRoot": function() { return /* binding */ EngineSearchRoot; }, +/* harmony export */ "EngineListRoot": function() { return /* binding */ EngineListRoot; }, +/* harmony export */ "EngineCardRoot": function() { return /* binding */ EngineCardRoot; }, +/* harmony export */ "EngineCardTitle": function() { return /* binding */ EngineCardTitle; }, +/* harmony export */ "EngineCardIcon": function() { return /* binding */ EngineCardIcon; }, +/* harmony export */ "EngineCardImage": function() { return /* binding */ EngineCardImage; }, +/* harmony export */ "EngineEmptyStateRoot": function() { return /* binding */ EngineEmptyStateRoot; }, +/* harmony export */ "EngineEmptyIcon": function() { return /* binding */ EngineEmptyIcon; }, +/* harmony export */ "EngineEmptyText": function() { return /* binding */ EngineEmptyText; }, +/* harmony export */ "EngineExpandButton": function() { return /* binding */ EngineExpandButton; }, +/* harmony export */ "EngineInfoRoot": function() { return /* binding */ EngineInfoRoot; }, +/* harmony export */ "EngineInfoTitle": function() { return /* binding */ EngineInfoTitle; }, +/* harmony export */ "EngineInfoIcon": function() { return /* binding */ EngineInfoIcon; } +/* harmony export */ }); +/* harmony import */ var styled_components__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! styled-components */ "../../../node_modules/styled-components/dist/styled-components.browser.es.js"); +/* harmony import */ var metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/lib/colors */ "./lib/colors.ts"); +/* harmony import */ var metabase_styled_components_theme__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/styled-components/theme */ "./styled-components/theme/index.ts"); +/* harmony import */ var metabase_components_Icon__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/components/Icon */ "./components/Icon.tsx"); +/* harmony import */ var metabase_components_IconButtonWrapper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! metabase/components/IconButtonWrapper */ "./components/IconButtonWrapper.jsx"); +/* harmony import */ var metabase_components_Button__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! metabase/components/Button */ "./components/Button.tsx"); + + + + + + +var EngineSearchRoot = styled_components__WEBPACK_IMPORTED_MODULE_0__.default.div.withConfig({ + displayName: "EngineWidgetstyled__EngineSearchRoot", + componentId: "sc-1eavdkf-0" +})(["display:block;"]); +var EngineListRoot = styled_components__WEBPACK_IMPORTED_MODULE_0__.default.div.withConfig({ + displayName: "EngineWidgetstyled__EngineListRoot", + componentId: "sc-1eavdkf-1" +})(["display:grid;grid-template-columns:1fr;gap:1.5rem;margin:1.5rem 0;", "{grid-template-columns:repeat(3,1fr);}"], metabase_styled_components_theme__WEBPACK_IMPORTED_MODULE_2__.breakpointMinSmall); +var EngineCardRoot = (0,styled_components__WEBPACK_IMPORTED_MODULE_0__.default)(metabase_components_IconButtonWrapper__WEBPACK_IMPORTED_MODULE_4__.default).withConfig({ + displayName: "EngineWidgetstyled__EngineCardRoot", + componentId: "sc-1eavdkf-2" +})(["flex:1 1 auto;flex-direction:column;height:5.375rem;padding:1rem;border:1px solid ", ";background-color:", ";&:hover{border-color:", ";background-color:", ";}"], (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.color)("bg-medium"), (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.color)("white"), (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.color)("brand"), (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.lighten)("brand", 0.6)); +var EngineCardTitle = styled_components__WEBPACK_IMPORTED_MODULE_0__.default.div.withConfig({ + displayName: "EngineWidgetstyled__EngineCardTitle", + componentId: "sc-1eavdkf-3" +})(["color:", ";margin-top:0.5rem;"], (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.color)("text-dark")); +var EngineCardIcon = (0,styled_components__WEBPACK_IMPORTED_MODULE_0__.default)(metabase_components_Icon__WEBPACK_IMPORTED_MODULE_3__.default).withConfig({ + displayName: "EngineWidgetstyled__EngineCardIcon", + componentId: "sc-1eavdkf-4" +})(["color:", ";width:1rem;height:1rem;padding:0.5rem;"], (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.color)("text-medium")); +var EngineCardImage = styled_components__WEBPACK_IMPORTED_MODULE_0__.default.img.withConfig({ + displayName: "EngineWidgetstyled__EngineCardImage", + componentId: "sc-1eavdkf-5" +})(["width:2rem;height:2rem;"]); +var EngineEmptyStateRoot = styled_components__WEBPACK_IMPORTED_MODULE_0__.default.div.withConfig({ + displayName: "EngineWidgetstyled__EngineEmptyStateRoot", + componentId: "sc-1eavdkf-6" +})(["display:flex;flex-direction:column;justify-content:center;align-items:center;min-height:12.25rem;margin:1.5rem 0;"]); +var EngineEmptyIcon = (0,styled_components__WEBPACK_IMPORTED_MODULE_0__.default)(metabase_components_Icon__WEBPACK_IMPORTED_MODULE_3__.default).withConfig({ + displayName: "EngineWidgetstyled__EngineEmptyIcon", + componentId: "sc-1eavdkf-7" +})(["color:", ";margin-bottom:0.5rem;"], (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.color)("text-medium")); +var EngineEmptyText = styled_components__WEBPACK_IMPORTED_MODULE_0__.default.div.withConfig({ + displayName: "EngineWidgetstyled__EngineEmptyText", + componentId: "sc-1eavdkf-8" +})(["color:", ";font-weight:bold;line-height:1.5rem;max-width:26rem;text-align:center;"], (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.color)("text-light")); +var EngineExpandButton = (0,styled_components__WEBPACK_IMPORTED_MODULE_0__.default)(metabase_components_Button__WEBPACK_IMPORTED_MODULE_5__.default).withConfig({ + displayName: "EngineWidgetstyled__EngineExpandButton", + componentId: "sc-1eavdkf-9" +})(["width:100%;"]); +var EngineInfoRoot = styled_components__WEBPACK_IMPORTED_MODULE_0__.default.div.withConfig({ + displayName: "EngineWidgetstyled__EngineInfoRoot", + componentId: "sc-1eavdkf-10" +})(["display:flex;align-items:center;color:", ";padding:0.75rem;border-radius:0.5rem;border:1px solid ", ";background-color:", ";"], (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.color)("white"), (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.color)("brand"), (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.color)("brand")); +var EngineInfoTitle = styled_components__WEBPACK_IMPORTED_MODULE_0__.default.div.withConfig({ + displayName: "EngineWidgetstyled__EngineInfoTitle", + componentId: "sc-1eavdkf-11" +})(["flex:1 0 auto;font-size:1rem;font-weight:bold;"]); +var EngineInfoIcon = (0,styled_components__WEBPACK_IMPORTED_MODULE_0__.default)(metabase_components_Icon__WEBPACK_IMPORTED_MODULE_3__.default).withConfig({ + displayName: "EngineWidgetstyled__EngineInfoIcon", + componentId: "sc-1eavdkf-12" +})(["cursor:pointer;"]); + +/***/ }), + +/***/ "./admin/databases/components/widgets/EngineWidget/index.js": +/*!******************************************************************!*\ + !*** ./admin/databases/components/widgets/EngineWidget/index.js ***! + \******************************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* reexport safe */ _EngineWidget__WEBPACK_IMPORTED_MODULE_0__.default; } +/* harmony export */ }); +/* harmony import */ var _EngineWidget__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./EngineWidget */ "./admin/databases/components/widgets/EngineWidget/EngineWidget.jsx"); + + +/***/ }), + +/***/ "./admin/databases/components/widgets/MetadataSyncScheduleWidget.jsx": +/*!***************************************************************************!*\ + !*** ./admin/databases/components/widgets/MetadataSyncScheduleWidget.jsx ***! + \***************************************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* binding */ MetadataSyncScheduleWidget; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! underscore */ "../../../node_modules/underscore/modules/index-all.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_2__); +/* harmony import */ var metabase_components_SchedulePicker__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/components/SchedulePicker */ "./components/SchedulePicker.jsx"); +var _templateObject; + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + +/* eslint-disable react/prop-types */ + + + + +function MetadataSyncScheduleWidget(_ref) { + var field = _ref.field; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_SchedulePicker__WEBPACK_IMPORTED_MODULE_3__.default, { + schedule: !underscore__WEBPACK_IMPORTED_MODULE_1__.default.isString(field.value) ? field.value : { + schedule_day: "mon", + schedule_frame: null, + schedule_hour: 0, + schedule_type: "daily" + }, + scheduleOptions: ["hourly", "daily"], + onScheduleChange: field.onChange, + textBeforeInterval: (0,ttag__WEBPACK_IMPORTED_MODULE_2__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["Scan"]))), + minutesOnHourPicker: true + }); +} + +/***/ }), + +/***/ "./admin/people/components/GroupSelect.jsx": +/*!*************************************************!*\ + !*** ./admin/people/components/GroupSelect.jsx ***! + \*************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "GroupSelect": function() { return /* binding */ GroupSelect; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var metabase_components_Icon__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/components/Icon */ "./components/Icon.tsx"); +/* harmony import */ var metabase_components_Select__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/components/Select */ "./components/Select.jsx"); +/* harmony import */ var metabase_components_PopoverWithTrigger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! metabase/components/PopoverWithTrigger */ "./components/PopoverWithTrigger.jsx"); +/* harmony import */ var _GroupSummary__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./GroupSummary */ "./admin/people/components/GroupSummary.jsx"); +/* harmony import */ var metabase_lib_groups__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! metabase/lib/groups */ "./lib/groups.js"); +var _templateObject, _templateObject2; + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + +/* eslint-disable react/prop-types */ + + + + + + + +var GroupSelect = function GroupSelect(_ref) { + var groups = _ref.groups, + _ref$selectedGroupIds = _ref.selectedGroupIds, + selectedGroupIds = _ref$selectedGroupIds === void 0 ? new Set() : _ref$selectedGroupIds, + onGroupChange = _ref.onGroupChange, + _ref$isCurrentUser = _ref.isCurrentUser, + isCurrentUser = _ref$isCurrentUser === void 0 ? false : _ref$isCurrentUser, + _ref$emptyListMessage = _ref.emptyListMessage, + emptyListMessage = _ref$emptyListMessage === void 0 ? (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["No groups"]))) : _ref$emptyListMessage; + var triggerElement = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "flex align-center" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { + className: "mr1 text-medium" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_GroupSummary__WEBPACK_IMPORTED_MODULE_5__.default, { + groups: groups, + selectedGroupIds: selectedGroupIds + })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Icon__WEBPACK_IMPORTED_MODULE_2__.default, { + className: "text-light", + name: "chevrondown", + size: 10 + })); + + if (groups.length === 0) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_PopoverWithTrigger__WEBPACK_IMPORTED_MODULE_4__.default, { + triggerElement: triggerElement + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { + className: "p1" + }, emptyListMessage)); + } + + var other = groups.filter(function (g) { + return !(0,metabase_lib_groups__WEBPACK_IMPORTED_MODULE_6__.isAdminGroup)(g) && !(0,metabase_lib_groups__WEBPACK_IMPORTED_MODULE_6__.isDefaultGroup)(g); + }); + var adminGroup = groups.find(metabase_lib_groups__WEBPACK_IMPORTED_MODULE_6__.isAdminGroup); + var defaultGroup = groups.find(metabase_lib_groups__WEBPACK_IMPORTED_MODULE_6__.isDefaultGroup); + var topGroups = [defaultGroup, adminGroup].filter(function (g) { + return g != null; + }); + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Select__WEBPACK_IMPORTED_MODULE_3__.default, { + triggerElement: triggerElement, + onChange: function onChange(_ref2) { + var value = _ref2.target.value; + groups.filter( // find the differing groups between the new `value` on previous `selectedGroupIds` + function (group) { + return selectedGroupIds.includes(group.id) ^ value.includes(group.id); + }).forEach(function (group) { + return onGroupChange(group, value.includes(group.id)); + }); + }, + optionDisabledFn: function optionDisabledFn(group) { + return (0,metabase_lib_groups__WEBPACK_IMPORTED_MODULE_6__.isAdminGroup)(group) && isCurrentUser || !(0,metabase_lib_groups__WEBPACK_IMPORTED_MODULE_6__.canEditMembership)(group); + }, + optionValueFn: function optionValueFn(group) { + return group.id; + }, + optionNameFn: metabase_lib_groups__WEBPACK_IMPORTED_MODULE_6__.getGroupNameLocalized, + optionClassNameFn: metabase_lib_groups__WEBPACK_IMPORTED_MODULE_6__.getGroupColor, + value: selectedGroupIds, + sections: topGroups.length > 0 ? [{ + items: topGroups + }, { + items: other, + name: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["Groups"]))) + }] : [{ + items: other + }], + multiple: true + }); +}; +/* harmony default export */ __webpack_exports__["default"] = (GroupSelect); + +/***/ }), + +/***/ "./admin/people/components/GroupSummary.jsx": +/*!**************************************************!*\ + !*** ./admin/people/components/GroupSummary.jsx ***! + \**************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var metabase_lib_groups__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/lib/groups */ "./lib/groups.js"); +var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5; + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + +/* eslint-disable react/prop-types */ + + + + +var GroupSummary = function GroupSummary(_ref) { + var groups = _ref.groups, + selectedGroupIds = _ref.selectedGroupIds; + var adminGroup = groups.find(metabase_lib_groups__WEBPACK_IMPORTED_MODULE_2__.isAdminGroup); + var otherGroups = groups.filter(function (g) { + return selectedGroupIds.includes(g.id) && !(0,metabase_lib_groups__WEBPACK_IMPORTED_MODULE_2__.isAdminGroup)(g) && !(0,metabase_lib_groups__WEBPACK_IMPORTED_MODULE_2__.isDefaultGroup)(g); + }); + + if (adminGroup && selectedGroupIds.includes(adminGroup.id)) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { + className: "text-purple" + }, (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["Admin"])))), otherGroups.length > 0 && " " + (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["and"]))) + " ", otherGroups.length > 0 && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { + className: "text-brand" + }, function (n) { + return (0,ttag__WEBPACK_IMPORTED_MODULE_1__.ngettext)((0,ttag__WEBPACK_IMPORTED_MODULE_1__.msgid)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["", " other group"])), n), "".concat(n, " other groups"), n); + }(otherGroups.length))); + } else if (otherGroups.length === 1) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { + className: "text-brand" + }, otherGroups[0].name); + } else if (otherGroups.length > 1) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { + className: "text-brand" + }, function (n) { + return (0,ttag__WEBPACK_IMPORTED_MODULE_1__.ngettext)((0,ttag__WEBPACK_IMPORTED_MODULE_1__.msgid)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["", " other group"])), n), "".concat(n, " other groups"), n); + }(otherGroups.length)); + } else { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", null, (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["Default"])))); + } +}; + +/* harmony default export */ __webpack_exports__["default"] = (GroupSummary); + +/***/ }), + +/***/ "./admin/people/people.js": +/*!********************************!*\ + !*** ./admin/people/people.js ***! + \********************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "LOAD_MEMBERSHIPS": function() { return /* binding */ LOAD_MEMBERSHIPS; }, +/* harmony export */ "CREATE_MEMBERSHIP": function() { return /* binding */ CREATE_MEMBERSHIP; }, +/* harmony export */ "DELETE_MEMBERSHIP": function() { return /* binding */ DELETE_MEMBERSHIP; }, +/* harmony export */ "CLEAR_TEMPORARY_PASSWORD": function() { return /* binding */ CLEAR_TEMPORARY_PASSWORD; }, +/* harmony export */ "loadMemberships": function() { return /* binding */ loadMemberships; }, +/* harmony export */ "createMembership": function() { return /* binding */ createMembership; }, +/* harmony export */ "deleteMembership": function() { return /* binding */ deleteMembership; }, +/* harmony export */ "clearTemporaryPassword": function() { return /* binding */ clearTemporaryPassword; } +/* harmony export */ }); +/* harmony import */ var metabase_lib_redux__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! metabase/lib/redux */ "./lib/redux.js"); +/* harmony import */ var metabase_lib_analytics__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/lib/analytics */ "./lib/analytics.js"); +/* harmony import */ var metabase_services__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/services */ "./services.js"); +/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! underscore */ "../../../node_modules/underscore/modules/index-all.js"); +/* harmony import */ var icepick__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! icepick */ "../../../node_modules/icepick/icepick.min.js"); +/* harmony import */ var icepick__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(icepick__WEBPACK_IMPORTED_MODULE_4__); +/* harmony import */ var metabase_entities_users__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! metabase/entities/users */ "./entities/users.js"); +var _handleActions, _handleActions2; + +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } + +function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } + + + + + + + +var LOAD_MEMBERSHIPS = "metabase/admin/people/LOAD_MEMBERSHIPS"; +var CREATE_MEMBERSHIP = "metabase/admin/people/CREATE_MEMBERSHIP"; +var DELETE_MEMBERSHIP = "metabase/admin/people/DELETE_MEMBERSHIP"; +var CLEAR_TEMPORARY_PASSWORD = "metabase/admin/people/CLEAR_TEMPORARY_PASSWORD"; // ACTION CREATORS + +var loadMemberships = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_0__.createAction)(LOAD_MEMBERSHIPS, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + _context.t0 = underscore__WEBPACK_IMPORTED_MODULE_3__.default; + _context.next = 3; + return metabase_services__WEBPACK_IMPORTED_MODULE_2__.PermissionsApi.memberships(); + + case 3: + _context.t1 = _context.sent; + return _context.abrupt("return", _context.t0.chain.call(_context.t0, _context.t1).values().flatten().map(function (m) { + return [m.membership_id, m]; + }).object().value()); + + case 5: + case "end": + return _context.stop(); + } + } + }, _callee); +}))); +var createMembership = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_0__.createAction)(CREATE_MEMBERSHIP, /*#__PURE__*/function () { + var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(_ref2) { + var userId, groupId, groupMemberships; + return regeneratorRuntime.wrap(function _callee2$(_context2) { + while (1) { + switch (_context2.prev = _context2.next) { + case 0: + userId = _ref2.userId, groupId = _ref2.groupId; + _context2.next = 3; + return metabase_services__WEBPACK_IMPORTED_MODULE_2__.PermissionsApi.createMembership({ + user_id: userId, + group_id: groupId + }); + + case 3: + groupMemberships = _context2.sent; + metabase_lib_analytics__WEBPACK_IMPORTED_MODULE_1__.trackStructEvent("People Groups", "Membership Added"); + return _context2.abrupt("return", { + user_id: userId, + group_id: groupId, + membership_id: underscore__WEBPACK_IMPORTED_MODULE_3__.default.findWhere(groupMemberships, { + user_id: userId + }).membership_id + }); + + case 6: + case "end": + return _context2.stop(); + } + } + }, _callee2); + })); + + return function (_x) { + return _ref3.apply(this, arguments); + }; +}()); +var deleteMembership = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_0__.createAction)(DELETE_MEMBERSHIP, /*#__PURE__*/function () { + var _ref5 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(_ref4) { + var membershipId; + return regeneratorRuntime.wrap(function _callee3$(_context3) { + while (1) { + switch (_context3.prev = _context3.next) { + case 0: + membershipId = _ref4.membershipId; + _context3.next = 3; + return metabase_services__WEBPACK_IMPORTED_MODULE_2__.PermissionsApi.deleteMembership({ + id: membershipId + }); + + case 3: + metabase_lib_analytics__WEBPACK_IMPORTED_MODULE_1__.trackStructEvent("People Groups", "Membership Deleted"); + return _context3.abrupt("return", membershipId); + + case 5: + case "end": + return _context3.stop(); + } + } + }, _callee3); + })); + + return function (_x2) { + return _ref5.apply(this, arguments); + }; +}()); +var clearTemporaryPassword = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_0__.createAction)(CLEAR_TEMPORARY_PASSWORD); // REDUCERS + +var memberships = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_0__.handleActions)((_handleActions = {}, _defineProperty(_handleActions, LOAD_MEMBERSHIPS, { + next: function next(state, _ref6) { + var memberships = _ref6.payload; + return memberships; + } +}), _defineProperty(_handleActions, CREATE_MEMBERSHIP, { + next: function next(state, _ref7) { + var membership = _ref7.payload; + return (0,icepick__WEBPACK_IMPORTED_MODULE_4__.assoc)(state, membership.membership_id, membership); + } +}), _defineProperty(_handleActions, DELETE_MEMBERSHIP, { + next: function next(state, _ref8) { + var membershipId = _ref8.payload; + return (0,icepick__WEBPACK_IMPORTED_MODULE_4__.dissoc)(state, membershipId); + } +}), _handleActions), {}); +var temporaryPasswords = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_0__.handleActions)((_handleActions2 = {}, _defineProperty(_handleActions2, metabase_entities_users__WEBPACK_IMPORTED_MODULE_5__.default.actionTypes.CREATE, { + next: function next(state, _ref9) { + var payload = _ref9.payload; + return _objectSpread(_objectSpread({}, state), {}, _defineProperty({}, payload.id, payload.password)); + } +}), _defineProperty(_handleActions2, metabase_entities_users__WEBPACK_IMPORTED_MODULE_5__.default.actionTypes.PASSWORD_RESET_MANUAL, { + next: function next(state, _ref10) { + var payload = _ref10.payload; + return _objectSpread(_objectSpread({}, state), {}, _defineProperty({}, payload.id, payload.password)); + } +}), _defineProperty(_handleActions2, CLEAR_TEMPORARY_PASSWORD, { + next: function next(state, _ref11) { + var payload = _ref11.payload; + return _objectSpread(_objectSpread({}, state), {}, _defineProperty({}, payload, null)); + } +}), _handleActions2), {}); +/* harmony default export */ __webpack_exports__["default"] = ((0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_0__.combineReducers)({ + memberships: memberships, + temporaryPasswords: temporaryPasswords +})); + +/***/ }), + +/***/ "./admin/settings/components/SettingHeader/SettingHeader.jsx": +/*!*******************************************************************!*\ + !*** ./admin/settings/components/SettingHeader/SettingHeader.jsx ***! + \*******************************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var _SettingHeader_styled__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./SettingHeader.styled */ "./admin/settings/components/SettingHeader/SettingHeader.styled.jsx"); +/* eslint-disable react/prop-types */ + + + +var SettingHeader = function SettingHeader(_ref) { + var id = _ref.id, + setting = _ref.setting; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_SettingHeader_styled__WEBPACK_IMPORTED_MODULE_1__.SettingTitle, { + htmlFor: id + }, setting.display_name), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_SettingHeader_styled__WEBPACK_IMPORTED_MODULE_1__.SettingDescription, null, setting.warningMessage && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("strong", null, setting.warningMessage), " "), setting.description, setting.note && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", null, setting.note))); +}; + +/* harmony default export */ __webpack_exports__["default"] = (SettingHeader); + +/***/ }), + +/***/ "./admin/settings/components/SettingHeader/SettingHeader.styled.jsx": +/*!**************************************************************************!*\ + !*** ./admin/settings/components/SettingHeader/SettingHeader.styled.jsx ***! + \**************************************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "SettingTitle": function() { return /* binding */ SettingTitle; }, +/* harmony export */ "SettingDescription": function() { return /* binding */ SettingDescription; } +/* harmony export */ }); +/* harmony import */ var styled_components__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! styled-components */ "../../../node_modules/styled-components/dist/styled-components.browser.es.js"); +/* harmony import */ var metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/lib/colors */ "./lib/colors.ts"); +/* harmony import */ var metabase_styled_components_theme__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/styled-components/theme */ "./styled-components/theme/index.ts"); + + + +var SettingTitle = styled_components__WEBPACK_IMPORTED_MODULE_0__.default.label.withConfig({ + displayName: "SettingHeaderstyled__SettingTitle", + componentId: "sc-1hvkqbp-0" +})(["display:block;color:", ";font-weight:bold;text-transform:uppercase;"], (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.color)("text-medium")); +var SettingDescription = styled_components__WEBPACK_IMPORTED_MODULE_0__.default.div.withConfig({ + displayName: "SettingHeaderstyled__SettingDescription", + componentId: "sc-1hvkqbp-1" +})(["color:", ";margin:", " 0;max-width:38.75rem;"], (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.color)("text-medium"), (0,metabase_styled_components_theme__WEBPACK_IMPORTED_MODULE_2__.space)(1)); + +/***/ }), + +/***/ "./admin/settings/components/SettingHeader/index.js": +/*!**********************************************************!*\ + !*** ./admin/settings/components/SettingHeader/index.js ***! + \**********************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* reexport safe */ _SettingHeader__WEBPACK_IMPORTED_MODULE_0__.default; } +/* harmony export */ }); +/* harmony import */ var _SettingHeader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./SettingHeader */ "./admin/settings/components/SettingHeader/SettingHeader.jsx"); + + +/***/ }), + +/***/ "./admin/settings/components/SettingsBatchForm.jsx": +/*!*********************************************************!*\ + !*** ./admin/settings/components/SettingsBatchForm.jsx ***! + \*********************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* binding */ SettingsBatchForm; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prop-types */ "../../../node_modules/prop-types/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var react_redux__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react-redux */ "../../../node_modules/react-redux/es/index.js"); +/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! underscore */ "../../../node_modules/underscore/modules/index-all.js"); +/* harmony import */ var react_collapse__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! react-collapse */ "../../../node_modules/react-collapse/lib/index.js"); +/* harmony import */ var react_collapse__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(react_collapse__WEBPACK_IMPORTED_MODULE_4__); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_5__); +/* harmony import */ var metabase_components_Breadcrumbs__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! metabase/components/Breadcrumbs */ "./components/Breadcrumbs.jsx"); +/* harmony import */ var metabase_components_Button__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! metabase/components/Button */ "./components/Button.tsx"); +/* harmony import */ var metabase_components_DisclosureTriangle__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! metabase/components/DisclosureTriangle */ "./components/DisclosureTriangle.jsx"); +/* harmony import */ var metabase_lib_utils__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! metabase/lib/utils */ "./lib/utils.js"); +/* harmony import */ var _SettingsSetting__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./SettingsSetting */ "./admin/settings/components/SettingsSetting.jsx"); +/* harmony import */ var _settings__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../settings */ "./admin/settings/settings.js"); +/* provided dependency */ var console = __webpack_require__(/*! console-browserify */ "../../../node_modules/console-browserify/index.js"); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _dec, _class, _class2, _temp, _templateObject6; + +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } + +function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } + +function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } + +function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + +/* eslint-disable react/prop-types */ + + + + + + + + + + + + +var VALIDATIONS = { + email: { + validate: function validate(value) { + return metabase_lib_utils__WEBPACK_IMPORTED_MODULE_9__.default.isEmail(value); + }, + message: (0,ttag__WEBPACK_IMPORTED_MODULE_5__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["That's not a valid email address"]))) + }, + integer: { + validate: function validate(value) { + return !isNaN(parseInt(value)); + }, + message: (0,ttag__WEBPACK_IMPORTED_MODULE_5__.t)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["That's not a valid integer"]))) + } +}; +var SAVE_SETTINGS_BUTTONS_STATES = { + default: (0,ttag__WEBPACK_IMPORTED_MODULE_5__.t)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["Save changes"]))), + working: (0,ttag__WEBPACK_IMPORTED_MODULE_5__.t)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["Saving..."]))), + success: (0,ttag__WEBPACK_IMPORTED_MODULE_5__.t)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["Changes saved!"]))) +}; +var SettingsBatchForm = (_dec = (0,react_redux__WEBPACK_IMPORTED_MODULE_2__.connect)(null, function (dispatch, _ref2) { + var updateSettings = _ref2.updateSettings; + return { + updateSettings: updateSettings || function (settings) { + return dispatch((0,_settings__WEBPACK_IMPORTED_MODULE_11__.updateSettings)(settings)); + } + }; +}, null, { + withRef: true +} // HACK: needed so consuming components can call methods on the component :-/ +), _dec(_class = (_temp = _class2 = /*#__PURE__*/function (_Component) { + _inherits(SettingsBatchForm, _Component); + + var _super2 = _createSuper(SettingsBatchForm); + + function SettingsBatchForm(props, context) { + var _this2; + + _classCallCheck(this, SettingsBatchForm); + + _this2 = _super2.call(this, props, context); + + _defineProperty(_assertThisInitialized(_this2), "handleChangeEvent", function (key, value) { + _this2.setState(function (previousState) { + var settingsValues = _objectSpread(_objectSpread({}, previousState.formData), {}, _defineProperty({}, key, value)); // support "onChanged" + + + var setting = underscore__WEBPACK_IMPORTED_MODULE_3__.default.findWhere(_this2.props.elements, { + key: key + }); + + if (setting && setting.onChanged) { + setting.onChanged(previousState.formData[key], settingsValues[key], settingsValues, _this2.handleChangeEvent); + } + + var pristine = _this2.props.elements.every(function (_ref3) { + var key = _ref3.key, + value = _ref3.value; + return settingsValues[key] === value; + }); + + return { + pristine: pristine, + formData: settingsValues + }; + }); + }); + + _defineProperty(_assertThisInitialized(_this2), "updateSettings", function (e) { + e.preventDefault(); + var _this2$state = _this2.state, + formData = _this2$state.formData, + valid = _this2$state.valid; + + if (valid) { + _this2.setState({ + formErrors: null, + submitting: "working" + }); + + _this2.props.updateSettings(formData).then(function () { + _this2.setState({ + pristine: true, + submitting: "success" + }); // show a confirmation for 3 seconds, then return to normal + + + setTimeout(function () { + return _this2.setState({ + submitting: "default" + }); + }, 3000); + }, function (error) { + _this2.setState({ + submitting: "default", + formErrors: _this2.handleFormErrors(error) + }); + }); + } + }); + + _this2.state = { + pristine: true, + formData: {}, + submitting: "default", + valid: false, + validationErrors: {} + }; + return _this2; + } + + _createClass(SettingsBatchForm, [{ + key: "componentDidMount", + value: function componentDidMount() { + this.updateFormData(); + this.validateForm(); + } + }, { + key: "componentDidUpdate", + value: function componentDidUpdate(prevProps) { + if (this.props.elements !== prevProps.elements) { + this.updateFormData(); + } + + this.validateForm(); + } + }, { + key: "updateFormData", + value: function updateFormData() { + var formData = {}; + + var _iterator = _createForOfIteratorHelper(this.props.elements), + _step; + + try { + for (_iterator.s(); !(_step = _iterator.n()).done;) { + var element = _step.value; + formData[element.key] = element.value; + } + } catch (err) { + _iterator.e(err); + } finally { + _iterator.f(); + } + + this.setState({ + formData: formData, + pristine: true + }); + } + }, { + key: "setSubmitting", + value: function setSubmitting(submitting) { + this.setState({ + submitting: submitting + }); + } + }, { + key: "setFormErrors", + value: function setFormErrors(formErrors) { + this.setState({ + formErrors: formErrors + }); + } // return null if element passes validation, otherwise return an error message + + }, { + key: "validateElement", + value: function validateElement(validation, value, element) { + if (metabase_lib_utils__WEBPACK_IMPORTED_MODULE_9__.default.isEmpty(value)) { + return; + } + + if (typeof validation === "function") { + return validation(value); + } + + var _validation = _slicedToArray(validation, 2), + validationType = _validation[0], + validationMessage = _validation[1]; + + if (!VALIDATIONS[validationType]) { + console.warn("Unknown validation " + validationType); + } + + if (!VALIDATIONS[validationType].validate(value)) { + return validationMessage || VALIDATIONS[validationType].message; + } + } + }, { + key: "validateForm", + value: function validateForm() { + var _this$props2 = this.props, + elements = _this$props2.elements, + enabledKey = _this$props2.enabledKey; + var formData = this.state.formData; + var valid = true; + var validationErrors = {}; // Validate form only if LDAP is enabled + + if (!enabledKey || formData[enabledKey]) { + elements.forEach(function (element) { + // test for required elements + if (element.required && metabase_lib_utils__WEBPACK_IMPORTED_MODULE_9__.default.isEmpty(formData[element.key])) { + valid = false; + } + + if (element.validations) { + element.validations.forEach(function (validation) { + validationErrors[element.key] = this.validateElement(validation, formData[element.key], element); + + if (validationErrors[element.key]) { + valid = false; + } + }, this); + } + }, this); + } + + if (this.state.valid !== valid || !underscore__WEBPACK_IMPORTED_MODULE_3__.default.isEqual(this.state.validationErrors, validationErrors)) { + this.setState({ + valid: valid, + validationErrors: validationErrors + }); + } + } + }, { + key: "handleFormErrors", + value: function handleFormErrors(error) { + // parse and format + var formErrors = {}; + + if (error.data && error.data.message) { + formErrors.message = error.data.message; + } else { + formErrors.message = (0,ttag__WEBPACK_IMPORTED_MODULE_5__.t)(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["Looks like we ran into some problems"]))); + } + + if (error.data && error.data.errors) { + formErrors.elements = error.data.errors; + } + + return formErrors; + } + }, { + key: "render", + value: function render() { + var _this3 = this; + + var _this$props3 = this.props, + elements = _this$props3.elements, + settingValues = _this$props3.settingValues; + var _this$state = this.state, + formData = _this$state.formData, + formErrors = _this$state.formErrors, + submitting = _this$state.submitting, + pristine = _this$state.pristine, + valid = _this$state.valid, + validationErrors = _this$state.validationErrors; + var layout = this.props.layout || [{ + settings: elements.map(function (element) { + return element.key; + }) + }]; + + var settings = underscore__WEBPACK_IMPORTED_MODULE_3__.default.indexBy(elements, "key"); + + var getSetting = function getSetting(key) { + var element = settings[key]; + + if (!element) { + console.warn("Missing setting", element); + return null; + } // merge together data from a couple places to provide a complete view of the Element state + + + var errorMessage = formErrors && formErrors.elements ? formErrors.elements[element.key] : validationErrors[element.key]; + var value = formData[element.key] == null ? element.defaultValue : formData[element.key]; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_SettingsSetting__WEBPACK_IMPORTED_MODULE_10__.default, { + key: element.key, + setting: _objectSpread(_objectSpread({}, element), {}, { + value: value + }), + onChange: function onChange(value) { + return _this3.handleChangeEvent(element.key, value); + }, + settingValues: settingValues, + onChangeSetting: function onChangeSetting(key, value) { + return _this3.handleChangeEvent(key, value); + }, + errorMessage: errorMessage, + fireOnChange: true + }); + }; + + var disabled = !valid || submitting !== "default"; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", null, this.props.breadcrumbs && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Breadcrumbs__WEBPACK_IMPORTED_MODULE_6__.default, { + crumbs: this.props.breadcrumbs, + className: "ml2 mb3" + }), layout.map(function (section, index) { + return section.collapse ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(CollapsibleSection, { + title: section.title, + key: index + }, section.settings.map(function (key) { + return getSetting(key); + })) : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(StandardSection, { + title: section.title, + key: index + }, section.settings.map(function (key) { + return getSetting(key); + })); + }), formErrors && formErrors.message && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "m2 text-error text-bold" + }, formErrors.message), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "m2 mb4" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Button__WEBPACK_IMPORTED_MODULE_7__.default, { + mr: 1, + primary: !disabled, + success: submitting === "success", + disabled: disabled || pristine, + onClick: this.updateSettings + }, SAVE_SETTINGS_BUTTONS_STATES[submitting]), this.props.renderExtraButtons && this.props.renderExtraButtons({ + valid: valid, + submitting: submitting, + disabled: disabled, + pristine: pristine + }))); + } + }]); + + return SettingsBatchForm; +}(react__WEBPACK_IMPORTED_MODULE_0__.Component), _defineProperty(_class2, "propTypes", { + elements: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().array.isRequired), + formErrors: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().object), + updateSettings: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func.isRequired) +}), _temp)) || _class); + + +var StandardSection = function StandardSection(_ref) { + var title = _ref.title, + children = _ref.children; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", null, title && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("h2", { + className: "mx2" + }, title), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("ul", null, children)); +}; + +var CollapsibleSection = /*#__PURE__*/function (_React$Component) { + _inherits(CollapsibleSection, _React$Component); + + var _super = _createSuper(CollapsibleSection); + + function CollapsibleSection() { + var _this; + + _classCallCheck(this, CollapsibleSection); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _super.call.apply(_super, [this].concat(args)); + + _defineProperty(_assertThisInitialized(_this), "state", { + show: false + }); + + return _this; + } + + _createClass(CollapsibleSection, [{ + key: "handleToggle", + value: function handleToggle() { + this.setState(function (previousState) { + return { + show: !previousState.show + }; + }); + } + }, { + key: "render", + value: function render() { + var _this$props = this.props, + title = _this$props.title, + children = _this$props.children; + var show = this.state.show; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("section", { + className: "mb4" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "inline-block ml1 cursor-pointer text-brand-hover", + onClick: this.handleToggle.bind(this) + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "flex align-center" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_DisclosureTriangle__WEBPACK_IMPORTED_MODULE_8__.default, { + className: "mx1", + open: show + }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("h3", null, title))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement((react_collapse__WEBPACK_IMPORTED_MODULE_4___default()), { + isOpened: show, + keepCollapsedContent: true + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("ul", null, children))); + } + }]); + + return CollapsibleSection; +}(react__WEBPACK_IMPORTED_MODULE_0__.Component); + +/***/ }), + +/***/ "./admin/settings/components/SettingsGoogleForm.jsx": +/*!**********************************************************!*\ + !*** ./admin/settings/components/SettingsGoogleForm.jsx ***! + \**********************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* binding */ SettingsGoogleForm; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prop-types */ "../../../node_modules/prop-types/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var react_redux__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react-redux */ "../../../node_modules/react-redux/es/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_3__); +/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! underscore */ "../../../node_modules/underscore/modules/index-all.js"); +/* harmony import */ var metabase_containers_Form__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! metabase/containers/Form */ "./containers/Form.jsx"); +/* harmony import */ var metabase_admin_settings_settings__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! metabase/admin/settings/settings */ "./admin/settings/settings.js"); +/* harmony import */ var metabase_admin_settings_utils__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! metabase/admin/settings/utils */ "./admin/settings/utils.js"); +/* harmony import */ var metabase_components_Breadcrumbs__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! metabase/components/Breadcrumbs */ "./components/Breadcrumbs.jsx"); +/* harmony import */ var metabase_components_ExternalLink__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! metabase/components/ExternalLink */ "./components/ExternalLink.tsx"); +/* harmony import */ var metabase_lib_settings__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! metabase/lib/settings */ "./lib/settings.ts"); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +var _dec, _class, _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10; + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + + + + + + + + + + + + +var settingsGoogleFormPropTypes = { + elements: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().array), + settingValues: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().object), + updateSettings: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func) +}; +var SettingsGoogleForm = (_dec = (0,react_redux__WEBPACK_IMPORTED_MODULE_2__.connect)(null, { + updateSettings: metabase_admin_settings_settings__WEBPACK_IMPORTED_MODULE_6__.updateSettings +}), _dec(_class = /*#__PURE__*/function (_Component) { + _inherits(SettingsGoogleForm, _Component); + + var _super = _createSuper(SettingsGoogleForm); + + function SettingsGoogleForm() { + _classCallCheck(this, SettingsGoogleForm); + + return _super.apply(this, arguments); + } + + _createClass(SettingsGoogleForm, [{ + key: "render", + value: function render() { + var _this$props = this.props, + elements = _this$props.elements, + settingValues = _this$props.settingValues, + updateSettings = _this$props.updateSettings; + + var setting = function setting(name) { + return underscore__WEBPACK_IMPORTED_MODULE_4__.default.findWhere(elements, { + key: name + }) || { + key: name + }; + }; + + var settingField = function settingField(name) { + return (0,metabase_admin_settings_utils__WEBPACK_IMPORTED_MODULE_7__.settingToFormField)(setting(name)); + }; + + var initialValues = _objectSpread({}, settingValues); + + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_containers_Form__WEBPACK_IMPORTED_MODULE_5__.default, { + className: "mx2", + style: { + maxWidth: 520 + }, + initialValues: initialValues, + onSubmit: updateSettings + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Breadcrumbs__WEBPACK_IMPORTED_MODULE_8__.default, { + crumbs: [[(0,ttag__WEBPACK_IMPORTED_MODULE_3__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["Authentication"]))), "/admin/settings/authentication"], [(0,ttag__WEBPACK_IMPORTED_MODULE_3__.t)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["Google Sign-In"])))]], + className: "mb2" + }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("h2", null, (0,ttag__WEBPACK_IMPORTED_MODULE_3__.t)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["Sign in with Google"])))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("p", { + className: "text-medium" + }, (0,ttag__WEBPACK_IMPORTED_MODULE_3__.t)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["Allows users with existing Metabase accounts to login with a Google account that matches their email address in addition to their Metabase username and password."])))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("p", { + className: "text-medium" + }, (0,ttag__WEBPACK_IMPORTED_MODULE_3__.jt)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["To allow users to sign in with Google you'll need to give Metabase a Google Developers console application client ID. It only takes a few steps and instructions on how to create a key can be found ", "."])), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_ExternalLink__WEBPACK_IMPORTED_MODULE_9__.default, { + href: metabase_lib_settings__WEBPACK_IMPORTED_MODULE_10__.default.docsUrl("administration-guide/10-single-sign-on", "enabling-google-sign-in"), + target: "_blank" + }, (0,ttag__WEBPACK_IMPORTED_MODULE_3__.t)(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["here"])))))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_containers_Form__WEBPACK_IMPORTED_MODULE_5__.FormField, _extends({}, settingField("google-auth-client-id"), { + title: (0,ttag__WEBPACK_IMPORTED_MODULE_3__.t)(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["Client ID"]))), + description: "", + placeholder: (0,ttag__WEBPACK_IMPORTED_MODULE_3__.t)(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["{your-client-id}.apps.googleusercontent.com"]))), + required: true, + autoFocus: true + })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_containers_Form__WEBPACK_IMPORTED_MODULE_5__.FormField, _extends({}, settingField("google-auth-auto-create-accounts-domain"), { + title: (0,ttag__WEBPACK_IMPORTED_MODULE_3__.t)(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["Domain"]))) + })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_containers_Form__WEBPACK_IMPORTED_MODULE_5__.FormMessage, null)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_containers_Form__WEBPACK_IMPORTED_MODULE_5__.FormSubmit, null, (0,ttag__WEBPACK_IMPORTED_MODULE_3__.t)(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["Save changes"])))))); + } + }]); + + return SettingsGoogleForm; +}(react__WEBPACK_IMPORTED_MODULE_0__.Component)) || _class); + +SettingsGoogleForm.propTypes = settingsGoogleFormPropTypes; + +/***/ }), + +/***/ "./admin/settings/components/SettingsLdapForm.jsx": +/*!********************************************************!*\ + !*** ./admin/settings/components/SettingsLdapForm.jsx ***! + \********************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* binding */ SettingsLdapForm; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var react_redux__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react-redux */ "../../../node_modules/react-redux/es/index.js"); +/* harmony import */ var metabase_admin_settings_settings__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/admin/settings/settings */ "./admin/settings/settings.js"); +/* harmony import */ var _SettingsBatchForm__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./SettingsBatchForm */ "./admin/settings/components/SettingsBatchForm.jsx"); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +var _dec, _class, _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6; + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +/* eslint-disable react/prop-types */ + + + + + +var SettingsLdapForm = (_dec = (0,react_redux__WEBPACK_IMPORTED_MODULE_2__.connect)(null, { + updateSettings: metabase_admin_settings_settings__WEBPACK_IMPORTED_MODULE_3__.updateLdapSettings +}), _dec(_class = /*#__PURE__*/function (_React$Component) { + _inherits(SettingsLdapForm, _React$Component); + + var _super = _createSuper(SettingsLdapForm); + + function SettingsLdapForm() { + _classCallCheck(this, SettingsLdapForm); + + return _super.apply(this, arguments); + } + + _createClass(SettingsLdapForm, [{ + key: "render", + value: function render() { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_SettingsBatchForm__WEBPACK_IMPORTED_MODULE_4__.default, _extends({}, this.props, { + breadcrumbs: [[(0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["Authentication"]))), "/admin/settings/authentication"], [(0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["LDAP"])))]], + enabledKey: "ldap-enabled", + layout: [{ + title: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["Server Settings"]))), + settings: ["ldap-enabled", "ldap-host", "ldap-port", "ldap-security", "ldap-bind-dn", "ldap-password"] + }, { + title: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["User Schema"]))), + settings: ["ldap-user-base", "ldap-user-filter"] + }, { + title: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["Attributes"]))), + collapse: true, + settings: ["ldap-attribute-email", "ldap-attribute-firstname", "ldap-attribute-lastname"] + }, { + title: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["Group Schema"]))), + settings: ["ldap-group-sync", "ldap-group-base", "ldap-group-membership-filter" in this.props.settingValues ? "ldap-group-membership-filter" : null, "ldap-sync-admin-group" in this.props.settingValues ? "ldap-sync-admin-group" : null].filter(Boolean) + }] + })); + } + }]); + + return SettingsLdapForm; +}(react__WEBPACK_IMPORTED_MODULE_0__.Component)) || _class); + + +/***/ }), + +/***/ "./admin/settings/components/SettingsSetting.jsx": +/*!*******************************************************!*\ + !*** ./admin/settings/components/SettingsSetting.jsx ***! + \*******************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* binding */ SettingsSetting; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prop-types */ "../../../node_modules/prop-types/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var icepick__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! icepick */ "../../../node_modules/icepick/icepick.min.js"); +/* harmony import */ var icepick__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(icepick__WEBPACK_IMPORTED_MODULE_2__); +/* harmony import */ var _SettingHeader__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./SettingHeader */ "./admin/settings/components/SettingHeader/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_4__); +/* harmony import */ var _widgets_SettingInput__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./widgets/SettingInput */ "./admin/settings/components/widgets/SettingInput.jsx"); +/* harmony import */ var _widgets_SettingNumber__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./widgets/SettingNumber */ "./admin/settings/components/widgets/SettingNumber.jsx"); +/* harmony import */ var _widgets_SettingPassword__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./widgets/SettingPassword */ "./admin/settings/components/widgets/SettingPassword.jsx"); +/* harmony import */ var _widgets_SettingRadio__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./widgets/SettingRadio */ "./admin/settings/components/widgets/SettingRadio.jsx"); +/* harmony import */ var _widgets_SettingToggle__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./widgets/SettingToggle */ "./admin/settings/components/widgets/SettingToggle.jsx"); +/* harmony import */ var _widgets_SettingSelect__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./widgets/SettingSelect */ "./admin/settings/components/widgets/SettingSelect.jsx"); +/* harmony import */ var _widgets_SettingText__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./widgets/SettingText */ "./admin/settings/components/widgets/SettingText.jsx"); +/* harmony import */ var _widgets_SettingColor__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./widgets/SettingColor */ "./admin/settings/components/widgets/SettingColor.jsx"); +/* harmony import */ var _settings_utils__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./../../settings/utils */ "./admin/settings/utils.js"); +/* provided dependency */ var console = __webpack_require__(/*! console-browserify */ "../../../node_modules/console-browserify/index.js"); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +var _templateObject; + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + +/* eslint-disable react/prop-types */ + + + + + + + + + + + + + + +var SETTING_WIDGET_MAP = { + string: _widgets_SettingInput__WEBPACK_IMPORTED_MODULE_5__.default, + number: _widgets_SettingNumber__WEBPACK_IMPORTED_MODULE_6__.default, + password: _widgets_SettingPassword__WEBPACK_IMPORTED_MODULE_7__.default, + select: _widgets_SettingSelect__WEBPACK_IMPORTED_MODULE_10__.default, + radio: _widgets_SettingRadio__WEBPACK_IMPORTED_MODULE_8__.default, + boolean: _widgets_SettingToggle__WEBPACK_IMPORTED_MODULE_9__.default, + text: _widgets_SettingText__WEBPACK_IMPORTED_MODULE_11__.default, + color: _widgets_SettingColor__WEBPACK_IMPORTED_MODULE_12__.default +}; + +var updatePlaceholderForEnvironmentVars = function updatePlaceholderForEnvironmentVars(props) { + if (props && props.setting && props.setting.is_env_setting) { + return (0,icepick__WEBPACK_IMPORTED_MODULE_2__.assocIn)(props, ["setting", "placeholder"], (0,ttag__WEBPACK_IMPORTED_MODULE_4__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["Using "]))) + props.setting.env_name); + } + + return props; +}; + +var SettingsSetting = /*#__PURE__*/function (_Component) { + _inherits(SettingsSetting, _Component); + + var _super = _createSuper(SettingsSetting); + + function SettingsSetting() { + _classCallCheck(this, SettingsSetting); + + return _super.apply(this, arguments); + } + + _createClass(SettingsSetting, [{ + key: "render", + value: function render() { + var _this$props = this.props, + setting = _this$props.setting, + errorMessage = _this$props.errorMessage; + var settingId = (0,_settings_utils__WEBPACK_IMPORTED_MODULE_13__.settingToFormFieldId)(setting); + var Widget = setting.widget || SETTING_WIDGET_MAP[setting.type]; + + if (!Widget) { + console.warn("No render method for setting type " + setting.type + ", defaulting to string input."); + Widget = _widgets_SettingInput__WEBPACK_IMPORTED_MODULE_5__.default; + } + + return ( + /*#__PURE__*/ + // TODO - this formatting needs to be moved outside this component + react__WEBPACK_IMPORTED_MODULE_0__.createElement("li", { + className: "m2 mb4" + }, !setting.noHeader && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_SettingHeader__WEBPACK_IMPORTED_MODULE_3__.default, { + id: settingId, + setting: setting + }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "flex" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(Widget, _extends({ + id: settingId + }, setting.props || {}, updatePlaceholderForEnvironmentVars(this.props)))), errorMessage && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "text-error text-bold pt1" + }, errorMessage), setting.warning && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "text-gold text-bold pt1" + }, setting.warning)) + ); + } + }]); + + return SettingsSetting; +}(react__WEBPACK_IMPORTED_MODULE_0__.Component); + +_defineProperty(SettingsSetting, "propTypes", { + setting: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().object.isRequired), + onChange: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func.isRequired), + onChangeSetting: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func), + autoFocus: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), + disabled: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool) +}); + + + +/***/ }), + +/***/ "./admin/settings/components/widgets/AuthenticationOption.jsx": +/*!********************************************************************!*\ + !*** ./admin/settings/components/widgets/AuthenticationOption.jsx ***! + \********************************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var react_router__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-router */ "../../../node_modules/react-router/es/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_2__); +var _templateObject, _templateObject2; + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + +/* eslint-disable react/prop-types */ + + + + +var AuthenticationOption = function AuthenticationOption(_ref) { + var setting = _ref.setting, + settingValues = _ref.settingValues; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "bordered rounded shadowed bg-white p4", + style: { + width: 500 + } + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "flex align-center" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("h2", null, setting.authName), setting.authEnabled && setting.authEnabled(settingValues) && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "ml-auto flex align-center text-uppercase text-success" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "bg-success circular mr1", + style: { + width: 10, + height: 10 + } + }), (0,ttag__WEBPACK_IMPORTED_MODULE_2__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["Active"]))))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("p", null, setting.authDescription), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(react_router__WEBPACK_IMPORTED_MODULE_1__.Link, { + className: "Button", + to: "/admin/settings/authentication/".concat(setting.authType) + }, (0,ttag__WEBPACK_IMPORTED_MODULE_2__.t)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["Configure"]))))); +}; + +/* harmony default export */ __webpack_exports__["default"] = (AuthenticationOption); + +/***/ }), + +/***/ "./admin/settings/components/widgets/GroupMappingsWidget.jsx": +/*!*******************************************************************!*\ + !*** ./admin/settings/components/widgets/GroupMappingsWidget.jsx ***! + \*******************************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* binding */ GroupMappingsWidget; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var metabase_components_ModalContent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/components/ModalContent */ "./components/ModalContent.jsx"); +/* harmony import */ var metabase_components_AdminContentTable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/components/AdminContentTable */ "./components/AdminContentTable.jsx"); +/* harmony import */ var metabase_components_Button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/components/Button */ "./components/Button.tsx"); +/* harmony import */ var metabase_admin_people_components_GroupSelect__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! metabase/admin/people/components/GroupSelect */ "./admin/people/components/GroupSelect.jsx"); +/* harmony import */ var metabase_components_LoadingSpinner__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! metabase/components/LoadingSpinner */ "./components/LoadingSpinner/index.ts"); +/* harmony import */ var metabase_components_Modal__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! metabase/components/Modal */ "./components/Modal.jsx"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_7__); +/* harmony import */ var metabase_services__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! metabase/services */ "./services.js"); +/* harmony import */ var metabase_lib_groups__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! metabase/lib/groups */ "./lib/groups.js"); +/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! underscore */ "../../../node_modules/underscore/modules/index-all.js"); +/* harmony import */ var _SettingToggle__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./SettingToggle */ "./admin/settings/components/widgets/SettingToggle.jsx"); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11; + +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } + +function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } + +function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } + +function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/* eslint-disable react/prop-types */ + + + + + + + + + + + + + +var groupIsMappable = function groupIsMappable(group) { + return !(0,metabase_lib_groups__WEBPACK_IMPORTED_MODULE_9__.isSpecialGroup)(group); +}; + +var GroupMappingsWidget = /*#__PURE__*/function (_React$Component) { + _inherits(GroupMappingsWidget, _React$Component); + + var _super = _createSuper(GroupMappingsWidget); + + function GroupMappingsWidget(props, context) { + var _this; + + _classCallCheck(this, GroupMappingsWidget); + + _this = _super.call(this, props, context); + + _defineProperty(_assertThisInitialized(_this), "_showEditModal", /*#__PURE__*/function () { + var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(e) { + var setting; + return regeneratorRuntime.wrap(function _callee$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + e.preventDefault(); // just load the setting again to make sure it's up to date + + _context.t0 = underscore__WEBPACK_IMPORTED_MODULE_10__.default; + _context.next = 4; + return metabase_services__WEBPACK_IMPORTED_MODULE_8__.SettingsApi.list(); + + case 4: + _context.t1 = _context.sent; + _context.t2 = { + key: _this.props.mappingSetting + }; + setting = _context.t0.findWhere.call(_context.t0, _context.t1, _context.t2); + + _this.setState({ + mappings: setting && setting.value || {}, + showEditModal: true + }); + + metabase_services__WEBPACK_IMPORTED_MODULE_8__.PermissionsApi.groups().then(function (groups) { + return _this.setState({ + groups: groups.filter(groupIsMappable) + }); + }); + + case 9: + case "end": + return _context.stop(); + } + } + }, _callee); + })); + + return function (_x) { + return _ref.apply(this, arguments); + }; + }()); + + _defineProperty(_assertThisInitialized(_this), "_showAddRow", function (e) { + e.preventDefault(); + + _this.setState({ + showAddRow: true + }); + }); + + _defineProperty(_assertThisInitialized(_this), "_hideAddRow", function () { + _this.setState({ + showAddRow: false + }); + }); + + _defineProperty(_assertThisInitialized(_this), "_addMapping", function (dn) { + _this.setState(function (prevState) { + return { + mappings: _objectSpread(_objectSpread({}, prevState.mappings), {}, _defineProperty({}, dn, [])), + showAddRow: false + }; + }); + }); + + _defineProperty(_assertThisInitialized(_this), "_changeMapping", function (dn) { + return function (group, selected) { + if (selected) { + _this.setState(function (prevState) { + return { + mappings: _objectSpread(_objectSpread({}, prevState.mappings), {}, _defineProperty({}, dn, [].concat(_toConsumableArray(prevState.mappings[dn]), [group.id]))) + }; + }); + } else { + _this.setState(function (prevState) { + return { + mappings: _objectSpread(_objectSpread({}, prevState.mappings), {}, _defineProperty({}, dn, prevState.mappings[dn].filter(function (id) { + return id !== group.id; + }))) + }; + }); + } + }; + }); + + _defineProperty(_assertThisInitialized(_this), "_deleteMapping", function (dn) { + return function (e) { + e.preventDefault(); + + _this.setState(function (prevState) { + return { + mappings: underscore__WEBPACK_IMPORTED_MODULE_10__.default.omit(prevState.mappings, dn) + }; + }); + }; + }); + + _defineProperty(_assertThisInitialized(_this), "_cancelClick", function (e) { + e.preventDefault(); + + _this.setState({ + showEditModal: false, + showAddRow: false + }); + }); + + _defineProperty(_assertThisInitialized(_this), "_saveClick", function (e) { + e.preventDefault(); + + var _assertThisInitialize = _assertThisInitialized(_this), + mappings = _assertThisInitialize.state.mappings, + onChangeSetting = _assertThisInitialize.props.onChangeSetting; + + metabase_services__WEBPACK_IMPORTED_MODULE_8__.SettingsApi.put({ + key: _this.props.mappingSetting, + value: mappings + }).then(function () { + onChangeSetting(_this.props.mappingSetting, mappings); + + _this.setState({ + showEditModal: false, + showAddRow: false, + saveError: null + }); + }, function (e) { + return _this.setState({ + saveError: e + }); + }); + }); + + _this.state = { + showEditModal: false, + showAddRow: false, + groups: null, + mappings: {}, + saveError: null + }; + return _this; + } + + _createClass(GroupMappingsWidget, [{ + key: "render", + value: function render() { + var _this2 = this; + + var _this$state = this.state, + showEditModal = _this$state.showEditModal, + showAddRow = _this$state.showAddRow, + groups = _this$state.groups, + mappings = _this$state.mappings, + saveError = _this$state.saveError; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "flex align-center" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_SettingToggle__WEBPACK_IMPORTED_MODULE_11__.default, this.props), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "flex align-center pt1" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Button__WEBPACK_IMPORTED_MODULE_3__.default, { + type: "button", + className: "ml1", + medium: true, + onClick: this._showEditModal + }, (0,ttag__WEBPACK_IMPORTED_MODULE_7__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["Edit Mappings"]))))), showEditModal ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Modal__WEBPACK_IMPORTED_MODULE_6__.default, { + wide: true + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "pt4 px4" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("h2", null, (0,ttag__WEBPACK_IMPORTED_MODULE_7__.t)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["Group Mappings"]))))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "px4" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Button__WEBPACK_IMPORTED_MODULE_3__.default, { + className: "float-right", + primary: true, + onClick: this._showAddRow + }, (0,ttag__WEBPACK_IMPORTED_MODULE_7__.t)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["Create a mapping"])))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("p", { + className: "text-measure" + }, (0,ttag__WEBPACK_IMPORTED_MODULE_7__.t)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["Mappings allow Metabase to automatically add and remove users from groups based on the membership information provided by the\n directory server. Membership to the Admin group can be granted through mappings, but will not be automatically removed as a\n failsafe measure."])))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_AdminContentTable__WEBPACK_IMPORTED_MODULE_2__.default, { + columnTitles: [this.props.groupHeading, (0,ttag__WEBPACK_IMPORTED_MODULE_7__.t)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["Groups"]))), ""] + }, showAddRow ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(AddMappingRow, { + mappings: mappings, + onCancel: this._hideAddRow, + onAdd: this._addMapping, + placeholder: this.props.groupPlaceholder + }) : null, Object.entries(mappings).map(function (_ref2) { + var _ref3 = _slicedToArray(_ref2, 2), + dn = _ref3[0], + ids = _ref3[1]; + + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(MappingRow, { + key: dn, + dn: dn, + groups: groups || [], + selectedGroups: ids, + onChange: _this2._changeMapping(dn), + onDelete: _this2._deleteMapping(dn) + }); + }))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_ModalContent__WEBPACK_IMPORTED_MODULE_1__.ModalFooter, null, saveError && saveError.data && saveError.data.message ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { + className: "text-error text-bold" + }, saveError.data.message) : null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Button__WEBPACK_IMPORTED_MODULE_3__.default, { + type: "button", + onClick: this._cancelClick + }, (0,ttag__WEBPACK_IMPORTED_MODULE_7__.t)(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["Cancel"])))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Button__WEBPACK_IMPORTED_MODULE_3__.default, { + primary: true, + onClick: this._saveClick + }, (0,ttag__WEBPACK_IMPORTED_MODULE_7__.t)(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["Save"]))))))) : null); + } + }]); + + return GroupMappingsWidget; +}(react__WEBPACK_IMPORTED_MODULE_0__.Component); + + + +var AddMappingRow = /*#__PURE__*/function (_React$Component2) { + _inherits(AddMappingRow, _React$Component2); + + var _super2 = _createSuper(AddMappingRow); + + function AddMappingRow(props, context) { + var _this3; + + _classCallCheck(this, AddMappingRow); + + _this3 = _super2.call(this, props, context); + + _defineProperty(_assertThisInitialized(_this3), "_handleCancelClick", function (e) { + e.preventDefault(); + var onCancel = _this3.props.onCancel; + onCancel && onCancel(); + + _this3.setState({ + value: "" + }); + }); + + _defineProperty(_assertThisInitialized(_this3), "_handleAddClick", function (e) { + e.preventDefault(); + var onAdd = _this3.props.onAdd; + onAdd && onAdd(_this3.state.value); + + _this3.setState({ + value: "" + }); + }); + + _this3.state = { + value: "" + }; + return _this3; + } + + _createClass(AddMappingRow, [{ + key: "render", + value: function render() { + var _this4 = this; + + var value = this.state.value; + var isValid = value && this.props.mappings[value] === undefined; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("tr", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("td", { + colSpan: "3", + style: { + padding: 0 + } + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "my2 pl1 p1 bordered border-brand rounded relative flex align-center" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("input", { + className: "input--borderless h3 ml1 flex-full", + type: "text", + value: value, + placeholder: this.props.placeholder, + autoFocus: true, + onChange: function onChange(e) { + return _this4.setState({ + value: e.target.value + }); + } + }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { + className: "link no-decoration cursor-pointer", + onClick: this._handleCancelClick + }, (0,ttag__WEBPACK_IMPORTED_MODULE_7__.t)(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["Cancel"])))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Button__WEBPACK_IMPORTED_MODULE_3__.default, { + className: "ml2", + primary: !!isValid, + disabled: !isValid, + onClick: this._handleAddClick + }, (0,ttag__WEBPACK_IMPORTED_MODULE_7__.t)(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["Add"]))))))); + } + }]); + + return AddMappingRow; +}(react__WEBPACK_IMPORTED_MODULE_0__.Component); + +var MappingGroupSelect = /*#__PURE__*/function (_React$Component3) { + _inherits(MappingGroupSelect, _React$Component3); + + var _super3 = _createSuper(MappingGroupSelect); + + function MappingGroupSelect() { + _classCallCheck(this, MappingGroupSelect); + + return _super3.apply(this, arguments); + } + + _createClass(MappingGroupSelect, [{ + key: "render", + value: function render() { + var _this$props = this.props, + groups = _this$props.groups, + selectedGroups = _this$props.selectedGroups, + onGroupChange = _this$props.onGroupChange; + + if (!groups) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_LoadingSpinner__WEBPACK_IMPORTED_MODULE_5__.default, null); + } + + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_admin_people_components_GroupSelect__WEBPACK_IMPORTED_MODULE_4__.default, { + groups: groups, + selectedGroupIds: selectedGroups, + onGroupChange: onGroupChange, + emptyListMessage: (0,ttag__WEBPACK_IMPORTED_MODULE_7__.t)(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["No mappable groups"]))) + }); + } + }]); + + return MappingGroupSelect; +}(react__WEBPACK_IMPORTED_MODULE_0__.Component); + +var MappingRow = /*#__PURE__*/function (_React$Component4) { + _inherits(MappingRow, _React$Component4); + + var _super4 = _createSuper(MappingRow); + + function MappingRow() { + _classCallCheck(this, MappingRow); + + return _super4.apply(this, arguments); + } + + _createClass(MappingRow, [{ + key: "render", + value: function render() { + var _this$props2 = this.props, + dn = _this$props2.dn, + groups = _this$props2.groups, + selectedGroups = _this$props2.selectedGroups, + onChange = _this$props2.onChange, + onDelete = _this$props2.onDelete; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("tr", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("td", null, dn), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("td", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(MappingGroupSelect, { + groups: groups, + selectedGroups: selectedGroups, + onGroupChange: onChange + })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("td", { + className: "Table-actions" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Button__WEBPACK_IMPORTED_MODULE_3__.default, { + warning: true, + onClick: onDelete + }, (0,ttag__WEBPACK_IMPORTED_MODULE_7__.t)(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["Remove"])))))); + } + }]); + + return MappingRow; +}(react__WEBPACK_IMPORTED_MODULE_0__.Component); + +/***/ }), + +/***/ "./admin/settings/components/widgets/SettingColor.jsx": +/*!************************************************************!*\ + !*** ./admin/settings/components/widgets/SettingColor.jsx ***! + \************************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var metabase_components_ColorPicker__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/components/ColorPicker */ "./components/ColorPicker.jsx"); +/* eslint-disable react/prop-types */ + + + +var SettingColor = function SettingColor(_ref) { + var setting = _ref.setting, + onChange = _ref.onChange; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_ColorPicker__WEBPACK_IMPORTED_MODULE_1__.default, { + value: setting.value || setting.default, + onChange: onChange + }); +}; + +/* harmony default export */ __webpack_exports__["default"] = (SettingColor); + +/***/ }), + +/***/ "./admin/settings/components/widgets/SettingInput.jsx": +/*!************************************************************!*\ + !*** ./admin/settings/components/widgets/SettingInput.jsx ***! + \************************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var metabase_components_InputBlurChange__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/components/InputBlurChange */ "./components/InputBlurChange.jsx"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! classnames */ "../../../node_modules/classnames/index.js"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_2__); +/* eslint-disable react/prop-types */ + + + + +var SettingInput = function SettingInput(_ref) { + var setting = _ref.setting, + onChange = _ref.onChange, + disabled = _ref.disabled, + autoFocus = _ref.autoFocus, + errorMessage = _ref.errorMessage, + fireOnChange = _ref.fireOnChange, + id = _ref.id, + _ref$type = _ref.type, + type = _ref$type === void 0 ? "text" : _ref$type; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_InputBlurChange__WEBPACK_IMPORTED_MODULE_1__.default, { + className: classnames__WEBPACK_IMPORTED_MODULE_2___default()("Form-input", { + SettingsInput: type !== "password", + SettingsPassword: type === "password", + "border-error bg-error-input": errorMessage + }), + id: id, + type: type, + value: setting.value || "", + placeholder: setting.placeholder, + onChange: fireOnChange ? function (e) { + return onChange(e.target.value); + } : null, + onBlurChange: !fireOnChange ? function (e) { + return onChange(e.target.value); + } : null, + autoFocus: autoFocus + }); +}; + +/* harmony default export */ __webpack_exports__["default"] = (SettingInput); + +/***/ }), + +/***/ "./admin/settings/components/widgets/SettingNumber.jsx": +/*!*************************************************************!*\ + !*** ./admin/settings/components/widgets/SettingNumber.jsx ***! + \*************************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var _SettingInput__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./SettingInput */ "./admin/settings/components/widgets/SettingInput.jsx"); +var _excluded = ["type"]; + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } + +function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } + +/* eslint-disable react/prop-types */ + + + +var SettingNumber = function SettingNumber(_ref) { + var _ref$type = _ref.type, + type = _ref$type === void 0 ? "number" : _ref$type, + props = _objectWithoutProperties(_ref, _excluded); + + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_SettingInput__WEBPACK_IMPORTED_MODULE_1__.default, _extends({}, props, { + type: "number" + })); +}; + +/* harmony default export */ __webpack_exports__["default"] = (SettingNumber); + +/***/ }), + +/***/ "./admin/settings/components/widgets/SettingPassword.jsx": +/*!***************************************************************!*\ + !*** ./admin/settings/components/widgets/SettingPassword.jsx ***! + \***************************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var _SettingInput__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./SettingInput */ "./admin/settings/components/widgets/SettingInput.jsx"); +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + + + + +var SettingPassword = function SettingPassword(props) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_SettingInput__WEBPACK_IMPORTED_MODULE_1__.default, _extends({}, props, { + type: "password" + })); +}; + +/* harmony default export */ __webpack_exports__["default"] = (SettingPassword); + +/***/ }), + +/***/ "./admin/settings/components/widgets/SettingRadio.jsx": +/*!************************************************************!*\ + !*** ./admin/settings/components/widgets/SettingRadio.jsx ***! + \************************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var metabase_components_Radio__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/components/Radio */ "./components/Radio.jsx"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! classnames */ "../../../node_modules/classnames/index.js"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_2__); +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } + +function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } + +function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } + +/* eslint-disable react/prop-types */ + + + + +var SettingRadio = function SettingRadio(_ref) { + var setting = _ref.setting, + _onChange = _ref.onChange, + disabled = _ref.disabled; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Radio__WEBPACK_IMPORTED_MODULE_1__.default, { + className: classnames__WEBPACK_IMPORTED_MODULE_2___default()({ + disabled: disabled + }), + value: setting.value, + onChange: function onChange(value) { + return _onChange(value); + }, + options: Object.entries(setting.options).map(function (_ref2) { + var _ref3 = _slicedToArray(_ref2, 2), + value = _ref3[0], + name = _ref3[1]; + + return { + name: name, + value: value + }; + }) + }); +}; + +/* harmony default export */ __webpack_exports__["default"] = (SettingRadio); + +/***/ }), + +/***/ "./admin/settings/components/widgets/SettingSelect.jsx": +/*!*************************************************************!*\ + !*** ./admin/settings/components/widgets/SettingSelect.jsx ***! + \*************************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var metabase_components_Select__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/components/Select */ "./components/Select.jsx"); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +/* eslint-disable react/prop-types */ + + + +var SettingSelect = function SettingSelect(_ref) { + var _ref$setting = _ref.setting, + placeholder = _ref$setting.placeholder, + value = _ref$setting.value, + options = _ref$setting.options, + defaultValue = _ref$setting.defaultValue, + searchProp = _ref$setting.searchProp, + _onChange = _ref.onChange, + disabled = _ref.disabled; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Select__WEBPACK_IMPORTED_MODULE_1__.default, { + className: "full-width", + placeholder: placeholder, + value: value, + defaultValue: defaultValue, + searchProp: searchProp, + onChange: function onChange(e) { + return _onChange(e.target.value); + } + }, options.map(function (option) { + var name = _typeof(option) === "object" ? option.name : option; + var value = _typeof(option) === "object" ? option.value : option; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Select__WEBPACK_IMPORTED_MODULE_1__.Option, { + key: value, + name: name, + value: value + }, name); + })); +}; + +/* harmony default export */ __webpack_exports__["default"] = (SettingSelect); + +/***/ }), + +/***/ "./admin/settings/components/widgets/SettingText.jsx": +/*!***********************************************************!*\ + !*** ./admin/settings/components/widgets/SettingText.jsx ***! + \***********************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! classnames */ "../../../node_modules/classnames/index.js"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_1__); +/* eslint-disable react/prop-types */ + + + +var SettingText = function SettingText(_ref) { + var setting = _ref.setting, + onChange = _ref.onChange, + disabled = _ref.disabled, + autoFocus = _ref.autoFocus, + errorMessage = _ref.errorMessage, + fireOnChange = _ref.fireOnChange; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("textarea", { + className: classnames__WEBPACK_IMPORTED_MODULE_1___default()("AdminInput bordered rounded h3 SettingsInput", { + "border-error bg-error-input": errorMessage + }), + defaultValue: setting.value || "", + placeholder: setting.placeholder, + onChange: fireOnChange ? function (e) { + return onChange(e.target.value); + } : null, + onBlur: !fireOnChange ? function (e) { + return onChange(e.target.value); + } : null, + autoFocus: autoFocus + }); +}; + +/* harmony default export */ __webpack_exports__["default"] = (SettingText); + +/***/ }), + +/***/ "./admin/settings/components/widgets/SettingToggle.jsx": +/*!*************************************************************!*\ + !*** ./admin/settings/components/widgets/SettingToggle.jsx ***! + \*************************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var metabase_components_Toggle__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/components/Toggle */ "./components/Toggle/index.ts"); +var _templateObject, _templateObject2; + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + +/* eslint-disable react/prop-types */ + + + + +var SettingToggle = function SettingToggle(_ref) { + var setting = _ref.setting, + onChange = _ref.onChange, + disabled = _ref.disabled; + var value = setting.value == null ? setting.default : setting.value; + var on = value === true || value === "true"; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "flex align-center pt1" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Toggle__WEBPACK_IMPORTED_MODULE_2__.default, { + value: on, + onChange: !disabled ? function () { + return onChange(!on); + } : null + }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { + className: "text-bold mx1" + }, on ? (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["Enabled"]))) : (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["Disabled"]))))); +}; + +/* harmony default export */ __webpack_exports__["default"] = (SettingToggle); + +/***/ }), + +/***/ "./admin/settings/settings.js": +/*!************************************!*\ + !*** ./admin/settings/settings.js ***! + \************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "reloadSettings": function() { return /* binding */ reloadSettings; }, +/* harmony export */ "refreshSettingsList": function() { return /* binding */ refreshSettingsList; }, +/* harmony export */ "INITIALIZE_SETTINGS": function() { return /* binding */ INITIALIZE_SETTINGS; }, +/* harmony export */ "initializeSettings": function() { return /* binding */ initializeSettings; }, +/* harmony export */ "UPDATE_SETTING": function() { return /* binding */ UPDATE_SETTING; }, +/* harmony export */ "updateSetting": function() { return /* binding */ updateSetting; }, +/* harmony export */ "UPDATE_SETTINGS": function() { return /* binding */ UPDATE_SETTINGS; }, +/* harmony export */ "updateSettings": function() { return /* binding */ updateSettings; }, +/* harmony export */ "UPDATE_EMAIL_SETTINGS": function() { return /* binding */ UPDATE_EMAIL_SETTINGS; }, +/* harmony export */ "updateEmailSettings": function() { return /* binding */ updateEmailSettings; }, +/* harmony export */ "SEND_TEST_EMAIL": function() { return /* binding */ SEND_TEST_EMAIL; }, +/* harmony export */ "sendTestEmail": function() { return /* binding */ sendTestEmail; }, +/* harmony export */ "CLEAR_EMAIL_SETTINGS": function() { return /* binding */ CLEAR_EMAIL_SETTINGS; }, +/* harmony export */ "clearEmailSettings": function() { return /* binding */ clearEmailSettings; }, +/* harmony export */ "UPDATE_SLACK_SETTINGS": function() { return /* binding */ UPDATE_SLACK_SETTINGS; }, +/* harmony export */ "updateSlackSettings": function() { return /* binding */ updateSlackSettings; }, +/* harmony export */ "UPDATE_LDAP_SETTINGS": function() { return /* binding */ UPDATE_LDAP_SETTINGS; }, +/* harmony export */ "updateLdapSettings": function() { return /* binding */ updateLdapSettings; }, +/* harmony export */ "warnings": function() { return /* binding */ warnings; } +/* harmony export */ }); +/* harmony import */ var metabase_lib_redux__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! metabase/lib/redux */ "./lib/redux.js"); +/* harmony import */ var metabase_services__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/services */ "./services.js"); +/* harmony import */ var metabase_redux_settings__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/redux/settings */ "./redux/settings.js"); +/* provided dependency */ var console = __webpack_require__(/*! console-browserify */ "../../../node_modules/console-browserify/index.js"); +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } + +function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } + + + + // ACITON TYPES AND ACTION CREATORS + +var reloadSettings = function reloadSettings() { + return /*#__PURE__*/function () { + var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(dispatch, getState) { + return regeneratorRuntime.wrap(function _callee$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + _context.next = 2; + return Promise.all([dispatch(refreshSettingsList()), dispatch((0,metabase_redux_settings__WEBPACK_IMPORTED_MODULE_2__.refreshSiteSettings)())]); + + case 2: + case "end": + return _context.stop(); + } + } + }, _callee); + })); + + return function (_x, _x2) { + return _ref.apply(this, arguments); + }; + }(); +}; +var REFRESH_SETTINGS_LIST = "metabase/admin/settings/REFRESH_SETTINGS_LIST"; +var refreshSettingsList = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_0__.createAction)(REFRESH_SETTINGS_LIST, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() { + var settingsList; + return regeneratorRuntime.wrap(function _callee2$(_context2) { + while (1) { + switch (_context2.prev = _context2.next) { + case 0: + _context2.next = 2; + return metabase_services__WEBPACK_IMPORTED_MODULE_1__.SettingsApi.list(); + + case 2: + settingsList = _context2.sent; + return _context2.abrupt("return", settingsList.map(function (setting) { + return _objectSpread(_objectSpread({}, setting), {}, { + originalValue: setting.value + }); + })); + + case 4: + case "end": + return _context2.stop(); + } + } + }, _callee2); +}))); +var INITIALIZE_SETTINGS = "metabase/admin/settings/INITIALIZE_SETTINGS"; +var initializeSettings = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_0__.createThunkAction)(INITIALIZE_SETTINGS, function () { + return /*#__PURE__*/function () { + var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(dispatch, getState) { + return regeneratorRuntime.wrap(function _callee3$(_context3) { + while (1) { + switch (_context3.prev = _context3.next) { + case 0: + _context3.prev = 0; + _context3.next = 3; + return dispatch(reloadSettings()); + + case 3: + _context3.next = 9; + break; + + case 5: + _context3.prev = 5; + _context3.t0 = _context3["catch"](0); + console.log("error fetching settings", _context3.t0); + throw _context3.t0; + + case 9: + case "end": + return _context3.stop(); + } + } + }, _callee3, null, [[0, 5]]); + })); + + return function (_x3, _x4) { + return _ref3.apply(this, arguments); + }; + }(); +}); +var UPDATE_SETTING = "metabase/admin/settings/UPDATE_SETTING"; +var updateSetting = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_0__.createThunkAction)(UPDATE_SETTING, function (setting) { + return /*#__PURE__*/function () { + var _ref4 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(dispatch, getState) { + return regeneratorRuntime.wrap(function _callee4$(_context4) { + while (1) { + switch (_context4.prev = _context4.next) { + case 0: + _context4.prev = 0; + _context4.next = 3; + return metabase_services__WEBPACK_IMPORTED_MODULE_1__.SettingsApi.put(setting); + + case 3: + _context4.next = 9; + break; + + case 5: + _context4.prev = 5; + _context4.t0 = _context4["catch"](0); + console.log("error updating setting", setting, _context4.t0); + throw _context4.t0; + + case 9: + _context4.prev = 9; + _context4.next = 12; + return dispatch(reloadSettings()); + + case 12: + return _context4.finish(9); + + case 13: + case "end": + return _context4.stop(); + } + } + }, _callee4, null, [[0, 5, 9, 13]]); + })); + + return function (_x5, _x6) { + return _ref4.apply(this, arguments); + }; + }(); +}); +var UPDATE_SETTINGS = "metabase/admin/settings/UPDATE_SETTINGS"; +var updateSettings = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_0__.createThunkAction)(UPDATE_SETTINGS, function (settings) { + return /*#__PURE__*/function () { + var _ref5 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5(dispatch, getState) { + return regeneratorRuntime.wrap(function _callee5$(_context5) { + while (1) { + switch (_context5.prev = _context5.next) { + case 0: + _context5.prev = 0; + _context5.next = 3; + return metabase_services__WEBPACK_IMPORTED_MODULE_1__.SettingsApi.putAll(settings); + + case 3: + _context5.next = 9; + break; + + case 5: + _context5.prev = 5; + _context5.t0 = _context5["catch"](0); + console.log("error updating settings", settings, _context5.t0); + throw _context5.t0; + + case 9: + _context5.prev = 9; + _context5.next = 12; + return dispatch(reloadSettings()); + + case 12: + return _context5.finish(9); + + case 13: + case "end": + return _context5.stop(); + } + } + }, _callee5, null, [[0, 5, 9, 13]]); + })); + + return function (_x7, _x8) { + return _ref5.apply(this, arguments); + }; + }(); +}); +var UPDATE_EMAIL_SETTINGS = "metabase/admin/settings/UPDATE_EMAIL_SETTINGS"; +var updateEmailSettings = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_0__.createThunkAction)(UPDATE_EMAIL_SETTINGS, function (settings) { + return /*#__PURE__*/function () { + var _ref6 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6(dispatch, getState) { + var result; + return regeneratorRuntime.wrap(function _callee6$(_context6) { + while (1) { + switch (_context6.prev = _context6.next) { + case 0: + _context6.prev = 0; + _context6.next = 3; + return metabase_services__WEBPACK_IMPORTED_MODULE_1__.EmailApi.updateSettings(settings); + + case 3: + result = _context6.sent; + _context6.next = 6; + return dispatch(reloadSettings()); + + case 6: + return _context6.abrupt("return", result); + + case 9: + _context6.prev = 9; + _context6.t0 = _context6["catch"](0); + console.log("error updating email settings", settings, _context6.t0); + throw _context6.t0; + + case 13: + case "end": + return _context6.stop(); + } + } + }, _callee6, null, [[0, 9]]); + })); + + return function (_x9, _x10) { + return _ref6.apply(this, arguments); + }; + }(); +}); +var SEND_TEST_EMAIL = "metabase/admin/settings/SEND_TEST_EMAIL"; +var sendTestEmail = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_0__.createThunkAction)(SEND_TEST_EMAIL, function () { + return /*#__PURE__*/function () { + var _ref7 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee7(dispatch, getState) { + return regeneratorRuntime.wrap(function _callee7$(_context7) { + while (1) { + switch (_context7.prev = _context7.next) { + case 0: + _context7.prev = 0; + _context7.next = 3; + return metabase_services__WEBPACK_IMPORTED_MODULE_1__.EmailApi.sendTest(); + + case 3: + _context7.next = 9; + break; + + case 5: + _context7.prev = 5; + _context7.t0 = _context7["catch"](0); + console.log("error sending test email", _context7.t0); + throw _context7.t0; + + case 9: + case "end": + return _context7.stop(); + } + } + }, _callee7, null, [[0, 5]]); + })); + + return function (_x11, _x12) { + return _ref7.apply(this, arguments); + }; + }(); +}); +var CLEAR_EMAIL_SETTINGS = "metabase/admin/settings/CLEAR_EMAIL_SETTINGS"; +var clearEmailSettings = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_0__.createAction)(CLEAR_EMAIL_SETTINGS, function () { + return metabase_services__WEBPACK_IMPORTED_MODULE_1__.EmailApi.clear(); +}); +var UPDATE_SLACK_SETTINGS = "metabase/admin/settings/UPDATE_SLACK_SETTINGS"; +var updateSlackSettings = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_0__.createThunkAction)(UPDATE_SLACK_SETTINGS, function (settings) { + return /*#__PURE__*/function () { + var _ref8 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee8(dispatch, getState) { + var result; + return regeneratorRuntime.wrap(function _callee8$(_context8) { + while (1) { + switch (_context8.prev = _context8.next) { + case 0: + _context8.prev = 0; + _context8.next = 3; + return metabase_services__WEBPACK_IMPORTED_MODULE_1__.SlackApi.updateSettings(settings); + + case 3: + result = _context8.sent; + _context8.next = 6; + return dispatch(reloadSettings()); + + case 6: + return _context8.abrupt("return", result); + + case 9: + _context8.prev = 9; + _context8.t0 = _context8["catch"](0); + console.log("error updating slack settings", settings, _context8.t0); + throw _context8.t0; + + case 13: + case "end": + return _context8.stop(); + } + } + }, _callee8, null, [[0, 9]]); + })); + + return function (_x13, _x14) { + return _ref8.apply(this, arguments); + }; + }(); +}, {}); +var UPDATE_LDAP_SETTINGS = "metabase/admin/settings/UPDATE_LDAP_SETTINGS"; +var updateLdapSettings = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_0__.createThunkAction)(UPDATE_LDAP_SETTINGS, function (settings) { + return /*#__PURE__*/function () { + var _ref9 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee9(dispatch, getState) { + var result; + return regeneratorRuntime.wrap(function _callee9$(_context9) { + while (1) { + switch (_context9.prev = _context9.next) { + case 0: + _context9.prev = 0; + _context9.next = 3; + return metabase_services__WEBPACK_IMPORTED_MODULE_1__.LdapApi.updateSettings(settings); + + case 3: + result = _context9.sent; + _context9.next = 6; + return dispatch(reloadSettings()); + + case 6: + return _context9.abrupt("return", result); + + case 9: + _context9.prev = 9; + _context9.t0 = _context9["catch"](0); + console.log("error updating LDAP settings", settings, _context9.t0); + throw _context9.t0; + + case 13: + case "end": + return _context9.stop(); + } + } + }, _callee9, null, [[0, 9]]); + })); + + return function (_x15, _x16) { + return _ref9.apply(this, arguments); + }; + }(); +}); // REDUCERS + +var warnings = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_0__.handleActions)(_defineProperty({}, UPDATE_EMAIL_SETTINGS, { + next: function next(state, _ref10) { + var payload = _ref10.payload; + return payload["with-corrections"]; + } +}), {}); +var settings = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_0__.handleActions)(_defineProperty({}, REFRESH_SETTINGS_LIST, { + next: function next(state, _ref11) { + var payload = _ref11.payload; + return payload; + } +}), []); +/* harmony default export */ __webpack_exports__["default"] = ((0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_0__.combineReducers)({ + settings: settings, + warnings: warnings +})); + +/***/ }), + +/***/ "./admin/settings/utils.js": +/*!*********************************!*\ + !*** ./admin/settings/utils.js ***! + \*********************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "prepareAnalyticsValue": function() { return /* binding */ prepareAnalyticsValue; }, +/* harmony export */ "settingToFormField": function() { return /* binding */ settingToFormField; }, +/* harmony export */ "settingToFormFieldId": function() { return /* binding */ settingToFormFieldId; } +/* harmony export */ }); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_0__); +var _templateObject; + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + + // in order to prevent collection of identifying information only fields +// that are explicitly marked as collectable or booleans should show the true value + +var prepareAnalyticsValue = function prepareAnalyticsValue(setting) { + return setting.allowValueCollection || setting.type === "boolean" ? setting.value : "success"; +}; +var settingToFormField = function settingToFormField(setting) { + return { + name: setting.key, + description: setting.description, + placeholder: setting.is_env_setting ? (0,ttag__WEBPACK_IMPORTED_MODULE_0__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["Using ", ""])), setting.env_name) : setting.placeholder || setting.default, + validate: setting.required ? function (value) { + return !value && "required"; + } : null + }; +}; +var settingToFormFieldId = function settingToFormFieldId(setting) { + return "setting-".concat(setting.key); +}; + +/***/ }), + +/***/ "./alert/alert.js": +/*!************************!*\ + !*** ./alert/alert.js ***! + \************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "FETCH_ALL_ALERTS": function() { return /* binding */ FETCH_ALL_ALERTS; }, +/* harmony export */ "fetchAllAlerts": function() { return /* binding */ fetchAllAlerts; }, +/* harmony export */ "FETCH_ALERTS_FOR_QUESTION_CLEAR_OLD_ALERTS": function() { return /* binding */ FETCH_ALERTS_FOR_QUESTION_CLEAR_OLD_ALERTS; }, +/* harmony export */ "FETCH_ALERTS_FOR_QUESTION": function() { return /* binding */ FETCH_ALERTS_FOR_QUESTION; }, +/* harmony export */ "fetchAlertsForQuestion": function() { return /* binding */ fetchAlertsForQuestion; }, +/* harmony export */ "CREATE_ALERT": function() { return /* binding */ CREATE_ALERT; }, +/* harmony export */ "createAlert": function() { return /* binding */ createAlert; }, +/* harmony export */ "UPDATE_ALERT": function() { return /* binding */ UPDATE_ALERT; }, +/* harmony export */ "updateAlert": function() { return /* binding */ updateAlert; }, +/* harmony export */ "UNSUBSCRIBE_FROM_ALERT": function() { return /* binding */ UNSUBSCRIBE_FROM_ALERT; }, +/* harmony export */ "UNSUBSCRIBE_FROM_ALERT_CLEANUP": function() { return /* binding */ UNSUBSCRIBE_FROM_ALERT_CLEANUP; }, +/* harmony export */ "unsubscribeFromAlert": function() { return /* binding */ unsubscribeFromAlert; }, +/* harmony export */ "DELETE_ALERT": function() { return /* binding */ DELETE_ALERT; }, +/* harmony export */ "deleteAlert": function() { return /* binding */ deleteAlert; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! underscore */ "../../../node_modules/underscore/modules/index-all.js"); +/* harmony import */ var redux_actions__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! redux-actions */ "../../../node_modules/redux-actions/es/handleActions.js"); +/* harmony import */ var redux__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! redux */ "../../../node_modules/redux/es/index.js"); +/* harmony import */ var metabase_redux_undo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/redux/undo */ "./redux/undo.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_4__); +/* harmony import */ var metabase_services__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! metabase/services */ "./services.js"); +/* harmony import */ var metabase_lib_request__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! metabase/lib/request */ "./lib/request.js"); +/* harmony import */ var metabase_components_Icon__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! metabase/components/Icon */ "./components/Icon.tsx"); +var _templateObject, _templateObject2, _templateObject3, _objectSpread3; + +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + +function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } + +function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } + + + + + + + + + + +var FETCH_ALL_ALERTS = "metabase/alerts/FETCH_ALL_ALERTS"; +var fetchAllAlertsRequest = new metabase_lib_request__WEBPACK_IMPORTED_MODULE_6__.RestfulRequest({ + endpoint: metabase_services__WEBPACK_IMPORTED_MODULE_5__.AlertApi.list, + actionPrefix: FETCH_ALL_ALERTS, + storeAsDictionary: true +}); +var fetchAllAlerts = function fetchAllAlerts() { + return /*#__PURE__*/function () { + var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(dispatch, getState) { + return regeneratorRuntime.wrap(function _callee$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + _context.next = 2; + return dispatch(fetchAllAlertsRequest.trigger()); + + case 2: + dispatch.action(FETCH_ALL_ALERTS); + + case 3: + case "end": + return _context.stop(); + } + } + }, _callee); + })); + + return function (_x, _x2) { + return _ref.apply(this, arguments); + }; + }(); +}; +var FETCH_ALERTS_FOR_QUESTION_CLEAR_OLD_ALERTS = "metabase/alerts/FETCH_ALERTS_FOR_QUESTION_CLEAR_OLD_ALERTS"; +var FETCH_ALERTS_FOR_QUESTION = "metabase/alerts/FETCH_ALERTS_FOR_QUESTION"; +var fetchAlertsForQuestionRequest = new metabase_lib_request__WEBPACK_IMPORTED_MODULE_6__.RestfulRequest({ + endpoint: metabase_services__WEBPACK_IMPORTED_MODULE_5__.AlertApi.list_for_question, + actionPrefix: FETCH_ALERTS_FOR_QUESTION, + storeAsDictionary: true +}); +var fetchAlertsForQuestion = function fetchAlertsForQuestion(questionId) { + return /*#__PURE__*/function () { + var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(dispatch, getState) { + return regeneratorRuntime.wrap(function _callee2$(_context2) { + while (1) { + switch (_context2.prev = _context2.next) { + case 0: + dispatch.action(FETCH_ALERTS_FOR_QUESTION_CLEAR_OLD_ALERTS, questionId); + _context2.next = 3; + return dispatch(fetchAlertsForQuestionRequest.trigger({ + questionId: questionId + })); + + case 3: + dispatch.action(FETCH_ALERTS_FOR_QUESTION); + + case 4: + case "end": + return _context2.stop(); + } + } + }, _callee2); + })); + + return function (_x3, _x4) { + return _ref2.apply(this, arguments); + }; + }(); +}; +var CREATE_ALERT = "metabase/alerts/CREATE_ALERT"; +var createAlertRequest = new metabase_lib_request__WEBPACK_IMPORTED_MODULE_6__.RestfulRequest({ + endpoint: metabase_services__WEBPACK_IMPORTED_MODULE_5__.AlertApi.create, + actionPrefix: CREATE_ALERT, + storeAsDictionary: true +}); +var createAlert = function createAlert(alert) { + return /*#__PURE__*/function () { + var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(dispatch, getState) { + return regeneratorRuntime.wrap(function _callee3$(_context3) { + while (1) { + switch (_context3.prev = _context3.next) { + case 0: + _context3.next = 2; + return dispatch(createAlertRequest.trigger(alert)); + + case 2: + dispatch((0,metabase_redux_undo__WEBPACK_IMPORTED_MODULE_3__.addUndo)({ + // eslint-disable-next-line react/display-name + message: function message() { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "flex align-center text-bold" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Icon__WEBPACK_IMPORTED_MODULE_7__.default, { + name: "alert_confirm", + size: "19", + className: "mr2 text-success" + }), (0,ttag__WEBPACK_IMPORTED_MODULE_4__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["Your alert is all set up."])))); + } + })); + dispatch.action(CREATE_ALERT); + + case 4: + case "end": + return _context3.stop(); + } + } + }, _callee3); + })); + + return function (_x5, _x6) { + return _ref3.apply(this, arguments); + }; + }(); +}; // NOTE: backend is a little picky about the properties present on the alert + +function cleanAlert(alert) { + alert = _objectSpread(_objectSpread({}, alert), {}, { + card: underscore__WEBPACK_IMPORTED_MODULE_1__.default.pick(alert.card, "id", "include_csv", "include_xls") + }); + + if (alert.collection_id == null) { + delete alert.collection_id; + } + + if (alert.alert_above_goal == null) { + delete alert.alert_above_goal; + } + + return alert; +} + +var UPDATE_ALERT = "metabase/alerts/UPDATE_ALERT"; +var updateAlertRequest = new metabase_lib_request__WEBPACK_IMPORTED_MODULE_6__.RestfulRequest({ + endpoint: metabase_services__WEBPACK_IMPORTED_MODULE_5__.AlertApi.update, + actionPrefix: UPDATE_ALERT, + storeAsDictionary: true +}); +var updateAlert = function updateAlert(alert) { + return /*#__PURE__*/function () { + var _ref4 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(dispatch, getState) { + return regeneratorRuntime.wrap(function _callee4$(_context4) { + while (1) { + switch (_context4.prev = _context4.next) { + case 0: + _context4.next = 2; + return dispatch(updateAlertRequest.trigger(cleanAlert(alert))); + + case 2: + dispatch((0,metabase_redux_undo__WEBPACK_IMPORTED_MODULE_3__.addUndo)({ + // eslint-disable-next-line react/display-name + message: function message() { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "flex align-center text-bold" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Icon__WEBPACK_IMPORTED_MODULE_7__.default, { + name: "alert_confirm", + size: "19", + className: "mr2 text-success" + }), (0,ttag__WEBPACK_IMPORTED_MODULE_4__.t)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["Your alert was updated."])))); + } + })); + dispatch.action(UPDATE_ALERT); + + case 4: + case "end": + return _context4.stop(); + } + } + }, _callee4); + })); + + return function (_x7, _x8) { + return _ref4.apply(this, arguments); + }; + }(); +}; +var UNSUBSCRIBE_FROM_ALERT = "metabase/alerts/UNSUBSCRIBE_FROM_ALERT"; +var UNSUBSCRIBE_FROM_ALERT_CLEANUP = "metabase/alerts/UNSUBSCRIBE_FROM_ALERT_CLEANUP"; +var unsubscribeFromAlertRequest = new metabase_lib_request__WEBPACK_IMPORTED_MODULE_6__.RestfulRequest({ + endpoint: metabase_services__WEBPACK_IMPORTED_MODULE_5__.AlertApi.unsubscribe, + actionPrefix: UNSUBSCRIBE_FROM_ALERT, + storeAsDictionary: true +}); +var unsubscribeFromAlert = function unsubscribeFromAlert(alert) { + return /*#__PURE__*/function () { + var _ref5 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5(dispatch, getState) { + return regeneratorRuntime.wrap(function _callee5$(_context5) { + while (1) { + switch (_context5.prev = _context5.next) { + case 0: + _context5.next = 2; + return dispatch(unsubscribeFromAlertRequest.trigger(alert)); + + case 2: + dispatch.action(UNSUBSCRIBE_FROM_ALERT); // This delay lets us to show "You're unsubscribed" text in place of an + // alert list item for a while before removing the list item completely + + setTimeout(function () { + return dispatch.action(UNSUBSCRIBE_FROM_ALERT_CLEANUP, alert.id); + }, 5000); + + case 4: + case "end": + return _context5.stop(); + } + } + }, _callee5); + })); + + return function (_x9, _x10) { + return _ref5.apply(this, arguments); + }; + }(); +}; +var DELETE_ALERT = "metabase/alerts/DELETE_ALERT"; +var deleteAlertRequest = new metabase_lib_request__WEBPACK_IMPORTED_MODULE_6__.RestfulRequest({ + endpoint: metabase_services__WEBPACK_IMPORTED_MODULE_5__.AlertApi.update, + actionPrefix: DELETE_ALERT, + storeAsDictionary: true +}); +var deleteAlert = function deleteAlert(alertId) { + return /*#__PURE__*/function () { + var _ref6 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6(dispatch, getState) { + return regeneratorRuntime.wrap(function _callee6$(_context6) { + while (1) { + switch (_context6.prev = _context6.next) { + case 0: + _context6.next = 2; + return dispatch(deleteAlertRequest.trigger({ + id: alertId, + archived: true + })); + + case 2: + dispatch((0,metabase_redux_undo__WEBPACK_IMPORTED_MODULE_3__.addUndo)({ + // eslint-disable-next-line react/display-name + message: function message() { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "flex align-center text-bold" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Icon__WEBPACK_IMPORTED_MODULE_7__.default, { + name: "alert_confirm", + size: "19", + className: "mr2 text-success" + }), (0,ttag__WEBPACK_IMPORTED_MODULE_4__.t)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["The alert was successfully deleted."])))); + } + })); + dispatch.action(DELETE_ALERT, alertId); + + case 4: + case "end": + return _context6.stop(); + } + } + }, _callee6); + })); + + return function (_x11, _x12) { + return _ref6.apply(this, arguments); + }; + }(); +}; // removal from the result dictionary (not supported by RestfulRequest yet) + +var removeAlertReducer = function removeAlertReducer(state, _ref7) { + var alertId = _ref7.payload; + return _objectSpread(_objectSpread({}, state), {}, { + result: underscore__WEBPACK_IMPORTED_MODULE_1__.default.omit(state.result || {}, alertId) + }); +}; + +var removeAlertsForQuestionReducer = function removeAlertsForQuestionReducer(state, _ref8) { + var questionId = _ref8.payload; + return _objectSpread(_objectSpread({}, state), {}, { + result: underscore__WEBPACK_IMPORTED_MODULE_1__.default.omit(state.result || {}, function (alert) { + return alert.card.id === questionId; + }) + }); +}; + +var alerts = (0,redux_actions__WEBPACK_IMPORTED_MODULE_8__.default)(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, fetchAllAlertsRequest.getReducers()), {}, _defineProperty({}, FETCH_ALERTS_FOR_QUESTION_CLEAR_OLD_ALERTS, removeAlertsForQuestionReducer), fetchAlertsForQuestionRequest.getReducers()), createAlertRequest.getReducers()), updateAlertRequest.getReducers()), {}, (_objectSpread3 = {}, _defineProperty(_objectSpread3, DELETE_ALERT, removeAlertReducer), _defineProperty(_objectSpread3, UNSUBSCRIBE_FROM_ALERT_CLEANUP, removeAlertReducer), _objectSpread3)), []); +/* harmony default export */ __webpack_exports__["default"] = ((0,redux__WEBPACK_IMPORTED_MODULE_2__.combineReducers)({ + alerts: alerts +})); + +/***/ }), + +/***/ "./alert/selectors.js": +/*!****************************!*\ + !*** ./alert/selectors.js ***! + \****************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "getAlerts": function() { return /* binding */ getAlerts; } +/* harmony export */ }); +var getAlerts = function getAlerts(state) { + return state.alert.alerts.result; +}; + +/***/ }), + +/***/ "./app-public.js": +/*!***********************!*\ + !*** ./app-public.js ***! + \***********************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var _app__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./app */ "./app.js"); +/* harmony import */ var _routes_public__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./routes-public */ "./routes-public.jsx"); +/* harmony import */ var _reducers_public__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./reducers-public */ "./reducers-public.js"); + + + +(0,_app__WEBPACK_IMPORTED_MODULE_0__.init)(_reducers_public__WEBPACK_IMPORTED_MODULE_2__.default, _routes_public__WEBPACK_IMPORTED_MODULE_1__.getRoutes, function () {}); + +/***/ }), + +/***/ "./app.js": +/*!****************!*\ + !*** ./app.js ***! + \****************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "init": function() { return /* binding */ init; } +/* harmony export */ }); +/* harmony import */ var core_js_stable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! core-js/stable */ "../../../node_modules/core-js/stable/index.js"); +/* harmony import */ var core_js_stable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(core_js_stable__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var regenerator_runtime_runtime__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! regenerator-runtime/runtime */ "../../../node_modules/regenerator-runtime/runtime.js"); +/* harmony import */ var regenerator_runtime_runtime__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(regenerator_runtime_runtime__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var classlist_polyfill__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! classlist-polyfill */ "../../../node_modules/classlist-polyfill/src/index.js"); +/* harmony import */ var classlist_polyfill__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(classlist_polyfill__WEBPACK_IMPORTED_MODULE_2__); +/* harmony import */ var number_to_locale_string__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! number-to-locale-string */ "../../../node_modules/number-to-locale-string/polyfill.number.toLocaleString.js"); +/* harmony import */ var number_to_locale_string__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(number_to_locale_string__WEBPACK_IMPORTED_MODULE_3__); +/* harmony import */ var metabase_lib_i18n_debug__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! metabase/lib/i18n-debug */ "./lib/i18n-debug.js"); +/* harmony import */ var metabase_lib_i18n__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! metabase/lib/i18n */ "./lib/i18n.js"); +/* harmony import */ var metabase_lib_colors__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! metabase/lib/colors */ "./lib/colors.ts"); +/* harmony import */ var metabase_plugins_builtin__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! metabase/plugins/builtin */ "./plugins/builtin.js"); +/* harmony import */ var ee_plugins__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ee-plugins */ "./lib/noop.js"); +/* harmony import */ var ee_plugins__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(ee_plugins__WEBPACK_IMPORTED_MODULE_8__); +/* harmony import */ var metabase_plugins__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! metabase/plugins */ "./plugins/index.js"); +/* harmony import */ var metabase_visualizations_register__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! metabase/visualizations/register */ "./visualizations/register.js"); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! react-dom */ "../../../node_modules/react-dom/index.js"); +/* harmony import */ var react_redux__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! react-redux */ "../../../node_modules/react-redux/es/index.js"); +/* harmony import */ var styled_components__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! styled-components */ "../../../node_modules/styled-components/dist/styled-components.browser.es.js"); +/* harmony import */ var metabase_lib_analytics__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! metabase/lib/analytics */ "./lib/analytics.js"); +/* harmony import */ var metabase_lib_settings__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! metabase/lib/settings */ "./lib/settings.ts"); +/* harmony import */ var metabase_lib_api__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! metabase/lib/api */ "./lib/api.js"); +/* harmony import */ var metabase_lib_embed__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! metabase/lib/embed */ "./lib/embed.js"); +/* harmony import */ var _store__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./store */ "./store.js"); +/* harmony import */ var metabase_redux_settings__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! metabase/redux/settings */ "./redux/settings.js"); +/* harmony import */ var react_router__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! react-router */ "../../../node_modules/react-router/es/index.js"); +/* harmony import */ var history__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! history */ "../../../node_modules/history/lib/index.js"); +/* harmony import */ var react_router_redux__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! react-router-redux */ "../../../node_modules/react-router-redux/lib/index.js"); +/* harmony import */ var react_dnd_html5_backend__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! react-dnd-html5-backend */ "../../../node_modules/react-dnd-html5-backend/lib/index.js"); +/* harmony import */ var react_dnd_html5_backend__WEBPACK_IMPORTED_MODULE_24___default = /*#__PURE__*/__webpack_require__.n(react_dnd_html5_backend__WEBPACK_IMPORTED_MODULE_24__); +/* harmony import */ var react_dnd__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! react-dnd */ "../../../node_modules/react-dnd/lib/index.js"); +function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } + +function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } + + + // Use of classList.add and .remove in Background and FitViewPort Hocs requires +// this polyfill so that those work in older browsers + + + // If enabled this monkeypatches `t` and `jt` to return blacked out +// strings/elements to assist in finding untranslated strings. + + // set the locale before loading anything else + + // NOTE: why do we need to load this here? + + // NOTE: this loads all builtin plugins + + // This is conditionally aliased in the webpack config. +// If EE isn't enabled, it loads an empty file. + + // eslint-disable-line import/no-unresolved + + + + + + + + + + + + + // router + + + + // drag and drop + + + // remove trailing slash + +var BASENAME = window.MetabaseRoot.replace(/\/+$/, ""); +metabase_lib_api__WEBPACK_IMPORTED_MODULE_17__.default.basename = BASENAME; // eslint-disable-next-line react-hooks/rules-of-hooks + +var browserHistory = (0,react_router__WEBPACK_IMPORTED_MODULE_21__.useRouterHistory)(history__WEBPACK_IMPORTED_MODULE_22__.createHistory)({ + basename: BASENAME +}); +var theme = { + space: [4, 8, 16, 32, 64, 128] +}; + +function _init(reducers, getRoutes, callback) { + var store = (0,_store__WEBPACK_IMPORTED_MODULE_19__.getStore)(reducers, browserHistory); + var routes = getRoutes(store); + var history = (0,react_router_redux__WEBPACK_IMPORTED_MODULE_23__.syncHistoryWithStore)(browserHistory, store); + (0,metabase_lib_analytics__WEBPACK_IMPORTED_MODULE_15__.createTracker)(store); + var root; + react_dom__WEBPACK_IMPORTED_MODULE_12__.render( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_11__.createElement(react_redux__WEBPACK_IMPORTED_MODULE_13__.Provider, { + store: store, + ref: function ref(_ref) { + return root = _ref; + } + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_11__.createElement(react_dnd__WEBPACK_IMPORTED_MODULE_25__.DragDropContextProvider, { + backend: (react_dnd_html5_backend__WEBPACK_IMPORTED_MODULE_24___default()), + context: { + window: window + } + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_11__.createElement(styled_components__WEBPACK_IMPORTED_MODULE_14__.ThemeProvider, { + theme: theme + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_11__.createElement(react_router__WEBPACK_IMPORTED_MODULE_21__.Router, { + history: history + }, routes)))), document.getElementById("root")); + (0,metabase_visualizations_register__WEBPACK_IMPORTED_MODULE_10__.default)(); + (0,metabase_lib_embed__WEBPACK_IMPORTED_MODULE_18__.initializeEmbedding)(store); + store.dispatch((0,metabase_redux_settings__WEBPACK_IMPORTED_MODULE_20__.refreshSiteSettings)()); + metabase_lib_settings__WEBPACK_IMPORTED_MODULE_16__.default.on("user-locale", /*#__PURE__*/function () { + var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(locale) { + return regeneratorRuntime.wrap(function _callee$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + _context.next = 2; + return Promise.all([(0,metabase_lib_i18n__WEBPACK_IMPORTED_MODULE_5__.loadLocalization)(locale), store.dispatch((0,metabase_redux_settings__WEBPACK_IMPORTED_MODULE_20__.refreshSiteSettings)({ + locale: locale + }))]); + + case 2: + // force re-render of React application + root.forceUpdate(); + + case 3: + case "end": + return _context.stop(); + } + } + }, _callee); + })); + + return function (_x) { + return _ref2.apply(this, arguments); + }; + }()); + metabase_plugins__WEBPACK_IMPORTED_MODULE_9__.PLUGIN_APP_INIT_FUCTIONS.forEach(function (init) { + return init({ + root: root + }); + }); + window.Metabase = window.Metabase || {}; + window.Metabase.store = store; + window.Metabase.settings = metabase_lib_settings__WEBPACK_IMPORTED_MODULE_16__.default; + + if (callback) { + callback(store); + } +} + +function init() { + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + if (document.readyState !== "loading") { + _init.apply(void 0, args); + } else { + document.addEventListener("DOMContentLoaded", function () { + return _init.apply(void 0, args); + }); + } +} + +/***/ }), + +/***/ "./auth/actions.ts": +/*!*************************!*\ + !*** ./auth/actions.ts ***! + \*************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "REFRESH_SESSION": function() { return /* binding */ REFRESH_SESSION; }, +/* harmony export */ "refreshSession": function() { return /* binding */ refreshSession; }, +/* harmony export */ "LOGIN": function() { return /* binding */ LOGIN; }, +/* harmony export */ "login": function() { return /* binding */ login; }, +/* harmony export */ "LOGIN_GOOGLE": function() { return /* binding */ LOGIN_GOOGLE; }, +/* harmony export */ "loginGoogle": function() { return /* binding */ loginGoogle; }, +/* harmony export */ "LOGOUT": function() { return /* binding */ LOGOUT; }, +/* harmony export */ "logout": function() { return /* binding */ logout; }, +/* harmony export */ "FORGOT_PASSWORD": function() { return /* binding */ FORGOT_PASSWORD; }, +/* harmony export */ "forgotPassword": function() { return /* binding */ forgotPassword; }, +/* harmony export */ "RESET_PASSWORD": function() { return /* binding */ RESET_PASSWORD; }, +/* harmony export */ "resetPassword": function() { return /* binding */ resetPassword; }, +/* harmony export */ "VALIDATE_PASSWORD": function() { return /* binding */ VALIDATE_PASSWORD; }, +/* harmony export */ "validatePassword": function() { return /* binding */ validatePassword; }, +/* harmony export */ "VALIDATE_PASSWORD_TOKEN": function() { return /* binding */ VALIDATE_PASSWORD_TOKEN; }, +/* harmony export */ "validatePasswordToken": function() { return /* binding */ validatePasswordToken; } +/* harmony export */ }); +/* harmony import */ var react_router_redux__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react-router-redux */ "../../../node_modules/react-router-redux/lib/index.js"); +/* harmony import */ var icepick__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! icepick */ "../../../node_modules/icepick/icepick.min.js"); +/* harmony import */ var icepick__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(icepick__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var metabase_services__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/services */ "./services.js"); +/* harmony import */ var metabase_lib_redux__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/lib/redux */ "./lib/redux.js"); +/* harmony import */ var metabase_lib_auth__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! metabase/lib/auth */ "./lib/auth.js"); +/* harmony import */ var metabase_redux_settings__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! metabase/redux/settings */ "./redux/settings.js"); +/* harmony import */ var metabase_redux_user__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! metabase/redux/user */ "./redux/user.js"); +/* harmony import */ var _analytics__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./analytics */ "./auth/analytics.ts"); +function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } + +function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } + + + + + + + + + +var REFRESH_SESSION = "metabase/auth/REFRESH_SESSION"; +var refreshSession = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_3__.createThunkAction)(REFRESH_SESSION, function () { + return /*#__PURE__*/function () { + var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(dispatch) { + return regeneratorRuntime.wrap(function _callee$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + _context.next = 2; + return Promise.all([dispatch((0,metabase_redux_user__WEBPACK_IMPORTED_MODULE_6__.refreshCurrentUser)()), dispatch((0,metabase_redux_settings__WEBPACK_IMPORTED_MODULE_5__.refreshSiteSettings)())]); + + case 2: + case "end": + return _context.stop(); + } + } + }, _callee); + })); + + return function (_x) { + return _ref.apply(this, arguments); + }; + }(); +}); +var LOGIN = "metabase/auth/LOGIN"; +var login = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_3__.createThunkAction)(LOGIN, function (data) { + var redirectUrl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "/"; + return /*#__PURE__*/function () { + var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(dispatch) { + return regeneratorRuntime.wrap(function _callee2$(_context2) { + while (1) { + switch (_context2.prev = _context2.next) { + case 0: + _context2.next = 2; + return metabase_services__WEBPACK_IMPORTED_MODULE_2__.SessionApi.create(data); + + case 2: + (0,_analytics__WEBPACK_IMPORTED_MODULE_7__.trackLogin)(); + _context2.next = 5; + return dispatch(refreshSession()); + + case 5: + dispatch((0,react_router_redux__WEBPACK_IMPORTED_MODULE_0__.push)(redirectUrl)); + + case 6: + case "end": + return _context2.stop(); + } + } + }, _callee2); + })); + + return function (_x2) { + return _ref2.apply(this, arguments); + }; + }(); +}); +var LOGIN_GOOGLE = "metabase/auth/LOGIN_GOOGLE"; +var loginGoogle = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_3__.createThunkAction)(LOGIN_GOOGLE, function (token) { + var redirectUrl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "/"; + return /*#__PURE__*/function () { + var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(dispatch) { + return regeneratorRuntime.wrap(function _callee3$(_context3) { + while (1) { + switch (_context3.prev = _context3.next) { + case 0: + _context3.prev = 0; + _context3.next = 3; + return metabase_services__WEBPACK_IMPORTED_MODULE_2__.SessionApi.createWithGoogleAuth({ + token: token + }); + + case 3: + (0,_analytics__WEBPACK_IMPORTED_MODULE_7__.trackLoginGoogle)(); + _context3.next = 6; + return dispatch(refreshSession()); + + case 6: + dispatch((0,react_router_redux__WEBPACK_IMPORTED_MODULE_0__.push)(redirectUrl)); + _context3.next = 14; + break; + + case 9: + _context3.prev = 9; + _context3.t0 = _context3["catch"](0); + _context3.next = 13; + return (0,metabase_lib_auth__WEBPACK_IMPORTED_MODULE_4__.clearGoogleAuthCredentials)(); + + case 13: + throw _context3.t0; + + case 14: + case "end": + return _context3.stop(); + } + } + }, _callee3, null, [[0, 9]]); + })); + + return function (_x3) { + return _ref3.apply(this, arguments); + }; + }(); +}); +var LOGOUT = "metabase/auth/LOGOUT"; +var logout = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_3__.createThunkAction)(LOGOUT, function () { + return /*#__PURE__*/function () { + var _ref4 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(dispatch) { + return regeneratorRuntime.wrap(function _callee4$(_context4) { + while (1) { + switch (_context4.prev = _context4.next) { + case 0: + _context4.next = 2; + return (0,metabase_lib_auth__WEBPACK_IMPORTED_MODULE_4__.deleteSession)(); + + case 2: + _context4.next = 4; + return (0,metabase_lib_auth__WEBPACK_IMPORTED_MODULE_4__.clearGoogleAuthCredentials)(); + + case 4: + _context4.next = 6; + return dispatch((0,metabase_redux_user__WEBPACK_IMPORTED_MODULE_6__.clearCurrentUser)()); + + case 6: + (0,_analytics__WEBPACK_IMPORTED_MODULE_7__.trackLogout)(); + dispatch((0,react_router_redux__WEBPACK_IMPORTED_MODULE_0__.push)("/auth/login")); + window.location.reload(); + + case 9: + case "end": + return _context4.stop(); + } + } + }, _callee4); + })); + + return function (_x4) { + return _ref4.apply(this, arguments); + }; + }(); +}); +var FORGOT_PASSWORD = "metabase/auth/FORGOT_PASSWORD"; +var forgotPassword = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_3__.createThunkAction)(FORGOT_PASSWORD, function (email) { + return /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5() { + return regeneratorRuntime.wrap(function _callee5$(_context5) { + while (1) { + switch (_context5.prev = _context5.next) { + case 0: + _context5.next = 2; + return metabase_services__WEBPACK_IMPORTED_MODULE_2__.SessionApi.forgot_password({ + email: email + }); + + case 2: + case "end": + return _context5.stop(); + } + } + }, _callee5); + })); +}); +var RESET_PASSWORD = "metabase/auth/RESET_PASSWORD"; +var resetPassword = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_3__.createThunkAction)(RESET_PASSWORD, function (token, password) { + return /*#__PURE__*/function () { + var _ref6 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6(dispatch) { + return regeneratorRuntime.wrap(function _callee6$(_context6) { + while (1) { + switch (_context6.prev = _context6.next) { + case 0: + _context6.next = 2; + return metabase_services__WEBPACK_IMPORTED_MODULE_2__.SessionApi.reset_password({ + token: token, + password: password + }); + + case 2: + _context6.next = 4; + return dispatch(refreshSession()); + + case 4: + (0,_analytics__WEBPACK_IMPORTED_MODULE_7__.trackPasswordReset)(); + + case 5: + case "end": + return _context6.stop(); + } + } + }, _callee6); + })); + + return function (_x5) { + return _ref6.apply(this, arguments); + }; + }(); +}); +var VALIDATE_PASSWORD = "metabase/auth/VALIDATE_PASSWORD"; +var validatePassword = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_3__.createThunkAction)(VALIDATE_PASSWORD, function (password) { + return /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee7() { + return regeneratorRuntime.wrap(function _callee7$(_context7) { + while (1) { + switch (_context7.prev = _context7.next) { + case 0: + _context7.next = 2; + return metabase_services__WEBPACK_IMPORTED_MODULE_2__.UtilApi.password_check({ + password: password + }); + + case 2: + case "end": + return _context7.stop(); + } + } + }, _callee7); + })); +}); +var VALIDATE_PASSWORD_TOKEN = "metabase/auth/VALIDATE_TOKEN"; +var validatePasswordToken = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_3__.createThunkAction)(VALIDATE_PASSWORD_TOKEN, function (token) { + return /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee8() { + var result, valid; + return regeneratorRuntime.wrap(function _callee8$(_context8) { + while (1) { + switch (_context8.prev = _context8.next) { + case 0: + _context8.next = 2; + return metabase_services__WEBPACK_IMPORTED_MODULE_2__.SessionApi.password_reset_token_valid({ + token: token + }); + + case 2: + result = _context8.sent; + valid = (0,icepick__WEBPACK_IMPORTED_MODULE_1__.getIn)(result, ["valid"]); + + if (valid) { + _context8.next = 6; + break; + } + + throw result; + + case 6: + case "end": + return _context8.stop(); + } + } + }, _callee8); + })); +}); + +/***/ }), + +/***/ "./auth/analytics.ts": +/*!***************************!*\ + !*** ./auth/analytics.ts ***! + \***************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "trackLogin": function() { return /* binding */ trackLogin; }, +/* harmony export */ "trackLoginGoogle": function() { return /* binding */ trackLoginGoogle; }, +/* harmony export */ "trackLogout": function() { return /* binding */ trackLogout; }, +/* harmony export */ "trackPasswordReset": function() { return /* binding */ trackPasswordReset; } +/* harmony export */ }); +/* harmony import */ var metabase_lib_analytics__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! metabase/lib/analytics */ "./lib/analytics.js"); + +var trackLogin = function trackLogin() { + (0,metabase_lib_analytics__WEBPACK_IMPORTED_MODULE_0__.trackStructEvent)("Auth", "Login"); +}; +var trackLoginGoogle = function trackLoginGoogle() { + (0,metabase_lib_analytics__WEBPACK_IMPORTED_MODULE_0__.trackStructEvent)("Auth", "Google Auth Login"); +}; +var trackLogout = function trackLogout() { + (0,metabase_lib_analytics__WEBPACK_IMPORTED_MODULE_0__.trackStructEvent)("Auth", "Logout"); +}; +var trackPasswordReset = function trackPasswordReset() { + (0,metabase_lib_analytics__WEBPACK_IMPORTED_MODULE_0__.trackStructEvent)("Auth", "Password Reset"); +}; + +/***/ }), + +/***/ "./auth/components/AuthButton/AuthButton.styled.tsx": +/*!**********************************************************!*\ + !*** ./auth/components/AuthButton/AuthButton.styled.tsx ***! + \**********************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "TextLink": function() { return /* binding */ TextLink; }, +/* harmony export */ "CardLink": function() { return /* binding */ CardLink; }, +/* harmony export */ "CardIcon": function() { return /* binding */ CardIcon; }, +/* harmony export */ "CardText": function() { return /* binding */ CardText; } +/* harmony export */ }); +/* harmony import */ var styled_components__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! styled-components */ "../../../node_modules/styled-components/dist/styled-components.browser.es.js"); +/* harmony import */ var metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/lib/colors */ "./lib/colors.ts"); +/* harmony import */ var metabase_components_Icon__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/components/Icon */ "./components/Icon.tsx"); +/* harmony import */ var metabase_components_Link__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/components/Link */ "./components/Link.tsx"); + + + + +var TextLink = (0,styled_components__WEBPACK_IMPORTED_MODULE_0__.default)(metabase_components_Link__WEBPACK_IMPORTED_MODULE_3__.default).withConfig({ + displayName: "AuthButtonstyled__TextLink", + componentId: "j2pohn-0" +})(["cursor:pointer;color:", ";&:hover{color:", ";}"], (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.color)("text-dark"), (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.color)("brand")); +var CardLink = (0,styled_components__WEBPACK_IMPORTED_MODULE_0__.default)(TextLink).withConfig({ + displayName: "AuthButtonstyled__CardLink", + componentId: "j2pohn-1" +})(["display:flex;justify-content:center;align-items:center;padding:1.25rem;background-color:", ";box-shadow:0 3px 10px ", ";border-radius:6px;"], (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.color)("white"), (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.color)("shadow")); +var CardIcon = (0,styled_components__WEBPACK_IMPORTED_MODULE_0__.default)(metabase_components_Icon__WEBPACK_IMPORTED_MODULE_2__.default).withConfig({ + displayName: "AuthButtonstyled__CardIcon", + componentId: "j2pohn-2" +})(["margin-right:0.5rem;"]); +var CardText = styled_components__WEBPACK_IMPORTED_MODULE_0__.default.span.withConfig({ + displayName: "AuthButtonstyled__CardText", + componentId: "j2pohn-3" +})(["font-weight:700;line-height:1rem;"]); + +/***/ }), + +/***/ "./auth/components/AuthButton/AuthButton.tsx": +/*!***************************************************!*\ + !*** ./auth/components/AuthButton/AuthButton.tsx ***! + \***************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var _AuthButton_styled__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./AuthButton.styled */ "./auth/components/AuthButton/AuthButton.styled.tsx"); + + + +var AuthButton = function AuthButton(_ref) { + var _ref$link = _ref.link, + link = _ref$link === void 0 ? "" : _ref$link, + icon = _ref.icon, + isCard = _ref.isCard, + children = _ref.children, + onClick = _ref.onClick; + return isCard ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_AuthButton_styled__WEBPACK_IMPORTED_MODULE_1__.CardLink, { + to: link, + onClick: onClick + }, icon && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_AuthButton_styled__WEBPACK_IMPORTED_MODULE_1__.CardIcon, { + name: icon + }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_AuthButton_styled__WEBPACK_IMPORTED_MODULE_1__.CardText, null, children)) : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_AuthButton_styled__WEBPACK_IMPORTED_MODULE_1__.TextLink, { + to: link, + onClick: onClick + }, children); +}; + +/* harmony default export */ __webpack_exports__["default"] = (AuthButton); + +/***/ }), + +/***/ "./auth/components/AuthButton/index.ts": +/*!*********************************************!*\ + !*** ./auth/components/AuthButton/index.ts ***! + \*********************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* reexport safe */ _AuthButton__WEBPACK_IMPORTED_MODULE_0__.default; } +/* harmony export */ }); +/* harmony import */ var _AuthButton__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./AuthButton */ "./auth/components/AuthButton/AuthButton.tsx"); + + +/***/ }), + +/***/ "./auth/components/GoogleButton/GoogleButton.styled.tsx": +/*!**************************************************************!*\ + !*** ./auth/components/GoogleButton/GoogleButton.styled.tsx ***! + \**************************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "AuthError": function() { return /* binding */ AuthError; }, +/* harmony export */ "AuthErrorContainer": function() { return /* binding */ AuthErrorContainer; } +/* harmony export */ }); +/* harmony import */ var styled_components__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! styled-components */ "../../../node_modules/styled-components/dist/styled-components.browser.es.js"); +/* harmony import */ var metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/lib/colors */ "./lib/colors.ts"); + + +var AuthError = styled_components__WEBPACK_IMPORTED_MODULE_0__.default.div.withConfig({ + displayName: "GoogleButtonstyled__AuthError", + componentId: "qxy76b-0" +})(["color:", ";text-align:center;"], (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.color)("error")); +var AuthErrorContainer = styled_components__WEBPACK_IMPORTED_MODULE_0__.default.div.withConfig({ + displayName: "GoogleButtonstyled__AuthErrorContainer", + componentId: "qxy76b-1" +})(["margin-top:1rem;"]); + +/***/ }), + +/***/ "./auth/components/GoogleButton/GoogleButton.tsx": +/*!*******************************************************!*\ + !*** ./auth/components/GoogleButton/GoogleButton.tsx ***! + \*******************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var icepick__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! icepick */ "../../../node_modules/icepick/icepick.min.js"); +/* harmony import */ var icepick__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(icepick__WEBPACK_IMPORTED_MODULE_2__); +/* harmony import */ var _AuthButton__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../AuthButton */ "./auth/components/AuthButton/index.ts"); +/* harmony import */ var _GoogleButton_styled__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./GoogleButton.styled */ "./auth/components/GoogleButton/GoogleButton.styled.tsx"); +var _templateObject; + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + +function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } + +function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } + +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } + +function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } + +function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } + + + + + + + +var GoogleButton = function GoogleButton(_ref) { + var isCard = _ref.isCard, + redirectUrl = _ref.redirectUrl, + onAttach = _ref.onAttach, + onLogin = _ref.onLogin; + var ref = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null); + + var _useState = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)([]), + _useState2 = _slicedToArray(_useState, 2), + errors = _useState2[0], + setErrors = _useState2[1]; + + var handleLogin = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)( /*#__PURE__*/function () { + var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(token) { + return regeneratorRuntime.wrap(function _callee$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + _context.prev = 0; + setErrors([]); + _context.next = 4; + return onLogin(token, redirectUrl); + + case 4: + _context.next = 9; + break; + + case 6: + _context.prev = 6; + _context.t0 = _context["catch"](0); + setErrors(getErrors(_context.t0)); + + case 9: + case "end": + return _context.stop(); + } + } + }, _callee, null, [[0, 6]]); + })); + + return function (_x) { + return _ref2.apply(this, arguments); + }; + }(), [onLogin, redirectUrl]); + var handleError = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function (error) { + setErrors([error]); + }, []); + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () { + ref.current && onAttach(ref.current, handleLogin, handleError); + }, [onAttach, handleLogin, handleError]); + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + ref: ref + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_AuthButton__WEBPACK_IMPORTED_MODULE_3__.default, { + icon: "google", + isCard: isCard + }, (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["Sign in with Google"])))), errors.length > 0 && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_GoogleButton_styled__WEBPACK_IMPORTED_MODULE_4__.AuthErrorContainer, null, errors.map(function (error, index) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_GoogleButton_styled__WEBPACK_IMPORTED_MODULE_4__.AuthError, { + key: index + }, error); + }))); +}; + +var getErrors = function getErrors(error) { + var errors = (0,icepick__WEBPACK_IMPORTED_MODULE_2__.getIn)(error, ["data", "errors"]); + return errors ? Object.values(errors) : []; +}; + +/* harmony default export */ __webpack_exports__["default"] = (GoogleButton); + +/***/ }), + +/***/ "./auth/components/GoogleButton/index.ts": +/*!***********************************************!*\ + !*** ./auth/components/GoogleButton/index.ts ***! + \***********************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* reexport safe */ _GoogleButton__WEBPACK_IMPORTED_MODULE_0__.default; } +/* harmony export */ }); +/* harmony import */ var _GoogleButton__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./GoogleButton */ "./auth/components/GoogleButton/GoogleButton.tsx"); + + +/***/ }), + +/***/ "./auth/components/PasswordButton/PasswordButton.tsx": +/*!***********************************************************!*\ + !*** ./auth/components/PasswordButton/PasswordButton.tsx ***! + \***********************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var _AuthButton__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../AuthButton */ "./auth/components/AuthButton/index.ts"); +var _templateObject; + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + + + + + +var PasswordButton = function PasswordButton(_ref) { + var redirectUrl = _ref.redirectUrl; + var link = redirectUrl ? "/auth/login/password?redirect=".concat(encodeURIComponent(redirectUrl)) : "/auth/login/password"; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_AuthButton__WEBPACK_IMPORTED_MODULE_2__.default, { + link: link + }, (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["Sign in with email"])))); +}; + +/* harmony default export */ __webpack_exports__["default"] = (PasswordButton); + +/***/ }), + +/***/ "./auth/components/PasswordButton/index.ts": +/*!*************************************************!*\ + !*** ./auth/components/PasswordButton/index.ts ***! + \*************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* reexport safe */ _PasswordButton__WEBPACK_IMPORTED_MODULE_0__.default; } +/* harmony export */ }); +/* harmony import */ var _PasswordButton__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./PasswordButton */ "./auth/components/PasswordButton/PasswordButton.tsx"); + + +/***/ }), + +/***/ "./auth/components/PasswordPanel/PasswordPanel.styled.tsx": +/*!****************************************************************!*\ + !*** ./auth/components/PasswordPanel/PasswordPanel.styled.tsx ***! + \****************************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "ActionList": function() { return /* binding */ ActionList; }, +/* harmony export */ "ActionListItem": function() { return /* binding */ ActionListItem; } +/* harmony export */ }); +/* harmony import */ var styled_components__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! styled-components */ "../../../node_modules/styled-components/dist/styled-components.browser.es.js"); + +var ActionList = styled_components__WEBPACK_IMPORTED_MODULE_0__.default.div.withConfig({ + displayName: "PasswordPanelstyled__ActionList", + componentId: "sc-2n7xm1-0" +})(["display:flex;flex-direction:column;align-items:center;margin-top:1.5rem;"]); +var ActionListItem = styled_components__WEBPACK_IMPORTED_MODULE_0__.default.div.withConfig({ + displayName: "PasswordPanelstyled__ActionListItem", + componentId: "sc-2n7xm1-1" +})(["&:not(:last-child){margin-bottom:1rem;}"]); + +/***/ }), + +/***/ "./auth/components/PasswordPanel/PasswordPanel.tsx": +/*!*********************************************************!*\ + !*** ./auth/components/PasswordPanel/PasswordPanel.tsx ***! + \*********************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var metabase_entities_users__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/entities/users */ "./entities/users.js"); +/* harmony import */ var _AuthButton__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../AuthButton */ "./auth/components/AuthButton/index.ts"); +/* harmony import */ var _PasswordPanel_styled__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./PasswordPanel.styled */ "./auth/components/PasswordPanel/PasswordPanel.styled.tsx"); +var _templateObject, _templateObject2; + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + +function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } + +function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } + + + + + + + +var PasswordPanel = function PasswordPanel(_ref) { + var _ref$providers = _ref.providers, + providers = _ref$providers === void 0 ? [] : _ref$providers, + redirectUrl = _ref.redirectUrl, + onLogin = _ref.onLogin; + var handleSubmit = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)( /*#__PURE__*/function () { + var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(data) { + return regeneratorRuntime.wrap(function _callee$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + _context.next = 2; + return onLogin(data, redirectUrl); + + case 2: + case "end": + return _context.stop(); + } + } + }, _callee); + })); + + return function (_x) { + return _ref2.apply(this, arguments); + }; + }(), [onLogin, redirectUrl]); + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_entities_users__WEBPACK_IMPORTED_MODULE_2__.default.Form, { + form: metabase_entities_users__WEBPACK_IMPORTED_MODULE_2__.default.forms.login(), + submitTitle: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["Sign in"]))), + submitFullWidth: true, + onSubmit: handleSubmit + }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_PasswordPanel_styled__WEBPACK_IMPORTED_MODULE_4__.ActionList, null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_PasswordPanel_styled__WEBPACK_IMPORTED_MODULE_4__.ActionListItem, null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_AuthButton__WEBPACK_IMPORTED_MODULE_3__.default, { + link: "/auth/forgot_password" + }, (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["I seem to have forgotten my password"]))))), providers.map(function (provider) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_PasswordPanel_styled__WEBPACK_IMPORTED_MODULE_4__.ActionListItem, { + key: provider.name + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(provider.Button, { + redirectUrl: redirectUrl + })); + }))); +}; + +/* harmony default export */ __webpack_exports__["default"] = (PasswordPanel); + +/***/ }), + +/***/ "./auth/components/PasswordPanel/index.ts": +/*!************************************************!*\ + !*** ./auth/components/PasswordPanel/index.ts ***! + \************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* reexport safe */ _PasswordPanel__WEBPACK_IMPORTED_MODULE_0__.default; } +/* harmony export */ }); +/* harmony import */ var _PasswordPanel__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./PasswordPanel */ "./auth/components/PasswordPanel/PasswordPanel.tsx"); + + +/***/ }), + +/***/ "./auth/containers/GoogleButton/GoogleButton.tsx": +/*!*******************************************************!*\ + !*** ./auth/containers/GoogleButton/GoogleButton.tsx ***! + \*******************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react_redux__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react-redux */ "../../../node_modules/react-redux/es/index.js"); +/* harmony import */ var metabase_lib_auth__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/lib/auth */ "./lib/auth.js"); +/* harmony import */ var _components_GoogleButton__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../components/GoogleButton */ "./auth/components/GoogleButton/index.ts"); +/* harmony import */ var _actions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../actions */ "./auth/actions.ts"); + + + + + +var mapStateToProps = function mapStateToProps() { + return { + onAttach: metabase_lib_auth__WEBPACK_IMPORTED_MODULE_1__.attachGoogleAuth + }; +}; + +var mapDispatchToProps = { + onLogin: _actions__WEBPACK_IMPORTED_MODULE_3__.loginGoogle +}; +/* harmony default export */ __webpack_exports__["default"] = ((0,react_redux__WEBPACK_IMPORTED_MODULE_0__.connect)(mapStateToProps, mapDispatchToProps)(_components_GoogleButton__WEBPACK_IMPORTED_MODULE_2__.default)); + +/***/ }), + +/***/ "./auth/containers/GoogleButton/index.ts": +/*!***********************************************!*\ + !*** ./auth/containers/GoogleButton/index.ts ***! + \***********************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* reexport safe */ _GoogleButton__WEBPACK_IMPORTED_MODULE_0__.default; } +/* harmony export */ }); +/* harmony import */ var _GoogleButton__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./GoogleButton */ "./auth/containers/GoogleButton/GoogleButton.tsx"); + + +/***/ }), + +/***/ "./auth/containers/PasswordPanel/PasswordPanel.tsx": +/*!*********************************************************!*\ + !*** ./auth/containers/PasswordPanel/PasswordPanel.tsx ***! + \*********************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react_redux__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react-redux */ "../../../node_modules/react-redux/es/index.js"); +/* harmony import */ var _actions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../actions */ "./auth/actions.ts"); +/* harmony import */ var _components_PasswordPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../components/PasswordPanel */ "./auth/components/PasswordPanel/index.ts"); +/* harmony import */ var metabase_auth_selectors__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/auth/selectors */ "./auth/selectors.ts"); + + + + + +var mapStateToProps = function mapStateToProps(state) { + return { + providers: (0,metabase_auth_selectors__WEBPACK_IMPORTED_MODULE_3__.getExternalAuthProviders)(state) + }; +}; + +var mapDispatchToProps = { + onLogin: _actions__WEBPACK_IMPORTED_MODULE_1__.login +}; +/* harmony default export */ __webpack_exports__["default"] = ((0,react_redux__WEBPACK_IMPORTED_MODULE_0__.connect)(mapStateToProps, mapDispatchToProps)(_components_PasswordPanel__WEBPACK_IMPORTED_MODULE_2__.default)); + +/***/ }), + +/***/ "./auth/containers/PasswordPanel/index.ts": +/*!************************************************!*\ + !*** ./auth/containers/PasswordPanel/index.ts ***! + \************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* reexport safe */ _PasswordPanel__WEBPACK_IMPORTED_MODULE_0__.default; } +/* harmony export */ }); +/* harmony import */ var _PasswordPanel__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./PasswordPanel */ "./auth/containers/PasswordPanel/PasswordPanel.tsx"); + + +/***/ }), + +/***/ "./auth/selectors.ts": +/*!***************************!*\ + !*** ./auth/selectors.ts ***! + \***************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "getAuthProviders": function() { return /* binding */ getAuthProviders; }, +/* harmony export */ "getExternalAuthProviders": function() { return /* binding */ getExternalAuthProviders; } +/* harmony export */ }); +/* harmony import */ var reselect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! reselect */ "../../../node_modules/reselect/lib/index.js"); +/* harmony import */ var metabase_plugins__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/plugins */ "./plugins/index.js"); +/* harmony import */ var metabase_selectors_settings__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/selectors/settings */ "./selectors/settings.js"); + + + +var getAuthProviders = (0,reselect__WEBPACK_IMPORTED_MODULE_0__.createSelector)([metabase_selectors_settings__WEBPACK_IMPORTED_MODULE_2__.getSettings], function () { + return metabase_plugins__WEBPACK_IMPORTED_MODULE_1__.PLUGIN_AUTH_PROVIDERS.reduce(function (providers, getProviders) { + return getProviders(providers); + }, []); +}); +var getExternalAuthProviders = (0,reselect__WEBPACK_IMPORTED_MODULE_0__.createSelector)([getAuthProviders], function (providers) { + return providers.filter(function (provider) { + return provider.name !== "password"; + }); +}); + +/***/ }), + +/***/ "./collections/utils.js": +/*!******************************!*\ + !*** ./collections/utils.js ***! + \******************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "nonPersonalOrArchivedCollection": function() { return /* binding */ nonPersonalOrArchivedCollection; }, +/* harmony export */ "isPersonalCollection": function() { return /* binding */ isPersonalCollection; }, +/* harmony export */ "currentUserPersonalCollections": function() { return /* binding */ currentUserPersonalCollections; }, +/* harmony export */ "getParentPath": function() { return /* binding */ getParentPath; }, +/* harmony export */ "isPersonalCollectionChild": function() { return /* binding */ isPersonalCollectionChild; } +/* harmony export */ }); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var metabase_entities_collections__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/entities/collections */ "./entities/collections.js"); +var _templateObject; + +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } + +function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } + +function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } + +function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + + + +function nonPersonalOrArchivedCollection(collection) { + // @TODO - should this be an API thing? + return !isPersonalCollection(collection) && !collection.archived; +} +function isPersonalCollection(collection) { + return typeof collection.personal_owner_id === "number"; +} // Replace the name for the current user's collection +// @Question - should we just update the API to do this? + +function preparePersonalCollection(c) { + return _objectSpread(_objectSpread({}, c), {}, { + name: (0,ttag__WEBPACK_IMPORTED_MODULE_0__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["Your personal collection"]))), + originalName: c.name + }); +} // get the top level collection that matches the current user ID + + +function currentUserPersonalCollections(collectionList, userID) { + return collectionList.filter(function (l) { + return l.personal_owner_id === userID; + }).map(preparePersonalCollection); +} +function getParentPath(collections, targetId) { + if (collections.length === 0) { + return null; // not found! + } + + var _iterator = _createForOfIteratorHelper(collections), + _step; + + try { + for (_iterator.s(); !(_step = _iterator.n()).done;) { + var collection = _step.value; + + if (collection.id === targetId) { + return [collection.id]; // we found it! + } + + if (collection.children) { + var path = getParentPath(collection.children, targetId); + + if (path !== null) { + // we found it under this collection + return [collection.id].concat(_toConsumableArray(path)); + } + } + } + } catch (err) { + _iterator.e(err); + } finally { + _iterator.f(); + } + + return null; // didn't find it under any collection +} + +function getNonRootParentId(collection) { + var _collection$location, _collection$location$; + + if (Array.isArray(collection.effective_ancestors)) { + // eslint-disable-next-line no-unused-vars + var _collection$effective = _slicedToArray(collection.effective_ancestors, 2), + root = _collection$effective[0], + nonRootParent = _collection$effective[1]; + + return nonRootParent ? nonRootParent.id : undefined; + } // location is a string like "/1/4" where numbers are parent collection IDs + + + var nonRootParentId = (_collection$location = collection.location) === null || _collection$location === void 0 ? void 0 : (_collection$location$ = _collection$location.split("/")) === null || _collection$location$ === void 0 ? void 0 : _collection$location$[0]; + return (0,metabase_entities_collections__WEBPACK_IMPORTED_MODULE_1__.canonicalCollectionId)(nonRootParentId); +} + +function isPersonalCollectionChild(collection, collectionList) { + var nonRootParentId = getNonRootParentId(collection); + + if (!nonRootParentId) { + return false; + } + + var parentCollection = collectionList.find(function (c) { + return c.id === nonRootParentId; + }); + return parentCollection && !!parentCollection.personal_owner_id; +} + +/***/ }), + +/***/ "./components/AccordionList/AccordionList.jsx": +/*!****************************************************!*\ + !*** ./components/AccordionList/AccordionList.jsx ***! + \****************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* binding */ AccordionList; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prop-types */ "../../../node_modules/prop-types/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! classnames */ "../../../node_modules/classnames/index.js"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_2__); +/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! underscore */ "../../../node_modules/underscore/modules/index-all.js"); +/* harmony import */ var icepick__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! icepick */ "../../../node_modules/icepick/icepick.min.js"); +/* harmony import */ var icepick__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(icepick__WEBPACK_IMPORTED_MODULE_4__); +/* harmony import */ var metabase_lib_colors__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! metabase/lib/colors */ "./lib/colors.ts"); +/* harmony import */ var metabase_components_Icon__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! metabase/components/Icon */ "./components/Icon.tsx"); +/* harmony import */ var metabase_components_LoadingSpinner__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! metabase/components/LoadingSpinner */ "./components/LoadingSpinner/index.ts"); +/* harmony import */ var metabase_components_ListSearchField__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! metabase/components/ListSearchField */ "./components/ListSearchField.jsx"); +/* harmony import */ var react_virtualized__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! react-virtualized */ "../../../node_modules/react-virtualized/dist/es/index.js"); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } + +function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } + +function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } + +function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + + + + + + + + + + + + +var AccordionList = /*#__PURE__*/function (_Component) { + _inherits(AccordionList, _Component); + + var _super = _createSuper(AccordionList); + + function AccordionList(props, context) { + var _this; + + _classCallCheck(this, AccordionList); + + _this = _super.call(this, props, context); + + _defineProperty(_assertThisInitialized(_this), "toggleSection", function (sectionIndex) { + var _this$props = _this.props, + sections = _this$props.sections, + onChangeSection = _this$props.onChangeSection; + + if (onChangeSection) { + if (onChangeSection(sections[sectionIndex], sectionIndex) === false) { + return; + } + } + + var openSection = _this.getOpenSection(); + + if (openSection === sectionIndex) { + sectionIndex = null; + } + + _this.setState({ + openSection: sectionIndex + }); + }); + + _defineProperty(_assertThisInitialized(_this), "handleChange", function (item) { + if (_this.props.onChange) { + _this.props.onChange(item); + } + }); + + _defineProperty(_assertThisInitialized(_this), "handleChangeSearchText", function (searchText) { + _this.setState({ + searchText: searchText + }); + }); + + _defineProperty(_assertThisInitialized(_this), "searchPredicate", function (item, searchPropMember) { + var _this$props2 = _this.props, + searchCaseInsensitive = _this$props2.searchCaseInsensitive, + searchFuzzy = _this$props2.searchFuzzy; + var searchText = _this.state.searchText; + var path = searchPropMember.split("."); + var itemText = String((0,icepick__WEBPACK_IMPORTED_MODULE_4__.getIn)(item, path) || ""); + + if (searchCaseInsensitive) { + itemText = itemText.toLowerCase(); + searchText = searchText.toLowerCase(); + } + + if (searchFuzzy) { + return itemText.indexOf(searchText) >= 0; + } else { + return itemText.startsWith(searchText); + } + }); + + var _openSection; // use initiallyOpenSection prop if present + + + if (props.initiallyOpenSection !== undefined) { + _openSection = props.initiallyOpenSection; + } // otherwise try to find the selected section, if any + + + if (_openSection === undefined) { + _openSection = underscore__WEBPACK_IMPORTED_MODULE_3__.default.findIndex(props.sections, function (section, index) { + return _this.sectionIsSelected(section, index); + }); + + if (_openSection === -1) { + _openSection = undefined; + } + } // default to the first section + + + if (_openSection === undefined) { + _openSection = 0; + } + + _this.state = { + openSection: _openSection, + searchText: "" + }; + _this._cache = new react_virtualized__WEBPACK_IMPORTED_MODULE_9__.CellMeasurerCache({ + fixedWidth: true, + minHeight: 10 + }); + return _this; + } + + _createClass(AccordionList, [{ + key: "componentDidMount", + value: function componentDidMount() { + var _this2 = this; + + // NOTE: for some reason the row heights aren't computed correctly when + // first rendering, so force the list to update + this._forceUpdateList(); // `scrollToRow` upon mounting, after _forceUpdateList + // Use list.scrollToRow instead of the scrollToIndex prop since the + // causes the list's scrolling to be pinned to the selected row + + + setTimeout(function () { + var index = _this2._initialSelectedRowIndex; + + if (_this2._list && index != null && !(index >= _this2._startIndex && index <= _this2._stopIndex)) { + _this2._list.scrollToRow(_this2._initialSelectedRowIndex); + } + }, 0); + } + }, { + key: "componentDidUpdate", + value: function componentDidUpdate(prevProps, prevState) { + // if anything changes that affects the selected rows we need to clear the row height cache + if (this.state.openSection !== prevState.openSection || this.state.searchText !== prevState.searchText) { + this._clearRowHeightCache(); + } + } + }, { + key: "componentWillUnmount", + value: function componentWillUnmount() { + // ensure _forceUpdateList is not called after unmounting + if (this._forceUpdateTimeout != null) { + clearTimeout(this._forceUpdateTimeout); + this._forceUpdateTimeout = null; + } + } // resets the row height cache when the displayed rows change + + }, { + key: "_clearRowHeightCache", + value: function _clearRowHeightCache() { + var _this3 = this; + + this._cache.clearAll(); // NOTE: unclear why this needs to be async + + + this._forceUpdateTimeout = setTimeout(function () { + _this3._forceUpdateTimeout = null; + + _this3._forceUpdateList(); + }); + } + }, { + key: "_forceUpdateList", + value: function _forceUpdateList() { + if (this._list) { + // NOTE: unclear why this particular set of functions works, but it does + this._list.invalidateCellSizeAfterRender({ + columnIndex: 0, + rowIndex: 0 + }); + + this._list.forceUpdateGrid(); + + this.forceUpdate(); + } + } + }, { + key: "getOpenSection", + value: function getOpenSection() { + if (this.props.sections.length === 1) { + return 0; + } + + var openSection = this.state.openSection; + + if (openSection === undefined) { + var _iterator = _createForOfIteratorHelper(this.props.sections.entries()), + _step; + + try { + for (_iterator.s(); !(_step = _iterator.n()).done;) { + var _step$value = _slicedToArray(_step.value, 2), + index = _step$value[0], + section = _step$value[1]; + + if (this.sectionIsSelected(section, index)) { + openSection = index; + break; + } + } + } catch (err) { + _iterator.e(err); + } finally { + _iterator.f(); + } + } + + return openSection; + } + }, { + key: "sectionIsSelected", + value: function sectionIsSelected(section, sectionIndex) { + var _this4 = this; + + var sections = this.props.sections; + var selectedSection = null; + + for (var i = 0; i < sections.length; i++) { + if (underscore__WEBPACK_IMPORTED_MODULE_3__.default.some(sections[i].items, function (item) { + return _this4.props.itemIsSelected(item); + })) { + selectedSection = i; + break; + } + } + + return selectedSection === sectionIndex; + } + }, { + key: "render", + value: function render() { + var _this5 = this; + + var _this$props3 = this.props, + id = _this$props3.id, + style = _this$props3.style, + className = _this$props3.className, + searchable = _this$props3.searchable, + searchProp = _this$props3.searchProp, + sections = _this$props3.sections, + alwaysTogglable = _this$props3.alwaysTogglable, + alwaysExpanded = _this$props3.alwaysExpanded, + hideSingleSectionTitle = _this$props3.hideSingleSectionTitle; + var openSection = this.getOpenSection(); + + var sectionIsExpanded = function sectionIsExpanded(sectionIndex) { + return alwaysExpanded || openSection === sectionIndex; + }; + + var sectionIsSearchable = function sectionIsSearchable(sectionIndex) { + return searchable && (typeof searchable !== "function" || searchable(sections[sectionIndex])); + }; + + var sectionIsTogglable = function sectionIsTogglable(sectionIndex) { + return alwaysTogglable || sections.length > 1; + }; + + var searchText = this.state.searchText; + + var searchFilter = function searchFilter() { + return true; + }; + + if (searchText) { + searchFilter = function searchFilter(item) { + if (typeof searchProp === "string") { + return _this5.searchPredicate(item, searchProp); + } else if (Array.isArray(searchProp)) { + var searchResults = searchProp.map(function (member) { + return _this5.searchPredicate(item, member); + }); + return searchResults.reduce(function (acc, curr) { + return acc || curr; + }); + } + }; + } // if any section is searchable just enable a global search + + + var globalSearch = false; + var rows = []; + + var _iterator2 = _createForOfIteratorHelper(sections.entries()), + _step2; + + try { + for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { + var _step2$value = _slicedToArray(_step2.value, 2), + sectionIndex = _step2$value[0], + section = _step2$value[1]; + + var isLastSection = sectionIndex === sections.length - 1; + + if (section.name && (!hideSingleSectionTitle || sections.length > 1 || alwaysTogglable)) { + rows.push({ + type: "header", + section: section, + sectionIndex: sectionIndex, + isLastSection: isLastSection + }); + } else { + rows.push({ + type: "header-hidden", + section: section, + sectionIndex: sectionIndex, + isLastSection: isLastSection + }); + } + + if (sectionIsSearchable(sectionIndex) && sectionIsExpanded(sectionIndex) && section.items && section.items.length > 0 && !section.loading) { + if (alwaysExpanded) { + globalSearch = true; + } else { + rows.push({ + type: "search", + section: section, + sectionIndex: sectionIndex, + isLastSection: isLastSection + }); + } + } + + if (sectionIsExpanded(sectionIndex) && section.items && section.items.length > 0 && !section.loading) { + var _iterator3 = _createForOfIteratorHelper(section.items.entries()), + _step3; + + try { + for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) { + var _step3$value = _slicedToArray(_step3.value, 2), + itemIndex = _step3$value[0], + item = _step3$value[1]; + + if (searchFilter(item)) { + var isLastItem = itemIndex === section.items.length - 1; + + if (this.props.itemIsSelected(item)) { + this._initialSelectedRowIndex = rows.length; + } + + rows.push({ + type: "item", + section: section, + sectionIndex: sectionIndex, + isLastSection: isLastSection, + item: item, + itemIndex: itemIndex, + isLastItem: isLastItem + }); + } + } + } catch (err) { + _iterator3.e(err); + } finally { + _iterator3.f(); + } + } + + if (sectionIsExpanded(sectionIndex) && section.loading) { + rows.push({ + type: "loading", + section: section, + sectionIndex: sectionIndex, + isLastSection: isLastSection + }); + } + } + } catch (err) { + _iterator2.e(err); + } finally { + _iterator2.f(); + } + + if (globalSearch) { + rows.unshift({ + type: "search", + section: {}, + sectionIndex: 0, + isLastSection: false + }); + } + + if (this.props.maxHeight === Infinity) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: className, + style: _objectSpread({ + width: this.props.width + }, style) + }, rows.map(function (row, index) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(AccordionListCell, _extends({ + key: index + }, _this5.props, { + row: row, + sections: sections, + onChange: _this5.handleChange, + searchText: _this5.state.searchText, + onChangeSearchText: _this5.handleChangeSearchText, + sectionIsExpanded: sectionIsExpanded, + sectionIsTogglable: sectionIsTogglable, + toggleSection: _this5.toggleSection + })); + })); + } + + var maxHeight = this.props.maxHeight > 0 && this.props.maxHeight < Infinity ? this.props.maxHeight : window.innerHeight; + var width = this.props.width; + var height = Math.min(maxHeight, rows.reduce(function (height, row, index) { + return height + _this5._cache.rowHeight({ + index: index + }); + }, 0)); + var defaultListStyle = { + // HACK - Ensure the component can scroll + // This is a temporary fix to handle cases where the parent component doesn’t pass in the correct `maxHeight` + overflowY: "auto" + }; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(react_virtualized__WEBPACK_IMPORTED_MODULE_9__.List, { + id: id, + ref: function ref(list) { + return _this5._list = list; + }, + className: className, + style: _objectSpread(_objectSpread({}, defaultListStyle), style), + containerStyle: { + pointerEvents: "auto" + }, + width: width, + height: height, + rowCount: rows.length, + deferredMeasurementCache: this._cache, + rowHeight: this._cache.rowHeight // HACK: needs to be large enough to render enough rows to fill the screen since we used + // the CellMeasurerCache to calculate the height + , + overscanRowCount: 100 // ensure `scrollToRow` scrolls the row to the top of the list + , + scrollToAlignment: "start", + rowRenderer: function rowRenderer(_ref) { + var key = _ref.key, + index = _ref.index, + parent = _ref.parent, + style = _ref.style; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(react_virtualized__WEBPACK_IMPORTED_MODULE_9__.CellMeasurer, { + cache: _this5._cache, + columnIndex: 0, + key: key, + rowIndex: index, + parent: parent + }, function (_ref2) { + var measure = _ref2.measure; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(AccordionListCell, _extends({}, _this5.props, { + style: style, + row: rows[index], + sections: sections, + onChange: _this5.handleChange, + searchText: _this5.state.searchText, + onChangeSearchText: _this5.handleChangeSearchText, + sectionIsExpanded: sectionIsExpanded, + sectionIsTogglable: sectionIsTogglable, + toggleSection: _this5.toggleSection + })); + }); + }, + onRowsRendered: function onRowsRendered(_ref3) { + var startIndex = _ref3.startIndex, + stopIndex = _ref3.stopIndex; + _this5._startIndex = startIndex; + _this5._stopIndex = stopIndex; + } + }); + } + }]); + + return AccordionList; +}(react__WEBPACK_IMPORTED_MODULE_0__.Component); +/* eslint-disable react/prop-types */ + + +_defineProperty(AccordionList, "propTypes", { + style: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().object), + className: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string), + id: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string), + // TODO: pass width to this component as solely number or string if possible + // currently prop is number on initialization, then string afterwards + width: prop_types__WEBPACK_IMPORTED_MODULE_1___default().oneOfType([(prop_types__WEBPACK_IMPORTED_MODULE_1___default().string), (prop_types__WEBPACK_IMPORTED_MODULE_1___default().number)]), + maxHeight: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().number), + sections: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().array.isRequired), + initiallyOpenSection: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().number), + openSection: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().number), + onChange: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func), + onChangeSection: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func), + // section getters/render props + renderSectionIcon: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func), + renderSectionExtra: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func), + // item getters/render props + itemIsSelected: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func), + itemIsClickable: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func), + renderItemName: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func), + renderItemDescription: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func), + renderItemIcon: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func), + renderItemExtra: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func), + renderItemWrapper: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func), + getItemClassName: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func), + alwaysTogglable: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), + alwaysExpanded: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), + hideSingleSectionTitle: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), + showItemArrows: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), + searchable: prop_types__WEBPACK_IMPORTED_MODULE_1___default().oneOfType([(prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func)]), + searchProp: prop_types__WEBPACK_IMPORTED_MODULE_1___default().oneOfType([(prop_types__WEBPACK_IMPORTED_MODULE_1___default().string), (prop_types__WEBPACK_IMPORTED_MODULE_1___default().array)]), + searchCaseInsensitive: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), + searchFuzzy: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), + searchPlaceholder: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string), + itemTestId: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string) +}); + +_defineProperty(AccordionList, "defaultProps", { + style: {}, + width: 300, + searchable: function searchable(section) { + return section.items && section.items.length > 10; + }, + searchProp: "name", + searchCaseInsensitive: true, + searchFuzzy: true, + alwaysTogglable: false, + alwaysExpanded: false, + hideSingleSectionTitle: false, + // section getters/render props + renderSectionIcon: function renderSectionIcon(section) { + return section.icon && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Icon__WEBPACK_IMPORTED_MODULE_6__.default, { + name: section.icon, + size: 18 + }); + }, + renderSectionExtra: function renderSectionExtra() { + return null; + }, + // item getters/render props + itemIsClickable: function itemIsClickable(item) { + return true; + }, + itemIsSelected: function itemIsSelected(item) { + return false; + }, + renderItemName: function renderItemName(item) { + return item.name; + }, + renderItemDescription: function renderItemDescription(item) { + return item.description; + }, + renderItemExtra: function renderItemExtra(item) { + return null; + }, + renderItemIcon: function renderItemIcon(item) { + return item.icon && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Icon__WEBPACK_IMPORTED_MODULE_6__.default, { + name: item.icon, + size: 18 + }); + }, + getItemClassName: function getItemClassName(item) { + return item.className; + } +}); + + + +var AccordionListCell = function AccordionListCell(_ref4) { + var style = _ref4.style, + sections = _ref4.sections, + row = _ref4.row, + onChange = _ref4.onChange, + itemIsSelected = _ref4.itemIsSelected, + itemIsClickable = _ref4.itemIsClickable, + sectionIsExpanded = _ref4.sectionIsExpanded, + sectionIsTogglable = _ref4.sectionIsTogglable, + alwaysExpanded = _ref4.alwaysExpanded, + toggleSection = _ref4.toggleSection, + renderSectionIcon = _ref4.renderSectionIcon, + renderSectionExtra = _ref4.renderSectionExtra, + renderItemName = _ref4.renderItemName, + renderItemDescription = _ref4.renderItemDescription, + renderItemIcon = _ref4.renderItemIcon, + renderItemExtra = _ref4.renderItemExtra, + renderItemWrapper = _ref4.renderItemWrapper, + searchText = _ref4.searchText, + onChangeSearchText = _ref4.onChangeSearchText, + searchPlaceholder = _ref4.searchPlaceholder, + showItemArrows = _ref4.showItemArrows, + itemTestId = _ref4.itemTestId, + getItemClassName = _ref4.getItemClassName; + var type = row.type, + section = row.section, + sectionIndex = row.sectionIndex, + item = row.item, + itemIndex = row.itemIndex, + isLastItem = row.isLastItem; + var content; + + if (type === "header") { + if (alwaysExpanded) { + content = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "pt2 mb1 mx2 h5 text-uppercase text-bold", + style: { + color: metabase_lib_colors__WEBPACK_IMPORTED_MODULE_5__.color + } + }, section.name); + } else { + var icon = renderSectionIcon(section, sectionIndex); + var extra = renderSectionExtra(section, sectionIndex); + var name = section.name; + content = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: classnames__WEBPACK_IMPORTED_MODULE_2___default()("List-section-header mx2 py2 flex align-center hover-parent hover--opacity", { + "cursor-pointer": sectionIsTogglable(sectionIndex), + "text-brand": sectionIsExpanded(sectionIndex) + }), + onClick: sectionIsTogglable(sectionIndex) && function () { + return toggleSection(sectionIndex); + } + }, icon && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { + className: "List-section-icon mr1 flex align-center" + }, icon), name && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("h3", { + className: "List-section-title text-wrap" + }, name), extra, sections.length > 1 && section.items && section.items.length > 0 && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { + className: "flex-align-right ml1 hover-child" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Icon__WEBPACK_IMPORTED_MODULE_6__.default, { + name: sectionIsExpanded(sectionIndex) ? "chevronup" : "chevrondown", + size: 12 + }))); + } + } else if (type === "header-hidden") { + content = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "my1" + }); + } else if (type === "loading") { + content = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "m1 flex layout-centered" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_LoadingSpinner__WEBPACK_IMPORTED_MODULE_7__.default, null)); + } else if (type === "search") { + content = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_ListSearchField__WEBPACK_IMPORTED_MODULE_8__.default, { + hasClearButton: true, + className: "bg-white m1", + onChange: onChangeSearchText, + value: searchText, + placeholder: searchPlaceholder, + autoFocus: true + }); + } else if (type === "item") { + var isSelected = itemIsSelected(item, itemIndex); + var isClickable = itemIsClickable(item, itemIndex); + + var _icon = renderItemIcon(item, itemIndex, isSelected); + + var _name = renderItemName(item, itemIndex, isSelected); + + var description = renderItemDescription(item, itemIndex, isSelected); + content = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + "data-testid": itemTestId, + "aria-selected": isSelected, + className: classnames__WEBPACK_IMPORTED_MODULE_2___default()("List-item flex mx1", { + "List-item--selected": isSelected, + "List-item--disabled": !isClickable, + mb1: isLastItem + }, getItemClassName(item, itemIndex)) + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("a", { + className: classnames__WEBPACK_IMPORTED_MODULE_2___default()("p1 flex-auto flex align-center", isClickable ? "cursor-pointer" : "cursor-default"), + onClick: isClickable ? function () { + return onChange(item); + } : null + }, _icon && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { + className: "List-item-icon text-default flex align-center" + }, _icon), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", null, _name && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("h4", { + className: "List-item-title ml1 text-wrap" + }, _name), description && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("p", { + className: "List-item-description ml1 text-wrap" + }, description))), renderItemExtra(item, itemIndex, isSelected), showItemArrows && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "List-item-arrow flex align-center px1" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Icon__WEBPACK_IMPORTED_MODULE_6__.default, { + name: "chevronright", + size: 8 + }))); + + if (renderItemWrapper) { + content = renderItemWrapper(content, item); + } + } + + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + style: style, + className: classnames__WEBPACK_IMPORTED_MODULE_2___default()("List-section", section.className, { + "List-section--expanded": sectionIsExpanded(sectionIndex), + "List-section--togglable": sectionIsTogglable(sectionIndex) + }) + }, content); +}; + +/***/ }), + +/***/ "./components/AccordionList/index.js": +/*!*******************************************!*\ + !*** ./components/AccordionList/index.js ***! + \*******************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* reexport safe */ _AccordionList__WEBPACK_IMPORTED_MODULE_0__.default; } +/* harmony export */ }); +/* harmony import */ var _AccordionList__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./AccordionList */ "./components/AccordionList/AccordionList.jsx"); + + +/***/ }), + +/***/ "./components/ActionButton.jsx": +/*!*************************************!*\ + !*** ./components/ActionButton.jsx ***! + \*************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* binding */ ActionButton; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prop-types */ "../../../node_modules/prop-types/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var metabase_components_Icon__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/components/Icon */ "./components/Icon.tsx"); +/* harmony import */ var metabase_components_Button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/components/Button */ "./components/Button.tsx"); +/* harmony import */ var metabase_lib_promise__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! metabase/lib/promise */ "./lib/promise.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_5__); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! classnames */ "../../../node_modules/classnames/index.js"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_6__); +/* provided dependency */ var console = __webpack_require__(/*! console-browserify */ "../../../node_modules/console-browserify/index.js"); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +var _templateObject, _templateObject2, _templateObject3, _templateObject4; + +var _excluded = ["normalText", "activeText", "failedText", "successText", "actionFn", "className", "successClassName", "failedClassName", "forceActiveStyle", "children"]; + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } + +function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/* eslint-disable react/prop-types */ + + + + + + + + +var ActionButton = /*#__PURE__*/function (_Component) { + _inherits(ActionButton, _Component); + + var _super = _createSuper(ActionButton); + + function ActionButton(props) { + var _this; + + _classCallCheck(this, ActionButton); + + _this = _super.call(this, props); + + _defineProperty(_assertThisInitialized(_this), "resetStateOnTimeout", function () { + // clear any previously set timeouts then start a new one + clearTimeout(_this.timeout); + _this.timeout = setTimeout(function () { + return _this.setState({ + active: false, + result: null + }); + }, 5000); + }); + + _defineProperty(_assertThisInitialized(_this), "onClick", function (event) { + event.preventDefault(); // set state to active + + _this.setState({ + active: true, + result: null + }); // run the function we want bound to this button + + + _this.actionPromise = (0,metabase_lib_promise__WEBPACK_IMPORTED_MODULE_4__.cancelable)(_this.props.actionFn()); + + _this.actionPromise.then(function (success) { + _this.setState({ + active: false, + result: "success" + }, _this.resetStateOnTimeout); + }, function (error) { + if (!error.isCanceled) { + console.error(error); + + _this.setState({ + active: false, + result: "failed" + }, _this.resetStateOnTimeout); + } + }); + }); + + _this.state = { + active: false, + result: null + }; + return _this; + } + + _createClass(ActionButton, [{ + key: "componentWillUnmount", + value: function componentWillUnmount() { + clearTimeout(this.timeout); + + if (this.actionPromise) { + this.actionPromise.cancel(); + } + } + }, { + key: "render", + value: function render() { + var _cx; + + var _this$props = this.props, + normalText = _this$props.normalText, + activeText = _this$props.activeText, + failedText = _this$props.failedText, + successText = _this$props.successText, + actionFn = _this$props.actionFn, + className = _this$props.className, + successClassName = _this$props.successClassName, + failedClassName = _this$props.failedClassName, + forceActiveStyle = _this$props.forceActiveStyle, + children = _this$props.children, + props = _objectWithoutProperties(_this$props, _excluded); + + var _this$state = this.state, + active = _this$state.active, + result = _this$state.result; + var isActionDisabled = active || result === "success"; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Button__WEBPACK_IMPORTED_MODULE_3__.default, _extends({}, props, { + className: forceActiveStyle ? classnames__WEBPACK_IMPORTED_MODULE_6___default()("Button", "Button--waiting") : classnames__WEBPACK_IMPORTED_MODULE_6___default()(className, (_cx = { + "Button--waiting": active + }, _defineProperty(_cx, successClassName, result === "success"), _defineProperty(_cx, failedClassName, result === "failed"), _defineProperty(_cx, "pointer-events-none", isActionDisabled), _cx)), + onClick: this.onClick + }), active ? // TODO: loading spinner + activeText : result === "success" ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", null, forceActiveStyle ? null : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Icon__WEBPACK_IMPORTED_MODULE_2__.default, { + name: "check", + size: 12 + }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { + className: "ml1" + }, successText)) : result === "failed" ? failedText : children || normalText); + } + }]); + + return ActionButton; +}(react__WEBPACK_IMPORTED_MODULE_0__.Component); + +_defineProperty(ActionButton, "propTypes", { + actionFn: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func.isRequired) +}); + +_defineProperty(ActionButton, "defaultProps", { + className: "Button", + successClassName: "Button--success", + failedClassName: "Button--danger", + normalText: (0,ttag__WEBPACK_IMPORTED_MODULE_5__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["Save"]))), + activeText: (0,ttag__WEBPACK_IMPORTED_MODULE_5__.t)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["Saving..."]))), + failedText: (0,ttag__WEBPACK_IMPORTED_MODULE_5__.t)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["Save failed"]))), + successText: (0,ttag__WEBPACK_IMPORTED_MODULE_5__.t)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["Saved"]))), + forceActiveStyle: false +}); + + + +/***/ }), + +/***/ "./components/AdminContentTable.jsx": +/*!******************************************!*\ + !*** ./components/AdminContentTable.jsx ***! + \******************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* eslint-disable react/prop-types */ + + +var AdminContentTable = function AdminContentTable(_ref) { + var columnTitles = _ref.columnTitles, + children = _ref.children; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("table", { + className: "ContentTable" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("thead", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("tr", null, columnTitles && columnTitles.map(function (title, index) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("th", { + key: index + }, title); + }))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("tbody", null, children)); +}; + +/* harmony default export */ __webpack_exports__["default"] = (AdminContentTable); + +/***/ }), + +/***/ "./components/Banner/Banner.jsx": +/*!**************************************!*\ + !*** ./components/Banner/Banner.jsx ***! + \**************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prop-types */ "../../../node_modules/prop-types/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var metabase_components_Banner_Banner_styled__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/components/Banner/Banner.styled */ "./components/Banner/Banner.styled.jsx"); + + + +var propTypes = { + children: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().node) +}; + +var Banner = function Banner(_ref) { + var children = _ref.children; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Banner_Banner_styled__WEBPACK_IMPORTED_MODULE_2__.BannerRoot, null, children); +}; + +Banner.propTypes = propTypes; +/* harmony default export */ __webpack_exports__["default"] = (Banner); + +/***/ }), + +/***/ "./components/Banner/Banner.styled.jsx": +/*!*********************************************!*\ + !*** ./components/Banner/Banner.styled.jsx ***! + \*********************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "BannerRoot": function() { return /* binding */ BannerRoot; } +/* harmony export */ }); +/* harmony import */ var styled_components__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! styled-components */ "../../../node_modules/styled-components/dist/styled-components.browser.es.js"); +/* harmony import */ var metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/lib/colors */ "./lib/colors.ts"); + + +var BannerRoot = styled_components__WEBPACK_IMPORTED_MODULE_0__.default.div.withConfig({ + displayName: "Bannerstyled__BannerRoot", + componentId: "sc-1m5iec8-0" +})(["padding:0.75rem;border-radius:6px;color:", ";background-color:", ";"], (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.color)("text-medium"), (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.color)("bg-light")); + +/***/ }), + +/***/ "./components/Banner/index.js": +/*!************************************!*\ + !*** ./components/Banner/index.js ***! + \************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* reexport safe */ _Banner__WEBPACK_IMPORTED_MODULE_0__.default; } +/* harmony export */ }); +/* harmony import */ var _Banner__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Banner */ "./components/Banner/Banner.jsx"); + + +/***/ }), + +/***/ "./components/Breadcrumbs.jsx": +/*!************************************!*\ + !*** ./components/Breadcrumbs.jsx ***! + \************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* binding */ Breadcrumbs; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prop-types */ "../../../node_modules/prop-types/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var react_router__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react-router */ "../../../node_modules/react-router/es/index.js"); +/* harmony import */ var _Breadcrumbs_css__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Breadcrumbs.css */ "./components/Breadcrumbs.css"); +/* harmony import */ var _Breadcrumbs_css__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_Breadcrumbs_css__WEBPACK_IMPORTED_MODULE_3__); +/* harmony import */ var metabase_components_Icon__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! metabase/components/Icon */ "./components/Icon.tsx"); +/* harmony import */ var metabase_components_Ellipsified__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! metabase/components/Ellipsified */ "./components/Ellipsified.jsx"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! classnames */ "../../../node_modules/classnames/index.js"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_6__); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + + + + + + + + // TODO: merge with BrowserCrumbs + +var Breadcrumbs = /*#__PURE__*/function (_Component) { + _inherits(Breadcrumbs, _Component); + + var _super = _createSuper(Breadcrumbs); + + function Breadcrumbs() { + _classCallCheck(this, Breadcrumbs); + + return _super.apply(this, arguments); + } + + _createClass(Breadcrumbs, [{ + key: "render", + value: function render() { + var _this$props = this.props, + className = _this$props.className, + crumbs = _this$props.crumbs, + inSidebar = _this$props.inSidebar, + placeholder = _this$props.placeholder; + var breadcrumbClass = inSidebar ? (_Breadcrumbs_css__WEBPACK_IMPORTED_MODULE_3___default().sidebarBreadcrumb) : (_Breadcrumbs_css__WEBPACK_IMPORTED_MODULE_3___default().breadcrumb); + var breadcrumbsClass = inSidebar ? (_Breadcrumbs_css__WEBPACK_IMPORTED_MODULE_3___default().sidebarBreadcrumbs) : (_Breadcrumbs_css__WEBPACK_IMPORTED_MODULE_3___default().breadcrumbs); + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("section", { + className: classnames__WEBPACK_IMPORTED_MODULE_6___default()(className, breadcrumbsClass) + }, crumbs.length <= 1 && placeholder ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { + className: classnames__WEBPACK_IMPORTED_MODULE_6___default()(breadcrumbClass, (_Breadcrumbs_css__WEBPACK_IMPORTED_MODULE_3___default().breadcrumbPage)) + }, placeholder) : crumbs.map(function (breadcrumb) { + return Array.isArray(breadcrumb) ? breadcrumb : [breadcrumb]; + }).map(function (breadcrumb, index) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Ellipsified__WEBPACK_IMPORTED_MODULE_5__.default, { + key: index, + tooltip: breadcrumb[0], + tooltipMaxWidth: "100%", + className: classnames__WEBPACK_IMPORTED_MODULE_6___default()(breadcrumbClass, breadcrumb.length > 1 ? (_Breadcrumbs_css__WEBPACK_IMPORTED_MODULE_3___default().breadcrumbPath) : (_Breadcrumbs_css__WEBPACK_IMPORTED_MODULE_3___default().breadcrumbPage)) + }, breadcrumb.length > 1 && typeof breadcrumb[1] === "string" ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(react_router__WEBPACK_IMPORTED_MODULE_2__.Link, { + to: breadcrumb[1] + }, breadcrumb[0]) : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { + onClick: breadcrumb[1] + }, breadcrumb[0])); + }).map(function (breadcrumb, index, breadcrumbs) { + return index < breadcrumbs.length - 1 ? [breadcrumb, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Icon__WEBPACK_IMPORTED_MODULE_4__.default, { + key: "".concat(index, "-separator"), + name: "chevronright", + className: (_Breadcrumbs_css__WEBPACK_IMPORTED_MODULE_3___default().breadcrumbDivider), + width: 12, + height: 12 + })] : breadcrumb; + })); + } + }]); + + return Breadcrumbs; +}(react__WEBPACK_IMPORTED_MODULE_0__.Component); + +_defineProperty(Breadcrumbs, "propTypes", { + className: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string), + // each "crumb" is an array, the first index being the string title, the + // second index being a string URL or action function + crumbs: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().array), + inSidebar: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), + placeholder: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string) +}); + +_defineProperty(Breadcrumbs, "defaultProps", { + crumbs: [], + inSidebar: false, + placeholder: null +}); + + + +/***/ }), + +/***/ "./components/Button.tsx": +/*!*******************************!*\ + !*** ./components/Button.tsx ***! + \*******************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! classnames */ "../../../node_modules/classnames/index.js"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var styled_components__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! styled-components */ "../../../node_modules/styled-components/dist/styled-components.browser.es.js"); +/* harmony import */ var styled_system__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! styled-system */ "../../../node_modules/styled-system/dist/index.js"); +/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! underscore */ "../../../node_modules/underscore/modules/index-all.js"); +/* harmony import */ var metabase_components_Icon__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! metabase/components/Icon */ "./components/Icon.tsx"); +/* harmony import */ var metabase_styled_components_utils__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! metabase/styled-components/utils */ "./styled-components/utils.tsx"); +var _excluded = ["className", "icon", "iconRight", "iconSize", "iconColor", "iconVertical", "labelBreakpoint", "children"]; + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } + +function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } + + + + + + + + +var BUTTON_VARIANTS = ["small", "medium", "large", "round", "primary", "danger", "warning", "cancel", "success", "purple", "white", "borderless", "onlyIcon", "fullWidth"]; +var BaseButton = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_1__.forwardRef)(function BaseButton(_ref, ref) { + var _cx; + + var className = _ref.className, + icon = _ref.icon, + iconRight = _ref.iconRight, + iconSize = _ref.iconSize, + iconColor = _ref.iconColor, + iconVertical = _ref.iconVertical, + labelBreakpoint = _ref.labelBreakpoint, + children = _ref.children, + props = _objectWithoutProperties(_ref, _excluded); + + var variantClasses = BUTTON_VARIANTS.filter(function (variant) { + return props[variant]; + }).map(function (variant) { + return "Button--" + variant; + }); + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1__.createElement("button", _extends({}, underscore__WEBPACK_IMPORTED_MODULE_4__.default.omit.apply(underscore__WEBPACK_IMPORTED_MODULE_4__.default, [props].concat(BUTTON_VARIANTS)), { + className: classnames__WEBPACK_IMPORTED_MODULE_0___default()("Button", className, "flex-no-shrink", variantClasses, { + p1: !children + }), + ref: ref + }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1__.createElement("div", { + className: classnames__WEBPACK_IMPORTED_MODULE_0___default()("flex layout-centered", { + "flex-column": iconVertical + }), + style: iconVertical ? { + minWidth: 60 + } : undefined + }, icon && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1__.createElement(metabase_components_Icon__WEBPACK_IMPORTED_MODULE_5__.default, { + color: iconColor, + name: icon, + size: iconSize ? iconSize : 14 + }), children && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1__.createElement("div", { + className: classnames__WEBPACK_IMPORTED_MODULE_0___default()((_cx = {}, _defineProperty(_cx, iconVertical ? "mt1" : "ml1", icon), _defineProperty(_cx, iconVertical ? "mb1" : "mr1", iconRight), _defineProperty(_cx, "hide ".concat(labelBreakpoint, "-show"), !!labelBreakpoint), _cx)) + }, children), iconRight && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1__.createElement(metabase_components_Icon__WEBPACK_IMPORTED_MODULE_5__.default, { + color: iconColor, + name: iconRight, + size: iconSize ? iconSize : 14 + }))); +}); +var Button = (0,metabase_styled_components_utils__WEBPACK_IMPORTED_MODULE_6__.forwardRefToInnerRef)((0,styled_components__WEBPACK_IMPORTED_MODULE_2__.default)(BaseButton).withConfig({ + displayName: "Button", + componentId: "sc-1j743ng-0" +})(["", ";", ";"], styled_system__WEBPACK_IMPORTED_MODULE_3__.color, styled_system__WEBPACK_IMPORTED_MODULE_3__.space)); +Button.displayName = "Button"; +/* harmony default export */ __webpack_exports__["default"] = (Button); + +/***/ }), + +/***/ "./components/Calendar.jsx": +/*!*********************************!*\ + !*** ./components/Calendar.jsx ***! + \*********************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* binding */ Calendar; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prop-types */ "../../../node_modules/prop-types/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var _Calendar_css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Calendar.css */ "./components/Calendar.css"); +/* harmony import */ var _Calendar_css__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_Calendar_css__WEBPACK_IMPORTED_MODULE_2__); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! classnames */ "../../../node_modules/classnames/index.js"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_3__); +/* harmony import */ var moment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! moment */ "../../../node_modules/moment/moment.js"); +/* harmony import */ var moment__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(moment__WEBPACK_IMPORTED_MODULE_4__); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_5__); +/* harmony import */ var metabase_components_Icon__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! metabase/components/Icon */ "./components/Icon.tsx"); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7; + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/* eslint-disable react/prop-types */ + + + + + + + + +var Calendar = /*#__PURE__*/function (_Component) { + _inherits(Calendar, _Component); + + var _super = _createSuper(Calendar); + + function Calendar(props) { + var _this; + + _classCallCheck(this, Calendar); + + _this = _super.call(this, props); + + _defineProperty(_assertThisInitialized(_this), "onClickDay", function (date) { + var _this$props = _this.props, + selected = _this$props.selected, + selectedEnd = _this$props.selectedEnd, + isRangePicker = _this$props.isRangePicker; + + if (!isRangePicker || !selected || selectedEnd) { + _this.props.onChange(date.format("YYYY-MM-DD"), null); + } else if (!selectedEnd) { + if (date.isAfter(selected)) { + _this.props.onChange(selected.format("YYYY-MM-DD"), date.format("YYYY-MM-DD")); + } else { + _this.props.onChange(date.format("YYYY-MM-DD"), selected.format("YYYY-MM-DD")); + } + } + }); + + _defineProperty(_assertThisInitialized(_this), "previous", function () { + _this.setState({ + current: moment__WEBPACK_IMPORTED_MODULE_4___default()(_this.state.current).add(-1, "M") + }); + }); + + _defineProperty(_assertThisInitialized(_this), "next", function () { + _this.setState({ + current: moment__WEBPACK_IMPORTED_MODULE_4___default()(_this.state.current).add(1, "M") + }); + }); + + _this.state = { + current: moment__WEBPACK_IMPORTED_MODULE_4___default()(props.initial || undefined) + }; + return _this; + } + + _createClass(Calendar, [{ + key: "UNSAFE_componentWillReceiveProps", + value: function UNSAFE_componentWillReceiveProps(nextProps) { + if ( // `selected` became null or not null + nextProps.selected == null !== (this.props.selected == null) || // `selectedEnd` became null or not null + nextProps.selectedEnd == null !== (this.props.selectedEnd == null) || nextProps.selected != null && !moment__WEBPACK_IMPORTED_MODULE_4___default()(nextProps.selected).isSame(this.props.selected, "day") || nextProps.selectedEnd != null && !moment__WEBPACK_IMPORTED_MODULE_4___default()(nextProps.selectedEnd).isSame(this.props.selectedEnd, "day")) { + var resetCurrent = false; + + if (nextProps.selected != null && nextProps.selectedEnd != null) { + // reset if `current` isn't between `selected` and `selectedEnd` month + resetCurrent = nextProps.selected.isAfter(this.state.current, "month") && nextProps.selectedEnd.isBefore(this.state.current, "month"); + } else if (nextProps.selected != null) { + // reset if `current` isn't in `selected` month + resetCurrent = nextProps.selected.isAfter(this.state.current, "month") || nextProps.selected.isBefore(this.state.current, "month"); + } + + if (resetCurrent) { + this.setState({ + current: nextProps.selected + }); + } + } + } + }, { + key: "renderMonthHeader", + value: function renderMonthHeader(current, side) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "Calendar-header flex align-center border-bottom" + }, side !== "right" && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "cursor-pointer text-brand-hover", + onClick: this.previous + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Icon__WEBPACK_IMPORTED_MODULE_6__.default, { + name: "chevronleft", + size: 10 + })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { + className: "flex-full" + }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("h4", null, current.format("MMMM YYYY")), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { + className: "flex-full" + }), side !== "left" && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "cursor-pointer text-brand-hover", + onClick: this.next + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Icon__WEBPACK_IMPORTED_MODULE_6__.default, { + name: "chevronright", + size: 10 + }))); + } + }, { + key: "renderDayNames", + value: function renderDayNames() { + var names = [(0,ttag__WEBPACK_IMPORTED_MODULE_5__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["Su"]))), (0,ttag__WEBPACK_IMPORTED_MODULE_5__.t)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["Mo"]))), (0,ttag__WEBPACK_IMPORTED_MODULE_5__.t)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["Tu"]))), (0,ttag__WEBPACK_IMPORTED_MODULE_5__.t)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["We"]))), (0,ttag__WEBPACK_IMPORTED_MODULE_5__.t)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["Th"]))), (0,ttag__WEBPACK_IMPORTED_MODULE_5__.t)(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["Fr"]))), (0,ttag__WEBPACK_IMPORTED_MODULE_5__.t)(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["Sa"])))]; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "Calendar-day-names Calendar-week py1" + }, names.map(function (name) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { + key: name, + className: "Calendar-day-name text-centered" + }, name); + })); + } + }, { + key: "renderWeeks", + value: function renderWeeks(current) { + var weeks = []; + var date = moment__WEBPACK_IMPORTED_MODULE_4___default()(current).startOf("month").day("Sunday"); + var done = false; + var monthIndex = date.month(); + var count = 0; + + while (!done) { + weeks.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(Week, { + key: date.toString(), + date: moment__WEBPACK_IMPORTED_MODULE_4___default()(date), + month: current, + onClickDay: this.onClickDay, + selected: this.props.selected, + selectedEnd: this.props.selectedEnd + })); + date.add(1, "w"); + done = count++ > 2 && monthIndex !== date.month(); + monthIndex = date.month(); + } + + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "Calendar-weeks relative" + }, weeks); + } + }, { + key: "renderCalender", + value: function renderCalender(current, side) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: classnames__WEBPACK_IMPORTED_MODULE_3___default()("Calendar", { + "Calendar--range": this.props.isRangePicker && this.props.selected && this.props.selectedEnd + }) + }, this.renderMonthHeader(current, side), this.renderDayNames(current), this.renderWeeks(current)); + } + }, { + key: "render", + value: function render() { + var current = this.state.current; + return this.renderCalender(current); + } + }]); + + return Calendar; +}(react__WEBPACK_IMPORTED_MODULE_0__.Component); + +_defineProperty(Calendar, "propTypes", { + selected: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().object), + selectedEnd: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().object), + onChange: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func.isRequired), + isRangePicker: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool) +}); + +_defineProperty(Calendar, "defaultProps", { + isRangePicker: true +}); + + + +var Week = /*#__PURE__*/function (_Component2) { + _inherits(Week, _Component2); + + var _super2 = _createSuper(Week); + + function Week() { + _classCallCheck(this, Week); + + return _super2.apply(this, arguments); + } + + _createClass(Week, [{ + key: "render", + value: function render() { + var days = []; + var _this$props2 = this.props, + date = _this$props2.date, + month = _this$props2.month, + selected = _this$props2.selected, + selectedEnd = _this$props2.selectedEnd; + + for (var i = 0; i < 7; i++) { + var classes = classnames__WEBPACK_IMPORTED_MODULE_3___default()("Calendar-day cursor-pointer text-centered", { + "Calendar-day--today": date.isSame(new Date(), "day"), + "Calendar-day--this-month": date.month() === month.month(), + "Calendar-day--selected": selected && date.isSame(selected, "day"), + "Calendar-day--selected-end": selectedEnd && date.isSame(selectedEnd, "day"), + "Calendar-day--week-start": i === 0, + "Calendar-day--week-end": i === 6, + "Calendar-day--in-range": !(date.isSame(selected, "day") || date.isSame(selectedEnd, "day")) && (date.isSame(selected, "day") || date.isSame(selectedEnd, "day") || selectedEnd && selectedEnd.isAfter(date, "day") && date.isAfter(selected, "day")) + }); + days.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { + key: date.toString(), + className: classes, + onClick: this.props.onClickDay.bind(null, date) + }, date.date())); + date = moment__WEBPACK_IMPORTED_MODULE_4___default()(date).add(1, "d"); + } + + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "Calendar-week", + key: days[0].toString() + }, days); + } + }]); + + return Week; +}(react__WEBPACK_IMPORTED_MODULE_0__.Component); + +_defineProperty(Week, "propTypes", { + selected: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().object), + selectedEnd: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().object), + onClickDay: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func.isRequired) +}); + +/***/ }), + +/***/ "./components/CheckBox.jsx": +/*!*********************************!*\ + !*** ./components/CheckBox.jsx ***! + \*********************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "DEFAULT_CHECKED_COLOR": function() { return /* binding */ DEFAULT_CHECKED_COLOR; }, +/* harmony export */ "DEFAULT_UNCHECKED_COLOR": function() { return /* binding */ DEFAULT_UNCHECKED_COLOR; }, +/* harmony export */ "DEFAULT_SIZE": function() { return /* binding */ DEFAULT_SIZE; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prop-types */ "../../../node_modules/prop-types/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var _CheckBox_styled__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./CheckBox.styled */ "./components/CheckBox.styled.jsx"); +var _excluded = ["label", "checked", "indeterminate", "disabled", "onChange", "onFocus", "onBlur", "checkedColor", "uncheckedColor", "size", "autoFocus", "className"]; + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } + +function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } + +function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } + +function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } + +function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } + + + + +var propTypes = { + checked: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), + indeterminate: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), + label: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().node), + disabled: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), + onChange: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func), + onFocus: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func), + onBlur: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func), + // Expect color aliases, literals + // Example: brand, accent1, success + // Won't work: red, #000, rgb(0, 0, 0) + checkedColor: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string), + uncheckedColor: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string), + size: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().number), + autoFocus: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), + className: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string) +}; +var DEFAULT_CHECKED_COLOR = "brand"; +var DEFAULT_UNCHECKED_COLOR = "text-light"; +var DEFAULT_SIZE = 16; +var ICON_PADDING = 4; + +function Checkbox(_ref) { + var label = _ref.label, + checked = _ref.checked, + indeterminate = _ref.indeterminate, + _ref$disabled = _ref.disabled, + disabled = _ref$disabled === void 0 ? false : _ref$disabled, + onChange = _ref.onChange, + onFocus = _ref.onFocus, + onBlur = _ref.onBlur, + _ref$checkedColor = _ref.checkedColor, + checkedColor = _ref$checkedColor === void 0 ? DEFAULT_CHECKED_COLOR : _ref$checkedColor, + _ref$uncheckedColor = _ref.uncheckedColor, + uncheckedColor = _ref$uncheckedColor === void 0 ? DEFAULT_UNCHECKED_COLOR : _ref$uncheckedColor, + _ref$size = _ref.size, + size = _ref$size === void 0 ? DEFAULT_SIZE : _ref$size, + _ref$autoFocus = _ref.autoFocus, + autoFocus = _ref$autoFocus === void 0 ? false : _ref$autoFocus, + className = _ref.className, + props = _objectWithoutProperties(_ref, _excluded); + + var _useState = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(autoFocus), + _useState2 = _slicedToArray(_useState, 2), + isFocused = _useState2[0], + setFocused = _useState2[1]; + + var handleFocus = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function (e) { + setFocused(true); + + if (typeof onFocus === "function") { + onFocus(e); + } + }, [onFocus]); + var handleBlur = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function (e) { + setFocused(false); + + if (typeof onBlur === "function") { + onBlur(e); + } + }, [onBlur]); + var onKeyPress = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function (e) { + if (e.key === "Enter" && typeof onChange === "function") { + onChange({ + preventDefault: function preventDefault() { + return e.preventDefault(); + }, + target: { + checked: !checked + } + }); + } + }, [checked, onChange]); + var renderLabel = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function () { + if (label == null) { + return null; + } + + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.isValidElement(label) ? label : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_CheckBox_styled__WEBPACK_IMPORTED_MODULE_2__.LabelText, null, label); + }, [label]); + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_CheckBox_styled__WEBPACK_IMPORTED_MODULE_2__.CheckboxRoot, { + className: className, + disabled: disabled, + "data-testid": "checkbox-root" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_CheckBox_styled__WEBPACK_IMPORTED_MODULE_2__.Container, null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_CheckBox_styled__WEBPACK_IMPORTED_MODULE_2__.VisibleBox, { + checked: checked, + isFocused: isFocused, + size: size, + checkedColor: checkedColor, + uncheckedColor: uncheckedColor + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_CheckBox_styled__WEBPACK_IMPORTED_MODULE_2__.Input, _extends({}, props, { + checked: checked, + disabled: disabled, + onChange: onChange, + onFocus: handleFocus, + onBlur: handleBlur, + onKeyPress: onKeyPress + })), (checked || indeterminate) && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_CheckBox_styled__WEBPACK_IMPORTED_MODULE_2__.CheckboxIcon, { + checked: checked, + name: indeterminate ? "dash" : "check", + size: size - ICON_PADDING, + uncheckedColor: uncheckedColor + })), renderLabel())); +} + +Checkbox.propTypes = propTypes; +Checkbox.Label = _CheckBox_styled__WEBPACK_IMPORTED_MODULE_2__.LabelText; +/* harmony default export */ __webpack_exports__["default"] = (Checkbox); + +/***/ }), + +/***/ "./components/CheckBox.styled.jsx": +/*!****************************************!*\ + !*** ./components/CheckBox.styled.jsx ***! + \****************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "CheckboxRoot": function() { return /* binding */ CheckboxRoot; }, +/* harmony export */ "Container": function() { return /* binding */ Container; }, +/* harmony export */ "VisibleBox": function() { return /* binding */ VisibleBox; }, +/* harmony export */ "Input": function() { return /* binding */ Input; }, +/* harmony export */ "CheckboxIcon": function() { return /* binding */ CheckboxIcon; }, +/* harmony export */ "LabelText": function() { return /* binding */ LabelText; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var styled_components__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! styled-components */ "../../../node_modules/styled-components/dist/styled-components.browser.es.js"); +/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! underscore */ "../../../node_modules/underscore/modules/index-all.js"); +/* harmony import */ var metabase_components_Icon__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/components/Icon */ "./components/Icon.tsx"); +/* harmony import */ var metabase_lib_colors__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! metabase/lib/colors */ "./lib/colors.ts"); + + + + + +var CheckboxRoot = styled_components__WEBPACK_IMPORTED_MODULE_1__.default.label.withConfig({ + displayName: "CheckBoxstyled__CheckboxRoot", + componentId: "rzkbqg-0" +})(["display:block;cursor:pointer;", ""], function (props) { + return props.disabled && (0,styled_components__WEBPACK_IMPORTED_MODULE_1__.css)(["opacity:0.4;pointer-events:none;"]); +}); +var Container = styled_components__WEBPACK_IMPORTED_MODULE_1__.default.div.withConfig({ + displayName: "CheckBoxstyled__Container", + componentId: "rzkbqg-1" +})(["display:flex;align-items:center;"]); +var VisibleBox = styled_components__WEBPACK_IMPORTED_MODULE_1__.default.span.withConfig({ + displayName: "CheckBoxstyled__VisibleBox", + componentId: "rzkbqg-2" +})(["display:flex;align-items:center;justify-center:center;position:relative;width:", ";height:", ";background-color:", ";border:2px solid ", ";border-radius:4px;", ""], function (props) { + return "".concat(props.size, "px"); +}, function (props) { + return "".concat(props.size, "px"); +}, function (props) { + return props.checked ? (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_4__.color)(props.checkedColor) : (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_4__.color)("bg-white"); +}, function (props) { + return props.checked ? (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_4__.color)(props.checkedColor) : (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_4__.color)(props.uncheckedColor); +}, function (props) { + return props.isFocused && (0,styled_components__WEBPACK_IMPORTED_MODULE_1__.css)(["outline:1px auto ", ";outline-offset:1px;"], props.checked ? (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_4__.darken)((0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_4__.color)(props.checkedColor)) : (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_4__.color)(props.checkedColor)); +}); +var Input = styled_components__WEBPACK_IMPORTED_MODULE_1__.default.input.attrs({ + type: "checkbox" +}).withConfig({ + displayName: "CheckBoxstyled__Input", + componentId: "rzkbqg-3" +})(["cursor:inherit;position:absolute;opacity:0;width:100%;height:100%;top:0;left:0;margin:0;padding:0;z-index:1;"]); + +function IconWrapped(props) { + var iconProps = underscore__WEBPACK_IMPORTED_MODULE_2__.default.omit(props, "uncheckedColor"); + + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Icon__WEBPACK_IMPORTED_MODULE_3__.default, iconProps); +} + +var CheckboxIcon = (0,styled_components__WEBPACK_IMPORTED_MODULE_1__.default)(IconWrapped).withConfig({ + displayName: "CheckBoxstyled__CheckboxIcon", + componentId: "rzkbqg-4" +})(["position:absolute;color:", ";"], function (props) { + return props.checked ? (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_4__.color)("white") : (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_4__.color)(props.uncheckedColor); +}); +var LabelText = styled_components__WEBPACK_IMPORTED_MODULE_1__.default.span.withConfig({ + displayName: "CheckBoxstyled__LabelText", + componentId: "rzkbqg-5" +})(["margin-left:8px;"]); + +/***/ }), + +/***/ "./components/ColorPicker.jsx": +/*!************************************!*\ + !*** ./components/ColorPicker.jsx ***! + \************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prop-types */ "../../../node_modules/prop-types/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var metabase_components_PopoverWithTrigger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/components/PopoverWithTrigger */ "./components/PopoverWithTrigger.jsx"); +/* harmony import */ var metabase_components_Button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/components/Button */ "./components/Button.tsx"); +/* harmony import */ var react_color__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! react-color */ "../../../node_modules/react-color/lib/index.js"); +/* harmony import */ var metabase_lib_colors__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! metabase/lib/colors */ "./lib/colors.ts"); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/* eslint-disable react/prop-types */ + + + + + + +var DEFAULT_COLOR_SQUARE_SIZE = 32; + +var ColorSquare = function ColorSquare(_ref) { + var color = _ref.color, + size = _ref.size; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + style: { + width: size, + height: size, + backgroundColor: color, + borderRadius: size / 8 + } + }); +}; + +var ColorPicker = /*#__PURE__*/function (_Component) { + _inherits(ColorPicker, _Component); + + var _super = _createSuper(ColorPicker); + + function ColorPicker(props) { + var _this; + + _classCallCheck(this, ColorPicker); + + _this = _super.call(this, props); + _this.colorPopover = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createRef(); + return _this; + } + + _createClass(ColorPicker, [{ + key: "render", + value: function render() { + var _this2 = this; + + var _this$props = this.props, + onChange = _this$props.onChange, + padding = _this$props.padding, + size = _this$props.size, + triggerSize = _this$props.triggerSize, + value = _this$props.value, + fancy = _this$props.fancy; + var colors = this.props.colors || Object.values(metabase_lib_colors__WEBPACK_IMPORTED_MODULE_5__.normal).slice(0, 12); + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "inline-block" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_PopoverWithTrigger__WEBPACK_IMPORTED_MODULE_2__.default, { + ref: this.colorPopover, + triggerElement: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "bordered rounded flex align-center", + style: { + padding: triggerSize / 4 + } + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(ColorSquare, { + color: value, + size: triggerSize + })) + }, fancy ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "rounded overflow-hidden" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(react_color__WEBPACK_IMPORTED_MODULE_4__.SketchPicker, { + color: value, + onChangeComplete: function onChangeComplete(color) { + onChange(color.hex); + } + })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "p1 border-top" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Button__WEBPACK_IMPORTED_MODULE_3__.default, { + onClick: function onClick() { + return _this2.colorPopover.current.close(); + } + }, "Done"))) : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "p1" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("ol", { + className: "flex flex-wrap", + style: { + maxWidth: 120 + } + }, colors.map(function (color, index) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("li", { + className: "cursor-pointer", + style: { + padding: padding + }, + key: index, + onClick: function onClick() { + onChange(color); + + _this2.colorPopover.current.close(); + } + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(ColorSquare, { + color: color, + size: size + })); + }))))); + } + }]); + + return ColorPicker; +}(react__WEBPACK_IMPORTED_MODULE_0__.Component); + +_defineProperty(ColorPicker, "defaultProps", { + size: DEFAULT_COLOR_SQUARE_SIZE, + triggerSize: DEFAULT_COLOR_SQUARE_SIZE, + padding: 4 +}); + +_defineProperty(ColorPicker, "propTypes", { + colors: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().array), + onChange: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func.isRequired), + size: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().number), + triggerSize: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().number), + value: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string) +}); + +/* harmony default export */ __webpack_exports__["default"] = (ColorPicker); + +/***/ }), + +/***/ "./components/ColorRangePicker.jsx": +/*!*****************************************!*\ + !*** ./components/ColorRangePicker.jsx ***! + \*****************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "ColorRangePreview": function() { return /* binding */ ColorRangePreview; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var metabase_components_PopoverWithTrigger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/components/PopoverWithTrigger */ "./components/PopoverWithTrigger.jsx"); +/* harmony import */ var metabase_lib_colors__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/lib/colors */ "./lib/colors.ts"); +/* harmony import */ var d3__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! d3 */ "../../../node_modules/d3/d3.js"); +/* harmony import */ var d3__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(d3__WEBPACK_IMPORTED_MODULE_3__); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! classnames */ "../../../node_modules/classnames/index.js"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_4__); +var _excluded = ["colors", "sections", "quantile", "className"]; + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } + +function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } + +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/* eslint-disable react/prop-types */ + + + + + + +var ColorRangePicker = function ColorRangePicker(_ref) { + var value = _ref.value, + onChange = _ref.onChange, + ranges = _ref.ranges, + className = _ref.className, + style = _ref.style, + _ref$sections = _ref.sections, + sections = _ref$sections === void 0 ? 5 : _ref$sections, + _ref$quantile = _ref.quantile, + quantile = _ref$quantile === void 0 ? false : _ref$quantile, + _ref$columns = _ref.columns, + columns = _ref$columns === void 0 ? 2 : _ref$columns; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_PopoverWithTrigger__WEBPACK_IMPORTED_MODULE_1__.default, { + triggerElement: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(ColorRangePreview, { + colors: value, + className: classnames__WEBPACK_IMPORTED_MODULE_4___default()(className, "bordered rounded overflow-hidden"), + style: _objectSpread({ + height: 30 + }, style), + sections: sections, + quantile: quantile + }) + }, function (_ref2) { + var onClose = _ref2.onClose; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "pt1 mr1 flex flex-wrap", + style: { + width: 300 + } + }, ranges.map(function (range, index) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + key: index, + className: "mb1 pl1", + style: { + flex: "1 1 ".concat(Math.round(100 / columns), "%") + } + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(ColorRangePreview, { + colors: range, + onClick: function onClick() { + onChange(range); + onClose(); + }, + className: classnames__WEBPACK_IMPORTED_MODULE_4___default()("bordered rounded overflow-hidden cursor-pointer"), + style: { + height: 30 + }, + sections: sections, + quantile: quantile + })); + })); + }); +}; + +var ColorRangePreview = function ColorRangePreview(_ref3) { + var _ref3$colors = _ref3.colors, + colors = _ref3$colors === void 0 ? [] : _ref3$colors, + _ref3$sections = _ref3.sections, + sections = _ref3$sections === void 0 ? 5 : _ref3$sections, + _ref3$quantile = _ref3.quantile, + quantile = _ref3$quantile === void 0 ? false : _ref3$quantile, + className = _ref3.className, + props = _objectWithoutProperties(_ref3, _excluded); + + var scale = (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_2__.getColorScale)([0, sections - 1], colors, quantile); + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", _extends({ + className: classnames__WEBPACK_IMPORTED_MODULE_4___default()(className, "flex") + }, props), d3__WEBPACK_IMPORTED_MODULE_3___default().range(0, sections).map(function (value) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + key: value, + className: "flex-full", + style: { + background: scale(value) + } + }); + })); +}; +/* harmony default export */ __webpack_exports__["default"] = (ColorRangePicker); + +/***/ }), + +/***/ "./components/Confirm.jsx": +/*!********************************!*\ + !*** ./components/Confirm.jsx ***! + \********************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* binding */ Confirm; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prop-types */ "../../../node_modules/prop-types/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var metabase_components_ModalWithTrigger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/components/ModalWithTrigger */ "./components/ModalWithTrigger.jsx"); +/* harmony import */ var _ConfirmContent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ConfirmContent */ "./components/ConfirmContent.jsx"); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/* eslint "react/prop-types": "warn" */ + + + + + +var Confirm = /*#__PURE__*/function (_Component) { + _inherits(Confirm, _Component); + + var _super = _createSuper(Confirm); + + function Confirm(props) { + var _this; + + _classCallCheck(this, Confirm); + + _this = _super.call(this, props); + _this.modal = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createRef(); + return _this; + } + + _createClass(Confirm, [{ + key: "render", + value: function render() { + var _this2 = this; + + var _this$props = this.props, + action = _this$props.action, + children = _this$props.children, + title = _this$props.title, + content = _this$props.content, + triggerClasses = _this$props.triggerClasses; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_ModalWithTrigger__WEBPACK_IMPORTED_MODULE_2__.default, { + ref: this.modal, + triggerElement: children, + triggerClasses: triggerClasses + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_ConfirmContent__WEBPACK_IMPORTED_MODULE_3__.default, { + title: title, + content: content, + onClose: function onClose() { + _this2.modal.current.close(); + }, + onAction: action + })); + } + }]); + + return Confirm; +}(react__WEBPACK_IMPORTED_MODULE_0__.Component); + +_defineProperty(Confirm, "propTypes", { + action: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func.isRequired), + title: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string.isRequired), + children: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().any), + content: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().any), + triggerClasses: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string) +}); + + + +/***/ }), + +/***/ "./components/ConfirmContent.jsx": +/*!***************************************!*\ + !*** ./components/ConfirmContent.jsx ***! + \***************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var metabase_components_ModalContent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/components/ModalContent */ "./components/ModalContent.jsx"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_2__); +/* harmony import */ var metabase_components_Button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/components/Button */ "./components/Button.tsx"); +var _templateObject, _templateObject2, _templateObject3; + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + +/* eslint-disable react/prop-types */ + + + + + +var nop = function nop() {}; + +var ConfirmContent = function ConfirmContent(_ref) { + var title = _ref.title, + content = _ref.content, + _ref$message = _ref.message, + message = _ref$message === void 0 ? (0,ttag__WEBPACK_IMPORTED_MODULE_2__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["Are you sure you want to do this?"]))) : _ref$message, + _ref$onClose = _ref.onClose, + _onClose = _ref$onClose === void 0 ? nop : _ref$onClose, + _ref$onAction = _ref.onAction, + onAction = _ref$onAction === void 0 ? nop : _ref$onAction, + _ref$onCancel = _ref.onCancel, + onCancel = _ref$onCancel === void 0 ? nop : _ref$onCancel, + _ref$confirmButtonTex = _ref.confirmButtonText, + confirmButtonText = _ref$confirmButtonTex === void 0 ? (0,ttag__WEBPACK_IMPORTED_MODULE_2__.t)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["Yes"]))) : _ref$confirmButtonTex, + _ref$cancelButtonText = _ref.cancelButtonText, + cancelButtonText = _ref$cancelButtonText === void 0 ? (0,ttag__WEBPACK_IMPORTED_MODULE_2__.t)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["Cancel"]))) : _ref$cancelButtonText; + + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_ModalContent__WEBPACK_IMPORTED_MODULE_1__.default, { + title: title, + formModal: true, + onClose: function onClose() { + onCancel(); + + _onClose(); + } + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", null, content), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("p", { + className: "mb4" + }, message), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "ml-auto" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Button__WEBPACK_IMPORTED_MODULE_3__.default, { + onClick: function onClick() { + onCancel(); + + _onClose(); + } + }, cancelButtonText), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Button__WEBPACK_IMPORTED_MODULE_3__.default, { + danger: true, + ml: 2, + onClick: function onClick() { + onAction(); + + _onClose(); + } + }, confirmButtonText))); +}; + +/* harmony default export */ __webpack_exports__["default"] = (ConfirmContent); + +/***/ }), + +/***/ "./components/CopyButton.jsx": +/*!***********************************!*\ + !*** ./components/CopyButton.jsx ***! + \***********************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* binding */ CopyWidget; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var metabase_components_Icon__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/components/Icon */ "./components/Icon.tsx"); +/* harmony import */ var metabase_components_Tooltip__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/components/Tooltip */ "./components/Tooltip/index.ts"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_3__); +/* harmony import */ var react_copy_to_clipboard__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! react-copy-to-clipboard */ "../../../node_modules/react-copy-to-clipboard/lib/index.js"); +/* harmony import */ var react_copy_to_clipboard__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(react_copy_to_clipboard__WEBPACK_IMPORTED_MODULE_4__); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +var _templateObject; + +var _excluded = ["value", "className", "style"]; + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + +function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } + +function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/* eslint-disable react/prop-types */ + + + + + + +var CopyWidget = /*#__PURE__*/function (_Component) { + _inherits(CopyWidget, _Component); + + var _super = _createSuper(CopyWidget); + + function CopyWidget(props) { + var _this; + + _classCallCheck(this, CopyWidget); + + _this = _super.call(this, props); + + _defineProperty(_assertThisInitialized(_this), "onCopy", function () { + _this.setState({ + copied: true + }); + + setTimeout(function () { + return _this.setState({ + copied: false + }); + }, 2000); + }); + + _this.state = { + copied: false + }; + return _this; + } + + _createClass(CopyWidget, [{ + key: "render", + value: function render() { + var _this$props = this.props, + value = _this$props.value, + className = _this$props.className, + style = _this$props.style, + props = _objectWithoutProperties(_this$props, _excluded); + + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement((react_copy_to_clipboard__WEBPACK_IMPORTED_MODULE_4___default()), { + text: value, + onCopy: this.onCopy + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: className, + style: style, + "data-testid": "copy-button" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Tooltip__WEBPACK_IMPORTED_MODULE_2__.default, { + tooltip: (0,ttag__WEBPACK_IMPORTED_MODULE_3__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["Copied!"]))), + isOpen: this.state.copied + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Icon__WEBPACK_IMPORTED_MODULE_1__.default, _extends({ + name: "copy" + }, props))))); + } + }]); + + return CopyWidget; +}(react__WEBPACK_IMPORTED_MODULE_0__.Component); + + + +/***/ }), + +/***/ "./components/CopyWidget.jsx": +/*!***********************************!*\ + !*** ./components/CopyWidget.jsx ***! + \***********************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* binding */ CopyWidget; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! classnames */ "../../../node_modules/classnames/index.js"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var _CopyButton__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./CopyButton */ "./components/CopyButton.jsx"); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +var _excluded = ["value", "onChange", "style"]; + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } + +function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +/* eslint-disable react/prop-types */ + + + + +var CopyWidget = /*#__PURE__*/function (_Component) { + _inherits(CopyWidget, _Component); + + var _super = _createSuper(CopyWidget); + + function CopyWidget() { + _classCallCheck(this, CopyWidget); + + return _super.apply(this, arguments); + } + + _createClass(CopyWidget, [{ + key: "render", + value: function render() { + var _this$props = this.props, + value = _this$props.value, + onChange = _this$props.onChange, + style = _this$props.style, + props = _objectWithoutProperties(_this$props, _excluded); + + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "flex relative", + style: style + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("input", _extends({ + className: classnames__WEBPACK_IMPORTED_MODULE_1___default()("Form-input flex-full", { + "no-focus": !onChange + }), + style: { + paddingRight: 40 + }, + onClick: !onChange ? function (e) { + return e.target.setSelectionRange(0, e.target.value.length); + } : null, + value: value, + onChange: onChange + }, props)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_CopyButton__WEBPACK_IMPORTED_MODULE_2__.default, { + value: value, + className: "absolute top bottom right Form-input-border p1 flex align-center text-brand bg-brand-hover text-white-hover", + style: { + borderBottomLeftRadius: 0, + borderTopLeftRadius: 0, + borderTop: "none", + borderRight: "none", + borderBottom: "none" + } + })); + } + }]); + + return CopyWidget; +}(react__WEBPACK_IMPORTED_MODULE_0__.Component); + + + +/***/ }), + +/***/ "./components/DirectionalButton.jsx": +/*!******************************************!*\ + !*** ./components/DirectionalButton.jsx ***! + \******************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var metabase_components_Icon__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/components/Icon */ "./components/Icon.tsx"); +/* harmony import */ var metabase_lib_colors__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/lib/colors */ "./lib/colors.ts"); +/* eslint-disable react/prop-types */ + + + + +var DirectionalButton = function DirectionalButton(_ref) { + var _ref$direction = _ref.direction, + direction = _ref$direction === void 0 ? "left" : _ref$direction, + onClick = _ref.onClick; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "shadowed cursor-pointer text-brand-hover text-medium flex align-center circle p2 bg-white transition-background transition-color", + onClick: onClick, + style: { + border: "1px solid ".concat((0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_2__.color)("border")), + boxShadow: "0 2px 4px 0 ".concat((0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_2__.color)("shadow")) + } + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Icon__WEBPACK_IMPORTED_MODULE_1__.default, { + name: "arrow_".concat(direction) + })); +}; + +/* harmony default export */ __webpack_exports__["default"] = (DirectionalButton); + +/***/ }), + +/***/ "./components/DisclosureTriangle.jsx": +/*!*******************************************!*\ + !*** ./components/DisclosureTriangle.jsx ***! + \*******************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var react_motion__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-motion */ "../../../node_modules/react-motion/lib/react-motion.js"); +/* harmony import */ var metabase_components_Icon__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/components/Icon */ "./components/Icon.tsx"); +/* eslint-disable react/prop-types */ + + + + +var DisclosureTriangle = function DisclosureTriangle(_ref) { + var open = _ref.open, + className = _ref.className; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(react_motion__WEBPACK_IMPORTED_MODULE_1__.Motion, { + defaultStyle: { + deg: 0 + }, + style: { + deg: open ? (0,react_motion__WEBPACK_IMPORTED_MODULE_1__.spring)(0, react_motion__WEBPACK_IMPORTED_MODULE_1__.presets.gentle) : (0,react_motion__WEBPACK_IMPORTED_MODULE_1__.spring)(-90, react_motion__WEBPACK_IMPORTED_MODULE_1__.presets.gentle) + } + }, function (motionStyle) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Icon__WEBPACK_IMPORTED_MODULE_2__.default, { + className: className, + name: "expand_arrow", + style: { + transform: "rotate(".concat(motionStyle.deg, "deg)") + } + }); + }); +}; + +/* harmony default export */ __webpack_exports__["default"] = (DisclosureTriangle); + +/***/ }), + +/***/ "./components/DownloadButton.jsx": +/*!***************************************!*\ + !*** ./components/DownloadButton.jsx ***! + \***************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prop-types */ "../../../node_modules/prop-types/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var grid_styled__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! grid-styled */ "../../../node_modules/grid-styled/dist/index.js"); +/* harmony import */ var metabase_lib_colors__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/lib/colors */ "./lib/colors.ts"); +/* harmony import */ var metabase_lib_urls__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! metabase/lib/urls */ "./lib/urls.js"); +/* harmony import */ var metabase_components_Icon__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! metabase/components/Icon */ "./components/Icon.tsx"); +/* harmony import */ var metabase_components_type_Label__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! metabase/components/type/Label */ "./components/type/Label.jsx"); +var _excluded = ["children", "method", "url", "params", "extensions"]; + +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } + +function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } + +function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } + +function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } + +/* eslint-disable react/prop-types */ + + + + + + + + +function colorForType(type) { + switch (type) { + case "csv": + return (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_3__.color)("accent7"); + + case "xlsx": + return (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_3__.color)("accent1"); + + case "json": + return (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_3__.color)("bg-dark"); + + default: + return (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_3__.color)("brand"); + } +} + +var DownloadButton = function DownloadButton(_ref) { + var children = _ref.children, + method = _ref.method, + url = _ref.url, + params = _ref.params, + extensions = _ref.extensions, + props = _objectWithoutProperties(_ref, _excluded); + + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(grid_styled__WEBPACK_IMPORTED_MODULE_2__.Box, null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("form", { + method: method, + action: url + }, params && (0,metabase_lib_urls__WEBPACK_IMPORTED_MODULE_4__.extractQueryParams)(params).map(getInput), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(grid_styled__WEBPACK_IMPORTED_MODULE_2__.Flex, _extends({ + is: "button", + className: "text-white-hover bg-brand-hover rounded cursor-pointer full hover-parent hover--inherit", + align: "center", + p: 1, + my: 1, + onClick: function onClick(e) { + if (window.OSX) { + // prevent form from being submitted normally + e.preventDefault(); // download using the API provided by the OS X app + + window.OSX.download(method, url, params, extensions); + } + } + }, props), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Icon__WEBPACK_IMPORTED_MODULE_5__.default, { + name: children, + size: 32, + mr: 1, + color: colorForType(children) + }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_type_Label__WEBPACK_IMPORTED_MODULE_6__.default, { + my: 0 + }, ".", children)))); +}; + +var getInput = function getInput(_ref2) { + var _ref3 = _slicedToArray(_ref2, 2), + name = _ref3[0], + value = _ref3[1]; + + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("input", { + type: "hidden", + name: name, + value: value + }); +}; + +DownloadButton.propTypes = { + url: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string.isRequired), + method: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string), + params: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().object), + extensions: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().array) +}; +DownloadButton.defaultProps = { + method: "POST", + params: {}, + extensions: [] +}; +/* harmony default export */ __webpack_exports__["default"] = (DownloadButton); + +/***/ }), + +/***/ "./components/Ellipsified.jsx": +/*!************************************!*\ + !*** ./components/Ellipsified.jsx ***! + \************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* binding */ Ellipsified; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var metabase_components_Tooltip__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/components/Tooltip */ "./components/Tooltip/index.ts"); +/* harmony import */ var resize_observer_polyfill__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! resize-observer-polyfill */ "../../../node_modules/resize-observer-polyfill/dist/ResizeObserver.es.js"); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/* eslint-disable react/prop-types */ + + + + +var Ellipsified = /*#__PURE__*/function (_Component) { + _inherits(Ellipsified, _Component); + + var _super = _createSuper(Ellipsified); + + function Ellipsified(props, context) { + var _this; + + _classCallCheck(this, Ellipsified); + + _this = _super.call(this, props, context); + _this.state = { + isTruncated: false + }; + return _this; + } + + _createClass(Ellipsified, [{ + key: "componentDidMount", + value: function componentDidMount() { + var _this2 = this; + + // NOTE: Assumes _content won't change. Is this safe? + this._ro = new resize_observer_polyfill__WEBPACK_IMPORTED_MODULE_2__.default(function (entries, observer) { + _this2._updateTruncated(); + }); + + this._ro.observe(this._content); + + this._updateTruncated(); + } + }, { + key: "componentWillUnmount", + value: function componentWillUnmount() { + this._ro.disconnect(); + } + }, { + key: "_updateTruncated", + value: function _updateTruncated() { + var isTruncated = this._content.offsetWidth < this._content.scrollWidth; + + if (this.state.isTruncated !== isTruncated) { + this.setState({ + isTruncated: isTruncated + }); + } + } + }, { + key: "render", + value: function render() { + var _this3 = this; + + var _this$props = this.props, + showTooltip = _this$props.showTooltip, + children = _this$props.children, + style = _this$props.style, + className = _this$props.className, + tooltip = _this$props.tooltip, + alwaysShowTooltip = _this$props.alwaysShowTooltip, + tooltipMaxWidth = _this$props.tooltipMaxWidth; + var isTruncated = this.state.isTruncated; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Tooltip__WEBPACK_IMPORTED_MODULE_1__.default, { + tooltip: tooltip || children || " ", + verticalAttachments: ["top", "bottom"], + isEnabled: showTooltip && (isTruncated || alwaysShowTooltip) || false, + maxWidth: tooltipMaxWidth + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + ref: function ref(r) { + return _this3._content = r; + }, + className: className, + style: _objectSpread(_objectSpread({}, style), {}, { + overflow: "hidden", + whiteSpace: "nowrap", + textOverflow: "ellipsis" + }) + }, children)); + } + }]); + + return Ellipsified; +}(react__WEBPACK_IMPORTED_MODULE_0__.Component); + +_defineProperty(Ellipsified, "propTypes", {}); + +_defineProperty(Ellipsified, "defaultProps", { + style: {}, + className: "", + showTooltip: true +}); + + + +/***/ }), + +/***/ "./components/EmptyState.jsx": +/*!***********************************!*\ + !*** ./components/EmptyState.jsx ***! + \***********************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var grid_styled__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! grid-styled */ "../../../node_modules/grid-styled/dist/index.js"); +/* harmony import */ var metabase_components_Button__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/components/Button */ "./components/Button.tsx"); +/* harmony import */ var metabase_components_Icon__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/components/Icon */ "./components/Icon.tsx"); +/* harmony import */ var metabase_components_Link__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! metabase/components/Link */ "./components/Link.tsx"); +/* harmony import */ var metabase_components_type_Text__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! metabase/components/type/Text */ "./components/type/Text.jsx"); +var _excluded = ["title", "message", "action", "link", "illustrationElement", "onActionClick"]; + +function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } + +function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } + +/* eslint-disable react/prop-types */ + + + + + + // Don't break existing empty states +// TODO - remove these and update empty states with proper usage of illustrationElement + +var LegacyIcon = function LegacyIcon(props) { + return props.icon ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Icon__WEBPACK_IMPORTED_MODULE_3__.default, { + name: props.icon, + className: "text-light", + size: 40 + }) : null; +}; + +var LegacyImage = function LegacyImage(props) { + return props.image ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("img", { + src: "".concat(props.image, ".png"), + width: "300px", + height: props.imageHeight, + alt: props.message, + srcSet: "".concat(props.image, "@2x.png 2x"), + className: props.imageClassName + }) : null; +}; + +var EmptyState = function EmptyState(_ref) { + var title = _ref.title, + message = _ref.message, + action = _ref.action, + link = _ref.link, + illustrationElement = _ref.illustrationElement, + onActionClick = _ref.onActionClick, + rest = _objectWithoutProperties(_ref, _excluded); + + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(grid_styled__WEBPACK_IMPORTED_MODULE_1__.Box, null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(grid_styled__WEBPACK_IMPORTED_MODULE_1__.Flex, { + justify: "center", + flexDirection: "column", + align: "center" + }, illustrationElement && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(grid_styled__WEBPACK_IMPORTED_MODULE_1__.Box, { + mb: [2, 3] + }, illustrationElement), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(grid_styled__WEBPACK_IMPORTED_MODULE_1__.Box, null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(LegacyIcon, rest), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(LegacyImage, rest)), title && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("h2", { + className: "text-medium" + }, title), message && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_type_Text__WEBPACK_IMPORTED_MODULE_5__.default, { + color: "medium" + }, message)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(grid_styled__WEBPACK_IMPORTED_MODULE_1__.Flex, { + mt: 2 + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(grid_styled__WEBPACK_IMPORTED_MODULE_1__.Flex, { + align: "center", + ml: "auto", + mr: "auto" + }, action && link && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Link__WEBPACK_IMPORTED_MODULE_4__.default, { + to: link, + target: link.startsWith("http") ? "_blank" : "" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Button__WEBPACK_IMPORTED_MODULE_2__.default, { + primary: true + }, action)), action && onActionClick && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Button__WEBPACK_IMPORTED_MODULE_2__.default, { + onClick: onActionClick, + primary: true + }, action)))); +}; + +/* harmony default export */ __webpack_exports__["default"] = (EmptyState); + +/***/ }), + +/***/ "./components/EventSandbox.tsx": +/*!*************************************!*\ + !*** ./components/EventSandbox.tsx ***! + \*************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + + + +function stop(event) { + event.stopPropagation(); +} + +var mouseEventBlockers = { + onMouseDown: stop, + onMouseEnter: stop, + onMouseLeave: stop, + onMouseMove: stop, + onMouseOver: stop, + onMouseOut: stop, + onMouseUp: stop +}; + +// Prevent DOM events from bubbling through the React component tree +// This is useful for modals and popovers as they are often targeted to +// interactive elements. +function EventSandbox(_ref) { + var children = _ref.children, + disabled = _ref.disabled, + _ref$enableMouseEvent = _ref.enableMouseEvents, + enableMouseEvents = _ref$enableMouseEvent === void 0 ? false : _ref$enableMouseEvent; + var extraProps = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(function () { + return enableMouseEvents ? {} : mouseEventBlockers; + }, [enableMouseEvents]); + return disabled === true ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, children) : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", _extends({ + onClick: stop, + onContextMenu: stop, + onDoubleClick: stop, + onDrag: stop, + onDragEnd: stop, + onDragEnter: stop, + onDragExit: stop, + onDragLeave: stop, + onDragOver: stop, + onDragStart: stop, + onDrop: stop, + onKeyDown: stop, + onKeyPress: stop, + onKeyUp: stop, + onFocus: stop, + onBlur: stop, + onChange: stop, + onInput: stop, + onInvalid: stop, + onSubmit: stop + }, extraProps), children); +} + +/* harmony default export */ __webpack_exports__["default"] = (EventSandbox); + +/***/ }), + +/***/ "./components/Expander/Expander.jsx": +/*!******************************************!*\ + !*** ./components/Expander/Expander.jsx ***! + \******************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prop-types */ "../../../node_modules/prop-types/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var _Expander_styled__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Expander.styled */ "./components/Expander/Expander.styled.jsx"); + + + +var propTypes = { + isExpanded: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), + children: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().node), + onChange: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func) +}; + +var Expander = function Expander(_ref) { + var isExpanded = _ref.isExpanded, + children = _ref.children, + onChange = _ref.onChange; + var handleClick = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function () { + onChange && onChange(!isExpanded); + }, [isExpanded, onChange]); + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_Expander_styled__WEBPACK_IMPORTED_MODULE_2__.ExpanderRoot, { + type: "button", + onClick: handleClick, + "aria-expanded": isExpanded + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_Expander_styled__WEBPACK_IMPORTED_MODULE_2__.ExpanderContent, null, children), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_Expander_styled__WEBPACK_IMPORTED_MODULE_2__.ExpanderIcon, { + name: isExpanded ? "chevronup" : "chevrondown" + })); +}; + +Expander.propTypes = propTypes; +/* harmony default export */ __webpack_exports__["default"] = (Expander); + +/***/ }), + +/***/ "./components/Expander/Expander.styled.jsx": +/*!*************************************************!*\ + !*** ./components/Expander/Expander.styled.jsx ***! + \*************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "ExpanderRoot": function() { return /* binding */ ExpanderRoot; }, +/* harmony export */ "ExpanderContent": function() { return /* binding */ ExpanderContent; }, +/* harmony export */ "ExpanderIcon": function() { return /* binding */ ExpanderIcon; } +/* harmony export */ }); +/* harmony import */ var styled_components__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! styled-components */ "../../../node_modules/styled-components/dist/styled-components.browser.es.js"); +/* harmony import */ var metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/lib/colors */ "./lib/colors.ts"); +/* harmony import */ var metabase_components_Icon__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/components/Icon */ "./components/Icon.tsx"); + + + +var ExpanderRoot = styled_components__WEBPACK_IMPORTED_MODULE_0__.default.button.withConfig({ + displayName: "Expanderstyled__ExpanderRoot", + componentId: "bwjgrn-0" +})(["display:flex;align-items:center;color:", ";cursor:pointer;font-weight:bold;&:hover,&:focus{color:", ";}"], (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.color)("brand"), (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.lighten)("brand", 0.12)); +var ExpanderContent = styled_components__WEBPACK_IMPORTED_MODULE_0__.default.span.withConfig({ + displayName: "Expanderstyled__ExpanderContent", + componentId: "bwjgrn-1" +})(["margin-right:0.5rem;"]); +var ExpanderIcon = (0,styled_components__WEBPACK_IMPORTED_MODULE_0__.default)(metabase_components_Icon__WEBPACK_IMPORTED_MODULE_2__.default).withConfig({ + displayName: "Expanderstyled__ExpanderIcon", + componentId: "bwjgrn-2" +})(["width:0.75rem;height:0.75rem;transform:translateY(2px);"]); + +/***/ }), + +/***/ "./components/Expander/index.js": +/*!**************************************!*\ + !*** ./components/Expander/index.js ***! + \**************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* reexport safe */ _Expander__WEBPACK_IMPORTED_MODULE_0__.default; } +/* harmony export */ }); +/* harmony import */ var _Expander__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Expander */ "./components/Expander/Expander.jsx"); + + +/***/ }), + +/***/ "./components/ExpandingContent.jsx": +/*!*****************************************!*\ + !*** ./components/ExpandingContent.jsx ***! + \*****************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! classnames */ "../../../node_modules/classnames/index.js"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var metabase_lib_dom__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/lib/dom */ "./lib/dom.js"); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/* eslint-disable react/prop-types */ + + + + +var ExpandingContent = /*#__PURE__*/function (_Component) { + _inherits(ExpandingContent, _Component); + + var _super = _createSuper(ExpandingContent); + + function ExpandingContent(_ref) { + var _this; + + var isInitiallyOpen = _ref.isInitiallyOpen; + + _classCallCheck(this, ExpandingContent); + + _this = _super.call(this); + _this.state = { + isOpen: isInitiallyOpen == null ? true : !!isInitiallyOpen, + // keep track of whether we're currently transitioning so we can set maxHeight to "none" when not + isTransitioning: false + }; + return _this; + } + + _createClass(ExpandingContent, [{ + key: "UNSAFE_componentWillReceiveProps", + value: function UNSAFE_componentWillReceiveProps(nextProps) { + this.setOpen(nextProps.isOpen); + } + }, { + key: "componentDidMount", + value: function componentDidMount() { + this.setOpen(this.props.isOpen); + } + }, { + key: "componentWillUnmount", + value: function componentWillUnmount() { + this.clearTimer(); + } + }, { + key: "setOpen", + value: function setOpen(isOpen) { + var _this2 = this; + + isOpen = !!isOpen; + + if (this.state.isOpen !== isOpen) { + this.clearTimer(); + this.setState({ + isOpen: isOpen, + isTransitioning: true + }, function () { + _this2._timer = setTimeout(function () { + _this2.setState({ + isTransitioning: false + }); + }, _this2.props.duration); + }); + } + } + }, { + key: "clearTimer", + value: function clearTimer() { + if (this._timer != null) { + clearTimeout(this._timer); + this._timer = null; + } + } + }, { + key: "render", + value: function render() { + var _this3 = this; + + var _this$props = this.props, + children = _this$props.children, + duration = _this$props.duration, + animateHeight = _this$props.animateHeight, + animateOpacity = _this$props.animateOpacity; + var transition = (0,metabase_lib_dom__WEBPACK_IMPORTED_MODULE_2__.isReducedMotionPreferred)() ? "none" : "all ".concat(duration, "ms ease"); + var _this$state = this.state, + isOpen = _this$state.isOpen, + isTransitioning = _this$state.isTransitioning; // get the actual content height (after the first render) + + var maxHeight = isTransitioning ? this._ref && this._ref.scrollHeight || 0 : "none"; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + ref: function ref(_ref2) { + return _this3._ref = _ref2; + }, + style: { + transition: transition, + maxHeight: !animateHeight || isOpen ? maxHeight : 0, + opacity: !animateOpacity || isOpen ? 1 : 0 + }, + className: classnames__WEBPACK_IMPORTED_MODULE_1___default()({ + "overflow-hidden": !isOpen + }) + }, children); + } + }]); + + return ExpandingContent; +}(react__WEBPACK_IMPORTED_MODULE_0__.Component); + +_defineProperty(ExpandingContent, "defaultProps", { + duration: 300, + opacity: true, + animateHeight: true, + animateOpacity: true +}); + +/* harmony default export */ __webpack_exports__["default"] = (ExpandingContent); + +/***/ }), + +/***/ "./components/ExplicitSize.jsx": +/*!*************************************!*\ + !*** ./components/ExplicitSize.jsx ***! + \*************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-dom */ "../../../node_modules/react-dom/index.js"); +/* harmony import */ var resize_observer_polyfill__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! resize-observer-polyfill */ "../../../node_modules/resize-observer-polyfill/dist/ResizeObserver.es.js"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! classnames */ "../../../node_modules/classnames/index.js"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_3__); +/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! underscore */ "../../../node_modules/underscore/modules/index-all.js"); +/* harmony import */ var metabase_env__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! metabase/env */ "./env.js"); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +var _excluded = ["className", "style"]; + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } + +function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } + +function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/* eslint-disable react/prop-types */ + + + + + + // After adding throttling for resize re-renders, our Cypress tests became flaky +// due to queried DOM elements are getting detached after re-renders + +var throttleDuration = metabase_env__WEBPACK_IMPORTED_MODULE_5__.isCypressActive ? 0 : 500; +/* harmony default export */ __webpack_exports__["default"] = (function () { + var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, + selector = _ref.selector, + wrapped = _ref.wrapped; + + return function (ComposedComponent) { + var _class, _temp; + + return _temp = _class = /*#__PURE__*/function (_Component) { + _inherits(_class, _Component); + + var _super = _createSuper(_class); + + function _class(props, context) { + var _this; + + _classCallCheck(this, _class); + + _this = _super.call(this, props, context); + + _defineProperty(_assertThisInitialized(_this), "_updateSize", underscore__WEBPACK_IMPORTED_MODULE_4__.default.throttle(function () { + var element = _this._getElement(); + + if (element) { + var _element$getBoundingC = element.getBoundingClientRect(), + width = _element$getBoundingC.width, + height = _element$getBoundingC.height; + + if (_this.state.width !== width || _this.state.height !== height) { + _this.setState({ + width: width, + height: height + }); + } + } + }, throttleDuration)); + + _this.state = { + width: null, + height: null + }; + return _this; + } + + _createClass(_class, [{ + key: "_getElement", + value: function _getElement() { + var element = react_dom__WEBPACK_IMPORTED_MODULE_1__.findDOMNode(this); + + if (selector) { + return element.querySelector(selector) || element; + } + + return element; + } + }, { + key: "componentDidMount", + value: function componentDidMount() { + this._initMediaQueryListener(); + + this._initResizeObserver(); + + this._updateResizeObserver(); // Set the size on the next tick. We had issues with wrapped components + // not adjusting if the size was fixed during mounting. + + + setTimeout(this._updateSize, 0); + } + }, { + key: "componentDidUpdate", + value: function componentDidUpdate() { + // update ResizeObserver if element changes + this._updateResizeObserver(); + + this._updateSize(); + } + }, { + key: "componentWillUnmount", + value: function componentWillUnmount() { + this._teardownResizeObserver(); + + this._teardownQueryMediaListener(); + } // ResizeObserver, ensure re-layout when container element changes size + + }, { + key: "_initResizeObserver", + value: function _initResizeObserver() { + var _this2 = this; + + this._ro = new resize_observer_polyfill__WEBPACK_IMPORTED_MODULE_2__.default(function (entries, observer) { + var element = _this2._getElement(); + + var _iterator = _createForOfIteratorHelper(entries), + _step; + + try { + for (_iterator.s(); !(_step = _iterator.n()).done;) { + var entry = _step.value; + + if (entry.target === element) { + _this2._updateSize(); + + return; + } + } + } catch (err) { + _iterator.e(err); + } finally { + _iterator.f(); + } + }); + } + }, { + key: "_updateResizeObserver", + value: function _updateResizeObserver() { + var element = this._getElement(); + + if (this._currentElement !== element) { + this._currentElement = element; + + this._ro.observe(this._currentElement); + } + } + }, { + key: "_teardownResizeObserver", + value: function _teardownResizeObserver() { + if (this._ro) { + this._ro.disconnect(); + + this._ro = null; + } + } // media query listener, ensure re-layout when printing + + }, { + key: "_initMediaQueryListener", + value: function _initMediaQueryListener() { + if (window.matchMedia) { + this._mql = window.matchMedia("print"); + + this._mql.addListener(this._updateSize); + } + } + }, { + key: "_teardownQueryMediaListener", + value: function _teardownQueryMediaListener() { + if (this._mql) { + this._mql.removeListener(this._updateSize); + + this._mql = null; + } + } // if _currentElement's dimensions change too frequently this function + // can freeze the application + + }, { + key: "render", + value: function render() { + if (wrapped) { + var _this$props = this.props, + className = _this$props.className, + _this$props$style = _this$props.style, + style = _this$props$style === void 0 ? {} : _this$props$style, + props = _objectWithoutProperties(_this$props, _excluded); + + var _this$state = this.state, + width = _this$state.width, + height = _this$state.height; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: classnames__WEBPACK_IMPORTED_MODULE_3___default()(className, "relative"), + style: style + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(ComposedComponent, _extends({ + style: { + position: "absolute", + top: 0, + left: 0, + width: width, + height: height + } + }, props, this.state))); + } else { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(ComposedComponent, _extends({}, this.props, this.state)); + } + } + }]); + + return _class; + }(react__WEBPACK_IMPORTED_MODULE_0__.Component), _defineProperty(_class, "displayName", "ExplicitSize[" + (ComposedComponent.displayName || ComposedComponent.name) + "]"), _temp; + }; +}); + +/***/ }), + +/***/ "./components/ExternalLink.tsx": +/*!*************************************!*\ + !*** ./components/ExternalLink.tsx ***! + \*************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var metabase_lib_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/lib/dom */ "./lib/dom.js"); +var _excluded = ["href", "target", "className", "children"]; + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } + +function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } + + + +var ExternalLink = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(function ExternalLink(_ref, ref) { + var href = _ref.href, + _ref$target = _ref.target, + target = _ref$target === void 0 ? (0,metabase_lib_dom__WEBPACK_IMPORTED_MODULE_1__.getUrlTarget)(href) : _ref$target, + className = _ref.className, + children = _ref.children, + props = _objectWithoutProperties(_ref, _excluded); + + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("a", _extends({ + ref: ref, + href: href, + className: className || "link", + target: target // prevent malicious pages from navigating us away + , + rel: "noopener noreferrer" // disables quickfilter in tables + , + onClickCapture: function onClickCapture(e) { + return e.stopPropagation(); + } + }, props), children); +}); +/* harmony default export */ __webpack_exports__["default"] = (ExternalLink); + +/***/ }), + +/***/ "./components/FieldSet.jsx": +/*!*********************************!*\ + !*** ./components/FieldSet.jsx ***! + \*********************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* binding */ FieldSet; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! classnames */ "../../../node_modules/classnames/index.js"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_1__); +/* eslint-disable react/prop-types */ + + +function FieldSet(_ref) { + var _ref$className = _ref.className, + className = _ref$className === void 0 ? "border-brand" : _ref$className, + legend = _ref.legend, + noPadding = _ref.noPadding, + children = _ref.children; + var fieldSetClassName = classnames__WEBPACK_IMPORTED_MODULE_1___default()("bordered rounded", { + "px2 pb2": !noPadding + }); + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("fieldset", { + className: classnames__WEBPACK_IMPORTED_MODULE_1___default()(className, fieldSetClassName) + }, legend && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("legend", { + className: "h5 text-bold text-uppercase px1 text-nowrap text-medium" + }, legend), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "w-full" + }, children)); +} + +/***/ }), + +/***/ "./components/FieldValuesWidget.jsx": +/*!******************************************!*\ + !*** ./components/FieldValuesWidget.jsx ***! + \******************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "FieldValuesWidget": function() { return /* binding */ FieldValuesWidget; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prop-types */ "../../../node_modules/prop-types/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var react_redux__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react-redux */ "../../../node_modules/react-redux/es/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_3__); +/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! underscore */ "../../../node_modules/underscore/modules/index-all.js"); +/* harmony import */ var metabase_components_TokenField__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! metabase/components/TokenField */ "./components/TokenField.jsx"); +/* harmony import */ var metabase_components_ListField__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! metabase/components/ListField */ "./components/ListField/index.ts"); +/* harmony import */ var metabase_components_Value__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! metabase/components/Value */ "./components/Value.jsx"); +/* harmony import */ var metabase_components_LoadingSpinner__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! metabase/components/LoadingSpinner */ "./components/LoadingSpinner/index.ts"); +/* harmony import */ var metabase_hoc_AutoExpanding__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! metabase/hoc/AutoExpanding */ "./hoc/AutoExpanding.jsx"); +/* harmony import */ var metabase_services__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! metabase/services */ "./services.js"); +/* harmony import */ var metabase_redux_metadata__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! metabase/redux/metadata */ "./redux/metadata.js"); +/* harmony import */ var metabase_lib_promise__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! metabase/lib/promise */ "./lib/promise.js"); +/* harmony import */ var metabase_lib_formatting__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! metabase/lib/formatting */ "./lib/formatting.js"); +/* harmony import */ var metabase_entities_fields__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! metabase/entities/fields */ "./entities/fields.js"); +/* provided dependency */ var console = __webpack_require__(/*! console-browserify */ "../../../node_modules/console-browserify/index.js"); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +var _class, _class2, _temp, _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10; + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } + +function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } + +function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } + +function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } + +/* eslint-disable react/prop-types */ + + + + + + + + + + + + + + + +var MAX_SEARCH_RESULTS = 100; +var fieldValuesWidgetPropTypes = { + addRemappings: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func), + expand: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool) +}; +var optionsMessagePropTypes = { + message: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string.isRequired) +}; // fetch the possible values of a parameter based on the values of the other parameters in a dashboard. +// parameterId = the auto-generated ID of the parameter +// parameters = all parameters in the current dashboard, as an array + +var fetchParameterPossibleValues = /*#__PURE__*/function () { + var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(dashboardId) { + var _ref2, + paramId, + _ref2$filteringParame, + filteringParameters, + parameters, + query, + otherValues, + args, + endpoint, + results, + _args = arguments; + + return regeneratorRuntime.wrap(function _callee$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + _ref2 = _args.length > 1 && _args[1] !== undefined ? _args[1] : {}, paramId = _ref2.id, _ref2$filteringParame = _ref2.filteringParameters, filteringParameters = _ref2$filteringParame === void 0 ? [] : _ref2$filteringParame; + parameters = _args.length > 2 ? _args[2] : undefined; + query = _args.length > 3 ? _args[3] : undefined; + // build a map of parameter ID -> value for parameters that this parameter is filtered by + otherValues = underscore__WEBPACK_IMPORTED_MODULE_4__.default.chain(parameters).filter(function (p) { + return filteringParameters.includes(p.id) && p.value != null; + }).map(function (p) { + return [p.id, p.value]; + }).object().value(); + args = _objectSpread({ + paramId: paramId, + query: query, + dashId: dashboardId + }, otherValues); + endpoint = query ? metabase_services__WEBPACK_IMPORTED_MODULE_10__.DashboardApi.parameterSearch : metabase_services__WEBPACK_IMPORTED_MODULE_10__.DashboardApi.parameterValues; // now call the new chain filter API endpoint + + _context.next = 8; + return endpoint(args); + + case 8: + results = _context.sent; + return _context.abrupt("return", results.map(function (result) { + return [].concat(result); + })); + + case 10: + case "end": + return _context.stop(); + } + } + }, _callee); + })); + + return function fetchParameterPossibleValues(_x) { + return _ref.apply(this, arguments); + }; +}(); + +var mapDispatchToProps = { + addRemappings: metabase_redux_metadata__WEBPACK_IMPORTED_MODULE_11__.addRemappings, + fetchFieldValues: metabase_redux_metadata__WEBPACK_IMPORTED_MODULE_11__.fetchFieldValues +}; + +function mapStateToProps(state, _ref3) { + var _ref3$fields = _ref3.fields, + fields = _ref3$fields === void 0 ? [] : _ref3$fields; + // try and use the selected fields, but fall back to the ones passed + return { + fields: fields.map(function (field) { + return metabase_entities_fields__WEBPACK_IMPORTED_MODULE_14__.default.selectors.getObject(state, { + entityId: field.id + }) || field; + }) + }; +} + +var FieldValuesWidget = (0,metabase_hoc_AutoExpanding__WEBPACK_IMPORTED_MODULE_9__.default)(_class = (_temp = _class2 = /*#__PURE__*/function (_Component) { + _inherits(FieldValuesWidget, _Component); + + var _super = _createSuper(FieldValuesWidget); + + function FieldValuesWidget(props) { + var _this; + + _classCallCheck(this, FieldValuesWidget); + + _this = _super.call(this, props); + + _defineProperty(_assertThisInitialized(_this), "fetchDashboardParamValues", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() { + var options, _this$props, dashboard, parameter, parameters; + + return regeneratorRuntime.wrap(function _callee2$(_context2) { + while (1) { + switch (_context2.prev = _context2.next) { + case 0: + _this.setState({ + loadingState: "LOADING", + options: [] + }); + + _context2.prev = 1; + _this$props = _this.props, dashboard = _this$props.dashboard, parameter = _this$props.parameter, parameters = _this$props.parameters; + _context2.next = 5; + return fetchParameterPossibleValues(dashboard && dashboard.id, parameter, parameters); + + case 5: + options = _context2.sent; + + case 6: + _context2.prev = 6; + + _this.setState({ + loadingState: "LOADED", + options: options + }); + + return _context2.finish(6); + + case 9: + case "end": + return _context2.stop(); + } + } + }, _callee2, null, [[1,, 6, 9]]); + }))); + + _defineProperty(_assertThisInitialized(_this), "onInputChange", function (value) { + if (value && _this.isSearchable()) { + _this._search(value); + } + + return value; + }); + + _defineProperty(_assertThisInitialized(_this), "searchField", function (field) { + if (_this.props.disablePKRemappingForSearch && field.isPK()) { + return field.isSearchable() ? field : null; + } + + var remappedField = field.remappedField(); + + if (remappedField && remappedField.isSearchable()) { + return remappedField; + } + + return field.isSearchable() ? field : null; + }); + + _defineProperty(_assertThisInitialized(_this), "showRemapping", function () { + return _this.props.fields.length === 1; + }); + + _defineProperty(_assertThisInitialized(_this), "search", /*#__PURE__*/function () { + var _ref5 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(value, cancelled) { + var fields, results, _this$props2, dashboard, parameter, parameters, _fields, field; + + return regeneratorRuntime.wrap(function _callee3$(_context3) { + while (1) { + switch (_context3.prev = _context3.next) { + case 0: + if (value) { + _context3.next = 2; + break; + } + + return _context3.abrupt("return"); + + case 2: + fields = _this.props.fields; + + if (!_this.useChainFilterEndpoints()) { + _context3.next = 10; + break; + } + + _this$props2 = _this.props, dashboard = _this$props2.dashboard, parameter = _this$props2.parameter, parameters = _this$props2.parameters; + _context3.next = 7; + return fetchParameterPossibleValues(dashboard && dashboard.id, parameter, parameters, value); + + case 7: + results = _context3.sent; + _context3.next = 16; + break; + + case 10: + _context3.t0 = dedupeValues; + _context3.next = 13; + return Promise.all(fields.map(function (field) { + return metabase_services__WEBPACK_IMPORTED_MODULE_10__.MetabaseApi.field_search({ + value: value, + fieldId: field.id, + searchFieldId: _this.searchField(field).id, + limit: _this.props.maxResults + }, { + cancelled: cancelled + }); + })); + + case 13: + _context3.t1 = _context3.sent; + results = (0, _context3.t0)(_context3.t1); + results = results.map(function (result) { + return [].concat(result); + }); + + case 16: + if (_this.showRemapping()) { + _fields = _slicedToArray(fields, 1), field = _fields[0]; + + if (field.remappedField() === _this.searchField(field)) { + _this.props.addRemappings(field.id, results); + } + } + + return _context3.abrupt("return", results); + + case 18: + case "end": + return _context3.stop(); + } + } + }, _callee3); + })); + + return function (_x2, _x3) { + return _ref5.apply(this, arguments); + }; + }()); + + _defineProperty(_assertThisInitialized(_this), "_search", function (value) { + var _this$state = _this.state, + lastValue = _this$state.lastValue, + options = _this$state.options; // if this search is just an extension of the previous search, and the previous search + // wasn't truncated, then we don't need to do another search because TypeaheadListing + // will filter the previous result client-side + + if (lastValue && value.slice(0, lastValue.length) === lastValue && options.length < _this.props.maxResults) { + return; + } + + _this.setState({ + loadingState: "LOADING" + }); + + if (_this._cancel) { + _this._cancel(); + } + + _this._searchDebounced(value); + }); + + _defineProperty(_assertThisInitialized(_this), "_searchDebounced", underscore__WEBPACK_IMPORTED_MODULE_4__.default.debounce( /*#__PURE__*/function () { + var _ref6 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(value) { + var cancelDeferred, results; + return regeneratorRuntime.wrap(function _callee4$(_context4) { + while (1) { + switch (_context4.prev = _context4.next) { + case 0: + _this.setState({ + loadingState: "LOADING" + }); + + cancelDeferred = (0,metabase_lib_promise__WEBPACK_IMPORTED_MODULE_12__.defer)(); + + _this._cancel = function () { + _this._cancel = null; + cancelDeferred.resolve(); + }; + + _context4.prev = 3; + _context4.next = 6; + return _this.search(value, cancelDeferred.promise); + + case 6: + results = _context4.sent; + _context4.next = 12; + break; + + case 9: + _context4.prev = 9; + _context4.t0 = _context4["catch"](3); + console.warn(_context4.t0); + + case 12: + _this._cancel = null; + + if (results) { + _this.setState({ + loadingState: "LOADED", + options: results, + lastValue: value + }); + } else { + _this.setState({ + loadingState: "INIT", + options: [], + lastValue: value + }); + } + + case 14: + case "end": + return _context4.stop(); + } + } + }, _callee4, null, [[3, 9]]); + })); + + return function (_x4) { + return _ref6.apply(this, arguments); + }; + }(), 500)); + + _defineProperty(_assertThisInitialized(_this), "renderValue", function (value, options) { + var _this$props3 = _this.props, + fields = _this$props3.fields, + formatOptions = _this$props3.formatOptions; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Value__WEBPACK_IMPORTED_MODULE_7__.default, _extends({ + value: value, + column: fields[0], + maximumFractionDigits: 20, + remap: _this.showRemapping() + }, formatOptions, options)); + }); + + _this.state = { + options: [], + loadingState: "INIT", + lastValue: "" + }; + return _this; + } + + _createClass(FieldValuesWidget, [{ + key: "useChainFilterEndpoints", + value: // if [dashboard] parameter ID is specified use the fancy new Chain Filter API endpoints to fetch parameter values. + // Otherwise (e.g. for Cards) fall back to the old field/:id/values endpoint + function useChainFilterEndpoints() { + return this.props.dashboard && this.props.dashboard.id; + } + }, { + key: "parameterId", + value: function parameterId() { + return this.props.parameter && this.props.parameter.id; + } + }, { + key: "componentDidMount", + value: function componentDidMount() { + if (this.shouldList()) { + if (this.useChainFilterEndpoints()) { + this.fetchDashboardParamValues(); + } else { + var _this$props4 = this.props, + fields = _this$props4.fields, + _fetchFieldValues = _this$props4.fetchFieldValues; + fields.forEach(function (field) { + return _fetchFieldValues(field.id); + }); + } + } + } + }, { + key: "componentWillUnmount", + value: function componentWillUnmount() { + if (this._cancel) { + this._cancel(); + } + } + }, { + key: "getSearchableTokenFieldPlaceholder", + value: function getSearchableTokenFieldPlaceholder(fields, firstField) { + var _this2 = this; + + var placeholder; + var names = new Set(fields.map(function (field) { + return (0,metabase_lib_formatting__WEBPACK_IMPORTED_MODULE_13__.stripId)(_this2.searchField(field).display_name); + })); + + if (names.size > 1) { + placeholder = (0,ttag__WEBPACK_IMPORTED_MODULE_3__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["Search"]))); + } else { + var _names = _slicedToArray(names, 1), + name = _names[0]; + + placeholder = (0,ttag__WEBPACK_IMPORTED_MODULE_3__.t)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["Search by ", ""])), name); + + if (firstField.isID() && firstField !== this.searchField(firstField)) { + placeholder += (0,ttag__WEBPACK_IMPORTED_MODULE_3__.t)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral([" or enter an ID"]))); + } + } + + return placeholder; + } + }, { + key: "getNonSearchableTokenFieldPlaceholder", + value: function getNonSearchableTokenFieldPlaceholder(firstField) { + if (firstField.isID()) { + return (0,ttag__WEBPACK_IMPORTED_MODULE_3__.t)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["Enter an ID"]))); + } else if (firstField.isNumeric()) { + return (0,ttag__WEBPACK_IMPORTED_MODULE_3__.t)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["Enter a number"]))); + } else { + return (0,ttag__WEBPACK_IMPORTED_MODULE_3__.t)(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["Enter some text"]))); + } + } + }, { + key: "getTokenFieldPlaceholder", + value: function getTokenFieldPlaceholder() { + var _this$props5 = this.props, + fields = _this$props5.fields, + placeholder = _this$props5.placeholder; + + if (placeholder) { + return placeholder; + } + + var _fields2 = _slicedToArray(fields, 1), + firstField = _fields2[0]; + + if (this.hasList()) { + return (0,ttag__WEBPACK_IMPORTED_MODULE_3__.t)(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["Search the list"]))); + } else if (this.isSearchable()) { + return this.getSearchableTokenFieldPlaceholder(fields, firstField); + } else { + return this.getNonSearchableTokenFieldPlaceholder(firstField); + } + } + }, { + key: "shouldList", + value: function shouldList() { + // Virtual fields come from questions that are based on other questions. + // Currently, the back end does not return `has_field_values` in their metadata, + // so we ignore them for now. + var nonVirtualFields = this.props.fields.filter(function (field) { + return typeof field.id === "number"; + }); + return !this.props.disableSearch && nonVirtualFields.every(function (field) { + return field.has_field_values === "list"; + }); + } + }, { + key: "hasList", + value: function hasList() { + var nonEmptyArray = function nonEmptyArray(a) { + return a && a.length > 0; + }; + + return this.shouldList() && (this.useChainFilterEndpoints() ? this.state.loadingState === "LOADED" && nonEmptyArray(this.state.options) : this.props.fields.every(function (field) { + return nonEmptyArray(field.values); + })); + } + }, { + key: "isSearchable", + value: function isSearchable() { + var _this$props6 = this.props, + fields = _this$props6.fields, + disableSearch = _this$props6.disableSearch; + return !disableSearch && // search is available if: + // all fields have a valid search field + fields.every(this.searchField) && // at least one field is set to display as "search" + fields.some(function (f) { + return f.has_field_values === "search"; + }) && // and all fields are either "search" or "list" + fields.every(function (f) { + return f.has_field_values === "search" || f.has_field_values === "list"; + }); + } + }, { + key: "renderOptions", + value: function renderOptions(_ref7) { + var optionsList = _ref7.optionsList, + isFocused = _ref7.isFocused, + isAllSelected = _ref7.isAllSelected, + isFiltered = _ref7.isFiltered; + var _this$props7 = this.props, + alwaysShowOptions = _this$props7.alwaysShowOptions, + fields = _this$props7.fields; + var loadingState = this.state.loadingState; + + if (alwaysShowOptions || isFocused) { + if (optionsList) { + return optionsList; + } else if (this.hasList()) { + if (isAllSelected) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(EveryOptionState, null); + } + } else if (this.isSearchable()) { + if (loadingState === "LOADING") { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(LoadingState, null); + } else if (loadingState === "LOADED" && isFiltered) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(NoMatchState, { + fields: fields.map(this.searchField) + }); + } + } + } + } + }, { + key: "render", + value: function render() { + var _this3 = this; + + var _this$props8 = this.props, + value = _this$props8.value, + onChange = _this$props8.onChange, + fields = _this$props8.fields, + multi = _this$props8.multi, + autoFocus = _this$props8.autoFocus, + color = _this$props8.color, + className = _this$props8.className, + style = _this$props8.style, + parameter = _this$props8.parameter; + var loadingState = this.state.loadingState; + var placeholder = this.getTokenFieldPlaceholder(); + var options = []; + + if (this.hasList() && !this.useChainFilterEndpoints()) { + options = dedupeValues(fields.map(function (field) { + return field.values; + })); + } else if (loadingState === "LOADED" && (this.isSearchable() || this.useChainFilterEndpoints())) { + options = this.state.options; + } else { + options = []; + } + + var isLoading = loadingState === "LOADING"; + var isFetchingList = this.shouldList() && isLoading; + var hasListData = this.hasList(); + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + style: { + width: this.props.expand ? this.props.maxWidth : null, + minWidth: this.props.minWidth, + maxWidth: this.props.maxWidth + } + }, isFetchingList && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(LoadingState, null), hasListData && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_ListField__WEBPACK_IMPORTED_MODULE_6__.ListField, { + isDashboardFilter: parameter, + placeholder: this.getTokenFieldPlaceholder(), + value: value.filter(function (v) { + return v != null; + }), + onChange: onChange, + options: options, + optionRenderer: function optionRenderer(option) { + return _this3.renderValue(option[0], { + autoLoad: false + }); + } + }), !hasListData && !isFetchingList && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_TokenField__WEBPACK_IMPORTED_MODULE_5__.default, { + value: value.filter(function (v) { + return v != null; + }), + onChange: onChange, + placeholder: placeholder, + updateOnInputChange: true // forwarded props + , + multi: multi, + autoFocus: autoFocus, + color: color, + style: _objectSpread(_objectSpread({}, style), {}, { + minWidth: "inherit" + }), + className: className, + parameter: this.props.parameter, + optionsStyle: !parameter ? { + maxHeight: "none" + } : {} // end forwarded props + , + options: options, + valueKey: 0, + valueRenderer: function valueRenderer(value) { + return _this3.renderValue(value, { + autoLoad: true, + compact: false + }); + }, + optionRenderer: function optionRenderer(option) { + return _this3.renderValue(option[0], { + autoLoad: false + }); + }, + layoutRenderer: function layoutRenderer(props) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", null, props.valuesList, _this3.renderOptions(props)); + }, + filterOption: function filterOption(option, filterString) { + var lowerCaseFilterString = filterString.toLowerCase(); + return option.some(function (value) { + return value != null && String(value).toLowerCase().includes(lowerCaseFilterString); + }); + }, + onInputChange: this.onInputChange, + parseFreeformValue: function parseFreeformValue(v) { + // trim whitespace + v = String(v || "").trim(); // empty string is not valid + + if (!v) { + return null; + } // if the field is numeric we need to parse the string into an integer + + + if (fields[0].isNumeric()) { + if (/^-?\d+(\.\d+)?$/.test(v)) { + return parseFloat(v); + } else { + return null; + } + } + + return v; + } + })); + } + }]); + + return FieldValuesWidget; +}(react__WEBPACK_IMPORTED_MODULE_0__.Component), _defineProperty(_class2, "defaultProps", { + color: "purple", + maxResults: MAX_SEARCH_RESULTS, + alwaysShowOptions: true, + style: {}, + formatOptions: {}, + maxWidth: 500, + disableSearch: false +}), _temp)) || _class; +FieldValuesWidget.propTypes = fieldValuesWidgetPropTypes; + +function dedupeValues(valuesList) { + var uniqueValueMap = new Map(valuesList.flat().map(function (o) { + return [o[0], o]; + })); + return Array.from(uniqueValueMap.values()); +} + +var LoadingState = function LoadingState() { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "flex layout-centered align-center border-bottom", + style: { + minHeight: 82 + } + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_LoadingSpinner__WEBPACK_IMPORTED_MODULE_8__.default, { + size: 32 + })); +}; + +var NoMatchState = function NoMatchState(_ref8) { + var fields = _ref8.fields; + + if (fields.length > 1) { + // if there is more than one field, don't name them + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(OptionsMessage, { + message: (0,ttag__WEBPACK_IMPORTED_MODULE_3__.t)(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["No matching result"]))) + }); + } + + var _fields3 = _slicedToArray(fields, 1), + display_name = _fields3[0].display_name; + + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(OptionsMessage, { + message: (0,ttag__WEBPACK_IMPORTED_MODULE_3__.jt)(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["No matching ", " found."])), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("strong", null, "\xA0", display_name, "\xA0")) + }); +}; + +var EveryOptionState = function EveryOptionState() { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(OptionsMessage, { + message: (0,ttag__WEBPACK_IMPORTED_MODULE_3__.t)(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["Including every option in your filter probably won\u2019t do much\u2026"]))) + }); +}; + +var OptionsMessage = function OptionsMessage(_ref9) { + var message = _ref9.message; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "flex layout-centered p4 border-bottom" + }, message); +}; + +OptionsMessage.propTypes = optionsMessagePropTypes; +/* harmony default export */ __webpack_exports__["default"] = ((0,react_redux__WEBPACK_IMPORTED_MODULE_2__.connect)(mapStateToProps, mapDispatchToProps)(FieldValuesWidget)); + +/***/ }), + +/***/ "./components/Grabber.jsx": +/*!********************************!*\ + !*** ./components/Grabber.jsx ***! + \********************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* binding */ Grabber; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! classnames */ "../../../node_modules/classnames/index.js"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_1__); +/* eslint-disable react/prop-types */ + + +function Grabber(_ref) { + var className = _ref.className, + style = _ref.style; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: classnames__WEBPACK_IMPORTED_MODULE_1___default()("Grabber cursor-grab", className), + style: style + }); +} + +/***/ }), + +/***/ "./components/Icon.tsx": +/*!*****************************!*\ + !*** ./components/Icon.tsx ***! + \*****************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "IconWrapper": function() { return /* binding */ IconWrapper; }, +/* harmony export */ "iconPropTypes": function() { return /* binding */ iconPropTypes; } +/* harmony export */ }); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! classnames */ "../../../node_modules/classnames/index.js"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prop-types */ "../../../node_modules/prop-types/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var styled_components__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! styled-components */ "../../../node_modules/styled-components/dist/styled-components.browser.es.js"); +/* harmony import */ var styled_system__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! styled-system */ "../../../node_modules/styled-system/dist/index.js"); +/* harmony import */ var metabase_components_Tooltip__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! metabase/components/Tooltip */ "./components/Tooltip/index.ts"); +/* harmony import */ var metabase_icon_paths__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! metabase/icon_paths */ "./icon_paths.ts"); +/* harmony import */ var metabase_lib_colors__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! metabase/lib/colors */ "./lib/colors.ts"); +/* harmony import */ var metabase_lib_utils__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! metabase/lib/utils */ "./lib/utils.js"); +/* harmony import */ var metabase_styled_components_utils__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! metabase/styled-components/utils */ "./styled-components/utils.tsx"); +/* provided dependency */ var console = __webpack_require__(/*! console-browserify */ "../../../node_modules/console-browserify/index.js"); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +var _excluded = ["name", "className", "innerRef"], + _excluded2 = ["_role"], + _excluded3 = ["tooltip"]; + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } + +function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + + + + + + + + + + + +var MISSING_ICON_NAME = "unknown"; +var IconWrapper = styled_components__WEBPACK_IMPORTED_MODULE_3__.default.div.withConfig({ + displayName: "Icon__IconWrapper", + componentId: "oj89wd-0" +})(["", ";display:flex;align-items:center;justify-content:center;width:40px;height:40px;border-radius:99px;cursor:pointer;color:", ";\"> .icon.icon-share\":{transform:translateY(-2px);}", ";transition:all 300ms ease-in-out;"], styled_system__WEBPACK_IMPORTED_MODULE_4__.space, function (props) { + return props.open ? (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_7__.color)("brand") : "inherit"; +}, styled_system__WEBPACK_IMPORTED_MODULE_4__.hover); +IconWrapper.defaultProps = { + hover: { + backgroundColor: (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_7__.color)("bg-medium"), + color: (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_7__.color)("brand") + } +}; +var stringOrNumberPropType = prop_types__WEBPACK_IMPORTED_MODULE_1___default().oneOfType([(prop_types__WEBPACK_IMPORTED_MODULE_1___default().number), (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string)]); +var iconPropTypes = { + name: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string.isRequired), + color: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string), + size: stringOrNumberPropType, + width: stringOrNumberPropType, + height: stringOrNumberPropType, + scale: stringOrNumberPropType, + tooltip: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string), + className: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string), + innerRef: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().any), + onClick: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func) +}; + +var BaseIcon = /*#__PURE__*/function (_Component) { + _inherits(BaseIcon, _Component); + + var _super = _createSuper(BaseIcon); + + function BaseIcon() { + _classCallCheck(this, BaseIcon); + + return _super.apply(this, arguments); + } + + _createClass(BaseIcon, [{ + key: "render", + value: function render() { + var _this$props = this.props, + name = _this$props.name, + className = _this$props.className, + innerRef = _this$props.innerRef, + rest = _objectWithoutProperties(_this$props, _excluded); + + var icon = (0,metabase_icon_paths__WEBPACK_IMPORTED_MODULE_6__.loadIcon)(name) || (0,metabase_icon_paths__WEBPACK_IMPORTED_MODULE_6__.loadIcon)(MISSING_ICON_NAME); + + if (!icon) { + console.warn("Icon \"".concat(name, "\" does not exist.")); + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2__.createElement("span", { + ref: innerRef + }); + } + + var props = _objectSpread(_objectSpread(_objectSpread({}, icon.attrs), (0,metabase_lib_utils__WEBPACK_IMPORTED_MODULE_8__.stripLayoutProps)(rest)), {}, { + className: classnames__WEBPACK_IMPORTED_MODULE_0___default()(icon.attrs.className, className) + }); + + for (var _i = 0, _arr = ["width", "height", "size", "scale"]; _i < _arr.length; _i++) { + var prop = _arr[_i]; + + if (typeof props[prop] === "string") { + props[prop] = parseInt(props[prop], 10); + } + } + + if (props.size != null) { + props.width = props.size; + props.height = props.size; + } + + if (props.scale != null && props.width != null && props.height != null) { + props.width *= props.scale; + props.height *= props.scale; + } + + delete props.size, props.scale; + + if (icon.img) { + // avoid passing `role="img"` to an actual image file + var _role = props._role, + _rest = _objectWithoutProperties(props, _excluded2); + + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2__.createElement("img", _extends({ + ref: innerRef, + src: icon.img, + srcSet: "\n ".concat(icon.img, " 1x,\n ").concat(icon.img_2x, " 2x\n ") + }, _rest)); + } else if (icon.svg) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2__.createElement("svg", _extends({}, props, { + dangerouslySetInnerHTML: { + __html: icon.svg + }, + ref: innerRef + })); + } else if (icon.path) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2__.createElement("svg", _extends({}, props, { + ref: innerRef + }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2__.createElement("path", { + d: icon.path + })); + } else { + console.warn("Icon \"".concat(name, "\" must have an img, svg, or path")); + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2__.createElement("span", { + ref: innerRef + }); + } + } + }]); + + return BaseIcon; +}(react__WEBPACK_IMPORTED_MODULE_2__.Component); + +_defineProperty(BaseIcon, "propTypes", iconPropTypes); + +var BaseIconWithRef = (0,metabase_styled_components_utils__WEBPACK_IMPORTED_MODULE_9__.forwardRefToInnerRef)(BaseIcon); +var StyledIcon = (0,metabase_styled_components_utils__WEBPACK_IMPORTED_MODULE_9__.forwardRefToInnerRef)((0,styled_components__WEBPACK_IMPORTED_MODULE_3__.default)(BaseIconWithRef).withConfig({ + displayName: "Icon__StyledIcon", + componentId: "oj89wd-1" +})(["", " ", " ", " flex-shrink:0"], styled_system__WEBPACK_IMPORTED_MODULE_4__.space, styled_system__WEBPACK_IMPORTED_MODULE_4__.color, styled_system__WEBPACK_IMPORTED_MODULE_4__.hover)); +var Icon = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_2__.forwardRef)(function Icon(_ref, ref) { + var tooltip = _ref.tooltip, + props = _objectWithoutProperties(_ref, _excluded3); + + return tooltip ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2__.createElement(metabase_components_Tooltip__WEBPACK_IMPORTED_MODULE_5__.default, { + tooltip: tooltip + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2__.createElement(StyledIcon, props)) : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2__.createElement(StyledIcon, _extends({ + ref: ref + }, props)); +}); +/* harmony default export */ __webpack_exports__["default"] = (Icon); + +/***/ }), + +/***/ "./components/IconBorder.jsx": +/*!***********************************!*\ + !*** ./components/IconBorder.jsx ***! + \***********************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* binding */ IconBorder; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prop-types */ "../../../node_modules/prop-types/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! classnames */ "../../../node_modules/classnames/index.js"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_2__); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/* eslint-disable react/prop-types */ + + + +/* + Creates a bordered container for an component + based on the component's size. + + usage: + + + + */ + +var IconBorder = /*#__PURE__*/function (_Component) { + _inherits(IconBorder, _Component); + + var _super = _createSuper(IconBorder); + + function IconBorder() { + _classCallCheck(this, IconBorder); + + return _super.apply(this, arguments); + } + + _createClass(IconBorder, [{ + key: "render", + value: function render() { + var _this$props = this.props, + borderWidth = _this$props.borderWidth, + borderStyle = _this$props.borderStyle, + borderColor = _this$props.borderColor, + borderRadius = _this$props.borderRadius, + className = _this$props.className, + style = _this$props.style, + children = _this$props.children; + var size = parseInt(children.props.size || children.props.width, 10) * 2; + + var styles = _objectSpread({ + width: size, + height: size, + borderWidth: borderWidth, + borderStyle: borderStyle, + borderColor: borderColor, + borderRadius: borderRadius + }, style); + + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: classnames__WEBPACK_IMPORTED_MODULE_2___default()("flex layout-centered", className), + style: styles + }, children); + } + }]); + + return IconBorder; +}(react__WEBPACK_IMPORTED_MODULE_0__.Component); + +_defineProperty(IconBorder, "propTypes", { + borderWidth: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string), + borderStyle: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string), + borderColor: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string), + borderRadius: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string), + style: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().object), + children: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().any.isRequired) +}); + +_defineProperty(IconBorder, "defaultProps", { + borderWidth: "1px", + borderStyle: "solid", + borderColor: "currentcolor", + borderRadius: "99px", + style: {} +}); + + + +/***/ }), + +/***/ "./components/IconButtonWrapper.jsx": +/*!******************************************!*\ + !*** ./components/IconButtonWrapper.jsx ***! + \******************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var styled_components__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! styled-components */ "../../../node_modules/styled-components/dist/styled-components.browser.es.js"); + +var IconButtonWrapper = styled_components__WEBPACK_IMPORTED_MODULE_0__.default.button.attrs({ + type: "button" +}).withConfig({ + displayName: "IconButtonWrapper", + componentId: "hw7s7a-0" +})(["display:flex;align-items:center;justify-content:center;border-radius:", ";cursor:pointer;"], function (props) { + return props.circle ? "50%" : "6px"; +}); +/* harmony default export */ __webpack_exports__["default"] = (IconButtonWrapper); + +/***/ }), + +/***/ "./components/IconWrapper.jsx": +/*!************************************!*\ + !*** ./components/IconWrapper.jsx ***! + \************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var styled_components__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! styled-components */ "../../../node_modules/styled-components/dist/styled-components.browser.es.js"); +/* harmony import */ var grid_styled__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! grid-styled */ "../../../node_modules/grid-styled/dist/index.js"); +/* harmony import */ var styled_system__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! styled-system */ "../../../node_modules/styled-system/dist/index.js"); +/* harmony import */ var metabase_lib_colors__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/lib/colors */ "./lib/colors.ts"); + + + + +var IconWrapper = (0,styled_components__WEBPACK_IMPORTED_MODULE_0__.default)(grid_styled__WEBPACK_IMPORTED_MODULE_1__.Flex).withConfig({ + displayName: "IconWrapper", + componentId: "sc-1oaa8i6-0" +})(["", ";border-radius:", ";"], styled_system__WEBPACK_IMPORTED_MODULE_2__.color, function (props) { + return props.borderRadius; +}); +IconWrapper.defaultProps = { + borderRadius: 6, + bg: (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_3__.color)("bg-medium"), + align: "center", + justify: "center" +}; +/* harmony default export */ __webpack_exports__["default"] = (IconWrapper); + +/***/ }), + +/***/ "./components/Input/Input.styled.tsx": +/*!*******************************************!*\ + !*** ./components/Input/Input.styled.tsx ***! + \*******************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "InputRoot": function() { return /* binding */ InputRoot; }, +/* harmony export */ "InputField": function() { return /* binding */ InputField; }, +/* harmony export */ "InputIconContainer": function() { return /* binding */ InputIconContainer; } +/* harmony export */ }); +/* harmony import */ var styled_components__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! styled-components */ "../../../node_modules/styled-components/dist/styled-components.browser.es.js"); +/* harmony import */ var metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/lib/colors */ "./lib/colors.ts"); + + +var InputRoot = styled_components__WEBPACK_IMPORTED_MODULE_0__.default.div.withConfig({ + displayName: "Inputstyled__InputRoot", + componentId: "sc-1mopkn9-0" +})(["display:inline-flex;align-items:center;position:relative;width:", ";"], function (props) { + return props.fullWidth ? "100%" : ""; +}); +var InputField = styled_components__WEBPACK_IMPORTED_MODULE_0__.default.input.withConfig({ + displayName: "Inputstyled__InputField", + componentId: "sc-1mopkn9-1" +})(["font-family:inherit;font-weight:700;font-size:1rem;color:", ";background-color:", ";padding:0.75rem;border:1px solid ", ";border-radius:4px;outline:none;&:focus{border-color:", ";transition:border 300ms ease-in-out;}", ";", ";", ""], (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.color)("text-dark"), (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.color)("bg-white"), (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.darken)("border", 0.1), (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.color)("brand"), function (props) { + return props.hasError && (0,styled_components__WEBPACK_IMPORTED_MODULE_0__.css)(["border-color:", ";"], (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.color)("error")); +}, function (props) { + return props.hasTooltip && (0,styled_components__WEBPACK_IMPORTED_MODULE_0__.css)(["padding-right:2.25rem;"]); +}, function (props) { + return props.fullWidth && (0,styled_components__WEBPACK_IMPORTED_MODULE_0__.css)(["width:100%;"]); +}); +var InputIconContainer = styled_components__WEBPACK_IMPORTED_MODULE_0__.default.div.withConfig({ + displayName: "Inputstyled__InputIconContainer", + componentId: "sc-1mopkn9-2" +})(["display:flex;align-items:center;justify-content:center;position:absolute;right:0.75rem;color:", ";cursor:pointer;border-radius:50%;"], (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.color)("text-light")); + +/***/ }), + +/***/ "./components/Input/Input.tsx": +/*!************************************!*\ + !*** ./components/Input/Input.tsx ***! + \************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var metabase_components_Icon__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/components/Icon */ "./components/Icon.tsx"); +/* harmony import */ var metabase_components_Tooltip__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/components/Tooltip */ "./components/Tooltip/index.ts"); +/* harmony import */ var _Input_styled__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Input.styled */ "./components/Input/Input.styled.tsx"); +var _excluded = ["className", "error", "fullWidth", "helperText"]; + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } + +function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } + + + + + + +var Input = function Input(_ref) { + var className = _ref.className, + error = _ref.error, + fullWidth = _ref.fullWidth, + helperText = _ref.helperText, + rest = _objectWithoutProperties(_ref, _excluded); + + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_Input_styled__WEBPACK_IMPORTED_MODULE_3__.InputRoot, { + className: className, + fullWidth: fullWidth + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_Input_styled__WEBPACK_IMPORTED_MODULE_3__.InputField, _extends({}, rest, { + hasError: error, + hasTooltip: Boolean(helperText), + fullWidth: fullWidth + })), helperText && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Tooltip__WEBPACK_IMPORTED_MODULE_2__.default, { + tooltip: helperText, + placement: "right", + offset: [0, 24] + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(InputHelpContent, null))); +}; + +var InputHelpContent = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(function InputHelpContent(props, ref) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_Input_styled__WEBPACK_IMPORTED_MODULE_3__.InputIconContainer, { + innerRef: ref + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Icon__WEBPACK_IMPORTED_MODULE_1__.default, { + name: "info" + })); +}); +/* harmony default export */ __webpack_exports__["default"] = (Input); + +/***/ }), + +/***/ "./components/InputBlurChange.jsx": +/*!****************************************!*\ + !*** ./components/InputBlurChange.jsx ***! + \****************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* binding */ InputBlurChange; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prop-types */ "../../../node_modules/prop-types/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! underscore */ "../../../node_modules/underscore/modules/index-all.js"); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + + + + +/** + * A small wrapper around , primarily should be used for the + * `onBlurChange` feature, otherwise you should use directly + */ + +var InputBlurChange = /*#__PURE__*/function (_Component) { + _inherits(InputBlurChange, _Component); + + var _super = _createSuper(InputBlurChange); + + function InputBlurChange(props, context) { + var _this; + + _classCallCheck(this, InputBlurChange); + + _this = _super.call(this, props, context); + _this.onBlur = _this.onBlur.bind(_assertThisInitialized(_this)); + _this.onChange = _this.onChange.bind(_assertThisInitialized(_this)); + _this.state = { + value: props.value + }; + return _this; + } + + _createClass(InputBlurChange, [{ + key: "UNSAFE_componentWillReceiveProps", + value: function UNSAFE_componentWillReceiveProps(newProps) { + this.setState({ + value: newProps.value + }); + } + }, { + key: "onChange", + value: function onChange(event) { + this.setState({ + value: event.target.value + }); + + if (this.props.onChange) { + this.props.onChange(event); + } + } + }, { + key: "onBlur", + value: function onBlur(event) { + if (this.props.onBlurChange && (this.props.value || "") !== event.target.value) { + this.props.onBlurChange(event); + } + } + }, { + key: "render", + value: function render() { + var props = underscore__WEBPACK_IMPORTED_MODULE_2__.default.omit(this.props, "onBlurChange", "value", "onBlur", "onChange"); + + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("input", _extends({}, props, { + value: this.state.value, + onBlur: this.onBlur, + onChange: this.onChange + })); + } + }]); + + return InputBlurChange; +}(react__WEBPACK_IMPORTED_MODULE_0__.Component); + +_defineProperty(InputBlurChange, "propTypes", { + type: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string), + value: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string), + placeholder: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string), + onChange: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func), + onBlurChange: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func) +}); + +_defineProperty(InputBlurChange, "defaultProps", { + type: "text" +}); + + + +/***/ }), + +/***/ "./components/Link.tsx": +/*!*****************************!*\ + !*** ./components/Link.tsx ***! + \*****************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! classnames */ "../../../node_modules/classnames/index.js"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var react_router__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react-router */ "../../../node_modules/react-router/es/index.js"); +/* harmony import */ var styled_components__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! styled-components */ "../../../node_modules/styled-components/dist/styled-components.browser.es.js"); +/* harmony import */ var styled_system__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! styled-system */ "../../../node_modules/styled-system/dist/index.js"); +/* harmony import */ var metabase_components_Tooltip__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! metabase/components/Tooltip */ "./components/Tooltip/index.ts"); +/* harmony import */ var metabase_lib_utils__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! metabase/lib/utils */ "./lib/utils.js"); +var _excluded = ["to", "className", "children", "disabled", "tooltip"]; + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } + +function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } + + + + + + + + + +function BaseLink(_ref) { + var to = _ref.to, + className = _ref.className, + children = _ref.children, + disabled = _ref.disabled, + tooltip = _ref.tooltip, + props = _objectWithoutProperties(_ref, _excluded); + + var link = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1__.createElement(react_router__WEBPACK_IMPORTED_MODULE_2__.Link, _extends({ + to: to, + className: classnames__WEBPACK_IMPORTED_MODULE_0___default()(className || "link", { + disabled: disabled, + "text-light": disabled + }) + }, (0,metabase_lib_utils__WEBPACK_IMPORTED_MODULE_6__.stripLayoutProps)(props)), children); + return tooltip ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1__.createElement(metabase_components_Tooltip__WEBPACK_IMPORTED_MODULE_5__.default, { + tooltip: tooltip + }, link) : link; +} + +var Link = (0,styled_components__WEBPACK_IMPORTED_MODULE_3__.default)(BaseLink).withConfig({ + displayName: "Link", + componentId: "sc-120rwae-0" +})(["", " ", " ", " ", " transition:color 0.3s linear;transition:opacity 0.3s linear;"], styled_system__WEBPACK_IMPORTED_MODULE_4__.display, styled_system__WEBPACK_IMPORTED_MODULE_4__.space, styled_system__WEBPACK_IMPORTED_MODULE_4__.hover, styled_system__WEBPACK_IMPORTED_MODULE_4__.color); +/* harmony default export */ __webpack_exports__["default"] = (Link); + +/***/ }), + +/***/ "./components/ListField/ListField.styled.tsx": +/*!***************************************************!*\ + !*** ./components/ListField/ListField.styled.tsx ***! + \***************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "EmptyStateContainer": function() { return /* binding */ EmptyStateContainer; }, +/* harmony export */ "FilterInput": function() { return /* binding */ FilterInput; }, +/* harmony export */ "OptionsList": function() { return /* binding */ OptionsList; }, +/* harmony export */ "OptionContainer": function() { return /* binding */ OptionContainer; }, +/* harmony export */ "LabelWrapper": function() { return /* binding */ LabelWrapper; } +/* harmony export */ }); +/* harmony import */ var styled_components__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! styled-components */ "../../../node_modules/styled-components/dist/styled-components.browser.es.js"); +/* harmony import */ var metabase_components_TextInput__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/components/TextInput */ "./components/TextInput/index.js"); +/* harmony import */ var metabase_lib_colors__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/lib/colors */ "./lib/colors.ts"); + + + +var EmptyStateContainer = styled_components__WEBPACK_IMPORTED_MODULE_0__.default.div.withConfig({ + displayName: "ListFieldstyled__EmptyStateContainer", + componentId: "sc-1t0fpwz-0" +})(["padding:2rem 2rem 0 2rem;"]); +var FilterInput = (0,styled_components__WEBPACK_IMPORTED_MODULE_0__.default)(metabase_components_TextInput__WEBPACK_IMPORTED_MODULE_1__.default).withConfig({ + displayName: "ListFieldstyled__FilterInput", + componentId: "sc-1t0fpwz-1" +})(["margin-bottom:", ";border:", ";"], function (props) { + return props.isDashboardFilter ? "0" : "0.5rem"; +}, function (props) { + return props.isDashboardFilter ? "1px solid ".concat((0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_2__.color)("border")) : "none"; +}); +var OptionsList = styled_components__WEBPACK_IMPORTED_MODULE_0__.default.ul.withConfig({ + displayName: "ListFieldstyled__OptionsList", + componentId: "sc-1t0fpwz-2" +})(["overflow:auto;list-style:none;max-height:", ";padding:", ";"], function (props) { + return props.isDashboardFilter ? "300px" : "none"; +}, function (props) { + return props.isDashboardFilter ? "0.5rem" : "0"; +}); +var OptionContainer = styled_components__WEBPACK_IMPORTED_MODULE_0__.default.li.withConfig({ + displayName: "ListFieldstyled__OptionContainer", + componentId: "sc-1t0fpwz-3" +})(["padding:0.5rem 0.125rem;"]); +var LabelWrapper = styled_components__WEBPACK_IMPORTED_MODULE_0__.default.div.withConfig({ + displayName: "ListFieldstyled__LabelWrapper", + componentId: "sc-1t0fpwz-4" +})(["padding-left:0.5rem;"]); + +/***/ }), + +/***/ "./components/ListField/ListField.tsx": +/*!********************************************!*\ + !*** ./components/ListField/ListField.tsx ***! + \********************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "ListField": function() { return /* binding */ ListField; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! underscore */ "../../../node_modules/underscore/modules/index-all.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_2__); +/* harmony import */ var metabase_hooks_use_debounced_value__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/hooks/use-debounced-value */ "./hooks/use-debounced-value.ts"); +/* harmony import */ var metabase_lib_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! metabase/lib/constants */ "./lib/constants.js"); +/* harmony import */ var metabase_components_EmptyState__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! metabase/components/EmptyState */ "./components/EmptyState.jsx"); +/* harmony import */ var _CheckBox__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../CheckBox */ "./components/CheckBox.jsx"); +/* harmony import */ var _ListField_styled__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ListField.styled */ "./components/ListField/ListField.styled.tsx"); +var _templateObject; + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } + +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } + +function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } + +function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } + + + + + + + + + +var SEARCH_THRESHOLD = 10; +var Checkbox = _CheckBox__WEBPACK_IMPORTED_MODULE_6__.default; +var EmptyState = metabase_components_EmptyState__WEBPACK_IMPORTED_MODULE_5__.default; +var ListField = function ListField(_ref) { + var onChange = _ref.onChange, + value = _ref.value, + options = _ref.options, + optionRenderer = _ref.optionRenderer, + placeholder = _ref.placeholder, + isDashboardFilter = _ref.isDashboardFilter; + + var _useState = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(new Set(value)), + _useState2 = _slicedToArray(_useState, 2), + selectedValues = _useState2[0], + setSelectedValues = _useState2[1]; + + var sortedOptions = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(function () { + if (selectedValues.size === 0) { + return options; + } + + var _$partition = underscore__WEBPACK_IMPORTED_MODULE_1__.default.partition(options, function (option) { + return selectedValues.has(option[0]); + }), + _$partition2 = _slicedToArray(_$partition, 2), + selected = _$partition2[0], + unselected = _$partition2[1]; + + return [].concat(_toConsumableArray(selected), _toConsumableArray(unselected)); // eslint-disable-next-line react-hooks/exhaustive-deps + }, [options.length]); + + var _useState3 = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(""), + _useState4 = _slicedToArray(_useState3, 2), + filter = _useState4[0], + setFilter = _useState4[1]; + + var debouncedFilter = (0,metabase_hooks_use_debounced_value__WEBPACK_IMPORTED_MODULE_3__.useDebouncedValue)(filter, metabase_lib_constants__WEBPACK_IMPORTED_MODULE_4__.SEARCH_DEBOUNCE_DURATION); + var filteredOptions = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(function () { + var trimmedFilter = debouncedFilter.trim().toLowerCase(); + + if (trimmedFilter.length === 0) { + return sortedOptions; + } + + return options.filter(function (option) { + return option[0].toString().toLowerCase().startsWith(trimmedFilter); + }); + }, [options, debouncedFilter, sortedOptions]); + + var handleToggleOption = function handleToggleOption(option) { + var newSelectedValues = selectedValues.has(option) ? Array.from(selectedValues).filter(function (value) { + return value !== option; + }) : [].concat(_toConsumableArray(selectedValues), [option]); + setSelectedValues(new Set(newSelectedValues)); + onChange === null || onChange === void 0 ? void 0 : onChange(newSelectedValues); + }; + + var shouldShowFilter = options.length > SEARCH_THRESHOLD; + var shouldShowEmptyState = options.length > 0 && filteredOptions.length === 0; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, shouldShowFilter && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_ListField_styled__WEBPACK_IMPORTED_MODULE_7__.FilterInput, { + isDashboardFilter: isDashboardFilter, + padding: isDashboardFilter ? "md" : "sm", + borderRadius: isDashboardFilter ? "md" : "sm", + colorScheme: isDashboardFilter ? "transparent" : "admin", + placeholder: placeholder, + value: filter, + onChange: setFilter, + hasClearButton: true + }), shouldShowEmptyState && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_ListField_styled__WEBPACK_IMPORTED_MODULE_7__.EmptyStateContainer, null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(EmptyState, { + message: (0,ttag__WEBPACK_IMPORTED_MODULE_2__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["Didn't find anything"]))), + icon: "search" + })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_ListField_styled__WEBPACK_IMPORTED_MODULE_7__.OptionsList, { + isDashboardFilter: isDashboardFilter + }, filteredOptions.map(function (option) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_ListField_styled__WEBPACK_IMPORTED_MODULE_7__.OptionContainer, { + key: option[0] + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(Checkbox, { + "data-testid": "".concat(option[0], "-filter-value"), + checkedColor: isDashboardFilter ? "brand" : "accent7", + checked: selectedValues.has(option[0]), + label: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_ListField_styled__WEBPACK_IMPORTED_MODULE_7__.LabelWrapper, null, optionRenderer(option)), + onChange: function onChange() { + return handleToggleOption(option[0]); + } + })); + }))); +}; + +/***/ }), + +/***/ "./components/ListField/index.ts": +/*!***************************************!*\ + !*** ./components/ListField/index.ts ***! + \***************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "ListField": function() { return /* reexport safe */ _ListField__WEBPACK_IMPORTED_MODULE_0__.ListField; } +/* harmony export */ }); +/* harmony import */ var _ListField__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ListField */ "./components/ListField/ListField.tsx"); + + +/***/ }), + +/***/ "./components/ListSearchField.jsx": +/*!****************************************!*\ + !*** ./components/ListSearchField.jsx ***! + \****************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* binding */ ListSearchField; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var metabase_components_Icon__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/components/Icon */ "./components/Icon.tsx"); +/* harmony import */ var metabase_components_TextInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/components/TextInput */ "./components/TextInput/index.js"); +var _excluded = ["autoFocus"]; + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } + +function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } + + + + +function ListSearchField(_ref) { + var autoFocus = _ref.autoFocus, + props = _objectWithoutProperties(_ref, _excluded); + + var inputRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(); + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () { + // this component is used within virtualized lists + // rerendering an input with autoFocus causes the list to be scrolled to the top + // so we override an autoFocus prop here to prevent any scrolling + if (inputRef.current && autoFocus) { + inputRef.current.focus({ + preventScroll: true + }); + } // eslint-disable-next-line react-hooks/exhaustive-deps + + }, []); + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_TextInput__WEBPACK_IMPORTED_MODULE_2__.default, _extends({ + ref: inputRef + }, props, { + padding: "sm", + borderRadius: "md", + icon: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Icon__WEBPACK_IMPORTED_MODULE_1__.default, { + name: "search", + size: 16 + }) + })); +} +ListSearchField.propTypes = metabase_components_TextInput__WEBPACK_IMPORTED_MODULE_2__.default.propTypes; + +/***/ }), + +/***/ "./components/LoadingAndErrorWrapper.jsx": +/*!***********************************************!*\ + !*** ./components/LoadingAndErrorWrapper.jsx ***! + \***********************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* binding */ LoadingAndErrorWrapper; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prop-types */ "../../../node_modules/prop-types/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var metabase_components_LoadingSpinner__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/components/LoadingSpinner */ "./components/LoadingSpinner/index.ts"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_3__); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! classnames */ "../../../node_modules/classnames/index.js"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_4__); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +var _templateObject, _templateObject2; + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/* eslint "react/prop-types": "warn" */ + + + + + + +var LoadingAndErrorWrapper = /*#__PURE__*/function (_Component) { + _inherits(LoadingAndErrorWrapper, _Component); + + var _super = _createSuper(LoadingAndErrorWrapper); + + function LoadingAndErrorWrapper() { + var _this; + + _classCallCheck(this, LoadingAndErrorWrapper); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _super.call.apply(_super, [this].concat(args)); + + _defineProperty(_assertThisInitialized(_this), "state", { + messageIndex: 0, + sceneIndex: 0 + }); + + _defineProperty(_assertThisInitialized(_this), "loadingInterval", function () { + if (_this.props.loading) { + _this.cycleLoadingMessage(); + } + }); + + _defineProperty(_assertThisInitialized(_this), "cycleLoadingMessage", function () { + _this.setState({ + messageIndex: _this.state.messageIndex + 1 < _this.props.loadingMessages.length ? _this.state.messageIndex + 1 : 0 + }); + }); + + return _this; + } + + _createClass(LoadingAndErrorWrapper, [{ + key: "getErrorMessage", + value: function getErrorMessage() { + var error = this.props.error; + var errorMessage = // NOTE Atte Keinänen 5/10/17 Dashboard API endpoint returns the error as JSON with `message` field + error.data && (error.data.message ? error.data.message : error.data) || error.statusText || error.message || error; + + if (!errorMessage || typeof errorMessage !== "string") { + errorMessage = (0,ttag__WEBPACK_IMPORTED_MODULE_3__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["An error occurred"]))); + } + + return errorMessage; + } + }, { + key: "componentDidMount", + value: function componentDidMount() { + var _this$props = this.props, + loadingMessages = _this$props.loadingMessages, + messageInterval = _this$props.messageInterval; // only start cycling if multiple messages are provided + + if (loadingMessages.length > 1) { + this.cycle = setInterval(this.loadingInterval, messageInterval); + } + } + }, { + key: "componentWillUnmount", + value: function componentWillUnmount() { + clearInterval(this.cycle); + } + }, { + key: "getChildren", + value: function getChildren() { + var child = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.props.children; + + if (Array.isArray(child)) { + return child.map(this.getChildren); + } else if (typeof child === "function") { + return child(); + } else { + return child; + } + } + }, { + key: "render", + value: function render() { + var _this$props2 = this.props, + loading = _this$props2.loading, + error = _this$props2.error, + noBackground = _this$props2.noBackground, + noWrapper = _this$props2.noWrapper, + showSpinner = _this$props2.showSpinner, + loadingMessages = _this$props2.loadingMessages, + loadingScenes = _this$props2.loadingScenes; + var _this$state = this.state, + messageIndex = _this$state.messageIndex, + sceneIndex = _this$state.sceneIndex; + var contentClassName = classnames__WEBPACK_IMPORTED_MODULE_4___default()("wrapper py4 text-brand text-centered flex-full flex flex-column layout-centered", { + "bg-white": !noBackground + }); + + if (noWrapper && !error && !loading) { + var children = this.getChildren(); // special case for loading wrapper with null/undefined child + + if (children == null) { + return null; + } + + return react__WEBPACK_IMPORTED_MODULE_0__.Children.only(children); + } + + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: this.props.className, + style: this.props.style + }, error ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: contentClassName + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("h2", { + className: "text-normal text-light ie-wrap-content-fix" + }, this.getErrorMessage())) : loading ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: contentClassName + }, loadingScenes && loadingScenes[sceneIndex], !loadingScenes && showSpinner && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_LoadingSpinner__WEBPACK_IMPORTED_MODULE_2__.default, null), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("h2", { + className: "text-normal text-light mt1" + }, loadingMessages[messageIndex])) : this.getChildren()); + } + }]); + + return LoadingAndErrorWrapper; +}(react__WEBPACK_IMPORTED_MODULE_0__.Component); + +_defineProperty(LoadingAndErrorWrapper, "propTypes", { + className: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string), + error: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().any), + loading: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().any), + noBackground: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), + noWrapper: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), + children: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().any), + style: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().object), + showSpinner: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), + loadingMessages: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().array), + messageInterval: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().number), + loadingScenes: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().array) +}); + +_defineProperty(LoadingAndErrorWrapper, "defaultProps", { + error: false, + loading: false, + noBackground: true, + noWrapper: false, + showSpinner: true, + loadingMessages: [(0,ttag__WEBPACK_IMPORTED_MODULE_3__.t)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["Loading..."])))], + messageInterval: 6000 +}); + + + +/***/ }), + +/***/ "./components/LoadingSpinner/LoadingSpinner.styled.tsx": +/*!*************************************************************!*\ + !*** ./components/LoadingSpinner/LoadingSpinner.styled.tsx ***! + \*************************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "SpinnerRoot": function() { return /* binding */ SpinnerRoot; }, +/* harmony export */ "SpinnerIcon": function() { return /* binding */ SpinnerIcon; } +/* harmony export */ }); +/* harmony import */ var styled_components__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! styled-components */ "../../../node_modules/styled-components/dist/styled-components.browser.es.js"); + +var spinnerAnimation = (0,styled_components__WEBPACK_IMPORTED_MODULE_0__.keyframes)(["from{transform:rotate(0deg);}to{transform:rotate(360deg);}"]); +var SpinnerRoot = styled_components__WEBPACK_IMPORTED_MODULE_0__.default.div.withConfig({ + displayName: "LoadingSpinnerstyled__SpinnerRoot", + componentId: "yfwy4j-0" +})(["font-size:0;"]); +var SpinnerIcon = styled_components__WEBPACK_IMPORTED_MODULE_0__.default.div.withConfig({ + displayName: "LoadingSpinnerstyled__SpinnerIcon", + componentId: "yfwy4j-1" +})(["display:inline-block;box-sizing:border-box;width:", ";height:", ";border:", " solid transparent;border-top-color:currentColor;border-radius:", ";animation:", " 1.3s infinite cubic-bezier(0.785,0.135,0.15,0.86);&::after{content:\"\";display:inherit;box-sizing:inherit;width:inherit;height:inherit;border:", " solid currentColor;border-radius:", ";opacity:0.25;position:relative;top:", ";left:", ";}"], function (props) { + return "".concat(props.iconSize, "px"); +}, function (props) { + return "".concat(props.iconSize, "px"); +}, function (props) { + return "".concat(props.borderWidth, "px"); +}, function (props) { + return "".concat(props.iconSize / 2, "px"); +}, spinnerAnimation, function (props) { + return "".concat(props.borderWidth, "px"); +}, function (props) { + return "".concat(props.iconSize / 2, "px"); +}, function (props) { + return "-".concat(props.borderWidth, "px"); +}, function (props) { + return "-".concat(props.borderWidth, "px"); +}); + +/***/ }), + +/***/ "./components/LoadingSpinner/LoadingSpinner.tsx": +/*!******************************************************!*\ + !*** ./components/LoadingSpinner/LoadingSpinner.tsx ***! + \******************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var metabase_lib_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/lib/dom */ "./lib/dom.js"); +/* harmony import */ var metabase_components_Icon__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/components/Icon */ "./components/Icon.tsx"); +/* harmony import */ var _LoadingSpinner_styled__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./LoadingSpinner.styled */ "./components/LoadingSpinner/LoadingSpinner.styled.tsx"); + + + + + +var LoadingSpinner = function LoadingSpinner(_ref) { + var className = _ref.className, + _ref$size = _ref.size, + size = _ref$size === void 0 ? 32 : _ref$size, + _ref$borderWidth = _ref.borderWidth, + borderWidth = _ref$borderWidth === void 0 ? 4 : _ref$borderWidth; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_LoadingSpinner_styled__WEBPACK_IMPORTED_MODULE_3__.SpinnerRoot, { + className: className, + "data-testid": "loading-spinner" + }, (0,metabase_lib_dom__WEBPACK_IMPORTED_MODULE_1__.isReducedMotionPreferred)() ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Icon__WEBPACK_IMPORTED_MODULE_2__.default, { + name: "hourglass", + size: "24" + }) : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_LoadingSpinner_styled__WEBPACK_IMPORTED_MODULE_3__.SpinnerIcon, { + iconSize: size, + borderWidth: borderWidth + })); +}; + +/* harmony default export */ __webpack_exports__["default"] = (LoadingSpinner); + +/***/ }), + +/***/ "./components/LoadingSpinner/index.ts": +/*!********************************************!*\ + !*** ./components/LoadingSpinner/index.ts ***! + \********************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* reexport safe */ _LoadingSpinner__WEBPACK_IMPORTED_MODULE_0__.default; } +/* harmony export */ }); +/* harmony import */ var _LoadingSpinner__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./LoadingSpinner */ "./components/LoadingSpinner/LoadingSpinner.tsx"); + + +/***/ }), + +/***/ "./components/LogoIcon.jsx": +/*!*********************************!*\ + !*** ./components/LogoIcon.jsx ***! + \*********************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* binding */ LogoIcon; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prop-types */ "../../../node_modules/prop-types/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! classnames */ "../../../node_modules/classnames/index.js"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_2__); +/* harmony import */ var metabase_plugins__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/plugins */ "./plugins/index.js"); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } + +function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } + +function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + + + + + + +var DefaultLogoIcon = /*#__PURE__*/function (_Component) { + _inherits(DefaultLogoIcon, _Component); + + var _super = _createSuper(DefaultLogoIcon); + + function DefaultLogoIcon() { + _classCallCheck(this, DefaultLogoIcon); + + return _super.apply(this, arguments); + } + + _createClass(DefaultLogoIcon, [{ + key: "render", + value: function render() { + var _this$props = this.props, + dark = _this$props.dark, + height = _this$props.height, + width = _this$props.width; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("svg", { + xmlns: "http://www.w3.org/2000/svg", + clipRule: "evenodd", + className: classnames__WEBPACK_IMPORTED_MODULE_2___default()("Icon", { + "text-brand": !dark + }, { + "text-white": dark + }), + fillRule: "evenodd", + strokeLinejoin: "round", + width: width, + height: height, + strokeMiterlimit: "2", + viewBox: "0 0 560 400" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("linearGradient", { + id: "a" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("stop", { + offset: "0", + stopColor: "#00ffa3" + }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("stop", { + offset: "1", + stopColor: "#dc1fff" + })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("linearGradient", { + id: "b", + gradientTransform: "matrix(-219.666 420.749 -420.749 -219.666 360.879 -37.4553)", + gradientUnits: "userSpaceOnUse", + x1: "0", + x2: "1", + xlinkHref: "#a", + y1: "0", + y2: "0" + }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("linearGradient", { + id: "c", + gradientTransform: "matrix(-219.666 420.749 -420.749 -219.666 264.829 -87.6014)", + gradientUnits: "userSpaceOnUse", + x1: "0", + x2: "1", + xlinkHref: "#a", + y1: "0", + y2: "0" + }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("linearGradient", { + id: "d", + gradientTransform: "matrix(-219.666 420.749 -420.749 -219.666 312.548 -62.688)", + gradientUnits: "userSpaceOnUse", + x1: "0", + x2: "1", + xlinkHref: "#a", + y1: "0", + y2: "0" + }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("g", { + fillRule: "nonzero", + transform: "matrix(.641643 0 0 .641643 152.409 100)" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", { + d: "m64.6 237.9c2.4-2.4 5.7-3.8 9.2-3.8h317.4c5.8 0 8.7 7 4.6 11.1l-62.7 62.7c-2.4 2.4-5.7 3.8-9.2 3.8h-317.4c-5.8 0-8.7-7-4.6-11.1z", + fill: "url(#b)" + }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", { + d: "m64.6 3.8c2.5-2.4 5.8-3.8 9.2-3.8h317.4c5.8 0 8.7 7 4.6 11.1l-62.7 62.7c-2.4 2.4-5.7 3.8-9.2 3.8h-317.4c-5.8 0-8.7-7-4.6-11.1z", + fill: "url(#c)" + }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", { + d: "m333.1 120.1c-2.4-2.4-5.7-3.8-9.2-3.8h-317.4c-5.8 0-8.7 7-4.6 11.1l62.7 62.7c2.4 2.4 5.7 3.8 9.2 3.8h317.4c5.8 0 8.7-7 4.6-11.1z", + fill: "url(#d)" + }))) // + // + // + // + ; + } + }]); + + return DefaultLogoIcon; +}(react__WEBPACK_IMPORTED_MODULE_0__.Component); + +_defineProperty(DefaultLogoIcon, "defaultProps", { + height: 32 +}); + +_defineProperty(DefaultLogoIcon, "propTypes", { + width: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().number), + height: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().number), + dark: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool) +}); + +function LogoIcon(props) { + var _PLUGIN_LOGO_ICON_COM = _slicedToArray(metabase_plugins__WEBPACK_IMPORTED_MODULE_3__.PLUGIN_LOGO_ICON_COMPONENTS, 1), + _PLUGIN_LOGO_ICON_COM2 = _PLUGIN_LOGO_ICON_COM[0], + Component = _PLUGIN_LOGO_ICON_COM2 === void 0 ? DefaultLogoIcon : _PLUGIN_LOGO_ICON_COM2; + + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(Component, props); +} + +/***/ }), + +/***/ "./components/MetadataInfo/DimensionInfo/DimensionInfo.jsx": +/*!*****************************************************************!*\ + !*** ./components/MetadataInfo/DimensionInfo/DimensionInfo.jsx ***! + \*****************************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "DimensionInfo": function() { return /* binding */ DimensionInfo; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prop-types */ "../../../node_modules/prop-types/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_2__); +/* harmony import */ var metabase_lib_lib_Dimension__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase-lib/lib/Dimension */ "../metabase-lib/lib/Dimension.ts"); +/* harmony import */ var _MetadataInfo_styled__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../MetadataInfo.styled */ "./components/MetadataInfo/MetadataInfo.styled.tsx"); +/* harmony import */ var _DimensionInfo_styled__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./DimensionInfo.styled */ "./components/MetadataInfo/DimensionInfo/DimensionInfo.styled.jsx"); +var _templateObject; + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + + + + + + + +DimensionInfo.propTypes = { + className: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string), + dimension: prop_types__WEBPACK_IMPORTED_MODULE_1___default().instanceOf(metabase_lib_lib_Dimension__WEBPACK_IMPORTED_MODULE_3__.default).isRequired +}; +function DimensionInfo(_ref) { + var className = _ref.className, + dimension = _ref.dimension; + var field = dimension.field(); + var description = field === null || field === void 0 ? void 0 : field.description; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_DimensionInfo_styled__WEBPACK_IMPORTED_MODULE_5__.InfoContainer, { + className: className + }, description ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_MetadataInfo_styled__WEBPACK_IMPORTED_MODULE_4__.Description, null, description) : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_MetadataInfo_styled__WEBPACK_IMPORTED_MODULE_4__.EmptyDescription, null, (0,ttag__WEBPACK_IMPORTED_MODULE_2__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["No description"])))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_DimensionInfo_styled__WEBPACK_IMPORTED_MODULE_5__.DimensionLabel, { + dimension: dimension + }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_DimensionInfo_styled__WEBPACK_IMPORTED_MODULE_5__.FieldFingerprintInfo, { + field: field + })); +} +/* harmony default export */ __webpack_exports__["default"] = (DimensionInfo); + +/***/ }), + +/***/ "./components/MetadataInfo/DimensionInfo/DimensionInfo.styled.jsx": +/*!************************************************************************!*\ + !*** ./components/MetadataInfo/DimensionInfo/DimensionInfo.styled.jsx ***! + \************************************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "DimensionLabel": function() { return /* binding */ DimensionLabel; }, +/* harmony export */ "FieldFingerprintInfo": function() { return /* binding */ FieldFingerprintInfo; }, +/* harmony export */ "InfoContainer": function() { return /* binding */ InfoContainer; } +/* harmony export */ }); +/* harmony import */ var styled_components__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! styled-components */ "../../../node_modules/styled-components/dist/styled-components.browser.es.js"); +/* harmony import */ var metabase_components_MetadataInfo_DimensionLabel__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/components/MetadataInfo/DimensionLabel */ "./components/MetadataInfo/DimensionLabel/index.js"); +/* harmony import */ var metabase_components_MetadataInfo_FieldFingerprintInfo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/components/MetadataInfo/FieldFingerprintInfo */ "./components/MetadataInfo/FieldFingerprintInfo/index.js"); +/* harmony import */ var metabase_components_MetadataInfo_MetadataInfo_styled__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/components/MetadataInfo/MetadataInfo.styled */ "./components/MetadataInfo/MetadataInfo.styled.tsx"); + + + + +var DimensionLabel = (0,styled_components__WEBPACK_IMPORTED_MODULE_0__.default)(metabase_components_MetadataInfo_DimensionLabel__WEBPACK_IMPORTED_MODULE_1__.default).withConfig({ + displayName: "DimensionInfostyled__DimensionLabel", + componentId: "sc-1em57yf-0" +})(["font-size:0.9em;"]); +var FieldFingerprintInfo = (0,styled_components__WEBPACK_IMPORTED_MODULE_0__.default)(metabase_components_MetadataInfo_FieldFingerprintInfo__WEBPACK_IMPORTED_MODULE_2__.default).withConfig({ + displayName: "DimensionInfostyled__FieldFingerprintInfo", + componentId: "sc-1em57yf-1" +})(["font-size:0.9em;"]); +var InfoContainer = (0,styled_components__WEBPACK_IMPORTED_MODULE_0__.default)(metabase_components_MetadataInfo_MetadataInfo_styled__WEBPACK_IMPORTED_MODULE_3__.InfoContainer).withConfig({ + displayName: "DimensionInfostyled__InfoContainer", + componentId: "sc-1em57yf-2" +})(["gap:0.8em;"]); + +/***/ }), + +/***/ "./components/MetadataInfo/DimensionInfo/index.js": +/*!********************************************************!*\ + !*** ./components/MetadataInfo/DimensionInfo/index.js ***! + \********************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* reexport safe */ _DimensionInfo__WEBPACK_IMPORTED_MODULE_0__.default; } +/* harmony export */ }); +/* harmony import */ var _DimensionInfo__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./DimensionInfo */ "./components/MetadataInfo/DimensionInfo/DimensionInfo.jsx"); + + +/***/ }), + +/***/ "./components/MetadataInfo/DimensionInfoPopover/DimensionInfoPopover.styled.tsx": +/*!**************************************************************************************!*\ + !*** ./components/MetadataInfo/DimensionInfoPopover/DimensionInfoPopover.styled.tsx ***! + \**************************************************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "WidthBoundDimensionInfo": function() { return /* binding */ WidthBoundDimensionInfo; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var styled_components__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! styled-components */ "../../../node_modules/styled-components/dist/styled-components.browser.es.js"); +/* harmony import */ var metabase_components_MetadataInfo_DimensionInfo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/components/MetadataInfo/DimensionInfo */ "./components/MetadataInfo/DimensionInfo/index.js"); + + + + +// this makes TypeScript happy until `DimensionInfo` is typed +function _DimensionInfo(props) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_MetadataInfo_DimensionInfo__WEBPACK_IMPORTED_MODULE_2__.default, props); +} + +var WidthBoundDimensionInfo = (0,styled_components__WEBPACK_IMPORTED_MODULE_1__.default)(_DimensionInfo).withConfig({ + displayName: "DimensionInfoPopoverstyled__WidthBoundDimensionInfo", + componentId: "sc-1b3f7c9-0" +})(["width:300px;font-size:14px;"]); + +/***/ }), + +/***/ "./components/MetadataInfo/DimensionInfoPopover/DimensionInfoPopover.tsx": +/*!*******************************************************************************!*\ + !*** ./components/MetadataInfo/DimensionInfoPopover/DimensionInfoPopover.tsx ***! + \*******************************************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "POPOVER_DELAY": function() { return /* binding */ POPOVER_DELAY; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prop-types */ "../../../node_modules/prop-types/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var tippy_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! tippy.js */ "../../../node_modules/tippy.js/dist/tippy.esm.js"); +/* harmony import */ var metabase_lib_lib_Dimension__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase-lib/lib/Dimension */ "../metabase-lib/lib/Dimension.ts"); +/* harmony import */ var metabase_components_Popover_TippyPopover__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/components/Popover/TippyPopover */ "./components/Popover/TippyPopover.tsx"); +/* harmony import */ var _DimensionInfoPopover_styled__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./DimensionInfoPopover.styled */ "./components/MetadataInfo/DimensionInfoPopover/DimensionInfoPopover.styled.tsx"); + + + + + + +var POPOVER_DELAY = [1000, 300]; +var propTypes = { + dimension: prop_types__WEBPACK_IMPORTED_MODULE_1___default().instanceOf(metabase_lib_lib_Dimension__WEBPACK_IMPORTED_MODULE_2__.default), + children: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().node), + placement: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string), + disabled: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool) +}; +var className = "dimension-info-popover"; + +function DimensionInfoPopover(_ref) { + var dimension = _ref.dimension, + children = _ref.children, + placement = _ref.placement, + disabled = _ref.disabled, + _ref$delay = _ref.delay, + delay = _ref$delay === void 0 ? POPOVER_DELAY : _ref$delay; + // avoid a scenario where we may have a Dimension instance but not enough metadata + // to even show a display name (probably indicative of a bug) + var hasMetadata = !!(dimension && dimension.displayName()); + return hasMetadata ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Popover_TippyPopover__WEBPACK_IMPORTED_MODULE_3__.default, { + className: className, + delay: delay, + interactive: true, + placement: placement || "left-start", + disabled: disabled, + content: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_DimensionInfoPopover_styled__WEBPACK_IMPORTED_MODULE_4__.WidthBoundDimensionInfo, { + dimension: dimension + }), + onTrigger: function onTrigger(instance) { + var dimensionInfoPopovers = document.querySelectorAll(".".concat(className, "[data-state~='visible']")); // if a dimension info popovers are already visible, hide them and show this popover immediately + + if (dimensionInfoPopovers.length > 0) { + (0,tippy_js__WEBPACK_IMPORTED_MODULE_5__.hideAll)({ + exclude: instance + }); + instance.show(); + } + } + }, children) : children; +} + +DimensionInfoPopover.propTypes = propTypes; +/* harmony default export */ __webpack_exports__["default"] = (DimensionInfoPopover); + +/***/ }), + +/***/ "./components/MetadataInfo/DimensionInfoPopover/index.js": +/*!***************************************************************!*\ + !*** ./components/MetadataInfo/DimensionInfoPopover/index.js ***! + \***************************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* reexport safe */ _DimensionInfoPopover__WEBPACK_IMPORTED_MODULE_0__.default; } +/* harmony export */ }); +/* harmony import */ var _DimensionInfoPopover__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./DimensionInfoPopover */ "./components/MetadataInfo/DimensionInfoPopover/DimensionInfoPopover.tsx"); + + +/***/ }), + +/***/ "./components/MetadataInfo/DimensionLabel/DimensionLabel.jsx": +/*!*******************************************************************!*\ + !*** ./components/MetadataInfo/DimensionLabel/DimensionLabel.jsx ***! + \*******************************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* binding */ DimensionLabel; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prop-types */ "../../../node_modules/prop-types/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var metabase_lib_lib_Dimension__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase-lib/lib/Dimension */ "../metabase-lib/lib/Dimension.ts"); +/* harmony import */ var _MetadataInfo_styled__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../MetadataInfo.styled */ "./components/MetadataInfo/MetadataInfo.styled.tsx"); + + + + +DimensionLabel.propTypes = { + className: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string), + dimension: prop_types__WEBPACK_IMPORTED_MODULE_1___default().instanceOf(metabase_lib_lib_Dimension__WEBPACK_IMPORTED_MODULE_2__.default).isRequired +}; +function DimensionLabel(_ref) { + var className = _ref.className, + dimension = _ref.dimension; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_MetadataInfo_styled__WEBPACK_IMPORTED_MODULE_3__.LabelContainer, { + className: className + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_MetadataInfo_styled__WEBPACK_IMPORTED_MODULE_3__.InvertedColorRelativeSizeIcon, { + name: dimension.icon() + }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_MetadataInfo_styled__WEBPACK_IMPORTED_MODULE_3__.Label, null, dimension.displayName())); +} + +/***/ }), + +/***/ "./components/MetadataInfo/DimensionLabel/index.js": +/*!*********************************************************!*\ + !*** ./components/MetadataInfo/DimensionLabel/index.js ***! + \*********************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* reexport safe */ _DimensionLabel__WEBPACK_IMPORTED_MODULE_0__.default; } +/* harmony export */ }); +/* harmony import */ var _DimensionLabel__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./DimensionLabel */ "./components/MetadataInfo/DimensionLabel/DimensionLabel.jsx"); + + +/***/ }), + +/***/ "./components/MetadataInfo/FieldFingerprintInfo/CategoryFingerprint.jsx": +/*!******************************************************************************!*\ + !*** ./components/MetadataInfo/FieldFingerprintInfo/CategoryFingerprint.jsx ***! + \******************************************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "CategoryFingerprint": function() { return /* binding */ CategoryFingerprint; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prop-types */ "../../../node_modules/prop-types/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var react_redux__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react-redux */ "../../../node_modules/react-redux/es/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_3__); +/* harmony import */ var metabase_hooks_use_async_function__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! metabase/hooks/use-async-function */ "./hooks/use-async-function.ts"); +/* harmony import */ var metabase_lib_lib_metadata_Field__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! metabase-lib/lib/metadata/Field */ "../metabase-lib/lib/metadata/Field.ts"); +/* harmony import */ var metabase_entities_fields__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! metabase/entities/fields */ "./entities/fields.js"); +/* harmony import */ var metabase_lib_formatting__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! metabase/lib/formatting */ "./lib/formatting.js"); +/* harmony import */ var _CategoryFingerprint_styled__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./CategoryFingerprint.styled */ "./components/MetadataInfo/FieldFingerprintInfo/CategoryFingerprint.styled.jsx"); +var _templateObject, _templateObject2; + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } + +function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } + +function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } + + + + + + + + + + +var propTypes = { + className: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string), + field: prop_types__WEBPACK_IMPORTED_MODULE_1___default().instanceOf(metabase_lib_lib_metadata_Field__WEBPACK_IMPORTED_MODULE_5__.default).isRequired, + fieldValues: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().array.isRequired), + fetchFieldValues: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func.isRequired) +}; +var FIELD_VALUES_SHOW_LIMIT = 35; + +var mapStateToProps = function mapStateToProps(state, props) { + var fieldId = props.field.id; + var fieldValues = fieldId != null ? metabase_entities_fields__WEBPACK_IMPORTED_MODULE_6__.default.selectors.getFieldValues(state, { + entityId: fieldId + }) : []; + return { + fieldValues: fieldValues || [] + }; +}; + +var mapDispatchToProps = { + fetchFieldValues: metabase_entities_fields__WEBPACK_IMPORTED_MODULE_6__.default.actions.fetchFieldValues +}; +function CategoryFingerprint(_ref) { + var _field$fingerprint, _field$fingerprint$gl; + + var className = _ref.className, + field = _ref.field, + _ref$fieldValues = _ref.fieldValues, + fieldValues = _ref$fieldValues === void 0 ? [] : _ref$fieldValues, + fetchFieldValues = _ref.fetchFieldValues; + var fieldId = field.id; + var listsFieldValues = field.has_field_values === "list"; + var isMissingFieldValues = fieldValues.length === 0; + var shouldFetchFieldValues = listsFieldValues && isMissingFieldValues; + var shortenedValuesStr = fieldValues.slice(0, FIELD_VALUES_SHOW_LIMIT).map(function (value) { + return Array.isArray(value) ? value[0] : value; + }).join(", "); + var distinctCount = (_field$fingerprint = field.fingerprint) === null || _field$fingerprint === void 0 ? void 0 : (_field$fingerprint$gl = _field$fingerprint.global) === null || _field$fingerprint$gl === void 0 ? void 0 : _field$fingerprint$gl["distinct-count"]; + var formattedDistinctCount = (0,metabase_lib_formatting__WEBPACK_IMPORTED_MODULE_7__.formatNumber)(distinctCount); + + var _useState = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(shouldFetchFieldValues), + _useState2 = _slicedToArray(_useState, 2), + isLoading = _useState2[0], + setIsLoading = _useState2[1]; + + var safeFetchFieldValues = (0,metabase_hooks_use_async_function__WEBPACK_IMPORTED_MODULE_4__.useAsyncFunction)(fetchFieldValues); + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () { + if (shouldFetchFieldValues) { + setIsLoading(true); + safeFetchFieldValues({ + id: fieldId + }).finally(function () { + setIsLoading(false); + }); + } + }, [fieldId, shouldFetchFieldValues, safeFetchFieldValues]); + var showDistinctCount = isLoading || distinctCount != null; + var showFieldValuesBlock = isLoading || shortenedValuesStr.length > 0; + var showComponent = showDistinctCount || showFieldValuesBlock; + return showComponent ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_CategoryFingerprint_styled__WEBPACK_IMPORTED_MODULE_8__.Container, { + className: className + }, showDistinctCount && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_CategoryFingerprint_styled__WEBPACK_IMPORTED_MODULE_8__.RelativeContainer, null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_CategoryFingerprint_styled__WEBPACK_IMPORTED_MODULE_8__.Fade, { + "aria-hidden": !isLoading, + visible: !isLoading + }, (0,ttag__WEBPACK_IMPORTED_MODULE_3__.ngettext)((0,ttag__WEBPACK_IMPORTED_MODULE_3__.msgid)(_templateObject || (_templateObject = _taggedTemplateLiteral(["", " distinct value"])), formattedDistinctCount), "".concat(formattedDistinctCount, " distinct values"), distinctCount || 0)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_CategoryFingerprint_styled__WEBPACK_IMPORTED_MODULE_8__.Fade, { + "aria-hidden": !isLoading, + visible: isLoading + }, (0,ttag__WEBPACK_IMPORTED_MODULE_3__.t)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["Getting distinct values..."]))))), showFieldValuesBlock && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_CategoryFingerprint_styled__WEBPACK_IMPORTED_MODULE_8__.RelativeContainer, { + height: isLoading && "1.8em" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_CategoryFingerprint_styled__WEBPACK_IMPORTED_MODULE_8__.Fade, { + visible: isLoading + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_CategoryFingerprint_styled__WEBPACK_IMPORTED_MODULE_8__.LoadingSpinner, null)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_CategoryFingerprint_styled__WEBPACK_IMPORTED_MODULE_8__.FadeAndSlide, { + visible: !isLoading + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_CategoryFingerprint_styled__WEBPACK_IMPORTED_MODULE_8__.NoWrap, null, shortenedValuesStr)))) : null; +} +CategoryFingerprint.propTypes = propTypes; +/* harmony default export */ __webpack_exports__["default"] = ((0,react_redux__WEBPACK_IMPORTED_MODULE_2__.connect)(mapStateToProps, mapDispatchToProps)(CategoryFingerprint)); + +/***/ }), + +/***/ "./components/MetadataInfo/FieldFingerprintInfo/CategoryFingerprint.styled.jsx": +/*!*************************************************************************************!*\ + !*** ./components/MetadataInfo/FieldFingerprintInfo/CategoryFingerprint.styled.jsx ***! + \*************************************************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "Container": function() { return /* binding */ Container; }, +/* harmony export */ "NoWrap": function() { return /* binding */ NoWrap; }, +/* harmony export */ "LoadingSpinner": function() { return /* binding */ LoadingSpinner; }, +/* harmony export */ "RelativeContainer": function() { return /* binding */ RelativeContainer; }, +/* harmony export */ "Fade": function() { return /* binding */ Fade; }, +/* harmony export */ "FadeAndSlide": function() { return /* binding */ FadeAndSlide; } +/* harmony export */ }); +/* harmony import */ var styled_components__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! styled-components */ "../../../node_modules/styled-components/dist/styled-components.browser.es.js"); +/* harmony import */ var metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/lib/colors */ "./lib/colors.ts"); +/* harmony import */ var metabase_components_LoadingSpinner__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/components/LoadingSpinner */ "./components/LoadingSpinner/index.ts"); +/* harmony import */ var metabase_lib_dom__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/lib/dom */ "./lib/dom.js"); + + + + + +var TRANSITION_DURATION = function TRANSITION_DURATION() { + return (0,metabase_lib_dom__WEBPACK_IMPORTED_MODULE_3__.isReducedMotionPreferred)() ? "0" : "0.25s"; +}; + +var Container = styled_components__WEBPACK_IMPORTED_MODULE_0__.default.div.withConfig({ + displayName: "CategoryFingerprintstyled__Container", + componentId: "sc-1yqdbeh-0" +})(["font-size:1em;position:relative;display:flex;flex-direction:column;gap:0.6em;height:auto;overflow:hidden;"]); +var NoWrap = styled_components__WEBPACK_IMPORTED_MODULE_0__.default.div.withConfig({ + displayName: "CategoryFingerprintstyled__NoWrap", + componentId: "sc-1yqdbeh-1" +})(["white-space:nowrap;text-overflow:ellipsis;overflow:hidden;font-weight:bold;padding-top:0.3em 0;"]); +var LoadingSpinner = (0,styled_components__WEBPACK_IMPORTED_MODULE_0__.default)(metabase_components_LoadingSpinner__WEBPACK_IMPORTED_MODULE_2__.default).attrs({ + size: 18 +}).withConfig({ + displayName: "CategoryFingerprintstyled__LoadingSpinner", + componentId: "sc-1yqdbeh-2" +})(["display:flex;flex-grow:1;align-self:center;justify-content:center;color:", ";"], (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.color)("brand")); +var RelativeContainer = styled_components__WEBPACK_IMPORTED_MODULE_0__.default.div.withConfig({ + displayName: "CategoryFingerprintstyled__RelativeContainer", + componentId: "sc-1yqdbeh-3" +})(["position:relative;height:", ";line-height:1em;"], function (_ref) { + var height = _ref.height; + return height || "1em"; +}); +var Fade = styled_components__WEBPACK_IMPORTED_MODULE_0__.default.div.withConfig({ + displayName: "CategoryFingerprintstyled__Fade", + componentId: "sc-1yqdbeh-4" +})(["position:absolute;top:0;left:0;width:100%;transition:opacity ", " linear;opacity:", ";"], TRANSITION_DURATION, function (_ref2) { + var visible = _ref2.visible; + return visible ? "1" : "0"; +}); +var FadeAndSlide = styled_components__WEBPACK_IMPORTED_MODULE_0__.default.div.withConfig({ + displayName: "CategoryFingerprintstyled__FadeAndSlide", + componentId: "sc-1yqdbeh-5" +})(["position:absolute;width:100%;transition:opacity ", " linear,transform ", " linear;opacity:", ";transform:", ";"], TRANSITION_DURATION, TRANSITION_DURATION, function (_ref3) { + var visible = _ref3.visible; + return visible ? "1" : "0"; +}, function (_ref4) { + var visible = _ref4.visible; + return visible ? "translateY(0)" : "translateY(100%)"; +}); + +/***/ }), + +/***/ "./components/MetadataInfo/FieldFingerprintInfo/FieldFingerprintInfo.jsx": +/*!*******************************************************************************!*\ + !*** ./components/MetadataInfo/FieldFingerprintInfo/FieldFingerprintInfo.jsx ***! + \*******************************************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prop-types */ "../../../node_modules/prop-types/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_2__); +/* harmony import */ var metabase_lib_formatting__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/lib/formatting */ "./lib/formatting.js"); +/* harmony import */ var metabase_lib_lib_metadata_Field__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! metabase-lib/lib/metadata/Field */ "../metabase-lib/lib/metadata/Field.ts"); +/* harmony import */ var _MetadataInfo_styled__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../MetadataInfo.styled */ "./components/MetadataInfo/MetadataInfo.styled.tsx"); +/* harmony import */ var _CategoryFingerprint__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./CategoryFingerprint */ "./components/MetadataInfo/FieldFingerprintInfo/CategoryFingerprint.jsx"); +var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6; + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + + + + + + + + +var propTypes = { + className: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string), + field: prop_types__WEBPACK_IMPORTED_MODULE_1___default().instanceOf(metabase_lib_lib_metadata_Field__WEBPACK_IMPORTED_MODULE_4__.default) +}; + +function FieldFingerprintInfo(_ref) { + var className = _ref.className, + field = _ref.field; + + if (!(field !== null && field !== void 0 && field.fingerprint)) { + return null; + } + + if (field.isDate()) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(DateTimeFingerprint, { + className: className, + field: field + }); + } else if (field.isNumber() && !field.isID()) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(NumberFingerprint, { + className: className, + field: field + }); + } else if (field.isCategory()) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_CategoryFingerprint__WEBPACK_IMPORTED_MODULE_6__.default, { + className: className, + field: field + }); + } else { + return null; + } +} + +function getTimezone(field) { + var _field$query, _field$query$database, _field$query$database2, _field$table, _field$table$database; + + return ((_field$query = field.query) === null || _field$query === void 0 ? void 0 : (_field$query$database = _field$query.database) === null || _field$query$database === void 0 ? void 0 : (_field$query$database2 = _field$query$database.call(_field$query)) === null || _field$query$database2 === void 0 ? void 0 : _field$query$database2.timezone) || ((_field$table = field.table) === null || _field$table === void 0 ? void 0 : (_field$table$database = _field$table.database) === null || _field$table$database === void 0 ? void 0 : _field$table$database.timezone); +} + +function DateTimeFingerprint(_ref2) { + var _field$fingerprint$ty; + + var className = _ref2.className, + field = _ref2.field; + var dateTimeFingerprint = (_field$fingerprint$ty = field.fingerprint.type) === null || _field$fingerprint$ty === void 0 ? void 0 : _field$fingerprint$ty["type/DateTime"]; + + if (!dateTimeFingerprint) { + return null; + } + + var timezone = getTimezone(field); + var earliest = dateTimeFingerprint.earliest, + latest = dateTimeFingerprint.latest; + var formattedEarliest = (0,metabase_lib_formatting__WEBPACK_IMPORTED_MODULE_3__.formatDateTimeWithUnit)(earliest, "minute"); + var formattedLatest = (0,metabase_lib_formatting__WEBPACK_IMPORTED_MODULE_3__.formatDateTimeWithUnit)(latest, "minute"); + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_MetadataInfo_styled__WEBPACK_IMPORTED_MODULE_5__.Table, { + className: className + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("tbody", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("tr", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("th", null, (0,ttag__WEBPACK_IMPORTED_MODULE_2__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["Timezone"])))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("td", null, timezone)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("tr", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("th", null, (0,ttag__WEBPACK_IMPORTED_MODULE_2__.t)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["Earliest date"])))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("td", null, formattedEarliest)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("tr", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("th", null, (0,ttag__WEBPACK_IMPORTED_MODULE_2__.t)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["Latest date"])))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("td", null, formattedLatest)))); +} + +function NumberFingerprint(_ref3) { + var _field$fingerprint$ty2; + + var className = _ref3.className, + field = _ref3.field; + var numberFingerprint = (_field$fingerprint$ty2 = field.fingerprint.type) === null || _field$fingerprint$ty2 === void 0 ? void 0 : _field$fingerprint$ty2["type/Number"]; + + if (!numberFingerprint) { + return null; + } + + var avg = numberFingerprint.avg, + min = numberFingerprint.min, + max = numberFingerprint.max; + var fixedAvg = (0,metabase_lib_formatting__WEBPACK_IMPORTED_MODULE_3__.formatNumber)(Number.isInteger(avg) ? avg : avg.toFixed(2)); + var fixedMin = (0,metabase_lib_formatting__WEBPACK_IMPORTED_MODULE_3__.formatNumber)(Number.isInteger(min) ? min : min.toFixed(2)); + var fixedMax = (0,metabase_lib_formatting__WEBPACK_IMPORTED_MODULE_3__.formatNumber)(Number.isInteger(max) ? max : max.toFixed(2)); + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_MetadataInfo_styled__WEBPACK_IMPORTED_MODULE_5__.Table, { + className: className + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("thead", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("tr", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("th", null, (0,ttag__WEBPACK_IMPORTED_MODULE_2__.t)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["Average"])))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("th", null, (0,ttag__WEBPACK_IMPORTED_MODULE_2__.t)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["Min"])))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("th", null, (0,ttag__WEBPACK_IMPORTED_MODULE_2__.t)(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["Max"])))))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("tbody", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("tr", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("td", null, fixedAvg), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("td", null, fixedMin), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("td", null, fixedMax)))); +} + +FieldFingerprintInfo.propTypes = propTypes; +DateTimeFingerprint.propTypes = propTypes; +NumberFingerprint.propTypes = propTypes; +/* harmony default export */ __webpack_exports__["default"] = (FieldFingerprintInfo); + +/***/ }), + +/***/ "./components/MetadataInfo/FieldFingerprintInfo/index.js": +/*!***************************************************************!*\ + !*** ./components/MetadataInfo/FieldFingerprintInfo/index.js ***! + \***************************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* reexport safe */ _FieldFingerprintInfo__WEBPACK_IMPORTED_MODULE_0__.default; } +/* harmony export */ }); +/* harmony import */ var _FieldFingerprintInfo__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./FieldFingerprintInfo */ "./components/MetadataInfo/FieldFingerprintInfo/FieldFingerprintInfo.jsx"); + + +/***/ }), + +/***/ "./components/MetadataInfo/MetadataInfo.styled.tsx": +/*!*********************************************************!*\ + !*** ./components/MetadataInfo/MetadataInfo.styled.tsx ***! + \*********************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "Container": function() { return /* binding */ Container; }, +/* harmony export */ "AbsoluteContainer": function() { return /* binding */ AbsoluteContainer; }, +/* harmony export */ "InfoContainer": function() { return /* binding */ InfoContainer; }, +/* harmony export */ "Description": function() { return /* binding */ Description; }, +/* harmony export */ "EmptyDescription": function() { return /* binding */ EmptyDescription; }, +/* harmony export */ "LabelContainer": function() { return /* binding */ LabelContainer; }, +/* harmony export */ "Label": function() { return /* binding */ Label; }, +/* harmony export */ "RelativeSizeIcon": function() { return /* binding */ RelativeSizeIcon; }, +/* harmony export */ "InvertedColorRelativeSizeIcon": function() { return /* binding */ InvertedColorRelativeSizeIcon; }, +/* harmony export */ "Fade": function() { return /* binding */ Fade; }, +/* harmony export */ "LoadingSpinner": function() { return /* binding */ LoadingSpinner; }, +/* harmony export */ "Table": function() { return /* binding */ Table; } +/* harmony export */ }); +/* harmony import */ var styled_components__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! styled-components */ "../../../node_modules/styled-components/dist/styled-components.browser.es.js"); +/* harmony import */ var metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/lib/colors */ "./lib/colors.ts"); +/* harmony import */ var metabase_components_Icon__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/components/Icon */ "./components/Icon.tsx"); +/* harmony import */ var metabase_lib_dom__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/lib/dom */ "./lib/dom.js"); +/* harmony import */ var metabase_components_LoadingSpinner__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! metabase/components/LoadingSpinner */ "./components/LoadingSpinner/index.ts"); + + + + + + +var TRANSITION_DURATION = function TRANSITION_DURATION() { + return (0,metabase_lib_dom__WEBPACK_IMPORTED_MODULE_3__.isReducedMotionPreferred)() ? "0" : "0.25s"; +}; + +var Container = styled_components__WEBPACK_IMPORTED_MODULE_0__.default.div.withConfig({ + displayName: "MetadataInfostyled__Container", + componentId: "sc-17hbmpo-0" +})(["position:relative;display:flex;flex-direction:column;gap:0.8em;overflow:auto;"]); +var AbsoluteContainer = styled_components__WEBPACK_IMPORTED_MODULE_0__.default.div.withConfig({ + displayName: "MetadataInfostyled__AbsoluteContainer", + componentId: "sc-17hbmpo-1" +})(["position:absolute;top:0;left:0;right:0;bottom:0;display:flex;justify-content:center;align-items:center;"]); +var InfoContainer = (0,styled_components__WEBPACK_IMPORTED_MODULE_0__.default)(Container).withConfig({ + displayName: "MetadataInfostyled__InfoContainer", + componentId: "sc-17hbmpo-2" +})(["padding:1.1em;"]); +var Description = styled_components__WEBPACK_IMPORTED_MODULE_0__.default.div.withConfig({ + displayName: "MetadataInfostyled__Description", + componentId: "sc-17hbmpo-3" +})(["white-space:pre-line;max-height:200px;overflow:auto;"]); +var EmptyDescription = (0,styled_components__WEBPACK_IMPORTED_MODULE_0__.default)(Description).withConfig({ + displayName: "MetadataInfostyled__EmptyDescription", + componentId: "sc-17hbmpo-4" +})(["color:", ";font-weight:700;"], (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.color)("text-light")); +var LabelContainer = styled_components__WEBPACK_IMPORTED_MODULE_0__.default.div.withConfig({ + displayName: "MetadataInfostyled__LabelContainer", + componentId: "sc-17hbmpo-5" +})(["display:inline-flex;align-items:center;column-gap:0.3em;font-size:1em;color:", ";"], function (_ref) { + var _ref$color = _ref.color, + _color = _ref$color === void 0 ? "brand" : _ref$color; + + return (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.color)(_color); +}); +var Label = styled_components__WEBPACK_IMPORTED_MODULE_0__.default.span.withConfig({ + displayName: "MetadataInfostyled__Label", + componentId: "sc-17hbmpo-6" +})(["font-weight:bold;font-size:1em;line-height:1em;"]); +var RelativeSizeIcon = (0,styled_components__WEBPACK_IMPORTED_MODULE_0__.default)(metabase_components_Icon__WEBPACK_IMPORTED_MODULE_2__.default).withConfig({ + displayName: "MetadataInfostyled__RelativeSizeIcon", + componentId: "sc-17hbmpo-7" +})(["height:1em;width:1em;"]); +var InvertedColorRelativeSizeIcon = (0,styled_components__WEBPACK_IMPORTED_MODULE_0__.default)(RelativeSizeIcon).withConfig({ + displayName: "MetadataInfostyled__InvertedColorRelativeSizeIcon", + componentId: "sc-17hbmpo-8" +})(["background-color:", ";color:", ";border-radius:0.3em;padding:0.3em;"], (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.color)("brand"), (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.color)("white")); +var Fade = styled_components__WEBPACK_IMPORTED_MODULE_0__.default.div.withConfig({ + displayName: "MetadataInfostyled__Fade", + componentId: "sc-17hbmpo-9" +})(["position:relative;width:100%;transition:opacity ", " linear;opacity:", ";&:empty{display:none;}"], TRANSITION_DURATION, function (_ref2) { + var visible = _ref2.visible; + return visible ? "1" : "0"; +}); +var LoadingSpinner = (0,styled_components__WEBPACK_IMPORTED_MODULE_0__.default)(metabase_components_LoadingSpinner__WEBPACK_IMPORTED_MODULE_4__.default).withConfig({ + displayName: "MetadataInfostyled__LoadingSpinner", + componentId: "sc-17hbmpo-10" +})(["display:flex;flex-grow:1;align-self:center;justify-content:center;color:", ";"], (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.color)("brand")); +var Table = styled_components__WEBPACK_IMPORTED_MODULE_0__.default.table.withConfig({ + displayName: "MetadataInfostyled__Table", + componentId: "sc-17hbmpo-11" +})(["font-size:1em;th{font-weight:normal;}td{font-weight:bold;}"]); + +/***/ }), + +/***/ "./components/Modal.jsx": +/*!******************************!*\ + !*** ./components/Modal.jsx ***! + \******************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "WindowModal": function() { return /* binding */ WindowModal; }, +/* harmony export */ "FullPageModal": function() { return /* binding */ FullPageModal; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prop-types */ "../../../node_modules/prop-types/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! classnames */ "../../../node_modules/classnames/index.js"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_2__); +/* harmony import */ var metabase_lib_dom__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/lib/dom */ "./lib/dom.js"); +/* harmony import */ var react_transition_group__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! react-transition-group */ "../../../node_modules/react-transition-group/index.js"); +/* harmony import */ var react_transition_group__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(react_transition_group__WEBPACK_IMPORTED_MODULE_4__); +/* harmony import */ var react_motion__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! react-motion */ "../../../node_modules/react-motion/lib/react-motion.js"); +/* harmony import */ var metabase_components_SandboxedPortal__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! metabase/components/SandboxedPortal */ "./components/SandboxedPortal.jsx"); +/* harmony import */ var _OnClickOutsideWrapper__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./OnClickOutsideWrapper */ "./components/OnClickOutsideWrapper.jsx"); +/* harmony import */ var _ModalContent__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ModalContent */ "./components/ModalContent.jsx"); +/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! underscore */ "../../../node_modules/underscore/modules/index-all.js"); +/* harmony import */ var metabase_hoc_Routeless__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! metabase/hoc/Routeless */ "./hoc/Routeless.jsx"); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +var _excluded = ["full"]; + +function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } + +function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } + +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/* eslint-disable react/prop-types */ + + + + + + + + + + + +function getModalContent(props) { + if (react__WEBPACK_IMPORTED_MODULE_0__.Children.count(props.children) > 1 || props.title != null || props.footer != null) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_ModalContent__WEBPACK_IMPORTED_MODULE_8__.default, underscore__WEBPACK_IMPORTED_MODULE_9__.default.omit(props, "className", "style")); + } else { + return react__WEBPACK_IMPORTED_MODULE_0__.Children.only(props.children); + } +} + +var WindowModal = /*#__PURE__*/function (_Component) { + _inherits(WindowModal, _Component); + + var _super = _createSuper(WindowModal); + + function WindowModal(props) { + var _this; + + _classCallCheck(this, WindowModal); + + _this = _super.call(this, props); + + _defineProperty(_assertThisInitialized(_this), "handleDismissal", function () { + if (_this.props.onClose) { + _this.props.onClose(); + } + }); + + _this._modalElement = document.createElement("div"); + _this._modalElement.className = "ModalContainer"; + document.body.appendChild(_this._modalElement); + return _this; + } + + _createClass(WindowModal, [{ + key: "componentWillUnmount", + value: function componentWillUnmount() { + this._modalElement.parentNode.removeChild(this._modalElement); + } + }, { + key: "_modalComponent", + value: function _modalComponent() { + var _this2 = this; + + var className = classnames__WEBPACK_IMPORTED_MODULE_2___default().apply(void 0, [this.props.className].concat(_toConsumableArray(["small", "medium", "wide", "tall"].filter(function (type) { + return _this2.props[type]; + }).map(function (type) { + return "Modal--".concat(type); + })))); + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_OnClickOutsideWrapper__WEBPACK_IMPORTED_MODULE_7__.default, { + handleDismissal: this.handleDismissal + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: classnames__WEBPACK_IMPORTED_MODULE_2___default()(className, "relative bg-white rounded") + }, getModalContent(_objectSpread(_objectSpread({}, this.props), {}, { + fullPageModal: false, + // if there is a form then its a form modal, or if there's a form + // modal prop use that + formModal: !!this.props.form || this.props.formModal + })))); + } + }, { + key: "render", + value: function render() { + var _this$props = this.props, + enableMouseEvents = _this$props.enableMouseEvents, + backdropClassName = _this$props.backdropClassName, + isOpen = _this$props.isOpen, + style = _this$props.style; + var backdropClassnames = "flex justify-center align-center fixed top left bottom right"; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_SandboxedPortal__WEBPACK_IMPORTED_MODULE_6__.default, { + container: this._modalElement, + enableMouseEvents: enableMouseEvents + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(react_transition_group__WEBPACK_IMPORTED_MODULE_4__.CSSTransitionGroup, { + transitionName: "Modal", + transitionAppear: true, + transitionAppearTimeout: 250, + transitionEnterTimeout: 250, + transitionLeaveTimeout: 250 + }, isOpen && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + key: "modal", + className: classnames__WEBPACK_IMPORTED_MODULE_2___default()(backdropClassName, backdropClassnames), + style: style + }, this._modalComponent()))); + } + }]); + + return WindowModal; +}(react__WEBPACK_IMPORTED_MODULE_0__.Component); + +_defineProperty(WindowModal, "propTypes", { + isOpen: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), + enableMouseEvents: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool) +}); + +_defineProperty(WindowModal, "defaultProps", { + className: "Modal", + backdropClassName: "Modal-backdrop" +}); + + +var FullPageModal = /*#__PURE__*/function (_Component2) { + _inherits(FullPageModal, _Component2); + + var _super2 = _createSuper(FullPageModal); + + function FullPageModal(props) { + var _this3; + + _classCallCheck(this, FullPageModal); + + _this3 = _super2.call(this, props); + + _defineProperty(_assertThisInitialized(_this3), "handleDismissal", function () { + _this3.setState({ + isOpen: false + }); // wait for animations to complete before unmounting + + + setTimeout(function () { + return _this3.props.onClose && _this3.props.onClose(); + }, 300); + }); + + _this3.state = { + isOpen: true + }; + _this3._modalElement = document.createElement("div"); + _this3._modalElement.className = "ModalContainer"; + document.body.appendChild(_this3._modalElement); // save the scroll position, scroll to the top left, and disable scrolling + + _this3._scrollX = (0,metabase_lib_dom__WEBPACK_IMPORTED_MODULE_3__.getScrollX)(); + _this3._scrollY = (0,metabase_lib_dom__WEBPACK_IMPORTED_MODULE_3__.getScrollY)(); + window.scrollTo(0, 0); + document.body.style.overflow = "hidden"; + return _this3; + } + + _createClass(FullPageModal, [{ + key: "setTopOfModalToBottomOfNav", + value: function setTopOfModalToBottomOfNav() { + var nav = document.body.querySelector(".Nav"); + + if (nav) { + this._modalElement.style.top = nav.getBoundingClientRect().bottom + "px"; + } + } + }, { + key: "componentDidMount", + value: function componentDidMount() { + this.setTopOfModalToBottomOfNav(); + } + }, { + key: "componentDidUpdate", + value: function componentDidUpdate() { + if (!this.state.isOpen) { + document.body.style.overflow = ""; + } + + this.setTopOfModalToBottomOfNav(); + } + }, { + key: "componentWillUnmount", + value: function componentWillUnmount() { + this._modalElement.parentNode.removeChild(this._modalElement); + + document.body.style.overflow = ""; + } + }, { + key: "render", + value: function render() { + var _this4 = this; + + var open = this.state.isOpen; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(react_motion__WEBPACK_IMPORTED_MODULE_5__.Motion, { + defaultStyle: { + opacity: 0, + top: 20 + }, + style: open ? { + opacity: (0,react_motion__WEBPACK_IMPORTED_MODULE_5__.spring)(1), + top: (0,react_motion__WEBPACK_IMPORTED_MODULE_5__.spring)(0) + } : { + opacity: (0,react_motion__WEBPACK_IMPORTED_MODULE_5__.spring)(0), + top: (0,react_motion__WEBPACK_IMPORTED_MODULE_5__.spring)(20) + } + }, function (motionStyle) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_SandboxedPortal__WEBPACK_IMPORTED_MODULE_6__.default, { + container: _this4._modalElement + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "Modal--full" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_OnClickOutsideWrapper__WEBPACK_IMPORTED_MODULE_7__.default, { + handleDismissal: _this4.handleDismissal + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "full-height relative scroll-y", + style: motionStyle + }, getModalContent(_objectSpread(_objectSpread({}, _this4.props), {}, { + fullPageModal: true, + formModal: !!_this4.props.form, + onClose: _this4.handleDismissal + })))))); + }); + } + }]); + + return FullPageModal; +}(react__WEBPACK_IMPORTED_MODULE_0__.Component); // the "routeless" version should only be used for non-inline modals + +var RoutelessFullPageModal = (0,metabase_hoc_Routeless__WEBPACK_IMPORTED_MODULE_10__.default)(FullPageModal); + +var Modal = function Modal(_ref) { + var full = _ref.full, + props = _objectWithoutProperties(_ref, _excluded); + + return full ? props.isOpen ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(RoutelessFullPageModal, props) : null : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(WindowModal, props); +}; + +Modal.defaultProps = { + isOpen: true +}; +/* harmony default export */ __webpack_exports__["default"] = (Modal); + +/***/ }), + +/***/ "./components/ModalContent.jsx": +/*!*************************************!*\ + !*** ./components/ModalContent.jsx ***! + \*************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* binding */ ModalContent; }, +/* harmony export */ "ModalHeader": function() { return /* binding */ ModalHeader; }, +/* harmony export */ "ModalBody": function() { return /* binding */ ModalBody; }, +/* harmony export */ "ModalFooter": function() { return /* binding */ ModalFooter; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prop-types */ "../../../node_modules/prop-types/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! classnames */ "../../../node_modules/classnames/index.js"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_2__); +/* harmony import */ var metabase_components_Icon__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/components/Icon */ "./components/Icon.tsx"); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/* eslint-disable react/prop-types */ + + + + + +var ModalContent = /*#__PURE__*/function (_Component) { + _inherits(ModalContent, _Component); + + var _super = _createSuper(ModalContent); + + function ModalContent() { + _classCallCheck(this, ModalContent); + + return _super.apply(this, arguments); + } + + _createClass(ModalContent, [{ + key: "getChildContext", + value: function getChildContext() { + return { + isModal: true + }; + } + }, { + key: "render", + value: function render() { + var _this$props = this.props, + title = _this$props.title, + footer = _this$props.footer, + onClose = _this$props.onClose, + children = _this$props.children, + className = _this$props.className, + fullPageModal = _this$props.fullPageModal, + formModal = _this$props.formModal; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + id: this.props.id, + className: classnames__WEBPACK_IMPORTED_MODULE_2___default()("ModalContent flex-full flex flex-column relative", className, { + "full-height": fullPageModal && !formModal + }, // add bottom padding if this is a standard "form modal" with no footer + { + pb4: formModal && !footer + }) + }, onClose && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Icon__WEBPACK_IMPORTED_MODULE_3__.default, { + className: "text-light text-medium-hover cursor-pointer absolute z2 m2 p2 top right", + name: "close", + size: fullPageModal ? 24 : 16, + onClick: onClose + }), title && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(ModalHeader, { + fullPageModal: fullPageModal, + formModal: formModal + }, title), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(ModalBody, { + fullPageModal: fullPageModal, + formModal: formModal + }, children), footer && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(ModalFooter, { + fullPageModal: fullPageModal, + formModal: formModal + }, footer)); + } + }]); + + return ModalContent; +}(react__WEBPACK_IMPORTED_MODULE_0__.Component); + +_defineProperty(ModalContent, "propTypes", { + id: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string), + title: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string), + onClose: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func), + // takes over the entire screen + fullPageModal: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), + // standard modal + formModal: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool) +}); + +_defineProperty(ModalContent, "defaultProps", { + formModal: true +}); + +_defineProperty(ModalContent, "childContextTypes", { + isModal: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool) +}); + + +var FORM_WIDTH = 500 + 32 * 2; // includes padding + +var ModalHeader = function ModalHeader(_ref) { + var children = _ref.children, + fullPageModal = _ref.fullPageModal, + formModal = _ref.formModal; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: classnames__WEBPACK_IMPORTED_MODULE_2___default()("ModalHeader flex-no-shrink px4 py4 full") + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("h2", { + className: classnames__WEBPACK_IMPORTED_MODULE_2___default()("text-bold", { + "text-centered": fullPageModal + }, { + mr4: !fullPageModal + }) + }, children)); +}; +var ModalBody = function ModalBody(_ref2) { + var children = _ref2.children, + fullPageModal = _ref2.fullPageModal, + formModal = _ref2.formModal; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: classnames__WEBPACK_IMPORTED_MODULE_2___default()("ModalBody", { + px4: formModal, + "flex flex-full flex-basis-auto": !formModal + }) + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "flex-full ml-auto mr-auto flex flex-column", + style: { + maxWidth: formModal && fullPageModal ? FORM_WIDTH : undefined + } + }, children)); +}; +var ModalFooter = function ModalFooter(_ref3) { + var children = _ref3.children, + fullPageModal = _ref3.fullPageModal, + formModal = _ref3.formModal; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: classnames__WEBPACK_IMPORTED_MODULE_2___default()("ModalFooter flex flex-no-shrink px4", fullPageModal ? "py4" : "py3") + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "ml-auto flex align-center", + style: { + maxWidth: formModal && fullPageModal ? FORM_WIDTH : undefined + } + }, Array.isArray(children) ? children.map(function (child, index) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { + key: index, + className: "ml2" + }, child); + }) : children)); +}; + +/***/ }), + +/***/ "./components/ModalWithTrigger.jsx": +/*!*****************************************!*\ + !*** ./components/ModalWithTrigger.jsx ***! + \*****************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var _Triggerable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Triggerable */ "./components/Triggerable.jsx"); +/* harmony import */ var _Modal__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Modal */ "./components/Modal.jsx"); + + +/* harmony default export */ __webpack_exports__["default"] = ((0,_Triggerable__WEBPACK_IMPORTED_MODULE_0__.default)(_Modal__WEBPACK_IMPORTED_MODULE_1__.default)); + +/***/ }), + +/***/ "./components/NumericInput.jsx": +/*!*************************************!*\ + !*** ./components/NumericInput.jsx ***! + \*************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var metabase_components_InputBlurChange__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/components/InputBlurChange */ "./components/InputBlurChange.jsx"); +var _excluded = ["value", "onChange"]; + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } + +function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } + +/* eslint-disable react/prop-types */ + + + +var NumericInput = function NumericInput(_ref) { + var value = _ref.value, + onChange = _ref.onChange, + props = _objectWithoutProperties(_ref, _excluded); + + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_InputBlurChange__WEBPACK_IMPORTED_MODULE_1__.default, _extends({ + value: value == null ? "" : String(value), + onBlurChange: function onBlurChange(_ref2) { + var value = _ref2.target.value; + value = value ? parseFloat(value) : null; + + if (!isNaN(value)) { + onChange(value); + } + } + }, props)); +}; + +/* harmony default export */ __webpack_exports__["default"] = (NumericInput); + +/***/ }), + +/***/ "./components/OnClickOutsideWrapper.jsx": +/*!**********************************************!*\ + !*** ./components/OnClickOutsideWrapper.jsx ***! + \**********************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* binding */ OnClickOutsideWrapper; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prop-types */ "../../../node_modules/prop-types/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react-dom */ "../../../node_modules/react-dom/index.js"); +/* harmony import */ var metabase_lib_keyboard__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/lib/keyboard */ "./lib/keyboard.js"); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/* eslint-disable react/prop-types */ + + + + // keep track of the order popovers were opened so we only close the last one when clicked outside + +var popoverStack = []; + +var OnClickOutsideWrapper = /*#__PURE__*/function (_Component) { + _inherits(OnClickOutsideWrapper, _Component); + + var _super = _createSuper(OnClickOutsideWrapper); + + function OnClickOutsideWrapper() { + var _this; + + _classCallCheck(this, OnClickOutsideWrapper); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _super.call.apply(_super, [this].concat(args)); + + _defineProperty(_assertThisInitialized(_this), "_handleClick", function (e) { + if (!react_dom__WEBPACK_IMPORTED_MODULE_2__.findDOMNode(_assertThisInitialized(_this)).contains(e.target)) { + setTimeout(_this._handleDismissal, 0); + } + }); + + _defineProperty(_assertThisInitialized(_this), "_handleKeyPress", function (e) { + if (e.keyCode === metabase_lib_keyboard__WEBPACK_IMPORTED_MODULE_3__.KEYCODE_ESCAPE) { + e.preventDefault(); + + _this._handleDismissal(); + } + }); + + _defineProperty(_assertThisInitialized(_this), "_handleDismissal", function (e) { + // only propagate event for the popover on top of the stack + if (_assertThisInitialized(_this) === popoverStack[popoverStack.length - 1]) { + _this.props.handleDismissal(e); + } + }); + + return _this; + } + + _createClass(OnClickOutsideWrapper, [{ + key: "componentDidMount", + value: function componentDidMount() { + var _this2 = this; + + // necessary to ignore click events that fire immediately, causing modals/popovers to close prematurely + this._timeout = setTimeout(function () { + popoverStack.push(_this2); // HACK: set the z-index of the parent element to ensure it"s always on top + // NOTE: this actually doesn"t seem to be working correctly for popovers since PopoverBody creates a stacking context + + react_dom__WEBPACK_IMPORTED_MODULE_2__.findDOMNode(_this2).parentNode.style.zIndex = popoverStack.length + 2; // HACK: add 2 to ensure it"s in front of main and nav elements + + if (_this2.props.dismissOnEscape) { + document.addEventListener("keydown", _this2._handleKeyPress, false); + } + + if (_this2.props.dismissOnClickOutside) { + window.addEventListener("mousedown", _this2._handleClick, true); + } + }, 0); + } + }, { + key: "componentWillUnmount", + value: function componentWillUnmount() { + var _this3 = this; + + document.removeEventListener("keydown", this._handleKeyPress, false); + window.removeEventListener("mousedown", this._handleClick, true); + clearTimeout(this._timeout); // remove from the stack after a delay, if it is removed through some other + // means this will happen too early causing parent modal to close + + setTimeout(function () { + var index = popoverStack.indexOf(_this3); + + if (index >= 0) { + popoverStack.splice(index, 1); + } + }, 0); + } + }, { + key: "render", + value: function render() { + return react__WEBPACK_IMPORTED_MODULE_0__.Children.only(this.props.children); + } + }]); + + return OnClickOutsideWrapper; +}(react__WEBPACK_IMPORTED_MODULE_0__.Component); + +_defineProperty(OnClickOutsideWrapper, "propTypes", { + handleDismissal: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func.isRequired) +}); + +_defineProperty(OnClickOutsideWrapper, "defaultProps", { + dismissOnClickOutside: true, + dismissOnEscape: true +}); + + + +/***/ }), + +/***/ "./components/Popover/Popover.jsx": +/*!****************************************!*\ + !*** ./components/Popover/Popover.jsx ***! + \****************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* binding */ Popover; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prop-types */ "../../../node_modules/prop-types/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react-dom */ "../../../node_modules/react-dom/index.js"); +/* harmony import */ var metabase_components_OnClickOutsideWrapper__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/components/OnClickOutsideWrapper */ "./components/OnClickOutsideWrapper.jsx"); +/* harmony import */ var tether__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! tether */ "../../../node_modules/tether/dist/js/tether.js"); +/* harmony import */ var tether__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(tether__WEBPACK_IMPORTED_MODULE_4__); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! classnames */ "../../../node_modules/classnames/index.js"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_5__); +/* harmony import */ var _Popover_css__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Popover.css */ "./components/Popover/Popover.css"); +/* harmony import */ var _Popover_css__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_Popover_css__WEBPACK_IMPORTED_MODULE_6__); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + + + + + + + + // space we should leave berween page edge and popover edge + +var PAGE_PADDING = 10; // Popover padding and border + +var POPOVER_BODY_PADDING = 2; + +var Popover = /*#__PURE__*/function (_Component) { + _inherits(Popover, _Component); + + var _super = _createSuper(Popover); + + function Popover(props, context) { + var _this; + + _classCallCheck(this, Popover); + + _this = _super.call(this, props, context); + _this.state = { + width: null, + height: null + }; + _this.handleDismissal = _this.handleDismissal.bind(_assertThisInitialized(_this)); + return _this; + } + + _createClass(Popover, [{ + key: "_getPopoverElement", + value: function _getPopoverElement(isOpen) { + var _this2 = this; + + if (!this._popoverElement && isOpen) { + this._popoverElement = document.createElement("span"); + this._popoverElement.className = "PopoverContainer ".concat(this.props.containerClassName); + document.body.appendChild(this._popoverElement); + this._timer = setInterval(function () { + var _this2$_popoverElemen = _this2._popoverElement.getBoundingClientRect(), + width = _this2$_popoverElemen.width, + height = _this2$_popoverElemen.height; + + if (_this2.state.width !== width || _this2.state.height !== height) { + _this2.setState({ + width: width, + height: height + }); + } + }, 100); + } + + return this._popoverElement; + } + }, { + key: "componentDidMount", + value: function componentDidMount() { + this._renderPopover(this.props.isOpen); + } + }, { + key: "componentDidUpdate", + value: function componentDidUpdate() { + this._renderPopover(this.props.isOpen); + } + }, { + key: "componentWillUnmount", + value: function componentWillUnmount() { + if (this._tether) { + this._tether.destroy(); + + delete this._tether; + } + + if (this._popoverElement) { + this._renderPopover(false); + + react_dom__WEBPACK_IMPORTED_MODULE_2__.unmountComponentAtNode(this._popoverElement); + + if (this._popoverElement.parentNode) { + this._popoverElement.parentNode.removeChild(this._popoverElement); + } + + delete this._popoverElement; + clearInterval(this._timer); + delete this._timer; + } + } + }, { + key: "handleDismissal", + value: function handleDismissal() { + if (this.props.onClose) { + var _this$props; + + (_this$props = this.props).onClose.apply(_this$props, arguments); + } + } + }, { + key: "_popoverComponent", + value: function _popoverComponent() { + var childProps = { + maxHeight: this._getMaxHeight() + }; + var content = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + id: this.props.id, + className: classnames__WEBPACK_IMPORTED_MODULE_5___default()("PopoverBody", { + "PopoverBody--withBackground": this.props.hasBackground, + "PopoverBody--withArrow": this.props.hasArrow && this.props.hasBackground, + "PopoverBody--autoWidth": this.props.autoWidth + }, // TODO kdoh 10/16/2017 we should eventually remove this + this.props.className), + role: this.props.role, + style: this.props.style + }, typeof this.props.children === "function" ? this.props.children(childProps) : react__WEBPACK_IMPORTED_MODULE_0__.Children.count(this.props.children) === 1 && // NOTE: workaround for https://github.com/facebook/react/issues/12136 + !Array.isArray(this.props.children) ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.cloneElement(react__WEBPACK_IMPORTED_MODULE_0__.Children.only(this.props.children), childProps) : this.props.children); + + if (this.props.noOnClickOutsideWrapper) { + return content; + } else { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_OnClickOutsideWrapper__WEBPACK_IMPORTED_MODULE_3__.default, { + handleDismissal: this.handleDismissal, + dismissOnEscape: this.props.dismissOnEscape, + dismissOnClickOutside: this.props.dismissOnClickOutside + }, content); + } + } + }, { + key: "_setTetherOptions", + value: function _setTetherOptions(tetherOptions, o) { + if (o) { + tetherOptions = _objectSpread(_objectSpread({}, tetherOptions), {}, { + attachment: "".concat(o.attachmentY, " ").concat(o.attachmentX), + targetAttachment: "".concat(o.targetAttachmentY, " ").concat(o.targetAttachmentX), + targetOffset: "".concat(o.offsetY, "px ").concat(o.offsetX, "px") + }); + } + + if (this._tether) { + this._tether.setOptions(tetherOptions); + } else { + this._tether = new (tether__WEBPACK_IMPORTED_MODULE_4___default())(tetherOptions); + } + } + }, { + key: "_getMaxHeight", + value: function _getMaxHeight() { + var _this3 = this; + + var _this$_getTargetEleme = this._getTargetElement().getBoundingClientRect(), + top = _this$_getTargetEleme.top, + bottom = _this$_getTargetEleme.bottom; + + var attachments; + + if (this.props.pinInitialAttachment && this._best) { + // if we have a pinned attachment only use that + attachments = [this._best.attachmentY]; + } else { + // otherwise use the verticalAttachments prop + attachments = this.props.verticalAttachments; + } + + var availableHeights = attachments.map(function (attachmentY) { + return attachmentY === "top" ? window.innerHeight - bottom - _this3.props.targetOffsetY - PAGE_PADDING : attachmentY === "bottom" ? top - _this3.props.targetOffsetY - PAGE_PADDING : 0; + }); // get the largest available height, then subtract .PopoverBody's border and padding + + return Math.max.apply(Math, _toConsumableArray(availableHeights)) - POPOVER_BODY_PADDING; + } + }, { + key: "_getBestAttachmentOptions", + value: function _getBestAttachmentOptions(tetherOptions, options, attachments, offscreenProps, getAttachmentOptions) { + var _this4 = this; + + var best = _objectSpread({}, options); + + var bestOffScreen = -Infinity; // try each attachment until one is entirely on screen, or pick the least bad one + + var _iterator = _createForOfIteratorHelper(attachments), + _step; + + try { + var _loop = function _loop() { + var attachment = _step.value; + // compute the options for this attachment position then set it + var options = getAttachmentOptions(best, attachment); + + _this4._setTetherOptions(tetherOptions, options); // get bounds within *document* + + + var elementRect = tether__WEBPACK_IMPORTED_MODULE_4___default().Utils.getBounds(tetherOptions.element); // get bounds within *window* + + var doc = document.documentElement; + var left = (window.pageXOffset || doc.scrollLeft) - (doc.clientLeft || 0); + var top = (window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0); + elementRect.top -= top; + elementRect.bottom += top; + elementRect.left -= left; + elementRect.right += left; // test to see how much of the popover is off-screen + + var offScreen = offscreenProps.map(function (prop) { + return Math.min(elementRect[prop], 0); + }).reduce(function (a, b) { + return a + b; + }); // if none then we're done, otherwise check to see if it's the best option so far + + if (offScreen === 0) { + best = options; + return "break"; + } else if (offScreen > bestOffScreen) { + best = options; + bestOffScreen = offScreen; + } + }; + + for (_iterator.s(); !(_step = _iterator.n()).done;) { + var _ret = _loop(); + + if (_ret === "break") break; + } + } catch (err) { + _iterator.e(err); + } finally { + _iterator.f(); + } + + return best; + } + }, { + key: "_getTargetElement", + value: function _getTargetElement() { + var target; + + if (this.props.targetEvent) { + // create a fake element at the event coordinates + target = document.getElementById("popover-event-target"); + + if (!target) { + target = document.createElement("div"); + target.id = "popover-event-target"; + document.body.appendChild(target); + } + + target.style.left = this.props.targetEvent.clientX - 3 + "px"; + target.style.top = this.props.targetEvent.clientY - 3 + "px"; + } else if (this.props.target) { + if (typeof this.props.target === "function") { + target = react_dom__WEBPACK_IMPORTED_MODULE_2__.findDOMNode(this.props.target()); + } else { + target = react_dom__WEBPACK_IMPORTED_MODULE_2__.findDOMNode(this.props.target); + } + } + + if (target == null) { + target = react_dom__WEBPACK_IMPORTED_MODULE_2__.findDOMNode(this).parentNode; + } + + return target; + } + }, { + key: "_renderPopover", + value: function _renderPopover(isOpen) { + var _this5 = this; + + var popoverElement = this._getPopoverElement(isOpen); + + if (popoverElement) { + if (isOpen) { + popoverElement.classList.add("PopoverContainer--open"); + popoverElement.classList.add("popover"); + popoverElement.dataset.state = "visible"; + } else { + popoverElement.classList.remove("PopoverContainer--open"); + popoverElement.classList.remove("popover"); + popoverElement.dataset.state = "hidden"; + } + } // popover is open, lets do this! + + + if (isOpen) { + react_dom__WEBPACK_IMPORTED_MODULE_2__.unstable_renderSubtreeIntoContainer(this, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", null, isOpen ? this._popoverComponent() : null), popoverElement, function () { + var tetherOptions = { + element: popoverElement, + target: _this5._getTargetElement() + }; + + if (!_this5._best || !_this5.props.pinInitialAttachment) { + var best = { + attachmentX: "center", + attachmentY: "top", + targetAttachmentX: "center", + targetAttachmentY: "bottom", + offsetX: 0, + offsetY: 0 + }; // horizontal + + best = _this5._getBestAttachmentOptions(tetherOptions, best, _this5.props.horizontalAttachments, ["left", "right"], function (best, attachmentX) { + return _objectSpread(_objectSpread({}, best), {}, { + attachmentX: attachmentX, + targetAttachmentX: _this5.props.alignHorizontalEdge ? attachmentX : "center", + offsetX: { + center: 0, + left: -_this5.props.targetOffsetX, + right: _this5.props.targetOffsetX + }[attachmentX] + }); + }); // vertical + + best = _this5._getBestAttachmentOptions(tetherOptions, best, _this5.props.verticalAttachments, ["top", "bottom"], function (best, attachmentY) { + return _objectSpread(_objectSpread({}, best), {}, { + attachmentY: attachmentY, + targetAttachmentY: (_this5.props.alignVerticalEdge ? attachmentY === "bottom" : attachmentY === "top") ? "bottom" : "top", + offsetY: { + top: _this5.props.targetOffsetY, + bottom: -_this5.props.targetOffsetY + }[attachmentY] + }); + }); + _this5._best = best; + } + + if (_this5.props.sizeToFit) { + if (_this5._best.targetAttachmentY === "top") { + _this5.constrainPopoverToBetweenViewportAndTarget(tetherOptions, "top"); + } else if (_this5._best.targetAttachmentY === "bottom") { + _this5.constrainPopoverToBetweenViewportAndTarget(tetherOptions, "bottom"); + } + } // finally set the best options + + + _this5._setTetherOptions(tetherOptions, _this5._best); + }); + } else { + if (this._popoverElement) { + react_dom__WEBPACK_IMPORTED_MODULE_2__.unmountComponentAtNode(this._popoverElement); + } + } + } + }, { + key: "constrainPopoverToBetweenViewportAndTarget", + value: function constrainPopoverToBetweenViewportAndTarget(tetherOptions, direction) { + var body = tetherOptions.element.querySelector(".PopoverBody"); + + var target = this._getTargetElement(); + + var bodyHeight = body.getBoundingClientRect().height; + var space = direction === "top" ? target.getBoundingClientRect().top : window.innerHeight - target.getBoundingClientRect().bottom; + var maxHeight = space - PAGE_PADDING; + + if (bodyHeight > maxHeight) { + body.style.maxHeight = maxHeight + "px"; + body.classList.add("scroll-y"); + body.classList.add("scroll-show"); + } + } + }, { + key: "render", + value: function render() { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { + className: "hide" + }); + } + }]); + + return Popover; +}(react__WEBPACK_IMPORTED_MODULE_0__.Component); + +_defineProperty(Popover, "propTypes", { + id: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string), + isOpen: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), + hasArrow: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), + hasBackground: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), + tetherOptions: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().object), + // used to prevent popovers from being taller than the screen + sizeToFit: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), + pinInitialAttachment: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), + // most popovers have a max-width to prevent them from being overly wide + // in the case their content is of an unexpected length + // noMaxWidth allows that to be overridden in cases where popovers should + // expand alongside their contents contents + autoWidth: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), + // prioritized vertical attachments points on the popover + verticalAttachments: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().array), + // prioritized horizontal attachment points on the popover + horizontalAttachments: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().array), + // by default we align the top edge of the target to the bottom edge of the + // popover or vice versa. This causes the same edges to be aligned + alignVerticalEdge: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), + // by default we align the popover to the center of the target. This + // causes the edges to be aligned + alignHorizontalEdge: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), + // don't wrap the popover in an OnClickOutsideWrapper + noOnClickOutsideWrapper: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), + targetOffsetX: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().number), + targetOffsetY: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().number), + onClose: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func), + containerClassName: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string), + className: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string), + style: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().object), + children: prop_types__WEBPACK_IMPORTED_MODULE_1___default().oneOfType([(prop_types__WEBPACK_IMPORTED_MODULE_1___default().element), (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func), (prop_types__WEBPACK_IMPORTED_MODULE_1___default().array)]), + dismissOnClickOutside: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func), + dismissOnEscape: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func), + target: prop_types__WEBPACK_IMPORTED_MODULE_1___default().oneOfType([(prop_types__WEBPACK_IMPORTED_MODULE_1___default().func), (prop_types__WEBPACK_IMPORTED_MODULE_1___default().node)]), + targetEvent: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().object), + role: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string) +}); + +_defineProperty(Popover, "defaultProps", { + isOpen: true, + hasArrow: false, + hasBackground: true, + verticalAttachments: ["top", "bottom"], + horizontalAttachments: ["left", "right"], + alignVerticalEdge: false, + alignHorizontalEdge: true, + targetOffsetX: 0, + targetOffsetY: 5, + sizeToFit: false, + autoWidth: false, + noOnClickOutsideWrapper: false, + containerClassName: "" +}); + + + +/***/ }), + +/***/ "./components/Popover/TippyPopover.tsx": +/*!*********************************************!*\ + !*** ./components/Popover/TippyPopover.tsx ***! + \*********************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prop-types */ "../../../node_modules/prop-types/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var _tippyjs_react__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @tippyjs/react */ "../../../node_modules/@tippyjs/react/dist/tippy-react.esm.js"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! classnames */ "../../../node_modules/classnames/index.js"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_2__); +/* harmony import */ var metabase_lib_dom__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/lib/dom */ "./lib/dom.js"); +/* harmony import */ var metabase_components_EventSandbox__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! metabase/components/EventSandbox */ "./components/EventSandbox.tsx"); +/* harmony import */ var metabase_env__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! metabase/env */ "./env.js"); +var _excluded = ["className", "disableContentSandbox", "lazy", "content", "delay"]; + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } + +function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } + +function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } + +function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } + +function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } + +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + + + + + + + + +var TippyComponent = _tippyjs_react__WEBPACK_IMPORTED_MODULE_6__.default; +var OFFSET = [0, 5]; + +var propTypes = _objectSpread({ + disablContentSandbox: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), + lazy: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool) +}, TippyComponent.propTypes); + +function TippyPopover(_ref) { + var className = _ref.className, + disableContentSandbox = _ref.disableContentSandbox, + _ref$lazy = _ref.lazy, + lazy = _ref$lazy === void 0 ? true : _ref$lazy, + content = _ref.content, + delay = _ref.delay, + props = _objectWithoutProperties(_ref, _excluded); + + delay = metabase_env__WEBPACK_IMPORTED_MODULE_5__.isCypressActive ? 0 : delay; + var animationDuration = (0,metabase_lib_dom__WEBPACK_IMPORTED_MODULE_3__.isReducedMotionPreferred)() ? 0 : undefined; + + var _useState = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(!lazy), + _useState2 = _slicedToArray(_useState, 2), + mounted = _useState2[0], + setMounted = _useState2[1]; + + var plugins = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(function () { + return lazy ? [{ + fn: function fn() { + return { + onMount: function onMount() { + return setMounted(true); + }, + onHidden: function onHidden() { + return setMounted(false); + } + }; + } + }] : []; + }, [lazy]); + var computedContent; + + if (!mounted) { + computedContent = ""; + } else if (content != null) { + computedContent = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_EventSandbox__WEBPACK_IMPORTED_MODULE_4__.default, { + disabled: disableContentSandbox + }, content); + } + + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(TippyComponent, _extends({ + className: classnames__WEBPACK_IMPORTED_MODULE_2___default()("popover", className), + theme: "popover", + arrow: false, + offset: OFFSET, + appendTo: function appendTo() { + return document.body; + }, + plugins: plugins + }, props, { + duration: animationDuration, + delay: delay, + content: computedContent + })); +} + +TippyPopover.propTypes = propTypes; +/* harmony default export */ __webpack_exports__["default"] = (TippyPopover); + +/***/ }), + +/***/ "./components/Popover/index.js": +/*!*************************************!*\ + !*** ./components/Popover/index.js ***! + \*************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* reexport safe */ _Popover__WEBPACK_IMPORTED_MODULE_0__.default; } +/* harmony export */ }); +/* harmony import */ var _Popover__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Popover */ "./components/Popover/Popover.jsx"); + + +/***/ }), + +/***/ "./components/PopoverWithTrigger.jsx": +/*!*******************************************!*\ + !*** ./components/PopoverWithTrigger.jsx ***! + \*******************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var _Triggerable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Triggerable */ "./components/Triggerable.jsx"); +/* harmony import */ var _Popover__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Popover */ "./components/Popover/index.js"); + + +/* harmony default export */ __webpack_exports__["default"] = ((0,_Triggerable__WEBPACK_IMPORTED_MODULE_0__.default)(_Popover__WEBPACK_IMPORTED_MODULE_1__.default)); + +/***/ }), + +/***/ "./components/Radio.jsx": +/*!******************************!*\ + !*** ./components/Radio.jsx ***! + \******************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "optionShape": function() { return /* binding */ optionShape; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prop-types */ "../../../node_modules/prop-types/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! underscore */ "../../../node_modules/underscore/modules/index-all.js"); +/* harmony import */ var metabase_components_Icon__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/components/Icon */ "./components/Icon.tsx"); +/* harmony import */ var _Radio_styled__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Radio.styled */ "./components/Radio.styled.jsx"); +/* provided dependency */ var console = __webpack_require__(/*! console-browserify */ "../../../node_modules/console-browserify/index.js"); +var _excluded = ["name", "value", "options", "onOptionClick", "onChange", "optionNameFn", "optionValueFn", "optionKeyFn", "variant", "vertical", "xspace", "yspace", "py", "showButtons", "colorScheme"]; + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } + +function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } + +function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } + +function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } + +function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } + + + + + + +var optionShape = prop_types__WEBPACK_IMPORTED_MODULE_1___default().shape({ + name: prop_types__WEBPACK_IMPORTED_MODULE_1___default().oneOfType([(prop_types__WEBPACK_IMPORTED_MODULE_1___default().string), (prop_types__WEBPACK_IMPORTED_MODULE_1___default().element), (prop_types__WEBPACK_IMPORTED_MODULE_1___default().node)]).isRequired, + value: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().any.isRequired), + icon: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string) +}); +var propTypes = { + name: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string), + value: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().any), + options: prop_types__WEBPACK_IMPORTED_MODULE_1___default().oneOfType([prop_types__WEBPACK_IMPORTED_MODULE_1___default().arrayOf((prop_types__WEBPACK_IMPORTED_MODULE_1___default().string)), prop_types__WEBPACK_IMPORTED_MODULE_1___default().arrayOf(optionShape)]).isRequired, + onChange: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func), + onOptionClick: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func), + optionNameFn: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func), + optionValueFn: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func), + optionKeyFn: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func), + showButtons: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), + xspace: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().number), + yspace: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().number), + py: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().number), + // Modes + variant: prop_types__WEBPACK_IMPORTED_MODULE_1___default().oneOf(["bubble", "normal", "underlined"]), + vertical: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), + colorScheme: prop_types__WEBPACK_IMPORTED_MODULE_1___default().oneOf(["admin", "default", "accent7"]) +}; + +var defaultNameGetter = function defaultNameGetter(option) { + return option.name; +}; + +var defaultValueGetter = function defaultValueGetter(option) { + return option.value; +}; + +var VARIANTS = { + normal: [_Radio_styled__WEBPACK_IMPORTED_MODULE_4__.NormalList, _Radio_styled__WEBPACK_IMPORTED_MODULE_4__.NormalItem], + bubble: [_Radio_styled__WEBPACK_IMPORTED_MODULE_4__.BubbleList, _Radio_styled__WEBPACK_IMPORTED_MODULE_4__.BubbleItem], + underlined: [_Radio_styled__WEBPACK_IMPORTED_MODULE_4__.UnderlinedList, _Radio_styled__WEBPACK_IMPORTED_MODULE_4__.UnderlinedItem] +}; + +function Radio(_ref) { + var nameFromProps = _ref.name, + currentValue = _ref.value, + options = _ref.options, + onOptionClick = _ref.onOptionClick, + _onChange = _ref.onChange, + _ref$optionNameFn = _ref.optionNameFn, + optionNameFn = _ref$optionNameFn === void 0 ? defaultNameGetter : _ref$optionNameFn, + _ref$optionValueFn = _ref.optionValueFn, + optionValueFn = _ref$optionValueFn === void 0 ? defaultValueGetter : _ref$optionValueFn, + _ref$optionKeyFn = _ref.optionKeyFn, + optionKeyFn = _ref$optionKeyFn === void 0 ? defaultValueGetter : _ref$optionKeyFn, + _ref$variant = _ref.variant, + variant = _ref$variant === void 0 ? "normal" : _ref$variant, + _ref$vertical = _ref.vertical, + vertical = _ref$vertical === void 0 ? false : _ref$vertical, + xspace = _ref.xspace, + yspace = _ref.yspace, + py = _ref.py, + _ref$showButtons = _ref.showButtons, + showButtons = _ref$showButtons === void 0 ? vertical && variant !== "bubble" : _ref$showButtons, + _ref$colorScheme = _ref.colorScheme, + colorScheme = _ref$colorScheme === void 0 ? "default" : _ref$colorScheme, + props = _objectWithoutProperties(_ref, _excluded); + + var id = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(function () { + return underscore__WEBPACK_IMPORTED_MODULE_2__.default.uniqueId("radio-"); + }, []); + var name = nameFromProps || id; + + var _ref2 = VARIANTS[variant] || VARIANTS.normal, + _ref3 = _slicedToArray(_ref2, 2), + List = _ref3[0], + Item = _ref3[1]; + + if (variant === "underlined" && currentValue === undefined) { + console.warn("Radio can't underline selected option when no value is given."); + } + + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(List, _extends({}, props, { + vertical: vertical, + showButtons: showButtons + }), options.map(function (option, index) { + var value = optionValueFn(option); + var selected = currentValue === value; + var last = index === options.length - 1; + var key = optionKeyFn(option); + var id = "".concat(name, "-").concat(key); + var labelId = "".concat(id, "-label"); + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("li", { + key: key + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(Item, { + id: labelId, + htmlFor: id, + colorScheme: colorScheme, + selected: selected, + last: last, + vertical: vertical, + showButtons: showButtons, + py: py, + xspace: xspace, + yspace: yspace, + onClick: function onClick() { + if (typeof onOptionClick === "function") { + onOptionClick(value); + } + } + }, option.icon && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Icon__WEBPACK_IMPORTED_MODULE_3__.default, { + name: option.icon, + mr: 1 + }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_Radio_styled__WEBPACK_IMPORTED_MODULE_4__.RadioInput, { + colorScheme: colorScheme, + id: id, + name: name, + value: value, + checked: selected, + onChange: function onChange() { + if (typeof _onChange === "function") { + _onChange(value); + } + } // Workaround for https://github.com/testing-library/dom-testing-library/issues/877 + , + "aria-labelledby": labelId + }), showButtons && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_Radio_styled__WEBPACK_IMPORTED_MODULE_4__.RadioButton, { + colorScheme: colorScheme, + checked: selected + }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { + "data-testid": "".concat(id, "-name") + }, optionNameFn(option)))); + })); +} + +Radio.propTypes = propTypes; +/* harmony default export */ __webpack_exports__["default"] = (Radio); + +/***/ }), + +/***/ "./components/Radio.styled.jsx": +/*!*************************************!*\ + !*** ./components/Radio.styled.jsx ***! + \*************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "RadioInput": function() { return /* binding */ RadioInput; }, +/* harmony export */ "RadioButton": function() { return /* binding */ RadioButton; }, +/* harmony export */ "BubbleList": function() { return /* binding */ BubbleList; }, +/* harmony export */ "BubbleItem": function() { return /* binding */ BubbleItem; }, +/* harmony export */ "NormalList": function() { return /* binding */ NormalList; }, +/* harmony export */ "NormalItem": function() { return /* binding */ NormalItem; }, +/* harmony export */ "UnderlinedList": function() { return /* binding */ UnderlinedList; }, +/* harmony export */ "UnderlinedItem": function() { return /* binding */ UnderlinedItem; } +/* harmony export */ }); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! classnames */ "../../../node_modules/classnames/index.js"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var styled_components__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! styled-components */ "../../../node_modules/styled-components/dist/styled-components.browser.es.js"); +/* harmony import */ var styled_system__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! styled-system */ "../../../node_modules/styled-system/dist/index.js"); +/* harmony import */ var metabase_lib_colors__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/lib/colors */ "./lib/colors.ts"); + + + + +var COLOR_SCHEMES = { + accent7: { + main: function main() { + return (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_3__.color)("accent7"); + }, + button: function button() { + return (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_3__.color)("accent7"); + } + }, + default: { + main: function main() { + return (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_3__.color)("brand"); + }, + button: function button() { + return (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_3__.color)("brand"); + } + } +}; +var RadioInput = styled_components__WEBPACK_IMPORTED_MODULE_1__.default.input.attrs({ + type: "radio" +}).withConfig({ + displayName: "Radiostyled__RadioInput", + componentId: "jq4vzl-0" +})(["cursor:inherit;position:absolute;opacity:0;width:0;height:0;top:0;left:0;margin:0;padding:0;z-index:1;"]); +var RadioButton = styled_components__WEBPACK_IMPORTED_MODULE_1__.default.div.withConfig({ + displayName: "Radiostyled__RadioButton", + componentId: "jq4vzl-1" +})(["cursor:pointer;display:inline-block;flex:0 0 auto;position:relative;margin-right:0.5rem;width:12px;height:12px;border:2px solid white;box-shadow:0 0 0 2px ", ";border-radius:12px;background-color:", ";"], function (props) { + if (props.checked) { + return props.colorScheme ? COLOR_SCHEMES[props.colorScheme].button() : (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_3__.color)("brand"); + } else { + return (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_3__.color)("text-medium"); + } +}, function (props) { + if (props.checked) { + return props.colorScheme ? COLOR_SCHEMES[props.colorScheme].button() : (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_3__.color)("brand"); + } else { + return "transparent"; + } +}); // BASE + +var BaseList = styled_components__WEBPACK_IMPORTED_MODULE_1__.default.ul.withConfig({ + displayName: "Radiostyled__BaseList", + componentId: "jq4vzl-2" +})(["display:flex;flex-direction:", ";font-weight:bold;"], function (props) { + return props.vertical ? "column" : "row"; +}); +var BaseItem = styled_components__WEBPACK_IMPORTED_MODULE_1__.default.label.attrs({ + mr: function mr(props) { + return !props.vertical && !props.last ? props.xspace : null; + }, + mb: function mb(props) { + return props.vertical && !props.last ? props.yspace : null; + } +}).withConfig({ + displayName: "Radiostyled__BaseItem", + componentId: "jq4vzl-3" +})(["", " position:relative;display:flex;align-items:center;cursor:pointer;:hover{color:", ";}"], styled_system__WEBPACK_IMPORTED_MODULE_2__.space, function (props) { + return !props.showButtons && !props.selected ? COLOR_SCHEMES[props.colorScheme].main() : null; +}); +BaseItem.defaultProps = { + xspace: 3, + yspace: 1 +}; // BUBBLE + +var BubbleList = (0,styled_components__WEBPACK_IMPORTED_MODULE_1__.default)(BaseList).withConfig({ + displayName: "Radiostyled__BubbleList", + componentId: "jq4vzl-4" +})([""]); +var BubbleItem = (0,styled_components__WEBPACK_IMPORTED_MODULE_1__.default)(BaseItem).withConfig({ + displayName: "Radiostyled__BubbleItem", + componentId: "jq4vzl-5" +})(["font-weight:700;border-radius:99px;color:", ";background-color:", ";:hover{background-color:", ";transition:background 300ms linear;}"], function (props) { + return props.selected ? (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_3__.color)("white") : COLOR_SCHEMES[props.colorScheme].main(); +}, function (props) { + return props.selected ? COLOR_SCHEMES[props.colorScheme].main() : (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_3__.lighten)(COLOR_SCHEMES[props.colorScheme].main()); +}, function (props) { + return !props.selected && (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_3__.lighten)(COLOR_SCHEMES[props.colorScheme].main(), 0.38); +}); +BubbleItem.defaultProps = { + xspace: 1, + py: 1, + px: 2 +}; // NORMAL + +var NormalList = (0,styled_components__WEBPACK_IMPORTED_MODULE_1__.default)(BaseList).attrs({ + className: function className(props) { + return classnames__WEBPACK_IMPORTED_MODULE_0___default()(props.className, { + "text-bold": !props.showButtons + }); + } +}).withConfig({ + displayName: "Radiostyled__NormalList", + componentId: "jq4vzl-6" +})([""]); +var NormalItem = (0,styled_components__WEBPACK_IMPORTED_MODULE_1__.default)(BaseItem).withConfig({ + displayName: "Radiostyled__NormalItem", + componentId: "jq4vzl-7" +})(["color:", ";"], function (props) { + return props.selected ? COLOR_SCHEMES[props.colorScheme].main() : null; +}); // UNDERLINE + +var UnderlinedList = (0,styled_components__WEBPACK_IMPORTED_MODULE_1__.default)(NormalList).withConfig({ + displayName: "Radiostyled__UnderlinedList", + componentId: "jq4vzl-8" +})([""]); +var UnderlinedItem = (0,styled_components__WEBPACK_IMPORTED_MODULE_1__.default)(NormalItem).withConfig({ + displayName: "Radiostyled__UnderlinedItem", + componentId: "jq4vzl-9" +})(["border-bottom:3px solid transparent;border-color:", ";"], function (props) { + return props.selected ? COLOR_SCHEMES[props.colorScheme].main() : null; +}); +UnderlinedItem.defaultProps = { + py: 2 +}; + +/***/ }), + +/***/ "./components/SandboxedPortal.jsx": +/*!****************************************!*\ + !*** ./components/SandboxedPortal.jsx ***! + \****************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-dom */ "../../../node_modules/react-dom/index.js"); +/* harmony import */ var _EventSandbox__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./EventSandbox */ "./components/EventSandbox.tsx"); + + + // Prevent DOM events from bubbling through the React component tree +// See https://reactjs.org/docs/portals.html#event-bubbling-through-portals + +function SandboxedPortal(_ref) { + var children = _ref.children, + container = _ref.container, + _ref$enableMouseEvent = _ref.enableMouseEvents, + enableMouseEvents = _ref$enableMouseEvent === void 0 ? false : _ref$enableMouseEvent; + return /*#__PURE__*/react_dom__WEBPACK_IMPORTED_MODULE_1__.createPortal( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_EventSandbox__WEBPACK_IMPORTED_MODULE_2__.default, { + enableMouseEvents: enableMouseEvents + }, children), container); +} + +/* harmony default export */ __webpack_exports__["default"] = (SandboxedPortal); + +/***/ }), + +/***/ "./components/SchedulePicker.jsx": +/*!***************************************!*\ + !*** ./components/SchedulePicker.jsx ***! + \***************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "HOUR_OPTIONS": function() { return /* binding */ HOUR_OPTIONS; }, +/* harmony export */ "MINUTE_OPTIONS": function() { return /* binding */ MINUTE_OPTIONS; }, +/* harmony export */ "AM_PM_OPTIONS": function() { return /* binding */ AM_PM_OPTIONS; }, +/* harmony export */ "DAY_OF_WEEK_OPTIONS": function() { return /* binding */ DAY_OF_WEEK_OPTIONS; }, +/* harmony export */ "MONTH_DAY_OPTIONS": function() { return /* binding */ MONTH_DAY_OPTIONS; }, +/* harmony export */ "default": function() { return /* binding */ SchedulePicker; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prop-types */ "../../../node_modules/prop-types/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var metabase_components_SegmentedControl__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/components/SegmentedControl */ "./components/SegmentedControl.jsx"); +/* harmony import */ var metabase_components_Select__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/components/Select */ "./components/Select.jsx"); +/* harmony import */ var metabase_lib_settings__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! metabase/lib/settings */ "./lib/settings.ts"); +/* harmony import */ var metabase_lib_formatting__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! metabase/lib/formatting */ "./lib/formatting.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_6__); +/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! underscore */ "../../../node_modules/underscore/modules/index-all.js"); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18, _templateObject19, _templateObject20, _templateObject21; + +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + +/* eslint "react/prop-types": "warn" */ + + + + + + + + +var HOUR_OPTIONS = underscore__WEBPACK_IMPORTED_MODULE_7__.default.times(12, function (n) { + return { + name: (n === 0 ? 12 : n) + ":00", + value: n + }; +}); +var MINUTE_OPTIONS = underscore__WEBPACK_IMPORTED_MODULE_7__.default.times(60, function (n) { + return { + name: n.toString(), + value: n + }; +}); +var AM_PM_OPTIONS = [{ + name: "AM", + value: 0 +}, { + name: "PM", + value: 1 +}]; +var DAY_OF_WEEK_OPTIONS = [{ + name: (0,ttag__WEBPACK_IMPORTED_MODULE_6__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["Sunday"]))), + value: "sun" +}, { + name: (0,ttag__WEBPACK_IMPORTED_MODULE_6__.t)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["Monday"]))), + value: "mon" +}, { + name: (0,ttag__WEBPACK_IMPORTED_MODULE_6__.t)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["Tuesday"]))), + value: "tue" +}, { + name: (0,ttag__WEBPACK_IMPORTED_MODULE_6__.t)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["Wednesday"]))), + value: "wed" +}, { + name: (0,ttag__WEBPACK_IMPORTED_MODULE_6__.t)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["Thursday"]))), + value: "thu" +}, { + name: (0,ttag__WEBPACK_IMPORTED_MODULE_6__.t)(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["Friday"]))), + value: "fri" +}, { + name: (0,ttag__WEBPACK_IMPORTED_MODULE_6__.t)(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["Saturday"]))), + value: "sat" +}]; +var MONTH_DAY_OPTIONS = [{ + name: (0,ttag__WEBPACK_IMPORTED_MODULE_6__.t)(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["First"]))), + value: "first" +}, { + name: (0,ttag__WEBPACK_IMPORTED_MODULE_6__.t)(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["Last"]))), + value: "last" +}, { + name: (0,ttag__WEBPACK_IMPORTED_MODULE_6__.t)(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["15th (Midpoint)"]))), + value: "mid" +}]; +var optionNameTranslations = { + hourly: (0,ttag__WEBPACK_IMPORTED_MODULE_6__.t)(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["Hourly"]))), + daily: (0,ttag__WEBPACK_IMPORTED_MODULE_6__.t)(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["Daily"]))), + weekly: (0,ttag__WEBPACK_IMPORTED_MODULE_6__.t)(_templateObject13 || (_templateObject13 = _taggedTemplateLiteral(["Weekly"]))), + monthly: (0,ttag__WEBPACK_IMPORTED_MODULE_6__.t)(_templateObject14 || (_templateObject14 = _taggedTemplateLiteral(["Monthly"]))) +}; +/** + * Picker for selecting a hourly/daily/weekly/monthly schedule. + * + * TODO Atte Keinänen 6/30/17: This could use text input fields instead of dropdown for time (hour + AM/PM) pickers + */ + +var SchedulePicker = /*#__PURE__*/function (_Component) { + _inherits(SchedulePicker, _Component); + + var _super = _createSuper(SchedulePicker); + + function SchedulePicker() { + var _this; + + _classCallCheck(this, SchedulePicker); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _super.call.apply(_super, [this].concat(args)); + + _defineProperty(_assertThisInitialized(_this), "DEFAULT_DAY", "mon"); + + return _this; + } + + _createClass(SchedulePicker, [{ + key: "handleChangeProperty", + value: function handleChangeProperty(name, value) { + var newSchedule = _objectSpread(_objectSpread({}, this.props.schedule), {}, _defineProperty({}, name, value)); + + if (name === "schedule_type") { + // clear out other values than schedule_type for hourly schedule + if (value === "hourly") { + newSchedule = _objectSpread(_objectSpread({}, newSchedule), {}, { + schedule_day: null, + schedule_frame: null, + schedule_hour: null, + schedule_minute: 0 + }); + } // default to midnight for all schedules other than hourly + + + if (value !== "hourly") { + newSchedule = _objectSpread(_objectSpread({}, newSchedule), {}, { + schedule_hour: newSchedule.schedule_hour || 0 + }); + } // clear out other values than schedule_type and schedule_day for daily schedule + + + if (value === "daily") { + newSchedule = _objectSpread(_objectSpread({}, newSchedule), {}, { + schedule_day: null, + schedule_frame: null + }); + } // default to Monday when user wants a weekly schedule + clear out schedule_frame + + + if (value === "weekly") { + newSchedule = _objectSpread(_objectSpread({}, newSchedule), {}, { + schedule_day: this.DEFAULT_DAY, + schedule_frame: null + }); + } // default to First, Monday when user wants a monthly schedule + + + if (value === "monthly") { + newSchedule = _objectSpread(_objectSpread({}, newSchedule), {}, { + schedule_frame: "first", + schedule_day: this.DEFAULT_DAY + }); + } + } else if (name === "schedule_frame") { + // when the monthly schedule frame is the 15th, clear out the schedule_day + if (value === "mid") { + newSchedule = _objectSpread(_objectSpread({}, newSchedule), {}, { + schedule_day: null + }); + } else { + // first or last, needs a day of the week + newSchedule = _objectSpread(_objectSpread({}, newSchedule), {}, { + schedule_day: newSchedule.schedule_day || this.DEFAULT_DAY + }); + } + } + + var changedProp = { + name: name, + value: value + }; + this.props.onScheduleChange(newSchedule, changedProp); + } + }, { + key: "renderMonthlyPicker", + value: function renderMonthlyPicker() { + var _this2 = this; + + var schedule = this.props.schedule; + var DAY_OPTIONS = DAY_OF_WEEK_OPTIONS.slice(0); + DAY_OPTIONS.unshift({ + name: (0,ttag__WEBPACK_IMPORTED_MODULE_6__.t)(_templateObject15 || (_templateObject15 = _taggedTemplateLiteral(["Calendar Day"]))), + value: null + }); + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "flex align-center mt1" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { + className: "text-bold", + style: { + minWidth: "48px" + } + }, (0,ttag__WEBPACK_IMPORTED_MODULE_6__.t)(_templateObject16 || (_templateObject16 = _taggedTemplateLiteral(["on the"])))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Select__WEBPACK_IMPORTED_MODULE_3__.default, { + value: schedule.schedule_frame, + onChange: function onChange(_ref) { + var value = _ref.target.value; + return _this2.handleChangeProperty("schedule_frame", value); + }, + options: MONTH_DAY_OPTIONS + }), schedule.schedule_frame !== "mid" && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { + className: "mx1" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Select__WEBPACK_IMPORTED_MODULE_3__.default, { + value: schedule.schedule_day, + onChange: function onChange(_ref2) { + var value = _ref2.target.value; + return _this2.handleChangeProperty("schedule_day", value); + }, + options: DAY_OPTIONS + }))); + } + }, { + key: "renderDayPicker", + value: function renderDayPicker() { + var _this3 = this; + + var schedule = this.props.schedule; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { + className: "flex align-center" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { + className: "text-bold mx1" + }, (0,ttag__WEBPACK_IMPORTED_MODULE_6__.t)(_templateObject17 || (_templateObject17 = _taggedTemplateLiteral(["on"])))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Select__WEBPACK_IMPORTED_MODULE_3__.default, { + value: schedule.schedule_day, + onChange: function onChange(_ref3) { + var value = _ref3.target.value; + return _this3.handleChangeProperty("schedule_day", value); + }, + options: DAY_OF_WEEK_OPTIONS + })); + } + }, { + key: "renderMinutePicker", + value: function renderMinutePicker() { + var _this4 = this; + + var schedule = this.props.schedule; + var minuteOfHour = isNaN(schedule.schedule_minute) ? 0 : schedule.schedule_minute; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "mt1" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "flex align-center" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { + className: "text-bold", + style: { + minWidth: "48px" + } + }, (0,ttag__WEBPACK_IMPORTED_MODULE_6__.t)(_templateObject18 || (_templateObject18 = _taggedTemplateLiteral(["at"])))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Select__WEBPACK_IMPORTED_MODULE_3__.default, { + className: "mr1", + value: minuteOfHour, + options: MINUTE_OPTIONS, + onChange: function onChange(_ref4) { + var value = _ref4.target.value; + return _this4.handleChangeProperty("schedule_minute", value); + } + }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { + className: "text-bold" + }, (0,ttag__WEBPACK_IMPORTED_MODULE_6__.t)(_templateObject19 || (_templateObject19 = _taggedTemplateLiteral(["minutes past the hour"])))))); + } + }, { + key: "renderHourPicker", + value: function renderHourPicker() { + var _this5 = this; + + var _this$props = this.props, + schedule = _this$props.schedule, + textBeforeSendTime = _this$props.textBeforeSendTime; + var hourOfDay = isNaN(schedule.schedule_hour) ? 8 : schedule.schedule_hour; + var hour = hourOfDay % 12; + var amPm = hourOfDay >= 12 ? 1 : 0; + var timezone = metabase_lib_settings__WEBPACK_IMPORTED_MODULE_4__.default.get("report-timezone-short"); + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "mt1" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "flex align-center" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { + className: "text-bold", + style: { + minWidth: "48px" + } + }, (0,ttag__WEBPACK_IMPORTED_MODULE_6__.t)(_templateObject20 || (_templateObject20 = _taggedTemplateLiteral(["at"])))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Select__WEBPACK_IMPORTED_MODULE_3__.default, { + className: "mr1", + value: hour, + options: HOUR_OPTIONS, + onChange: function onChange(_ref5) { + var value = _ref5.target.value; + return _this5.handleChangeProperty("schedule_hour", value + amPm * 12); + } + }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_SegmentedControl__WEBPACK_IMPORTED_MODULE_2__.SegmentedControl, { + value: amPm, + onChange: function onChange(value) { + return _this5.handleChangeProperty("schedule_hour", hour + value * 12); + }, + options: AM_PM_OPTIONS, + fullWidth: true + })), textBeforeSendTime && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "mt1 text-medium pt2" + }, textBeforeSendTime, " ", hour === 0 ? 12 : hour, ":00", " ", amPm ? "PM" : "AM", " ", timezone, ", ", (0,ttag__WEBPACK_IMPORTED_MODULE_6__.t)(_templateObject21 || (_templateObject21 = _taggedTemplateLiteral(["your Metabase timezone"]))), ".")); + } + }, { + key: "render", + value: function render() { + var _this6 = this; + + var _this$props2 = this.props, + schedule = _this$props2.schedule, + scheduleOptions = _this$props2.scheduleOptions, + textBeforeInterval = _this$props2.textBeforeInterval; + var scheduleType = schedule.schedule_type; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "mt3" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "flex align-center" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { + className: "text-bold", + style: { + minWidth: "48px" + } + }, textBeforeInterval), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Select__WEBPACK_IMPORTED_MODULE_3__.default, { + value: scheduleType, + onChange: function onChange(_ref6) { + var value = _ref6.target.value; + return _this6.handleChangeProperty("schedule_type", value); + }, + options: scheduleOptions, + optionNameFn: function optionNameFn(o) { + return optionNameTranslations[o] || (0,metabase_lib_formatting__WEBPACK_IMPORTED_MODULE_5__.capitalize)(o); + }, + optionValueFn: function optionValueFn(o) { + return o; + } + }), scheduleType === "weekly" && this.renderDayPicker()), scheduleType === "hourly" && this.props.minutesOnHourPicker && this.renderMinutePicker(), scheduleType === "monthly" && this.renderMonthlyPicker(), (scheduleType === "daily" || scheduleType === "weekly" || scheduleType === "monthly") && this.renderHourPicker()); + } + }]); + + return SchedulePicker; +}(react__WEBPACK_IMPORTED_MODULE_0__.Component); + +_defineProperty(SchedulePicker, "propTypes", { + // the currently chosen schedule, e.g. { schedule_day: "mon", schedule_frame: "null", schedule_hour: 4, schedule_type: "daily" } + schedule: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().object.isRequired), + // TODO: hourly option? + // available schedules, e.g. [ "daily", "weekly", "monthly"] + scheduleOptions: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().array.isRequired), + // text before Daily/Weekly/Monthly... option + textBeforeInterval: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string), + // text prepended to "12:00 PM PST, your Metabase timezone" + textBeforeSendTime: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string), + onScheduleChange: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func.isRequired), + minutesOnHourPicker: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool) +}); + + + +/***/ }), + +/***/ "./components/SegmentedControl.jsx": +/*!*****************************************!*\ + !*** ./components/SegmentedControl.jsx ***! + \*****************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "optionShape": function() { return /* binding */ optionShape; }, +/* harmony export */ "SegmentedControl": function() { return /* binding */ SegmentedControl; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prop-types */ "../../../node_modules/prop-types/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! underscore */ "../../../node_modules/underscore/modules/index-all.js"); +/* harmony import */ var _SegmentedControl_styled__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./SegmentedControl.styled */ "./components/SegmentedControl.styled.jsx"); +var _excluded = ["name", "value", "options", "onChange", "fullWidth", "inactiveColor", "variant"]; + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } + +function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } + + + + + +var optionShape = prop_types__WEBPACK_IMPORTED_MODULE_1___default().shape({ + name: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().node), + value: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().any), + icon: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string), + iconSize: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().number), + // Expects a color alias, not a color code + // Example: brand, accent1, success + // Won't work: red, #000, rgb(0, 0, 0) + selectedColor: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string) +}); +var propTypes = { + name: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string), + value: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().any), + options: prop_types__WEBPACK_IMPORTED_MODULE_1___default().arrayOf(optionShape).isRequired, + variant: prop_types__WEBPACK_IMPORTED_MODULE_1___default().oneOf(["fill-text", "fill-background"]), + inactiveColor: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string), + onChange: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func), + fullWidth: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool) +}; +var DEFAULT_OPTION_ICON_SIZE = 16; +function SegmentedControl(_ref) { + var nameFromProps = _ref.name, + value = _ref.value, + options = _ref.options, + _onChange = _ref.onChange, + _ref$fullWidth = _ref.fullWidth, + fullWidth = _ref$fullWidth === void 0 ? false : _ref$fullWidth, + _ref$inactiveColor = _ref.inactiveColor, + inactiveColor = _ref$inactiveColor === void 0 ? "text-medium" : _ref$inactiveColor, + _ref$variant = _ref.variant, + variant = _ref$variant === void 0 ? "fill-text" : _ref$variant, + props = _objectWithoutProperties(_ref, _excluded); + + var id = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(function () { + return underscore__WEBPACK_IMPORTED_MODULE_2__.default.uniqueId("radio-"); + }, []); + var name = nameFromProps || id; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_SegmentedControl_styled__WEBPACK_IMPORTED_MODULE_3__.SegmentedList, _extends({}, props, { + fullWidth: fullWidth + }), options.map(function (option, index) { + var isSelected = option.value === value; + var isFirst = index === 0; + var isLast = index === options.length - 1; + var id = "".concat(name, "-").concat(option.value); + var labelId = "".concat(name, "-").concat(option.value); + var iconOnly = !option.name; + var selectedColor = option.selectedColor || "brand"; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_SegmentedControl_styled__WEBPACK_IMPORTED_MODULE_3__.SegmentedItem, { + key: option.value, + isSelected: isSelected, + isFirst: isFirst, + isLast: isLast, + fullWidth: fullWidth, + variant: variant, + selectedColor: selectedColor + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_SegmentedControl_styled__WEBPACK_IMPORTED_MODULE_3__.SegmentedItemLabel, { + id: labelId, + isSelected: isSelected, + variant: variant, + selectedColor: selectedColor, + inactiveColor: inactiveColor, + compact: iconOnly + }, option.icon && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_SegmentedControl_styled__WEBPACK_IMPORTED_MODULE_3__.ItemIcon, { + name: option.icon, + size: option.iconSize || DEFAULT_OPTION_ICON_SIZE, + iconOnly: iconOnly + }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_SegmentedControl_styled__WEBPACK_IMPORTED_MODULE_3__.SegmentedControlRadio, { + id: id, + name: name, + value: option.value, + checked: isSelected, + onChange: function onChange() { + return _onChange(option.value); + } // Workaround for https://github.com/testing-library/dom-testing-library/issues/877 + , + "aria-labelledby": labelId + }), option.name)); + })); +} +SegmentedControl.propTypes = propTypes; + +/***/ }), + +/***/ "./components/SegmentedControl.styled.jsx": +/*!************************************************!*\ + !*** ./components/SegmentedControl.styled.jsx ***! + \************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "SegmentedList": function() { return /* binding */ SegmentedList; }, +/* harmony export */ "SegmentedItem": function() { return /* binding */ SegmentedItem; }, +/* harmony export */ "SegmentedItemLabel": function() { return /* binding */ SegmentedItemLabel; }, +/* harmony export */ "SegmentedControlRadio": function() { return /* binding */ SegmentedControlRadio; }, +/* harmony export */ "ItemIcon": function() { return /* binding */ ItemIcon; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var styled_components__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! styled-components */ "../../../node_modules/styled-components/dist/styled-components.browser.es.js"); +/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! underscore */ "../../../node_modules/underscore/modules/index-all.js"); +/* harmony import */ var metabase_components_Icon__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/components/Icon */ "./components/Icon.tsx"); +/* harmony import */ var metabase_lib_colors__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! metabase/lib/colors */ "./lib/colors.ts"); + + + + + +var BORDER_RADIUS = "8px"; +var SegmentedList = styled_components__WEBPACK_IMPORTED_MODULE_1__.default.ul.withConfig({ + displayName: "SegmentedControlstyled__SegmentedList", + componentId: "fbxv0s-0" +})(["display:flex;width:", ";"], function (props) { + return props.fullWidth ? 1 : 0; +}); + +function getSegmentedItemColor(props, fallbackColor) { + if (props.variant === "fill-text") { + return fallbackColor; + } + + return props.isSelected ? (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_4__.color)(props.selectedColor) : fallbackColor; +} + +var SegmentedItem = styled_components__WEBPACK_IMPORTED_MODULE_1__.default.li.withConfig({ + displayName: "SegmentedControlstyled__SegmentedItem", + componentId: "fbxv0s-1" +})(["display:flex;flex-grow:", ";background-color:", ";border:1px solid ", ";border-right-width:", ";border-top-left-radius:", ";border-bottom-left-radius:", ";border-top-right-radius:", ";border-bottom-right-radius:", ";"], function (props) { + return props.fullWidth ? 1 : 0; +}, function (props) { + return getSegmentedItemColor(props, "transparent"); +}, function (props) { + return getSegmentedItemColor(props, (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_4__.darken)((0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_4__.color)("border"), 0.1)); +}, function (props) { + return props.isLast ? "1px" : 0; +}, function (props) { + return props.isFirst ? BORDER_RADIUS : 0; +}, function (props) { + return props.isFirst ? BORDER_RADIUS : 0; +}, function (props) { + return props.isLast ? BORDER_RADIUS : 0; +}, function (props) { + return props.isLast ? BORDER_RADIUS : 0; +}); +var SegmentedItemLabel = styled_components__WEBPACK_IMPORTED_MODULE_1__.default.label.withConfig({ + displayName: "SegmentedControlstyled__SegmentedItemLabel", + componentId: "fbxv0s-2" +})(["display:flex;width:100%;align-items:center;justify-content:center;position:relative;font-weight:bold;color:", ";padding:", ";cursor:pointer;:hover{color:", ";}"], function (props) { + var selectedColor = (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_4__.color)(props.variant === "fill-text" ? props.selectedColor : "white"); + return props.isSelected ? selectedColor : (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_4__.color)(props.inactiveColor); +}, function (props) { + return props.compact ? "8px" : "8px 12px"; +}, function (props) { + return !props.isSelected ? (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_4__.color)(props.selectedColor) : null; +}); +var SegmentedControlRadio = styled_components__WEBPACK_IMPORTED_MODULE_1__.default.input.attrs({ + type: "radio" +}).withConfig({ + displayName: "SegmentedControlstyled__SegmentedControlRadio", + componentId: "fbxv0s-3" +})(["cursor:inherit;position:absolute;opacity:0;width:0;height:0;top:0;left:0;margin:0;padding:0;z-index:1;"]); + +function IconWrapper(props) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Icon__WEBPACK_IMPORTED_MODULE_3__.default, underscore__WEBPACK_IMPORTED_MODULE_2__.default.omit(props, "iconOnly")); +} + +var ItemIcon = (0,styled_components__WEBPACK_IMPORTED_MODULE_1__.default)(IconWrapper).withConfig({ + displayName: "SegmentedControlstyled__ItemIcon", + componentId: "fbxv0s-4" +})(["margin-right:", ";"], function (props) { + return props.iconOnly ? 0 : "4px"; +}); + +/***/ }), + +/***/ "./components/Select.jsx": +/*!*******************************!*\ + !*** ./components/Select.jsx ***! + \*******************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* binding */ Select; }, +/* harmony export */ "OptionSection": function() { return /* binding */ OptionSection; }, +/* harmony export */ "Option": function() { return /* binding */ Option; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prop-types */ "../../../node_modules/prop-types/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var metabase_components_Icon__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/components/Icon */ "./components/Icon.tsx"); +/* harmony import */ var metabase_components_PopoverWithTrigger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/components/PopoverWithTrigger */ "./components/PopoverWithTrigger.jsx"); +/* harmony import */ var _SelectButton__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./SelectButton */ "./components/SelectButton.jsx"); +/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! underscore */ "../../../node_modules/underscore/modules/index-all.js"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! classnames */ "../../../node_modules/classnames/index.js"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_6__); +/* harmony import */ var _AccordionList__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./AccordionList */ "./components/AccordionList/index.js"); +/* harmony import */ var reselect__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! reselect */ "../../../node_modules/reselect/lib/index.js"); +/* harmony import */ var metabase_lib_colors__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! metabase/lib/colors */ "./lib/colors.ts"); +/* harmony import */ var metabase_hoc_Uncontrollable__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! metabase/hoc/Uncontrollable */ "./hoc/Uncontrollable.jsx"); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +var _dec, _class, _class2, _temp; + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } + +function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } + +function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } + +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/* eslint "react/prop-types": "warn" */ + + + + + + + + + + + +var MIN_ICON_WIDTH = 20; +var Select = (_dec = (0,metabase_hoc_Uncontrollable__WEBPACK_IMPORTED_MODULE_10__.default)(), _dec(_class = (_temp = _class2 = /*#__PURE__*/function (_Component3) { + _inherits(Select, _Component3); + + var _super3 = _createSuper(Select); + + function Select(props) { + var _this; + + _classCallCheck(this, Select); + + _this = _super3.call(this, props); // reselect selectors + + _defineProperty(_assertThisInitialized(_this), "itemIsSelected", function (option) { + var optionValue = _this.props.optionValueFn(option); + + return _this._getValuesSet().has(optionValue); + }); + + _defineProperty(_assertThisInitialized(_this), "itemIsClickable", function (option) { + return !_this.props.optionDisabledFn(option); + }); + + _defineProperty(_assertThisInitialized(_this), "handleChange", function (option) { + var _this$props = _this.props, + multiple = _this$props.multiple, + onChange = _this$props.onChange; + + var optionValue = _this.props.optionValueFn(option); + + var value; + + if (multiple) { + var values = _this._getValues(); + + value = _this.itemIsSelected(option) ? values.filter(function (value) { + return value !== optionValue; + }) : [].concat(_toConsumableArray(values), [optionValue]); + } else { + value = optionValue; + } + + onChange({ + target: { + value: value + } + }); + + if (!multiple) { + _this._popover.close(); + } + }); + + _defineProperty(_assertThisInitialized(_this), "renderItemIcon", function (item) { + if (_this.itemIsSelected(item)) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Icon__WEBPACK_IMPORTED_MODULE_2__.default, { + name: "check", + size: 14, + color: (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_9__.color)("text-dark"), + style: { + minWidth: MIN_ICON_WIDTH + } + }); + } + + var icon = _this.props.optionIconFn(item); + + if (icon) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Icon__WEBPACK_IMPORTED_MODULE_2__.default, { + name: icon, + size: item.iconSize || 18, + color: item.iconColor || (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_9__.color)("text-dark"), + style: { + minWidth: MIN_ICON_WIDTH + } + }); + } + + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { + style: { + minWidth: MIN_ICON_WIDTH + } + }); + }); + + var _getValue = function _getValue(props) { + return (// If a defaultValue is passed, replace a null value with it. + // Otherwise, allow null values since we sometimes want them. + Object.prototype.hasOwnProperty.call(props, "defaultValue") && props.value == null ? props.defaultValue : props.value + ); + }; + + var _getValues = (0,reselect__WEBPACK_IMPORTED_MODULE_8__.createSelector)([_getValue], function (value) { + return Array.isArray(value) ? value : [value]; + }); + + var _getValuesSet = (0,reselect__WEBPACK_IMPORTED_MODULE_8__.createSelector)([_getValues], function (values) { + return new Set(values); + }); + + _this._getValues = function () { + return _getValues(_this.props); + }; + + _this._getValuesSet = function () { + return _getValuesSet(_this.props); + }; + + return _this; + } + + _createClass(Select, [{ + key: "_getSections", + value: function _getSections() { + // normalize `children`/`options` into same format as `sections` + var _this$props2 = this.props, + children = _this$props2.children, + sections = _this$props2.sections, + options = _this$props2.options; + + if (children) { + var optionToItem = function optionToItem(option) { + return option.props; + }; + + var first = Array.isArray(children) ? children[0] : children; + + if (first && first.type === OptionSection) { + return react__WEBPACK_IMPORTED_MODULE_0__.Children.map(children, function (child) { + return _objectSpread(_objectSpread({}, child.props), {}, { + items: react__WEBPACK_IMPORTED_MODULE_0__.Children.map(child.props.children, optionToItem) + }); + }); + } else if (first && first.type === Option) { + return [{ + items: react__WEBPACK_IMPORTED_MODULE_0__.Children.map(children, optionToItem) + }]; + } + } else if (options) { + if (this.props.optionSectionFn) { + return underscore__WEBPACK_IMPORTED_MODULE_5__.default.chain(options).groupBy(this.props.optionSectionFn).pairs().map(function (_ref) { + var _ref2 = _slicedToArray(_ref, 2), + section = _ref2[0], + items = _ref2[1]; + + return { + name: section, + items: items + }; + }).value(); + } else { + return [{ + items: options + }]; + } + } else if (sections) { + return sections; + } + + return []; + } + }, { + key: "render", + value: function render() { + var _this2 = this; + + var _this$props3 = this.props, + buttonProps = _this$props3.buttonProps, + className = _this$props3.className, + placeholder = _this$props3.placeholder, + searchProp = _this$props3.searchProp, + searchCaseInsensitive = _this$props3.searchCaseInsensitive, + searchFuzzy = _this$props3.searchFuzzy, + isInitiallyOpen = _this$props3.isInitiallyOpen; + + var sections = this._getSections(); + + var selectedNames = sections.map(function (section) { + return section.items.filter(_this2.itemIsSelected).map(_this2.props.optionNameFn); + }).flat().filter(function (n) { + return n; + }); + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_PopoverWithTrigger__WEBPACK_IMPORTED_MODULE_3__.default, { + ref: function ref(_ref3) { + return _this2._popover = _ref3; + }, + triggerElement: this.props.triggerElement || /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_SelectButton__WEBPACK_IMPORTED_MODULE_4__.default, _extends({ + className: "flex-full", + hasValue: selectedNames.length > 0 + }, buttonProps), selectedNames.length > 0 ? selectedNames.map(function (name, index) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { + key: index + }, name, index < selectedNames.length - 1 ? ", " : ""); + }) : placeholder), + triggerClasses: classnames__WEBPACK_IMPORTED_MODULE_6___default()("flex", className), + isInitiallyOpen: isInitiallyOpen, + verticalAttachments: ["top", "bottom"] // keep the popover from jumping around one its been opened, + // this can happen when filtering items via search + , + pinInitialAttachment: true + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_AccordionList__WEBPACK_IMPORTED_MODULE_7__.default, { + sections: sections, + className: "MB-Select text-brand", + alwaysExpanded: true, + itemIsSelected: this.itemIsSelected, + itemIsClickable: this.itemIsClickable, + renderItemName: this.props.optionNameFn, + getItemClassName: this.props.optionClassNameFn, + renderItemDescription: this.props.optionDescriptionFn, + renderItemIcon: this.renderItemIcon, + onChange: this.handleChange, + searchable: !!searchProp, + searchProp: searchProp, + searchCaseInsensitive: searchCaseInsensitive, + searchFuzzy: searchFuzzy + })); + } + }]); + + return Select; +}(react__WEBPACK_IMPORTED_MODULE_0__.Component), _defineProperty(_class2, "propTypes", { + className: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string), + // one of these is required + options: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().any), + sections: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().any), + children: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().any), + value: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().any.isRequired), + defaultValue: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().any), + onChange: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func.isRequired), + multiple: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), + placeholder: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string), + // PopoverWithTrigger props + isInitiallyOpen: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), + triggerElement: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().any), + // SelectButton props + buttonProps: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().object), + // AccordianList props + searchProp: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string), + searchCaseInsensitive: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), + searchFuzzy: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), + optionNameFn: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func), + optionValueFn: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func), + optionDescriptionFn: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func), + optionSectionFn: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func), + optionDisabledFn: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func), + optionIconFn: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func), + optionClassNameFn: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func) +}), _defineProperty(_class2, "defaultProps", { + optionNameFn: function optionNameFn(option) { + return option.children || option.name; + }, + optionValueFn: function optionValueFn(option) { + return option.value; + }, + optionDescriptionFn: function optionDescriptionFn(option) { + return option.description; + }, + optionDisabledFn: function optionDisabledFn(option) { + return option.disabled; + }, + optionIconFn: function optionIconFn(option) { + return option.icon; + } +}), _temp)) || _class); + +var OptionSection = /*#__PURE__*/function (_Component) { + _inherits(OptionSection, _Component); + + var _super = _createSuper(OptionSection); + + function OptionSection() { + _classCallCheck(this, OptionSection); + + return _super.apply(this, arguments); + } + + _createClass(OptionSection, [{ + key: "render", + value: function render() { + return null; + } + }]); + + return OptionSection; +}(react__WEBPACK_IMPORTED_MODULE_0__.Component); + +_defineProperty(OptionSection, "propTypes", { + name: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().any), + icon: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().any), + children: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().any.isRequired) +}); + +var Option = /*#__PURE__*/function (_Component2) { + _inherits(Option, _Component2); + + var _super2 = _createSuper(Option); + + function Option() { + _classCallCheck(this, Option); + + return _super2.apply(this, arguments); + } + + _createClass(Option, [{ + key: "render", + value: function render() { + return null; + } + }]); + + return Option; +}(react__WEBPACK_IMPORTED_MODULE_0__.Component); + +_defineProperty(Option, "propTypes", { + value: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().any.isRequired), + // one of these two is required + name: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().any), + children: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().any), + icon: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().any), + disabled: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool) +}); + +/***/ }), + +/***/ "./components/SelectButton.jsx": +/*!*************************************!*\ + !*** ./components/SelectButton.jsx ***! + \*************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prop-types */ "../../../node_modules/prop-types/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var metabase_components_Icon__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/components/Icon */ "./components/Icon.tsx"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! classnames */ "../../../node_modules/classnames/index.js"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_3__); +/* eslint "react/prop-types": "warn" */ + + + + + +var SelectButton = function SelectButton(_ref) { + var className = _ref.className, + style = _ref.style, + children = _ref.children, + _ref$hasValue = _ref.hasValue, + hasValue = _ref$hasValue === void 0 ? true : _ref$hasValue; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + style: style, + className: classnames__WEBPACK_IMPORTED_MODULE_3___default()(className, "AdminSelect flex align-center", { + "text-medium": !hasValue + }) + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { + className: "AdminSelect-content mr1" + }, children), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Icon__WEBPACK_IMPORTED_MODULE_2__.default, { + className: "AdminSelect-chevron flex-align-right", + name: "chevrondown", + size: 12 + })); +}; + +SelectButton.propTypes = { + className: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string), + style: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().object), + children: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().any), + hasValue: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().any) +}; +/* harmony default export */ __webpack_exports__["default"] = (SelectButton); + +/***/ }), + +/***/ "./components/TextEditor.jsx": +/*!***********************************!*\ + !*** ./components/TextEditor.jsx ***! + \***********************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* binding */ TextEditor; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prop-types */ "../../../node_modules/prop-types/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react-dom */ "../../../node_modules/react-dom/index.js"); +/* harmony import */ var ace_ace__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ace/ace */ "../../../node_modules/ace-builds/src-min-noconflict/ace.js"); +/* harmony import */ var ace_ace__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(ace_ace__WEBPACK_IMPORTED_MODULE_3__); +/* harmony import */ var ace_mode_plain_text__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ace/mode-plain_text */ "../../../node_modules/ace-builds/src-min-noconflict/mode-plain_text.js"); +/* harmony import */ var ace_mode_plain_text__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(ace_mode_plain_text__WEBPACK_IMPORTED_MODULE_4__); +/* harmony import */ var ace_mode_javascript__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ace/mode-javascript */ "../../../node_modules/ace-builds/src-min-noconflict/mode-javascript.js"); +/* harmony import */ var ace_mode_javascript__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(ace_mode_javascript__WEBPACK_IMPORTED_MODULE_5__); +/* harmony import */ var ace_mode_json__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ace/mode-json */ "../../../node_modules/ace-builds/src-min-noconflict/mode-json.js"); +/* harmony import */ var ace_mode_json__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(ace_mode_json__WEBPACK_IMPORTED_MODULE_6__); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/*global ace*/ + +/* eslint-disable react/prop-types */ + + + + + + + +var SCROLL_MARGIN = 8; +var LINE_HEIGHT = 16; + +var TextEditor = /*#__PURE__*/function (_Component) { + _inherits(TextEditor, _Component); + + var _super = _createSuper(TextEditor); + + function TextEditor() { + var _this; + + _classCallCheck(this, TextEditor); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _super.call.apply(_super, [this].concat(args)); + + _defineProperty(_assertThisInitialized(_this), "onChange", function (e) { + _this._update(); + + if (_this.props.onChange) { + _this.props.onChange(_this.value); + } + }); + + return _this; + } + + _createClass(TextEditor, [{ + key: "UNSAFE_componentWillReceiveProps", + value: function UNSAFE_componentWillReceiveProps(nextProps) { + if (this._editor && nextProps.value != null && nextProps.value !== this._editor.getValue()) { + this._editor.setValue(nextProps.value); + + this._editor.clearSelection(); + } + } + }, { + key: "_update", + value: function _update() { + var element = react_dom__WEBPACK_IMPORTED_MODULE_2__.findDOMNode(this); + + if (this._editor == null) { + return; // _editor is undefined when ace isn't loaded in tests + } + + this._updateValue(); + + this._editor.getSession().setMode(this.props.mode); + + this._editor.setTheme(this.props.theme); // read only + + + this._editor.setReadOnly(this.props.readOnly); + + element.classList[this.props.readOnly ? "add" : "remove"]("read-only"); + + this._updateSize(); + } + }, { + key: "_updateValue", + value: function _updateValue() { + if (this._editor) { + this.value = this._editor.getValue(); + } + } + }, { + key: "_updateSize", + value: function _updateSize() { + var doc = this._editor.getSession().getDocument(); + + var element = react_dom__WEBPACK_IMPORTED_MODULE_2__.findDOMNode(this); + element.style.height = 2 * SCROLL_MARGIN + LINE_HEIGHT * doc.getLength() + "px"; + + this._editor.resize(); + } + }, { + key: "componentDidMount", + value: function componentDidMount() { + if (typeof ace === "undefined" || !ace || !ace.edit) { + // fail gracefully-ish if ace isn't available, e.x. in integration tests + return; + } + + var element = react_dom__WEBPACK_IMPORTED_MODULE_2__.findDOMNode(this); + this._editor = ace.edit(element); + window.editor = this._editor; // listen to onChange events + + this._editor.getSession().on("change", this.onChange); // misc options, copied from NativeQueryEditor + + + this._editor.setOptions({ + enableBasicAutocompletion: true, + enableSnippets: true, + enableLiveAutocompletion: true, + showPrintMargin: false, + highlightActiveLine: false, + highlightGutterLine: false, + showLineNumbers: true // wrap: true + + }); + + this._editor.renderer.setScrollMargin(SCROLL_MARGIN, SCROLL_MARGIN); // initialize the content + + + this._editor.setValue((this.props.value != null ? this.props.value : this.props.defaultValue) || ""); // clear the editor selection, otherwise we start with the whole editor selected + + + this._editor.clearSelection(); // hmmm, this could be dangerous + // this._editor.focus(); + + + this._update(); + } + }, { + key: "componentDidUpdate", + value: function componentDidUpdate() { + this._update(); + } + }, { + key: "render", + value: function render() { + var _this$props = this.props, + className = _this$props.className, + style = _this$props.style; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: className, + style: style + }); + } + }]); + + return TextEditor; +}(react__WEBPACK_IMPORTED_MODULE_0__.Component); + +_defineProperty(TextEditor, "propTypes", { + mode: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string), + theme: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string), + value: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string), + defaultValue: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string), + onChange: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func) +}); + +_defineProperty(TextEditor, "defaultProps", { + mode: "ace/mode/plain_text", + theme: null +}); + + + +/***/ }), + +/***/ "./components/TextInput/TextInput.styled.tsx": +/*!***************************************************!*\ + !*** ./components/TextInput/TextInput.styled.tsx ***! + \***************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "Input": function() { return /* binding */ Input; }, +/* harmony export */ "TextInputRoot": function() { return /* binding */ TextInputRoot; }, +/* harmony export */ "ClearButton": function() { return /* binding */ ClearButton; }, +/* harmony export */ "IconWrapper": function() { return /* binding */ IconWrapper; } +/* harmony export */ }); +/* harmony import */ var styled_components__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! styled-components */ "../../../node_modules/styled-components/dist/styled-components.browser.es.js"); +/* harmony import */ var metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/lib/colors */ "./lib/colors.ts"); + + +var PADDING = { + sm: "0.5rem", + md: "0.75rem" +}; +var BORDER_RADIUS = { + sm: "4px", + md: "8px" +}; +var BORDER_COLOR = { + default: function _default() { + return (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.color)("brand"); + }, + admin: function admin() { + return (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.color)("accent7"); + }, + transparent: function transparent() { + return "transparent"; + } +}; + +var getBorderColor = function getBorderColor(colorScheme, invalid) { + if (invalid) { + return (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.color)("error"); + } + + return colorScheme === "transparent" ? "transparent" : (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.color)("border"); +}; + +var Input = styled_components__WEBPACK_IMPORTED_MODULE_0__.default.input.withConfig({ + displayName: "TextInputstyled__Input", + componentId: "sc-1lhamsb-0" +})(["border:1px solid ", ";outline:none;width:100%;font-size:1.12em;font-weight:400;color:", ";min-width:200px;background-color:", ";&:disabled{background-color:", ";}", " ", " ", " &:focus{border-color:", ";}"], function (props) { + return getBorderColor(props.colorScheme, props.invalid); +}, (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.color)("text-dark"), function (props) { + return props.colorScheme === "transparent" ? "transparent" : (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.color)("white"); +}, (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.color)("bg-light"), function (_ref) { + var borderRadius = _ref.borderRadius, + padding = _ref.padding; + return (0,styled_components__WEBPACK_IMPORTED_MODULE_0__.css)(["border-radius:", ";padding:", ";"], BORDER_RADIUS[borderRadius], PADDING[padding]); +}, function (props) { + return props.hasClearButton ? (0,styled_components__WEBPACK_IMPORTED_MODULE_0__.css)(["padding-right:26px;"]) : null; +}, function (props) { + return props.hasIcon ? (0,styled_components__WEBPACK_IMPORTED_MODULE_0__.css)(["padding-left:36px;"]) : null; +}, function (props) { + return BORDER_COLOR[props.colorScheme](); +}); +var TextInputRoot = styled_components__WEBPACK_IMPORTED_MODULE_0__.default.div.withConfig({ + displayName: "TextInputstyled__TextInputRoot", + componentId: "sc-1lhamsb-1" +})(["position:relative;display:flex;align-items:center;"]); +var ClearButton = styled_components__WEBPACK_IMPORTED_MODULE_0__.default.button.withConfig({ + displayName: "TextInputstyled__ClearButton", + componentId: "sc-1lhamsb-2" +})(["display:flex;position:absolute;right:12px;color:", ";cursor:pointer;&:hover{color:", ";}"], (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.color)("bg-dark"), (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.color)("text-dark")); +var IconWrapper = styled_components__WEBPACK_IMPORTED_MODULE_0__.default.span.withConfig({ + displayName: "TextInputstyled__IconWrapper", + componentId: "sc-1lhamsb-3" +})(["position:absolute;padding-left:0.75rem;color:", ";"], (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.color)("text-light")); + +/***/ }), + +/***/ "./components/TextInput/TextInput.tsx": +/*!********************************************!*\ + !*** ./components/TextInput/TextInput.tsx ***! + \********************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var metabase_components_Icon__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/components/Icon */ "./components/Icon.tsx"); +/* harmony import */ var _TextInput_styled__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./TextInput.styled */ "./components/TextInput/TextInput.styled.tsx"); +var _templateObject; + +var _excluded = ["value", "className", "placeholder", "onChange", "hasClearButton", "icon", "type", "colorScheme", "autoFocus", "padding", "borderRadius", "innerRef", "ref", "invalid"]; + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + +function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } + +function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } + + + + + + +function TextInput(_ref) { + var _ref$value = _ref.value, + value = _ref$value === void 0 ? "" : _ref$value, + className = _ref.className, + _ref$placeholder = _ref.placeholder, + placeholder = _ref$placeholder === void 0 ? (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["Find..."]))) : _ref$placeholder, + _onChange = _ref.onChange, + _ref$hasClearButton = _ref.hasClearButton, + hasClearButton = _ref$hasClearButton === void 0 ? false : _ref$hasClearButton, + icon = _ref.icon, + _ref$type = _ref.type, + type = _ref$type === void 0 ? "text" : _ref$type, + _ref$colorScheme = _ref.colorScheme, + colorScheme = _ref$colorScheme === void 0 ? "default" : _ref$colorScheme, + _ref$autoFocus = _ref.autoFocus, + autoFocus = _ref$autoFocus === void 0 ? false : _ref$autoFocus, + _ref$padding = _ref.padding, + padding = _ref$padding === void 0 ? "md" : _ref$padding, + _ref$borderRadius = _ref.borderRadius, + borderRadius = _ref$borderRadius === void 0 ? "md" : _ref$borderRadius, + innerRef = _ref.innerRef, + ref = _ref.ref, + invalid = _ref.invalid, + rest = _objectWithoutProperties(_ref, _excluded); + + var handleClearClick = function handleClearClick() { + _onChange(""); + }; + + var showClearButton = hasClearButton && value.length > 0; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_TextInput_styled__WEBPACK_IMPORTED_MODULE_3__.TextInputRoot, { + className: className + }, icon && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_TextInput_styled__WEBPACK_IMPORTED_MODULE_3__.IconWrapper, null, icon), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_TextInput_styled__WEBPACK_IMPORTED_MODULE_3__.Input, _extends({ + innerRef: innerRef, + colorScheme: colorScheme, + autoFocus: autoFocus, + hasClearButton: hasClearButton, + hasIcon: !!icon, + placeholder: placeholder, + value: value, + type: type, + onChange: function onChange(e) { + return _onChange(e.target.value); + }, + padding: padding, + borderRadius: borderRadius, + invalid: invalid + }, rest)), showClearButton && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_TextInput_styled__WEBPACK_IMPORTED_MODULE_3__.ClearButton, { + onClick: handleClearClick + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Icon__WEBPACK_IMPORTED_MODULE_2__.default, { + name: "close", + size: 12 + }))); +} + +/* harmony default export */ __webpack_exports__["default"] = (/*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(function TextInputForwardRef(props, ref) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(TextInput, _extends({}, props, { + innerRef: ref + })); +})); + +/***/ }), + +/***/ "./components/TextInput/index.js": +/*!***************************************!*\ + !*** ./components/TextInput/index.js ***! + \***************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* reexport safe */ _TextInput__WEBPACK_IMPORTED_MODULE_0__.default; } +/* harmony export */ }); +/* harmony import */ var _TextInput__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./TextInput */ "./components/TextInput/TextInput.tsx"); + + +/***/ }), + +/***/ "./components/TitleAndDescription.jsx": +/*!********************************************!*\ + !*** ./components/TitleAndDescription.jsx ***! + \********************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! classnames */ "../../../node_modules/classnames/index.js"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var metabase_components_Icon__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/components/Icon */ "./components/Icon.tsx"); +/* harmony import */ var metabase_components_Tooltip__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/components/Tooltip */ "./components/Tooltip/index.ts"); +/* eslint-disable react/prop-types */ + + + + + +var TitleAndDescription = function TitleAndDescription(_ref) { + var title = _ref.title, + description = _ref.description, + className = _ref.className; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: classnames__WEBPACK_IMPORTED_MODULE_1___default()("flex align-center", className) + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("h2", { + className: "h2 mr1 text-wrap" + }, title), description && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Tooltip__WEBPACK_IMPORTED_MODULE_3__.default, { + tooltip: description, + maxWidth: "22em" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Icon__WEBPACK_IMPORTED_MODULE_2__.default, { + name: "info", + className: "mx1" + }))); +}; + +/* harmony default export */ __webpack_exports__["default"] = (/*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.memo(TitleAndDescription)); + +/***/ }), + +/***/ "./components/Toggle/Toggle.styled.tsx": +/*!*********************************************!*\ + !*** ./components/Toggle/Toggle.styled.tsx ***! + \*********************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "ToggleRoot": function() { return /* binding */ ToggleRoot; } +/* harmony export */ }); +/* harmony import */ var styled_components__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! styled-components */ "../../../node_modules/styled-components/dist/styled-components.browser.es.js"); +/* harmony import */ var metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/lib/colors */ "./lib/colors.ts"); + + + +var getLeft = function getLeft(_ref) { + var isSmall = _ref.isSmall, + isSelected = _ref.isSelected; + + if (!isSelected) { + return "1px"; + } else if (!isSmall) { + return "25px"; + } else { + return "12px"; + } +}; + +var getBackgroundColor = function getBackgroundColor(_ref2) { + var isSelected = _ref2.isSelected, + currentColor = _ref2.currentColor; + + if (isSelected) { + return currentColor !== null && currentColor !== void 0 ? currentColor : (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.color)("brand"); + } else { + return (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.color)("bg-medium"); + } +}; + +var ToggleRoot = styled_components__WEBPACK_IMPORTED_MODULE_0__.default.a.withConfig({ + displayName: "Togglestyled__ToggleRoot", + componentId: "p2144r-0" +})(["position:relative;display:inline-block;color:", ";box-sizing:border-box;width:", ";height:", ";border-radius:99px;border:1px solid ", ";background-color:", ";background-color:", ";transition:all 0.3s;text-decoration:none;&:after{content:\"\";width:", ";height:", ";border-radius:99px;position:absolute;top:1px;left:", ";background-color:", ";transition:all 0.3s;box-shadow:2px 2px 6px ", ";}"], function (props) { + var _props$currentColor; + + return (_props$currentColor = props.currentColor) !== null && _props$currentColor !== void 0 ? _props$currentColor : (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.color)("brand"); +}, function (props) { + return props.isSmall ? "28px" : "48px"; +}, function (props) { + return props.isSmall ? "17px" : "24px"; +}, (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.color)("border"), (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.color)("bg-medium"), getBackgroundColor, function (props) { + return props.isSmall ? "13px" : "20px"; +}, function (props) { + return props.isSmall ? "13px" : "20px"; +}, getLeft, (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.color)("white"), (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.color)("shadow")); + +/***/ }), + +/***/ "./components/Toggle/Toggle.tsx": +/*!**************************************!*\ + !*** ./components/Toggle/Toggle.tsx ***! + \**************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var metabase_components_Toggle_Toggle_styled__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/components/Toggle/Toggle.styled */ "./components/Toggle/Toggle.styled.tsx"); +var _excluded = ["className", "value", "small", "color", "onChange"]; + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } + +function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } + + + + +var Toggle = function Toggle(_ref) { + var className = _ref.className, + value = _ref.value, + small = _ref.small, + color = _ref.color, + onChange = _ref.onChange, + rest = _objectWithoutProperties(_ref, _excluded); + + var handleClick = function handleClick() { + onChange && onChange(!value); + }; + + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Toggle_Toggle_styled__WEBPACK_IMPORTED_MODULE_1__.ToggleRoot, _extends({}, rest, { + className: className, + role: "checkbox", + "aria-checked": value, + isSmall: small, + isSelected: value, + currentColor: color, + onClick: handleClick + })); +}; + +/* harmony default export */ __webpack_exports__["default"] = (Toggle); + +/***/ }), + +/***/ "./components/Toggle/index.ts": +/*!************************************!*\ + !*** ./components/Toggle/index.ts ***! + \************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* reexport safe */ _Toggle__WEBPACK_IMPORTED_MODULE_0__.default; } +/* harmony export */ }); +/* harmony import */ var _Toggle__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Toggle */ "./components/Toggle/Toggle.tsx"); + + +/***/ }), + +/***/ "./components/ToggleLarge.jsx": +/*!************************************!*\ + !*** ./components/ToggleLarge.jsx ***! + \************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! classnames */ "../../../node_modules/classnames/index.js"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_1__); +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/* eslint-disable react/prop-types */ + + + +var ToggleLarge = function ToggleLarge(_ref) { + var style = _ref.style, + className = _ref.className, + value = _ref.value, + onChange = _ref.onChange, + textLeft = _ref.textLeft, + textRight = _ref.textRight; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: classnames__WEBPACK_IMPORTED_MODULE_1___default()(className, "bg-medium flex relative text-bold", { + "cursor-pointer": onChange + }), + style: _objectSpread({ + borderRadius: 8 + }, style), + onClick: function onClick() { + return onChange({ + target: { + value: !value + } + }); + } + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "absolute bg-white z1", + style: _defineProperty({ + borderRadius: 6, + top: 3, + bottom: 3, + width: "50%" + }, value ? "left" : "right", 3) + }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "flex-full flex layout-centered z2" + }, textLeft), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "flex-full flex layout-centered z2" + }, textRight)); +}; + +/* harmony default export */ __webpack_exports__["default"] = (ToggleLarge); + +/***/ }), + +/***/ "./components/TokenField.jsx": +/*!***********************************!*\ + !*** ./components/TokenField.jsx ***! + \***********************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* binding */ TokenField; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prop-types */ "../../../node_modules/prop-types/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react-dom */ "../../../node_modules/react-dom/index.js"); +/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! underscore */ "../../../node_modules/underscore/modules/index-all.js"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! classnames */ "../../../node_modules/classnames/index.js"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_4__); +/* harmony import */ var metabase_components_OnClickOutsideWrapper__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! metabase/components/OnClickOutsideWrapper */ "./components/OnClickOutsideWrapper.jsx"); +/* harmony import */ var metabase_components_Icon__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! metabase/components/Icon */ "./components/Icon.tsx"); +/* harmony import */ var metabase_components_Popover__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! metabase/components/Popover */ "./components/Popover/index.js"); +/* harmony import */ var _TokenField_styled__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./TokenField.styled */ "./components/TokenField.styled.jsx"); +/* harmony import */ var metabase_lib_keyboard__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! metabase/lib/keyboard */ "./lib/keyboard.js"); +/* harmony import */ var metabase_lib_dom__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! metabase/lib/dom */ "./lib/dom.js"); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/* eslint-disable react/prop-types */ + +/* eslint "react/prop-types": "warn" */ + + + + + + + + + + + +var defaultStyleValue = { + fontSize: 14, + fontWeight: 700 +}; // somewhat matches react-select's API: https://github.com/JedWatson/react-select + +var TokenField = /*#__PURE__*/function (_Component) { + _inherits(TokenField, _Component); + + var _super = _createSuper(TokenField); + + function TokenField(_props) { + var _this; + + _classCallCheck(this, TokenField); + + _this = _super.call(this, _props); + + _defineProperty(_assertThisInitialized(_this), "scrollElement", null); + + _defineProperty(_assertThisInitialized(_this), "_updateFilteredValues", function (props) { + var _props$options = props.options, + options = _props$options === void 0 ? [] : _props$options, + value = props.value, + removeSelected = props.removeSelected, + filterOption = props.filterOption; + var _this$state = _this.state, + searchValue = _this$state.searchValue, + selectedOptionValue = _this$state.selectedOptionValue; + var selectedValueIds = new Set(value.map(function (v) { + return JSON.stringify(_this._id(v)); + })); + + if (!filterOption) { + filterOption = function filterOption(option, searchValue) { + return String(_this._label(option) || "").indexOf(searchValue) >= 0; + }; + } + + var selectedCount = 0; + var filteredOptions = options.filter(function (option) { + var isSelected = selectedValueIds.has(JSON.stringify(_this._id(_this._value(option)))); + + var isLastFreeform = _this._isLastFreeformValue(_this._value(option)) && _this._isLastFreeformValue(searchValue); + + var isMatching = filterOption(option, searchValue); + + if (isSelected) { + selectedCount++; + } // filter out options who have already been selected, unless: + + + return (// remove selected is disabled + (!removeSelected || // or it's not in the selectedValues + !isSelected || // or it's the current "freeform" value, which updates as we type + isLastFreeform) && // and it's matching + isMatching + ); + }); + + if (selectedOptionValue == null || !underscore__WEBPACK_IMPORTED_MODULE_3__.default.find(filteredOptions, function (option) { + return _this._valueIsEqual(selectedOptionValue, _this._value(option)); + })) { + // if there are results based on the user's typing... + if (filteredOptions.length > 0) { + // select the first option in the list and set the selected option to that + selectedOptionValue = _this._value(filteredOptions[0]); + } else { + selectedOptionValue = null; + } + } + + _this.setState({ + filteredOptions: filteredOptions, + selectedOptionValue: selectedOptionValue, + isAllSelected: options.length > 0 && selectedCount === options.length + }); + }); + + _defineProperty(_assertThisInitialized(_this), "onInputChange", function (_ref) { + var value = _ref.target.value; + var _this$props = _this.props, + updateOnInputChange = _this$props.updateOnInputChange, + onInputChange = _this$props.onInputChange, + parseFreeformValue = _this$props.parseFreeformValue; + + if (onInputChange) { + value = onInputChange(value) || ""; + } // update the input value + + + _this.setInputValue(value); // if updateOnInputChange is true and parseFreeformValue is enabled then try adding/updating the freeform value immediately + + + if (updateOnInputChange && parseFreeformValue) { + var replaceLast = _this._isLastFreeformValue(_this.state.inputValue); // call parseFreeformValue to make sure we can add it + + + var freeformValue = parseFreeformValue(value); + + if (freeformValue != null) { + // if so, add it, replacing the last value if necessary + _this.addValue(freeformValue, replaceLast); + } else { + // otherwise remove the value if necessary, e.x. after deleting + if (replaceLast) { + _this.removeValue(parseFreeformValue(_this.state.inputValue)); + } + } + } + }); + + _defineProperty(_assertThisInitialized(_this), "onInputKeyDown", function (event) { + if (_this.props.onInputKeyDown) { + _this.props.onInputKeyDown(event); + } + + var key = event.key, + keyCode = event.keyCode; + var _this$state2 = _this.state, + filteredOptions = _this$state2.filteredOptions, + selectedOptionValue = _this$state2.selectedOptionValue; // enter, tab, comma + + if (keyCode === metabase_lib_keyboard__WEBPACK_IMPORTED_MODULE_9__.KEYCODE_ESCAPE || keyCode === metabase_lib_keyboard__WEBPACK_IMPORTED_MODULE_9__.KEYCODE_TAB || // We check event.key for comma presses because some keyboard layouts + // (e.g. Russian) have a letter on that key and require a modifier to type + // ",". Similarly, if you want to type "<" on the US keyboard layout, you + // need to look at `key` to distinguish it from ",". + key === metabase_lib_keyboard__WEBPACK_IMPORTED_MODULE_9__.KEY_COMMA || keyCode === metabase_lib_keyboard__WEBPACK_IMPORTED_MODULE_9__.KEYCODE_ENTER) { + if (_this.addSelectedOption(event)) { + event.stopPropagation(); + } + } else if (event.keyCode === metabase_lib_keyboard__WEBPACK_IMPORTED_MODULE_9__.KEYCODE_UP) { + // up arrow + event.preventDefault(); + + var index = underscore__WEBPACK_IMPORTED_MODULE_3__.default.findIndex(filteredOptions, function (option) { + return _this._valueIsEqual(selectedOptionValue, _this._value(option)); + }); + + if (index > 0) { + _this.setState({ + selectedOptionValue: _this._value(filteredOptions[index - 1]) + }); + } + } else if (keyCode === metabase_lib_keyboard__WEBPACK_IMPORTED_MODULE_9__.KEYCODE_DOWN) { + // down arrow + event.preventDefault(); + + var _index = underscore__WEBPACK_IMPORTED_MODULE_3__.default.findIndex(filteredOptions, function (option) { + return _this._valueIsEqual(selectedOptionValue, _this._value(option)); + }); + + if (_index >= 0 && _index < filteredOptions.length - 1) { + _this.setState({ + selectedOptionValue: _this._value(filteredOptions[_index + 1]) + }); + } + } else if (keyCode === metabase_lib_keyboard__WEBPACK_IMPORTED_MODULE_9__.KEYCODE_BACKSPACE) { + // backspace + var value = _this.props.value; + + if (!_this.state.inputValue && value.length > 0) { + _this.removeValue(value[value.length - 1]); + } + } + }); + + _defineProperty(_assertThisInitialized(_this), "onInputFocus", function () { + if (_this.props.onFocus) { + _this.props.onFocus(); + } + + _this.setState({ + isFocused: true, + searchValue: _this.state.inputValue + }, function () { + return _this._updateFilteredValues(_this.props); + }); + }); + + _defineProperty(_assertThisInitialized(_this), "onInputBlur", function () { + if (_this.props.updateOnInputBlur && _this.props.parseFreeformValue) { + var input = _this.inputRef.current; + + var value = _this.props.parseFreeformValue(input.value); + + if (value != null && (_this.props.multi || value !== _this.props.value[0])) { + _this.addValue(value); + + _this.clearInputValue(); + } + } + + if (_this.props.onBlur) { + _this.props.onBlur(); + } + + _this.setState({ + isFocused: false + }); + }); + + _defineProperty(_assertThisInitialized(_this), "onInputPaste", function (e) { + if (_this.props.parseFreeformValue) { + e.preventDefault(); + var string = e.clipboardData.getData("Text"); + var values = _this.props.multi ? string.split(/\n|,/g).map(_this.props.parseFreeformValue).filter(function (s) { + return s; + }) : [string]; + + if (values.length > 0) { + _this.addValue(values); + } + } + }); + + _defineProperty(_assertThisInitialized(_this), "onMouseDownCapture", function (e) { + var input = _this.inputRef.current; + input.focus(); // prevents clicks from blurring input while still allowing text selection: + + if (input !== e.target) { + e.preventDefault(); + } + }); + + _defineProperty(_assertThisInitialized(_this), "onClose", function () { + _this.setState({ + isFocused: false + }); + }); + + _defineProperty(_assertThisInitialized(_this), "addOption", function (option) { + var replaceLast = _this._isLastFreeformValue(_this.state.inputValue); // add the option's value to the current value + + + _this.addValue(_this._value(option), replaceLast); + }); + + _this.state = { + inputValue: "", + searchValue: "", + filteredOptions: [], + selectedOptionValue: null, + isFocused: _props.autoFocus || false, + isAllSelected: false, + listIsHovered: false + }; + _this.inputRef = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createRef(); + return _this; + } + + _createClass(TokenField, [{ + key: "UNSAFE_componentWillMount", + value: function UNSAFE_componentWillMount() { + this._updateFilteredValues(this.props); + } + }, { + key: "UNSAFE_componentWillReceiveProps", + value: function UNSAFE_componentWillReceiveProps(nextProps) { + this._updateFilteredValues(nextProps); + } + }, { + key: "setInputValue", + value: function setInputValue(inputValue) { + var _this2 = this; + + var setSearchValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; + var newState = { + inputValue: inputValue + }; + + if (setSearchValue) { + newState.searchValue = inputValue; + } + + this.setState(newState, function () { + return _this2._updateFilteredValues(_this2.props); + }); + } + }, { + key: "clearInputValue", + value: function clearInputValue() { + var clearSearchValue = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true; + this.setInputValue("", clearSearchValue); + } + }, { + key: "_id", + value: function _id(value) { + var idKey = this.props.idKey; + + if (typeof idKey === "function") { + return idKey(value); + } else if (typeof idKey === "string") { + return value[idKey]; + } else { + return value; + } + } + }, { + key: "_value", + value: function _value(option) { + var valueKey = this.props.valueKey; + return typeof valueKey === "function" ? valueKey(option) : option[valueKey]; + } + }, { + key: "_label", + value: function _label(option) { + var labelKey = this.props.labelKey; + return typeof labelKey === "function" ? labelKey(option) : option[labelKey]; + } + }, { + key: "_key", + value: function _key(option) { + return JSON.stringify(this._value(option)); + } + }, { + key: "_isLastFreeformValue", + value: function _isLastFreeformValue(inputValue) { + var _this$props2 = this.props, + value = _this$props2.value, + parseFreeformValue = _this$props2.parseFreeformValue, + updateOnInputChange = _this$props2.updateOnInputChange; + + if (parseFreeformValue && updateOnInputChange) { + var freeformValue = parseFreeformValue(inputValue); + var currentLastValue = value[value.length - 1]; // check to see if the current last value is the same as the inputValue, in which case we should replace it or remove it + + return currentLastValue === freeformValue; + } + } + }, { + key: "addSelectedOption", + value: function addSelectedOption(e) { + var _this3 = this; + + var multi = this.props.multi; + var _this$state3 = this.state, + filteredOptions = _this$state3.filteredOptions, + selectedOptionValue = _this$state3.selectedOptionValue; + var input = this.inputRef.current; + + var option = underscore__WEBPACK_IMPORTED_MODULE_3__.default.find(filteredOptions, function (option) { + return _this3._valueIsEqual(selectedOptionValue, _this3._value(option)); + }); + + if (option) { + this.addOption(option); // clear the input if the option is the same as the last value + + if (this._isLastFreeformValue(this._value(option))) { + // also clear the search + this.clearInputValue(true); + } else { + // only clear the search if this was the last option + this.clearInputValue(filteredOptions.length === 1); + } + + return true; + } else if (this.props.parseFreeformValue) { + // if we previously updated on input change then we don't need to do it again, + if (this.props.updateOnInputChange) { + // if multi=true also prevent the input from changing due to this key press + if (multi) { + e.preventDefault(); + } // and clear the input + + + this.clearInputValue(); // return false so we don't stop the keyDown from propagating in case we're listening + // for it, e.x. in the filter popover this allows enter to commit the filter + + return false; + } else { + var value = this.props.parseFreeformValue(input.value); + + if (value != null && (multi || value !== this.props.value[0])) { + this.addValue(value); + this.clearInputValue(); + return true; + } + } + } + } + }, { + key: "addValue", + value: function addValue(valueToAdd) { + var replaceLast = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; + var _this$props3 = this.props, + value = _this$props3.value, + onChange = _this$props3.onChange, + multi = _this$props3.multi; + + if (!Array.isArray(valueToAdd)) { + valueToAdd = [valueToAdd]; + } + + if (multi) { + if (replaceLast) { + onChange(dedup(value.slice(0, -1).concat(valueToAdd))); + } else { + onChange(dedup(value.concat(valueToAdd))); + } + } else { + onChange(valueToAdd.slice(0, 1)); + } // reset the input value + // setTimeout(() => + // this.setInputValue("") + // ) + + } + }, { + key: "removeValue", + value: function removeValue(valueToRemove) { + var _this4 = this; + + var _this$props4 = this.props, + value = _this$props4.value, + onChange = _this$props4.onChange; + var values = value.filter(function (v) { + return !_this4._valueIsEqual(v, valueToRemove); + }); + onChange(values); // reset the input value + // this.setInputValue(""); + } + }, { + key: "_valueIsEqual", + value: function _valueIsEqual(v1, v2) { + return JSON.stringify(v1) === JSON.stringify(v2); + } + }, { + key: "componentDidUpdate", + value: function componentDidUpdate(prevProps, prevState) { + var input = this.inputRef.current; + + if (prevState.selectedOptionValue !== this.state.selectedOptionValue && this.scrollElement != null) { + var element = (0,react_dom__WEBPACK_IMPORTED_MODULE_2__.findDOMNode)(this.scrollElement); + + if (element && (0,metabase_lib_dom__WEBPACK_IMPORTED_MODULE_10__.isObscured)(element)) { + element.scrollIntoView({ + block: "nearest" + }); + } + } // if we added a value then scroll to the last item (the input) + + + if (this.props.value.length > prevProps.value.length) { + if (input && (0,metabase_lib_dom__WEBPACK_IMPORTED_MODULE_10__.isObscured)(input)) { + input.scrollIntoView({ + block: "nearest" + }); + } + } // We focus on the input here, and not on the input itself as a prop + // (say by passing prop autoFocus={isFocused}) + // because certain TokenFields will live in position: fixed containers. + // Autofocusing like that would make the page jump in scroll position. + // One example: parameter filters in dashboard pages. + + + if (this.state.isFocused) { + input.focus({ + preventScroll: true + }); + } + } + }, { + key: "render", + value: function render() { + var _this5 = this; + + var _this$props5 = this.props, + value = _this$props5.value, + placeholder = _this$props5.placeholder, + multi = _this$props5.multi, + validateValue = _this$props5.validateValue, + parseFreeformValue = _this$props5.parseFreeformValue, + updateOnInputChange = _this$props5.updateOnInputChange, + optionRenderer = _this$props5.optionRenderer, + valueRenderer = _this$props5.valueRenderer, + layoutRenderer = _this$props5.layoutRenderer, + color = _this$props5.color, + style = _this$props5.style, + className = _this$props5.className, + valueStyle = _this$props5.valueStyle, + optionsStyle = _this$props5.optionsStyle, + optionsClassName = _this$props5.optionsClassName; + var _this$state4 = this.state, + inputValue = _this$state4.inputValue, + searchValue = _this$state4.searchValue, + filteredOptions = _this$state4.filteredOptions, + isFocused = _this$state4.isFocused, + isAllSelected = _this$state4.isAllSelected, + selectedOptionValue = _this$state4.selectedOptionValue; + + if (!multi && isFocused) { + inputValue = inputValue || value[0]; + value = []; + } // if we have a value and updateOnInputChange is enabled, and the last value matches the inputValue + + + if (value.length > 0 && updateOnInputChange && parseFreeformValue && value[value.length - 1] === parseFreeformValue(inputValue)) { + if (isFocused) { + // if focused, don't render the last value + value = value.slice(0, -1); + } else { + // if not focused, don't render the inputValue + inputValue = ""; + } + } // if not focused we won't get key events to accept the selected value, so don't render as selected + + + if (!isFocused) { + selectedOptionValue = null; + } // don't show the placeholder if we already have a value + + + if (value.length > 0) { + placeholder = null; + } + + var valuesList = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("ul", { + className: classnames__WEBPACK_IMPORTED_MODULE_4___default()(className, "pl1 pt1 pb0 pr0 flex flex-wrap bg-white scroll-x scroll-y"), + style: _objectSpread({ + maxHeight: 130 + }, style), + onMouseDownCapture: this.onMouseDownCapture + }, value.map(function (v, index) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_TokenField_styled__WEBPACK_IMPORTED_MODULE_8__.TokenFieldItem, { + key: index, + isValid: validateValue(v) + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { + style: _objectSpread(_objectSpread({}, defaultStyleValue), valueStyle), + className: multi ? "pl1 pr0" : "px1" + }, valueRenderer(v)), multi && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_TokenField_styled__WEBPACK_IMPORTED_MODULE_8__.TokenFieldAddon, { + isValid: validateValue(v), + onClick: function onClick(e) { + e.preventDefault(); + + _this5.removeValue(v); + }, + onMouseDown: function onMouseDown(e) { + return e.preventDefault(); + } + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Icon__WEBPACK_IMPORTED_MODULE_6__.default, { + name: "close", + className: "flex align-center", + size: 12 + }))); + }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("li", { + className: classnames__WEBPACK_IMPORTED_MODULE_4___default()("flex-full flex align-center mr1 mb1 p1") + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("input", { + ref: this.inputRef, + style: _objectSpread(_objectSpread({}, defaultStyleValue), valueStyle), + className: classnames__WEBPACK_IMPORTED_MODULE_4___default()("full no-focus borderless px1") // set size to be small enough that it fits in a parameter. + , + size: 10, + placeholder: placeholder, + value: inputValue, + onKeyDown: this.onInputKeyDown, + onChange: this.onInputChange, + onFocus: this.onInputFocus, + onBlur: this.onInputBlur, + onPaste: this.onInputPaste + }))); + var optionsList = filteredOptions.length === 0 ? null : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("ul", { + className: classnames__WEBPACK_IMPORTED_MODULE_4___default()(optionsClassName, "overflow-auto pl1 my1 scroll-hide"), + style: _objectSpread({ + maxHeight: 300 + }, optionsStyle), + onMouseEnter: function onMouseEnter() { + return _this5.setState({ + listIsHovered: true + }); + }, + onMouseLeave: function onMouseLeave() { + return _this5.setState({ + listIsHovered: false + }); + } + }, filteredOptions.map(function (option) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("li", { + className: "mr1", + key: _this5._key(option) + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: classnames__WEBPACK_IMPORTED_MODULE_4___default()("py1 pl1 pr2 block rounded text-bold text-".concat(color, "-hover inline-block full cursor-pointer"), "bg-light-hover", _defineProperty({}, "text-".concat(color, " bg-light"), !_this5.state.listIsHovered && _this5._valueIsEqual(selectedOptionValue, _this5._value(option)))), + onClick: function onClick(e) { + _this5.addOption(option); // clear the input value, and search value if last option + + + _this5.clearInputValue(filteredOptions.length === 1); + + e.preventDefault(); + }, + onMouseDown: function onMouseDown(e) { + return e.preventDefault(); + } + }, optionRenderer(option))); + })); + return layoutRenderer({ + valuesList: valuesList, + optionsList: optionsList, + isFocused: isFocused, + isAllSelected: isAllSelected, + isFiltered: !!searchValue, + onClose: this.onClose + }); + } + }]); + + return TokenField; +}(react__WEBPACK_IMPORTED_MODULE_0__.Component); + +_defineProperty(TokenField, "defaultProps", { + removeSelected: true, + valueKey: "value", + labelKey: "label", + valueRenderer: function valueRenderer(value) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", null, value); + }, + optionRenderer: function optionRenderer(option) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", null, option); + }, + layoutRenderer: function layoutRenderer(props) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(DefaultTokenFieldLayout, props); + }, + validateValue: function validateValue() { + return true; + }, + color: "brand", + style: {}, + valueStyle: {}, + optionsStyle: {} +}); + + + +var dedup = function dedup(array) { + return Array.from(new Set(array)); +}; + +var DefaultTokenFieldLayout = function DefaultTokenFieldLayout(_ref2) { + var valuesList = _ref2.valuesList, + optionsList = _ref2.optionsList, + isFocused = _ref2.isFocused, + onClose = _ref2.onClose; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_OnClickOutsideWrapper__WEBPACK_IMPORTED_MODULE_5__.default, { + handleDismissal: onClose + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", null, valuesList, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Popover__WEBPACK_IMPORTED_MODULE_7__.default, { + isOpen: isFocused && !!optionsList, + hasArrow: false, + tetherOptions: { + attachment: "top left", + targetAttachment: "bottom left", + targetOffset: "10 0" + } + }, optionsList))); +}; + +DefaultTokenFieldLayout.propTypes = { + valuesList: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().element.isRequired), + optionsList: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().element), + isFocused: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), + onClose: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func) +}; + +/***/ }), + +/***/ "./components/TokenField.styled.jsx": +/*!******************************************!*\ + !*** ./components/TokenField.styled.jsx ***! + \******************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "TokenFieldItem": function() { return /* binding */ TokenFieldItem; }, +/* harmony export */ "TokenFieldAddon": function() { return /* binding */ TokenFieldAddon; } +/* harmony export */ }); +/* harmony import */ var styled_components__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! styled-components */ "../../../node_modules/styled-components/dist/styled-components.browser.es.js"); +/* harmony import */ var metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/lib/colors */ "./lib/colors.ts"); + + +var TokenFieldItem = styled_components__WEBPACK_IMPORTED_MODULE_0__.default.li.withConfig({ + displayName: "TokenFieldstyled__TokenFieldItem", + componentId: "sc-5bzv7n-0" +})(["display:flex;align-items:center;margin:0 0.25rem 0.25rem 0;padding:0.75rem 0.5rem;border-radius:0.5rem;color:", ";background-color:", ";"], function (_ref) { + var isValid = _ref.isValid; + return isValid ? "" : (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.color)("error"); +}, (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.color)("bg-medium")); +var TokenFieldAddon = styled_components__WEBPACK_IMPORTED_MODULE_0__.default.a.withConfig({ + displayName: "TokenFieldstyled__TokenFieldAddon", + componentId: "sc-5bzv7n-1" +})(["display:flex;align-items:center;padding:0 0.5rem;color:", ";&:hover{color:", ";}"], function (_ref2) { + var isValid = _ref2.isValid; + return isValid ? "" : (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.color)("error"); +}, (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.color)("error")); + +/***/ }), + +/***/ "./components/Tooltip/Tooltip.tsx": +/*!****************************************!*\ + !*** ./components/Tooltip/Tooltip.tsx ***! + \****************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prop-types */ "../../../node_modules/prop-types/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var _tippyjs_react__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @tippyjs/react */ "../../../node_modules/@tippyjs/react/dist/tippy-react.esm.js"); +/* harmony import */ var react_is__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react-is */ "../../../node_modules/react-is/index.js"); +/* harmony import */ var metabase_lib_dom__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/lib/dom */ "./lib/dom.js"); +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + + + + + + +var TippyComponent = _tippyjs_react__WEBPACK_IMPORTED_MODULE_4__.default; +Tooltip.propTypes = { + tooltip: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().node), + children: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().node), + reference: prop_types__WEBPACK_IMPORTED_MODULE_1___default().instanceOf(Element), + placement: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string), + isEnabled: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), + isOpen: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), + offset: prop_types__WEBPACK_IMPORTED_MODULE_1___default().oneOfType([(prop_types__WEBPACK_IMPORTED_MODULE_1___default().array), (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func)]), + maxWidth: prop_types__WEBPACK_IMPORTED_MODULE_1___default().oneOfType([(prop_types__WEBPACK_IMPORTED_MODULE_1___default().number), (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string)]) +}; + +// checking to see if the `element` is in JSX.IntrinisicElements since they support refs +// tippy's `children` prop seems to complain about anything more specific that React.ReactElement, unfortunately +function isReactDOMTypeElement(element) { + return react_is__WEBPACK_IMPORTED_MODULE_2__.isElement(element) && typeof element.type === "string"; +} // Tippy relies on child nodes forwarding refs, so when `children` is neither +// a DOM element or a forwardRef, we need to wrap it in a span. + + +function getSafeChildren(children) { + if (isReactDOMTypeElement(children) || react_is__WEBPACK_IMPORTED_MODULE_2__.isForwardRef(children)) { + return children; + } else { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { + "data-testid": "tooltip-component-wrapper" + }, children); + } +} + +function getTargetProps(reference, children) { + if (reference) { + return { + reference: reference + }; + } else if (children != null) { + return { + children: getSafeChildren(children) + }; + } +} + +function Tooltip(_ref) { + var tooltip = _ref.tooltip, + children = _ref.children, + reference = _ref.reference, + placement = _ref.placement, + offset = _ref.offset, + isEnabled = _ref.isEnabled, + isOpen = _ref.isOpen, + _ref$maxWidth = _ref.maxWidth, + maxWidth = _ref$maxWidth === void 0 ? 200 : _ref$maxWidth; + var visible = isOpen != null ? isOpen : undefined; + var animationDuration = (0,metabase_lib_dom__WEBPACK_IMPORTED_MODULE_3__.isReducedMotionPreferred)() ? 0 : undefined; + var disabled = isEnabled === false; + var targetProps = getTargetProps(reference, children); + + if (tooltip && targetProps) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(TippyComponent, _extends({ + theme: "tooltip", + className: "popover", + appendTo: function appendTo() { + return document.body; + }, + content: tooltip, + visible: visible, + disabled: disabled, + maxWidth: maxWidth, + reference: reference, + duration: animationDuration, + placement: placement, + offset: offset + }, targetProps)); + } else { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, children); + } +} + +/* harmony default export */ __webpack_exports__["default"] = (Tooltip); + +/***/ }), + +/***/ "./components/Tooltip/index.ts": +/*!*************************************!*\ + !*** ./components/Tooltip/index.ts ***! + \*************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* reexport safe */ _Tooltip__WEBPACK_IMPORTED_MODULE_0__.default; } +/* harmony export */ }); +/* harmony import */ var _Tooltip__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Tooltip */ "./components/Tooltip/Tooltip.tsx"); + + +/***/ }), + +/***/ "./components/Triggerable.jsx": +/*!************************************!*\ + !*** ./components/Triggerable.jsx ***! + \************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var metabase_lib_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/lib/dom */ "./lib/dom.js"); +/* harmony import */ var _Tooltip__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Tooltip */ "./components/Tooltip/index.ts"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! classnames */ "../../../node_modules/classnames/index.js"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_3__); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/* eslint-disable react/prop-types */ + + + + // higher order component that takes a component which takes props "isOpen" and optionally "onClose" +// and returns a component that renders a element "trigger", and tracks whether that component is open or not + +/* harmony default export */ __webpack_exports__["default"] = (function (ComposedComponent) { + var _class, _temp; + + return _temp = _class = /*#__PURE__*/function (_Component) { + _inherits(_class, _Component); + + var _super = _createSuper(_class); + + function _class(props, context) { + var _this; + + _classCallCheck(this, _class); + + _this = _super.call(this, props, context); + _this.state = { + isOpen: props.isInitiallyOpen || false + }; + _this._startCheckObscured = _this._startCheckObscured.bind(_assertThisInitialized(_this)); + _this._stopCheckObscured = _this._stopCheckObscured.bind(_assertThisInitialized(_this)); + _this.onClose = _this.onClose.bind(_assertThisInitialized(_this)); + _this.trigger = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createRef(); + return _this; + } + + _createClass(_class, [{ + key: "open", + value: function open() { + this.toggle(true); + } + }, { + key: "close", + value: function close() { + this.toggle(false); + } + }, { + key: "toggle", + value: function toggle() { + var isOpen = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : !this.state.isOpen; + this.setState({ + isOpen: isOpen + }); + } + }, { + key: "onClose", + value: function onClose(e) { + // don't close if clicked the actual trigger, it will toggle + if (e && e.target && this.trigger.current.contains(e.target)) { + return; + } + + if (this.props.onClose) { + this.props.onClose(e); + } + + this.close(); + } + }, { + key: "target", + value: function target() { + if (this.props.target) { + return this.props.target(); + } else { + return this.trigger.current; + } + } + }, { + key: "componentDidMount", + value: function componentDidMount() { + this.componentDidUpdate(); + } + }, { + key: "componentDidUpdate", + value: function componentDidUpdate() { + if (this.state.isOpen && this.props.closeOnObscuredTrigger) { + this._startCheckObscured(); + } else { + this._stopCheckObscured(); + } + } + }, { + key: "componentWillUnmount", + value: function componentWillUnmount() { + this._stopCheckObscured(); + } + }, { + key: "_startCheckObscured", + value: function _startCheckObscured() { + var _this2 = this; + + if (this._offscreenTimer == null) { + this._offscreenTimer = setInterval(function () { + var trigger = _this2.trigger.current; + + if ((0,metabase_lib_dom__WEBPACK_IMPORTED_MODULE_1__.isObscured)(trigger)) { + _this2.close(); + } + }, 250); + } + } + }, { + key: "_stopCheckObscured", + value: function _stopCheckObscured() { + if (this._offscreenTimer != null) { + clearInterval(this._offscreenTimer); + this._offscreenTimer = null; + } + } + }, { + key: "render", + value: function render() { + var _this3 = this; + + var _this$props = this.props, + triggerId = _this$props.triggerId, + triggerClasses = _this$props.triggerClasses, + triggerStyle = _this$props.triggerStyle, + triggerClassesOpen = _this$props.triggerClassesOpen, + triggerClassesClose = _this$props.triggerClassesClose; + var isOpen = this.props.isOpen != null ? this.props.isOpen : this.state.isOpen; + var triggerElement = this.props.triggerElement; + + if (triggerElement && triggerElement.type === _Tooltip__WEBPACK_IMPORTED_MODULE_2__.default) { + // Disables tooltip when open: + triggerElement = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.cloneElement(triggerElement, { + isEnabled: triggerElement.props.isEnabled && !isOpen + }); + } + + var children = this.props.children; + + if (typeof children === "function" && isOpen) { + // if children is a render prop, pass onClose to it + children = children({ + onClose: this.onClose + }); + } else if (react__WEBPACK_IMPORTED_MODULE_0__.Children.count(children) === 1 && react__WEBPACK_IMPORTED_MODULE_0__.Children.only(children).props.onClose === undefined && typeof react__WEBPACK_IMPORTED_MODULE_0__.Children.only(children).type !== "string") { + // if we have a single child which isn't an HTML element and doesn't have an onClose prop go ahead and inject it directly + children = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.cloneElement(children, { + onClose: this.onClose + }); + } + + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("a", { + id: triggerId, + ref: this.trigger, + onClick: function onClick(event) { + event.preventDefault(); + !_this3.props.disabled && _this3.toggle(); + }, + className: classnames__WEBPACK_IMPORTED_MODULE_3___default()(triggerClasses, isOpen && triggerClassesOpen, !isOpen && triggerClassesClose, "no-decoration", { + "cursor-default": this.props.disabled + }), + "aria-disabled": this.props.disabled, + style: triggerStyle + }, typeof triggerElement === "function" ? triggerElement({ + isTriggeredComponentOpen: isOpen + }) : triggerElement, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(ComposedComponent, _extends({}, this.props, { + isOpen: isOpen, + onClose: this.onClose, + target: function target() { + return _this3.target(); + } + }), children)); + } + }]); + + return _class; + }(react__WEBPACK_IMPORTED_MODULE_0__.Component), _defineProperty(_class, "displayName", "Triggerable[" + (ComposedComponent.displayName || ComposedComponent.name) + "]"), _defineProperty(_class, "defaultProps", { + closeOnObscuredTrigger: false + }), _temp; +}); + +/***/ }), + +/***/ "./components/Value.jsx": +/*!******************************!*\ + !*** ./components/Value.jsx ***! + \******************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var metabase_containers_RemappedValue__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/containers/RemappedValue */ "./containers/RemappedValue.jsx"); +/* harmony import */ var metabase_lib_formatting__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/lib/formatting */ "./lib/formatting.js"); +var _excluded = ["value"]; + +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } + +function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } + +/* eslint-disable react/prop-types */ + + + + +var Value = function Value(_ref) { + var value = _ref.value, + options = _objectWithoutProperties(_ref, _excluded); + + if (options.hide) { + return null; + } + + if (options.remap) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_containers_RemappedValue__WEBPACK_IMPORTED_MODULE_1__.default, _extends({ + value: value + }, options)); + } + + var formatted = (0,metabase_lib_formatting__WEBPACK_IMPORTED_MODULE_2__.formatValue)(value, _objectSpread(_objectSpread({}, options), {}, { + jsx: true + })); + + if ( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.isValidElement(formatted)) { + return formatted; + } else { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", null, formatted); + } +}; + +/* harmony default export */ __webpack_exports__["default"] = (Value); + +/***/ }), + +/***/ "./components/form/CustomForm.jsx": +/*!****************************************!*\ + !*** ./components/form/CustomForm.jsx ***! + \****************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "CustomFormField": function() { return /* binding */ CustomFormField; }, +/* harmony export */ "CustomFormSubmit": function() { return /* binding */ CustomFormSubmit; }, +/* harmony export */ "CustomFormMessage": function() { return /* binding */ CustomFormMessage; }, +/* harmony export */ "CustomFormSection": function() { return /* binding */ CustomFormSection; }, +/* harmony export */ "CustomFormFooter": function() { return /* binding */ CustomFormFooter; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prop-types */ "../../../node_modules/prop-types/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var metabase_components_form_FormField__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/components/form/FormField */ "./components/form/FormField.jsx"); +/* harmony import */ var metabase_components_form_FormWidget__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/components/form/FormWidget */ "./components/form/FormWidget.jsx"); +/* harmony import */ var metabase_components_form_FormMessage__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! metabase/components/form/FormMessage */ "./components/form/FormMessage.jsx"); +/* harmony import */ var metabase_components_DisclosureTriangle__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! metabase/components/DisclosureTriangle */ "./components/DisclosureTriangle.jsx"); +/* harmony import */ var metabase_components_Button__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! metabase/components/Button */ "./components/Button.tsx"); +/* harmony import */ var metabase_components_ActionButton__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! metabase/components/ActionButton */ "./components/ActionButton.jsx"); +/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! underscore */ "../../../node_modules/underscore/modules/index-all.js"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! classnames */ "../../../node_modules/classnames/index.js"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_9___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_9__); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_10___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_10__); +/* harmony import */ var icepick__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! icepick */ "../../../node_modules/icepick/icepick.min.js"); +/* harmony import */ var icepick__WEBPACK_IMPORTED_MODULE_11___default = /*#__PURE__*/__webpack_require__.n(icepick__WEBPACK_IMPORTED_MODULE_11__); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +var _templateObject, _templateObject2, _templateObject3, _templateObject4; + +var _excluded = ["children"], + _excluded2 = ["collapsible"]; + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + +function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } + +function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } + +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/* eslint-disable react/prop-types */ + + + + + + + + + + + + + +var CustomForm = /*#__PURE__*/function (_React$Component) { + _inherits(CustomForm, _React$Component); + + var _super = _createSuper(CustomForm); + + function CustomForm() { + _classCallCheck(this, CustomForm); + + return _super.apply(this, arguments); + } + + _createClass(CustomForm, [{ + key: "getChildContext", + value: function getChildContext() { + var _this$props = this.props, + fields = _this$props.fields, + values = _this$props.values, + form = _this$props.formObject, + submitting = _this$props.submitting, + invalid = _this$props.invalid, + pristine = _this$props.pristine, + error = _this$props.error, + handleSubmit = _this$props.handleSubmit, + submitTitle = _this$props.submitTitle, + renderSubmit = _this$props.renderSubmit, + className = _this$props.className, + style = _this$props.style, + onChangeField = _this$props.onChangeField; + var disablePristineSubmit = form.disablePristineSubmit; + var formFields = form.fields(values); + + var formFieldsByName = underscore__WEBPACK_IMPORTED_MODULE_8__.default.indexBy(formFields, "name"); + + return { + handleSubmit: handleSubmit, + submitTitle: submitTitle, + renderSubmit: renderSubmit, + className: className, + style: style, + fields: fields, + formFields: formFields, + formFieldsByName: formFieldsByName, + values: values, + submitting: submitting, + invalid: invalid, + pristine: pristine, + error: error, + onChangeField: onChangeField, + disablePristineSubmit: disablePristineSubmit + }; + } + }, { + key: "render", + value: function render() { + var _this = this; + + var _this$props2 = this.props, + form = _this$props2.formObject, + values = _this$props2.values, + children = _this$props2.children; + + if (typeof children === "function") { + return children(_objectSpread(_objectSpread({}, this.props), {}, { + form: form, + formFields: form.fields(values), + Form: Form, + FormField: CustomFormField, + FormSubmit: CustomFormSubmit, + FormMessage: CustomFormMessage, + FormFooter: CustomFormFooter + })); + } else { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(Form, { + formRef: function formRef(form) { + return _this._formRef = form; + } + }, children); + } + } + }]); + + return CustomForm; +}(react__WEBPACK_IMPORTED_MODULE_0__.Component); + +_defineProperty(CustomForm, "childContextTypes", { + handleSubmit: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func), + submitTitle: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string), + renderSubmit: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func), + className: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string), + style: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().object), + fields: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().object), + formFields: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().array), + formFieldsByName: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().object), + values: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().object), + submitting: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), + invalid: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), + pristine: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), + error: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string), + onChangeField: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func), + disablePristineSubmit: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool) +}); + +var Form = function Form(_ref, _ref2) { + var children = _ref.children, + formRef = _ref.formRef; + var handleSubmit = _ref2.handleSubmit, + className = _ref2.className, + style = _ref2.style; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("form", { + onSubmit: handleSubmit, + ref: formRef, + className: className, + style: style + }, children); +}; + +Form.contextTypes = { + handleSubmit: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func), + className: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string), + style: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().object) +}; +var CustomFormField = /*#__PURE__*/function (_React$Component2) { + _inherits(CustomFormField, _React$Component2); + + var _super2 = _createSuper(CustomFormField); + + function CustomFormField() { + _classCallCheck(this, CustomFormField); + + return _super2.apply(this, arguments); + } + + _createClass(CustomFormField, [{ + key: "_getFieldDefinition", + value: function _getFieldDefinition() { + return underscore__WEBPACK_IMPORTED_MODULE_8__.default.pick(this.props, "name", "type", "title", "description", "initial", "validate", "normalize"); + } + }, { + key: "UNSAFE_componentWillMount", + value: function UNSAFE_componentWillMount() { + if (this.context.registerFormField) { + this.context.registerFormField(this._getFieldDefinition()); + } + } + }, { + key: "componentWillUnmount", + value: function componentWillUnmount() { + if (this.context.unregisterFormField) { + this.context.unregisterFormField(this._getFieldDefinition()); + } + } + }, { + key: "render", + value: function render() { + var name = this.props.name; + var _this$context = this.context, + fields = _this$context.fields, + formFieldsByName = _this$context.formFieldsByName, + values = _this$context.values, + onChangeField = _this$context.onChangeField; + var field = (0,icepick__WEBPACK_IMPORTED_MODULE_11__.getIn)(fields, name.split(".")); + var formField = formFieldsByName[name]; + + if (!field || !formField) { + return null; + } + + var props = _objectSpread(_objectSpread({}, this.props), {}, { + values: values, + onChangeField: onChangeField, + field: field, + formField: formField + }); + + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_form_FormField__WEBPACK_IMPORTED_MODULE_2__.default, props, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_form_FormWidget__WEBPACK_IMPORTED_MODULE_3__.default, props)); + } + }]); + + return CustomFormField; +}(react__WEBPACK_IMPORTED_MODULE_0__.Component); + +_defineProperty(CustomFormField, "contextTypes", { + fields: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().object), + formFieldsByName: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().object), + values: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().object), + onChangeField: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func), + registerFormField: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func), + unregisterFormField: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func) +}); + +var CustomFormSubmit = function CustomFormSubmit(_ref3, _ref4) { + var children = _ref3.children, + props = _objectWithoutProperties(_ref3, _excluded); + + var submitting = _ref4.submitting, + invalid = _ref4.invalid, + pristine = _ref4.pristine, + handleSubmit = _ref4.handleSubmit, + submitTitle = _ref4.submitTitle, + renderSubmit = _ref4.renderSubmit, + disablePristineSubmit = _ref4.disablePristineSubmit; + var title = children || submitTitle || (0,ttag__WEBPACK_IMPORTED_MODULE_10__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["Submit"]))); + var canSubmit = !(submitting || invalid || pristine && disablePristineSubmit); + + if (renderSubmit) { + return renderSubmit({ + canSubmit: canSubmit, + title: title, + handleSubmit: handleSubmit + }); + } else { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_ActionButton__WEBPACK_IMPORTED_MODULE_7__.default, _extends({ + normalText: title, + activeText: title, + failedText: (0,ttag__WEBPACK_IMPORTED_MODULE_10__.t)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["Failed"]))), + successText: (0,ttag__WEBPACK_IMPORTED_MODULE_10__.t)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["Success"]))), + primary: canSubmit, + disabled: !canSubmit + }, props, { + type: "submit", + actionFn: handleSubmit + })); + } +}; +CustomFormSubmit.contextTypes = { + values: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().object), + submitting: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), + invalid: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), + pristine: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), + handleSubmit: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func), + submitTitle: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string), + renderSubmit: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func), + disablePristineSubmit: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool) +}; +var CustomFormMessage = function CustomFormMessage(props, _ref5) { + var error = _ref5.error; + return error ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_form_FormMessage__WEBPACK_IMPORTED_MODULE_4__.default, { + message: error, + formError: true + }) : null; +}; +CustomFormMessage.contextTypes = { + error: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string) +}; +/* harmony default export */ __webpack_exports__["default"] = (CustomForm); + +var StandardSection = function StandardSection(_ref6) { + var title = _ref6.title, + children = _ref6.children; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("section", { + className: "mb4" + }, title && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("h2", { + className: "mb2" + }, title), children); +}; + +var CollapsibleSection = /*#__PURE__*/function (_React$Component3) { + _inherits(CollapsibleSection, _React$Component3); + + var _super3 = _createSuper(CollapsibleSection); + + function CollapsibleSection() { + var _this2; + + _classCallCheck(this, CollapsibleSection); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this2 = _super3.call.apply(_super3, [this].concat(args)); + + _defineProperty(_assertThisInitialized(_this2), "state", { + show: false + }); + + _defineProperty(_assertThisInitialized(_this2), "handleToggle", function () { + _this2.setState(function (previousState) { + return { + show: !previousState.show + }; + }); + }); + + return _this2; + } + + _createClass(CollapsibleSection, [{ + key: "render", + value: function render() { + var _this$props3 = this.props, + title = _this$props3.title, + children = _this$props3.children; + var show = this.state.show; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("section", { + className: "mb4" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "mb2 flex align-center cursor-pointer text-brand-hover", + onClick: this.handleToggle + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_DisclosureTriangle__WEBPACK_IMPORTED_MODULE_5__.default, { + className: "mr1", + open: show + }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("h3", null, title)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: show ? null : "hide" + }, children)); + } + }]); + + return CollapsibleSection; +}(react__WEBPACK_IMPORTED_MODULE_0__.Component); + +var CustomFormSection = function CustomFormSection(_ref7) { + var collapsible = _ref7.collapsible, + props = _objectWithoutProperties(_ref7, _excluded2); + + return collapsible ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(CollapsibleSection, props) : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(StandardSection, props); +}; +var CustomFormFooter = function CustomFormFooter(_ref8, _ref9) { + var submitTitle = _ref8.submitTitle, + _ref8$cancelTitle = _ref8.cancelTitle, + cancelTitle = _ref8$cancelTitle === void 0 ? (0,ttag__WEBPACK_IMPORTED_MODULE_10__.t)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["Cancel"]))) : _ref8$cancelTitle, + onCancel = _ref8.onCancel, + footerExtraButtons = _ref8.footerExtraButtons, + fullWidth = _ref8.fullWidth; + var isModal = _ref9.isModal; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: classnames__WEBPACK_IMPORTED_MODULE_9___default()("flex align-center", { + "flex-reverse": isModal + }) + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(CustomFormSubmit, { + fullWidth: fullWidth + }, submitTitle), onCancel && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Button__WEBPACK_IMPORTED_MODULE_6__.default, { + className: "mx1", + onClick: onCancel + }, cancelTitle), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "flex-full" + }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(CustomFormMessage, null), footerExtraButtons); +}; +CustomFormFooter.contextTypes = { + isModal: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool) +}; + +/***/ }), + +/***/ "./components/form/FormField.jsx": +/*!***************************************!*\ + !*** ./components/form/FormField.jsx ***! + \***************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prop-types */ "../../../node_modules/prop-types/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! classnames */ "../../../node_modules/classnames/index.js"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_2__); +/* harmony import */ var metabase_components_Tooltip__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/components/Tooltip */ "./components/Tooltip/index.ts"); +/* harmony import */ var _FormField_styled__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./FormField.styled */ "./components/form/FormField.styled.jsx"); +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + + + + + + +var formFieldCommon = { + title: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string), + description: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string), + descriptionPosition: prop_types__WEBPACK_IMPORTED_MODULE_1___default().oneOf(["top", "bottom"]), + info: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string), + hidden: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), + horizontal: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool) +}; + +var propTypes = _objectSpread(_objectSpread({}, formFieldCommon), {}, { + field: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().object), + formField: prop_types__WEBPACK_IMPORTED_MODULE_1___default().shape(_objectSpread(_objectSpread({}, formFieldCommon), {}, { + type: prop_types__WEBPACK_IMPORTED_MODULE_1___default().oneOfType([(prop_types__WEBPACK_IMPORTED_MODULE_1___default().string), (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func)]) + })), + // redux-form compatible: + name: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string), + error: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().any), + visited: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), + active: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), + children: prop_types__WEBPACK_IMPORTED_MODULE_1___default().oneOfType([prop_types__WEBPACK_IMPORTED_MODULE_1___default().arrayOf((prop_types__WEBPACK_IMPORTED_MODULE_1___default().node)), (prop_types__WEBPACK_IMPORTED_MODULE_1___default().node)]), + className: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string) +}); + +var ALL_DOT_CHARS = /\./g; + +function FormField(props) { + var className = props.className, + formField = props.formField, + _props$title = props.title, + title = _props$title === void 0 ? formField && formField.title : _props$title, + _props$description = props.description, + description = _props$description === void 0 ? formField && formField.description : _props$description, + _props$descriptionPos = props.descriptionPosition, + descriptionPosition = _props$descriptionPos === void 0 ? descriptionPosition || formField && formField.descriptionPosition || "top" : _props$descriptionPos, + _props$info = props.info, + info = _props$info === void 0 ? formField && formField.info : _props$info, + _props$hidden = props.hidden, + hidden = _props$hidden === void 0 ? formField && (formField.hidden || formField.type === "hidden") : _props$hidden, + _props$horizontal = props.horizontal, + horizontal = _props$horizontal === void 0 ? formField && (formField.horizontal || formField.type === "boolean") : _props$horizontal, + children = props.children; + + if (hidden) { + return null; + } + + var _props = _objectSpread(_objectSpread({}, props.field || {}), props), + name = _props.name, + error = _props.error, + visited = _props.visited, + active = _props.active; + + var formFieldId = "formField-".concat(name.replace(ALL_DOT_CHARS, "-")); + + if (!visited || active) { + // if the field hasn't been visited or is currently active then don't show the error + error = null; + } + + var rootClassNames = classnames__WEBPACK_IMPORTED_MODULE_2___default()("Form-field", className, { + "Form--fieldError": !!error, + flex: horizontal + }); + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + id: formFieldId, + className: rootClassNames + }, (title || description) && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_FormField_styled__WEBPACK_IMPORTED_MODULE_4__.FieldRow, null, title && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_FormField_styled__WEBPACK_IMPORTED_MODULE_4__.Label, { + id: "".concat(name, "-label"), + htmlFor: name, + horizontal: horizontal + }, title, error && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { + className: "text-error" + }, ": ", error)), info && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Tooltip__WEBPACK_IMPORTED_MODULE_3__.default, { + tooltip: info + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_FormField_styled__WEBPACK_IMPORTED_MODULE_4__.InfoIcon, null))), description && descriptionPosition === "top" && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "mb1" + }, description)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_FormField_styled__WEBPACK_IMPORTED_MODULE_4__.InputContainer, { + horizontal: horizontal + }, children), description && descriptionPosition === "bottom" && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "mt1" + }, description)); +} + +FormField.propTypes = propTypes; +/* harmony default export */ __webpack_exports__["default"] = (FormField); + +/***/ }), + +/***/ "./components/form/FormField.styled.jsx": +/*!**********************************************!*\ + !*** ./components/form/FormField.styled.jsx ***! + \**********************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "FieldRow": function() { return /* binding */ FieldRow; }, +/* harmony export */ "Label": function() { return /* binding */ Label; }, +/* harmony export */ "InfoIcon": function() { return /* binding */ InfoIcon; }, +/* harmony export */ "InputContainer": function() { return /* binding */ InputContainer; } +/* harmony export */ }); +/* harmony import */ var styled_components__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! styled-components */ "../../../node_modules/styled-components/dist/styled-components.browser.es.js"); +/* harmony import */ var metabase_components_Icon__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/components/Icon */ "./components/Icon.tsx"); +/* harmony import */ var metabase_lib_colors__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/lib/colors */ "./lib/colors.ts"); + + + +var FieldRow = styled_components__WEBPACK_IMPORTED_MODULE_0__.default.div.withConfig({ + displayName: "FormFieldstyled__FieldRow", + componentId: "j00asi-0" +})(["display:flex;align-items:center;margin-bottom:0.5em;"]); +var Label = styled_components__WEBPACK_IMPORTED_MODULE_0__.default.label.attrs({ + className: "Form-label" +}).withConfig({ + displayName: "FormFieldstyled__Label", + componentId: "j00asi-1" +})(["margin-bottom:0;", ""], function (props) { + return props.horizontal && (0,styled_components__WEBPACK_IMPORTED_MODULE_0__.css)(["margin-right:auto;"]); +}); +var InfoIcon = (0,styled_components__WEBPACK_IMPORTED_MODULE_0__.default)(metabase_components_Icon__WEBPACK_IMPORTED_MODULE_1__.default).attrs({ + name: "info", + size: 12 +}).withConfig({ + displayName: "FormFieldstyled__InfoIcon", + componentId: "j00asi-2" +})(["margin-left:8px;color:", ";&:hover{color:", ";}"], (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_2__.color)("bg-dark"), (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_2__.color)("brand")); +var InputContainer = styled_components__WEBPACK_IMPORTED_MODULE_0__.default.div.withConfig({ + displayName: "FormFieldstyled__InputContainer", + componentId: "j00asi-3" +})(["flex-shrink:0;", ""], function (props) { + return props.horizontal && (0,styled_components__WEBPACK_IMPORTED_MODULE_0__.css)(["margin-left:auto;"]); +}); + +/***/ }), + +/***/ "./components/form/FormMessage.jsx": +/*!*****************************************!*\ + !*** ./components/form/FormMessage.jsx ***! + \*****************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "SERVER_ERROR_MESSAGE": function() { return /* binding */ SERVER_ERROR_MESSAGE; }, +/* harmony export */ "UNKNOWN_ERROR_MESSAGE": function() { return /* binding */ UNKNOWN_ERROR_MESSAGE; }, +/* harmony export */ "default": function() { return /* binding */ FormMessage; }, +/* harmony export */ "getErrorMessage": function() { return /* binding */ getErrorMessage; }, +/* harmony export */ "getSuccessMessage": function() { return /* binding */ getSuccessMessage; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! classnames */ "../../../node_modules/classnames/index.js"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_2__); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +var _templateObject, _templateObject2; + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + +/* eslint-disable react/prop-types */ + + + +var SERVER_ERROR_MESSAGE = (0,ttag__WEBPACK_IMPORTED_MODULE_2__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["Server error encountered"]))); +var UNKNOWN_ERROR_MESSAGE = (0,ttag__WEBPACK_IMPORTED_MODULE_2__.t)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["Unknown error encountered"]))); + +var FormMessage = /*#__PURE__*/function (_Component) { + _inherits(FormMessage, _Component); + + var _super = _createSuper(FormMessage); + + function FormMessage() { + _classCallCheck(this, FormMessage); + + return _super.apply(this, arguments); + } + + _createClass(FormMessage, [{ + key: "render", + value: function render() { + var _this$props = this.props, + className = _this$props.className, + formError = _this$props.formError, + formSuccess = _this$props.formSuccess, + message = _this$props.message; + + if (!message) { + if (formError) { + message = getErrorMessage(formError); + } else if (formSuccess) { + message = getSuccessMessage(formSuccess); + } + } + + var classes = classnames__WEBPACK_IMPORTED_MODULE_1___default()("Form-message", "px2", className, { + "Form-message--visible": !!message, + "text-success": formSuccess, + "text-error": formError + }); + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { + className: classes + }, message); + } + }]); + + return FormMessage; +}(react__WEBPACK_IMPORTED_MODULE_0__.Component); + + +var getErrorMessage = function getErrorMessage(formError) { + if (formError) { + if (formError.data && formError.data.message) { + return formError.data.message; + } else if (formError.status >= 400) { + return SERVER_ERROR_MESSAGE; + } else { + return UNKNOWN_ERROR_MESSAGE; + } + } +}; +var getSuccessMessage = function getSuccessMessage(formSuccess) { + if (formSuccess && formSuccess.data.message) { + return formSuccess.data.message; + } +}; + +/***/ }), + +/***/ "./components/form/FormWidget.jsx": +/*!****************************************!*\ + !*** ./components/form/FormWidget.jsx ***! + \****************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var metabase_plugins__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/plugins */ "./plugins/index.js"); +/* harmony import */ var _widgets_FormInfoWidget__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./widgets/FormInfoWidget */ "./components/form/widgets/FormInfoWidget.jsx"); +/* harmony import */ var _widgets_FormInputWidget__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./widgets/FormInputWidget */ "./components/form/widgets/FormInputWidget.jsx"); +/* harmony import */ var _widgets_FormEmailWidget__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./widgets/FormEmailWidget */ "./components/form/widgets/FormEmailWidget.jsx"); +/* harmony import */ var _widgets_FormTextAreaWidget__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./widgets/FormTextAreaWidget */ "./components/form/widgets/FormTextAreaWidget.jsx"); +/* harmony import */ var _widgets_FormPasswordWidget__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./widgets/FormPasswordWidget */ "./components/form/widgets/FormPasswordWidget.jsx"); +/* harmony import */ var _widgets_FormRadioWidget__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./widgets/FormRadioWidget */ "./components/form/widgets/FormRadioWidget.jsx"); +/* harmony import */ var _widgets_FormCheckBoxWidget__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./widgets/FormCheckBoxWidget */ "./components/form/widgets/FormCheckBoxWidget.jsx"); +/* harmony import */ var _widgets_FormColorWidget__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./widgets/FormColorWidget */ "./components/form/widgets/FormColorWidget.jsx"); +/* harmony import */ var _widgets_FormSectionWidget__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./widgets/FormSectionWidget */ "./components/form/widgets/FormSectionWidget.jsx"); +/* harmony import */ var _widgets_FormSelectWidget__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./widgets/FormSelectWidget */ "./components/form/widgets/FormSelectWidget.jsx"); +/* harmony import */ var _widgets_FormNumericInputWidget__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./widgets/FormNumericInputWidget */ "./components/form/widgets/FormNumericInputWidget.jsx"); +/* harmony import */ var _widgets_FormBooleanWidget__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./widgets/FormBooleanWidget */ "./components/form/widgets/FormBooleanWidget.jsx"); +/* harmony import */ var _widgets_FormCollectionWidget__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./widgets/FormCollectionWidget */ "./components/form/widgets/FormCollectionWidget.jsx"); +/* harmony import */ var _widgets_FormSnippetCollectionWidget__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./widgets/FormSnippetCollectionWidget */ "./components/form/widgets/FormSnippetCollectionWidget.jsx"); +/* harmony import */ var _widgets_FormHiddenWidget__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./widgets/FormHiddenWidget */ "./components/form/widgets/FormHiddenWidget.jsx"); +/* harmony import */ var _widgets_FormTextFileWidget__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./widgets/FormTextFileWidget */ "./components/form/widgets/FormTextFileWidget.jsx"); +var _excluded = ["field", "formField"]; + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } + +function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } + +/* eslint-disable react/prop-types */ + + + + + + + + + + + + + + + + + + +var WIDGETS = { + info: _widgets_FormInfoWidget__WEBPACK_IMPORTED_MODULE_2__.default, + input: _widgets_FormInputWidget__WEBPACK_IMPORTED_MODULE_3__.default, + email: _widgets_FormEmailWidget__WEBPACK_IMPORTED_MODULE_4__.default, + text: _widgets_FormTextAreaWidget__WEBPACK_IMPORTED_MODULE_5__.default, + checkbox: _widgets_FormCheckBoxWidget__WEBPACK_IMPORTED_MODULE_8__.default, + color: _widgets_FormColorWidget__WEBPACK_IMPORTED_MODULE_9__.default, + password: _widgets_FormPasswordWidget__WEBPACK_IMPORTED_MODULE_6__.default, + radio: _widgets_FormRadioWidget__WEBPACK_IMPORTED_MODULE_7__.default, + section: _widgets_FormSectionWidget__WEBPACK_IMPORTED_MODULE_10__.default, + select: _widgets_FormSelectWidget__WEBPACK_IMPORTED_MODULE_11__.default, + integer: _widgets_FormNumericInputWidget__WEBPACK_IMPORTED_MODULE_12__.default, + boolean: _widgets_FormBooleanWidget__WEBPACK_IMPORTED_MODULE_13__.default, + collection: _widgets_FormCollectionWidget__WEBPACK_IMPORTED_MODULE_14__.default, + snippetCollection: _widgets_FormSnippetCollectionWidget__WEBPACK_IMPORTED_MODULE_15__.default, + hidden: _widgets_FormHiddenWidget__WEBPACK_IMPORTED_MODULE_16__.default, + textFile: _widgets_FormTextFileWidget__WEBPACK_IMPORTED_MODULE_17__.default +}; + +function getWidgetComponent(formField) { + if (typeof formField.type === "string") { + var widget = WIDGETS[formField.type] || metabase_plugins__WEBPACK_IMPORTED_MODULE_1__.PLUGIN_FORM_WIDGETS[formField.type]; + return widget || _widgets_FormInputWidget__WEBPACK_IMPORTED_MODULE_3__.default; + } + + return formField.type || _widgets_FormInputWidget__WEBPACK_IMPORTED_MODULE_3__.default; +} + +var FormWidget = function FormWidget(_ref) { + var field = _ref.field, + formField = _ref.formField, + props = _objectWithoutProperties(_ref, _excluded); + + var Widget = getWidgetComponent(formField); + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(Widget, _extends({ + field: field + }, formField, props)); +}; + +/* harmony default export */ __webpack_exports__["default"] = (FormWidget); + +/***/ }), + +/***/ "./components/form/StandardForm.jsx": +/*!******************************************!*\ + !*** ./components/form/StandardForm.jsx ***! + \******************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var _CustomForm__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./CustomForm */ "./components/form/CustomForm.jsx"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_2__); +var _templateObject, _templateObject2; + +var _excluded = ["onClose", "submitTitle", "submitFullWidth"]; + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + +function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } + +function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } + +/* eslint-disable react/prop-types */ + + + + +var StandardForm = function StandardForm(_ref) { + var onClose = _ref.onClose, + submitTitle = _ref.submitTitle, + submitFullWidth = _ref.submitFullWidth, + props = _objectWithoutProperties(_ref, _excluded); + + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_CustomForm__WEBPACK_IMPORTED_MODULE_1__.default, props, function (_ref2) { + var values = _ref2.values, + formFields = _ref2.formFields, + Form = _ref2.Form, + FormField = _ref2.FormField, + FormFooter = _ref2.FormFooter; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(Form, null, formFields.map(function (formField) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(FormField, { + key: formField.name, + name: formField.name + }); + }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(FormFooter, { + footerExtraButtons: props.footerExtraButtons, + onCancel: onClose, + submitTitle: submitTitle || (values.id != null ? (0,ttag__WEBPACK_IMPORTED_MODULE_2__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["Update"]))) : (0,ttag__WEBPACK_IMPORTED_MODULE_2__.t)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["Create"])))), + fullWidth: submitFullWidth + })); + }); +}; + +/* harmony default export */ __webpack_exports__["default"] = (StandardForm); + +/***/ }), + +/***/ "./components/form/widgets/FormBooleanWidget.jsx": +/*!*******************************************************!*\ + !*** ./components/form/widgets/FormBooleanWidget.jsx ***! + \*******************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var metabase_components_Toggle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/components/Toggle */ "./components/Toggle/index.ts"); +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +/* eslint-disable react/prop-types */ + + + +var FormBooleanWidget = function FormBooleanWidget(_ref) { + var field = _ref.field; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Toggle__WEBPACK_IMPORTED_MODULE_1__.default, _extends({ + "aria-labelledby": "".concat(field.name, "-label"), + "aria-checked": field.value, + role: "switch" + }, field)); +}; + +/* harmony default export */ __webpack_exports__["default"] = (FormBooleanWidget); + +/***/ }), + +/***/ "./components/form/widgets/FormCheckBoxWidget.jsx": +/*!********************************************************!*\ + !*** ./components/form/widgets/FormCheckBoxWidget.jsx ***! + \********************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var metabase_components_CheckBox__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! metabase/components/CheckBox */ "./components/CheckBox.jsx"); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var metabase_lib_redux__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/lib/redux */ "./lib/redux.js"); +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +/* eslint-disable react/prop-types */ + + + + +var FormCheckBoxWidget = function FormCheckBoxWidget(_ref) { + var field = _ref.field; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1__.createElement(metabase_components_CheckBox__WEBPACK_IMPORTED_MODULE_0__.default, _extends({}, (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_2__.formDomOnlyProps)(field), { + onChange: function onChange(e) { + return field.onChange(e.target.checked); + } + })); +}; + +/* harmony default export */ __webpack_exports__["default"] = (FormCheckBoxWidget); + +/***/ }), + +/***/ "./components/form/widgets/FormCollectionWidget.jsx": +/*!**********************************************************!*\ + !*** ./components/form/widgets/FormCollectionWidget.jsx ***! + \**********************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var metabase_containers_CollectionSelect__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/containers/CollectionSelect */ "./containers/CollectionSelect.jsx"); +/* eslint-disable react/prop-types */ + + + +var FormCollectionWidget = function FormCollectionWidget(_ref) { + var field = _ref.field; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_containers_CollectionSelect__WEBPACK_IMPORTED_MODULE_1__.default, field); +}; + +/* harmony default export */ __webpack_exports__["default"] = (FormCollectionWidget); + +/***/ }), + +/***/ "./components/form/widgets/FormColorWidget.jsx": +/*!*****************************************************!*\ + !*** ./components/form/widgets/FormColorWidget.jsx ***! + \*****************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var metabase_components_ColorPicker__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/components/ColorPicker */ "./components/ColorPicker.jsx"); +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +/* eslint-disable react/prop-types */ + + + +var FormColorWidget = function FormColorWidget(_ref) { + var field = _ref.field, + initial = _ref.initial; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_ColorPicker__WEBPACK_IMPORTED_MODULE_1__.default, _extends({}, field, { + value: // if the field has a value use that, otherwise use the initial + field.value || initial() + }))); +}; + +/* harmony default export */ __webpack_exports__["default"] = (FormColorWidget); + +/***/ }), + +/***/ "./components/form/widgets/FormEmailWidget.jsx": +/*!*****************************************************!*\ + !*** ./components/form/widgets/FormEmailWidget.jsx ***! + \*****************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var _FormInputWidget__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./FormInputWidget */ "./components/form/widgets/FormInputWidget.jsx"); +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + + + + +var FormEmailWidget = function FormEmailWidget(props) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_FormInputWidget__WEBPACK_IMPORTED_MODULE_1__.default, _extends({}, props, { + type: "email" + })); +}; + +/* harmony default export */ __webpack_exports__["default"] = (FormEmailWidget); + +/***/ }), + +/***/ "./components/form/widgets/FormGroupsWidget.jsx": +/*!******************************************************!*\ + !*** ./components/form/widgets/FormGroupsWidget.jsx ***! + \******************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var metabase_admin_people_components_GroupSelect__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/admin/people/components/GroupSelect */ "./admin/people/components/GroupSelect.jsx"); +/* harmony import */ var metabase_components_Toggle__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/components/Toggle */ "./components/Toggle/index.ts"); +/* harmony import */ var metabase_entities_groups__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/entities/groups */ "./entities/groups.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_4__); +/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! underscore */ "../../../node_modules/underscore/modules/index-all.js"); +/* harmony import */ var metabase_lib_groups__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! metabase/lib/groups */ "./lib/groups.js"); +var _templateObject; + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + +/* eslint-disable react/prop-types */ + + + + + + + + +var FormGroupsWidget = function FormGroupsWidget(_ref) { + var _ref$field = _ref.field, + value = _ref$field.value, + onChange = _ref$field.onChange, + groups = _ref.groups; + + var adminGroup = underscore__WEBPACK_IMPORTED_MODULE_5__.default.find(groups, metabase_lib_groups__WEBPACK_IMPORTED_MODULE_6__.isAdminGroup); + + var defaultGroup = underscore__WEBPACK_IMPORTED_MODULE_5__.default.find(groups, metabase_lib_groups__WEBPACK_IMPORTED_MODULE_6__.isDefaultGroup); + + if (!value) { + value = [defaultGroup.id]; + } + + var selection = new Set(value); + + function onGroupChange(group, selected) { + var newSelection = new Set(selection); + + if (selected) { + newSelection.add(group.id); + } else { + newSelection.delete(group.id); + } + + onChange(Array.from(newSelection)); + } + + var visibleGroups = underscore__WEBPACK_IMPORTED_MODULE_5__.default.filter(groups, function (g) { + return (0,metabase_lib_groups__WEBPACK_IMPORTED_MODULE_6__.canEditMembership)(g) || (0,metabase_lib_groups__WEBPACK_IMPORTED_MODULE_6__.isDefaultGroup)(g); + }); + + var hadAdminGroup = !!adminGroup; + + var hasNonAdminEditableGroups = underscore__WEBPACK_IMPORTED_MODULE_5__.default.any(groups, function (g) { + return (0,metabase_lib_groups__WEBPACK_IMPORTED_MODULE_6__.canEditMembership)(g) && !(0,metabase_lib_groups__WEBPACK_IMPORTED_MODULE_6__.isAdminGroup)(g); + }); + + return hasNonAdminEditableGroups ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_admin_people_components_GroupSelect__WEBPACK_IMPORTED_MODULE_1__.default, { + groups: visibleGroups, + selectedGroupIds: value, + onGroupChange: onGroupChange + }) : hadAdminGroup ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "flex align-center" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Toggle__WEBPACK_IMPORTED_MODULE_2__.default, { + value: selection.has(adminGroup.id), + onChange: function onChange(isAdmin) { + onGroupChange(adminGroup, isAdmin); + } + }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { + className: "ml2" + }, (0,ttag__WEBPACK_IMPORTED_MODULE_4__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["Make this user an admin"]))))) : null; +}; + +/* harmony default export */ __webpack_exports__["default"] = (metabase_entities_groups__WEBPACK_IMPORTED_MODULE_3__.default.loadList()(FormGroupsWidget)); + +/***/ }), + +/***/ "./components/form/widgets/FormHiddenWidget.jsx": +/*!******************************************************!*\ + !*** ./components/form/widgets/FormHiddenWidget.jsx ***! + \******************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var metabase_lib_redux__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/lib/redux */ "./lib/redux.js"); +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +/* eslint-disable react/prop-types */ + + + +var FormHiddenWidget = function FormHiddenWidget(_ref) { + var _ref$type = _ref.type, + type = _ref$type === void 0 ? "hidden" : _ref$type, + field = _ref.field; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("input", _extends({ + type: type + }, (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_1__.formDomOnlyProps)(field))); +}; + +/* harmony default export */ __webpack_exports__["default"] = (FormHiddenWidget); + +/***/ }), + +/***/ "./components/form/widgets/FormInfoWidget.jsx": +/*!****************************************************!*\ + !*** ./components/form/widgets/FormInfoWidget.jsx ***! + \****************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prop-types */ "../../../node_modules/prop-types/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var metabase_components_Banner__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/components/Banner */ "./components/Banner/index.js"); + + + +var propTypes = { + placeholder: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string) +}; + +var FormInfoWidget = function FormInfoWidget(_ref) { + var placeholder = _ref.placeholder; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Banner__WEBPACK_IMPORTED_MODULE_2__.default, null, placeholder); +}; + +FormInfoWidget.propTypes = propTypes; +/* harmony default export */ __webpack_exports__["default"] = (FormInfoWidget); + +/***/ }), + +/***/ "./components/form/widgets/FormInputWidget.jsx": +/*!*****************************************************!*\ + !*** ./components/form/widgets/FormInputWidget.jsx ***! + \*****************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prop-types */ "../../../node_modules/prop-types/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var metabase_lib_redux__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/lib/redux */ "./lib/redux.js"); +/* harmony import */ var metabase_components_Input_Input__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/components/Input/Input */ "./components/Input/Input.tsx"); +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + + + + + // Important: do NOT use this as an input of type="file" +// For file inputs, See component FormTextFileWidget.jsx + +var propTypes = { + type: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string), + placeholder: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string), + field: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().object), + readOnly: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), + autoFocus: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), + helperText: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().node) +}; + +var FormInputWidget = function FormInputWidget(_ref) { + var _ref$type = _ref.type, + type = _ref$type === void 0 ? "text" : _ref$type, + placeholder = _ref.placeholder, + field = _ref.field, + readOnly = _ref.readOnly, + autoFocus = _ref.autoFocus, + helperText = _ref.helperText; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Input_Input__WEBPACK_IMPORTED_MODULE_3__.default, _extends({}, (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_2__.formDomOnlyProps)(field), { + type: type, + placeholder: placeholder, + "aria-labelledby": "".concat(field.name, "-label"), + readOnly: readOnly, + autoFocus: autoFocus, + error: field.visited && !field.active && field.error != null, + helperText: helperText, + fullWidth: true + })); +}; + +FormInputWidget.propTypes = propTypes; +/* harmony default export */ __webpack_exports__["default"] = (FormInputWidget); + +/***/ }), + +/***/ "./components/form/widgets/FormNumericInputWidget.jsx": +/*!************************************************************!*\ + !*** ./components/form/widgets/FormNumericInputWidget.jsx ***! + \************************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var metabase_lib_redux__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/lib/redux */ "./lib/redux.js"); +/* harmony import */ var metabase_components_NumericInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/components/NumericInput */ "./components/NumericInput.jsx"); +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +/* eslint-disable react/prop-types */ + + + + +var FormInputWidget = function FormInputWidget(_ref) { + var placeholder = _ref.placeholder, + field = _ref.field; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_NumericInput__WEBPACK_IMPORTED_MODULE_2__.default, _extends({ + className: "Form-input full", + placeholder: placeholder, + "aria-labelledby": "".concat(field.name, "-label") + }, (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_1__.formDomOnlyProps)(field))); +}; + +/* harmony default export */ __webpack_exports__["default"] = (FormInputWidget); + +/***/ }), + +/***/ "./components/form/widgets/FormPasswordWidget.jsx": +/*!********************************************************!*\ + !*** ./components/form/widgets/FormPasswordWidget.jsx ***! + \********************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var _FormInputWidget__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./FormInputWidget */ "./components/form/widgets/FormInputWidget.jsx"); +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + + + + +var FormPasswordWidget = function FormPasswordWidget(props) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_FormInputWidget__WEBPACK_IMPORTED_MODULE_1__.default, _extends({}, props, { + type: "password" + })); +}; + +/* harmony default export */ __webpack_exports__["default"] = (FormPasswordWidget); + +/***/ }), + +/***/ "./components/form/widgets/FormRadioWidget.jsx": +/*!*****************************************************!*\ + !*** ./components/form/widgets/FormRadioWidget.jsx ***! + \*****************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prop-types */ "../../../node_modules/prop-types/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var styled_components__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! styled-components */ "../../../node_modules/styled-components/dist/styled-components.browser.es.js"); +/* harmony import */ var metabase_components_Radio__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/components/Radio */ "./components/Radio.jsx"); +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + + + + + +var StyledRadio = (0,styled_components__WEBPACK_IMPORTED_MODULE_2__.default)(metabase_components_Radio__WEBPACK_IMPORTED_MODULE_3__.default).withConfig({ + displayName: "FormRadioWidget__StyledRadio", + componentId: "sc-8tgeqb-0" +})(["font-weight:bold;"]); +var propTypes = { + field: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().object.isRequired), + options: prop_types__WEBPACK_IMPORTED_MODULE_1___default().arrayOf(metabase_components_Radio__WEBPACK_IMPORTED_MODULE_3__.optionShape).isRequired +}; + +function FormRadioWidget(_ref) { + var field = _ref.field, + options = _ref.options; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(StyledRadio, _extends({ + showButtons: true, + vertical: true + }, field, { + options: options + })); +} + +FormRadioWidget.propTypes = propTypes; +/* harmony default export */ __webpack_exports__["default"] = (FormRadioWidget); + +/***/ }), + +/***/ "./components/form/widgets/FormSectionWidget.jsx": +/*!*******************************************************!*\ + !*** ./components/form/widgets/FormSectionWidget.jsx ***! + \*******************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prop-types */ "../../../node_modules/prop-types/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_2__); +/* harmony import */ var metabase_components_Expander__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/components/Expander */ "./components/Expander/index.js"); +var _templateObject, _templateObject2; + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + + + + + +var propTypes = { + field: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().object.isRequired) +}; + +var FormSectionWidget = function FormSectionWidget(_ref) { + var field = _ref.field; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Expander__WEBPACK_IMPORTED_MODULE_3__.default, { + isExpanded: field.value, + onChange: field.onChange + }, field.value ? (0,ttag__WEBPACK_IMPORTED_MODULE_2__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["Hide advanced options"]))) : (0,ttag__WEBPACK_IMPORTED_MODULE_2__.t)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["Show advanced options"])))); +}; + +FormSectionWidget.propTypes = propTypes; +/* harmony default export */ __webpack_exports__["default"] = (FormSectionWidget); + +/***/ }), + +/***/ "./components/form/widgets/FormSelectWidget.jsx": +/*!******************************************************!*\ + !*** ./components/form/widgets/FormSelectWidget.jsx ***! + \******************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var metabase_components_Select__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/components/Select */ "./components/Select.jsx"); +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +/* eslint-disable react/prop-types */ + + + +var FormSelectWidget = function FormSelectWidget(_ref) { + var placeholder = _ref.placeholder, + _ref$options = _ref.options, + options = _ref$options === void 0 ? [] : _ref$options, + field = _ref.field; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Select__WEBPACK_IMPORTED_MODULE_1__.default, _extends({ + placeholder: placeholder + }, field, { + // react-redux expects to be raw value + onChange: function onChange(e) { + return field.onChange(e.target.value); + }, + buttonProps: { + style: { + minWidth: 200 + } + } + }), options.map(function (_ref2) { + var name = _ref2.name, + value = _ref2.value; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Select__WEBPACK_IMPORTED_MODULE_1__.Option, { + key: value, + value: value + }, name); + })); +}; + +/* harmony default export */ __webpack_exports__["default"] = (FormSelectWidget); + +/***/ }), + +/***/ "./components/form/widgets/FormSnippetCollectionWidget.jsx": +/*!*****************************************************************!*\ + !*** ./components/form/widgets/FormSnippetCollectionWidget.jsx ***! + \*****************************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var metabase_containers_ItemSelect__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/containers/ItemSelect */ "./containers/ItemSelect.jsx"); +/* harmony import */ var metabase_containers_CollectionPicker__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/containers/CollectionPicker */ "./containers/CollectionPicker.jsx"); +/* harmony import */ var metabase_entities_collections__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/entities/collections */ "./entities/collections.js"); +/* harmony import */ var metabase_entities_snippet_collections__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! metabase/entities/snippet-collections */ "./entities/snippet-collections.js"); +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +/* eslint-disable react/prop-types */ + + + + + +var CollectionSelect = (0,metabase_containers_ItemSelect__WEBPACK_IMPORTED_MODULE_1__.default)(metabase_containers_CollectionPicker__WEBPACK_IMPORTED_MODULE_2__.default, metabase_entities_snippet_collections__WEBPACK_IMPORTED_MODULE_4__.default.Name, "collection"); + +var FormSnippetCollectionWidget = function FormSnippetCollectionWidget(_ref) { + var field = _ref.field; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(CollectionSelect, _extends({ + entity: metabase_entities_snippet_collections__WEBPACK_IMPORTED_MODULE_4__.default, + showSearch: false // seems that search endpoint doesn't support namespace yet + + }, field, { + value: field.value || metabase_entities_collections__WEBPACK_IMPORTED_MODULE_3__.ROOT_COLLECTION.id // needed so SnippetCollections.Name finds the right collection + + })); +}; + +/* harmony default export */ __webpack_exports__["default"] = (FormSnippetCollectionWidget); + +/***/ }), + +/***/ "./components/form/widgets/FormTextAreaWidget.jsx": +/*!********************************************************!*\ + !*** ./components/form/widgets/FormTextAreaWidget.jsx ***! + \********************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! classnames */ "../../../node_modules/classnames/index.js"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var metabase_lib_redux__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/lib/redux */ "./lib/redux.js"); +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +/* eslint-disable react/prop-types */ + + + + +var FormTextAreaWidget = function FormTextAreaWidget(_ref) { + var placeholder = _ref.placeholder, + field = _ref.field, + className = _ref.className, + rows = _ref.rows, + autoFocus = _ref.autoFocus; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("textarea", _extends({ + autoFocus: autoFocus, + className: classnames__WEBPACK_IMPORTED_MODULE_1___default()(className, "Form-input full"), + rows: rows, + placeholder: placeholder, + "aria-labelledby": "".concat(field.name, "-label") + }, (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_2__.formDomOnlyProps)(field))); +}; + +/* harmony default export */ __webpack_exports__["default"] = (FormTextAreaWidget); + +/***/ }), + +/***/ "./components/form/widgets/FormTextFileWidget.jsx": +/*!********************************************************!*\ + !*** ./components/form/widgets/FormTextFileWidget.jsx ***! + \********************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! classnames */ "../../../node_modules/classnames/index.js"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var metabase_lib_redux__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/lib/redux */ "./lib/redux.js"); +var _excluded = ["value"]; + +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } + +function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } + +function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } + +function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } + +/* eslint-disable react/prop-types */ + + + // This is a special-case widget +// setting value on a file input widget throws an error + +var FormTextFileWidget = function FormTextFileWidget(_ref) { + var field = _ref.field, + treatBeforePosting = _ref.treatBeforePosting; + + var _formDomOnlyProps = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_2__.formDomOnlyProps)(field), + value = _formDomOnlyProps.value, + otherProps = _objectWithoutProperties(_formDomOnlyProps, _excluded); + + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("input", _extends({ + type: "file", + className: classnames__WEBPACK_IMPORTED_MODULE_1___default()({ + "Form-file-input--has-value": value + }, "Form-file-input full"), + "aria-labelledby": "".concat(field.name, "-label") + }, otherProps, { + onChange: wrapHandler(field.onChange, treatBeforePosting), + onBlur: wrapHandler(field.onBlur, treatBeforePosting) + })); +}; + +function wrapHandler(h, treatBeforePosting) { + return function (_ref2) { + var files = _ref2.target.files; + + if (files.length === 0) { + h(""); + } + + var fr = new FileReader(); + + fr.onload = function () { + return h(fr.result); + }; + + var _files = _slicedToArray(files, 1), + file = _files[0]; + + if (treatBeforePosting === "base64") { + fr.readAsDataURL(file); + } else { + fr.readAsText(file); + } + }; +} + +/* harmony default export */ __webpack_exports__["default"] = (FormTextFileWidget); + +/***/ }), + +/***/ "./components/icons/ClockIcon.jsx": +/*!****************************************!*\ + !*** ./components/icons/ClockIcon.jsx ***! + \****************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* eslint-disable react/prop-types */ + + +var ClockIcon = function ClockIcon(_ref) { + var _ref$hour = _ref.hour, + hour = _ref$hour === void 0 ? 12 : _ref$hour, + _ref$minute = _ref.minute, + minute = _ref$minute === void 0 ? 40 : _ref$minute, + _ref$width = _ref.width, + width = _ref$width === void 0 ? 20 : _ref$width, + _ref$height = _ref.height, + height = _ref$height === void 0 ? 20 : _ref$height, + className = _ref.className; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("svg", { + width: width, + height: height, + className: className, + viewBox: "0 0 20 20", + version: "1.1", + xmlns: "http://www.w3.org/2000/svg" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("circle", { + cx: "10", + cy: "10", + r: "10", + fill: "currentColor" + }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("line", { + x1: "10", + y1: "10", + x2: "10", + y2: "5", + stroke: "white", + strokeWidth: 2, + strokeLinecap: "round", + transform: "rotate(".concat(hour % 12 / 12 * 360, " 10 10)") + }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("line", { + x1: "10", + y1: "10", + x2: "10", + y2: "6", + stroke: "white", + strokeWidth: 2, + strokeLinecap: "round", + transform: "rotate(".concat(minute % 60 / 60 * 360, " 10 10)") + })); +}; + +/* harmony default export */ __webpack_exports__["default"] = (ClockIcon); + +/***/ }), + +/***/ "./components/icons/CountdownIcon.jsx": +/*!********************************************!*\ + !*** ./components/icons/CountdownIcon.jsx ***! + \********************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* eslint-disable react/prop-types */ + + +var CountdownIcon = function CountdownIcon(_ref) { + var _ref$percent = _ref.percent, + percent = _ref$percent === void 0 ? 0.75 : _ref$percent, + _ref$width = _ref.width, + width = _ref$width === void 0 ? 20 : _ref$width, + _ref$height = _ref.height, + height = _ref$height === void 0 ? 20 : _ref$height, + className = _ref.className; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("svg", { + width: width, + height: height, + className: className, + viewBox: "0 0 32 32", + style: { + transform: "rotate(-" + (percent * 360 + 90) + "deg)", + borderRadius: "50%" + } + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("circle", { + r: "16", + cx: "16", + cy: "16", + fill: "currentColor", + stroke: "currentColor", + fillOpacity: "0.5", + strokeWidth: "32", + strokeDasharray: percent * 100 + " 100" + })); +}; + +/* harmony default export */ __webpack_exports__["default"] = (CountdownIcon); + +/***/ }), + +/***/ "./components/icons/FullscreenIcon.jsx": +/*!*********************************************!*\ + !*** ./components/icons/FullscreenIcon.jsx ***! + \*********************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var metabase_components_Icon__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/components/Icon */ "./components/Icon.tsx"); +var _excluded = ["isFullscreen"]; + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } + +function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } + +/* eslint-disable react/prop-types */ + + + +var FullscreenIcon = function FullscreenIcon(_ref) { + var isFullscreen = _ref.isFullscreen, + props = _objectWithoutProperties(_ref, _excluded); + + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Icon__WEBPACK_IMPORTED_MODULE_1__.default, _extends({ + name: isFullscreen ? "contract" : "expand" + }, props)); +}; + +/* harmony default export */ __webpack_exports__["default"] = (FullscreenIcon); + +/***/ }), + +/***/ "./components/icons/NightModeIcon.jsx": +/*!********************************************!*\ + !*** ./components/icons/NightModeIcon.jsx ***! + \********************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var metabase_components_Icon__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/components/Icon */ "./components/Icon.tsx"); +var _excluded = ["isNightMode"]; + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } + +function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } + +/* eslint-disable react/prop-types */ + + + +var NightModeIcon = function NightModeIcon(_ref) { + var isNightMode = _ref.isNightMode, + props = _objectWithoutProperties(_ref, _excluded); + + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Icon__WEBPACK_IMPORTED_MODULE_1__.default, _extends({ + name: isNightMode ? "sun" : "moon" + }, props)); +}; + +/* harmony default export */ __webpack_exports__["default"] = (NightModeIcon); + +/***/ }), + +/***/ "./components/sortable/index.js": +/*!**************************************!*\ + !*** ./components/sortable/index.js ***! + \**************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "SortableContainer": function() { return /* reexport safe */ _sortable__WEBPACK_IMPORTED_MODULE_0__.SortableContainer; }, +/* harmony export */ "SortableElement": function() { return /* reexport safe */ _sortable__WEBPACK_IMPORTED_MODULE_0__.SortableElement; }, +/* harmony export */ "SortableHandle": function() { return /* reexport safe */ _sortable__WEBPACK_IMPORTED_MODULE_0__.SortableHandle; } +/* harmony export */ }); +/* harmony import */ var _sortable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./sortable */ "./components/sortable/sortable.jsx"); + + +/***/ }), + +/***/ "./components/sortable/sortable.jsx": +/*!******************************************!*\ + !*** ./components/sortable/sortable.jsx ***! + \******************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "SortableContainer": function() { return /* binding */ SortableContainer; }, +/* harmony export */ "SortableElement": function() { return /* reexport safe */ react_sortable_hoc__WEBPACK_IMPORTED_MODULE_4__.SortableElement; }, +/* harmony export */ "SortableHandle": function() { return /* reexport safe */ react_sortable_hoc__WEBPACK_IMPORTED_MODULE_4__.SortableHandle; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prop-types */ "../../../node_modules/prop-types/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! classnames */ "../../../node_modules/classnames/index.js"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_2__); +/* harmony import */ var styled_components__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! styled-components */ "../../../node_modules/styled-components/dist/styled-components.browser.es.js"); +/* harmony import */ var react_sortable_hoc__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! react-sortable-hoc */ "../../../node_modules/react-sortable-hoc/dist/react-sortable-hoc.esm.js"); +/* harmony import */ var _sortable_css__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./sortable.css */ "./components/sortable/sortable.css"); +/* harmony import */ var _sortable_css__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_sortable_css__WEBPACK_IMPORTED_MODULE_5__); +var _excluded = ["helperClass"]; + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } + +function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } + + + + + + + +var SortableContainerWrapper = styled_components__WEBPACK_IMPORTED_MODULE_3__.default.div.withConfig({ + displayName: "sortable__SortableContainerWrapper", + componentId: "x6xy1y-0" +})(["user-select:none;"]); // Workaround for https://github.com/clauderic/react-sortable-hoc/issues/253 +// See issue demo here: https://github.com/metabase/metabase/issues/12870 + +function SortableContainer(WrappedComponent, config) { + var SortableList = (0,react_sortable_hoc__WEBPACK_IMPORTED_MODULE_4__.SortableContainer)(function (props) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(SortableContainerWrapper, null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(WrappedComponent, props)); + }, config); // Makes sure the sortable-hoc always receives "react-sortable-hoc-helper" class + // The class just applies a big z-index to the dragged item created by sortable-hoc + // to prevent https://github.com/clauderic/react-sortable-hoc#item-disappearing-when-sorting--css-issues + + function SortableListWithDraggedItemVisibilityFix(_ref) { + var helperClass = _ref.helperClass, + props = _objectWithoutProperties(_ref, _excluded); + + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(SortableList, _extends({}, props, { + helperClass: classnames__WEBPACK_IMPORTED_MODULE_2___default()("react-sortable-hoc-helper", helperClass) + })); + } + + SortableListWithDraggedItemVisibilityFix.displayName = WrappedComponent.displayName; + SortableListWithDraggedItemVisibilityFix.propTypes = { + helperClass: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string) + }; + return SortableListWithDraggedItemVisibilityFix; +} + + +/***/ }), + +/***/ "./components/type/Label.jsx": +/*!***********************************!*\ + !*** ./components/type/Label.jsx ***! + \***********************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var metabase_components_type_Text__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/components/type/Text */ "./components/type/Text.jsx"); +var _excluded = ["children"]; + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } + +function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } + +/* eslint-disable react/prop-types */ + + + +var Label = function Label(_ref) { + var children = _ref.children, + props = _objectWithoutProperties(_ref, _excluded); + + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_type_Text__WEBPACK_IMPORTED_MODULE_1__.default, _extends({ + mb: "8px", + color: "dark" + }, props, { + fontSize: "14px", + fontWeight: 700 + }), children); +}; + +/* harmony default export */ __webpack_exports__["default"] = (Label); + +/***/ }), + +/***/ "./components/type/Text.jsx": +/*!**********************************!*\ + !*** ./components/type/Text.jsx ***! + \**********************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var styled_components__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! styled-components */ "../../../node_modules/styled-components/dist/styled-components.browser.es.js"); +/* harmony import */ var styled_system__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! styled-system */ "../../../node_modules/styled-system/dist/index.js"); +/* harmony import */ var metabase_lib_colors__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/lib/colors */ "./lib/colors.ts"); + + + +var Text = styled_components__WEBPACK_IMPORTED_MODULE_0__.default.div.withConfig({ + displayName: "Text", + componentId: "r5zl0h-0" +})(["", ";", ";", ";", ";", ";color:", ";"], styled_system__WEBPACK_IMPORTED_MODULE_1__.space, styled_system__WEBPACK_IMPORTED_MODULE_1__.fontSize, styled_system__WEBPACK_IMPORTED_MODULE_1__.fontWeight, styled_system__WEBPACK_IMPORTED_MODULE_1__.letterSpacing, styled_system__WEBPACK_IMPORTED_MODULE_1__.lineHeight, function (props) { + return (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_2__.color)("text-".concat(props.color)); +}); +Text.defaultProps = { + fontSize: 14, + color: "medium", + mb: "8px", + mt: "4px" +}; +Text.propTypes = {}; +/* harmony default export */ __webpack_exports__["default"] = (Text); + +/***/ }), + +/***/ "./containers/CollectionName.jsx": +/*!***************************************!*\ + !*** ./containers/CollectionName.jsx ***! + \***************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var metabase_entities_collections__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/entities/collections */ "./entities/collections.js"); +/* eslint-disable react/prop-types */ + + + +var CollectionName = function CollectionName(_ref) { + var id = _ref.id; + + if (id === "root" || id === null) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", null, metabase_entities_collections__WEBPACK_IMPORTED_MODULE_1__.ROOT_COLLECTION.name); + } else if (id === undefined || isNaN(id)) { + return null; + } else { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_entities_collections__WEBPACK_IMPORTED_MODULE_1__.default.Name, { + id: id + }); + } +}; + +/* harmony default export */ __webpack_exports__["default"] = (CollectionName); + +/***/ }), + +/***/ "./containers/CollectionPicker.jsx": +/*!*****************************************!*\ + !*** ./containers/CollectionPicker.jsx ***! + \*****************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prop-types */ "../../../node_modules/prop-types/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var _ItemPicker__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ItemPicker */ "./containers/ItemPicker.jsx"); +var _excluded = ["value", "onChange"]; + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } + +function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } + + + + + +var CollectionPicker = function CollectionPicker(_ref) { + var value = _ref.value, + _onChange = _ref.onChange, + props = _objectWithoutProperties(_ref, _excluded); + + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_ItemPicker__WEBPACK_IMPORTED_MODULE_2__.default, _extends({}, props, { + value: value === undefined ? undefined : { + model: "collection", + id: value + }, + onChange: function onChange(collection) { + return _onChange(collection ? collection.id : undefined); + }, + models: ["collection"] + })); +}; + +CollectionPicker.propTypes = { + // a collection ID or null (for "root" collection), or undefined if none selected + value: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().number), + // callback that takes a collection ID or null (for "root" collection) + onChange: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func.isRequired) +}; +/* harmony default export */ __webpack_exports__["default"] = (CollectionPicker); + +/***/ }), + +/***/ "./containers/CollectionSelect.jsx": +/*!*****************************************!*\ + !*** ./containers/CollectionSelect.jsx ***! + \*****************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var metabase_entities_collections__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! metabase/entities/collections */ "./entities/collections.js"); +/* harmony import */ var _ItemSelect__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ItemSelect */ "./containers/ItemSelect.jsx"); +/* harmony import */ var _CollectionPicker__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./CollectionPicker */ "./containers/CollectionPicker.jsx"); +/* harmony import */ var _CollectionName__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./CollectionName */ "./containers/CollectionName.jsx"); +/* eslint-disable react/prop-types */ + + + + +var CollectionSelect = (0,_ItemSelect__WEBPACK_IMPORTED_MODULE_1__.default)(_CollectionPicker__WEBPACK_IMPORTED_MODULE_2__.default, _CollectionName__WEBPACK_IMPORTED_MODULE_3__.default, "collection"); +/** + * When suggesting an initial collection, + * we need to check a user has `write` access to it. + * For that, collection objects have to be present in Redux store, + * so we can retrieve a collection by ID and check the `can_write` flag. + * + * This component is wrapped with @Collection.loadList + * to ensure collection are fetched and permissions can be checked. + */ + +/* harmony default export */ __webpack_exports__["default"] = (metabase_entities_collections__WEBPACK_IMPORTED_MODULE_0__.default.loadList({ + loadingAndErrorWrapper: false +})(CollectionSelect)); + +/***/ }), + +/***/ "./containers/Form.jsx": +/*!*****************************!*\ + !*** ./containers/Form.jsx ***! + \*****************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "FormField": function() { return /* reexport safe */ metabase_components_form_CustomForm__WEBPACK_IMPORTED_MODULE_8__.CustomFormField; }, +/* harmony export */ "FormSubmit": function() { return /* reexport safe */ metabase_components_form_CustomForm__WEBPACK_IMPORTED_MODULE_8__.CustomFormSubmit; }, +/* harmony export */ "FormMessage": function() { return /* reexport safe */ metabase_components_form_CustomForm__WEBPACK_IMPORTED_MODULE_8__.CustomFormMessage; }, +/* harmony export */ "FormFooter": function() { return /* reexport safe */ metabase_components_form_CustomForm__WEBPACK_IMPORTED_MODULE_8__.CustomFormFooter; }, +/* harmony export */ "FormSection": function() { return /* reexport safe */ metabase_components_form_CustomForm__WEBPACK_IMPORTED_MODULE_8__.CustomFormSection; }, +/* harmony export */ "default": function() { return /* binding */ Form; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prop-types */ "../../../node_modules/prop-types/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var react_redux__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react-redux */ "../../../node_modules/react-redux/es/index.js"); +/* harmony import */ var reselect__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! reselect */ "../../../node_modules/reselect/lib/index.js"); +/* harmony import */ var redux_form__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! redux-form */ "../../../node_modules/redux-form/lib/index.js"); +/* harmony import */ var icepick__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! icepick */ "../../../node_modules/icepick/icepick.min.js"); +/* harmony import */ var icepick__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(icepick__WEBPACK_IMPORTED_MODULE_5__); +/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! underscore */ "../../../node_modules/underscore/modules/index-all.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_7__); +/* harmony import */ var metabase_components_form_CustomForm__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! metabase/components/form/CustomForm */ "./components/form/CustomForm.jsx"); +/* harmony import */ var metabase_components_form_StandardForm__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! metabase/components/form/StandardForm */ "./components/form/StandardForm.jsx"); +/* provided dependency */ var console = __webpack_require__(/*! console-browserify */ "../../../node_modules/console-browserify/index.js"); +var _dec, _class, _class2, _temp, _templateObject; + +var _excluded = ["handleSubmit", "submitState"]; + +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } + +function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } + +function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } + +function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } + +function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } + +/* eslint-disable react/prop-types */ + + + + + + + + + + + +var FORM_ID = 0; // use makeMapStateToProps so each component gets it's own unique formId + +var makeMapStateToProps = function makeMapStateToProps() { + var formId = FORM_ID++; + return function (state, ownProps) { + var formName = ownProps.formName || "form_".concat(formId); + return { + formName: formName, + values: (0,redux_form__WEBPACK_IMPORTED_MODULE_4__.getValues)(state.form[formName]) + }; + }; +}; + +var ReduxFormComponent = (0,redux_form__WEBPACK_IMPORTED_MODULE_4__.reduxForm)()(function (_ref) { + var handleSubmit = _ref.handleSubmit, + submitState = _ref.submitState, + props = _objectWithoutProperties(_ref, _excluded); + + var FormComponent = props.formComponent || (props.children ? metabase_components_form_CustomForm__WEBPACK_IMPORTED_MODULE_8__.default : metabase_components_form_StandardForm__WEBPACK_IMPORTED_MODULE_9__.default); + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(FormComponent, _extends({}, props, { + handleSubmit: /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() { + var _args = arguments; + return regeneratorRuntime.wrap(function _callee$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + _context.next = 2; + return handleSubmit.apply(void 0, _args); + + case 2: + if (!submitState.failed) { + _context.next = 6; + break; + } + + throw submitState.result; + + case 6: + return _context.abrupt("return", submitState.result); + + case 7: + case "end": + return _context.stop(); + } + } + }, _callee); + })) + })); +}); +var Form = (_dec = (0,react_redux__WEBPACK_IMPORTED_MODULE_2__.connect)(makeMapStateToProps), _dec(_class = (_temp = _class2 = /*#__PURE__*/function (_React$Component) { + _inherits(Form, _React$Component); + + var _super = _createSuper(Form); + + function Form(_props) { + var _this; + + _classCallCheck(this, Form); + + _this = _super.call(this, _props); + + _defineProperty(_assertThisInitialized(_this), "_state", { + submitting: false, + failed: false, + result: undefined + }); + + _defineProperty(_assertThisInitialized(_this), "_registerFormField", function (field) { + if (!underscore__WEBPACK_IMPORTED_MODULE_6__.default.isEqual(_this.state.inlineFields[field.name], field)) { + _this.setState(function (prevState) { + return (0,icepick__WEBPACK_IMPORTED_MODULE_5__.assocIn)(prevState, ["inlineFields", field.name], field); + }); + } + }); + + _defineProperty(_assertThisInitialized(_this), "_unregisterFormField", function (field) { + if (_this.state.inlineFields[field.name]) {// this.setState(prevState => + // dissocIn(prevState, ["inlineFields", field.name]), + // ); + } + }); + + _defineProperty(_assertThisInitialized(_this), "_validate", function (values, props) { + // HACK: clears failed state for global error + if (!_this._state.submitting && _this._state.failed) { + _this._state.failed = false; + props.stopSubmit(); + } + + var formObject = _this._getFormObject(); + + return formObject.validate(values, props); + }); + + _defineProperty(_assertThisInitialized(_this), "_onSubmit", /*#__PURE__*/function () { + var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(values) { + var formObject, normalized, fieldNames, errorNames, hasUnknownFields; + return regeneratorRuntime.wrap(function _callee2$(_context2) { + while (1) { + switch (_context2.prev = _context2.next) { + case 0: + formObject = _this._getFormObject(); // HACK: clears failed state for global error + + _this._state.submitting = true; + _context2.prev = 2; + normalized = formObject.normalize(values); + _context2.next = 6; + return _this.props.onSubmit(normalized); + + case 6: + return _context2.abrupt("return", _this._state.result = _context2.sent); + + case 9: + _context2.prev = 9; + _context2.t0 = _context2["catch"](2); + console.error("Form submission error", _context2.t0); + _this._state.failed = true; + _this._state.result = _context2.t0; // redux-form expects { "FIELD NAME": "FIELD ERROR STRING" } or {"_error": "GLOBAL ERROR STRING" } + + if (!(_context2.t0 && _context2.t0.data && _context2.t0.data.errors)) { + _context2.next = 22; + break; + } + + try { + // HACK: blur the current element to ensure we show the error + document.activeElement.blur(); + } catch (e) {} // if there are errors for fields we don't know about then inject a generic top-level _error key + + + fieldNames = new Set(_this._getFieldNames()); + errorNames = Object.keys(_context2.t0.data.errors); + hasUnknownFields = errorNames.some(function (name) { + return !fieldNames.has(name); + }); + throw _objectSpread({ + _error: hasUnknownFields ? (0,ttag__WEBPACK_IMPORTED_MODULE_7__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["An error occurred"]))) : null + }, _context2.t0.data.errors); + + case 22: + if (!_context2.t0) { + _context2.next = 24; + break; + } + + throw { + _error: _context2.t0.data.message || _context2.t0.data + }; + + case 24: + _context2.prev = 24; + setTimeout(function () { + return _this._state.submitting = false; + }); + return _context2.finish(24); + + case 27: + case "end": + return _context2.stop(); + } + } + }, _callee2, null, [[2, 9, 24, 27]]); + })); + + return function (_x) { + return _ref3.apply(this, arguments); + }; + }()); + + _defineProperty(_assertThisInitialized(_this), "_handleSubmitSuccess", /*#__PURE__*/function () { + var _ref4 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(action) { + return regeneratorRuntime.wrap(function _callee3$(_context3) { + while (1) { + switch (_context3.prev = _context3.next) { + case 0: + if (!_this.props.onSubmitSuccess) { + _context3.next = 3; + break; + } + + _context3.next = 3; + return _this.props.onSubmitSuccess(action); + + case 3: + _this.props.dispatch((0,redux_form__WEBPACK_IMPORTED_MODULE_4__.initialize)(_this.props.formName, _this.props.values, _this._getFieldNames())); + + case 4: + case "end": + return _context3.stop(); + } + } + }, _callee3); + })); + + return function (_x2) { + return _ref4.apply(this, arguments); + }; + }()); + + _defineProperty(_assertThisInitialized(_this), "_handleChangeField", function (fieldName, value) { + return _this.props.dispatch((0,redux_form__WEBPACK_IMPORTED_MODULE_4__.change)(_this.props.formName, fieldName, value)); + }); + + _this.state = { + // fields defined via child FormField elements + inlineFields: {} + }; // memoized functions + + var getFormDefinition = (0,reselect__WEBPACK_IMPORTED_MODULE_3__.createSelector)([function (state, props) { + return props.form; + }, function (state, props) { + return props.validate; + }, function (state, props) { + return props.initial; + }, function (state, props) { + return props.normalize; + }, function (state, props) { + return props.fields; + }, function (state, props) { + return state.inlineFields; + }], function (form, validate, initial, normalize, fields, inlineFields) { + // use props.form if provided, otherwise generate from props.{fields,initial,validate,normalize} + var formDef = form || { + validate: validate, + initial: initial, + normalize: normalize, + fields: fields || Object.values(inlineFields) + }; + return _objectSpread(_objectSpread({}, formDef), {}, { + fields: function fields() { + for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { + args[_key3] = arguments[_key3]; + } + + return (// merge inlineFields in + getValue.apply(void 0, [formDef.fields].concat(args)).map(function (fieldDef) { + return _objectSpread(_objectSpread({}, fieldDef), inlineFields[fieldDef.name]); + }) + ); + } + }); + }); + var getFormObject = (0,reselect__WEBPACK_IMPORTED_MODULE_3__.createSelector)([getFormDefinition], function (formDef) { + return makeFormObject(formDef); + }); + var getInitialValues = (0,reselect__WEBPACK_IMPORTED_MODULE_3__.createSelector)([getFormObject, function (state, props) { + return props.initialValues || {}; + }, function (state, props) { + return props.values || {}; + }], function (formObject, initialValues, values) { + var formInitialValues = formObject.initial(values); // merge nested fields: {details: {foo: 123}} + {details: {bar: 321}} => {details: {foo: 123, bar: 321}} + + var merged = {}; + + for (var _i = 0, _Object$keys = Object.keys(initialValues); _i < _Object$keys.length; _i++) { + var k = _Object$keys[_i]; + + if (_typeof(initialValues[k]) === "object" && _typeof(formInitialValues[k]) === "object") { + merged[k] = _objectSpread(_objectSpread({}, formInitialValues[k]), initialValues[k]); + } + } + + return _objectSpread(_objectSpread(_objectSpread({}, initialValues), formInitialValues), merged); + }); + var getFieldNames = (0,reselect__WEBPACK_IMPORTED_MODULE_3__.createSelector)([getFormObject, getInitialValues, function (state, props) { + return props.values || {}; + }], function (formObject, initialValues, values) { + return formObject.fieldNames(_objectSpread(_objectSpread({}, initialValues), values)); + }); + + _this._getFormObject = function () { + return getFormObject(_this.state, _this.props); + }; + + _this._getFormDefinition = function () { + return getFormDefinition(_this.state, _this.props); + }; + + _this._getInitialValues = function () { + return getInitialValues(_this.state, _this.props); + }; + + _this._getFieldNames = function () { + return getFieldNames(_this.state, _this.props); + }; + + return _this; + } + + _createClass(Form, [{ + key: "componentDidUpdate", + value: function componentDidUpdate(prevProps, prevState) { + // HACK: when new fields are added they aren't initialized with their intialValues, so we have to force it here: + var newFields = underscore__WEBPACK_IMPORTED_MODULE_6__.default.difference(Object.keys(this.state.inlineFields), Object.keys(prevState.inlineFields)); + + if (newFields.length > 0) { + this.props.dispatch((0,redux_form__WEBPACK_IMPORTED_MODULE_4__.initialize)(this.props.formName, this._getInitialValues(), newFields)); + } + } + }, { + key: "getChildContext", + value: function getChildContext() { + return { + registerFormField: this._registerFormField, + unregisterFormField: this._unregisterFormField + }; + } + }, { + key: "render", + value: function render() { + // eslint-disable-next-line + var _this$props = this.props, + formName = _this$props.formName, + overwriteOnInitialValuesChange = _this$props.overwriteOnInitialValuesChange; + + var formObject = this._getFormObject(); + + var initialValues = this._getInitialValues(); + + var fieldNames = this._getFieldNames(); + + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(ReduxFormComponent, _extends({}, this.props, { + overwriteOnInitialValuesChange: overwriteOnInitialValuesChange, + formObject: formObject // redux-form props: + , + form: formName, + fields: fieldNames, + initialValues: initialValues, + validate: this._validate, + onSubmit: this._onSubmit, + onSubmitSuccess: this._handleSubmitSuccess, + onChangeField: this._handleChangeField // HACK: _state is a mutable object so we can pass by reference into the ReduxFormComponent + , + submitState: this._state + })); + } + }]); + + return Form; +}(react__WEBPACK_IMPORTED_MODULE_0__.Component), _defineProperty(_class2, "propTypes", { + form: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().object), + onSubmit: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func.isRequired), + initialValues: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().object), + formName: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string), + overwriteOnInitialValuesChange: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool) +}), _defineProperty(_class2, "defaultProps", { + overwriteOnInitialValuesChange: false +}), _defineProperty(_class2, "childContextTypes", { + registerFormField: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func), + unregisterFormField: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func), + fieldNames: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().array) +}), _temp)) || _class); + // returns a function that takes an object +// apply the top level method (if any) to the whole object +// then apply each field's method (if any) to each value in object, setting the result if not undefined +// +// equivalent examples: +// +// form.initial is { foo: "bar" } +// form.initial is () => ({ foo: "bar" }) +// form.fields[0] is { name: "foo", initial: "bar" } +// form.fields[0] is { name: "foo", initial: () => "bar" } +// + +function makeFormMethod(form, methodName) { + var defaultValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; + var mergeFn = arguments.length > 3 ? arguments[3] : undefined; + var originalMethod = form[methodName]; + + form[methodName] = function (object) { + for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } + + // make a copy + var values = _objectSpread({}, getValue.apply(void 0, [originalMethod, object].concat(args)) || getValue.apply(void 0, [defaultValues, object].concat(args))); + + var _iterator = _createForOfIteratorHelper(form.fields(object)), + _step; + + try { + for (_iterator.s(); !(_step = _iterator.n()).done;) { + var field = _step.value; + var value = getValue.apply(void 0, [field[methodName], object && getValueAtPath(object, field.name)].concat(args)); + + if (value !== undefined) { + setValueAtPath(values, field.name, value, mergeFn); + } + } + } catch (err) { + _iterator.e(err); + } finally { + _iterator.f(); + } + + return values; + }; +} // if the first arg is a function, call it, otherwise return it. + + +function getValue(fnOrValue) { + for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { + args[_key2 - 1] = arguments[_key2]; + } + + return typeof fnOrValue === "function" ? fnOrValue.apply(void 0, args) : fnOrValue; +} + +function makeFormObject(formDef) { + var form = _objectSpread(_objectSpread({}, formDef), {}, { + fields: function fields(values) { + return getValue(formDef.fields, values); + }, + fieldNames: function fieldNames(values) { + return ["id"].concat(_toConsumableArray(form.fields(values).map(function (field) { + return field.name; + }))); + } + }); // for validating the object, or individual values + + + makeFormMethod(form, "validate", {}, function (a, b) { + return [a, b].filter(function (a) { + return a; + }).join(", "); + }); // for getting the initial values object, or getting individual values + + makeFormMethod(form, "initial"); // for normalizeing the object before submitting, or normalizeing individual values + + makeFormMethod(form, "normalize", function (object) { + return object; + }); + makeFormMethod(form, "hidden"); + return form; +} + +function getObjectPath(path) { + return typeof path === "string" ? path.split(".") : path; +} + +function getValueAtPath(object, path) { + return (0,icepick__WEBPACK_IMPORTED_MODULE_5__.getIn)(object, getObjectPath(path)); +} + +function setValueAtPath(object, path, value) { + var mergeFn = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : function (a, b) { + return b; + }; + path = getObjectPath(path); + + for (var i = 0; i < path.length; i++) { + if (i === path.length - 1) { + object[path[i]] = mergeFn(object[path[i]], value); + } else { + object = object[path[i]] = object[path[i]] || {}; + } + } +} + +/***/ }), + +/***/ "./containers/ItemPicker.jsx": +/*!***********************************!*\ + !*** ./containers/ItemPicker.jsx ***! + \***********************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* binding */ ItemPicker; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prop-types */ "../../../node_modules/prop-types/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! classnames */ "../../../node_modules/classnames/index.js"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_2__); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_3__); +/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! underscore */ "../../../node_modules/underscore/modules/index-all.js"); +/* harmony import */ var grid_styled__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! grid-styled */ "../../../node_modules/grid-styled/dist/index.js"); +/* harmony import */ var metabase_components_Icon__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! metabase/components/Icon */ "./components/Icon.tsx"); +/* harmony import */ var metabase_components_Breadcrumbs__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! metabase/components/Breadcrumbs */ "./components/Breadcrumbs.jsx"); +/* harmony import */ var metabase_components_LoadingAndErrorWrapper__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! metabase/components/LoadingAndErrorWrapper */ "./components/LoadingAndErrorWrapper.jsx"); +/* harmony import */ var metabase_lib_colors__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! metabase/lib/colors */ "./lib/colors.ts"); +/* harmony import */ var react_redux__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! react-redux */ "../../../node_modules/react-redux/es/index.js"); +/* harmony import */ var metabase_entities_containers_EntityListLoader__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! metabase/entities/containers/EntityListLoader */ "./entities/containers/EntityListLoader.jsx"); +/* harmony import */ var metabase_entities_collections__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! metabase/entities/collections */ "./entities/collections.js"); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +var _dec, _dec2, _class, _class2, _temp, _templateObject; + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +/* eslint-disable react/prop-types */ + + + + + + + + + + + // NOTE: replacing these with Collections.ListLoader etc currently fails due to circular dependency + + + + +var getCollectionIconColor = function getCollectionIconColor() { + return (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_9__.color)("text-light"); +}; + +var isRoot = function isRoot(collection) { + return collection.id === "root" || collection.id == null; +}; + +var ItemPicker = (_dec = (0,metabase_entities_containers_EntityListLoader__WEBPACK_IMPORTED_MODULE_11__.entityListLoader)({ + entityType: function entityType(state, props) { + return props.entity ? props.entity.name : "collections"; + }, + loadingAndErrorWrapper: false +}), _dec2 = (0,react_redux__WEBPACK_IMPORTED_MODULE_10__.connect)(function (state, props) { + return { + collectionsById: (props.entity || metabase_entities_collections__WEBPACK_IMPORTED_MODULE_12__.default).selectors.getExpandedCollectionsById(state), + getCollectionIcon: (props.entity || metabase_entities_collections__WEBPACK_IMPORTED_MODULE_12__.default).objectSelectors.getIcon + }; +}), _dec(_class = _dec2(_class = (_temp = _class2 = /*#__PURE__*/function (_React$Component) { + _inherits(ItemPicker, _React$Component); + + var _super = _createSuper(ItemPicker); + + function ItemPicker(props) { + var _this; + + _classCallCheck(this, ItemPicker); + + _this = _super.call(this, props); + _this.state = { + parentId: "root", + searchMode: false, + searchString: false + }; + return _this; + } + + _createClass(ItemPicker, [{ + key: "getCrumbs", + value: // returns a list of "crumbs" starting with the "root" collection + function getCrumbs(collection, collectionsById) { + var _this2 = this; + + if (collection && collection.path) { + return [].concat(_toConsumableArray(collection.path.map(function (id) { + return [collectionsById[id].name, function () { + return _this2.setState({ + parentId: id + }); + }]; + })), [[collection.name]]); + } else { + return [[collectionsById["root"].name, function () { + return _this2.setState({ + parentId: collectionsById["root"].id + }); + }], ["Unknown"]]; + } + } + }, { + key: "checkHasWritePermissionForItem", + value: function checkHasWritePermissionForItem(item, models) { + var collectionsById = this.props.collectionsById; // if user is selecting a collection, they must have a `write` access to it + + if (models.has("collection") && item.model === "collection") { + return item.can_write; + } // if user is selecting something else (e.g. dashboard), + // they must have `write` access to a collection item belongs to + + + var collection = item.collection_id ? collectionsById[item.collection_id] : collectionsById["root"]; + return collection.can_write; + } + }, { + key: "checkCanWriteToCollectionOrItsChildren", + value: function checkCanWriteToCollectionOrItsChildren(collection) { + var _this3 = this; + + return collection.can_write || collection.children.some(function (child) { + return _this3.checkCanWriteToCollectionOrItsChildren(child); + }); + } + }, { + key: "render", + value: function render() { + var _this4 = this; + + var _this$props = this.props, + value = _this$props.value, + _onChange = _this$props.onChange, + collectionsById = _this$props.collectionsById, + getCollectionIcon = _this$props.getCollectionIcon, + style = _this$props.style, + className = _this$props.className, + _this$props$showSearc = _this$props.showSearch, + showSearch = _this$props$showSearc === void 0 ? true : _this$props$showSearc; + var _this$state = this.state, + parentId = _this$state.parentId, + searchMode = _this$state.searchMode, + searchString = _this$state.searchString; + var models = new Set(this.props.models); + var modelsIncludeNonCollections = this.props.models.filter(function (model) { + return model !== "collection"; + }).length > 0; + var collection = collectionsById[parentId]; + var crumbs = this.getCrumbs(collection, collectionsById); + var allCollections = collection && collection.children || []; // show root in itself if we can pick it + + if (collection && isRoot(collection) && models.has("collection")) { + allCollections = [collection].concat(_toConsumableArray(allCollections)); + } // ensure we only display collections a user can write to + + + allCollections = allCollections.filter(function (collection) { + return _this4.checkCanWriteToCollectionOrItsChildren(collection); + }); // code below assumes items have a "model" property + + allCollections = allCollections.map(function (collection) { + return _objectSpread(_objectSpread({}, collection), {}, { + model: "collection" + }); + }); // special case for root collection + + var getId = function getId(item) { + return item && (item.model === "collection" && item.id === null ? "root" : item.id); + }; + + var isSelected = function isSelected(item) { + return item && value && getId(item) === getId(value) && (models.size === 1 || item.model === value.model); + }; + + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_LoadingAndErrorWrapper__WEBPACK_IMPORTED_MODULE_8__.default, { + loading: !collectionsById, + className: "scroll-y" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(grid_styled__WEBPACK_IMPORTED_MODULE_5__.Box, { + style: style, + className: classnames__WEBPACK_IMPORTED_MODULE_2___default()(className, "scroll-y") + }, searchMode ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(grid_styled__WEBPACK_IMPORTED_MODULE_5__.Box, { + pb: 1, + mb: 2, + className: "border-bottom flex align-center", + "data-testid": "item-picker-header" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("input", { + type: "search", + className: "input rounded flex-full", + placeholder: (0,ttag__WEBPACK_IMPORTED_MODULE_3__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["Search"]))), + autoFocus: true, + onKeyPress: function onKeyPress(e) { + if (e.key === "Enter") { + _this4.setState({ + searchString: e.target.value + }); + } + } + }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Icon__WEBPACK_IMPORTED_MODULE_6__.default, { + name: "close", + className: "ml-auto pl2 text-light text-medium-hover cursor-pointer", + onClick: function onClick() { + return _this4.setState({ + searchMode: null, + searchString: null + }); + } + })) : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(grid_styled__WEBPACK_IMPORTED_MODULE_5__.Box, { + pb: 1, + mb: 2, + className: "border-bottom flex align-center", + "data-testid": "item-picker-header" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Breadcrumbs__WEBPACK_IMPORTED_MODULE_7__.default, { + crumbs: crumbs + }), showSearch && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Icon__WEBPACK_IMPORTED_MODULE_6__.default, { + name: "search", + className: "ml-auto pl2 text-light text-medium-hover cursor-pointer", + onClick: function onClick() { + return _this4.setState({ + searchMode: true + }); + } + })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(grid_styled__WEBPACK_IMPORTED_MODULE_5__.Box, { + className: "scroll-y", + "data-testid": "item-picker-list" + }, !searchString ? allCollections.map(function (collection) { + var hasChildren = collection.children && collection.children.length > 0 && // exclude root since we show root's subcollections alongside it + !isRoot(collection) || // non-collection models are loaded on-demand so we don't know ahead of time + // if they have children, so we have to assume they do + modelsIncludeNonCollections; // NOTE: this assumes the only reason you'd be selecting a collection is to modify it in some way + + var canSelect = models.has("collection") && collection.can_write; + var icon = getCollectionIcon(collection); // only show if collection can be selected or has children + + return canSelect || hasChildren ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(Item, { + key: "collection-".concat(collection.id), + item: collection, + name: collection.name, + color: (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_9__.color)(icon.color) || getCollectionIconColor(), + icon: icon, + selected: canSelect && isSelected(collection), + canSelect: canSelect, + hasChildren: hasChildren, + onChange: function onChange(collection) { + return isRoot(collection) ? // "root" collection should have `null` id + _onChange({ + id: null, + model: "collection" + }) : _onChange(collection); + }, + onChangeParentId: function onChangeParentId(parentId) { + return _this4.setState({ + parentId: parentId + }); + } + }) : null; + }) : null, (modelsIncludeNonCollections || searchString) && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_entities_containers_EntityListLoader__WEBPACK_IMPORTED_MODULE_11__.default, { + entityType: "search", + entityQuery: _objectSpread(_objectSpread({}, searchString ? { + q: searchString + } : { + collection: parentId + }), models.size === 1 ? { + models: Array.from(models) + } : {}), + wrapped: true + }, function (_ref2) { + var list = _ref2.list; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", null, list.map(function (item) { + var hasPermission = _this4.checkHasWritePermissionForItem(item, models); + + if (hasPermission && // only include desired models (TODO: ideally the endpoint would handle this) + models.has(item.model) && (item.model !== "collection" || !!searchString)) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(Item, { + key: item.id, + item: item, + name: item.getName(), + color: item.getColor(), + icon: item.getIcon().name, + selected: isSelected(item), + canSelect: hasPermission, + onChange: _onChange + }); + } + + return null; + })); + })))); + } + }]); + + return ItemPicker; +}(react__WEBPACK_IMPORTED_MODULE_0__.Component), _defineProperty(_class2, "propTypes", { + // undefined = no selection + // null = root collection + // number = non-root collection id + value: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().number), + types: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().array), + showSearch: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool) +}), _temp)) || _class) || _class); + + +var Item = function Item(_ref) { + var item = _ref.item, + name = _ref.name, + icon = _ref.icon, + color = _ref.color, + selected = _ref.selected, + canSelect = _ref.canSelect, + hasChildren = _ref.hasChildren, + onChange = _ref.onChange, + onChangeParentId = _ref.onChangeParentId; + var iconProps = underscore__WEBPACK_IMPORTED_MODULE_4__.default.isObject(icon) ? icon : { + name: icon + }; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(grid_styled__WEBPACK_IMPORTED_MODULE_5__.Box, { + mt: 1, + p: 1, + onClick: canSelect ? function () { + return onChange(item); + } : hasChildren ? function () { + return onChangeParentId(item.id); + } : null, + className: classnames__WEBPACK_IMPORTED_MODULE_2___default()("rounded", { + "bg-brand text-white": selected, + "bg-brand-hover text-white-hover cursor-pointer": canSelect || hasChildren + }), + "data-testid": "item-picker-item" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(grid_styled__WEBPACK_IMPORTED_MODULE_5__.Flex, { + align: "center" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Icon__WEBPACK_IMPORTED_MODULE_6__.default, _extends({ + size: 22 + }, iconProps, { + color: selected ? "white" : color + })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("h4", { + className: "mx1" + }, name), hasChildren && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Icon__WEBPACK_IMPORTED_MODULE_6__.default, { + name: "chevronright", + className: classnames__WEBPACK_IMPORTED_MODULE_2___default()("p1 ml-auto circular text-light border-grey-2 bordered bg-white-hover cursor-pointer", { + "bg-brand-hover": !canSelect + }), + onClick: function onClick(e) { + e.stopPropagation(); + onChangeParentId(item.id); + } + }))); +}; + +/***/ }), + +/***/ "./containers/ItemSelect.jsx": +/*!***********************************!*\ + !*** ./containers/ItemSelect.jsx ***! + \***********************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-dom */ "../../../node_modules/react-dom/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! prop-types */ "../../../node_modules/prop-types/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_2__); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_3__); +/* harmony import */ var metabase_components_PopoverWithTrigger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! metabase/components/PopoverWithTrigger */ "./components/PopoverWithTrigger.jsx"); +/* harmony import */ var metabase_components_SelectButton__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! metabase/components/SelectButton */ "./components/SelectButton.jsx"); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +var _templateObject; + +var _excluded = ["value", "onChange", "className", "style", "placeholder", "inheritWidth"]; + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } + +function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/* eslint-disable react/prop-types */ + + + + + + +var MIN_POPOVER_WIDTH = 300; +/* harmony default export */ __webpack_exports__["default"] = (function (PickerComponent, NameComponent, type) { + var _class, _temp; + + return _temp = _class = /*#__PURE__*/function (_React$Component) { + _inherits(ItemSelect, _React$Component); + + var _super = _createSuper(ItemSelect); + + function ItemSelect() { + var _this; + + _classCallCheck(this, ItemSelect); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _super.call.apply(_super, [this].concat(args)); + + _defineProperty(_assertThisInitialized(_this), "state", { + width: MIN_POPOVER_WIDTH + }); + + return _this; + } + + _createClass(ItemSelect, [{ + key: "componentDidMount", + value: function componentDidMount() { + this.componentDidUpdate(); + } + }, { + key: "componentDidUpdate", + value: function componentDidUpdate() { + // save the width so we can make the poopver content match + var _ReactDOM$findDOMNode = react_dom__WEBPACK_IMPORTED_MODULE_1__.findDOMNode(this).getBoundingClientRect(), + width = _ReactDOM$findDOMNode.width; + + if (this.state.width !== width) { + this.setState({ + width: width + }); + } + } + }, { + key: "render", + value: function render() { + var _this2 = this; + + var _this$props = this.props, + value = _this$props.value, + _onChange = _this$props.onChange, + className = _this$props.className, + style = _this$props.style, + placeholder = _this$props.placeholder, + inheritWidth = _this$props.inheritWidth, + props = _objectWithoutProperties(_this$props, _excluded); + + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_PopoverWithTrigger__WEBPACK_IMPORTED_MODULE_4__.default, { + pinInitialAttachment: true // keep the popover from jumping if content height changes + , + triggerClasses: className, + triggerElement: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_SelectButton__WEBPACK_IMPORTED_MODULE_5__.default, { + style: style + }, value !== undefined && value !== "" ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(NameComponent, { + id: value + }) : placeholder), + sizeToFit: true, + autoWidth: true + }, function (_ref) { + var onClose = _ref.onClose; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(PickerComponent, _extends({}, props, { + style: inheritWidth ? { + width: Math.max(_this2.state.width, MIN_POPOVER_WIDTH) + } : { + minWidth: MIN_POPOVER_WIDTH + }, + className: "p2 overflow-auto", + value: value, + onChange: function onChange(itemId) { + _onChange(itemId); + + onClose(); + } + })); + }); + } + }]); + + return ItemSelect; + }(react__WEBPACK_IMPORTED_MODULE_0__.Component), _defineProperty(_class, "propTypes", { + // collection ID, null (for root collection), or undefined + value: (prop_types__WEBPACK_IMPORTED_MODULE_2___default().number), + onChange: (prop_types__WEBPACK_IMPORTED_MODULE_2___default().func.isRequired), + field: (prop_types__WEBPACK_IMPORTED_MODULE_2___default().object.isRequired), + // optional collectionId to filter out so you can't move a collection into itself + collectionId: (prop_types__WEBPACK_IMPORTED_MODULE_2___default().number), + // make the popover content inherit the select widget's width + inheritWidth: (prop_types__WEBPACK_IMPORTED_MODULE_2___default().bool) + }), _defineProperty(_class, "defaultProps", { + placeholder: (0,ttag__WEBPACK_IMPORTED_MODULE_3__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["Select a ", ""])), type), + inheritWidth: true + }), _temp; +}); + +/***/ }), + +/***/ "./containers/RemappedValue.jsx": +/*!**************************************!*\ + !*** ./containers/RemappedValue.jsx ***! + \**************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "AutoLoadRemappedValue": function() { return /* binding */ AutoLoadRemappedValue; }, +/* harmony export */ "FieldRemappedValue": function() { return /* binding */ FieldRemappedValue; }, +/* harmony export */ "TestRemappedValue": function() { return /* binding */ TestRemappedValue; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var metabase_lib_formatting__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/lib/formatting */ "./lib/formatting.js"); +/* harmony import */ var metabase_hoc_Remapped__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/hoc/Remapped */ "./hoc/Remapped.jsx"); +var _excluded = ["value", "column", "displayValue", "displayColumn", "renderNormal", "renderRemapped"], + _excluded2 = ["autoLoad"]; + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } + +function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } + +/* eslint-disable react/prop-types */ + + + + +var defaultRenderNormal = function defaultRenderNormal(_ref) { + var value = _ref.value, + column = _ref.column; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { + className: "text-bold" + }, value); +}; + +var defaultRenderRemapped = function defaultRenderRemapped(_ref2) { + var value = _ref2.value, + displayValue = _ref2.displayValue, + column = _ref2.column, + displayColumn = _ref2.displayColumn; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { + className: "text-bold" + }, displayValue), column.isID() && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { + style: { + opacity: 0.5 + } + }, " - " + value)); +}; + +var RemappedValueContent = function RemappedValueContent(_ref3) { + var value = _ref3.value, + column = _ref3.column, + displayValue = _ref3.displayValue, + displayColumn = _ref3.displayColumn, + _ref3$renderNormal = _ref3.renderNormal, + renderNormal = _ref3$renderNormal === void 0 ? defaultRenderNormal : _ref3$renderNormal, + _ref3$renderRemapped = _ref3.renderRemapped, + renderRemapped = _ref3$renderRemapped === void 0 ? defaultRenderRemapped : _ref3$renderRemapped, + props = _objectWithoutProperties(_ref3, _excluded); + + if (column != null) { + value = (0,metabase_lib_formatting__WEBPACK_IMPORTED_MODULE_1__.formatValue)(value, _objectSpread(_objectSpread({}, props), {}, { + column: column, + jsx: true, + remap: false + })); + } + + if (displayColumn != null) { + displayValue = (0,metabase_lib_formatting__WEBPACK_IMPORTED_MODULE_1__.formatValue)(displayValue, _objectSpread(_objectSpread({}, props), {}, { + column: displayColumn, + jsx: true, + remap: false + })); + } + + if (displayValue != null) { + return renderRemapped({ + value: value, + displayValue: displayValue, + column: column, + displayColumn: displayColumn + }); + } else { + return renderNormal({ + value: value, + column: column + }); + } +}; + +var AutoLoadRemappedValue = (0,metabase_hoc_Remapped__WEBPACK_IMPORTED_MODULE_2__.default)(RemappedValueContent); +var FieldRemappedValue = function FieldRemappedValue(props) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(RemappedValueContent, _extends({}, props, { + displayValue: props.column.remappedValue(props.value), + displayColumn: props.column.remappedField() + })); +}; + +var RemappedValue = function RemappedValue(_ref4) { + var _ref4$autoLoad = _ref4.autoLoad, + autoLoad = _ref4$autoLoad === void 0 ? true : _ref4$autoLoad, + props = _objectWithoutProperties(_ref4, _excluded2); + + return autoLoad ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(AutoLoadRemappedValue, props) : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(FieldRemappedValue, props); +}; + +/* harmony default export */ __webpack_exports__["default"] = (RemappedValue); // test version doesn't use metabase/hoc/Remapped which requires a redux store + +var TestRemappedValue = RemappedValueContent; + +/***/ }), + +/***/ "./dashboard/actions.js": +/*!******************************!*\ + !*** ./dashboard/actions.js ***! + \******************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "INITIALIZE": function() { return /* binding */ INITIALIZE; }, +/* harmony export */ "SET_EDITING_DASHBOARD": function() { return /* binding */ SET_EDITING_DASHBOARD; }, +/* harmony export */ "FETCH_DASHBOARD": function() { return /* binding */ FETCH_DASHBOARD; }, +/* harmony export */ "SAVE_DASHBOARD_AND_CARDS": function() { return /* binding */ SAVE_DASHBOARD_AND_CARDS; }, +/* harmony export */ "SET_DASHBOARD_ATTRIBUTES": function() { return /* binding */ SET_DASHBOARD_ATTRIBUTES; }, +/* harmony export */ "ADD_CARD_TO_DASH": function() { return /* binding */ ADD_CARD_TO_DASH; }, +/* harmony export */ "REMOVE_CARD_FROM_DASH": function() { return /* binding */ REMOVE_CARD_FROM_DASH; }, +/* harmony export */ "SET_DASHCARD_ATTRIBUTES": function() { return /* binding */ SET_DASHCARD_ATTRIBUTES; }, +/* harmony export */ "SET_MULTIPLE_DASHCARD_ATTRIBUTES": function() { return /* binding */ SET_MULTIPLE_DASHCARD_ATTRIBUTES; }, +/* harmony export */ "UPDATE_DASHCARD_VISUALIZATION_SETTINGS": function() { return /* binding */ UPDATE_DASHCARD_VISUALIZATION_SETTINGS; }, +/* harmony export */ "UPDATE_DASHCARD_VISUALIZATION_SETTINGS_FOR_COLUMN": function() { return /* binding */ UPDATE_DASHCARD_VISUALIZATION_SETTINGS_FOR_COLUMN; }, +/* harmony export */ "REPLACE_ALL_DASHCARD_VISUALIZATION_SETTINGS": function() { return /* binding */ REPLACE_ALL_DASHCARD_VISUALIZATION_SETTINGS; }, +/* harmony export */ "UPDATE_DASHCARD_ID": function() { return /* binding */ UPDATE_DASHCARD_ID; }, +/* harmony export */ "FETCH_DASHBOARD_CARD_DATA": function() { return /* binding */ FETCH_DASHBOARD_CARD_DATA; }, +/* harmony export */ "FETCH_CARD_DATA": function() { return /* binding */ FETCH_CARD_DATA; }, +/* harmony export */ "CANCEL_FETCH_DASHBOARD_CARD_DATA": function() { return /* binding */ CANCEL_FETCH_DASHBOARD_CARD_DATA; }, +/* harmony export */ "CANCEL_FETCH_CARD_DATA": function() { return /* binding */ CANCEL_FETCH_CARD_DATA; }, +/* harmony export */ "MARK_CARD_AS_SLOW": function() { return /* binding */ MARK_CARD_AS_SLOW; }, +/* harmony export */ "CLEAR_CARD_DATA": function() { return /* binding */ CLEAR_CARD_DATA; }, +/* harmony export */ "MARK_NEW_CARD_SEEN": function() { return /* binding */ MARK_NEW_CARD_SEEN; }, +/* harmony export */ "ADD_PARAMETER": function() { return /* binding */ ADD_PARAMETER; }, +/* harmony export */ "REMOVE_PARAMETER": function() { return /* binding */ REMOVE_PARAMETER; }, +/* harmony export */ "SET_PARAMETER_MAPPING": function() { return /* binding */ SET_PARAMETER_MAPPING; }, +/* harmony export */ "SET_PARAMETER_NAME": function() { return /* binding */ SET_PARAMETER_NAME; }, +/* harmony export */ "SET_PARAMETER_VALUE": function() { return /* binding */ SET_PARAMETER_VALUE; }, +/* harmony export */ "SET_PARAMETER_INDEX": function() { return /* binding */ SET_PARAMETER_INDEX; }, +/* harmony export */ "SET_PARAMETER_DEFAULT_VALUE": function() { return /* binding */ SET_PARAMETER_DEFAULT_VALUE; }, +/* harmony export */ "SHOW_ADD_PARAMETER_POPOVER": function() { return /* binding */ SHOW_ADD_PARAMETER_POPOVER; }, +/* harmony export */ "HIDE_ADD_PARAMETER_POPOVER": function() { return /* binding */ HIDE_ADD_PARAMETER_POPOVER; }, +/* harmony export */ "SET_SIDEBAR": function() { return /* binding */ SET_SIDEBAR; }, +/* harmony export */ "CLOSE_SIDEBAR": function() { return /* binding */ CLOSE_SIDEBAR; }, +/* harmony export */ "initialize": function() { return /* binding */ initialize; }, +/* harmony export */ "setEditingDashboard": function() { return /* binding */ setEditingDashboard; }, +/* harmony export */ "setSidebar": function() { return /* binding */ setSidebar; }, +/* harmony export */ "closeSidebar": function() { return /* binding */ closeSidebar; }, +/* harmony export */ "setSharing": function() { return /* binding */ setSharing; }, +/* harmony export */ "showClickBehaviorSidebar": function() { return /* binding */ showClickBehaviorSidebar; }, +/* harmony export */ "setEditingParameter": function() { return /* binding */ setEditingParameter; }, +/* harmony export */ "openAddQuestionSidebar": function() { return /* binding */ openAddQuestionSidebar; }, +/* harmony export */ "markNewCardSeen": function() { return /* binding */ markNewCardSeen; }, +/* harmony export */ "showAddParameterPopover": function() { return /* binding */ showAddParameterPopover; }, +/* harmony export */ "hideAddParameterPopover": function() { return /* binding */ hideAddParameterPopover; }, +/* harmony export */ "setDashboardAttributes": function() { return /* binding */ setDashboardAttributes; }, +/* harmony export */ "setDashCardAttributes": function() { return /* binding */ setDashCardAttributes; }, +/* harmony export */ "setMultipleDashCardAttributes": function() { return /* binding */ setMultipleDashCardAttributes; }, +/* harmony export */ "addCardToDashboard": function() { return /* binding */ addCardToDashboard; }, +/* harmony export */ "addDashCardToDashboard": function() { return /* binding */ addDashCardToDashboard; }, +/* harmony export */ "addTextDashCardToDashboard": function() { return /* binding */ addTextDashCardToDashboard; }, +/* harmony export */ "saveDashboardAndCards": function() { return /* binding */ saveDashboardAndCards; }, +/* harmony export */ "removeCardFromDashboard": function() { return /* binding */ removeCardFromDashboard; }, +/* harmony export */ "clearCardData": function() { return /* binding */ clearCardData; }, +/* harmony export */ "fetchDashboardCardData": function() { return /* binding */ fetchDashboardCardData; }, +/* harmony export */ "cancelFetchDashboardCardData": function() { return /* binding */ cancelFetchDashboardCardData; }, +/* harmony export */ "cancelFetchCardData": function() { return /* binding */ cancelFetchCardData; }, +/* harmony export */ "fetchCardData": function() { return /* binding */ fetchCardData; }, +/* harmony export */ "markCardAsSlow": function() { return /* binding */ markCardAsSlow; }, +/* harmony export */ "fetchDashboard": function() { return /* binding */ fetchDashboard; }, +/* harmony export */ "UPDATE_ENABLE_EMBEDDING": function() { return /* binding */ UPDATE_ENABLE_EMBEDDING; }, +/* harmony export */ "updateEnableEmbedding": function() { return /* binding */ updateEnableEmbedding; }, +/* harmony export */ "UPDATE_EMBEDDING_PARAMS": function() { return /* binding */ UPDATE_EMBEDDING_PARAMS; }, +/* harmony export */ "updateEmbeddingParams": function() { return /* binding */ updateEmbeddingParams; }, +/* harmony export */ "onUpdateDashCardVisualizationSettings": function() { return /* binding */ onUpdateDashCardVisualizationSettings; }, +/* harmony export */ "onUpdateDashCardColumnSettings": function() { return /* binding */ onUpdateDashCardColumnSettings; }, +/* harmony export */ "onReplaceAllDashCardVisualizationSettings": function() { return /* binding */ onReplaceAllDashCardVisualizationSettings; }, +/* harmony export */ "setParameterMapping": function() { return /* binding */ setParameterMapping; }, +/* harmony export */ "addParameter": function() { return /* binding */ addParameter; }, +/* harmony export */ "removeParameter": function() { return /* binding */ removeParameter; }, +/* harmony export */ "setParameter": function() { return /* binding */ setParameter; }, +/* harmony export */ "setParameterName": function() { return /* binding */ setParameterName; }, +/* harmony export */ "setParameterFilteringParameters": function() { return /* binding */ setParameterFilteringParameters; }, +/* harmony export */ "setParameterDefaultValue": function() { return /* binding */ setParameterDefaultValue; }, +/* harmony export */ "setParameterIndex": function() { return /* binding */ setParameterIndex; }, +/* harmony export */ "setParameterValue": function() { return /* binding */ setParameterValue; }, +/* harmony export */ "setOrUnsetParameterValues": function() { return /* binding */ setOrUnsetParameterValues; }, +/* harmony export */ "CREATE_PUBLIC_LINK": function() { return /* binding */ CREATE_PUBLIC_LINK; }, +/* harmony export */ "createPublicLink": function() { return /* binding */ createPublicLink; }, +/* harmony export */ "DELETE_PUBLIC_LINK": function() { return /* binding */ DELETE_PUBLIC_LINK; }, +/* harmony export */ "deletePublicLink": function() { return /* binding */ deletePublicLink; }, +/* harmony export */ "navigateToNewCardFromDashboard": function() { return /* binding */ navigateToNewCardFromDashboard; } +/* harmony export */ }); +/* harmony import */ var icepick__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! icepick */ "../../../node_modules/icepick/icepick.min.js"); +/* harmony import */ var icepick__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(icepick__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! underscore */ "../../../node_modules/underscore/modules/index-all.js"); +/* harmony import */ var metabase_lib_redux__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/lib/redux */ "./lib/redux.js"); +/* harmony import */ var metabase_lib_dom__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/lib/dom */ "./lib/dom.js"); +/* harmony import */ var metabase_lib_promise__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! metabase/lib/promise */ "./lib/promise.js"); +/* harmony import */ var normalizr__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! normalizr */ "../../../node_modules/normalizr/dist/normalizr.es.js"); +/* harmony import */ var metabase_lib_lib_Question__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! metabase-lib/lib/Question */ "../metabase-lib/lib/Question.ts"); +/* harmony import */ var metabase_entities_dashboards__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! metabase/entities/dashboards */ "./entities/dashboards.js"); +/* harmony import */ var metabase_entities_questions__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! metabase/entities/questions */ "./entities/questions.js"); +/* harmony import */ var metabase_parameters_utils_dashboards__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! metabase/parameters/utils/dashboards */ "./parameters/utils/dashboards.js"); +/* harmony import */ var metabase_meta_Card__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! metabase/meta/Card */ "./meta/Card.js"); +/* harmony import */ var metabase_parameters_utils_parameter_values__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! metabase/parameters/utils/parameter-values */ "./parameters/utils/parameter-values.js"); +/* harmony import */ var metabase_lib_urls__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! metabase/lib/urls */ "./lib/urls.js"); +/* harmony import */ var metabase_dashboard_constants__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! metabase/dashboard/constants */ "./dashboard/constants.js"); +/* harmony import */ var metabase_lib_utils__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! metabase/lib/utils */ "./lib/utils.js"); +/* harmony import */ var metabase_lib_dashboard_grid__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! metabase/lib/dashboard_grid */ "./lib/dashboard_grid.js"); +/* harmony import */ var metabase_lib_click_behavior__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! metabase/lib/click-behavior */ "./lib/click-behavior.js"); +/* harmony import */ var metabase_lib_card__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! metabase/lib/card */ "./lib/card.js"); +/* harmony import */ var metabase_redux_metadata__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! metabase/redux/metadata */ "./redux/metadata.js"); +/* harmony import */ var react_router_redux__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! react-router-redux */ "../../../node_modules/react-router-redux/lib/index.js"); +/* harmony import */ var metabase_services__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! metabase/services */ "./services.js"); +/* harmony import */ var _selectors__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./selectors */ "./dashboard/selectors.js"); +/* harmony import */ var metabase_selectors_metadata__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! metabase/selectors/metadata */ "./selectors/metadata.js"); +/* harmony import */ var metabase_visualizations_lib_utils__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! metabase/visualizations/lib/utils */ "./visualizations/lib/utils.js"); +/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./utils */ "./dashboard/utils.js"); +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } + +function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } + +function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } + +function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } + +function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } + +/* eslint-disable react/prop-types */ + + + + + + + + + + + + + + + + + + + + + + + + + +var DATASET_SLOW_TIMEOUT = 15 * 1000; // normalizr schemas + +var dashcard = new normalizr__WEBPACK_IMPORTED_MODULE_24__.schema.Entity("dashcard"); +var dashboard = new normalizr__WEBPACK_IMPORTED_MODULE_24__.schema.Entity("dashboard", { + ordered_cards: [dashcard] +}); // action constants + +var INITIALIZE = "metabase/dashboard/INITIALIZE"; +var SET_EDITING_DASHBOARD = "metabase/dashboard/SET_EDITING_DASHBOARD"; // NOTE: this is used in metabase/redux/metadata but can't be imported directly due to circular reference + +var FETCH_DASHBOARD = "metabase/dashboard/FETCH_DASHBOARD"; +var SAVE_DASHBOARD_AND_CARDS = "metabase/dashboard/SAVE_DASHBOARD_AND_CARDS"; +var SET_DASHBOARD_ATTRIBUTES = "metabase/dashboard/SET_DASHBOARD_ATTRIBUTES"; +var ADD_CARD_TO_DASH = "metabase/dashboard/ADD_CARD_TO_DASH"; +var REMOVE_CARD_FROM_DASH = "metabase/dashboard/REMOVE_CARD_FROM_DASH"; +var SET_DASHCARD_ATTRIBUTES = "metabase/dashboard/SET_DASHCARD_ATTRIBUTES"; +var SET_MULTIPLE_DASHCARD_ATTRIBUTES = "metabase/dashboard/SET_MULTIPLE_DASHCARD_ATTRIBUTES"; +var UPDATE_DASHCARD_VISUALIZATION_SETTINGS = "metabase/dashboard/UPDATE_DASHCARD_VISUALIZATION_SETTINGS"; +var UPDATE_DASHCARD_VISUALIZATION_SETTINGS_FOR_COLUMN = "metabase/dashboard/UPDATE_DASHCARD_VISUALIZATION_SETTINGS_FOR_COLUMN"; +var REPLACE_ALL_DASHCARD_VISUALIZATION_SETTINGS = "metabase/dashboard/REPLACE_ALL_DASHCARD_VISUALIZATION_SETTINGS"; +var UPDATE_DASHCARD_ID = "metabase/dashboard/UPDATE_DASHCARD_ID"; +var FETCH_DASHBOARD_CARD_DATA = "metabase/dashboard/FETCH_DASHBOARD_CARD_DATA"; +var FETCH_CARD_DATA = "metabase/dashboard/FETCH_CARD_DATA"; +var CANCEL_FETCH_DASHBOARD_CARD_DATA = "metabase/dashboard/CANCEL_FETCH_DASHBOARD_CARD_DATA"; +var CANCEL_FETCH_CARD_DATA = "metabase/dashboard/CANCEL_FETCH_CARD_DATA"; +var MARK_CARD_AS_SLOW = "metabase/dashboard/MARK_CARD_AS_SLOW"; +var CLEAR_CARD_DATA = "metabase/dashboard/CLEAR_CARD_DATA"; +var MARK_NEW_CARD_SEEN = "metabase/dashboard/MARK_NEW_CARD_SEEN"; +var ADD_PARAMETER = "metabase/dashboard/ADD_PARAMETER"; +var REMOVE_PARAMETER = "metabase/dashboard/REMOVE_PARAMETER"; +var SET_PARAMETER_MAPPING = "metabase/dashboard/SET_PARAMETER_MAPPING"; +var SET_PARAMETER_NAME = "metabase/dashboard/SET_PARAMETER_NAME"; +var SET_PARAMETER_VALUE = "metabase/dashboard/SET_PARAMETER_VALUE"; +var SET_PARAMETER_INDEX = "metabase/dashboard/SET_PARAMETER_INDEX"; +var SET_PARAMETER_DEFAULT_VALUE = "metabase/dashboard/SET_PARAMETER_DEFAULT_VALUE"; +var SHOW_ADD_PARAMETER_POPOVER = "metabase/dashboard/SHOW_ADD_PARAMETER_POPOVER"; +var HIDE_ADD_PARAMETER_POPOVER = "metabase/dashboard/HIDE_ADD_PARAMETER_POPOVER"; +var SET_SIDEBAR = "metabase/dashboard/SET_SIDEBAR"; +var CLOSE_SIDEBAR = "metabase/dashboard/CLOSE_SIDEBAR"; +var initialize = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_2__.createAction)(INITIALIZE); +var setEditingDashboard = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_2__.createAction)(SET_EDITING_DASHBOARD); +var setSidebar = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_2__.createAction)(SET_SIDEBAR); +var closeSidebar = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_2__.createAction)(CLOSE_SIDEBAR); +var setSharing = function setSharing(isSharing) { + return function (dispatch) { + if (isSharing) { + dispatch(setSidebar({ + name: metabase_dashboard_constants__WEBPACK_IMPORTED_MODULE_12__.SIDEBAR_NAME.sharing + })); + } else { + dispatch(closeSidebar()); + } + }; +}; +var showClickBehaviorSidebar = function showClickBehaviorSidebar(dashcardId) { + return function (dispatch) { + if (dashcardId != null) { + dispatch(setSidebar({ + name: metabase_dashboard_constants__WEBPACK_IMPORTED_MODULE_12__.SIDEBAR_NAME.clickBehavior, + props: { + dashcardId: dashcardId + } + })); + } else { + dispatch(closeSidebar()); + } + }; +}; +var setEditingParameter = function setEditingParameter(parameterId) { + return function (dispatch) { + if (parameterId != null) { + dispatch(setSidebar({ + name: metabase_dashboard_constants__WEBPACK_IMPORTED_MODULE_12__.SIDEBAR_NAME.editParameter, + props: { + parameterId: parameterId + } + })); + } else { + dispatch(closeSidebar()); + } + }; +}; +var openAddQuestionSidebar = function openAddQuestionSidebar() { + return function (dispatch) { + dispatch(setSidebar({ + name: metabase_dashboard_constants__WEBPACK_IMPORTED_MODULE_12__.SIDEBAR_NAME.addQuestion + })); + }; +}; +var markNewCardSeen = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_2__.createAction)(MARK_NEW_CARD_SEEN); +var showAddParameterPopover = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_2__.createAction)(SHOW_ADD_PARAMETER_POPOVER); +var hideAddParameterPopover = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_2__.createAction)(HIDE_ADD_PARAMETER_POPOVER); // these operations don't get saved to server immediately + +var setDashboardAttributes = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_2__.createAction)(SET_DASHBOARD_ATTRIBUTES); +var setDashCardAttributes = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_2__.createAction)(SET_DASHCARD_ATTRIBUTES); +var setMultipleDashCardAttributes = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_2__.createAction)(SET_MULTIPLE_DASHCARD_ATTRIBUTES); + +function generateTemporaryDashcardId() { + return Math.random(); +} // real dashcard ids are integers >= 1 + + +function isNewDashcard(dashcard) { + return dashcard.id < 1 && dashcard.id >= 0; +} + +var addCardToDashboard = function addCardToDashboard(_ref) { + var dashId = _ref.dashId, + cardId = _ref.cardId; + return /*#__PURE__*/function () { + var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(dispatch, getState) { + var card, _getState$dashboard, dashboards, dashcards, dashboard, existingCards, dashcard; + + return regeneratorRuntime.wrap(function _callee$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + _context.next = 2; + return dispatch(metabase_entities_questions__WEBPACK_IMPORTED_MODULE_7__.default.actions.fetch({ + id: cardId + })); + + case 2: + card = metabase_entities_questions__WEBPACK_IMPORTED_MODULE_7__.default.selectors.getObject(getState(), { + entityId: cardId + }); + _getState$dashboard = getState().dashboard, dashboards = _getState$dashboard.dashboards, dashcards = _getState$dashboard.dashcards; + dashboard = dashboards[dashId]; + existingCards = dashboard.ordered_cards.map(function (id) { + return dashcards[id]; + }).filter(function (dc) { + return !dc.isRemoved; + }); + dashcard = _objectSpread(_objectSpread({ + id: generateTemporaryDashcardId(), + dashboard_id: dashId, + card_id: card.id, + card: card, + series: [] + }, (0,metabase_lib_dashboard_grid__WEBPACK_IMPORTED_MODULE_14__.getPositionForNewDashCard)(existingCards)), {}, { + parameter_mappings: [], + visualization_settings: {} + }); + dispatch((0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_2__.createAction)(ADD_CARD_TO_DASH)(dashcard)); + dispatch(fetchCardData(card, dashcard, { + reload: true, + clear: true + })); + dispatch(loadMetadataForDashboard([dashcard])); + + case 10: + case "end": + return _context.stop(); + } + } + }, _callee); + })); + + return function (_x, _x2) { + return _ref2.apply(this, arguments); + }; + }(); +}; +var addDashCardToDashboard = function addDashCardToDashboard(_ref3) { + var dashId = _ref3.dashId, + dashcardOverrides = _ref3.dashcardOverrides; + return function (dispatch, getState) { + var _getState$dashboard2 = getState().dashboard, + dashboards = _getState$dashboard2.dashboards, + dashcards = _getState$dashboard2.dashcards; + var dashboard = dashboards[dashId]; + var existingCards = dashboard.ordered_cards.map(function (id) { + return dashcards[id]; + }).filter(function (dc) { + return !dc.isRemoved; + }); + + var dashcard = _objectSpread(_objectSpread({ + id: generateTemporaryDashcardId(), + card_id: null, + card: null, + dashboard_id: dashId, + series: [] + }, (0,metabase_lib_dashboard_grid__WEBPACK_IMPORTED_MODULE_14__.getPositionForNewDashCard)(existingCards)), {}, { + parameter_mappings: [], + visualization_settings: {} + }); + + underscore__WEBPACK_IMPORTED_MODULE_1__.default.extend(dashcard, dashcardOverrides); + + dispatch((0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_2__.createAction)(ADD_CARD_TO_DASH)(dashcard)); + }; +}; +var addTextDashCardToDashboard = function addTextDashCardToDashboard(_ref4) { + var dashId = _ref4.dashId; + var virtualTextCard = (0,metabase_lib_card__WEBPACK_IMPORTED_MODULE_16__.createCard)(); + virtualTextCard.display = "text"; + virtualTextCard.archived = false; + var dashcardOverrides = { + card: virtualTextCard, + visualization_settings: { + virtual_card: virtualTextCard + } + }; + return addDashCardToDashboard({ + dashId: dashId, + dashcardOverrides: dashcardOverrides + }); +}; +var saveDashboardAndCards = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_2__.createThunkAction)(SAVE_DASHBOARD_AND_CARDS, function () { + return /*#__PURE__*/function () { + var _ref5 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(dispatch, getState) { + var state, _state$dashboard, dashboards, dashcards, dashboardId, dashboard, dashboardBeforeEditing, clickBehaviorPath, updatedDashcards, id, name, description, parameters, cards, result; + + return regeneratorRuntime.wrap(function _callee4$(_context4) { + while (1) { + switch (_context4.prev = _context4.next) { + case 0: + state = getState(); + _state$dashboard = state.dashboard, dashboards = _state$dashboard.dashboards, dashcards = _state$dashboard.dashcards, dashboardId = _state$dashboard.dashboardId; + dashboard = _objectSpread(_objectSpread({}, dashboards[dashboardId]), {}, { + ordered_cards: dashboards[dashboardId].ordered_cards.map(function (dashcardId) { + return dashcards[dashcardId]; + }) + }); // clean invalid dashcards + // We currently only do this for dashcard click behavior. + // Invalid (partially complete) states are fine during editing, + // but we should restore the previous value if saved while invalid. + + dashboardBeforeEditing = (0,_selectors__WEBPACK_IMPORTED_MODULE_20__.getDashboardBeforeEditing)(state); + clickBehaviorPath = ["visualization_settings", "click_behavior"]; + dashboard.ordered_cards = dashboard.ordered_cards.map(function (card, index) { + if (!(0,metabase_lib_click_behavior__WEBPACK_IMPORTED_MODULE_15__.clickBehaviorIsValid)((0,icepick__WEBPACK_IMPORTED_MODULE_0__.getIn)(card, clickBehaviorPath))) { + var startingValue = (0,icepick__WEBPACK_IMPORTED_MODULE_0__.getIn)(dashboardBeforeEditing, ["ordered_cards", index].concat(clickBehaviorPath)); + return startingValue == null ? (0,icepick__WEBPACK_IMPORTED_MODULE_0__.dissocIn)(card, clickBehaviorPath) : (0,icepick__WEBPACK_IMPORTED_MODULE_0__.assocIn)(card, clickBehaviorPath, startingValue); + } + + return card; + }); // remove isRemoved dashboards + + _context4.next = 8; + return Promise.all(dashboard.ordered_cards.filter(function (dc) { + return dc.isRemoved && !dc.isAdded; + }).map(function (dc) { + return metabase_services__WEBPACK_IMPORTED_MODULE_19__.DashboardApi.removecard({ + dashId: dashboard.id, + dashcardId: dc.id + }); + })); + + case 8: + _context4.next = 10; + return Promise.all(dashboard.ordered_cards.filter(function (dc) { + return !dc.isRemoved; + }).map( /*#__PURE__*/function () { + var _ref6 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(dc) { + var result; + return regeneratorRuntime.wrap(function _callee2$(_context2) { + while (1) { + switch (_context2.prev = _context2.next) { + case 0: + if (!dc.isAdded) { + _context2.next = 8; + break; + } + + _context2.next = 3; + return metabase_services__WEBPACK_IMPORTED_MODULE_19__.DashboardApi.addcard({ + dashId: dashboard.id, + cardId: dc.card_id + }); + + case 3: + result = _context2.sent; + dispatch(updateDashcardId(dc.id, result.id)); // mark isAdded because addcard doesn't record the position + + return _context2.abrupt("return", _objectSpread(_objectSpread({}, result), {}, { + col: dc.col, + row: dc.row, + sizeX: dc.sizeX, + sizeY: dc.sizeY, + series: dc.series, + parameter_mappings: dc.parameter_mappings, + visualization_settings: dc.visualization_settings, + isAdded: true + })); + + case 8: + return _context2.abrupt("return", dc); + + case 9: + case "end": + return _context2.stop(); + } + } + }, _callee2); + })); + + return function (_x5) { + return _ref6.apply(this, arguments); + }; + }())); + + case 10: + updatedDashcards = _context4.sent; + _context4.next = 13; + return Promise.all(dashboard.ordered_cards.filter(function (dc) { + return dc.card.isDirty; + }).map( /*#__PURE__*/function () { + var _ref7 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(dc) { + return regeneratorRuntime.wrap(function _callee3$(_context3) { + while (1) { + switch (_context3.prev = _context3.next) { + case 0: + return _context3.abrupt("return", metabase_services__WEBPACK_IMPORTED_MODULE_19__.CardApi.update(dc.card)); + + case 1: + case "end": + return _context3.stop(); + } + } + }, _callee3); + })); + + return function (_x6) { + return _ref7.apply(this, arguments); + }; + }())); + + case 13: + if (!dashboard.isDirty) { + _context4.next = 17; + break; + } + + id = dashboard.id, name = dashboard.name, description = dashboard.description, parameters = dashboard.parameters; + _context4.next = 17; + return dispatch(metabase_entities_dashboards__WEBPACK_IMPORTED_MODULE_6__.default.actions.update({ + id: id + }, { + name: name, + description: description, + parameters: parameters + })); + + case 17: + if (!underscore__WEBPACK_IMPORTED_MODULE_1__.default.some(updatedDashcards, function (dc) { + return dc.isDirty || dc.isAdded; + })) { + _context4.next = 24; + break; + } + + cards = updatedDashcards.map(function (_ref8) { + var id = _ref8.id, + card_id = _ref8.card_id, + row = _ref8.row, + col = _ref8.col, + sizeX = _ref8.sizeX, + sizeY = _ref8.sizeY, + series = _ref8.series, + parameter_mappings = _ref8.parameter_mappings, + visualization_settings = _ref8.visualization_settings; + return { + id: id, + card_id: card_id, + row: row, + col: col, + sizeX: sizeX, + sizeY: sizeY, + series: series, + visualization_settings: visualization_settings, + parameter_mappings: parameter_mappings && parameter_mappings.filter(function (mapping) { + return (// filter out mappings for deleted parameters + underscore__WEBPACK_IMPORTED_MODULE_1__.default.findWhere(dashboard.parameters, { + id: mapping.parameter_id + }) && (card_id === mapping.card_id || underscore__WEBPACK_IMPORTED_MODULE_1__.default.findWhere(series, { + id: mapping.card_id + })) + ); + }) + }; + }); + _context4.next = 21; + return metabase_services__WEBPACK_IMPORTED_MODULE_19__.DashboardApi.reposition_cards({ + dashId: dashboard.id, + cards: cards + }); + + case 21: + result = _context4.sent; + + if (!(result.status !== "ok")) { + _context4.next = 24; + break; + } + + throw new Error(result.status); + + case 24: + _context4.next = 26; + return dispatch(metabase_entities_dashboards__WEBPACK_IMPORTED_MODULE_6__.default.actions.update(dashboard)); + + case 26: + // make sure that we've fully cleared out any dirty state from editing (this is overkill, but simple) + dispatch(fetchDashboard(dashboard.id, null)); // disable using query parameters when saving + + case 27: + case "end": + return _context4.stop(); + } + } + }, _callee4); + })); + + return function (_x3, _x4) { + return _ref5.apply(this, arguments); + }; + }(); +}); +var removeCardFromDashboard = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_2__.createAction)(REMOVE_CARD_FROM_DASH); +var updateDashcardId = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_2__.createAction)(UPDATE_DASHCARD_ID, function (oldDashcardId, newDashcardId) { + return { + oldDashcardId: oldDashcardId, + newDashcardId: newDashcardId + }; +}); +var clearCardData = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_2__.createAction)(CLEAR_CARD_DATA, function (cardId, dashcardId) { + return { + cardId: cardId, + dashcardId: dashcardId + }; +}); +var fetchDashboardCardData = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_2__.createThunkAction)(FETCH_DASHBOARD_CARD_DATA, function (options) { + return function (dispatch, getState) { + var dashboard = (0,_selectors__WEBPACK_IMPORTED_MODULE_20__.getDashboardComplete)(getState()); + + var _iterator = _createForOfIteratorHelper((0,_utils__WEBPACK_IMPORTED_MODULE_23__.getAllDashboardCards)(dashboard)), + _step; + + try { + for (_iterator.s(); !(_step = _iterator.n()).done;) { + var _step$value = _step.value, + card = _step$value.card, + _dashcard = _step$value.dashcard; + + // we skip over virtual cards, i.e. dashcards that do not have backing cards in the backend + if (!(0,_utils__WEBPACK_IMPORTED_MODULE_23__.isVirtualDashCard)(_dashcard)) { + dispatch(fetchCardData(card, _dashcard, options)); + } + } + } catch (err) { + _iterator.e(err); + } finally { + _iterator.f(); + } + }; +}); +var cancelFetchDashboardCardData = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_2__.createThunkAction)(CANCEL_FETCH_DASHBOARD_CARD_DATA, function () { + return function (dispatch, getState) { + var dashboard = (0,_selectors__WEBPACK_IMPORTED_MODULE_20__.getDashboardComplete)(getState()); + + var _iterator2 = _createForOfIteratorHelper((0,_utils__WEBPACK_IMPORTED_MODULE_23__.getAllDashboardCards)(dashboard)), + _step2; + + try { + for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { + var _step2$value = _step2.value, + card = _step2$value.card, + _dashcard2 = _step2$value.dashcard; + dispatch(cancelFetchCardData(card.id, _dashcard2.id)); + } + } catch (err) { + _iterator2.e(err); + } finally { + _iterator2.f(); + } + }; +}); // TODO: this doesn't need to be stored in Redux, does it? + +var cardDataCancelDeferreds = {}; // machinery to support query cancellation + +var cancelFetchCardData = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_2__.createAction)(CANCEL_FETCH_CARD_DATA, function (card_id, dashcard_id) { + var deferred = cardDataCancelDeferreds["".concat(dashcard_id, ",").concat(card_id)]; + + if (deferred) { + deferred.resolve(); + cardDataCancelDeferreds["".concat(dashcard_id, ",").concat(card_id)] = null; + } + + return { + dashcard_id: dashcard_id, + card_id: card_id + }; +}); + +function setFetchCardDataCancel(card_id, dashcard_id, deferred) { + cardDataCancelDeferreds["".concat(dashcard_id, ",").concat(card_id)] = deferred; +} + +var fetchCardData = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_2__.createThunkAction)(FETCH_CARD_DATA, function (card, dashcard) { + var _ref9 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}, + reload = _ref9.reload, + clear = _ref9.clear, + ignoreCache = _ref9.ignoreCache; + + return /*#__PURE__*/function () { + var _ref10 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5(dispatch, getState) { + var dashboardType, _getState$dashboard3, dashboardId, dashboards, parameterValues, dashcardData, dashboard, datasetQuery, lastResult, result, slowCardTimer, deferred, cancelled, queryOptions, endpoint; + + return regeneratorRuntime.wrap(function _callee5$(_context5) { + while (1) { + switch (_context5.prev = _context5.next) { + case 0: + if (card.dataset_query) { + _context5.next = 2; + break; + } + + return _context5.abrupt("return", { + dashcard_id: dashcard.id, + card_id: card.id, + result: { + error: { + status: 403 + } + } + }); + + case 2: + dashboardType = (0,_utils__WEBPACK_IMPORTED_MODULE_23__.getDashboardType)(dashcard.dashboard_id); + _getState$dashboard3 = getState().dashboard, dashboardId = _getState$dashboard3.dashboardId, dashboards = _getState$dashboard3.dashboards, parameterValues = _getState$dashboard3.parameterValues, dashcardData = _getState$dashboard3.dashcardData; + dashboard = dashboards[dashboardId]; // if we have a parameter, apply it to the card query before we execute + + datasetQuery = (0,metabase_meta_Card__WEBPACK_IMPORTED_MODULE_9__.applyParameters)(card, dashboard.parameters, parameterValues, dashcard && dashcard.parameter_mappings); + + if (reload) { + _context5.next = 10; + break; + } + + // if reload not set, check to see if the last result has the same query dict and return that + lastResult = (0,icepick__WEBPACK_IMPORTED_MODULE_0__.getIn)(dashcardData, [dashcard.id, card.id]); // "constraints" is added by the backend, remove it when comparing + + if (!(lastResult && metabase_lib_utils__WEBPACK_IMPORTED_MODULE_13__.default.equals(underscore__WEBPACK_IMPORTED_MODULE_1__.default.omit(lastResult.json_query, "constraints"), datasetQuery))) { + _context5.next = 10; + break; + } + + return _context5.abrupt("return", { + dashcard_id: dashcard.id, + card_id: card.id, + result: lastResult + }); + + case 10: + cancelFetchCardData(card.id, dashcard.id); + + if (clear) { + // clears the card data to indicate the card is reloading + dispatch(clearCardData(card.id, dashcard.id)); + } + + result = null; // start a timer that will show the expected card duration if the query takes too long + + slowCardTimer = setTimeout(function () { + if (result === null) { + dispatch(markCardAsSlow(card, datasetQuery)); + } + }, DATASET_SLOW_TIMEOUT); + deferred = (0,metabase_lib_promise__WEBPACK_IMPORTED_MODULE_4__.defer)(); + setFetchCardDataCancel(card.id, dashcard.id, deferred); + cancelled = false; + deferred.promise.then(function () { + cancelled = true; + }); + queryOptions = { + cancelled: deferred.promise + }; // make the actual request + + if (!(datasetQuery.type === "endpoint")) { + _context5.next = 25; + break; + } + + _context5.next = 22; + return (0,_utils__WEBPACK_IMPORTED_MODULE_23__.fetchDataOrError)(metabase_services__WEBPACK_IMPORTED_MODULE_19__.MetabaseApi.datasetEndpoint({ + endpoint: datasetQuery.endpoint, + parameters: datasetQuery.parameters + }, queryOptions)); + + case 22: + result = _context5.sent; + _context5.next = 47; + break; + + case 25: + if (!(dashboardType === "public")) { + _context5.next = 31; + break; + } + + _context5.next = 28; + return (0,_utils__WEBPACK_IMPORTED_MODULE_23__.fetchDataOrError)((0,metabase_services__WEBPACK_IMPORTED_MODULE_19__.maybeUsePivotEndpoint)(metabase_services__WEBPACK_IMPORTED_MODULE_19__.PublicApi.dashboardCardQuery, card)({ + uuid: dashcard.dashboard_id, + cardId: card.id, + parameters: datasetQuery.parameters ? JSON.stringify(datasetQuery.parameters) : undefined, + ignore_cache: ignoreCache + }, queryOptions)); + + case 28: + result = _context5.sent; + _context5.next = 47; + break; + + case 31: + if (!(dashboardType === "embed")) { + _context5.next = 37; + break; + } + + _context5.next = 34; + return (0,_utils__WEBPACK_IMPORTED_MODULE_23__.fetchDataOrError)((0,metabase_services__WEBPACK_IMPORTED_MODULE_19__.maybeUsePivotEndpoint)(metabase_services__WEBPACK_IMPORTED_MODULE_19__.EmbedApi.dashboardCardQuery, card)(_objectSpread(_objectSpread({ + token: dashcard.dashboard_id, + dashcardId: dashcard.id, + cardId: card.id + }, (0,metabase_parameters_utils_parameter_values__WEBPACK_IMPORTED_MODULE_10__.getParameterValuesBySlug)(dashboard.parameters, parameterValues)), {}, { + ignore_cache: ignoreCache + }), queryOptions)); + + case 34: + result = _context5.sent; + _context5.next = 47; + break; + + case 37: + if (!(dashboardType === "transient" || dashboardType === "inline")) { + _context5.next = 43; + break; + } + + _context5.next = 40; + return (0,_utils__WEBPACK_IMPORTED_MODULE_23__.fetchDataOrError)((0,metabase_services__WEBPACK_IMPORTED_MODULE_19__.maybeUsePivotEndpoint)(metabase_services__WEBPACK_IMPORTED_MODULE_19__.MetabaseApi.dataset, card)(_objectSpread(_objectSpread({}, datasetQuery), {}, { + ignore_cache: ignoreCache + }), queryOptions)); + + case 40: + result = _context5.sent; + _context5.next = 47; + break; + + case 43: + // new cards aren't yet saved to the dashboard, so they need to be run using the card query endpoint + endpoint = isNewDashcard(dashcard) ? metabase_services__WEBPACK_IMPORTED_MODULE_19__.CardApi.query : metabase_services__WEBPACK_IMPORTED_MODULE_19__.DashboardApi.cardQuery; + _context5.next = 46; + return (0,_utils__WEBPACK_IMPORTED_MODULE_23__.fetchDataOrError)((0,metabase_services__WEBPACK_IMPORTED_MODULE_19__.maybeUsePivotEndpoint)(endpoint, card)({ + dashboardId: dashcard.dashboard_id, + cardId: card.id, + parameters: datasetQuery.parameters, + ignore_cache: ignoreCache, + dashboard_id: dashcard.dashboard_id + }, queryOptions)); + + case 46: + result = _context5.sent; + + case 47: + setFetchCardDataCancel(card.id, dashcard.id, null); + clearTimeout(slowCardTimer); + return _context5.abrupt("return", { + dashcard_id: dashcard.id, + card_id: card.id, + result: cancelled ? null : result + }); + + case 50: + case "end": + return _context5.stop(); + } + } + }, _callee5); + })); + + return function (_x7, _x8) { + return _ref10.apply(this, arguments); + }; + }(); +}); +var markCardAsSlow = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_2__.createAction)(MARK_CARD_AS_SLOW, function (card) { + return { + id: card.id, + result: true + }; +}); +var fetchDashboard = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_2__.createThunkAction)(FETCH_DASHBOARD, function (dashId, queryParams, preserveParameters) { + var result; + return /*#__PURE__*/function () { + var _ref11 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6(dispatch, getState) { + var dashboardType, subPath, metadata, mappingsByParameter, parameters, parameterValuesById; + return regeneratorRuntime.wrap(function _callee6$(_context6) { + while (1) { + switch (_context6.prev = _context6.next) { + case 0: + dashboardType = (0,_utils__WEBPACK_IMPORTED_MODULE_23__.getDashboardType)(dashId); + + if (!(dashboardType === "public")) { + _context6.next = 8; + break; + } + + _context6.next = 4; + return metabase_services__WEBPACK_IMPORTED_MODULE_19__.PublicApi.dashboard({ + uuid: dashId + }); + + case 4: + result = _context6.sent; + result = _objectSpread(_objectSpread({}, result), {}, { + id: dashId, + ordered_cards: result.ordered_cards.map(function (dc) { + return _objectSpread(_objectSpread({}, dc), {}, { + dashboard_id: dashId + }); + }) + }); + _context6.next = 31; + break; + + case 8: + if (!(dashboardType === "embed")) { + _context6.next = 15; + break; + } + + _context6.next = 11; + return metabase_services__WEBPACK_IMPORTED_MODULE_19__.EmbedApi.dashboard({ + token: dashId + }); + + case 11: + result = _context6.sent; + result = _objectSpread(_objectSpread({}, result), {}, { + id: dashId, + ordered_cards: result.ordered_cards.map(function (dc) { + return _objectSpread(_objectSpread({}, dc), {}, { + dashboard_id: dashId + }); + }) + }); + _context6.next = 31; + break; + + case 15: + if (!(dashboardType === "transient")) { + _context6.next = 23; + break; + } + + subPath = dashId.split("/").slice(3).join("/"); + _context6.next = 19; + return metabase_services__WEBPACK_IMPORTED_MODULE_19__.AutoApi.dashboard({ + subPath: subPath + }); + + case 19: + result = _context6.sent; + result = _objectSpread(_objectSpread({}, result), {}, { + id: dashId, + ordered_cards: result.ordered_cards.map(function (dc) { + return _objectSpread(_objectSpread({}, dc), {}, { + dashboard_id: dashId + }); + }) + }); + _context6.next = 31; + break; + + case 23: + if (!(dashboardType === "inline")) { + _context6.next = 28; + break; + } + + // HACK: this is horrible but the easiest way to get "inline" dashboards up and running + // pass the dashboard in as dashboardId, and replace the id with [object Object] because + // that's what it will be when cast to a string + result = (0,_utils__WEBPACK_IMPORTED_MODULE_23__.expandInlineDashboard)(dashId); + dashId = result.id = String(dashId); + _context6.next = 31; + break; + + case 28: + _context6.next = 30; + return metabase_services__WEBPACK_IMPORTED_MODULE_19__.DashboardApi.get({ + dashId: dashId + }); + + case 30: + result = _context6.sent; + + case 31: + if (!(dashboardType === "normal" || dashboardType === "transient")) { + _context6.next = 34; + break; + } + + _context6.next = 34; + return dispatch(loadMetadataForDashboard(result.ordered_cards)); + + case 34: + // copy over any virtual cards from the dashcard to the underlying card/question + result.ordered_cards.forEach(function (card) { + if (card.visualization_settings.virtual_card) { + card.card = Object.assign(card.card || {}, card.visualization_settings.virtual_card); + } + }); + + if (result.param_values) { + dispatch((0,metabase_redux_metadata__WEBPACK_IMPORTED_MODULE_17__.addParamValues)(result.param_values)); + } + + if (result.param_fields) { + dispatch((0,metabase_redux_metadata__WEBPACK_IMPORTED_MODULE_17__.addFields)(result.param_fields)); + } + + metadata = (0,metabase_selectors_metadata__WEBPACK_IMPORTED_MODULE_21__.getMetadata)(getState()); + mappingsByParameter = (0,metabase_parameters_utils_dashboards__WEBPACK_IMPORTED_MODULE_8__.getMappingsByParameter)(metadata, result); + parameters = (0,metabase_parameters_utils_dashboards__WEBPACK_IMPORTED_MODULE_8__.getDashboardParametersWithFieldMetadata)(metadata, result, mappingsByParameter); + parameterValuesById = preserveParameters ? (0,_selectors__WEBPACK_IMPORTED_MODULE_20__.getParameterValues)(getState()) : (0,metabase_parameters_utils_parameter_values__WEBPACK_IMPORTED_MODULE_10__.getParameterValuesByIdFromQueryParams)(parameters, queryParams, metadata, { + forcefullyUnsetDefaultedParametersWithEmptyStringValue: true + }); + return _context6.abrupt("return", _objectSpread(_objectSpread({}, (0,normalizr__WEBPACK_IMPORTED_MODULE_24__.normalize)(result, dashboard)), {}, { + // includes `result` and `entities` + dashboardId: dashId, + parameterValues: parameterValuesById + })); + + case 42: + case "end": + return _context6.stop(); + } + } + }, _callee6); + })); + + return function (_x9, _x10) { + return _ref11.apply(this, arguments); + }; + }(); +}); +var UPDATE_ENABLE_EMBEDDING = "metabase/dashboard/UPDATE_ENABLE_EMBEDDING"; +var updateEnableEmbedding = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_2__.createAction)(UPDATE_ENABLE_EMBEDDING, function (_ref12, enable_embedding) { + var id = _ref12.id; + return metabase_services__WEBPACK_IMPORTED_MODULE_19__.DashboardApi.update({ + id: id, + enable_embedding: enable_embedding + }); +}); +var UPDATE_EMBEDDING_PARAMS = "metabase/dashboard/UPDATE_EMBEDDING_PARAMS"; +var updateEmbeddingParams = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_2__.createAction)(UPDATE_EMBEDDING_PARAMS, function (_ref13, embedding_params) { + var id = _ref13.id; + return metabase_services__WEBPACK_IMPORTED_MODULE_19__.DashboardApi.update({ + id: id, + embedding_params: embedding_params + }); +}); +var onUpdateDashCardVisualizationSettings = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_2__.createAction)(UPDATE_DASHCARD_VISUALIZATION_SETTINGS, function (id, settings) { + return { + id: id, + settings: settings + }; +}); +var onUpdateDashCardColumnSettings = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_2__.createAction)(UPDATE_DASHCARD_VISUALIZATION_SETTINGS_FOR_COLUMN, function (id, column, settings) { + return { + id: id, + column: column, + settings: settings + }; +}); +var onReplaceAllDashCardVisualizationSettings = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_2__.createAction)(REPLACE_ALL_DASHCARD_VISUALIZATION_SETTINGS, function (id, settings) { + return { + id: id, + settings: settings + }; +}); +var setParameterMapping = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_2__.createThunkAction)(SET_PARAMETER_MAPPING, function (parameter_id, dashcard_id, card_id, target) { + return function (dispatch, getState) { + var parameter_mappings = getState().dashboard.dashcards[dashcard_id].parameter_mappings || []; + parameter_mappings = parameter_mappings.filter(function (m) { + return m.card_id !== card_id || m.parameter_id !== parameter_id; + }); + + if (target) { + parameter_mappings = parameter_mappings.concat({ + parameter_id: parameter_id, + card_id: card_id, + target: target + }); + } + + dispatch(setDashCardAttributes({ + id: dashcard_id, + attributes: { + parameter_mappings: parameter_mappings + } + })); + }; +}); + +function updateParameter(dispatch, getState, id, parameterUpdater) { + var dashboard = (0,_selectors__WEBPACK_IMPORTED_MODULE_20__.getDashboard)(getState()); + + var index = underscore__WEBPACK_IMPORTED_MODULE_1__.default.findIndex(dashboard && dashboard.parameters, function (p) { + return p.id === id; + }); + + if (index >= 0) { + var parameters = (0,icepick__WEBPACK_IMPORTED_MODULE_0__.assoc)(dashboard.parameters, index, parameterUpdater(dashboard.parameters[index])); + dispatch(setDashboardAttributes({ + id: dashboard.id, + attributes: { + parameters: parameters + } + })); + } +} + +function updateParameters(dispatch, getState, parametersUpdater) { + var dashboard = (0,_selectors__WEBPACK_IMPORTED_MODULE_20__.getDashboard)(getState()); + + if (dashboard) { + var parameters = parametersUpdater(dashboard.parameters || []); + dispatch(setDashboardAttributes({ + id: dashboard.id, + attributes: { + parameters: parameters + } + })); + } +} + +var addParameter = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_2__.createThunkAction)(ADD_PARAMETER, function (parameterOption) { + return function (dispatch, getState) { + var parameter; + updateParameters(dispatch, getState, function (parameters) { + parameter = (0,metabase_parameters_utils_dashboards__WEBPACK_IMPORTED_MODULE_8__.createParameter)(parameterOption, parameters); + return parameters.concat(parameter); + }); + dispatch(setSidebar({ + name: metabase_dashboard_constants__WEBPACK_IMPORTED_MODULE_12__.SIDEBAR_NAME.editParameter, + props: { + parameterId: parameter.id + } + })); + }; +}); +var removeParameter = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_2__.createThunkAction)(REMOVE_PARAMETER, function (parameterId) { + return function (dispatch, getState) { + updateParameters(dispatch, getState, function (parameters) { + return parameters.filter(function (p) { + return p.id !== parameterId; + }); + }); + }; +}); +var setParameter = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_2__.createThunkAction)(SET_PARAMETER_NAME, function (parameterId, parameter) { + return function (dispatch, getState) { + updateParameter(dispatch, getState, parameterId, function () { + return parameter; + }); + return _objectSpread({ + id: parameterId + }, parameter); + }; +}); +var setParameterName = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_2__.createThunkAction)(SET_PARAMETER_NAME, function (parameterId, name) { + return function (dispatch, getState) { + updateParameter(dispatch, getState, parameterId, function (parameter) { + return (0,metabase_parameters_utils_dashboards__WEBPACK_IMPORTED_MODULE_8__.setParameterName)(parameter, name); + }); + return { + id: parameterId, + name: name + }; + }; +}); +var setParameterFilteringParameters = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_2__.createThunkAction)(SET_PARAMETER_NAME, function (parameterId, filteringParameters) { + return function (dispatch, getState) { + updateParameter(dispatch, getState, parameterId, function (parameter) { + return _objectSpread(_objectSpread({}, parameter), {}, { + filteringParameters: filteringParameters + }); + }); + return { + id: parameterId, + filteringParameters: filteringParameters + }; + }; +}); +var setParameterDefaultValue = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_2__.createThunkAction)(SET_PARAMETER_DEFAULT_VALUE, function (parameterId, defaultValue) { + return function (dispatch, getState) { + updateParameter(dispatch, getState, parameterId, function (parameter) { + return (0,metabase_parameters_utils_dashboards__WEBPACK_IMPORTED_MODULE_8__.setParameterDefaultValue)(parameter, defaultValue); + }); + return { + id: parameterId, + defaultValue: defaultValue + }; + }; +}); +var setParameterIndex = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_2__.createThunkAction)(SET_PARAMETER_INDEX, function (parameterId, index) { + return function (dispatch, getState) { + var dashboard = (0,_selectors__WEBPACK_IMPORTED_MODULE_20__.getDashboard)(getState()); + + var parameterIndex = underscore__WEBPACK_IMPORTED_MODULE_1__.default.findIndex(dashboard.parameters, function (p) { + return p.id === parameterId; + }); + + if (parameterIndex >= 0) { + var parameters = dashboard.parameters.slice(); + parameters.splice(index, 0, parameters.splice(parameterIndex, 1)[0]); + dispatch(setDashboardAttributes({ + id: dashboard.id, + attributes: { + parameters: parameters + } + })); + } + + return { + id: parameterId, + index: index + }; + }; +}); +var setParameterValue = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_2__.createThunkAction)(SET_PARAMETER_VALUE, function (parameterId, value) { + return function (dispatch, getState) { + return { + id: parameterId, + value: value + }; + }; +}); +var setOrUnsetParameterValues = function setOrUnsetParameterValues(parameterIdValuePairs) { + return function (dispatch, getState) { + var parameterValues = (0,_selectors__WEBPACK_IMPORTED_MODULE_20__.getParameterValues)(getState()); + parameterIdValuePairs.map(function (_ref14) { + var _ref15 = _slicedToArray(_ref14, 2), + id = _ref15[0], + value = _ref15[1]; + + return setParameterValue(id, value === parameterValues[id] ? null : value); + }).forEach(dispatch); + }; +}; +var CREATE_PUBLIC_LINK = "metabase/dashboard/CREATE_PUBLIC_LINK"; +var createPublicLink = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_2__.createAction)(CREATE_PUBLIC_LINK, /*#__PURE__*/function () { + var _ref17 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee7(_ref16) { + var id, _yield$DashboardApi$c, uuid; + + return regeneratorRuntime.wrap(function _callee7$(_context7) { + while (1) { + switch (_context7.prev = _context7.next) { + case 0: + id = _ref16.id; + _context7.next = 3; + return metabase_services__WEBPACK_IMPORTED_MODULE_19__.DashboardApi.createPublicLink({ + id: id + }); + + case 3: + _yield$DashboardApi$c = _context7.sent; + uuid = _yield$DashboardApi$c.uuid; + return _context7.abrupt("return", { + id: id, + uuid: uuid + }); + + case 6: + case "end": + return _context7.stop(); + } + } + }, _callee7); + })); + + return function (_x11) { + return _ref17.apply(this, arguments); + }; +}()); +var DELETE_PUBLIC_LINK = "metabase/dashboard/DELETE_PUBLIC_LINK"; +var deletePublicLink = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_2__.createAction)(DELETE_PUBLIC_LINK, /*#__PURE__*/function () { + var _ref19 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee8(_ref18) { + var id; + return regeneratorRuntime.wrap(function _callee8$(_context8) { + while (1) { + switch (_context8.prev = _context8.next) { + case 0: + id = _ref18.id; + _context8.next = 3; + return metabase_services__WEBPACK_IMPORTED_MODULE_19__.DashboardApi.deletePublicLink({ + id: id + }); + + case 3: + return _context8.abrupt("return", { + id: id + }); + + case 4: + case "end": + return _context8.stop(); + } + } + }, _callee8); + })); + + return function (_x12) { + return _ref19.apply(this, arguments); + }; +}()); +/** + * All navigation actions from dashboards to cards (e.x. clicking a title, drill through) + * should go through this action, which merges any currently applied dashboard filters + * into the new card / URL parameters. + * + * User-triggered events that are handled here: + * - clicking a dashcard legend: + * * question title legend (only for single-question cards) + * * series legend (multi-aggregation, multi-breakout, multiple questions) + * - clicking the visualization inside dashcard + * * drill-through (single series, multi-aggregation, multi-breakout, multiple questions) + * * (not in 0.24.2 yet: drag on line/area/bar visualization) + * - those all can be applied without or with a dashboard filter + */ + +var NAVIGATE_TO_NEW_CARD = "metabase/dashboard/NAVIGATE_TO_NEW_CARD"; +var navigateToNewCardFromDashboard = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_2__.createThunkAction)(NAVIGATE_TO_NEW_CARD, function (_ref20) { + var nextCard = _ref20.nextCard, + previousCard = _ref20.previousCard, + dashcard = _ref20.dashcard; + return function (dispatch, getState) { + var metadata = (0,metabase_selectors_metadata__WEBPACK_IMPORTED_MODULE_21__.getMetadata)(getState()); + var _getState$dashboard4 = getState().dashboard, + dashboardId = _getState$dashboard4.dashboardId, + dashboards = _getState$dashboard4.dashboards, + parameterValues = _getState$dashboard4.parameterValues; + var dashboard = dashboards[dashboardId]; + var cardAfterClick = (0,metabase_visualizations_lib_utils__WEBPACK_IMPORTED_MODULE_22__.getCardAfterVisualizationClick)(nextCard, previousCard); + var question = new metabase_lib_lib_Question__WEBPACK_IMPORTED_MODULE_5__.default(cardAfterClick, metadata); + + if (question.query().isEditable()) { + question = question.setDisplay(cardAfterClick.display || previousCard.display).setSettings(dashcard.card.visualization_settings).lockDisplay(); + } else { + question = question.setCard(dashcard.card).setDashboardId(dashboard.id); + } + + var parametersMappedToCard = (0,metabase_parameters_utils_dashboards__WEBPACK_IMPORTED_MODULE_8__.getParametersMappedToDashcard)(dashboard, dashcard); // when the query is for a specific object it does not make sense to apply parameter filters + // because we'll be navigating to the details view of a specific row on a table + + var url = question.isObjectDetail() ? metabase_lib_urls__WEBPACK_IMPORTED_MODULE_11__.serializedQuestion(question.card()) : question.getUrlWithParameters(parametersMappedToCard, parameterValues); + (0,metabase_lib_dom__WEBPACK_IMPORTED_MODULE_3__.open)(url, { + blankOnMetaOrCtrlKey: true, + openInSameWindow: function openInSameWindow(url) { + return dispatch((0,react_router_redux__WEBPACK_IMPORTED_MODULE_18__.push)(url)); + } + }); + }; +}); + +var loadMetadataForDashboard = function loadMetadataForDashboard(dashCards) { + return function (dispatch, getState) { + var metadata = (0,metabase_selectors_metadata__WEBPACK_IMPORTED_MODULE_21__.getMetadata)(getState()); + var queries = dashCards.filter(function (dc) { + return !(0,_utils__WEBPACK_IMPORTED_MODULE_23__.isVirtualDashCard)(dc) && dc.card.dataset_query; + }) // exclude text cards and queries without perms + .flatMap(function (dc) { + return [dc.card].concat(dc.series || []); + }).map(function (card) { + return new metabase_lib_lib_Question__WEBPACK_IMPORTED_MODULE_5__.default(card, metadata).query(); + }); + return dispatch((0,metabase_redux_metadata__WEBPACK_IMPORTED_MODULE_17__.loadMetadataForQueries)(queries)); + }; +}; + +/***/ }), + +/***/ "./dashboard/components/AddSeriesModal/AddSeriesModal.jsx": +/*!****************************************************************!*\ + !*** ./dashboard/components/AddSeriesModal/AddSeriesModal.jsx ***! + \****************************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* binding */ AddSeriesModal; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prop-types */ "../../../node_modules/prop-types/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_2__); +/* harmony import */ var icepick__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! icepick */ "../../../node_modules/icepick/icepick.min.js"); +/* harmony import */ var icepick__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(icepick__WEBPACK_IMPORTED_MODULE_3__); +/* harmony import */ var react_redux__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! react-redux */ "../../../node_modules/react-redux/es/index.js"); +/* harmony import */ var reselect__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! reselect */ "../../../node_modules/reselect/lib/index.js"); +/* harmony import */ var metabase_visualizations_components_Visualization__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! metabase/visualizations/components/Visualization */ "./visualizations/components/Visualization.jsx"); +/* harmony import */ var metabase_lib_analytics__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! metabase/lib/analytics */ "./lib/analytics.js"); +/* harmony import */ var metabase_lib_colors__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! metabase/lib/colors */ "./lib/colors.ts"); +/* harmony import */ var metabase_entities_questions__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! metabase/entities/questions */ "./entities/questions.js"); +/* harmony import */ var metabase_selectors_metadata__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! metabase/selectors/metadata */ "./selectors/metadata.js"); +/* harmony import */ var metabase_redux_metadata__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! metabase/redux/metadata */ "./redux/metadata.js"); +/* harmony import */ var metabase_lib_lib_Question__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! metabase-lib/lib/Question */ "../metabase-lib/lib/Question.ts"); +/* harmony import */ var metabase_visualizations__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! metabase/visualizations */ "./visualizations/index.js"); +/* harmony import */ var _QuestionList__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./QuestionList */ "./dashboard/components/AddSeriesModal/QuestionList.jsx"); +/* provided dependency */ var console = __webpack_require__(/*! console-browserify */ "../../../node_modules/console-browserify/index.js"); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +var _dec, _dec2, _class, _class2, _temp, _templateObject, _templateObject2, _templateObject3, _templateObject4; + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + +function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } + +function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/* eslint-disable react/prop-types */ + + + + + + + + + + + + + + + +var getQuestions = (0,reselect__WEBPACK_IMPORTED_MODULE_5__.createSelector)([metabase_selectors_metadata__WEBPACK_IMPORTED_MODULE_10__.getMetadataWithHiddenTables, function (_state, props) { + return props.questions; +}], function (metadata, questions) { + return questions && questions.map(function (card) { + return new metabase_lib_lib_Question__WEBPACK_IMPORTED_MODULE_12__.default(card, metadata); + }); +}); // TODO: rework this so we don't have to load all cards up front + +var AddSeriesModal = (_dec = metabase_entities_questions__WEBPACK_IMPORTED_MODULE_9__.default.loadList({ + query: { + f: "all" + } +}), _dec2 = (0,react_redux__WEBPACK_IMPORTED_MODULE_4__.connect)(function (state, ownProps) { + return { + questions: getQuestions(state, ownProps) + }; +}, { + loadMetadataForQueries: metabase_redux_metadata__WEBPACK_IMPORTED_MODULE_11__.loadMetadataForQueries +}), _dec(_class = _dec2(_class = (_temp = _class2 = /*#__PURE__*/function (_Component) { + _inherits(AddSeriesModal, _Component); + + var _super = _createSuper(AddSeriesModal); + + function AddSeriesModal(props, context) { + var _this; + + _classCallCheck(this, AddSeriesModal); + + _this = _super.call(this, props, context); + + _defineProperty(_assertThisInitialized(_this), "handleQuestionSelectedChange", /*#__PURE__*/function () { + var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(question, selected) { + var _this$props, dashcard, dashcardData, _getVisualizationRaw, visualization, card, sourceDataset, seriesDataset; + + return regeneratorRuntime.wrap(function _callee$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + _this$props = _this.props, dashcard = _this$props.dashcard, dashcardData = _this$props.dashcardData; + _getVisualizationRaw = (0,metabase_visualizations__WEBPACK_IMPORTED_MODULE_13__.getVisualizationRaw)([{ + card: dashcard.card + }]), visualization = _getVisualizationRaw.visualization; + card = question.card(); + _context.prev = 3; + + if (!selected) { + _context.next = 14; + break; + } + + if (!((0,icepick__WEBPACK_IMPORTED_MODULE_3__.getIn)(dashcardData, [dashcard.id, card.id]) === undefined)) { + _context.next = 9; + break; + } + + _this.setState({ + state: "loading" + }); + + _context.next = 9; + return _this.props.fetchCardData(card, dashcard, { + reload: false, + clear: true + }); + + case 9: + sourceDataset = (0,icepick__WEBPACK_IMPORTED_MODULE_3__.getIn)(_this.props.dashcardData, [dashcard.id, dashcard.card.id]); + seriesDataset = (0,icepick__WEBPACK_IMPORTED_MODULE_3__.getIn)(_this.props.dashcardData, [dashcard.id, card.id]); + + if (visualization.seriesAreCompatible({ + card: dashcard.card, + data: sourceDataset.data + }, { + card: card, + data: seriesDataset.data + })) { + _this.setState({ + state: null, + series: _this.state.series.concat(card) + }); + + metabase_lib_analytics__WEBPACK_IMPORTED_MODULE_7__.trackStructEvent("Dashboard", "Add Series", card.display + ", success"); + } else { + _this.setState({ + state: "incompatible", + badQuestions: _objectSpread(_objectSpread({}, _this.state.badQuestions), {}, _defineProperty({}, card.id, true)) + }); + + setTimeout(function () { + return _this.setState({ + state: null + }); + }, 2000); + metabase_lib_analytics__WEBPACK_IMPORTED_MODULE_7__.trackStructEvent("Dashboard", "Add Series", card.dataset_query.type + ", " + card.display + ", fail"); + } + + _context.next = 16; + break; + + case 14: + _this.setState({ + series: _this.state.series.filter(function (c) { + return c.id !== card.id; + }) + }); + + metabase_lib_analytics__WEBPACK_IMPORTED_MODULE_7__.trackStructEvent("Dashboard", "Remove Series"); + + case 16: + _context.next = 23; + break; + + case 18: + _context.prev = 18; + _context.t0 = _context["catch"](3); + console.error("AddSeriesModal handleQuestionChange", _context.t0); + + _this.setState({ + state: "incompatible", + badQuestions: _objectSpread(_objectSpread({}, _this.state.badQuestions), {}, _defineProperty({}, card.id, true)) + }); + + setTimeout(function () { + return _this.setState({ + state: null + }); + }, 2000); + + case 23: + case "end": + return _context.stop(); + } + } + }, _callee, null, [[3, 18]]); + })); + + return function (_x, _x2) { + return _ref.apply(this, arguments); + }; + }()); + + _defineProperty(_assertThisInitialized(_this), "handleDone", function () { + _this.props.setDashCardAttributes({ + id: _this.props.dashcard.id, + attributes: { + series: _this.state.series + } + }); + + _this.props.onClose(); + + metabase_lib_analytics__WEBPACK_IMPORTED_MODULE_7__.trackStructEvent("Dashboard", "Edit Series Modal", "done"); + }); + + _defineProperty(_assertThisInitialized(_this), "handleLoadMetadata", /*#__PURE__*/function () { + var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(queries) { + return regeneratorRuntime.wrap(function _callee2$(_context2) { + while (1) { + switch (_context2.prev = _context2.next) { + case 0: + _this.setState({ + isLoadingMetadata: true + }); + + _context2.next = 3; + return _this.props.loadMetadataForQueries(queries); + + case 3: + _this.setState({ + isLoadingMetadata: false + }); + + case 4: + case "end": + return _context2.stop(); + } + } + }, _callee2); + })); + + return function (_x3) { + return _ref2.apply(this, arguments); + }; + }()); + + _this.state = { + error: null, + series: props.dashcard.series || [], + badQuestions: {}, + isLoadingMetadata: false + }; + return _this; + } + + _createClass(AddSeriesModal, [{ + key: "handleRemoveSeries", + value: function handleRemoveSeries(card) { + this.setState({ + series: this.state.series.filter(function (c) { + return c.id !== card.id; + }) + }); + metabase_lib_analytics__WEBPACK_IMPORTED_MODULE_7__.trackStructEvent("Dashboard", "Remove Series"); + } + }, { + key: "render", + value: function render() { + var _this$props2 = this.props, + dashcard = _this$props2.dashcard, + dashcardData = _this$props2.dashcardData, + questions = _this$props2.questions; + var badQuestions = this.state.badQuestions; + + var _getVisualizationRaw2 = (0,metabase_visualizations__WEBPACK_IMPORTED_MODULE_13__.getVisualizationRaw)([{ + card: dashcard.card + }]), + visualization = _getVisualizationRaw2.visualization; + + var error = this.state.error; + var enabledQuestions = {}; + + var _iterator = _createForOfIteratorHelper(this.state.series), + _step; + + try { + for (_iterator.s(); !(_step = _iterator.n()).done;) { + var card = _step.value; + enabledQuestions[card.id] = true; + } + } catch (err) { + _iterator.e(err); + } finally { + _iterator.f(); + } + + var series = [dashcard.card].concat(this.state.series).map(function (card) { + return { + card: card, + data: (0,icepick__WEBPACK_IMPORTED_MODULE_3__.getIn)(dashcardData, [dashcard.id, card.id, "data"]) + }; + }).filter(function (s) { + return !!s.data; + }); + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "spread flex" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "flex flex-column flex-full" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "flex-no-shrink h3 pl4 pt4 pb2 text-bold" + }, "Edit data"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "flex-full ml2 mr1 relative" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_visualizations_components_Visualization__WEBPACK_IMPORTED_MODULE_6__.default, { + className: "spread", + rawSeries: series, + showTitle: true, + isDashboard: true, + isMultiseries: true, + onRemoveSeries: this.handleRemoveSeries + }), this.state.state && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "spred flex layout-centered", + style: { + backgroundColor: (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_8__.color)("bg-white") + } + }, this.state.state === "loading" ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "h3 rounded bordered p3 bg-white shadowed" + }, (0,ttag__WEBPACK_IMPORTED_MODULE_2__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["Applying Question"])))) : this.state.state === "incompatible" ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "h3 rounded bordered p3 bg-error border-error text-white" + }, (0,ttag__WEBPACK_IMPORTED_MODULE_2__.t)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["That question isn't compatible"])))) : null)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "flex-no-shrink pl4 pb4 pt1" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("button", { + className: "Button Button--primary", + onClick: this.handleDone + }, (0,ttag__WEBPACK_IMPORTED_MODULE_2__.t)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["Done"])))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("button", { + "data-metabase-event": "Dashboard;Edit Series Modal;cancel", + className: "Button ml2", + onClick: this.props.onClose + }, (0,ttag__WEBPACK_IMPORTED_MODULE_2__.t)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["Cancel"])))))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "border-left flex flex-column", + style: { + width: 370, + backgroundColor: (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_8__.color)("bg-light"), + borderColor: (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_8__.color)("border") + } + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_QuestionList__WEBPACK_IMPORTED_MODULE_14__.QuestionList, { + questions: questions, + badQuestions: badQuestions, + enabledQuestions: enabledQuestions, + error: error, + onSelect: this.handleQuestionSelectedChange, + dashcard: this.props.dashcard, + dashcardData: this.props.dashcardData, + loadMetadataForQueries: this.handleLoadMetadata, + visualization: visualization, + isLoadingMetadata: this.state.isLoadingMetadata + }))); + } + }]); + + return AddSeriesModal; +}(react__WEBPACK_IMPORTED_MODULE_0__.Component), _defineProperty(_class2, "propTypes", { + dashcard: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().object.isRequired), + questions: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().array), + dashcardData: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().object.isRequired), + fetchCardData: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func.isRequired), + fetchDatabaseMetadata: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func.isRequired), + setDashCardAttributes: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func.isRequired), + onClose: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func.isRequired) +}), _defineProperty(_class2, "defaultProps", {}), _temp)) || _class) || _class); + + +/***/ }), + +/***/ "./dashboard/components/AddSeriesModal/QuestionList.jsx": +/*!**************************************************************!*\ + !*** ./dashboard/components/AddSeriesModal/QuestionList.jsx ***! + \**************************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "QuestionList": function() { return /* binding */ QuestionList; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prop-types */ "../../../node_modules/prop-types/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_2__); +/* harmony import */ var react_virtualized__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! react-virtualized */ "../../../node_modules/react-virtualized/dist/es/index.js"); +/* harmony import */ var metabase_components_LoadingAndErrorWrapper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! metabase/components/LoadingAndErrorWrapper */ "./components/LoadingAndErrorWrapper.jsx"); +/* harmony import */ var metabase_components_Icon__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! metabase/components/Icon */ "./components/Icon.tsx"); +/* harmony import */ var metabase_lib_analytics__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! metabase/lib/analytics */ "./lib/analytics.js"); +/* harmony import */ var metabase_hooks_use_debounced_value__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! metabase/hooks/use-debounced-value */ "./hooks/use-debounced-value.ts"); +/* harmony import */ var metabase_lib_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! metabase/lib/constants */ "./lib/constants.js"); +/* harmony import */ var metabase_components_EmptyState__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! metabase/components/EmptyState */ "./components/EmptyState.jsx"); +/* harmony import */ var _QuestionList_styled__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./QuestionList.styled */ "./dashboard/components/AddSeriesModal/QuestionList.styled.jsx"); +/* harmony import */ var _QuestionListItem__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./QuestionListItem */ "./dashboard/components/AddSeriesModal/QuestionListItem.jsx"); +/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./utils */ "./dashboard/components/AddSeriesModal/utils.js"); +var _templateObject, _templateObject2, _templateObject3, _templateObject4; + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + +function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } + +function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } + +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } + +function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } + +function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } + + + + + + + + + + + + + + +var LOAD_CHUNK_SIZE = 15; +var propTypes = { + questions: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().object), + badQuestions: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().object), + enabledQuestions: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().object), + error: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string), + onSelect: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func), + dashcard: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().object), + dashcardData: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().object), + loadMetadataForQueries: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().function), + visualization: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().object), + isLoadingMetadata: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool) +}; +var QuestionList = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.memo(function QuestionList(_ref) { + var questions = _ref.questions, + badQuestions = _ref.badQuestions, + enabledQuestions = _ref.enabledQuestions, + error = _ref.error, + onSelect = _ref.onSelect, + dashcard = _ref.dashcard, + dashcardData = _ref.dashcardData, + loadMetadataForQueries = _ref.loadMetadataForQueries, + visualization = _ref.visualization, + isLoadingMetadata = _ref.isLoadingMetadata; + + var _useState = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(""), + _useState2 = _slicedToArray(_useState, 2), + searchText = _useState2[0], + setSearchText = _useState2[1]; + + var debouncedSearchText = (0,metabase_hooks_use_debounced_value__WEBPACK_IMPORTED_MODULE_7__.useDebouncedValue)(searchText, metabase_lib_constants__WEBPACK_IMPORTED_MODULE_8__.SEARCH_DEBOUNCE_DURATION); + + var handleSearchFocus = function handleSearchFocus() { + metabase_lib_analytics__WEBPACK_IMPORTED_MODULE_6__.trackStructEvent("Dashboard", "Edit Series Modal", "search"); + }; + + var filteredQuestions = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(function () { + var filterText = debouncedSearchText.toLowerCase(); + var filteredQuestions = questions.filter(function (question) { + return question.displayName().toLowerCase().includes(filterText); + }); + filteredQuestions.sort(function (a, b) { + if (!a.isNative()) { + return 1; + } else if (!b.isNative()) { + return -1; + } else { + return 0; + } + }); + return filteredQuestions; + }, [questions, debouncedSearchText]); + var compatibleQuestions = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(function () { + return filteredQuestions === null || filteredQuestions === void 0 ? void 0 : filteredQuestions.filter(function (question) { + return (0,_utils__WEBPACK_IMPORTED_MODULE_12__.isQuestionCompatible)(visualization, dashcard, dashcardData, question); + }); + }, [dashcard, dashcardData, filteredQuestions, visualization]); + var questionsWithoutMetadata = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(function () { + return filteredQuestions.filter(function (question) { + return question.isStructured() && !question.query().hasMetadata(); + }); + }, [filteredQuestions]); + var handleLoadNext = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() { + var questionsChunk; + return regeneratorRuntime.wrap(function _callee$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + if (!(questionsWithoutMetadata.length === 0)) { + _context.next = 2; + break; + } + + return _context.abrupt("return"); + + case 2: + questionsChunk = questionsWithoutMetadata.slice(0, LOAD_CHUNK_SIZE); + _context.next = 5; + return loadMetadataForQueries(questionsChunk.map(function (question) { + return question.query(); + })); + + case 5: + case "end": + return _context.stop(); + } + } + }, _callee); + })), [loadMetadataForQueries, questionsWithoutMetadata]); + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () { + handleLoadNext(); // eslint-disable-next-line react-hooks/exhaustive-deps + }, [filteredQuestions.length]); + var hasQuestionsToShow = compatibleQuestions.length > 0; + var canLoadMore = questionsWithoutMetadata.length > 0; + var rowsCount = canLoadMore ? compatibleQuestions.length + 1 : compatibleQuestions.length; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_QuestionList_styled__WEBPACK_IMPORTED_MODULE_10__.SearchContainer, null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_QuestionList_styled__WEBPACK_IMPORTED_MODULE_10__.SearchInput, { + value: searchText, + colorScheme: "transparent", + icon: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Icon__WEBPACK_IMPORTED_MODULE_5__.default, { + name: "search", + size: 16, + pt: "0.25rem" + }), + placeholder: (0,ttag__WEBPACK_IMPORTED_MODULE_2__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["Search for a question"]))), + onFocus: handleSearchFocus, + onChange: function onChange(value) { + return setSearchText(value); + } + })), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_LoadingAndErrorWrapper__WEBPACK_IMPORTED_MODULE_4__.default, { + className: "flex flex-full overflow-auto", + loading: !filteredQuestions, + error: error, + noBackground: true + }, function () { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_QuestionList_styled__WEBPACK_IMPORTED_MODULE_10__.QuestionListContainer, null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(react_virtualized__WEBPACK_IMPORTED_MODULE_3__.AutoSizer, null, function (_ref3) { + var width = _ref3.width, + height = _ref3.height; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(react_virtualized__WEBPACK_IMPORTED_MODULE_3__.List, { + overscanRowCount: 0, + width: width, + height: height, + rowCount: rowsCount, + rowHeight: 36, + rowRenderer: function rowRenderer(_ref4) { + var index = _ref4.index, + key = _ref4.key, + style = _ref4.style; + var isLoadMoreRow = index === compatibleQuestions.length; + + if (isLoadMoreRow) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_QuestionList_styled__WEBPACK_IMPORTED_MODULE_10__.LoadMoreRow, { + style: style + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_QuestionList_styled__WEBPACK_IMPORTED_MODULE_10__.LoadMoreButton, { + onClick: handleLoadNext, + disabled: isLoadingMetadata + }, isLoadingMetadata ? (0,ttag__WEBPACK_IMPORTED_MODULE_2__.t)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["Loading"]))) : (0,ttag__WEBPACK_IMPORTED_MODULE_2__.t)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["Load more"]))))); + } + + var question = compatibleQuestions[index]; + var isEnabled = enabledQuestions[question.id()]; + var isBad = badQuestions[question.id()]; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_QuestionListItem__WEBPACK_IMPORTED_MODULE_11__.QuestionListItem, { + key: key, + question: question, + isEnabled: isEnabled, + isBad: isBad, + style: style, + onChange: function onChange(e) { + return onSelect(question, e.target.checked); + } + }); + } + }); + }), !hasQuestionsToShow && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_QuestionList_styled__WEBPACK_IMPORTED_MODULE_10__.EmptyStateContainer, null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_EmptyState__WEBPACK_IMPORTED_MODULE_9__.default, { + message: (0,ttag__WEBPACK_IMPORTED_MODULE_2__.t)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["Nothing here"]))), + icon: "all" + }))); + })); +}); +QuestionList.propTypes = propTypes; + +/***/ }), + +/***/ "./dashboard/components/AddSeriesModal/QuestionList.styled.jsx": +/*!*********************************************************************!*\ + !*** ./dashboard/components/AddSeriesModal/QuestionList.styled.jsx ***! + \*********************************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "QuestionListContainer": function() { return /* binding */ QuestionListContainer; }, +/* harmony export */ "LoadMoreButton": function() { return /* binding */ LoadMoreButton; }, +/* harmony export */ "LoadMoreRow": function() { return /* binding */ LoadMoreRow; }, +/* harmony export */ "SearchContainer": function() { return /* binding */ SearchContainer; }, +/* harmony export */ "SearchInput": function() { return /* binding */ SearchInput; }, +/* harmony export */ "EmptyStateContainer": function() { return /* binding */ EmptyStateContainer; } +/* harmony export */ }); +/* harmony import */ var styled_components__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! styled-components */ "../../../node_modules/styled-components/dist/styled-components.browser.es.js"); +/* harmony import */ var metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/lib/colors */ "./lib/colors.ts"); +/* harmony import */ var metabase_components_TextInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/components/TextInput */ "./components/TextInput/index.js"); + + + +var QuestionListContainer = styled_components__WEBPACK_IMPORTED_MODULE_0__.default.div.withConfig({ + displayName: "QuestionListstyled__QuestionListContainer", + componentId: "xy6ag8-0" +})(["padding-right:0.5rem;padding-bottom:1rem;width:100%;"]); +var LoadMoreButton = styled_components__WEBPACK_IMPORTED_MODULE_0__.default.button.withConfig({ + displayName: "QuestionListstyled__LoadMoreButton", + componentId: "xy6ag8-1" +})(["font-family:var(--default-font-family);display:flex;align-items:center;cursor:pointer;color:", ";padding:0.25rem 1.5rem;font-size:14px;font-weight:700;"], (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.color)("brand")); +var LoadMoreRow = styled_components__WEBPACK_IMPORTED_MODULE_0__.default.li.withConfig({ + displayName: "QuestionListstyled__LoadMoreRow", + componentId: "xy6ag8-2" +})(["display:flex;align-items:center;justify-content:center;list-style:none;"]); +var SearchContainer = styled_components__WEBPACK_IMPORTED_MODULE_0__.default.div.withConfig({ + displayName: "QuestionListstyled__SearchContainer", + componentId: "xy6ag8-3" +})(["display:flex;flex-direction:row;align-items:center;flex-shrink:0;border-bottom:1px solid ", ";"], (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.color)("border")); +var SearchInput = (0,styled_components__WEBPACK_IMPORTED_MODULE_0__.default)(metabase_components_TextInput__WEBPACK_IMPORTED_MODULE_2__.default).withConfig({ + displayName: "QuestionListstyled__SearchInput", + componentId: "xy6ag8-4" +})(["width:100%;"]); +var EmptyStateContainer = styled_components__WEBPACK_IMPORTED_MODULE_0__.default.div.withConfig({ + displayName: "QuestionListstyled__EmptyStateContainer", + componentId: "xy6ag8-5" +})(["display:flex;align-items:center;justify-content:center;width:100%;height:100%;"]); + +/***/ }), + +/***/ "./dashboard/components/AddSeriesModal/QuestionListItem.jsx": +/*!******************************************************************!*\ + !*** ./dashboard/components/AddSeriesModal/QuestionListItem.jsx ***! + \******************************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "QuestionListItem": function() { return /* binding */ QuestionListItem; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prop-types */ "../../../node_modules/prop-types/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_2__); +/* harmony import */ var metabase_components_Tooltip__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/components/Tooltip */ "./components/Tooltip/index.ts"); +/* harmony import */ var metabase_components_CheckBox__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! metabase/components/CheckBox */ "./components/CheckBox.jsx"); +/* harmony import */ var _QuestionListItem_styled__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./QuestionListItem.styled */ "./dashboard/components/AddSeriesModal/QuestionListItem.styled.jsx"); +var _templateObject; + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + + + + + + + +var propTypes = { + question: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().object), + onChange: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func.isRequired), + isEnabled: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), + isBad: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), + style: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().object) +}; +var QuestionListItem = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.memo(function QuestionListItem(_ref) { + var question = _ref.question, + onChange = _ref.onChange, + isEnabled = _ref.isEnabled, + isBad = _ref.isBad, + style = _ref.style; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_QuestionListItem_styled__WEBPACK_IMPORTED_MODULE_5__.QuestionListItemRoot, { + style: style, + isDisabled: isBad + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_QuestionListItem_styled__WEBPACK_IMPORTED_MODULE_5__.CheckboxContainer, null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_CheckBox__WEBPACK_IMPORTED_MODULE_4__.default, { + label: question.displayName(), + checked: isEnabled, + onChange: onChange + })), !question.isStructured() && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Tooltip__WEBPACK_IMPORTED_MODULE_3__.default, { + tooltip: (0,ttag__WEBPACK_IMPORTED_MODULE_2__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["We're not sure if this question is compatible"]))) + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_QuestionListItem_styled__WEBPACK_IMPORTED_MODULE_5__.WarningIcon, null))); +}); +QuestionListItem.propTypes = propTypes; + +/***/ }), + +/***/ "./dashboard/components/AddSeriesModal/QuestionListItem.styled.jsx": +/*!*************************************************************************!*\ + !*** ./dashboard/components/AddSeriesModal/QuestionListItem.styled.jsx ***! + \*************************************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "QuestionListItemRoot": function() { return /* binding */ QuestionListItemRoot; }, +/* harmony export */ "CheckboxContainer": function() { return /* binding */ CheckboxContainer; }, +/* harmony export */ "WarningIcon": function() { return /* binding */ WarningIcon; } +/* harmony export */ }); +/* harmony import */ var styled_components__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! styled-components */ "../../../node_modules/styled-components/dist/styled-components.browser.es.js"); +/* harmony import */ var metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/lib/colors */ "./lib/colors.ts"); +/* harmony import */ var metabase_components_Icon__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/components/Icon */ "./components/Icon.tsx"); + + + +var QuestionListItemRoot = styled_components__WEBPACK_IMPORTED_MODULE_0__.default.li.withConfig({ + displayName: "QuestionListItemstyled__QuestionListItemRoot", + componentId: "sc-1n1q347-0" +})(["display:flex;align-items:center;margin:0.5rem 0;padding:0.5rem 0 0.5rem 1rem;opacity:", ";pointer-events:", ";"], function (props) { + return props.isDisabled ? 0.5 : 1; +}, function (props) { + return props.isDisabled ? "none" : "all"; +}); +var CheckboxContainer = styled_components__WEBPACK_IMPORTED_MODULE_0__.default.li.withConfig({ + displayName: "QuestionListItemstyled__CheckboxContainer", + componentId: "sc-1n1q347-1" +})(["display:flex;flex-shrink:0;padding:0 0.5rem;"]); +var WarningIcon = (0,styled_components__WEBPACK_IMPORTED_MODULE_0__.default)(metabase_components_Icon__WEBPACK_IMPORTED_MODULE_2__.default).attrs({ + size: 20, + name: "warning" +}).withConfig({ + displayName: "QuestionListItemstyled__WarningIcon", + componentId: "sc-1n1q347-2" +})(["padding:0 0.5rem;display:flex;margin-left:auto;color:", ";cursor:pointer;flex-shrink:0;&:hover{color:", ";}"], (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.color)("text-light"), (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.color)("text-medium")); + +/***/ }), + +/***/ "./dashboard/components/AddSeriesModal/utils.js": +/*!******************************************************!*\ + !*** ./dashboard/components/AddSeriesModal/utils.js ***! + \******************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "isQuestionCompatible": function() { return /* binding */ isQuestionCompatible; } +/* harmony export */ }); +/* harmony import */ var icepick__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! icepick */ "../../../node_modules/icepick/icepick.min.js"); +/* harmony import */ var icepick__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(icepick__WEBPACK_IMPORTED_MODULE_0__); + +function isQuestionCompatible(visualization, dashcard, dashcardData, question) { + var initialSeries = { + card: dashcard.card, + data: (0,icepick__WEBPACK_IMPORTED_MODULE_0__.getIn)(dashcardData, [dashcard.id, dashcard.card.id, "data"]) + }; + + try { + if (question.id() === dashcard.card.id) { + return false; + } + + if (question.isStructured()) { + if (!visualization.seriesAreCompatible(initialSeries, { + card: question.card(), + data: { + cols: question.query().columns(), + rows: [] + } + })) { + return false; + } + } + + return true; + } catch (e) { + return false; + } +} + +/***/ }), + +/***/ "./dashboard/components/DashCard.jsx": +/*!*******************************************!*\ + !*** ./dashboard/components/DashCard.jsx ***! + \*******************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* binding */ DashCard; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var styled_components__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! styled-components */ "../../../node_modules/styled-components/dist/styled-components.browser.es.js"); +/* harmony import */ var react_redux__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react-redux */ "../../../node_modules/react-redux/es/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! prop-types */ "../../../node_modules/prop-types/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_3__); +/* harmony import */ var react_dom__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! react-dom */ "../../../node_modules/react-dom/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_5__); +/* harmony import */ var metabase_visualizations__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! metabase/visualizations */ "./visualizations/index.js"); +/* harmony import */ var metabase_visualizations_lib_settings__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! metabase/visualizations/lib/settings */ "./visualizations/lib/settings.js"); +/* harmony import */ var metabase_visualizations_components_Visualization__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! metabase/visualizations/components/Visualization */ "./visualizations/components/Visualization.jsx"); +/* harmony import */ var metabase_query_builder_components_QueryDownloadWidget__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! metabase/query_builder/components/QueryDownloadWidget */ "./query_builder/components/QueryDownloadWidget.jsx"); +/* harmony import */ var metabase_components_ModalWithTrigger__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! metabase/components/ModalWithTrigger */ "./components/ModalWithTrigger.jsx"); +/* harmony import */ var metabase_visualizations_components_ChartSettings__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! metabase/visualizations/components/ChartSettings */ "./visualizations/components/ChartSettings.jsx"); +/* harmony import */ var metabase_visualizations_hoc_WithVizSettingsData__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! metabase/visualizations/hoc/WithVizSettingsData */ "./visualizations/hoc/WithVizSettingsData.js"); +/* harmony import */ var metabase_components_Icon__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! metabase/components/Icon */ "./components/Icon.tsx"); +/* harmony import */ var metabase_components_Tooltip__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! metabase/components/Tooltip */ "./components/Tooltip/index.ts"); +/* harmony import */ var metabase_dashboard_utils__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! metabase/dashboard/utils */ "./dashboard/utils.js"); +/* harmony import */ var _DashCardParameterMapper__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./DashCardParameterMapper */ "./dashboard/components/DashCardParameterMapper.jsx"); +/* harmony import */ var metabase_lib_embed__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! metabase/lib/embed */ "./lib/embed.js"); +/* harmony import */ var metabase_lib_click_behavior__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! metabase/lib/click-behavior */ "./lib/click-behavior.js"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! classnames */ "../../../node_modules/classnames/index.js"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_19___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_19__); +/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! underscore */ "../../../node_modules/underscore/modules/index-all.js"); +/* harmony import */ var icepick__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! icepick */ "../../../node_modules/icepick/icepick.min.js"); +/* harmony import */ var icepick__WEBPACK_IMPORTED_MODULE_21___default = /*#__PURE__*/__webpack_require__.n(icepick__WEBPACK_IMPORTED_MODULE_21__); +/* harmony import */ var metabase_parameters_utils_parameter_values__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! metabase/parameters/utils/parameter-values */ "./parameters/utils/parameter-values.js"); +/* harmony import */ var metabase_lib_utils__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! metabase/lib/utils */ "./lib/utils.js"); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9; + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } + +function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/* eslint-disable react/prop-types */ + + + + + + + + + + + + + + + + + + + + + + + + +var DATASET_USUALLY_FAST_THRESHOLD = 15 * 1000; +var HEADER_ICON_SIZE = 16; +var HEADER_ACTION_STYLE = { + padding: 4 +}; // This is done to add the `getExtraDataForClick` prop. +// We need that to pass relevant data along with the clicked object. + +var WrappedVisualization = (0,metabase_visualizations_hoc_WithVizSettingsData__WEBPACK_IMPORTED_MODULE_12__.default)((0,react_redux__WEBPACK_IMPORTED_MODULE_2__.connect)(null, function (dispatch) { + return { + dispatch: dispatch + }; +})(metabase_visualizations_components_Visualization__WEBPACK_IMPORTED_MODULE_8__.default)); + +var DashCard = /*#__PURE__*/function (_Component) { + _inherits(DashCard, _Component); + + var _super = _createSuper(DashCard); + + function DashCard(props) { + var _this; + + _classCallCheck(this, DashCard); + + _this = _super.call(this, props); + + _defineProperty(_assertThisInitialized(_this), "handlePreviewToggle", function () { + _this.setState(function (prevState) { + return { + isPreviewingCard: !prevState.isPreviewingCard + }; + }); + }); + + _defineProperty(_assertThisInitialized(_this), "preventDragging", function (e) { + e.stopPropagation(); + }); + + _this.state = { + isPreviewingCard: false + }; + return _this; + } + + _createClass(DashCard, [{ + key: "componentDidMount", + value: function () { + var _componentDidMount = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() { + var _this$props, dashcard, markNewCardSeen, element; + + return regeneratorRuntime.wrap(function _callee$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + _this$props = this.props, dashcard = _this$props.dashcard, markNewCardSeen = _this$props.markNewCardSeen; // HACK: way to scroll to a newly added card + + if (dashcard.justAdded) { + element = react_dom__WEBPACK_IMPORTED_MODULE_4__.findDOMNode(this); + + if (element && element.scrollIntoView) { + element.scrollIntoView({ + block: "nearest" + }); + } + + markNewCardSeen(dashcard.id); + } + + case 2: + case "end": + return _context.stop(); + } + } + }, _callee, this); + })); + + function componentDidMount() { + return _componentDidMount.apply(this, arguments); + } + + return componentDidMount; + }() + }, { + key: "componentWillUnmount", + value: function componentWillUnmount() { + window.clearInterval(this.visibilityTimer); + } + }, { + key: "render", + value: function render() { + var _this2 = this; + + var _this$props2 = this.props, + dashcard = _this$props2.dashcard, + dashcardData = _this$props2.dashcardData, + slowCards = _this$props2.slowCards, + isEditing = _this$props2.isEditing, + clickBehaviorSidebarDashcard = _this$props2.clickBehaviorSidebarDashcard, + isEditingParameter = _this$props2.isEditingParameter, + isFullscreen = _this$props2.isFullscreen, + onAddSeries = _this$props2.onAddSeries, + onRemove = _this$props2.onRemove, + navigateToNewCardFromDashboard = _this$props2.navigateToNewCardFromDashboard, + metadata = _this$props2.metadata, + dashboard = _this$props2.dashboard, + parameterValues = _this$props2.parameterValues, + mode = _this$props2.mode, + headerIcon = _this$props2.headerIcon; + + var mainCard = _objectSpread(_objectSpread({}, dashcard.card), {}, { + visualization_settings: (0,metabase_visualizations_lib_settings__WEBPACK_IMPORTED_MODULE_7__.mergeSettings)(dashcard.card.visualization_settings, dashcard.visualization_settings) + }); + + var cards = [mainCard].concat(dashcard.series || []); + var dashboardId = dashcard.dashboard_id; + var isEmbed = metabase_lib_utils__WEBPACK_IMPORTED_MODULE_23__.default.isJWT(dashboardId); + var series = cards.map(function (card) { + return _objectSpread(_objectSpread({}, (0,icepick__WEBPACK_IMPORTED_MODULE_21__.getIn)(dashcardData, [dashcard.id, card.id])), {}, { + card: card, + isSlow: slowCards[card.id], + isUsuallyFast: card.query_average_duration && card.query_average_duration < DATASET_USUALLY_FAST_THRESHOLD + }); + }); + var loading = !(series.length > 0 && underscore__WEBPACK_IMPORTED_MODULE_20__.default.every(series, function (s) { + return s.data; + })); + var expectedDuration = Math.max.apply(Math, _toConsumableArray(series.map(function (s) { + return s.card.query_average_duration || 0; + }))); + + var usuallyFast = underscore__WEBPACK_IMPORTED_MODULE_20__.default.every(series, function (s) { + return s.isUsuallyFast; + }); + + var isSlow = loading && underscore__WEBPACK_IMPORTED_MODULE_20__.default.some(series, function (s) { + return s.isSlow; + }) && (usuallyFast ? "usually-fast" : "usually-slow"); + var errors = series.map(function (s) { + return s.error; + }).filter(function (e) { + return e; + }); + var errorMessage, errorIcon; + + if (underscore__WEBPACK_IMPORTED_MODULE_20__.default.any(errors, function (e) { + return e && e.status === 403; + })) { + errorMessage = metabase_visualizations_components_Visualization__WEBPACK_IMPORTED_MODULE_8__.ERROR_MESSAGE_PERMISSION; + errorIcon = "key"; + } else if (errors.length > 0) { + if (metabase_lib_embed__WEBPACK_IMPORTED_MODULE_17__.IS_EMBED_PREVIEW) { + errorMessage = errors[0] && errors[0].data || metabase_visualizations_components_Visualization__WEBPACK_IMPORTED_MODULE_8__.ERROR_MESSAGE_GENERIC; + } else { + errorMessage = metabase_visualizations_components_Visualization__WEBPACK_IMPORTED_MODULE_8__.ERROR_MESSAGE_GENERIC; + } + + errorIcon = "warning"; + } + + var parameterValuesBySlug = (0,metabase_parameters_utils_parameter_values__WEBPACK_IMPORTED_MODULE_22__.getParameterValuesBySlug)(dashboard.parameters, parameterValues); + var hideBackground = !isEditing && mainCard.visualization_settings["dashcard.background"] === false; + var isEditingDashboardLayout = isEditing && clickBehaviorSidebarDashcard == null && !isEditingParameter; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: classnames__WEBPACK_IMPORTED_MODULE_19___default()("Card bordered rounded flex flex-column hover-parent hover--visibility", { + "Card--slow": isSlow === "usually-slow" + }), + style: hideBackground ? { + border: 0, + background: "transparent", + boxShadow: "none" + } : null + }, isEditingDashboardLayout ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(DashboardCardActionsPanel, { + onMouseDown: this.preventDragging + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(DashCardActionButtons, { + series: series, + hasError: !!errorMessage, + isVirtualDashCard: (0,metabase_dashboard_utils__WEBPACK_IMPORTED_MODULE_15__.isVirtualDashCard)(dashcard), + onRemove: onRemove, + onAddSeries: onAddSeries, + onReplaceAllVisualizationSettings: this.props.onReplaceAllVisualizationSettings, + showClickBehaviorSidebar: function showClickBehaviorSidebar() { + return _this2.props.showClickBehaviorSidebar(dashcard.id); + }, + isPreviewing: this.state.isPreviewingCard, + onPreviewToggle: this.handlePreviewToggle + })) : null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(WrappedVisualization, { + className: classnames__WEBPACK_IMPORTED_MODULE_19___default()("flex-full overflow-hidden", { + "pointer-events-none": isEditingDashboardLayout + }), + classNameWidgets: isEmbed && "text-light text-medium-hover", + error: errorMessage, + headerIcon: headerIcon, + errorIcon: errorIcon, + isSlow: isSlow, + expectedDuration: expectedDuration, + rawSeries: series, + showTitle: true, + isFullscreen: isFullscreen, + isDashboard: true, + dispatch: this.props.dispatch, + dashboard: dashboard, + parameterValuesBySlug: parameterValuesBySlug, + isEditing: isEditing, + isPreviewing: this.state.isPreviewingCard, + gridSize: this.props.isMobile ? undefined : { + width: dashcard.sizeX, + height: dashcard.sizeY + }, + actionButtons: isEmbed ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_query_builder_components_QueryDownloadWidget__WEBPACK_IMPORTED_MODULE_9__.default, { + className: "m1 text-brand-hover text-light", + classNameClose: "hover-child", + card: dashcard.card, + params: parameterValuesBySlug, + dashcardId: dashcard.id, + token: dashcard.dashboard_id, + icon: "download" + }) : null, + onUpdateVisualizationSettings: this.props.onUpdateVisualizationSettings, + replacementContent: (clickBehaviorSidebarDashcard != null || isEditingParameter) && (0,metabase_dashboard_utils__WEBPACK_IMPORTED_MODULE_15__.isVirtualDashCard)(dashcard) ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "flex full-height align-center justify-center" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("h4", { + className: "text-medium" + }, (0,ttag__WEBPACK_IMPORTED_MODULE_5__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["Text card"]))))) : isEditingParameter ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_DashCardParameterMapper__WEBPACK_IMPORTED_MODULE_16__.default, { + dashcard: dashcard + }) : clickBehaviorSidebarDashcard != null ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(ClickBehaviorSidebarOverlay, { + dashcard: dashcard, + dashcardWidth: this.props.gridItemWidth, + dashboard: dashboard, + showClickBehaviorSidebar: this.props.showClickBehaviorSidebar, + isShowingThisClickBehaviorSidebar: clickBehaviorSidebarDashcard.id === dashcard.id + }) : null, + metadata: metadata, + mode: mode, + onChangeCardAndRun: navigateToNewCardFromDashboard ? function (_ref) { + var nextCard = _ref.nextCard, + previousCard = _ref.previousCard; + // navigateToNewCardFromDashboard needs `dashcard` for applying active filters to the query + navigateToNewCardFromDashboard({ + nextCard: nextCard, + previousCard: previousCard, + dashcard: dashcard + }); + } : null, + onChangeLocation: this.props.onChangeLocation + })); + } + }]); + + return DashCard; +}(react__WEBPACK_IMPORTED_MODULE_0__.Component); + +_defineProperty(DashCard, "propTypes", { + dashcard: (prop_types__WEBPACK_IMPORTED_MODULE_3___default().object.isRequired), + gridItemWidth: (prop_types__WEBPACK_IMPORTED_MODULE_3___default().number.isRequired), + dashcardData: (prop_types__WEBPACK_IMPORTED_MODULE_3___default().object.isRequired), + slowCards: (prop_types__WEBPACK_IMPORTED_MODULE_3___default().object.isRequired), + parameterValues: (prop_types__WEBPACK_IMPORTED_MODULE_3___default().object.isRequired), + markNewCardSeen: (prop_types__WEBPACK_IMPORTED_MODULE_3___default().func.isRequired), + fetchCardData: (prop_types__WEBPACK_IMPORTED_MODULE_3___default().func.isRequired), + navigateToNewCardFromDashboard: (prop_types__WEBPACK_IMPORTED_MODULE_3___default().func.isRequired), + headerIcon: prop_types__WEBPACK_IMPORTED_MODULE_3___default().shape(metabase_components_Icon__WEBPACK_IMPORTED_MODULE_13__.iconPropTypes) +}); + + +var DashboardCardActionsPanel = styled_components__WEBPACK_IMPORTED_MODULE_1__.default.div.withConfig({ + displayName: "DashCard__DashboardCardActionsPanel", + componentId: "sc-1c4lkzs-0" +})(["padding:0.125em 0.25em;position:absolute;background:white;transform:translateY(-50%);top:0;right:20px;border-radius:8px;box-shadow:0px 1px 3px rgb(0 0 0 / 13%);z-index:3;cursor:default;transition:opacity 200ms;opacity:0;pointer-events:none;.Card:hover &{opacity:1;pointer-events:all;}.Dash--dragging &{display:none;}"]); + +var DashCardActionButtons = function DashCardActionButtons(_ref2) { + var series = _ref2.series, + isVirtualDashCard = _ref2.isVirtualDashCard, + hasError = _ref2.hasError, + onRemove = _ref2.onRemove, + onAddSeries = _ref2.onAddSeries, + onReplaceAllVisualizationSettings = _ref2.onReplaceAllVisualizationSettings, + showClickBehaviorSidebar = _ref2.showClickBehaviorSidebar, + onPreviewToggle = _ref2.onPreviewToggle, + isPreviewing = _ref2.isPreviewing; + var buttons = []; + + if ((0,metabase_visualizations__WEBPACK_IMPORTED_MODULE_6__.getVisualizationRaw)(series).visualization.supportPreviewing) { + buttons.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(ToggleCardPreviewButton, { + isPreviewing: isPreviewing, + onPreviewToggle: onPreviewToggle + })); + } + + if (!hasError) { + if (onReplaceAllVisualizationSettings && !(0,metabase_visualizations__WEBPACK_IMPORTED_MODULE_6__.getVisualizationRaw)(series).visualization.disableSettingsConfig) { + buttons.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(ChartSettingsButton, { + series: series, + onReplaceAllVisualizationSettings: onReplaceAllVisualizationSettings + })); + } + + if (!isVirtualDashCard) { + buttons.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Tooltip__WEBPACK_IMPORTED_MODULE_14__.default, { + tooltip: (0,ttag__WEBPACK_IMPORTED_MODULE_5__.t)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["Click behavior"]))) + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("a", { + className: "text-dark-hover drag-disabled mr1", + "data-metabase-event": "Dashboard;Open Click Behavior Sidebar", + onClick: showClickBehaviorSidebar, + style: HEADER_ACTION_STYLE + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Icon__WEBPACK_IMPORTED_MODULE_13__.default, { + name: "click" + })))); + } + + if ((0,metabase_visualizations__WEBPACK_IMPORTED_MODULE_6__.getVisualizationRaw)(series).visualization.supportsSeries) { + buttons.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(AddSeriesButton, { + series: series, + onAddSeries: onAddSeries + })); + } + } + + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { + className: "flex align-center text-medium", + style: { + lineHeight: 1 + } + }, buttons, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Tooltip__WEBPACK_IMPORTED_MODULE_14__.default, { + tooltip: (0,ttag__WEBPACK_IMPORTED_MODULE_5__.t)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["Remove"]))) + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(RemoveButton, { + className: "ml1", + onRemove: onRemove + }))); +}; + +var ChartSettingsButton = function ChartSettingsButton(_ref3) { + var series = _ref3.series, + onReplaceAllVisualizationSettings = _ref3.onReplaceAllVisualizationSettings; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_ModalWithTrigger__WEBPACK_IMPORTED_MODULE_10__.default, { + wide: true, + tall: true, + triggerElement: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Tooltip__WEBPACK_IMPORTED_MODULE_14__.default, { + tooltip: (0,ttag__WEBPACK_IMPORTED_MODULE_5__.t)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["Visualization options"]))) + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Icon__WEBPACK_IMPORTED_MODULE_13__.default, { + name: "palette", + size: HEADER_ICON_SIZE, + style: HEADER_ACTION_STYLE + })), + triggerClasses: "text-dark-hover cursor-pointer flex align-center flex-no-shrink mr1 drag-disabled", + enableMouseEvents: true + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_visualizations_components_ChartSettings__WEBPACK_IMPORTED_MODULE_11__.ChartSettingsWithState, { + className: "spread", + series: series, + onChange: onReplaceAllVisualizationSettings, + isDashboard: true + })); +}; + +var RemoveButton = function RemoveButton(_ref4) { + var onRemove = _ref4.onRemove; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("a", { + className: "text-dark-hover drag-disabled", + "data-metabase-event": "Dashboard;Remove Card Modal", + onClick: onRemove, + style: HEADER_ACTION_STYLE + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Icon__WEBPACK_IMPORTED_MODULE_13__.default, { + name: "close", + size: HEADER_ICON_SIZE + })); +}; + +var AddSeriesButton = function AddSeriesButton(_ref5) { + var series = _ref5.series, + onAddSeries = _ref5.onAddSeries; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("a", { + "data-metabase-event": "Dashboard;Edit Series Modal;open", + className: "text-dark-hover cursor-pointer h3 flex-no-shrink relative mr1 drag-disabled", + onClick: onAddSeries, + style: HEADER_ACTION_STYLE + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Tooltip__WEBPACK_IMPORTED_MODULE_14__.default, { + tooltip: series.length > 1 ? (0,ttag__WEBPACK_IMPORTED_MODULE_5__.t)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["Edit series"]))) : (0,ttag__WEBPACK_IMPORTED_MODULE_5__.t)(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["Add series"]))) + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { + className: "flex align-center" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { + className: "flex" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Icon__WEBPACK_IMPORTED_MODULE_13__.default, { + className: "absolute", + name: "add", + style: { + top: 0, + left: 1 + }, + size: HEADER_ICON_SIZE / 2 + }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Icon__WEBPACK_IMPORTED_MODULE_13__.default, { + name: getSeriesIconName(series), + size: HEADER_ICON_SIZE - 2 + }))))); +}; + +var ToggleCardPreviewButton = function ToggleCardPreviewButton(_ref6) { + var isPreviewing = _ref6.isPreviewing, + onPreviewToggle = _ref6.onPreviewToggle; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("a", { + "data-metabase-event": "Dashboard;Text;edit", + className: "text-dark-hover cursor-pointer h3 flex-no-shrink relative mr1 drag-disabled", + onClick: onPreviewToggle, + style: HEADER_ACTION_STYLE + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Tooltip__WEBPACK_IMPORTED_MODULE_14__.default, { + tooltip: isPreviewing ? (0,ttag__WEBPACK_IMPORTED_MODULE_5__.t)(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["Edit"]))) : (0,ttag__WEBPACK_IMPORTED_MODULE_5__.t)(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["Preview"]))) + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { + className: "flex align-center" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { + className: "flex", + style: { + width: 18 + } + }, isPreviewing ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Icon__WEBPACK_IMPORTED_MODULE_13__.default, { + name: "edit_document", + size: HEADER_ICON_SIZE + }) : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Icon__WEBPACK_IMPORTED_MODULE_13__.default, { + name: "eye", + size: 18 + }))))); +}; + +function getSeriesIconName(series) { + try { + var display = series[0].card.display; + return metabase_visualizations__WEBPACK_IMPORTED_MODULE_6__.default.get(display === "scalar" ? "bar" : display).iconName; + } catch (e) { + return "bar"; + } +} + +var MIN_WIDTH_FOR_ON_CLICK_LABEL = 330; + +var ClickBehaviorSidebarOverlay = function ClickBehaviorSidebarOverlay(_ref7) { + var dashcard = _ref7.dashcard, + dashcardWidth = _ref7.dashcardWidth, + showClickBehaviorSidebar = _ref7.showClickBehaviorSidebar, + isShowingThisClickBehaviorSidebar = _ref7.isShowingThisClickBehaviorSidebar; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "flex align-center justify-center full-height" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: classnames__WEBPACK_IMPORTED_MODULE_19___default()("text-bold flex py1 px2 mb2 rounded cursor-pointer", { + "bg-brand text-white": isShowingThisClickBehaviorSidebar, + "bg-light text-medium": !isShowingThisClickBehaviorSidebar + }), + onClick: function onClick() { + return showClickBehaviorSidebar(isShowingThisClickBehaviorSidebar ? null : dashcard.id); + } + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Icon__WEBPACK_IMPORTED_MODULE_13__.default, { + name: "click", + className: classnames__WEBPACK_IMPORTED_MODULE_19___default()("mr1", { + "text-light": !isShowingThisClickBehaviorSidebar + }) + }), dashcardWidth > MIN_WIDTH_FOR_ON_CLICK_LABEL && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "mr2" + }, (0,ttag__WEBPACK_IMPORTED_MODULE_5__.t)(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["On click"])))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: classnames__WEBPACK_IMPORTED_MODULE_19___default()({ + "text-brand": !isShowingThisClickBehaviorSidebar + }) + }, (0,metabase_lib_click_behavior__WEBPACK_IMPORTED_MODULE_18__.getClickBehaviorDescription)(dashcard)))); +}; + +/***/ }), + +/***/ "./dashboard/components/DashCardCardParameterMapper.jsx": +/*!**************************************************************!*\ + !*** ./dashboard/components/DashCardCardParameterMapper.jsx ***! + \**************************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prop-types */ "../../../node_modules/prop-types/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var react_redux__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react-redux */ "../../../node_modules/react-redux/es/index.js"); +/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! underscore */ "../../../node_modules/underscore/modules/index-all.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_4__); +/* harmony import */ var metabase_components_Tooltip__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! metabase/components/Tooltip */ "./components/Tooltip/index.ts"); +/* harmony import */ var metabase_components_Popover_TippyPopover__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! metabase/components/Popover/TippyPopover */ "./components/Popover/TippyPopover.tsx"); +/* harmony import */ var metabase_parameters_components_ParameterTargetList__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! metabase/parameters/components/ParameterTargetList */ "./parameters/components/ParameterTargetList.jsx"); +/* harmony import */ var metabase_parameters_utils_targets__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! metabase/parameters/utils/targets */ "./parameters/utils/targets.js"); +/* harmony import */ var metabase_parameters_utils_parameter_type__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! metabase/parameters/utils/parameter-type */ "./parameters/utils/parameter-type.js"); +/* harmony import */ var metabase_selectors_metadata__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! metabase/selectors/metadata */ "./selectors/metadata.js"); +/* harmony import */ var metabase_lib_lib_Question__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! metabase-lib/lib/Question */ "../metabase-lib/lib/Question.ts"); +/* harmony import */ var _selectors__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../selectors */ "./dashboard/selectors.js"); +/* harmony import */ var _actions__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../actions */ "./dashboard/actions.js"); +/* harmony import */ var _DashCardCardParameterMapper_styled__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./DashCardCardParameterMapper.styled */ "./dashboard/components/DashCardCardParameterMapper.styled.jsx"); +var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6; + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } + +function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } + +function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } + + + + + + + + + + + + + + + + + +function formatSelected(_ref) { + var name = _ref.name, + sectionName = _ref.sectionName; + + if (sectionName == null) { + // for native question variables or field literals we just display the name + return name; + } + + return "".concat(sectionName, ".").concat(name); +} + +var mapStateToProps = function mapStateToProps(state, props) { + return { + editingParameter: (0,_selectors__WEBPACK_IMPORTED_MODULE_12__.getEditingParameter)(state, props), + target: (0,_selectors__WEBPACK_IMPORTED_MODULE_12__.getParameterTarget)(state, props), + mappingOptions: (0,_selectors__WEBPACK_IMPORTED_MODULE_12__.makeGetParameterMappingOptions)()(state, props), + mappingsByParameter: (0,_selectors__WEBPACK_IMPORTED_MODULE_12__.getMappingsByParameter)(state, props), + metadata: (0,metabase_selectors_metadata__WEBPACK_IMPORTED_MODULE_10__.getMetadata)(state) + }; +}; + +var mapDispatchToProps = { + setParameterMapping: _actions__WEBPACK_IMPORTED_MODULE_13__.setParameterMapping +}; +DashCardCardParameterMapper.propTypes = { + card: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().object.isRequired), + dashcard: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().object.isRequired), + editingParameter: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().object.isRequired), + target: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().object), + mappingOptions: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().array.isRequired), + mappingsByParameter: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().object.isRequired), + metadata: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().object.isRequired), + setParameterMapping: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func.isRequired) +}; + +function DashCardCardParameterMapper(_ref2) { + var card = _ref2.card, + dashcard = _ref2.dashcard, + editingParameter = _ref2.editingParameter, + target = _ref2.target, + mappingsByParameter = _ref2.mappingsByParameter, + mappingOptions = _ref2.mappingOptions, + metadata = _ref2.metadata, + setParameterMapping = _ref2.setParameterMapping; + + var _useState = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false), + _useState2 = _slicedToArray(_useState, 2), + isDropdownVisible = _useState2[0], + setIsDropdownVisible = _useState2[1]; + + var hasSeries = dashcard.series && dashcard.series.length > 0; + var onlyAcceptsSingleValue = (0,metabase_parameters_utils_targets__WEBPACK_IMPORTED_MODULE_8__.isVariableTarget)(target) && !(0,metabase_parameters_utils_parameter_type__WEBPACK_IMPORTED_MODULE_9__.isDateParameter)(editingParameter); + var isDisabled = mappingOptions.length === 0; + + var selectedMappingOption = underscore__WEBPACK_IMPORTED_MODULE_3__.default.find(mappingOptions, function (o) { + return underscore__WEBPACK_IMPORTED_MODULE_3__.default.isEqual(o.target, target); + }); + + var handleChangeTarget = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function (target) { + setParameterMapping(editingParameter.id, dashcard.id, card.id, target); + }, [card.id, dashcard.id, editingParameter.id, setParameterMapping]); + var hasPermissionsToMap = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(function () { + var question = new metabase_lib_lib_Question__WEBPACK_IMPORTED_MODULE_11__.default(card, metadata); + return question.query().isEditable(); + }, [card, metadata]); + + var _useMemo = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(function () { + if (!hasPermissionsToMap) { + return { + variant: "unauthed", + tooltip: (0,ttag__WEBPACK_IMPORTED_MODULE_4__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["You don\u2019t have permission to see this question\u2019s columns."]))), + text: null, + buttonIcon: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_DashCardCardParameterMapper_styled__WEBPACK_IMPORTED_MODULE_14__.KeyIcon, null) + }; + } else if (isDisabled) { + return { + variant: "disabled", + tooltip: (0,ttag__WEBPACK_IMPORTED_MODULE_4__.t)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["This card doesn't have any fields or parameters that can be mapped to this parameter type."]))), + buttonText: (0,ttag__WEBPACK_IMPORTED_MODULE_4__.t)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["No valid fields"]))), + buttonIcon: null + }; + } else if (selectedMappingOption) { + return { + variant: "mapped", + tooltip: null, + buttonText: formatSelected(selectedMappingOption), + buttonIcon: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_DashCardCardParameterMapper_styled__WEBPACK_IMPORTED_MODULE_14__.CloseIconButton, { + onClick: function onClick(e) { + handleChangeTarget(null); + e.stopPropagation(); + } + }) + }; + } else { + return { + variant: "default", + tooltip: null, + buttonText: (0,ttag__WEBPACK_IMPORTED_MODULE_4__.t)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["Select\u2026"]))), + buttonIcon: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_DashCardCardParameterMapper_styled__WEBPACK_IMPORTED_MODULE_14__.ChevrondownIcon, null) + }; + } + }, [hasPermissionsToMap, isDisabled, selectedMappingOption, handleChangeTarget]), + variant = _useMemo.variant, + tooltip = _useMemo.tooltip, + buttonText = _useMemo.buttonText, + buttonIcon = _useMemo.buttonIcon; + + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_DashCardCardParameterMapper_styled__WEBPACK_IMPORTED_MODULE_14__.Container, null, hasSeries && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_DashCardCardParameterMapper_styled__WEBPACK_IMPORTED_MODULE_14__.CardLabel, null, card.name), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_DashCardCardParameterMapper_styled__WEBPACK_IMPORTED_MODULE_14__.Header, null, (0,ttag__WEBPACK_IMPORTED_MODULE_4__.t)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["Column to filter on"])))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Tooltip__WEBPACK_IMPORTED_MODULE_5__.default, { + tooltip: tooltip + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Popover_TippyPopover__WEBPACK_IMPORTED_MODULE_6__.default, { + visible: isDropdownVisible && !isDisabled && hasPermissionsToMap, + onClickOutside: function onClickOutside() { + return setIsDropdownVisible(false); + }, + placement: "bottom-start", + interactive: true, + content: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_parameters_components_ParameterTargetList__WEBPACK_IMPORTED_MODULE_7__.default, { + onChange: function onChange(target) { + handleChangeTarget(target); + setIsDropdownVisible(false); + }, + target: target, + mappingOptions: mappingOptions + }) + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_DashCardCardParameterMapper_styled__WEBPACK_IMPORTED_MODULE_14__.TargetButton, { + variant: variant, + "aria-haspopup": "listbox", + "aria-expanded": isDropdownVisible, + "aria-disabled": isDisabled || !hasPermissionsToMap, + onClick: function onClick() { + setIsDropdownVisible(true); + }, + onKeyDown: function onKeyDown(e) { + if (e.key === "Enter") { + setIsDropdownVisible(true); + } + } + }, buttonText && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_DashCardCardParameterMapper_styled__WEBPACK_IMPORTED_MODULE_14__.TargetButtonText, null, buttonText), buttonIcon))), onlyAcceptsSingleValue && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_DashCardCardParameterMapper_styled__WEBPACK_IMPORTED_MODULE_14__.Warning, null, (0,ttag__WEBPACK_IMPORTED_MODULE_4__.t)(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["This field only accepts a single value because it's used in a SQL query."]))))); +} + +/* harmony default export */ __webpack_exports__["default"] = ((0,react_redux__WEBPACK_IMPORTED_MODULE_2__.connect)(mapStateToProps, mapDispatchToProps)(DashCardCardParameterMapper)); + +/***/ }), + +/***/ "./dashboard/components/DashCardCardParameterMapper.styled.jsx": +/*!*********************************************************************!*\ + !*** ./dashboard/components/DashCardCardParameterMapper.styled.jsx ***! + \*********************************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "Container": function() { return /* binding */ Container; }, +/* harmony export */ "CardLabel": function() { return /* binding */ CardLabel; }, +/* harmony export */ "Header": function() { return /* binding */ Header; }, +/* harmony export */ "TargetButton": function() { return /* binding */ TargetButton; }, +/* harmony export */ "TargetButtonText": function() { return /* binding */ TargetButtonText; }, +/* harmony export */ "CloseIconButton": function() { return /* binding */ CloseIconButton; }, +/* harmony export */ "ChevrondownIcon": function() { return /* binding */ ChevrondownIcon; }, +/* harmony export */ "KeyIcon": function() { return /* binding */ KeyIcon; }, +/* harmony export */ "Warning": function() { return /* binding */ Warning; } +/* harmony export */ }); +/* harmony import */ var styled_components__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! styled-components */ "../../../node_modules/styled-components/dist/styled-components.browser.es.js"); +/* harmony import */ var metabase_styled_components_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/styled-components/utils */ "./styled-components/utils.tsx"); +/* harmony import */ var metabase_styled_components_theme__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/styled-components/theme */ "./styled-components/theme/index.ts"); +/* harmony import */ var metabase_lib_colors__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/lib/colors */ "./lib/colors.ts"); +/* harmony import */ var metabase_components_Icon__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! metabase/components/Icon */ "./components/Icon.tsx"); +/* harmony import */ var metabase_components_Button__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! metabase/components/Button */ "./components/Button.tsx"); + + + + + + +var Container = styled_components__WEBPACK_IMPORTED_MODULE_0__.default.div.withConfig({ + displayName: "DashCardCardParameterMapperstyled__Container", + componentId: "sc-15hr1zq-0" +})(["margin:", " 0;display:flex;flex-direction:column;align-items:center;"], (0,metabase_styled_components_theme__WEBPACK_IMPORTED_MODULE_2__.space)(1)); +var CardLabel = styled_components__WEBPACK_IMPORTED_MODULE_0__.default.div.withConfig({ + displayName: "DashCardCardParameterMapperstyled__CardLabel", + componentId: "sc-15hr1zq-1" +})(["font-size:0.83em;margin-bottom:", ";text-weight:bold;text-overflow:ellipsis;white-space:nowrap;overflow:hidden;max-width:100px;"], (0,metabase_styled_components_theme__WEBPACK_IMPORTED_MODULE_2__.space)(1)); +var Header = styled_components__WEBPACK_IMPORTED_MODULE_0__.default.h4.withConfig({ + displayName: "DashCardCardParameterMapperstyled__Header", + componentId: "sc-15hr1zq-2" +})(["color:", ";margin-bottom:", ";"], (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_3__.color)("text-medium"), (0,metabase_styled_components_theme__WEBPACK_IMPORTED_MODULE_2__.space)(1)); +var TargetButton = (0,metabase_styled_components_utils__WEBPACK_IMPORTED_MODULE_1__.forwardRefToInnerRef)(styled_components__WEBPACK_IMPORTED_MODULE_0__.default.div.attrs({ + tabIndex: 0, + role: "button" +}).withConfig({ + displayName: "DashCardCardParameterMapperstyled__TargetButton", + componentId: "sc-15hr1zq-3" +})(["display:flex;align-items:center;justify-content:space-between;background-color:", ";text-weight:bold;cursor:pointer;font-size:1.2em;border:2px solid ", ";border-radius:8px;min-height:30px;min-width:100px;padding:0.25em 0.5em;color:", ";", " ", " ", ""], (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_3__.color)("white"), (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_3__.color)("brand"), (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_3__.color)("text-medium"), function (_ref) { + var variant = _ref.variant; + return variant === "disabled" && (0,styled_components__WEBPACK_IMPORTED_MODULE_0__.css)(["pointer-events:none;opacity:0.4;border-color:inherit;"]); +}, function (_ref2) { + var variant = _ref2.variant; + return variant === "mapped" && (0,styled_components__WEBPACK_IMPORTED_MODULE_0__.css)(["border-color:", ";background-color:", ";color:", ";"], (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_3__.color)("brand"), (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_3__.color)("brand"), (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_3__.color)("white")); +}, function (_ref3) { + var variant = _ref3.variant; + return variant === "unauthed" && (0,styled_components__WEBPACK_IMPORTED_MODULE_0__.css)(["pointer-events:none;border-color:", ";background-color:", ";color:", ";"], (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_3__.color)("bg-light"), (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_3__.color)("bg-light"), (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_3__.color)("text-medium")); +})); +var TargetButtonText = styled_components__WEBPACK_IMPORTED_MODULE_0__.default.span.withConfig({ + displayName: "DashCardCardParameterMapperstyled__TargetButtonText", + componentId: "sc-15hr1zq-4" +})(["text-align:center;margin-right:", ";"], (0,metabase_styled_components_theme__WEBPACK_IMPORTED_MODULE_2__.space)(1)); +var CloseIconButton = (0,styled_components__WEBPACK_IMPORTED_MODULE_0__.default)(metabase_components_Button__WEBPACK_IMPORTED_MODULE_5__.default).attrs({ + icon: "close", + size: 12 +}).withConfig({ + displayName: "DashCardCardParameterMapperstyled__CloseIconButton", + componentId: "sc-15hr1zq-5" +})(["color:", ";background-color:transparent;border:none;padding:", " !important;&:hover{color:", ";background-color:", ";}"], (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_3__.color)("white"), (0,metabase_styled_components_theme__WEBPACK_IMPORTED_MODULE_2__.space)(0), (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_3__.color)("white"), (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_3__.lighten)("brand", 0.2)); +var ChevrondownIcon = (0,styled_components__WEBPACK_IMPORTED_MODULE_0__.default)(metabase_components_Icon__WEBPACK_IMPORTED_MODULE_4__.default).attrs({ + name: "chevrondown", + size: 12 +}).withConfig({ + displayName: "DashCardCardParameterMapperstyled__ChevrondownIcon", + componentId: "sc-15hr1zq-6" +})(["margin-top:2px;"]); +var KeyIcon = (0,styled_components__WEBPACK_IMPORTED_MODULE_0__.default)(metabase_components_Icon__WEBPACK_IMPORTED_MODULE_4__.default).attrs({ + name: "key", + size: 18 +}).withConfig({ + displayName: "DashCardCardParameterMapperstyled__KeyIcon", + componentId: "sc-15hr1zq-7" +})(["flex:1;"]); +var Warning = styled_components__WEBPACK_IMPORTED_MODULE_0__.default.span.withConfig({ + displayName: "DashCardCardParameterMapperstyled__Warning", + componentId: "sc-15hr1zq-8" +})(["margin-top:", ";margin-bottom:-", ";padding:", " 0;text-align:center;"], (0,metabase_styled_components_theme__WEBPACK_IMPORTED_MODULE_2__.space)(1), (0,metabase_styled_components_theme__WEBPACK_IMPORTED_MODULE_2__.space)(1), (0,metabase_styled_components_theme__WEBPACK_IMPORTED_MODULE_2__.space)(4)); + +/***/ }), + +/***/ "./dashboard/components/DashCardParameterMapper.jsx": +/*!**********************************************************!*\ + !*** ./dashboard/components/DashCardParameterMapper.jsx ***! + \**********************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var _components_DashCardCardParameterMapper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../components/DashCardCardParameterMapper */ "./dashboard/components/DashCardCardParameterMapper.jsx"); +/* harmony import */ var metabase_lib_colors__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/lib/colors */ "./lib/colors.ts"); +var _templateObject; + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + +/* eslint-disable react/prop-types */ + + + + + +var DashCardParameterMapper = function DashCardParameterMapper(_ref) { + var dashcard = _ref.dashcard; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "relative flex-full flex flex-column layout-centered" + }, dashcard.series && dashcard.series.length > 0 && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "mx4 my1 p1 rounded", + style: { + backgroundColor: (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_3__.color)("bg-light"), + color: (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_3__.color)("text-medium"), + marginTop: -10 + } + }, (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["Make sure to make a selection for each series, or the filter won't work on this card."])))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "flex mx4 z1", + style: { + justifyContent: "space-around" + } + }, [dashcard.card].concat(dashcard.series || []).map(function (card) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_components_DashCardCardParameterMapper__WEBPACK_IMPORTED_MODULE_2__.default, { + key: "".concat(dashcard.id, ",").concat(card.id), + dashcard: dashcard, + card: card + }); + }))); +}; + +/* harmony default export */ __webpack_exports__["default"] = (DashCardParameterMapper); + +/***/ }), + +/***/ "./dashboard/components/DashboardActions.jsx": +/*!***************************************************!*\ + !*** ./dashboard/components/DashboardActions.jsx ***! + \***************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "getDashboardActions": function() { return /* binding */ getDashboardActions; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! classnames */ "../../../node_modules/classnames/index.js"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_2__); +/* harmony import */ var _containers_DashboardSharingEmbeddingModal_jsx__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../containers/DashboardSharingEmbeddingModal.jsx */ "./dashboard/containers/DashboardSharingEmbeddingModal.jsx"); +/* harmony import */ var metabase_components_icons_FullscreenIcon__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! metabase/components/icons/FullscreenIcon */ "./components/icons/FullscreenIcon.jsx"); +/* harmony import */ var metabase_components_Icon__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! metabase/components/Icon */ "./components/Icon.tsx"); +/* harmony import */ var metabase_lib_settings__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! metabase/lib/settings */ "./lib/settings.ts"); +/* harmony import */ var metabase_components_icons_NightModeIcon__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! metabase/components/icons/NightModeIcon */ "./components/icons/NightModeIcon.jsx"); +/* harmony import */ var metabase_components_PopoverWithTrigger__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! metabase/components/PopoverWithTrigger */ "./components/PopoverWithTrigger.jsx"); +/* harmony import */ var metabase_dashboard_components_RefreshWidget__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! metabase/dashboard/components/RefreshWidget */ "./dashboard/components/RefreshWidget.jsx"); +/* harmony import */ var metabase_components_Tooltip__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! metabase/components/Tooltip */ "./components/Tooltip/index.ts"); +/* harmony import */ var _DashboardHeader_styled__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./DashboardHeader.styled */ "./dashboard/components/DashboardHeader.styled.jsx"); +var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10; + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + +/* eslint-disable react/no-string-refs */ + + + + + + + + + + + + +var getDashboardActions = function getDashboardActions(self, _ref) { + var dashboard = _ref.dashboard, + isAdmin = _ref.isAdmin, + _ref$isEditing = _ref.isEditing, + isEditing = _ref$isEditing === void 0 ? false : _ref$isEditing, + _ref$isEmpty = _ref.isEmpty, + isEmpty = _ref$isEmpty === void 0 ? false : _ref$isEmpty, + isFullscreen = _ref.isFullscreen, + isNightMode = _ref.isNightMode, + _ref$isPublic = _ref.isPublic, + isPublic = _ref$isPublic === void 0 ? false : _ref$isPublic, + onNightModeChange = _ref.onNightModeChange, + onFullscreenChange = _ref.onFullscreenChange, + refreshPeriod = _ref.refreshPeriod, + setRefreshElapsedHook = _ref.setRefreshElapsedHook, + onRefreshPeriodChange = _ref.onRefreshPeriodChange, + onSharingClick = _ref.onSharingClick; + var isPublicLinksEnabled = metabase_lib_settings__WEBPACK_IMPORTED_MODULE_6__.default.get("enable-public-sharing"); + var isEmbeddingEnabled = metabase_lib_settings__WEBPACK_IMPORTED_MODULE_6__.default.get("enable-embedding"); + var buttons = []; + var isLoaded = !!dashboard; + var hasCards = isLoaded && dashboard.ordered_cards.length > 0; // dashcardData only contains question cards, text ones don't appear here + + var hasDataCards = hasCards && dashboard.ordered_cards.some(function (dashCard) { + return dashCard.card.display !== "text"; + }); + var canShareDashboard = hasCards; // Getting notifications with static text-only cards doesn't make a lot of sense + + var canSubscribeToDashboard = hasDataCards; + + if (!isEditing && !isEmpty && !isPublic) { + var extraButtonClassNames = "bg-brand-hover text-white-hover py2 px3 text-bold block cursor-pointer"; + + if (canSubscribeToDashboard) { + buttons.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_PopoverWithTrigger__WEBPACK_IMPORTED_MODULE_8__.default, { + ref: "popover", + disabled: !canShareDashboard, + triggerElement: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Tooltip__WEBPACK_IMPORTED_MODULE_10__.default, { + tooltip: canShareDashboard ? (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["Sharing"]))) : (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["Add data to share this dashboard"]))) + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_DashboardHeader_styled__WEBPACK_IMPORTED_MODULE_11__.DashboardHeaderButton, null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Icon__WEBPACK_IMPORTED_MODULE_5__.default, { + name: "share", + className: classnames__WEBPACK_IMPORTED_MODULE_2___default()({ + "text-brand-hover": canShareDashboard, + "text-light": !canShareDashboard + }) + }))) + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "py1" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("a", { + className: extraButtonClassNames, + "data-metabase-event": "Dashboard;Subscriptions", + onClick: function onClick() { + self.refs.popover.close(); + onSharingClick(); + } + }, (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["Dashboard subscriptions"]))))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_containers_DashboardSharingEmbeddingModal_jsx__WEBPACK_IMPORTED_MODULE_3__.default, { + additionalClickActions: function additionalClickActions() { + return self.refs.popover.close(); + }, + dashboard: dashboard, + enabled: !isEditing && !isFullscreen && (isPublicLinksEnabled && (isAdmin || dashboard.public_uuid) || isEmbeddingEnabled && isAdmin), + linkClassNames: extraButtonClassNames, + linkText: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["Sharing and embedding"]))), + key: "dashboard-embed" + }))))); + } else { + buttons.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_containers_DashboardSharingEmbeddingModal_jsx__WEBPACK_IMPORTED_MODULE_3__.default, { + key: "dashboard-embed", + additionalClickActions: function additionalClickActions() { + return self.refs.popover.close(); + }, + dashboard: dashboard, + enabled: !isEditing && !isFullscreen && (isPublicLinksEnabled && (isAdmin || dashboard.public_uuid) || isEmbeddingEnabled && isAdmin), + isLinkEnabled: canShareDashboard, + linkText: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Tooltip__WEBPACK_IMPORTED_MODULE_10__.default, { + isLinkEnabled: canShareDashboard, + tooltip: canShareDashboard ? (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["Sharing"]))) : (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["Add data to share this dashboard"]))) + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_DashboardHeader_styled__WEBPACK_IMPORTED_MODULE_11__.DashboardHeaderButton, null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Icon__WEBPACK_IMPORTED_MODULE_5__.default, { + name: "share", + className: classnames__WEBPACK_IMPORTED_MODULE_2___default()({ + "text-brand-hover": canShareDashboard, + "text-light": !canShareDashboard + }) + }))) + })); + } + } + + if (!isEditing && !isEmpty) { + buttons.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_dashboard_components_RefreshWidget__WEBPACK_IMPORTED_MODULE_9__.default, { + key: "refresh", + "data-metabase-event": "Dashboard;Refresh Menu Open", + className: "text-brand-hover", + period: refreshPeriod, + setRefreshElapsedHook: setRefreshElapsedHook, + onChangePeriod: onRefreshPeriodChange + })); + } + + if (!isEditing) { + buttons.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Tooltip__WEBPACK_IMPORTED_MODULE_10__.default, { + key: "night", + tooltip: isNightMode ? (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["Daytime mode"]))) : (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["Nighttime mode"]))) + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { + "data-metabase-event": "Dashboard;Night Mode;" + !isNightMode + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_DashboardHeader_styled__WEBPACK_IMPORTED_MODULE_11__.DashboardHeaderButton, null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_icons_NightModeIcon__WEBPACK_IMPORTED_MODULE_7__.default, { + className: "text-brand-hover cursor-pointer", + isNightMode: isNightMode, + onClick: function onClick() { + return onNightModeChange(!isNightMode); + } + }))))); + } + + if (!isEditing && !isEmpty) { + // option click to enter fullscreen without making the browser go fullscreen + buttons.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Tooltip__WEBPACK_IMPORTED_MODULE_10__.default, { + key: "fullscreen", + tooltip: isFullscreen ? (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["Exit fullscreen"]))) : (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["Enter fullscreen"]))) + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { + "data-metabase-event": "Dashboard;Fullscreen Mode;" + !isFullscreen + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_DashboardHeader_styled__WEBPACK_IMPORTED_MODULE_11__.DashboardHeaderButton, { + onClick: function onClick(e) { + return onFullscreenChange(!isFullscreen, !e.altKey); + } + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_icons_FullscreenIcon__WEBPACK_IMPORTED_MODULE_4__.default, { + className: "text-brand-hover", + isFullscreen: isFullscreen + }))))); + } + + return buttons; +}; + +/***/ }), + +/***/ "./dashboard/components/DashboardGrid.jsx": +/*!************************************************!*\ + !*** ./dashboard/components/DashboardGrid.jsx ***! + \************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* binding */ DashboardGrid; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prop-types */ "../../../node_modules/prop-types/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var metabase_components_ExplicitSize__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/components/ExplicitSize */ "./components/ExplicitSize.jsx"); +/* harmony import */ var metabase_components_Modal__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/components/Modal */ "./components/Modal.jsx"); +/* harmony import */ var metabase_plugins__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! metabase/plugins */ "./plugins/index.js"); +/* harmony import */ var metabase_visualizations__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! metabase/visualizations */ "./visualizations/index.js"); +/* harmony import */ var metabase_lib_analytics__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! metabase/lib/analytics */ "./lib/analytics.js"); +/* harmony import */ var metabase_lib_colors__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! metabase/lib/colors */ "./lib/colors.ts"); +/* harmony import */ var metabase_lib_dashboard_grid__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! metabase/lib/dashboard_grid */ "./lib/dashboard_grid.js"); +/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! underscore */ "../../../node_modules/underscore/modules/index-all.js"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! classnames */ "../../../node_modules/classnames/index.js"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_10___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_10__); +/* harmony import */ var _grid_GridLayout__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./grid/GridLayout */ "./dashboard/components/grid/GridLayout.jsx"); +/* harmony import */ var _grid_utils__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./grid/utils */ "./dashboard/components/grid/utils.js"); +/* harmony import */ var _AddSeriesModal_AddSeriesModal__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./AddSeriesModal/AddSeriesModal */ "./dashboard/components/AddSeriesModal/AddSeriesModal.jsx"); +/* harmony import */ var _RemoveFromDashboardModal__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./RemoveFromDashboardModal */ "./dashboard/components/RemoveFromDashboardModal.jsx"); +/* harmony import */ var _DashCard__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./DashCard */ "./dashboard/components/DashCard.jsx"); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +var _dec, _class, _class2, _temp; + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/* eslint-disable react/prop-types */ + + + + + + + + + + + + + + + + +var DashboardGrid = (_dec = (0,metabase_components_ExplicitSize__WEBPACK_IMPORTED_MODULE_2__.default)(), _dec(_class = (_temp = _class2 = /*#__PURE__*/function (_Component) { + _inherits(DashboardGrid, _Component); + + var _super = _createSuper(DashboardGrid); + + function DashboardGrid(props, context) { + var _this; + + _classCallCheck(this, DashboardGrid); + + _this = _super.call(this, props, context); + + _defineProperty(_assertThisInitialized(_this), "onLayoutChange", function (_ref) { + var layout = _ref.layout, + breakpoint = _ref.breakpoint; + + // We allow moving and resizing cards only on the desktop + // Ensures onLayoutChange triggered by window resize, + // won't break the main layout + if (breakpoint !== "desktop") { + return; + } + + var _this$props = _this.props, + dashboard = _this$props.dashboard, + setMultipleDashCardAttributes = _this$props.setMultipleDashCardAttributes; + var changes = []; + layout.forEach(function (layoutItem) { + var dashboardCard = dashboard.ordered_cards.find(function (card) { + return String(card.id) === layoutItem.i; + }); + var changed = !underscore__WEBPACK_IMPORTED_MODULE_9__.default.isEqual(layoutItem, _this.getLayoutForDashCard(dashboardCard)); + + if (changed) { + changes.push({ + id: dashboardCard.id, + attributes: { + col: layoutItem.x, + row: layoutItem.y, + sizeX: layoutItem.w, + sizeY: layoutItem.h + } + }); + } + }); + + if (changes.length > 0) { + setMultipleDashCardAttributes(changes); + metabase_lib_analytics__WEBPACK_IMPORTED_MODULE_6__.trackStructEvent("Dashboard", "Layout Changed"); + } + }); + + _defineProperty(_assertThisInitialized(_this), "onDrag", function () { + if (!_this.state.isDragging) { + _this.setState({ + isDragging: true + }); + } + }); + + _defineProperty(_assertThisInitialized(_this), "onDragStop", function () { + _this.setState({ + isDragging: false + }); + }); + + _defineProperty(_assertThisInitialized(_this), "getDashboardCardIcon", function (dashCard) { + var isRegularCollection = metabase_plugins__WEBPACK_IMPORTED_MODULE_4__.PLUGIN_COLLECTIONS.isRegularCollection; + var dashboard = _this.props.dashboard; + var isRegularQuestion = isRegularCollection({ + authority_level: dashCard.collection_authority_level + }); + var isRegularDashboard = isRegularCollection({ + authority_level: dashboard.collection_authority_level + }); + + if (isRegularDashboard && !isRegularQuestion) { + var _opts$tooltips; + + var authorityLevel = dashCard.collection_authority_level; + var opts = metabase_plugins__WEBPACK_IMPORTED_MODULE_4__.PLUGIN_COLLECTIONS.AUTHORITY_LEVEL[authorityLevel]; + var iconSize = 14; + return { + name: opts.icon, + color: (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_7__.color)(opts.color), + tooltip: (_opts$tooltips = opts.tooltips) === null || _opts$tooltips === void 0 ? void 0 : _opts$tooltips.belonging, + size: iconSize, + // Workaround: headerIcon on cards in a first column have incorrect offset out of the box + targetOffsetX: dashCard.col === 0 ? iconSize : 0 + }; + } + }); + + _defineProperty(_assertThisInitialized(_this), "renderGridItem", function (_ref2) { + var dc = _ref2.item, + breakpoint = _ref2.breakpoint, + gridItemWidth = _ref2.gridItemWidth; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + key: String(dc.id), + className: "DashCard" + }, _this.renderDashCard(dc, { + isMobile: breakpoint === "mobile", + gridItemWidth: gridItemWidth + })); + }); + + _this.state = { + layouts: _this.getLayouts(props), + dashcards: _this.getSortedDashcards(props), + removeModalDashCard: null, + addSeriesModalDashCard: null, + isDragging: false + }; + return _this; + } + + _createClass(DashboardGrid, [{ + key: "UNSAFE_componentWillReceiveProps", + value: function UNSAFE_componentWillReceiveProps(nextProps) { + this.setState({ + dashcards: this.getSortedDashcards(nextProps), + layouts: this.getLayouts(nextProps) + }); + } + }, { + key: "getSortedDashcards", + value: function getSortedDashcards(props) { + return props.dashboard && props.dashboard.ordered_cards.sort(function (a, b) { + if (a.row < b.row) { + return -1; + } + + if (a.row > b.row) { + return 1; + } + + if (a.col < b.col) { + return -1; + } + + if (a.col > b.col) { + return 1; + } + + return 0; + }); + } + }, { + key: "getLayoutForDashCard", + value: function getLayoutForDashCard(dashcard) { + var _getVisualizationRaw = (0,metabase_visualizations__WEBPACK_IMPORTED_MODULE_5__.getVisualizationRaw)([{ + card: dashcard.card + }]), + visualization = _getVisualizationRaw.visualization; + + var initialSize = metabase_lib_dashboard_grid__WEBPACK_IMPORTED_MODULE_8__.DEFAULT_CARD_SIZE; + var minSize = visualization.minSize || metabase_lib_dashboard_grid__WEBPACK_IMPORTED_MODULE_8__.DEFAULT_CARD_SIZE; + return { + i: String(dashcard.id), + x: dashcard.col || 0, + y: dashcard.row || 0, + w: dashcard.sizeX || initialSize.width, + h: dashcard.sizeY || initialSize.height, + dashcard: dashcard, + minW: minSize.width, + minH: minSize.height + }; + } + }, { + key: "getLayouts", + value: function getLayouts(_ref3) { + var dashboard = _ref3.dashboard; + var desktop = dashboard.ordered_cards.map(this.getLayoutForDashCard); + var mobile = (0,_grid_utils__WEBPACK_IMPORTED_MODULE_12__.generateMobileLayout)({ + desktopLayout: desktop, + // We want to keep the heights for all visualizations equal not to break the visual rhythm + // Exceptions are text cards (can take too much vertical space) + // and scalar value cards (basically a number and some text on a big card) + heightByDisplayType: { + text: 2, + scalar: 4 + }, + defaultCardHeight: 6 + }); + return { + desktop: desktop, + mobile: mobile + }; + } + }, { + key: "getRowHeight", + value: function getRowHeight() { + var width = this.props.width; + var hasScroll = window.innerWidth > document.documentElement.offsetWidth; + var aspectHeight = width / metabase_lib_dashboard_grid__WEBPACK_IMPORTED_MODULE_8__.GRID_WIDTH / metabase_lib_dashboard_grid__WEBPACK_IMPORTED_MODULE_8__.GRID_ASPECT_RATIO; + var actualHeight = Math.max(aspectHeight, metabase_lib_dashboard_grid__WEBPACK_IMPORTED_MODULE_8__.MIN_ROW_HEIGHT); // prevent infinite re-rendering when the scroll bar appears/disappears + // https://github.com/metabase/metabase/issues/17229 + + return hasScroll ? Math.ceil(actualHeight) : Math.floor(actualHeight); + } + }, { + key: "renderRemoveModal", + value: function renderRemoveModal() { + var _this2 = this; + + // can't use PopoverWithTrigger due to strange interaction with ReactGridLayout + var isOpen = this.state.removeModalDashCard != null; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Modal__WEBPACK_IMPORTED_MODULE_3__.default, { + isOpen: isOpen + }, isOpen && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_RemoveFromDashboardModal__WEBPACK_IMPORTED_MODULE_14__.default, { + dashcard: this.state.removeModalDashCard, + dashboard: this.props.dashboard, + removeCardFromDashboard: this.props.removeCardFromDashboard, + onClose: function onClose() { + return _this2.setState({ + removeModalDashCard: null + }); + } + })); + } + }, { + key: "renderAddSeriesModal", + value: function renderAddSeriesModal() { + var _this3 = this; + + // can't use PopoverWithTrigger due to strange interaction with ReactGridLayout + var isOpen = this.state.addSeriesModalDashCard != null; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Modal__WEBPACK_IMPORTED_MODULE_3__.default, { + className: "Modal AddSeriesModal", + isOpen: isOpen + }, isOpen && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_AddSeriesModal_AddSeriesModal__WEBPACK_IMPORTED_MODULE_13__.default, { + dashcard: this.state.addSeriesModalDashCard, + dashboard: this.props.dashboard, + dashcardData: this.props.dashcardData, + databases: this.props.databases, + fetchCardData: this.props.fetchCardData, + fetchDatabaseMetadata: this.props.fetchDatabaseMetadata, + removeCardFromDashboard: this.props.removeCardFromDashboard, + setDashCardAttributes: this.props.setDashCardAttributes, + onClose: function onClose() { + return _this3.setState({ + addSeriesModalDashCard: null + }); + } + })); + } // we need to track whether or not we're dragging so we can disable pointer events on action buttons :-/ + + }, { + key: "onDashCardRemove", + value: function onDashCardRemove(dc) { + this.setState({ + removeModalDashCard: dc + }); + } + }, { + key: "onDashCardAddSeries", + value: function onDashCardAddSeries(dc) { + this.setState({ + addSeriesModalDashCard: dc + }); + } + }, { + key: "renderDashCard", + value: function renderDashCard(dc, _ref4) { + var isMobile = _ref4.isMobile, + gridItemWidth = _ref4.gridItemWidth; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_DashCard__WEBPACK_IMPORTED_MODULE_15__.default, { + dashcard: dc, + headerIcon: this.getDashboardCardIcon(dc), + dashcardData: this.props.dashcardData, + parameterValues: this.props.parameterValues, + slowCards: this.props.slowCards, + fetchCardData: this.props.fetchCardData, + gridItemWidth: gridItemWidth, + markNewCardSeen: this.props.markNewCardSeen, + isEditing: this.props.isEditing, + isEditingParameter: this.props.isEditingParameter, + isFullscreen: this.props.isFullscreen, + isMobile: isMobile, + onRemove: this.onDashCardRemove.bind(this, dc), + onAddSeries: this.onDashCardAddSeries.bind(this, dc), + onUpdateVisualizationSettings: this.props.onUpdateDashCardVisualizationSettings.bind(this, dc.id), + onReplaceAllVisualizationSettings: this.props.onReplaceAllDashCardVisualizationSettings.bind(this, dc.id), + mode: this.props.mode, + navigateToNewCardFromDashboard: this.props.navigateToNewCardFromDashboard, + onChangeLocation: this.props.onChangeLocation, + metadata: this.props.metadata, + dashboard: this.props.dashboard, + showClickBehaviorSidebar: this.props.showClickBehaviorSidebar, + clickBehaviorSidebarDashcard: this.props.clickBehaviorSidebarDashcard + }); + } + }, { + key: "isEditingLayout", + get: function get() { + var _this$props2 = this.props, + isEditing = _this$props2.isEditing, + isEditingParameter = _this$props2.isEditingParameter, + clickBehaviorSidebarDashcard = _this$props2.clickBehaviorSidebarDashcard; + return isEditing && !isEditingParameter && clickBehaviorSidebarDashcard == null; + } + }, { + key: "renderGrid", + value: function renderGrid() { + var _this$props3 = this.props, + dashboard = _this$props3.dashboard, + width = _this$props3.width; + var layouts = this.state.layouts; + var rowHeight = this.getRowHeight(); + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_grid_GridLayout__WEBPACK_IMPORTED_MODULE_11__.default, { + className: classnames__WEBPACK_IMPORTED_MODULE_10___default()("DashboardGrid", { + "Dash--editing": this.isEditingLayout, + "Dash--dragging": this.state.isDragging + }), + layouts: layouts, + breakpoints: metabase_lib_dashboard_grid__WEBPACK_IMPORTED_MODULE_8__.GRID_BREAKPOINTS, + cols: metabase_lib_dashboard_grid__WEBPACK_IMPORTED_MODULE_8__.GRID_COLUMNS, + width: width, + margin: { + desktop: [6, 6], + mobile: [6, 10] + }, + containerPadding: [0, 0], + rowHeight: rowHeight, + onLayoutChange: this.onLayoutChange, + onDrag: this.onDrag, + onDragStop: this.onDragStop, + isEditing: this.isEditingLayout, + compactType: "vertical", + items: dashboard.ordered_cards, + itemRenderer: this.renderGridItem + }); + } + }, { + key: "render", + value: function render() { + var width = this.props.width; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "flex layout-centered" + }, width > 0 ? this.renderGrid() : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", null), this.renderRemoveModal(), this.renderAddSeriesModal()); + } + }]); + + return DashboardGrid; +}(react__WEBPACK_IMPORTED_MODULE_0__.Component), _defineProperty(_class2, "propTypes", { + isEditing: prop_types__WEBPACK_IMPORTED_MODULE_1___default().oneOfType([(prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), (prop_types__WEBPACK_IMPORTED_MODULE_1___default().object)]).isRequired, + isEditingParameter: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool.isRequired), + dashboard: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().object.isRequired), + parameterValues: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().object.isRequired), + setDashCardAttributes: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func.isRequired), + setMultipleDashCardAttributes: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func.isRequired), + removeCardFromDashboard: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func.isRequired), + markNewCardSeen: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func.isRequired), + fetchCardData: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func.isRequired), + onUpdateDashCardVisualizationSettings: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func.isRequired), + onReplaceAllDashCardVisualizationSettings: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func.isRequired), + onChangeLocation: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func.isRequired) +}), _defineProperty(_class2, "defaultProps", { + width: 0, + isEditing: false, + isEditingParameter: false +}), _temp)) || _class); + + +/***/ }), + +/***/ "./dashboard/components/DashboardHeader.styled.jsx": +/*!*********************************************************!*\ + !*** ./dashboard/components/DashboardHeader.styled.jsx ***! + \*********************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "DashboardHeaderButton": function() { return /* binding */ DashboardHeaderButton; } +/* harmony export */ }); +/* harmony import */ var styled_components__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! styled-components */ "../../../node_modules/styled-components/dist/styled-components.browser.es.js"); +/* harmony import */ var metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/lib/colors */ "./lib/colors.ts"); + + +var DashboardHeaderButton = styled_components__WEBPACK_IMPORTED_MODULE_0__.default.button.withConfig({ + displayName: "DashboardHeaderstyled__DashboardHeaderButton", + componentId: "vfvqnm-0" +})(["display:flex;align-items:center;justify-content:center;padding:8px 12px;border-radius:6px;color:", ";background-color:", ";transition:all 200ms;cursor:pointer;&:hover{color:", ";background-color:", ";}"], function (props) { + return props.isActive ? metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.default.brand : metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.default["text-neutral"]; +}, function (props) { + return props.isActive ? metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.default["brand-light"] : "transparent"; +}, function (props) { + return props.isActive ? metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.default.white : metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.default.brand; +}, function (props) { + return props.isActive ? metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.default.brand : "transparent"; +}); + +/***/ }), + +/***/ "./dashboard/components/RefreshWidget.jsx": +/*!************************************************!*\ + !*** ./dashboard/components/RefreshWidget.jsx ***! + \************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* binding */ RefreshWidget; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var _RefreshWidget_css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./RefreshWidget.css */ "./dashboard/components/RefreshWidget.css"); +/* harmony import */ var _RefreshWidget_css__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_RefreshWidget_css__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var metabase_components_PopoverWithTrigger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/components/PopoverWithTrigger */ "./components/PopoverWithTrigger.jsx"); +/* harmony import */ var metabase_components_Tooltip__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/components/Tooltip */ "./components/Tooltip/index.ts"); +/* harmony import */ var metabase_components_Icon__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! metabase/components/Icon */ "./components/Icon.tsx"); +/* harmony import */ var metabase_components_icons_ClockIcon__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! metabase/components/icons/ClockIcon */ "./components/icons/ClockIcon.jsx"); +/* harmony import */ var metabase_components_icons_CountdownIcon__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! metabase/components/icons/CountdownIcon */ "./components/icons/CountdownIcon.jsx"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_7__); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! classnames */ "../../../node_modules/classnames/index.js"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_8__); +/* harmony import */ var _DashboardHeader_styled__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./DashboardHeader.styled */ "./dashboard/components/DashboardHeader.styled.jsx"); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9; + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + +/* eslint-disable react/prop-types */ + + + + + + + + + + +var OPTIONS = [{ + name: (0,ttag__WEBPACK_IMPORTED_MODULE_7__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["Off"]))), + period: null +}, { + name: (0,ttag__WEBPACK_IMPORTED_MODULE_7__.t)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["1 minute"]))), + period: 1 * 60 +}, { + name: (0,ttag__WEBPACK_IMPORTED_MODULE_7__.t)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["5 minutes"]))), + period: 5 * 60 +}, { + name: (0,ttag__WEBPACK_IMPORTED_MODULE_7__.t)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["10 minutes"]))), + period: 10 * 60 +}, { + name: (0,ttag__WEBPACK_IMPORTED_MODULE_7__.t)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["15 minutes"]))), + period: 15 * 60 +}, { + name: (0,ttag__WEBPACK_IMPORTED_MODULE_7__.t)(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["30 minutes"]))), + period: 30 * 60 +}, { + name: (0,ttag__WEBPACK_IMPORTED_MODULE_7__.t)(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["60 minutes"]))), + period: 60 * 60 +}]; + +var RefreshWidget = /*#__PURE__*/function (_Component) { + _inherits(RefreshWidget, _Component); + + var _super = _createSuper(RefreshWidget); + + function RefreshWidget(props) { + var _this; + + _classCallCheck(this, RefreshWidget); + + _this = _super.call(this, props); + + _defineProperty(_assertThisInitialized(_this), "state", { + elapsed: null + }); + + _this.popover = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createRef(); + return _this; + } + + _createClass(RefreshWidget, [{ + key: "UNSAFE_componentWillMount", + value: function UNSAFE_componentWillMount() { + var _this2 = this; + + var setRefreshElapsedHook = this.props.setRefreshElapsedHook; + + if (setRefreshElapsedHook) { + setRefreshElapsedHook(function (elapsed) { + return _this2.setState({ + elapsed: elapsed + }); + }); + } + } + }, { + key: "componentDidUpdate", + value: function componentDidUpdate(prevProps) { + var _this3 = this; + + var setRefreshElapsedHook = this.props.setRefreshElapsedHook; + + if (setRefreshElapsedHook && prevProps.setRefreshElapsedHook !== setRefreshElapsedHook) { + setRefreshElapsedHook(function (elapsed) { + return _this3.setState({ + elapsed: elapsed + }); + }); + } + } + }, { + key: "render", + value: function render() { + var _this4 = this; + + var _this$props = this.props, + period = _this$props.period, + onChangePeriod = _this$props.onChangePeriod, + className = _this$props.className; + var elapsed = this.state.elapsed; + var remaining = period - elapsed; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_PopoverWithTrigger__WEBPACK_IMPORTED_MODULE_2__.default, { + ref: this.popover, + triggerElement: elapsed == null ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Tooltip__WEBPACK_IMPORTED_MODULE_3__.default, { + tooltip: (0,ttag__WEBPACK_IMPORTED_MODULE_7__.t)(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["Auto-refresh"]))) + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_DashboardHeader_styled__WEBPACK_IMPORTED_MODULE_9__.DashboardHeaderButton, null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_icons_ClockIcon__WEBPACK_IMPORTED_MODULE_5__.default, { + width: 18, + height: 18, + className: className + }))) : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Tooltip__WEBPACK_IMPORTED_MODULE_3__.default, { + tooltip: (0,ttag__WEBPACK_IMPORTED_MODULE_7__.t)(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["Refreshing in"]))) + " " + Math.floor(remaining / 60) + ":" + (remaining % 60 < 10 ? "0" : "") + Math.round(remaining % 60) + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_DashboardHeader_styled__WEBPACK_IMPORTED_MODULE_9__.DashboardHeaderButton, null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_icons_CountdownIcon__WEBPACK_IMPORTED_MODULE_6__.default, { + width: 18, + height: 18, + className: "text-green", + percent: Math.min(0.95, (period - elapsed) / period) + }))), + targetOffsetY: 10 + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: (_RefreshWidget_css__WEBPACK_IMPORTED_MODULE_1___default().popover) + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: (_RefreshWidget_css__WEBPACK_IMPORTED_MODULE_1___default().title) + }, "Auto Refresh"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(RefreshOptionList, null, OPTIONS.map(function (option) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(RefreshOption, { + key: option.period, + name: option.name, + period: option.period, + selected: option.period === period, + onClick: function onClick() { + _this4.popover.current.close(); + + onChangePeriod(option.period); + } + }); + })))); + } + }]); + + return RefreshWidget; +}(react__WEBPACK_IMPORTED_MODULE_0__.Component); + + + +var RefreshOptionList = function RefreshOptionList(_ref) { + var children = _ref.children; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("ul", null, children); +}; + +var RefreshOption = function RefreshOption(_ref2) { + var name = _ref2.name, + period = _ref2.period, + selected = _ref2.selected, + onClick = _ref2.onClick; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("li", { + className: classnames__WEBPACK_IMPORTED_MODULE_8___default()((_RefreshWidget_css__WEBPACK_IMPORTED_MODULE_1___default().option), (_RefreshWidget_css__WEBPACK_IMPORTED_MODULE_1___default())[period == null ? "off" : "on"], _defineProperty({}, (_RefreshWidget_css__WEBPACK_IMPORTED_MODULE_1___default().selected), selected)), + onClick: onClick + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Icon__WEBPACK_IMPORTED_MODULE_4__.default, { + name: "check", + size: 14 + }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { + className: (_RefreshWidget_css__WEBPACK_IMPORTED_MODULE_1___default().name) + }, name.split(" ")[0]), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { + className: (_RefreshWidget_css__WEBPACK_IMPORTED_MODULE_1___default().nameSuffix) + }, " ", name.split(" ")[1])); +}; + +/***/ }), + +/***/ "./dashboard/components/RemoveFromDashboardModal.jsx": +/*!***********************************************************!*\ + !*** ./dashboard/components/RemoveFromDashboardModal.jsx ***! + \***********************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* binding */ RemoveFromDashboardModal; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prop-types */ "../../../node_modules/prop-types/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_2__); +/* harmony import */ var metabase_lib_analytics__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/lib/analytics */ "./lib/analytics.js"); +/* harmony import */ var metabase_components_Button__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! metabase/components/Button */ "./components/Button.tsx"); +/* harmony import */ var metabase_components_ModalContent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! metabase/components/ModalContent */ "./components/ModalContent.jsx"); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +var _templateObject, _templateObject2, _templateObject3; + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + + + + + + + + +var RemoveFromDashboardModal = /*#__PURE__*/function (_Component) { + _inherits(RemoveFromDashboardModal, _Component); + + var _super = _createSuper(RemoveFromDashboardModal); + + function RemoveFromDashboardModal() { + _classCallCheck(this, RemoveFromDashboardModal); + + return _super.apply(this, arguments); + } + + _createClass(RemoveFromDashboardModal, [{ + key: "onRemove", + value: function onRemove() { + this.props.removeCardFromDashboard({ + dashId: this.props.dashboard.id, + dashcardId: this.props.dashcard.id + }); + this.props.onClose(); + metabase_lib_analytics__WEBPACK_IMPORTED_MODULE_3__.trackStructEvent("Dashboard", "Remove Card"); + } + }, { + key: "render", + value: function render() { + var _this = this; + + var _onClose = this.props.onClose; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_ModalContent__WEBPACK_IMPORTED_MODULE_5__.default, { + title: (0,ttag__WEBPACK_IMPORTED_MODULE_2__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["Remove this question?"]))), + onClose: function onClose() { + return _onClose(); + } + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + className: "flex-align-right" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Button__WEBPACK_IMPORTED_MODULE_4__.default, { + onClick: _onClose + }, (0,ttag__WEBPACK_IMPORTED_MODULE_2__.t)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["Cancel"])))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Button__WEBPACK_IMPORTED_MODULE_4__.default, { + danger: true, + ml: 2, + onClick: function onClick() { + return _this.onRemove(); + } + }, (0,ttag__WEBPACK_IMPORTED_MODULE_2__.t)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["Remove"])))))); + } + }]); + + return RemoveFromDashboardModal; +}(react__WEBPACK_IMPORTED_MODULE_0__.Component); + +_defineProperty(RemoveFromDashboardModal, "propTypes", { + dashcard: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().object.isRequired), + dashboard: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().object.isRequired), + removeCardFromDashboard: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func.isRequired), + onClose: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func.isRequired) +}); + + + +/***/ }), + +/***/ "./dashboard/components/grid/GridLayout.jsx": +/*!**************************************************!*\ + !*** ./dashboard/components/grid/GridLayout.jsx ***! + \**************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var react_grid_layout__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-grid-layout */ "../../../node_modules/react-grid-layout/index.js"); +/* harmony import */ var react_grid_layout__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_grid_layout__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var react_grid_layout_css_styles_css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react-grid-layout/css/styles.css */ "../../../node_modules/react-grid-layout/css/styles.css"); +/* harmony import */ var react_grid_layout_css_styles_css__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(react_grid_layout_css_styles_css__WEBPACK_IMPORTED_MODULE_2__); +/* harmony import */ var react_resizable_css_styles_css__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! react-resizable/css/styles.css */ "../../../node_modules/react-resizable/css/styles.css"); +/* harmony import */ var react_resizable_css_styles_css__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(react_resizable_css_styles_css__WEBPACK_IMPORTED_MODULE_3__); +/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./utils */ "./dashboard/components/grid/utils.js"); +var _excluded = ["items", "itemRenderer", "breakpoints", "layouts", "cols", "width", "margin", "rowHeight", "isEditing", "onLayoutChange"]; + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } + +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } + +function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } + +function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } + +function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } + +function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } + +/* eslint-disable react/prop-types */ + + + + + + +function GridLayout(_ref) { + var items = _ref.items, + itemRenderer = _ref.itemRenderer, + breakpoints = _ref.breakpoints, + layouts = _ref.layouts, + columnsMap = _ref.cols, + gridWidth = _ref.width, + marginMap = _ref.margin, + rowHeight = _ref.rowHeight, + isEditing = _ref.isEditing, + onLayoutChange = _ref.onLayoutChange, + props = _objectWithoutProperties(_ref, _excluded); + + var _useState = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(react_grid_layout__WEBPACK_IMPORTED_MODULE_1__.Responsive.utils.getBreakpointFromWidth(breakpoints, gridWidth)), + _useState2 = _slicedToArray(_useState, 2), + currentBreakpoint = _useState2[0], + setCurrentBreakpoint = _useState2[1]; + + var onLayoutChangeWrapped = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function (nextLayout) { + onLayoutChange({ + layout: nextLayout, + // Calculating the breakpoint right here, + // so we're definitely passing the most recent one + // Workaround for https://github.com/react-grid-layout/react-grid-layout/issues/889 + breakpoint: react_grid_layout__WEBPACK_IMPORTED_MODULE_1__.Responsive.utils.getBreakpointFromWidth(breakpoints, gridWidth) + }); + }, [onLayoutChange, breakpoints, gridWidth]); + var onBreakpointChange = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function (newBreakpoint) { + setCurrentBreakpoint(newBreakpoint); + }, []); + var margin = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(function () { + return marginMap[currentBreakpoint]; + }, [marginMap, currentBreakpoint]); + var layout = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(function () { + return layouts[currentBreakpoint]; + }, [layouts, currentBreakpoint]); + var cols = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(function () { + return columnsMap[currentBreakpoint]; + }, [columnsMap, currentBreakpoint]); + var cellSize = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(function () { + var marginSlotsCount = cols - 1; + + var _margin = _slicedToArray(margin, 1), + horizontalMargin = _margin[0]; + + var totalHorizontalMargin = marginSlotsCount * horizontalMargin; + var freeSpace = gridWidth - totalHorizontalMargin; + return { + width: freeSpace / cols, + height: rowHeight + }; + }, [cols, gridWidth, rowHeight, margin]); + var renderItem = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function (item) { + var itemLayout = layout.find(function (l) { + return String(l.i) === String(item.id); + }); + var gridItemWidth = cellSize.width * itemLayout.w; + return itemRenderer({ + item: item, + gridItemWidth: gridItemWidth, + breakpoint: currentBreakpoint + }); + }, [layout, cellSize, itemRenderer, currentBreakpoint]); + var height = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(function () { + var lowestLayoutCellPoint = Math.max.apply(Math, _toConsumableArray(layout.map(function (l) { + return l.y + l.h; + }))); + + if (isEditing) { + lowestLayoutCellPoint += Math.ceil(window.innerHeight / cellSize.height); + } // eslint-disable-next-line no-unused-vars + + + var _margin2 = _slicedToArray(margin, 2), + horizontalMargin = _margin2[0], + verticalMargin = _margin2[1]; + + return (cellSize.height + verticalMargin) * lowestLayoutCellPoint; + }, [cellSize.height, layout, margin, isEditing]); + var background = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(function () { + return (0,_utils__WEBPACK_IMPORTED_MODULE_4__.generateGridBackground)({ + cellSize: cellSize, + margin: margin, + cols: cols, + gridWidth: gridWidth + }); + }, [cellSize, gridWidth, margin, cols]); + var style = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(function () { + return { + width: gridWidth, + height: height, + background: isEditing ? background : "" + }; + }, [gridWidth, height, background, isEditing]); + var isMobile = currentBreakpoint === "mobile"; // https://github.com/react-grid-layout/react-grid-layout#performance + + var children = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(function () { + return items.map(renderItem); + }, [items, renderItem]); + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(react_grid_layout__WEBPACK_IMPORTED_MODULE_1__.Responsive, _extends({ + breakpoints: breakpoints, + cols: columnsMap, + layouts: layouts, + width: gridWidth, + margin: margin, + rowHeight: rowHeight, + isDraggable: isEditing && !isMobile, + isResizable: isEditing && !isMobile + }, props, { + autoSize: false, + onLayoutChange: onLayoutChangeWrapped, + onBreakpointChange: onBreakpointChange, + style: style + }), children); +} + +/* harmony default export */ __webpack_exports__["default"] = (GridLayout); + +/***/ }), + +/***/ "./dashboard/components/grid/utils.js": +/*!********************************************!*\ + !*** ./dashboard/components/grid/utils.js ***! + \********************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "generateMobileLayout": function() { return /* binding */ generateMobileLayout; }, +/* harmony export */ "generateGridBackground": function() { return /* binding */ generateGridBackground; } +/* harmony export */ }); +/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! underscore */ "../../../node_modules/underscore/modules/index-all.js"); +/* harmony import */ var metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/lib/colors */ "./lib/colors.ts"); +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } + +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } + +function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } + +function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } + +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + + + + +function sumVerticalSpace(layout) { + return layout.reduce(function (sum, current) { + return sum + current.h; + }, 0); +} + +function generateMobileLayout(_ref) { + var desktopLayout = _ref.desktopLayout, + defaultCardHeight = _ref.defaultCardHeight, + _ref$heightByDisplayT = _ref.heightByDisplayType, + heightByDisplayType = _ref$heightByDisplayT === void 0 ? {} : _ref$heightByDisplayT; + var mobile = []; + desktopLayout.forEach(function (item) { + var card = item.dashcard.card; + var height = heightByDisplayType[card.display] || defaultCardHeight; + mobile.push(_objectSpread(_objectSpread({}, item), {}, { + x: 0, + y: sumVerticalSpace(mobile), + h: height, + w: 1 + })); + }); + return mobile; +} +function generateGridBackground(_ref2) { + var cellSize = _ref2.cellSize, + margin = _ref2.margin, + cols = _ref2.cols, + gridWidth = _ref2.gridWidth; + var XMLNS = "http://www.w3.org/2000/svg"; + + var _margin = _slicedToArray(margin, 2), + horizontalMargin = _margin[0], + verticalMargin = _margin[1]; + + var rowHeight = cellSize.height + verticalMargin; + var cellStrokeColor = (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.color)("border"); + var y = 0; + var w = cellSize.width; + var h = cellSize.height; + + var rectangles = (0,underscore__WEBPACK_IMPORTED_MODULE_0__.default)(cols).times(function (i) { + var x = i * (cellSize.width + horizontalMargin); + return ""); + }); + + var svg = ["")].concat(_toConsumableArray(rectangles), [""]).join(""); + return "url(\"data:image/svg+xml;utf8,".concat(encodeURIComponent(svg), "\")"); +} + +/***/ }), + +/***/ "./dashboard/constants.js": +/*!********************************!*\ + !*** ./dashboard/constants.js ***! + \********************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "SIDEBAR_NAME": function() { return /* binding */ SIDEBAR_NAME; } +/* harmony export */ }); +var SIDEBAR_NAME = { + addQuestion: "addQuestion", + clickBehavior: "clickBehavior", + editParameter: "editParameter", + sharing: "sharing" +}; + +/***/ }), + +/***/ "./dashboard/containers/DashboardSharingEmbeddingModal.jsx": +/*!*****************************************************************!*\ + !*** ./dashboard/containers/DashboardSharingEmbeddingModal.jsx ***! + \*****************************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var react_redux__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-redux */ "../../../node_modules/react-redux/es/index.js"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! classnames */ "../../../node_modules/classnames/index.js"); +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_2__); +/* harmony import */ var metabase_components_ModalWithTrigger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/components/ModalWithTrigger */ "./components/ModalWithTrigger.jsx"); +/* harmony import */ var metabase_public_components_widgets_EmbedModalContent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! metabase/public/components/widgets/EmbedModalContent */ "./public/components/widgets/EmbedModalContent.jsx"); +/* harmony import */ var metabase_lib_urls__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! metabase/lib/urls */ "./lib/urls.js"); +/* harmony import */ var metabase_lib_analytics__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! metabase/lib/analytics */ "./lib/analytics.js"); +/* harmony import */ var _actions__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../actions */ "./dashboard/actions.js"); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +var _excluded = ["additionalClickActions", "className", "createPublicLink", "dashboard", "deletePublicLink", "enabled", "linkClassNames", "linkText", "isLinkEnabled", "updateEnableEmbedding", "updateEmbeddingParams"]; + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } + +function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/* eslint-disable react/prop-types */ + + + + + + + + +var defaultProps = { + isLinkEnabled: true +}; +var mapDispatchToProps = { + createPublicLink: _actions__WEBPACK_IMPORTED_MODULE_7__.createPublicLink, + deletePublicLink: _actions__WEBPACK_IMPORTED_MODULE_7__.deletePublicLink, + updateEnableEmbedding: _actions__WEBPACK_IMPORTED_MODULE_7__.updateEnableEmbedding, + updateEmbeddingParams: _actions__WEBPACK_IMPORTED_MODULE_7__.updateEmbeddingParams +}; + +var DashboardSharingEmbeddingModal = /*#__PURE__*/function (_Component) { + _inherits(DashboardSharingEmbeddingModal, _Component); + + var _super = _createSuper(DashboardSharingEmbeddingModal); + + function DashboardSharingEmbeddingModal() { + var _this; + + _classCallCheck(this, DashboardSharingEmbeddingModal); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _super.call.apply(_super, [this].concat(args)); + + _defineProperty(_assertThisInitialized(_this), "_modal", void 0); + + return _this; + } + + _createClass(DashboardSharingEmbeddingModal, [{ + key: "render", + value: function render() { + var _this2 = this; + + var _this$props = this.props, + additionalClickActions = _this$props.additionalClickActions, + className = _this$props.className, + createPublicLink = _this$props.createPublicLink, + dashboard = _this$props.dashboard, + deletePublicLink = _this$props.deletePublicLink, + enabled = _this$props.enabled, + linkClassNames = _this$props.linkClassNames, + linkText = _this$props.linkText, + isLinkEnabled = _this$props.isLinkEnabled, + updateEnableEmbedding = _this$props.updateEnableEmbedding, + updateEmbeddingParams = _this$props.updateEmbeddingParams, + props = _objectWithoutProperties(_this$props, _excluded); + + if (!enabled) { + return null; + } + + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_ModalWithTrigger__WEBPACK_IMPORTED_MODULE_3__.default, { + ref: function ref(m) { + return _this2._modal = m; + }, + full: true, + disabled: !isLinkEnabled, + triggerElement: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("a", { + className: linkClassNames, + "aria-disabled": !isLinkEnabled, + onClick: function onClick() { + if (isLinkEnabled) { + metabase_lib_analytics__WEBPACK_IMPORTED_MODULE_6__.trackStructEvent("Sharing / Embedding", "dashboard", "Sharing Link Clicked"); + } + } + }, linkText), + triggerClasses: classnames__WEBPACK_IMPORTED_MODULE_2___default()(className, "text-brand-hover"), + className: "scroll-y" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_public_components_widgets_EmbedModalContent__WEBPACK_IMPORTED_MODULE_4__.default, _extends({}, props, { + className: className, + resource: dashboard, + resourceParameters: dashboard && dashboard.parameters, + resourceType: "dashboard", + onCreatePublicLink: function onCreatePublicLink() { + return createPublicLink(dashboard); + }, + onDisablePublicLink: function onDisablePublicLink() { + return deletePublicLink(dashboard); + }, + onUpdateEnableEmbedding: function onUpdateEnableEmbedding(enableEmbedding) { + return updateEnableEmbedding(dashboard, enableEmbedding); + }, + onUpdateEmbeddingParams: function onUpdateEmbeddingParams(embeddingParams) { + return updateEmbeddingParams(dashboard, embeddingParams); + }, + onClose: function onClose() { + _this2._modal && _this2._modal.close(); + additionalClickActions(); + }, + getPublicUrl: function getPublicUrl(_ref) { + var public_uuid = _ref.public_uuid; + return metabase_lib_urls__WEBPACK_IMPORTED_MODULE_5__.publicDashboard(public_uuid); + } + }))); + } + }]); + + return DashboardSharingEmbeddingModal; +}(react__WEBPACK_IMPORTED_MODULE_0__.Component); + +DashboardSharingEmbeddingModal.defaultProps = defaultProps; +/* harmony default export */ __webpack_exports__["default"] = ((0,react_redux__WEBPACK_IMPORTED_MODULE_1__.connect)(null, mapDispatchToProps)(DashboardSharingEmbeddingModal)); + +/***/ }), + +/***/ "./dashboard/hoc/DashboardControls.jsx": +/*!*********************************************!*\ + !*** ./dashboard/hoc/DashboardControls.jsx ***! + \*********************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var react_redux__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-redux */ "../../../node_modules/react-redux/es/index.js"); +/* harmony import */ var react_router_redux__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react-router-redux */ "../../../node_modules/react-router-redux/lib/index.js"); +/* harmony import */ var metabase_lib_analytics__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/lib/analytics */ "./lib/analytics.js"); +/* harmony import */ var metabase_lib_browser__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! metabase/lib/browser */ "./lib/browser.js"); +/* harmony import */ var screenfull__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! screenfull */ "../../../node_modules/screenfull/dist/screenfull.js"); +/* harmony import */ var screenfull__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(screenfull__WEBPACK_IMPORTED_MODULE_5__); +/* provided dependency */ var console = __webpack_require__(/*! console-browserify */ "../../../node_modules/console-browserify/index.js"); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } + +function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/* eslint-disable react/prop-types */ + + + + + + +var TICK_PERIOD = 1; // seconds + +/* This contains some state for dashboard controls on both private and embedded dashboards. + * It should probably be in Redux? + */ + +/* harmony default export */ __webpack_exports__["default"] = (function (ComposedComponent) { + var _class, _temp; + + return (0,react_redux__WEBPACK_IMPORTED_MODULE_1__.connect)(null, { + replace: react_router_redux__WEBPACK_IMPORTED_MODULE_2__.replace + })((_temp = _class = /*#__PURE__*/function (_Component) { + _inherits(_class, _Component); + + var _super = _createSuper(_class); + + function _class() { + var _this; + + _classCallCheck(this, _class); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _super.call.apply(_super, [this].concat(args)); + + _defineProperty(_assertThisInitialized(_this), "state", { + isFullscreen: false, + isNightMode: false, + refreshPeriod: null, + hideParameters: null + }); + + _defineProperty(_assertThisInitialized(_this), "loadDashboardParams", function () { + var location = _this.props.location; + var options = (0,metabase_lib_browser__WEBPACK_IMPORTED_MODULE_4__.parseHashOptions)(location.hash); + + _this.setRefreshPeriod(Number.isNaN(options.refresh) || options.refresh === 0 ? null : options.refresh); + + _this.setNightMode(options.theme === "night" || options.night); // DEPRECATED: options.night + + + _this.setFullscreen(options.fullscreen); + + _this.setHideParameters(options.hide_parameters); + }); + + _defineProperty(_assertThisInitialized(_this), "updateDashboardParams", function () { + var _this$props = _this.props, + location = _this$props.location, + replace = _this$props.replace; + var options = (0,metabase_lib_browser__WEBPACK_IMPORTED_MODULE_4__.parseHashOptions)(location.hash); + + var setValue = function setValue(name, value) { + if (value) { + options[name] = value; + } else { + delete options[name]; + } + }; + + setValue("refresh", _this.state.refreshPeriod); + setValue("fullscreen", _this.state.isFullscreen); + setValue("theme", _this.state.isNightMode ? "night" : null); + delete options.night; // DEPRECATED: options.night + // Delete the "add card to dashboard" and "editing mode" parameters + // if they are present because we do not want to add the card again on + // page refresh. The parameters are already handled in DashboardApp + // before this method is called. + + delete options.add; + delete options.edit; + var hash = (0,metabase_lib_browser__WEBPACK_IMPORTED_MODULE_4__.stringifyHashOptions)(options); + hash = hash ? "#" + hash : ""; + + if (hash !== location.hash) { + replace({ + pathname: location.pathname, + search: location.search, + hash: hash + }); + } + }); + + _defineProperty(_assertThisInitialized(_this), "setRefreshPeriod", function (refreshPeriod) { + _this._clearRefreshInterval(); + + if (refreshPeriod != null) { + _this._interval = setInterval(_this._tickRefreshClock, TICK_PERIOD * 1000); + + _this.setState({ + refreshPeriod: refreshPeriod + }); + + _this.setRefreshElapsed(0); + + metabase_lib_analytics__WEBPACK_IMPORTED_MODULE_3__.trackStructEvent("Dashboard", "Set Refresh", refreshPeriod); + } else { + _this.setState({ + refreshPeriod: null + }); + + _this.setRefreshElapsed(null); + } + }); + + _defineProperty(_assertThisInitialized(_this), "setNightMode", function (isNightMode) { + isNightMode = !!isNightMode; + + _this.setState({ + isNightMode: isNightMode + }); + }); + + _defineProperty(_assertThisInitialized(_this), "setFullscreen", /*#__PURE__*/function () { + var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(isFullscreen) { + var browserFullscreen, + _args = arguments; + return regeneratorRuntime.wrap(function _callee$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + browserFullscreen = _args.length > 1 && _args[1] !== undefined ? _args[1] : true; + isFullscreen = !!isFullscreen; + + if (!(isFullscreen !== _this.state.isFullscreen)) { + _context.next = 18; + break; + } + + if (!((screenfull__WEBPACK_IMPORTED_MODULE_5___default().enabled) && browserFullscreen)) { + _context.next = 17; + break; + } + + if (!isFullscreen) { + _context.next = 15; + break; + } + + _context.prev = 5; + _context.next = 8; + return screenfull__WEBPACK_IMPORTED_MODULE_5___default().request(); + + case 8: + _context.next = 13; + break; + + case 10: + _context.prev = 10; + _context.t0 = _context["catch"](5); + console.warn("Couldn't enable browser fullscreen: ".concat(_context.t0)); + + case 13: + _context.next = 17; + break; + + case 15: + _context.next = 17; + return screenfull__WEBPACK_IMPORTED_MODULE_5___default().exit(); + + case 17: + _this.setState({ + isFullscreen: isFullscreen + }); + + case 18: + case "end": + return _context.stop(); + } + } + }, _callee, null, [[5, 10]]); + })); + + return function (_x) { + return _ref.apply(this, arguments); + }; + }()); + + _defineProperty(_assertThisInitialized(_this), "setHideParameters", function (parameters) { + _this.setState({ + hideParameters: parameters + }); + }); + + _defineProperty(_assertThisInitialized(_this), "_tickRefreshClock", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() { + var refreshPeriod; + return regeneratorRuntime.wrap(function _callee2$(_context2) { + while (1) { + switch (_context2.prev = _context2.next) { + case 0: + _this._refreshElapsed = (_this._refreshElapsed || 0) + TICK_PERIOD; + refreshPeriod = _this.state.refreshPeriod; + + if (!(refreshPeriod && _this._refreshElapsed >= refreshPeriod)) { + _context2.next = 7; + break; + } + + _this._refreshElapsed = 0; + _context2.next = 6; + return _this.props.fetchDashboard(_this.props.dashboardId, _this.props.location.query, true); + + case 6: + _this.props.fetchDashboardCardData({ + reload: true, + clear: false + }); + + case 7: + _this.setRefreshElapsed(_this._refreshElapsed); + + case 8: + case "end": + return _context2.stop(); + } + } + }, _callee2); + }))); + + _defineProperty(_assertThisInitialized(_this), "_fullScreenChanged", function () { + _this.setState({ + isFullscreen: !!(screenfull__WEBPACK_IMPORTED_MODULE_5___default().isFullscreen) + }); + }); + + _defineProperty(_assertThisInitialized(_this), "setRefreshElapsedHook", function (hook) { + _this._refreshElapsedHook = hook; + }); + + _defineProperty(_assertThisInitialized(_this), "setRefreshElapsed", function (elapsed) { + if (_this._refreshElapsedHook) { + _this._refreshElapsedHook(elapsed); + } + }); + + return _this; + } + + _createClass(_class, [{ + key: "UNSAFE_componentWillMount", + value: function UNSAFE_componentWillMount() { + if ((screenfull__WEBPACK_IMPORTED_MODULE_5___default().enabled)) { + document.addEventListener((screenfull__WEBPACK_IMPORTED_MODULE_5___default().raw.fullscreenchange), this._fullScreenChanged); + } + + this.loadDashboardParams(); + } + }, { + key: "componentDidUpdate", + value: function componentDidUpdate() { + this.updateDashboardParams(); + + this._showNav(!this.state.isFullscreen); + } + }, { + key: "componentWillUnmount", + value: function componentWillUnmount() { + this._showNav(true); + + this._clearRefreshInterval(); + + if ((screenfull__WEBPACK_IMPORTED_MODULE_5___default().enabled)) { + document.removeEventListener((screenfull__WEBPACK_IMPORTED_MODULE_5___default().raw.fullscreenchange), this._fullScreenChanged); + } + } + }, { + key: "_clearRefreshInterval", + value: function _clearRefreshInterval() { + if (this._interval != null) { + clearInterval(this._interval); + } + } + }, { + key: "_showNav", + value: function _showNav(show) { + // NOTE Atte Keinänen 8/10/17: For some reason `document` object isn't present in Jest tests + // when _showNav is called for the first time + if (window.document) { + var nav = window.document.querySelector(".Nav"); + + if (show && nav) { + nav.classList.remove("hide"); + } else if (!show && nav) { + nav.classList.add("hide"); + } + } + } + }, { + key: "render", + value: function render() { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(ComposedComponent, _extends({}, this.props, this.state, { + setRefreshElapsedHook: this.setRefreshElapsedHook, + loadDashboardParams: this.loadDashboardParams, + updateDashboardParams: this.updateDashboardParams, + onNightModeChange: this.setNightMode, + onFullscreenChange: this.setFullscreen, + onRefreshPeriodChange: this.setRefreshPeriod + })); + } + }]); + + return _class; + }(react__WEBPACK_IMPORTED_MODULE_0__.Component), _defineProperty(_class, "displayName", "DashboardControls[" + (ComposedComponent.displayName || ComposedComponent.name) + "]"), _temp)); +}); + +/***/ }), + +/***/ "./dashboard/reducers.js": +/*!*******************************!*\ + !*** ./dashboard/reducers.js ***! + \*******************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var icepick__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! icepick */ "../../../node_modules/icepick/icepick.min.js"); +/* harmony import */ var icepick__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(icepick__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var metabase_lib_redux__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/lib/redux */ "./lib/redux.js"); +/* harmony import */ var _actions__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./actions */ "./dashboard/actions.js"); +/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./utils */ "./dashboard/utils.js"); +var _handleActions, _handleActions2, _handleActions3, _handleActions4, _handleActions5, _handleActions6, _handleActions8, _handleActions9, _handleActions10; + +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + + + + + +var dashboardId = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_1__.handleActions)((_handleActions = {}, _defineProperty(_handleActions, _actions__WEBPACK_IMPORTED_MODULE_2__.INITIALIZE, { + next: function next(state) { + return null; + } +}), _defineProperty(_handleActions, _actions__WEBPACK_IMPORTED_MODULE_2__.FETCH_DASHBOARD, { + next: function next(state, _ref) { + var dashboardId = _ref.payload.dashboardId; + return dashboardId; + } +}), _handleActions), null); +var isEditing = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_1__.handleActions)((_handleActions2 = {}, _defineProperty(_handleActions2, _actions__WEBPACK_IMPORTED_MODULE_2__.INITIALIZE, { + next: function next(state) { + return null; + } +}), _defineProperty(_handleActions2, _actions__WEBPACK_IMPORTED_MODULE_2__.SET_EDITING_DASHBOARD, { + next: function next(state, _ref2) { + var payload = _ref2.payload; + return payload ? payload : null; + } +}), _handleActions2), {}); + +function newDashboard(before, after, isDirty) { + return _objectSpread(_objectSpread(_objectSpread({}, before), after), {}, { + embedding_params: (0,_utils__WEBPACK_IMPORTED_MODULE_3__.syncParametersAndEmbeddingParams)(before, after), + isDirty: isDirty !== null && isDirty !== void 0 ? isDirty : true + }); +} + +var dashboards = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_1__.handleActions)((_handleActions3 = {}, _defineProperty(_handleActions3, _actions__WEBPACK_IMPORTED_MODULE_2__.FETCH_DASHBOARD, { + next: function next(state, _ref3) { + var payload = _ref3.payload; + return _objectSpread(_objectSpread({}, state), payload.entities.dashboard); + } +}), _defineProperty(_handleActions3, _actions__WEBPACK_IMPORTED_MODULE_2__.SET_DASHBOARD_ATTRIBUTES, { + next: function next(state, _ref4) { + var _ref4$payload = _ref4.payload, + id = _ref4$payload.id, + attributes = _ref4$payload.attributes, + isDirty = _ref4$payload.isDirty; + return _objectSpread(_objectSpread({}, state), {}, _defineProperty({}, id, newDashboard(state[id], attributes, isDirty))); + } +}), _defineProperty(_handleActions3, _actions__WEBPACK_IMPORTED_MODULE_2__.ADD_CARD_TO_DASH, function (state, _ref5) { + var dashcard = _ref5.payload; + return _objectSpread(_objectSpread({}, state), {}, _defineProperty({}, dashcard.dashboard_id, _objectSpread(_objectSpread({}, state[dashcard.dashboard_id]), {}, { + ordered_cards: [].concat(_toConsumableArray(state[dashcard.dashboard_id].ordered_cards), [dashcard.id]) + }))); +}), _defineProperty(_handleActions3, _actions__WEBPACK_IMPORTED_MODULE_2__.CREATE_PUBLIC_LINK, { + next: function next(state, _ref6) { + var payload = _ref6.payload; + return (0,icepick__WEBPACK_IMPORTED_MODULE_0__.assocIn)(state, [payload.id, "public_uuid"], payload.uuid); + } +}), _defineProperty(_handleActions3, _actions__WEBPACK_IMPORTED_MODULE_2__.DELETE_PUBLIC_LINK, { + next: function next(state, _ref7) { + var payload = _ref7.payload; + return (0,icepick__WEBPACK_IMPORTED_MODULE_0__.assocIn)(state, [payload.id, "public_uuid"], null); + } +}), _defineProperty(_handleActions3, _actions__WEBPACK_IMPORTED_MODULE_2__.UPDATE_EMBEDDING_PARAMS, { + next: function next(state, _ref8) { + var payload = _ref8.payload; + return (0,icepick__WEBPACK_IMPORTED_MODULE_0__.assocIn)(state, [payload.id, "embedding_params"], payload.embedding_params); + } +}), _defineProperty(_handleActions3, _actions__WEBPACK_IMPORTED_MODULE_2__.UPDATE_ENABLE_EMBEDDING, { + next: function next(state, _ref9) { + var payload = _ref9.payload; + return (0,icepick__WEBPACK_IMPORTED_MODULE_0__.assocIn)(state, [payload.id, "enable_embedding"], payload.enable_embedding); + } +}), _handleActions3), {}); +var dashcards = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_1__.handleActions)((_handleActions4 = {}, _defineProperty(_handleActions4, _actions__WEBPACK_IMPORTED_MODULE_2__.FETCH_DASHBOARD, { + next: function next(state, _ref10) { + var payload = _ref10.payload; + return _objectSpread(_objectSpread({}, state), payload.entities.dashcard); + } +}), _defineProperty(_handleActions4, _actions__WEBPACK_IMPORTED_MODULE_2__.SET_DASHCARD_ATTRIBUTES, { + next: function next(state, _ref11) { + var _ref11$payload = _ref11.payload, + id = _ref11$payload.id, + attributes = _ref11$payload.attributes; + return _objectSpread(_objectSpread({}, state), {}, _defineProperty({}, id, _objectSpread(_objectSpread(_objectSpread({}, state[id]), attributes), {}, { + isDirty: true + }))); + } +}), _defineProperty(_handleActions4, _actions__WEBPACK_IMPORTED_MODULE_2__.SET_MULTIPLE_DASHCARD_ATTRIBUTES, { + next: function next(state, _ref12) { + var dashcards = _ref12.payload; + + var nextState = _objectSpread({}, state); + + dashcards.forEach(function (_ref13) { + var id = _ref13.id, + attributes = _ref13.attributes; + nextState[id] = _objectSpread(_objectSpread(_objectSpread({}, state[id]), attributes), {}, { + isDirty: true + }); + }); + return nextState; + } +}), _defineProperty(_handleActions4, _actions__WEBPACK_IMPORTED_MODULE_2__.UPDATE_DASHCARD_VISUALIZATION_SETTINGS, { + next: function next(state, _ref14) { + var _ref14$payload = _ref14.payload, + id = _ref14$payload.id, + settings = _ref14$payload.settings; + return (0,icepick__WEBPACK_IMPORTED_MODULE_0__.chain)(state).updateIn([id, "visualization_settings"], function () { + var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + return _objectSpread(_objectSpread({}, value), settings); + }).assocIn([id, "isDirty"], true).value(); + } +}), _defineProperty(_handleActions4, _actions__WEBPACK_IMPORTED_MODULE_2__.UPDATE_DASHCARD_VISUALIZATION_SETTINGS_FOR_COLUMN, { + next: function next(state, _ref15) { + var _ref15$payload = _ref15.payload, + column = _ref15$payload.column, + id = _ref15$payload.id, + settings = _ref15$payload.settings; + return (0,icepick__WEBPACK_IMPORTED_MODULE_0__.chain)(state).updateIn([id, "visualization_settings"], function () { + var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + return (0,icepick__WEBPACK_IMPORTED_MODULE_0__.updateIn)((0,icepick__WEBPACK_IMPORTED_MODULE_0__.merge)({ + column_settings: {} + }, value), ["column_settings", column], function (columnSettings) { + return _objectSpread(_objectSpread({}, columnSettings), settings); + }); + }).assocIn([id, "isDirty"], true).value(); + } +}), _defineProperty(_handleActions4, _actions__WEBPACK_IMPORTED_MODULE_2__.REPLACE_ALL_DASHCARD_VISUALIZATION_SETTINGS, { + next: function next(state, _ref16) { + var _ref16$payload = _ref16.payload, + id = _ref16$payload.id, + settings = _ref16$payload.settings; + return (0,icepick__WEBPACK_IMPORTED_MODULE_0__.chain)(state).assocIn([id, "visualization_settings"], settings).assocIn([id, "isDirty"], true).value(); + } +}), _defineProperty(_handleActions4, _actions__WEBPACK_IMPORTED_MODULE_2__.ADD_CARD_TO_DASH, function (state, _ref17) { + var dashcard = _ref17.payload; + return _objectSpread(_objectSpread({}, state), {}, _defineProperty({}, dashcard.id, _objectSpread(_objectSpread({}, dashcard), {}, { + isAdded: true, + justAdded: true + }))); +}), _defineProperty(_handleActions4, _actions__WEBPACK_IMPORTED_MODULE_2__.REMOVE_CARD_FROM_DASH, function (state, _ref18) { + var dashcardId = _ref18.payload.dashcardId; + return _objectSpread(_objectSpread({}, state), {}, _defineProperty({}, dashcardId, _objectSpread(_objectSpread({}, state[dashcardId]), {}, { + isRemoved: true + }))); +}), _defineProperty(_handleActions4, _actions__WEBPACK_IMPORTED_MODULE_2__.MARK_NEW_CARD_SEEN, function (state, _ref19) { + var dashcardId = _ref19.payload; + return _objectSpread(_objectSpread({}, state), {}, _defineProperty({}, dashcardId, _objectSpread(_objectSpread({}, state[dashcardId]), {}, { + justAdded: false + }))); +}), _handleActions4), {}); +var isAddParameterPopoverOpen = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_1__.handleActions)((_handleActions5 = {}, _defineProperty(_handleActions5, _actions__WEBPACK_IMPORTED_MODULE_2__.SHOW_ADD_PARAMETER_POPOVER, function () { + return true; +}), _defineProperty(_handleActions5, _actions__WEBPACK_IMPORTED_MODULE_2__.HIDE_ADD_PARAMETER_POPOVER, function () { + return false; +}), _defineProperty(_handleActions5, _actions__WEBPACK_IMPORTED_MODULE_2__.INITIALIZE, function () { + return false; +}), _handleActions5), false); +var dashcardData = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_1__.handleActions)((_handleActions6 = {}, _defineProperty(_handleActions6, _actions__WEBPACK_IMPORTED_MODULE_2__.INITIALIZE, { + next: function next(state) { + return {}; + } +}), _defineProperty(_handleActions6, _actions__WEBPACK_IMPORTED_MODULE_2__.FETCH_CARD_DATA, { + next: function next(state, _ref20) { + var _ref20$payload = _ref20.payload, + dashcard_id = _ref20$payload.dashcard_id, + card_id = _ref20$payload.card_id, + result = _ref20$payload.result; + return (0,icepick__WEBPACK_IMPORTED_MODULE_0__.assocIn)(state, [dashcard_id, card_id], result); + } +}), _defineProperty(_handleActions6, _actions__WEBPACK_IMPORTED_MODULE_2__.CLEAR_CARD_DATA, { + next: function next(state, _ref21) { + var _ref21$payload = _ref21.payload, + cardId = _ref21$payload.cardId, + dashcardId = _ref21$payload.dashcardId; + return (0,icepick__WEBPACK_IMPORTED_MODULE_0__.assocIn)(state, [dashcardId, cardId]); + } +}), _defineProperty(_handleActions6, _actions__WEBPACK_IMPORTED_MODULE_2__.UPDATE_DASHCARD_ID, { + next: function next(state, _ref22) { + var _ref22$payload = _ref22.payload, + oldDashcardId = _ref22$payload.oldDashcardId, + newDashcardId = _ref22$payload.newDashcardId; + return (0,icepick__WEBPACK_IMPORTED_MODULE_0__.chain)(state).assoc(newDashcardId, state[oldDashcardId]).dissoc(oldDashcardId).value(); + } +}), _handleActions6), {}); +var slowCards = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_1__.handleActions)(_defineProperty({}, _actions__WEBPACK_IMPORTED_MODULE_2__.MARK_CARD_AS_SLOW, { + next: function next(state, _ref23) { + var _ref23$payload = _ref23.payload, + id = _ref23$payload.id, + result = _ref23$payload.result; + return _objectSpread(_objectSpread({}, state), {}, _defineProperty({}, id, result)); + } +}), {}); +var parameterValues = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_1__.handleActions)((_handleActions8 = {}, _defineProperty(_handleActions8, _actions__WEBPACK_IMPORTED_MODULE_2__.INITIALIZE, { + next: function next() { + return {}; + } +}), _defineProperty(_handleActions8, _actions__WEBPACK_IMPORTED_MODULE_2__.SET_PARAMETER_VALUE, { + next: function next(state, _ref24) { + var _ref24$payload = _ref24.payload, + id = _ref24$payload.id, + value = _ref24$payload.value; + return (0,icepick__WEBPACK_IMPORTED_MODULE_0__.assoc)(state, id, value); + } +}), _defineProperty(_handleActions8, _actions__WEBPACK_IMPORTED_MODULE_2__.REMOVE_PARAMETER, { + next: function next(state, _ref25) { + var id = _ref25.payload.id; + return (0,icepick__WEBPACK_IMPORTED_MODULE_0__.dissoc)(state, id); + } +}), _defineProperty(_handleActions8, _actions__WEBPACK_IMPORTED_MODULE_2__.FETCH_DASHBOARD, { + next: function next(state, _ref26) { + var parameterValues = _ref26.payload.parameterValues; + return parameterValues; + } +}), _handleActions8), {}); +var loadingDashCards = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_1__.handleActions)((_handleActions9 = {}, _defineProperty(_handleActions9, _actions__WEBPACK_IMPORTED_MODULE_2__.FETCH_DASHBOARD, { + next: function next(state, _ref27) { + var payload = _ref27.payload; + return _objectSpread(_objectSpread({}, state), {}, { + dashcardIds: Object.values(payload.entities.dashcard || {}).filter(function (dc) { + return !(0,_utils__WEBPACK_IMPORTED_MODULE_3__.isVirtualDashCard)(dc); + }).map(function (dc) { + return dc.id; + }) + }); + } +}), _defineProperty(_handleActions9, _actions__WEBPACK_IMPORTED_MODULE_2__.FETCH_DASHBOARD_CARD_DATA, { + next: function next(state) { + return _objectSpread(_objectSpread({}, state), {}, { + loadingIds: state.dashcardIds, + startTime: state.dashcardIds.length > 0 && // check that performance is defined just in case + (typeof performance === "undefined" ? "undefined" : _typeof(performance)) === "object" ? performance.now() : null + }); + } +}), _defineProperty(_handleActions9, _actions__WEBPACK_IMPORTED_MODULE_2__.FETCH_CARD_DATA, { + next: function next(state, _ref28) { + var dashcard_id = _ref28.payload.dashcard_id; + var loadingIds = state.loadingIds.filter(function (id) { + return id !== dashcard_id; + }); + return _objectSpread(_objectSpread({}, state), {}, { + loadingIds: loadingIds + }, loadingIds.length === 0 ? { + startTime: null + } : {}); + } +}), _defineProperty(_handleActions9, _actions__WEBPACK_IMPORTED_MODULE_2__.CANCEL_FETCH_CARD_DATA, { + next: function next(state, _ref29) { + var dashcard_id = _ref29.payload.dashcard_id; + var loadingIds = state.loadingIds.filter(function (id) { + return id !== dashcard_id; + }); + return _objectSpread(_objectSpread({}, state), {}, { + loadingIds: loadingIds + }, loadingIds.length === 0 ? { + startTime: null + } : {}); + } +}), _handleActions9), { + dashcardIds: [], + loadingIds: [], + startTime: null +}); +var DEFAULT_SIDEBAR = { + props: {} +}; +var sidebar = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_1__.handleActions)((_handleActions10 = {}, _defineProperty(_handleActions10, _actions__WEBPACK_IMPORTED_MODULE_2__.SET_SIDEBAR, { + next: function next(state, _ref30) { + var _ref30$payload = _ref30.payload, + name = _ref30$payload.name, + props = _ref30$payload.props; + return { + name: name, + props: props || {} + }; + } +}), _defineProperty(_handleActions10, _actions__WEBPACK_IMPORTED_MODULE_2__.CLOSE_SIDEBAR, { + next: function next() { + return DEFAULT_SIDEBAR; + } +}), _defineProperty(_handleActions10, _actions__WEBPACK_IMPORTED_MODULE_2__.INITIALIZE, { + next: function next() { + return DEFAULT_SIDEBAR; + } +}), _defineProperty(_handleActions10, _actions__WEBPACK_IMPORTED_MODULE_2__.SET_EDITING_DASHBOARD, { + next: function next(state, _ref31) { + var isEditing = _ref31.payload; + return isEditing ? state : DEFAULT_SIDEBAR; + } +}), _defineProperty(_handleActions10, _actions__WEBPACK_IMPORTED_MODULE_2__.REMOVE_PARAMETER, { + next: function next() { + return DEFAULT_SIDEBAR; + } +}), _handleActions10), DEFAULT_SIDEBAR); +/* harmony default export */ __webpack_exports__["default"] = ((0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_1__.combineReducers)({ + dashboardId: dashboardId, + isEditing: isEditing, + dashboards: dashboards, + dashcards: dashcards, + dashcardData: dashcardData, + slowCards: slowCards, + parameterValues: parameterValues, + loadingDashCards: loadingDashCards, + isAddParameterPopoverOpen: isAddParameterPopoverOpen, + sidebar: sidebar +})); + +/***/ }), + +/***/ "./dashboard/selectors.js": +/*!********************************!*\ + !*** ./dashboard/selectors.js ***! + \********************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "getDashboardId": function() { return /* binding */ getDashboardId; }, +/* harmony export */ "getIsEditing": function() { return /* binding */ getIsEditing; }, +/* harmony export */ "getDashboardBeforeEditing": function() { return /* binding */ getDashboardBeforeEditing; }, +/* harmony export */ "getClickBehaviorSidebarDashcard": function() { return /* binding */ getClickBehaviorSidebarDashcard; }, +/* harmony export */ "getDashboards": function() { return /* binding */ getDashboards; }, +/* harmony export */ "getDashcards": function() { return /* binding */ getDashcards; }, +/* harmony export */ "getCardData": function() { return /* binding */ getCardData; }, +/* harmony export */ "getSlowCards": function() { return /* binding */ getSlowCards; }, +/* harmony export */ "getParameterValues": function() { return /* binding */ getParameterValues; }, +/* harmony export */ "getLoadingStartTime": function() { return /* binding */ getLoadingStartTime; }, +/* harmony export */ "getIsAddParameterPopoverOpen": function() { return /* binding */ getIsAddParameterPopoverOpen; }, +/* harmony export */ "getSidebar": function() { return /* binding */ getSidebar; }, +/* harmony export */ "getIsSharing": function() { return /* binding */ getIsSharing; }, +/* harmony export */ "getShowAddQuestionSidebar": function() { return /* binding */ getShowAddQuestionSidebar; }, +/* harmony export */ "getDashboard": function() { return /* binding */ getDashboard; }, +/* harmony export */ "getDashboardComplete": function() { return /* binding */ getDashboardComplete; }, +/* harmony export */ "getIsDirty": function() { return /* binding */ getIsDirty; }, +/* harmony export */ "getEditingParameterId": function() { return /* binding */ getEditingParameterId; }, +/* harmony export */ "getIsEditingParameter": function() { return /* binding */ getIsEditingParameter; }, +/* harmony export */ "getEditingParameter": function() { return /* binding */ getEditingParameter; }, +/* harmony export */ "getParameterTarget": function() { return /* binding */ getParameterTarget; }, +/* harmony export */ "getMappingsByParameter": function() { return /* binding */ getMappingsByParameter; }, +/* harmony export */ "getParameters": function() { return /* binding */ getParameters; }, +/* harmony export */ "makeGetParameterMappingOptions": function() { return /* binding */ makeGetParameterMappingOptions; }, +/* harmony export */ "getDefaultParametersById": function() { return /* binding */ getDefaultParametersById; } +/* harmony export */ }); +/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! underscore */ "../../../node_modules/underscore/modules/index-all.js"); +/* harmony import */ var reselect__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! reselect */ "../../../node_modules/reselect/lib/index.js"); +/* harmony import */ var metabase_selectors_metadata__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/selectors/metadata */ "./selectors/metadata.js"); +/* harmony import */ var metabase_parameters_utils_dashboards__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/parameters/utils/dashboards */ "./parameters/utils/dashboards.js"); +/* harmony import */ var metabase_parameters_utils_mapping_options__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! metabase/parameters/utils/mapping-options */ "./parameters/utils/mapping-options.js"); +/* harmony import */ var metabase_dashboard_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! metabase/dashboard/constants */ "./dashboard/constants.js"); +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + + + + + + + +var getDashboardId = function getDashboardId(state) { + return state.dashboard.dashboardId; +}; +var getIsEditing = function getIsEditing(state) { + return !!state.dashboard.isEditing; +}; +var getDashboardBeforeEditing = function getDashboardBeforeEditing(state) { + return state.dashboard.isEditing; +}; +var getClickBehaviorSidebarDashcard = function getClickBehaviorSidebarDashcard(state) { + var _state$dashboard = state.dashboard, + sidebar = _state$dashboard.sidebar, + dashcards = _state$dashboard.dashcards; + return sidebar.name === metabase_dashboard_constants__WEBPACK_IMPORTED_MODULE_5__.SIDEBAR_NAME.clickBehavior ? dashcards[sidebar.props.dashcardId] : null; +}; +var getDashboards = function getDashboards(state) { + return state.dashboard.dashboards; +}; +var getDashcards = function getDashcards(state) { + return state.dashboard.dashcards; +}; +var getCardData = function getCardData(state) { + return state.dashboard.dashcardData; +}; +var getSlowCards = function getSlowCards(state) { + return state.dashboard.slowCards; +}; +var getParameterValues = function getParameterValues(state) { + return state.dashboard.parameterValues; +}; +var getLoadingStartTime = function getLoadingStartTime(state) { + return state.dashboard.loadingDashCards.startTime; +}; +var getIsAddParameterPopoverOpen = function getIsAddParameterPopoverOpen(state) { + return state.dashboard.isAddParameterPopoverOpen; +}; +var getSidebar = function getSidebar(state) { + return state.dashboard.sidebar; +}; +var getIsSharing = (0,reselect__WEBPACK_IMPORTED_MODULE_1__.createSelector)([getSidebar], function (sidebar) { + return sidebar.name === metabase_dashboard_constants__WEBPACK_IMPORTED_MODULE_5__.SIDEBAR_NAME.sharing; +}); +var getShowAddQuestionSidebar = (0,reselect__WEBPACK_IMPORTED_MODULE_1__.createSelector)([getSidebar], function (sidebar) { + return sidebar.name === metabase_dashboard_constants__WEBPACK_IMPORTED_MODULE_5__.SIDEBAR_NAME.addQuestion; +}); +var getDashboard = (0,reselect__WEBPACK_IMPORTED_MODULE_1__.createSelector)([getDashboardId, getDashboards], function (dashboardId, dashboards) { + return dashboards[dashboardId]; +}); +var getDashboardComplete = (0,reselect__WEBPACK_IMPORTED_MODULE_1__.createSelector)([getDashboard, getDashcards], function (dashboard, dashcards) { + return dashboard && _objectSpread(_objectSpread({}, dashboard), {}, { + ordered_cards: dashboard.ordered_cards.map(function (id) { + return dashcards[id]; + }).filter(function (dc) { + return !dc.isRemoved; + }) + }); +}); +var getIsDirty = (0,reselect__WEBPACK_IMPORTED_MODULE_1__.createSelector)([getDashboard, getDashcards], function (dashboard, dashcards) { + return !!(dashboard && (dashboard.isDirty || underscore__WEBPACK_IMPORTED_MODULE_0__.default.some(dashboard.ordered_cards, function (id) { + return !(dashcards[id].isAdded && dashcards[id].isRemoved) && (dashcards[id].isDirty || dashcards[id].isAdded || dashcards[id].isRemoved); + }))); +}); +var getEditingParameterId = (0,reselect__WEBPACK_IMPORTED_MODULE_1__.createSelector)([getSidebar], function (sidebar) { + var _sidebar$props; + + return sidebar.name === metabase_dashboard_constants__WEBPACK_IMPORTED_MODULE_5__.SIDEBAR_NAME.editParameter ? (_sidebar$props = sidebar.props) === null || _sidebar$props === void 0 ? void 0 : _sidebar$props.parameterId : null; +}); +var getIsEditingParameter = (0,reselect__WEBPACK_IMPORTED_MODULE_1__.createSelector)([getEditingParameterId], function (parameterId) { + return parameterId != null; +}); +var getEditingParameter = (0,reselect__WEBPACK_IMPORTED_MODULE_1__.createSelector)([getDashboard, getEditingParameterId], function (dashboard, editingParameterId) { + return editingParameterId != null ? underscore__WEBPACK_IMPORTED_MODULE_0__.default.findWhere(dashboard.parameters, { + id: editingParameterId + }) : null; +}); + +var getCard = function getCard(state, props) { + return props.card; +}; + +var getDashCard = function getDashCard(state, props) { + return props.dashcard; +}; + +var getParameterTarget = (0,reselect__WEBPACK_IMPORTED_MODULE_1__.createSelector)([getEditingParameter, getCard, getDashCard], function (parameter, card, dashcard) { + if (parameter == null) { + return null; + } + + var mapping = underscore__WEBPACK_IMPORTED_MODULE_0__.default.findWhere(dashcard.parameter_mappings, { + card_id: card.id, + parameter_id: parameter.id + }); + + return mapping && mapping.target; +}); +var getMappingsByParameter = (0,reselect__WEBPACK_IMPORTED_MODULE_1__.createSelector)([metabase_selectors_metadata__WEBPACK_IMPORTED_MODULE_2__.getMetadata, getDashboardComplete], metabase_parameters_utils_dashboards__WEBPACK_IMPORTED_MODULE_3__.getMappingsByParameter); +/** Returns the dashboard's parameters objects, with field_id added, if appropriate */ + +var getParameters = (0,reselect__WEBPACK_IMPORTED_MODULE_1__.createSelector)([metabase_selectors_metadata__WEBPACK_IMPORTED_MODULE_2__.getMetadata, getDashboard, getMappingsByParameter], metabase_parameters_utils_dashboards__WEBPACK_IMPORTED_MODULE_3__.getDashboardParametersWithFieldMetadata); +var makeGetParameterMappingOptions = function makeGetParameterMappingOptions() { + var getParameterMappingOptions = (0,reselect__WEBPACK_IMPORTED_MODULE_1__.createSelector)([metabase_selectors_metadata__WEBPACK_IMPORTED_MODULE_2__.getMetadata, getEditingParameter, getCard], function (metadata, parameter, card) { + return (0,metabase_parameters_utils_mapping_options__WEBPACK_IMPORTED_MODULE_4__.getParameterMappingOptions)(metadata, parameter, card); + }); + return getParameterMappingOptions; +}; +var getDefaultParametersById = (0,reselect__WEBPACK_IMPORTED_MODULE_1__.createSelector)([getDashboard], function (dashboard) { + return (dashboard && dashboard.parameters || []).reduce(function (map, parameter) { + if (parameter.default) { + map[parameter.id] = parameter.default; + } + + return map; + }, {}); +}); + +/***/ }), + +/***/ "./dashboard/utils.js": +/*!****************************!*\ + !*** ./dashboard/utils.js ***! + \****************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "syncParametersAndEmbeddingParams": function() { return /* binding */ syncParametersAndEmbeddingParams; }, +/* harmony export */ "expandInlineDashboard": function() { return /* binding */ expandInlineDashboard; }, +/* harmony export */ "expandInlineCard": function() { return /* binding */ expandInlineCard; }, +/* harmony export */ "isVirtualDashCard": function() { return /* binding */ isVirtualDashCard; }, +/* harmony export */ "getAllDashboardCards": function() { return /* binding */ getAllDashboardCards; }, +/* harmony export */ "getDashboardType": function() { return /* binding */ getDashboardType; }, +/* harmony export */ "fetchDataOrError": function() { return /* binding */ fetchDataOrError; } +/* harmony export */ }); +/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! underscore */ "../../../node_modules/underscore/modules/index-all.js"); +/* harmony import */ var metabase_lib_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/lib/utils */ "./lib/utils.js"); +function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } + +function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } + +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } + +function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + + + +function syncParametersAndEmbeddingParams(before, after) { + if (after.parameters && before.embedding_params) { + return Object.keys(before.embedding_params).reduce(function (memo, embedSlug) { + var slugParam = underscore__WEBPACK_IMPORTED_MODULE_0__.default.find(before.parameters, function (param) { + return param.slug === embedSlug; + }); + + if (slugParam) { + var slugParamId = slugParam && slugParam.id; + + var newParam = underscore__WEBPACK_IMPORTED_MODULE_0__.default.findWhere(after.parameters, { + id: slugParamId + }); + + if (newParam) { + memo[newParam.slug] = before.embedding_params[embedSlug]; + } + } + + return memo; + }, {}); + } else { + return before.embedding_params; + } +} // This adds default properties and placeholder IDs for an inline dashboard + +function expandInlineDashboard(dashboard) { + return _objectSpread(_objectSpread({ + name: "", + parameters: [] + }, dashboard), {}, { + ordered_cards: dashboard.ordered_cards.map(function (dashcard) { + return _objectSpread(_objectSpread({ + visualization_settings: {}, + parameter_mappings: [] + }, dashcard), {}, { + id: underscore__WEBPACK_IMPORTED_MODULE_0__.default.uniqueId("dashcard"), + card: expandInlineCard(dashcard.card), + series: (dashcard.series || []).map(function (card) { + return expandInlineCard(card); + }) + }); + }) + }); +} +function expandInlineCard(card) { + return _objectSpread(_objectSpread({ + name: "", + visualization_settings: {} + }, card), {}, { + id: underscore__WEBPACK_IMPORTED_MODULE_0__.default.uniqueId("card") + }); +} +function isVirtualDashCard(dashcard) { + return underscore__WEBPACK_IMPORTED_MODULE_0__.default.isObject(dashcard.visualization_settings.virtual_card); +} +function getAllDashboardCards(dashboard) { + var results = []; + + if (dashboard) { + var _iterator = _createForOfIteratorHelper(dashboard.ordered_cards), + _step; + + try { + var _loop = function _loop() { + var dashcard = _step.value; + var cards = [dashcard.card].concat(dashcard.series || []); + results.push.apply(results, _toConsumableArray(cards.map(function (card) { + return { + card: card, + dashcard: dashcard + }; + }))); + }; + + for (_iterator.s(); !(_step = _iterator.n()).done;) { + _loop(); + } + } catch (err) { + _iterator.e(err); + } finally { + _iterator.f(); + } + } + + return results; +} +function getDashboardType(id) { + if (id == null || _typeof(id) === "object") { + // HACK: support inline dashboards + return "inline"; + } else if (metabase_lib_utils__WEBPACK_IMPORTED_MODULE_1__.default.isUUID(id)) { + return "public"; + } else if (metabase_lib_utils__WEBPACK_IMPORTED_MODULE_1__.default.isJWT(id)) { + return "embed"; + } else if (/\/auto\/dashboard/.test(id)) { + return "transient"; + } else { + return "normal"; + } +} +function fetchDataOrError(_x) { + return _fetchDataOrError.apply(this, arguments); +} + +function _fetchDataOrError() { + _fetchDataOrError = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(dataPromise) { + return regeneratorRuntime.wrap(function _callee$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + _context.prev = 0; + _context.next = 3; + return dataPromise; + + case 3: + return _context.abrupt("return", _context.sent); + + case 6: + _context.prev = 6; + _context.t0 = _context["catch"](0); + return _context.abrupt("return", { + error: _context.t0 + }); + + case 9: + case "end": + return _context.stop(); + } + } + }, _callee, null, [[0, 6]]); + })); + return _fetchDataOrError.apply(this, arguments); +} + +/***/ }), + +/***/ "./entities/alerts.js": +/*!****************************!*\ + !*** ./entities/alerts.js ***! + \****************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "UNSUBSCRIBE": function() { return /* binding */ UNSUBSCRIBE; } +/* harmony export */ }); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var metabase_lib_entities__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/lib/entities */ "./lib/entities.js"); +/* harmony import */ var metabase_services__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/services */ "./services.js"); +/* harmony import */ var metabase_redux_undo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/redux/undo */ "./redux/undo.js"); +var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6; + +function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } + +function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + + + + + +var UNSUBSCRIBE = "metabase/entities/alerts/unsubscribe"; +var Alerts = (0,metabase_lib_entities__WEBPACK_IMPORTED_MODULE_1__.createEntity)({ + name: "alerts", + nameOne: "alert", + path: "/api/alert", + actionTypes: { + UNSUBSCRIBE: UNSUBSCRIBE + }, + objectActions: { + setArchived: function setArchived(_ref, archived, opts) { + var id = _ref.id; + return Alerts.actions.update({ + id: id + }, { + archived: archived + }, (0,metabase_lib_entities__WEBPACK_IMPORTED_MODULE_1__.undo)(opts, (0,ttag__WEBPACK_IMPORTED_MODULE_0__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["alert"]))), archived ? (0,ttag__WEBPACK_IMPORTED_MODULE_0__.t)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["deleted"]))) : (0,ttag__WEBPACK_IMPORTED_MODULE_0__.t)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["restored"]))))); + }, + unsubscribe: function unsubscribe(_ref2) { + var id = _ref2.id; + return /*#__PURE__*/function () { + var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(dispatch) { + return regeneratorRuntime.wrap(function _callee$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + _context.next = 2; + return metabase_services__WEBPACK_IMPORTED_MODULE_2__.AlertApi.unsubscribe({ + id: id + }); + + case 2: + dispatch((0,metabase_redux_undo__WEBPACK_IMPORTED_MODULE_3__.addUndo)({ + message: (0,ttag__WEBPACK_IMPORTED_MODULE_0__.t)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["Successfully unsubscribed"]))) + })); + dispatch({ + type: UNSUBSCRIBE, + payload: { + id: id + } + }); + dispatch({ + type: Alerts.actionTypes.INVALIDATE_LISTS_ACTION + }); + + case 5: + case "end": + return _context.stop(); + } + } + }, _callee); + })); + + return function (_x) { + return _ref3.apply(this, arguments); + }; + }(); + }, + setChannels: function setChannels(_ref4, channels, opts) { + var id = _ref4.id; + return Alerts.actions.update({ + id: id + }, { + channels: channels + }, (0,metabase_lib_entities__WEBPACK_IMPORTED_MODULE_1__.undo)(opts, (0,ttag__WEBPACK_IMPORTED_MODULE_0__.t)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["alert"]))), (0,ttag__WEBPACK_IMPORTED_MODULE_0__.t)(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["updated"]))))); + } + } +}); +/* harmony default export */ __webpack_exports__["default"] = (Alerts); + +/***/ }), + +/***/ "./entities/collections.js": +/*!*********************************!*\ + !*** ./entities/collections.js ***! + \*********************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "ROOT_COLLECTION": function() { return /* binding */ ROOT_COLLECTION; }, +/* harmony export */ "PERSONAL_COLLECTION": function() { return /* binding */ PERSONAL_COLLECTION; }, +/* harmony export */ "PERSONAL_COLLECTIONS": function() { return /* binding */ PERSONAL_COLLECTIONS; }, +/* harmony export */ "getCollectionIcon": function() { return /* binding */ getCollectionIcon; }, +/* harmony export */ "canonicalCollectionId": function() { return /* binding */ canonicalCollectionId; }, +/* harmony export */ "normalizedCollection": function() { return /* binding */ normalizedCollection; }, +/* harmony export */ "getCollectionType": function() { return /* binding */ getCollectionType; }, +/* harmony export */ "getExpandedCollectionsById": function() { return /* binding */ getExpandedCollectionsById; } +/* harmony export */ }); +/* harmony import */ var metabase_lib_entities__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! metabase/lib/entities */ "./lib/entities.js"); +/* harmony import */ var metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/lib/colors */ "./lib/colors.ts"); +/* harmony import */ var metabase_lib_urls__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/lib/urls */ "./lib/urls.js"); +/* harmony import */ var metabase_schema__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/schema */ "./schema.js"); +/* harmony import */ var reselect__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! reselect */ "../../../node_modules/reselect/lib/index.js"); +/* harmony import */ var metabase_lib_api__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! metabase/lib/api */ "./lib/api.js"); +/* harmony import */ var metabase_selectors_user__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! metabase/selectors/user */ "./selectors/user.js"); +/* harmony import */ var metabase_collections_utils__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! metabase/collections/utils */ "./collections/utils.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_8__); +/* harmony import */ var metabase_plugins__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! metabase/plugins */ "./plugins/index.js"); +/* harmony import */ var _collections_forms__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./collections/forms */ "./entities/collections/forms.js"); +var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5; + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } + +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } + +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } + +function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } + +function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } + +function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } + +function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + + + + + + + + + + + + +var listCollectionsTree = (0,metabase_lib_api__WEBPACK_IMPORTED_MODULE_5__.GET)("/api/collection/tree"); +var listCollections = (0,metabase_lib_api__WEBPACK_IMPORTED_MODULE_5__.GET)("/api/collection"); +var ROOT_COLLECTION = { + id: "root", + name: (0,ttag__WEBPACK_IMPORTED_MODULE_8__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["Our analytics"]))), + location: "", + path: [] +}; +var PERSONAL_COLLECTION = { + id: undefined, + // to be filled in by getExpandedCollectionsById + name: (0,ttag__WEBPACK_IMPORTED_MODULE_8__.t)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["My personal collection"]))), + location: "/", + path: [ROOT_COLLECTION.id], + can_write: true +}; // fake collection for admins that contains all other user's collections + +var PERSONAL_COLLECTIONS = { + id: "personal", + // placeholder id + name: (0,ttag__WEBPACK_IMPORTED_MODULE_8__.t)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["All personal collections"]))), + location: "/", + path: [ROOT_COLLECTION.id], + can_write: false +}; +var Collections = (0,metabase_lib_entities__WEBPACK_IMPORTED_MODULE_0__.createEntity)({ + name: "collections", + path: "/api/collection", + schema: metabase_schema__WEBPACK_IMPORTED_MODULE_3__.CollectionSchema, + displayNameOne: (0,ttag__WEBPACK_IMPORTED_MODULE_8__.t)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["collection"]))), + displayNameMany: (0,ttag__WEBPACK_IMPORTED_MODULE_8__.t)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["collections"]))), + api: { + list: function () { + var _list = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(params) { + var _len, + args, + _key, + _args = arguments; + + return regeneratorRuntime.wrap(function _callee$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + for (_len = _args.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = _args[_key]; + } + + return _context.abrupt("return", + /* Parts of the UI, like ItemPicker don't yet know about the /tree endpoint and break if it's used, + so choose which endpoint to use based on the presence of a "tree" param + */ + params && params.tree ? listCollectionsTree.apply(void 0, [params].concat(args)) : listCollections.apply(void 0, [params].concat(args))); + + case 2: + case "end": + return _context.stop(); + } + } + }, _callee); + })); + + function list(_x) { + return _list.apply(this, arguments); + } + + return list; + }() + }, + objectActions: { + setArchived: function setArchived(_ref, archived, opts) { + var id = _ref.id; + return Collections.actions.update({ + id: id + }, { + archived: archived + }, (0,metabase_lib_entities__WEBPACK_IMPORTED_MODULE_0__.undo)(opts, "collection", archived ? "archived" : "unarchived")); + }, + setCollection: function setCollection(_ref2, collection, opts) { + var id = _ref2.id; + return Collections.actions.update({ + id: id + }, { + parent_id: canonicalCollectionId(collection && collection.id) + }, (0,metabase_lib_entities__WEBPACK_IMPORTED_MODULE_0__.undo)(opts, "collection", "moved")); + }, + // NOTE: DELETE not currently implemented + delete: null + }, + objectSelectors: { + getName: function getName(collection) { + return collection && collection.name; + }, + getUrl: function getUrl(collection) { + return metabase_lib_urls__WEBPACK_IMPORTED_MODULE_2__.collection(collection); + }, + getIcon: function getIcon(collection, opts) { + var wrappedCollection = collection.collection; + return getCollectionIcon(wrappedCollection || collection, opts); + } + }, + selectors: { + getForm: _collections_forms__WEBPACK_IMPORTED_MODULE_10__.getFormSelector, + getExpandedCollectionsById: (0,reselect__WEBPACK_IMPORTED_MODULE_4__.createSelector)([function (state) { + return state.entities.collections; + }, function (state) { + var _ref3 = state.entities.collections_list[null] || {}, + list = _ref3.list; + + return list || []; + }, metabase_selectors_user__WEBPACK_IMPORTED_MODULE_6__.getUser], function (collections, collectionsIds, user) { + return getExpandedCollectionsById(collectionsIds.map(function (id) { + return collections[id]; + }), user && user.personal_collection_id); + }), + getInitialCollectionId: (0,reselect__WEBPACK_IMPORTED_MODULE_4__.createSelector)([function (state) { + return state.entities.collections; + }, // these are listed in order of priority + byCollectionIdProp, byCollectionIdNavParam, byCollectionUrlId, byCollectionQueryParameter, // defaults + function () { + return ROOT_COLLECTION.id; + }, metabase_selectors_user__WEBPACK_IMPORTED_MODULE_6__.getUserPersonalCollectionId], function (collections) { + for (var _len2 = arguments.length, collectionIds = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { + collectionIds[_key2 - 1] = arguments[_key2]; + } + + for (var _i = 0, _collectionIds = collectionIds; _i < _collectionIds.length; _i++) { + var collectionId = _collectionIds[_i]; + var collection = collections[collectionId]; + + if (collection && collection.can_write) { + return canonicalCollectionId(collectionId); + } + } + + return canonicalCollectionId(ROOT_COLLECTION.id); + }) + }, + getAnalyticsMetadata: function getAnalyticsMetadata(_ref4, _ref5, getState) { + var _ref6 = _slicedToArray(_ref4, 1), + object = _ref6[0]; + + var action = _ref5.action; + var type = object && getCollectionType(object.parent_id, getState()); + return type && "collection=".concat(type); + } +}); +/* harmony default export */ __webpack_exports__["default"] = (Collections); +function getCollectionIcon(collection) { + var _authorityLevel$toolt; + + var _ref7 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, + _ref7$tooltip = _ref7.tooltip, + tooltip = _ref7$tooltip === void 0 ? "default" : _ref7$tooltip; + + if (collection.id === PERSONAL_COLLECTIONS.id) { + return { + name: "group" + }; + } + + if ((0,metabase_collections_utils__WEBPACK_IMPORTED_MODULE_7__.isPersonalCollection)(collection)) { + return { + name: "person" + }; + } + + var authorityLevel = metabase_plugins__WEBPACK_IMPORTED_MODULE_9__.PLUGIN_COLLECTIONS.AUTHORITY_LEVEL[collection.authority_level]; + return authorityLevel ? { + name: authorityLevel.icon, + color: (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_1__.color)(authorityLevel.color), + tooltip: (_authorityLevel$toolt = authorityLevel.tooltips) === null || _authorityLevel$toolt === void 0 ? void 0 : _authorityLevel$toolt[tooltip] + } : { + name: "folder" + }; +} // API requires items in "root" collection be persisted with a "null" collection ID +// Also ensure it's parsed as a number + +var canonicalCollectionId = function canonicalCollectionId(collectionId) { + return collectionId == null || collectionId === "root" ? null : parseInt(collectionId, 10); +}; +function normalizedCollection(collection) { + if (canonicalCollectionId(collection.id) === null) { + return ROOT_COLLECTION; + } + + return collection; +} +var getCollectionType = function getCollectionType(collectionId, state) { + return collectionId === null || collectionId === "root" ? "root" : collectionId === (0,metabase_selectors_user__WEBPACK_IMPORTED_MODULE_6__.getUserPersonalCollectionId)(state) ? "personal" : collectionId !== undefined ? "other" : null; +}; // a "real" collection +// includes "root" and "personal" pseudo collection IDs +// given list of collections with { id, name, location } returns a map of ids to +// expanded collection objects like { id, name, location, path, children } +// including a root collection + +function getExpandedCollectionsById(collections, userPersonalCollectionId) { + var collectionsById = {}; + + var _iterator = _createForOfIteratorHelper(collections), + _step; + + try { + for (_iterator.s(); !(_step = _iterator.n()).done;) { + var c = _step.value; + collectionsById[c.id] = _objectSpread(_objectSpread({}, c), {}, { + path: c.id === "root" ? [] : c.location != null ? ["root"].concat(_toConsumableArray(c.location.split("/").filter(function (l) { + return l; + }))) : null, + parent: null, + children: [], + is_personal: c.personal_owner_id != null + }); + } // "Our Analytics" + + } catch (err) { + _iterator.e(err); + } finally { + _iterator.f(); + } + + collectionsById[ROOT_COLLECTION.id] = _objectSpread(_objectSpread({}, ROOT_COLLECTION), {}, { + parent: null, + children: [] + }, collectionsById[ROOT_COLLECTION.id] || {}); // "My personal collection" + + if (userPersonalCollectionId != null) { + var personalCollection = collectionsById[userPersonalCollectionId]; + collectionsById[ROOT_COLLECTION.id].children.push(_objectSpread(_objectSpread({}, PERSONAL_COLLECTION), {}, { + id: userPersonalCollectionId, + parent: collectionsById[ROOT_COLLECTION.id], + children: (personalCollection === null || personalCollection === void 0 ? void 0 : personalCollection.children) || [], + is_personal: true + })); + } // "Personal Collections" + + + collectionsById[PERSONAL_COLLECTIONS.id] = _objectSpread(_objectSpread({}, PERSONAL_COLLECTIONS), {}, { + parent: collectionsById[ROOT_COLLECTION.id], + children: [], + is_personal: true + }); + collectionsById[ROOT_COLLECTION.id].children.push(collectionsById[PERSONAL_COLLECTIONS.id]); // iterate over original collections so we don't include ROOT_COLLECTION as + // a child of itself + + var _iterator2 = _createForOfIteratorHelper(collections), + _step2; + + try { + for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { + var id = _step2.value.id; + var _c = collectionsById[id]; // don't add root as parent of itself + + if (_c.path && _c.id !== ROOT_COLLECTION.id) { + var parentId = void 0; // move personal collections into PERSONAL_COLLECTIONS fake collection + + if (_c.personal_owner_id != null) { + parentId = PERSONAL_COLLECTIONS.id; + } else if (_c.path[_c.path.length - 1]) { + parentId = _c.path[_c.path.length - 1]; + } else { + parentId = ROOT_COLLECTION.id; + } + + var parent = parentId == null ? null : collectionsById[parentId]; + _c.parent = parent; // need to ensure the parent collection exists, it may have been filtered + // because we're selecting a collection's parent collection and it can't + // contain itself + + if (parent) { + parent.children.push(_c); + } + } + } // remove PERSONAL_COLLECTIONS collection if there are none or just one (the user's own) + + } catch (err) { + _iterator2.e(err); + } finally { + _iterator2.f(); + } + + if (collectionsById[PERSONAL_COLLECTIONS.id].children.length <= 1) { + delete collectionsById[PERSONAL_COLLECTIONS.id]; + collectionsById[ROOT_COLLECTION.id].children = collectionsById[ROOT_COLLECTION.id].children.filter(function (c) { + return c.id !== PERSONAL_COLLECTIONS.id; + }); + } + + return collectionsById; +} // Initial collection ID selector helpers + +/** + * @param {ReduxState} state + * @param {{collectionId?: number}} props + * @returns {number | undefined} + */ + +function byCollectionIdProp(state, _ref8) { + var collectionId = _ref8.collectionId; + return collectionId; +} +/** + * @param {ReduxState} state + * @param {params?: {collectionId?: number}} props + * @returns {number | undefined} + */ + + +function byCollectionIdNavParam(state, _ref9) { + var params = _ref9.params; + return params && params.collectionId; +} +/** + * Extracts ID from collection URL slugs + * + * Example: /collection/14-marketing —> 14 + * + * @param {ReduxState} state + * @param {params?: {slug?: string}, location?: {pathname?: string}} props + * @returns {number | undefined} + */ + + +function byCollectionUrlId(state, _ref10) { + var params = _ref10.params, + location = _ref10.location; + var isCollectionPath = params && params.slug && location && metabase_lib_urls__WEBPACK_IMPORTED_MODULE_2__.isCollectionPath(location.pathname); + return isCollectionPath && metabase_lib_urls__WEBPACK_IMPORTED_MODULE_2__.extractCollectionId(params.slug); +} +/** + * Extracts collection ID from query params + * + * Example: /some-route?collectionId=14 —> 14 + * + * @param {ReduxState} state + * @param {location?: {query?: {collectionId?: number}}} props + * @returns {number | undefined} + */ + + +function byCollectionQueryParameter(state, _ref11) { + var location = _ref11.location; + return location && location.query && location.query.collectionId; +} + +/***/ }), + +/***/ "./entities/collections/forms.js": +/*!***************************************!*\ + !*** ./entities/collections/forms.js ***! + \***************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "getFormSelector": function() { return /* binding */ getFormSelector; } +/* harmony export */ }); +/* harmony import */ var reselect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! reselect */ "../../../node_modules/reselect/lib/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var metabase_plugins__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/plugins */ "./plugins/index.js"); +/* harmony import */ var metabase_lib_colors__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/lib/colors */ "./lib/colors.ts"); +/* harmony import */ var metabase_selectors_user__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! metabase/selectors/user */ "./selectors/user.js"); +/* harmony import */ var metabase_collections_utils__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! metabase/collections/utils */ "./collections/utils.js"); +var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9; + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + + + + + + + + +function createForm() { + var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, + _ref$extraFields = _ref.extraFields, + extraFields = _ref$extraFields === void 0 ? [] : _ref$extraFields; + + return { + fields: function fields() { + var values = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { + color: (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_3__.color)("brand") + }; + return [{ + name: "name", + title: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["Name"]))), + placeholder: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["My new fantastic collection"]))), + autoFocus: true, + validate: function validate(name) { + return !name && (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["Name is required"]))) || name && name.length > 100 && (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["Name must be 100 characters or less"]))); + } + }, { + name: "description", + title: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["Description"]))), + type: "text", + placeholder: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["It's optional but oh, so helpful"]))), + normalize: function normalize(description) { + return description || null; + } // expected to be nil or non-empty string + + }, { + name: "color", + title: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["Color"]))), + type: "hidden", + initial: function initial() { + return (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_3__.color)("brand"); + }, + validate: function validate(color) { + return !color && (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["Color is required"]))); + } + }, { + name: "parent_id", + title: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["Collection it's saved in"]))), + type: "collection" + }].concat(_toConsumableArray(extraFields)); + } + }; +} + +function isPersonalOrPersonalChild(collection, collectionList) { + if (!collection) { + return false; + } + + return (0,metabase_collections_utils__WEBPACK_IMPORTED_MODULE_5__.isPersonalCollection)(collection) || (0,metabase_collections_utils__WEBPACK_IMPORTED_MODULE_5__.isPersonalCollectionChild)(collection, collectionList); +} + +var getFormSelector = (0,reselect__WEBPACK_IMPORTED_MODULE_0__.createSelector)([function (state, props) { + return props.collection || {}; +}, function (state, props) { + return props.formValues || {}; +}, function (state) { + return state.entities.collections || {}; +}, metabase_selectors_user__WEBPACK_IMPORTED_MODULE_4__.getUser], function (collection, formValues, allCollections, user) { + var collectionList = Object.values(allCollections); + var extraFields = []; + var creatingNewCollection = !collection.id; + var parentId = creatingNewCollection ? formValues.parent_id : collection.parent_id; + var parentCollection = allCollections[parentId]; + var canManageAuthorityLevel = user.is_superuser && !(0,metabase_collections_utils__WEBPACK_IMPORTED_MODULE_5__.isPersonalCollection)(collection) && !isPersonalOrPersonalChild(parentCollection, collectionList); + + if (canManageAuthorityLevel) { + extraFields.push.apply(extraFields, _toConsumableArray(metabase_plugins__WEBPACK_IMPORTED_MODULE_2__.PLUGIN_COLLECTIONS.authorityLevelFormFields)); + } + + var form = createForm({ + extraFields: extraFields + }); + return form; +}); + +/***/ }), + +/***/ "./entities/containers/EntityForm.jsx": +/*!********************************************!*\ + !*** ./entities/containers/EntityForm.jsx ***! + \********************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "getForm": function() { return /* binding */ getForm; }, +/* harmony export */ "default": function() { return /* binding */ EntityForm; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var metabase_containers_Form__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/containers/Form */ "./containers/Form.jsx"); +/* harmony import */ var metabase_components_ModalContent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/components/ModalContent */ "./components/ModalContent.jsx"); +/* harmony import */ var _EntityType__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./EntityType */ "./entities/containers/EntityType.jsx"); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +var _templateObject, _dec, _class; + +var _excluded = ["entityDef", "entityObject", "form", "update", "create", "onSubmit", "onSaved"], + _excluded2 = ["modal"]; + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } + +function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } + +/* eslint-disable react/prop-types */ + + + + + +function getForm(entityDef) { + // 1. default `form` + // 2. first of the named `forms` + return entityDef.form || Object.values(entityDef.forms)[0]; +} + +var EForm = function EForm(_ref) { + var entityDef = _ref.entityDef, + entityObject = _ref.entityObject, + _ref$form = _ref.form, + form = _ref$form === void 0 ? getForm(entityDef) : _ref$form, + update = _ref.update, + create = _ref.create, + _ref$onSubmit = _ref.onSubmit, + onSubmit = _ref$onSubmit === void 0 ? function (object) { + return object.id ? update(object) : create(object); + } : _ref$onSubmit, + onSaved = _ref.onSaved, + props = _objectWithoutProperties(_ref, _excluded); + + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_containers_Form__WEBPACK_IMPORTED_MODULE_2__.default, _extends({}, props, { + form: form, + initialValues: entityObject, + onSubmit: onSubmit, + onSubmitSuccess: function onSubmitSuccess(action) { + return onSaved && onSaved(action.payload.object); + } + })); +}; + +var Modal = function Modal(_ref2) { + var children = _ref2.children, + titleProp = _ref2.title, + entityDef = _ref2.entityDef, + entityObject = _ref2.entityObject, + onClose = _ref2.onClose; + + var parseTitleFromEntity = function parseTitleFromEntity() { + return entityObject !== null && entityObject !== void 0 && entityObject.id ? entityDef.objectSelectors.getName(entityObject) : (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["New ", ""])), entityDef.displayNameOne); + }; + + var title = titleProp || parseTitleFromEntity(); + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_ModalContent__WEBPACK_IMPORTED_MODULE_3__.default, { + title: title, + onClose: onClose + }, children); +}; + +var EntityForm = (_dec = (0,_EntityType__WEBPACK_IMPORTED_MODULE_4__.default)(), _dec(_class = /*#__PURE__*/function (_React$Component) { + _inherits(EntityForm, _React$Component); + + var _super = _createSuper(EntityForm); + + function EntityForm() { + _classCallCheck(this, EntityForm); + + return _super.apply(this, arguments); + } + + _createClass(EntityForm, [{ + key: "render", + value: function render() { + var _this$props = this.props, + modal = _this$props.modal, + props = _objectWithoutProperties(_this$props, _excluded2); + + var eForm = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(EForm, props); + + if (modal) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(Modal, this.props, eForm); + } else { + return eForm; + } + } + }]); + + return EntityForm; +}(react__WEBPACK_IMPORTED_MODULE_0__.Component)) || _class); + + +/***/ }), + +/***/ "./entities/containers/EntityLink.jsx": +/*!********************************************!*\ + !*** ./entities/containers/EntityLink.jsx ***! + \********************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var metabase_components_Link__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/components/Link */ "./components/Link.tsx"); +/* harmony import */ var _EntityObjectLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./EntityObjectLoader */ "./entities/containers/EntityObjectLoader.jsx"); +var _excluded = ["entityType", "entityId", "name", "LinkComponent"]; + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } + +function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } + +/* eslint-disable react/prop-types */ + + + + +var EntityLink = function EntityLink(_ref) { + var entityType = _ref.entityType, + entityId = _ref.entityId, + _ref$name = _ref.name, + name = _ref$name === void 0 ? "name" : _ref$name, + _ref$LinkComponent = _ref.LinkComponent, + LinkComponent = _ref$LinkComponent === void 0 ? metabase_components_Link__WEBPACK_IMPORTED_MODULE_1__.default : _ref$LinkComponent, + linkProps = _objectWithoutProperties(_ref, _excluded); + + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_EntityObjectLoader__WEBPACK_IMPORTED_MODULE_2__.default, { + entityType: entityType, + entityId: entityId, + properties: [name], + loadingAndErrorWrapper: false, + wrapped: true + }, function (_ref2) { + var object = _ref2.object; + return object ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(LinkComponent, _extends({}, linkProps, { + to: object.getUrl() + }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", null, object.getName())) : null; + }); +}; + +/* harmony default export */ __webpack_exports__["default"] = (EntityLink); + +/***/ }), + +/***/ "./entities/containers/EntityListLoader.jsx": +/*!**************************************************!*\ + !*** ./entities/containers/EntityListLoader.jsx ***! + \**************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "entityListLoader": function() { return /* binding */ entityListLoader; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prop-types */ "../../../node_modules/prop-types/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var react_redux__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react-redux */ "../../../node_modules/react-redux/es/index.js"); +/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! underscore */ "../../../node_modules/underscore/modules/index-all.js"); +/* harmony import */ var reselect__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! reselect */ "../../../node_modules/reselect/lib/index.js"); +/* harmony import */ var metabase_lib_redux__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! metabase/lib/redux */ "./lib/redux.js"); +/* harmony import */ var _EntityType__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./EntityType */ "./entities/containers/EntityType.jsx"); +/* harmony import */ var metabase_hoc_PaginationState__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! metabase/hoc/PaginationState */ "./hoc/PaginationState.jsx"); +/* harmony import */ var metabase_components_LoadingAndErrorWrapper__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! metabase/components/LoadingAndErrorWrapper */ "./components/LoadingAndErrorWrapper.jsx"); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +var _excluded = ["children", "entityDef", "wrapped", "list", "listName", "loading", "reload", "keepListWhileLoading"]; + +var _dec, _dec2, _dec3, _class; + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } + +function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } + +function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } + +function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + + + + + + + + + + +var propTypes = { + entityType: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string), + entityQuery: prop_types__WEBPACK_IMPORTED_MODULE_1___default().oneOfType([(prop_types__WEBPACK_IMPORTED_MODULE_1___default().func), (prop_types__WEBPACK_IMPORTED_MODULE_1___default().object)]), + reload: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), + reloadInterval: prop_types__WEBPACK_IMPORTED_MODULE_1___default().oneOfType([(prop_types__WEBPACK_IMPORTED_MODULE_1___default().number), (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func)]), + wrapped: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), + debounced: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), + loadingAndErrorWrapper: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), + keepListWhileLoading: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), + listName: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string), + selectorName: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().string), + children: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func), + // via entityType HOC + entityDef: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().object), + // via react-redux connect + list: prop_types__WEBPACK_IMPORTED_MODULE_1___default().arrayOf((prop_types__WEBPACK_IMPORTED_MODULE_1___default().object)), + metadata: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().object), + loading: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), + loaded: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), + fetched: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), + error: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().any), + allLoading: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), + allLoaded: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), + allFetched: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), + allError: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().bool), + dispatch: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func) +}; +var defaultProps = { + loadingAndErrorWrapper: true, + keepListWhileLoading: false, + reload: false, + wrapped: false, + debounced: false +}; // props that shouldn't be passed to children in order to properly stack + +var CONSUMED_PROPS = ["entityType", "entityQuery", // "reload", // Masked by `reload` function. Should we rename that? +"reloadInterval", "wrapped", "debounced", "loadingAndErrorWrapper", "selectorName"]; + +var getEntityQuery = function getEntityQuery(state, props) { + return typeof props.entityQuery === "function" ? props.entityQuery(state, props) : props.entityQuery; +}; // NOTE: Memoize entityQuery so we don't re-render even if a new but identical +// object is created. This works because entityQuery must be JSON serializable +// NOTE: Technically leaks a small amount of memory because it uses an unbounded +// memoization cache, but that's probably ok. + + +var getMemoizedEntityQuery = (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_5__.createMemoizedSelector)([getEntityQuery], function (entityQuery) { + return entityQuery; +}); +var EntityListLoader = (_dec = (0,_EntityType__WEBPACK_IMPORTED_MODULE_6__.default)(), _dec2 = (0,metabase_hoc_PaginationState__WEBPACK_IMPORTED_MODULE_7__.default)(), _dec3 = (0,react_redux__WEBPACK_IMPORTED_MODULE_2__.connect)(function (state, props) { + var entityDef = props.entityDef, + entityQuery = props.entityQuery, + reloadInterval = props.reloadInterval, + page = props.page, + pageSize = props.pageSize, + allLoading = props.allLoading, + allLoaded = props.allLoaded, + allFetched = props.allFetched, + allError = props.allError, + _props$selectorName = props.selectorName, + selectorName = _props$selectorName === void 0 ? "getList" : _props$selectorName; + + if (typeof entityQuery === "function") { + entityQuery = entityQuery(state, props); + } + + if (typeof pageSize === "number" && typeof page === "number") { + entityQuery = _objectSpread({ + limit: pageSize, + offset: pageSize * page + }, entityQuery); + } + + entityQuery = getMemoizedEntityQuery(state, { + entityQuery: entityQuery + }); + var list = entityDef.selectors[selectorName](state, { + entityQuery: entityQuery + }); + + if (typeof reloadInterval === "function") { + reloadInterval = reloadInterval(state, props, list); + } + + var loading = entityDef.selectors.getLoading(state, { + entityQuery: entityQuery + }); + var loaded = entityDef.selectors.getLoaded(state, { + entityQuery: entityQuery + }); + var fetched = entityDef.selectors.getFetched(state, { + entityQuery: entityQuery + }); + var error = entityDef.selectors.getError(state, { + entityQuery: entityQuery + }); + var metadata = entityDef.selectors.getListMetadata(state, { + entityQuery: entityQuery + }); + return { + list: list, + entityQuery: entityQuery, + reloadInterval: reloadInterval, + metadata: metadata, + loading: loading, + loaded: loaded, + fetched: fetched, + error: error, + // merge props passed in from stacked Entity*Loaders: + allLoading: loading || (allLoading == null ? false : allLoading), + allLoaded: loaded && (allLoaded == null ? true : allLoaded), + allFetched: fetched && (allFetched == null ? true : allFetched), + allError: error || (allError == null ? null : allError) + }; +}), _dec(_class = _dec2(_class = _dec3(_class = /*#__PURE__*/function (_React$Component) { + _inherits(EntityListLoader, _React$Component); + + var _super = _createSuper(EntityListLoader); + + function EntityListLoader(_props) { + var _this; + + _classCallCheck(this, EntityListLoader); + + _this = _super.call(this, _props); + + _defineProperty(_assertThisInitialized(_this), "state", { + previousList: [], + isReloading: _this.props.reload + }); + + _defineProperty(_assertThisInitialized(_this), "fetchList", _this.maybeDebounce( /*#__PURE__*/function () { + var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(_ref, options) { + var fetchList, entityQuery, pageSize, onChangeHasMorePages, result; + return regeneratorRuntime.wrap(function _callee$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + fetchList = _ref.fetchList, entityQuery = _ref.entityQuery, pageSize = _ref.pageSize, onChangeHasMorePages = _ref.onChangeHasMorePages; + _context.next = 3; + return fetchList(entityQuery, options); + + case 3: + result = _context.sent; + + _this.setState({ + isReloading: false + }); + + if (typeof pageSize === "number" && onChangeHasMorePages) { + onChangeHasMorePages(!result.payload.result || result.payload.result.length === pageSize); + } + + return _context.abrupt("return", result); + + case 7: + case "end": + return _context.stop(); + } + } + }, _callee); + })); + + return function (_x, _x2) { + return _ref2.apply(this, arguments); + }; + }(), 250)); + + _defineProperty(_assertThisInitialized(_this), "renderChildren", function () { + var _objectSpread2; + + var _this$props = _this.props, + children = _this$props.children, + entityDef = _this$props.entityDef, + wrapped = _this$props.wrapped, + currentList = _this$props.list, + _this$props$listName = _this$props.listName, + listName = _this$props$listName === void 0 ? entityDef.nameMany : _this$props$listName, + loading = _this$props.loading, + reload = _this$props.reload, + keepListWhileLoading = _this$props.keepListWhileLoading, + props = _objectWithoutProperties(_this$props, _excluded); + + var previousList = _this.state.previousList; + var finalList = keepListWhileLoading && loading ? previousList : currentList; + var list = wrapped ? _this._getWrappedList(_objectSpread(_objectSpread({}, _this.props), {}, { + list: finalList + })) : finalList; + return children(_objectSpread(_objectSpread({}, underscore__WEBPACK_IMPORTED_MODULE_3__.default.omit.apply(underscore__WEBPACK_IMPORTED_MODULE_3__.default, [props].concat(CONSUMED_PROPS))), {}, (_objectSpread2 = { + list: list, + loading: loading + }, _defineProperty(_objectSpread2, listName, list), _defineProperty(_objectSpread2, "reload", _this.reload), _objectSpread2))); + }); + + _defineProperty(_assertThisInitialized(_this), "reload", function () { + _this.fetchList(_this.props, { + reload: true + }); + }); + + _this._getWrappedList = (0,reselect__WEBPACK_IMPORTED_MODULE_4__.createSelector)([function (props) { + return props.list; + }, function (props) { + return props.dispatch; + }, function (props) { + return props.entityDef; + }], function (list, dispatch, entityDef) { + return list && list.map(function (object) { + return entityDef.wrapEntity(object, dispatch); + }); + }); + return _this; + } + + _createClass(EntityListLoader, [{ + key: "maybeDebounce", + value: function maybeDebounce(f) { + if (this.props.debounced) { + for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } + + return underscore__WEBPACK_IMPORTED_MODULE_3__.default.debounce.apply(underscore__WEBPACK_IMPORTED_MODULE_3__.default, [f].concat(args)); + } else { + return f; + } + } + }, { + key: "componentDidMount", + value: function componentDidMount() { + var _this$props2 = this.props, + loaded = _this$props2.loaded, + reload = _this$props2.reload, + reloadInterval = _this$props2.reloadInterval; + this.fetchList(this.props, { + reload: reload + }); + + if (loaded && reloadInterval) { + this.reloadTimeout = setTimeout(this.reload, reloadInterval); + } + } + }, { + key: "UNSAFE_componentWillReceiveProps", + value: function UNSAFE_componentWillReceiveProps(nextProps) { + if (!underscore__WEBPACK_IMPORTED_MODULE_3__.default.isEqual(nextProps.entityQuery, this.props.entityQuery)) { + // entityQuery changed, reload + this.fetchList(nextProps, { + reload: nextProps.reload + }); + } else if (this.props.loaded && !nextProps.loaded && !nextProps.loading) { + // transitioned from loaded to not loaded, and isn't yet loading again + // this typically means the list request state was cleared by a + // create/update/delete action + this.fetchList(nextProps); + } + } + }, { + key: "componentDidUpdate", + value: function componentDidUpdate(prevProps) { + var _this$props3 = this.props, + loaded = _this$props3.loaded, + reloadInterval = _this$props3.reloadInterval, + keepListWhileLoading = _this$props3.keepListWhileLoading; + var previousList = this.state.previousList; + var shouldUpdatePrevList = keepListWhileLoading && Array.isArray(prevProps.list) && previousList !== prevProps.list; + + if (shouldUpdatePrevList) { + this.setState({ + previousList: prevProps.list + }); + } + + if (loaded && !prevProps.loaded) { + clearTimeout(this.reloadTimeout); + + if (reloadInterval) { + this.reloadTimeout = setTimeout(this.reload, reloadInterval); + } + } + } + }, { + key: "componentWillUnmount", + value: function componentWillUnmount() { + clearTimeout(this.reloadTimeout); + } + }, { + key: "render", + value: function render() { + var _this$props4 = this.props, + allFetched = _this$props4.allFetched, + allError = _this$props4.allError, + loadingAndErrorWrapper = _this$props4.loadingAndErrorWrapper; + var isReloading = this.state.isReloading; + return loadingAndErrorWrapper ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_LoadingAndErrorWrapper__WEBPACK_IMPORTED_MODULE_8__.default, { + loading: !allFetched || isReloading, + error: allError, + noWrapper: true + }, this.renderChildren) : this.renderChildren(); + } + }]); + + return EntityListLoader; +}(react__WEBPACK_IMPORTED_MODULE_0__.Component)) || _class) || _class) || _class); +EntityListLoader.propTypes = propTypes; +EntityListLoader.defaultProps = defaultProps; +/* harmony default export */ __webpack_exports__["default"] = (EntityListLoader); +var entityListLoader = function entityListLoader(ellProps) { + return function (ComposedComponent) { + function WrappedComponent(props) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(EntityListLoader, _extends({}, props, ellProps), function (childProps) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(ComposedComponent, _extends({}, underscore__WEBPACK_IMPORTED_MODULE_3__.default.omit.apply(underscore__WEBPACK_IMPORTED_MODULE_3__.default, [props].concat(CONSUMED_PROPS)), childProps)); + }); + } + + WrappedComponent.displayName = ComposedComponent.displayName; + return WrappedComponent; + }; +}; + +/***/ }), + +/***/ "./entities/containers/EntityName.jsx": +/*!********************************************!*\ + !*** ./entities/containers/EntityName.jsx ***! + \********************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var _EntityObjectLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./EntityObjectLoader */ "./entities/containers/EntityObjectLoader.jsx"); +/* eslint-disable react/prop-types */ + + + +var EntityName = function EntityName(_ref) { + var entityType = _ref.entityType, + entityId = _ref.entityId, + _ref$name = _ref.name, + name = _ref$name === void 0 ? "name" : _ref$name; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_EntityObjectLoader__WEBPACK_IMPORTED_MODULE_1__.default, { + entityType: entityType, + entityId: entityId, + properties: [name], + loadingAndErrorWrapper: false, + wrapped: true + }, function (_ref2) { + var object = _ref2.object; + return object ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", null, object.getName()) : null; + }); +}; + +/* harmony default export */ __webpack_exports__["default"] = (EntityName); + +/***/ }), + +/***/ "./entities/containers/EntityObjectLoader.jsx": +/*!****************************************************!*\ + !*** ./entities/containers/EntityObjectLoader.jsx ***! + \****************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* binding */ EntityObjectLoader; }, +/* harmony export */ "entityObjectLoader": function() { return /* binding */ entityObjectLoader; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var react_redux__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-redux */ "../../../node_modules/react-redux/es/index.js"); +/* harmony import */ var reselect__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! reselect */ "../../../node_modules/reselect/lib/index.js"); +/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! underscore */ "../../../node_modules/underscore/modules/index-all.js"); +/* harmony import */ var _EntityType__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./EntityType */ "./entities/containers/EntityType.jsx"); +/* harmony import */ var metabase_components_LoadingAndErrorWrapper__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! metabase/components/LoadingAndErrorWrapper */ "./components/LoadingAndErrorWrapper.jsx"); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +var _excluded = ["entityDef", "entityId", "selectorName"], + _excluded2 = ["children", "entityDef", "wrapped", "object"]; + +var _dec, _dec2, _class, _class2, _temp; + +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } + +function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +/* eslint-disable react/prop-types */ + + + + + + // props that shouldn't be passed to children in order to properly stack + +var CONSUMED_PROPS = ["entityType", "entityId", // "reload", // Masked by `reload` function. Should we rename that? +"wrapped", "properties", "loadingAndErrorWrapper", "selectorName"]; +var EntityObjectLoader = (_dec = (0,_EntityType__WEBPACK_IMPORTED_MODULE_4__.default)(), _dec2 = (0,react_redux__WEBPACK_IMPORTED_MODULE_1__.connect)(function (state, _ref) { + var entityDef = _ref.entityDef, + entityId = _ref.entityId, + _ref$selectorName = _ref.selectorName, + selectorName = _ref$selectorName === void 0 ? "getObject" : _ref$selectorName, + props = _objectWithoutProperties(_ref, _excluded); + + if (typeof entityId === "function") { + entityId = entityId(state, props); + } + + return { + entityId: entityId, + object: entityDef.selectors[selectorName](state, { + entityId: entityId + }), + fetched: entityDef.selectors.getFetched(state, { + entityId: entityId + }), + loading: entityDef.selectors.getLoading(state, { + entityId: entityId + }), + error: entityDef.selectors.getError(state, { + entityId: entityId + }) + }; +}), _dec(_class = _dec2(_class = (_temp = _class2 = /*#__PURE__*/function (_React$Component) { + _inherits(EntityObjectLoader, _React$Component); + + var _super = _createSuper(EntityObjectLoader); + + function EntityObjectLoader(_props) { + var _this; + + _classCallCheck(this, EntityObjectLoader); + + _this = _super.call(this, _props); + + _defineProperty(_assertThisInitialized(_this), "props", void 0); + + _defineProperty(_assertThisInitialized(_this), "_getWrappedObject", void 0); + + _defineProperty(_assertThisInitialized(_this), "renderChildren", function () { + var _objectSpread2; + + var _this$props = _this.props, + children = _this$props.children, + entityDef = _this$props.entityDef, + wrapped = _this$props.wrapped, + object = _this$props.object, + props = _objectWithoutProperties(_this$props, _excluded2); // eslint-disable-line no-unused-vars + + + if (wrapped) { + object = _this._getWrappedObject(_this.props); + } + + return children(_objectSpread(_objectSpread({}, underscore__WEBPACK_IMPORTED_MODULE_3__.default.omit.apply(underscore__WEBPACK_IMPORTED_MODULE_3__.default, [props].concat(CONSUMED_PROPS))), {}, (_objectSpread2 = { + object: object + }, _defineProperty(_objectSpread2, entityDef.nameOne, object), _defineProperty(_objectSpread2, "reload", _this.reload), _defineProperty(_objectSpread2, "remove", _this.remove), _objectSpread2))); + }); + + _defineProperty(_assertThisInitialized(_this), "reload", function () { + return _this.props.fetch({ + id: _this.props.entityId + }, { + reload: true, + properties: _this.props.properties + }); + }); + + _defineProperty(_assertThisInitialized(_this), "remove", function () { + return _this.props.delete(_this.props.object); + }); + + _this._getWrappedObject = (0,reselect__WEBPACK_IMPORTED_MODULE_2__.createSelector)([function (props) { + return props.object; + }, function (props) { + return props.dispatch; + }, function (props) { + return props.entityDef; + }], function (object, dispatch, entityDef) { + return object && entityDef.wrapEntity(object, dispatch); + }); + return _this; + } + + _createClass(EntityObjectLoader, [{ + key: "UNSAFE_componentWillMount", + value: function UNSAFE_componentWillMount() { + var _this$props2 = this.props, + entityId = _this$props2.entityId, + fetch = _this$props2.fetch; + + if (entityId != null) { + fetch({ + id: entityId + }, { + reload: this.props.reload, + properties: this.props.properties + }); + } + } + }, { + key: "UNSAFE_componentWillReceiveProps", + value: function UNSAFE_componentWillReceiveProps(nextProps) { + if (nextProps.entityId !== this.props.entityId && nextProps.entityId != null) { + nextProps.fetch({ + id: nextProps.entityId + }, { + reload: nextProps.reload, + properties: nextProps.properties + }); + } + } + }, { + key: "render", + value: function render() { + var _this$props3 = this.props, + entityId = _this$props3.entityId, + fetched = _this$props3.fetched, + error = _this$props3.error, + loadingAndErrorWrapper = _this$props3.loadingAndErrorWrapper; + return loadingAndErrorWrapper ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_LoadingAndErrorWrapper__WEBPACK_IMPORTED_MODULE_5__.default, { + loading: !fetched && entityId != null, + error: error, + noWrapper: true + }, this.renderChildren) : this.renderChildren(); + } + }]); + + return EntityObjectLoader; +}(react__WEBPACK_IMPORTED_MODULE_0__.Component), _defineProperty(_class2, "defaultProps", { + loadingAndErrorWrapper: true, + reload: false, + wrapped: false +}), _temp)) || _class) || _class); + +var entityObjectLoader = function entityObjectLoader(eolProps) { + return (// eslint-disable-line react/display-name + function (ComposedComponent) { + return (// eslint-disable-next-line react/display-name + function (props) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(EntityObjectLoader, _extends({}, props, eolProps), function (childProps) { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(ComposedComponent, _extends({}, underscore__WEBPACK_IMPORTED_MODULE_3__.default.omit.apply(underscore__WEBPACK_IMPORTED_MODULE_3__.default, [props].concat(CONSUMED_PROPS)), childProps)); + }); + } + ); + } + ); +}; + +/***/ }), + +/***/ "./entities/containers/EntityType.jsx": +/*!********************************************!*\ + !*** ./entities/containers/EntityType.jsx ***! + \********************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var react_redux__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-redux */ "../../../node_modules/react-redux/es/index.js"); +/* harmony import */ var redux__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! redux */ "../../../node_modules/redux/es/index.js"); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/* eslint-disable react/prop-types */ + + + +/* harmony default export */ __webpack_exports__["default"] = (function (entityType) { + return function (ComposedComponent) { + var _class, _temp; + + var mapStateToProps = function mapStateToProps(state, props) { + return { + entityDef: // dynamic require due to dependency load order issues + __webpack_require__(/*! metabase/entities */ "./entities/index.js")[entityType || (typeof props.entityType === "function" ? props.entityType(state, props) : props.entityType)] + }; + }; + + return (0,react_redux__WEBPACK_IMPORTED_MODULE_1__.connect)(mapStateToProps)((_temp = _class = /*#__PURE__*/function (_React$Component) { + _inherits(_class, _React$Component); + + var _super = _createSuper(_class); + + function _class(props) { + var _this; + + _classCallCheck(this, _class); + + _this = _super.call(this, props); + + _defineProperty(_assertThisInitialized(_this), "_boundActionCreators", {}); + + _this._bindActionCreators(props); + + return _this; + } + + _createClass(_class, [{ + key: "UNSAFE_componentWillReceiveProps", + value: function UNSAFE_componentWillReceiveProps(nextProps) { + if (nextProps.entityDef !== this.props.entityDef || nextProps.dispatch !== this.props.dispatch) { + this._bindActionCreators(nextProps); + + this.forceUpdate(); + } + } + }, { + key: "_bindActionCreators", + value: function _bindActionCreators(_ref) { + var entityDef = _ref.entityDef, + dispatch = _ref.dispatch; + this._boundActionCreators = (0,redux__WEBPACK_IMPORTED_MODULE_2__.bindActionCreators)(entityDef.actions, dispatch); + } + }, { + key: "render", + value: function render() { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(ComposedComponent, _extends({}, this.props, this._boundActionCreators)); + } + }]); + + return _class; + }(react__WEBPACK_IMPORTED_MODULE_0__.Component), _defineProperty(_class, "displayName", "EntityType"), _temp)); + }; +}); + +/***/ }), + +/***/ "./entities/containers/index.js": +/*!**************************************!*\ + !*** ./entities/containers/index.js ***! + \**************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "addEntityContainers": function() { return /* binding */ addEntityContainers; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var _EntityListLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./EntityListLoader */ "./entities/containers/EntityListLoader.jsx"); +/* harmony import */ var _EntityObjectLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./EntityObjectLoader */ "./entities/containers/EntityObjectLoader.jsx"); +/* harmony import */ var _EntityName__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./EntityName */ "./entities/containers/EntityName.jsx"); +/* harmony import */ var _EntityForm__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./EntityForm */ "./entities/containers/EntityForm.jsx"); +/* harmony import */ var _EntityLink__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./EntityLink */ "./entities/containers/EntityLink.jsx"); +var _excluded = ["id"], + _excluded2 = ["id"], + _excluded3 = ["query"], + _excluded4 = ["query"], + _excluded5 = ["id"], + _excluded6 = ["id"], + _excluded7 = ["object"], + _excluded8 = ["object"]; + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } + +function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } + +/* eslint-disable react/prop-types */ + + + + + + +function addEntityContainers(entity) { + var ObjectName = entity.nameOne; // Entity.load higher-order component + + entity.load = function () { + var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, + id = _ref.id, + props = _objectWithoutProperties(_ref, _excluded); + + return (0,_EntityObjectLoader__WEBPACK_IMPORTED_MODULE_2__.entityObjectLoader)(_objectSpread({ + entityType: entity.name, + entityId: id + }, props)); + }; // Entity.Loader component + + + entity.Loader = function (_ref2) { + var id = _ref2.id, + props = _objectWithoutProperties(_ref2, _excluded2); + + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_EntityObjectLoader__WEBPACK_IMPORTED_MODULE_2__.default, _extends({ + entityType: entity.name, + entityId: id + }, props)); + }; + + entity.Loader.displayName = "".concat(ObjectName, ".Loader"); // Entity.loadList higher-order component + + entity.loadList = function () { + var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, + query = _ref3.query, + props = _objectWithoutProperties(_ref3, _excluded3); + + return (0,_EntityListLoader__WEBPACK_IMPORTED_MODULE_1__.entityListLoader)(_objectSpread({ + entityType: entity.name, + entityQuery: query + }, props)); + }; // Entity.ListLoader component + + + entity.ListLoader = function (_ref4) { + var query = _ref4.query, + props = _objectWithoutProperties(_ref4, _excluded4); + + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_EntityListLoader__WEBPACK_IMPORTED_MODULE_1__.default, _extends({ + entityType: entity.name, + entityQuery: query + }, props)); + }; + + entity.ListLoader.displayName = "".concat(ObjectName, ".ListLoader"); // Entity.Name component + + entity.Name = function (_ref5) { + var id = _ref5.id, + props = _objectWithoutProperties(_ref5, _excluded5); + + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_EntityName__WEBPACK_IMPORTED_MODULE_3__.default, _extends({ + entityType: entity.name, + entityId: id + }, props)); + }; + + entity.Name.displayName = "".concat(ObjectName, ".Name"); // Entity.Link component + + entity.Link = function (_ref6) { + var id = _ref6.id, + props = _objectWithoutProperties(_ref6, _excluded6); + + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_EntityLink__WEBPACK_IMPORTED_MODULE_5__.default, _extends({ + entityType: entity.name, + entityId: id + }, props)); + }; + + entity.Link.displayName = "".concat(ObjectName, ".Link"); // Entity.Form component + + entity.Form = function (_ref7) { + var object = _ref7.object, + props = _objectWithoutProperties(_ref7, _excluded7); + + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_EntityForm__WEBPACK_IMPORTED_MODULE_4__.default, _extends({ + entityType: entity.name, + entityObject: object || props[entity.nameOne] + }, props)); + }; + + entity.Form.displayName = "".concat(ObjectName, ".Form"); // Entity.ModalForm component + + entity.ModalForm = function (_ref8) { + var object = _ref8.object, + props = _objectWithoutProperties(_ref8, _excluded8); + + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_EntityForm__WEBPACK_IMPORTED_MODULE_4__.default, _extends({ + modal: true, + entityType: entity.name, + entityObject: object || props[entity.nameOne] + }, props)); + }; + + entity.ModalForm.displayName = "".concat(ObjectName, ".ModalForm"); +} + +/***/ }), + +/***/ "./entities/dashboards.js": +/*!********************************!*\ + !*** ./entities/dashboards.js ***! + \********************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var metabase_lib_redux__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! metabase/lib/redux */ "./lib/redux.js"); +/* harmony import */ var metabase_lib_entities__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/lib/entities */ "./lib/entities.js"); +/* harmony import */ var metabase_lib_urls__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/lib/urls */ "./lib/urls.js"); +/* harmony import */ var metabase_lib_colors__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/lib/colors */ "./lib/colors.ts"); +/* harmony import */ var icepick__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! icepick */ "../../../node_modules/icepick/icepick.min.js"); +/* harmony import */ var icepick__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(icepick__WEBPACK_IMPORTED_MODULE_4__); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_5__); +/* harmony import */ var metabase_redux_undo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! metabase/redux/undo */ "./redux/undo.js"); +/* harmony import */ var metabase_lib_api__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! metabase/lib/api */ "./lib/api.js"); +/* harmony import */ var metabase_entities_collections__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! metabase/entities/collections */ "./entities/collections.js"); +/* harmony import */ var _dashboards_forms__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./dashboards/forms */ "./entities/dashboards/forms.js"); +var _templateObject, _templateObject2; + +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } + +function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } + +function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } + +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } + +function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + + + + + + + + + + + +var FAVORITE_ACTION = "metabase/entities/dashboards/FAVORITE"; +var UNFAVORITE_ACTION = "metabase/entities/dashboards/UNFAVORITE"; +var COPY_ACTION = "metabase/entities/dashboards/COPY"; +var Dashboards = (0,metabase_lib_entities__WEBPACK_IMPORTED_MODULE_1__.createEntity)({ + name: "dashboards", + nameOne: "dashboard", + path: "/api/dashboard", + displayNameOne: (0,ttag__WEBPACK_IMPORTED_MODULE_5__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["dashboard"]))), + displayNameMany: (0,ttag__WEBPACK_IMPORTED_MODULE_5__.t)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["dashboards"]))), + api: { + favorite: (0,metabase_lib_api__WEBPACK_IMPORTED_MODULE_7__.POST)("/api/dashboard/:id/favorite"), + unfavorite: (0,metabase_lib_api__WEBPACK_IMPORTED_MODULE_7__.DELETE)("/api/dashboard/:id/favorite"), + save: (0,metabase_lib_api__WEBPACK_IMPORTED_MODULE_7__.POST)("/api/dashboard/save"), + copy: (0,metabase_lib_api__WEBPACK_IMPORTED_MODULE_7__.POST)("/api/dashboard/:id/copy") + }, + objectActions: { + setArchived: function setArchived(_ref, archived, opts) { + var id = _ref.id; + return Dashboards.actions.update({ + id: id + }, { + archived: archived + }, (0,metabase_lib_entities__WEBPACK_IMPORTED_MODULE_1__.undo)(opts, "dashboard", archived ? "archived" : "unarchived")); + }, + setCollection: function setCollection(_ref2, collection, opts) { + var id = _ref2.id; + return Dashboards.actions.update({ + id: id + }, { + collection_id: (0,metabase_entities_collections__WEBPACK_IMPORTED_MODULE_8__.canonicalCollectionId)(collection && collection.id) + }, (0,metabase_lib_entities__WEBPACK_IMPORTED_MODULE_1__.undo)(opts, "dashboard", "moved")); + }, + setPinned: function setPinned(_ref3, pinned, opts) { + var id = _ref3.id; + return Dashboards.actions.update({ + id: id + }, { + collection_position: typeof pinned === "number" ? pinned : pinned ? 1 : null + }, opts); + }, + setFavorited: function () { + var _setFavorited = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(_ref4, favorite) { + var id; + return regeneratorRuntime.wrap(function _callee$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + id = _ref4.id; + + if (!favorite) { + _context.next = 7; + break; + } + + _context.next = 4; + return Dashboards.api.favorite({ + id: id + }); + + case 4: + return _context.abrupt("return", { + type: FAVORITE_ACTION, + payload: id + }); + + case 7: + _context.next = 9; + return Dashboards.api.unfavorite({ + id: id + }); + + case 9: + return _context.abrupt("return", { + type: UNFAVORITE_ACTION, + payload: id + }); + + case 10: + case "end": + return _context.stop(); + } + } + }, _callee); + })); + + function setFavorited(_x, _x2) { + return _setFavorited.apply(this, arguments); + } + + return setFavorited; + }(), + // TODO move into more common area as copy is implemented for more entities + copy: (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_0__.compose)((0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_0__.withAction)(COPY_ACTION), // NOTE: unfortunately we can't use Dashboard.withRequestState, etc because the entity isn't defined yet + (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_0__.withRequestState)(function (dashboard) { + return ["entities", "dashboard", dashboard.id, "copy"]; + }), (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_0__.withAnalytics)("entities", "dashboard", "copy"))(function (entityObject, overrides) { + var _ref5 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}, + notify = _ref5.notify; + + return /*#__PURE__*/function () { + var _ref6 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(dispatch, getState) { + var result; + return regeneratorRuntime.wrap(function _callee2$(_context2) { + while (1) { + switch (_context2.prev = _context2.next) { + case 0: + _context2.t0 = Dashboards; + _context2.next = 3; + return Dashboards.api.copy(_objectSpread({ + id: entityObject.id + }, overrides)); + + case 3: + _context2.t1 = _context2.sent; + result = _context2.t0.normalize.call(_context2.t0, _context2.t1); + + if (notify) { + dispatch((0,metabase_redux_undo__WEBPACK_IMPORTED_MODULE_6__.addUndo)(notify)); + } + + dispatch({ + type: Dashboards.actionTypes.INVALIDATE_LISTS_ACTION + }); + return _context2.abrupt("return", result); + + case 8: + case "end": + return _context2.stop(); + } + } + }, _callee2); + })); + + return function (_x3, _x4) { + return _ref6.apply(this, arguments); + }; + }(); + }) + }, + actions: { + save: function save(dashboard) { + return /*#__PURE__*/function () { + var _ref7 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(dispatch) { + var savedDashboard; + return regeneratorRuntime.wrap(function _callee3$(_context3) { + while (1) { + switch (_context3.prev = _context3.next) { + case 0: + _context3.next = 2; + return Dashboards.api.save(dashboard); + + case 2: + savedDashboard = _context3.sent; + dispatch({ + type: Dashboards.actionTypes.INVALIDATE_LISTS_ACTION + }); + return _context3.abrupt("return", { + type: "metabase/entities/dashboards/SAVE_DASHBOARD", + payload: savedDashboard + }); + + case 5: + case "end": + return _context3.stop(); + } + } + }, _callee3); + })); + + return function (_x5) { + return _ref7.apply(this, arguments); + }; + }(); + } + }, + reducer: function reducer() { + var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + + var _ref8 = arguments.length > 1 ? arguments[1] : undefined, + type = _ref8.type, + payload = _ref8.payload, + error = _ref8.error; + + if (type === FAVORITE_ACTION && !error) { + return (0,icepick__WEBPACK_IMPORTED_MODULE_4__.assocIn)(state, [payload, "favorite"], true); + } else if (type === UNFAVORITE_ACTION && !error) { + return (0,icepick__WEBPACK_IMPORTED_MODULE_4__.assocIn)(state, [payload, "favorite"], false); + } else if (type === COPY_ACTION && !error && state[""]) { + return _objectSpread(_objectSpread({}, state), {}, { + "": state[""].concat([payload.result]) + }); + } + + return state; + }, + objectSelectors: { + getFavorited: function getFavorited(dashboard) { + return dashboard && dashboard.favorite; + }, + getName: function getName(dashboard) { + return dashboard && dashboard.name; + }, + getUrl: function getUrl(dashboard) { + return dashboard && metabase_lib_urls__WEBPACK_IMPORTED_MODULE_2__.dashboard(dashboard); + }, + getCollection: function getCollection(dashboard) { + return dashboard && (0,metabase_entities_collections__WEBPACK_IMPORTED_MODULE_8__.normalizedCollection)(dashboard.collection); + }, + getIcon: function getIcon(dashboard) { + return { + name: "dashboard" + }; + }, + getColor: function getColor() { + return (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_3__.color)("dashboard"); + } + }, + getAnalyticsMetadata: function getAnalyticsMetadata(_ref9, _ref10, getState) { + var _ref11 = _slicedToArray(_ref9, 1), + object = _ref11[0]; + + var action = _ref10.action; + var type = object && (0,metabase_entities_collections__WEBPACK_IMPORTED_MODULE_8__.getCollectionType)(object.collection_id, getState()); + return type && "collection=".concat(type); + }, + forms: _dashboards_forms__WEBPACK_IMPORTED_MODULE_9__.default +}); +/* harmony default export */ __webpack_exports__["default"] = (Dashboards); + +/***/ }), + +/***/ "./entities/dashboards/forms.js": +/*!**************************************!*\ + !*** ./entities/dashboards/forms.js ***! + \**************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var metabase_lib_settings__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/lib/settings */ "./lib/settings.ts"); +/* harmony import */ var metabase_plugins__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/plugins */ "./plugins/index.js"); +var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8; + +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + + + + +var FORM_FIELDS = [{ + name: "name", + title: (0,ttag__WEBPACK_IMPORTED_MODULE_0__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["Name"]))), + placeholder: (0,ttag__WEBPACK_IMPORTED_MODULE_0__.t)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["What is the name of your dashboard?"]))), + autoFocus: true, + validate: function validate(name) { + return !name ? (0,ttag__WEBPACK_IMPORTED_MODULE_0__.t)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["Name is required"]))) : null; + } +}, { + name: "description", + title: (0,ttag__WEBPACK_IMPORTED_MODULE_0__.t)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["Description"]))), + type: "text", + placeholder: (0,ttag__WEBPACK_IMPORTED_MODULE_0__.t)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["It's optional but oh, so helpful"]))) +}, { + name: "collection_id", + title: (0,ttag__WEBPACK_IMPORTED_MODULE_0__.t)(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["Which collection should this go in?"]))), + type: "collection", + validate: function validate(collectionId) { + return collectionId === undefined ? (0,ttag__WEBPACK_IMPORTED_MODULE_0__.t)(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["Collection is required"]))) : null; + } +}]; +/* harmony default export */ __webpack_exports__["default"] = ({ + create: { + fields: FORM_FIELDS + }, + edit: { + fields: function fields() { + var fields = [].concat(FORM_FIELDS); + + if (metabase_lib_settings__WEBPACK_IMPORTED_MODULE_1__.default.get("enable-query-caching") && metabase_plugins__WEBPACK_IMPORTED_MODULE_2__.PLUGIN_CACHING.cacheTTLFormField) { + fields.push(_objectSpread(_objectSpread({}, metabase_plugins__WEBPACK_IMPORTED_MODULE_2__.PLUGIN_CACHING.cacheTTLFormField), {}, { + type: "dashboardCacheTTL", + message: (0,ttag__WEBPACK_IMPORTED_MODULE_0__.t)(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["Cache all question results for"]))) + })); + } + + return fields; + } + } +}); + +/***/ }), + +/***/ "./entities/database-candidates.js": +/*!*****************************************!*\ + !*** ./entities/database-candidates.js ***! + \*****************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var metabase_lib_entities__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! metabase/lib/entities */ "./lib/entities.js"); +/* harmony import */ var metabase_services__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/services */ "./services.js"); +function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } + +function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } + + + +var DatabaseCandidates = (0,metabase_lib_entities__WEBPACK_IMPORTED_MODULE_0__.createEntity)({ + name: "databaseCandidates", + api: { + list: function () { + var _list = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() { + var query, + _args = arguments; + return regeneratorRuntime.wrap(function _callee$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + query = _args.length > 0 && _args[0] !== undefined ? _args[0] : {}; + return _context.abrupt("return", query.id ? metabase_services__WEBPACK_IMPORTED_MODULE_1__.AutoApi.db_candidates(query) : []); + + case 2: + case "end": + return _context.stop(); + } + } + }, _callee); + })); + + function list() { + return _list.apply(this, arguments); + } + + return list; + }() + } +}); +/* harmony default export */ __webpack_exports__["default"] = (DatabaseCandidates); + +/***/ }), + +/***/ "./entities/databases.js": +/*!*******************************!*\ + !*** ./entities/databases.js ***! + \*******************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "FETCH_DATABASE_METADATA": function() { return /* binding */ FETCH_DATABASE_METADATA; }, +/* harmony export */ "FETCH_DATABASE_SCHEMAS": function() { return /* binding */ FETCH_DATABASE_SCHEMAS; }, +/* harmony export */ "FETCH_DATABASE_IDFIELDS": function() { return /* binding */ FETCH_DATABASE_IDFIELDS; } +/* harmony export */ }); +/* harmony import */ var normalizr__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! normalizr */ "../../../node_modules/normalizr/dist/normalizr.es.js"); +/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! underscore */ "../../../node_modules/underscore/modules/index-all.js"); +/* harmony import */ var metabase_lib_entities__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/lib/entities */ "./lib/entities.js"); +/* harmony import */ var metabase_lib_urls__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/lib/urls */ "./lib/urls.js"); +/* harmony import */ var metabase_lib_colors__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/lib/colors */ "./lib/colors.ts"); +/* harmony import */ var metabase_lib_redux__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! metabase/lib/redux */ "./lib/redux.js"); +/* harmony import */ var metabase_services__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! metabase/services */ "./services.js"); +/* harmony import */ var metabase_schema__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! metabase/schema */ "./schema.js"); +/* harmony import */ var metabase_entities_fields__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! metabase/entities/fields */ "./entities/fields.js"); +/* harmony import */ var metabase_entities_schemas__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! metabase/entities/schemas */ "./entities/schemas.js"); +/* harmony import */ var metabase_selectors_metadata__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! metabase/selectors/metadata */ "./selectors/metadata.js"); +/* harmony import */ var reselect__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! reselect */ "../../../node_modules/reselect/lib/index.js"); +/* harmony import */ var _databases_forms__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./databases/forms */ "./entities/databases/forms.js"); +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } + +function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } + + + + + + + + + + + + + + // OBJECT ACTIONS + +var FETCH_DATABASE_METADATA = "metabase/entities/database/FETCH_DATABASE_METADATA"; +var FETCH_DATABASE_SCHEMAS = "metabase/entities/database/FETCH_DATABASE_SCHEMAS"; +var FETCH_DATABASE_IDFIELDS = "metabase/entities/database/FETCH_DATABASE_IDFIELDS"; +var Databases = (0,metabase_lib_entities__WEBPACK_IMPORTED_MODULE_1__.createEntity)({ + name: "databases", + path: "/api/database", + schema: metabase_schema__WEBPACK_IMPORTED_MODULE_6__.DatabaseSchema, + nameOne: "database", + nameMany: "databases", + // ACTION CREATORS + objectActions: { + fetchDatabaseMetadata: (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_4__.createThunkAction)(FETCH_DATABASE_METADATA, function (_ref) { + var id = _ref.id; + + var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, + _ref2$reload = _ref2.reload, + reload = _ref2$reload === void 0 ? false : _ref2$reload, + params = _ref2.params; + + return function (dispatch, getState) { + return (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_4__.fetchData)({ + dispatch: dispatch, + getState: getState, + requestStatePath: ["metadata", "databases", id], + existingStatePath: ["metadata", "databases", id], + getData: function () { + var _getData = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() { + var databaseMetadata; + return regeneratorRuntime.wrap(function _callee$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + _context.next = 2; + return metabase_services__WEBPACK_IMPORTED_MODULE_5__.MetabaseApi.db_metadata(_objectSpread({ + dbId: id + }, params)); + + case 2: + databaseMetadata = _context.sent; + return _context.abrupt("return", (0,normalizr__WEBPACK_IMPORTED_MODULE_12__.normalize)(databaseMetadata, metabase_schema__WEBPACK_IMPORTED_MODULE_6__.DatabaseSchema)); + + case 4: + case "end": + return _context.stop(); + } + } + }, _callee); + })); + + function getData() { + return _getData.apply(this, arguments); + } + + return getData; + }(), + reload: reload + }); + }; + }), + fetchIdfields: (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_4__.createThunkAction)(FETCH_DATABASE_IDFIELDS, function (_ref3) { + var id = _ref3.id; + return /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() { + return regeneratorRuntime.wrap(function _callee2$(_context2) { + while (1) { + switch (_context2.prev = _context2.next) { + case 0: + _context2.t0 = normalizr__WEBPACK_IMPORTED_MODULE_12__.normalize; + _context2.next = 3; + return metabase_services__WEBPACK_IMPORTED_MODULE_5__.MetabaseApi.db_idfields({ + dbId: id + }); + + case 3: + _context2.t1 = _context2.sent; + _context2.t2 = [metabase_entities_fields__WEBPACK_IMPORTED_MODULE_7__.default.schema]; + return _context2.abrupt("return", (0, _context2.t0)(_context2.t1, _context2.t2)); + + case 6: + case "end": + return _context2.stop(); + } + } + }, _callee2); + })); + }), + fetchSchemas: function fetchSchemas(_ref5) { + var id = _ref5.id; + return metabase_entities_schemas__WEBPACK_IMPORTED_MODULE_8__.default.actions.fetchList({ + dbId: id + }); + } + }, + objectSelectors: { + getName: function getName(db) { + return db && db.name; + }, + getUrl: function getUrl(db) { + return db && metabase_lib_urls__WEBPACK_IMPORTED_MODULE_2__.browseDatabase(db); + }, + getIcon: function getIcon(db) { + return { + name: "database" + }; + }, + getColor: function getColor(db) { + return (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_3__.color)("database"); + } + }, + selectors: { + getObject: function getObject(state, _ref6) { + var entityId = _ref6.entityId; + return (0,metabase_selectors_metadata__WEBPACK_IMPORTED_MODULE_9__.getMetadata)(state).database(entityId); + }, + getHasSampleDataset: function getHasSampleDataset(state) { + return underscore__WEBPACK_IMPORTED_MODULE_0__.default.any(Databases.selectors.getList(state), function (db) { + return db.is_sample; + }); + }, + getIdfields: (0,reselect__WEBPACK_IMPORTED_MODULE_10__.createSelector)( // we wrap getFields to handle a circular dep issue + [function (state) { + return (0,metabase_selectors_metadata__WEBPACK_IMPORTED_MODULE_9__.getFields)(state); + }, function (state, props) { + return props.databaseId; + }], function (fields, databaseId) { + return Object.values(fields).filter(function (f) { + var _ref7 = f.table || {}, + db_id = _ref7.db_id; // a field's table can be null + + + return db_id === databaseId && f.isPK(); + }); + }) + }, + // FORM + forms: _databases_forms__WEBPACK_IMPORTED_MODULE_11__.default +}); +/* harmony default export */ __webpack_exports__["default"] = (Databases); + +/***/ }), + +/***/ "./entities/databases/big-query-fields.js": +/*!************************************************!*\ + !*** ./entities/databases/big-query-fields.js ***! + \************************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* binding */ getFieldsForBigQuery; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var metabase_lib_colors__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/lib/colors */ "./lib/colors.ts"); +/* harmony import */ var metabase_components_ExternalLink__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/components/ExternalLink */ "./components/ExternalLink.tsx"); +/* harmony import */ var metabase_components_Link__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! metabase/components/Link */ "./components/Link.tsx"); +/* harmony import */ var metabase_admin_databases_components_widgets_MetadataSyncScheduleWidget__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! metabase/admin/databases/components/widgets/MetadataSyncScheduleWidget */ "./admin/databases/components/widgets/MetadataSyncScheduleWidget.jsx"); +/* harmony import */ var metabase_admin_databases_components_widgets_CacheFieldValuesScheduleWidget__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! metabase/admin/databases/components/widgets/CacheFieldValuesScheduleWidget */ "./admin/databases/components/widgets/CacheFieldValuesScheduleWidget.jsx"); +var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18, _templateObject19, _templateObject20, _templateObject21, _templateObject22, _templateObject23, _templateObject24, _templateObject25, _templateObject26, _templateObject27; + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + +/* eslint-disable react/prop-types */ + + + + + + + +var SERVICE_ACCOUNT_DOCS_URL = "https://developers.google.com/identity/protocols/OAuth2ServiceAccount"; + +function BigQueryServiceAccountToggle(_ref) { + var _ref$field = _ref.field, + value = _ref$field.value, + onChange = _ref$field.onChange, + details = _ref.values.details; + var saLink = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_ExternalLink__WEBPACK_IMPORTED_MODULE_3__.default, { + href: SERVICE_ACCOUNT_DOCS_URL + }, (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["Service Accounts"])))); + var hasNoOldStyleData = ["client-id", "client-secret"].every(function (key) { + return details[key] == null; + }); + return !value && hasNoOldStyleData || value === true ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("p", null, (0,ttag__WEBPACK_IMPORTED_MODULE_1__.jt)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["Metabase connects to Big Query via ", "."])), saLink)), value === true && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Link__WEBPACK_IMPORTED_MODULE_4__.default, { + className: "link", + onClick: function onClick() { + return onChange(false); + } + }, (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["Continue using an OAuth application to connect"]))))) : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { + style: { + borderLeftWidth: 3, + borderLeftStyle: "solid", + borderLeftColor: (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_2__.color)("brand") + }, + className: "pl1" + }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("p", null, (0,ttag__WEBPACK_IMPORTED_MODULE_1__.jt)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["We recommend switching to use ", " instead of an OAuth application to connect to BigQuery"])), saLink)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Link__WEBPACK_IMPORTED_MODULE_4__.default, { + className: "link", + onClick: function onClick() { + return onChange(true); + } + }, (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["Connect to a Service Account instead"]))))); +} + +function getFieldsForBigQuery(details) { + var useServiceAccount = // If this field is unset, show the service account form unless an old-style connection exists. + details["use-service-account"] == null ? ["client-id", "client-secret"].every(function (key) { + return details[key] == null; + }) : details["use-service-account"]; + return { + "details-fields": [{ + name: "use-service-account", + type: BigQueryServiceAccountToggle, + hidden: true + }].concat(_toConsumableArray(useServiceAccount ? [] : [{ + name: "project-id", + "display-name": (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["Project ID"]))), + "helper-text": (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["Project ID to be used for authentication. You can omit this field if you are only querying datasets owned by your organization."]))), + placeholder: "1w08oDRKPrOqBt06yxY8uiCz2sSvOp3u", + required: true + }]), [{ + name: "dataset-id", + "display-name": (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["Dataset ID"]))), + "helper-text": (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["Make sure to leave out the Project ID prefix in \"project_name:dataset_id\" and only enter \u201Cdataset_id\u201D"]))), + placeholder: "dataset_id", + required: true + }], _toConsumableArray(useServiceAccount ? [{ + name: "service-account-json", + "display-name": (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["Service account JSON file"]))), + "helper-text": (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["This JSON file contains the credentials Metabase needs to read and query your dataset."]))), + type: "textFile", + required: true + }] : [{ + name: "client-id", + "display-name": (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["Client ID"]))), + placeholder: "1201327674725-y6ferb0feo1hfssr7t40o4aikqll46d4.apps.googleusercontent.com", + required: true + }, { + name: "client-secret", + "display-name": (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject13 || (_templateObject13 = _taggedTemplateLiteral(["Client Secret"]))), + placeholder: "dJNi4utWgMzyIFo2JbnsK6Np", + required: true + }, { + name: "auth-code", + "display-name": (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject14 || (_templateObject14 = _taggedTemplateLiteral(["Auth Code"]))), + placeholder: "4/HSk-KtxkSzTt61j5zcbee2Rmm5JHkRFbL5gD5lgkXek", + required: true + }]), [{ + name: "advanced-options", + type: "section", + default: false + }, { + name: "use-jvm-timezone", + "display-name": (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject15 || (_templateObject15 = _taggedTemplateLiteral(["Use the Java Virtual Machine (JVM) timezone"]))), + default: false, + type: "boolean", + "visible-if": { + "advanced-options": true + } + }, { + name: "include-user-id-and-hash", + "display-name": (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject16 || (_templateObject16 = _taggedTemplateLiteral(["Include User ID and query hash in queries"]))), + default: true, + type: "boolean", + "visible-if": { + "advanced-options": true + } + }, { + name: "auto_run_queries", + type: "boolean", + default: true, + "display-name": (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject17 || (_templateObject17 = _taggedTemplateLiteral(["Rerun queries for simple explorations"]))), + description: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject18 || (_templateObject18 = _taggedTemplateLiteral(["We execute the underlying query when you explore data using Summarize or Filter. This is on by default but you can turn it off if performance is slow."]))), + "visible-if": { + "advanced-options": true + } + }, { + name: "let-user-control-scheduling", + type: "boolean", + "display-name": (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject19 || (_templateObject19 = _taggedTemplateLiteral(["Choose when syncs and scans happen"]))), + description: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject20 || (_templateObject20 = _taggedTemplateLiteral(["By default, Metabase does a lightweight hourly sync and an intensive daily scan of field values. If you have a large database, turn this on to make changes."]))), + "visible-if": { + "advanced-options": true + } + }, { + name: "schedules.metadata_sync", + "display-name": (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject21 || (_templateObject21 = _taggedTemplateLiteral(["Database syncing"]))), + type: metabase_admin_databases_components_widgets_MetadataSyncScheduleWidget__WEBPACK_IMPORTED_MODULE_5__.default, + description: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject22 || (_templateObject22 = _taggedTemplateLiteral(["This is a lightweight process that checks for updates to this database\u2019s schema. In most cases, you should be fine leaving this set to sync hourly."]))), + "visible-if": { + "let-user-control-scheduling": true + } + }, { + name: "schedules.cache_field_values", + "display-name": (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject23 || (_templateObject23 = _taggedTemplateLiteral(["Scanning for Filter Values"]))), + type: metabase_admin_databases_components_widgets_CacheFieldValuesScheduleWidget__WEBPACK_IMPORTED_MODULE_6__.default, + description: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject24 || (_templateObject24 = _taggedTemplateLiteral(["Metabase can scan the values present in each field in this database to enable checkbox filters in dashboards and questions. This can be a somewhat resource-intensive process, particularly if you have a very large database."]))) + " " + (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject25 || (_templateObject25 = _taggedTemplateLiteral(["When should Metabase automatically scan and cache field values?"]))), + "visible-if": { + "let-user-control-scheduling": true + } + }, { + name: "refingerprint", + type: "boolean", + "display-name": (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject26 || (_templateObject26 = _taggedTemplateLiteral(["Periodically refingerprint tables"]))), + description: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject27 || (_templateObject27 = _taggedTemplateLiteral(["This enables Metabase to scan for additional field values during syncs allowing smarter behavior, like improved auto-binning on your bar charts."]))), + "visible-if": { + "advanced-options": true + } + }]) + }; +} + +/***/ }), + +/***/ "./entities/databases/forms.js": +/*!*************************************!*\ + !*** ./entities/databases/forms.js ***! + \*************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "engineSupersedesMap": function() { return /* binding */ engineSupersedesMap; }, +/* harmony export */ "allEngines": function() { return /* binding */ allEngines; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var metabase_lib_settings__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/lib/settings */ "./lib/settings.ts"); +/* harmony import */ var metabase_lib_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/lib/engine */ "./lib/engine.js"); +/* harmony import */ var metabase_components_ExternalLink__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! metabase/components/ExternalLink */ "./components/ExternalLink.tsx"); +/* harmony import */ var metabase_plugins__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! metabase/plugins */ "./plugins/index.js"); +/* harmony import */ var _big_query_fields__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./big-query-fields */ "./entities/databases/big-query-fields.js"); +/* harmony import */ var _mongo_fields__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./mongo-fields */ "./entities/databases/mongo-fields.js"); +/* harmony import */ var metabase_admin_databases_components_widgets_MetadataSyncScheduleWidget__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! metabase/admin/databases/components/widgets/MetadataSyncScheduleWidget */ "./admin/databases/components/widgets/MetadataSyncScheduleWidget.jsx"); +/* harmony import */ var metabase_admin_databases_components_widgets_CacheFieldValuesScheduleWidget__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! metabase/admin/databases/components/widgets/CacheFieldValuesScheduleWidget */ "./admin/databases/components/widgets/CacheFieldValuesScheduleWidget.jsx"); +/* harmony import */ var metabase_admin_databases_components_widgets_EngineWidget__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! metabase/admin/databases/components/widgets/EngineWidget */ "./admin/databases/components/widgets/EngineWidget/index.js"); +var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18, _templateObject19, _templateObject20, _templateObject21, _templateObject22, _templateObject23, _templateObject24, _templateObject25, _templateObject26, _templateObject27, _templateObject28, _templateObject29, _templateObject30, _templateObject31, _templateObject32, _templateObject33, _templateObject34, _templateObject35, _templateObject36, _templateObject37; + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } + +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } + +function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } + +function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + + + + + + + + + + + + +var DATABASE_DETAIL_OVERRIDES = { + "tunnel-enabled": function tunnelEnabled() { + return { + title: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["Use an SSH-tunnel"]))), + description: getSshDescription() + }; + }, + "use-jvm-timezone": function useJvmTimezone() { + return { + title: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["Use the Java Virtual Machine (JVM) timezone"]))), + description: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["We suggest you leave this off unless you plan on doing a lot of manual timezone casting with this data."]))) + }; + }, + "include-user-id-and-hash": function includeUserIdAndHash() { + return { + title: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["Include User ID and query hash in queries"]))), + description: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["This can be useful for auditing and debugging, but prevents BigQuery from caching results and may increase your costs."]))) + }; + }, + "use-srv": function useSrv() { + return { + title: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["Connect using DNS SRV"]))), + description: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["If you're connecting to an Atlas cluster, you might need to turn this on. Note that your provided host must be a fully qualified domain name."]))) + }; + }, + "client-id": function clientId(engine, details) { + return { + description: getClientIdDescription(engine, details) + }; + }, + "auth-code": function authCode(engine, details) { + return { + description: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", null, getAuthCodeLink(engine, details)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", null, getAuthCodeEnableAPILink(engine, details))) + }; + }, + "service-account-json": function serviceAccountJson(engine, details, id) { + return { + validate: function validate(value) { + // this field is only required if this is a new entry + if (id) { + return null; + } + + if (!value) { + return (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["required"]))); + } + + try { + JSON.parse(value); + } catch (e) { + return (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["invalid JSON"]))); + } + + return null; + } + }; + }, + "tunnel-private-key": function tunnelPrivateKey() { + return { + title: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["SSH private key"]))), + placeholder: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["Paste the contents of your ssh private key here"]))), + type: "text" + }; + }, + "tunnel-private-key-passphrase": function tunnelPrivateKeyPassphrase() { + return { + title: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["Passphrase for the SSH private key"]))) + }; + }, + "tunnel-auth-option": function tunnelAuthOption() { + return { + title: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject13 || (_templateObject13 = _taggedTemplateLiteral(["SSH authentication"]))), + options: [{ + name: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject14 || (_templateObject14 = _taggedTemplateLiteral(["SSH Key"]))), + value: "ssh-key" + }, { + name: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject15 || (_templateObject15 = _taggedTemplateLiteral(["Password"]))), + value: "password" + }] + }; + }, + "ssl-cert": function sslCert() { + return { + title: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject16 || (_templateObject16 = _taggedTemplateLiteral(["Server SSL certificate chain"]))), + placeholder: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject17 || (_templateObject17 = _taggedTemplateLiteral(["Paste the contents of the server's SSL certificate chain here"]))), + type: "text" + }; + }, + "schedules.metadata_sync": function schedulesMetadata_sync() { + return { + name: "schedules.metadata_sync", + type: metabase_admin_databases_components_widgets_MetadataSyncScheduleWidget__WEBPACK_IMPORTED_MODULE_8__.default, + normalize: function normalize(value) { + return value; + } + }; + }, + "schedules.cache_field_values": function schedulesCache_field_values() { + return { + name: "schedules.cache_field_values", + type: metabase_admin_databases_components_widgets_CacheFieldValuesScheduleWidget__WEBPACK_IMPORTED_MODULE_9__.default, + normalize: function normalize(value) { + return value; + } + }; + }, + auto_run_queries: function auto_run_queries() { + return { + name: "auto_run_queries", + initial: undefined + }; + }, + refingerprint: function refingerprint() { + return { + name: "refingerprint" + }; + } +}; + +function getEngineName(engine) { + var engineInfo = ENGINES[engine]; + return engineInfo != null ? engineInfo["driver-name"] : (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject18 || (_templateObject18 = _taggedTemplateLiteral(["Database"]))); +} + +function getEngineInfo(engine, details, id) { + var engineInfo = (metabase_lib_settings__WEBPACK_IMPORTED_MODULE_2__.default.get("engines") || {})[engine]; + + switch (engine) { + // BigQuery has special logic to switch out forms depending on what style of authenication we use. + case "bigquery": + return (0,_big_query_fields__WEBPACK_IMPORTED_MODULE_6__.default)(details); + // Mongo has special logic to switch between a connection URI and broken out fields + + case "mongo": + return (0,_mongo_fields__WEBPACK_IMPORTED_MODULE_7__.default)(details, engineInfo, id); + + default: + return engineInfo; + } +} + +function shouldShowEngineProvidedField(field, details) { + var detailAndValueRequiredToShowField = field.visibleIf; + + if (detailAndValueRequiredToShowField) { + var pred = function pred(currentValue) { + var _currentValue = _slicedToArray(currentValue, 2), + detail = _currentValue[0], + expectedDetailValue = _currentValue[1]; + + if (Array.isArray(expectedDetailValue)) { + // if the expectedDetailValue is itself an array, then consider the condition satisfied if any of those values + // match the current detail value + return expectedDetailValue.includes(details[detail]); + } else { + return details[detail] === expectedDetailValue; + } + }; // check all entries in the visible-if map, and only show this field if all key/values are satisfied + // (i.e. boolean AND) + + + return Object.entries(detailAndValueRequiredToShowField).every(pred); + } + + return true; +} + +function getSshDescription() { + var link = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_ExternalLink__WEBPACK_IMPORTED_MODULE_4__.default, { + href: metabase_lib_settings__WEBPACK_IMPORTED_MODULE_2__.default.docsUrl("administration-guide/ssh-tunnel-for-database-connections") + }, (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject19 || (_templateObject19 = _taggedTemplateLiteral(["Learn more"])))); + return (0,ttag__WEBPACK_IMPORTED_MODULE_1__.jt)(_templateObject20 || (_templateObject20 = _taggedTemplateLiteral(["If a direct connection to your database isn't possible, you may want to use an SSH tunnel. ", "."])), link); +} + +var AUTH_URL_PREFIXES = { + bigquery: "https://accounts.google.com/o/oauth2/auth?redirect_uri=urn:ietf:wg:oauth:2.0:oob&response_type=code&scope=https://www.googleapis.com/auth/bigquery&client_id=", + bigquery_with_drive: "https://accounts.google.com/o/oauth2/auth?redirect_uri=urn:ietf:wg:oauth:2.0:oob&response_type=code&scope=https://www.googleapis.com/auth/bigquery%20https://www.googleapis.com/auth/drive&client_id=", + googleanalytics: "https://accounts.google.com/o/oauth2/auth?access_type=offline&redirect_uri=urn:ietf:wg:oauth:2.0:oob&response_type=code&scope=https://www.googleapis.com/auth/analytics.readonly&client_id=" +}; +var ENABLE_API_PREFIXES = { + googleanalytics: "https://console.developers.google.com/apis/api/analytics.googleapis.com/overview?project=" +}; +var CREDENTIALS_URL_PREFIXES = { + bigquery: "https://console.developers.google.com/apis/credentials/oauthclient?project=", + googleanalytics: "https://console.developers.google.com/apis/credentials/oauthclient?project=" +}; + +function concatTrimmed(a, b) { + return (a || "").trim() + (b || "").trim(); +} + +function getClientIdDescription(engine, details) { + if (CREDENTIALS_URL_PREFIXES[engine]) { + var credentialsURL = concatTrimmed(CREDENTIALS_URL_PREFIXES[engine], details["project-id"] || ""); + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", null, (0,ttag__WEBPACK_IMPORTED_MODULE_1__.jt)(_templateObject21 || (_templateObject21 = _taggedTemplateLiteral(["", " to generate a Client ID and Client Secret for your project."])), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_ExternalLink__WEBPACK_IMPORTED_MODULE_4__.default, { + className: "link", + href: credentialsURL + }, (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject22 || (_templateObject22 = _taggedTemplateLiteral(["Click here"]))))), " ", (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject23 || (_templateObject23 = _taggedTemplateLiteral(["Choose \"Desktop App\" as the application type. Name it whatever you'd like."])))); + } +} + +function getAuthCodeLink(engine, details) { + if (AUTH_URL_PREFIXES[engine] && details["client-id"]) { + var authCodeURL = concatTrimmed(AUTH_URL_PREFIXES[engine], details["client-id"]); + var googleDriveAuthCodeURL = concatTrimmed(AUTH_URL_PREFIXES["bigquery_with_drive"], details["client-id"]); + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", null, (0,ttag__WEBPACK_IMPORTED_MODULE_1__.jt)(_templateObject24 || (_templateObject24 = _taggedTemplateLiteral(["", " to get an auth code."])), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_ExternalLink__WEBPACK_IMPORTED_MODULE_4__.default, { + href: authCodeURL + }, (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject25 || (_templateObject25 = _taggedTemplateLiteral(["Click here"]))))), engine === "bigquery" && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", null, " ", "(", (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject26 || (_templateObject26 = _taggedTemplateLiteral(["or"]))), " ", /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_ExternalLink__WEBPACK_IMPORTED_MODULE_4__.default, { + href: googleDriveAuthCodeURL + }, (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject27 || (_templateObject27 = _taggedTemplateLiteral(["with Google Drive permissions"])))), ")")); + } +} + +function getAuthCodeEnableAPILink(engine, details) { + // for Google Analytics we need to show a link for people to go to the Console to enable the GA API + if (AUTH_URL_PREFIXES[engine] && details["client-id"]) { + // projectID is just the first numeric part of the client-id. + // e.g. client-id might be 123436115855-q8z42hilmjf8iplnnu49n7jbudmxxdf.apps.googleusercontent.com + // then project-id would be 123436115855 + var projectID = details["client-id"] && (details["client-id"].match(/^\d+/) || [])[0]; + + if (ENABLE_API_PREFIXES[engine] && projectID) { + // URL looks like https://console.developers.google.com/apis/api/analytics.googleapis.com/overview?project=12343611585 + var enableAPIURL = concatTrimmed(ENABLE_API_PREFIXES[engine], projectID); + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", null, (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject28 || (_templateObject28 = _taggedTemplateLiteral(["To use Metabase with this data you must enable API access in the Google Developers Console."]))), " ", (0,ttag__WEBPACK_IMPORTED_MODULE_1__.jt)(_templateObject29 || (_templateObject29 = _taggedTemplateLiteral(["", " to go to the console if you haven't already done so."])), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_ExternalLink__WEBPACK_IMPORTED_MODULE_4__.default, { + href: enableAPIURL + }, (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject30 || (_templateObject30 = _taggedTemplateLiteral(["Click here"])))))); + } + } +} + +function getDefaultValue(field) { + return "default" in field ? field.default : null; +} + +function normalizeFieldValue(value, field) { + if (value === "" || value == null) { + return getDefaultValue(field); + } + + if (typeof value === "string" && field.type !== "password") { + var trimmedValue = value.trim(); + return trimmedValue === "" ? getDefaultValue(field) : trimmedValue; + } + + return value; +} + +function getEngineFormFields(engine, details, id) { + var engineInfo = getEngineInfo(engine, details, id); + var engineFields = engineInfo ? engineInfo["details-fields"] : []; + var cachingField = getDatabaseCachingField(); // convert database details-fields to Form fields + + return engineFields.map(function (field) { + var overrides = DATABASE_DETAIL_OVERRIDES[field.name]; + return _objectSpread({ + name: "details.".concat(field.name), + title: field["display-name"], + type: field.type, + description: field.description, + placeholder: field.placeholder || field.default, + options: field.options, + validate: function validate(value) { + return field.required && !value ? (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject31 || (_templateObject31 = _taggedTemplateLiteral(["required"]))) : null; + }, + normalize: function normalize(value) { + return normalizeFieldValue(value, field); + }, + horizontal: field.type === "boolean", + initial: field.default, + readOnly: field.readOnly || false, + helperText: field["helper-text"], + visibleIf: field["visible-if"] + }, overrides && overrides(engine, details, id)); + }).concat(cachingField ? [cachingField] : []).filter(function (field) { + return shouldShowEngineProvidedField(field, details); + }); +} + +var ENGINES = metabase_lib_settings__WEBPACK_IMPORTED_MODULE_2__.default.get("engines", {}); +var ELEVATED_ENGINES = (0,metabase_lib_engine__WEBPACK_IMPORTED_MODULE_3__.getElevatedEngines)(); +var ENGINE_OPTIONS = Object.entries(ENGINES).map(function (_ref) { + var _info$official; + + var _ref2 = _slicedToArray(_ref, 2), + engine = _ref2[0], + info = _ref2[1]; + + return { + value: engine, + name: info["driver-name"], + official: (_info$official = info["official"]) !== null && _info$official !== void 0 ? _info$official : true, + // TODO remove default + index: ELEVATED_ENGINES.indexOf(engine) + }; +}).sort(function (a, b) { + return a.name.localeCompare(b.name); +}); // use top level constant for engines so we only need to compute these maps once + +var ENGINE_SUPERSEDES_MAPS = Object.keys(ENGINES).reduce(function (acc, engine) { + var newEngine = ENGINES[engine]["superseded-by"]; + + if (newEngine) { + acc.supersedes[newEngine] = engine; + acc.superseded_by[engine] = newEngine; + } + + return acc; +}, { + supersedes: {}, + superseded_by: {} +}); +/** + * Returns the options to show in the engines selection widget. An engine is available to be selected if either + * - it is not superseded by any other engine + * - it is the selected engine (i.e. someone is already using it) + * - it is superseded by some engine, which happens to be the currently selected one + * + * The idea behind this behavior is to only show someone a "legacy" driver if they have at least selected the one that + * will replace it first, at which point they can "fall back" on the legacy one if needed. + * + * @param currentEngine the current (selected engine) + * @returns the filtered engine options to be shown in the selection widget + */ + +function getEngineOptions(currentEngine) { + return ENGINE_OPTIONS.filter(function (engine) { + var engineName = engine.value; + var newDriver = ENGINE_SUPERSEDES_MAPS["superseded_by"][engineName]; + return typeof newDriver === "undefined" || newDriver === currentEngine || engineName === currentEngine; + }); +} + +function getDatabaseCachingField() { + var hasField = metabase_plugins__WEBPACK_IMPORTED_MODULE_5__.PLUGIN_CACHING.databaseCacheTTLFormField && metabase_lib_settings__WEBPACK_IMPORTED_MODULE_2__.default.get("enable-query-caching"); + return hasField ? metabase_plugins__WEBPACK_IMPORTED_MODULE_5__.PLUGIN_CACHING.databaseCacheTTLFormField : null; +} + +var forms = { + details: { + fields: function fields() { + var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, + id = _ref3.id, + engine = _ref3.engine, + _ref3$details = _ref3.details, + details = _ref3$details === void 0 ? {} : _ref3$details; + + return [{ + name: "engine", + title: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject32 || (_templateObject32 = _taggedTemplateLiteral(["Database type"]))), + type: "select", + options: getEngineOptions(engine), + placeholder: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject33 || (_templateObject33 = _taggedTemplateLiteral(["Select a database"]))), + isHosted: metabase_lib_settings__WEBPACK_IMPORTED_MODULE_2__.default.isHosted() + }, { + name: "name", + title: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject34 || (_templateObject34 = _taggedTemplateLiteral(["Display name"]))), + placeholder: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject35 || (_templateObject35 = _taggedTemplateLiteral(["Our ", ""])), getEngineName(engine)), + validate: function validate(value) { + return !value && (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject36 || (_templateObject36 = _taggedTemplateLiteral(["required"]))); + }, + hidden: !engine, + helperText: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject37 || (_templateObject37 = _taggedTemplateLiteral(["Choose what this data will be called in Metabase."]))) + }].concat(_toConsumableArray(getEngineFormFields(engine, details, id) || []), [{ + name: "is_full_sync", + type: "hidden" + }, { + name: "is_on_demand", + type: "hidden" + }]).filter(Boolean); + }, + normalize: function normalize(database) { + if (!database.details["let-user-control-scheduling"]) { + // TODO Atte Keinänen 8/15/17: Implement engine-specific scheduling defaults + return _objectSpread(_objectSpread({}, database), {}, { + is_full_sync: true + }); + } else { + return database; + } + } + } +}; +forms.setup = _objectSpread(_objectSpread({}, forms.details), {}, { + fields: function fields() { + var _forms$details; + + return (_forms$details = forms.details).fields.apply(_forms$details, arguments).map(function (field) { + return _objectSpread(_objectSpread({}, field), {}, { + type: field.name === "engine" ? metabase_admin_databases_components_widgets_EngineWidget__WEBPACK_IMPORTED_MODULE_10__.default : field.type, + title: field.name === "engine" ? null : field.title, + hidden: field.hidden || ADVANCED_FIELDS.has(field.name) + }); + }); + } +}); +forms.connection = _objectSpread(_objectSpread({}, forms.details), {}, { + fields: function fields() { + var _forms$details2; + + return (_forms$details2 = forms.details).fields.apply(_forms$details2, arguments).map(function (field) { + return _objectSpread(_objectSpread({}, field), {}, { + hidden: field.hidden + }); + }); + } +}); +var ADVANCED_FIELDS = new Set(["auto_run_queries", "details.let-user-control-scheduling", "cache_ttl"]); +/* harmony default export */ __webpack_exports__["default"] = (forms); +var engineSupersedesMap = ENGINE_SUPERSEDES_MAPS; +var allEngines = ENGINES; + +/***/ }), + +/***/ "./entities/databases/mongo-fields.js": +/*!********************************************!*\ + !*** ./entities/databases/mongo-fields.js ***! + \********************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": function() { return /* binding */ getFieldsForMongo; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var metabase_components_Link__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/components/Link */ "./components/Link.tsx"); +var _templateObject, _templateObject2; + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + +/* eslint-disable react/prop-types */ + + + + +function MongoConnectionStringToggle(_ref) { + var _ref$field = _ref.field, + value = _ref$field.value, + onChange = _ref$field.onChange; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(metabase_components_Link__WEBPACK_IMPORTED_MODULE_2__.default, { + className: "link", + onClick: function onClick() { + return onChange(!value); + } + }, value === false ? (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["Paste a connection string"]))) : (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["Fill out individual fields"]))))); +} + +function getFieldsForMongo(details, defaults, id) { + var useConnectionString = details["use-connection-uri"] == null || details["use-connection-uri"]; + var manualFields = ["host", "dbname", "port", "user", "pass", "authdb", "additional-options", "use-srv", "ssl"]; + var fields = defaults["details-fields"].filter(function (field) { + return !(useConnectionString && manualFields.includes(field["name"]) || !useConnectionString && field["name"] === "conn-uri"); + }).map(function (field) { + if (field["name"] === "conn-uri" && id) { + field.type = "password"; + } + + return field; + }); + return { + "details-fields": [{ + name: "use-connection-uri", + type: MongoConnectionStringToggle, + hidden: true, + default: false + }].concat(_toConsumableArray(fields)) + }; +} + +/***/ }), + +/***/ "./entities/fields.js": +/*!****************************!*\ + !*** ./entities/fields.js ***! + \****************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "FETCH_FIELD_VALUES": function() { return /* binding */ FETCH_FIELD_VALUES; }, +/* harmony export */ "UPDATE_FIELD_VALUES": function() { return /* binding */ UPDATE_FIELD_VALUES; }, +/* harmony export */ "DELETE_FIELD_DIMENSION": function() { return /* binding */ DELETE_FIELD_DIMENSION; }, +/* harmony export */ "UPDATE_FIELD_DIMENSION": function() { return /* binding */ UPDATE_FIELD_DIMENSION; }, +/* harmony export */ "ADD_REMAPPINGS": function() { return /* binding */ ADD_REMAPPINGS; }, +/* harmony export */ "ADD_PARAM_VALUES": function() { return /* binding */ ADD_PARAM_VALUES; }, +/* harmony export */ "ADD_FIELDS": function() { return /* binding */ ADD_FIELDS; } +/* harmony export */ }); +/* harmony import */ var metabase_lib_entities__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! metabase/lib/entities */ "./lib/entities.js"); +/* harmony import */ var metabase_lib_redux__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/lib/redux */ "./lib/redux.js"); +/* harmony import */ var normalizr__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! normalizr */ "../../../node_modules/normalizr/dist/normalizr.es.js"); +/* harmony import */ var icepick__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! icepick */ "../../../node_modules/icepick/icepick.min.js"); +/* harmony import */ var icepick__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(icepick__WEBPACK_IMPORTED_MODULE_2__); +/* harmony import */ var metabase_schema__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/schema */ "./schema.js"); +/* harmony import */ var metabase_services__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! metabase/services */ "./services.js"); +/* harmony import */ var metabase_selectors_metadata__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! metabase/selectors/metadata */ "./selectors/metadata.js"); +/* harmony import */ var metabase_lib_core__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! metabase/lib/core */ "./lib/core.js"); +/* harmony import */ var metabase_lib_query_field__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! metabase/lib/query/field */ "./lib/query/field.js"); +/* harmony import */ var metabase_lib_types__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! metabase/lib/types */ "./lib/types.js"); +var _handleActions; + +function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } + +function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + + + + + + + + + + + // ADDITIONAL OBJECT ACTIONS + +var FETCH_FIELD_VALUES = "metabase/entities/fields/FETCH_FIELD_VALUES"; +var UPDATE_FIELD_VALUES = "metabase/entities/fields/UPDATE_FIELD_VALUES"; +var DELETE_FIELD_DIMENSION = "metabase/metadata/DELETE_FIELD_DIMENSION"; +var UPDATE_FIELD_DIMENSION = "metabase/metadata/UPDATE_FIELD_DIMENSION"; +var ADD_REMAPPINGS = "metabase/entities/fields/ADD_REMAPPINGS"; // ADDITIONAL OTHER ACTIONS + +var ADD_PARAM_VALUES = "metabase/entities/fields/ADD_PARAM_VALUES"; +var ADD_FIELDS = "metabase/entities/fields/ADD_FIELDS"; +var Fields = (0,metabase_lib_entities__WEBPACK_IMPORTED_MODULE_0__.createEntity)({ + name: "fields", + path: "/api/field", + schema: metabase_schema__WEBPACK_IMPORTED_MODULE_3__.FieldSchema, + selectors: { + getObject: function getObject(state, _ref) { + var entityId = _ref.entityId; + return (0,metabase_selectors_metadata__WEBPACK_IMPORTED_MODULE_5__.getMetadata)(state).field(entityId); + }, + // getMetadata filters out sensitive fields by default. + // This selector is used in the data model when we want to show them. + getObjectUnfiltered: function getObjectUnfiltered(state, _ref2) { + var entityId = _ref2.entityId; + var field = state.entities.fields[entityId]; + return field && _objectSpread(_objectSpread({}, field), {}, { + values: (0,metabase_lib_query_field__WEBPACK_IMPORTED_MODULE_7__.getFieldValues)(field), + remapping: new Map((0,metabase_lib_query_field__WEBPACK_IMPORTED_MODULE_7__.getRemappings)(field)), + target: state.entities.fields[field.fk_target_field_id] + }); + }, + getFieldValues: function getFieldValues(state, _ref3) { + var entityId = _ref3.entityId; + var field = state.entities.fields[entityId]; + return field ? (0,metabase_lib_query_field__WEBPACK_IMPORTED_MODULE_7__.getFieldValues)(field) : []; + } + }, + // ACTION CREATORS + objectActions: { + fetchFieldValues: (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_1__.compose)((0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_1__.withAction)(FETCH_FIELD_VALUES), (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_1__.withCachedDataAndRequestState)(function (_ref4) { + var id = _ref4.id; + return _toConsumableArray(Fields.getObjectStatePath(id)); + }, function (_ref5) { + var id = _ref5.id; + return [].concat(_toConsumableArray(Fields.getObjectStatePath(id)), ["values"]); + }), (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_1__.withNormalize)(metabase_schema__WEBPACK_IMPORTED_MODULE_3__.FieldSchema))(function (_ref6) { + var fieldId = _ref6.id; + return /*#__PURE__*/function () { + var _ref7 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(dispatch, getState) { + var _yield$MetabaseApi$fi, id, values; + + return regeneratorRuntime.wrap(function _callee$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + _context.next = 2; + return metabase_services__WEBPACK_IMPORTED_MODULE_4__.MetabaseApi.field_values({ + fieldId: fieldId + }); + + case 2: + _yield$MetabaseApi$fi = _context.sent; + id = _yield$MetabaseApi$fi.field_id; + values = _yield$MetabaseApi$fi.values; + return _context.abrupt("return", { + id: id, + values: values + }); + + case 6: + case "end": + return _context.stop(); + } + } + }, _callee); + })); + + return function (_x, _x2) { + return _ref7.apply(this, arguments); + }; + }(); + }), + // Docstring from m.api.field: + // Update the human-readable values for a `Field` whose semantic type is + // `category`/`city`/`state`/`country` or whose base type is `type/Boolean`." + updateFieldValues: (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_1__.createThunkAction)(UPDATE_FIELD_VALUES, function (_ref8, fieldValuePairs) { + var id = _ref8.id; + return function (dispatch, getState) { + return (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_1__.updateData)({ + dispatch: dispatch, + getState: getState, + requestStatePath: ["entities", "fields", id, "dimension"], + existingStatePath: ["entities", "fields", id], + putData: function putData() { + return metabase_services__WEBPACK_IMPORTED_MODULE_4__.MetabaseApi.field_values_update({ + fieldId: id, + values: fieldValuePairs + }); + } + }); + }; + }), + updateFieldDimension: (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_1__.createThunkAction)(UPDATE_FIELD_DIMENSION, function (_ref9, dimension) { + var id = _ref9.id; + return function (dispatch, getState) { + return (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_1__.updateData)({ + dispatch: dispatch, + getState: getState, + requestStatePath: ["entities", "fields", id, "dimension"], + existingStatePath: ["entities", "fields", id], + putData: function putData() { + return metabase_services__WEBPACK_IMPORTED_MODULE_4__.MetabaseApi.field_dimension_update(_objectSpread({ + fieldId: id + }, dimension)); + } + }); + }; + }), + deleteFieldDimension: (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_1__.createThunkAction)(DELETE_FIELD_DIMENSION, function (_ref10) { + var id = _ref10.id; + return function (dispatch, getState) { + return (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_1__.updateData)({ + dispatch: dispatch, + getState: getState, + requestStatePath: ["entities", "fields", id, "dimension"], + existingStatePath: ["entities", "fields", id], + putData: function putData() { + return metabase_services__WEBPACK_IMPORTED_MODULE_4__.MetabaseApi.field_dimension_delete({ + fieldId: id + }); + } + }); + }; + }), + addRemappings: (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_1__.createAction)(ADD_REMAPPINGS, function (_ref11, remappings) { + var id = _ref11.id; + return { + fieldId: id, + remappings: remappings + }; + }) + }, + actions: { + addParamValues: (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_1__.createAction)(ADD_PARAM_VALUES), + addFields: (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_1__.createAction)(ADD_FIELDS, function (fields) { + return (0,normalizr__WEBPACK_IMPORTED_MODULE_9__.normalize)(fields, [metabase_schema__WEBPACK_IMPORTED_MODULE_3__.FieldSchema]); + }) + }, + // ADDITIONAL REDUCER + reducer: (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_1__.handleActions)((_handleActions = {}, _defineProperty(_handleActions, ADD_PARAM_VALUES, { + next: function next(state, _ref12) { + var paramValues = _ref12.payload; + + for (var _i = 0, _Object$values = Object.values(paramValues); _i < _Object$values.length; _i++) { + var fieldValues = _Object$values[_i]; + state = (0,icepick__WEBPACK_IMPORTED_MODULE_2__.assocIn)(state, [fieldValues.field_id, "values"], fieldValues); + } + + return state; + } + }), _defineProperty(_handleActions, ADD_REMAPPINGS, function (state, _ref13) { + var _ref13$payload = _ref13.payload, + fieldId = _ref13$payload.fieldId, + remappings = _ref13$payload.remappings; + return (0,icepick__WEBPACK_IMPORTED_MODULE_2__.updateIn)(state, [fieldId, "remappings"], function () { + var existing = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; + return Array.from(new Map(existing.concat(remappings))); + }); + }), _handleActions), {}), + form: { + fields: function fields() { + var values = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + return [{ + name: "display_name" + }, { + name: "description" + }, { + name: "visibility_type", + type: "select", + options: metabase_lib_core__WEBPACK_IMPORTED_MODULE_6__.field_visibility_types.map(function (type) { + return { + name: type.name, + value: type.id + }; + }) + }, { + name: "semantic_type", + type: "select", + options: metabase_lib_core__WEBPACK_IMPORTED_MODULE_6__.field_semantic_types.map(function (type) { + return { + name: type.name, + value: type.id + }; + }) + }, values.semantic_type === metabase_lib_types__WEBPACK_IMPORTED_MODULE_8__.TYPE.FK && { + name: "fk_target_field_id" + }, { + name: "has_field_values", + type: "select", + options: metabase_lib_core__WEBPACK_IMPORTED_MODULE_6__.has_field_values_options + }].filter(function (f) { + return f; + }); + } + } +}); +/* harmony default export */ __webpack_exports__["default"] = (Fields); + +/***/ }), + +/***/ "./entities/groups.js": +/*!****************************!*\ + !*** ./entities/groups.js ***! + \****************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var metabase_lib_entities__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! metabase/lib/entities */ "./lib/entities.js"); + +var Groups = (0,metabase_lib_entities__WEBPACK_IMPORTED_MODULE_0__.createEntity)({ + name: "groups", + path: "/api/permissions/group", + form: { + fields: [{ + name: "name" + }] + } +}); +/* harmony default export */ __webpack_exports__["default"] = (Groups); + +/***/ }), + +/***/ "./entities/index.js": +/*!***************************!*\ + !*** ./entities/index.js ***! + \***************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "alerts": function() { return /* reexport safe */ _alerts__WEBPACK_IMPORTED_MODULE_0__.default; }, +/* harmony export */ "collections": function() { return /* reexport safe */ _collections__WEBPACK_IMPORTED_MODULE_1__.default; }, +/* harmony export */ "snippetCollections": function() { return /* reexport safe */ _snippet_collections__WEBPACK_IMPORTED_MODULE_2__.default; }, +/* harmony export */ "dashboards": function() { return /* reexport safe */ _dashboards__WEBPACK_IMPORTED_MODULE_3__.default; }, +/* harmony export */ "databaseCandidates": function() { return /* reexport safe */ _database_candidates__WEBPACK_IMPORTED_MODULE_4__.default; }, +/* harmony export */ "pulses": function() { return /* reexport safe */ _pulses__WEBPACK_IMPORTED_MODULE_5__.default; }, +/* harmony export */ "questions": function() { return /* reexport safe */ _questions__WEBPACK_IMPORTED_MODULE_6__.default; }, +/* harmony export */ "revisions": function() { return /* reexport safe */ _revisions__WEBPACK_IMPORTED_MODULE_7__.default; }, +/* harmony export */ "databases": function() { return /* reexport safe */ _databases__WEBPACK_IMPORTED_MODULE_8__.default; }, +/* harmony export */ "schemas": function() { return /* reexport safe */ _schemas__WEBPACK_IMPORTED_MODULE_9__.default; }, +/* harmony export */ "tables": function() { return /* reexport safe */ _tables__WEBPACK_IMPORTED_MODULE_10__.default; }, +/* harmony export */ "fields": function() { return /* reexport safe */ _fields__WEBPACK_IMPORTED_MODULE_11__.default; }, +/* harmony export */ "metrics": function() { return /* reexport safe */ _metrics__WEBPACK_IMPORTED_MODULE_12__.default; }, +/* harmony export */ "segments": function() { return /* reexport safe */ _segments__WEBPACK_IMPORTED_MODULE_13__.default; }, +/* harmony export */ "tasks": function() { return /* reexport safe */ _tasks__WEBPACK_IMPORTED_MODULE_14__.default; }, +/* harmony export */ "loginHistory": function() { return /* reexport safe */ _loginHistory__WEBPACK_IMPORTED_MODULE_15__.default; }, +/* harmony export */ "users": function() { return /* reexport safe */ _users__WEBPACK_IMPORTED_MODULE_16__.default; }, +/* harmony export */ "groups": function() { return /* reexport safe */ _groups__WEBPACK_IMPORTED_MODULE_17__.default; }, +/* harmony export */ "search": function() { return /* reexport safe */ _search__WEBPACK_IMPORTED_MODULE_18__.default; }, +/* harmony export */ "recents": function() { return /* reexport safe */ _recents__WEBPACK_IMPORTED_MODULE_19__.default; }, +/* harmony export */ "snippets": function() { return /* reexport safe */ _snippets__WEBPACK_IMPORTED_MODULE_20__.default; } +/* harmony export */ }); +/* harmony import */ var _alerts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./alerts */ "./entities/alerts.js"); +/* harmony import */ var _collections__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./collections */ "./entities/collections.js"); +/* harmony import */ var _snippet_collections__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./snippet-collections */ "./entities/snippet-collections.js"); +/* harmony import */ var _dashboards__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./dashboards */ "./entities/dashboards.js"); +/* harmony import */ var _database_candidates__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./database-candidates */ "./entities/database-candidates.js"); +/* harmony import */ var _pulses__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./pulses */ "./entities/pulses.js"); +/* harmony import */ var _questions__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./questions */ "./entities/questions.js"); +/* harmony import */ var _revisions__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./revisions */ "./entities/revisions.js"); +/* harmony import */ var _databases__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./databases */ "./entities/databases.js"); +/* harmony import */ var _schemas__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./schemas */ "./entities/schemas.js"); +/* harmony import */ var _tables__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./tables */ "./entities/tables.js"); +/* harmony import */ var _fields__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./fields */ "./entities/fields.js"); +/* harmony import */ var _metrics__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./metrics */ "./entities/metrics.js"); +/* harmony import */ var _segments__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./segments */ "./entities/segments.js"); +/* harmony import */ var _tasks__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./tasks */ "./entities/tasks.js"); +/* harmony import */ var _loginHistory__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./loginHistory */ "./entities/loginHistory.js"); +/* harmony import */ var _users__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./users */ "./entities/users.js"); +/* harmony import */ var _groups__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./groups */ "./entities/groups.js"); +/* harmony import */ var _search__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./search */ "./entities/search.js"); +/* harmony import */ var _recents__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./recents */ "./entities/recents.js"); +/* harmony import */ var _snippets__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./snippets */ "./entities/snippets.js"); + + + + + + + + + + + + + + + + + + + + + + +/***/ }), + +/***/ "./entities/loginHistory.js": +/*!**********************************!*\ + !*** ./entities/loginHistory.js ***! + \**********************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var metabase_schema__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! metabase/schema */ "./schema.js"); +/* harmony import */ var metabase_lib_entities__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/lib/entities */ "./lib/entities.js"); + + +var LoginHistory = (0,metabase_lib_entities__WEBPACK_IMPORTED_MODULE_1__.createEntity)({ + name: "loginHistory", + path: "/api/login-history/current", + schema: metabase_schema__WEBPACK_IMPORTED_MODULE_0__.LoginHistorySchema +}); +/* harmony default export */ __webpack_exports__["default"] = (LoginHistory); + +/***/ }), + +/***/ "./entities/metrics.js": +/*!*****************************!*\ + !*** ./entities/metrics.js ***! + \*****************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var metabase_lib_entities__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! metabase/lib/entities */ "./lib/entities.js"); +/* harmony import */ var metabase_schema__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/schema */ "./schema.js"); +/* harmony import */ var metabase_lib_colors__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/lib/colors */ "./lib/colors.ts"); +/* harmony import */ var metabase_lib_urls__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/lib/urls */ "./lib/urls.js"); +/* harmony import */ var metabase_selectors_metadata__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! metabase/selectors/metadata */ "./selectors/metadata.js"); + + + + + +var Metrics = (0,metabase_lib_entities__WEBPACK_IMPORTED_MODULE_0__.createEntity)({ + name: "metrics", + nameOne: "metric", + path: "/api/metric", + schema: metabase_schema__WEBPACK_IMPORTED_MODULE_1__.MetricSchema, + objectActions: { + setArchived: function setArchived(_ref, archived) { + var id = _ref.id; + + var _ref2 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}, + _ref2$revision_messag = _ref2.revision_message, + revision_message = _ref2$revision_messag === void 0 ? archived ? "(Archive)" : "(Unarchive)" : _ref2$revision_messag; + + return Metrics.actions.update({ + id: id + }, { + archived: archived, + revision_message: revision_message + }); + }, + // NOTE: DELETE not currently implemented + delete: null + }, + objectSelectors: { + getName: function getName(metric) { + return metric && metric.name; + }, + getUrl: function getUrl(metric) { + return metabase_lib_urls__WEBPACK_IMPORTED_MODULE_3__.tableRowsQuery(metric.database_id, metric.table_id, metric.id); + }, + getColor: function getColor(metric) { + return (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_2__.color)("accent1"); + }, + getIcon: function getIcon(metric) { + return { + name: "sum" + }; + } + }, + selectors: { + getObject: function getObject(state, _ref3) { + var entityId = _ref3.entityId; + return (0,metabase_selectors_metadata__WEBPACK_IMPORTED_MODULE_4__.getMetadata)(state).metric(entityId); + } + }, + form: { + fields: [{ + name: "name" + }, { + name: "description", + type: "text" + }] + } +}); +/* harmony default export */ __webpack_exports__["default"] = (Metrics); + +/***/ }), + +/***/ "./entities/pulses.js": +/*!****************************!*\ + !*** ./entities/pulses.js ***! + \****************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "UNSUBSCRIBE": function() { return /* binding */ UNSUBSCRIBE; } +/* harmony export */ }); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var metabase_lib_entities__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/lib/entities */ "./lib/entities.js"); +/* harmony import */ var metabase_lib_urls__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/lib/urls */ "./lib/urls.js"); +/* harmony import */ var metabase_lib_colors__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/lib/colors */ "./lib/colors.ts"); +/* harmony import */ var metabase_services__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! metabase/services */ "./services.js"); +/* harmony import */ var metabase_redux_undo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! metabase/redux/undo */ "./redux/undo.js"); +/* harmony import */ var metabase_entities_collections__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! metabase/entities/collections */ "./entities/collections.js"); +var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8; + +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } + +function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } + +function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } + +function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } + +function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + + + + + + + + +var UNSUBSCRIBE = "metabase/entities/pulses/unsubscribe"; +var Pulses = (0,metabase_lib_entities__WEBPACK_IMPORTED_MODULE_1__.createEntity)({ + name: "pulses", + nameOne: "pulse", + path: "/api/pulse", + actionTypes: { + UNSUBSCRIBE: UNSUBSCRIBE + }, + objectActions: { + setArchived: function setArchived(_ref, archived, opts) { + var id = _ref.id; + return Pulses.actions.update({ + id: id + }, { + archived: archived + }, (0,metabase_lib_entities__WEBPACK_IMPORTED_MODULE_1__.undo)(opts, (0,ttag__WEBPACK_IMPORTED_MODULE_0__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["subscription"]))), archived ? (0,ttag__WEBPACK_IMPORTED_MODULE_0__.t)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["deleted"]))) : (0,ttag__WEBPACK_IMPORTED_MODULE_0__.t)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["restored"]))))); + }, + setChannels: function setChannels(_ref2, channels, opts) { + var id = _ref2.id; + return Pulses.actions.update({ + id: id + }, { + channels: channels + }, (0,metabase_lib_entities__WEBPACK_IMPORTED_MODULE_1__.undo)(opts, (0,ttag__WEBPACK_IMPORTED_MODULE_0__.t)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["subscription"]))), (0,ttag__WEBPACK_IMPORTED_MODULE_0__.t)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["updated"]))))); + }, + setCollection: function setCollection(_ref3, collection, opts) { + var id = _ref3.id; + return Pulses.actions.update({ + id: id + }, { + collection_id: (0,metabase_entities_collections__WEBPACK_IMPORTED_MODULE_6__.canonicalCollectionId)(collection && collection.id) + }, (0,metabase_lib_entities__WEBPACK_IMPORTED_MODULE_1__.undo)(opts, (0,ttag__WEBPACK_IMPORTED_MODULE_0__.t)(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["subscription"]))), (0,ttag__WEBPACK_IMPORTED_MODULE_0__.t)(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["moved"]))))); + }, + setPinned: function setPinned(_ref4, pinned, opts) { + var id = _ref4.id; + return Pulses.actions.update({ + id: id + }, { + collection_position: typeof pinned === "number" ? pinned : pinned ? 1 : null + }, opts); + }, + unsubscribe: function unsubscribe(_ref5) { + var id = _ref5.id; + return /*#__PURE__*/function () { + var _ref6 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(dispatch) { + return regeneratorRuntime.wrap(function _callee$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + _context.next = 2; + return metabase_services__WEBPACK_IMPORTED_MODULE_4__.PulseApi.unsubscribe({ + id: id + }); + + case 2: + dispatch((0,metabase_redux_undo__WEBPACK_IMPORTED_MODULE_5__.addUndo)({ + message: (0,ttag__WEBPACK_IMPORTED_MODULE_0__.t)(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["Successfully unsubscribed"]))) + })); + dispatch({ + type: UNSUBSCRIBE, + payload: { + id: id + } + }); + dispatch({ + type: Pulses.actionTypes.INVALIDATE_LISTS_ACTION + }); + + case 5: + case "end": + return _context.stop(); + } + } + }, _callee); + })); + + return function (_x) { + return _ref6.apply(this, arguments); + }; + }(); + } + }, + objectSelectors: { + getName: function getName(pulse) { + return pulse && pulse.name; + }, + getUrl: function getUrl(pulse) { + return pulse && metabase_lib_urls__WEBPACK_IMPORTED_MODULE_2__.pulse(pulse.id); + }, + getIcon: function getIcon(pulse) { + return { + name: "pulse" + }; + }, + getColor: function getColor(pulse) { + return (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_3__.color)("pulse"); + } + }, + form: { + fields: [{ + name: "name" + }, { + name: "collection_id", + title: "Collection", + type: "collection" + }] + }, + getAnalyticsMetadata: function getAnalyticsMetadata(_ref7, _ref8, getState) { + var _ref9 = _slicedToArray(_ref7, 1), + object = _ref9[0]; + + var action = _ref8.action; + var type = object && (0,metabase_entities_collections__WEBPACK_IMPORTED_MODULE_6__.getCollectionType)(object.collection_id, getState()); + return type && "collection=".concat(type); + } +}); +/* harmony default export */ __webpack_exports__["default"] = (Pulses); + +/***/ }), + +/***/ "./entities/questions.js": +/*!*******************************!*\ + !*** ./entities/questions.js ***! + \*******************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var icepick__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! icepick */ "../../../node_modules/icepick/icepick.min.js"); +/* harmony import */ var icepick__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(icepick__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var metabase_lib_entities__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/lib/entities */ "./lib/entities.js"); +/* harmony import */ var metabase_lib_urls__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/lib/urls */ "./lib/urls.js"); +/* harmony import */ var metabase_lib_colors__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/lib/colors */ "./lib/colors.ts"); +/* harmony import */ var metabase_entities_collections__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! metabase/entities/collections */ "./entities/collections.js"); +/* harmony import */ var metabase_lib_api__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! metabase/lib/api */ "./lib/api.js"); +/* harmony import */ var _questions_forms__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./questions/forms */ "./entities/questions/forms.js"); +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } + +function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } + +function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } + +function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } + +function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } + + + + + + + + +var FAVORITE_ACTION = "metabase/entities/questions/FAVORITE"; +var UNFAVORITE_ACTION = "metabase/entities/questions/UNFAVORITE"; +var Questions = (0,metabase_lib_entities__WEBPACK_IMPORTED_MODULE_1__.createEntity)({ + name: "questions", + nameOne: "question", + path: "/api/card", + api: { + favorite: (0,metabase_lib_api__WEBPACK_IMPORTED_MODULE_5__.POST)("/api/card/:id/favorite"), + unfavorite: (0,metabase_lib_api__WEBPACK_IMPORTED_MODULE_5__.DELETE)("/api/card/:id/favorite") + }, + objectActions: { + setArchived: function setArchived(_ref, archived, opts) { + var id = _ref.id; + return Questions.actions.update({ + id: id + }, { + archived: archived + }, (0,metabase_lib_entities__WEBPACK_IMPORTED_MODULE_1__.undo)(opts, "question", archived ? "archived" : "unarchived")); + }, + setCollection: function setCollection(_ref2, collection, opts) { + var id = _ref2.id; + return Questions.actions.update({ + id: id + }, { + collection_id: (0,metabase_entities_collections__WEBPACK_IMPORTED_MODULE_4__.canonicalCollectionId)(collection && collection.id) + }, (0,metabase_lib_entities__WEBPACK_IMPORTED_MODULE_1__.undo)(opts, "question", "moved")); + }, + setPinned: function setPinned(_ref3, pinned, opts) { + var id = _ref3.id; + return Questions.actions.update({ + id: id + }, { + collection_position: typeof pinned === "number" ? pinned : pinned ? 1 : null + }, opts); + }, + setFavorited: function () { + var _setFavorited = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(_ref4, favorite) { + var id; + return regeneratorRuntime.wrap(function _callee$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + id = _ref4.id; + + if (!favorite) { + _context.next = 7; + break; + } + + _context.next = 4; + return Questions.api.favorite({ + id: id + }); + + case 4: + return _context.abrupt("return", { + type: FAVORITE_ACTION, + payload: id + }); + + case 7: + _context.next = 9; + return Questions.api.unfavorite({ + id: id + }); + + case 9: + return _context.abrupt("return", { + type: UNFAVORITE_ACTION, + payload: id + }); + + case 10: + case "end": + return _context.stop(); + } + } + }, _callee); + })); + + function setFavorited(_x, _x2) { + return _setFavorited.apply(this, arguments); + } + + return setFavorited; + }() + }, + objectSelectors: { + getName: function getName(question) { + return question && question.name; + }, + getUrl: function getUrl(question) { + return question && metabase_lib_urls__WEBPACK_IMPORTED_MODULE_2__.question(question); + }, + getColor: function getColor() { + return (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_3__.color)("text-medium"); + }, + getCollection: function getCollection(question) { + return question && (0,metabase_entities_collections__WEBPACK_IMPORTED_MODULE_4__.normalizedCollection)(question.collection); + }, + getIcon: getIcon + }, + reducer: function reducer() { + var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + + var _ref5 = arguments.length > 1 ? arguments[1] : undefined, + type = _ref5.type, + payload = _ref5.payload, + error = _ref5.error; + + if (type === FAVORITE_ACTION && !error) { + return (0,icepick__WEBPACK_IMPORTED_MODULE_0__.assocIn)(state, [payload, "favorite"], true); + } else if (type === UNFAVORITE_ACTION && !error) { + return (0,icepick__WEBPACK_IMPORTED_MODULE_0__.assocIn)(state, [payload, "favorite"], false); + } + + return state; + }, + // NOTE: keep in sync with src/metabase/api/card.clj + writableProperties: ["name", "cache_ttl", "dataset", "dataset_query", "display", "description", "visualization_settings", "archived", "enable_embedding", "embedding_params", "collection_id", "collection_position", "result_metadata", "metadata_checksum"], + getAnalyticsMetadata: function getAnalyticsMetadata(_ref6, _ref7, getState) { + var _ref8 = _slicedToArray(_ref6, 1), + object = _ref8[0]; + + var action = _ref7.action; + var type = object && (0,metabase_entities_collections__WEBPACK_IMPORTED_MODULE_4__.getCollectionType)(object.collection_id, getState()); + return type && "collection=".concat(type); + }, + forms: _questions_forms__WEBPACK_IMPORTED_MODULE_6__.default +}); + +function getIcon(question) { + var _visualization$iconNa; + + if (question.dataset || question.model === "dataset") { + return { + name: "dataset" + }; + } + + var visualization = __webpack_require__(/*! metabase/visualizations */ "./visualizations/index.js").default.get(question.display); + + return { + name: (_visualization$iconNa = visualization === null || visualization === void 0 ? void 0 : visualization.iconName) !== null && _visualization$iconNa !== void 0 ? _visualization$iconNa : "beaker" + }; +} + +/* harmony default export */ __webpack_exports__["default"] = (Questions); + +/***/ }), + +/***/ "./entities/questions/forms.js": +/*!*************************************!*\ + !*** ./entities/questions/forms.js ***! + \*************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var metabase_lib_settings__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/lib/settings */ "./lib/settings.ts"); +/* harmony import */ var metabase_plugins__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/plugins */ "./plugins/index.js"); +var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5; + +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + + + + +var FORM_FIELDS = [{ + name: "name", + title: (0,ttag__WEBPACK_IMPORTED_MODULE_0__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["Name"]))) +}, { + name: "description", + title: (0,ttag__WEBPACK_IMPORTED_MODULE_0__.t)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["Description"]))), + type: "text", + placeholder: (0,ttag__WEBPACK_IMPORTED_MODULE_0__.t)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["It's optional but oh, so helpful"]))) +}]; +/* harmony default export */ __webpack_exports__["default"] = ({ + create: { + fields: [].concat(FORM_FIELDS, [{ + name: "collection_id", + title: (0,ttag__WEBPACK_IMPORTED_MODULE_0__.t)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["Collection"]))), + type: "collection" + }]) + }, + edit: { + fields: function fields() { + var fields = [].concat(FORM_FIELDS); + + if (metabase_lib_settings__WEBPACK_IMPORTED_MODULE_1__.default.get("enable-query-caching") && metabase_plugins__WEBPACK_IMPORTED_MODULE_2__.PLUGIN_CACHING.cacheTTLFormField) { + fields.push(_objectSpread(_objectSpread({}, metabase_plugins__WEBPACK_IMPORTED_MODULE_2__.PLUGIN_CACHING.cacheTTLFormField), {}, { + title: (0,ttag__WEBPACK_IMPORTED_MODULE_0__.t)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["Caching"]))), + type: "questionCacheTTL" + })); + } + + return fields; + } + } +}); + +/***/ }), + +/***/ "./entities/recents.js": +/*!*****************************!*\ + !*** ./entities/recents.js ***! + \*****************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var metabase_lib_entities__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! metabase/lib/entities */ "./lib/entities.js"); +/* harmony import */ var metabase_lib_schema__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/lib/schema */ "./lib/schema/index.js"); +/* harmony import */ var metabase_schema__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/schema */ "./schema.js"); +/* provided dependency */ var console = __webpack_require__(/*! console-browserify */ "../../../node_modules/console-browserify/index.js"); + + + +var Recents = (0,metabase_lib_entities__WEBPACK_IMPORTED_MODULE_0__.createEntity)({ + name: "recents", + nameOne: "recent", + path: "/api/activity/recent_views", + schema: metabase_schema__WEBPACK_IMPORTED_MODULE_2__.RecentsSchema, + // delegate to the actual object's entity wrapEntity + wrapEntity: function wrapEntity(object) { + var dispatch = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; + + var entities = __webpack_require__(/*! metabase/entities */ "./entities/index.js"); + + var entity = entities[(0,metabase_lib_schema__WEBPACK_IMPORTED_MODULE_1__.entityTypeForObject)(object)]; + + if (entity) { + return entity.wrapEntity(object, dispatch); + } else { + console.warn("Couldn't find entity for object", object); + return object; + } + } +}); +/* harmony default export */ __webpack_exports__["default"] = (Recents); + +/***/ }), + +/***/ "./entities/revisions.js": +/*!*******************************!*\ + !*** ./entities/revisions.js ***! + \*******************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var metabase_lib_entities__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! metabase/lib/entities */ "./lib/entities.js"); +/* harmony import */ var metabase_lib_api__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/lib/api */ "./lib/api.js"); +function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + + + +var listRevisions = (0,metabase_lib_api__WEBPACK_IMPORTED_MODULE_1__.GET)("/api/revision"); +var ASSOCIATED_ENTITY_TYPES = ["questions", "dashboards"]; +var Revision = (0,metabase_lib_entities__WEBPACK_IMPORTED_MODULE_0__.createEntity)({ + name: "revisions", + api: { + list: function list(_ref, options) { + var model_type = _ref.model_type, + model_id = _ref.model_id; + return (// add model_type and model_id to each object since they are required for revert + listRevisions({ + entity: model_type, + id: model_id + }).then(function (revisions) { + return revisions.map(function (revision) { + return _objectSpread({ + model_type: model_type, + model_id: model_id + }, revision); + }); + }) + ); + }, + revert: (0,metabase_lib_api__WEBPACK_IMPORTED_MODULE_1__.POST)("/api/revision/revert") + }, + objectActions: { + // use thunk since we don't actually want to dispatch an action + revert: function revert(revision) { + return function (dispatch, getState) { + return Revision.api.revert({ + entity: revision.model_type, + id: revision.model_id, + revision_id: revision.id + }); + }; + } + }, + actionShouldInvalidateLists: function actionShouldInvalidateLists(action) { + var entities = __webpack_require__(/*! metabase/entities */ "./entities/index.js"); + + var _iterator = _createForOfIteratorHelper(ASSOCIATED_ENTITY_TYPES), + _step; + + try { + for (_iterator.s(); !(_step = _iterator.n()).done;) { + var type = _step.value; + + if (entities[type].actionShouldInvalidateLists(action)) { + return true; + } + } + } catch (err) { + _iterator.e(err); + } finally { + _iterator.f(); + } + + return action.type === this.actionTypes.INVALIDATE_LISTS_ACTION; + } +}); +/* harmony default export */ __webpack_exports__["default"] = (Revision); + +/***/ }), + +/***/ "./entities/schemas.js": +/*!*****************************!*\ + !*** ./entities/schemas.js ***! + \*****************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var icepick__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! icepick */ "../../../node_modules/icepick/icepick.min.js"); +/* harmony import */ var icepick__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(icepick__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var metabase_lib_entities__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/lib/entities */ "./lib/entities.js"); +/* harmony import */ var metabase_lib_api__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/lib/api */ "./lib/api.js"); +/* harmony import */ var metabase_lib_saved_questions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/lib/saved-questions */ "./lib/saved-questions/index.js"); +/* harmony import */ var metabase_lib_schema__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! metabase/lib/schema */ "./lib/schema/index.js"); +/* harmony import */ var metabase_schema__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! metabase/schema */ "./schema.js"); +/* harmony import */ var metabase_entities_questions__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! metabase/entities/questions */ "./entities/questions.js"); +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } + +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } + +function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } + +function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } + +function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } + +function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } + + + + + + + + // This is a weird entity because we don't have actual schema objects + +var listDatabaseSchemas = (0,metabase_lib_api__WEBPACK_IMPORTED_MODULE_2__.GET)("/api/database/:dbId/schemas"); +var getSchemaTables = (0,metabase_lib_api__WEBPACK_IMPORTED_MODULE_2__.GET)("/api/database/:dbId/schema/:schemaName"); +var getVirtualDatasetTables = (0,metabase_lib_api__WEBPACK_IMPORTED_MODULE_2__.GET)("/api/database/:dbId/datasets/:schemaName"); +/* harmony default export */ __webpack_exports__["default"] = ((0,metabase_lib_entities__WEBPACK_IMPORTED_MODULE_1__.createEntity)({ + name: "schemas", + schema: metabase_schema__WEBPACK_IMPORTED_MODULE_5__.SchemaSchema, + api: { + list: function () { + var _list = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(_ref) { + var dbId, schemaNames; + return regeneratorRuntime.wrap(function _callee$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + dbId = _ref.dbId; + + if (dbId) { + _context.next = 3; + break; + } + + throw new Error("Schemas can only be listed for a particular dbId"); + + case 3: + _context.next = 5; + return listDatabaseSchemas({ + dbId: dbId + }); + + case 5: + schemaNames = _context.sent; + return _context.abrupt("return", schemaNames.map(function (schemaName) { + return { + // NOTE: needs unqiue IDs for entities to work correctly + id: (0,metabase_lib_schema__WEBPACK_IMPORTED_MODULE_4__.generateSchemaId)(dbId, schemaName), + name: schemaName, + database: { + id: dbId + } + }; + })); + + case 7: + case "end": + return _context.stop(); + } + } + }, _callee); + })); + + function list(_x) { + return _list.apply(this, arguments); + } + + return list; + }(), + get: function () { + var _get = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(_ref2) { + var id, _parseSchemaId, _parseSchemaId2, dbId, schemaName, opts, tables; + + return regeneratorRuntime.wrap(function _callee2$(_context2) { + while (1) { + switch (_context2.prev = _context2.next) { + case 0: + id = _ref2.id; + _parseSchemaId = (0,metabase_lib_schema__WEBPACK_IMPORTED_MODULE_4__.parseSchemaId)(id), _parseSchemaId2 = _slicedToArray(_parseSchemaId, 3), dbId = _parseSchemaId2[0], schemaName = _parseSchemaId2[1], opts = _parseSchemaId2[2]; + + if (!(!dbId || schemaName === undefined)) { + _context2.next = 4; + break; + } + + throw new Error("Schemas ID is of the form dbId:schemaName"); + + case 4: + if (!(opts !== null && opts !== void 0 && opts.isDatasets)) { + _context2.next = 10; + break; + } + + _context2.next = 7; + return getVirtualDatasetTables({ + dbId: dbId, + schemaName: schemaName + }); + + case 7: + _context2.t0 = _context2.sent; + _context2.next = 13; + break; + + case 10: + _context2.next = 12; + return getSchemaTables({ + dbId: dbId, + schemaName: schemaName + }); + + case 12: + _context2.t0 = _context2.sent; + + case 13: + tables = _context2.t0; + return _context2.abrupt("return", { + id: id, + name: schemaName, + tables: tables, + database: { + id: dbId + } + }); + + case 15: + case "end": + return _context2.stop(); + } + } + }, _callee2); + })); + + function get(_x2) { + return _get.apply(this, arguments); + } + + return get; + }() + }, + reducer: function reducer() { + var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + + var _ref3 = arguments.length > 1 ? arguments[1] : undefined, + type = _ref3.type, + payload = _ref3.payload; + + if (type === metabase_entities_questions__WEBPACK_IMPORTED_MODULE_6__.default.actionTypes.CREATE) { + var question = payload.question; + var schema = (0,metabase_lib_saved_questions__WEBPACK_IMPORTED_MODULE_3__.getCollectionVirtualSchemaId)(question.collection); + + if (!state[schema]) { + return state; + } + + var virtualQuestionId = (0,metabase_lib_saved_questions__WEBPACK_IMPORTED_MODULE_3__.getQuestionVirtualTableId)(question); + return (0,icepick__WEBPACK_IMPORTED_MODULE_0__.updateIn)(state, [schema, "tables"], function (tables) { + return addTableAvoidingDuplicates(tables, virtualQuestionId); + }); + } + + if (type === metabase_entities_questions__WEBPACK_IMPORTED_MODULE_6__.default.actionTypes.UPDATE) { + var _question = payload.question; + + var _schema = (0,metabase_lib_saved_questions__WEBPACK_IMPORTED_MODULE_3__.getCollectionVirtualSchemaId)(_question.collection); + + if (!state[_schema]) { + return state; + } + + var _virtualQuestionId = (0,metabase_lib_saved_questions__WEBPACK_IMPORTED_MODULE_3__.getQuestionVirtualTableId)(_question); + + return (0,icepick__WEBPACK_IMPORTED_MODULE_0__.updateIn)(state, [_schema, "tables"], function (tables) { + if (_question.archived) { + return tables.filter(function (id) { + return id !== _virtualQuestionId; + }); + } + + return addTableAvoidingDuplicates(tables, _virtualQuestionId); + }); + } + + return state; + } +})); + +function addTableAvoidingDuplicates(tables, tableId) { + if (!Array.isArray(tables)) { + return [tableId]; + } + + return tables.includes(tableId) ? tables : [].concat(_toConsumableArray(tables), [tableId]); +} + +/***/ }), + +/***/ "./entities/search.js": +/*!****************************!*\ + !*** ./entities/search.js ***! + \****************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var metabase_lib_entities__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! metabase/lib/entities */ "./lib/entities.js"); +/* harmony import */ var metabase_lib_api__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/lib/api */ "./lib/api.js"); +/* harmony import */ var metabase_lib_schema__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/lib/schema */ "./lib/schema/index.js"); +/* harmony import */ var metabase_schema__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/schema */ "./schema.js"); +/* harmony import */ var metabase_entities_collections__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! metabase/entities/collections */ "./entities/collections.js"); +/* provided dependency */ var console = __webpack_require__(/*! console-browserify */ "../../../node_modules/console-browserify/index.js"); +var _excluded = ["collection", "archived", "models", "namespace", "pinned_state", "limit", "offset", "sort_column", "sort_direction"], + _excluded2 = ["data"]; + +function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } + +function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } + +function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } + +function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } + + + + + + +var ENTITIES_TYPES = Object.keys(metabase_schema__WEBPACK_IMPORTED_MODULE_3__.ENTITIES_SCHEMA_MAP); +var searchList = (0,metabase_lib_api__WEBPACK_IMPORTED_MODULE_1__.GET)("/api/search"); +var collectionList = (0,metabase_lib_api__WEBPACK_IMPORTED_MODULE_1__.GET)("/api/collection/:collection/items"); +/* harmony default export */ __webpack_exports__["default"] = ((0,metabase_lib_entities__WEBPACK_IMPORTED_MODULE_0__.createEntity)({ + name: "search", + path: "/api/search", + api: { + list: function () { + var _list = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() { + var query, + collection, + archived, + models, + namespace, + pinned_state, + limit, + offset, + sort_column, + sort_direction, + unsupported, + _yield$collectionList, + data, + rest, + _args = arguments; + + return regeneratorRuntime.wrap(function _callee$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + query = _args.length > 0 && _args[0] !== undefined ? _args[0] : {}; + + if (!query.collection) { + _context.next = 13; + break; + } + + collection = query.collection, archived = query.archived, models = query.models, namespace = query.namespace, pinned_state = query.pinned_state, limit = query.limit, offset = query.offset, sort_column = query.sort_column, sort_direction = query.sort_direction, unsupported = _objectWithoutProperties(query, _excluded); + + if (!(Object.keys(unsupported).length > 0)) { + _context.next = 5; + break; + } + + throw new Error("search with `collection` filter does not support these filters: " + Object.keys(unsupported).join(", ")); + + case 5: + _context.next = 7; + return collectionList({ + collection: collection, + archived: archived, + models: models, + namespace: namespace, + pinned_state: pinned_state, + limit: limit, + offset: offset, + sort_column: sort_column, + sort_direction: sort_direction + }); + + case 7: + _yield$collectionList = _context.sent; + data = _yield$collectionList.data; + rest = _objectWithoutProperties(_yield$collectionList, _excluded2); + return _context.abrupt("return", _objectSpread(_objectSpread({}, rest), {}, { + data: data ? data.map(function (item) { + return _objectSpread({ + collection_id: (0,metabase_entities_collections__WEBPACK_IMPORTED_MODULE_4__.canonicalCollectionId)(collection), + archived: archived || false + }, item); + }) : [] + })); + + case 13: + return _context.abrupt("return", searchList(query)); + + case 14: + case "end": + return _context.stop(); + } + } + }, _callee); + })); + + function list() { + return _list.apply(this, arguments); + } + + return list; + }() + }, + schema: metabase_schema__WEBPACK_IMPORTED_MODULE_3__.ObjectUnionSchema, + // delegate to the actual object's entity wrapEntity + wrapEntity: function wrapEntity(object) { + var dispatch = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; + + var entities = __webpack_require__(/*! metabase/entities */ "./entities/index.js"); + + var entity = entities[(0,metabase_lib_schema__WEBPACK_IMPORTED_MODULE_2__.entityTypeForObject)(object)]; + + if (entity) { + return entity.wrapEntity(object, dispatch); + } else { + console.warn("Couldn't find entity for object", object); + return object; + } + }, + // delegate to each entity's actionShouldInvalidateLists + actionShouldInvalidateLists: function actionShouldInvalidateLists(action) { + var entities = __webpack_require__(/*! metabase/entities */ "./entities/index.js"); + + var _iterator = _createForOfIteratorHelper(ENTITIES_TYPES), + _step; + + try { + for (_iterator.s(); !(_step = _iterator.n()).done;) { + var type = _step.value; + + if (entities[type].actionShouldInvalidateLists(action)) { + return true; + } + } + } catch (err) { + _iterator.e(err); + } finally { + _iterator.f(); + } + + return false; + } +})); + +/***/ }), + +/***/ "./entities/segments.js": +/*!******************************!*\ + !*** ./entities/segments.js ***! + \******************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var metabase_lib_entities__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! metabase/lib/entities */ "./lib/entities.js"); +/* harmony import */ var metabase_schema__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/schema */ "./schema.js"); +/* harmony import */ var metabase_lib_colors__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/lib/colors */ "./lib/colors.ts"); +/* harmony import */ var metabase_lib_urls__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/lib/urls */ "./lib/urls.js"); +/* harmony import */ var metabase_selectors_metadata__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! metabase/selectors/metadata */ "./selectors/metadata.js"); + + + + + +var Segments = (0,metabase_lib_entities__WEBPACK_IMPORTED_MODULE_0__.createEntity)({ + name: "segments", + nameOne: "segment", + path: "/api/segment", + schema: metabase_schema__WEBPACK_IMPORTED_MODULE_1__.SegmentSchema, + objectActions: { + setArchived: function setArchived(_ref, archived) { + var id = _ref.id; + + var _ref2 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}, + _ref2$revision_messag = _ref2.revision_message, + revision_message = _ref2$revision_messag === void 0 ? archived ? "(Archive)" : "(Unarchive)" : _ref2$revision_messag; + + return Segments.actions.update({ + id: id + }, { + archived: archived, + revision_message: revision_message + }); + }, + // NOTE: DELETE not currently implemented + delete: null + }, + selectors: { + getObject: function getObject(state, _ref3) { + var entityId = _ref3.entityId; + return (0,metabase_selectors_metadata__WEBPACK_IMPORTED_MODULE_4__.getMetadata)(state).segment(entityId); + } + }, + objectSelectors: { + getName: function getName(segment) { + return segment && segment.name; + }, + getUrl: function getUrl(segment) { + return metabase_lib_urls__WEBPACK_IMPORTED_MODULE_3__.tableRowsQuery(segment.database_id, segment.table_id, null, segment.id); + }, + getColor: function getColor(segment) { + return (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_2__.color)("accent7"); + }, + getIcon: function getIcon(segment) { + return { + name: "segment" + }; + } + }, + form: { + fields: [{ + name: "name" + }, { + name: "description", + type: "text" + }] + } +}); +/* harmony default export */ __webpack_exports__["default"] = (Segments); + +/***/ }), + +/***/ "./entities/snippet-collections.js": +/*!*****************************************!*\ + !*** ./entities/snippet-collections.js ***! + \*****************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! underscore */ "../../../node_modules/underscore/modules/index-all.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var reselect__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! reselect */ "../../../node_modules/reselect/lib/index.js"); +/* harmony import */ var metabase_lib_colors__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/lib/colors */ "./lib/colors.ts"); +/* harmony import */ var metabase_lib_entities__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! metabase/lib/entities */ "./lib/entities.js"); +/* harmony import */ var metabase_schema__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! metabase/schema */ "./schema.js"); +/* harmony import */ var metabase_entities_collections__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! metabase/entities/collections */ "./entities/collections.js"); +var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11; + +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } + +function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } + +function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + + + + + + + + +var SnippetCollections = (0,metabase_lib_entities__WEBPACK_IMPORTED_MODULE_4__.createEntity)({ + name: "snippetCollections", + schema: metabase_schema__WEBPACK_IMPORTED_MODULE_5__.SnippetCollectionSchema, + api: underscore__WEBPACK_IMPORTED_MODULE_0__.default.mapObject(metabase_entities_collections__WEBPACK_IMPORTED_MODULE_6__.default.api, function (f) { + return function (first) { + for (var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + rest[_key - 1] = arguments[_key]; + } + + return f.apply(void 0, [_objectSpread(_objectSpread({}, first), {}, { + namespace: "snippets" + })].concat(rest)); + }; + }), + displayNameOne: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["snippet collection"]))), + displayNameMany: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["snippet collections"]))), + objectActions: { + setArchived: function setArchived(_ref, archived, opts) { + var id = _ref.id; + return SnippetCollections.actions.update({ + id: id + }, { + archived: archived + }, (0,metabase_lib_entities__WEBPACK_IMPORTED_MODULE_4__.undo)(opts, "folder", archived ? "archived" : "unarchived")); + }, + setCollection: function setCollection(_ref2, collection, opts) { + var id = _ref2.id; + return SnippetCollections.actions.update({ + id: id + }, { + parent_id: (0,metabase_entities_collections__WEBPACK_IMPORTED_MODULE_6__.canonicalCollectionId)(collection && collection.id) + }, (0,metabase_lib_entities__WEBPACK_IMPORTED_MODULE_4__.undo)(opts, "folder", "moved")); + }, + // NOTE: DELETE not currently implemented + delete: null + }, + selectors: { + getExpandedCollectionsById: (0,reselect__WEBPACK_IMPORTED_MODULE_2__.createSelector)([function (state) { + return state.entities.snippetCollections; + }, function (state) { + var _ref3 = state.entities.snippetCollections_list[null] || {}, + list = _ref3.list; + + return list || []; + }], function (collections, collectionsIds) { + return (0,metabase_entities_collections__WEBPACK_IMPORTED_MODULE_6__.getExpandedCollectionsById)(collectionsIds.map(function (id) { + return collections[id]; + }), null); + }) + }, + createSelectors: function createSelectors(_ref4) { + var getObject = _ref4.getObject, + _getFetched = _ref4.getFetched; + return { + getFetched: function getFetched(state, props) { + return _getFetched(state, props) || getObject(state, props); + } + }; + }, + objectSelectors: { + getIcon: function getIcon(collection) { + return { + name: "folder" + }; + } + }, + form: { + fields: [{ + name: "name", + title: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["Give your folder a name"]))), + placeholder: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["Something short but sweet"]))), + validate: function validate(name) { + return !name && (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["Name is required"]))) || name && name.length > 100 && (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["Name must be 100 characters or less"]))); + } + }, { + name: "description", + title: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["Add a description"]))), + type: "text", + placeholder: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["It's optional but oh, so helpful"]))), + normalize: function normalize(description) { + return description || null; + } // expected to be nil or non-empty string + + }, { + name: "color", + title: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["Color"]))), + type: "hidden", + initial: function initial() { + return (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_3__.color)("brand"); + }, + validate: function validate(color) { + return !color && (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["Color is required"]))); + } + }, { + name: "parent_id", + title: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["Folder this should be in"]))), + type: "snippetCollection", + normalize: metabase_entities_collections__WEBPACK_IMPORTED_MODULE_6__.canonicalCollectionId + }] + }, + getAnalyticsMetadata: function getAnalyticsMetadata(_ref5, _ref6, getState) { + var _ref7 = _slicedToArray(_ref5, 1), + object = _ref7[0]; + + var action = _ref6.action; + return undefined; // TODO: is there anything informative to track here? + } +}); +/* harmony default export */ __webpack_exports__["default"] = (SnippetCollections); + +/***/ }), + +/***/ "./entities/snippets.js": +/*!******************************!*\ + !*** ./entities/snippets.js ***! + \******************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var metabase_lib_entities__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/lib/entities */ "./lib/entities.js"); +/* harmony import */ var metabase_lib_validate__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/lib/validate */ "./lib/validate.js"); +/* harmony import */ var metabase_entities_collections__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/entities/collections */ "./entities/collections.js"); +var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6; + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + + + + + +var formFields = [{ + name: "content", + title: (0,ttag__WEBPACK_IMPORTED_MODULE_0__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["Enter some SQL here so you can reuse it later"]))), + placeholder: "AND canceled_at IS null\nAND account_type = 'PAID'", + type: "text", + className: "Form-input full text-monospace text-normal text-small bg-light text-spaced", + rows: 4, + autoFocus: true, + validate: metabase_lib_validate__WEBPACK_IMPORTED_MODULE_2__.default.required().maxLength(10000) +}, { + name: "name", + title: (0,ttag__WEBPACK_IMPORTED_MODULE_0__.t)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["Give your snippet a name"]))), + placeholder: (0,ttag__WEBPACK_IMPORTED_MODULE_0__.t)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["Current Customers"]))), + validate: metabase_lib_validate__WEBPACK_IMPORTED_MODULE_2__.default.required().maxLength(100) +}, { + name: "description", + title: (0,ttag__WEBPACK_IMPORTED_MODULE_0__.t)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["Add a description"]))), + placeholder: (0,ttag__WEBPACK_IMPORTED_MODULE_0__.t)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["It's optional but oh, so helpful"]))), + validate: metabase_lib_validate__WEBPACK_IMPORTED_MODULE_2__.default.maxLength(500) +}]; +var Snippets = (0,metabase_lib_entities__WEBPACK_IMPORTED_MODULE_1__.createEntity)({ + name: "snippets", + nameOne: "snippet", + path: "/api/native-query-snippet", + createSelectors: function createSelectors(_ref) { + var getObject = _ref.getObject, + _getFetched = _ref.getFetched; + return { + getFetched: function getFetched(state, props) { + return _getFetched(state, props) || getObject(state, props); + } + }; + }, + forms: { + withoutVisibleCollectionPicker: { + fields: [].concat(formFields, [{ + name: "collection_id", + hidden: true + }]) + }, + withVisibleCollectionPicker: { + fields: [].concat(formFields, [{ + name: "collection_id", + title: (0,ttag__WEBPACK_IMPORTED_MODULE_0__.t)(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["Folder this should be in"]))), + type: "snippetCollection", + normalize: metabase_entities_collections__WEBPACK_IMPORTED_MODULE_3__.canonicalCollectionId + }]) + } + } +}); +/* harmony default export */ __webpack_exports__["default"] = (Snippets); + +/***/ }), + +/***/ "./entities/tables.js": +/*!****************************!*\ + !*** ./entities/tables.js ***! + \****************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "TABLES_BULK_UPDATE": function() { return /* binding */ TABLES_BULK_UPDATE; }, +/* harmony export */ "FETCH_METADATA": function() { return /* binding */ FETCH_METADATA; }, +/* harmony export */ "FETCH_TABLE_METADATA": function() { return /* binding */ FETCH_TABLE_METADATA; }, +/* harmony export */ "FETCH_TABLE_FOREIGN_KEYS": function() { return /* binding */ FETCH_TABLE_FOREIGN_KEYS; } +/* harmony export */ }); +/* harmony import */ var metabase_lib_entities__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! metabase/lib/entities */ "./lib/entities.js"); +/* harmony import */ var metabase_lib_redux__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/lib/redux */ "./lib/redux.js"); +/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! underscore */ "../../../node_modules/underscore/modules/index-all.js"); +/* harmony import */ var metabase_lib_urls__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/lib/urls */ "./lib/urls.js"); +/* harmony import */ var metabase_lib_colors__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! metabase/lib/colors */ "./lib/colors.ts"); +/* harmony import */ var reselect__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! reselect */ "../../../node_modules/reselect/lib/index.js"); +/* harmony import */ var metabase_services__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! metabase/services */ "./services.js"); +/* harmony import */ var metabase_schema__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! metabase/schema */ "./schema.js"); +/* harmony import */ var metabase_entities_metrics__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! metabase/entities/metrics */ "./entities/metrics.js"); +/* harmony import */ var metabase_entities_segments__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! metabase/entities/segments */ "./entities/segments.js"); +/* harmony import */ var metabase_entities_fields__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! metabase/entities/fields */ "./entities/fields.js"); +/* harmony import */ var metabase_entities_questions__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! metabase/entities/questions */ "./entities/questions.js"); +/* harmony import */ var metabase_lib_api__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! metabase/lib/api */ "./lib/api.js"); +/* harmony import */ var metabase_lib_saved_questions__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! metabase/lib/saved-questions */ "./lib/saved-questions/index.js"); +/* harmony import */ var metabase_selectors_metadata__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! metabase/selectors/metadata */ "./selectors/metadata.js"); +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } + +function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } + + + + + + + + + + + + + + + + +var listTables = (0,metabase_lib_api__WEBPACK_IMPORTED_MODULE_12__.GET)("/api/table"); + +var listTablesForDatabase = /*#__PURE__*/function () { + var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() { + var _args = arguments; + return regeneratorRuntime.wrap(function _callee$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + _context.next = 2; + return (0,metabase_lib_api__WEBPACK_IMPORTED_MODULE_12__.GET)("/api/database/:dbId/metadata").apply(void 0, _args); + + case 2: + return _context.abrupt("return", _context.sent.tables); + + case 3: + case "end": + return _context.stop(); + } + } + }, _callee); + })); + + return function listTablesForDatabase() { + return _ref.apply(this, arguments); + }; +}(); + +var listTablesForSchema = (0,metabase_lib_api__WEBPACK_IMPORTED_MODULE_12__.GET)("/api/database/:dbId/schema/:schemaName"); +var updateFieldOrder = (0,metabase_lib_api__WEBPACK_IMPORTED_MODULE_12__.PUT)("/api/table/:id/fields/order"); +var updateTables = (0,metabase_lib_api__WEBPACK_IMPORTED_MODULE_12__.PUT)("/api/table"); // OBJECT ACTIONS + +var TABLES_BULK_UPDATE = "metabase/entities/TABLES_BULK_UPDATE"; +var FETCH_METADATA = "metabase/entities/FETCH_METADATA"; +var FETCH_TABLE_METADATA = "metabase/entities/FETCH_TABLE_METADATA"; +var FETCH_TABLE_FOREIGN_KEYS = "metabase/entities/FETCH_TABLE_FOREIGN_KEYS"; +var UPDATE_TABLE_FIELD_ORDER = "metabase/entities/UPDATE_TABLE_FIELD_ORDER"; +var Tables = (0,metabase_lib_entities__WEBPACK_IMPORTED_MODULE_0__.createEntity)({ + name: "tables", + nameOne: "table", + path: "/api/table", + schema: metabase_schema__WEBPACK_IMPORTED_MODULE_7__.TableSchema, + api: { + list: function () { + var _list = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(params) { + var _len, + args, + _key, + _args2 = arguments; + + return regeneratorRuntime.wrap(function _callee2$(_context2) { + while (1) { + switch (_context2.prev = _context2.next) { + case 0: + for (_len = _args2.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = _args2[_key]; + } + + if (!(params.dbId && params.schemaName)) { + _context2.next = 5; + break; + } + + return _context2.abrupt("return", listTablesForSchema.apply(void 0, [params].concat(args))); + + case 5: + if (!params.dbId) { + _context2.next = 9; + break; + } + + return _context2.abrupt("return", listTablesForDatabase.apply(void 0, [params].concat(args))); + + case 9: + return _context2.abrupt("return", listTables.apply(void 0, [params].concat(args))); + + case 10: + case "end": + return _context2.stop(); + } + } + }, _callee2); + })); + + function list(_x) { + return _list.apply(this, arguments); + } + + return list; + }() + }, + actions: { + // updates all tables in the `ids` key + bulkUpdate: (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_1__.compose)((0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_1__.withAction)(TABLES_BULK_UPDATE), (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_1__.withNormalize)([metabase_schema__WEBPACK_IMPORTED_MODULE_7__.TableSchema]))(function (updates) { + return /*#__PURE__*/function () { + var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(dispatch, getState) { + return regeneratorRuntime.wrap(function _callee3$(_context3) { + while (1) { + switch (_context3.prev = _context3.next) { + case 0: + return _context3.abrupt("return", updateTables(updates)); + + case 1: + case "end": + return _context3.stop(); + } + } + }, _callee3); + })); + + return function (_x2, _x3) { + return _ref2.apply(this, arguments); + }; + }(); + }) + }, + // ACTION CREATORS + objectActions: { + // loads `query_metadata` for a single table + fetchMetadata: (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_1__.compose)((0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_1__.withAction)(FETCH_METADATA), (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_1__.withCachedDataAndRequestState)(function (_ref3) { + var id = _ref3.id; + return _toConsumableArray(Tables.getObjectStatePath(id)); + }, function (_ref4) { + var id = _ref4.id; + return [].concat(_toConsumableArray(Tables.getObjectStatePath(id)), ["fetchMetadata"]); + }), (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_1__.withNormalize)(metabase_schema__WEBPACK_IMPORTED_MODULE_7__.TableSchema))(function (_ref5) { + var id = _ref5.id; + var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + return function (dispatch, getState) { + return metabase_services__WEBPACK_IMPORTED_MODULE_6__.MetabaseApi.table_query_metadata(_objectSpread({ + tableId: id + }, options.params)); + }; + }), + // like fetchMetadata but also loads tables linked by foreign key + fetchMetadataAndForeignTables: (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_1__.createThunkAction)(FETCH_TABLE_METADATA, function (_ref6) { + var id = _ref6.id; + var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + return /*#__PURE__*/function () { + var _ref7 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(dispatch, getState) { + var table; + return regeneratorRuntime.wrap(function _callee4$(_context4) { + while (1) { + switch (_context4.prev = _context4.next) { + case 0: + _context4.next = 2; + return dispatch(Tables.actions.fetchMetadata({ + id: id + }, options)); + + case 2: + // fetch foreign key linked table's metadata as well + table = Tables.selectors[options.selectorName || "getObjectUnfiltered"](getState(), { + entityId: id + }); + _context4.next = 5; + return Promise.all(getTableForeignKeyTableIds(table).map(function (id) { + return dispatch(Tables.actions.fetchMetadata({ + id: id + }, options)); + })); + + case 5: + case "end": + return _context4.stop(); + } + } + }, _callee4); + })); + + return function (_x4, _x5) { + return _ref7.apply(this, arguments); + }; + }(); + }), + fetchForeignKeys: (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_1__.compose)((0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_1__.withAction)(FETCH_TABLE_FOREIGN_KEYS), (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_1__.withCachedDataAndRequestState)(function (_ref8) { + var id = _ref8.id; + return _toConsumableArray(Tables.getObjectStatePath(id)); + }, function (_ref9) { + var id = _ref9.id; + return [].concat(_toConsumableArray(Tables.getObjectStatePath(id)), ["fetchForeignKeys"]); + }), (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_1__.withNormalize)(metabase_schema__WEBPACK_IMPORTED_MODULE_7__.TableSchema))(function (entityObject) { + return /*#__PURE__*/function () { + var _ref10 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5(dispatch, getState) { + var fks; + return regeneratorRuntime.wrap(function _callee5$(_context5) { + while (1) { + switch (_context5.prev = _context5.next) { + case 0: + _context5.next = 2; + return metabase_services__WEBPACK_IMPORTED_MODULE_6__.MetabaseApi.table_fks({ + tableId: entityObject.id + }); + + case 2: + fks = _context5.sent; + return _context5.abrupt("return", { + id: entityObject.id, + fks: fks + }); + + case 4: + case "end": + return _context5.stop(); + } + } + }, _callee5); + })); + + return function (_x6, _x7) { + return _ref10.apply(this, arguments); + }; + }(); + }), + setFieldOrder: (0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_1__.compose)((0,metabase_lib_redux__WEBPACK_IMPORTED_MODULE_1__.withAction)(UPDATE_TABLE_FIELD_ORDER))(function (_ref11, fieldOrder) { + var id = _ref11.id; + return function (dispatch, getState) { + return updateFieldOrder({ + id: id, + fieldOrder: fieldOrder + }, { + bodyParamName: "fieldOrder" + }); + }; + }) + }, + // FORMS + form: { + fields: [{ + name: "name" + }, { + name: "description", + type: "text" + }] + }, + reducer: function reducer() { + var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + + var _ref12 = arguments.length > 1 ? arguments[1] : undefined, + type = _ref12.type, + payload = _ref12.payload, + error = _ref12.error; + + if (type === metabase_entities_questions__WEBPACK_IMPORTED_MODULE_11__.default.actionTypes.CREATE) { + var card = payload.question; + var virtualQuestionTable = (0,metabase_lib_saved_questions__WEBPACK_IMPORTED_MODULE_13__.convertSavedQuestionToVirtualTable)(card); + + if (state[virtualQuestionTable.id]) { + return state; + } + + return _objectSpread(_objectSpread({}, state), {}, _defineProperty({}, virtualQuestionTable.id, virtualQuestionTable)); + } + + if (type === metabase_entities_questions__WEBPACK_IMPORTED_MODULE_11__.default.actionTypes.UPDATE) { + var _card = payload.question; + var virtualQuestionId = (0,metabase_lib_saved_questions__WEBPACK_IMPORTED_MODULE_13__.getQuestionVirtualTableId)(_card); + + if (_card.archived && state[virtualQuestionId]) { + delete state[virtualQuestionId]; + return state; + } + + if (state[virtualQuestionId]) { + return state; + } + + return _objectSpread(_objectSpread({}, state), {}, _defineProperty({}, virtualQuestionId, (0,metabase_lib_saved_questions__WEBPACK_IMPORTED_MODULE_13__.convertSavedQuestionToVirtualTable)(_card))); + } + + if (type === metabase_entities_segments__WEBPACK_IMPORTED_MODULE_9__.default.actionTypes.CREATE) { + var _payload$segment = payload.segment, + tableId = _payload$segment.table_id, + segmentId = _payload$segment.id; + var table = state[tableId]; + + if (table) { + return _objectSpread(_objectSpread({}, state), {}, _defineProperty({}, tableId, _objectSpread(_objectSpread({}, table), {}, { + segments: [segmentId].concat(_toConsumableArray(table.segments)) + }))); + } + } + + if (type === metabase_entities_metrics__WEBPACK_IMPORTED_MODULE_8__.default.actionTypes.CREATE) { + var _payload$metric = payload.metric, + _tableId = _payload$metric.table_id, + metricId = _payload$metric.id; + var _table = state[_tableId]; + + if (_table) { + return _objectSpread(_objectSpread({}, state), {}, _defineProperty({}, _tableId, _objectSpread(_objectSpread({}, _table), {}, { + metrics: [metricId].concat(_toConsumableArray(_table.metrics)) + }))); + } + } + + if (type === metabase_entities_segments__WEBPACK_IMPORTED_MODULE_9__.default.actionTypes.UPDATE) { + var _payload$segment2 = payload.segment, + _tableId2 = _payload$segment2.table_id, + archived = _payload$segment2.archived, + _segmentId = _payload$segment2.id; + var _table2 = state[_tableId2]; + + if (archived && _table2 && _table2.segments) { + return _objectSpread(_objectSpread({}, state), {}, _defineProperty({}, _tableId2, _objectSpread(_objectSpread({}, _table2), {}, { + segments: _table2.segments.filter(function (id) { + return id !== _segmentId; + }) + }))); + } + } + + if (type === metabase_entities_metrics__WEBPACK_IMPORTED_MODULE_8__.default.actionTypes.UPDATE) { + var _payload$metric2 = payload.metric, + _tableId3 = _payload$metric2.table_id, + _archived = _payload$metric2.archived, + _metricId = _payload$metric2.id; + var _table3 = state[_tableId3]; + + if (_archived && _table3 && _table3.metrics) { + return _objectSpread(_objectSpread({}, state), {}, _defineProperty({}, _tableId3, _objectSpread(_objectSpread({}, _table3), {}, { + metrics: _table3.metrics.filter(function (id) { + return id !== _metricId; + }) + }))); + } + } + + return state; + }, + objectSelectors: { + getUrl: function getUrl(table) { + return metabase_lib_urls__WEBPACK_IMPORTED_MODULE_3__.tableRowsQuery(table.database_id, table.table_id, null); + }, + getIcon: function getIcon(table) { + return { + name: "table" + }; + }, + getColor: function getColor(table) { + return (0,metabase_lib_colors__WEBPACK_IMPORTED_MODULE_4__.color)("accent2"); + } + }, + selectors: { + getObject: function getObject(state, _ref13) { + var entityId = _ref13.entityId; + return (0,metabase_selectors_metadata__WEBPACK_IMPORTED_MODULE_14__.getMetadata)(state).table(entityId); + }, + // these unfiltered selectors include hidden tables/fields for display in the admin panel + getObjectUnfiltered: function getObjectUnfiltered(state, _ref14) { + var entityId = _ref14.entityId; + var table = state.entities.tables[entityId]; + return table && _objectSpread(_objectSpread({}, table), {}, { + fields: (table.fields || []).map(function (entityId) { + return metabase_entities_fields__WEBPACK_IMPORTED_MODULE_10__.default.selectors.getObjectUnfiltered(state, { + entityId: entityId + }); + }), + metrics: (table.metrics || []).map(function (id) { + return state.entities.metrics[id]; + }), + segments: (table.segments || []).map(function (id) { + return state.entities.segments[id]; + }) + }); + }, + getListUnfiltered: function getListUnfiltered(_ref15, _ref16) { + var entities = _ref15.entities; + var entityQuery = _ref16.entityQuery; + + var _ref17 = entities.tables_list[JSON.stringify(entityQuery)] || {}, + list = _ref17.list; + + return (list || []).map(function (id) { + return entities.tables[id]; + }); + }, + getTable: (0,reselect__WEBPACK_IMPORTED_MODULE_5__.createSelector)( // we wrap getMetadata to handle a circular dep issue + [function (state) { + return (0,metabase_selectors_metadata__WEBPACK_IMPORTED_MODULE_14__.getMetadata)(state); + }, function (state, props) { + return props.entityId; + }], function (metadata, id) { + return metadata.table(id); + }) + } +}); + +function getTableForeignKeyTableIds(table) { + return underscore__WEBPACK_IMPORTED_MODULE_2__.default.chain(table.fields).filter(function (field) { + return field.target; + }).map(function (field) { + return field.target.table_id; + }).uniq().value(); +} + +/* harmony default export */ __webpack_exports__["default"] = (Tables); + +/***/ }), + +/***/ "./entities/tasks.js": +/*!***************************!*\ + !*** ./entities/tasks.js ***! + \***************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var metabase_lib_entities__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! metabase/lib/entities */ "./lib/entities.js"); + +/* harmony default export */ __webpack_exports__["default"] = ((0,metabase_lib_entities__WEBPACK_IMPORTED_MODULE_0__.createEntity)({ + name: "tasks", + path: "/api/task" +})); + +/***/ }), + +/***/ "./entities/users.js": +/*!***************************!*\ + !*** ./entities/users.js ***! + \***************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "DEACTIVATE": function() { return /* binding */ DEACTIVATE; }, +/* harmony export */ "REACTIVATE": function() { return /* binding */ REACTIVATE; }, +/* harmony export */ "PASSWORD_RESET_EMAIL": function() { return /* binding */ PASSWORD_RESET_EMAIL; }, +/* harmony export */ "PASSWORD_RESET_MANUAL": function() { return /* binding */ PASSWORD_RESET_MANUAL; }, +/* harmony export */ "RESEND_INVITE": function() { return /* binding */ RESEND_INVITE; } +/* harmony export */ }); +/* harmony import */ var icepick__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! icepick */ "../../../node_modules/icepick/icepick.min.js"); +/* harmony import */ var icepick__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(icepick__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var metabase_lib_analytics__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/lib/analytics */ "./lib/analytics.js"); +/* harmony import */ var metabase_lib_settings__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/lib/settings */ "./lib/settings.ts"); +/* harmony import */ var metabase_lib_utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/lib/utils */ "./lib/utils.js"); +/* harmony import */ var metabase_lib_entities__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! metabase/lib/entities */ "./lib/entities.js"); +/* harmony import */ var metabase_services__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! metabase/services */ "./services.js"); +/* harmony import */ var _users_forms__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./users/forms */ "./entities/users/forms.js"); +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } + +function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } + + + + + + + + +var DEACTIVATE = "metabase/entities/users/DEACTIVATE"; +var REACTIVATE = "metabase/entities/users/REACTIVATE"; +var PASSWORD_RESET_EMAIL = "metabase/entities/users/PASSWORD_RESET_EMAIL"; +var PASSWORD_RESET_MANUAL = "metabase/entities/users/RESET_PASSWORD_MANUAL"; +var RESEND_INVITE = "metabase/entities/users/RESEND_INVITE"; // TODO: It'd be nice to import loadMemberships, but we need to resolve a circular dependency + +function loadMemberships() { + return __webpack_require__(/*! metabase/admin/people/people */ "./admin/people/people.js").loadMemberships(); +} + +var Users = (0,metabase_lib_entities__WEBPACK_IMPORTED_MODULE_4__.createEntity)({ + name: "users", + nameOne: "user", + path: "/api/user", + objectSelectors: { + getName: function getName(user) { + return user.common_name || "".concat(user.first_name, " ").concat(user.last_name); + } + }, + actionTypes: { + DEACTIVATE: DEACTIVATE, + REACTIVATE: REACTIVATE, + PASSWORD_RESET_EMAIL: PASSWORD_RESET_EMAIL, + PASSWORD_RESET_MANUAL: PASSWORD_RESET_MANUAL, + RESEND_INVITE: RESEND_INVITE + }, + actionDecorators: { + create: function create(thunkCreator) { + return function (user) { + return /*#__PURE__*/function () { + var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(dispatch, getState) { + var result; + return regeneratorRuntime.wrap(function _callee$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + if (!metabase_lib_settings__WEBPACK_IMPORTED_MODULE_2__.default.isEmailConfigured()) { + user = _objectSpread(_objectSpread({}, user), {}, { + password: metabase_lib_utils__WEBPACK_IMPORTED_MODULE_3__.default.generatePassword() + }); + } + + _context.next = 3; + return thunkCreator(user)(dispatch, getState); + + case 3: + result = _context.sent; + dispatch(loadMemberships()); + return _context.abrupt("return", _objectSpread({ + // HACK: include user ID and password for temporaryPasswords reducer + id: result.result, + password: user.password + }, result)); + + case 6: + case "end": + return _context.stop(); + } + } + }, _callee); + })); + + return function (_x, _x2) { + return _ref.apply(this, arguments); + }; + }(); + }; + }, + update: function update(thunkCreator) { + return function (user) { + return /*#__PURE__*/function () { + var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(dispatch, getState) { + var result; + return regeneratorRuntime.wrap(function _callee2$(_context2) { + while (1) { + switch (_context2.prev = _context2.next) { + case 0: + _context2.next = 2; + return thunkCreator(user)(dispatch, getState); + + case 2: + result = _context2.sent; + + if (user.group_ids) { + // group ids were just updated + dispatch(loadMemberships()); + } + + return _context2.abrupt("return", result); + + case 5: + case "end": + return _context2.stop(); + } + } + }, _callee2); + })); + + return function (_x3, _x4) { + return _ref2.apply(this, arguments); + }; + }(); + }; + } + }, + objectActions: { + resentInvite: function () { + var _resentInvite = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(_ref3) { + var id; + return regeneratorRuntime.wrap(function _callee3$(_context3) { + while (1) { + switch (_context3.prev = _context3.next) { + case 0: + id = _ref3.id; + metabase_lib_analytics__WEBPACK_IMPORTED_MODULE_1__.trackStructEvent("People Admin", "Resent Invite"); + _context3.next = 4; + return metabase_services__WEBPACK_IMPORTED_MODULE_5__.UserApi.send_invite({ + id: id + }); + + case 4: + return _context3.abrupt("return", { + type: RESEND_INVITE + }); + + case 5: + case "end": + return _context3.stop(); + } + } + }, _callee3); + })); + + function resentInvite(_x5) { + return _resentInvite.apply(this, arguments); + } + + return resentInvite; + }(), + passwordResetEmail: function () { + var _passwordResetEmail = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(_ref4) { + var email; + return regeneratorRuntime.wrap(function _callee4$(_context4) { + while (1) { + switch (_context4.prev = _context4.next) { + case 0: + email = _ref4.email; + metabase_lib_analytics__WEBPACK_IMPORTED_MODULE_1__.trackStructEvent("People Admin", "Trigger User Password Reset"); + _context4.next = 4; + return metabase_services__WEBPACK_IMPORTED_MODULE_5__.SessionApi.forgot_password({ + email: email + }); + + case 4: + return _context4.abrupt("return", { + type: PASSWORD_RESET_EMAIL + }); + + case 5: + case "end": + return _context4.stop(); + } + } + }, _callee4); + })); + + function passwordResetEmail(_x6) { + return _passwordResetEmail.apply(this, arguments); + } + + return passwordResetEmail; + }(), + passwordResetManual: function () { + var _passwordResetManual = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5(_ref5) { + var id, + password, + _args5 = arguments; + return regeneratorRuntime.wrap(function _callee5$(_context5) { + while (1) { + switch (_context5.prev = _context5.next) { + case 0: + id = _ref5.id; + password = _args5.length > 1 && _args5[1] !== undefined ? _args5[1] : metabase_lib_utils__WEBPACK_IMPORTED_MODULE_3__.default.generatePassword(); + metabase_lib_analytics__WEBPACK_IMPORTED_MODULE_1__.trackStructEvent("People Admin", "Manual Password Reset"); + _context5.next = 5; + return metabase_services__WEBPACK_IMPORTED_MODULE_5__.UserApi.update_password({ + id: id, + password: password + }); + + case 5: + return _context5.abrupt("return", { + type: PASSWORD_RESET_MANUAL, + payload: { + id: id, + password: password + } + }); + + case 6: + case "end": + return _context5.stop(); + } + } + }, _callee5); + })); + + function passwordResetManual(_x7) { + return _passwordResetManual.apply(this, arguments); + } + + return passwordResetManual; + }(), + deactivate: function () { + var _deactivate = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6(_ref6) { + var id; + return regeneratorRuntime.wrap(function _callee6$(_context6) { + while (1) { + switch (_context6.prev = _context6.next) { + case 0: + id = _ref6.id; + metabase_lib_analytics__WEBPACK_IMPORTED_MODULE_1__.trackStructEvent("People Admin", "User Removed"); // TODO: move these APIs from services to this file + + _context6.next = 4; + return metabase_services__WEBPACK_IMPORTED_MODULE_5__.UserApi.delete({ + userId: id + }); + + case 4: + return _context6.abrupt("return", { + type: DEACTIVATE, + payload: { + id: id + } + }); + + case 5: + case "end": + return _context6.stop(); + } + } + }, _callee6); + })); + + function deactivate(_x8) { + return _deactivate.apply(this, arguments); + } + + return deactivate; + }(), + reactivate: function () { + var _reactivate = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee7(_ref7) { + var id, user; + return regeneratorRuntime.wrap(function _callee7$(_context7) { + while (1) { + switch (_context7.prev = _context7.next) { + case 0: + id = _ref7.id; + metabase_lib_analytics__WEBPACK_IMPORTED_MODULE_1__.trackStructEvent("People Admin", "User Reactivated"); // TODO: move these APIs from services to this file + + _context7.next = 4; + return metabase_services__WEBPACK_IMPORTED_MODULE_5__.UserApi.reactivate({ + userId: id + }); + + case 4: + user = _context7.sent; + return _context7.abrupt("return", { + type: REACTIVATE, + payload: user + }); + + case 6: + case "end": + return _context7.stop(); + } + } + }, _callee7); + })); + + function reactivate(_x9) { + return _reactivate.apply(this, arguments); + } + + return reactivate; + }() + }, + reducer: function reducer() { + var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + + var _ref8 = arguments.length > 1 ? arguments[1] : undefined, + type = _ref8.type, + payload = _ref8.payload, + error = _ref8.error; + + if (type === DEACTIVATE && !error) { + return (0,icepick__WEBPACK_IMPORTED_MODULE_0__.assocIn)(state, [payload.id, "is_active"], false); + } else if (type === REACTIVATE && !error) { + return (0,icepick__WEBPACK_IMPORTED_MODULE_0__.assocIn)(state, [payload.id, "is_active"], true); + } else if (type === PASSWORD_RESET_MANUAL && !error) { + return (0,icepick__WEBPACK_IMPORTED_MODULE_0__.assocIn)(state, [payload.id, "password"], payload.password); + } + + return state; + }, + forms: _users_forms__WEBPACK_IMPORTED_MODULE_6__.default +}); +/* harmony default export */ __webpack_exports__["default"] = (Users); + +/***/ }), + +/***/ "./entities/users/forms.js": +/*!*********************************!*\ + !*** ./entities/users/forms.js ***! + \*********************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! underscore */ "../../../node_modules/underscore/modules/index-all.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var metabase_lib_settings__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/lib/settings */ "./lib/settings.ts"); +/* harmony import */ var metabase_lib_utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/lib/utils */ "./lib/utils.js"); +/* harmony import */ var metabase_plugins__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! metabase/plugins */ "./plugins/index.js"); +/* harmony import */ var metabase_lib_validate__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! metabase/lib/validate */ "./lib/validate.js"); +/* harmony import */ var metabase_components_form_widgets_FormGroupsWidget__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! metabase/components/form/widgets/FormGroupsWidget */ "./components/form/widgets/FormGroupsWidget.jsx"); +var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18, _templateObject19, _templateObject20, _templateObject21, _templateObject22, _templateObject23, _templateObject24, _templateObject25, _templateObject26, _templateObject27, _templateObject28; + +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } + +function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } + +function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + + + + + + + + +var NAME_FIELDS = [{ + name: "first_name", + title: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["First name"]))), + placeholder: "Johnny", + autoFocus: true, + validate: metabase_lib_validate__WEBPACK_IMPORTED_MODULE_5__.default.required().maxLength(100) +}, { + name: "last_name", + title: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["Last name"]))), + placeholder: "Appleseed", + validate: metabase_lib_validate__WEBPACK_IMPORTED_MODULE_5__.default.required().maxLength(100) +}]; +var EMAIL_FIELD = { + name: "email", + title: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["Email"]))), + placeholder: "youlooknicetoday@email.com", + validate: metabase_lib_validate__WEBPACK_IMPORTED_MODULE_5__.default.required().email() +}; +var LOCALE_FIELD = { + name: "locale", + title: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["Language"]))), + type: "select", + options: [[null, (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["Use site default"])))]].concat(_toConsumableArray(underscore__WEBPACK_IMPORTED_MODULE_0__.default.sortBy(metabase_lib_settings__WEBPACK_IMPORTED_MODULE_2__.default.get("available-locales") || [["en", "English"]], function (_ref) { + var _ref2 = _slicedToArray(_ref, 2), + code = _ref2[0], + name = _ref2[1]; + + return name; + }))).map(function (_ref3) { + var _ref4 = _slicedToArray(_ref3, 2), + code = _ref4[0], + name = _ref4[1]; + + return { + name: name, + value: code + }; + }) +}; +var PASSWORD_FORM_FIELDS = [{ + name: "password", + title: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["Create a password"]))), + type: "password", + placeholder: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["Shhh..."]))), + validate: metabase_lib_validate__WEBPACK_IMPORTED_MODULE_5__.default.required().passwordComplexity() +}, { + name: "password_confirm", + title: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["Confirm your password"]))), + type: "password", + placeholder: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["Shhh... but one more time so we get it right"]))), + validate: function validate(password_confirm, _ref5) { + var _ref5$values = _ref5.values; + _ref5$values = _ref5$values === void 0 ? {} : _ref5$values; + var password = _ref5$values.password; + + if (!password_confirm) { + return (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["required"]))); + } else if (password_confirm !== password) { + return (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["passwords do not match"]))); + } + } +}]; +/* harmony default export */ __webpack_exports__["default"] = ({ + admin: { + fields: [].concat(NAME_FIELDS, [EMAIL_FIELD, { + name: "group_ids", + title: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["Groups"]))), + type: metabase_components_form_widgets_FormGroupsWidget__WEBPACK_IMPORTED_MODULE_6__.default + }], _toConsumableArray(metabase_plugins__WEBPACK_IMPORTED_MODULE_4__.PLUGIN_ADMIN_USER_FORM_FIELDS)) + }, + user: { + fields: [].concat(NAME_FIELDS, [EMAIL_FIELD, LOCALE_FIELD]), + disablePristineSubmit: true + }, + setup: { + fields: [].concat(NAME_FIELDS, [EMAIL_FIELD, { + name: "site_name", + title: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject13 || (_templateObject13 = _taggedTemplateLiteral(["Company or team name"]))), + placeholder: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject14 || (_templateObject14 = _taggedTemplateLiteral(["Department of Awesome"]))), + validate: metabase_lib_validate__WEBPACK_IMPORTED_MODULE_5__.default.required() + }], PASSWORD_FORM_FIELDS) + }, + setup_invite: function setup_invite(user) { + return { + fields: [].concat(NAME_FIELDS, [{ + name: "email", + title: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject15 || (_templateObject15 = _taggedTemplateLiteral(["Email"]))), + placeholder: "youlooknicetoday@email.com", + validate: function validate(email) { + if (!email) { + return (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject16 || (_templateObject16 = _taggedTemplateLiteral(["required"]))); + } else if (!metabase_lib_utils__WEBPACK_IMPORTED_MODULE_3__.default.isEmail(email)) { + return (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject17 || (_templateObject17 = _taggedTemplateLiteral(["must be a valid email address"]))); + } else if (email === user.email) { + return (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject18 || (_templateObject18 = _taggedTemplateLiteral(["must be different from the email address you used in setup"]))); + } + } + }]) + }; + }, + login: function login() { + var ldap = metabase_lib_settings__WEBPACK_IMPORTED_MODULE_2__.default.ldapEnabled(); + var cookies = metabase_lib_settings__WEBPACK_IMPORTED_MODULE_2__.default.get("session-cookies"); + return { + fields: [{ + name: "username", + type: ldap ? "input" : "email", + title: ldap ? (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject19 || (_templateObject19 = _taggedTemplateLiteral(["Username or email address"]))) : (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject20 || (_templateObject20 = _taggedTemplateLiteral(["Email address"]))), + placeholder: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject21 || (_templateObject21 = _taggedTemplateLiteral(["youlooknicetoday@email.com"]))), + validate: ldap ? metabase_lib_validate__WEBPACK_IMPORTED_MODULE_5__.default.required() : metabase_lib_validate__WEBPACK_IMPORTED_MODULE_5__.default.required().email(), + autoFocus: true + }, { + name: "password", + type: "password", + title: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject22 || (_templateObject22 = _taggedTemplateLiteral(["Password"]))), + placeholder: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject23 || (_templateObject23 = _taggedTemplateLiteral(["Shhh..."]))), + validate: metabase_lib_validate__WEBPACK_IMPORTED_MODULE_5__.default.required() + }, { + name: "remember", + type: "checkbox", + title: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject24 || (_templateObject24 = _taggedTemplateLiteral(["Remember me"]))), + initial: true, + hidden: cookies, + horizontal: true + }] + }; + }, + password: { + fields: [{ + name: "old_password", + type: "password", + title: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject25 || (_templateObject25 = _taggedTemplateLiteral(["Current password"]))), + placeholder: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject26 || (_templateObject26 = _taggedTemplateLiteral(["Shhh..."]))), + validate: metabase_lib_validate__WEBPACK_IMPORTED_MODULE_5__.default.required() + }].concat(PASSWORD_FORM_FIELDS) + }, + password_forgot: { + fields: [{ + name: "email", + title: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject27 || (_templateObject27 = _taggedTemplateLiteral(["Email address"]))), + placeholder: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject28 || (_templateObject28 = _taggedTemplateLiteral(["The email you use for your Metabase account"]))), + validate: metabase_lib_validate__WEBPACK_IMPORTED_MODULE_5__.default.required().email() + }] + }, + password_reset: { + fields: [].concat(PASSWORD_FORM_FIELDS) + } +}); + +/***/ }), + +/***/ "./env.js": +/*!****************!*\ + !*** ./env.js ***! + \****************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "isCypressActive": function() { return /* binding */ isCypressActive; }, +/* harmony export */ "isProduction": function() { return /* binding */ isProduction; } +/* harmony export */ }); +var isCypressActive = !!window.Cypress; // eslint-disable-next-line no-undef + +var isProduction = "development" === "production"; + +/***/ }), + +/***/ "./hoc/AutoExpanding.jsx": +/*!*******************************!*\ + !*** ./hoc/AutoExpanding.jsx ***! + \*******************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var metabase_components_ExplicitSize__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/components/ExplicitSize */ "./components/ExplicitSize.jsx"); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/* eslint-disable react/prop-types */ + + // If the composed element increases from it's original width, sets `expand` to true +// +// Used for components which we initially want to be small, but if they expand +// beyond their initial size we want to fix their size to be larger so it doesn't +// jump around, etc + +/* harmony default export */ __webpack_exports__["default"] = (function (ComposedComponent) { + return (0,metabase_components_ExplicitSize__WEBPACK_IMPORTED_MODULE_1__.default)()( /*#__PURE__*/function (_React$Component) { + _inherits(AutoExpanding, _React$Component); + + var _super = _createSuper(AutoExpanding); + + function AutoExpanding() { + var _this; + + _classCallCheck(this, AutoExpanding); + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + _this = _super.call.apply(_super, [this].concat(args)); + + _defineProperty(_assertThisInitialized(_this), "state", { + expand: false + }); + + return _this; + } + + _createClass(AutoExpanding, [{ + key: "UNSAFE_componentWillReceiveProps", + value: function UNSAFE_componentWillReceiveProps(nextProps) { + if (nextProps.width != null && this.props.width != null && nextProps.width > this.props.width) { + this.setState({ + expand: true + }); + } + } + }, { + key: "render", + value: function render() { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(ComposedComponent, _extends({}, this.props, this.state)); + } + }]); + + return AutoExpanding; + }(react__WEBPACK_IMPORTED_MODULE_0__.Component)); +}); + +/***/ }), + +/***/ "./hoc/FitViewPort.jsx": +/*!*****************************!*\ + !*** ./hoc/FitViewPort.jsx ***! + \*****************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "isFitViewportMode": function() { return /* binding */ isFitViewportMode; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + + +/* fitViewport allows you to modify the top level classes on the react root node + * to set certain display properties that make it easier to create a view that will always + * be the size of the viewport height. + * + * When to use this + * ---------------------------------------------------------------------------- + * You need to ensure things can stretch to the full size of the current + * view port no matter what size the things are. + * + * When not to use this + * ---------------------------------------------------------------------------- + * You want content to expand to its size, so lists of things is probably a bad + * + * On an element that isn't the top level of a route. + * + */ + +function fitViewport(ComposedComponent) { + var _class, _temp; + + return _temp = _class = /*#__PURE__*/function (_React$Component) { + _inherits(_class, _React$Component); + + var _super = _createSuper(_class); + + function _class() { + _classCallCheck(this, _class); + + return _super.apply(this, arguments); + } + + _createClass(_class, [{ + key: "componentDidMount", + value: + /* + * Whats happening here: + * 1. set the position of the element to 'absolute' and have it stretch to + * the top, left, botto, and right of the viewport which should be all of it + * since we set the 'html', 'body', and '#root' elements to have a height + * of 100%. + * + * 2. set a flex context. Since the immediate children should be the + * nav and the current route this will allow the + * + * 3. Set the flex direction to flex-column to keep the content vertical + */ + // componentDidMount is required here to ensure the top level react child is present + function componentDidMount() { + var root = document.getElementById("root"); + + if (root && root.firstChild) { + root.firstChild.classList.add("spread", "flex", "flex-column"); + } + } + }, { + key: "componentWillUnmount", + value: function componentWillUnmount() { + var root = document.getElementById("root"); + + if (root && root.firstChild) { + root.firstChild.classList.remove("spread", "flex", "flex-column"); + } + } + }, { + key: "render", + value: function render() { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(ComposedComponent, _extends({}, this.props, { + fitClassNames: "relative flex flex-full" + })); + } + }]); + + return _class; + }(react__WEBPACK_IMPORTED_MODULE_0__.Component), _defineProperty(_class, "displayName", "FitViewport"), _temp; +} + +function isFitViewportMode() { + var root = document.getElementById("root"); + + if (root && root.firstChild) { + return root.firstChild.classList.contains("spread"); + } + + return false; +} +/* harmony default export */ __webpack_exports__["default"] = (fitViewport); + +/***/ }), + +/***/ "./hoc/PaginationState.jsx": +/*!*********************************!*\ + !*** ./hoc/PaginationState.jsx ***! + \*********************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/* eslint-disable react/prop-types */ + + +var paginationState = function paginationState() { + return function (ComposedComponent) { + return /*#__PURE__*/function (_React$Component) { + _inherits(_class2, _React$Component); + + var _super = _createSuper(_class2); + + function _class2(props) { + var _this; + + _classCallCheck(this, _class2); + + _this = _super.call(this, props); + + _defineProperty(_assertThisInitialized(_this), "handleChangeHasMorePages", function (hasMorePages) { + _this.setState({ + hasMorePages: hasMorePages + }); + }); + + _defineProperty(_assertThisInitialized(_this), "handleNextPage", function () { + _this.setState({ + page: _this.state.page + 1, + hasMorePages: null + }); + }); + + _defineProperty(_assertThisInitialized(_this), "handlePreviousPage", function () { + _this.setState({ + page: _this.state.page - 1, + hasMorePages: true + }); + }); + + _defineProperty(_assertThisInitialized(_this), "handleResetPagination", function () { + _this.setState({ + page: 0, + hasMorePages: null + }); + }); + + _this.state = { + page: props.initialPage || 0, + hasMorePages: null + }; + return _this; + } + + _createClass(_class2, [{ + key: "render", + value: function render() { + var isPaginated = typeof this.props.pageSize === "number"; + var extraProps = isPaginated ? _objectSpread(_objectSpread({}, this.state), {}, { + onChangeHasMorePages: this.handleChangeHasMorePages, + onNextPage: this.state.hasMorePages ? this.handleNextPage : null, + onPreviousPage: this.state.page > 0 ? this.handlePreviousPage : null + }) : {}; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(ComposedComponent, _extends({}, extraProps, this.props)); + } + }]); + + return _class2; + }(react__WEBPACK_IMPORTED_MODULE_0__.Component); + }; +}; + +/* harmony default export */ __webpack_exports__["default"] = (paginationState); + +/***/ }), + +/***/ "./hoc/Remapped.jsx": +/*!**************************!*\ + !*** ./hoc/Remapped.jsx ***! + \**************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var react_redux__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-redux */ "../../../node_modules/react-redux/es/index.js"); +/* harmony import */ var metabase_selectors_metadata__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/selectors/metadata */ "./selectors/metadata.js"); +/* harmony import */ var metabase_redux_metadata__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/redux/metadata */ "./redux/metadata.js"); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +var _excluded = ["metadata", "fetchRemapping"]; + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } + +function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/* eslint-disable react/prop-types */ + + + + + +var mapStateToProps = function mapStateToProps(state, props) { + return { + metadata: (0,metabase_selectors_metadata__WEBPACK_IMPORTED_MODULE_2__.getMetadata)(state, props) + }; +}; + +var mapDispatchToProps = { + fetchRemapping: metabase_redux_metadata__WEBPACK_IMPORTED_MODULE_3__.fetchRemapping +}; +/* harmony default export */ __webpack_exports__["default"] = (function (ComposedComponent) { + var _class, _temp; + + return (0,react_redux__WEBPACK_IMPORTED_MODULE_1__.connect)(mapStateToProps, mapDispatchToProps)((_temp = _class = /*#__PURE__*/function (_Component) { + _inherits(_class, _Component); + + var _super = _createSuper(_class); + + function _class() { + _classCallCheck(this, _class); + + return _super.apply(this, arguments); + } + + _createClass(_class, [{ + key: "UNSAFE_componentWillMount", + value: function UNSAFE_componentWillMount() { + if (this.props.column) { + this.props.fetchRemapping(this.props.value, this.props.column.id); + } + } + }, { + key: "UNSAFE_componentWillReceiveProps", + value: function UNSAFE_componentWillReceiveProps(nextProps) { + if (nextProps.column && (this.props.value !== nextProps.value || this.props.column !== nextProps.column)) { + this.props.fetchRemapping(nextProps.value, nextProps.column.id); + } + } + }, { + key: "render", + value: function render() { + // eslint-disable-next-line no-unused-vars + var _this$props = this.props, + metadata = _this$props.metadata, + fetchRemapping = _this$props.fetchRemapping, + props = _objectWithoutProperties(_this$props, _excluded); + + var field = metadata.field(props.column && props.column.id); + var displayValue = field && field.remappedValue(props.value); + var displayColumn = displayValue != null && field && field.remappedField() || null; + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(ComposedComponent, _extends({}, props, { + displayValue: displayValue, + displayColumn: displayColumn + })); + } + }]); + + return _class; + }(react__WEBPACK_IMPORTED_MODULE_0__.Component), _defineProperty(_class, "displayName", "Remapped[" + (ComposedComponent.displayName || ComposedComponent.name) + "]"), _temp)); +}); + +/***/ }), + +/***/ "./hoc/Routeless.jsx": +/*!***************************!*\ + !*** ./hoc/Routeless.jsx ***! + \***************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var react_redux__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-redux */ "../../../node_modules/react-redux/es/index.js"); +/* harmony import */ var react_router_redux__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react-router-redux */ "../../../node_modules/react-router-redux/lib/index.js"); +/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! underscore */ "../../../node_modules/underscore/modules/index-all.js"); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/* eslint-disable react/prop-types */ + + + + // namespace under _routeless_ + +var mapStateToProps = function mapStateToProps(state, props) { + return { + _routeless_location: state.routing.locationBeforeTransitions + }; +}; + +var mapDispatchToProps = { + _routeless_push: react_router_redux__WEBPACK_IMPORTED_MODULE_2__.push, + _routeless_goBack: react_router_redux__WEBPACK_IMPORTED_MODULE_2__.goBack +}; // this higher order component wraps any component (typically a fullscreen modal) with an "onClose" +// prop, injects an entry in the browser history, and closes the component if the back button is pressed + +/* harmony default export */ __webpack_exports__["default"] = (function (ComposedComponent // clone the state object otherwise the state will be replaced rather than pushed +// save the state object so that we know when it's changed +// if the state previously was the saved one and is now not, then we probably +// hit the back button, so close the wrapped component +// perform this in a timeout because the component may be unmounted anyway, in which +// case calling onClose again may cause problems. +// alternatively may be able to tighten up the logic above +// if we unmount (e.x. hit the close button which calls onClose directly) and still have the +// same state then go back to the original state +// NOTE: ideally we would remove the current state from the history so the forward +// button wouldn't be enabled, maybe using `replace` +) { + var _class, _temp; + + return (0,react_redux__WEBPACK_IMPORTED_MODULE_1__.connect)(mapStateToProps, mapDispatchToProps)((_temp = _class = /*#__PURE__*/function (_Component) { + _inherits(_class, _Component); + + var _super = _createSuper(_class); + + function _class() { + _classCallCheck(this, _class); + + return _super.apply(this, arguments); + } + + _createClass(_class, [{ + key: "UNSAFE_componentWillMount", + value: function UNSAFE_componentWillMount() { + var push = this.props._routeless_push; + var location = this.props._routeless_location; + var pathname = location.pathname, + query = location.query, + search = location.search, + hash = location.hash, + state = location.state; + this._state = _typeof(state) === "object" ? Object.create(state) : {}; + push({ + pathname: pathname, + query: query, + search: search, + hash: hash, + state: this._state + }); + } + }, { + key: "UNSAFE_componentWillReceiveProps", + value: function UNSAFE_componentWillReceiveProps(nextProps) { + var _this = this; + + var location = this.props._routeless_location; + var nextLocation = nextProps._routeless_location; + + if (location.state === this._state && nextLocation.state !== this._state) { + this._timeout = setTimeout(function () { + _this.props.onClose(); + }, 100); + } + } + }, { + key: "componentWillUnmount", + value: function componentWillUnmount() { + var location = this.props._routeless_location; + var goBack = this.props._routeless_goBack; + + if (this._timeout != null) { + clearTimeout(this._timeout); + } + + if (location.state === this._state) { + goBack(); + } + } + }, { + key: "render", + value: function render() { + var props = underscore__WEBPACK_IMPORTED_MODULE_3__.default.omit(this.props, "_routeless_location", "_routeless_goBack", "_routeless_push"); + + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(ComposedComponent, props); + } + }]); + + return _class; + }(react__WEBPACK_IMPORTED_MODULE_0__.Component), _defineProperty(_class, "displayName", "Routeless[" + (ComposedComponent.displayName || ComposedComponent.name) + "]"), _temp)); +}); + +/***/ }), + +/***/ "./hoc/Title.jsx": +/*!***********************!*\ + !*** ./hoc/Title.jsx ***! + \***********************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "Route": function() { return /* binding */ Route; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! underscore */ "../../../node_modules/underscore/modules/index-all.js"); +/* harmony import */ var react_router__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react-router */ "../../../node_modules/react-router/es/index.js"); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + + + +var componentStack = []; +var SEPARATOR = " · "; + +var updateDocumentTitle = underscore__WEBPACK_IMPORTED_MODULE_1__.default.debounce(function () { + document.title = componentStack.map(function (component) { + return component._documentTitle; + }).filter(function (title) { + return title; + }).reverse().join(SEPARATOR); +}); + +var title = function title(documentTitleOrGetter) { + return function (ComposedComponent) { + var _class, _temp; + + return _temp = _class = /*#__PURE__*/function (_React$Component) { + _inherits(_class, _React$Component); + + var _super = _createSuper(_class); + + function _class() { + _classCallCheck(this, _class); + + return _super.apply(this, arguments); + } + + _createClass(_class, [{ + key: "UNSAFE_componentWillMount", + value: function UNSAFE_componentWillMount() { + componentStack.push(this); + + this._updateDocumentTitle(); + } + }, { + key: "componentDidUpdate", + value: function componentDidUpdate() { + this._updateDocumentTitle(); + } + }, { + key: "componentWillUnmount", + value: function componentWillUnmount() { + for (var i = 0; i < componentStack.length; i++) { + if (componentStack[i] === this) { + componentStack.splice(i, 1); + break; + } + } + + this._updateDocumentTitle(); + } + }, { + key: "_updateDocumentTitle", + value: function _updateDocumentTitle() { + var _this = this; + + if (typeof documentTitleOrGetter === "string") { + this._documentTitle = documentTitleOrGetter; + } else if (typeof documentTitleOrGetter === "function") { + var result = documentTitleOrGetter(this.props); + + if (result == null) { + // title functions might return null before data is loaded + this._documentTitle = ""; + } else if (result instanceof String || typeof result === "string") { + this._documentTitle = result; + } else if (_typeof(result) === "object") { + // The getter can return an object with a `refresh` promise along with + // the title. When that promise resolves, we call + // `documentTitleOrGetter` again. + this._documentTitle = result.title; + result.refresh.then(function () { + return _this._updateDocumentTitle(); + }); + } + } + + updateDocumentTitle(); + } + }, { + key: "render", + value: function render() { + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(ComposedComponent, this.props); + } + }]); + + return _class; + }(react__WEBPACK_IMPORTED_MODULE_0__.Component), _defineProperty(_class, "displayName", "Title[" + (ComposedComponent.displayName || ComposedComponent.name) + "]"), _temp; + }; +}; + +/* harmony default export */ __webpack_exports__["default"] = (title); + // react-router Route wrapper that adds a `title` property + +var Route = /*#__PURE__*/function (_Route2) { + _inherits(Route, _Route2); + + var _super2 = _createSuper(Route); + + function Route() { + _classCallCheck(this, Route); + + return _super2.apply(this, arguments); + } + + _createClass(Route, null, [{ + key: "createRouteFromReactElement", + value: function createRouteFromReactElement(element) { + if (element.props.title) { + element = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.cloneElement(element, { + component: title(element.props.title)(element.props.component || function (_ref) { + var children = _ref.children; + return children; + }) + }); + } + + return react_router__WEBPACK_IMPORTED_MODULE_2__.Route.createRouteFromReactElement(element); + } + }]); + + return Route; +}(react_router__WEBPACK_IMPORTED_MODULE_2__.Route); + +/***/ }), + +/***/ "./hoc/Uncontrollable.jsx": +/*!********************************!*\ + !*** ./hoc/Uncontrollable.jsx ***! + \********************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! prop-types */ "../../../node_modules/prop-types/index.js"); +/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./utils */ "./hoc/utils.js"); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + + + + // wraps a component that takes `value` and `onChange` and allows it to be "uncontrolled" +// i.e. https://reactjs.org/docs/uncontrolled-components.html + +var Uncontrollable = function Uncontrollable() { + return function (WrappedComponent) { + var _class, _temp; + + return _temp = _class = /*#__PURE__*/function (_React$Component) { + _inherits(_class, _React$Component); + + var _super = _createSuper(_class); + + function _class(props) { + var _this; + + _classCallCheck(this, _class); + + _this = _super.call(this, props); + + _defineProperty(_assertThisInitialized(_this), "handleChange", function (e) { + _this.setState({ + value: e.target.value + }); + }); + + _this.state = { + value: props.defaultValue + }; + return _this; + } + + _createClass(_class, [{ + key: "render", + value: function render() { + if (this.props.value !== undefined) { + // controlled + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(WrappedComponent, this.props); + } else { + // uncontrolled + return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(WrappedComponent, _extends({}, this.props, { + value: this.state.value, + onChange: this.handleChange + })); + } + } + }]); + + return _class; + }(react__WEBPACK_IMPORTED_MODULE_0__.Component), _defineProperty(_class, "displayName", "Uncontrollable(".concat((0,_utils__WEBPACK_IMPORTED_MODULE_2__.getDisplayName)(WrappedComponent), ")")), _defineProperty(_class, "propTypes", _objectSpread(_objectSpread({}, WrappedComponent.propTypes), {}, { + // controlled + value: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().any), + onChange: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().func), + // uncontrolled + defaultValue: (prop_types__WEBPACK_IMPORTED_MODULE_1___default().any) + })), _temp; + }; +}; + +/* harmony default export */ __webpack_exports__["default"] = (Uncontrollable); + +/***/ }), + +/***/ "./hoc/utils.js": +/*!**********************!*\ + !*** ./hoc/utils.js ***! + \**********************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "getDisplayName": function() { return /* binding */ getDisplayName; } +/* harmony export */ }); +function getDisplayName(WrappedComponent) { + return WrappedComponent.displayName || WrappedComponent.name || "Component"; +} + +/***/ }), + +/***/ "./hooks/use-async-function.ts": +/*!*************************************!*\ + !*** ./hooks/use-async-function.ts ***! + \*************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "useAsyncFunction": function() { return /* binding */ useAsyncFunction; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var _use_is_mounted__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./use-is-mounted */ "./hooks/use-is-mounted.ts"); +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + + + +// wraps the given async function in a promise that does not resolve +// after the component has unmounted +function useAsyncFunction(fn, deps) { + var isMounted = (0,_use_is_mounted__WEBPACK_IMPORTED_MODULE_1__.useIsMounted)(); + var safeFn = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function () { + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + return new Promise(function (resolve, reject) { + return fn.apply(void 0, args).then(function (res) { + if (isMounted()) { + resolve(res); + } + }).catch(function (err) { + if (isMounted()) { + reject(err); + } + }); + }); + }, // eslint-disable-next-line react-hooks/exhaustive-deps + deps ? [].concat(_toConsumableArray(deps), [isMounted]) : [isMounted]); + return safeFn; +} + +/***/ }), + +/***/ "./hooks/use-debounced-value.ts": +/*!**************************************!*\ + !*** ./hooks/use-debounced-value.ts ***! + \**************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "useDebouncedValue": function() { return /* binding */ useDebouncedValue; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } + +function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } + +function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } + + +function useDebouncedValue(value, delay) { + var _useState = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(value), + _useState2 = _slicedToArray(_useState, 2), + debouncedValue = _useState2[0], + setDebouncedValue = _useState2[1]; + + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () { + var handler = setTimeout(function () { + setDebouncedValue(value); + }, delay); + return function () { + return clearTimeout(handler); + }; + }, [delay, value]); + return debouncedValue; +} + +/***/ }), + +/***/ "./hooks/use-is-mounted.ts": +/*!*********************************!*\ + !*** ./hooks/use-is-mounted.ts ***! + \*********************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "useIsMounted": function() { return /* binding */ useIsMounted; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); + +function useIsMounted() { + var isMountedRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(false); + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () { + isMountedRef.current = true; + return function () { + isMountedRef.current = false; + }; + }, []); + return (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function () { + return isMountedRef.current; + }, []); +} + +/***/ }), + +/***/ "./hooks/use-synced-query-string.ts": +/*!******************************************!*\ + !*** ./hooks/use-synced-query-string.ts ***! + \******************************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "useSyncedQueryString": function() { return /* binding */ useSyncedQueryString; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +/* harmony import */ var querystring__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! querystring */ "../../../node_modules/querystring/index.js"); + + +function useSyncedQueryString(fn, deps) { + (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () { + var object = fn(); + var searchString = buildSearchString(object); + + if (searchString !== window.location.search) { + history.replaceState(null, document.title, window.location.pathname + searchString + window.location.hash); + } // exhaustive-deps is enabled for useSyncedQueryString so we don't need to include `fn` as a dependency + // eslint-disable-next-line react-hooks/exhaustive-deps + + }, [deps]); +} + +function buildSearchString(object) { + var search = querystring__WEBPACK_IMPORTED_MODULE_1__.stringify(object); + return search ? "?".concat(search) : ""; +} + +/***/ }), + +/***/ "./hooks/use-toggle.ts": +/*!*****************************!*\ + !*** ./hooks/use-toggle.ts ***! + \*****************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "useToggle": function() { return /* binding */ useToggle; } +/* harmony export */ }); +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../../../node_modules/react/index.js"); +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } + +function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } + +function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } + + +function useToggle() { + var initialValue = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; + + var _useState = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(initialValue), + _useState2 = _slicedToArray(_useState, 2), + value = _useState2[0], + setValue = _useState2[1]; + + var turnOn = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function () { + return setValue(true); + }, []); + var turnOff = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function () { + return setValue(false); + }, []); + var toggle = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function () { + return setValue(function (current) { + return !current; + }); + }, []); + return [value, { + turnOn: turnOn, + turnOff: turnOff, + toggle: toggle + }]; +} + +/***/ }), + +/***/ "./icon_paths.ts": +/*!***********************!*\ + !*** ./icon_paths.ts ***! + \***********************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "ICON_PATHS": function() { return /* binding */ ICON_PATHS; }, +/* harmony export */ "parseViewBox": function() { return /* binding */ parseViewBox; }, +/* harmony export */ "loadIcon": function() { return /* binding */ loadIcon; } +/* harmony export */ }); +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } + +function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } + +function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } + +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +/* + Metabase Icon Paths + ----- + + These paths represent the current canonical icon set for Metabase. +*/ +var ICON_PATHS = { + add: "M12.4285714,12.4285714 L12.4285714,0 L19.5714286,0 L19.5714286,12.4285714 L32,12.4285714 L32,19.5714286 L19.5714286,19.5714286 L19.5714286,32 L12.4285714,32 L12.4285714,19.5714286 L0,19.5714286 L0,12.4285714 L12.4285714,12.4285714 Z", + add_data: "M0 8h5.926v6.208H0V8zm7.704 0h5.926v6.208H7.704V8zM0 16.07h5.926v6.209H0V16.07zm7.704 0h5.926v6.209H7.704V16.07zm7.703 0h5.926v6.209h-5.926V16.07zM0 24.142h5.926v6.208H0v-6.208zm7.704 0h5.926v6.208H7.704v-6.208zm7.703 0h5.926v6.208h-5.926v-6.208zM23.08 8.08V3h4.064v5.08h5.08v4.063h-5.08v5.08h-4.064v-5.08H18V8.079h5.08z", + add_to_dash: { + path: "M21,23 L16,23 L16,27 L21,27 L21,32 L25,32 L25,27 L30,27 L30,23 L25,23 L25,18 L21,18 L21,23 Z M32,7 L32,14 L28,14 L28,8 L0,8 L0,4 L0,4 C-2.705415e-16,1.790861 1.790861,4.05812251e-16 4,0 L4,0 L28,0 C30.209139,-4.05812251e-16 32,1.790861 32,4 L32,7 Z M0,8 L4,8 L4,28 L0,28 L0,8 Z M0,28 L12,28 L12,32 L4,32 C1.790861,32 2.705415e-16,30.209139 0,28 Z", + attrs: { + fillRule: "evenodd" + } + }, + alert: { + path: "M14.677 7.339c-4.77.562-5.23 4.75-5.23 7.149 0 2.576 0 3.606-.53 4.121-.352.344-1.058.515-2.117.515V21.7h18v-2.576c-1.059 0-1.588 0-2.118-.515-.353-.343-.53-2.06-.53-5.151-.316-3.705-2.06-5.745-5.23-6.12a1.52 1.52 0 0 0 .466-1.093c0-.853-.71-1.545-1.588-1.545-.877 0-1.588.692-1.588 1.545 0 .427.178.814.465 1.094zM16.05 0c2.473 0 5.57 1.851 6.22 4.12 3.057 1.58 4.868 4.503 5.223 8.706l.013.158v.157c0 .905.014 1.682.042 2.327H30.6V25.73H1.5V15.468h3.091c.002-.326.003-.725.003-1.222 0-2.308.316-4.322 1.26-6.233.881-1.784 2.223-2.988 3.976-3.893C10.48 1.85 13.576 0 16.05 0zM13.1 25.8c.25 1.6 1.166 2.4 2.75 2.4s2.5-.8 2.75-2.4h-5.5zm-4.35-3.16h14.191l-.586 3.261c-.497 3.607-2.919 6.001-6.51 6.001-3.59 0-6.012-2.394-6.508-6L8.75 22.64z", + attrs: { + fillRule: "nonzero" + } + }, + alert_confirm: { + path: "M24.326 7.184a9.604 9.604 0 0 0-.021-.034c-.876-1.39-2.056-2.47-3.518-3.19-.509-2.269-2.51-3.96-4.9-3.96-2.361 0-4.344 1.652-4.881 3.88C7.113 5.63 5.68 9.55 5.68 14.424c0 .88-.003 1.473-.01 1.902H2.8v9.605h26.175v-9.602h-3.297v6.257H6.097V19.67c1.152 0 1.92-.194 2.304-.583.576-.583.576-1.75.576-4.664 0-2.716.5-7.456 5.69-8.091a1.754 1.754 0 0 1-.507-1.238c0-.966.773-1.749 1.727-1.749.955 0 1.728.783 1.728 1.75 0 .483-.194.92-.507 1.237 2.2.27 3.768 1.308 4.705 3.112.037-.04.874-.793 2.513-2.26zm-11.312 18.7H9.741C10.214 29.398 12.48 32 15.887 32c3.409 0 5.674-2.602 6.147-6.116H18.76c-.27 1.911-1.228 2.77-2.874 2.77-1.645 0-2.603-.859-2.873-2.77zm.297-12.466l2.504-2.707 3.819 4.106 7.653-8.254L29.8 9.38 19.636 20.295l-6.325-6.877z", + attrs: { + fillRule: "nonzero" + } + }, + all: "M30.595 13.536c1.85.755 1.879 2.05.053 2.9l-11.377 5.287c-1.82.846-4.763.858-6.583.022L1.344 16.532c-1.815-.835-1.785-2.131.05-2.89l1.637-.677 8.977 4.125c2.194 1.009 5.74.994 7.934-.026l9.022-4.193 1.63.665zm-1.63 7.684l1.63.666c1.85.755 1.879 2.05.053 2.898l-11.377 5.288c-1.82.847-4.763.859-6.583.022L1.344 24.881c-1.815-.834-1.785-2.131.05-2.89l1.637-.677 8.977 4.126c2.194 1.008 5.74.993 7.934-.026l9.022-4.194zM12.686 1.576c1.843-.762 4.834-.77 6.687-.013l11.22 4.578c1.85.755 1.88 2.05.054 2.899l-11.377 5.288c-1.82.846-4.763.858-6.583.022L1.344 9.136c-1.815-.834-1.785-2.13.05-2.89l11.293-4.67z", + archive: { + path: "M6.857 2.762c0-.42.341-.762.762-.762h16.762a.762.762 0 0 1 0 1.524H7.619a.762.762 0 0 1-.762-.762zM0 11.809a6 6 0 0 1 6-6h20a6 6 0 0 1 6 6v12.382a6 6 0 0 1-6 6H6a6 6 0 0 1-6-6V11.81zm10.62 3.097a1.143 1.143 0 0 1 1.617 0L16 18.67l3.763-3.763a1.143 1.143 0 0 1 1.617 1.616l-4.572 4.572a1.143 1.143 0 0 1-1.616 0l-4.572-4.572a1.143 1.143 0 0 1 0-1.616z", + attrs: { + fillRule: "evenodd" + } + }, + area: "M31.154 28.846l.852.004V8.64l-1.15 2.138-6.818 6.37c-.13.122-9.148 1.622-9.148 1.622l-.545.096-.383.4-7.93 8.31-1.016 1.146 2.227.017 23.91.107L7.25 28.74l7.93-8.31 9.615-1.684 7.211-6.737v15.984a.855.855 0 0 1-.852.854zM0 28.74l11.79-13.362 11.788-3.369 8.077-8.07c.194-.193.351-.128.351.15V28.85L0 28.74z", + attachment: { + path: "M22.162 8.704c.029 8.782-.038 14.123-.194 15.926-.184 2.114-2.922 4.322-5.9 4.322-3.06 0-5.542-1.98-5.836-4.376-.294-2.392-.195-14.266.01-18.699.077-1.661 1.422-2.83 3.548-2.83 2.067 0 3.488 1.335 3.594 3.164.06 1.052.074 3.49.053 7.107-.006.928-.013 1.891-.023 3.072l-.023 2.527c-.006.824-.01 1.358-.01 1.718 0 1.547-.39 2.011-1.475 2.011-.804 0-1.202-.522-1.202-1.38V8.699a1.524 1.524 0 0 0-3.048 0v12.567c0 2.389 1.554 4.428 4.25 4.428 2.897 0 4.523-1.934 4.523-5.06 0-.348.003-.875.01-1.691l.022-2.526c.01-1.184.018-2.15.024-3.082.021-3.697.008-6.155-.058-7.3C20.227 2.592 17.469 0 13.79 0c-3.695 0-6.438 2.382-6.593 5.737-.213 4.613-.312 16.585.01 19.21C7.697 28.94 11.53 32 16.067 32c4.482 0 8.61-3.327 8.937-7.106.168-1.935.235-7.302.206-16.2a1.524 1.524 0 0 0-3.048.01z", + attrs: { + fillRule: "nonzero" + } + }, + arrow_up: { + path: "M16 34.23a2.5 2.5 0 002.5-2.5V9.036l8.732 8.732a2.5 2.5 0 003.405.122l.13-.122a2.5 2.5 0 000-3.536l-13-13a2.5 2.5 0 00-3.535 0l-13 13a2.5 2.5 0 103.536 3.536L13.5 9.036V31.73a2.5 2.5 0 002.336 2.495z", + attrs: { + viewBox: "0 0 32 34" + } + }, + arrow_down: { + path: "M16 .5A2.5 2.5 0 0118.5 3v22.694l8.732-8.732a2.5 2.5 0 013.405-.122l.13.122a2.5 2.5 0 010 3.536l-13 13a2.5 2.5 0 01-3.535 0l-13-13a2.5 2.5 0 113.536-3.536l8.732 8.732V3A2.5 2.5 0 0115.836.505z", + attrs: { + viewBox: "0 0 32 34" + } + }, + arrow_left: { + path: "M14.502 1.232a2.5 2.5 0 113.536 3.536l-8.732 8.731L32 13.5a2.5 2.5 0 012.495 2.336L34.5 16a2.5 2.5 0 01-2.5 2.5l-22.696-.001 8.734 8.733a2.5 2.5 0 01.122 3.405l-.122.13a2.5 2.5 0 01-3.536 0l-13-13a2.5 2.5 0 010-3.535z", + attrs: { + viewBox: "0 0 35 32" + } + }, + arrow_left_to_line: { + path: "M1,1v10 M3,6h8 M6,3L3,6L6,9", + attrs: { + viewBox: "0 0 12 12", + style: { + fill: "none", + strokeLinecap: "round", + strokeLinejoin: "round", + strokeWidth: 1.5, + stroke: "currentColor" + } + } + }, + badge: { + path: "M14.7368 28.421L6.31579 24.2105L0 36.8421L6.31579 33.6842L8.42105 40L14.7368 28.421Z M17.8947 28.421L26.3158 24.2105L32.6316 36.8421L26.3158 33.6842L24.2105 40L17.8947 28.421Z M16.842 25.2632C23.8183 25.2632 29.4736 19.6078 29.4736 12.6316C29.4736 5.65535 23.8183 0 16.842 0C9.8658 0 4.21045 5.65535 4.21045 12.6316C4.21045 19.6078 9.8658 25.2632 16.842 25.2632ZM16.842 16.8421C19.1674 16.8421 21.0526 14.957 21.0526 12.6316C21.0526 10.3062 19.1674 8.42105 16.842 8.42105C14.5166 8.42105 12.6315 10.3062 12.6315 12.6316C12.6315 14.957 14.5166 16.8421 16.842 16.8421Z", + attrs: { + viewBox: "0 0 33 40", + fillRule: "evenodd" + } + }, + bar: "M2 23.467h6.4V32H2v-8.533zm10.667-12.8h6.4V32h-6.4V10.667zM23.333 0h6.4v32h-6.4V0z", + beaker: "M4.31736354,31.1631075 C3.93810558,30.6054137 3.89343681,29.6635358 4.20559962,29.0817181 L11.806982,14.9140486 L11.8069821,10.5816524 L10.7015144,10.4653256 C10.0309495,10.394763 9.48734928,9.78799739 9.48734928,9.12166999 L9.48734928,7.34972895 C9.48734928,6.67821106 10.0368737,6.13383825 10.7172248,6.13383825 L21.8462005,6.13383825 C22.525442,6.13383825 23.0760761,6.68340155 23.0760761,7.34972895 L23.0760761,9.12166999 C23.0760761,9.79318788 22.5250158,10.3375607 21.856025,10.3375607 L20.9787023,10.3375607 L20.9787024,14.9281806 L28.77277,29.0827118 C29.0983515,29.6739888 29.0709073,30.6193105 28.7174156,31.1846409 L28.852457,30.9686726 C28.4963041,31.538259 27.6541076,32 26.9865771,32 L6.10749779,32 C5.43315365,32 4.58248747,31.5529687 4.19978245,30.9902061 L4.31736354,31.1631075 Z M15.5771418,17.6040443 C16.5170398,17.6040443 17.2789777,16.8377777 17.2789777,15.89254 C17.2789777,14.9473023 16.5170398,14.1810358 15.5771418,14.1810358 C14.6372438,14.1810358 13.8753059,14.9473023 13.8753059,15.89254 C13.8753059,16.8377777 14.6372438,17.6040443 15.5771418,17.6040443 Z M16.5496195,12.8974079 C17.8587633,12.8974079 18.9200339,11.830108 18.9200339,10.5135268 C18.9200339,9.1969457 17.8587633,8.1296458 16.5496195,8.1296458 C15.2404758,8.1296458 14.1792052,9.1969457 14.1792052,10.5135268 C14.1792052,11.830108 15.2404758,12.8974079 16.5496195,12.8974079 Z M5.71098553,30.2209651 L10.9595331,20.5151267 C10.9595331,20.5151267 12.6834557,21.2672852 14.3734184,21.2672852 C16.0633811,21.2672852 16.8198616,19.2872624 17.588452,18.6901539 C18.3570425,18.0930453 19.9467191,17.1113296 19.9467191,17.1113296 L27.0506095,30.1110325 L5.71098553,30.2209651 Z M13.6608671,4.37817079 C14.4114211,4.37817079 15.0198654,3.78121712 15.0198654,3.04483745 C15.0198654,2.30845779 14.4114211,1.71150412 13.6608671,1.71150412 C12.9103132,1.71150412 12.3018689,2.30845779 12.3018689,3.04483745 C12.3018689,3.78121712 12.9103132,4.37817079 13.6608671,4.37817079 Z M17.9214578,2.45333328 C18.6119674,2.45333328 19.1717361,1.90413592 19.1717361,1.22666664 C19.1717361,0.549197362 18.6119674,0 17.9214578,0 C17.2309481,0 16.6711794,0.549197362 16.6711794,1.22666664 C16.6711794,1.90413592 17.2309481,2.45333328 17.9214578,2.45333328 Z", + bell: "M14.254 5.105c-7.422.874-8.136 7.388-8.136 11.12 0 4.007 0 5.61-.824 6.411-.549.535-1.647.802-3.294.802v4.006h28v-4.006c-1.647 0-2.47 0-3.294-.802-.55-.534-.824-3.205-.824-8.013-.493-5.763-3.205-8.936-8.136-9.518a2.365 2.365 0 0 0 .725-1.701C18.47 2.076 17.364 1 16 1s-2.47 1.076-2.47 2.404c0 .664.276 1.266.724 1.7zM11.849 29c.383 1.556 1.793 2.333 4.229 2.333s3.845-.777 4.229-2.333h-8.458z", + bolt: "M21.697 0L8 16.809l7.549 2.538L11.687 32l12.652-16.6-7.695-2.317z", + breakout: "M24.47 1H32v7.53h-7.53V1zm0 11.294H32v7.53h-7.53v-7.53zm0 11.294H32v7.53h-7.53v-7.53zM0 1h9.412v30.118H0V1zm11.731 13.714c.166-.183.452-.177.452-.177h6.475s-1.601-2.053-2.07-2.806c-.469-.753-.604-1.368 0-1.905.603-.536 1.226-.281 1.878.497.652.779 2.772 3.485 3.355 4.214.583.73.65 1.965 0 2.835-.65.87-2.65 4.043-3.163 4.65-.514.607-1.123.713-1.732.295-.609-.419-.838-1.187-.338-1.872.5-.684 2.07-3.073 2.07-3.073h-6.475s-.27 0-.46-.312-.151-.612-.151-.612l.007-1.246s-.014-.306.152-.488z", + bubble: "M18.155 20.882c-5.178-.638-9.187-5.051-9.187-10.402C8.968 4.692 13.66 0 19.448 0c5.789 0 10.48 4.692 10.48 10.48 0 3.05-1.302 5.797-3.383 7.712a7.127 7.127 0 1 1-8.39 2.69zm-6.392 10.14a2.795 2.795 0 1 1 0-5.59 2.795 2.795 0 0 1 0 5.59zm-6.079-6.288a4.541 4.541 0 1 1 0-9.083 4.541 4.541 0 0 1 0 9.083z", + burger: "M2.5 3.6h27a2.5 2.5 0 1 1 0 5h-27a2.5 2.5 0 0 1 0-5zm0 9.931h27a2.5 2.5 0 1 1 0 5h-27a2.5 2.5 0 1 1 0-5zm0 9.931h27a2.5 2.5 0 1 1 0 5h-27a2.5 2.5 0 0 1 0-5z", + calendar: { + path: "M21,2 L21,0 L18,0 L18,2 L6,2 L6,0 L3,0 L3,2 L2.99109042,2 C1.34177063,2 0,3.34314575 0,5 L0,6.99502651 L0,20.009947 C0,22.2157067 1.78640758,24 3.99005301,24 L20.009947,24 C22.2157067,24 24,22.2135924 24,20.009947 L24,6.99502651 L24,5 C24,3.34651712 22.6608432,2 21.0089096,2 L21,2 L21,2 Z M22,8 L22,20.009947 C22,21.1099173 21.1102431,22 20.009947,22 L3.99005301,22 C2.89008272,22 2,21.1102431 2,20.009947 L2,8 L22,8 L22,8 Z M6,12 L10,12 L10,16 L6,16 L6,12 Z", + attrs: { + viewBox: "0 0 24 24" + } + }, + check: "M1 14 L5 10 L13 18 L27 4 L31 8 L13 26 z ", + chevrondown: "M1 12 L16 26 L31 12 L27 8 L16 18 L5 8 z ", + chevronleft: "M20 1 L24 5 L14 16 L24 27 L20 31 L6 16 z", + chevronright: "M12 1 L26 16 L12 31 L8 27 L18 16 L8 5 z ", + chevronup: "M1 20 L16 6 L31 20 L27 24 L16 14 L5 24 z", + click: "M5.38519 1C2.41104 1 0 3.41103 0 6.38519V26.779C0 29.7532 2.41103 32.1642 5.38519 32.1642H13.3818V27.7911H5.38519C4.82624 27.7911 4.37313 27.338 4.37313 26.779V6.38519C4.37313 5.82624 4.82624 5.37313 5.38519 5.37313H22.779C23.338 5.37313 23.7911 5.82624 23.7911 6.38519V7.98451H28.1642V6.38519C28.1642 3.41103 25.7532 1 22.779 1H5.38519ZM12 10.6L17.5213 29.1906L21.8777 24.8341L27.6436 30.6L32 26.2436L26.2341 20.4777L30.5906 16.1213L12 10.6Z", + clipboard: "M8.54667751,5.50894675 L6.00494659,5.50894675 C4.89702623,5.50894675 4,6.40070914 4,7.50075379 L4,30.0171397 C4,31.1120596 4.89764516,32.0089468 6.00494659,32.0089468 L25.9950534,32.0089468 C27.1029738,32.0089468 28,31.1171844 28,30.0171397 L28,7.50075379 C28,6.40583387 27.1023548,5.50894675 25.9950534,5.50894675 L23.5373296,5.50894675 L23.5373296,3.0446713 L19.9106557,3.0446713 C19.9106557,3.0446713 19.6485834,8.05825522e-08 16.0837607,0 C12.518938,-8.05825523e-08 12.1644547,3.04776207 12.1644547,3.04776207 L8.57253264,3.04776207 L8.54667751,5.50894675 Z M23.5373296,7.50894675 L26,7.50894675 L26,30.0089468 L6,30.0089468 L6,7.50894675 L8.52566721,7.50894675 L8.4996301,9.98745456 L23.5373296,9.98745456 L23.5373296,7.50894675 Z M10.573037,5.01478303 L13.9861608,5.01478303 L13.9861608,3.76128231 C13.9861608,3.76128231 14.0254332,1.94834752 16.0135743,1.94834752 C18.0017155,1.94834752 18.0017156,3.7055821 18.0017156,3.7055821 L18.0017156,4.94060459 L21.4955568,4.94060459 L21.4955568,8.03924122 L10.5173901,8.03924122 L10.573037,5.01478303 Z M16,5.00894675 C16.5522847,5.00894675 17,4.5612315 17,4.00894675 C17,3.456662 16.5522847,3.00894675 16,3.00894675 C15.4477153,3.00894675 15,3.456662 15,4.00894675 C15,4.5612315 15.4477153,5.00894675 16,5.00894675 Z M8.5,18.0089468 L8.5,21.0082323 L11.5,21.0082323 L11.5,18.0446111 L8.5,18.0089468 Z M8.5,23.0089468 L8.5,26.0082323 L11.5,26.0082323 L11.5,23.0446111 L8.5,23.0089468 Z M8.5,13.0089468 L8.5,16.0082323 L11.5,16.0082323 L11.5,13.0446111 L8.5,13.0089468 Z M13.5,13.0193041 L13.5,16 L23.5,16 L23.5,13 L13.5,13.0193041 Z M13.5,23.0193041 L13.5,26 L23.5,26 L23.5,23 L13.5,23.0193041 Z M13.5,18.0193041 L13.5,21 L23.5,21 L23.5,18 L13.5,18.0193041 Z", + clock: "M16 0 A16 16 0 0 0 0 16 A16 16 0 0 0 16 32 A16 16 0 0 0 32 16 A16 16 0 0 0 16 0 M16 4 A12 12 0 0 1 28 16 A12 12 0 0 1 16 28 A12 12 0 0 1 4 16 A12 12 0 0 1 16 4 M14 6 L14 17.25 L22 22 L24.25 18.5 L18 14.75 L18 6z", + clone: { + path: "M24,22 L32,22 L32,0 L10,0 L10,6 L24,6 L24,22 L24,22 Z M0,8 L22,8 L22,30 L0,30 L0,8 Z", + attrs: { + viewBox: "0 0 32 30" + } + }, + close: "M4 8 L8 4 L16 12 L24 4 L28 8 L20 16 L28 24 L24 28 L16 20 L8 28 L4 24 L12 16 z ", + cloud: "M6.951 12.397a7.385 7.385 0 0 0 .434 14.757h17.23a7.385 7.385 0 0 0 .434-14.757C24.199 8.177 20.47 5 16 5s-8.198 3.178-9.049 7.397z", + collection: "M16.5695046,2.82779686 L15.5639388,2.83217072 L30.4703127,11.5065092 L30.4818076,9.80229623 L15.5754337,18.2115855 L16.5436335,18.2077098 L1.65289961,9.96407638 L1.67877073,11.6677911 L16.5695046,2.82779686 Z M0.691634577,11.6826271 L15.5823685,19.9262606 C15.8836872,20.0930731 16.2506087,20.0916044 16.5505684,19.9223849 L31.4569423,11.5130957 C32.1196316,11.1392458 32.1260238,10.1915465 31.4684372,9.80888276 L16.5620632,1.1345443 C16.2511162,0.953597567 15.8658421,0.955273376 15.5564974,1.13891816 L0.665763463,9.97891239 C0.0118284022,10.3671258 0.0262104889,11.3142428 0.691634577,11.6826271 Z M15.5699489,25.798061 L16.0547338,26.0652615 L16.536759,25.7931643 L31.4991818,17.3470627 C31.973977,17.0790467 32.1404815,16.4788587 31.8710802,16.0065052 C31.6016788,15.5341517 30.9983884,15.3685033 30.5235933,15.6365193 L15.5611705,24.0826209 L16.5279806,24.0777242 L1.46763754,15.7768642 C0.99012406,15.5136715 0.388560187,15.6854222 0.124007019,16.16048 C-0.14054615,16.6355379 0.0320922897,17.2340083 0.509605765,17.497201 L15.5699489,25.798061 Z M15.5699489,31.7327994 L16.0547338,32 L16.536759,31.7279028 L31.4991818,23.2818011 C31.973977,23.0137852 32.1404815,22.4135972 31.8710802,21.9412437 C31.6016788,21.4688901 30.9983884,21.3032418 30.5235933,21.5712578 L15.5611705,30.0173594 L16.5279806,30.0124627 L1.46763754,21.7116027 C0.99012406,21.44841 0.388560187,21.6201606 0.124007019,22.0952185 C-0.14054615,22.5702764 0.0320922897,23.1687467 0.509605765,23.4319394 L15.5699489,31.7327994 Z", + compare: "M24.5815137,18.6109617 L32.110976,18.6109617 L32.110976,25.7224662 L24.5815137,25.7224662 L24.5815137,31.7951059 L14.9536477,22.1672398 L24.5815137,12.5393738 L24.5815137,18.6109617 Z M7.52979828,20.2568769 L7.52941566,14.1855356 L0.000277209616,14.1851279 L-3.37507799e-14,7.07317197 L7.52913845,7.0735796 L7.5287557,1 L17.1577154,10.6289597 L7.52979828,20.2568769 Z", + connections: { + path: "M5.37815706,11.5570815 C5.55061975,11.1918363 5.64705882,10.783651 5.64705882,10.3529412 C5.64705882,9.93118218 5.55458641,9.53102128 5.38881053,9.1716274 L11.1846365,4.82475792 C11.6952189,5.33295842 12.3991637,5.64705882 13.1764706,5.64705882 C14.7358628,5.64705882 16,4.38292165 16,2.82352941 C16,1.26413718 14.7358628,0 13.1764706,0 C11.6170784,0 10.3529412,1.26413718 10.3529412,2.82352941 C10.3529412,3.2452884 10.4454136,3.64544931 10.6111895,4.00484319 L10.6111895,4.00484319 L4.81536351,8.35171266 C4.3047811,7.84351217 3.60083629,7.52941176 2.82352941,7.52941176 C1.26413718,7.52941176 0,8.79354894 0,10.3529412 C0,11.9123334 1.26413718,13.1764706 2.82352941,13.1764706 C3.59147157,13.1764706 4.28780867,12.8698929 4.79682555,12.3724528 L10.510616,16.0085013 C10.408473,16.3004758 10.3529412,16.6143411 10.3529412,16.9411765 C10.3529412,18.5005687 11.6170784,19.7647059 13.1764706,19.7647059 C14.7358628,19.7647059 16,18.5005687 16,16.9411765 C16,15.3817842 14.7358628,14.1176471 13.1764706,14.1176471 C12.3029783,14.1176471 11.5221273,14.5142917 11.0042049,15.1372938 L5.37815706,11.5570815 Z", + attrs: { + viewBox: "0 0 16 19.7647" + } + }, + contract: "M18.0015892,0.327942852 L18.0015892,14 L31.6736463,14 L26.6544389,8.98079262 L32,3.63523156 L28.3647684,0 L23.0192074,5.34556106 L18.0015892,0.327942852 Z M14,31.6720571 L14,18 L0.327942852,18 L5.34715023,23.0192074 L0.00158917013,28.3647684 L3.63682073,32 L8.98238179,26.6544389 L14,31.6720571 Z", + copy: { + path: "M10.329 6.4h-3.33c-.95 0-1.72.77-1.72 1.72v.413h17.118V8.12c0-.941-.77-1.719-1.72-1.719h-3.31l-1.432-1.705a2.137 2.137 0 0 0-2.097-2.562 2.137 2.137 0 0 0-2.054 2.73L10.329 6.4zm12.808 4.267h1.4v8.557h-4.42l.111-4.188-5.981 6.064 5.805 6.264v-3.966h4.485v6.469H3.14v-19.2h19.997zm3.54 12.731v6.888c0 .947-.769 1.714-1.725 1.714H2.725C1.772 32 1 31.23 1 30.286V5.981c0-.947.768-1.714 1.725-1.714h6.834A4.273 4.273 0 0 1 13.839 0c2.363 0 4.279 1.91 4.279 4.267h6.834c.953 0 1.725.77 1.725 1.714v13.243H31v4.174h-4.323zM5.279 12.8h10.7v2.133h-10.7V12.8zm0 4.267h5.564V19.2H5.279v-2.133zm0 4.266h5.564v2.134H5.279v-2.134zm0 4.267h8.56v2.133h-8.56V25.6z", + attrs: { + fillRule: "evenodd" + } + }, + curved: "M3.314 25.007c-.398.852-1.427 1.228-2.298.84a1.68 1.68 0 0 1-.86-2.247c3.754-8.047 7.654-12.229 12.06-12.229 2.93 0 4.406 1.185 6.481 4.098l.098.137c1.413 1.984 2.054 2.507 3.318 2.507 2.293 0 4.562-2.814 6.495-8.918.283-.895 1.254-1.396 2.17-1.119.915.277 1.427 1.227 1.144 2.122-2.337 7.38-5.503 11.307-9.809 11.307-2.765 0-4.15-1.132-6.166-3.961l-.097-.137c-1.479-2.075-2.187-2.644-3.635-2.644-2.58 0-5.667 3.31-8.901 10.244z", + csv: "M28 10.105v18.728A3.166 3.166 0 0 1 24.834 32H6.166A3.163 3.163 0 0 1 3 28.844V3.156A3.163 3.163 0 0 1 6.16 0h13.553V10.105H28zm-.215-1.684h-6.4V.311l6.4 8.11zM17 13v2h2v-2h-2zm0 4v2h2v-2h-2zm4-4v2h2v-2h-2zM7 13v2h7v-2H7zm14 4v2h2v-2h-2zM7 17v2h7v-2H7zm10 4v2h2v-2h-2zm4 0v2h2v-2h-2zM7 21v2h7v-2H7z", + database: "M0 9.32V4.054S1.584 0 15.657 0C29.731 0 31.89 3.669 31.89 4.054v5.24s-1.445 4.125-15.424 4.125S0 10.138 0 9.32zm.305 12.93s2.044 3.692 15.727 3.692 15.63-3.72 15.63-3.72.338.099.338.632v5S30.463 32 15.964 32C1.465 32 .041 27.817.041 27.817V22.9c0-.582.264-.65.264-.65zm0-9.368s2.044 3.692 15.727 3.692 15.63-3.72 15.63-3.72.338.099.338.632v5.001s-1.537 4.145-16.036 4.145C1.465 22.632.041 18.45.041 18.45v-4.918c0-.583.264-.65.264-.65z", + dataset: { + path: "M17.0086 0.596191H4.38525C2.17612 0.596191 0.385254 2.38705 0.385254 4.59619V17.739C0.385254 19.9482 2.17612 21.739 4.38525 21.739H17.0086C19.2178 21.739 21.0086 19.9482 21.0086 17.739V4.59619C21.0086 2.38705 19.2178 0.596191 17.0086 0.596191ZM2.38525 4.59619C2.38525 3.49162 3.28068 2.59619 4.38525 2.59619H17.0086C18.1132 2.59619 19.0086 3.49162 19.0086 4.59619V17.739C19.0086 18.8436 18.1132 19.739 17.0086 19.739H4.38525C3.28069 19.739 2.38525 18.8436 2.38525 17.739V4.59619ZM7.92633 4.73904H4.46313V8.31047H7.92633V4.73904ZM12.4284 4.73904H8.96524V8.31047H12.4284V4.73904ZM13.4675 4.73904H16.9307V8.31047H13.4675V4.73904ZM7.92633 9.38189H4.46313V12.9533H7.92633V9.38189ZM8.96524 9.38189H12.4284V12.9533H8.96524V9.38189ZM16.9307 9.38189H13.4675V12.9533H16.9307V9.38189ZM4.46313 14.0247H7.92633V17.5962H4.46313V14.0247ZM12.4284 14.0247H8.96524V17.5962H12.4284V14.0247ZM13.4675 14.0247H16.9307V17.5962H13.4675V14.0247Z", + attrs: { + viewBox: "0.385254 0.596191 20.623346 21.142809" + } + }, + dataset_framed: { + path: "M4.38606 0.0780849H6.13235V2.07808H4.38606C3.28149 2.07808 2.38606 2.97351 2.38606 4.07808V5.6526H0.386059V4.07808C0.386059 1.86894 2.17692 0.0780849 4.38606 0.0780849ZM0.386059 10.5864V12.1609C0.386059 14.3701 2.17692 16.1609 4.38606 16.1609H6.13235V14.1609H4.38606C3.28149 14.1609 2.38606 13.2655 2.38606 12.1609V10.5864H0.386059ZM10.3614 16.1609V14.1609H12.1028C13.2073 14.1609 14.1028 13.2655 14.1028 12.1609V10.6883H16.1028V12.1609C16.1028 14.3701 14.3119 16.1609 12.1028 16.1609H10.3614ZM16.1028 5.75447V4.07808C16.1028 1.86895 14.3119 0.0780849 12.1028 0.0780849H10.3614V2.07808H12.1028C13.2073 2.07808 14.1028 2.97352 14.1028 4.07808V5.75447H16.1028ZM6.29163 3.58845H3.85065V6.10571H6.29163V3.58845ZM9.46487 3.58845H7.0239V6.10571H9.46487V3.58845ZM10.1972 3.58845H12.6382V6.10571H10.1972V3.58845ZM6.29163 6.86089H3.85065V9.37815H6.29163V6.86089ZM7.0239 6.86089H9.46487V9.37815H7.0239V6.86089ZM12.6382 6.86089H10.1972V9.37815H12.6382V6.86089ZM3.85065 10.1333H6.29163V12.6506H3.85065V10.1333ZM9.46487 10.1333H7.0239V12.6506H9.46487V10.1333ZM10.1972 10.1333H12.6382V12.6506H10.1972V10.1333Z", + attrs: { + viewBox: "0.386059 0.0780849 15.716740999999999 16.0828151" + } + }, + dash: "M0 13h32v6.61H0z", + dashboard: "M32 28a4 4 0 0 1-4 4H4a4.002 4.002 0 0 1-3.874-3H0V4a4 4 0 0 1 4-4h25a3 3 0 0 1 3 3v25zm-4 0V8H4v20h24zM7.273 18.91h10.182v4.363H7.273v-4.364zm0-6.82h17.454v4.365H7.273V12.09zm13.09 6.82h4.364v4.363h-4.363v-4.364z", + curve: "M3.033 3.791v22.211H31.09c.403 0 .882.872.882 1.59 0 .717-.48 1.408-.882 1.408H0V3.791c0-.403.875-.914 1.487-.914.612 0 1.546.511 1.546.914zm3.804 17.912C5.714 21.495 5 20.318 5 19.355c0-.963.831-2.296 1.837-2.296 2.093 0 2.965-1.207 4.204-5.242l.148-.482C12.798 6.077 14.18 3 17.968 3c3.792 0 5.17 3.08 6.765 8.343l.145.478c1.227 4.034 2.093 5.238 4.181 5.238 1.006 0 1.875 1.29 1.875 2.296 0 1.007-.898 2.184-1.875 2.348-3.656.612-6.004-2.364-7.665-7.821l-.146-.482c-1.14-3.76-1.8-6.754-3.28-6.754-1.483 0-2.147 2.995-3.297 6.754l-.148.486c-1.675 5.454-3.93 8.514-7.686 7.817z", + document: "M29,10.1052632 L29,28.8325291 C29,30.581875 27.5842615,32 25.8337327,32 L7.16626728,32 C5.41758615,32 4,30.5837102 4,28.8441405 L4,3.15585953 C4,1.41292644 5.42339685,9.39605581e-15 7.15970573,8.42009882e-15 L20.713352,8.01767853e-16 L20.713352,8.42105263 L22.3846872,8.42105263 L22.3846872,0.310375032 L28.7849894,8.42105263 L20.713352,8.42105263 L20.713352,10.1052632 L29,10.1052632 Z M7.3426704,12.8000006 L25.7273576,12.8000006 L25.7273576,14.4842112 L7.3426704,14.4842112 L7.3426704,12.8000006 Z M7.3426704,17.3473687 L25.7273576,17.3473687 L25.7273576,19.0315793 L7.3426704,19.0315793 L7.3426704,17.3473687 Z M7.3426704,21.8947352 L25.7273576,21.8947352 L25.7273576,23.5789458 L7.3426704,23.5789458 L7.3426704,21.8947352 Z M7.43137255,26.2736849 L16.535014,26.2736849 L16.535014,27.9578954 L7.43137255,27.9578954 L7.43137255,26.2736849 Z", + download: { + path: "M26 0c7.264 0 13.323 5.164 14.704 12.022C47.004 12.384 52 17.609 52 24c0 6.627-5.373 12-12 12H12C5.373 36 0 30.627 0 24c0-6.391 4.997-11.616 11.297-11.98C12.677 5.164 18.736 0 26 0zm0 6a3 3 0 00-3 3v13.649l-5.232-5.511-.13-.128a2.409 2.409 0 00-3.406.128c-.976 1.028-.976 2.696 0 3.724l10 10.533.13.129a2.409 2.409 0 003.406-.129l10-10.533.122-.138c.852-1.034.812-2.602-.122-3.586l-.13-.128a2.409 2.409 0 00-3.406.128L29 22.649V9a3 3 0 00-3-3z", + attrs: { + viewBox: "0 0 52 32" + } + }, + edit_document: "M19.27 20.255l-5.642 2.173 1.75-6.085L28.108 3.45 32 7.363 19.27 20.255zM20.442 6.9l-2.044-2.049H4.79v23.29h18.711v-6.577l4.787-4.83V31a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V2a2 2 0 0 1 2-2h18.024a1 1 0 0 1 .711.297L23.85 3.45 20.442 6.9z", + ellipsis: "M3.613 19.226a3.613 3.613 0 1 0 0-7.226 3.613 3.613 0 0 0 0 7.226zM28.387 19.226a3.613 3.613 0 1 0 0-7.226 3.613 3.613 0 0 0 0 7.226zM19.613 15.613a3.613 3.613 0 1 1-7.226 0 3.613 3.613 0 0 1 7.226 0z", + embed: "M12.734 9.333L6.099 16l6.635 6.667a2.547 2.547 0 0 1 0 3.59 2.518 2.518 0 0 1-3.573 0L.74 17.795a2.547 2.547 0 0 1 0-3.59L9.16 5.743a2.518 2.518 0 0 1 3.573 0 2.547 2.547 0 0 1 0 3.59zm6.527 13.339l6.64-6.71-6.63-6.623a2.547 2.547 0 0 1-.01-3.59 2.518 2.518 0 0 1 3.573-.01l8.42 8.412c.99.988.995 2.596.011 3.59l-8.42 8.51a2.518 2.518 0 0 1-3.574.01 2.547 2.547 0 0 1-.01-3.59z", + empty: " ", + enter_or_return: "M6.81 16.784l6.14-4.694a1.789 1.789 0 0 0 .341-2.49 1.748 1.748 0 0 0-2.464-.344L.697 17a1.788 1.788 0 0 0-.01 2.826l10.058 7.806c.77.598 1.875.452 2.467-.326a1.79 1.79 0 0 0-.323-2.492l-5.766-4.475h23.118c.971 0 1.759-.796 1.759-1.777V6.777C32 5.796 31.212 5 30.24 5c-.971 0-1.759.796-1.759 1.777v10.007H6.811z", + expand: "M27.448 13.42a2.051 2.051 0 0 0 4.101 0V2.052A2.05 2.05 0 0 0 29.5 0h-11.37a2.05 2.05 0 0 0 0 4.102h6.418L18.46 10.19a2.051 2.051 0 0 0 2.901 2.9l6.088-6.088v6.419zM4.102 18.58a2.051 2.051 0 0 0-4.102 0v11.369A2.05 2.05 0 0 0 2.051 32h11.37a2.051 2.051 0 1 0 0-4.102H7.002l6.088-6.087a2.05 2.05 0 1 0-2.9-2.901l-6.088 6.088v-6.419z", + expand_arrow: "M16.429 28.429L.429 5.57h32z", + external: "M13.7780693,4.44451732 L5.1588494,4.44451732 C2.32615959,4.44451732 0,6.75504816 0,9.60367661 L0,25.1192379 C0,27.9699171 2.30950226,30.2783972 5.1588494,30.2783972 L18.9527718,30.2783972 C21.7854617,30.2783972 24.1116212,27.9678664 24.1116212,25.1192379 L24.1116212,19.9448453 L20.6671039,19.9448453 L20.6671039,25.1192379 C20.6671039,26.0662085 19.882332,26.8338799 18.9527718,26.8338799 L5.1588494,26.8338799 C4.21204994,26.8338799 3.44451732,26.0677556 3.44451732,25.1192379 L3.44451732,9.60367661 C3.44451732,8.656706 4.22928927,7.88903464 5.1588494,7.88903464 L13.7780693,7.88903464 L13.7780693,4.44451732 L13.7780693,4.44451732 Z M30.9990919,14.455325 L30.9990919,1 L17.5437669,1 L22.4834088,5.93964193 L17.2225866,11.2004641 L20.8001918,14.7780693 L26.061014,9.51724709 L30.9990919,14.455325 L30.9990919,14.455325 L30.9990919,14.455325 Z", + eye: "M30.622 18.49c-.549.769-1.46 1.86-2.737 3.273-1.276 1.414-2.564 2.614-3.866 3.602-2.297 1.757-4.963 2.635-8 2.635-3.062 0-5.741-.878-8.038-2.635-1.302-.988-2.59-2.188-3.866-3.602-1.276-1.413-2.188-2.504-2.737-3.272-.549-.769-.9-1.277-1.053-1.524-.433-.63-.433-1.276 0-1.934.128-.247.472-.755 1.034-1.524.561-.768 1.48-1.852 2.756-3.252 1.276-1.4 2.564-2.593 3.866-3.581C10.303 4.892 12.982 4 16.019 4c3.011 0 5.678.892 8 2.676 1.302.988 2.59 2.182 3.866 3.581 1.276 1.4 2.195 2.484 2.756 3.252.562.769.906 1.277 1.034 1.524.433.63.433 1.276 0 1.934-.153.247-.504.755-1.053 1.524zm-1.516-3.214c-.248.376-.248 1.089.034 1.499l-.11-.16-.088-.17a21.93 21.93 0 0 0-.784-1.121c-.483-.66-1.338-1.67-2.546-2.995-1.154-1.266-2.306-2.333-3.466-3.214-1.781-1.368-3.788-2.04-6.127-2.04-2.365 0-4.385.673-6.179 2.05-1.146.87-2.298 1.938-3.452 3.204-1.208 1.325-2.063 2.334-2.546 2.995a21.93 21.93 0 0 0-.784 1.12l-.075.145-.09.135c.249-.376.249-1.089-.033-1.499l.08.122c.105.17.432.644.941 1.356.466.653 1.313 1.666 2.517 3 1.152 1.275 2.3 2.346 3.451 3.22 1.752 1.339 3.773 2.001 6.17 2.001 2.37 0 4.379-.661 6.14-2.008 1.143-.867 2.291-1.938 3.443-3.214 1.204-1.333 2.05-2.346 2.517-2.999.509-.712.836-1.186.942-1.356l.045-.071zm-17.353 5.663C10.584 19.709 10 18.237 10 16.522c0-1.744.584-3.224 1.753-4.439 1.168-1.215 2.59-1.822 4.268-1.822 1.65 0 3.058.607 4.226 1.822C21.416 13.298 22 14.778 22 16.522c0 1.715-.584 3.187-1.753 4.417-1.168 1.229-2.577 1.844-4.226 1.844-1.677 0-3.1-.615-4.268-1.844zm6.265-2.12c.624-.655.906-1.368.906-2.297 0-.957-.281-1.67-.893-2.307-.592-.616-1.203-.879-2.01-.879-.84 0-1.462.266-2.052.88-.612.636-.893 1.35-.893 2.306 0 .929.282 1.642.906 2.298.59.62 1.207.887 2.039.887.8 0 1.405-.264 1.997-.887z", + eye_crossed_out: "M21.775 3.183C20.007 2.393 18.082 2 16.017 2c-3.043 0-5.778.84-8.151 2.54-1.263.896-2.5 1.967-3.711 3.207-1.168 1.196-2.05 2.162-2.61 2.88-.457.582-.828 1.078-1.025 1.411-.305.451-.52.993-.52 1.607 0 .632.228 1.188.557 1.645.177.263.52.723.995 1.343.552.722 1.43 1.697 2.598 2.905.137.141.274.28.411.417l2.084-2.03c-.135-.134-.27-.27-.404-.41-1.152-1.19-1.933-2.067-2.378-2.65a30.87 30.87 0 0 1-.901-1.213l-.01-.016.033-.047.038-.069.014-.023.046-.07c.04-.06.095-.138.166-.236.142-.197.337-.452.586-.771.46-.587 1.249-1.46 2.4-2.64C7.344 8.646 8.45 7.693 9.552 6.912l.006-.005c1.848-1.325 3.984-1.998 6.46-1.998 1.236 0 2.388.17 3.463.51l2.295-2.236zm-5.093 4.962a6.109 6.109 0 0 0-.668-.036c-1.53 0-2.883.536-3.972 1.6-1.09 1.064-1.652 2.402-1.652 3.927 0 .207.01.41.031.61l6.26-6.1zm-1.583 10.95l6.453-6.29c.039.27.058.547.058.83 0 1.514-.566 2.841-1.646 3.908-1.083 1.07-2.426 1.619-3.95 1.619a6.1 6.1 0 0 1-.915-.068zm-2.78 2.707c1.133.373 2.363.562 3.698.562 2.482 0 4.606-.665 6.428-1.965l.004-.003c1.1-.78 2.204-1.737 3.31-2.88 1.152-1.192 1.933-2.068 2.378-2.65.506-.661.794-1.052.901-1.213l.01-.016-.025-.035-.046-.082-.014-.023a7.635 7.635 0 0 0-.212-.306 28.444 28.444 0 0 0-.586-.771c-.46-.587-1.249-1.46-2.4-2.64a29.152 29.152 0 0 0-.548-.545l2.085-2.031c.181.177.363.358.543.543 1.168 1.196 2.05 2.162 2.61 2.88.451.575.819 1.066 1.018 1.399.313.449.527.99.527 1.602 0 .633-.23 1.19-.55 1.65-.174.261-.52.726-1.002 1.355-.552.722-1.43 1.697-2.598 2.905-1.213 1.253-2.45 2.333-3.717 3.23-2.353 1.679-5.077 2.505-8.116 2.505-2.161 0-4.162-.412-5.98-1.246l2.282-2.225zM28.617 3L5 26.618l-2.121-2.122L26.496.88 28.617 3z", + field: "M27 25v7H5V1h22v24zm-3 0H8v4h16v-4zm0-3v-4H8v4h16zM8 15h16v-4H8v4zm0-7h16V4H8v4z", + fields: "M0,0 L7.51851852,0 L7.51851852,3.2 L0,3.2 L0,0 Z M10.7407407,0 L18.2592593,0 L18.2592593,3.2 L10.7407407,3.2 L10.7407407,0 Z M21.4814815,0 L29,0 L29,3.2 L21.4814815,3.2 L21.4814815,0 Z M0,5.33333333 L7.51851852,5.33333333 L7.51851852,29.8666667 L3.85540334,32 L0,29.8666667 L0,5.33333333 Z M10.7407407,5.33333333 L18.2592593,5.33333333 L18.2592593,29.8666667 L14.5690136,32 L10.7407407,29.8666667 L10.7407407,5.33333333 Z M21.4814815,5.33333333 L29,5.33333333 L29,29.8666667 L25.2114718,32 L21.4814815,29.8666667 L21.4814815,5.33333333 Z", + filter: "M3.556 4h24.888a3.556 3.556 0 1 1 0 7.111H3.556a3.556 3.556 0 1 1 0-7.111zm4 11.556h16.888a2.222 2.222 0 1 1 0 4.444H7.556a2.222 2.222 0 0 1 0-4.444zM12 24.444h8a2.222 2.222 0 0 1 0 4.445h-8a2.222 2.222 0 0 1 0-4.445z", + function: "M10.956 13.244L7 32h6.311l3.956-18.756H21.8l.889-4.222H18.2c.178-.681.326-1.274.444-1.778.119-.533.282-.977.49-1.333.236-.385.562-.667.977-.844.415-.208 1.022-.311 1.822-.311.326 0 .667.014 1.023.044l1.022.089.978-4.533a23.65 23.65 0 0 0-2.09-.267A23.59 23.59 0 0 0 20.823 0c-1.659 0-3.007.193-4.044.578-1.008.385-1.822.963-2.445 1.733-.622.77-1.11 1.719-1.466 2.845-.356 1.096-.682 2.385-.978 3.866H8.11l-.889 4.222h3.734z", + funnel: "M3.18586974,3.64621479 C2.93075885,3.28932022 3.08031197,3 3.5066208,3 L28.3780937,3 C28.9190521,3 29.0903676,3.34981042 28.7617813,3.77995708 L18.969764,16.5985181 L18.969764,24.3460671 C18.969764,24.8899179 18.5885804,25.5564176 18.133063,25.8254534 C18.133063,25.8254534 12.5698889,29.1260709 12.5673818,28.9963552 C12.4993555,25.4767507 12.5749031,16.7812673 12.5749031,16.7812673 L3.18586974,3.64621479 Z", + funnel_outline: { + path: "M3.186 3.646C2.93 3.29 3.08 3 3.506 3h24.872c.541 0 .712.35.384.78L18.97 16.599v7.747c0 .544-.381 1.21-.837 1.48 0 0-5.563 3.3-5.566 3.17-.068-3.52.008-12.215.008-12.215L3.185 3.646z", + attrs: { + stroke: "currentcolor", + strokeWidth: "4", + fill: "none", + fillRule: "evenodd" + } + }, + folder: "M4 3a4 4 0 0 0-4 4v18.667a4 4 0 0 0 4 4h24a4 4 0 0 0 4-4V8.333h-9.65a3.5 3.5 0 0 1-2.19-.77L14.476 3H4z", + gauge: "M5.197 29.803A15.958 15.958 0 0 1 0 18C0 9.163 7.163 2 16 2s16 7.163 16 16a15.96 15.96 0 0 1-5.344 11.936L22.983 26.5A10.978 10.978 0 0 0 27 18c0-6.075-4.925-11-11-11S5 11.925 5 18c0 3.292 1.446 6.246 3.738 8.262l-3.54 3.54zM13 21.25a3.774 3.774 0 0 1 1.122-5.975L23 11l-4.34 9.347a3.455 3.455 0 0 1-5.66.903z", + gear: "M12.088.996c0-.55.441-.996 1.006-.996h6.189c.555 0 1.005.452 1.005 1.007V3.53c0 .556.375 1.235.848 1.524l1.806 1.102c.468.286 1.252.328 1.748.095l2.756-1.292a1.125 1.125 0 0 1 1.417.432l2.979 4.93a1.063 1.063 0 0 1-.307 1.408l-2.147 1.445c-.455.306-.823 1.011-.823 1.55v2.6c0 .55.353 1.278.774 1.614l2.279 1.818c.428.341.512.976.181 1.43l-3.211 4.394c-.328.448-.992.588-1.463.324l-2.27-1.272c-.48-.27-1.238-.242-1.709.071l-2.019 1.344c-.463.309-.839 1.013-.839 1.556v2.4c0 .55-.44.997-1.005.997h-6.19a1.006 1.006 0 0 1-1.005-.997v-2.4c0-.55-.372-1.26-.823-1.58l-1.829-1.295c-.454-.322-1.198-.35-1.664-.06l-2.9 1.808a.985.985 0 0 1-1.361-.325L.309 21.923a1.03 1.03 0 0 1 .318-1.393l2.566-1.666c.463-.3.838-.99.838-1.539v-2.494c0-.55-.391-1.226-.86-1.503L.485 11.74a.99.99 0 0 1-.35-1.36l3.14-5.236c.28-.47.907-.646 1.393-.397l3.308 1.7c.488.25 1.23.175 1.666-.178l1.665-1.345c.432-.348.781-1.074.781-1.627V.996zM16.002 22c3.33 0 6.028-2.686 6.028-6s-2.699-6-6.028-6c-3.329 0-6.027 2.686-6.027 6s2.698 6 6.027 6z", + grabber: "M0,5 L32,5 L32,9.26666667 L0,9.26666667 L0,5 Z M0,13.5333333 L32,13.5333333 L32,17.8 L0,17.8 L0,13.5333333 Z M0,22.0666667 L32,22.0666667 L32,26.3333333 L0,26.3333333 L0,22.0666667 Z", + grabber2: "M9.692 7.385a3.692 3.692 0 1 1 0-7.385 3.692 3.692 0 0 1 0 7.385zm0 12.307a3.692 3.692 0 1 1 0-7.384 3.692 3.692 0 0 1 0 7.384zM22 7.385A3.692 3.692 0 1 1 22 0a3.692 3.692 0 0 1 0 7.385zm0 12.307a3.692 3.692 0 1 1 0-7.384 3.692 3.692 0 0 1 0 7.384zM9.692 32a3.692 3.692 0 1 1 0-7.385 3.692 3.692 0 0 1 0 7.385zM22 32a3.692 3.692 0 1 1 0-7.385A3.692 3.692 0 0 1 22 32z", + grid: "M2 2 L10 2 L10 10 L2 10z M12 2 L20 2 L20 10 L12 10z M22 2 L30 2 L30 10 L22 10z M2 12 L10 12 L10 20 L2 20z M12 12 L20 12 L20 20 L12 20z M22 12 L30 12 L30 20 L22 20z M2 22 L10 22 L10 30 L2 30z M12 22 L20 22 L20 30 L12 30z M22 22 L30 22 L30 30 L22 30z", + group: "M11.044 4.805c4.38-.157 6.166 3.841 6.166 6.134s-1.132 5.67-3.048 7.412c-.424.385-.345 2.822.58 3.218 1.938.83 7.242 2.51 7.443 5.971.224 3.853-6.733 4.244-11.023 4.244S0 31.26 0 28.024c0-1.501.15-2.489 2.625-4.16 2.474-1.67 4.36-2.08 4.77-2.333.412-.254 1.17-1.574.677-3.048 0 0-2.973-3.248-2.973-6.824 0-3.577 1.566-6.698 5.945-6.854zm5.554-.51S17.686 1 21.591 1c3.905 0 5.502 3.217 5.502 5.87s-1.023 5.356-2.623 6.946c-.18.178-.408 1.742.302 2.09.71.347 7.228 2.274 7.228 5.74s-4.39 3.524-7.698 3.856c0 0-.639-3.165-7.78-5.943 0 0 3.315-3.944 3.165-8.697-.151-4.754-3.089-6.568-3.089-6.568z", + google: { + svg: '' + }, + history: { + path: "M4.03074198,15 C4.54693838,6.62927028 11.4992947,0 20,0 C28.836556,0 36,7.163444 36,16 C36,24.836556 28.836556,32 20,32 C16.9814511,32 14.1581361,31.164104 11.7489039,29.7111608 L14.1120194,26.4586113 C15.8515127,27.4400159 17.8603607,28 20,28 C26.627417,28 32,22.627417 32,16 C32,9.372583 26.627417,4 20,4 C13.7093362,4 8.54922468,8.84046948 8.04107378,15 L11,15 L6,22 L1.34313965,15 L4.03074198,15 Z M22,15.2218254 L24.5913352,17.8131606 L24.5913352,17.8131606 C25.3723838,18.5942092 25.3723838,19.8605392 24.5913352,20.6415878 C23.8176686,21.4152544 22.5633071,21.4152544 21.7896404,20.6415878 C21.7852062,20.6371536 21.7807931,20.6326983 21.7764012,20.6282222 L18.8194549,17.6145768 C18.3226272,17.2506894 18,16.6630215 18,16 L18,10 C18,8.8954305 18.8954305,8 20,8 C21.1045695,8 22,8.8954305 22,10 L22,15.2218254 Z", + attrs: { + viewBox: "0 0 36 33" + } + }, + hourglass: { + path: "M3 1.838C3 .823 3.617 0 4.378 0H27.35c.761 0 1.379.823 1.379 1.838 0 1.015-.618 1.837-1.379 1.837h-.143a28.303 28.303 0 0 1-.25 3.17c-.237 1.641-.695 3.295-1.654 4.574-1.157 1.543-2.537 2.456-3.52 3.108h-.001l-.214.142c-.53.354-.839.58-1.028.783-.138.15-.138.205-.137.24v.005c0 .009-.002.014-.003.018v.002l-.002.003c0 .008.008.016.052.058l.002.002c.14.134.32.254.664.481l.403.269c1.154.776 2.72 1.971 4.291 4.563.764 1.26 1.212 3.171 1.41 4.777a15.138 15.138 0 0 1 .119 2.455h.011c.761 0 1.379.822 1.379 1.837 0 1.015-.618 1.838-1.379 1.838H4.38C3.616 32 3 31.177 3 30.162c0-1.015.617-1.837 1.378-1.837h.012a15.146 15.146 0 0 1 .118-2.454c.199-1.607.647-3.519 1.41-4.778 1.57-2.591 3.137-3.787 4.292-4.563.155-.105.288-.193.403-.269.343-.227.524-.347.664-.481l.002-.002c.043-.042.052-.05.051-.058l-.001-.005c-.001-.004-.003-.01-.003-.018v-.005c0-.035.001-.09-.138-.24-.189-.204-.497-.43-1.028-.783l-.214-.142c-.984-.652-2.364-1.565-3.52-3.107-.96-1.28-1.418-2.934-1.655-4.575a28.31 28.31 0 0 1-.25-3.17h-.143C3.618 3.675 3 2.853 3 1.838zm4.28 1.837h17.168c-.03.973-.094 1.908-.22 2.775-.212 1.468-.58 2.582-1.131 3.316-.862 1.15-1.88 1.825-2.881 2.491l-.178.118c-.494.33-1.075.724-1.52 1.203-.487.526-.873 1.218-.873 2.119 0 .898.367 1.561.894 2.069.34.327.804.632 1.193.888l.248.163c.93.626 2.167 1.551 3.472 3.705.457.753.847 2.196 1.032 3.687.09.72.123 1.387.104 1.907a6.013 6.013 0 0 1-.011.209H7.15a6.192 6.192 0 0 1-.011-.21c-.019-.52.014-1.186.103-1.906.185-1.49.576-2.934 1.032-3.687 1.305-2.154 2.543-3.08 3.473-3.705.077-.052.16-.106.248-.163.388-.256.853-.561 1.192-.888.527-.508.894-1.17.894-2.07 0-.9-.385-1.592-.873-2.118-.444-.48-1.026-.874-1.52-1.203l-.177-.118c-1.002-.666-2.019-1.342-2.881-2.491-.55-.734-.92-1.848-1.132-3.316a25.21 25.21 0 0 1-.22-2.775zm2.152 3.682h12.421c0 2.948-6.132 6.04-6.132 6.04s-6.29-3.38-6.29-6.04zm-.919 19.59h14.702c0-.7-.744-1.323-1.764-1.848-3.56-1.834-8.014-1.823-11.48.182-.856.495-1.458 1.059-1.458 1.665zm7.35-5.17a1.378 1.378 0 1 0 0-2.757 1.378 1.378 0 0 0 0 2.757z", + attrs: { + fillRule: "evenodd", + clipRule: "evenodd" + } + }, + info: "M16 0 A16 16 0 0 1 16 32 A16 16 0 0 1 16 0 M19 15 L13 15 L13 26 L19 26 z M16 6 A3 3 0 0 0 16 12 A3 3 0 0 0 16 6", + info_outline: "M16 29c7.18 0 13-5.82 13-13S23.18 3 16 3 3 8.82 3 16s5.82 13 13 13zm0 3C7.163 32 0 24.837 0 16S7.163 0 16 0s16 7.163 16 16-7.163 16-16 16zm1.697-20h-4.185v14h4.185V12zm.432-3.834c0-.342-.067-.661-.203-.958a2.527 2.527 0 0 0-1.37-1.31 2.613 2.613 0 0 0-.992-.188c-.342 0-.661.062-.959.189a2.529 2.529 0 0 0-1.33 1.309c-.13.297-.195.616-.195.958 0 .334.065.646.196.939.13.292.31.549.54.77.23.22.492.395.79.526.297.13.616.196.958.196.351 0 .682-.066.992-.196.31-.13.583-.306.817-.527a2.47 2.47 0 0 0 .553-.77c.136-.292.203-.604.203-.938z", + insight: "M12.6325203 19.3674797 0 16 12.6325203 12.6325203 16 0 19.3674797 12.6325203 32 16 19.3674797 19.3674797 16 32z", + int: { + path: "M15.141,15.512 L14.294,20 L13.051,20 C12.8309989,20 12.6403341,19.9120009 12.479,19.736 C12.3176659,19.5599991 12.237,19.343668 12.237,19.087 C12.237,19.0503332 12.2388333,19.0155002 12.2425,18.9825 C12.2461667,18.9494998 12.2516666,18.9146668 12.259,18.878 L12.908,15.512 L10.653,15.512 L10.015,19.01 C9.94899967,19.3620018 9.79866784,19.6149992 9.564,19.769 C9.32933216,19.9230008 9.06900143,20 8.783,20 L7.584,20 L8.42,15.512 L7.155,15.512 C6.92033216,15.512 6.74066729,15.4551672 6.616,15.3415 C6.49133271,15.2278328 6.429,15.0390013 6.429,14.775 C6.429,14.6723328 6.43999989,14.5550007 6.462,14.423 L6.605,13.554 L8.695,13.554 L9.267,10.518 L6.913,10.518 L7.122,9.385 C7.17333359,9.10633194 7.28699912,8.89916734 7.463,8.7635 C7.63900088,8.62783266 7.92499802,8.56 8.321,8.56 L9.542,8.56 L10.224,5.018 C10.282667,4.7246652 10.4183323,4.49733414 10.631,4.336 C10.8436677,4.17466586 11.0929986,4.094 11.379,4.094 L12.611,4.094 L11.775,8.56 L14.019,8.56 L14.866,4.094 L16.076,4.094 C16.3326679,4.094 16.5416659,4.1673326 16.703,4.314 C16.8643341,4.4606674 16.945,4.64766553 16.945,4.875 C16.945,4.9483337 16.9413334,5.00333315 16.934,5.04 L16.252,8.56 L18.485,8.56 L18.276,9.693 C18.2246664,9.97166806 18.1091676,10.1788327 17.9295,10.3145 C17.7498324,10.4501673 17.4656686,10.518 17.077,10.518 L15.977,10.518 L15.416,13.554 L16.978,13.554 C17.2126678,13.554 17.3904994,13.6108328 17.5115,13.7245 C17.6325006,13.8381672 17.693,14.0306653 17.693,14.302 C17.693,14.4046672 17.6820001,14.5219993 17.66,14.654 L17.528,15.512 L15.141,15.512 Z M10.928,13.554 L13.183,13.554 L13.744,10.518 L11.5,10.518 L10.928,13.554 Z", + attrs: { + viewBox: "0 0 24 24" + } + }, + io: "M1,9 L6,9 L6,24 L1,24 L1,9 Z M31,16 C31,11.581722 27.418278,8 23,8 C18.581722,8 15,11.581722 15,16 C15,20.418278 18.581722,24 23,24 C27.418278,24 31,20.418278 31,16 Z M19,16 C19,13.790861 20.790861,12 23,12 C25.209139,12 27,13.790861 27,16 C27,18.209139 25.209139,20 23,20 C20.790861,20 19,18.209139 19,16 Z M15.3815029,9 L13.4537572,9 L7,23.5 L8.92774566,23.5 L15.3815029,9 Z", + join_full_outer: "M16.044 7.903A9.955 9.955 0 0 1 22 5.936c5.523 0 10 4.477 10 10s-4.477 10-10 10a9.955 9.955 0 0 1-5.903-1.928l-.097.065-.051-.034A9.955 9.955 0 0 1 10 26C4.477 26 0 21.523 0 16S4.477 6 10 6c2.211 0 4.255.718 5.911 1.933l.089-.06.044.03zm0 0l-.087.064-.046-.034-.25.168c-2.648 1.78-4.261 4.695-4.261 7.872 0 3.177 1.613 6.092 4.262 7.873l.287.193.094-.07.054.04.241-.163c2.649-1.781 4.262-4.696 4.262-7.873 0-3.177-1.613-6.091-4.262-7.872l-.294-.198zm-3.444 8.07c0-2.643 1.276-5.08 3.4-6.657 2.124 1.578 3.4 4.014 3.4 6.657 0 2.644-1.276 5.08-3.4 6.658-2.124-1.578-3.4-4.014-3.4-6.658z", + join_inner: "M14.923 7.148c-.427.315-.826.66-1.195 1.03a8.865 8.865 0 0 0-3.546-.734C5.35 7.444 1.444 11.28 1.444 16c0 4.72 3.906 8.556 8.738 8.556 1.547 0 2.999-.393 4.258-1.083.26.217.533.423.816.616l.454.31A10.268 10.268 0 0 1 10.182 26C4.559 26 0 21.523 0 16S4.559 6 10.182 6c1.712 0 3.325.415 4.74 1.148zm1.879 0c.434.315.84.66 1.217 1.03a9.172 9.172 0 0 1 3.611-.734c4.921 0 8.9 3.836 8.9 8.556 0 4.72-3.979 8.556-8.9 8.556a9.137 9.137 0 0 1-4.337-1.083c-.265.217-.543.423-.83.616L16 24.4A10.6 10.6 0 0 0 21.63 26C27.357 26 32 21.523 32 16S27.357 6 21.63 6c-1.743 0-3.386.415-4.828 1.148zM16 8c2.418 1.651 4 4.395 4 7.5 0 3.105-1.582 5.849-4 7.5-2.418-1.651-4-4.395-4-7.5 0-3.105 1.582-5.849 4-7.5z", + join_left_outer: "M17.077 7.148A10.285 10.285 0 0 1 21.818 6C27.441 6 32 10.477 32 16s-4.559 10-10.182 10c-2.038 0-3.936-.588-5.528-1.6l.454-.31c.283-.194.555-.4.816-.617a8.842 8.842 0 0 0 4.258 1.083c4.832 0 8.738-3.836 8.738-8.556 0-4.72-3.906-8.556-8.738-8.556a8.865 8.865 0 0 0-3.546.733 10.65 10.65 0 0 0-1.195-1.03zM15.71 24.399A10.268 10.268 0 0 1 10.182 26C4.559 26 0 21.523 0 16S4.559 6 10.182 6c1.712 0 3.325.415 4.74 1.148-2.643 1.957-4.241 5.022-4.241 8.352 0 3.468 1.733 6.649 4.575 8.59l.454.31zM16 8c2.418 1.651 4 4.395 4 7.5 0 3.105-1.582 5.849-4 7.5-2.418-1.651-4-4.395-4-7.5 0-3.105 1.582-5.849 4-7.5z", + json: "M28 10.105v18.728A3.166 3.166 0 0 1 24.834 32H6.166A3.163 3.163 0 0 1 3 28.844V3.156A3.163 3.163 0 0 1 6.16 0h13.553V10.105H28zm-.215-1.684h-6.4V.311l6.4 8.11zM10.894 19.233v-.218c1.162-.13 1.79-.718 1.79-1.703v-1.394c0-.964.322-1.333 1.19-1.333h.3v-1.45h-.505c-2.03 0-2.885.766-2.885 2.55v1.094c0 1.005-.451 1.388-1.613 1.395v1.9c1.169.007 1.613.39 1.613 1.395v1.066c0 1.805.862 2.584 2.885 2.584h.506v-1.45h-.301c-.861 0-1.19-.361-1.19-1.332v-1.401c0-.992-.628-1.573-1.79-1.703zm8.184-.212v.22c-1.162.122-1.791.71-1.791 1.701v1.395c0 .964-.321 1.333-1.19 1.333h-.3v1.45h.505c2.03 0 2.892-.766 2.892-2.55v-1.094c0-1.012.444-1.388 1.607-1.395v-1.9c-1.17-.014-1.607-.39-1.607-1.395v-1.073c0-1.798-.861-2.577-2.892-2.577h-.505v1.449h.3c.862 0 1.19.362 1.19 1.326v1.408c0 .985.629 1.573 1.79 1.702z", + key: { + path: "M11.5035746,7.9975248 C10.8617389,5.26208051 13.0105798,1.44695394 16.9897081,1.44695394 C20.919315,1.44695394 23.1811258,5.37076315 22.2565255,8.42469226 C21.3223229,7.86427598 20.2283376,7.54198814 19.0589133,7.54198814 C17.3567818,7.54198814 15.8144729,8.22477622 14.6920713,9.33083544 C14.4930673,9.31165867 14.2913185,9.30184676 14.087273,9.30184676 C10.654935,9.30184676 7.87247532,12.0782325 7.87247532,15.5030779 C7.87247532,17.1058665 8.48187104,18.5666337 9.48208198,19.6672763 L8.98356958,20.658345 L9.19925633,22.7713505 L7.5350473,23.4587525 C7.37507672,23.5248284 7.30219953,23.707739 7.37031308,23.8681037 L7.95501877,25.2447188 L6.28291833,25.7863476 C6.10329817,25.8445303 6.01548404,26.0233452 6.06755757,26.1919683 L6.54426059,27.7356153 L5.02460911,28.2609385 C4.86686602,28.3154681 4.7743984,28.501653 4.83652351,28.6704172 L6.04508836,31.95351 C6.10987939,32.1295162 6.29662279,32.2151174 6.46814592,32.160881 L9.48965349,31.2054672 C9.66187554,31.1510098 9.86840241,30.9790422 9.95250524,30.8208731 L14.8228902,21.6613229 C15.8820565,21.5366928 16.8596786,21.1462953 17.6869404,20.558796 C17.5652123,20.567429 17.4424042,20.5718139 17.318643,20.5718139 C14.2753735,20.5718139 11.8083161,17.9204625 11.8083161,14.6498548 C11.8083161,12.518229 12.8562751,10.6496514 14.428709,9.60671162 C13.4433608,10.7041074 12.8441157,12.1538355 12.8441157,13.7432193 C12.8441157,16.9974306 15.3562245,19.6661883 18.5509945,19.9240384 L19.1273026,21.5699573 L20.7971002,22.8826221 L20.1355191,24.5572635 C20.0719252,24.7182369 20.1528753,24.8977207 20.3155476,24.9601226 L21.7119724,25.4957977 L20.9400489,27.0748531 C20.8571275,27.2444782 20.9247553,27.4318616 21.082226,27.5115385 L22.5237784,28.2409344 L21.8460256,29.6990003 C21.7756734,29.8503507 21.8453702,30.0462011 22.0099247,30.1187455 L25.2111237,31.5300046 C25.3827397,31.6056621 25.5740388,31.5307937 25.6541745,31.3697345 L27.0658228,28.5325576 C27.1462849,28.3708422 27.1660474,28.1028205 27.1106928,27.9324485 L23.8023823,17.7500271 C24.7201964,16.6692906 25.273711,15.270754 25.273711,13.7432193 C25.273711,12.0364592 24.582689,10.4907436 23.4645818,9.36943333 C25.0880384,5.38579616 22.187534,0 16.9897081,0 C12.1196563,0 9.42801686,4.46934651 10.0266074,7.9975248 L11.5035746,7.9975248 Z M19.0589133,14.7767578 C20.203026,14.7767578 21.1305126,13.8512959 21.1305126,12.7096808 C21.1305126,11.5680656 20.203026,10.6426037 19.0589133,10.6426037 C17.9148007,10.6426037 16.9873141,11.5680656 16.9873141,12.7096808 C16.9873141,13.8512959 17.9148007,14.7767578 19.0589133,14.7767578 Z", + attrs: { + fillRule: "evenodd" + } + }, + label: "M14.577 31.042a2.005 2.005 0 0 1-2.738-.733L1.707 12.759c-.277-.477-.298-1.265-.049-1.757L6.45 1.537C6.7 1.044 7.35.67 7.9.7l10.593.582c.551.03 1.22.44 1.498.921l10.132 17.55a2.002 2.002 0 0 1-.734 2.737l-14.812 8.552zm.215-22.763a3.016 3.016 0 1 0-5.224 3.016 3.016 3.016 0 0 0 5.224-3.016z", + ldap: { + path: "M1.006 3h13.702c.554 0 1.178.41 1.39.915l.363.874c.21.504.827.915 1.376.915h13.169c.54 0 .994.448.994 1.001v20.952a.99.99 0 0 1-.992 1H1.002c-.54 0-.993-.45-.993-1.005l-.01-23.646C0 3.446.45 3 1.007 3zM16.5 19.164c1.944 0 3.52-1.828 3.52-4.082 0-2.254-1.576-4.082-3.52-4.082-1.945 0-3.52 1.828-3.52 4.082 0 2.254 1.575 4.082 3.52 4.082zm6.5 4.665c0-1.872-1.157-3.521-2.913-4.484-.927.97-2.192 1.568-3.587 1.568s-2.66-.597-3.587-1.568C11.157 20.308 10 21.957 10 23.83h13z", + attrs: { + fillRule: "evenodd" + } + }, + lightbulb: "M16.1 11.594L18.756 8.9a1.03 1.03 0 0 1 1.446-.018c.404.39.412 1.03.018 1.43l-3.193 3.24v4.975c0 .559-.458 1.011-1.022 1.011a1.017 1.017 0 0 1-1.023-1.01v-5.17l-3.003-3.046c-.394-.4-.386-1.04.018-1.43a1.03 1.03 0 0 1 1.446.018l2.657 2.695zM11.03 28.815h9.938a1.01 1.01 0 1 1 0 2.02 376.72 376.72 0 0 0-2.964.002C18.005 31.857 16.767 32 16 32c-.767 0-1.993-.139-1.993-1.163H11.03a1.011 1.011 0 0 1 0-2.022zm0-3.033h9.938a1.011 1.011 0 0 1 0 2.022H11.03a1.011 1.011 0 1 1 0-2.022zM8.487 20.43A11.659 11.659 0 0 1 4.5 11.627C4.5 5.214 9.64 0 16 0s11.5 5.214 11.5 11.627c0 3.43-1.481 6.617-3.987 8.803v1.308c0 1.954-1.601 3.538-3.577 3.538h-7.872c-1.976 0-3.577-1.584-3.577-3.538V20.43zm2.469-1.915l.597.455v2.768c0 .279.23.505.511.505h7.872a.508.508 0 0 0 .51-.505V18.97l.598-.455a8.632 8.632 0 0 0 3.39-6.888c0-4.755-3.785-8.594-8.434-8.594-4.649 0-8.433 3.84-8.433 8.594a8.632 8.632 0 0 0 3.389 6.888z", + link: "M12.56 17.04c-1.08 1.384-1.303 1.963 1.755 4.04 3.058 2.076 7.29.143 8.587-1.062 1.404-1.304 4.81-4.697 7.567-7.842 2.758-3.144 1.338-8.238-.715-9.987-5.531-4.71-9.5-.554-11.088.773-2.606 2.176-5.207 5.144-5.207 5.144s1.747-.36 2.784 0c1.036.36 2.102.926 2.102.926l4.003-3.969s2.367-1.907 4.575 0 .674 4.404 0 5.189c-.674.784-6.668 6.742-6.668 6.742s-1.52.811-2.37.811c-.85 0-2.582-.528-2.582-.932 0-.405-1.665-1.22-2.744.166zm7.88-2.08c1.08-1.384 1.303-1.963-1.755-4.04-3.058-2.076-7.29-.143-8.587 1.062-1.404 1.304-4.81 4.697-7.567 7.842-2.758 3.144-1.338 8.238.715 9.987 5.531 4.71 9.5.554 11.088-.773 2.606-2.176 5.207-5.144 5.207-5.144s-1.747.36-2.784 0a17.379 17.379 0 0 1-2.102-.926l-4.003 3.969s-2.367 1.907-4.575 0-.674-4.404 0-5.189c.674-.784 6.668-6.742 6.668-6.742s1.52-.811 2.37-.811c.85 0 2.582.528 2.582.932 0 .405 1.665 1.22 2.744-.166z", + line: "M18.867 16.377l-3.074-3.184-.08.077-.002-.002.01-.01-.53-.528-.066-.07-.001.002-2.071-2.072L-.002 23.645l2.668 2.668 10.377-10.377 3.074 3.183.08-.076.001.003-.008.008.5.501.094.097.002-.001 2.072 2.072L31.912 8.669 29.244 6 18.867 16.377z", + lineandbar: "M3.056 24.041h6.706v7.78H3.056v-7.78zm10.06-6.483h6.706v14.264h-6.707V17.558zm9.8-4.631h6.707v18.895h-6.706V12.927zm-11.812-1.582l-9.061 6.412L0 14.864l10.517-7.442 7.144 2.353L29.425 1l2.115 2.84-13.238 9.876-7.198-2.37z", + list: "M3 8 A3 3 0 0 0 9 8 A3 3 0 0 0 3 8 M12 6 L28 6 L28 10 L12 10z M3 16 A3 3 0 0 0 9 16 A3 3 0 0 0 3 16 M12 14 L28 14 L28 18 L12 18z M3 24 A3 3 0 0 0 9 24 A3 3 0 0 0 3 24 M12 22 L28 22 L28 26 L12 26z", + location: { + path: "M19.4917776,13.9890373 C20.4445763,12.5611169 21,10.8454215 21,9 C21,4.02943725 16.9705627,0 12,0 C7.02943725,0 3,4.02943725 3,9 C3,10.8454215 3.5554237,12.5611168 4.50822232,13.9890371 L4.49999986,14.0000004 L4.58010869,14.0951296 C4.91305602,14.5790657 5.29212089,15.0288088 5.71096065,15.4380163 L12.5,23.5 L19.4999993,13.9999996 L19.4917776,13.9890373 L19.4917776,13.9890373 Z M12,12 C13.6568542,12 15,10.6568542 15,9 C15,7.34314575 13.6568542,6 12,6 C10.3431458,6 9,7.34314575 9,9 C9,10.6568542 10.3431458,12 12,12 Z", + attrs: { + viewBox: "0 0 24 24", + fillRule: "evenodd" + } + }, + lock: { + path: "M9.215 7.215a3.607 3.607 0 0 1 3.607-3.608h6.313a3.607 3.607 0 0 1 3.607 3.608V9.25h3.607V7.215A7.215 7.215 0 0 0 19.134 0h-6.312a7.215 7.215 0 0 0-7.215 7.215v5.49A5.002 5.002 0 0 0 2 17.51V27a5 5 0 0 0 5 5h17.956a5 5 0 0 0 5-5v-9.49a5 5 0 0 0-5-5H9.215V7.214z", + attrs: { + fillRule: "evenodd" + } + }, + mail: { + path: "M36 0a6 6 0 016 6v20a6 6 0 01-6 6H6a6 6 0 01-6-6V6a6 6 0 016-6h30zm-3.292 5.473L21 15.38 9.292 5.473a2 2 0 10-2.584 3.054l13 11a2 2 0 002.584 0l13-11a2 2 0 10-2.584-3.054z", + attrs: { + viewBox: "0 0 42 32" + } + }, + moon: "M11.6291702,1.84239429e-11 C19.1234093,1.22958025 24.8413559,7.73631246 24.8413559,15.5785426 C24.8413559,24.2977683 17.7730269,31.3660972 9.05380131,31.3660972 C7.28632096,31.3660972 5.58667863,31.0756481 4,30.5398754 C11.5007933,28.2096945 16.9475786,21.2145715 16.9475786,12.9472835 C16.9475786,7.90001143 14.9174312,3.32690564 11.6291702,1.70246039e-11 L11.6291702,1.84239429e-11 Z", + move: "M23 27h-8v-5h8v-4l8 6-8 7v-4zM17.266 0h.86a2 2 0 0 1 1.42.592L27.49 8.61a2 2 0 0 1 .58 1.407v6h-5.01v-5.065L17.133 5H0V2a2 2 0 0 1 2-2h15.266zM5 27h7v5H2a2 2 0 0 1-2-2V5h5v22z", + new_folder: { + path: "M0 6a4 4 0 0 1 4-4h5.892a4 4 0 0 1 2.058.57L16 5h12a4 4 0 0 1 4 4v17a4 4 0 0 1-4 4H4a4 4 0 0 1-4-4V6zm16 6c.621 0 1.125.504 1.125 1.125v3.75h3.75a1.125 1.125 0 0 1 0 2.25h-3.75v3.75a1.125 1.125 0 0 1-2.25 0v-3.75h-3.75a1.125 1.125 0 0 1 0-2.25h3.75v-3.75c0-.621.504-1.125 1.125-1.125z", + attrs: { + fillRule: "evenodd", + clipRule: "evenodd" + } + }, + notebook: "M10.105 15.023c0-1.048.859-1.898 1.905-1.898h18.085c1.052 0 1.905.855 1.905 1.898v2.954a1.905 1.905 0 0 1-1.905 1.898H12.01a1.905 1.905 0 0 1-1.905-1.898v-2.954zm0 10.125c0-1.048.844-1.898 1.901-1.898h6.304c1.05 0 1.9.855 1.9 1.898v2.954A1.895 1.895 0 0 1 18.31 30h-6.304c-1.05 0-1.9-.855-1.9-1.898v-2.954zM0 15.023a1.9 1.9 0 0 1 1.895-1.898h2.947a1.9 1.9 0 0 1 1.895 1.898v2.954a1.9 1.9 0 0 1-1.895 1.898H1.895A1.9 1.9 0 0 1 0 17.977v-2.954zm0 10.125a1.9 1.9 0 0 1 1.895-1.898h2.947a1.9 1.9 0 0 1 1.895 1.898v2.954A1.9 1.9 0 0 1 4.842 30H1.895A1.9 1.9 0 0 1 0 28.102v-2.954zm10.105-20.25c0-1.048.848-1.898 1.89-1.898h11.379c1.043 0 1.89.855 1.89 1.898v2.954a1.895 1.895 0 0 1-1.89 1.898h-11.38a1.897 1.897 0 0 1-1.889-1.898V4.898zM0 4.898A1.9 1.9 0 0 1 1.895 3h2.947a1.9 1.9 0 0 1 1.895 1.898v2.954A1.9 1.9 0 0 1 4.842 9.75H1.895A1.9 1.9 0 0 1 0 7.852V4.898z", + number: "M0 .503A.5.5 0 0 1 .503 0h30.994A.5.5 0 0 1 32 .503v30.994a.5.5 0 0 1-.503.503H.503A.5.5 0 0 1 0 31.497V.503zM8.272 22V10.8H6.464c-.064.427-.197.784-.4 1.072-.203.288-.45.52-.744.696a2.984 2.984 0 0 1-.992.368c-.368.07-.75.099-1.144.088v1.712H6V22h2.272zm2.96-5.648c0 1.12.11 2.056.328 2.808.219.752.515 1.352.888 1.8.373.448.808.768 1.304.96a4.327 4.327 0 0 0 1.576.288c.565 0 1.096-.096 1.592-.288a3.243 3.243 0 0 0 1.312-.96c.379-.448.677-1.048.896-1.8.219-.752.328-1.688.328-2.808 0-1.088-.11-2.003-.328-2.744-.219-.741-.517-1.336-.896-1.784a3.243 3.243 0 0 0-1.312-.96 4.371 4.371 0 0 0-1.592-.288c-.555 0-1.08.096-1.576.288-.496.192-.93.512-1.304.96-.373.448-.67 1.043-.888 1.784-.219.741-.328 1.656-.328 2.744zm2.272 0c0-.192.003-.424.008-.696.005-.272.024-.552.056-.84.032-.288.085-.573.16-.856a2.95 2.95 0 0 1 .312-.76 1.67 1.67 0 0 1 .512-.544c.208-.139.467-.208.776-.208.31 0 .57.07.784.208.213.139.39.32.528.544.139.224.243.477.312.76a7.8 7.8 0 0 1 .224 1.696 25.247 25.247 0 0 1-.024 1.856c-.021.453-.088.89-.2 1.312a2.754 2.754 0 0 1-.544 1.08c-.25.299-.61.448-1.08.448-.459 0-.81-.15-1.056-.448a2.815 2.815 0 0 1-.536-1.08 6.233 6.233 0 0 1-.2-1.312c-.021-.453-.032-.84-.032-1.16zm6.624 0c0 1.12.11 2.056.328 2.808.219.752.515 1.352.888 1.8.373.448.808.768 1.304.96a4.327 4.327 0 0 0 1.576.288c.565 0 1.096-.096 1.592-.288a3.243 3.243 0 0 0 1.312-.96c.379-.448.677-1.048.896-1.8.219-.752.328-1.688.328-2.808 0-1.088-.11-2.003-.328-2.744-.219-.741-.517-1.336-.896-1.784a3.243 3.243 0 0 0-1.312-.96 4.371 4.371 0 0 0-1.592-.288c-.555 0-1.08.096-1.576.288-.496.192-.93.512-1.304.96-.373.448-.67 1.043-.888 1.784-.219.741-.328 1.656-.328 2.744zm2.272 0c0-.192.003-.424.008-.696.005-.272.024-.552.056-.84.032-.288.085-.573.16-.856a2.95 2.95 0 0 1 .312-.76 1.67 1.67 0 0 1 .512-.544c.208-.139.467-.208.776-.208.31 0 .57.07.784.208.213.139.39.32.528.544.139.224.243.477.312.76a7.8 7.8 0 0 1 .224 1.696 25.247 25.247 0 0 1-.024 1.856c-.021.453-.088.89-.2 1.312a2.754 2.754 0 0 1-.544 1.08c-.25.299-.61.448-1.08.448-.459 0-.81-.15-1.056-.448a2.815 2.815 0 0 1-.536-1.08 6.233 6.233 0 0 1-.2-1.312c-.021-.453-.032-.84-.032-1.16z", + palette: { + path: "M21.925 3.275c11.278 5.97 11.278 16.586 8.625 17.912-1.99.664-3.317-2.653-3.317-2.653-.443-.885-1.327-.995-1.99 0-.74 1.109.39 4.12 1.027 5.814.125.332.23.614.3.82.663 1.99 0 4.312-1.991 5.307-1.99.995-7.855 1.4-12.973 0C7.304 29.298.492 24.807.033 16.544-.69 3.554 10.647-2.696 21.925 3.275zm-.696 5.021a2.654 2.654 0 1 1-5.307 0 2.654 2.654 0 0 1 5.307 0zM10.391 9.91a2.654 2.654 0 1 0 0-5.307 2.654 2.654 0 0 0 0 5.307zm-1.989 4.577a2.654 2.654 0 1 1-5.307 0 2.654 2.654 0 0 1 5.307 0zm2.213 10.018a2.654 2.654 0 1 0 0-5.307 2.654 2.654 0 0 0 0 5.307z", + attrs: { + fillRule: "evenodd" + } + }, + pencil: "M21.187 4.359L24.71.835c1.363-1.362 3.912-1.022 5.694.76 1.783 1.783 2.123 4.332.761 5.695l-3.523 3.523-6.455-6.454zM19.425 6.12L1.455 24.091C.091 25.453-.47 30.625.452 31.547c.922.922 6.094.361 7.456-1.001l17.97-17.971-6.454-6.455z", + permissions_limited: "M0,16 C0,7.163444 7.163444,0 16,0 C24.836556,0 32,7.163444 32,16 C32,24.836556 24.836556,32 16,32 C7.163444,32 0,24.836556 0,16 Z M29,16 C29,8.82029825 23.1797017,3 16,3 C8.82029825,3 3,8.82029825 3,16 C3,23.1797017 8.82029825,29 16,29 C23.1797017,29 29,23.1797017 29,16 Z M16,5 C11.0100706,5.11743299 5.14533409,7.90852303 5,15.5 C4.85466591,23.091477 11.0100706,26.882567 16,27 L16,5 Z", + person: "M16.068.005c5.181-.185 7.295 4.545 7.295 7.258s-1.34 6.71-3.607 8.77c-.5.456-.408 3.34.686 3.808 2.294.982 8.57 2.97 8.808 7.065.265 4.558-7.968 5.022-13.043 5.022-5.075 0-13.207-.62-13.207-4.45 0-1.776.178-2.944 3.106-4.92 2.927-1.978 5.16-2.462 5.645-2.763.486-.3 1.384-1.861.8-3.606 0 0-3.518-3.842-3.518-8.074 0-4.232 1.853-7.925 7.035-8.11z", + pie: "M22.9192471,17.0666667 C22.9724214,16.7188743 23,16.3626578 23,16 C23,14.3667929 22.4406801,12.8642219 21.5031397,11.6733866 L28.0205298,5.44000778 C30.4977559,8.25762919 32,11.9533806 32,16 C32,16.3584305 31.988214,16.7141081 31.9650085,17.0666667 L22.9192471,17.0666667 Z M16,9 L16,-3.10862447e-15 C20.0533476,-3.55271368e-15 23.7546596,1.50724379 26.5740394,3.99183486 L20.2205338,10.4149697 C19.0471112,9.52684227 17.5850809,9 16,9 Z M13.8666667,9.33102327 C11.0439201,10.2332367 9,12.8779268 9,16 C9,19.8659932 12.1340068,23 16,23 C18.7129744,23 21.0654761,21.4566333 22.2274052,19.2 L31.679942,19.2 C30.197477,26.503169 23.7406653,32 16,32 C7.163444,32 -3.55271368e-15,24.836556 -3.55271368e-15,16 C-3.55271368e-15,7.88676941 6.03869982,1.18395273 13.8666667,0.140982757 L13.8666667,9.33102327 Z", + pin: "M9.417 4.226A2.183 2.183 0 0 1 10.182 0h12.636a2.182 2.182 0 0 1 .765 4.226v9.003a2.183 2.183 0 0 1-.765 4.226H10.182a2.182 2.182 0 0 1-.765-4.226V4.226zm4.25 14.683h5.666L16.5 32l-2.833-13.09z", + pinmap: "M13.4 18.987v8.746L15.533 32l2.134-4.25v-8.763a10.716 10.716 0 0 1-4.267 0zm2.133-1.92a8.533 8.533 0 1 0 0-17.067 8.533 8.533 0 0 0 0 17.067z", + pivot_table: { + path: "M9.846 0H0v9.846h9.846V0zM32 12.308H12.308V32H32V12.308zm-32 0h9.846V32H0V12.308zM32 0H12.308v9.846H32V0z", + attrs: { + fillRule: "evenodd" + } + }, + play: "M2 2.432v27.136a2 2 0 0 0 2.986 1.74L28.929 17.74a2 2 0 0 0 0-3.48L4.986.692A2 2 0 0 0 2 2.432z", + popover: "M5 7.52564C5 6.42107 5.89543 5.52564 7 5.52564H12.7647L15.2632 2.80292C15.6595 2.37107 16.3405 2.37107 16.7368 2.80292L19.2353 5.52564H25C26.1046 5.52564 27 6.42107 27 7.52564V25.5C27 26.6046 26.1046 27.5 25 27.5H7C5.89543 27.5 5 26.6046 5 25.5V7.52564Z", + popular: "M23.29 11.224l-7.067 7.067-2.658-2.752.007-.007-.386-.385-.126-.131-.003.002-1.789-1.79L.705 23.793A.994.994 0 0 0 .704 25.2l.896.897a1 1 0 0 0 1.408-.002l8.253-8.252 2.654 2.748.226-.218-.161.161 1.152 1.152c.64.64 1.668.636 2.304 0l8.158-8.159L32 19.933V5H17.067l6.223 6.224z", + progress: { + path: "M0 11.996A3.998 3.998 0 0 1 4.004 8h23.992A4 4 0 0 1 32 11.996v8.008A3.998 3.998 0 0 1 27.996 24H4.004A4 4 0 0 1 0 20.004v-8.008zM22 11h3.99A3.008 3.008 0 0 1 29 14v4c0 1.657-1.35 3-3.01 3H22V11z", + attrs: { + fillRule: "evenodd" + } + }, + pulse: "M16.9862306,27.387699 C17.4904976,29.2137955 20.0148505,29.3806482 20.7550803,27.6368095 L24.8588086,17.9692172 L31.7352165,17.9692172 L31.7352165,13.9692172 L23.5350474,13.9692172 C22.7324769,13.9692172 22.0076375,14.4489743 21.6940431,15.1877423 L19.314793,20.7927967 L14.8067319,4.4678059 C14.3010535,2.63659841 11.7668377,2.47581319 11.033781,4.22842821 L6.99549907,13.8832799 L0,13.8832799 L0,17.8832799 L8.32686781,17.8832799 C9.13327931,17.8832799 9.86080237,17.3989791 10.1719732,16.655022 L12.491241,11.1100437 L16.9862306,27.387699 Z", + recents: "M32 16c0 8.837-7.163 16-16 16S0 24.837 0 16 7.163 0 16 0s16 7.163 16 16zM9.553 22.447a1.778 1.778 0 0 1 0-2.514l4.67-4.67V6.452a1.778 1.778 0 1 1 3.555 0V16l-.52 1.257-5.191 5.19a1.778 1.778 0 0 1-2.514 0z", + share: "M29.5 22.725c-1.46 0-2.5-1.183-2.5-2.643V9L5 31.226c-1.032 1.032-2.968 1.032-4 0S-.258 28.52.774 27.488L23 5H12c-1.46 0-2.725-1.04-2.725-2.5S10.54 0 12 0h16.5c2 0 3.5 1.5 3.5 4v16.082c0 1.46-1.04 2.643-2.5 2.643z", + sql: { + path: "M4,0 L28,0 C30.209139,-4.05812251e-16 32,1.790861 32,4 L32,28 C32,30.209139 30.209139,32 28,32 L4,32 C1.790861,32 2.705415e-16,30.209139 0,28 L0,4 L0,4 C-2.705415e-16,1.790861 1.790861,4.05812251e-16 4,0 L4,0 Z M6,6 C4.8954305,6 4,6.8954305 4,8 L4,26 C4,27.1045695 4.8954305,28 6,28 L26,28 C27.1045695,28 28,27.1045695 28,26 L28,8 C28,6.8954305 27.1045695,6 26,6 L6,6 Z M14,20 L25,20 L25,24 L14,24 L14,20 Z M14,13.5 L8,17 L8,10 L14,13.5 Z", + attrs: { + fillRule: "evenodd" + } + }, + straight: "M2.1 27.101L0 23.516 29.9 6 32 9.585z", + stepped: "M13.946 17.892v8H1V22h9.054v-8h9V6H32v3.892h-9.054v8z", + sort: "M14.615.683c.765-.926 2.002-.93 2.77 0L26.39 11.59c.765.927.419 1.678-.788 1.678H6.398c-1.2 0-1.557-.747-.788-1.678L14.615.683zm2.472 30.774c-.6.727-1.578.721-2.174 0l-9.602-11.63c-.6-.727-.303-1.316.645-1.316h20.088c.956 0 1.24.595.645 1.316l-9.602 11.63z", + sum: "M3 27.41l1.984 4.422L27.895 32l.04-5.33-17.086-.125 8.296-9.457-.08-3.602L11.25 5.33H27.43V0H5.003L3.08 4.51l10.448 10.9z", + sync: "M19.506 8.633a9.3 9.3 0 0 0-7.864-.534C6.81 9.966 4.395 15.422 6.251 20.285c1.855 4.863 7.276 7.292 12.11 5.425a9.332 9.332 0 0 0 3.72-2.622l4.746 3.101a14.935 14.935 0 0 1-6.451 4.805C12.643 33.98 3.968 30.094 1 22.313c-2.968-7.781.894-16.51 8.627-19.497 4.395-1.698 9.096-1.175 12.879 1.022L24.907 0 31 12.733H16.94l2.566-4.1z", + question: "M16,32 C24.836556,32 32,24.836556 32,16 C32,7.163444 24.836556,0 16,0 C7.163444,0 0,7.163444 0,16 C0,24.836556 7.163444,32 16,32 L16,32 Z M16,29.0909091 C8.77009055,29.0909091 2.90909091,23.2299095 2.90909091,16 C2.90909091,8.77009055 8.77009055,2.90909091 16,2.90909091 C23.2299095,2.90909091 29.0909091,8.77009055 29.0909091,16 C29.0909091,23.2299095 23.2299095,29.0909091 16,29.0909091 Z M12,9.56020942 C12.2727286,9.34380346 12.5694087,9.1413622 12.8900491,8.95287958 C13.2106896,8.76439696 13.5552807,8.59860455 13.9238329,8.45549738 C14.2923851,8.31239021 14.6885728,8.20069848 15.1124079,8.12041885 C15.5362429,8.04013921 15.9950835,8 16.4889435,8 C17.1818216,8 17.8065083,8.08725916 18.3630221,8.2617801 C18.919536,8.43630105 19.3931184,8.68586225 19.7837838,9.0104712 C20.1744491,9.33508016 20.4748147,9.7260012 20.6848894,10.1832461 C20.8949642,10.6404909 21,11.1483393 21,11.7068063 C21,12.2373499 20.9226052,12.6963331 20.7678133,13.0837696 C20.6130213,13.4712061 20.4176916,13.8080265 20.1818182,14.0942408 C19.9459448,14.3804552 19.6861194,14.6282712 19.4023342,14.8376963 C19.1185489,15.0471215 18.8495099,15.2408368 18.5952088,15.4188482 C18.3409078,15.5968595 18.1197798,15.773123 17.9318182,15.947644 C17.7438566,16.1221649 17.6240789,16.3176254 17.5724816,16.5340314 L17.2628993,18 L14.9189189,18 L14.6756757,16.3141361 C14.6167073,15.9720751 14.653562,15.6736487 14.7862408,15.4188482 C14.9189196,15.1640476 15.1013502,14.9336834 15.3335381,14.7277487 C15.565726,14.521814 15.8255514,14.3263535 16.1130221,14.1413613 C16.4004928,13.9563691 16.6695319,13.7574182 16.9201474,13.5445026 C17.1707629,13.3315871 17.3826773,13.0942421 17.5558968,12.8324607 C17.7291163,12.5706793 17.8157248,12.2582915 17.8157248,11.895288 C17.8157248,11.4764377 17.6701489,11.1431077 17.3789926,10.895288 C17.0878364,10.6474682 16.6879632,10.5235602 16.1793612,10.5235602 C15.7886958,10.5235602 15.462532,10.5619542 15.20086,10.6387435 C14.9391879,10.7155327 14.7143744,10.8010466 14.5264128,10.895288 C14.3384511,10.9895293 14.1744479,11.0750432 14.034398,11.1518325 C13.8943482,11.2286217 13.7543005,11.2670157 13.6142506,11.2670157 C13.2972957,11.2670157 13.0614258,11.1378721 12.9066339,10.8795812 L12,9.56020942 Z M14,22 C14,21.7192968 14.0511359,21.4580909 14.1534091,21.2163743 C14.2556823,20.9746577 14.3958324,20.7641335 14.5738636,20.5847953 C14.7518948,20.4054572 14.96212,20.2631584 15.2045455,20.1578947 C15.4469709,20.0526311 15.7121198,20 16,20 C16.2803044,20 16.5416655,20.0526311 16.7840909,20.1578947 C17.0265164,20.2631584 17.2386355,20.4054572 17.4204545,20.5847953 C17.6022736,20.7641335 17.7443177,20.9746577 17.8465909,21.2163743 C17.9488641,21.4580909 18,21.7192968 18,22 C18,22.2807032 17.9488641,22.5438584 17.8465909,22.7894737 C17.7443177,23.0350889 17.6022736,23.2475625 17.4204545,23.4269006 C17.2386355,23.6062387 17.0265164,23.7465882 16.7840909,23.8479532 C16.5416655,23.9493182 16.2803044,24 16,24 C15.7121198,24 15.4469709,23.9493182 15.2045455,23.8479532 C14.96212,23.7465882 14.7518948,23.6062387 14.5738636,23.4269006 C14.3958324,23.2475625 14.2556823,23.0350889 14.1534091,22.7894737 C14.0511359,22.5438584 14,22.2807032 14,22 Z", + return: "M15.3040432,11.8500793 C22.1434689,13.0450349 27.291257,18.2496116 27.291257,24.4890512 C27.291257,25.7084278 27.0946472,26.8882798 26.7272246,28.0064033 L26.7272246,28.0064033 C25.214579,22.4825472 20.8068367,18.2141694 15.3040432,17.0604596 L15.3040432,25.1841972 L4.70874296,14.5888969 L15.3040432,3.99359668 L15.3040432,3.99359668 L15.3040432,11.8500793 Z", + reference: "M32 25h-5V7a2 2 0 0 0-2-2H7a2 2 0 1 0 0 4h16v23H4a4 4 0 0 1-4-4V6a6 6 0 0 1 6-6h22a4 4 0 0 1 4 4v21z", + refresh: "M19.506 8.633a9.3 9.3 0 0 0-7.864-.534C6.81 9.966 4.395 15.422 6.251 20.285c1.855 4.863 7.276 7.292 12.11 5.425a9.332 9.332 0 0 0 3.72-2.622l4.746 3.101a14.935 14.935 0 0 1-6.451 4.805C12.643 33.98 3.968 30.094 1 22.313c-2.968-7.781.894-16.51 8.627-19.497 4.395-1.698 9.096-1.175 12.879 1.022L24.907 0 31 12.733H16.94l2.566-4.1z", + ruler: "M0.595961814,24.9588734 C-0.196619577,24.166292 -0.200005392,22.8846495 0.593926984,22.0907171 L22.0908075,0.593836573 C22.8822651,-0.197621013 24.1641442,-0.198948234 24.9589638,0.595871404 L31.4040382,7.04094576 C32.1966196,7.83352715 32.2000054,9.11516967 31.406073,9.90910205 L9.90919246,31.4059826 C9.11773487,32.1974402 7.83585581,32.1987674 7.04103617,31.4039478 L0.595961814,24.9588734 Z M17.8319792,7.8001489 L16.3988585,9.23326963 L18.548673,11.3830842 C18.9443414,11.7787526 18.9470387,12.4175604 18.5485351,12.816064 C18.1527906,13.2118086 17.5140271,13.2146738 17.1155553,12.816202 L14.9657407,10.6663874 L13.5326229,12.0995052 L15.6824375,14.2493198 C16.0781059,14.6449881 16.0808032,15.283796 15.6822996,15.6822996 C15.286555,16.0780441 14.6477916,16.0809094 14.2493198,15.6824375 L12.0995052,13.5326229 L10.6663845,14.9657436 C10.6670858,14.9664411 10.6677865,14.9671398 10.6684864,14.9678397 L14.2470828,18.5464361 C14.6439866,18.9433399 14.6476854,19.5831493 14.2491818,19.9816529 C13.8534373,20.3773974 13.2188552,20.384444 12.813965,19.9795538 L9.23536867,16.4009575 C9.23466875,16.4002576 9.23397006,16.3995569 9.2332726,16.3988555 L7.80015186,17.8319762 L9.94996646,19.9817908 C10.3456348,20.3774592 10.3483321,21.016267 9.94982851,21.4147706 C9.55408397,21.8105152 8.91532053,21.8133804 8.51684869,21.4149086 L6.3670341,19.265094 L4.93391633,20.6982118 L7.08373093,22.8480263 C7.47939928,23.2436947 7.48209658,23.8825026 7.08359298,24.2810062 C6.68784844,24.6767507 6.049085,24.6796159 5.65061316,24.2811441 L3.50079857,22.1313295 L2.02673458,23.6053935 L8.47576453,30.0544235 L30.0544235,8.47576453 L23.6053935,2.02673458 L22.1313295,3.50079857 L24.2811441,5.65061316 C24.6768125,6.04628152 24.6795098,6.68508938 24.2810062,7.08359298 C23.8852616,7.47933752 23.2464982,7.48220276 22.8480263,7.08373093 L20.6982118,4.93391633 L19.2650911,6.36703697 C19.2657924,6.36773446 19.2664931,6.36843318 19.267193,6.36913314 L22.8457894,9.94772948 C23.2426932,10.3446333 23.246392,10.9844427 22.8478884,11.3829463 C22.4521439,11.7786908 21.8175617,11.7857374 21.4126716,11.3808472 L17.8340753,7.8022509 C17.8333753,7.80155099 17.8326767,7.80085032 17.8319792,7.8001489 Z", + search: "M22.805 25.734c-5.582 4.178-13.543 3.718-18.632-1.37-5.58-5.581-5.595-14.615-.031-20.179 5.563-5.563 14.597-5.55 20.178.031 5.068 5.068 5.545 12.985 1.422 18.563l5.661 5.661a2.08 2.08 0 0 1 .003 2.949 2.085 2.085 0 0 1-2.95-.003l-5.651-5.652zm-1.486-4.371c3.895-3.895 3.885-10.218-.021-14.125-3.906-3.906-10.23-3.916-14.125-.021-3.894 3.894-3.885 10.218.022 14.124 3.906 3.907 10.23 3.916 14.124.022z", + segment: "M2.99631547,14.0294075 L2.99631579,1.99517286 C2.99631582,0.893269315 3.89614282,0 4.98985651,0 L30.0064593,0 C31.1074614,0 32,0.895880847 32,2.00761243 L32,26.8688779 C32,27.9776516 31.1071386,28.8764903 30.0003242,28.8764903 L17.7266598,28.8764903 L17.7266594,14.0294075 L2.99631547,14.0294075 Z M-7.10651809e-15,16.9955967 L-7.10651809e-15,30.0075311 C-7.10651809e-15,31.1079413 0.900469916,32 2.00155906,32 L14.3949712,32 L14.3949712,16.9955967 L-7.10651809e-15,16.9955967 Z", + shield: "M27.922 5.804c-5.157 0-10.667-3.294-13.46-5.804C10.69 3.16 6.118 5.333 1.57 5.804.314 5.804 0 7.029 0 7.529 0 16.314 2.04 29.333 14.62 32 27.52 29.172 29.73 11.892 28.856 7.059c-.144-.797-.677-1.255-.934-1.255z", + slack_colorized: { + img: "app/assets/img/slack.png", + img_2x: "app/assets/img/slack@2x.png" + }, + slack: "M20.209 0a3.374 3.374 0 0 0-3.374 3.374v8.417a3.374 3.374 0 1 0 6.748 0V3.374A3.374 3.374 0 0 0 20.209 0zm0 16.835a3.374 3.374 0 1 0 0 6.748h8.417a3.374 3.374 0 1 0 0-6.748H20.21zM0 11.79a3.374 3.374 0 0 1 3.374-3.374h8.417a3.374 3.374 0 1 1 0 6.748H3.374A3.374 3.374 0 0 1 0 11.791zM11.791 0a3.374 3.374 0 1 0 0 6.748h3.374V3.374A3.374 3.374 0 0 0 11.791 0zm13.461 11.791a3.374 3.374 0 1 1 3.374 3.374h-3.374v-3.374zM3.374 16.835a3.374 3.374 0 1 0 3.374 3.374v-3.374H3.374zm13.46 8.417h3.375a3.374 3.374 0 1 1-3.374 3.374v-3.374zm-5.043-8.417a3.374 3.374 0 0 0-3.374 3.374v8.417a3.374 3.374 0 1 0 6.748 0V20.21a3.374 3.374 0 0 0-3.374-3.374z", + smartscalar: "M9.806 9.347v13.016h-2.79V9.593L3.502 14.12a1.405 1.405 0 0 1-1.957.254 1.372 1.372 0 0 1-.256-1.937L7.418 4.54a1.404 1.404 0 0 1 2.219.008l6.08 7.953a1.372 1.372 0 0 1-.27 1.935c-.615.46-1.49.34-1.955-.268l-3.686-4.82zM24.806 23.016V13h-2.79v9.77l-3.514-4.527a1.405 1.405 0 0 0-1.957-.254 1.372 1.372 0 0 0-.256 1.937l6.129 7.897c.56.723 1.663.72 2.219-.008l6.08-7.953a1.372 1.372 0 0 0-.27-1.935 1.405 1.405 0 0 0-1.955.268l-3.686 4.82z", + snippet: { + path: "M1,2H8M1,5H9M1,8H6", + attrs: { + viewBox: "0 0 10 10", + style: { + strokeWidth: 2, + stroke: "currentcolor", + strokeLinecap: "round" + } + } + }, + star: "M16 0 L21 11 L32 12 L23 19 L26 31 L16 25 L6 31 L9 19 L0 12 L11 11", + star_outline: "M16 21.935l5.967 3.14-1.14-6.653 4.828-4.712-6.671-.97L16 6.685l-2.984 6.053-6.67.971 4.827 4.712-1.14 6.654L16 21.935zm-9.892 8.547l1.89-11.029L0 11.647l11.053-1.609L16 0l4.947 10.038L32 11.647l-7.997 7.806 1.889 11.03L16 25.274l-9.892 5.207z", + store: { + path: "M4.537.091a.475.475 0 01.103.663L2.957 3.058a.475.475 0 11-.767-.56L3.873.193a.475.475 0 01.664-.103zM.031 5.018A.95.95 0 01.952 3.84h12.101a.95.95 0 01.921 1.178l-1.812 7.308a1.424 1.424 0 01-1.382 1.081H3.225a1.424 1.424 0 01-1.382-1.081L.031 5.018zM8.745.754a.475.475 0 11.767-.56l1.683 2.303a.475.475 0 11-.767.56L8.745.755z", + attrs: { + viewBox: "0 0 15 14" + } + }, + string: { + path: "M14.022,18 L11.533,18 C11.2543319,18 11.0247509,17.935084 10.84425,17.80525 C10.6637491,17.675416 10.538667,17.5091677 10.469,17.3065 L9.652,14.8935 L4.389,14.8935 L3.572,17.3065 C3.50866635,17.4838342 3.38516758,17.6437493 3.2015,17.78625 C3.01783241,17.9287507 2.79300133,18 2.527,18 L0.019,18 L5.377,4.1585 L8.664,4.1585 L14.022,18 Z M5.13,12.7085 L8.911,12.7085 L7.638,8.918 C7.55566626,8.67733213 7.45908389,8.3939183 7.34825,8.06775 C7.23741611,7.7415817 7.12816721,7.3885019 7.0205,7.0085 C6.91916616,7.39483527 6.8146672,7.75266502 6.707,8.082 C6.5993328,8.41133498 6.49800047,8.69633213 6.403,8.937 L5.13,12.7085 Z M21.945,18 C21.6663319,18 21.4557507,17.9620004 21.31325,17.886 C21.1707493,17.8099996 21.0520005,17.6516679 20.957,17.411 L20.748,16.8695 C20.5009988,17.078501 20.2635011,17.2621659 20.0355,17.4205 C19.8074989,17.5788341 19.5715846,17.7134161 19.32775,17.82425 C19.0839154,17.9350839 18.8242514,18.0174164 18.54875,18.07125 C18.2732486,18.1250836 17.9676683,18.152 17.632,18.152 C17.1823311,18.152 16.7738352,18.0934173 16.4065,17.97625 C16.0391648,17.8590827 15.7272513,17.6865011 15.47075,17.4585 C15.2142487,17.2304989 15.016334,16.947085 14.877,16.60825 C14.737666,16.269415 14.668,15.8783355 14.668,15.435 C14.668,15.0866649 14.7566658,14.7288352 14.934,14.3615 C15.1113342,13.9941648 15.4184978,13.6600848 15.8555,13.35925 C16.2925022,13.0584152 16.8814963,12.8066677 17.6225,12.604 C18.3635037,12.4013323 19.297661,12.2873335 20.425,12.262 L20.425,11.844 C20.425,11.2676638 20.3062512,10.8512513 20.06875,10.59475 C19.8312488,10.3382487 19.4940022,10.21 19.057,10.21 C18.7086649,10.21 18.4236678,10.2479996 18.202,10.324 C17.9803322,10.4000004 17.7824175,10.4854995 17.60825,10.5805 C17.4340825,10.6755005 17.2646675,10.7609996 17.1,10.837 C16.9353325,10.9130004 16.7390011,10.951 16.511,10.951 C16.3083323,10.951 16.1357507,10.9019172 15.99325,10.80375 C15.8507493,10.7055828 15.7383337,10.5836674 15.656,10.438 L15.124,9.5165 C15.7193363,8.99083071 16.3795797,8.59975128 17.10475,8.34325 C17.8299203,8.08674872 18.6073292,7.9585 19.437,7.9585 C20.0323363,7.9585 20.5690809,8.05508237 21.04725,8.24825 C21.5254191,8.44141763 21.9307483,8.71058161 22.26325,9.05575 C22.5957517,9.40091839 22.8506658,9.81099763 23.028,10.286 C23.2053342,10.7610024 23.294,11.2803305 23.294,11.844 L23.294,18 L21.945,18 Z M18.563,16.2045 C18.9430019,16.2045 19.2754986,16.1380007 19.5605,16.005 C19.8455014,15.8719993 20.1336652,15.6566682 20.425,15.359 L20.425,13.991 C19.8359971,14.0163335 19.3515019,14.0669996 18.9715,14.143 C18.5914981,14.2190004 18.2906678,14.3139994 18.069,14.428 C17.8473322,14.5420006 17.6937504,14.6718326 17.60825,14.8175 C17.5227496,14.9631674 17.48,15.1214991 17.48,15.2925 C17.48,15.6281683 17.5718324,15.8640827 17.7555,16.00025 C17.9391676,16.1364173 18.2083316,16.2045 18.563,16.2045 L18.563,16.2045 Z", + attrs: { + viewBox: "0 0 24 24" + } + }, + sun: "M18.2857143,27.1999586 L18.2857143,29.7130168 C18.2857143,30.9760827 17.2711661,32 16,32 C14.7376349,32 13.7142857,30.9797942 13.7142857,29.7130168 L13.7142857,27.1999586 C14.4528227,27.3498737 15.2172209,27.4285714 16,27.4285714 C16.7827791,27.4285714 17.5471773,27.3498737 18.2857143,27.1999586 Z M13.7142857,4.80004141 L13.7142857,2.28698322 C13.7142857,1.02391726 14.7288339,0 16,0 C17.2623651,0 18.2857143,1.02020582 18.2857143,2.28698322 L18.2857143,4.80004141 C17.5471773,4.65012631 16.7827791,4.57142857 16,4.57142857 C15.2172209,4.57142857 14.4528227,4.65012631 13.7142857,4.80004141 Z M10.5518048,26.0488463 L8.93640145,27.9740091 C8.1245183,28.9415738 6.68916799,29.0738009 5.71539825,28.2567111 C4.74837044,27.4452784 4.62021518,26.0059593 5.43448399,25.0355515 L7.05102836,23.1090289 C8.00526005,24.3086326 9.1956215,25.3120077 10.5518048,26.0488463 Z M21.4481952,5.95115366 L23.0635986,4.02599087 C23.8754817,3.05842622 25.310832,2.92619908 26.2846018,3.74328891 C27.2516296,4.55472158 27.3797848,5.99404073 26.565516,6.96444852 L24.9489716,8.89097108 C23.9947399,7.69136735 22.8043785,6.68799226 21.4481952,5.95115366 Z M7.05102836,8.89097108 L5.43448399,6.96444852 C4.62260085,5.99688386 4.7416285,4.56037874 5.71539825,3.74328891 C6.68242605,2.93185624 8.12213263,3.05558308 8.93640145,4.02599087 L10.5518048,5.95115366 C9.1956215,6.68799226 8.00526005,7.69136735 7.05102836,8.89097108 Z M24.9489716,23.1090289 L26.565516,25.0355515 C27.3773992,26.0031161 27.2583715,27.4396213 26.2846018,28.2567111 C25.317574,29.0681438 23.8778674,28.9444169 23.0635986,27.9740091 L21.4481952,26.0488463 C22.8043785,25.3120077 23.9947399,24.3086326 24.9489716,23.1090289 Z M27.1999586,13.7142857 L29.7130168,13.7142857 C30.9760827,13.7142857 32,14.7288339 32,16 C32,17.2623651 30.9797942,18.2857143 29.7130168,18.2857143 L27.1999586,18.2857143 C27.3498737,17.5471773 27.4285714,16.7827791 27.4285714,16 C27.4285714,15.2172209 27.3498737,14.4528227 27.1999586,13.7142857 Z M4.80004141,18.2857143 L2.28698322,18.2857143 C1.02391726,18.2857143 2.7533531e-14,17.2711661 2.84217094e-14,16 C2.84217094e-14,14.7376349 1.02020582,13.7142857 2.28698322,13.7142857 L4.80004141,13.7142857 C4.65012631,14.4528227 4.57142857,15.2172209 4.57142857,16 C4.57142857,16.7827791 4.65012631,17.5471773 4.80004141,18.2857143 Z M16,22.8571429 C19.7870954,22.8571429 22.8571429,19.7870954 22.8571429,16 C22.8571429,12.2129046 19.7870954,9.14285714 16,9.14285714 C12.2129046,9.14285714 9.14285714,12.2129046 9.14285714,16 C9.14285714,19.7870954 12.2129046,22.8571429 16,22.8571429 Z", + table: "M11.077 11.077h9.846v9.846h-9.846v-9.846zm11.077 11.077H32V32h-9.846v-9.846zm-11.077 0h9.846V32h-9.846v-9.846zM0 22.154h9.846V32H0v-9.846zM0 0h9.846v9.846H0V0zm0 11.077h9.846v9.846H0v-9.846zM22.154 0H32v9.846h-9.846V0zm0 11.077H32v9.846h-9.846v-9.846zM11.077 0h9.846v9.846h-9.846V0z", + table2: "M1.6 0h28.8A1.6 1.6 0 0 1 32 1.6v28.8a1.6 1.6 0 0 1-1.6 1.6H1.6A1.6 1.6 0 0 1 0 30.4V1.6A1.6 1.6 0 0 1 1.6 0zm1.6 3.2v6.4h6.4V3.2H3.2zm9.6 0v6.4h16V3.2h-16zm-9.6 9.6v6.4h6.4v-6.4H3.2zm9.6 0v6.4h16v-6.4h-16zm-9.6 9.6v6.4h6.4v-6.4H3.2zm9.6 0v6.4h16v-6.4h-16z", + table_spaced: "M0 0h7.784v7.784H0V0zm12.108 0h7.784v7.784h-7.784V0zm12.108 0H32v7.784h-7.784V0zM0 12.108h7.784v7.784H0v-7.784zm12.108 0h7.784v7.784h-7.784v-7.784zm12.108 0H32v7.784h-7.784v-7.784zM0 24.216h7.784V32H0v-7.784zm12.108 0h7.784V32h-7.784v-7.784zm12.108 0H32V32h-7.784v-7.784z", + trash: "M4.31904507,29.7285487 C4.45843264,30.9830366 5.59537721,32 6.85726914,32 L20.5713023,32 C21.8337371,32 22.9701016,30.9833707 23.1095264,29.7285487 L25.1428571,11.4285714 L2.28571429,11.4285714 L4.31904507,29.7285487 L4.31904507,29.7285487 Z M6.85714286,4.57142857 L8.57142857,0 L18.8571429,0 L20.5714286,4.57142857 L25.1428571,4.57142857 C27.4285714,4.57142857 27.4285714,9.14285714 27.4285714,9.14285714 L13.7142857,9.14285714 L-1.0658141e-14,9.14285714 C-1.0658141e-14,9.14285714 -1.0658141e-14,4.57142857 2.28571429,4.57142857 L6.85714286,4.57142857 L6.85714286,4.57142857 Z M9.14285714,4.57142857 L18.2857143,4.57142857 L17.1428571,2.28571429 L10.2857143,2.28571429 L9.14285714,4.57142857 L9.14285714,4.57142857 Z", + triangle_left: "M21,0 L5,16 L21,32 L21,5.47117907e-13 L21,0 Z", + triangle_right: "M9,0 L25,16 L9,32 L9,5.47117907e-13 L9,0 Z", + unarchive: { + path: "M6.857 2.762c0-.42.341-.762.762-.762h16.762a.762.762 0 0 1 0 1.524H7.619a.762.762 0 0 1-.762-.762zM0 11.809a6 6 0 0 1 6-6h20a6 6 0 0 1 6 6v12.382a6 6 0 0 1-6 6H6a6 6 0 0 1-6-6V11.81zm10.62 9.285c.447.446 1.17.446 1.617 0L16 17.33l3.763 3.764a1.143 1.143 0 0 0 1.617-1.616l-4.572-4.572a1.143 1.143 0 0 0-1.616 0l-4.572 4.572a1.143 1.143 0 0 0 0 1.616z", + attrs: { + fillRule: "evenodd" + } + }, + unknown: "M16.5,26.5 C22.0228475,26.5 26.5,22.0228475 26.5,16.5 C26.5,10.9771525 22.0228475,6.5 16.5,6.5 C10.9771525,6.5 6.5,10.9771525 6.5,16.5 C6.5,22.0228475 10.9771525,26.5 16.5,26.5 L16.5,26.5 Z M16.5,23.5 C12.6340068,23.5 9.5,20.3659932 9.5,16.5 C9.5,12.6340068 12.6340068,9.5 16.5,9.5 C20.3659932,9.5 23.5,12.6340068 23.5,16.5 C23.5,20.3659932 20.3659932,23.5 16.5,23.5 L16.5,23.5 Z", + variable: "M32,3.85760518 C32,5.35923081 31.5210404,6.55447236 30.5631068,7.4433657 C29.6051732,8.33225903 28.4358214,8.77669903 27.0550162,8.77669903 C26.2265331,8.77669903 25.4110072,8.67314019 24.6084142,8.46601942 C23.8058212,8.25889864 23.111114,8.05178097 22.5242718,7.84466019 C22.2481108,8.03452091 21.8425054,8.44875625 21.3074434,9.08737864 C20.7723814,9.72600104 20.1682882,10.5026923 19.4951456,11.4174757 C20.116508,14.0582656 20.6170423,15.9352695 20.9967638,17.0485437 C21.3764852,18.1618179 21.7389411,19.2880202 22.0841424,20.4271845 C22.3775635,21.3419679 22.8090586,22.0582498 23.3786408,22.5760518 C23.9482229,23.0938537 24.8457328,23.3527508 26.0711974,23.3527508 C26.5199591,23.3527508 27.0809028,23.2664518 27.7540453,23.0938511 C28.4271878,22.9212505 28.9795016,22.7486524 29.4110032,22.5760518 L28.8414239,24.9061489 C27.1326775,25.6310716 25.6397043,26.1574957 24.3624595,26.4854369 C23.0852148,26.8133781 21.9460676,26.9773463 20.9449838,26.9773463 C20.2200611,26.9773463 19.5037792,26.9083071 18.7961165,26.7702265 C18.0884539,26.632146 17.4412111,26.3818788 16.8543689,26.0194175 C16.2157465,25.6396961 15.6763776,25.1650514 15.236246,24.5954693 C14.7961143,24.0258871 14.4207135,23.2319361 14.1100324,22.2135922 C13.9029116,21.5749698 13.7130537,20.850058 13.5404531,20.038835 C13.3678524,19.2276119 13.1952544,18.51133 13.0226537,17.8899676 C12.5221118,18.6321504 12.1596559,19.1844642 11.9352751,19.5469256 C11.7108942,19.9093869 11.3829579,20.4185512 10.9514563,21.0744337 C9.5879112,23.1629015 8.4056145,24.6515597 7.40453074,25.5404531 C6.40344699,26.4293464 5.20389049,26.8737864 3.80582524,26.8737864 C2.75296129,26.8737864 1.85545139,26.5199604 1.11326861,25.8122977 C0.371085825,25.1046351 0,24.1812355 0,23.0420712 C0,21.5059254 0.478959612,20.2934241 1.4368932,19.4045307 C2.3948268,18.5156374 3.56417864,18.0711974 4.94498382,18.0711974 C5.77346693,18.0711974 6.56741799,18.1704413 7.32686084,18.368932 C8.08630369,18.5674228 8.80258563,18.7874853 9.47572816,19.0291262 C9.73462913,18.8220054 10.1359196,18.4164 10.6796117,17.8122977 C11.2233037,17.2081955 11.814452,16.4573939 12.4530744,15.5598706 C11.8834923,13.2470219 11.4174775,11.5037815 11.0550162,10.3300971 C10.6925548,9.15641269 10.321469,7.99137579 9.94174757,6.83495146 C9.63106641,5.90290796 9.18231146,5.18231107 8.59546926,4.67313916 C8.00862706,4.16396725 7.12837696,3.90938511 5.95469256,3.90938511 C5.43689061,3.90938511 4.85868712,3.99999909 4.22006472,4.18122977 C3.58144233,4.36246045 3.04638835,4.53074356 2.61488673,4.68608414 L3.18446602,2.35598706 C4.73787184,1.66558447 6.20927029,1.14779029 7.5987055,0.802588997 C8.98814071,0.457387702 10.1488627,0.284789644 11.0809061,0.284789644 C11.9266493,0.284789644 12.6515612,0.345198964 13.2556634,0.466019417 C13.8597657,0.586839871 14.4983785,0.845736958 15.171521,1.24271845 C15.7928834,1.62243987 16.3322523,2.10139948 16.789644,2.67961165 C17.2470357,3.25782382 17.6224365,4.04745994 17.9158576,5.04854369 C18.1229784,5.73894628 18.3128362,6.45522822 18.4854369,7.197411 C18.6580375,7.93959379 18.8047459,8.5782066 18.9255663,9.11326861 C19.2880277,8.56094654 19.6634285,7.99137294 20.0517799,7.40453074 C20.4401314,6.81768854 20.7723827,6.29989437 21.0485437,5.85113269 C22.3775687,3.76266485 23.5684953,2.2653767 24.6213592,1.3592233 C25.6742232,0.453069903 26.8651498,0 28.1941748,0 C29.2815588,0 30.1876986,0.358140971 30.9126214,1.07443366 C31.6375441,1.79072634 32,2.71844091 32,3.85760518 L32,3.85760518 Z", + verified: { + svg: '' + }, + view_archive: { + path: "M2.783 12.8h26.434V29H2.783V12.8zm6.956 3.4h12.522v2.6H9.739v-2.6zM0 4h32v6.4H0V4z", + attrs: { + fillRule: "evenodd" + } + }, + warning: { + path: "M12.3069589,4.52260192 C14.3462632,1.2440969 17.653446,1.24541073 19.691933,4.52260192 L31.2249413,23.0637415 C33.2642456,26.3422466 31.7889628,29 27.9115531,29 L4.08733885,29 C0.218100769,29 -1.26453645,26.3409327 0.77395061,23.0637415 L12.3069589,4.52260192 Z M18.0499318,23.0163223 C18.0499772,23.0222378 18.05,23.0281606 18.05,23.0340907 C18.05,23.3266209 17.9947172,23.6030345 17.8840476,23.8612637 C17.7737568,24.1186089 17.6195847,24.3426723 17.4224081,24.5316332 C17.2266259,24.7192578 16.998292,24.8660439 16.7389806,24.9713892 C16.4782454,25.0773129 16.1979962,25.1301134 15.9,25.1301134 C15.5950083,25.1301134 15.3111795,25.0774024 15.0502239,24.9713892 C14.7901813,24.8657469 14.5629613,24.7183609 14.3703047,24.5298034 C14.177545,24.3411449 14.0258626,24.1177208 13.9159524,23.8612637 C13.8052827,23.6030345 13.75,23.3266209 13.75,23.0340907 C13.75,22.7411889 13.8054281,22.4661013 13.9165299,22.2109786 C14.0264627,21.9585404 14.1779817,21.7374046 14.3703047,21.5491736 C14.5621821,21.3613786 14.7883231,21.2126553 15.047143,21.1034656 C15.3089445,20.9930181 15.593871,20.938068 15.9,20.938068 C16.1991423,20.938068 16.4804862,20.9931136 16.7420615,21.1034656 C17.0001525,21.2123478 17.2274115,21.360472 17.4224081,21.5473437 C17.6191428,21.7358811 17.7731504,21.957652 17.88347,22.2109786 C17.9124619,22.2775526 17.9376628,22.3454862 17.9590769,22.414741 C18.0181943,22.5998533 18.05,22.7963729 18.05,23 C18.05,23.0054459 18.0499772,23.0108867 18.0499318,23.0163223 L18.0499318,23.0163223 Z M17.7477272,14.1749999 L17.7477272,8.75 L14.1170454,8.75 L14.1170454,14.1749999 C14.1170454,14.8471841 14.1572355,15.5139742 14.2376219,16.1753351 C14.3174838,16.8323805 14.4227217,17.5019113 14.5533248,18.1839498 L14.5921937,18.3869317 L17.272579,18.3869317 L17.3114479,18.1839498 C17.442051,17.5019113 17.5472889,16.8323805 17.6271507,16.1753351 C17.7075371,15.5139742 17.7477272,14.8471841 17.7477272,14.1749999 Z", + attrs: { + fillRule: "evenodd" + } + }, + waterfall: { + path: "M12 0h8v13h-8V0zM0 13h8v19H0V13zM32 0h-8v21h8V0z", + attrs: { + fillRule: "evenodd" + } + }, + zoom_in: "M12.416 12.454V8.37h3.256v4.083h4.07v3.266h-4.07v4.083h-3.256V15.72h-4.07v-3.266h4.07zm10.389 13.28c-5.582 4.178-13.543 3.718-18.632-1.37-5.58-5.581-5.595-14.615-.031-20.179 5.563-5.563 14.597-5.55 20.178.031 5.068 5.068 5.545 12.985 1.422 18.563l5.661 5.661a2.08 2.08 0 0 1 .003 2.949 2.085 2.085 0 0 1-2.95-.003l-5.651-5.652zm-1.486-4.371c3.895-3.895 3.885-10.218-.021-14.125-3.906-3.906-10.23-3.916-14.125-.021-3.894 3.894-3.885 10.218.022 14.124 3.906 3.907 10.23 3.916 14.124.022z", + xlsx: "M28 10.105v18.728A3.166 3.166 0 0 1 24.834 32H6.166A3.163 3.163 0 0 1 3 28.844V3.156A3.163 3.163 0 0 1 6.16 0h13.553V10.105H28zm-.215-1.684h-6.4V.311l6.4 8.11zM9.446 25h2.427l2.796-3.37h.055L16.207 25h2.256l-2.18-4.888 4.32-4.976h-2.468l-2.769 3.343h-.054l-1.477-3.343h-2.256l2.18 4.874L9.447 25z", + zoom_out: "M22.8048272,25.7342559 C17.2227958,29.9120922 9.26170192,29.4524812 4.17264358,24.3634229 C-1.40785877,18.7829205 -1.42162182,9.74890155 4.14190296,4.18537677 C9.70542774,-1.37814801 18.7394467,-1.36438497 24.319949,4.21611739 C29.3880584,9.28422669 29.8647559,17.2007749 25.7421403,22.7792454 L31.4029793,28.4400843 C32.2180024,29.2551074 32.2248604,30.569663 31.4056282,31.3888951 C30.5920681,32.2024552 29.2715215,32.2009502 28.4568175,31.3862462 L22.8048272,25.7342559 Z M21.3193717,21.3628455 C25.213839,17.4683781 25.2042049,11.1445649 21.2978532,7.23821321 C17.3915016,3.33186156 11.0676883,3.32222743 7.17322097,7.21669477 C3.27875362,11.1111621 3.28838776,17.4349754 7.1947394,21.341327 C11.1010911,25.2476787 17.4249043,25.2573128 21.3193717,21.3628455 Z M8.34528717,12.453545 L19.7423242,12.453545 L19.7423242,15.7197782 L8.34528717,15.7197782 L8.34528717,12.453545 Z" +}; +ICON_PATHS["horizontal_bar"] = { + path: ICON_PATHS["bar"], + attrs: { + style: { + transform: "rotate(90deg) scaleX(-1)" + } + } +}; +ICON_PATHS["arrow_right"] = { + path: ICON_PATHS["arrow_left"].path, + attrs: _objectSpread(_objectSpread({}, ICON_PATHS["arrow_left"].attrs), {}, { + style: { + transform: "rotate(-180deg)" + } + }) +}; +ICON_PATHS["join_right_outer"] = { + path: ICON_PATHS["join_left_outer"], + attrs: { + style: { + transform: "rotate(-180deg)" + } + } +}; +ICON_PATHS["scalar"] = ICON_PATHS["number"]; +function parseViewBox(viewBox) { + // a viewBox is a string that takes the form 'min-x, min-y, width, height' + // grab the values and return just width and height since we currently don't + // tend to care about min-x or min-y + // we cast to numbers so we can do math-y stuff with the width and height + return viewBox.split(" ").map(function (v) { + return Number(v); + }).slice(2, 4); +} +function loadIcon(name) { + var def = ICON_PATHS[name]; + + if (!def) { + return null; + } + + if (def.img) { + return _objectSpread(_objectSpread({}, def), {}, { + attrs: _objectSpread(_objectSpread({}, def.attrs), {}, { + className: "Icon Icon-" + name + }) + }); + } + + var icon = { + attrs: { + className: "Icon Icon-" + name, + viewBox: "0 0 32 32", + width: 16, + height: 16, + fill: "currentcolor", + role: "img", + "aria-label": name + " icon" + }, + svg: undefined, + path: undefined + }; + + if (typeof def === "string") { + icon.path = def; + } else if (def != null) { + var svg = def.svg, + path = def.path, + attrs = def.attrs; + + for (var attr in attrs) { + icon.attrs[attr] = attrs[attr]; + } // Note - @kdoh 10/13/2017 + // in the case of a custom viewBox, we need to set the width and height + // of the icon def based on the view box since we're scaling all icons + // down by half currently + + + if (attrs && attrs.viewBox) { + var _parseViewBox = parseViewBox(attrs.viewBox), + _parseViewBox2 = _slicedToArray(_parseViewBox, 2), + width = _parseViewBox2[0], + height = _parseViewBox2[1]; + + icon.attrs.width = width / 2; + icon.attrs.height = height / 2; + } + + icon.path = path; + icon.svg = svg; + } + + return icon; +} + +/***/ }), + +/***/ "./lib/ace/theme-metabase.js": +/*!***********************************!*\ + !*** ./lib/ace/theme-metabase.js ***! + \***********************************/ +/***/ (function() { + +/*global ace*/ + +/* eslint-disable import/no-commonjs */ + +/* eslint-disable no-color-literals */ +ace.define("ace/theme/metabase", ["require", "exports", "module", "ace/lib/dom"], function (require, exports, module) { + exports.isDark = false; + exports.cssClass = "ace-metabase"; + exports.cssText = '\ +.ace-metabase .ace_gutter {\ +background: rgb(220,236,249);\ +color: #509EE3;\ +font-weight: bold;\ +}\ +.ace-metabase {\ +background: #fff;\ +color: #000;\ +}\ +.ace-metabase .ace_keyword {\ +font-weight: bold;\ +}\ +.ace-metabase .ace_string {\ +color: #A989C5;\ +font-weight: bold;\ +}\ +.ace-metabase .ace_variable.ace_class {\ +color: teal;\ +}\ +.ace-metabase .ace_constant.ace_numeric {\ +color: #6EA637;\ +}\ +.ace-metabase .ace_constant.ace_buildin {\ +color: #0086B3;\ +}\ +.ace-metabase .ace_support.ace_function {\ +color: #0086B3;\ +}\ +.ace-metabase .ace_comment {\ +color: #998;\ +font-style: italic;\ +}\ +.ace-metabase .ace_variable.ace_language {\ +color: #0086B3;\ +}\ +.ace-metabase .ace_paren {\ +font-weight: bold;\ +}\ +.ace-metabase .ace_boolean {\ +font-weight: bold;\ +}\ +.ace-metabase .ace_string.ace_regexp {\ +color: #009926;\ +font-weight: normal;\ +}\ +.ace-metabase .ace_variable.ace_instance {\ +color: teal;\ +}\ +.ace-metabase .ace_constant.ace_language {\ +font-weight: bold;\ +}\ +.ace-metabase .ace_cursor {\ +color: black;\ +}\ +.ace-metabase.ace_focus .ace_marker-layer .ace_active-line {\ +background: rgb(255, 255, 204);\ +}\ +.ace-metabase .ace_marker-layer .ace_active-line {\ +background: rgb(245, 245, 245);\ +}\ +.ace-metabase .ace_marker-layer .ace_selection {\ +background: rgb(181, 213, 255);\ +}\ +.ace-metabase.ace_multiselect .ace_selection.ace_start {\ +box-shadow: 0 0 3px 0px white;\ +}\ +.ace-metabase.ace_nobold .ace_line > span {\ +font-weight: normal !important;\ +}\ +.ace-metabase .ace_marker-layer .ace_step {\ +background: rgb(252, 255, 0);\ +}\ +.ace-metabase .ace_marker-layer .ace_stack {\ +background: rgb(164, 229, 101);\ +}\ +.ace-metabase .ace_marker-layer .ace_bracket {\ +margin: -1px 0 0 -1px;\ +border: 1px solid rgb(192, 192, 192);\ +}\ +.ace-metabase .ace_gutter-active-line {\ +background-color : rgba(0, 0, 0, 0.07);\ +}\ +.ace-metabase .ace_marker-layer .ace_selected-word {\ +background: rgb(250, 250, 255);\ +border: 1px solid rgb(200, 200, 250);\ +}\ +.ace-metabase .ace_invisible {\ +color: #BFBFBF\ +}\ +.ace-metabase .ace_print-margin {\ +width: 1px;\ +background: #e8e8e8;\ +}\ +.ace-metabase .ace_indent-guide {\ +background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAE0lEQVQImWP4////f4bLly//BwAmVgd1/w11/gAAAABJRU5ErkJggg==") right repeat-y;\ +}'; + + var dom = require("../lib/dom"); + + dom.importCssString(exports.cssText, exports.cssClass); +}); + +/***/ }), + +/***/ "./lib/analytics.js": +/*!**************************!*\ + !*** ./lib/analytics.js ***! + \**************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "createTracker": function() { return /* binding */ createTracker; }, +/* harmony export */ "trackPageView": function() { return /* binding */ trackPageView; }, +/* harmony export */ "trackStructEvent": function() { return /* binding */ trackStructEvent; }, +/* harmony export */ "trackSchemaEvent": function() { return /* binding */ trackSchemaEvent; } +/* harmony export */ }); +/* harmony import */ var _snowplow_browser_tracker__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @snowplow/browser-tracker */ "../../../node_modules/@snowplow/browser-tracker/dist/index.module.js"); +/* harmony import */ var metabase_lib_settings__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! metabase/lib/settings */ "./lib/settings.ts"); +/* harmony import */ var metabase_selectors_user__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/selectors/user */ "./selectors/user.js"); +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + + + + +var createTracker = function createTracker(store) { + if (metabase_lib_settings__WEBPACK_IMPORTED_MODULE_0__.default.googleAnalyticsEnabled()) { + createGoogleAnalyticsTracker(); + } + + if (metabase_lib_settings__WEBPACK_IMPORTED_MODULE_0__.default.snowplowEnabled()) { + createSnowplowTracker(store); + } + + if (metabase_lib_settings__WEBPACK_IMPORTED_MODULE_0__.default.googleAnalyticsEnabled() || metabase_lib_settings__WEBPACK_IMPORTED_MODULE_0__.default.snowplowEnabled()) { + document.body.addEventListener("click", handleStructEventClick, true); + } +}; +var trackPageView = function trackPageView(url) { + if (!url) { + return; + } + + if (metabase_lib_settings__WEBPACK_IMPORTED_MODULE_0__.default.googleAnalyticsEnabled()) { + trackGoogleAnalyticsPageView(url); + } + + if (metabase_lib_settings__WEBPACK_IMPORTED_MODULE_0__.default.snowplowEnabled()) { + trackSnowplowPageView(url); + } +}; +var trackStructEvent = function trackStructEvent(category, action, label, value) { + if (!category || !label) { + return; + } + + if (metabase_lib_settings__WEBPACK_IMPORTED_MODULE_0__.default.googleAnalyticsEnabled()) { + trackGoogleAnalyticsStructEvent(category, action, label, value); + } +}; +var trackSchemaEvent = function trackSchemaEvent(schema, version, data) { + if (!schema) { + return; + } + + if (metabase_lib_settings__WEBPACK_IMPORTED_MODULE_0__.default.snowplowEnabled()) { + trackSnowplowSchemaEvent(schema, version, data); + } +}; + +var createGoogleAnalyticsTracker = function createGoogleAnalyticsTracker() { + var _window$ga, _window; + + var code = metabase_lib_settings__WEBPACK_IMPORTED_MODULE_0__.default.get("ga-code"); + (_window$ga = (_window = window).ga) === null || _window$ga === void 0 ? void 0 : _window$ga.call(_window, "create", code, "auto"); + metabase_lib_settings__WEBPACK_IMPORTED_MODULE_0__.default.on("anon-tracking-enabled", function (enabled) { + window["ga-disable-".concat(code)] = enabled ? null : true; + }); +}; + +var trackGoogleAnalyticsPageView = function trackGoogleAnalyticsPageView(url) { + var _window$ga2, _window2, _window$ga3, _window3, _window$ga4, _window4; + + var version = metabase_lib_settings__WEBPACK_IMPORTED_MODULE_0__.default.get("version", {}); + (_window$ga2 = (_window2 = window).ga) === null || _window$ga2 === void 0 ? void 0 : _window$ga2.call(_window2, "set", "dimension1", version.tag); + (_window$ga3 = (_window3 = window).ga) === null || _window$ga3 === void 0 ? void 0 : _window$ga3.call(_window3, "set", "page", url); + (_window$ga4 = (_window4 = window).ga) === null || _window$ga4 === void 0 ? void 0 : _window$ga4.call(_window4, "send", "pageview", url); +}; + +var trackGoogleAnalyticsStructEvent = function trackGoogleAnalyticsStructEvent(category, action, label, value) { + var _window$ga5, _window5, _window$ga6, _window6; + + var version = metabase_lib_settings__WEBPACK_IMPORTED_MODULE_0__.default.get("version", {}); + (_window$ga5 = (_window5 = window).ga) === null || _window$ga5 === void 0 ? void 0 : _window$ga5.call(_window5, "set", "dimension1", version.tag); + (_window$ga6 = (_window6 = window).ga) === null || _window$ga6 === void 0 ? void 0 : _window$ga6.call(_window6, "send", "event", category, action, label, value); +}; + +var createSnowplowTracker = function createSnowplowTracker(store) { + _snowplow_browser_tracker__WEBPACK_IMPORTED_MODULE_2__.newTracker("sp", metabase_lib_settings__WEBPACK_IMPORTED_MODULE_0__.default.snowplowUrl(), { + appId: "metabase", + platform: "web", + eventMethod: "post", + discoverRootDomain: true, + contexts: { + webPage: true + }, + anonymousTracking: { + withServerAnonymisation: true + }, + stateStorageStrategy: "none", + plugins: [createSnowplowPlugin(store)] + }); +}; + +var createSnowplowPlugin = function createSnowplowPlugin(store) { + return { + beforeTrack: function beforeTrack() { + var userId = (0,metabase_selectors_user__WEBPACK_IMPORTED_MODULE_1__.getUserId)(store.getState()); + userId && _snowplow_browser_tracker__WEBPACK_IMPORTED_MODULE_2__.setUserId(String(userId)); + }, + contexts: function contexts() { + var id = metabase_lib_settings__WEBPACK_IMPORTED_MODULE_0__.default.get("analytics-uuid"); + var version = metabase_lib_settings__WEBPACK_IMPORTED_MODULE_0__.default.get("version", {}); + var createdAt = metabase_lib_settings__WEBPACK_IMPORTED_MODULE_0__.default.get("instance-creation"); + var tokenFeatures = metabase_lib_settings__WEBPACK_IMPORTED_MODULE_0__.default.get("token-features"); + return [{ + schema: "iglu:com.metabase/instance/jsonschema/1-1-0", + data: { + id: id, + version: { + tag: version.tag + }, + created_at: createdAt, + token_features: tokenFeatures + } + }]; + } + }; +}; + +var trackSnowplowPageView = function trackSnowplowPageView(url) { + _snowplow_browser_tracker__WEBPACK_IMPORTED_MODULE_2__.setReferrerUrl("#"); + _snowplow_browser_tracker__WEBPACK_IMPORTED_MODULE_2__.setCustomUrl(url); + _snowplow_browser_tracker__WEBPACK_IMPORTED_MODULE_2__.trackPageView(); +}; + +var trackSnowplowSchemaEvent = function trackSnowplowSchemaEvent(schema, version, data) { + _snowplow_browser_tracker__WEBPACK_IMPORTED_MODULE_2__.trackSelfDescribingEvent({ + event: { + schema: "iglu:com.metabase/".concat(schema, "/jsonschema/").concat(version), + data: data + } + }); +}; + +var handleStructEventClick = function handleStructEventClick(event) { + if (!metabase_lib_settings__WEBPACK_IMPORTED_MODULE_0__.default.trackingEnabled()) { + return; + } + + for (var node = event.target; node != null; node = node.parentNode) { + if (node.dataset && node.dataset.metabaseEvent) { + var parts = node.dataset.metabaseEvent.split(";").map(function (p) { + return p.trim(); + }); + trackStructEvent.apply(void 0, _toConsumableArray(parts)); + } + } +}; + +/***/ }), + +/***/ "./lib/api.js": +/*!********************!*\ + !*** ./lib/api.js ***! + \********************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "Api": function() { return /* binding */ Api; }, +/* harmony export */ "GET": function() { return /* binding */ GET; }, +/* harmony export */ "POST": function() { return /* binding */ POST; }, +/* harmony export */ "PUT": function() { return /* binding */ PUT; }, +/* harmony export */ "DELETE": function() { return /* binding */ DELETE; } +/* harmony export */ }); +/* harmony import */ var querystring__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! querystring */ "../../../node_modules/querystring/index.js"); +/* harmony import */ var events__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! events */ "../../../node_modules/events/events.js"); +/* harmony import */ var events__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(events__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var metabase_lib_promise__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/lib/promise */ "./lib/promise.js"); +/* harmony import */ var metabase_lib_dom__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/lib/dom */ "./lib/dom.js"); +/* provided dependency */ var console = __webpack_require__(/*! console-browserify */ "../../../node_modules/console-browserify/index.js"); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } + +function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } + +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + + + + + +var ONE_SECOND = 1000; +var MAX_RETRIES = 10; +var ANTI_CSRF_HEADER = "X-Metabase-Anti-CSRF-Token"; +var ANTI_CSRF_TOKEN = null; +var DEFAULT_OPTIONS = { + json: true, + hasBody: false, + noEvent: false, + transformResponse: function transformResponse(o) { + return o; + }, + raw: {}, + headers: {}, + retry: false, + retryCount: MAX_RETRIES, + // Creates an array with exponential backoff in millis + // i.e. [1000, 2000, 4000, 8000...] + retryDelayIntervals: Array.from(new Array(MAX_RETRIES).keys()).map(function (x) { + return ONE_SECOND * Math.pow(2, x); + }).reverse() +}; +var Api = /*#__PURE__*/function (_EventEmitter) { + _inherits(Api, _EventEmitter); + + var _super = _createSuper(Api); + + function Api() { + var _this; + + _classCallCheck(this, Api); + + _this = _super.call(this); + + _defineProperty(_assertThisInitialized(_this), "basename", ""); + + _defineProperty(_assertThisInitialized(_this), "GET", void 0); + + _defineProperty(_assertThisInitialized(_this), "POST", void 0); + + _defineProperty(_assertThisInitialized(_this), "PUT", void 0); + + _defineProperty(_assertThisInitialized(_this), "DELETE", void 0); + + _this.GET = _this._makeMethod("GET", { + retry: true + }); + _this.DELETE = _this._makeMethod("DELETE", {}); + _this.POST = _this._makeMethod("POST", { + hasBody: true, + retry: true + }); + _this.PUT = _this._makeMethod("PUT", { + hasBody: true + }); + return _this; + } + + _createClass(Api, [{ + key: "_makeMethod", + value: function _makeMethod(method) { + var _this2 = this; + + var creatorOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + return function (urlTemplate) { + var methodOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + + if (typeof methodOptions === "function") { + methodOptions = { + transformResponse: methodOptions + }; + } + + var defaultOptions = _objectSpread(_objectSpread(_objectSpread({}, DEFAULT_OPTIONS), creatorOptions), methodOptions); + + return /*#__PURE__*/function () { + var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(data) { + var invocationOptions, + options, + url, + _iterator, + _step, + tag, + paramName, + value, + name, + headers, + body, + qs, + _args = arguments; + + return regeneratorRuntime.wrap(function _callee$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + invocationOptions = _args.length > 1 && _args[1] !== undefined ? _args[1] : {}; + options = _objectSpread(_objectSpread({}, defaultOptions), invocationOptions); + url = urlTemplate; + data = _objectSpread({}, data); + _iterator = _createForOfIteratorHelper(url.match(/:\w+/g) || []); + + try { + for (_iterator.s(); !(_step = _iterator.n()).done;) { + tag = _step.value; + paramName = tag.slice(1); + value = data[paramName]; + delete data[paramName]; + + if (value === undefined) { + console.warn("Warning: calling", method, "without", tag); + value = ""; + } + + if (!options.raw || !options.raw[paramName]) { + value = encodeURIComponent(value); + } + + url = url.replace(tag, value); + } // remove undefined + + } catch (err) { + _iterator.e(err); + } finally { + _iterator.f(); + } + + for (name in data) { + if (data[name] === undefined) { + delete data[name]; + } + } + + headers = options.json ? { + Accept: "application/json", + "Content-Type": "application/json" + } : {}; + + if (metabase_lib_dom__WEBPACK_IMPORTED_MODULE_3__.IFRAMED) { + headers["X-Metabase-Embedded"] = "true"; + } + + if (ANTI_CSRF_TOKEN) { + headers[ANTI_CSRF_HEADER] = ANTI_CSRF_TOKEN; + } + + if (options.hasBody) { + body = JSON.stringify(options.bodyParamName != null ? data[options.bodyParamName] : data); + } else { + qs = querystring__WEBPACK_IMPORTED_MODULE_0__.stringify(data); + + if (qs) { + url += (url.indexOf("?") >= 0 ? "&" : "?") + qs; + } + } + + Object.assign(headers, options.headers); + + if (!options.retry) { + _context.next = 16; + break; + } + + return _context.abrupt("return", _this2._makeRequestWithRetries(method, url, headers, body, data, options)); + + case 16: + return _context.abrupt("return", _this2._makeRequest(method, url, headers, body, data, options)); + + case 17: + case "end": + return _context.stop(); + } + } + }, _callee); + })); + + return function (_x) { + return _ref.apply(this, arguments); + }; + }(); + }; + } + }, { + key: "_makeRequestWithRetries", + value: function () { + var _makeRequestWithRetries2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(method, url, headers, body, data, options) { + var retryDelays, retryCount, maxAttempts; + return regeneratorRuntime.wrap(function _callee2$(_context2) { + while (1) { + switch (_context2.prev = _context2.next) { + case 0: + // Get a copy of the delay intervals that we can remove items from as we retry + retryDelays = options.retryDelayIntervals.slice(); + retryCount = 0; // maxAttempts is the first attempt followed by the number of retries + + maxAttempts = options.retryCount + 1; // Make the first attempt for the request, then loop incrementing the retryCount + + case 3: + _context2.prev = 3; + _context2.next = 6; + return this._makeRequest(method, url, headers, body, data, options); + + case 6: + return _context2.abrupt("return", _context2.sent); + + case 9: + _context2.prev = 9; + _context2.t0 = _context2["catch"](3); + retryCount++; // If the response is 503 and the next retry won't put us over the maxAttempts, + // wait a bit and try again + + if (!(_context2.t0.status === 503 && retryCount < maxAttempts)) { + _context2.next = 17; + break; + } + + _context2.next = 15; + return (0,metabase_lib_promise__WEBPACK_IMPORTED_MODULE_2__.delay)(retryDelays.pop()); + + case 15: + _context2.next = 18; + break; + + case 17: + throw _context2.t0; + + case 18: + if (retryCount < maxAttempts) { + _context2.next = 3; + break; + } + + case 19: + case "end": + return _context2.stop(); + } + } + }, _callee2, this, [[3, 9]]); + })); + + function _makeRequestWithRetries(_x2, _x3, _x4, _x5, _x6, _x7) { + return _makeRequestWithRetries2.apply(this, arguments); + } + + return _makeRequestWithRetries; + }() // TODO Atte Keinänen 6/26/17: Replacing this with isomorphic-fetch could simplify the implementation + + }, { + key: "_makeRequest", + value: function _makeRequest(method, url, headers, body, data, options) { + var _this3 = this; + + return new Promise(function (resolve, reject) { + var isCancelled = false; + var xhr = new XMLHttpRequest(); + xhr.open(method, _this3.basename + url); + + for (var headerName in headers) { + xhr.setRequestHeader(headerName, headers[headerName]); + } + + xhr.onreadystatechange = function () { + if (xhr.readyState === XMLHttpRequest.DONE) { + // getResponseHeader() is case-insensitive + var antiCsrfToken = xhr.getResponseHeader(ANTI_CSRF_HEADER); + + if (antiCsrfToken) { + ANTI_CSRF_TOKEN = antiCsrfToken; + } + + var _body = xhr.responseText; + + if (options.json) { + try { + _body = JSON.parse(_body); + } catch (e) {} + } + + var status = xhr.status; + + if (status === 202 && _body && _body._status > 0) { + status = _body._status; + } + + if (status >= 200 && status <= 299) { + if (options.transformResponse) { + _body = options.transformResponse(_body, { + data: data + }); + } + + resolve(_body); + } else { + reject({ + status: status, + data: _body, + isCancelled: isCancelled + }); + } + + if (!options.noEvent) { + _this3.emit(status, url); + } + } + }; + + xhr.send(body); + + if (options.cancelled) { + options.cancelled.then(function () { + isCancelled = true; + xhr.abort(); + }); + } + }); + } + }]); + + return Api; +}((events__WEBPACK_IMPORTED_MODULE_1___default())); +var instance = new Api(); +/* harmony default export */ __webpack_exports__["default"] = (instance); +var GET = instance.GET, + POST = instance.POST, + PUT = instance.PUT, + DELETE = instance.DELETE; + + +/***/ }), + +/***/ "./lib/auth.js": +/*!*********************!*\ + !*** ./lib/auth.js ***! + \*********************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "deleteSession": function() { return /* binding */ deleteSession; }, +/* harmony export */ "attachGoogleAuth": function() { return /* binding */ attachGoogleAuth; }, +/* harmony export */ "clearGoogleAuthCredentials": function() { return /* binding */ clearGoogleAuthCredentials; } +/* harmony export */ }); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var metabase_services__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/services */ "./services.js"); +/* harmony import */ var metabase_lib_settings__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/lib/settings */ "./lib/settings.ts"); +/* provided dependency */ var console = __webpack_require__(/*! console-browserify */ "../../../node_modules/console-browserify/index.js"); +var _templateObject, _templateObject2; + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + +function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } + +function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } + +/*global gapi*/ + + + +var deleteSession = /*#__PURE__*/function () { + var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() { + return regeneratorRuntime.wrap(function _callee$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + _context.prev = 0; + _context.next = 3; + return metabase_services__WEBPACK_IMPORTED_MODULE_1__.SessionApi.delete(); + + case 3: + _context.next = 8; + break; + + case 5: + _context.prev = 5; + _context.t0 = _context["catch"](0); + + if (_context.t0.status !== 404) { + console.error("Problem clearing session", _context.t0); + } + + case 8: + case "end": + return _context.stop(); + } + } + }, _callee, null, [[0, 5]]); + })); + + return function deleteSession() { + return _ref.apply(this, arguments); + }; +}(); +var GOOGLE_AUTH_ERRORS = { + generic: (0,ttag__WEBPACK_IMPORTED_MODULE_0__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["There was an issue signing in with Google. Please contact an administrator."]))), + popup_closed_by_user: (0,ttag__WEBPACK_IMPORTED_MODULE_0__.t)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["The window was closed before completing Google Authentication."]))) +}; +var attachGoogleAuth = function attachGoogleAuth(element, onLogin, onError) { + if (!window.gapi) { + window.setTimeout(function () { + return attachGoogleAuth(element, onLogin, onError); + }, 100); + return; + } + + window.gapi.load("auth2", function () { + var auth2 = window.gapi.auth2.init({ + client_id: metabase_lib_settings__WEBPACK_IMPORTED_MODULE_2__.default.get("google-auth-client-id"), + cookiepolicy: "single_host_origin" + }); + auth2.attachClickHandler(element, {}, function (user) { + onLogin(user.getAuthResponse().id_token); + }, function (error) { + var _GOOGLE_AUTH_ERRORS$e; + + onError((_GOOGLE_AUTH_ERRORS$e = GOOGLE_AUTH_ERRORS[error.error]) !== null && _GOOGLE_AUTH_ERRORS$e !== void 0 ? _GOOGLE_AUTH_ERRORS$e : GOOGLE_AUTH_ERRORS.generic); + }); + }); +}; +var clearGoogleAuthCredentials = /*#__PURE__*/function () { + var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() { + var googleAuth; + return regeneratorRuntime.wrap(function _callee2$(_context2) { + while (1) { + switch (_context2.prev = _context2.next) { + case 0: + googleAuth = typeof gapi !== "undefined" && gapi && gapi.auth2 ? gapi.auth2.getAuthInstance() : undefined; + + if (googleAuth) { + _context2.next = 3; + break; + } + + return _context2.abrupt("return"); + + case 3: + _context2.prev = 3; + _context2.next = 6; + return googleAuth.signOut(); + + case 6: + _context2.next = 11; + break; + + case 8: + _context2.prev = 8; + _context2.t0 = _context2["catch"](3); + console.error("Problem clearing Google Auth credentials", _context2.t0); + + case 11: + case "end": + return _context2.stop(); + } + } + }, _callee2, null, [[3, 8]]); + })); + + return function clearGoogleAuthCredentials() { + return _ref2.apply(this, arguments); + }; +}(); + +/***/ }), + +/***/ "./lib/browser.js": +/*!************************!*\ + !*** ./lib/browser.js ***! + \************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "parseHashOptions": function() { return /* binding */ parseHashOptions; }, +/* harmony export */ "stringifyHashOptions": function() { return /* binding */ stringifyHashOptions; }, +/* harmony export */ "updateQueryString": function() { return /* binding */ updateQueryString; }, +/* harmony export */ "isMac": function() { return /* binding */ isMac; } +/* harmony export */ }); +/* harmony import */ var querystring__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! querystring */ "../../../node_modules/querystring/index.js"); + +function parseHashOptions(hash) { + var options = querystring__WEBPACK_IMPORTED_MODULE_0__.parse(hash.replace(/^#/, "")); + + for (var name in options) { + if (options[name] === "") { + options[name] = true; + } else if (/^(true|false|-?\d+(\.\d+)?)$/.test(options[name])) { + options[name] = JSON.parse(options[name]); + } + } + + return options; +} +function stringifyHashOptions(options) { + return querystring__WEBPACK_IMPORTED_MODULE_0__.stringify(options).replace(/=true\b/g, ""); +} +function updateQueryString(location, optionsUpdater) { + var currentOptions = parseHashOptions(location.search.substring(1)); + var queryString = stringifyHashOptions(optionsUpdater(currentOptions)); + return { + pathname: location.pathname, + hash: location.hash, + search: queryString ? "?".concat(queryString) : null + }; +} +function isMac() { + var _navigator = navigator, + _navigator$platform = _navigator.platform, + platform = _navigator$platform === void 0 ? "" : _navigator$platform; + return Boolean(platform.match(/^Mac/)); +} + +/***/ }), + +/***/ "./lib/card.js": +/*!*********************!*\ + !*** ./lib/card.js ***! + \*********************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "createCard": function() { return /* binding */ createCard; }, +/* harmony export */ "startNewCard": function() { return /* binding */ startNewCard; }, +/* harmony export */ "loadCard": function() { return /* binding */ loadCard; }, +/* harmony export */ "isCardDirty": function() { return /* binding */ isCardDirty; }, +/* harmony export */ "serializeCardForUrl": function() { return /* binding */ serializeCardForUrl; }, +/* harmony export */ "deserializeCardFromUrl": function() { return /* binding */ deserializeCardFromUrl; }, +/* harmony export */ "urlForCardState": function() { return /* binding */ urlForCardState; }, +/* harmony export */ "cleanCopyCard": function() { return /* binding */ cleanCopyCard; } +/* harmony export */ }); +/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! underscore */ "../../../node_modules/underscore/modules/index-all.js"); +/* harmony import */ var metabase_lib_query__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/lib/query */ "./lib/query.js"); +/* harmony import */ var metabase_lib_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase/lib/utils */ "./lib/utils.js"); +/* harmony import */ var metabase_lib_urls__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/lib/urls */ "./lib/urls.js"); +/* harmony import */ var metabase_services__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! metabase/services */ "./services.js"); +/* harmony import */ var metabase_lib_encoding__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! metabase/lib/encoding */ "./lib/encoding.js"); +/* provided dependency */ var console = __webpack_require__(/*! console-browserify */ "../../../node_modules/console-browserify/index.js"); +function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } + +function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } + + + + + + + +function createCard() { + var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; + return { + name: name, + display: "table", + visualization_settings: {}, + dataset_query: {} + }; +} // start a new card using the given query type and optional database and table selections + +function startNewCard(type, databaseId, tableId) { + // create a brand new card to work from + var card = createCard(); + card.dataset_query = metabase_lib_query__WEBPACK_IMPORTED_MODULE_1__.createQuery(type, databaseId, tableId); + return card; +} // load a card either by ID or from a base64 serialization. if both are present then they are merged, which the serialized version taking precedence +// TODO: move to redux + +function loadCard(_x) { + return _loadCard.apply(this, arguments); +} // TODO Atte Keinänen 5/31/17 Deprecated, we should migrate existing references to this method to `question.isCardDirty` +// predicate function that dermines if a given card is "dirty" compared to the last known version of the card + +function _loadCard() { + _loadCard = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(cardId) { + return regeneratorRuntime.wrap(function _callee$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + _context.prev = 0; + _context.next = 3; + return metabase_services__WEBPACK_IMPORTED_MODULE_4__.CardApi.get({ + cardId: cardId + }); + + case 3: + return _context.abrupt("return", _context.sent); + + case 6: + _context.prev = 6; + _context.t0 = _context["catch"](0); + console.log("error loading card", _context.t0); + throw _context.t0; + + case 10: + case "end": + return _context.stop(); + } + } + }, _callee, null, [[0, 6]]); + })); + return _loadCard.apply(this, arguments); +} + +function isCardDirty(card, originalCard) { + // The rules: + // - if it's new, then it's dirty when + // 1) there is a database/table chosen or + // 2) when there is any content on the native query + // - if it's saved, then it's dirty when + // 1) the current card doesn't match the last saved version + if (!card) { + return false; + } else if (!card.id) { + if (card.dataset_query.query && card.dataset_query.query["source-table"]) { + return true; + } else if (card.dataset_query.native && !underscore__WEBPACK_IMPORTED_MODULE_0__.default.isEmpty(card.dataset_query.native.query)) { + return true; + } else { + return false; + } + } else { + var origCardSerialized = originalCard ? serializeCardForUrl(originalCard) : null; + var newCardSerialized = card ? serializeCardForUrl(underscore__WEBPACK_IMPORTED_MODULE_0__.default.omit(card, "original_card_id")) : null; + return newCardSerialized !== origCardSerialized; + } +} // TODO Atte Keinänen 5/31/17 Deprecated, we should move tests to Questions.spec.js + +function serializeCardForUrl(card) { + var dataset_query = metabase_lib_utils__WEBPACK_IMPORTED_MODULE_2__.default.copy(card.dataset_query); + + if (dataset_query.query) { + dataset_query.query = metabase_lib_query__WEBPACK_IMPORTED_MODULE_1__.cleanQuery(dataset_query.query); + } + + var cardCopy = { + name: card.name, + description: card.description, + dataset_query: dataset_query, + display: card.display, + displayIsLocked: card.displayIsLocked, + parameters: card.parameters, + dashboardId: card.dashboardId, + visualization_settings: card.visualization_settings, + original_card_id: card.original_card_id + }; + return (0,metabase_lib_encoding__WEBPACK_IMPORTED_MODULE_5__.utf8_to_b64url)(JSON.stringify(cardCopy)); +} +function deserializeCardFromUrl(serialized) { + return JSON.parse((0,metabase_lib_encoding__WEBPACK_IMPORTED_MODULE_5__.b64hash_to_utf8)(serialized)); +} +function urlForCardState(state, dirty) { + return metabase_lib_urls__WEBPACK_IMPORTED_MODULE_3__.question(state.card, state.serializedCard && dirty ? state.serializedCard : ""); +} +function cleanCopyCard(card) { + var cardCopy = {}; + + for (var name in card) { + if (name.charAt(0) !== "$") { + cardCopy[name] = card[name]; + } + } + + return cardCopy; +} + +/***/ }), + +/***/ "./lib/click-behavior.js": +/*!*******************************!*\ + !*** ./lib/click-behavior.js ***! + \*******************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "getDataFromClicked": function() { return /* binding */ getDataFromClicked; }, +/* harmony export */ "getTargetsWithSourceFilters": function() { return /* binding */ getTargetsWithSourceFilters; }, +/* harmony export */ "getClickBehaviorDescription": function() { return /* binding */ getClickBehaviorDescription; }, +/* harmony export */ "clickBehaviorIsValid": function() { return /* binding */ clickBehaviorIsValid; }, +/* harmony export */ "hasActionsMenu": function() { return /* binding */ hasActionsMenu; }, +/* harmony export */ "isTableDisplay": function() { return /* binding */ isTableDisplay; }, +/* harmony export */ "formatSourceForTarget": function() { return /* binding */ formatSourceForTarget; }, +/* harmony export */ "getTargetForQueryParams": function() { return /* binding */ getTargetForQueryParams; } +/* harmony export */ }); +/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! underscore */ "../../../node_modules/underscore/modules/index-all.js"); +/* harmony import */ var icepick__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! icepick */ "../../../node_modules/icepick/icepick.min.js"); +/* harmony import */ var icepick__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(icepick__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_2__); +/* harmony import */ var metabase_lib_schema_metadata__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/lib/schema_metadata */ "./lib/schema_metadata.js"); +/* harmony import */ var metabase_lib_time__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! metabase/lib/time */ "./lib/time.js"); +/* harmony import */ var metabase_lib_formatting_date__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! metabase/lib/formatting/date */ "./lib/formatting/date.js"); +/* harmony import */ var metabase_lib_lib_Question__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! metabase-lib/lib/Question */ "../metabase-lib/lib/Question.ts"); +/* harmony import */ var metabase_lib_lib_Variable__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! metabase-lib/lib/Variable */ "../metabase-lib/lib/Variable.ts"); +/* harmony import */ var metabase_lib_lib_Dimension__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! metabase-lib/lib/Dimension */ "../metabase-lib/lib/Dimension.ts"); +/* harmony import */ var metabase_lib_types__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! metabase/lib/types */ "./lib/types.js"); +/* harmony import */ var metabase_parameters_utils_filters__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! metabase/parameters/utils/filters */ "./parameters/utils/filters.js"); +var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8; + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } + +function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } + +function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } + +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + + + + + + + + + + + + +function getDataFromClicked(_ref) { + var _ref$extraData = _ref.extraData; + _ref$extraData = _ref$extraData === void 0 ? {} : _ref$extraData; + var dashboard = _ref$extraData.dashboard, + parameterValuesBySlug = _ref$extraData.parameterValuesBySlug, + userAttributes = _ref$extraData.userAttributes, + dimensions = _ref.dimensions, + data = _ref.data; + var column = [].concat(_toConsumableArray(dimensions || []), _toConsumableArray((data || []).map(function (d) { + return { + column: d.col, + // When the data is changed to a display value for use in tooltips, we can set clickBehaviorValue to the raw value for filtering. + value: d.clickBehaviorValue || d.value + }; + }))).filter(function (d) { + return d.column != null; + }).reduce(function (acc, _ref2) { + var column = _ref2.column, + value = _ref2.value; + return acc[name] === undefined ? _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, column.name.toLowerCase(), { + value: value, + column: column + })) : acc; + }, {}); + var parameterByName = dashboard == null ? {} : underscore__WEBPACK_IMPORTED_MODULE_0__.default.chain(dashboard.parameters).filter(function (p) { + return parameterValuesBySlug[p.slug] != null; + }).map(function (p) { + return [p.name.toLowerCase(), { + value: parameterValuesBySlug[p.slug] + }]; + }).object().value(); + + var parameterBySlug = underscore__WEBPACK_IMPORTED_MODULE_0__.default.mapObject(parameterValuesBySlug, function (value) { + return { + value: value + }; + }); + + var parameter = dashboard == null ? {} : underscore__WEBPACK_IMPORTED_MODULE_0__.default.chain(dashboard.parameters).filter(function (p) { + return parameterValuesBySlug[p.slug] != null; + }).map(function (p) { + return [p.id, { + value: parameterValuesBySlug[p.slug] + }]; + }).object().value(); + + var userAttribute = underscore__WEBPACK_IMPORTED_MODULE_0__.default.mapObject(userAttributes, function (value) { + return { + value: value + }; + }); + + return { + column: column, + parameter: parameter, + parameterByName: parameterByName, + parameterBySlug: parameterBySlug, + userAttribute: userAttribute + }; +} +var Text = metabase_lib_types__WEBPACK_IMPORTED_MODULE_9__.TYPE.Text, + Number = metabase_lib_types__WEBPACK_IMPORTED_MODULE_9__.TYPE.Number, + Temporal = metabase_lib_types__WEBPACK_IMPORTED_MODULE_9__.TYPE.Temporal; + +function notRelativeDateOrRange(_ref3) { + var type = _ref3.type; + return type !== "date/range" && type !== "date/relative"; +} + +function getTargetsWithSourceFilters(_ref4) { + var isDash = _ref4.isDash, + object = _ref4.object, + metadata = _ref4.metadata; + return isDash ? getTargetsForDashboard(object) : getTargetsForQuestion(object, metadata); +} + +function getTargetsForQuestion(question, metadata) { + var query = new metabase_lib_lib_Question__WEBPACK_IMPORTED_MODULE_6__.default(question, metadata).query(); + return query.dimensionOptions().all().concat(query.variables()).map(function (o) { + var id, target; + + if (o instanceof metabase_lib_lib_Variable__WEBPACK_IMPORTED_MODULE_7__.TemplateTagVariable || o instanceof metabase_lib_lib_Dimension__WEBPACK_IMPORTED_MODULE_8__.TemplateTagDimension) { + var _name; + + var _o$tag = o.tag(); + + id = _o$tag.id; + _name = _o$tag.name; + target = { + type: "variable", + id: _name + }; + } else { + var dimension = ["dimension", o.mbql()]; + id = JSON.stringify(dimension); + target = { + type: "dimension", + id: id, + dimension: dimension + }; + } + + var parentType; + + var parameterSourceFilter = function parameterSourceFilter() { + return true; + }; + + var columnSourceFilter = function columnSourceFilter(c) { + return (0,metabase_lib_types__WEBPACK_IMPORTED_MODULE_9__.isa)(c.base_type, parentType); + }; + + if (o instanceof metabase_lib_lib_Variable__WEBPACK_IMPORTED_MODULE_7__.TemplateTagVariable) { + parentType = { + text: Text, + number: Number, + date: Temporal + }[o.tag().type]; + + parameterSourceFilter = function parameterSourceFilter(parameter) { + return (0,metabase_parameters_utils_filters__WEBPACK_IMPORTED_MODULE_10__.variableFilterForParameter)(parameter)(o); + }; + } else if (o.field() != null) { + var _o$field = o.field(), + base_type = _o$field.base_type; + + parentType = [Temporal, Number, Text].find(function (t) { + return (0,metabase_lib_types__WEBPACK_IMPORTED_MODULE_9__.isa)(base_type, t); + }) || base_type; + + parameterSourceFilter = function parameterSourceFilter(parameter) { + return (0,metabase_parameters_utils_filters__WEBPACK_IMPORTED_MODULE_10__.dimensionFilterForParameter)(parameter)(o); + }; + } + + return { + id: id, + target: target, + name: o.displayName({ + includeTable: true + }), + sourceFilters: { + column: columnSourceFilter, + parameter: parameterSourceFilter, + userAttribute: function userAttribute() { + return parentType === Text; + } + } + }; + }); +} + +function getTargetsForDashboard(dashboard) { + return dashboard.parameters.map(function (_parameter) { + var type = _parameter.type, + id = _parameter.id, + name = _parameter.name; + var filter = baseTypeFilterForParameterType(type); + return { + id: id, + name: name, + target: { + type: "parameter", + id: id + }, + sourceFilters: { + column: function column(c) { + return notRelativeDateOrRange(_parameter) && filter(c.base_type); + }, + parameter: function parameter(sourceParam) { + return _parameter.type === sourceParam.type && _parameter.id !== sourceParam.id; + }, + userAttribute: function userAttribute() { + return !_parameter.type.startsWith("date"); + } + } + }; + }); +} + +function baseTypeFilterForParameterType(parameterType) { + var _parameterType$split = parameterType.split("/"), + _parameterType$split2 = _slicedToArray(_parameterType$split, 1), + typePrefix = _parameterType$split2[0]; + + var allowedTypes = { + date: [metabase_lib_types__WEBPACK_IMPORTED_MODULE_9__.TYPE.Temporal], + id: [metabase_lib_types__WEBPACK_IMPORTED_MODULE_9__.TYPE.Integer], + category: [metabase_lib_types__WEBPACK_IMPORTED_MODULE_9__.TYPE.Text, metabase_lib_types__WEBPACK_IMPORTED_MODULE_9__.TYPE.Integer], + location: [metabase_lib_types__WEBPACK_IMPORTED_MODULE_9__.TYPE.Text] + }[typePrefix]; + + if (allowedTypes === undefined) { + // default to showing everything + return function () { + return true; + }; + } + + return function (baseType) { + return allowedTypes.some(function (allowedType) { + return (0,metabase_lib_types__WEBPACK_IMPORTED_MODULE_9__.isa)(baseType, allowedType); + }); + }; +} + +function getClickBehaviorDescription(dashcard) { + var noBehaviorMessage = hasActionsMenu(dashcard) ? (0,ttag__WEBPACK_IMPORTED_MODULE_2__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["Open the action menu"]))) : (0,ttag__WEBPACK_IMPORTED_MODULE_2__.t)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["Do nothing"]))); + + if (isTableDisplay(dashcard)) { + var count = Object.values((0,icepick__WEBPACK_IMPORTED_MODULE_1__.getIn)(dashcard, ["visualization_settings", "column_settings"]) || {}).filter(function (settings) { + return settings.click_behavior != null; + }).length; + + if (count === 0) { + return noBehaviorMessage; + } + + return (0,ttag__WEBPACK_IMPORTED_MODULE_2__.ngettext)((0,ttag__WEBPACK_IMPORTED_MODULE_2__.msgid)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["", " column has custom behavior"])), count), "".concat(count, " columns have custom behavior"), count); + } + + var clickBehavior = dashcard.visualization_settings.click_behavior; + + if (clickBehavior == null) { + return noBehaviorMessage; + } + + if (clickBehavior.type === "link") { + var linkType = clickBehavior.linkType; + return linkType == null ? (0,ttag__WEBPACK_IMPORTED_MODULE_2__.t)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["Go to..."]))) : linkType === "dashboard" ? (0,ttag__WEBPACK_IMPORTED_MODULE_2__.t)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["Go to dashboard"]))) : linkType === "question" ? (0,ttag__WEBPACK_IMPORTED_MODULE_2__.t)(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["Go to question"]))) : (0,ttag__WEBPACK_IMPORTED_MODULE_2__.t)(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["Go to url"]))); + } + + return (0,ttag__WEBPACK_IMPORTED_MODULE_2__.t)(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["Filter this dashboard"]))); +} +function clickBehaviorIsValid(clickBehavior) { + // opens action menu + if (clickBehavior == null) { + return true; + } + + var type = clickBehavior.type, + _clickBehavior$parame = clickBehavior.parameterMapping, + parameterMapping = _clickBehavior$parame === void 0 ? {} : _clickBehavior$parame, + linkType = clickBehavior.linkType, + targetId = clickBehavior.targetId, + linkTemplate = clickBehavior.linkTemplate; + + if (type === "crossfilter") { + return Object.keys(parameterMapping).length > 0; + } // if it's not a crossfilter, it's a link + + + if (linkType === "url") { + return (linkTemplate || "").length > 0; + } // if we're linking to a question or dashboard we just need a targetId + + + if (linkType === "dashboard" || linkType === "question") { + return targetId != null; + } // we've picked "link" without picking a link type + + + return false; +} +function hasActionsMenu(dashcard) { + // This seems to work, but it isn't the right logic. + // The right thing to do would be to check for any drills. However, we'd need a "clicked" object for that. + return (0,icepick__WEBPACK_IMPORTED_MODULE_1__.getIn)(dashcard, ["card", "dataset_query", "type"]) !== "native"; +} +function isTableDisplay(dashcard) { + return dashcard.card.display === "table"; +} +function formatSourceForTarget(source, target, _ref5) { + var data = _ref5.data, + extraData = _ref5.extraData, + clickBehavior = _ref5.clickBehavior; + var datum = data[source.type][source.id.toLowerCase()] || []; + + if (datum.column && (0,metabase_lib_schema_metadata__WEBPACK_IMPORTED_MODULE_3__.isDate)(datum.column)) { + if (target.type === "parameter") { + // we should serialize differently based on the target parameter type + var parameter = getParameter(target, { + extraData: extraData, + clickBehavior: clickBehavior + }); + + if (parameter) { + return formatDateForParameterType(datum.value, parameter.type, datum.column.unit); + } + } else { + // If the target is a dimension or variable,, we serialize as a date to remove the timestamp. + // TODO: provide better serialization for field filter widget types + return formatDateForParameterType(datum.value, "date/single"); + } + } + + return datum.value; +} + +function formatDateForParameterType(value, parameterType, unit) { + var m = (0,metabase_lib_time__WEBPACK_IMPORTED_MODULE_4__.parseTimestamp)(value); + + if (!m.isValid()) { + return String(value); + } + + if (parameterType === "date/month-year") { + return m.format("YYYY-MM"); + } else if (parameterType === "date/quarter-year") { + return m.format("[Q]Q-YYYY"); + } else if (parameterType === "date/single") { + return m.format("YYYY-MM-DD"); + } else if (parameterType === "date/all-options") { + return (0,metabase_lib_formatting_date__WEBPACK_IMPORTED_MODULE_5__.formatDateTimeForParameter)(value, unit); + } + + return value; +} + +function getTargetForQueryParams(target, _ref6) { + var extraData = _ref6.extraData, + clickBehavior = _ref6.clickBehavior; + + if (target.type === "parameter") { + var parameter = getParameter(target, { + extraData: extraData, + clickBehavior: clickBehavior + }); + return parameter && parameter.slug; + } + + return target.id; +} + +function getParameter(target, _ref7) { + var extraData = _ref7.extraData, + clickBehavior = _ref7.clickBehavior; + var parameterPath = clickBehavior.type === "crossfilter" ? ["dashboard", "parameters"] : ["dashboards", clickBehavior.targetId, "parameters"]; + var parameters = (0,icepick__WEBPACK_IMPORTED_MODULE_1__.getIn)(extraData, parameterPath) || []; + return parameters.find(function (p) { + return p.id === target.id; + }); +} + +/***/ }), + +/***/ "./lib/colors.ts": +/*!***********************!*\ + !*** ./lib/colors.ts ***! + \***********************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "aliases": function() { return /* binding */ aliases; }, +/* harmony export */ "harmony": function() { return /* binding */ harmony; }, +/* harmony export */ "normal": function() { return /* binding */ normal; }, +/* harmony export */ "saturated": function() { return /* binding */ saturated; }, +/* harmony export */ "desaturated": function() { return /* binding */ desaturated; }, +/* harmony export */ "syncColors": function() { return /* binding */ syncColors; }, +/* harmony export */ "HARMONY_GROUP_SIZE": function() { return /* binding */ HARMONY_GROUP_SIZE; }, +/* harmony export */ "getRandomColor": function() { return /* binding */ getRandomColor; }, +/* harmony export */ "getColorScale": function() { return /* binding */ getColorScale; }, +/* harmony export */ "roundColor": function() { return /* binding */ roundColor; }, +/* harmony export */ "color": function() { return /* binding */ color; }, +/* harmony export */ "alpha": function() { return /* binding */ alpha; }, +/* harmony export */ "darken": function() { return /* binding */ darken; }, +/* harmony export */ "lighten": function() { return /* binding */ lighten; }, +/* harmony export */ "getColorsForValues": function() { return /* binding */ getColorsForValues; }, +/* harmony export */ "getColorForValue": function() { return /* binding */ getColorForValue; } +/* harmony export */ }); +/* harmony import */ var d3__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! d3 */ "../../../node_modules/d3/d3.js"); +/* harmony import */ var d3__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(d3__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var color__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! color */ "../../../node_modules/color/index.js"); +/* harmony import */ var color__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(color__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var color_harmony__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! color-harmony */ "../../../node_modules/color-harmony/lib/color-harmony.js"); +/* harmony import */ var _deterministic__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./deterministic */ "./lib/deterministic.js"); +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } + +function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } + +function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } + + + + + // NOTE: DO NOT ADD COLORS WITHOUT EXTREMELY GOOD REASON AND DESIGN REVIEW +// NOTE: KEEP SYNCRONIZED WITH COLORS.CSS + +/* eslint-disable no-color-literals */ + +var colors = { + brand: "#509EE3", + "brand-light": "#DDECFA", + accent1: "#80F4DA", + accent2: "#00E8B4", + accent3: "#00C59A", + accent4: "#F9D45C", + accent5: "#F2A86F", + accent6: "#C74AE3", + accent7: "#7172AD", + "admin-navbar": "#7172AD", + white: "#FFFFFF", + black: "#2E353B", + success: "#84BB4C", + danger: "#ED6E6E", + error: "#ED6E6E", + warning: "#F9CF48", + "text-neutral": "#4e4e4e", + "text-dark": "#282828", + "text-medium": "#949AAB", + "text-light": "#B8BBC3", + "text-white": "#FFFFFF", + "bg-black": "#2E353B", + "bg-dark": "#93A1AB", + "bg-medium": "#EDF2F5", + "bg-light": "#F9FBFC", + "bg-white": "#FFFFFF", + "bg-yellow": "#FFFCF2", + shadow: "rgba(0,0,0,0.08)", + border: "#F0F0F0", + + /* Saturated colors for the SQL editor. Shouldn't be used elsewhere since they're not white-labelable. */ + "saturated-blue": "#2D86D4", + "saturated-green": "#70A63A", + "saturated-purple": "#885AB1", + "saturated-red": "#ED6E6E", + "saturated-yellow": "#F9CF48" +}; +/* eslint-enable no-color-literals */ + +/* harmony default export */ __webpack_exports__["default"] = (colors); +var aliases = { + summarize: "accent1", + filter: "accent7", + database: "accent2", + dashboard: "brand", + pulse: "accent4", + nav: "brand" +}; +var harmony = []; // DEPRECATED: we should remove these and use `colors` directly +// compute satured/desaturated variants using "color" lib if absolutely required + +var normal = {}; +var saturated = {}; +var desaturated = {}; // make sure to do the initial "sync" + +syncColors(); +function syncColors() { + syncHarmony(); + syncDeprecatedColorFamilies(); +} +var HARMONY_GROUP_SIZE = 8; // match initialColors length below + +function syncHarmony() { + var harmonizer = new color_harmony__WEBPACK_IMPORTED_MODULE_2__.Harmonizer(); + var initialColors = [colors["brand"], colors["accent1"], colors["accent2"], colors["accent3"], colors["accent4"], colors["accent5"], colors["accent6"], colors["accent7"]]; + harmony.splice(0, harmony.length); // round 0 includes brand and all accents + + harmony.push.apply(harmony, initialColors); // rounds 1-4 generated harmony + // only harmonize brand and accents 1 through 4 + + var initialColorHarmonies = initialColors.slice(0, 5).map(function (color) { + return harmonizer.harmonize(color, "fiveToneD"); + }); + + for (var roundIndex = 1; roundIndex < 5; roundIndex++) { + for (var colorIndex = 0; colorIndex < initialColorHarmonies.length; colorIndex++) { + harmony.push(initialColorHarmonies[colorIndex][roundIndex]); + } + } +} // syncs deprecated color families for legacy code + + +function syncDeprecatedColorFamilies() { + // normal + saturated + desaturated + normal.blue = saturated.blue = desaturated.blue = colors["brand"]; + normal.green = saturated.green = desaturated.green = colors["accent1"]; + normal.purple = saturated.purple = desaturated.purple = colors["accent2"]; + normal.red = saturated.red = desaturated.red = colors["accent3"]; + normal.yellow = saturated.yellow = desaturated.yellow = colors["accent4"]; + normal.orange = colors["accent5"]; + normal.teal = colors["accent6"]; + normal.indigo = colors["accent7"]; + normal.gray = colors["text-dark"]; + normal.grey1 = colors["text-light"]; + normal.grey2 = colors["text-medium"]; + normal.grey3 = colors["text-dark"]; + normal.text = colors["text-dark"]; +} + +var getRandomColor = function getRandomColor(family) { + var colors = Object.values(family); + return colors[Math.floor(Math.random() * colors.length)]; +}; +var getColorScale = function getColorScale(extent, colors) { + var quantile = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; + + if (quantile) { + return d3__WEBPACK_IMPORTED_MODULE_0___default().scale.quantile().domain(extent).range(colors); + } else { + var _extent = _slicedToArray(extent, 2), + start = _extent[0], + end = _extent[1]; + + return d3__WEBPACK_IMPORTED_MODULE_0___default().scale.linear().domain(colors.length === 3 ? [start, start + (end - start) / 2, end] : [start, end]).range(colors); + } +}; // HACK: d3 may return rgb values with decimals but certain rendering engines +// don't support that (e.x. Safari and CSSBox) + +function roundColor(color) { + return color.replace(/rgba\((\d+(?:\.\d+)),\s*(\d+(?:\.\d+)),\s*(\d+(?:\.\d+)),\s*(\d+\.\d+)\)/, function (_, r, g, b, a) { + return "rgba(".concat(Math.round(r), ",").concat(Math.round(g), ",").concat(Math.round(b), ",").concat(a, ")"); + }); +} +function color(color) { + if (color in colors) { + return colors[color]; + } + + if (color in aliases) { + return colors[aliases[color]]; + } // TODO: validate this is a ColorString + + + return color; +} +function alpha(c, a) { + return color__WEBPACK_IMPORTED_MODULE_1___default()(color(c)).alpha(a).string(); +} +function darken(c) { + var f = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0.25; + return color__WEBPACK_IMPORTED_MODULE_1___default()(color(c)).darken(f).string(); +} +function lighten(c) { + var f = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0.5; + return color__WEBPACK_IMPORTED_MODULE_1___default()(color(c)).lighten(f).string(); +} +var PREFERRED_COLORS = { + success: ["success", "succeeded", "pass", "passed", "valid", "complete", "completed", "accepted", "active", "profit"], + error: ["error", "fail", "failed", "failure", "failures", "invalid", "rejected", "inactive", "loss", "cost", "deleted", "pending"], + warning: ["warn", "warning", "incomplete", "unstable"], + brand: ["count"], + accent1: ["sum"], + accent2: ["average"] +}; +var PREFERRED_COLORS_MAP = {}; + +for (var _color in PREFERRED_COLORS) { + if (Object.prototype.hasOwnProperty.call(PREFERRED_COLORS, _color)) { + var keys = PREFERRED_COLORS[_color]; + + for (var i = 0; i < keys.length; i++) { + PREFERRED_COLORS_MAP[keys[i]] = _color; + } + } +} + +function getPreferredColor(key) { + return color(PREFERRED_COLORS_MAP[key.toLowerCase()]); +} // returns a mapping of deterministically assigned colors to keys, optionally with a fixed value mapping + + +function getColorsForValues(keys) { + var existingAssignments = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + var all = Object.values(harmony); + var primaryTier = all.slice(0, 8); + var secondaryTier = all.slice(8); + return (0,_deterministic__WEBPACK_IMPORTED_MODULE_3__.deterministicAssign)(keys, primaryTier, existingAssignments, getPreferredColor, [secondaryTier]); +} // conviennce for a single color (only use for visualizations with a single color) + +function getColorForValue(key) { + return getColorsForValues([key])[key]; +} + +/***/ }), + +/***/ "./lib/constants.js": +/*!**************************!*\ + !*** ./lib/constants.js ***! + \**************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "SEARCH_DEBOUNCE_DURATION": function() { return /* binding */ SEARCH_DEBOUNCE_DURATION; }, +/* harmony export */ "DEFAULT_SEARCH_LIMIT": function() { return /* binding */ DEFAULT_SEARCH_LIMIT; }, +/* harmony export */ "NULL_NUMERIC_VALUE": function() { return /* binding */ NULL_NUMERIC_VALUE; }, +/* harmony export */ "NULL_DISPLAY_VALUE": function() { return /* binding */ NULL_DISPLAY_VALUE; }, +/* harmony export */ "TOTAL_ORDINAL_VALUE": function() { return /* binding */ TOTAL_ORDINAL_VALUE; } +/* harmony export */ }); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_0__); +var _templateObject; + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + + +var SEARCH_DEBOUNCE_DURATION = 300; +var DEFAULT_SEARCH_LIMIT = 50; // A part of hack required to work with both null and 0 +// values in numeric dimensions + +var NULL_NUMERIC_VALUE = -Infinity; +var NULL_DISPLAY_VALUE = (0,ttag__WEBPACK_IMPORTED_MODULE_0__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["(empty)"]))); // Hack to work with numeric and string x values in waterfall charts +// Must be a unique string which can be converted to a number since +// crossfilter converts strings to numbers when grouping starts with numeric data + +var TOTAL_ORDINAL_VALUE = "Infinity"; + +/***/ }), + +/***/ "./lib/core.js": +/*!*********************!*\ + !*** ./lib/core.js ***! + \*********************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "field_semantic_types": function() { return /* binding */ field_semantic_types; }, +/* harmony export */ "field_semantic_types_map": function() { return /* binding */ field_semantic_types_map; }, +/* harmony export */ "has_field_values_options": function() { return /* binding */ has_field_values_options; }, +/* harmony export */ "field_visibility_types": function() { return /* binding */ field_visibility_types; } +/* harmony export */ }); +/* harmony import */ var metabase_lib_types__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! metabase/lib/types */ "./lib/types.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_1__); +var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18, _templateObject19, _templateObject20, _templateObject21, _templateObject22, _templateObject23, _templateObject24, _templateObject25, _templateObject26, _templateObject27, _templateObject28, _templateObject29, _templateObject30, _templateObject31, _templateObject32, _templateObject33, _templateObject34, _templateObject35, _templateObject36, _templateObject37, _templateObject38, _templateObject39, _templateObject40, _templateObject41, _templateObject42, _templateObject43, _templateObject44, _templateObject45, _templateObject46, _templateObject47, _templateObject48, _templateObject49, _templateObject50, _templateObject51, _templateObject52, _templateObject53, _templateObject54, _templateObject55, _templateObject56, _templateObject57, _templateObject58, _templateObject59, _templateObject60, _templateObject61, _templateObject62, _templateObject63, _templateObject64, _templateObject65, _templateObject66, _templateObject67, _templateObject68, _templateObject69, _templateObject70, _templateObject71, _templateObject72, _templateObject73, _templateObject74, _templateObject75, _templateObject76, _templateObject77, _templateObject78, _templateObject79, _templateObject80, _templateObject81, _templateObject82, _templateObject83, _templateObject84, _templateObject85, _templateObject86, _templateObject87, _templateObject88, _templateObject89, _templateObject90, _templateObject91, _templateObject92, _templateObject93, _templateObject94, _templateObject95, _templateObject96, _templateObject97, _templateObject98, _templateObject99, _templateObject100, _templateObject101, _templateObject102, _templateObject103, _templateObject104, _templateObject105, _templateObject106, _templateObject107, _templateObject108, _templateObject109, _templateObject110, _templateObject111, _templateObject112; + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + + + +var field_semantic_types = [ +/* Overall Row */ +{ + id: metabase_lib_types__WEBPACK_IMPORTED_MODULE_0__.TYPE.PK, + name: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["Entity Key"]))), + section: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["Overall Row"]))), + description: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["The primary key for this table."]))) +}, { + id: metabase_lib_types__WEBPACK_IMPORTED_MODULE_0__.TYPE.Name, + name: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["Entity Name"]))), + section: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["Overall Row"]))), + description: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["The \"name\" of each record. Usually a column called \"name\", \"title\", etc."]))) +}, { + id: metabase_lib_types__WEBPACK_IMPORTED_MODULE_0__.TYPE.FK, + name: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["Foreign Key"]))), + section: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["Overall Row"]))), + description: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["Points to another table to make a connection."]))) +}, +/* Common */ +{ + id: metabase_lib_types__WEBPACK_IMPORTED_MODULE_0__.TYPE.Category, + name: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["Category"]))), + section: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["Common"]))) +}, { + id: metabase_lib_types__WEBPACK_IMPORTED_MODULE_0__.TYPE.Comment, + name: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["Comment"]))), + section: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject13 || (_templateObject13 = _taggedTemplateLiteral(["Common"]))) +}, { + id: metabase_lib_types__WEBPACK_IMPORTED_MODULE_0__.TYPE.Description, + name: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject14 || (_templateObject14 = _taggedTemplateLiteral(["Description"]))), + section: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject15 || (_templateObject15 = _taggedTemplateLiteral(["Common"]))) +}, { + id: metabase_lib_types__WEBPACK_IMPORTED_MODULE_0__.TYPE.Title, + name: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject16 || (_templateObject16 = _taggedTemplateLiteral(["Title"]))), + section: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject17 || (_templateObject17 = _taggedTemplateLiteral(["Common"]))) +}, +/* Location */ +{ + id: metabase_lib_types__WEBPACK_IMPORTED_MODULE_0__.TYPE.City, + name: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject18 || (_templateObject18 = _taggedTemplateLiteral(["City"]))), + section: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject19 || (_templateObject19 = _taggedTemplateLiteral(["Location"]))) +}, { + id: metabase_lib_types__WEBPACK_IMPORTED_MODULE_0__.TYPE.Country, + name: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject20 || (_templateObject20 = _taggedTemplateLiteral(["Country"]))), + section: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject21 || (_templateObject21 = _taggedTemplateLiteral(["Location"]))) +}, { + id: metabase_lib_types__WEBPACK_IMPORTED_MODULE_0__.TYPE.Latitude, + name: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject22 || (_templateObject22 = _taggedTemplateLiteral(["Latitude"]))), + section: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject23 || (_templateObject23 = _taggedTemplateLiteral(["Location"]))) +}, { + id: metabase_lib_types__WEBPACK_IMPORTED_MODULE_0__.TYPE.Longitude, + name: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject24 || (_templateObject24 = _taggedTemplateLiteral(["Longitude"]))), + section: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject25 || (_templateObject25 = _taggedTemplateLiteral(["Location"]))) +}, { + id: metabase_lib_types__WEBPACK_IMPORTED_MODULE_0__.TYPE.State, + name: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject26 || (_templateObject26 = _taggedTemplateLiteral(["State"]))), + section: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject27 || (_templateObject27 = _taggedTemplateLiteral(["Location"]))) +}, { + id: metabase_lib_types__WEBPACK_IMPORTED_MODULE_0__.TYPE.ZipCode, + name: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject28 || (_templateObject28 = _taggedTemplateLiteral(["Zip Code"]))), + section: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject29 || (_templateObject29 = _taggedTemplateLiteral(["Location"]))) +}, +/* Financial */ +{ + id: metabase_lib_types__WEBPACK_IMPORTED_MODULE_0__.TYPE.Cost, + name: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject30 || (_templateObject30 = _taggedTemplateLiteral(["Cost"]))), + section: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject31 || (_templateObject31 = _taggedTemplateLiteral(["Financial"]))) +}, { + id: metabase_lib_types__WEBPACK_IMPORTED_MODULE_0__.TYPE.Currency, + name: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject32 || (_templateObject32 = _taggedTemplateLiteral(["Currency"]))), + section: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject33 || (_templateObject33 = _taggedTemplateLiteral(["Financial"]))) +}, { + id: metabase_lib_types__WEBPACK_IMPORTED_MODULE_0__.TYPE.Discount, + name: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject34 || (_templateObject34 = _taggedTemplateLiteral(["Discount"]))), + section: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject35 || (_templateObject35 = _taggedTemplateLiteral(["Financial"]))) +}, { + id: metabase_lib_types__WEBPACK_IMPORTED_MODULE_0__.TYPE.GrossMargin, + name: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject36 || (_templateObject36 = _taggedTemplateLiteral(["Gross margin"]))), + section: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject37 || (_templateObject37 = _taggedTemplateLiteral(["Financial"]))) +}, { + id: metabase_lib_types__WEBPACK_IMPORTED_MODULE_0__.TYPE.Income, + name: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject38 || (_templateObject38 = _taggedTemplateLiteral(["Income"]))), + section: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject39 || (_templateObject39 = _taggedTemplateLiteral(["Financial"]))) +}, { + id: metabase_lib_types__WEBPACK_IMPORTED_MODULE_0__.TYPE.Price, + name: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject40 || (_templateObject40 = _taggedTemplateLiteral(["Price"]))), + section: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject41 || (_templateObject41 = _taggedTemplateLiteral(["Financial"]))) +}, +/* Numeric */ +{ + id: metabase_lib_types__WEBPACK_IMPORTED_MODULE_0__.TYPE.Quantity, + name: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject42 || (_templateObject42 = _taggedTemplateLiteral(["Quantity"]))), + section: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject43 || (_templateObject43 = _taggedTemplateLiteral(["Numeric"]))) +}, { + id: metabase_lib_types__WEBPACK_IMPORTED_MODULE_0__.TYPE.Score, + name: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject44 || (_templateObject44 = _taggedTemplateLiteral(["Score"]))), + section: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject45 || (_templateObject45 = _taggedTemplateLiteral(["Numeric"]))) +}, { + id: metabase_lib_types__WEBPACK_IMPORTED_MODULE_0__.TYPE.Share, + name: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject46 || (_templateObject46 = _taggedTemplateLiteral(["Share"]))), + section: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject47 || (_templateObject47 = _taggedTemplateLiteral(["Numeric"]))) +}, +/* Profile */ +{ + id: metabase_lib_types__WEBPACK_IMPORTED_MODULE_0__.TYPE.Birthdate, + name: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject48 || (_templateObject48 = _taggedTemplateLiteral(["Birthday"]))), + section: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject49 || (_templateObject49 = _taggedTemplateLiteral(["Profile"]))) +}, { + id: metabase_lib_types__WEBPACK_IMPORTED_MODULE_0__.TYPE.Company, + name: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject50 || (_templateObject50 = _taggedTemplateLiteral(["Company"]))), + section: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject51 || (_templateObject51 = _taggedTemplateLiteral(["Profile"]))) +}, { + id: metabase_lib_types__WEBPACK_IMPORTED_MODULE_0__.TYPE.Email, + name: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject52 || (_templateObject52 = _taggedTemplateLiteral(["Email"]))), + section: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject53 || (_templateObject53 = _taggedTemplateLiteral(["Profile"]))) +}, { + id: metabase_lib_types__WEBPACK_IMPORTED_MODULE_0__.TYPE.Owner, + name: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject54 || (_templateObject54 = _taggedTemplateLiteral(["Owner"]))), + section: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject55 || (_templateObject55 = _taggedTemplateLiteral(["Profile"]))) +}, { + id: metabase_lib_types__WEBPACK_IMPORTED_MODULE_0__.TYPE.Subscription, + name: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject56 || (_templateObject56 = _taggedTemplateLiteral(["Subscription"]))), + section: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject57 || (_templateObject57 = _taggedTemplateLiteral(["Profile"]))) +}, { + id: metabase_lib_types__WEBPACK_IMPORTED_MODULE_0__.TYPE.User, + name: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject58 || (_templateObject58 = _taggedTemplateLiteral(["User"]))), + section: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject59 || (_templateObject59 = _taggedTemplateLiteral(["Profile"]))) +}, +/* Date and Time */ +{ + id: metabase_lib_types__WEBPACK_IMPORTED_MODULE_0__.TYPE.CancelationDate, + name: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject60 || (_templateObject60 = _taggedTemplateLiteral(["Cancelation date"]))), + section: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject61 || (_templateObject61 = _taggedTemplateLiteral(["Date and Time"]))) +}, { + id: metabase_lib_types__WEBPACK_IMPORTED_MODULE_0__.TYPE.CancelationTime, + name: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject62 || (_templateObject62 = _taggedTemplateLiteral(["Cancelation time"]))), + section: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject63 || (_templateObject63 = _taggedTemplateLiteral(["Date and Time"]))) +}, { + id: metabase_lib_types__WEBPACK_IMPORTED_MODULE_0__.TYPE.CancelationTimestamp, + name: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject64 || (_templateObject64 = _taggedTemplateLiteral(["Cancelation timestamp"]))), + section: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject65 || (_templateObject65 = _taggedTemplateLiteral(["Date and Time"]))) +}, { + id: metabase_lib_types__WEBPACK_IMPORTED_MODULE_0__.TYPE.CreationDate, + name: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject66 || (_templateObject66 = _taggedTemplateLiteral(["Creation date"]))), + section: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject67 || (_templateObject67 = _taggedTemplateLiteral(["Date and Time"]))) +}, { + id: metabase_lib_types__WEBPACK_IMPORTED_MODULE_0__.TYPE.CreationTime, + name: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject68 || (_templateObject68 = _taggedTemplateLiteral(["Creation time"]))), + section: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject69 || (_templateObject69 = _taggedTemplateLiteral(["Date and Time"]))) +}, { + id: metabase_lib_types__WEBPACK_IMPORTED_MODULE_0__.TYPE.CreationTimestamp, + name: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject70 || (_templateObject70 = _taggedTemplateLiteral(["Creation timestamp"]))), + section: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject71 || (_templateObject71 = _taggedTemplateLiteral(["Date and Time"]))) +}, { + id: metabase_lib_types__WEBPACK_IMPORTED_MODULE_0__.TYPE.DeletionDate, + name: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject72 || (_templateObject72 = _taggedTemplateLiteral(["Deletion date"]))), + section: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject73 || (_templateObject73 = _taggedTemplateLiteral(["Date and Time"]))) +}, { + id: metabase_lib_types__WEBPACK_IMPORTED_MODULE_0__.TYPE.DeletionTime, + name: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject74 || (_templateObject74 = _taggedTemplateLiteral(["Deletion time"]))), + section: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject75 || (_templateObject75 = _taggedTemplateLiteral(["Date and Time"]))) +}, { + id: metabase_lib_types__WEBPACK_IMPORTED_MODULE_0__.TYPE.DeletionTimestamp, + name: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject76 || (_templateObject76 = _taggedTemplateLiteral(["Deletion timestamp"]))), + section: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject77 || (_templateObject77 = _taggedTemplateLiteral(["Date and Time"]))) +}, { + id: metabase_lib_types__WEBPACK_IMPORTED_MODULE_0__.TYPE.UpdatedDate, + name: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject78 || (_templateObject78 = _taggedTemplateLiteral(["Updated date"]))), + section: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject79 || (_templateObject79 = _taggedTemplateLiteral(["Date and Time"]))) +}, { + id: metabase_lib_types__WEBPACK_IMPORTED_MODULE_0__.TYPE.UpdatedTime, + name: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject80 || (_templateObject80 = _taggedTemplateLiteral(["Updated time"]))), + section: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject81 || (_templateObject81 = _taggedTemplateLiteral(["Date and Time"]))) +}, { + id: metabase_lib_types__WEBPACK_IMPORTED_MODULE_0__.TYPE.UpdatedTimestamp, + name: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject82 || (_templateObject82 = _taggedTemplateLiteral(["Updated timestamp"]))), + section: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject83 || (_templateObject83 = _taggedTemplateLiteral(["Date and Time"]))) +}, { + id: metabase_lib_types__WEBPACK_IMPORTED_MODULE_0__.TYPE.JoinDate, + name: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject84 || (_templateObject84 = _taggedTemplateLiteral(["Join date"]))), + section: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject85 || (_templateObject85 = _taggedTemplateLiteral(["Date and Time"]))) +}, { + id: metabase_lib_types__WEBPACK_IMPORTED_MODULE_0__.TYPE.JoinTime, + name: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject86 || (_templateObject86 = _taggedTemplateLiteral(["Join time"]))), + section: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject87 || (_templateObject87 = _taggedTemplateLiteral(["Date and Time"]))) +}, { + id: metabase_lib_types__WEBPACK_IMPORTED_MODULE_0__.TYPE.JoinTimestamp, + name: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject88 || (_templateObject88 = _taggedTemplateLiteral(["Join timestamp"]))), + section: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject89 || (_templateObject89 = _taggedTemplateLiteral(["Date and Time"]))) +}, +/* Categorical */ +{ + id: metabase_lib_types__WEBPACK_IMPORTED_MODULE_0__.TYPE.Enum, + name: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject90 || (_templateObject90 = _taggedTemplateLiteral(["Enum"]))), + section: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject91 || (_templateObject91 = _taggedTemplateLiteral(["Categorical"]))) +}, { + id: metabase_lib_types__WEBPACK_IMPORTED_MODULE_0__.TYPE.Product, + name: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject92 || (_templateObject92 = _taggedTemplateLiteral(["Product"]))), + section: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject93 || (_templateObject93 = _taggedTemplateLiteral(["Categorical"]))) +}, { + id: metabase_lib_types__WEBPACK_IMPORTED_MODULE_0__.TYPE.Source, + name: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject94 || (_templateObject94 = _taggedTemplateLiteral(["Source"]))), + section: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject95 || (_templateObject95 = _taggedTemplateLiteral(["Categorical"]))) +}, +/* URLs */ +{ + id: metabase_lib_types__WEBPACK_IMPORTED_MODULE_0__.TYPE.AvatarURL, + name: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject96 || (_templateObject96 = _taggedTemplateLiteral(["Avatar Image URL"]))), + section: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject97 || (_templateObject97 = _taggedTemplateLiteral(["URLs"]))) +}, { + id: metabase_lib_types__WEBPACK_IMPORTED_MODULE_0__.TYPE.ImageURL, + name: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject98 || (_templateObject98 = _taggedTemplateLiteral(["Image URL"]))), + section: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject99 || (_templateObject99 = _taggedTemplateLiteral(["URLs"]))) +}, { + id: metabase_lib_types__WEBPACK_IMPORTED_MODULE_0__.TYPE.URL, + name: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject100 || (_templateObject100 = _taggedTemplateLiteral(["URL"]))), + section: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject101 || (_templateObject101 = _taggedTemplateLiteral(["URLs"]))) +}, +/* Other */ +{ + id: metabase_lib_types__WEBPACK_IMPORTED_MODULE_0__.TYPE.SerializedJSON, + name: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject102 || (_templateObject102 = _taggedTemplateLiteral(["Field containing JSON"]))), + section: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject103 || (_templateObject103 = _taggedTemplateLiteral(["Other"]))) +}]; +var field_semantic_types_map = field_semantic_types.reduce(function (map, type) { + return Object.assign({}, map, _defineProperty({}, type.id, type)); +}, {}); +var has_field_values_options = [{ + name: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject104 || (_templateObject104 = _taggedTemplateLiteral(["Search box"]))), + value: "search" +}, { + name: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject105 || (_templateObject105 = _taggedTemplateLiteral(["A list of all values"]))), + value: "list" +}, { + name: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject106 || (_templateObject106 = _taggedTemplateLiteral(["Plain input box"]))), + value: "none" +}]; +var field_visibility_types = [{ + id: "normal", + name: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject107 || (_templateObject107 = _taggedTemplateLiteral(["Everywhere"]))), + description: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject108 || (_templateObject108 = _taggedTemplateLiteral(["The default setting. This field will be displayed normally in tables and charts."]))) +}, { + id: "details-only", + name: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject109 || (_templateObject109 = _taggedTemplateLiteral(["Only in detail views"]))), + description: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject110 || (_templateObject110 = _taggedTemplateLiteral(["This field will only be displayed when viewing the details of a single record. Use this for information that's lengthy or that isn't useful in a table or chart."]))) +}, { + id: "sensitive", + name: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject111 || (_templateObject111 = _taggedTemplateLiteral(["Do not include"]))), + description: (0,ttag__WEBPACK_IMPORTED_MODULE_1__.t)(_templateObject112 || (_templateObject112 = _taggedTemplateLiteral(["This field won't be visible or selectable in questions created with the GUI interfaces. It will still be accessible in SQL/native queries."]))) +}]; + +/***/ }), + +/***/ "./lib/dashboard_grid.js": +/*!*******************************!*\ + !*** ./lib/dashboard_grid.js ***! + \*******************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "GRID_WIDTH": function() { return /* binding */ GRID_WIDTH; }, +/* harmony export */ "GRID_ASPECT_RATIO": function() { return /* binding */ GRID_ASPECT_RATIO; }, +/* harmony export */ "GRID_BREAKPOINTS": function() { return /* binding */ GRID_BREAKPOINTS; }, +/* harmony export */ "GRID_COLUMNS": function() { return /* binding */ GRID_COLUMNS; }, +/* harmony export */ "DEFAULT_CARD_SIZE": function() { return /* binding */ DEFAULT_CARD_SIZE; }, +/* harmony export */ "MIN_ROW_HEIGHT": function() { return /* binding */ MIN_ROW_HEIGHT; }, +/* harmony export */ "getPositionForNewDashCard": function() { return /* binding */ getPositionForNewDashCard; } +/* harmony export */ }); +/* provided dependency */ var console = __webpack_require__(/*! console-browserify */ "../../../node_modules/console-browserify/index.js"); +function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +var GRID_WIDTH = 18; +var GRID_ASPECT_RATIO = 4 / 3; +var MOBILE_BREAKPOINT = 752; +var GRID_BREAKPOINTS = { + desktop: MOBILE_BREAKPOINT + 1, + mobile: MOBILE_BREAKPOINT +}; +var GRID_COLUMNS = { + desktop: GRID_WIDTH, + mobile: 1 +}; +var DEFAULT_CARD_SIZE = { + width: 4, + height: 4 +}; +var MIN_ROW_HEIGHT = 54; // returns the first available position from left to right, top to bottom, +// based on the existing cards, item size, and grid width + +function getPositionForNewDashCard(cards) { + var sizeX = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_CARD_SIZE.width; + var sizeY = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : DEFAULT_CARD_SIZE.height; + var width = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : GRID_WIDTH; + var row = 0; + var col = 0; + + while (row < 1000) { + while (col <= width - sizeX) { + var good = true; + var position = { + col: col, + row: row, + sizeX: sizeX, + sizeY: sizeY + }; + + var _iterator = _createForOfIteratorHelper(cards), + _step; + + try { + for (_iterator.s(); !(_step = _iterator.n()).done;) { + var card = _step.value; + + if (intersects(card, position)) { + good = false; + break; + } + } + } catch (err) { + _iterator.e(err); + } finally { + _iterator.f(); + } + + if (good) { + return position; + } + + col++; + } + + col = 0; + row++; + } // this should never happen but flow complains if we return undefined + + + return { + col: col, + row: row, + sizeX: sizeX, + sizeY: sizeY + }; +} + +function intersects(a, b) { + return !(b.col >= a.col + a.sizeX || b.col + b.sizeX <= a.col || b.row >= a.row + a.sizeY || b.row + b.sizeY <= a.row); +} // for debugging + +/*eslint-disable */ + + +function printGrid(cards, width) { + var grid = []; + + var _iterator2 = _createForOfIteratorHelper(cards), + _step2; + + try { + for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { + var card = _step2.value; + + for (var col = card.col; col < card.col + card.sizeX; col++) { + for (var row = card.row; row < card.row + card.sizeY; row++) { + grid[row] = grid[row] || Array(width).join(".").split(".").map(function () { + return 0; + }); + grid[row][col]++; + } + } + } + } catch (err) { + _iterator2.e(err); + } finally { + _iterator2.f(); + } + + console.log("\n" + grid.map(function (row) { + return row.join("."); + }).join("\n") + "\n"); +} +/*eslint-enable */ + +/***/ }), + +/***/ "./lib/data_grid.js": +/*!**************************!*\ + !*** ./lib/data_grid.js ***! + \**************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "isPivotGroupColumn": function() { return /* binding */ isPivotGroupColumn; }, +/* harmony export */ "COLLAPSED_ROWS_SETTING": function() { return /* binding */ COLLAPSED_ROWS_SETTING; }, +/* harmony export */ "COLUMN_SPLIT_SETTING": function() { return /* binding */ COLUMN_SPLIT_SETTING; }, +/* harmony export */ "COLUMN_SHOW_TOTALS": function() { return /* binding */ COLUMN_SHOW_TOTALS; }, +/* harmony export */ "COLUMN_SORT_ORDER": function() { return /* binding */ COLUMN_SORT_ORDER; }, +/* harmony export */ "COLUMN_SORT_ORDER_ASC": function() { return /* binding */ COLUMN_SORT_ORDER_ASC; }, +/* harmony export */ "COLUMN_SORT_ORDER_DESC": function() { return /* binding */ COLUMN_SORT_ORDER_DESC; }, +/* harmony export */ "multiLevelPivot": function() { return /* binding */ multiLevelPivot; }, +/* harmony export */ "pivot": function() { return /* binding */ pivot; } +/* harmony export */ }); +/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! underscore */ "../../../node_modules/underscore/modules/index-all.js"); +/* harmony import */ var icepick__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! icepick */ "../../../node_modules/icepick/icepick.min.js"); +/* harmony import */ var icepick__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(icepick__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ttag */ "../../../node_modules/ttag/index.js"); +/* harmony import */ var ttag__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(ttag__WEBPACK_IMPORTED_MODULE_2__); +/* harmony import */ var metabase_lib_formatting__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! metabase/lib/formatting */ "./lib/formatting.js"); +/* provided dependency */ var console = __webpack_require__(/*! console-browserify */ "../../../node_modules/console-browserify/index.js"); +var _excluded = ["value", "children"], + _excluded2 = ["children", "rawValue", "isGrandTotal", "isValueColumn"]; + +var _templateObject, _templateObject2, _templateObject3; + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } + +function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } + +function _toArray(arr) { return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest(); } + +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } + +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } + +function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } + +function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } + +function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } + +function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + + + + + +function isPivotGroupColumn(col) { + return col.name === "pivot-grouping"; +} +var COLLAPSED_ROWS_SETTING = "pivot_table.collapsed_rows"; +var COLUMN_SPLIT_SETTING = "pivot_table.column_split"; +var COLUMN_SHOW_TOTALS = "pivot_table.column_show_totals"; +var COLUMN_SORT_ORDER = "pivot_table.column_sort_order"; +var COLUMN_SORT_ORDER_ASC = "ascending"; +var COLUMN_SORT_ORDER_DESC = "descending"; +function multiLevelPivot(data, settings) { + var columnSplit = settings[COLUMN_SPLIT_SETTING]; + + if (columnSplit == null) { + return null; + } + + var columnsWithoutPivotGroup = data.cols.filter(function (col) { + return !isPivotGroupColumn(col); + }); + + var _$mapObject = underscore__WEBPACK_IMPORTED_MODULE_0__.default.mapObject(columnSplit, function (columnFieldRefs) { + return columnFieldRefs.map(function (field_ref) { + return columnsWithoutPivotGroup.findIndex(function (col) { + return underscore__WEBPACK_IMPORTED_MODULE_0__.default.isEqual(col.field_ref, field_ref); + }); + }).filter(function (index) { + return index !== -1; + }); + }), + columnColumnIndexes = _$mapObject.columns, + rowColumnIndexes = _$mapObject.rows, + valueColumnIndexes = _$mapObject.values; + + var _splitPivotData = splitPivotData(data, rowColumnIndexes, columnColumnIndexes), + pivotData = _splitPivotData.pivotData, + columns = _splitPivotData.columns; + + var columnSettings = columns.map(function (column) { + return settings.column(column); + }); + var allCollapsedSubtotals = settings[COLLAPSED_ROWS_SETTING].value; + var collapsedSubtotals = filterCollapsedSubtotals(allCollapsedSubtotals, rowColumnIndexes.map(function (index) { + return columnSettings[index]; + })); // we build a tree for each tuple of pivoted column/row values seen in the data + + var columnColumnTree = []; + var rowColumnTree = []; // this stores pivot table values keyed by all pivoted columns + + var valuesByKey = {}; // loop over the primary rows to build trees of column/row header data + + var primaryRowsKey = JSON.stringify(underscore__WEBPACK_IMPORTED_MODULE_0__.default.range(columnColumnIndexes.length + rowColumnIndexes.length)); + + var _iterator = _createForOfIteratorHelper(pivotData[primaryRowsKey]), + _step; + + try { + var _loop2 = function _loop2() { + var row = _step.value; + // mutate the trees to add the tuple from the current row + updateValueObject(row, columnColumnIndexes, columnSettings, columnColumnTree); + updateValueObject(row, rowColumnIndexes, columnSettings, rowColumnTree, collapsedSubtotals); // save the value columns keyed by the values in the column/row pivoted columns + + var valueKey = JSON.stringify(columnColumnIndexes.concat(rowColumnIndexes).map(function (index) { + return row[index]; + })); + var values = valueColumnIndexes.map(function (index) { + return row[index]; + }); + valuesByKey[valueKey] = { + values: values, + data: row.map(function (value, index) { + return { + value: value, + col: columns[index] + }; + }), + dimensions: row.map(function (value, index) { + return { + value: value, + column: columns[index] + }; + }).filter(function (_ref) { + var column = _ref.column; + return column.source === "breakout"; + }) + }; + }; + + for (_iterator.s(); !(_step = _iterator.n()).done;) { + _loop2(); + } // build objects to look up subtotal values + + } catch (err) { + _iterator.e(err); + } finally { + _iterator.f(); + } + + var subtotalValues = {}; + + for (var _i = 0, _Object$entries = Object.entries(pivotData); _i < _Object$entries.length; _i++) { + var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2), + subtotalName = _Object$entries$_i[0], + subtotal = _Object$entries$_i[1]; + + var indexes = JSON.parse(subtotalName); + subtotalValues[subtotalName] = {}; + + var _iterator2 = _createForOfIteratorHelper(subtotal), + _step2; + + try { + var _loop = function _loop() { + var row = _step2.value; + var valueKey = JSON.stringify(indexes.map(function (index) { + return row[index]; + })); + subtotalValues[subtotalName][valueKey] = valueColumnIndexes.map(function (index) { + return row[index]; + }); + }; + + for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { + _loop(); + } + } catch (err) { + _iterator2.e(err); + } finally { + _iterator2.f(); + } + } // pivot tables have a lot of repeated values, so we use memoized formatters for each column + + + var _map = [valueColumnIndexes, columnColumnIndexes, rowColumnIndexes].map(function (indexes) { + return indexes.map(function (index) { + return underscore__WEBPACK_IMPORTED_MODULE_0__.default.memoize(function (value) { + return (0,metabase_lib_formatting__WEBPACK_IMPORTED_MODULE_3__.formatValue)(value, columnSettings[index]); + }, function (value) { + return [value, index].join(); + }); + }); + }), + _map2 = _slicedToArray(_map, 3), + valueFormatters = _map2[0], + topIndexFormatters = _map2[1], + leftIndexFormatters = _map2[2]; + + var topIndexColumns = columnColumnIndexes.map(function (index) { + return columns[index]; + }); + var formattedColumnTreeWithoutValues = formatValuesInTree(columnColumnTree, topIndexFormatters, topIndexColumns); + + if (formattedColumnTreeWithoutValues.length > 1) { + // if there are multiple columns, we should add another for row totals + formattedColumnTreeWithoutValues.push({ + value: (0,ttag__WEBPACK_IMPORTED_MODULE_2__.t)(_templateObject || (_templateObject = _taggedTemplateLiteral(["Row totals"]))), + children: [], + isSubtotal: true, + isGrandTotal: true + }); + } + + var columnIndex = addEmptyIndexItem(formattedColumnTreeWithoutValues.flatMap(function (root) { + return enumeratePaths(root); + })); + var valueColumns = valueColumnIndexes.map(function (index) { + return columns[index]; + }); + var formattedColumnTree = addValueColumnNodes(formattedColumnTreeWithoutValues, valueColumns); + var leftIndexColumns = rowColumnIndexes.map(function (index) { + return columns[index]; + }); + var formattedRowTreeWithoutSubtotals = formatValuesInTree(rowColumnTree, leftIndexFormatters, leftIndexColumns); + var showSubtotalsByColumn = rowColumnIndexes.map(function (index) { + return (0,icepick__WEBPACK_IMPORTED_MODULE_1__.getIn)(columnSettings, [index, COLUMN_SHOW_TOTALS]) !== false; + }); + var formattedRowTree = addSubtotals(formattedRowTreeWithoutSubtotals, leftIndexFormatters, showSubtotalsByColumn); + + if (formattedRowTreeWithoutSubtotals.length > 1) { + // if there are multiple columns, we should add another for row totals + formattedRowTree.push({ + value: (0,ttag__WEBPACK_IMPORTED_MODULE_2__.t)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["Grand totals"]))), + isSubtotal: true, + isGrandTotal: true, + children: [] + }); + } + + var rowIndex = addEmptyIndexItem(formattedRowTree.flatMap(function (root) { + return enumeratePaths(root); + })); + var leftHeaderItems = treeToArray(formattedRowTree.flat()); + var topHeaderItems = treeToArray(formattedColumnTree.flat()); + var getRowSection = createRowSectionGetter({ + valuesByKey: valuesByKey, + subtotalValues: subtotalValues, + valueFormatters: valueFormatters, + columnColumnIndexes: columnColumnIndexes, + rowColumnIndexes: rowColumnIndexes, + columnIndex: columnIndex, + rowIndex: rowIndex + }); + return { + leftHeaderItems: leftHeaderItems, + topHeaderItems: topHeaderItems, + rowCount: rowIndex.length, + columnCount: columnIndex.length, + rowIndex: rowIndex, + getRowSection: getRowSection, + rowIndexes: rowColumnIndexes, + columnIndexes: columnColumnIndexes, + valueIndexes: valueColumnIndexes + }; +} // This pulls apart the different aggregations that were packed into one result set. +// There's a column indicating which breakouts were used to compute that row. +// We use that column to split apart the data and convert the field refs to indexes. + +function splitPivotData(data, rowIndexes, columnIndexes) { + var groupIndex = data.cols.findIndex(isPivotGroupColumn); + var columns = data.cols.filter(function (col) { + return !isPivotGroupColumn(col); + }); + var breakouts = columns.filter(function (col) { + return col.source === "breakout"; + }); + + var pivotData = underscore__WEBPACK_IMPORTED_MODULE_0__.default.chain(data.rows).groupBy(function (row) { + return row[groupIndex]; + }).pairs().map(function (_ref2) { + var _ref3 = _slicedToArray(_ref2, 2), + key = _ref3[0], + rows = _ref3[1]; + + key = parseInt(key); + + var indexes = underscore__WEBPACK_IMPORTED_MODULE_0__.default.range(breakouts.length).filter(function (index) { + return !(1 << index & key); + }); + + var keyAsIndexes = JSON.stringify(indexes); + var rowsWithoutColumn = rows.map(function (row) { + return row.slice(0, groupIndex).concat(row.slice(groupIndex + 1)); + }); + return [keyAsIndexes, rowsWithoutColumn]; + }).object().value(); + + return { + pivotData: pivotData, + columns: columns + }; +} + +function addEmptyIndexItem(index) { + // we need a single item even if all columns are on the other axis + return index.length === 0 ? [[]] : index; +} // A path can't be collapsed if subtotals are turned off for that column. +// TODO: can we move this to the COLLAPSED_ROW_SETTING itself? + + +function filterCollapsedSubtotals(collapsedSubtotals, columnSettings) { + var columnIsCollapsible = columnSettings.map(function (settings) { + return settings[COLUMN_SHOW_TOTALS] !== false; + }); + return collapsedSubtotals.filter(function (pathOrLengthString) { + var pathOrLength = JSON.parse(pathOrLengthString); + var length = Array.isArray(pathOrLength) ? pathOrLength.length : pathOrLength; + return columnIsCollapsible[length - 1]; + }); +} // The getter returned from this function returns the value(s) at given (column, row) location + + +function createRowSectionGetter(_ref4) { + var valuesByKey = _ref4.valuesByKey, + subtotalValues = _ref4.subtotalValues, + valueFormatters = _ref4.valueFormatters, + columnColumnIndexes = _ref4.columnColumnIndexes, + rowColumnIndexes = _ref4.rowColumnIndexes, + columnIndex = _ref4.columnIndex, + rowIndex = _ref4.rowIndex; + + var formatValues = function formatValues(values) { + return values === undefined ? Array(valueFormatters.length).fill({ + value: null + }) : values.map(function (v, i) { + return { + value: valueFormatters[i](v) + }; + }); + }; + + var getSubtotals = function getSubtotals(breakoutIndexes, values, otherAttrs) { + return formatValues((0,icepick__WEBPACK_IMPORTED_MODULE_1__.getIn)(subtotalValues, [breakoutIndexes, values].map(function (a) { + return JSON.stringify(underscore__WEBPACK_IMPORTED_MODULE_0__.default.sortBy(a, function (_value, index) { + return breakoutIndexes[index]; + })); + }))).map(function (value) { + return _objectSpread(_objectSpread({}, value), {}, { + isSubtotal: true + }, otherAttrs); + }); + }; + + var getter = function getter(columnIdx, rowIdx) { + var columnValues = columnIndex[columnIdx] || []; + var rowValues = rowIndex[rowIdx] || []; + var indexValues = columnValues.concat(rowValues); + + if (rowValues.length < rowColumnIndexes.length || columnValues.length < columnColumnIndexes.length) { + // if we don't have a full-length key, we're looking for a subtotal + var rowIndexes = rowColumnIndexes.slice(0, rowValues.length); + var columnIndexes = columnColumnIndexes.slice(0, columnValues.length); + var indexes = columnIndexes.concat(rowIndexes); + var otherAttrs = rowValues.length === 0 ? { + isGrandTotal: true + } : {}; + return getSubtotals(indexes, indexValues, otherAttrs); + } + + var _ref5 = valuesByKey[JSON.stringify(indexValues)] || {}, + values = _ref5.values, + data = _ref5.data, + dimensions = _ref5.dimensions; + + return formatValues(values).map(function (o) { + return data === undefined ? o : _objectSpread(_objectSpread({}, o), {}, { + clicked: { + data: data, + dimensions: dimensions + } + }); + }); + }; + + return underscore__WEBPACK_IMPORTED_MODULE_0__.default.memoize(getter, function (i1, i2) { + return [i1, i2].join(); + }); +} // Given a tree representation of an index, enumeratePaths produces a list of all paths to leaf nodes + + +function enumeratePaths(_ref6) { + var rawValue = _ref6.rawValue, + isGrandTotal = _ref6.isGrandTotal, + children = _ref6.children, + isValueColumn = _ref6.isValueColumn; + var path = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; + + if (isGrandTotal) { + return [[]]; + } + + if (isValueColumn) { + return [path]; + } + + var pathWithValue = [].concat(_toConsumableArray(path), [rawValue]); + return children.length === 0 ? [pathWithValue] : children.flatMap(function (child) { + return enumeratePaths(child, pathWithValue); + }); +} + +function formatValuesInTree(rowColumnTree, _ref7, _ref8) { + var _ref9 = _toArray(_ref7), + formatter = _ref9[0], + formatters = _ref9.slice(1); + + var _ref10 = _toArray(_ref8), + column = _ref10[0], + columns = _ref10.slice(1); + + return rowColumnTree.map(function (_ref11) { + var value = _ref11.value, + children = _ref11.children, + rest = _objectWithoutProperties(_ref11, _excluded); + + return _objectSpread(_objectSpread({}, rest), {}, { + value: formatter(value), + rawValue: value, + children: formatValuesInTree(children, formatters, columns), + clicked: { + value: value, + column: column + } + }); + }); +} // This might add value column(s) to the bottom of the top header tree. +// We display the value column names if there are multiple +// or if there are no columns pivoted to the top header. + + +function addValueColumnNodes(nodes, valueColumns) { + var leafNodes = valueColumns.map(function (column) { + return { + value: column.display_name, + children: [], + isValueColumn: true + }; + }); + + if (nodes.length === 0) { + return leafNodes; + } + + if (valueColumns.length <= 1) { + return nodes; + } + + function updateNode(node) { + var children = node.children.length === 0 ? leafNodes : node.children.map(updateNode); + return _objectSpread(_objectSpread({}, node), {}, { + children: children + }); + } + + return nodes.map(updateNode); +} // This inserts nodes into the left header tree for subtotals. +// We also mark nodes with `hasSubtotal` to display collapsing UI + + +function addSubtotals(rowColumnTree, formatters, showSubtotalsByColumn) { + // For top-level items we want to show subtotal even if they have only one child + // Except the case when top-level items have flat structure + // (meaning all of the items have just one child) + // If top-level items are flat, subtotals will just repeat their corresponding row + // https://github.com/metabase/metabase/issues/15211 + // https://github.com/metabase/metabase/pull/16566 + var notFlat = rowColumnTree.some(function (item) { + return item.children.length > 1; + }); + return rowColumnTree.flatMap(function (item) { + return addSubtotal(item, formatters, showSubtotalsByColumn, { + shouldShowSubtotal: notFlat || item.children.length > 1 + }); + }); +} + +function addSubtotal(item, _ref12, _ref13) { + var _ref14 = _toArray(_ref12), + formatter = _ref14[0], + formatters = _ref14.slice(1); + + var _ref15 = _toArray(_ref13), + isSubtotalEnabled = _ref15[0], + showSubtotalsByColumn = _ref15.slice(1); + + var _ref16 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}, + _ref16$shouldShowSubt = _ref16.shouldShowSubtotal, + shouldShowSubtotal = _ref16$shouldShowSubt === void 0 ? false : _ref16$shouldShowSubt; + + var hasSubtotal = isSubtotalEnabled && shouldShowSubtotal; + var subtotal = hasSubtotal ? [{ + value: (0,ttag__WEBPACK_IMPORTED_MODULE_2__.t)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["Totals for ", ""])), formatter(item.value)), + rawValue: item.rawValue, + span: 1, + isSubtotal: true, + children: [] + }] : []; + + if (item.isCollapsed) { + return subtotal; + } + + var node = _objectSpread(_objectSpread({}, item), {}, { + hasSubtotal: hasSubtotal, + children: item.children.flatMap(function (child) { + return (// add subtotals until the last level + child.children.length > 0 ? addSubtotal(child, formatters, showSubtotalsByColumn, { + shouldShowSubtotal: child.children.length > 1 + }) : child + ); + }) + }); + + return [node].concat(subtotal); +} // Update the tree with a row of data + + +function updateValueObject(row, indexes, columnSettings, seenValues) { + var collapsedSubtotals = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : []; + var currentLevelSeenValues = seenValues; + var prefix = []; + + var _iterator3 = _createForOfIteratorHelper(indexes), + _step3; + + try { + var _loop3 = function _loop3() { + var index = _step3.value; + var value = row[index]; + prefix.push(value); + var seenValue = currentLevelSeenValues.find(function (d) { + return d.value === value; + }); + var isCollapsed = // the specific path is collapsed + collapsedSubtotals.includes(JSON.stringify(prefix)) || // the entire column is collapsed + collapsedSubtotals.includes(JSON.stringify(prefix.length)); + + if (seenValue === undefined) { + seenValue = { + value: value, + children: [], + isCollapsed: isCollapsed + }; + currentLevelSeenValues.push(seenValue); + sortLevelOfTree(currentLevelSeenValues, columnSettings[index]); + } + + currentLevelSeenValues = seenValue.children; + }; + + for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) { + _loop3(); + } + } catch (err) { + _iterator3.e(err); + } finally { + _iterator3.f(); + } +} // Sorts the array of nodes in place if a sort order is set for that column + + +function sortLevelOfTree(array) { + var _ref17 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, + sortOrder = _ref17[COLUMN_SORT_ORDER]; + + if (sortOrder == null) { + // don't sort unless there's a column sort order set + return; + } + + array.sort(function (a, b) { + if (a.value === b.value) { + return 0; + } // by default use "<" to compare values + + + var result = a.value < b.value ? -1 : 1; // strings should use localeCompare to handle accents, etc + + if (typeof a.value === "string") { + result = a.value.localeCompare(b.value); + } // flip the comparison for descending + + + if (sortOrder === COLUMN_SORT_ORDER_DESC) { + result *= -1; + } + + return result; + }); +} // Take a tree and produce a flat list used to layout the top/left headers. +// We track the depth, offset, etc to know how to line items up in the headers. + + +function treeToArray(nodes) { + var a = []; + + function dfs(nodes, depth, offset) { + var path = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : []; + + if (nodes.length === 0) { + return { + span: 1, + maxDepth: 0 + }; + } + + var totalSpan = 0; + var maxDepth = 0; + + var _iterator4 = _createForOfIteratorHelper(nodes), + _step4; + + try { + for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) { + var _ref19 = _step4.value; + + var children = _ref19.children, + rawValue = _ref19.rawValue, + isGrandTotal = _ref19.isGrandTotal, + isValueColumn = _ref19.isValueColumn, + rest = _objectWithoutProperties(_ref19, _excluded2); + + var pathWithValue = isValueColumn || isGrandTotal ? null : [].concat(_toConsumableArray(path), [rawValue]); + + var item = _objectSpread(_objectSpread({}, rest), {}, { + rawValue: rawValue, + isGrandTotal: isGrandTotal, + depth: depth, + offset: offset, + hasChildren: children.length > 0, + path: pathWithValue + }); + + a.push(item); + var result = dfs(children, depth + 1, offset, pathWithValue); + item.span = result.span; + item.maxDepthBelow = result.maxDepth; + offset += result.span; + totalSpan += result.span; + maxDepth = Math.max(maxDepth, result.maxDepth); + } + } catch (err) { + _iterator4.e(err); + } finally { + _iterator4.f(); + } + + return { + span: totalSpan, + maxDepth: maxDepth + 1 + }; + } + + dfs(nodes, 0, 0); + return a; +} // This is the pivot function used in the normal table visualization. + + +function pivot(data, normalCol, pivotCol, cellCol) { + var _distinctValuesSorted = distinctValuesSorted(data.rows, pivotCol, normalCol), + pivotValues = _distinctValuesSorted.pivotValues, + normalValues = _distinctValuesSorted.normalValues; // make sure that the first element in the pivoted column list is null which makes room for the label of the other column + + + pivotValues.unshift(data.cols[normalCol].display_name); // start with an empty grid that we'll fill with the appropriate values + + var pivotedRows = normalValues.map(function (normalValues, index) { + var row = pivotValues.map(function () { + return null; + }); // for onVisualizationClick: + + row._dimension = { + value: normalValues, + column: data.cols[normalCol] + }; + return row; + }); // keep a record of which row the data came from for onVisualizationClick + + var sourceRows = normalValues.map(function () { + return pivotValues.map(function () { + return null; + }); + }); // fill it up with the data + + for (var j = 0; j < data.rows.length; j++) { + var normalColIdx = normalValues.lastIndexOf(data.rows[j][normalCol]); + var pivotColIdx = pivotValues.lastIndexOf(data.rows[j][pivotCol]); + pivotedRows[normalColIdx][0] = data.rows[j][normalCol]; + pivotedRows[normalColIdx][pivotColIdx] = data.rows[j][cellCol]; + sourceRows[normalColIdx][pivotColIdx] = j; + } // provide some column metadata to maintain consistency + + + var cols = pivotValues.map(function (value, idx) { + if (idx === 0) { + // first column is always the coldef of the normal column + return data.cols[normalCol]; + } else { + return _objectSpread(_objectSpread({}, data.cols[cellCol]), {}, { + // `name` must be the same for conditional formatting, but put the + // formatted pivotted value in the `display_name` + display_name: (0,metabase_lib_formatting__WEBPACK_IMPORTED_MODULE_3__.formatValue)(value, { + column: data.cols[pivotCol] + }) || "", + // for onVisualizationClick: + _dimension: { + value: value, + column: data.cols[pivotCol] + } + }); + } + }); + return { + cols: cols, + columns: pivotValues, + rows: pivotedRows, + sourceRows: sourceRows + }; +} + +function distinctValuesSorted(rows, pivotColIdx, normalColIdx) { + var normalSet = new Set(); + var pivotSet = new Set(); + var normalSortState = new SortState(); + var pivotSortState = new SortState(); + + var _iterator5 = _createForOfIteratorHelper(rows), + _step5; + + try { + for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) { + var row = _step5.value; + var pivotValue = row[pivotColIdx]; + var normalValue = row[normalColIdx]; + normalSet.add(normalValue); + pivotSet.add(pivotValue); + normalSortState.update(normalValue, pivotValue); + pivotSortState.update(pivotValue, normalValue); + } + } catch (err) { + _iterator5.e(err); + } finally { + _iterator5.f(); + } + + var normalValues = Array.from(normalSet); + var pivotValues = Array.from(pivotSet); + normalSortState.sort(normalValues); + pivotSortState.sort(pivotValues); + return { + normalValues: normalValues, + pivotValues: pivotValues + }; +} // This should work for both strings and numbers + + +var DEFAULT_COMPARE = function DEFAULT_COMPARE(a, b) { + return a < b ? -1 : a > b ? 1 : 0; +}; + +var SortState = /*#__PURE__*/function () { + function SortState() { + var compare = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_COMPARE; + + _classCallCheck(this, SortState); + + this.compare = compare; + this.asc = true; + this.desc = true; + this.lastValue = undefined; + this.groupAsc = true; + this.groupDesc = true; + this.lastGroupKey = undefined; + this.isGrouped = false; + } + + _createClass(SortState, [{ + key: "update", + value: function update(value, groupKey) { + // skip the first value since there's nothing to compare it to + if (this.lastValue !== undefined) { + // compare the current value with the previous value + var result = this.compare(value, this.lastValue); // update global sort state + + this.asc = this.asc && result >= 0; + this.desc = this.desc && result <= 0; + + if ( // if current and last values are different + result !== 0 && // and current and last group are same + this.lastGroupKey !== undefined && this.lastGroupKey === groupKey) { + // update grouped sort state + this.groupAsc = this.groupAsc && result >= 0; + this.groupDesc = this.groupDesc && result <= 0; + this.isGrouped = true; + } + } // update last value and group key + + + this.lastValue = value; + this.lastGroupKey = groupKey; + } + }, { + key: "sort", + value: function sort(array) { + var _this = this; + + if (this.isGrouped) { + if (this.groupAsc && this.groupDesc) { + console.warn("This shouldn't happen"); + } else if (this.groupAsc && !this.asc) { + array.sort(this.compare); + } else if (this.groupDesc && !this.desc) { + array.sort(function (a, b) { + return _this.compare(b, a); + }); + } + } + } + }]); + + return SortState; +}(); + +/***/ }), + +/***/ "./lib/dataset.js": +/*!************************!*\ + !*** ./lib/dataset.js ***! + \************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "datasetContainsNoResults": function() { return /* binding */ datasetContainsNoResults; }, +/* harmony export */ "rangeForValue": function() { return /* binding */ rangeForValue; }, +/* harmony export */ "fieldRefForColumn": function() { return /* binding */ fieldRefForColumn; }, +/* harmony export */ "fieldRefWithOption": function() { return /* binding */ fieldRefWithOption; }, +/* harmony export */ "keyForColumn": function() { return /* binding */ keyForColumn; }, +/* harmony export */ "findColumnForColumnSetting": function() { return /* binding */ findColumnForColumnSetting; }, +/* harmony export */ "normalizeFieldRef": function() { return /* binding */ normalizeFieldRef; }, +/* harmony export */ "findColumnIndexForColumnSetting": function() { return /* binding */ findColumnIndexForColumnSetting; }, +/* harmony export */ "findColumnSettingIndexForColumn": function() { return /* binding */ findColumnSettingIndexForColumn; }, +/* harmony export */ "syncTableColumnsToQuery": function() { return /* binding */ syncTableColumnsToQuery; } +/* harmony export */ }); +/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! underscore */ "../../../node_modules/underscore/modules/index-all.js"); +/* harmony import */ var metabase_lib_lib_queries_StructuredQuery__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase-lib/lib/queries/StructuredQuery */ "../metabase-lib/lib/queries/StructuredQuery.ts"); +/* harmony import */ var metabase_lib_lib_Dimension__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! metabase-lib/lib/Dimension */ "../metabase-lib/lib/Dimension.ts"); +/* provided dependency */ var console = __webpack_require__(/*! console-browserify */ "../../../node_modules/console-browserify/index.js"); +function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + + + + +var datasetContainsNoResults = function datasetContainsNoResults(data) { + return data.rows == null || data.rows.length === 0; +}; +/** + * @returns min and max for a value in a column + */ + +var rangeForValue = function rangeForValue(value, column) { + var _column$binning_info; + + if (typeof value === "number" && column !== null && column !== void 0 && (_column$binning_info = column.binning_info) !== null && _column$binning_info !== void 0 && _column$binning_info.bin_width) { + return [value, value + column.binning_info.bin_width]; + } +}; +/** + * Returns a MBQL field reference (FieldReference) for a given result dataset column + * + * @param {Column} column Dataset result column + * @return {?FieldReference} MBQL field reference + */ + +function fieldRefForColumn(column) { + // NOTE: matching existing behavior of returning the unwrapped base dimension until we understand the implications of changing this + return column.field_ref && metabase_lib_lib_Dimension__WEBPACK_IMPORTED_MODULE_2__.default.parseMBQL(column.field_ref).baseDimension().mbql(); +} +function fieldRefWithOption(fieldRef, key, value) { + var dimension = metabase_lib_lib_Dimension__WEBPACK_IMPORTED_MODULE_2__.FieldDimension.parseMBQLOrWarn(fieldRef); + return dimension && dimension.withOption(key, value).mbql(); +} +var keyForColumn = function keyForColumn(column) { + var fieldRef = column.field_ref; + + if (!fieldRef) { + console.error("column is missing field_ref", column); + fieldRef = new metabase_lib_lib_Dimension__WEBPACK_IMPORTED_MODULE_2__.FieldDimension(column.name).mbql(); + } + + var dimension = metabase_lib_lib_Dimension__WEBPACK_IMPORTED_MODULE_2__.default.parseMBQL(fieldRef); + + if (!dimension) { + console.warn("Unknown field_ref", fieldRef); + return JSON.stringify(fieldRef); + } + + dimension = dimension.baseDimension(); // match bug where field w/ join alias returned field w/o join alias instead + + if (dimension instanceof metabase_lib_lib_Dimension__WEBPACK_IMPORTED_MODULE_2__.FieldDimension) { + dimension = dimension.withoutOptions("join-alias"); + } // match legacy behavior which didn't have "field-literal" or "aggregation" field refs + + + var isLegacyRef = dimension instanceof metabase_lib_lib_Dimension__WEBPACK_IMPORTED_MODULE_2__.FieldDimension && dimension.isStringFieldName() || dimension instanceof metabase_lib_lib_Dimension__WEBPACK_IMPORTED_MODULE_2__.AggregationDimension; + return JSON.stringify(isLegacyRef ? ["name", column.name] : ["ref", dimension.mbql()]); +}; +/** + * finds the column object from the dataset results for the given `table.columns` column setting + * @param {Column[]} columns Dataset results columns + * @param {ColumnSetting} columnSetting A "column setting" from the `table.columns` settings + * @return {?Column} A result column + */ + +function findColumnForColumnSetting(columns, columnSetting) { + var index = findColumnIndexForColumnSetting(columns, columnSetting); + + if (index >= 0) { + return columns[index]; + } else { + return null; + } +} +function normalizeFieldRef(fieldRef) { + var dimension = metabase_lib_lib_Dimension__WEBPACK_IMPORTED_MODULE_2__.default.parseMBQL(fieldRef); + return dimension && dimension.mbql(); +} +function findColumnIndexForColumnSetting(columns, columnSetting) { + // NOTE: need to normalize field refs because they may be old style [fk->, 1, 2] + var fieldRef = normalizeFieldRef(columnSetting.fieldRef); // first try to find by fieldRef + + if (fieldRef != null) { + var index = underscore__WEBPACK_IMPORTED_MODULE_0__.default.findIndex(columns, function (col) { + return underscore__WEBPACK_IMPORTED_MODULE_0__.default.isEqual(fieldRef, normalizeFieldRef(fieldRefForColumn(col))); + }); + + if (index >= 0) { + return index; + } + } // if that fails, find by column name + + + return underscore__WEBPACK_IMPORTED_MODULE_0__.default.findIndex(columns, function (col) { + return col.name === columnSetting.name; + }); +} +function findColumnSettingIndexForColumn(columnSettings, column) { + var fieldRef = normalizeFieldRef(fieldRefForColumn(column)); + + if (fieldRef == null) { + return columnSettings.findIndex(function (columnSetting) { + return columnSetting.name === column.name; + }); + } + + var index = columnSettings.findIndex(function (columnSetting) { + return underscore__WEBPACK_IMPORTED_MODULE_0__.default.isEqual(fieldRef, normalizeFieldRef(columnSetting.fieldRef)); + }); + return index; +} +function syncTableColumnsToQuery(question) { + var query = question.query(); + var columnSettings = question.settings()["table.columns"]; + + if (columnSettings && query instanceof metabase_lib_lib_queries_StructuredQuery__WEBPACK_IMPORTED_MODULE_1__.default) { + // clear `fields` first + query = query.clearFields(); // do this before clearing join columns since the default is "none" thus joined columns will be removed + + var columnDimensions = query.columnDimensions(); + var columnNames = query.columnNames(); // clear join's `fields` + + for (var i = query.joins().length - 1; i >= 0; i--) { + var join = query.joins()[i]; + query = join.clearFields().parent(); + } + + var _iterator = _createForOfIteratorHelper(columnSettings), + _step; + + try { + var _loop = function _loop() { + var columnSetting = _step.value; + + if (columnSetting.enabled) { + var fieldRef; + + if (columnSetting.fieldRef) { + fieldRef = columnSetting.fieldRef; + } else if (columnSetting.name) { + var index = underscore__WEBPACK_IMPORTED_MODULE_0__.default.findIndex(columnNames, function (n) { + return n === columnSetting.name; + }); + + if (index >= 0) { + fieldRef = columnDimensions[index].mbql(); + } + } + + if (fieldRef) { + var dimension = query.parseFieldReference(fieldRef); // NOTE: this logic should probably be in StructuredQuery + + if (dimension instanceof metabase_lib_lib_Dimension__WEBPACK_IMPORTED_MODULE_2__.FieldDimension && dimension.joinAlias()) { + var _join = dimension.join(); + + if (_join) { + query = _join.addField(dimension.mbql()).parent(); + } else { + console.warn("missing join?", query, dimension); + } + } else { + query = query.addField(dimension.mbql()); + } + } else { + console.warn("Unknown column", columnSetting); + } + } + }; + + for (_iterator.s(); !(_step = _iterator.n()).done;) { + _loop(); + } // if removing `fields` wouldn't change the resulting columns, just remove it + + } catch (err) { + _iterator.e(err); + } finally { + _iterator.f(); + } + + var newColumnDimensions = query.columnDimensions(); + + if (columnDimensions.length === newColumnDimensions.length && underscore__WEBPACK_IMPORTED_MODULE_0__.default.all(columnDimensions, function (d, i) { + return d.isSameBaseDimension(newColumnDimensions[i]); + })) { + return query.clearFields().question(); + } else { + return query.question(); + } + } + + return question; +} + +/***/ }), + +/***/ "./lib/debug.js": +/*!**********************!*\ + !*** ./lib/debug.js ***! + \**********************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "DEBUG": function() { return /* binding */ DEBUG; } +/* harmony export */ }); +/* harmony import */ var metabase_lib_dom__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! metabase/lib/dom */ "./lib/dom.js"); +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + + +var debug; + +if ((typeof window === "undefined" ? "undefined" : _typeof(window)) === "object" && (window.location && window.location.hash === "#debug" || metabase_lib_dom__WEBPACK_IMPORTED_MODULE_0__.HAS_LOCAL_STORAGE && window.localStorage.getItem("debug"))) { + debug = true; +} else { + debug = false; +} + +var DEBUG = debug; + +/***/ }), + +/***/ "./lib/deterministic.js": +/*!******************************!*\ + !*** ./lib/deterministic.js ***! + \******************************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "deterministicAssign": function() { return /* binding */ deterministicAssign; } +/* harmony export */ }); +function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } + +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } + +function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } + +function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } + +function hashCode(s) { + var h = 0; + + for (var i = 0; i < s.length; i++) { + h = Math.imul(31, h) + s.charCodeAt(i) | 0; + } + + return h; +} // assigns values to keys using a best effort deterministic algorithm +// keys: keys that need to be assigned values +// values: all possible values to assign +// existing: optional existing assignments +// getPreferred: to get preferred assignments + + +function deterministicAssign(keys, primaryTier) { + var existing = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; + var getPreferred = arguments.length > 3 ? arguments[3] : undefined; + var secondaryTiers = arguments.length > 4 ? arguments[4] : undefined; + var unassigned = new Set(keys.slice().sort()); // sort the keys for extra determinism + + var all; + var used; + var values; + var tiers = [primaryTier].concat(secondaryTiers || []); + var current = -1; + + var nextTier = function nextTier() { + current = (current + 1) % tiers.length; + values = tiers[current]; + all = new Set(values); + used = new Set(); + }; + + nextTier(); + var assignments = {}; + + var assign = function assign(key, value) { + assignments[key] = value; + unassigned.delete(key); // if assignment is one of the values mark it as used + + if (all.has(value)) { + used.add(value); + } + }; // add all exisisting assignments + + + for (var _i = 0, _Object$entries = Object.entries(existing); _i < _Object$entries.length; _i++) { + var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2), + key = _Object$entries$_i[0], + value = _Object$entries$_i[1]; + + assign(key, value); + } // attempt to get a "preferred" assignment, if desired + + + if (getPreferred) { + var _iterator = _createForOfIteratorHelper(unassigned), + _step; + + try { + for (_iterator.s(); !(_step = _iterator.n()).done;) { + var _key = _step.value; + + var _value = getPreferred(_key, values); + + if (_value !== undefined && !used.has(_value)) { + assign(_key, _value); + } + } + } catch (err) { + _iterator.e(err); + } finally { + _iterator.f(); + } + } // assign as many values as possible. if there are still any remaining, shift by one and try again + + + var iterations = 0; + + while (unassigned.size > 0) { + if (all.size - used.size <= 0) { + // if all have been used reset available options + nextTier(); + } + + var _iterator2 = _createForOfIteratorHelper(unassigned), + _step2; + + try { + for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { + var _key2 = _step2.value; + var hash = Math.abs(hashCode(_key2)) + iterations; + var _value2 = values[hash % values.length]; + + if (!used.has(_value2)) { + assign(_key2, _value2); + } + } + } catch (err) { + _iterator2.e(err); + } finally { + _iterator2.f(); + } + + iterations++; + } + + return assignments; +} + +/***/ }), + +/***/ "./lib/dom.js": +/*!********************!*\ + !*** ./lib/dom.js ***! + \********************/ +/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "getScrollX": function() { return /* binding */ getScrollX; }, +/* harmony export */ "getScrollY": function() { return /* binding */ getScrollY; }, +/* harmony export */ "IFRAMED": function() { return /* binding */ IFRAMED; }, +/* harmony export */ "IFRAMED_IN_SELF": function() { return /* binding */ IFRAMED_IN_SELF; }, +/* harmony export */ "getScrollBarSize": function() { return /* binding */ getScrollBarSize; }, +/* harmony export */ "HAS_LOCAL_STORAGE": function() { return /* binding */ HAS_LOCAL_STORAGE; }, +/* harmony export */ "isObscured": function() { return /* binding */ isObscured; }, +/* harmony export */ "elementIsInView": function() { return /* binding */ elementIsInView; }, +/* harmony export */ "getSelectionPosition": function() { return /* binding */ getSelectionPosition; }, +/* harmony export */ "setSelectionPosition": function() { return /* binding */ setSelectionPosition; }, +/* harmony export */ "saveSelection": function() { return /* binding */ saveSelection; }, +/* harmony export */ "getCaretPosition": function() { return /* binding */ getCaretPosition; }, +/* harmony export */ "setCaretPosition": function() { return /* binding */ setCaretPosition; }, +/* harmony export */ "saveCaretPosition": function() { return /* binding */ saveCaretPosition; }, +/* harmony export */ "addCSSRule": function() { return /* binding */ addCSSRule; }, +/* harmony export */ "constrainToScreen": function() { return /* binding */ constrainToScreen; }, +/* harmony export */ "forceRedraw": function() { return /* binding */ forceRedraw; }, +/* harmony export */ "moveToBack": function() { return /* binding */ moveToBack; }, +/* harmony export */ "moveToFront": function() { return /* binding */ moveToFront; }, +/* harmony export */ "open": function() { return /* binding */ open; }, +/* harmony export */ "shouldOpenInBlankWindow": function() { return /* binding */ shouldOpenInBlankWindow; }, +/* harmony export */ "isSameOrigin": function() { return /* binding */ isSameOrigin; }, +/* harmony export */ "getUrlTarget": function() { return /* binding */ getUrlTarget; }, +/* harmony export */ "removeAllChildren": function() { return /* binding */ removeAllChildren; }, +/* harmony export */ "parseDataUri": function() { return /* binding */ parseDataUri; }, +/* harmony export */ "clipPathReference": function() { return /* binding */ clipPathReference; }, +/* harmony export */ "initializeIframeResizer": function() { return /* binding */ initializeIframeResizer; }, +/* harmony export */ "isEventOverElement": function() { return /* binding */ isEventOverElement; }, +/* harmony export */ "isReducedMotionPreferred": function() { return /* binding */ isReducedMotionPreferred; } +/* harmony export */ }); +/* harmony import */ var underscore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! underscore */ "../../../node_modules/underscore/modules/index-all.js"); +/* harmony import */ var metabase_env__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! metabase/env */ "./env.js"); +/* provided dependency */ var console = __webpack_require__(/*! console-browserify */ "../../../node_modules/console-browserify/index.js"); +var _excluded = ["openInSameWindow", "openInBlankWindow"]; + +function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } + +function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } + +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } + +function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } + +function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } + + + // IE doesn't support scrollX/scrollY: + +var getScrollX = function getScrollX() { + return typeof window.scrollX === "undefined" ? window.pageXOffset : window.scrollX; +}; +var getScrollY = function getScrollY() { + return typeof window.scrollY === "undefined" ? window.pageYOffset : window.scrollY; +}; // denotes whether the current page is loaded in an iframe or not +// Cypress renders the whole app within an iframe, but we want to exlude it from this check to avoid certain components (like Nav bar) not rendering + +var IFRAMED = function () { + try { + return !metabase_env__WEBPACK_IMPORTED_MODULE_1__.isCypressActive && window.self !== window.top; + } catch (e) { + return true; + } +}(); // add a global so we can check if the parent iframe is Metabase + +window.METABASE = true; // check that we're both iframed, and the parent is a Metabase instance +// used for detecting if we're previewing an embed + +var IFRAMED_IN_SELF = function () { + try { + return window.self !== window.top && window.top.METABASE; + } catch (e) { + return false; + } +}(); // check whether scrollbars are visible to the user, +// this is off by default on Macs, but can be changed +// Always on on most other non mobile platforms + +var getScrollBarSize = underscore__WEBPACK_IMPORTED_MODULE_0__.default.memoize(function () { + var scrollableElem = document.createElement("div"), + innerElem = document.createElement("div"); + scrollableElem.style.width = "30px"; + scrollableElem.style.height = "30px"; + scrollableElem.style.overflow = "scroll"; + scrollableElem.style.borderWidth = "0"; + innerElem.style.width = "30px"; + innerElem.style.height = "60px"; + scrollableElem.appendChild(innerElem); + document.body.appendChild(scrollableElem); // Elements only have width if they're in the layout + + var diff = scrollableElem.offsetWidth - scrollableElem.clientWidth; + document.body.removeChild(scrollableElem); + return diff; +}); // check if we have access to localStorage to avoid handling "access denied" +// exceptions + +var HAS_LOCAL_STORAGE = function () { + try { + window.localStorage; // This will trigger an exception if access is denied. + + return true; + } catch (e) { + console.warn("localStorage not available:", e); + return false; + } +}(); +function isObscured(element, offset) { + if (!document.elementFromPoint) { + return false; + } + + var box = element.getBoundingClientRect(); // default to the center of the element + + offset = offset || { + top: Math.round(box.height / 2), + left: Math.round(box.width / 2) + }; + var position = { + left: box.x + offset.left, + top: box.y + offset.top + }; + var elem = document.elementFromPoint(position.left, position.top); + return !element.contains(elem); +} // based on http://stackoverflow.com/a/38039019/113 + +function elementIsInView(element) { + var percentX = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1; + var percentY = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1; + var tolerance = 0.01; //needed because the rects returned by getBoundingClientRect provide the position up to 10 decimals + + var elementRect = element.getBoundingClientRect(); + var parentRects = []; + + while (element.parentElement != null) { + parentRects.push(element.parentElement.getBoundingClientRect()); + element = element.parentElement; + } + + return parentRects.every(function (parentRect) { + var visiblePixelX = Math.min(elementRect.right, parentRect.right) - Math.max(elementRect.left, parentRect.left); + var visiblePixelY = Math.min(elementRect.bottom, parentRect.bottom) - Math.max(elementRect.top, parentRect.top); + var visiblePercentageX = visiblePixelX / elementRect.width; + var visiblePercentageY = visiblePixelY / elementRect.height; + return visiblePercentageX + tolerance > percentX && visiblePercentageY + tolerance > percentY; + }); +} +function getSelectionPosition(element) { + // input, textarea, IE + if (element.setSelectionRange || element.createTextRange) { + return [element.selectionStart, element.selectionEnd]; + } else { + // contenteditable + try { + var selection = window.getSelection(); // Clone the Range otherwise setStart/setEnd will mutate the actual selection in Chrome 58+ and Firefox! + + var range = selection.getRangeAt(0).cloneRange(); + var startContainer = range.startContainer, + startOffset = range.startOffset; + range.setStart(element, 0); + var end = range.toString().length; + range.setEnd(startContainer, startOffset); + var start = range.toString().length; + return [start, end]; + } catch (e) { + return [0, 0]; + } + } +} +function setSelectionPosition(element, _ref) { + var _ref2 = _slicedToArray(_ref, 2), + start = _ref2[0], + end = _ref2[1]; + + // input, textarea + if (element.setSelectionRange) { + element.focus(); + element.setSelectionRange(start, end); + } else if (element.createTextRange) { + // IE + var range = element.createTextRange(); + range.collapse(true); + range.moveEnd("character", end); + range.moveStart("character", start); + range.select(); + } else { + // contenteditable + var selection = window.getSelection(); + var startPos = getTextNodeAtPosition(element, start); + var endPos = getTextNodeAtPosition(element, end); + selection.removeAllRanges(); + + var _range = new Range(); + + _range.setStart(startPos.node, startPos.position); + + _range.setEnd(endPos.node, endPos.position); + + selection.addRange(_range); + } +} +function saveSelection(element) { + var range = getSelectionPosition(element); + return function () { + return setSelectionPosition(element, range); + }; +} +function getCaretPosition(element) { + return getSelectionPosition(element)[1]; +} +function setCaretPosition(element, position) { + setSelectionPosition(element, [position, position]); +} +function saveCaretPosition(element) { + var position = getCaretPosition(element); + return function () { + return setCaretPosition(element, position); + }; +} + +function getTextNodeAtPosition(root, index) { + var treeWalker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT, function (elem) { + if (index > elem.textContent.length) { + index -= elem.textContent.length; + return NodeFilter.FILTER_REJECT; + } + + return NodeFilter.FILTER_ACCEPT; + }); + var c = treeWalker.nextNode(); + return { + node: c ? c : root, + position: c ? index : 0 + }; +} // https://davidwalsh.name/add-rules-stylesheets + + +var STYLE_SHEET = function () { + // Create the