"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("primereact/utils"),n=require("primereact/csstransition"),r=require("primereact/ripple"),o=require("primereact/api");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var l=i(e),s=i(o);function c(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){for(var n=0;nthis.props.threshold})}},{key:"bindParentScrollListener",value:function(){var e=this;this.scrollListener=function(){e.checkVisibility(e.helper.parentElement.scrollTop)},this.helper.parentElement.addEventListener("scroll",this.scrollListener)}},{key:"bindDocumentScrollListener",value:function(){var e=this;this.scrollListener=function(){e.checkVisibility(t.DomHandler.getWindowScrollTop())},window.addEventListener("scroll",this.scrollListener)}},{key:"unbindParentScrollListener",value:function(){this.scrollListener&&(this.helper.parentElement.removeEventListener("scroll",this.scrollListener),this.scrollListener=null)}},{key:"unbindDocumentScrollListener",value:function(){this.scrollListener&&(window.removeEventListener("scroll",this.scrollListener),this.scrollListener=null)}},{key:"onEnter",value:function(){t.ZIndexUtils.set("overlay",this.scrollElementRef.current,s.default.autoZIndex,s.default.zIndex.overlay)}},{key:"onEntered",value:function(){this.props.onShow&&this.props.onShow()}},{key:"onExited",value:function(){t.ZIndexUtils.clear(this.scrollElementRef.current),this.props.onHide&&this.props.onHide()}},{key:"componentDidMount",value:function(){"window"===this.props.target?this.bindDocumentScrollListener():"parent"===this.props.target&&this.bindParentScrollListener()}},{key:"componentWillUnmount",value:function(){"window"===this.props.target?this.unbindDocumentScrollListener():"parent"===this.props.target&&this.unbindParentScrollListener(),t.ZIndexUtils.clear(this.scrollElementRef.current)}},{key:"render",value:function(){var e=this,o=t.classNames("p-scrolltop p-link p-component",{"p-scrolltop-sticky":"window"!==this.props.target},this.props.className),i="parent"===this.props.target;return l.default.createElement(l.default.Fragment,null,l.default.createElement(n.CSSTransition,{nodeRef:this.scrollElementRef,classNames:"p-scrolltop",in:this.state.visible,timeout:{enter:150,exit:150},options:this.props.transitionOptions,unmountOnExit:!0,onEnter:this.onEnter,onEntered:this.onEntered,onExited:this.onExited},l.default.createElement("button",{ref:this.scrollElementRef,type:"button",className:o,style:this.props.style,onClick:this.onClick},t.IconUtils.getJSXIcon(this.props.icon,{className:"p-scrolltop-icon"},{props:this.props}),l.default.createElement(r.Ripple,null))),i&&l.default.createElement("span",{ref:function(t){return e.helper=t},className:"p-scrolltop-helper"}))}}])&&u(h.prototype,m),v&&u(h,v),Object.defineProperty(h,"prototype",{writable:!1}),w}();E={target:"window",threshold:400,icon:"pi pi-chevron-up",behavior:"smooth",className:null,style:null,transitionOptions:null,onShow:null,onHide:null},(v="defaultProps")in(m=w)?Object.defineProperty(m,v,{value:E,enumerable:!0,configurable:!0,writable:!0}):m[v]=E,exports.ScrollTop=w;