this.primereact=this.primereact||{},this.primereact.splitter=function(e,t,n){"use strict";function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=r(t);function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);ne)&&!(this.props.children[this.prevPanelIndex+1].props&&this.props.children[this.prevPanelIndex+1].props.minSize&&this.props.children[this.prevPanelIndex+1].props.minSize>t)}},{key:"unbindMouseListeners",value:function(){this.mouseMoveListener&&(document.removeEventListener("mousemove",this.mouseMoveListener),this.mouseMoveListener=null),this.mouseUpListener&&(document.removeEventListener("mouseup",this.mouseUpListener),this.mouseUpListener=null)}},{key:"clear",value:function(){this.dragging=!1,this.size=null,this.startPos=null,this.prevPanelElement=null,this.nextPanelElement=null,this.prevPanelSize=null,this.nextPanelSize=null,this.gutterElement=null,this.prevPanelIndex=null}},{key:"isStateful",value:function(){return null!=this.props.stateKey}},{key:"getStorage",value:function(){switch(this.props.stateStorage){case"local":return window.localStorage;case"session":return window.sessionStorage;default:throw new Error(this.props.stateStorage+' is not a valid value for the state storage, supported values are "local" and "session".')}}},{key:"saveState",value:function(){this.getStorage().setItem(this.props.stateKey,JSON.stringify(this.panelSizes))}},{key:"restoreState",value:function(){var e=this,t=this.getStorage().getItem(this.props.stateKey);return!!t&&(this.panelSizes=JSON.parse(t),p(this.container.children).filter((function(e){return n.DomHandler.hasClass(e,"p-splitter-panel")})).forEach((function(t,n){t.style.flexBasis="calc("+e.panelSizes[n]+"% - "+(e.props.children.length-1)*e.props.gutterSize+"px)"})),!0)}},{key:"onResizeStart",value:function(e,t){var r="touchstart"===e.type?e.touches[0].pageX:e.pageX,i="touchstart"===e.type?e.touches[0].pageY:e.pageY;this.gutterElement=e.currentTarget,this.size="horizontal"===this.props.layout?n.DomHandler.getWidth(this.container):n.DomHandler.getHeight(this.container),this.dragging=!0,this.startPos="horizontal"===this.props.layout?r:i,this.prevPanelElement=this.gutterElement.previousElementSibling,this.nextPanelElement=this.gutterElement.nextElementSibling,this.prevPanelSize=100*("horizontal"===this.props.layout?n.DomHandler.getOuterWidth(this.prevPanelElement,!0):n.DomHandler.getOuterHeight(this.prevPanelElement,!0))/this.size,this.nextPanelSize=100*("horizontal"===this.props.layout?n.DomHandler.getOuterWidth(this.nextPanelElement,!0):n.DomHandler.getOuterHeight(this.nextPanelElement,!0))/this.size,this.prevPanelIndex=t,n.DomHandler.addClass(this.gutterElement,"p-splitter-gutter-resizing"),n.DomHandler.addClass(this.container,"p-splitter-resizing")}},{key:"onResize",value:function(e){var t,n=this.prevPanelSize+(t="horizontal"===this.props.layout?100*("touchmove"===e.type?e.touches[0].pageX:e.pageX)/this.size-100*this.startPos/this.size:100*("touchmove"===e.type?e.touches[0].pageY:e.pageY)/this.size-100*this.startPos/this.size),r=this.nextPanelSize-t;this.validateResize(n,r)&&(this.prevPanelElement.style.flexBasis="calc("+n+"% - "+(this.props.children.length-1)*this.props.gutterSize+"px)",this.nextPanelElement.style.flexBasis="calc("+r+"% - "+(this.props.children.length-1)*this.props.gutterSize+"px)",this.panelSizes[this.prevPanelIndex]=n,this.panelSizes[this.prevPanelIndex+1]=r)}},{key:"onResizeEnd",value:function(e){this.isStateful()&&this.saveState(),this.props.onResizeEnd&&this.props.onResizeEnd({originalEvent:e,sizes:this.panelSizes}),n.DomHandler.removeClass(this.gutterElement,"p-splitter-gutter-resizing"),n.DomHandler.removeClass(this.container,"p-splitter-resizing"),this.clear()}},{key:"onGutterMouseDown",value:function(e,t){this.onResizeStart(e,t),this.bindMouseListeners()}},{key:"onGutterTouchStart",value:function(e,t){this.onResizeStart(e,t),this.windowTouchMoveListener=this.onGutterTouchMove.bind(this),this.windowTouchEndListener=this.onGutterTouchEnd.bind(this),window.addEventListener("touchmove",this.windowTouchMoveListener,{passive:!1,cancelable:!1}),window.addEventListener("touchend",this.windowTouchEndListener)}},{key:"onGutterTouchMove",value:function(e){this.onResize(e)}},{key:"onGutterTouchEnd",value:function(e){this.onResizeEnd(e),window.removeEventListener("touchmove",this.windowTouchMoveListener),window.removeEventListener("touchend",this.windowTouchEndListener),this.windowTouchMoveListener=null,this.windowTouchEndListener=null}},{key:"componentDidMount",value:function(){var e=this;if(this.panelElement&&this.panelElement.childNodes&&n.ObjectUtils.isNotEmpty(n.DomHandler.find(this.panelElement,".p-splitter"))&&n.DomHandler.addClass(this.panelElement,"p-splitter-panel-nested"),this.props.children&&this.props.children.length){var t=!1;if(this.isStateful()&&(t=this.restoreState()),!t){var r=p(this.container.children).filter((function(e){return n.DomHandler.hasClass(e,"p-splitter-panel")})),i=[];this.props.children.map((function(t,n){var s=(t.props&&t.props.size?t.props.size:null)||100/e.props.children.length;return i[n]=s,r[n].style.flexBasis="calc("+s+"% - "+(e.props.children.length-1)*e.props.gutterSize+"px)",i})),this.panelSizes=i}}}},{key:"renderPanel",value:function(e,t){var r=this,s=n.classNames("p-splitter-panel",e.props.className),o=t!==this.props.children.length-1&&i.default.createElement("div",{ref:function(e){return r.gutterElement=e},className:"p-splitter-gutter",style:"horizontal"===this.props.layout?{width:this.props.gutterSize+"px"}:{height:this.props.gutterSize+"px"},onMouseDown:function(e){return r.onGutterMouseDown(e,t)},onTouchStart:function(e){return r.onGutterTouchStart(e,t)},onTouchMove:function(e){return r.onGutterTouchMove(e)},onTouchEnd:function(e){return r.onGutterTouchEnd(e)}},i.default.createElement("div",{className:"p-splitter-gutter-handle"}));return i.default.createElement(i.default.Fragment,null,i.default.createElement("div",{ref:function(e){return r.panelElement=e},key:t,className:s,style:e.props.style},e.props.children),o)}},{key:"renderPanels",value:function(){var e=this;return i.default.Children.map(this.props.children,(function(t,n){return e.renderPanel(t,n)}))}},{key:"render",value:function(){var e=this,t=n.classNames("p-splitter p-component p-splitter-".concat(this.props.layout),this.props.className),r=this.renderPanels();return i.default.createElement("div",{ref:function(t){return e.container=t},id:this.props.id,className:t,style:this.props.style},r)}}]),r}(t.Component);return z(P,"defaultProps",{id:null,className:null,style:null,layout:"horizontal",gutterSize:4,stateKey:null,stateStorage:"session",onResizeEnd:null}),e.Splitter=P,e.SplitterPanel=w,Object.defineProperty(e,"__esModule",{value:!0}),e}({},React,primereact.utils);