welsonjs/app/assets/js/goldenlayout-1.5.9.min.js

3 lines
66 KiB
JavaScript

!function(t){var e={config:{},container:{},controls:{},errors:{},items:{},utils:{}};e.utils.F=function(){},e.utils.extend=function(t,i){t.prototype=e.utils.createObject(i.prototype),t.prototype.contructor=t},e.utils.createObject=function(t){return"function"==typeof Object.create?Object.create(t):(e.utils.F.prototype=t,new e.utils.F)},e.utils.objectKeys=function(t){var e,i;if("function"==typeof Object.keys)return Object.keys(t);e=[];for(i in t)e.push(i);return e},e.utils.getHashValue=function(t){var e=location.hash.match(new RegExp(t+"=([^&]*)"));return e?e[1]:null},e.utils.getQueryStringParam=function(t){if(window.location.hash)return e.utils.getHashValue(t);if(!window.location.search)return null;var i,n,s=window.location.search.substr(1).split("&"),o={};for(n=0;n<s.length;n++)i=s[n].split("="),o[i[0]]=i[1];return o[t]||null},e.utils.copy=function(t,e){for(var i in e)t[i]=e[i];return t},e.utils.animFrame=function(t){return(window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||function(t){window.setTimeout(t,1e3/60)})(function(){t()})},e.utils.indexOf=function(t,e){if(!(e instanceof Array))throw new Error("Haystack is not an Array");if(e.indexOf)return e.indexOf(t);for(var i=0;i<e.length;i++)if(e[i]===t)return i;return-1},"function"!=typeof/./&&"object"!=typeof Int8Array?e.utils.isFunction=function(t){return"function"==typeof t||!1}:e.utils.isFunction=function(t){return"[object Function]"===toString.call(t)},e.utils.fnBind=function(t,e,i){if(void 0!==Function.prototype.bind)return Function.prototype.bind.apply(t,[e].concat(i||[]));var n=function(){var s=(i||[]).concat(Array.prototype.slice.call(arguments,0));return this instanceof n?void t.apply(this,s):t.apply(e,s)};return n.prototype=t.prototype,n},e.utils.removeFromArray=function(t,i){var n=e.utils.indexOf(t,i);if(n===-1)throw new Error("Can't remove item from array. Item is not in the array");i.splice(n,1)},e.utils.now=function(){return"function"==typeof Date.now?Date.now():(new Date).getTime()},e.utils.getUniqueId=function(){return(1e15*Math.random()).toString(36).replace(".","")},e.utils.filterXss=function(t,e){var i=t.replace(/javascript/gi,"j&#97;vascript").replace(/expression/gi,"expr&#101;ssion").replace(/onload/gi,"onlo&#97;d").replace(/script/gi,"&#115;cript").replace(/onerror/gi,"on&#101;rror");return e===!0?i:i.replace(/>/g,"&gt;").replace(/</g,"&lt;")},e.utils.stripTags=function(e){return t.trim(e.replace(/(<([^>]+)>)/gi,""))},e.utils.EventEmitter=function(){this._mSubscriptions={},this._mSubscriptions[e.utils.EventEmitter.ALL_EVENT]=[],this.on=function(t,i,n){if(!e.utils.isFunction(i))throw new Error("Tried to listen to event "+t+" with non-function callback "+i);this._mSubscriptions[t]||(this._mSubscriptions[t]=[]),this._mSubscriptions[t].push({fn:i,ctx:n})},this.emit=function(t){var i,n,s;s=Array.prototype.slice.call(arguments,1);var o=this._mSubscriptions[t];if(o)for(o=o.slice(),i=0;i<o.length;i++)n=o[i].ctx||{},o[i].fn.apply(n,s);s.unshift(t);var r=this._mSubscriptions[e.utils.EventEmitter.ALL_EVENT].slice();for(i=0;i<r.length;i++)n=r[i].ctx||{},r[i].fn.apply(n,s)},this.unbind=function(t,e,i){if(!this._mSubscriptions[t])throw new Error("No subscribtions to unsubscribe for event "+t);var n,s=!1;for(n=0;n<this._mSubscriptions[t].length;n++)e&&this._mSubscriptions[t][n].fn!==e||i&&i!==this._mSubscriptions[t][n].ctx||(this._mSubscriptions[t].splice(n,1),s=!0);if(s===!1)throw new Error("Nothing to unbind for "+t)},this.off=this.unbind,this.trigger=this.emit},e.utils.EventEmitter.ALL_EVENT="__all",e.utils.DragListener=function(i,n){e.utils.EventEmitter.call(this),this._eElement=t(i),this._oDocument=t(document),this._eBody=t(document.body),this._nButtonCode=n||0,this._nDelay=200,this._nDistance=10,this._nX=0,this._nY=0,this._nOriginalX=0,this._nOriginalY=0,this._bDragging=!1,this._fMove=e.utils.fnBind(this.onMouseMove,this),this._fUp=e.utils.fnBind(this.onMouseUp,this),this._fDown=e.utils.fnBind(this.onMouseDown,this),this._eElement.on("mousedown touchstart",this._fDown)},e.utils.DragListener.timeout=null,e.utils.copy(e.utils.DragListener.prototype,{destroy:function(){this._eElement.unbind("mousedown touchstart",this._fDown),this._oDocument.unbind("mouseup touchend",this._fUp),this._eElement=null,this._oDocument=null,this._eBody=null},onMouseDown:function(t){if(t.preventDefault(),0==t.button||"touchstart"===t.type){var i=this._getCoordinates(t);this._nOriginalX=i.x,this._nOriginalY=i.y,this._oDocument.on("mousemove touchmove",this._fMove),this._oDocument.one("mouseup touchend",this._fUp),this._timeout=setTimeout(e.utils.fnBind(this._startDrag,this),this._nDelay)}},onMouseMove:function(t){if(null!=this._timeout){t.preventDefault();var e=this._getCoordinates(t);this._nX=e.x-this._nOriginalX,this._nY=e.y-this._nOriginalY,this._bDragging===!1&&(Math.abs(this._nX)>this._nDistance||Math.abs(this._nY)>this._nDistance)&&(clearTimeout(this._timeout),this._startDrag()),this._bDragging&&this.emit("drag",this._nX,this._nY,t)}},onMouseUp:function(t){null!=this._timeout&&(clearTimeout(this._timeout),this._eBody.removeClass("lm_dragging"),this._eElement.removeClass("lm_dragging"),this._oDocument.find("iframe").css("pointer-events",""),this._oDocument.unbind("mousemove touchmove",this._fMove),this._oDocument.unbind("mouseup touchend",this._fUp),this._bDragging===!0&&(this._bDragging=!1,this.emit("dragStop",t,this._nOriginalX+this._nX)))},_startDrag:function(){this._bDragging=!0,this._eBody.addClass("lm_dragging"),this._eElement.addClass("lm_dragging"),this._oDocument.find("iframe").css("pointer-events","none"),this.emit("dragStart",this._nOriginalX,this._nOriginalY)},_getCoordinates:function(t){return t=t.originalEvent&&t.originalEvent.touches?t.originalEvent.touches[0]:t,{x:t.pageX,y:t.pageY}}}),e.LayoutManager=function(i,n){if(!t||"function"!=typeof t.noConflict){var s="jQuery is missing as dependency for GoldenLayout. ";throw s+='Please either expose $ on GoldenLayout\'s scope (e.g. window) or add "jquery" to ',s+="your paths when using RequireJS/AMD",new Error(s)}e.utils.EventEmitter.call(this),this.isInitialised=!1,this._isFullPage=!1,this._resizeTimeoutId=null,this._components={"lm-react-component":e.utils.ReactComponentHandler},this._itemAreas=[],this._resizeFunction=e.utils.fnBind(this._onResize,this),this._unloadFunction=e.utils.fnBind(this._onUnload,this),this._maximisedItem=null,this._maximisePlaceholder=t('<div class="lm_maximise_place"></div>'),this._creationTimeoutPassed=!1,this._subWindowsCreated=!1,this._dragSources=[],this._updatingColumnsResponsive=!1,this._firstLoad=!0,this.width=null,this.height=null,this.root=null,this.openPopouts=[],this.selectedItem=null,this.isSubWindow=!1,this.eventHub=new e.utils.EventHub(this),this.config=this._createConfig(i),this.container=n,this.dropTargetIndicator=null,this.transitionIndicator=null,this.tabDropPlaceholder=t('<div class="lm_drop_tab_placeholder"></div>'),this.isSubWindow===!0&&t("body").css("visibility","hidden"),this._typeToItem={column:e.utils.fnBind(e.items.RowOrColumn,this,[!0]),row:e.utils.fnBind(e.items.RowOrColumn,this,[!1]),stack:e.items.Stack,component:e.items.Component}},e.LayoutManager.__lm=e,e.LayoutManager.minifyConfig=function(t){return(new e.utils.ConfigMinifier).minifyConfig(t)},e.LayoutManager.unminifyConfig=function(t){return(new e.utils.ConfigMinifier).unminifyConfig(t)},e.utils.copy(e.LayoutManager.prototype,{registerComponent:function(t,e){if("function"!=typeof e)throw new Error("Please register a constructor function");if(void 0!==this._components[t])throw new Error("Component "+t+" is already registered");this._components[t]=e},toConfig:function(t){var i,n,s;if(this.isInitialised===!1)throw new Error("Can't create config, layout not yet initialised");if(t&&!(t instanceof e.items.AbstractContentItem))throw new Error("Root must be a ContentItem");for(i={settings:e.utils.copy({},this.config.settings),dimensions:e.utils.copy({},this.config.dimensions),labels:e.utils.copy({},this.config.labels)},i.content=[],n=function(t,e){var i,s;for(i in e.config)"content"!==i&&(t[i]=e.config[i]);if(e.contentItems.length)for(t.content=[],s=0;s<e.contentItems.length;s++)t.content[s]={},n(t.content[s],e.contentItems[s])},t?n(i,{contentItems:[t]}):n(i,this.root),this._$reconcilePopoutWindows(),i.openPopouts=[],s=0;s<this.openPopouts.length;s++)i.openPopouts.push(this.openPopouts[s].toConfig());return i.maximisedItemId=this._maximisedItem?"__glMaximised":null,i},getComponent:function(t){if(void 0===this._components[t])throw new e.errors.ConfigurationError('Unknown component "'+t+'"');return this._components[t]},init:function(){return this._subWindowsCreated===!1&&(this._createSubWindows(),this._subWindowsCreated=!0),"loading"===document.readyState||null===document.body?void t(document).ready(e.utils.fnBind(this.init,this)):this.isSubWindow===!0&&this._creationTimeoutPassed===!1?(setTimeout(e.utils.fnBind(this.init,this),7),void(this._creationTimeoutPassed=!0)):(this.isSubWindow===!0&&this._adjustToWindowMode(),this._setContainer(),this.dropTargetIndicator=new e.controls.DropTargetIndicator(this.container),this.transitionIndicator=new e.controls.TransitionIndicator,this.updateSize(),this._create(this.config),this._bindEvents(),this.isInitialised=!0,this._adjustColumnsResponsive(),void this.emit("initialised"))},updateSize:function(t,e){2===arguments.length?(this.width=t,this.height=e):(this.width=this.container.width(),this.height=this.container.height()),this.isInitialised===!0&&(this.root.callDownwards("setSize",[this.width,this.height]),this._maximisedItem&&(this._maximisedItem.element.width(this.container.width()),this._maximisedItem.element.height(this.container.height()),this._maximisedItem.callDownwards("setSize")),this._adjustColumnsResponsive())},destroy:function(){this.isInitialised!==!1&&(this._onUnload(),t(window).off("resize",this._resizeFunction),t(window).off("unload beforeunload",this._unloadFunction),this.root.callDownwards("_$destroy",[],!0),this.root.contentItems=[],this.tabDropPlaceholder.remove(),this.dropTargetIndicator.destroy(),this.transitionIndicator.destroy(),this.eventHub.destroy(),this._dragSources.forEach(function(t){t._dragListener.destroy(),t._element=null,t._itemConfig=null,t._dragListener=null}),this._dragSources=[])},createContentItem:function(t,i){var n,s;if("string"!=typeof t.type)throw new e.errors.ConfigurationError("Missing parameter 'type'",t);if("react-component"===t.type&&(t.type="component",t.componentName="lm-react-component"),!this._typeToItem[t.type])throw n="Unknown type '"+t.type+"'. Valid types are "+e.utils.objectKeys(this._typeToItem).join(","),new e.errors.ConfigurationError(n);return"component"!==t.type||i instanceof e.items.Stack||!i||this.isSubWindow===!0&&i instanceof e.items.Root||(t={type:"stack",width:t.width,height:t.height,content:[t]}),s=new this._typeToItem[t.type](this,t,i)},createPopout:function(t,i,n,s){var o,r,a,h,l,c,d=t,m=t instanceof e.items.AbstractContentItem,u=this;if(n=n||null,m){for(d=this.toConfig(t).content,n=e.utils.getUniqueId(),h=t.parent,l=t;1===h.contentItems.length&&!h.isRoot;)h=h.parent,l=l.parent;h.addId(n),isNaN(s)&&(s=e.utils.indexOf(l,h.contentItems))}else d instanceof Array||(d=[d]);return!i&&m&&(o=window.screenX||window.screenLeft,r=window.screenY||window.screenTop,a=t.element.offset(),i={left:o+a.left,top:r+a.top,width:t.element.width(),height:t.element.height()}),i||m||(i={left:window.screenX||window.screenLeft+20,top:window.screenY||window.screenTop+20,width:500,height:309}),m&&t.remove(),c=new e.controls.BrowserPopout(d,i,n,s,this),c.on("initialised",function(){u.emit("windowOpened",c)}),c.on("closed",function(){u._$reconcilePopoutWindows()}),this.openPopouts.push(c),c},createDragSource:function(i,n){this.config.settings.constrainDragToContainer=!1;var s=new e.controls.DragSource(t(i),n,this);return this._dragSources.push(s),s},selectItem:function(t,e){if(this.config.settings.selectionEnabled!==!0)throw new Error("Please set selectionEnabled to true to use this feature");t!==this.selectedItem&&(null!==this.selectedItem&&this.selectedItem.deselect(),t&&e!==!0&&t.select(),this.selectedItem=t,this.emit("selectionChanged",t))},_$maximiseItem:function(t){null!==this._maximisedItem&&this._$minimiseItem(this._maximisedItem),this._maximisedItem=t,this._maximisedItem.addId("__glMaximised"),t.element.addClass("lm_maximised"),t.element.after(this._maximisePlaceholder),this.root.element.prepend(t.element),t.element.width(this.container.width()),t.element.height(this.container.height()),t.callDownwards("setSize"),this._maximisedItem.emit("maximised"),this.emit("stateChanged")},_$minimiseItem:function(t){t.element.removeClass("lm_maximised"),t.removeId("__glMaximised"),this._maximisePlaceholder.after(t.element),this._maximisePlaceholder.remove(),t.parent.callDownwards("setSize"),this._maximisedItem=null,t.emit("minimised"),this.emit("stateChanged")},_$closeWindow:function(){window.setTimeout(function(){window.close()},1)},_$getArea:function(t,e){var i,n,s=1/0,o=null;for(i=0;i<this._itemAreas.length;i++)n=this._itemAreas[i],t>n.x1&&t<n.x2&&e>n.y1&&e<n.y2&&s>n.surface&&(s=n.surface,o=n);return o},_$createRootItemAreas:function(){var t=50,e={y2:0,x2:0,y1:"y2",x1:"x2"};for(var i in e){var n=this.root._$getArea();n.side=i,e[i]?n[i]=n[e[i]]-t:n[i]=t,n.surface=(n.x2-n.x1)*(n.y2-n.y1),this._itemAreas.push(n)}},_$calculateItemAreas:function(){var t,i,n=this._getAllContentItems();if(this._itemAreas=[],1===n.length)return void this._itemAreas.push(this.root._$getArea());for(this._$createRootItemAreas(),t=0;t<n.length;t++)if(n[t].isStack&&(i=n[t]._$getArea(),null!==i))if(i instanceof Array)this._itemAreas=this._itemAreas.concat(i);else{this._itemAreas.push(i);var s={};e.utils.copy(s,i),e.utils.copy(s,i.contentItem._contentAreaDimensions.header.highlightArea),s.surface=(s.x2-s.x1)*(s.y2-s.y1),this._itemAreas.push(s)}},_$normalizeContentItem:function(i,n){if(!i)throw new Error("No content item defined");if(e.utils.isFunction(i)&&(i=i()),i instanceof e.items.AbstractContentItem)return i;if(t.isPlainObject(i)&&i.type){var s=this.createContentItem(i,n);return s.callDownwards("_$init"),s}throw new Error("Invalid contentItem")},_$reconcilePopoutWindows:function(){var t,e=[];for(t=0;t<this.openPopouts.length;t++)this.openPopouts[t].getWindow().closed===!1?e.push(this.openPopouts[t]):this.emit("windowClosed",this.openPopouts[t]);this.openPopouts.length!==e.length&&(this.emit("stateChanged"),this.openPopouts=e)},_getAllContentItems:function(){var t=[],e=function(i){if(t.push(i),i.contentItems instanceof Array)for(var n=0;n<i.contentItems.length;n++)e(i.contentItems[n])};return e(this.root),t},_bindEvents:function(){this._isFullPage&&t(window).resize(this._resizeFunction),t(window).on("unload beforeunload",this._unloadFunction)},_onResize:function(){clearTimeout(this._resizeTimeoutId),this._resizeTimeoutId=setTimeout(e.utils.fnBind(this.updateSize,this),100)},_createConfig:function(i){var n=e.utils.getQueryStringParam("gl-window");n&&(this.isSubWindow=!0,i=localStorage.getItem(n),i=JSON.parse(i),i=(new e.utils.ConfigMinifier).unminifyConfig(i),localStorage.removeItem(n)),i=t.extend(!0,{},e.config.defaultConfig,i);var s=function(t){for(var e in t)"props"!==e&&"object"==typeof t[e]?s(t[e]):"type"===e&&"react-component"===t[e]&&(t.type="component",t.componentName="lm-react-component")};return s(i),i.settings.hasHeaders===!1&&(i.dimensions.headerHeight=0),i},_adjustToWindowMode:function(){var i=t('<div class="lm_popin" title="'+this.config.labels.popin+'"><div class="lm_icon"></div><div class="lm_bg"></div></div>');i.click(e.utils.fnBind(function(){this.emit("popIn")},this)),document.title=e.utils.stripTags(this.config.content[0].title),t("head").append(t("body link, body style, template, .gl_keep")),this.container=t("body").html("").css("visibility","visible").append(i);document.body.offsetHeight;window.__glInstance=this},_createSubWindows:function(){var t,e;for(t=0;t<this.config.openPopouts.length;t++)e=this.config.openPopouts[t],this.createPopout(e.content,e.dimensions,e.parentId,e.indexInParent)},_setContainer:function(){var e=t(this.container||"body");if(0===e.length)throw new Error("GoldenLayout container not found");if(e.length>1)throw new Error("GoldenLayout more than one container element specified");e[0]===document.body&&(this._isFullPage=!0,t("html, body").css({height:"100%",margin:0,padding:0,overflow:"hidden"})),this.container=e},_create:function(t){var i;if(!(t.content instanceof Array))throw i=void 0===t.content?"Missing setting 'content' on top level of configuration":"Configuration parameter 'content' must be an array",new e.errors.ConfigurationError(i,t);if(t.content.length>1)throw i="Top level content can't contain more then one element.",new e.errors.ConfigurationError(i,t);this.root=new e.items.Root(this,{content:t.content},this.container),this.root.callDownwards("_$init"),"__glMaximised"===t.maximisedItemId&&this.root.getItemsById(t.maximisedItemId)[0].toggleMaximise()},_onUnload:function(){if(this.config.settings.closePopoutsOnUnload===!0)for(var t=0;t<this.openPopouts.length;t++)this.openPopouts[t].close()},_adjustColumnsResponsive:function(){if(!this._useResponsiveLayout()||this._updatingColumnsResponsive||!this.config.dimensions||!this.config.dimensions.minItemWidth||0===this.root.contentItems.length||!this.root.contentItems[0].isRow)return void(this._firstLoad=!1);this._firstLoad=!1;var t=this.root.contentItems[0].contentItems.length;if(!(t<=1)){var e=this.config.dimensions.minItemWidth,i=t*e;if(!(i<=this.width)){this._updatingColumnsResponsive=!0;for(var n=Math.max(Math.floor(this.width/e),1),s=t-n,o=this.root.contentItems[0],r=this._findAllStackContainers()[0],a=0;a<s;a++){var h=o.contentItems[o.contentItems.length-1];this._addChildContentItemsToContainer(r,h)}this._updatingColumnsResponsive=!1}}},_useResponsiveLayout:function(){return this.config.settings&&("always"==this.config.settings.responsiveMode||"onload"==this.config.settings.responsiveMode&&this._firstLoad)},_addChildContentItemsToContainer:function(t,i){"stack"===i.type?i.contentItems.forEach(function(e){t.addChild(e),i.removeChild(e,!0)}):i.contentItems.forEach(e.utils.fnBind(function(e){this._addChildContentItemsToContainer(t,e)},this))},_findAllStackContainers:function(){var t=[];return this._findAllStackContainersRecursive(t,this.root),t},_findAllStackContainersRecursive:function(t,i){i.contentItems.forEach(e.utils.fnBind(function(e){"stack"==e.type?t.push(e):e.isComponent||this._findAllStackContainersRecursive(t,e)},this))}}),function(){"function"==typeof define&&define.amd?define(["jquery"],function(i){return t=i,e.LayoutManager}):"object"==typeof exports?module.exports=e.LayoutManager:window.GoldenLayout=e.LayoutManager}(),e.config.itemDefaultConfig={isClosable:!0,reorderEnabled:!0,title:""},e.config.defaultConfig={openPopouts:[],settings:{hasHeaders:!0,constrainDragToContainer:!0,reorderEnabled:!0,selectionEnabled:!1,popoutWholeStack:!1,blockedPopoutsThrowError:!0,closePopoutsOnUnload:!0,showPopoutIcon:!0,showMaximiseIcon:!0,showCloseIcon:!0,responsiveMode:"onload",tabOverlapAllowance:0,reorderOnTabMenuClick:!0,tabControlOffset:10},dimensions:{borderWidth:5,borderGrabWidth:15,minItemHeight:10,minItemWidth:10,headerHeight:20,dragProxyWidth:300,dragProxyHeight:200},labels:{close:"close",maximise:"maximise",minimise:"minimise",popout:"open in new window",popin:"pop in",tabDropdown:"additional tabs"}},e.container.ItemContainer=function(i,n,s){e.utils.EventEmitter.call(this),this.width=null,this.height=null,this.title=i.componentName,this.parent=n,this.layoutManager=s,this.isHidden=!1,this._config=i,this._element=t(['<div class="lm_item_container">','<div class="lm_content"></div>',"</div>"].join("")),this._contentElement=this._element.find(".lm_content")},e.utils.copy(e.container.ItemContainer.prototype,{getElement:function(){return this._contentElement},hide:function(){this.emit("hide"),this.isHidden=!0,this._element.hide()},show:function(){this.emit("show"),this.isHidden=!1,this._element.show(),0==this.height&&0==this.width||this.emit("shown")},setSize:function(t,e){for(var i,n,s,o,r,a,h=this.parent,l=this;!h.isColumn&&!h.isRow;)if(l=h,h=h.parent,h.isRoot)return!1;for(s=h.isColumn?"height":"width",o="height"===s?e:t,i=this[s]*(1/(l.config[s]/100)),n=o/i*100,r=(l.config[s]-n)/(h.contentItems.length-1),a=0;a<h.contentItems.length;a++)h.contentItems[a]===l?h.contentItems[a].config[s]=n:h.contentItems[a].config[s]+=r;return h.callDownwards("setSize"),!0},close:function(){this._config.isClosable&&(this.emit("close"),this.parent.close())},getState:function(){return this._config.componentState},extendState:function(e){this.setState(t.extend(!0,this.getState(),e))},setState:function(t){this._config.componentState=t,this.parent.emitBubblingEvent("stateChanged")},setTitle:function(t){this.parent.setTitle(t)},_$setSize:function(t,e){if(t!==this.width||e!==this.height){this.width=t,this.height=e;var i=this._contentElement[0],n=i.offsetWidth-i.clientWidth,s=i.offsetHeight-i.clientHeight;this._contentElement.width(this.width-n).height(this.height-s),this.emit("resize")}}}),e.controls.BrowserPopout=function(t,i,n,s,o){e.utils.EventEmitter.call(this),this.isInitialised=!1,this._config=t,this._dimensions=i,this._parentId=n,this._indexInParent=s,this._layoutManager=o,this._popoutWindow=null,this._id=null,this._createWindow()},e.utils.copy(e.controls.BrowserPopout.prototype,{toConfig:function(){if(this.isInitialised===!1)throw new Error("Can't create config, layout not yet initialised");return{dimensions:{width:this.getGlInstance().width,height:this.getGlInstance().height,left:this._popoutWindow.screenX||this._popoutWindow.screenLeft,top:this._popoutWindow.screenY||this._popoutWindow.screenTop},content:this.getGlInstance().toConfig().content,parentId:this._parentId,indexInParent:this._indexInParent}},getGlInstance:function(){return this._popoutWindow.__glInstance},getWindow:function(){return this._popoutWindow},close:function(){if(this.getGlInstance())this.getGlInstance()._$closeWindow();else try{this.getWindow().close()}catch(t){}},popIn:function(){var e,i,n=this._indexInParent;this._parentId&&(e=t.extend(!0,{},this.getGlInstance().toConfig()).content[0],i=this._layoutManager.root.getItemsById(this._parentId)[0],i||(i=this._layoutManager.root.contentItems.length>0?this._layoutManager.root.contentItems[0]:this._layoutManager.root,n=0)),i.addChild(e,this._indexInParent),this.close()},_createWindow:function(){var i,n=this._createUrl(),s=Math.floor(1e6*Math.random()).toString(36),o=this._serializeWindowOptions({width:this._dimensions.width,height:this._dimensions.height,innerWidth:this._dimensions.width,innerHeight:this._dimensions.height,menubar:"no",toolbar:"no",location:"no",personalbar:"no",resizable:"yes",scrollbars:"no",status:"no"});if(this._popoutWindow=window.open(n,s,o),this._popoutWindow)t(this._popoutWindow).on("load",e.utils.fnBind(this._positionWindow,this)).on("unload beforeunload",e.utils.fnBind(this._onClose,this)),i=setInterval(e.utils.fnBind(function(){this._popoutWindow.__glInstance&&this._popoutWindow.__glInstance.isInitialised&&(this._onInitialised(),clearInterval(i))},this),10);else if(this._layoutManager.config.settings.blockedPopoutsThrowError===!0){var r=new Error("Popout blocked");throw r.type="popoutBlocked",r}},_serializeWindowOptions:function(t){var e,i=[];for(e in t)i.push(e+"="+t[e]);return i.join(",")},_createUrl:function(){var t,i={content:this._config},n="gl-window-config-"+e.utils.getUniqueId();i=(new e.utils.ConfigMinifier).minifyConfig(i);try{localStorage.setItem(n,JSON.stringify(i))}catch(s){throw new Error("Error while writing to localStorage "+s.toString())}return t=document.location.href.split("?"),1===t.length?t[0]+"?gl-window="+n:document.location.href+"&gl-window="+n},_positionWindow:function(){this._popoutWindow.moveTo(this._dimensions.left,this._dimensions.top),this._popoutWindow.focus()},_onInitialised:function(){this.isInitialised=!0,this.getGlInstance().on("popIn",this.popIn,this),this.emit("initialised")},_onClose:function(){setTimeout(e.utils.fnBind(this.emit,this,["closed"]),50)}}),e.controls.DragProxy=function(i,n,s,o,r,a){e.utils.EventEmitter.call(this),this._dragListener=s,this._layoutManager=o,this._contentItem=r,this._originalParent=a,this._area=null,this._lastValidArea=null,this._dragListener.on("drag",this._onDrag,this),this._dragListener.on("dragStop",this._onDrop,this),this.element=t(e.controls.DragProxy._template),a&&a._side&&(this._sided=a._sided,this.element.addClass("lm_"+a._side),["right","bottom"].indexOf(a._side)>=0&&this.element.find(".lm_content").after(this.element.find(".lm_header"))),this.element.css({left:i,top:n}),this.element.find(".lm_tab").attr("title",e.utils.stripTags(this._contentItem.config.title)),this.element.find(".lm_title").html(this._contentItem.config.title),this.childElementContainer=this.element.find(".lm_content"),this.childElementContainer.append(r.element),this._updateTree(),this._layoutManager._$calculateItemAreas(),this._setDimensions(),t(document.body).append(this.element);var h=this._layoutManager.container.offset();this._minX=h.left,this._minY=h.top,this._maxX=this._layoutManager.container.width()+this._minX,this._maxY=this._layoutManager.container.height()+this._minY,this._width=this.element.width(),this._height=this.element.height(),this._setDropPosition(i,n)},e.controls.DragProxy._template='<div class="lm_dragProxy"><div class="lm_header"><ul class="lm_tabs"><li class="lm_tab lm_active"><i class="lm_left"></i><span class="lm_title"></span><i class="lm_right"></i></li></ul></div><div class="lm_content"></div></div>',e.utils.copy(e.controls.DragProxy.prototype,{_onDrag:function(t,e,i){i=i.originalEvent&&i.originalEvent.touches?i.originalEvent.touches[0]:i;var n=i.pageX,s=i.pageY,o=n>this._minX&&n<this._maxX&&s>this._minY&&s<this._maxY;(o||this._layoutManager.config.settings.constrainDragToContainer!==!0)&&this._setDropPosition(n,s)},_setDropPosition:function(t,e){this.element.css({left:t,top:e}),this._area=this._layoutManager._$getArea(t,e),null!==this._area&&(this._lastValidArea=this._area,this._area.contentItem._$highlightDropZone(t,e,this._area))},_onDrop:function(){this._layoutManager.dropTargetIndicator.hide(),null!==this._area?this._area.contentItem._$onDrop(this._contentItem,this._area):null!==this._lastValidArea?this._lastValidArea.contentItem._$onDrop(this._contentItem,this._lastValidArea):this._originalParent?this._originalParent.addChild(this._contentItem):this._contentItem._$destroy(),this.element.remove(),this._layoutManager.emit("itemDropped",this._contentItem)},_updateTree:function(){this._contentItem.parent&&this._contentItem.parent.removeChild(this._contentItem,!0),this._contentItem._$setParent(this)},_setDimensions:function(){var t=this._layoutManager.config.dimensions,e=t.dragProxyWidth,i=t.dragProxyHeight;this.element.width(e),this.element.height(i),e-=this._sided?t.headerHeight:0,i-=this._sided?0:t.headerHeight,this.childElementContainer.width(e),this.childElementContainer.height(i),this._contentItem.element.width(e),this._contentItem.element.height(i),this._contentItem.callDownwards("_$show"),this._contentItem.callDownwards("setSize")}}),e.controls.DragSource=function(t,e,i){this._element=t,this._itemConfig=e,this._layoutManager=i,this._dragListener=null,this._createDragListener()},e.utils.copy(e.controls.DragSource.prototype,{_createDragListener:function(){null!==this._dragListener&&this._dragListener.destroy(),this._dragListener=new e.utils.DragListener(this._element),this._dragListener.on("dragStart",this._onDragStart,this),this._dragListener.on("dragStop",this._createDragListener,this)},_onDragStart:function(i,n){var s=this._itemConfig;e.utils.isFunction(s)&&(s=s());var o=this._layoutManager._$normalizeContentItem(t.extend(!0,{},s)),r=new e.controls.DragProxy(i,n,this._dragListener,this._layoutManager,o,null);this._layoutManager.transitionIndicator.transitionElements(this._element,r.element)}}),e.controls.DropTargetIndicator=function(){this.element=t(e.controls.DropTargetIndicator._template),t(document.body).append(this.element)},e.controls.DropTargetIndicator._template='<div class="lm_dropTargetIndicator"><div class="lm_inner"></div></div>',e.utils.copy(e.controls.DropTargetIndicator.prototype,{destroy:function(){this.element.remove()},highlight:function(t,e,i,n){this.highlightArea({x1:t,y1:e,x2:i,y2:n})},highlightArea:function(t){this.element.css({left:t.x1,top:t.y1,width:t.x2-t.x1,height:t.y2-t.y1}).show()},hide:function(){this.element.hide()}}),e.controls.Header=function(i,n){e.utils.EventEmitter.call(this),this.layoutManager=i,this.element=t(e.controls.Header._template),this.layoutManager.config.settings.selectionEnabled===!0&&(this.element.addClass("lm_selectable"),this.element.on("click touchstart",e.utils.fnBind(this._onHeaderClick,this))),this.tabsContainer=this.element.find(".lm_tabs"),this.tabDropdownContainer=this.element.find(".lm_tabdropdown_list"),this.tabDropdownContainer.hide(),this.controlsContainer=this.element.find(".lm_controls"),this.parent=n,this.parent.on("resize",this._updateTabSizes,this),this.tabs=[],this.activeContentItem=null,this.closeButton=null,this.tabDropdownButton=null,this.hideAdditionalTabsDropdown=e.utils.fnBind(this._hideAdditionalTabsDropdown,this),t(document).mouseup(this.hideAdditionalTabsDropdown),this._lastVisibleTabIndex=-1,this._tabControlOffset=this.layoutManager.config.settings.tabControlOffset,this._createControls()},e.controls.Header._template=['<div class="lm_header">','<ul class="lm_tabs"></ul>','<ul class="lm_controls"></ul>','<ul class="lm_tabdropdown_list"></ul>',"</div>"].join(""),e.utils.copy(e.controls.Header.prototype,{createTab:function(t,i){var n,s;for(s=0;s<this.tabs.length;s++)if(this.tabs[s].contentItem===t)return;return n=new e.controls.Tab(this,t),0===this.tabs.length?(this.tabs.push(n),void this.tabsContainer.append(n.element)):(void 0===i&&(i=this.tabs.length),i>0?this.tabs[i-1].element.after(n.element):this.tabs[0].element.before(n.element),this.tabs.splice(i,0,n),void this._updateTabSizes())},removeTab:function(t){for(var e=0;e<this.tabs.length;e++)if(this.tabs[e].contentItem===t)return this.tabs[e]._$destroy(),void this.tabs.splice(e,1);throw new Error("contentItem is not controlled by this header")},setActiveContentItem:function(t){var e,i,n,s;for(e=0;e<this.tabs.length;e++)n=this.tabs[e].contentItem===t,this.tabs[e].setActive(n),n===!0&&(this.activeContentItem=t,this.parent.config.activeItemIndex=e);if(this.layoutManager.config.settings.reorderOnTabMenuClick&&this._lastVisibleTabIndex!==-1&&this.parent.config.activeItemIndex>this._lastVisibleTabIndex){for(s=this.tabs[this.parent.config.activeItemIndex],i=this.parent.config.activeItemIndex;i>0;i--)this.tabs[i]=this.tabs[i-1];this.tabs[0]=s,this.parent.config.activeItemIndex=0}this._updateTabSizes(),this.parent.emitBubblingEvent("stateChanged")},position:function(t){var e=this.parent._header.show;return e&&!this.parent._side&&(e="top"),void 0!==t&&this.parent._header.show!=t&&(this.parent._header.show=t,this.parent._setupHeaderPosition()),e},_$setClosable:function(t){return!(!this.closeButton||!this._isClosable())&&(this.closeButton.element[t?"show":"hide"](),!0)},_$destroy:function(){this.emit("destroy",this);for(var e=0;e<this.tabs.length;e++)this.tabs[e]._$destroy();t(document).off("mouseup",this.hideAdditionalTabsDropdown),this.element.remove()},_getHeaderSetting:function(t){if(t in this.parent._header)return this.parent._header[t]},_createControls:function(){var t,i,n,s,o,r,a,h,l;l=e.utils.fnBind(this._showAdditionalTabsDropdown,this),h=this.layoutManager.config.labels.tabDropdown,this.tabDropdownButton=new e.controls.HeaderButton(this,h,"lm_tabdropdown",l),this.tabDropdownButton.element.hide(),this._getHeaderSetting("popout")&&(i=e.utils.fnBind(this._onPopoutClick,this),n=this._getHeaderSetting("popout"),new e.controls.HeaderButton(this,n,"lm_popout",i)),
this._getHeaderSetting("maximise")&&(r=e.utils.fnBind(this.parent.toggleMaximise,this.parent),s=this._getHeaderSetting("maximise"),o=this._getHeaderSetting("minimise"),a=new e.controls.HeaderButton(this,s,"lm_maximise",r),this.parent.on("maximised",function(){a.element.attr("title",o)}),this.parent.on("minimised",function(){a.element.attr("title",s)})),this._isClosable()&&(t=e.utils.fnBind(this.parent.remove,this.parent),n=this._getHeaderSetting("close"),this.closeButton=new e.controls.HeaderButton(this,n,"lm_close",t))},_showAdditionalTabsDropdown:function(){this.tabDropdownContainer.show()},_hideAdditionalTabsDropdown:function(t){this.tabDropdownContainer.hide()},_isClosable:function(){return this.parent.config.isClosable&&this.layoutManager.config.settings.showCloseIcon},_onPopoutClick:function(){this.layoutManager.config.settings.popoutWholeStack===!0?this.parent.popout():this.activeContentItem.popout()},_onHeaderClick:function(t){t.target===this.element[0]&&this.parent.select()},_updateTabSizes:function(t){if(0!==this.tabs.length){this.tabDropdownButton.element.toggle(t===!0);var e=function(t){return t?"width":"height"};this.element.css(e(!this.parent._sided),""),this.element[e(this.parent._sided)](this.layoutManager.config.dimensions.headerHeight);var i,n,s,o,r,a=this.element.outerWidth()-this.controlsContainer.outerWidth()-this._tabControlOffset,h=0,l=0,c=0,d=this.layoutManager.config.settings.tabOverlapAllowance,m=!1,u=this.activeContentItem?this.tabs.indexOf(this.activeContentItem.tab):0,g=this.tabs[u];for(this.parent._sided&&(a=this.element.outerHeight()-this.controlsContainer.outerHeight()-this._tabControlOffset),this._lastVisibleTabIndex=-1,n=0;n<this.tabs.length;n++)if(i=this.tabs[n].element,this.tabsContainer.append(i),r=i.outerWidth()+parseInt(i.css("margin-right"),10),h+=r,l=u<=n?h:h+g.element.outerWidth()+parseInt(g.element.css("margin-right"),10),l>a){if(m)n===u&&(i.css({"z-index":"auto","margin-left":""}),this.tabsContainer.append(i));else if(c=u>0&&u<=n?(l-a)/(n-1):(l-a)/n,c<d){for(s=0;s<=n;s++)o=s!==u&&0!==s?"-"+c+"px":"",this.tabs[s].element.css({"z-index":n-s,"margin-left":o});this._lastVisibleTabIndex=n,this.tabsContainer.append(i)}else m=!0;if(m&&n!==u){if(!t)return void this._updateTabSizes(!0);i.css({"z-index":"auto","margin-left":""}),this.tabDropdownContainer.append(i)}}else this._lastVisibleTabIndex=n,i.css({"z-index":"auto","margin-left":""}),this.tabsContainer.append(i)}}}),e.controls.HeaderButton=function(e,i,n,s){this._header=e,this.element=t('<li class="'+n+'" title="'+i+'"></li>'),this._header.on("destroy",this._$destroy,this),this._action=s,this.element.on("click touchstart",this._action),this._header.controlsContainer.append(this.element)},e.utils.copy(e.controls.HeaderButton.prototype,{_$destroy:function(){this.element.off(),this.element.remove()}}),e.controls.Splitter=function(t,i,n){this._isVertical=t,this._size=i,this._grabSize=n<i?i:n,this.element=this._createElement(),this._dragListener=new e.utils.DragListener(this.element)},e.utils.copy(e.controls.Splitter.prototype,{on:function(t,e,i){this._dragListener.on(t,e,i)},_$destroy:function(){this.element.remove()},_createElement:function(){var e=t('<div class="lm_drag_handle"></div>'),i=t('<div class="lm_splitter"></div>');i.append(e);var n=this._grabSize-this._size,s=n/2;return this._isVertical?(e.css("top",-s),e.css("height",this._size+n),i.addClass("lm_vertical"),i.height(this._size)):(e.css("left",-s),e.css("width",this._size+n),i.addClass("lm_horizontal"),i.width(this._size)),i}}),e.controls.Tab=function(i,n){this.header=i,this.contentItem=n,this.element=t(e.controls.Tab._template),this.titleElement=this.element.find(".lm_title"),this.closeElement=this.element.find(".lm_close_tab"),this.closeElement[n.config.isClosable?"show":"hide"](),this.isActive=!1,this.setTitle(n.config.title),this.contentItem.on("titleChanged",this.setTitle,this),this._layoutManager=this.contentItem.layoutManager,this._layoutManager.config.settings.reorderEnabled===!0&&n.config.reorderEnabled===!0&&(this._dragListener=new e.utils.DragListener(this.element),this._dragListener.on("dragStart",this._onDragStart,this),this.contentItem.on("destroy",this._dragListener.destroy,this._dragListener)),this._onTabClickFn=e.utils.fnBind(this._onTabClick,this),this._onCloseClickFn=e.utils.fnBind(this._onCloseClick,this),this.element.on("mousedown touchstart",this._onTabClickFn),this.contentItem.config.isClosable?(this.closeElement.on("click touchstart",this._onCloseClickFn),this.closeElement.on("mousedown",this._onCloseMousedown)):this.closeElement.remove(),this.contentItem.tab=this,this.contentItem.emit("tab",this),this.contentItem.layoutManager.emit("tabCreated",this),this.contentItem.isComponent&&(this.contentItem.container.tab=this,this.contentItem.container.emit("tab",this))},e.controls.Tab._template='<li class="lm_tab"><i class="lm_left"></i><span class="lm_title"></span><div class="lm_close_tab"></div><i class="lm_right"></i></li>',e.utils.copy(e.controls.Tab.prototype,{setTitle:function(t){this.element.attr("title",e.utils.stripTags(t)),this.titleElement.html(t)},setActive:function(t){t!==this.isActive&&(this.isActive=t,t?this.element.addClass("lm_active"):this.element.removeClass("lm_active"))},_$destroy:function(){this.element.off("mousedown touchstart",this._onTabClickFn),this.closeElement.off("click touchstart",this._onCloseClickFn),this._dragListener&&(this.contentItem.off("destroy",this._dragListener.destroy,this._dragListener),this._dragListener.off("dragStart",this._onDragStart),this._dragListener=null),this.element.remove()},_onDragStart:function(t,i){this.contentItem.parent.isMaximised===!0&&this.contentItem.parent.toggleMaximise(),new e.controls.DragProxy(t,i,this._dragListener,this._layoutManager,this.contentItem,this.header.parent)},_onTabClick:function(t){if(0===t.button||"touchstart"===t.type){var e=this.header.parent.getActiveContentItem();this.contentItem!==e&&this.header.parent.setActiveContentItem(this.contentItem)}else 1===t.button&&this.contentItem.config.isClosable&&this._onCloseClick(t)},_onCloseClick:function(t){t.stopPropagation(),this.header.parent.removeChild(this.contentItem)},_onCloseMousedown:function(t){t.stopPropagation()}}),e.controls.TransitionIndicator=function(){this._element=t('<div class="lm_transition_indicator"></div>'),t(document.body).append(this._element),this._toElement=null,this._fromDimensions=null,this._totalAnimationDuration=200,this._animationStartTime=null},e.utils.copy(e.controls.TransitionIndicator.prototype,{destroy:function(){this._element.remove()},transitionElements:function(t,e){},_nextAnimationFrame:function(){var t,i=this._measure(this._toElement),n=(e.utils.now()-this._animationStartTime)/this._totalAnimationDuration,s={};if(n>=1)return void this._element.hide();i.opacity=0;for(t in this._fromDimensions)s[t]=this._fromDimensions[t]+(i[t]-this._fromDimensions[t])*n;this._element.css(s),e.utils.animFrame(e.utils.fnBind(this._nextAnimationFrame,this))},_measure:function(t){var e=t.offset();return{left:e.left,top:e.top,width:t.outerWidth(),height:t.outerHeight()}}}),e.errors.ConfigurationError=function(t,e){Error.call(this),this.name="Configuration Error",this.message=t,this.node=e},e.errors.ConfigurationError.prototype=new Error,e.items.AbstractContentItem=function(t,i,n){e.utils.EventEmitter.call(this),this.config=this._extendItemNode(i),this.type=i.type,this.contentItems=[],this.parent=n,this.isInitialised=!1,this.isMaximised=!1,this.isRoot=!1,this.isRow=!1,this.isColumn=!1,this.isStack=!1,this.isComponent=!1,this.layoutManager=t,this._pendingEventPropagations={},this._throttledEvents=["stateChanged"],this.on(e.utils.EventEmitter.ALL_EVENT,this._propagateEvent,this),i.content&&this._createContentItems(i)},e.utils.copy(e.items.AbstractContentItem.prototype,{setSize:function(){throw new Error("Abstract Method")},callDownwards:function(t,e,i,n){var s;for(i!==!0&&n!==!0&&this[t].apply(this,e||[]),s=0;s<this.contentItems.length;s++)this.contentItems[s].callDownwards(t,e,i);i===!0&&n!==!0&&this[t].apply(this,e||[])},removeChild:function(t,i){var n=e.utils.indexOf(t,this.contentItems);if(n===-1)throw new Error("Can't remove child item. Unknown content item");i!==!0&&this.contentItems[n]._$destroy(),this.contentItems.splice(n,1),this.config.content.splice(n,1),this.contentItems.length>0?this.callDownwards("setSize"):this instanceof e.items.Root||this.config.isClosable!==!0||this.parent.removeChild(this)},addChild:function(t,e){void 0===e&&(e=this.contentItems.length),this.contentItems.splice(e,0,t),void 0===this.config.content&&(this.config.content=[]),this.config.content.splice(e,0,t.config),t.parent=this,t.parent.isInitialised===!0&&t.isInitialised===!1&&t._$init()},replaceChild:function(t,i,n){i=this.layoutManager._$normalizeContentItem(i);var s=e.utils.indexOf(t,this.contentItems),o=t.element[0].parentNode;if(s===-1)throw new Error("Can't replace child. oldChild is not child of this");o.replaceChild(i.element[0],t.element[0]),n===!0&&(t.parent=null,t._$destroy()),this.contentItems[s]=i,i.parent=this,this.isStack&&(this.header.tabs[s].contentItem=i),i.parent.isInitialised===!0&&i.isInitialised===!1&&i._$init(),this.callDownwards("setSize")},remove:function(){this.parent.removeChild(this)},popout:function(){var t=this.layoutManager.createPopout(this);return this.emitBubblingEvent("stateChanged"),t},toggleMaximise:function(t){t&&t.preventDefault(),this.isMaximised===!0?this.layoutManager._$minimiseItem(this):this.layoutManager._$maximiseItem(this),this.isMaximised=!this.isMaximised,this.emitBubblingEvent("stateChanged")},select:function(){this.layoutManager.selectedItem!==this&&(this.layoutManager.selectItem(this,!0),this.element.addClass("lm_selected"))},deselect:function(){this.layoutManager.selectedItem===this&&(this.layoutManager.selectedItem=null,this.element.removeClass("lm_selected"))},setTitle:function(t){this.config.title=t,this.emit("titleChanged",t),this.emit("stateChanged")},hasId:function(t){return!!this.config.id&&("string"==typeof this.config.id?this.config.id===t:this.config.id instanceof Array?e.utils.indexOf(t,this.config.id)!==-1:void 0)},addId:function(t){this.hasId(t)||(this.config.id?"string"==typeof this.config.id?this.config.id=[this.config.id,t]:this.config.id instanceof Array&&this.config.id.push(t):this.config.id=t)},removeId:function(t){if(!this.hasId(t))throw new Error("Id not found");if("string"==typeof this.config.id)delete this.config.id;else if(this.config.id instanceof Array){var i=e.utils.indexOf(t,this.config.id);this.config.id.splice(i,1)}},getItemsByFilter:function(t){var e=[],i=function(n){for(var s=0;s<n.contentItems.length;s++)t(n.contentItems[s])===!0&&e.push(n.contentItems[s]),i(n.contentItems[s])};return i(this),e},getItemsById:function(t){return this.getItemsByFilter(function(i){return i.config.id instanceof Array?e.utils.indexOf(t,i.config.id)!==-1:i.config.id===t})},getItemsByType:function(t){return this._$getItemsByProperty("type",t)},getComponentsByName:function(t){var e,i=this._$getItemsByProperty("componentName",t),n=[];for(e=0;e<i.length;e++)n.push(i[e].instance);return n},_$getItemsByProperty:function(t,e){return this.getItemsByFilter(function(i){return i[t]===e})},_$setParent:function(t){this.parent=t},_$highlightDropZone:function(t,e,i){this.layoutManager.dropTargetIndicator.highlightArea(i)},_$onDrop:function(t){this.addChild(t)},_$hide:function(){this._callOnActiveComponents("hide"),this.element.hide(),this.layoutManager.updateSize()},_$show:function(){this._callOnActiveComponents("show"),this.element.show(),this.layoutManager.updateSize()},_callOnActiveComponents:function(t){var e,i,n=this.getItemsByType("stack");for(i=0;i<n.length;i++)e=n[i].getActiveContentItem(),e&&e.isComponent&&e.container[t]()},_$destroy:function(){this.emitBubblingEvent("beforeItemDestroyed"),this.callDownwards("_$destroy",[],!0,!0),this.element.remove(),this.emitBubblingEvent("itemDestroyed")},_$getArea:function(t){t=t||this.element;var e=t.offset(),i=t.width(),n=t.height();return{x1:e.left,y1:e.top,x2:e.left+i,y2:e.top+n,surface:i*n,contentItem:this}},_$init:function(){var t;for(this.setSize(),t=0;t<this.contentItems.length;t++)this.childElementContainer.append(this.contentItems[t].element);this.isInitialised=!0,this.emitBubblingEvent("itemCreated"),this.emitBubblingEvent(this.type+"Created")},emitBubblingEvent:function(t){var i=new e.utils.BubblingEvent(t,this);this.emit(t,i)},_createContentItems:function(t){var i,n;if(!(t.content instanceof Array))throw new e.errors.ConfigurationError("content must be an Array",t);for(n=0;n<t.content.length;n++)i=this.layoutManager.createContentItem(t.content[n],this),this.contentItems.push(i)},_extendItemNode:function(t){for(var i in e.config.itemDefaultConfig)void 0===t[i]&&(t[i]=e.config.itemDefaultConfig[i]);return t},_propagateEvent:function(t,i){i instanceof e.utils.BubblingEvent&&i.isPropagationStopped===!1&&this.isInitialised===!0&&(this.isRoot===!1&&this.parent?this.parent.emit.apply(this.parent,Array.prototype.slice.call(arguments,0)):this._scheduleEventPropagationToLayoutManager(t,i))},_scheduleEventPropagationToLayoutManager:function(t,i){e.utils.indexOf(t,this._throttledEvents)===-1?this.layoutManager.emit(t,i.origin):this._pendingEventPropagations[t]!==!0&&(this._pendingEventPropagations[t]=!0,e.utils.animFrame(e.utils.fnBind(this._propagateEventToLayoutManager,this,[t,i])))},_propagateEventToLayoutManager:function(t,e){this._pendingEventPropagations[t]=!1,this.layoutManager.emit(t,e)}}),e.items.Component=function(i,n,s){e.items.AbstractContentItem.call(this,i,n,s);var o=i.getComponent(this.config.componentName),r=t.extend(!0,{},this.config.componentState||{});r.componentName=this.config.componentName,this.componentName=this.config.componentName,""===this.config.title&&(this.config.title=this.config.componentName),this.isComponent=!0,this.container=new e.container.ItemContainer(this.config,this,i),this.instance=new o(this.container,r),this.element=this.container._element},e.utils.extend(e.items.Component,e.items.AbstractContentItem),e.utils.copy(e.items.Component.prototype,{close:function(){this.parent.removeChild(this)},setSize:function(){this.element.is(":visible")&&this.container._$setSize(this.element.width(),this.element.height())},_$init:function(){e.items.AbstractContentItem.prototype._$init.call(this),this.container.emit("open")},_$hide:function(){this.container.hide(),e.items.AbstractContentItem.prototype._$hide.call(this)},_$show:function(){this.container.show(),e.items.AbstractContentItem.prototype._$show.call(this)},_$shown:function(){this.container.shown(),e.items.AbstractContentItem.prototype._$shown.call(this)},_$destroy:function(){this.container.emit("destroy",this),e.items.AbstractContentItem.prototype._$destroy.call(this)},_$getArea:function(){return null}}),e.items.Root=function(i,n,s){e.items.AbstractContentItem.call(this,i,n,null),this.isRoot=!0,this.type="root",this.element=t('<div class="lm_goldenlayout lm_item lm_root"></div>'),this.childElementContainer=this.element,this._containerElement=s,this._containerElement.append(this.element)},e.utils.extend(e.items.Root,e.items.AbstractContentItem),e.utils.copy(e.items.Root.prototype,{addChild:function(t){if(this.contentItems.length>0)throw new Error("Root node can only have a single child");t=this.layoutManager._$normalizeContentItem(t,this),this.childElementContainer.append(t.element),e.items.AbstractContentItem.prototype.addChild.call(this,t),this.callDownwards("setSize"),this.emitBubblingEvent("stateChanged")},setSize:function(t,e){t="undefined"==typeof t?this._containerElement.width():t,e="undefined"==typeof e?this._containerElement.height():e,this.element.width(t),this.element.height(e),this.contentItems[0]&&(this.contentItems[0].element.width(t),this.contentItems[0].element.height(e))},_$highlightDropZone:function(t,i,n){this.layoutManager.tabDropPlaceholder.remove(),e.items.AbstractContentItem.prototype._$highlightDropZone.apply(this,arguments)},_$onDrop:function(t,i){var n;if(t.isComponent&&(n=this.layoutManager.createContentItem({type:"stack",header:t.config.header||{}},this),n._$init(),n.addChild(t),t=n),this.contentItems.length){var s="x"==i.side[0]?"row":"column",o="x"==i.side[0]?"width":"height",r="2"==i.side[1],a=this.contentItems[0];if(!a instanceof e.items.RowOrColumn||a.type!=s){var h=this.layoutManager.createContentItem({type:s},this);this.replaceChild(a,h),h.addChild(t,r?0:void 0,!0),h.addChild(a,r?void 0:0,!0),a.config[o]=50,t.config[o]=50,h.callDownwards("setSize")}else{var l=a.contentItems[r?0:a.contentItems.length-1];a.addChild(t,r?0:void 0,!0),l.config[o]*=.5,t.config[o]=l.config[o],a.callDownwards("setSize")}}else this.addChild(t)}}),e.items.RowOrColumn=function(i,n,s,o){e.items.AbstractContentItem.call(this,n,s,o),this.isRow=!i,this.isColumn=i,this.element=t('<div class="lm_item lm_'+(i?"column":"row")+'"></div>'),this.childElementContainer=this.element,this._splitterSize=n.config.dimensions.borderWidth,this._splitterGrabSize=n.config.dimensions.borderGrabWidth,this._isColumn=i,this._dimension=i?"height":"width",this._splitter=[],this._splitterPosition=null,this._splitterMinPosition=null,this._splitterMaxPosition=null},e.utils.extend(e.items.RowOrColumn,e.items.AbstractContentItem),e.utils.copy(e.items.RowOrColumn.prototype,{addChild:function(t,i,n){var s,o,r,a;if(t=this.layoutManager._$normalizeContentItem(t,this),void 0===i&&(i=this.contentItems.length),this.contentItems.length>0?(a=this._createSplitter(Math.max(0,i-1)).element,i>0?(this.contentItems[i-1].element.after(a),a.after(t.element)):(this.contentItems[0].element.before(a),a.before(t.element))):this.childElementContainer.append(t.element),e.items.AbstractContentItem.prototype.addChild.call(this,t,i),s=1/this.contentItems.length*100,n===!0)return void this.emitBubblingEvent("stateChanged");for(r=0;r<this.contentItems.length;r++)this.contentItems[r]===t?t.config[this._dimension]=s:(o=this.contentItems[r].config[this._dimension]*=(100-s)/100,this.contentItems[r].config[this._dimension]=o);this.callDownwards("setSize"),this.emitBubblingEvent("stateChanged")},removeChild:function(t,i){var n,s,o=t.config[this._dimension],r=e.utils.indexOf(t,this.contentItems),a=Math.max(r-1,0);if(r===-1)throw new Error("Can't remove child. ContentItem is not child of this Row or Column");for(this._splitter[a]&&(this._splitter[a]._$destroy(),this._splitter.splice(a,1)),n=0;n<this.contentItems.length;n++)this.contentItems[n]!==t&&(this.contentItems[n].config[this._dimension]+=o/(this.contentItems.length-1));e.items.AbstractContentItem.prototype.removeChild.call(this,t,i),1===this.contentItems.length&&this.config.isClosable===!0?(s=this.contentItems[0],this.contentItems=[],this.parent.replaceChild(this,s,!0)):(this.callDownwards("setSize"),this.emitBubblingEvent("stateChanged"))},replaceChild:function(t,i){var n=t.config[this._dimension];e.items.AbstractContentItem.prototype.replaceChild.call(this,t,i),i.config[this._dimension]=n,this.callDownwards("setSize"),this.emitBubblingEvent("stateChanged")},setSize:function(){this.contentItems.length>0&&(this._calculateRelativeSizes(),this._setAbsoluteSizes()),this.emitBubblingEvent("stateChanged"),this.emit("resize")},_$init:function(){if(this.isInitialised!==!0){var t;for(e.items.AbstractContentItem.prototype._$init.call(this),t=0;t<this.contentItems.length-1;t++)this.contentItems[t].element.after(this._createSplitter(t).element)}},_setAbsoluteSizes:function(){var t,e=this._calculateAbsoluteSizes();for(t=0;t<this.contentItems.length;t++)e.additionalPixel-t>0&&e.itemSizes[t]++,this._isColumn?(this.contentItems[t].element.width(e.totalWidth),this.contentItems[t].element.height(e.itemSizes[t])):(this.contentItems[t].element.width(e.itemSizes[t]),this.contentItems[t].element.height(e.totalHeight))},_calculateAbsoluteSizes:function(){var t,e,i,n=(this.contentItems.length-1)*this._splitterSize,s=this.element.width(),o=this.element.height(),r=0,a=[];for(this._isColumn?o-=n:s-=n,t=0;t<this.contentItems.length;t++)i=this._isColumn?Math.floor(o*(this.contentItems[t].config.height/100)):Math.floor(s*(this.contentItems[t].config.width/100)),r+=i,a.push(i);return e=Math.floor((this._isColumn?o:s)-r),{itemSizes:a,additionalPixel:e,totalWidth:s,totalHeight:o}},_calculateRelativeSizes:function(){var t,e=0,i=[],n=this._isColumn?"height":"width";for(t=0;t<this.contentItems.length;t++)void 0!==this.contentItems[t].config[n]?e+=this.contentItems[t].config[n]:i.push(this.contentItems[t]);if(100===Math.round(e))return void this._respectMinItemWidth();if(Math.round(e)<100&&i.length>0){for(t=0;t<i.length;t++)i[t].config[n]=(100-e)/i.length;return void this._respectMinItemWidth()}if(Math.round(e)>100)for(t=0;t<i.length;t++)i[t].config[n]=50,e+=50;for(t=0;t<this.contentItems.length;t++)this.contentItems[t].config[n]=this.contentItems[t].config[n]/e*100;this._respectMinItemWidth()},_respectMinItemWidth:function(){var t,e,i,n=this.layoutManager.config.dimensions?this.layoutManager.config.dimensions.minItemWidth||0:0,s=null,o=[],r=0,a=0,h=0,l=0,c=null,d=[];if(!(this._isColumn||!n||this.contentItems.length<=1)){s=this._calculateAbsoluteSizes();for(var m=0;m<this.contentItems.length;m++)c=this.contentItems[m],l=s.itemSizes[m],l<n?(a+=n-l,i={width:n}):(r+=l-n,i={width:l},o.push(i)),d.push(i);if(!(0===a||a>r)){for(t=a/r,h=a,m=0;m<o.length;m++)i=o[m],e=Math.round((i.width-n)*t),h-=e,i.width-=e;for(0!==h&&(d[d.length-1].width-=h),m=0;m<this.contentItems.length;m++)this.contentItems[m].config.width=d[m].width/s.totalWidth*100}}},_createSplitter:function(t){var i;return i=new e.controls.Splitter(this._isColumn,this._splitterSize,this._splitterGrabSize),i.on("drag",e.utils.fnBind(this._onSplitterDrag,this,[i]),this),i.on("dragStop",e.utils.fnBind(this._onSplitterDragStop,this,[i]),this),i.on("dragStart",e.utils.fnBind(this._onSplitterDragStart,this,[i]),this),this._splitter.splice(t,0,i),i},_getItemsForSplitter:function(t){var i=e.utils.indexOf(t,this._splitter);return{before:this.contentItems[i],after:this.contentItems[i+1]}},_getMinimumDimensions:function(t){for(var e=0,i=0,n=0;n<t.length;++n)e=Math.max(t[n].minWidth||0,e),i=Math.max(t[n].minHeight||0,i);return{horizontal:e,vertical:i}},_onSplitterDragStart:function(t){var e=this._getItemsForSplitter(t),i=this.layoutManager.config.dimensions[this._isColumn?"minItemHeight":"minItemWidth"],n=this._getMinimumDimensions(e.before.config.content),s=this._isColumn?n.vertical:n.horizontal,o=this._getMinimumDimensions(e.after.config.content),r=this._isColumn?o.vertical:o.horizontal;this._splitterPosition=0,this._splitterMinPosition=-1*(e.before.element[this._dimension]()-(s||i)),this._splitterMaxPosition=e.after.element[this._dimension]()-(r||i)},_onSplitterDrag:function(t,e,i){var n=this._isColumn?i:e;n>this._splitterMinPosition&&n<this._splitterMaxPosition&&(this._splitterPosition=n,t.element.css(this._isColumn?"top":"left",n))},_onSplitterDragStop:function(t){var i=this._getItemsForSplitter(t),n=i.before.element[this._dimension](),s=i.after.element[this._dimension](),o=(this._splitterPosition+n)/(n+s),r=i.before.config[this._dimension]+i.after.config[this._dimension];i.before.config[this._dimension]=o*r,i.after.config[this._dimension]=(1-o)*r,t.element.css({top:0,left:0}),e.utils.animFrame(e.utils.fnBind(this.callDownwards,this,["setSize"]))}}),e.items.Stack=function(i,n,s){e.items.AbstractContentItem.call(this,i,n,s),this.element=t('<div class="lm_item lm_stack"></div>'),this._activeContentItem=null;var o=i.config;this._header={show:o.settings.hasHeaders===!0&&n.hasHeaders!==!1,popout:o.settings.showPopoutIcon&&o.labels.popout,maximise:o.settings.showMaximiseIcon&&o.labels.maximise,close:o.settings.showCloseIcon&&o.labels.close,minimise:o.labels.minimise},o.header&&e.utils.copy(this._header,o.header),n.header&&e.utils.copy(this._header,n.header),n.content&&n.content[0]&&n.content[0].header&&e.utils.copy(this._header,n.content[0].header),this._dropZones={},this._dropSegment=null,this._contentAreaDimensions=null,this._dropIndex=null,this.isStack=!0,this.childElementContainer=t('<div class="lm_items"></div>'),this.header=new e.controls.Header(i,this),this.element.append(this.header.element),this.element.append(this.childElementContainer),this._setupHeaderPosition(),this._$validateClosability()},e.utils.extend(e.items.Stack,e.items.AbstractContentItem),e.utils.copy(e.items.Stack.prototype,{setSize:function(){var t,e=this._header.show?this.layoutManager.config.dimensions.headerHeight:0,i=this.element.width()-(this._sided?e:0),n=this.element.height()-(this._sided?0:e);for(this.childElementContainer.width(i),this.childElementContainer.height(n),t=0;t<this.contentItems.length;t++)this.contentItems[t].element.width(i).height(n);this.emit("resize"),this.emitBubblingEvent("stateChanged")},_$init:function(){var t,i;if(this.isInitialised!==!0){for(e.items.AbstractContentItem.prototype._$init.call(this),t=0;t<this.contentItems.length;t++)this.header.createTab(this.contentItems[t]),this.contentItems[t]._$hide();if(this.contentItems.length>0){if(i=this.contentItems[this.config.activeItemIndex||0],!i)throw new Error("Configured activeItemIndex out of bounds");this.setActiveContentItem(i)}}},setActiveContentItem:function(t){if(e.utils.indexOf(t,this.contentItems)===-1)throw new Error("contentItem is not a child of this stack");null!==this._activeContentItem&&this._activeContentItem._$hide(),this._activeContentItem=t,this.header.setActiveContentItem(t),t._$show(),this.emit("activeContentItemChanged",t),this.layoutManager.emit("activeContentItemChanged",t),this.emitBubblingEvent("stateChanged")},getActiveContentItem:function(){return this.header.activeContentItem},addChild:function(t,i){t=this.layoutManager._$normalizeContentItem(t,this),e.items.AbstractContentItem.prototype.addChild.call(this,t,i),this.childElementContainer.append(t.element),this.header.createTab(t,i),this.setActiveContentItem(t),this.callDownwards("setSize"),this._$validateClosability(),this.emitBubblingEvent("stateChanged")},removeChild:function(t,i){var n=e.utils.indexOf(t,this.contentItems);e.items.AbstractContentItem.prototype.removeChild.call(this,t,i),this.header.removeTab(t),this.header.activeContentItem===t&&(this.contentItems.length>0?this.setActiveContentItem(this.contentItems[Math.max(n-1,0)]):this._activeContentItem=null),this._$validateClosability(),this.emitBubblingEvent("stateChanged")},_$validateClosability:function(){var t,e,i;for(t=this.header._isClosable(),i=0,e=this.contentItems.length;i<e&&t;i++)t=this.contentItems[i].config.isClosable;this.header._$setClosable(t)},_$destroy:function(){e.items.AbstractContentItem.prototype._$destroy.call(this),this.header._$destroy()},_$onDrop:function(t){if("header"===this._dropSegment)return this._resetHeaderDropZone(),void this.addChild(t,this._dropIndex);if("body"===this._dropSegment)return void this.addChild(t);var i,n,s,o="top"===this._dropSegment||"bottom"===this._dropSegment,r="left"===this._dropSegment||"right"===this._dropSegment,a="top"===this._dropSegment||"left"===this._dropSegment,h=o&&this.parent.isColumn||r&&this.parent.isRow,l=o?"column":"row",c=o?"height":"width";t.isComponent&&(n=this.layoutManager.createContentItem({type:"stack",header:t.config.header||{}},this),n._$init(),n.addChild(t),t=n),h?(i=e.utils.indexOf(this,this.parent.contentItems),this.parent.addChild(t,a?i:i+1,!0),this.config[c]*=.5,t.config[c]=this.config[c],this.parent.callDownwards("setSize")):(l=o?"column":"row",s=this.layoutManager.createContentItem({type:l},this),this.parent.replaceChild(this,s),s.addChild(t,a?0:void 0,!0),s.addChild(this,a?void 0:0,!0),this.config[c]=50,t.config[c]=50,s.callDownwards("setSize"))},_$highlightDropZone:function(t,e){var i,n;for(i in this._contentAreaDimensions)if(n=this._contentAreaDimensions[i].hoverArea,n.x1<t&&n.x2>t&&n.y1<e&&n.y2>e)return void("header"===i?(this._dropSegment="header",this._highlightHeaderDropZone(this._sided?e:t)):(this._resetHeaderDropZone(),this._highlightBodyDropZone(i)))},_$getArea:function(){if(this.element.is(":visible")===!1)return null;var t=e.items.AbstractContentItem.prototype._$getArea,i=t.call(this,this.header.element),n=t.call(this,this.childElementContainer),s=n.x2-n.x1,o=n.y2-n.y1;return this._contentAreaDimensions={header:{hoverArea:{x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2},highlightArea:{x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2}}},this._activeContentItem&&this._activeContentItem.isComponent===!1?i:0===this.contentItems.length?(this._contentAreaDimensions.body={hoverArea:{x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2},highlightArea:{x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2}},t.call(this,this.element)):(this._contentAreaDimensions.left={hoverArea:{x1:n.x1,y1:n.y1,x2:n.x1+.25*s,y2:n.y2},highlightArea:{x1:n.x1,y1:n.y1,x2:n.x1+.5*s,y2:n.y2}},this._contentAreaDimensions.top={hoverArea:{x1:n.x1+.25*s,y1:n.y1,x2:n.x1+.75*s,y2:n.y1+.5*o},highlightArea:{x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y1+.5*o}},this._contentAreaDimensions.right={hoverArea:{x1:n.x1+.75*s,y1:n.y1,x2:n.x2,y2:n.y2},highlightArea:{x1:n.x1+.5*s,y1:n.y1,x2:n.x2,y2:n.y2}},this._contentAreaDimensions.bottom={hoverArea:{x1:n.x1+.25*s,y1:n.y1+.5*o,x2:n.x1+.75*s,y2:n.y2},highlightArea:{x1:n.x1,y1:n.y1+.5*o,x2:n.x2,y2:n.y2}},t.call(this,this.element))},_highlightHeaderDropZone:function(t){var e,i,n,s,o,r,a,h,l,c=this.header.tabs.length,d=!1;if(0===c)return a=this.header.element.offset(),void this.layoutManager.dropTargetIndicator.highlightArea({x1:a.left,x2:a.left+100,y1:a.top+this.header.element.height()-20,y2:a.top+this.header.element.height()});for(e=0;e<c;e++)if(i=this.header.tabs[e].element,o=i.offset(),this._sided?(s=o.top,n=o.left,h=i.height()):(s=o.left,n=o.top,h=i.width()),t>s&&t<s+h){d=!0;break}if(!(d===!1&&t<s)){if(l=s+h/2,t<l?(this._dropIndex=e,i.before(this.layoutManager.tabDropPlaceholder)):(this._dropIndex=Math.min(e+1,c),i.after(this.layoutManager.tabDropPlaceholder)),this._sided)return placeHolderTop=this.layoutManager.tabDropPlaceholder.offset().top,void this.layoutManager.dropTargetIndicator.highlightArea({x1:n,x2:n+i.innerHeight(),y1:placeHolderTop,y2:placeHolderTop+this.layoutManager.tabDropPlaceholder.width()});r=this.layoutManager.tabDropPlaceholder.offset().left,this.layoutManager.dropTargetIndicator.highlightArea({x1:r,x2:r+this.layoutManager.tabDropPlaceholder.width(),y1:n,y2:n+i.innerHeight()})}},_resetHeaderDropZone:function(){this.layoutManager.tabDropPlaceholder.remove()},_setupHeaderPosition:function(){var t=["right","left","bottom"].indexOf(this._header.show)>=0&&this._header.show;if(this.header.element.toggle(!!this._header.show),this._side=t,this._sided=["right","left"].indexOf(this._side)>=0,this.element.removeClass("lm_left lm_right lm_bottom"),this._side&&this.element.addClass("lm_"+this._side),this.element.find(".lm_header").length&&this.childElementContainer){var e=["right","bottom"].indexOf(this._side)>=0?"before":"after";this.header.element[e](this.childElementContainer),this.callDownwards("setSize")}},_highlightBodyDropZone:function(t){var e=this._contentAreaDimensions[t].highlightArea;this.layoutManager.dropTargetIndicator.highlightArea(e),this._dropSegment=t}}),e.utils.BubblingEvent=function(t,e){this.name=t,this.origin=e,this.isPropagationStopped=!1},e.utils.BubblingEvent.prototype.stopPropagation=function(){this.isPropagationStopped=!0},e.utils.ConfigMinifier=function(){if(this._keys=["settings","hasHeaders","constrainDragToContainer","selectionEnabled","dimensions","borderWidth","minItemHeight","minItemWidth","headerHeight","dragProxyWidth","dragProxyHeight","labels","close","maximise","minimise","popout","content","componentName","componentState","id","width","type","height","isClosable","title","popoutWholeStack","openPopouts","parentId","activeItemIndex","reorderEnabled","borderGrabWidth"],this._keys.length>36)throw new Error("Too many keys in config minifier map");this._values=[!0,!1,"row","column","stack","component","close","maximise","minimise","open in new window"]},e.utils.copy(e.utils.ConfigMinifier.prototype,{
minifyConfig:function(t){var e={};return this._nextLevel(t,e,"_min"),e},unminifyConfig:function(t){var e={};return this._nextLevel(t,e,"_max"),e},_nextLevel:function(t,e,i){var n,s;for(n in t)t instanceof Array&&(n=parseInt(n,10)),t.hasOwnProperty(n)&&(s=this[i](n,this._keys),"object"==typeof t[n]?(e[s]=t[n]instanceof Array?[]:{},this._nextLevel(t[n],e[s],i)):e[s]=this[i](t[n],this._values))},_min:function(t,i){if("string"==typeof t&&1===t.length)return"___"+t;var n=e.utils.indexOf(t,i);return n===-1?t:n.toString(36)},_max:function(t,e){return"string"==typeof t&&1===t.length?e[parseInt(t,36)]:"string"==typeof t&&"___"===t.substr(0,3)?t[3]:t}}),e.utils.EventHub=function(i){e.utils.EventEmitter.call(this),this._layoutManager=i,this._dontPropagateToParent=null,this._childEventSource=null,this.on(e.utils.EventEmitter.ALL_EVENT,e.utils.fnBind(this._onEventFromThis,this)),this._boundOnEventFromChild=e.utils.fnBind(this._onEventFromChild,this),t(window).on("gl_child_event",this._boundOnEventFromChild)},e.utils.EventHub.prototype._onEventFromThis=function(){var t=Array.prototype.slice.call(arguments);this._layoutManager.isSubWindow&&t[0]!==this._dontPropagateToParent&&this._propagateToParent(t),this._propagateToChildren(t),this._dontPropagateToParent=null,this._childEventSource=null},e.utils.EventHub.prototype._$onEventFromParent=function(t){this._dontPropagateToParent=t[0],this.emit.apply(this,t)},e.utils.EventHub.prototype._onEventFromChild=function(t){this._childEventSource=t.originalEvent.__gl,this.emit.apply(this,t.originalEvent.__glArgs)},e.utils.EventHub.prototype._propagateToParent=function(t){var e,i="gl_child_event";document.createEvent?(e=window.opener.document.createEvent("HTMLEvents"),e.initEvent(i,!0,!0)):(e=window.opener.document.createEventObject(),e.eventType=i),e.eventName=i,e.__glArgs=t,e.__gl=this._layoutManager,document.createEvent?window.opener.dispatchEvent(e):window.opener.fireEvent("on"+e.eventType,e)},e.utils.EventHub.prototype._propagateToChildren=function(t){var e,i;for(i=0;i<this._layoutManager.openPopouts.length;i++)e=this._layoutManager.openPopouts[i].getGlInstance(),e&&e!==this._childEventSource&&e.eventHub._$onEventFromParent(t)},e.utils.EventHub.prototype.destroy=function(){t(window).off("gl_child_event",this._boundOnEventFromChild)},e.utils.ReactComponentHandler=function(t,e){this._reactComponent=null,this._originalComponentWillUpdate=null,this._container=t,this._initialState=e,this._reactClass=this._getReactClass(),this._container.on("open",this._render,this),this._container.on("destroy",this._destroy,this)},e.utils.copy(e.utils.ReactComponentHandler.prototype,{_render:function(){this._reactComponent=ReactDOM.render(this._getReactComponent(),this._container.getElement()[0]),this._originalComponentWillUpdate=this._reactComponent.componentWillUpdate||function(){},this._reactComponent.componentWillUpdate=this._onUpdate.bind(this),this._container.getState()&&this._reactComponent.setState(this._container.getState())},_destroy:function(){ReactDOM.unmountComponentAtNode(this._container.getElement()[0]),this._container.off("open",this._render,this),this._container.off("destroy",this._destroy,this)},_onUpdate:function(t,e){this._container.setState(e),this._originalComponentWillUpdate.call(this._reactComponent,t,e)},_getReactClass:function(){var t,e=this._container._config.component;if(!e)throw new Error("No react component name. type: react-component needs a field `component`");if(t=this._container.layoutManager.getComponent(e),!t)throw new Error('React component "'+e+'" not found. Please register all components with GoldenLayout using `registerComponent(name, component)`');return t},_getReactComponent:function(){var e={glEventHub:this._container.layoutManager.eventHub,glContainer:this._container},i=t.extend(e,this._container._config.props);return React.createElement(this._reactClass,i)}})}(window.$);