text: /*! Locuszoom 0.13.0-beta.2 */
  var LzIntervalsTrack=function(t){var e={};function a(r){if(e[r])return e[r].exports;var n=e[r]={i:r,l:!1,exports:{}};return t[r].call(n.exports,n,n.exports,a),n.l=!0,n.exports}return a.m=t,a.c=e,a.d=function(t,e,r){a.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},a.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},a.t=function(t,e){if(1&e&&(t=a(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(a.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)a.d(r,n,function(e){return t[e]}.bind(null,n));return r},a.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return a.d(e,"a",e),e},a.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},a.p="",a(a.s=8)}({0:function(t,e){t.exports=d3},8:function(t,e,a){"use strict";a.r(e);var r=a(0);function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){for(var a=0;a<e.length;a++){var r=e[a];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function l(t,e,a){return e&&s(t.prototype,e),a&&s(t,a),t}function o(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&c(t,e)}function c(t,e){return(c=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function d(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var a,r=_(t);if(e){var n=_(this).constructor;a=Reflect.construct(r,arguments,n)}else a=r.apply(this,arguments);return u(this,a)}}function u(t,e){return!e||"object"!==n(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function _(t){return(_=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function p(t){var e=t.Adapters.get("BaseApiAdapter"),a=t.Widgets.get("_Button"),n=t.Widgets.get("BaseWidget"),s=function(t){o(a,t);var e=d(a);function a(){return i(this,a),e.apply(this,arguments)}return l(a,[{key:"getURL",value:function(t,e,a){var r=e.header.bedtracksource||this.params.source,n="?filter=id in ".concat(r," and chromosome eq '").concat(t.chr,"' and start le ").concat(t.end," and end ge ").concat(t.start);return"".concat(this.url).concat(n)}}]),a}(e),c=function(t){o(r,t);var e=d(r);function r(t){var a;if(i(this,r),a=e.apply(this,arguments),t.data_layer_id||(t.data_layer_id="intervals"),!a.parent_panel.data_layers[t.data_layer_id])throw new Error("Toggle split tracks widget specifies an invalid data layer ID");return a}return l(r,[{key:"update",value:function(){var t=this,e=this.parent_panel.data_layers[this.layout.data_layer_id],r=e.layout.split_tracks?"Merge Tracks":"Split Tracks";return this.button?(this.button.setHtml(r),this.button.show(),this.parent.position(),this):(this.button=new a(this).setColor(this.layout.color).setHtml(r).setTitle("Toggle whether tracks are split apart or merged together").setOnclick((function(){e.toggleSplitTracks(),t.scale_timeout&&clearTimeout(t.scale_timeout),t.scale_timeout=setTimeout((function(){t.parent_panel.scaleHeightToData(),t.parent_plot.positionPanels()}),0),t.update()})),this.update())}}]),r}(n);var u,_={start_field:"start",end_field:"end",track_label_field:"state_name",track_split_field:"state_id",track_split_order:"DESC",track_split_legend_to_y_axis:2,split_tracks:!0,track_height:15,track_vertical_spacing:3,bounding_box_padding:2,always_hide_legend:!1,color:"#B8B8B8",fill_opacity:1,tooltip_positioning:"vertical"},p=function(e){o(n,e);var a=d(n);function n(e){var r;return i(this,n),t.Layouts.merge(e,_),(r=a.apply(this,arguments)).tracks=1,r.previous_tracks=1,r.interval_track_index={1:[]},r}return l(n,[{key:"getElementStatusNodeId",value:function(t){return this.layout.split_tracks?"".concat(this.getBaseId(),"-statusnode-").concat(t[this.layout.track_split_field]).replace(/[^\w]/g,"_"):"".concat(this.getElementId(t),"-statusnode")}},{key:"getTrackHeight",value:function(){return this.layout.track_height+this.layout.track_vertical_spacing+2*this.layout.bounding_box_padding}},{key:"_applyLayoutOptions",value:function(){var t=this,e=this._base_layout,a=this.layout,r=e.color.find((function(t){return t.scale_function&&"categorical_bin"===t.scale_function})),n=a.color.find((function(t){return t.scale_function&&"categorical_bin"===t.scale_function}));if(!r)throw new Error("Interval tracks must define a `categorical_bin` color scale");var i=r.parameters.categories.length&&r.parameters.values.length,s=e.legend&&e.legend.length;if(!!i^!!s)throw new Error("To use a manually specified color scheme, both color and legend options must be set.");var l=e.color.find((function(t){return t.scale_function&&"to_rgb"===t.scale_function})),o=l&&l.field,c=this._generateCategoriesFromData(this.data,o);if(!i&&!s){var d=this._makeColorScheme(c);n.parameters.categories=c.map((function(t){return t[0]})),n.parameters.values=d,this.layout.legend=c.map((function(e,a){var r=e[0],i={shape:"rect",width:9,label:e[1],color:n.parameters.values[a]};return i[t.layout.track_split_field]=r,i}))}}},{key:"assignTracks",value:function(){var t=this;if(this._applyLayoutOptions(),this.previous_tracks=this.tracks,this.tracks=0,this.interval_track_index={1:[]},this.track_split_field_index={},this.layout.track_split_field&&this.layout.split_tracks){this.data.forEach((function(e){t.track_split_field_index[e[t.layout.track_split_field]]=null}));var e=Object.keys(this.track_split_field_index);"DESC"===this.layout.track_split_order&&e.reverse(),e.forEach((function(e){t.track_split_field_index[e]=t.tracks+1,t.interval_track_index[t.tracks+1]=[],t.tracks++}))}return this.data.forEach(function(t,e){var a=this;if(this.data[e].parent=this,this.data[e].display_range={start:this.parent.x_scale(Math.max(t[this.layout.start_field],this.state.start)),end:this.parent.x_scale(Math.min(t[this.layout.end_field],this.state.end))},this.data[e].display_range.width=this.data[e].display_range.end-this.data[e].display_range.start,this.data[e].display_domain={start:this.parent.x_scale.invert(this.data[e].display_range.start),end:this.parent.x_scale.invert(this.data[e].display_range.end)},this.data[e].display_domain.width=this.data[e].display_domain.end-this.data[e].display_domain.start,this.layout.track_split_field&&this.layout.split_tracks){var r=this.data[e][this.layout.track_split_field];this.data[e].track=this.track_split_field_index[r],this.interval_track_index[this.data[e].track].push(e)}else{this.tracks=1,this.data[e].track=null;for(var n=1,i=function(){var t=!1;a.interval_track_index[n].map(function(e){if(!t){var a=Math.min(e.display_range.start,this.display_range.start);Math.max(e.display_range.end,this.display_range.end)-a<e.display_range.width+this.display_range.width&&(t=!0)}}.bind(a.data[e])),t?++n>a.tracks&&(a.tracks=n,a.interval_track_index[n]=[]):(a.data[e].track=n,a.interval_track_index[n].push(a.data[e]))};null===this.data[e].track;)i()}}.bind(this)),this}},{key:"render",value:function(){var t=this;this.assignTracks();var e=this._applyFilters();this.svg.group.selectAll(".lz-data_layer-intervals-statusnode.lz-data_layer-intervals-shared").remove(),Object.keys(this.track_split_field_index).forEach((function(e){var a={};a[t.layout.track_split_field]=e,t.svg.group.insert("rect",":first-child").attr("id",t.getElementStatusNodeId(a)).attr("class","lz-data_layer-intervals lz-data_layer-intervals-statusnode lz-data_layer-intervals-shared").attr("rx",t.layout.bounding_box_padding).attr("ry",t.layout.bounding_box_padding).attr("width",t.parent.layout.cliparea.width).attr("height",t.getTrackHeight()-t.layout.track_vertical_spacing).attr("x",0).attr("y",(t.track_split_field_index[e]-1)*t.getTrackHeight()).style("display",t.layout.split_tracks?null:"none")}));var a=this.svg.group.selectAll("g.lz-data_layer-intervals").data(e,(function(e){return e[t.layout.id_field]}));return a.enter().append("g").attr("class","lz-data_layer-intervals").merge(a).attr("id",(function(e){return t.getElementId(e)})).each((function(t){var e=t.parent,a=r.select(this).selectAll("rect.lz-data_layer-intervals.lz-data_layer-intervals-statusnode.lz-data_layer-intervals-statusnode-discrete").data([t],(function(t){return"".concat(e.getElementId(t),"-statusnode")}));a.enter().insert("rect",":first-child").attr("class","lz-data_layer-intervals lz-data_layer-intervals-statusnode lz-data_layer-intervals-statusnode-discrete").merge(a).attr("id",(function(t){return"".concat(e.getElementId(t),"-statusnode")})).attr("rx",e.layout.bounding_box_padding).attr("ry",e.layout.bounding_box_padding).style("display",e.layout.split_tracks?"none":null).attr("width",(function(t){return t.display_range.width+2*e.layout.bounding_box_padding})).attr("height",e.getTrackHeight()-e.layout.track_vertical_spacing).attr("x",(function(t){return t.display_range.start-e.layout.bounding_box_padding})).attr("y",(function(t){return(t.track-1)*e.getTrackHeight()})),a.exit().remove();var n=r.select(this).selectAll("rect.lz-data_layer-intervals.lz-interval_rect").data([t],(function(t){return"".concat(t[e.layout.id_field],"_interval_rect")}));n.enter().append("rect").attr("class","lz-data_layer-intervals lz-interval_rect").merge(n).attr("width",(function(t){return t.display_range.width})).attr("height",e.layout.track_height).attr("x",(function(t){return t.display_range.start})).attr("y",(function(t){return(t.track-1)*e.getTrackHeight()+e.layout.bounding_box_padding})).attr("fill",(function(t,a){return e.resolveScalableParameter(e.layout.color,t,a)})).attr("fill-opacity",(function(t,a){return e.resolveScalableParameter(e.layout.fill_opacity,t,a)})),n.exit().remove();var i=r.select(this).selectAll("rect.lz-data_layer-intervals.lz-clickarea").data([t],(function(t){return"".concat(t.interval_name,"_clickarea")}));i.enter().append("rect").attr("class","lz-data_layer-intervals lz-clickarea").merge(i).attr("id",(function(t){return"".concat(e.getElementId(t),"_clickarea")})).attr("rx",e.layout.bounding_box_padding).attr("ry",e.layout.bounding_box_padding).attr("width",(function(t){return t.display_range.width})).attr("height",e.getTrackHeight()-e.layout.track_vertical_spacing).attr("x",(function(t){return t.display_range.start})).attr("y",(function(t){return(t.track-1)*e.getTrackHeight()})).on("click",(function(t){t.parent.parent.emit("element_clicked",t,!0)})).call(e.applyBehaviors.bind(e)),i.exit().remove()})),a.exit().remove(),this.previous_tracks!==this.tracks&&this.updateSplitTrackAxis(),this.parent&&this.parent.legend&&this.parent.legend.render(),this}},{key:"_getTooltipPosition",value:function(t){var e=r.select("#".concat(this.getElementStatusNodeId(t.data))).node().getBBox();return{x_min:t.data.display_range.start,x_max:t.data.display_range.end,y_min:e.y,y_max:e.y+e.height}}},{key:"updateSplitTrackAxis",value:function(){var t=this,e=!!this.layout.track_split_legend_to_y_axis&&"y".concat(this.layout.track_split_legend_to_y_axis);if(this.layout.split_tracks){var a=+this.tracks||0,r=+this.layout.track_height||0,n=2*(+this.layout.bounding_box_padding||0)+(+this.layout.track_vertical_spacing||0),i=a*r+(a-1)*n;this.parent.scaleHeightToData(i),e&&this.parent.legend&&(this.parent.legend.hide(),this.parent.layout.axes[e]={render:!0,ticks:[],range:{start:i-this.layout.track_height/2,end:this.layout.track_height/2}},this.layout.legend.forEach((function(r){var n=r[t.layout.track_split_field],i=t.track_split_field_index[n];i&&("DESC"===t.layout.track_split_order&&(i=Math.abs(i-a-1)),t.parent.layout.axes[e].ticks.push({y:i,text:r.label}))})),this.layout.y_axis={axis:this.layout.track_split_legend_to_y_axis,floor:1,ceiling:a},this.parent.render()),this.parent_plot.positionPanels()}else e&&this.parent.legend&&(this.layout.always_hide_legend||this.parent.legend.show(),this.parent.layout.axes[e]={render:!1},this.parent.render());return this}},{key:"toggleSplitTracks",value:function(){return this.layout.split_tracks=!this.layout.split_tracks,this.parent.legend&&!this.layout.always_hide_legend&&(this.parent.layout.margin.bottom=5+(this.layout.split_tracks?0:this.parent.legend.layout.height+5)),this.render(),this.updateSplitTrackAxis(),this}},{key:"_makeColorScheme",value:function(t){if(t.find((function(t){return t[2]})))return t.map((function(t){return t[2]}));var e=t.length;return e<=15?["rgb(212,212,212)","rgb(192,192,192)","rgb(128,128,128)","rgb(189,183,107)","rgb(233,150,122)","rgb(205,92,92)","rgb(138,145,208)","rgb(102,205,170)","rgb(255,255,0)","rgb(194,225,5)","rgb(0,100,0)","rgb(0,128,0)","rgb(50,205,50)","rgb(255,69,0)","rgb(255,0,0)"]:e<=18?["rgb(212,212,212)","rgb(192,192,192)","rgb(128,128,128)","rgb(189,183,107)","rgb(205,92,92)","rgb(138,145,208)","rgb(102,205,170)","rgb(255,255,0)","rgb(255,195,77)","rgb(255,195,77)","rgb(194,225,5)","rgb(194,225,5)","rgb(0,100,0)","rgb(0,128,0)","rgb(255,69,0)","rgb(255,69,0)","rgb(255,69,0)","rgb(255,0,0)"]:["rgb(212,212,212)","rgb(128,128,128)","rgb(112,48,160)","rgb(230,184,183)","rgb(138,145,208)","rgb(102,205,170)","rgb(255,255,102)","rgb(255,255,0)","rgb(255,255,0)","rgb(255,255,0)","rgb(255,195,77)","rgb(255,195,77)","rgb(255,195,77)","rgb(194,225,5)","rgb(194,225,5)","rgb(194,225,5)","rgb(194,225,5)","rgb(0,150,0)","rgb(0,128,0)","rgb(0,128,0)","rgb(0,128,0)","rgb(255,69,0)","rgb(255,69,0)","rgb(255,69,0)","rgb(255,0,0)"]}},{key:"_generateCategoriesFromData",value:function(t,e){var a=this,r=this,n=this._base_layout.legend;if(n&&n.length)return n.map((function(t){return[t[a.layout.track_split_field],t.label,t.color]}));var i={},s=[];return t.forEach((function(t){var n=t[r.layout.track_split_field];Object.prototype.hasOwnProperty.call(i,n)||(i[n]=null,s.push([n,t[a.layout.track_label_field],t[e]]))})),s}}]),n}(t.DataLayers.get("BaseDataLayer")),h={namespace:{intervals:"intervals"},closable:!1,show:{or:["highlighted","selected"]},hide:{and:["unhighlighted","unselected"]},html:"{{{{namespace[intervals]}}state_name|htmlescape}}<br>{{{{namespace[intervals]}}start|htmlescape}}-{{{{namespace[intervals]}}end|htmlescape}}"},g={namespace:{intervals:"intervals"},id:"intervals",type:"intervals",fields:["{{namespace[intervals]}}start","{{namespace[intervals]}}end","{{namespace[intervals]}}state_id","{{namespace[intervals]}}state_name","{{namespace[intervals]}}itemRgb"],id_field:"{{namespace[intervals]}}start",start_field:"{{namespace[intervals]}}start",end_field:"{{namespace[intervals]}}end",track_split_field:"{{namespace[intervals]}}state_name",track_label_field:"{{namespace[intervals]}}state_name",split_tracks:!1,always_hide_legend:!0,color:[{field:"{{namespace[intervals]}}itemRgb",scale_function:"to_rgb"},{field:"{{namespace[intervals]}}state_name",scale_function:"categorical_bin",parameters:{categories:[],values:[],null_value:"#B8B8B8"}}],legend:[],behaviors:{onmouseover:[{action:"set",status:"highlighted"}],onmouseout:[{action:"unset",status:"highlighted"}],onclick:[{action:"toggle",status:"selected",exclusive:!0}],onshiftclick:[{action:"toggle",status:"selected"}]},tooltip:h},y={id:"intervals",width:1e3,height:50,min_width:500,min_height:50,margin:{top:25,right:150,bottom:5,left:50},toolbar:(u=t.Layouts.get("toolbar","standard_panel",{unnamespaced:!0}),u.widgets.push({type:"toggle_split_tracks",data_layer_id:"intervals",position:"right"}),u),axes:{},interaction:{drag_background_to_pan:!0,scroll_to_zoom:!0,x_linked:!0},legend:{hidden:!0,orientation:"horizontal",origin:{x:50,y:0},pad_from_bottom:5},data_layers:[g]},f={state:{},width:800,height:550,responsive_resize:!0,min_region_scale:2e4,max_region_scale:1e6,toolbar:t.Layouts.get("toolbar","standard_association",{unnamespaced:!0}),panels:[t.Layouts.get("panel","association",{unnamespaced:!0,width:800,proportional_height:225/570}),Object.assign({unnamespaced:!0,proportional_height:120/570},y),t.Layouts.get("panel","genes",{unnamespaced:!0,width:800,proportional_height:225/570})]};t.Adapters.add("IntervalLZ",s),t.DataLayers.add("intervals",p),t.Layouts.add("tooltip","standard_intervals",h),t.Layouts.add("data_layer","intervals",g),t.Layouts.add("panel","intervals",y),t.Layouts.add("plot","interval_association",f),t.ScaleFunctions.add("to_rgb",(function(t,e){return e?"rgb(".concat(e,")"):null})),t.Widgets.add("toggle_split_tracks",c)}"undefined"!=typeof LocusZoom&&LocusZoom.use(p),e.default=p}}).default;
  //# sourceMappingURL=lz-intervals-track.min.js.map