text: /*! marvin 2018-03-19 */
  "use strict";function iqr(a){return function(b,c){for(var d=b.quartiles[0],e=b.quartiles[2],f=(e-d)*a,g=-1,h=b.length;b[++g]<d-f;);for(;b[--h]>e+f;);return[g,h]}}function boxWhiskers(a){return[0,a.length-1]}function boxQuartiles(a){return[d3.quantile(a,.25),d3.quantile(a,.5),d3.quantile(a,.75)]}function getTooltip(){var a=d3.select("body").append("div").attr("class","tooltip").style("opacity",0);return a}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!=typeof b&&"function"!=typeof b?a:b}function _inherits(a,b){if("function"!=typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}d3.box=function(){function a(a){a.each(function(a,e){var n=a;a=a.sample.map(f).sort(d3.ascending);var o=d3.select(this),p=a.length,q=a[0],r=a[p-1],s=a.quartiles=h(a),t=(d3.quantile(a,.1),d3.quantile(a,.9),s[2]-s[0],iqr(2.5).call(this,a,e)),u=t.map(function(b){return a[b]}),v=g&&g.call(this,a,e),w=v&&v.map(function(b){return a[b]}),x=v?d3.range(0,v[0]).concat(d3.range(v[1]+1,p)):d3.range(p),y=s[1],z=Math.max(u[1]-y,y-u[0]);Math.min(r-w[1],q-w[0]);j=d3.scaleLinear().domain([y-z,y,y+z]).range([c,c/2,0]),k=this.__chart__||d3.scaleLinear().domain([0,1/0]).range(j.range()),this.__chart__=j;var A=o.selectAll("line.center").data(w?[w]:[]);A.enter().insert("line","rect").attr("class","center").attr("x1",b/2).attr("y1",function(a){return k(a[0])}).attr("x2",b/2).attr("y2",function(a){return k(a[1])}).style("opacity",1e-6).transition().duration(d).style("opacity",1).attr("y1",function(a){return j(a[0])}).attr("y2",function(a){return j(a[1])}),A.transition().duration(d).style("opacity",1).attr("y1",function(a){return j(a[0])}).attr("y2",function(a){return j(a[1])}),A.exit().transition().duration(d).style("opacity",1e-6).attr("y1",function(a){return j(a[0])}).attr("y2",function(a){return j(a[1])}).remove();var B=o.selectAll("rect.box").data([s]);B.enter().append("rect").attr("class","box").attr("x",0).attr("y",function(a){return k(a[2])}).attr("width",b).attr("height",function(a){return k(a[0])-k(a[2])}).transition().duration(d).attr("y",function(a){return j(a[2])}).attr("height",function(a){return j(a[0])-j(a[2])}),B.transition().duration(d).attr("y",function(a){return j(a[2])}).attr("height",function(a){return j(a[0])-j(a[2])});var C=o.selectAll("line.median").data([s[1]]);C.enter().append("line").attr("class","median").attr("x1",0).attr("y1",k).attr("x2",b).attr("y2",k).transition().duration(d).attr("y1",j).attr("y2",j),C.transition().duration(d).attr("y1",j).attr("y2",j);var D=o.selectAll("line.whisker").data(w||[]);if(D.enter().insert("line","circle, text").attr("class","whisker").attr("x1",0).attr("y1",k).attr("x2",b).attr("y2",k).style("opacity",1e-6).transition().duration(d).attr("y1",j).attr("y2",j).style("opacity",1),D.transition().duration(d).attr("y1",j).attr("y2",j).style("opacity",1),D.exit().transition().duration(d).attr("y1",j).attr("y2",j).style("opacity",1e-6).remove(),n.value){var E=o.selectAll("circle.datapoint").data([n.value]);E.enter().append("circle").attr("class","datapoint").attr("cx",b/2).attr("cy",j(n.value)).attr("r",5).style("fill","red").on("mouseover",function(a){m.transition().duration(200).style("opacity",.9),m.html("<b> Value: "+n.value+"</b>").style("left",d3.event.pageX+"px").style("top",d3.event.pageY-28+"px")}).on("mouseout",function(a){m.transition().duration(500).style("opacity",0)})}if(n.title){var F=o.selectAll("text.title").data([n.title]);F.enter().append("text").text(n.title).attr("x",b/2).attr("y",c).attr("dy",20).attr("text-anchor","middle").style("font-weight","bold").style("font-size",15)}var G=o.selectAll("circle.outlier").data(x,Number);G.enter().insert("circle","text").attr("class","outlier").attr("r",5).attr("cx",b/2).attr("cy",function(b){return k(a[b])}).style("opacity",1e-6).on("mouseover",function(b){m.transition().duration(200).style("opacity",.9),m.html("<b> Value: "+a[b]+"</b>").style("left",d3.event.pageX+"px").style("top",d3.event.pageY-28+"px")}).on("mouseout",function(a){m.transition().duration(500).style("opacity",0)}).transition().duration(d).attr("cy",function(b){return j(a[b])}).style("opacity",1);var H=l||j.tickFormat(8),I=o.selectAll("text.box").data(s);i===!0&&I.enter().append("text").attr("class","box").attr("dy",".3em").attr("dx",function(a,b){return 1&b?6:-6}).attr("x",function(a,c){return 1&c?b:0}).attr("y",k).attr("text-anchor",function(a,b){return 1&b?"start":"end"}).text(H).transition().duration(d).attr("y",j),I.transition().duration(d).text(H).attr("y",j);var J=o.selectAll("text.whisker").data(w||[]);J.enter().append("text").attr("class","whisker").attr("dy",".3em").attr("dx",6).attr("x",b).attr("y",k).text(H).style("opacity",1e-6).transition().duration(d).attr("y",j).style("opacity",1),J.transition().duration(d).text(H).attr("y",j).style("opacity",1),J.exit().transition().duration(d).attr("y",j).style("opacity",1e-6).remove()}),d3.timerFlush()}var b=1,c=1,d=0,e=null,f=Number,g=boxWhiskers,h=boxQuartiles,i=!0,j=null,k=null,l=null,m=getTooltip();return a.overlay=function(a){return arguments.length?(overlay=a,overlay):overlay},a.x1=function(a){return arguments.length?j(a):j},a.x0=function(a){return arguments.length?k(a):k},a.width=function(c){return arguments.length?(b=c,a):b},a.height=function(b){return arguments.length?(c=b,a):c},a.tickFormat=function(b){return arguments.length?(l=b,a):l},a.duration=function(b){return arguments.length?(d=b,a):d},a.domain=function(b){return arguments.length?(e=null===b?b:d3.functor(b),a):e},a.value=function(b){return arguments.length?(f=b,a):f},a.tooltip=function(a){return arguments.length?m=a:m},a.whiskers=function(b){return arguments.length?(g=b,a):g},a.showLabels=function(b){return arguments.length?(i=b,a):i},a.quartiles=function(b){return arguments.length?(h=b,a):h},a};var _createClass=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(a,d.key,d)}}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),BoxWhisker=function(){function a(b,c,d){_classCallCheck(this,a),void 0===c?console.error("Must specify input plot data to initialize a BoxWhisker!"):void 0===b?console.error("Must specify an input plotdiv to initialize a BoxWhisker"):(this.plotdiv=b,this.plotid="#"+this.plotdiv.attr("id"),this.tooltip="#d3tooltip",this.data=c,this.setOptions(d),this.initBoxplot())}return _createClass(a,[{key:"print",value:function(){console.log("We are now printing boxwhisker for ",this.cfg.title)}},{key:"setOptions",value:function(a){if(this.margin={top:10,right:50,bottom:40,left:50},this.cfg={title:"BoxWhisker Title",origthis:null,width:120-this.margin.left-this.margin.right,height:500-this.margin.top-this.margin.bottom},"undefined"!=typeof a)for(var b in a)"undefined"!=typeof a[b]&&(this.cfg[b]=a[b])}},{key:"iqr",value:function(a){return function(b,c){for(var d=b.quartiles[0],e=b.quartiles[2],f=(e-d)*a,g=-1,h=b.length;b[++g]<d-f;);for(;b[--h]>e+f;);return[g,h]}}},{key:"initBoxplot",value:function(){var a=d3.box().whiskers(this.iqr(1.5)).width(this.cfg.width).height(this.cfg.height);d3.select(this.plotid).selectAll("svg").data(this.data).enter().append("svg").attr("class","box").attr("width",this.cfg.width+this.margin.left+this.margin.right).attr("height",this.cfg.height+this.margin.bottom+this.margin.top).append("g").attr("transform","translate("+this.margin.left+","+this.margin.top+")").call(a)}}]),a}(),_createClass=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(a,d.key,d)}}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),Carousel=function(){function a(b,c){_classCallCheck(this,a),this.carouseldiv=$(b),this.thumbsdiv=void 0!==c?$(c):$("[id^=carousel-selector-]"),this.carouseldiv.carousel({interval:5e3}),this.thumbsdiv.on("click",this,this.handleThumbs),this.carouseldiv.on("slid.bs.carousel",this,this.updateText)}return _createClass(a,[{key:"print",value:function(){console.log("I am Carousel!")}},{key:"handleThumbs",value:function(a){var b=a.data,c=$(this).attr("id");try{var d=/-(\d+)$/.exec(c)[1];b.carouseldiv.carousel(parseInt(d))}catch(e){console.log("MyCarousel: Regex failed!",e)}}},{key:"updateText",value:function(a){var b=(a.data,$(".item.active").data("slide-number"));$("#carousel-text").html($("#slide-content-"+b).html())}}]),a}(),_slicedToArray=function(){function a(a,b){var c=[],d=!0,e=!1,f=void 0;try{for(var g,h=a[Symbol.iterator]();!(d=(g=h.next()).done)&&(c.push(g.value),!b||c.length!==b);d=!0);}catch(i){e=!0,f=i}finally{try{!d&&h["return"]&&h["return"]()}finally{if(e)throw f}}return c}return function(b,c){if(Array.isArray(b))return b;if(Symbol.iterator in Object(b))return a(b,c);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),_createClass=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(a,d.key,d)}}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),SpaxelError=function(a){function b(a){_classCallCheck(this,b);var c=_possibleConstructorReturn(this,(b.__proto__||Object.getPrototypeOf(b)).call(this,a));return c.message=a,c.name="SpaxelError",c.status=-1,c}return _inherits(b,a),b}(Error),MapError=function(a){function b(a){_classCallCheck(this,b);var c=_possibleConstructorReturn(this,(b.__proto__||Object.getPrototypeOf(b)).call(this,a));return c.message=a,c.name="MapError",c.status=-1,c}return _inherits(b,a),b}(Error),Galaxy=function(){function a(b,c){_classCallCheck(this,a),this.setPlateIfu(b),this.toggleon=c,this.maindiv=$("#"+this.plateifu),this.metadiv=this.maindiv.find("#metadata"),this.specdiv=this.maindiv.find("#specview"),this.imagediv=this.specdiv.find("#imagediv"),this.mapsdiv=this.specdiv.find("#mapsdiv"),this.mapdiv=this.specdiv.find("#mapdiv1"),this.graphdiv=this.specdiv.find("#graphdiv"),this.specmsg=this.specdiv.find("#specmsg"),this.mapmsg=this.specdiv.find("#mapmsg"),this.webspec=null,this.staticdiv=this.specdiv.find("#staticdiv"),this.dynamicdiv=this.specdiv.find("#dynamicdiv"),this.maptab=$("#maptab"),this.togglediv=$("#toggleinteract"),this.toggleload=$("#toggle-load"),this.togglediv.bootstrapToggle("off"),this.qualpop=$("#qualitypopover"),this.targpops=$(".targpopovers"),this.dapmapsbut=$("#dapmapsbut"),this.dapselect=$("#dapmapchoices"),this.dapbt=$("#dapbtchoices"),this.resetmapsbut=$("#resetmapsbut"),this.nsadisplay=$("#nsadisp"),this.nsaplots=$(".marvinplot"),this.nsaplotdiv=this.maindiv.find("#nsahighchart1"),this.nsaboxdiv=this.maindiv.find("#nsad3box"),this.nsaselect=$(".nsaselect"),this.nsamsg=this.maindiv.find("#nsamsg"),this.nsaresetbut=$(".nsareset"),this.nsamovers=$("#nsatable").find(".mover"),this.nsaplotbuttons=$(".nsaplotbuts"),this.nsatable=$("#nsatable"),this.nsaload=$("#nsa-load"),this.magband={F:0,N:1,u:2,g:3,r:4,i:5,z:6},this.initFlagPopovers(),this.maptab.on("click",this,this.resizeSpecView),this.dapmapsbut.on("click",this,this.getDapMaps),this.resetmapsbut.on("click",this,this.resetMaps),this.togglediv.on("change",this,this.initDynamic),this.nsadisplay.on("click",this,this.displayNSA),this.nsaresetbut.on("click",this,this.resetNSASelect),this.nsaplotbuttons.on("click",this,this.updateNSAPlot)}return _createClass(a,[{key:"print",value:function(){console.log("We are now printing galaxy",this.plateifu,this.plate,this.ifu)}},{key:"setPlateIfu",value:function(a){void 0===a?this.plateifu=$(".singlegalaxy").attr("id"):this.plateifu=a;var b=this.plateifu.split("-"),c=_slicedToArray(b,2);this.plate=c[0],this.ifu=c[1]}},{key:"resizeSpecView",value:function(a){var b=a.data;m.utils.window[0].setTimeout(function(){b.webspec.resize(),b.olmap.map.updateSize()},10)}},{key:"loadSpaxel",value:function(a,b){var c=3==a[0].length?["Wavelength","Flux","Model Fit"]:["Wavelength","Flux"];this.webspec=new Dygraph(this.graphdiv[0],a,{title:b,labels:c,errorBars:!0,ylabel:"Flux [10<sup>-17</sup> erg/cm<sup>2</sup>/s/Å]",xlabel:"Observed Wavelength [Ångströms]"})}},{key:"updateSpecMsg",value:function(a,b){this.specmsg.hide(),void 0!==b&&b===-1&&this.specmsg.show(),a=a.replace("<","").replace(">","");var c="<strong>"+a+"</strong>";this.specmsg.empty(),this.specmsg.html(c)}},{key:"updateSpaxel",value:function(a,b){this.updateSpecMsg(b),this.webspec.updateOptions({file:a,title:b})}},{key:"initOpenLayers",value:function(a){this.image=a,this.olmap=new OLMap(a),this.olmap.map.on("singleclick",this.getSpaxel,this)}},{key:"initHeatmap",value:function(a){var b=this.mapsdiv.children("div"),c=this;$.each(b,function(b,d){var e=$(d).find("div").first();e.empty(),void 0!==a[b]&&null!==a[b].data&&(this.heatmap=new HeatMap(e,a[b].data,a[b].msg,a[b].plotparams,c),this.heatmap.mapdiv.highcharts().reflow())})}},{key:"makeError",value:function(a){return"Unknown Error: the "+a+" javascript Ajax request failed!"}},{key:"getSpaxel",value:function(a){var b=this,c=void 0===a.coordinate?null:a.coordinate,d=$(a.target).parents("div").first().attr("id"),e=void 0!==d&&d.search("highcharts")!==-1?"heatmap":"optical",f=void 0===a.point?null:a.point.x,g=void 0===a.point?null:a.point.y,h=["plateifu","image","imwidth","imheight","mousecoords","type","x","y"],i=m.utils.buildForm(h,this.plateifu,this.image,this.olmap.imwidth,this.olmap.imheight,c,e,f,g);Promise.resolve($.post(Flask.url_for("galaxy_page.getspaxel"),i,"json")).then(function(a){if(a.result.status===-1)throw new SpaxelError("Error: "+a.result.specmsg);b.updateSpaxel(a.result.spectra,a.result.specmsg)})["catch"](function(a){var c=void 0===a.message?b.makeError("getSpaxel"):a.message;b.updateSpecMsg(c,-1)})}},{key:"checkToggle",value:function(){this.toggleon?this.toggleOn():this.toggleOff()}},{key:"toggleOn",value:function(){this.toggleon=!0,this.staticdiv.hide(),this.dynamicdiv.show()}},{key:"toggleOff",value:function(){this.toggleon=!1,this.dynamicdiv.hide(),this.staticdiv.show()}},{key:"testTogg",value:function(a){var b=a.data;console.log("toggling",b.togglediv.prop("checked"),b.togglediv.hasClass("active"))}},{key:"initDynamic",value:function(a){var b=this,c=a.data;if(c.togglediv.prop("checked")){c.toggleOn();var d=(c.graphdiv.is(":empty"),c.imagediv.is(":empty"));c.mapdiv.is(":empty");if(d){var e=["plateifu","toggleon"],f=m.utils.buildForm(e,c.plateifu,c.toggleon);c.toggleload.show(),Promise.resolve($.post(Flask.url_for("galaxy_page.initdynamic"),f,"json")).then(function(a){if(a.result.error){var b=a.result.error;throw new SpaxelError("Error : "+b)}if(a.result.specstatus===-1)throw new SpaxelError("Error: "+a.result.specmsg);if(a.result.mapstatus===-1)throw new MapError("Error: "+a.result.mapmsg);var d=a.result.image,e=a.result.spectra,f=a.result.specmsg,g=a.result.maps;a.result.mapmsg;c.initOpenLayers(d),c.toggleload.hide(),c.loadSpaxel(e,f),c.initHeatmap(g),c.dapselect.selectpicker("refresh")})["catch"](function(a){var d=void 0===a.message?b.makeError("initDynamic"):a.message;c.updateSpecMsg(d,-1),c.updateMapMsg(d,-1)})}}else c.toggleOff()}},{key:"initFlagPopovers",value:function(){this.qualpop.popover({html:!0,content:$("#list_drp3quality").html()}),$.each(this.targpops,function(a,b){var c=b.id,d=c.split("_"),e=_slicedToArray(d,2),f=(e[0],e[1]),g="#list_"+f;$("#"+c).popover({html:!0,content:$(g).html()})})}},{key:"getDapMaps",value:function(a){var b=a.data,c=b.dapselect.selectpicker("val"),d=b.dapbt.selectpicker("val"),e=["plateifu","params","bintemp"],f=m.utils.buildForm(e,b.plateifu,c,d);b.mapmsg.hide(),$(this).button("loading"),Promise.resolve($.post(Flask.url_for("galaxy_page.updatemaps"),f,"json")).then(function(a){if(a.result.status===-1)throw new MapError("Error: "+a.result.mapmsg);b.dapmapsbut.button("reset"),b.initHeatmap(a.result.maps)})["catch"](function(a){var c=void 0===a.message?b.makeError("getDapMaps"):a.message;b.updateMapMsg(c,-1),b.dapmapsbut.button("reset")})}},{key:"updateMapMsg",value:function(a,b){this.mapmsg.hide(),void 0!==b&&b===-1&&this.mapmsg.show(),a=a.replace("<","").replace(">","");var c="<strong>"+a+"</strong>";this.mapmsg.empty(),this.mapmsg.html(c)}},{key:"resetMaps",value:function(a){var b=a.data;b.mapmsg.hide(),b.dapselect.selectpicker("deselectAll"),b.dapselect.selectpicker("refresh")}},{key:"hasNSA",value:function(a){this.hasnsa=a}},{key:"displayNSA",value:function(a){var b=a.data,c=["plateifu"],d=m.utils.buildForm(c,b.plateifu),e=b.nsaplots.is(":empty");e&b.hasnsa&&Promise.resolve($.post(Flask.url_for("galaxy_page.initnsaplot"),d,"json")).then(function(a){if(1!==a.result.status)throw new Error("Error: "+a.result.nsamsg);b.addNSAData(a.result.nsa),b.refreshNSASelect(a.result.nsachoices),b.initNSAScatter(),b.setTableEvents(),b.addNSAEvents(),b.initNSABoxPlot(a.result.nsaplotcols),b.nsaload.hide()})["catch"](function(a){var c=void 0===a.message?b.makeError("displayNSA"):a.message;b.updateNSAMsg(c,-1)})}},{key:"addNSAData",value:function(a){return a[this.plateifu]?(this.mygalaxy=a[this.plateifu],a.sample?void(this.nsasample=a.sample):void this.updateNSAMsg("Error: Problem getting NSA data found for the MaNGA sample",-1)):void this.updateNSAMsg("Error: No NSA data found for "+this.plateifu,-1)}},{key:"updateNSAData",value:function(a,b){var c=this,d=void 0,e=void 0;if("galaxy"===b){var f=this.mygalaxy[this.nsachoices[a].x],g=this.mygalaxy[this.nsachoices[a].y],h=this.nsachoices[a].x.search("absmag")>-1,i=this.nsachoices[a].y.search("absmag")>-1;d=[{name:this.plateifu,x:f,y:g}],e={xtitle:this.nsachoices[a].xtitle,ytitle:this.nsachoices[a].ytitle,title:this.nsachoices[a].title,galaxy:{name:this.plateifu},xrev:h,yrev:i}}else"sample"===b&&!function(){var b=c.nsasample[c.nsachoices[a].x],f=c.nsasample[c.nsachoices[a].y];d=[],$.each(b,function(a,b){if(b>-9999&&f[a]>-9999){var e={name:c.nsasample.plateifu[a],x:b,y:f[a]};d.push(e)}}),e={xtitle:c.nsachoices[a].xtitle,ytitle:c.nsachoices[a].ytitle,title:c.nsachoices[a].title,altseries:{name:"Sample"}}}();return[d,e]}},{key:"setTableEvents",value:function(){var a=this,b=this.nsatable.bootstrapTable("getData");$.each(this.nsamovers,function(b,c){var d=c.id;$("#"+d).on("dragstart",a,a.dragStart),$("#"+d).on("dragover",a,a.dragOver),$("#"+d).on("drop",a,a.moverDrop)}),this.nsatable.on("page-change.bs.table",function(){$.each(b,function(b,c){var d=c[0],e=$(d).attr("id");$("#"+e).on("dragstart",a,a.dragStart),$("#"+e).on("dragover",a,a.dragOver),$("#"+e).on("drop",a,a.moverDrop)})})}},{key:"addNSAEvents",value:function(){var a=this;this.nsaplots=$(".marvinplot"),$.each(this.nsaplots,function(b,c){var d=c.id,e=$("#"+d).find(".highcharts-xaxis"),f=$("#"+d).find(".highcharts-yaxis");e.on("dragover",a,a.dragOver),e.on("dragenter",a,a.dragEnter),e.on("drop",a,a.dropElement),f.on("dragover",a,a.dragOver),f.on("dragenter",a,a.dragEnter),f.on("drop",a,a.dropElement)})}},{key:"updateNSAMsg",value:function(a,b){this.nsamsg.hide(),void 0!==b&&b===-1&&this.nsamsg.show();var c="<strong>"+a+"</strong>";this.nsamsg.empty(),this.nsamsg.html(c)}},{key:"filterArray",value:function(a){return a!==-9999}},{key:"createD3data",value:function(){var a=this,b=[];return this.nsaplotcols.forEach(function(c,d){var e=a.nsasample[c].filter(a.filterArray),f={value:a.mygalaxy[c],title:c,sample:e};b.push(f)}),b}},{key:"initNSABoxPlot",value:function(a){void 0===a&&void 0===this.nsaplotcols?console.error("columns for NSA boxplot are undefined"):this.nsaplotcols=a;var b=void 0,c=void 0;b=this.createD3data(),this.nsad3box=new BoxWhisker(this.nsaboxdiv,b,c)}},{key:"destroyChart",value:function(a,b){this.nsascatter[b].chart.destroy(),a.empty()}},{key:"initNSAScatter",value:function(a){var b=this;if(void 0!==a){var c=this.maindiv.find("#"+a),d=parseInt(a[a.length-1]),e=this.updateNSAData(d,"galaxy"),f=_slicedToArray(e,2),g=f[0],h=f[1],i=this.updateNSAData(d,"sample"),j=_slicedToArray(i,2),k=j[0];j[1];h.altseries={data:k,name:"Sample"},this.destroyChart(c,d),this.nsascatter[d]=new Scatter(c,g,h)}else this.nsascatter={},$.each(this.nsaplots,function(a,c){var d=$(c),e=b.updateNSAData(a+1,"galaxy"),f=_slicedToArray(e,2),g=f[0],h=f[1],i=b.updateNSAData(a+1,"sample"),j=_slicedToArray(i,2),k=j[0];j[1];h.altseries={data:k,name:"Sample"},b.nsascatter[a+1]=new Scatter(d,g,h)})}},{key:"refreshNSASelect",value:function(a){this.nsachoices=a,$.each(this.nsaselect,function(b,c){$(c).selectpicker("deselectAll"),$(c).selectpicker("val",["x_"+a[b+1].x,"y_"+a[b+1].y]),$(c).selectpicker("refresh")})}},{key:"updateNSAChoices",value:function(a,b){var c=b[0].slice(2,b[0].length),d=b[1].slice(2,b[1].length);this.nsachoices[a].title=d+" vs "+c,this.nsachoices[a].xtitle=c,this.nsachoices[a].x=c,this.nsachoices[a].ytitle=d,this.nsachoices[a].y=d}},{key:"resetNSASelect",value:function(a){var b=$(this).attr("id"),c=parseInt(b[b.length-1]),d=a.data,e=d.nsaselect[c-1];d.nsamsg.hide(),$(e).selectpicker("deselectAll"),$(e).selectpicker("refresh")}},{key:"updateNSAPlot",value:function(a){var b=a.data,c=$(this).attr("id"),d=parseInt(c[c.length-1]),e=b.nsaselect[d-1],f=$(e).selectpicker("val"),g="nsahighchart"+d;b.updateNSAChoices(d,f),b.initNSAScatter(g),b.addNSAEvents()}},{key:"dragStart",value:function(a){var b=a.data,c=this.id+"+"+this.textContent;a.originalEvent.dataTransfer.setData("Text",c),$.each(b.nsascatter,function(a,b){b.overgroup.show()})}},{key:"dragOver",value:function(a){a.preventDefault(),a.originalEvent.dataTransfer.dropEffect="move"}},{key:"dragEnter",value:function(a){a.preventDefault()}},{key:"moverDrop",value:function(a){a.preventDefault(),a.stopPropagation()}},{key:"dropElement",value:function(a){a.preventDefault(),a.stopPropagation();var b=a.data,c=a.originalEvent.dataTransfer.getData("Text"),d=c.split("+"),e=_slicedToArray(d,2),f=e[0],g=e[1];$.each(b.nsascatter,function(a,b){b.overgroup.hide()});var h=$(this).attr("class"),i=h.includes("highcharts-xaxis"),j=h.includes("highcharts-yaxis"),k=$(this).closest(".marvinplot"),l=k.attr("id");if(void 0===l)return a.stopPropagation(),!1;var m=parseInt(l[l.length-1]),n=null;i?n=$(this).next():j&&(n=$(this).prev());var o=this.textContent,p=(n[0].textContent,b.nsachoices[m].title.replace(o,g));return b.nsachoices[m].title=p,i?(b.nsachoices[m].xtitle=g,b.nsachoices[m].x=f):j&&(b.nsachoices[m].ytitle=g,b.nsachoices[m].y=f),b.initNSAScatter(l),b.addNSAEvents(),!1}}]),a}(),_createClass=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(a,d.key,d)}}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),Header=function(){function a(){_classCallCheck(this,a),this.navbar=$(".navbar"),this.galidform=$("#headform"),this.typeahead=$("#headform .typeahead"),this.mplform=$("#mplform"),this.mplselect=$("#mplselect"),this.initTypeahead(),this.mplselect.on("change",this,this.selectMPL)}return _createClass(a,[{key:"print",value:function(){console.log("I am Header!")}},{key:"initTypeahead",value:function(a,b,c,d){a=void 0===a?this.typeahead:$(a),b=void 0===b?this.galidform:$(b);var e=void 0===c?Flask.url_for("index_page.getgalidlist"):c;this.galids=new Bloodhound({datumTokenizer:Bloodhound.tokenizers.whitespace,queryTokenizer:Bloodhound.tokenizers.whitespace,prefetch:e,remote:{url:e,filter:function(a){return a}}}),this.galids.initialize(),a.typeahead("destroy"),a.typeahead({showHintOnFocus:!0,items:30,source:this.galids.ttAdapter(),afterSelect:function(){b.submit()}})}},{key:"selectMPL",value:function(a){var b=a.data,c="index_page.selectmpl",d=m.utils.serializeForm("#mplform");b.sendAjax(d,c,b.reloadPage)}},{key:"reloadPage",value:function(){location.reload(!0)}},{key:"sendAjax",value:function(a,b,c){var d=this;$.post(Flask.url_for(b),a,"json").done(function(a){1==a.result.status?(c(),d.galids.clearPrefetchCache(),d.galids.initialize()):alert("Failed to set the versions! "+a.result.msg)}).fail(function(a){alert("Failed to set the versions! Problem with Flask setversion. "+a.result.msg)})}}]),a}(),_slicedToArray=function(){function a(a,b){var c=[],d=!0,e=!1,f=void 0;try{for(var g,h=a[Symbol.iterator]();!(d=(g=h.next()).done)&&(c.push(g.value),!b||c.length!==b);d=!0);}catch(i){e=!0,f=i}finally{try{!d&&h["return"]&&h["return"]()}finally{if(e)throw f}}return c}return function(b,c){if(Array.isArray(b))return b;if(Symbol.iterator in Object(b))return a(b,c);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),_createClass=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(a,d.key,d)}}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),HeatMap=function(){function a(b,c,d,e,f){_classCallCheck(this,a),void 0===c?console.error("Must specify input map data to initialize a HeatMap!"):void 0===b?console.error("Must specify an input mapdiv to initialize a HeatMap"):(this.mapdiv=b,this.data=c,this.title=d,this.plotparams=e,this.galthis=f,this.parseTitle(),this.initMap(),this.setColorNoData(this,Highcharts))}return _createClass(a,[{key:"print",value:function(){console.log("We are now printing heatmap for ",this.title)}},{key:"parseTitle",value:function(){var a=this.title.split(":"),b=_slicedToArray(a,2),c=(b[0],b[1]),d=c.split("_"),e=_slicedToArray(d,3);this.category=e[0],this.parameter=e[1],this.channel=e[2]}},{key:"getRange",value:function(){var a=this.data.values.length,b=Array.apply(null,{length:a}).map(Number.call,Number),c=[].concat.apply([],this.data.values);return[b,c]}},{key:"filterRange",value:function(a){return void 0!==a&&"number"==typeof a&&!isNaN(a)}},{key:"getMinMax",value:function(a){var b=Math.min.apply(null,a),c=Math.max.apply(null,a);return[b,c]}},{key:"setNull",value:function(a){for(var b=a.values,c=a.ivar,d=a.mask,e=Array(),f=0;f<b.length;f++)for(var g=0;g<b.length;g++){var h=b[f][g],i=void 0,j=void 0,k=void 0,l=void 0;if(null!==d){var m=this.plotparams.bits;i=d[f][g]&Math.pow(2,m.nocov),j=!1;for(var n in m.badData)j=j||d[f][g]&Math.pow(2,m.badData[n])}else i=null,j=null;l=this.plotparams.snr_min,null!==c&&(k=Math.abs(h)*Math.sqrt(c[f][g])),i?h="no-data":j?h=null:null!==c&&k<l?h=null:null===c&&(this.title.search("binid")!==-1?h=h==-1?"no-data":h:0===h&&(h="no-data")),e.push([g,f,h])}return e}},{key:"setColorNoData",value:function(a,b){b.wrap(b.ColorAxis.prototype,"toColor",function(a,b,c){return"no-data"===b?"rgba(0,0,0,0)":"low-sn"===b?"rgba(0,191,255,0.5)":a.apply(this,Array.prototype.slice.call(arguments,1))})}},{key:"setColorMapHex",value:function(a){var b=["#040404","#0a0308","#0d040b","#10050e","#120510","#150612","#160713","#180815","#1a0816","#1b0918","#1c0a19","#1e0b1a","#1f0c1b","#200c1c","#210d1d","#230e1f","#240e20","#250f20","#260f21","#271022","#281123","#291124","#2a1226","#2b1326","#2c1327","#2e1429","#2e142d","#2e1532","#2d1537","#2d153c","#2d1640","#2d1743","#2d1747","#2d184b","#2d184d","#2d1951","#2d1954","#2c1a57","#2c1b5a","#2d1b5c","#2d1c5f","#2c1d62","#2c1d64","#2c1e67","#2c1f6a","#2c1f6d","#2c206e","#2c2171","#2c2274","#2c2276","#2a2379","#282678","#262877","#242a78","#222c78","#212e78","#202f78","#1f3179","#1e327a","#1e337b","#1d347b","#1d357d","#1c377d","#1c387e","#1b397f","#1c3a80","#1c3b81","#1b3c81","#1b3d83","#1b3e84","#1b3f85","#1c4086","#1b4187","#1b4288","#1b4489","#1b458a","#194788","#164986","#154a85","#144c83","#114e81","#104f80","#0f517e","#0e527d","#0a547b","#0a557a","#095778","#085877","#075976","#065b75","#045c73","#045e72","#045f72","#036070","#01626f","#01636e","#00646d","#00656c","#00676b","#00686a","#006969","#006b68","#006c65","#006e64","#006f63","#007062","#007260","#00735f","#00745d","#00765c","#00775a","#007859","#007958","#007b56","#007c55","#007d53","#007f52","#008050","#00814f","#00834d","#00844b","#008549","#008648","#008846","#008944","#008a42","#008b41","#008d40","#008e3f","#008f3d","#00913c","#00923c","#00933a","#009539","#009638","#009737","#009935","#009a34","#009b33","#009d32","#009e30","#009f2f","#00a02d","#00a22c","#00a32a","#00a429","#00a527","#00a724","#00a822","#00a91f","#00aa17","#00a908","#09aa00","#14ab00","#1dac00","#23ad00","#28ae00","#2daf00","#30b000","#34b100","#37b200","#3bb300","#3db400","#40b500","#42b600","#44b700","#47b800","#49b900","#4cba00","#4ebb00","#4fbc00","#51bd00","#53be00","#55bf00","#57c000","#5cc000","#63c100","#6ac100","#72c100","#77c200","#7dc200","#82c200","#87c300","#8cc300","#91c300","#95c400","#99c400","#9dc500","#a1c500","#a5c500","#a9c600","#acc600","#b0c700","#b4c700","#b8c700","#bac800","#bec900","#c1c900","#c5c900","#c8ca00","#c9c918","#cbca33","#ceca41","#cfcb4d","#d1cb57","#d4cb5f","#d5cc67","#d7cd6d","#dacd74","#dbce79","#ddcf7f","#dfcf84","#e2cf8a","#e3d08f","#e5d193","#e7d197","#e8d29b","#ebd39f","#edd3a4","#eed4a8","#f0d4ac","#f3d5af","#f3d6b3","#f5d6b7","#f8d7ba","#f8d8bd","#f8dac1","#f7dbc3","#f7dcc6","#f7dec9","#f8dfcc","#f7e0ce","#f7e2d1","#f7e3d3","#f7e5d6","#f7e6d8","#f7e7da","#f7e8dc","#f8eae0","#f7ebe1","#f7ece5","#f7eee7","#f7efe8","#f8f0eb","#f8f2ed","#f7f3ef","#f8f4f1","#f8f6f4","#f8f7f6","#f8f8f8","#f9f9f9","#fbfbfb","#fcfcfc","#fdfdfd","#fefefe","#ffffff"],c=["#000004","#010005","#010106","#010108","#02010a","#02020c","#02020e","#030210","#040312","#040314","#050417","#060419","#07051b","#08051d","#09061f","#0a0722","#0b0724","#0c0826","#0d0829","#0e092b","#10092d","#110a30","#120a32","#140b34","#150b37","#160b39","#180c3c","#190c3e","#1b0c41","#1c0c43","#1e0c45","#1f0c48","#210c4a","#230c4c","#240c4f","#260c51","#280b53","#290b55","#2b0b57","#2d0b59","#2f0a5b","#310a5c","#320a5e","#340a5f","#360961","#380962","#390963","#3b0964","#3d0965","#3e0966","#400a67","#420a68","#440a68","#450a69","#470b6a","#490b6a","#4a0c6b","#4c0c6b","#4d0d6c","#4f0d6c","#510e6c","#520e6d","#540f6d","#550f6d","#57106e","#59106e","#5a116e","#5c126e","#5d126e","#5f136e","#61136e","#62146e","#64156e","#65156e","#67166e","#69166e","#6a176e","#6c186e","#6d186e","#6f196e","#71196e","#721a6e","#741a6e","#751b6e","#771c6d","#781c6d","#7a1d6d","#7c1d6d","#7d1e6d","#7f1e6c","#801f6c","#82206c","#84206b","#85216b","#87216b","#88226a","#8a226a","#8c2369","#8d2369","#8f2469","#902568","#922568","#932667","#952667","#972766","#982766","#9a2865","#9b2964","#9d2964","#9f2a63","#a02a63","#a22b62","#a32c61","#a52c60","#a62d60","#a82e5f","#a92e5e","#ab2f5e","#ad305d","#ae305c","#b0315b","#b1325a","#b3325a","#b43359","#b63458","#b73557","#b93556","#ba3655","#bc3754","#bd3853","#bf3952","#c03a51","#c13a50","#c33b4f","#c43c4e","#c63d4d","#c73e4c","#c83f4b","#ca404a","#cb4149","#cc4248","#ce4347","#cf4446","#d04545","#d24644","#d34743","#d44842","#d54a41","#d74b3f","#d84c3e","#d94d3d","#da4e3c","#db503b","#dd513a","#de5238","#df5337","#e05536","#e15635","#e25734","#e35933","#e45a31","#e55c30","#e65d2f","#e75e2e","#e8602d","#e9612b","#ea632a","#eb6429","#eb6628","#ec6726","#ed6925","#ee6a24","#ef6c23","#ef6e21","#f06f20","#f1711f","#f1731d","#f2741c","#f3761b","#f37819","#f47918","#f57b17","#f57d15","#f67e14","#f68013","#f78212","#f78410","#f8850f","#f8870e","#f8890c","#f98b0b","#f98c0a","#f98e09","#fa9008","#fa9207","#fa9407","#fb9606","#fb9706","#fb9906","#fb9b06","#fb9d07","#fc9f07","#fca108","#fca309","#fca50a","#fca60c","#fca80d","#fcaa0f","#fcac11","#fcae12","#fcb014","#fcb216","#fcb418","#fbb61a","#fbb81d","#fbba1f","#fbbc21","#fbbe23","#fac026","#fac228","#fac42a","#fac62d","#f9c72f","#f9c932","#f9cb35","#f8cd37","#f8cf3a","#f7d13d","#f7d340","#f6d543","#f6d746","#f5d949","#f5db4c","#f4dd4f","#f4df53","#f4e156","#f3e35a","#f3e55d","#f2e661","#f2e865","#f2ea69","#f1ec6d","#f1ed71","#f1ef75","#f1f179","#f2f27d","#f2f482","#f3f586","#f3f68a","#f4f88e","#f5f992","#f6fa96","#f8fb9a","#f9fc9d","#fafda1","#fcffa4"],d=["#053061","#063264","#073467","#08366a","#09386d","#0a3b70","#0c3d73","#0d3f76","#0e4179","#0f437b","#10457e","#114781","#124984","#134c87","#144e8a","#15508d","#175290","#185493","#195696","#1a5899","#1b5a9c","#1c5c9f","#1d5fa2","#1e61a5","#1f63a8","#2065ab","#2267ac","#2369ad","#246aae","#266caf","#276eb0","#2870b1","#2a71b2","#2b73b3","#2c75b4","#2e77b5","#2f79b5","#307ab6","#327cb7","#337eb8","#3480b9","#3681ba","#3783bb","#3885bc","#3a87bd","#3b88be","#3c8abe","#3e8cbf","#3f8ec0","#408fc1","#4291c2","#4393c3","#4695c4","#4997c5","#4c99c6","#4f9bc7","#529dc8","#569fc9","#59a1ca","#5ca3cb","#5fa5cd","#62a7ce","#65a9cf","#68abd0","#6bacd1","#6eaed2","#71b0d3","#75b2d4","#78b4d5","#7bb6d6","#7eb8d7","#81bad8","#84bcd9","#87beda","#8ac0db","#8dc2dc","#90c4dd","#93c6de","#96c7df","#98c8e0","#9bc9e0","#9dcbe1","#a0cce2","#a2cde3","#a5cee3","#a7d0e4","#a9d1e5","#acd2e5","#aed3e6","#b1d5e7","#b3d6e8","#b6d7e8","#b8d8e9","#bbdaea","#bddbea","#c0dceb","#c2ddec","#c5dfec","#c7e0ed","#cae1ee","#cce2ef","#cfe4ef","#d1e5f0","#d2e6f0","#d4e6f1","#d5e7f1","#d7e8f1","#d8e9f1","#dae9f2","#dbeaf2","#ddebf2","#deebf2","#e0ecf3","#e1edf3","#e3edf3","#e4eef4","#e6eff4","#e7f0f4","#e9f0f4","#eaf1f5","#ecf2f5","#edf2f5","#eff3f5","#f0f4f6","#f2f5f6","#f3f5f6","#f5f6f7","#f6f7f7","#f7f6f6","#f7f5f4","#f8f4f2","#f8f3f0","#f8f2ef","#f8f1ed","#f9f0eb","#f9efe9","#f9eee7","#f9ede5","#f9ebe3","#faeae1","#fae9df","#fae8de","#fae7dc","#fbe6da","#fbe5d8","#fbe4d6","#fbe3d4","#fce2d2","#fce0d0","#fcdfcf","#fcdecd","#fdddcb","#fddcc9","#fddbc7","#fdd9c4","#fcd7c2","#fcd5bf","#fcd3bc","#fbd0b9","#fbceb7","#fbccb4","#facab1","#fac8af","#f9c6ac","#f9c4a9","#f9c2a7","#f8bfa4","#f8bda1","#f8bb9e","#f7b99c","#f7b799","#f7b596","#f6b394","#f6b191","#f6af8e","#f5ac8b","#f5aa89","#f5a886","#f4a683","#f3a481","#f2a17f","#f19e7d","#f09c7b","#ef9979","#ee9677","#ec9374","#eb9172","#ea8e70","#e98b6e","#e8896c","#e6866a","#e58368","#e48066","#e37e64","#e27b62","#e17860","#df765e","#de735c","#dd7059","#dc6e57","#db6b55","#da6853","#d86551","#d7634f","#d6604d","#d55d4c","#d35a4a","#d25849","#d05548","#cf5246","#ce4f45","#cc4c44","#cb4942","#c94741","#c84440","#c6413e","#c53e3d","#c43b3c","#c2383a","#c13639","#bf3338","#be3036","#bd2d35","#bb2a34","#ba2832","#b82531","#b72230","#b61f2e","#b41c2d","#b3192c","#b1182b","#ae172a","#ab162a","#a81529","#a51429","#a21328","#9f1228","#9c1127","#991027","#960f27","#930e26","#900d26","#8d0c25","#8a0b25","#870a24","#840924","#810823","#7f0823","#7c0722","#790622","#760521","#730421","#700320","#6d0220","#6a011f","#67001f"];
  return"linearlab"===a?b:"inferno"===a?c:"RdBu_r"===a?d:["#000000","#FFFFFF"]}},{key:"setColorStops",value:function(a){for(var b=this.setColorMapHex(a),c=b.length,d=new Array(c),e=0;e<c;e++)d[e]=[e/(c-1),b[e]];return d}},{key:"quantileClip",value:function(a){var b=void 0,c=void 0,d=void 0,e=void 0,f=_slicedToArray(this.plotparams.percentile_clip,2);b=f[0],c=f[1];var g=this.getMinMax(a),h=_slicedToArray(g,2);return d=h[0],e=h[1],a.length>0&&(b>0&&(d=math.quantileSeq(a,b/100)),c<100&&(e=math.quantileSeq(a,c/100))),[d,e]}},{key:"initMap",value:function(){var a=this.galthis,b=void 0,c=void 0,d=this.getRange(),e=_slicedToArray(d,2);b=e[0],c=e[1];var f=void 0,g=void 0,h=void 0,i=void 0,j=this.getMinMax(b),k=_slicedToArray(j,2);f=k[0],g=k[1];var l=this.getMinMax(c),m=_slicedToArray(l,2);h=m[0],i=m[1];var n=this.setNull(this.data);c=n.map(function(a){return a[2]}),c=c.filter(this.filterRange);var o=this.quantileClip(c),p=_slicedToArray(o,2);h=p[0],i=p[1];var q=this.plotparams.cmap;if(this.plotparams.symmetric){var r=Math.max.apply(null,[Math.abs(h),Math.abs(i)]);h=-r,i=r}var s=this.setColorStops(q);this.mapdiv.highcharts({chart:{type:"heatmap",marginTop:40,marginBottom:80,plotBorderWidth:1,backgroundColor:null,plotBackgroundColor:"#A8A8A8"},credits:{enabled:!1},title:{text:this.title.replace(/[_]/g," "),style:{fontSize:"14px"}},navigation:{buttonOptions:{theme:{fill:null}}},xAxis:{title:{text:"Spaxel X"},minorGridLineWidth:0,min:f,max:g,tickInterval:1,tickLength:0},yAxis:{title:{text:"Spaxel Y"},min:f,max:g,tickInterval:1,endOnTick:!1,gridLineWidth:0},colorAxis:{min:h,max:i,minColor:s[0][1],maxColor:s[s.length-1][1],stops:s,labels:{align:"center"},reversed:!1,startOnTick:!1,endOnTick:!1,tickPixelInterval:30,type:"linear"},plotOptions:{heatmap:{nullColor:"url(#custom-pattern)"}},defs:{patterns:[{width:3,height:3,id:"custom-pattern",path:{d:"M 0 0 L 3 3 M 0 3 L 3 0",stroke:"white",strokeWidth:.3}}]},legend:{align:"right",layout:"vertical",verticalAlign:"middle",title:{text:this.parameter}},tooltip:{formatter:function(){return"<br>("+this.point.x+", "+this.point.y+"): <b>"+this.point.value+"</b><br>"}},series:[{type:"heatmap",data:n,dataLabels:{enabled:!1},events:{click:function(b){a.getSpaxel(b)}}}]})}}]),a}(),_createClass=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(a,d.key,d)}}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),Marvin=function(){function a(b){_classCallCheck(this,a),this.options=b,this.utils=new Utils,this.utils.print(),this.utils.initInfoPopOvers(),this.utils.initToolTips(),this.header=new Header,this.header.print(),this.setupRaven(),this.window=$(window)}return _createClass(a,[{key:"setupRaven",value:function(){Raven.config("https://98bc7162624049ffa3d8d9911e373430@sentry.io/107924",{release:"0.2.0b1",whitelistUrls:["/(sas|api).sdss.org/marvin/","/(sas|api).sdss.org/marvin2/"],includePaths:["/https?://((sas|api).)?sdss.org/marvin","/https?://((sas|api).)?sdss.org/marvin2"]}).install()}},{key:"checkBrowser",value:function(a){a.data;navigator.userAgent.match(/Version\/[\d\.]+.*Safari/)&&m.utils.marvinBanner("We have detected that you are using Safari. Some features may not work as expected. We recommend using Chrome or Firefox.",1,"safari_banner","http://sdss-marvin.readthedocs.io/en/latest/known-issues.html#known-browser")}}]),a}(),_createClass=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(a,d.key,d)}}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),OLMap=function(){function a(b){_classCallCheck(this,a),void 0===b?console.error("Must specify an input image to initialize a Map!"):(this.image=b,this.staticimdiv=$("#staticimage")[0],this.mapdiv=$("#imagediv")[0],this.getImageSize(),this.setProjection(),this.setView(),this.initMap(),this.addDrawInteraction())}return _createClass(a,[{key:"print",value:function(){console.log("We are now printing openlayers map")}},{key:"getImageSize",value:function(){void 0!==this.staticimdiv&&(this.imwidth=this.staticimdiv.naturalWidth,this.imheight=this.staticimdiv.naturalHeight)}},{key:"setMouseControl",value:function(){var a=new ol.control.MousePosition({coordinateFormat:ol.coordinate.createStringXY(4),projection:"EPSG:4326",undefinedHTML:"&nbsp;"});return a}},{key:"setProjection",value:function(){this.extent=[0,0,this.imwidth,this.imheight],this.projection=new ol.proj.Projection({code:"ifu",units:"pixels",extent:this.extent})}},{key:"setBaseImageLayer",value:function(){var a=new ol.layer.Image({source:new ol.source.ImageStatic({url:this.image,projection:this.projection,imageExtent:this.extent})});return a}},{key:"setView",value:function(){this.view=new ol.View({projection:this.projection,center:ol.extent.getCenter(this.extent),zoom:1,maxZoom:8,maxResolution:1.4})}},{key:"initMap",value:function(){var a=this.setMouseControl(),b=this.setBaseImageLayer();this.map=new ol.Map({controls:ol.control.defaults({attributionOptions:{collapsible:!1}}).extend([a]),layers:[b],target:this.mapdiv,view:this.view})}},{key:"addDrawInteraction",value:function(){var a=void 0,b=new ol.source.Vector({wrapX:!1}),c=this.newVectorLayer(b);this.map.addLayer(c);var d="Point",e=void 0,f=void 0;this.draw=new ol.interaction.Draw({source:b,type:d,geometryFunction:e,maxPoints:f}),this.draw.on("drawend",function(c){a&&b.removeFeature(a),a=c.feature}),this.map.addInteraction(this.draw)}},{key:"newVectorLayer",value:function(a){var b=new ol.layer.Vector({source:a,style:new ol.style.Style({fill:new ol.style.Fill({color:"rgba(255, 255, 255, 0.2)"}),stroke:new ol.style.Stroke({color:"#FF0808",width:2}),image:new ol.style.Circle({radius:3,fill:new ol.style.Fill({color:"#FF0808"})})})});return b}}]),a}(),_createClass=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(a,d.key,d)}}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),Scatter=function(){function a(b,c,d){_classCallCheck(this,a),void 0===c?console.error("Must specify input plot data to initialize a ScatterPlot!"):void 0===b?console.error("Must specify an input plotdiv to initialize a ScatterPlot"):(this.plotdiv=b,this.data=c,this.setOptions(d),this.initChart(),this.createTitleOverlays())}return _createClass(a,[{key:"print",value:function(){console.log("We are now printing scatter for ",this.cfg.title)}},{key:"setOptions",value:function(a){if(this.cfg={title:"Scatter Title",origthis:null,xtitle:"X-Axis",ytitle:"Y-Axis",galaxy:{name:"Galaxy"},altseries:{name:null,data:null},xrev:!1,yrev:!1},"undefined"!=typeof a)for(var b in a)"undefined"!=typeof a[b]&&(this.cfg[b]=a[b])}},{key:"initChart",value:function(){this.plotdiv.empty(),this.chart=Highcharts.chart(this.plotdiv.attr("id"),{chart:{type:"scatter",zoomType:"xy",backgroundColor:"#F5F5F5",plotBackgroundColor:"#F5F5F5"},title:{text:null},xAxis:{title:{enabled:!0,text:this.cfg.xtitle},startOnTick:!0,endOnTick:!0,showLastLabel:!0,reversed:this.cfg.xrev,id:this.cfg.xtitle.replace(/\s/g,"").toLowerCase()+"-axis"},yAxis:{title:{text:this.cfg.ytitle},gridLineWidth:0,reversed:this.cfg.yrev,id:this.cfg.ytitle.replace(/\s/g,"").toLowerCase()+"-axis"},legend:{layout:"vertical",align:"left",verticalAlign:"top",x:75,y:20,title:{text:"Drag Me"},floating:!0,draggable:!0,backgroundColor:Highcharts.theme&&Highcharts.theme.legendBackgroundColor||"#FFFFFF",borderWidth:1},plotOptions:{scatter:{marker:{radius:5,states:{hover:{enabled:!0,lineColor:"rgb(100,100,100)"}}},states:{hover:{marker:{enabled:!1}}},tooltip:{headerFormat:"<b>{series.name}</b><br>",pointFormat:"({point.x}, {point.y})"}}},series:[{name:this.cfg.altseries.name,color:"rgba(70,130,180,0.4)",data:this.cfg.altseries.data,turboThreshold:0,marker:{radius:2,symbol:"circle"},tooltip:{headerFormat:"<b>{series.name}: {point.key}</b><br>"}},{name:this.cfg.galaxy.name,color:"rgba(255, 0, 0, 1)",data:this.data,marker:{symbol:"circle",radius:5}}]})}},{key:"createTitleOverlays",value:function(){this.overgroup=this.chart.renderer.g().add(),this.overheight=20,this.overwidth=100,this.overedge=5,this.overcolor="rgba(255,0,0,0.5)",this.overborder="black",this.overbwidth=2,this.overzindex=3;var a=this.chart.xAxis[0].axisTitle.element,b=a.getAttribute("x"),c=a.getAttribute("y"),d=this.chart.yAxis[0].axisTitle.element,e=d.getAttribute("x"),f=d.getAttribute("y");this.yover=this.chart.renderer.rect(e-(this.overheight/2+3),f-this.overwidth/2,this.overheight,this.overwidth,this.overedge).attr({"stroke-width":this.overbwidth,stroke:this.overborder,fill:this.overcolor,zIndex:this.overzindex}).add(this.overgroup),this.xover=this.chart.renderer.rect(b-this.overwidth/2,c-(this.overheight/2+3),this.overwidth,this.overheight,this.overedge).attr({"stroke-width":this.overbwidth,stroke:this.overborder,fill:this.overcolor,zIndex:this.overzindex}).add(this.overgroup),this.overgroup.hide()}}]),a}(),_createClass=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(a,d.key,d)}}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),Search=function(){function a(){_classCallCheck(this,a),this.searchform=$("#searchform"),this.typeahead=$("#searchform .typeahead"),this.returnparams=$("#returnparams"),this.parambox=$("#parambox"),this.searchbox=$("#searchbox"),this.builder=$("#builder"),this.sqlalert=$("#sqlalert"),this.getsql=$("#get-sql"),this.resetsql=$("#reset-sql"),this.runsql=$("#run-sql"),this.getsql.on("click",this,this.getSQL),this.resetsql.on("click",this,this.resetSQL),this.runsql.on("click",this,this.runSQL)}return _createClass(a,[{key:"print",value:function(){console.log("I am Search!")}},{key:"extractor",value:function(a){var b=new RegExp("([^,]+)$"),c=b.exec(a);return c&&c[1]?c[1].trim():""}},{key:"initTypeahead",value:function(a,b,c,d){function e(a){var b=a.toString();return[f.extractor(b)]}var f=this,g=void 0;a=void 0===a?this.typeahead:$(a),b=void 0===b?this.searchform:$(b);try{g=void 0===c?Flask.url_for("search_page.getparams",{paramdisplay:"best"}):c}catch(h){Raven.captureException(h),console.error("Error getting search getparams url:",h)}this.queryparams=new Bloodhound({datumTokenizer:Bloodhound.tokenizers.whitespace,queryTokenizer:e,prefetch:g,remote:{url:g,filter:function(a){return a}}}),this.queryparams.initialize(),a.typeahead("destroy"),a.typeahead({showHintOnFocus:!0,items:"all",source:this.queryparams.ttAdapter(),updater:function(a){var b=this.$element.val(),c=b.replace(/[^,]*$/,""),d=c+a+", ";return d},matcher:function(a){var b=f.extractor(this.query);return console.log("query",this.query),console.log(b),!!b&&~a.toLowerCase().indexOf(b.toLowerCase())},highlighter:function(a){var b=f.extractor(this.query),c=b.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&");return a.replace(new RegExp("("+c+")","ig"),function(a,b){return"<strong>"+b+"</strong>"})}})}},{key:"setupQB",value:function(a){$(".modal-dialog").draggable(),this.builder.queryBuilder({plugins:["bt-selectpicker","not-group","invert"],filters:a,operators:["equal","not_equal","less","less_or_equal","greater","greater_or_equal","between","contains","begins_with","ends_with"]})}},{key:"getSQL",value:function(a){var b=a.data;try{var c=b.builder.queryBuilder("getSQL",!1);if(c.sql.length){b.sqlalert.html("");var d=c.sql.replace(/[']+/g,""),e=d.indexOf("LIKE");if(e!==-1){d=d.replace("LIKE(","= ").replace(/[%]/g,"*");var f=d.indexOf(")",e);d=d.replace(d.charAt(f)," ")}b.searchbox.val(d)}}catch(g){b.sqlalert.html("<p class='text-center text-danger'>Must provide valid input.</p>")}}},{key:"resetSQL",value:function(a){var b=a.data;b.searchbox.val("")}},{key:"runSQL",value:function(a){var b=a.data;""===b.searchbox.val()?b.sqlalert.html("<p class='text-center text-danger'>You must generate SQL first!</p>"):b.searchform.submit()}}]),a}(),_createClass=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(a,d.key,d)}}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),Table=function(){function a(b){_classCallCheck(this,a),this.setTable(b),this.table.on("load-success.bs.table",this,this.setSuccessMsg),this.table.on("load-error.bs.table",this,this.setErrMsg)}return _createClass(a,[{key:"print",value:function(){console.log("I am Table!")}},{key:"setTable",value:function(a){void 0!==a&&(console.log("setting the table"),this.table=a,this.errdiv=this.table.siblings("#errdiv"),this.tableerr=this.errdiv.find("#tableerror"),this.tableerr.hide())}},{key:"initTable",value:function(a,b){this.url=a;var c=void 0;null!==b.columns&&(c=this.makeColumns(b.columns)),console.log(b),console.log("cols",c),this.table.bootstrapTable({classes:"table table-bordered table-condensed table-hover",toggle:"table",toolbar:"#toolbar",pagination:!0,pageSize:10,pageList:"[10, 20, 50]",sidePagination:"server",method:"post",contentType:"application/x-www-form-urlencoded",data:b.rows,totalRows:b.total,columns:c,url:a,showColumns:!0,showToggle:!0,sortName:"mangaid",sortOrder:"asc",formatNoMatches:function(){return"This table is empty..."}})}},{key:"updateMsg",value:function(a){var b="<strong>"+a+"</strong>";this.tableerr.html(b),this.tableerr.show()}},{key:"setErrMsg",value:function(a,b,c){var d=a.data,e="";502===b&&(e="bad server response retrieving web table.  likely uncaught error on server side.  check logs.");var f="Status "+b+" - "+c.statusText+": "+e;d.updateMsg(f)}},{key:"setSuccessMsg",value:function(a,b){var c=a.data;c.tableerr.hide(),b.status===-1&&c.updateMsg(b.errmsg)}},{key:"makeColumns",value:function(a){var b=this,c=[];return a.forEach(function(a,d){var e={};e.field=a,e.title=a,e.sortable=!0,a.match("plateifu|mangaid")&&(e.formatter=b.linkformatter),c.push(e)}),c}},{key:"linkformatter",value:function(a,b,c){var d=Flask.url_for("galaxy_page.Galaxy:get",{galid:a}),e="<a href="+d+" target='_blank'>"+a+"</a>";return e}},{key:"handleResponse",value:function(a){null===this.table&&this.setTable(),this.table=$("#table");var b=a.columns;return b=[],a.columns.forEach(function(a,c){var d={};d.field=a,d.title=a,d.sortable=!0,b.push(d)}),this.table.bootstrapTable("refreshOptions",{columns:b,totalRows:a.total}),a}}]),a}(),_createClass=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(a,d.key,d)}}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),Utils=function(){function a(){_classCallCheck(this,a),this.window=$(window),$("#login-user").on("keyup",this,this.submitLogin),$("#login-pass").on("keyup",this,this.submitLogin),$("#login-drop").on("hide.bs.dropdown",this,this.resetLogin)}return _createClass(a,[{key:"print",value:function(){console.log("I am Utils!")}},{key:"buildForm",value:function(a){var b=Array.prototype.slice.call(arguments,1),c={};return a.forEach(function(a,d){c[a]=b[d]}),c}},{key:"serializeForm",value:function(a){var b=$(a).serializeArray();return b}},{key:"unique",value:function(a){return new Set(a)}},{key:"scrollTo",value:function(a){if(void 0!==a){var b=$(a);$("html,body").animate({scrollTop:b.offset().top},1500,"easeInOutExpo")}else $("html,body").animate({scrollTop:0},1500,"easeInOutExpo")}},{key:"initInfoPopOvers",value:function(){$('.infopop [data-toggle="popover"]').popover()}},{key:"initToolTips",value:function(){$('[data-toggle="tooltip"]').tooltip()}},{key:"selectChoices",value:function(a,b){$(a).selectpicker("val",b),$(a).selectpicker("refresh")}},{key:"resetChoices",value:function(a){console.log("reseting in utils",a);var b="string"==typeof a?$(a):a;b.selectpicker("deselectAll"),b.selectpicker("refresh"),b.selectpicker("render")}},{key:"login",value:function(){var a=this,b=$("#loginform").serialize();Promise.resolve($.post(Flask.url_for("index_page.login"),b,"json")).then(function(a){if(a.result.status<0)throw new Error("Bad status login");if(""!==a.result.message){var b=0===a.result.status?"danger":"success",c="<div class='alert alert-"+b+"' role='alert'><h4>"+a.result.message+"</h4></div>";$("#loginmessage").html(c)}1===a.result.status&&location.reload(!0)})["catch"](function(b){a.resetLogin(),alert("Bad login attempt")})}},{key:"resetLogin",value:function(){console.log("reset"),$("#loginform").trigger("reset"),$("#loginmessage").empty()}},{key:"submitLogin",value:function(a){var b=a.data;13==a.keyCode&&$("#login-user").val()&&$("#login-pass").val()&&b.login()}},{key:"marvinBanner",value:function(a,b,c,d,e){var f=this;b=void 0===b?0:b,c=void 0===c?"marvin_banner_cookie":c,d=void 0===d?"":d,e=void 0===e?"Learn more":e,""!==e&&""!==d||(e="",d=""),f.window[0].cookieconsent.initialise({palette:{popup:{background:"#000"},button:{background:"#f1d600"}},position:"top",cookie:{name:c,expiryDays:b,domain:"localhost"},content:{message:a,dismiss:"Got it!",href:d,link:e}}),0===b&&(document.cookie=c+"=;expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/;domain=localhost")}}]),a}();