UNPKG

@annotationhub/react-golden-layout

Version:

A multi-screen javascript Layout manager https://golden-layout.com

1 lines 104 kB
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("jquery"),require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["jquery","React","ReactDOM"],e):"object"==typeof exports?exports.GoldenLayout=e(require("jquery"),require("react"),require("react-dom")):t.GoldenLayout=e(t.$,t.React,t.ReactDOM)}(window,(function(t,e,n){return function(t){var e={};function n(i){if(e[i])return e[i].exports;var o=e[i]={i:i,l:!1,exports:{}};return t[i].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(i,o,function(e){return t[e]}.bind(null,o));return i},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=3)}([function(e,n){e.exports=t},function(t,n){t.exports=e},function(t,e){t.exports=n},function(t,e,n){"use strict";n.r(e),n.d(e,"default",(function(){return Me})),n.d(e,"ItemContainer",(function(){return Kt})),n.d(e,"BrowserPopout",(function(){return ye})),n.d(e,"Header",(function(){return bt})),n.d(e,"HeaderButton",(function(){return ut})),n.d(e,"Tab",(function(){return lt})),n.d(e,"Component",(function(){return le})),n.d(e,"Root",(function(){return Ut})),n.d(e,"RowOrColumn",(function(){return $t})),n.d(e,"Stack",(function(){return Et})),n.d(e,"BubblingEvent",(function(){return E})),n.d(e,"ConfigMinifier",(function(){return g})),n.d(e,"DragListener",(function(){return Q})),n.d(e,"EventEmitter",(function(){return p})),n.d(e,"EventHub",(function(){return x})),n.d(e,"ReactComponentHandler",(function(){return ee})),n.d(e,"GoldenLayoutComponent",(function(){return Ne}));var i=n(0),o=n.n(i);function r(t){return(r="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 s(t){return o.a.zepto?t.touches?t.targetTouches[0]:t:t.originalEvent&&t.originalEvent.touches?t.originalEvent.touches[0]:t}function a(t){if(window.location.hash)return e=t,(n=location.hash.match(new RegExp(e+"=([^&]*)")))?n[1]:null;if(!window.location.search)return null;var e,n,i,o,r=window.location.search.substr(1).split("&"),s={};for(o=0;o<r.length;o++)s[(i=r[o].split("="))[0]]=i[1];return s[t]||null}function c(t,e){for(var n in e)t[n]=e[n];return t}function l(t){return(window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||function(t){window.setTimeout(t,1e3/60)})((function(){t()}))}function h(t,e){if(!(e instanceof Array))throw new Error("Haystack is not an Array");if(e.indexOf)return e.indexOf(t);for(var n=0;n<e.length;n++)if(e[n]===t)return n;return-1}var u="object"!=("undefined"==typeof Int8Array?"undefined":r(Int8Array))?function(t){return"function"==typeof t||!1}:function(t){return"[object Function]"===toString.call(t)};function f(t,e,n){if(void 0!==Function.prototype.bind)return Function.prototype.bind.apply(t,[e].concat(n||[]));var i=function i(){var o=(n||[]).concat(Array.prototype.slice.call(arguments,0));if(!(this instanceof i))return t.apply(e,o);t.apply(this,o)};return i.prototype=t.prototype,i}function d(){return(1e15*Math.random()).toString(36).replace(".","")}function m(t){return o.a.trim(t.replace(/(<([^>]+)>)/gi,""))}var p=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this._mSubscriptions={},this._mSubscriptions.__all=[],this.on=function(t,e,n){if(!u(e))throw new Error("Tried to listen to event "+t+" with non-function callback "+e);this._mSubscriptions[t]||(this._mSubscriptions[t]=[]),this._mSubscriptions[t].push({fn:e,ctx:n})},this.emit=function(t){var e,n,i;i=Array.prototype.slice.call(arguments,1);var o=this._mSubscriptions[t];if(o)for(o=o.slice(),e=0;e<o.length;e++)n=o[e].ctx||{},o[e].fn.apply(n,i);i.unshift(t);var r=this._mSubscriptions.__all.slice();for(e=0;e<r.length;e++)n=r[e].ctx||{},r[e].fn.apply(n,i)},this.unbind=function(t,e,n){if(!this._mSubscriptions[t])throw new Error("No subscribtions to unsubscribe for event "+t);var i,o=!1;for(i=0;i<this._mSubscriptions[t].length;i++)e&&this._mSubscriptions[t][i].fn!==e||n&&n!==this._mSubscriptions[t][i].ctx||(this._mSubscriptions[t].splice(i,1),o=!0);if(!1===o)throw new Error("Nothing to unbind for "+t)},this.off=this.unbind,this.trigger=this.emit};function y(t){return(y="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 _(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}var g=function(){function t(){if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),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"]}var e,n,i;return e=t,(n=[{key:"minifyConfig",value:function(t){var e={};return this._nextLevel(t,e,"_min"),e}},{key:"unminifyConfig",value:function(t){var e={};return this._nextLevel(t,e,"_max"),e}},{key:"_nextLevel",value:function(t,e,n){var i,o;for(i in t)t instanceof Array&&(i=parseInt(i,10)),Object.prototype.hasOwnProperty.call(t,i)&&(o=this[n](i,this._keys),"object"===y(t[i])?(e[o]=t[i]instanceof Array?[]:{},this._nextLevel(t[i],e[o],n)):e[o]=this[n](t[i],this._values))}},{key:"_min",value:function(t,e){if("string"==typeof t&&1===t.length)return"___"+t;var n=h(t,e);return-1===n?t:n.toString(36)}},{key:"_max",value: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.prototype,n),i&&_(e,i),t}();function v(t){return(v="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 b(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function w(t,e){return(w=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function I(t,e){return!e||"object"!==v(e)&&"function"!=typeof e?C(t):e}function C(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function k(){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}}function S(t){return(S=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var x=function(t){!function(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&&w(t,e)}(a,t);var e,n,i,r,s=(e=a,function(){var t,n=S(e);if(k()){var i=S(this).constructor;t=Reflect.construct(n,arguments,i)}else t=n.apply(this,arguments);return I(this,t)});function a(t){var e;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,a),(e=s.call(this))._layoutManager=t,e._dontPropagateToParent=null,e._childEventSource=null,e.on("__all",f(e._onEventFromThis,C(e))),e._boundOnEventFromChild=f(e._onEventFromChild,C(e)),o()(window).on("gl_child_event",e._boundOnEventFromChild),e}return n=a,(i=[{key:"_onEventFromThis",value: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}},{key:"_$onEventFromParent",value:function(t){this._dontPropagateToParent=t[0],this.emit.apply(this,t)}},{key:"_onEventFromChild",value:function(t){this._childEventSource=t.originalEvent.__gl,this.emit.apply(this,t.originalEvent.__glArgs)}},{key:"_propagateToParent",value:function(t){var e;document.createEvent?(e=window.opener.document.createEvent("HTMLEvents")).initEvent("gl_child_event",!0,!0):(e=window.opener.document.createEventObject()).eventType="gl_child_event",e.eventName="gl_child_event",e.__glArgs=t,e.__gl=this._layoutManager,document.createEvent?window.opener.dispatchEvent(e):window.opener.fireEvent("on"+e.eventType,e)}},{key:"_propagateToChildren",value:function(t){var e,n;for(n=0;n<this._layoutManager.openPopouts.length;n++)(e=this._layoutManager.openPopouts[n].getGlInstance())&&e!==this._childEventSource&&e.eventHub._$onEventFromParent(t)}},{key:"destroy",value:function(){o()(window).off("gl_child_event",this._boundOnEventFromChild)}}])&&b(n.prototype,i),r&&b(n,r),a}(p);function D(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}var E=function(){function t(e,n){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.name=e,this.origin=n,this.isPropagationStopped=!1}var e,n,i;return e=t,(n=[{key:"stopPropagation",value:function(){this.isPropagationStopped=!0}}])&&D(e.prototype,n),i&&D(e,i),t}();function O(t){return(O="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 P(t,e){return!e||"object"!==O(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 M(t){var e="function"==typeof Map?new Map:void 0;return(M=function(t){if(null===t||(n=t,-1===Function.toString.call(n).indexOf("[native code]")))return t;var n;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,i)}function i(){return j(t,arguments,A(this).constructor)}return i.prototype=Object.create(t.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),R(i,t)})(t)}function j(t,e,n){return(j=T()?Reflect.construct:function(t,e,n){var i=[null];i.push.apply(i,e);var o=new(Function.bind.apply(t,i));return n&&R(o,n.prototype),o}).apply(null,arguments)}function T(){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}}function R(t,e){return(R=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function A(t){return(A=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var z=function(t){!function(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&&R(t,e)}(i,t);var e,n=(e=i,function(){var t,n=A(e);if(T()){var i=A(this).constructor;t=Reflect.construct(n,arguments,i)}else t=n.apply(this,arguments);return P(this,t)});function i(t,e){var o;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,i),(o=n.call(this)).name="Configuration Error",o.message=t,o.node=e,o}return i}(M(Error)),$={isClosable:!0,reorderEnabled:!0,title:""};function W(t){return(W="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 H(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function B(t,e){return(B=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function L(t,e){return!e||"object"!==W(e)&&"function"!=typeof e?F(t):e}function F(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function N(){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}}function U(t){return(U=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var G=function(t){!function(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&&B(t,e)}(s,t);var e,n,i,o,r=(e=s,function(){var t,n=U(e);if(N()){var i=U(this).constructor;t=Reflect.construct(n,arguments,i)}else t=n.apply(this,arguments);return L(this,t)});function s(t,e,n){var i;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),(i=r.call(this)).config=i._extendItemNode(e),i.type=e.type,i.contentItems=[],i.parent=n,i.isInitialised=!1,i.isMaximised=!1,i.isRoot=!1,i.isRow=!1,i.isColumn=!1,i.isStack=!1,i.isComponent=!1,i.layoutManager=t,i._pendingEventPropagations={},i._throttledEvents=["stateChanged"],i.on("__all",i._propagateEvent,F(i)),e.content&&i._createContentItems(e),i}return n=s,(i=[{key:"setSize",value:function(){throw new Error("Abstract Method")}},{key:"callDownwards",value:function(t,e,n,i){var o;for(!0!==n&&!0!==i&&this[t].apply(this,e||[]),o=0;o<this.contentItems.length;o++)this.contentItems[o].callDownwards(t,e,n);!0===n&&!0!==i&&this[t].apply(this,e||[])}},{key:"removeChild",value:function(t,e){var n=h(t,this.contentItems);if(-1===n)throw new Error("Can't remove child item. Unknown content item");!0!==e&&(this.contentItems[n]._$destroy(),this.contentItems[n].callDownwards("_$destroy",[],!0,!0)),this.contentItems.splice(n,1),this.config.content.splice(n,1),this.contentItems.length>0?this.callDownwards("setSize"):this instanceof Ut||!0!==this.config.isClosable||this.parent.removeChild(this)}},{key:"undisplayChild",value:function(t){if(-1===h(t,this.contentItems))throw new Error("Can't remove child item. Unknown content item");this instanceof Ut||!0!==this.config.isClosable||this.parent.undisplayChild(this)}},{key:"addChild",value: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,!0===t.parent.isInitialised&&!1===t.isInitialised&&t._$init()}},{key:"replaceChild",value:function(t,e,n){e=this.layoutManager._$normalizeContentItem(e);var i=h(t,this.contentItems),o=t.element[0].parentNode;if(-1===i)throw new Error("Can't replace child. oldChild is not child of this");o.replaceChild(e.element[0],t.element[0]),!0===n&&(t.parent=null,t._$destroy()),this.contentItems[i]=e,e.parent=this,this.isStack&&(this.header.tabs[i].contentItem=e),!0===e.parent.isInitialised&&!1===e.isInitialised&&e._$init(),this.callDownwards("setSize")}},{key:"remove",value:function(){this.parent.removeChild(this)}},{key:"popout",value:function(){var t=this.layoutManager.createPopout(this);return this.emitBubblingEvent("stateChanged"),t}},{key:"toggleMaximise",value:function(t){t&&t.preventDefault(),!0===this.isMaximised?this.layoutManager._$minimiseItem(this):this.layoutManager._$maximiseItem(this),this.isMaximised=!this.isMaximised,this.emitBubblingEvent("stateChanged")}},{key:"select",value:function(){this.layoutManager.selectedItem!==this&&(this.layoutManager.selectItem(this,!0),this.element.addClass("lm_selected"))}},{key:"deselect",value:function(){this.layoutManager.selectedItem===this&&(this.layoutManager.selectedItem=null,this.element.removeClass("lm_selected"))}},{key:"setTitle",value:function(t){this.config.title=t,this.emit("titleChanged",t),this.emit("stateChanged")}},{key:"hasId",value:function(t){return!!this.config.id&&("string"==typeof this.config.id?this.config.id===t:this.config.id instanceof Array?-1!==h(t,this.config.id):void 0)}},{key:"addId",value: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)}},{key:"removeId",value: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 e=h(t,this.config.id);this.config.id.splice(e,1)}}},{key:"getItemsByFilter",value:function(t){var e=[];return function n(i){for(var o=0;o<i.contentItems.length;o++)!0===t(i.contentItems[o])&&e.push(i.contentItems[o]),n(i.contentItems[o])}(this),e}},{key:"getItemsById",value:function(t){return this.getItemsByFilter((function(e){return e.config.id instanceof Array?-1!==h(t,e.config.id):e.config.id===t}))}},{key:"getItemsByType",value:function(t){return this._$getItemsByProperty("type",t)}},{key:"getComponentsByName",value:function(t){var e,n=this._$getItemsByProperty("componentName",t),i=[];for(e=0;e<n.length;e++)i.push(n[e].instance);return i}},{key:"_$getItemsByProperty",value:function(t,e){return this.getItemsByFilter((function(n){return n[t]===e}))}},{key:"_$setParent",value:function(t){this.parent=t}},{key:"_$highlightDropZone",value:function(t,e,n){this.layoutManager.dropTargetIndicator.highlightArea(n)}},{key:"_$onDrop",value:function(t){this.addChild(t)}},{key:"_$hide",value:function(){this._callOnActiveComponents("hide"),this.element.hide(),this.layoutManager.updateSize()}},{key:"_$show",value:function(){this._callOnActiveComponents("show"),this.element.show(),this.layoutManager.updateSize()}},{key:"_callOnActiveComponents",value:function(t){var e,n,i=this.getItemsByType("stack");for(n=0;n<i.length;n++)(e=i[n].getActiveContentItem())&&e.isComponent&&e.container[t]()}},{key:"_$destroy",value:function(){this.emitBubblingEvent("beforeItemDestroyed"),this.element.remove(),this.emitBubblingEvent("itemDestroyed")}},{key:"_$getArea",value:function(t){var e=(t=t||this.element).offset(),n=t.width(),i=t.height();return{x1:e.left,y1:e.top,x2:e.left+n,y2:e.top+i,surface:n*i,contentItem:this}}},{key:"_$init",value: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")}},{key:"emitBubblingEvent",value:function(t){var e=new E(t,this);this.emit(t,e)}},{key:"_createContentItems",value:function(t){var e,n;if(!(t.content instanceof Array))throw new z("content must be an Array",t);for(n=0;n<t.content.length;n++)e=this.layoutManager.createContentItem(t.content[n],this),this.contentItems.push(e)}},{key:"_extendItemNode",value:function(t){for(var e in $)void 0===t[e]&&(t[e]=$[e]);return t}},{key:"_propagateEvent",value:function(t,e){e instanceof E&&!1===e.isPropagationStopped&&!0===this.isInitialised&&(!1===this.isRoot&&this.parent?this.parent.emit.apply(this.parent,Array.prototype.slice.call(arguments,0)):this._scheduleEventPropagationToLayoutManager(t,e))}},{key:"_scheduleEventPropagationToLayoutManager",value:function(t,e){-1===h(t,this._throttledEvents)?this.layoutManager.emit(t,e.origin):!0!==this._pendingEventPropagations[t]&&(this._pendingEventPropagations[t]=!0,l(f(this._propagateEventToLayoutManager,this,[t,e])))}},{key:"_propagateEventToLayoutManager",value:function(t,e){this._pendingEventPropagations[t]=!1,this.layoutManager.emit(t,e)}}])&&H(n.prototype,i),o&&H(n,o),s}(p);function X(t){return(X="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 Y(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function V(t,e){return(V=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Z(t,e){return!e||"object"!==X(e)&&"function"!=typeof e?q(t):e}function q(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function K(){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}}function J(t){return(J=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var Q=function(t){!function(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&&V(t,e)}(c,t);var e,n,i,r,a=(e=c,function(){var t,n=J(e);if(K()){var i=J(this).constructor;t=Reflect.construct(n,arguments,i)}else t=n.apply(this,arguments);return Z(this,t)});function c(t,e){var n;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,c),(n=a.call(this))._timeout=null,n._eElement=o()(t),n._oDocument=o()(document),n._eBody=o()(document.body),n._nButtonCode=e||0,n._nDelay=200,n._nDistance=10,n._nX=0,n._nY=0,n._nOriginalX=0,n._nOriginalY=0,n._bDragging=!1,n._fMove=f(n.onMouseMove,q(n)),n._fUp=f(n.onMouseUp,q(n)),n._fDown=f(n.onMouseDown,q(n)),n._fClick=f(n.onClick,q(n)),n._eElement.on("mousedown touchstart",n._fDown),n._eElement.hasClass("add-target")&&n._eElement.on("click",n._fClick),n}return n=c,(i=[{key:"destroy",value:function(){this._eElement.unbind("mousedown touchstart",this._fDown),this._oDocument.unbind("mouseup touchend",this._fUp),this._eElement=null,this._oDocument=null,this._eBody=null}},{key:"onMouseDown",value:function(t){if(t.preventDefault(),0==t.button||"touchstart"===t.type){var e=this._getCoordinates(t);this._nOriginalX=e.x,this._nOriginalY=e.y,this._oDocument.on("mousemove touchmove",this._fMove),this._oDocument.one("mouseup touchend",this._fUp),this._oDocument.on("keydown",this._fKeyDown),this._timeout=setTimeout(f(this._startDrag,this),this._nDelay)}}},{key:"onMouseMove",value: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,!1===this._bDragging&&(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)}}},{key:"onMouseUp",value: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._oDocument.unbind("keydown",this._fKeyDown),!0===this._bDragging&&(this._bDragging=!1,this.emit("dragStop",t,this._nOriginalX+this._nX)))}},{key:"onClick",value:function(){this._oDocument.on("mousemove touchmove",this._fMove),this._oDocument.one("mouseup touchend",this._fUp),this._oDocument.on("keydown",this._fKeyDown),this._timeout=setTimeout(f(this._startDrag,this),this._nDelay)}},{key:"onKeyDown",value:function(t){!0===this._bDragging&&27===t.keyCode&&(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._oDocument.unbind("keydown",this._fKeyDown),o()(".lm_dropTargetIndicator").hide(),o()(".lm_dragProxy").remove())}},{key:"_startDrag",value: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)}},{key:"_getCoordinates",value:function(t){return{x:(t=s(t)).pageX,y:t.pageY}}}])&&Y(n.prototype,i),r&&Y(n,r),c}(p);function tt(t){return(tt="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 et(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function nt(t,e){return(nt=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function it(t,e){return!e||"object"!==tt(e)&&"function"!=typeof e?ot(t):e}function ot(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function rt(){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}}function st(t){return(st=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var at=function(t){!function(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&&nt(t,e)}(c,t);var e,n,i,r,a=(e=c,function(){var t,n=st(e);if(rt()){var i=st(this).constructor;t=Reflect.construct(n,arguments,i)}else t=n.apply(this,arguments);return it(this,t)});function c(t,e,n,i,r,s){var l;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,c),(l=a.call(this))._dragListener=n,l._layoutManager=i,l._contentItem=r,l._originalParent=s,l._area=null,l._lastValidArea=null,l._dragListener.on("drag",l._onDrag,ot(l)),l._dragListener.on("dragStop",l._onDrop,ot(l)),l.element=o()('<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>'),s&&s._side&&(l._sided=s._sided,l.element.addClass("lm_"+s._side),["right","bottom"].indexOf(s._side)>=0&&l.element.find(".lm_content").after(l.element.find(".lm_header"))),l.element.css({left:t,top:e}),l.element.find(".lm_tab").attr("title",m(l._contentItem.config.title)),l.element.find(".lm_title").html(l._contentItem.config.title),l.childElementContainer=l.element.find(".lm_content"),l.childElementContainer.append(r.element),l._undisplayTree(),l._layoutManager._$calculateItemAreas(),l._setDimensions(),o()(document.body).append(l.element);var h=l._layoutManager.container.offset();return l._minX=h.left,l._minY=h.top,l._maxX=l._layoutManager.container.width()+l._minX,l._maxY=l._layoutManager.container.height()+l._minY,l._width=l.element.width(),l._height=l.element.height(),l._setDropPosition(t,e),l}return n=c,(i=[{key:"_onDrag",value:function(t,e,n){var i=(n=s(n)).pageX,o=n.pageY;(i>this._minX&&i<this._maxX&&o>this._minY&&o<this._maxY||!0!==this._layoutManager.config.settings.constrainDragToContainer)&&this._setDropPosition(i,o)}},{key:"_setDropPosition",value: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))}},{key:"_onDrop",value:function(){this._updateTree(),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)}},{key:"_undisplayTree",value:function(){this._contentItem.parent&&this._contentItem.parent.undisplayChild(this._contentItem)}},{key:"_updateTree",value:function(){this._contentItem.parent&&this._contentItem.parent.removeChild(this._contentItem,!0),this._contentItem._$setParent(this)}},{key:"_setDimensions",value:function(){var t=this._layoutManager.config.dimensions,e=t.dragProxyWidth,n=t.dragProxyHeight;this.element.width(e),this.element.height(n),e-=this._sided?t.headerHeight:0,n-=this._sided?0:t.headerHeight,this.childElementContainer.width(e),this.childElementContainer.height(n),this._contentItem.element.width(e),this._contentItem.element.height(n),this._contentItem.callDownwards("_$show"),this._contentItem.callDownwards("setSize")}}])&&et(n.prototype,i),r&&et(n,r),c}(p);function ct(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}var lt=function(){function t(e,n){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.header=e,this.contentItem=n,this.element=o()('<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>'),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,!0===this._layoutManager.config.settings.reorderEnabled&&!0===n.config.reorderEnabled&&(this._dragListener=new Q(this.element),this._dragListener.on("dragStart",this._onDragStart,this),this.contentItem.on("destroy",this._dragListener.destroy,this._dragListener)),this._onTabClickFn=f(this._onTabClick,this),this._onCloseClickFn=f(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))}var e,n,i;return e=t,(n=[{key:"setTitle",value:function(t){this.element.attr("title",m(t)),this.titleElement.html(t)}},{key:"setActive",value:function(t){t!==this.isActive&&(this.isActive=t,t?this.element.addClass("lm_active"):this.element.removeClass("lm_active"))}},{key:"_$destroy",value: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()}},{key:"_onDragStart",value:function(t,e){if(!this.header._canDestroy)return null;!0===this.contentItem.parent.isMaximised&&this.contentItem.parent.toggleMaximise(),new at(t,e,this._dragListener,this._layoutManager,this.contentItem,this.header.parent)}},{key:"_onTabClick",value:function(t){0===t.button||"touchstart"===t.type?this.header.parent.setActiveContentItem(this.contentItem):1===t.button&&this.contentItem.config.isClosable&&this._onCloseClick(t)}},{key:"_onCloseClick",value:function(t){t.stopPropagation(),this.header._canDestroy&&this.header.parent.removeChild(this.contentItem)}},{key:"_onCloseMousedown",value:function(t){t.stopPropagation()}}])&&ct(e.prototype,n),i&&ct(e,i),t}();function ht(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}var ut=function(){function t(e,n,i,r){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this._header=e,this.element=o()('<li class="'+i+'" title="'+n+'"></li>'),this._header.on("destroy",this._$destroy,this),this._action=r,this.element.on("click touchstart",this._action),this._header.controlsContainer.append(this.element)}var e,n,i;return e=t,(n=[{key:"_$destroy",value:function(){this.element.off(),this.element.remove()}}])&&ht(e.prototype,n),i&&ht(e,i),t}();function ft(t){return(ft="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 dt(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function mt(t,e){return(mt=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function pt(t,e){return!e||"object"!==ft(e)&&"function"!=typeof e?yt(t):e}function yt(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function _t(){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}}function gt(t){return(gt=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var vt=['<div class="lm_header">','<ul class="lm_tabs"></ul>','<ul class="lm_controls"></ul>','<ul class="lm_tabdropdown_list"></ul>',"</div>"].join(""),bt=function(t){!function(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&&mt(t,e)}(a,t);var e,n,i,r,s=(e=a,function(){var t,n=gt(e);if(_t()){var i=gt(this).constructor;t=Reflect.construct(n,arguments,i)}else t=n.apply(this,arguments);return pt(this,t)});function a(t,e){var n;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,a),(n=s.call(this)).layoutManager=t,n.element=o()(vt),!0===n.layoutManager.config.settings.selectionEnabled&&(n.element.addClass("lm_selectable"),n.element.on("click touchstart",f(n._onHeaderClick,yt(n)))),n.tabsContainer=n.element.find(".lm_tabs"),n.tabDropdownContainer=n.element.find(".lm_tabdropdown_list"),n.tabDropdownContainer.hide(),n.controlsContainer=n.element.find(".lm_controls"),n.parent=e,n.parent.on("resize",n._updateTabSizes,yt(n)),n.tabs=[],n.tabsMarkedForRemoval=[],n.activeContentItem=null,n.closeButton=null,n.dockButton=null,n.tabDropdownButton=null,n.hideAdditionalTabsDropdown=f(n._hideAdditionalTabsDropdown,yt(n)),o()(document).mouseup(n.hideAdditionalTabsDropdown),n._lastVisibleTabIndex=-1,n._tabControlOffset=n.layoutManager.config.settings.tabControlOffset,n._createControls(),n}return n=a,(i=[{key:"createTab",value:function(t,e){var n,i;for(i=0;i<this.tabs.length;i++)if(this.tabs[i].contentItem===t)return;if(n=new lt(this,t),0===this.tabs.length)return this.tabs.push(n),void this.tabsContainer.append(n.element);void 0===e&&(e=this.tabs.length),e>0?this.tabs[e-1].element.after(n.element):this.tabs[0].element.before(n.element),this.tabs.splice(e,0,n),this._updateTabSizes()}},{key:"removeTab",value: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);for(e=0;e<this.tabsMarkedForRemoval.length;e++)if(this.tabsMarkedForRemoval[e].contentItem===t)return this.tabsMarkedForRemoval[e]._$destroy(),void this.tabsMarkedForRemoval.splice(e,1);throw new Error("contentItem is not controlled by this header")}},{key:"hideTab",value:function(t){for(var e=0;e<this.tabs.length;e++)if(this.tabs[e].contentItem===t)return this.tabs[e].element.hide(),this.tabsMarkedForRemoval.push(this.tabs[e]),void this.tabs.splice(e,1);throw new Error("contentItem is not controlled by this header")}},{key:"setActiveContentItem",value:function(t){var e,n,i,o;if(this.activeContentItem!==t){for(e=0;e<this.tabs.length;e++)i=this.tabs[e].contentItem===t,this.tabs[e].setActive(i),!0===i&&(this.activeContentItem=t,this.parent.config.activeItemIndex=e);if(this.layoutManager.config.settings.reorderOnTabMenuClick&&-1!==this._lastVisibleTabIndex&&this.parent.config.activeItemIndex>this._lastVisibleTabIndex){for(o=this.tabs[this.parent.config.activeItemIndex],n=this.parent.config.activeItemIndex;n>0;n--)this.tabs[n]=this.tabs[n-1];this.tabs[0]=o,this.parent.config.activeItemIndex=0}this._updateTabSizes(),this.parent.emitBubblingEvent("stateChanged")}}},{key:"position",value:function(t){var e=this.parent._header.show;if(this.parent._docker&&this.parent._docker.docked)throw new Error("Can't change header position in docked stack");return e&&!this.parent._side&&(e="top"),void 0!==t&&this.parent._header.show!=t&&(this.parent._header.show=t,this.parent.config.header?this.parent.config.header.show=t:this.parent.config.header={show:t},this.parent._setupHeaderPosition()),e}},{key:"_$setClosable",value:function(t){return this._canDestroy=t||this.tabs.length>1,!(!this.closeButton||!this._isClosable()||(this.closeButton.element[t?"show":"hide"](),0))}},{key:"_setDockable",value:function(t){return!!(this.dockButton&&this.parent._header&&this.parent._header.dock)&&(this.dockButton.element.toggle(!!t),!0)}},{key:"_$destroy",value:function(){this.emit("destroy",this);for(var t=0;t<this.tabs.length;t++)this.tabs[t]._$destroy();o()(document).off("mouseup",this.hideAdditionalTabsDropdown),this.element.remove()}},{key:"_getHeaderSetting",value:function(t){if(t in this.parent._header)return this.parent._header[t]}},{key:"_createControls",value:function(){var t,e,n,i,o,r,s,a,c;if(c=f(this._showAdditionalTabsDropdown,this),a=this.layoutManager.config.labels.tabDropdown,this.tabDropdownButton=new ut(this,a,"lm_tabdropdown",c),this.tabDropdownButton.element.hide(),this.parent._header&&this.parent._header.dock){var l=f(this.parent.dock,this.parent);n=this._getHeaderSetting("dock"),this.dockButton=new ut(this,n,"lm_dock",l)}this._getHeaderSetting("popout")&&(e=f(this._onPopoutClick,this),n=this._getHeaderSetting("popout"),new ut(this,n,"lm_popout",e)),this._getHeaderSetting("maximise")&&(r=f(this.parent.toggleMaximise,this.parent),i=this._getHeaderSetting("maximise"),o=this._getHeaderSetting("minimise"),s=new ut(this,i,"lm_maximise",r),this.parent.on("maximised",(function(){s.element.attr("title",o)})),this.parent.on("minimised",(function(){s.element.attr("title",i)}))),this._isClosable()&&(t=f(this.parent.remove,this.parent),n=this._getHeaderSetting("close"),this.closeButton=new ut(this,n,"lm_close",t))}},{key:"_showAdditionalTabsDropdown",value:function(){this.tabDropdownContainer.show()}},{key:"_hideAdditionalTabsDropdown",value:function(t){this.tabDropdownContainer.hide()}},{key:"_isClosable",value:function(){return this.parent.config.isClosable&&this.layoutManager.config.settings.showCloseIcon}},{key:"_onPopoutClick",value:function(){!0===this.layoutManager.config.settings.popoutWholeStack?this.parent.popout():this.activeContentItem.popout()}},{key:"_onHeaderClick",value:function(t){t.target===this.element[0]&&this.parent.select()}},{key:"_updateTabSizes",value:function(t){if(0!==this.tabs.length){this.tabDropdownButton.element.toggle(!0===t);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 n,i,o,r,s=this.element.outerWidth()-this.controlsContainer.outerWidth()-this._tabControlOffset,a=0,c=0,l=0,h=this.layoutManager.config.settings.tabOverlapAllowance,u=!1,f=this.activeContentItem?this.tabs.indexOf(this.activeContentItem.tab):0,d=this.tabs[f];for(this.parent._sided&&(s=this.element.outerHeight()-this.controlsContainer.outerHeight()-this._tabControlOffset),this._lastVisibleTabIndex=-1,i=0;i<this.tabs.length;i++)if(n=this.tabs[i].element,this.tabsContainer.append(n),a+=n.outerWidth()+parseInt(n.css("margin-right"),10),(c=f<=i?a:a+d.element.outerWidth()+parseInt(d.element.css("margin-right"),10))>s){if(u)i===f&&(n.css({"z-index":"auto","margin-left":""}),this.tabsContainer.append(n));else if((l=f>0&&f<=i?(c-s)/(i-1):(c-s)/i)<h){for(o=0;o<=i;o++)r=o!==f&&0!==o?"-"+l+"px":"",this.tabs[o].element.css({"z-index":i-o,"margin-left":r});this._lastVisibleTabIndex=i,this.tabsContainer.append(n)}else u=!0;if(u&&i!==f){if(!t)return void this._updateTabSizes(!0);n.css({"z-index":"auto","margin-left":""}),this.tabDropdownContainer.append(n)}}else this._lastVisibleTabIndex=i,n.css({"z-index":"auto","margin-left":""}),this.tabsContainer.append(n)}}}])&&dt(n.prototype,i),r&&dt(n,r),a}(p);function wt(t){return(wt="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 It(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function Ct(t,e){return(Ct=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function kt(t,e){return!e||"object"!==wt(e)&&"function"!=typeof e?St(t):e}function St(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function xt(){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}}function Dt(t){return(Dt=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var Et=function(t){!function(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&&Ct(t,e)}(a,t);var e,n,i,r,s=(e=a,function(){var t,n=Dt(e);if(xt()){var i=Dt(this).constructor;t=Reflect.construct(n,arguments,i)}else t=n.apply(this,arguments);return kt(this,t)});function a(t,e,n){var i;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,a),(i=s.call(this,t,e,n)).element=o()('<div class="lm_item lm_stack"></div>'),i._activeContentItem=null;var r=t.config;return i._header={show:!0===r.settings.hasHeaders&&!1!==e.hasHeaders,popout:r.settings.showPopoutIcon&&r.labels.popout,maximise:r.settings.showMaximiseIcon&&r.labels.maximise,close:r.settings.showCloseIcon&&r.labels.close,minimise:r.labels.minimise},r.header&&c(i._header,r.header),e.header&&c(i._header,e.header),e.content&&e.content[0]&&e.content[0].header&&c(i._header,e.content[0].header),i._dropZones={},i._dropSegment=null,i._contentAreaDimensions=null,i._dropIndex=null,i.isStack=!0,i.childElementContainer=o()('<div class="lm_items"></div>'),i.header=new bt(t,St(i)),i.element.on("mouseleave mouseenter",f((function(t){this._docker&&this._docker.docked&&this.childElementContainer[this._docker.dimension]("mouseenter"==t.type?this._docker.realSize:0)}),St(i))),i.element.append(i.header.element),i.element.append(i.childElementContainer),i._setupHeaderPosition(),i._$validateClosability(),i}return n=a,(i=[{key:"dock",value:function(t){this._header.dock&&this.parent instanceof $t&&this.parent.dock(this,t)}},{key:"setSize",value:function(){if("none"!==this.element.css("display")){var t=this._docker&&this._docker.docked,e={width:this.element.width(),height:this.element.height()};this._header.show&&(e[this._sided?"width":"height"]-=this.layoutManager.config.dimensions.headerHeight),t&&(e[this._docker.dimension]=this._docker.realSize),t&&"height"!=this._docker.dimension||this.childElementContainer.width(e.width),t&&"width"!=this._docker.dimension||this.childElementContainer.height(e.height);for(var n=0;n<this.contentItems.length;n++)this.contentItems[n].element.width(e.width),this.contentItems[n].element.height(e.height);this.emit("resize"),this.emitBubblingEvent("stateChanged")}}},{key:"_$init",value:function(){var t,e;if(!0!==this.isInitialised){for(G.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(!(e=this.contentItems[this.config.activeItemIndex||0]))throw new Error("Configured activeItemIndex out of bounds");this.setActiveContentItem(e)}this._$validateClosability(),this.parent instanceof $t&&this.parent._validateDocking()}}},{key:"setActiveContentItem",value:function(t){if(this._activeContentItem!==t){if(-1===h(t,this.contentItems))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")}}},{key:"getActiveContentItem",value:function(){return this.header.activeContentItem}},{key:"addChild",value:function(t,e){e>this.contentItems.length&&(e-=1),t=this.layoutManager._$normalizeContentItem(t,this),G.prototype.addChild.call(this,t,e),this.childElementContainer.append(t.element),this.header.createTab(t,e),this.setActiveContentItem(t),this.callDownwards("setSize"),this._$validateClosability(),this.parent instanceof $t&&this.parent._validateDocking(),this.emitBubblingEvent("stateChanged")}},{key:"removeChild",value:function(t,e){var n=h(t,this.contentItems);if(G.prototype.removeChild.call(this,t,e),this.header.removeTab(t),this.header.activeContentItem===t)this.contentItems.length>0?this.setActiveContentItem(this.contentItems[Math.max(n-1,0)]):this._activeContentItem=null;else if(this.config.activeItemIndex>=this.contentItems.length){if(this.contentItems.length>0){var i=h(this.getActiveContentItem(),this.contentItems);this.config.activeItemIndex=Math.max(i,0)}}else n<=this.config.activeContentItem&&(this.config.activeItemIndex-=1);this._$validateClosability(),this.parent instanceof $t&&this.parent._validateDocking(),this.emitBubblingEvent("stateChanged")}},{key:"undisplayChild",value:function(t){if(this.contentItems.length>1){var e=h(t,this.contentItems);t._$hide&&t._$hide(),this.setActiveContentItem(this.contentItems[0===e?e+1:e-1])}else this.header.hideTab(t),t._$hide&&t._$hide(),G.prototype.undisplayChild.call(this,t),this.parent instanceof $t&&this.parent._validateDocking();this.emitBubblingEvent("stateChanged")}},{key:"_$validateClosability",value:function(){var t,e,n;for(t=this.header._isClosable(),n=0,e=this.contentItems.length;n<e&&t;n++)t=this.contentItems[n].config.isClosable;this.header._$setClosable(t)}},{key:"_$destroy",value:function(){G.prototype._$destroy.call(this),this.header._$destroy(),this.element.off("mouseenter mouseleave")}},{key:"_$onDrop",value:function(t){if("header"===this._dropSegment)return this._resetHeaderDropZone(),void this.addChild(t,this._dropIndex);if("body"!==this._dropSegment){var e,n,i,o="top"===this._dropSegment||"bottom"===this._dropSegment,r="left"===this._dropSegment||"right"===this._dropSegment,s="top"===this._dropSegment||"left"===this._dropSegment,a=o&&this.parent.isColumn||r&&this.parent.isRow,c=o?"column":"row",l=o?"height":"width";t.isComponent&&((n=this.layoutManager.createContentItem({type:"stack",header:t.config.header||{}},this))._$init(),n.addChild(t),t=n),"row"!==t.config.type&&"column"!==t.config.type||((n=this.layoutManager.createContentItem({type:"stack"},this)).addChild(t),t=n),a?(e=h(this,this.parent.contentItems),this.parent.addChild(t,s?e:e+1,!0),this.config[l]*=.5,t.config[l]=this.config[l],this.parent.callDownwards("setSize")):(c=o?"column":"row",i=this.layoutManager.createContentItem({type:c},this),this.parent.replaceChild(this,i),i.addChild(t,s?0:void 0,!0),i.addChild(this,s?void 0:0,!0),this.config[l]=50,t.config[l]=50,i.callDownwards("setSize")),this.parent._validateDocking()}else this.addChild(t)}},{key:"_$highlightDropZone",value:function(t,e){var n,i;for(n in this._contentAreaDimensions)if((i=this._contentAreaDimensions[n].hoverArea).x1<t&&i.x2>t&&i.y1<e&&i.y2>e)return void("header"===n?(this._dropSegment="header",this._highlightHeaderDropZone(this._sided?e:t)):(this._resetHeaderDropZone(),this._highlightBodyDropZone(n)))}},{key:"_$getArea",value:function(){if("none"===this.element.css("display"))return null;var t=G.prototype._$getArea,e=t.call(this,this.header.element),