define("layout/scratchbook",["exports","backbone","underscore","mvc/ui/ui-frames","mvc/dataset/data","viz/visualization","viz/trackster","utils/localization"],function(t,e,a,i,n,o,l,r){"use strict";function s(t){return t&&t.__esModule?t:{default:t}}function c(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e.default=t,e}Object.defineProperty(t,"__esModule",{value:!0});var d=c(e),u=c(a),f=s(i),h=s(n),v=s(o),_=s(l),b=s(r);t.default=d.View.extend({initialize:function(t){var e=this;t=t||{},this.frames=new f.default.View({visible:!1}),this.setElement(this.frames.$el),this.buttonActive=t.collection.add({id:"enable-scratchbook",icon:"fa-th",tooltip:(0,b.default)("Enable/Disable Scratchbook"),onclick:function(){e.active=!e.active,e.buttonActive.set({toggle:e.active,show_note:e.active,note_cls:e.active&&"fa fa-check"}),e.active||e.frames.hide()},onbeforeunload:function(){if(e.frames.length()>0)return"You opened "+e.frames.length()+" frame(s) which will be lost."}}),this.buttonLoad=t.collection.add({id:"show-scratchbook",icon:"fa-eye",tooltip:(0,b.default)("Show/Hide Scratchbook"),show_note:!0,visible:!1,onclick:function(t){e.frames.visible?e.frames.hide():e.frames.show()}}),this.frames.on("add remove",function(){this.visible&&0===this.length()&&this.hide(),e.buttonLoad.set({note:this.length(),visible:this.length()>0})}).on("show hide ",function(){e.buttonLoad.set({toggle:this.visible,icon:this.visible&&"fa-eye"||"fa-eye-slash"})}),this.history_cache={}},addDataset:function(t){var e=this,a=null;if(Galaxy&&Galaxy.currHistoryPanel){var i=Galaxy.currHistoryPanel.collection.historyId;this.history_cache[i]={name:Galaxy.currHistoryPanel.model.get("name"),dataset_ids:[]},Galaxy.currHistoryPanel.collection.each(function(t){!t.get("deleted")&&t.get("visible")&&e.history_cache[i].dataset_ids.push(t.get("id"))})}var n=function(t,a){if(t){var i=e.history_cache[t.get("history_id")];if(i&&i.dataset_ids){var n=i.dataset_ids,o=n.indexOf(t.get("id"));if(-1!==o&&o+a>=0&&o+a