"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=require("primereact/api"),n=require("primereact/componentbase"),t=require("primereact/hooks"),o=require("primereact/utils");function l(e){if(e&&e.__esModule)return e;var r=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var t=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,t.get?t:{enumerable:!0,get:function(){return e[n]}})}})),r.default=e,Object.freeze(r)}var a=l(e);function c(){return c=Object.assign?Object.assign.bind():function(e){for(var r=1;re.length)&&(r=e.length);for(var n=0,t=Array(r);n=1?o.DomHandler.addClass(E.current,"p-scrollpanel-hidden"):(o.DomHandler.removeClass(E.current,"p-scrollpanel-hidden"),o.DomHandler.applyStyle(E.current,{width:Math.max(100*N.current,10)+"%",left:H.current.scrollLeft/e*100+"%",bottom:r+"px"})),F.current>=1?o.DomHandler.addClass(S.current,"p-scrollpanel-hidden"):(o.DomHandler.removeClass(S.current,"p-scrollpanel-hidden"),o.DomHandler.applyStyle(S.current,{height:Math.max(100*F.current,10)+"%",top:"calc("+H.current.scrollTop/n*100+"% - "+E.current.clientHeight+"px)",right:t+"px"}))}))}},_=function(e){E.current.isSameNode(e.target)?g("horizontal"):S.current.isSameNode(e.target)&&g("vertical")},W=function(){"horizontal"===b&&g("vertical")},Y=function(e){j.current?K(e):(T.current||K(e),X(e))},K=function(e){var r=e.pageX-z.current;z.current=e.pageX,I.current=window.requestAnimationFrame((function(){H.current.scrollLeft+=r/N.current}))},X=function(e){var r=e.pageY-M.current;M.current=e.pageY,I.current=window.requestAnimationFrame((function(){H.current.scrollTop+=r/F.current}))},$=function(e){o.DomHandler.removeClass(S.current,"p-scrollpanel-grabbed"),o.DomHandler.removeClass(E.current,"p-scrollpanel-grabbed"),o.DomHandler.removeClass(document.body,"p-scrollpanel-grabbed"),document.removeEventListener("mousemove",Y),document.removeEventListener("mouseup",$),j.current=!1,T.current=!1},G=function(e){if("vertical"===b)switch(e.code){case"ArrowDown":V("scrollTop",s.step),e.preventDefault();break;case"ArrowUp":V("scrollTop",-1*s.step),e.preventDefault();break;case"ArrowLeft":case"ArrowRight":e.preventDefault()}else if("horizontal"===b)switch(e.code){case"ArrowRight":V("scrollLeft",s.step),e.preventDefault();break;case"ArrowLeft":V("scrollLeft",-1*s.step),e.preventDefault();break;case"ArrowDown":case"ArrowUp":e.preventDefault()}},J=function(){Z()},Q=function(e,r){H.current[e]+=r,B()},V=function(e,r){Z(),U.current=setTimeout((function(){Q(e,r)}),40)},Z=function(){U.current&&clearTimeout(U.current)},ee=function(){B()};t.useMountEffect((function(){var e,r,n;s.id||h(o.UniqueComponentId()),B(),window.addEventListener("resize",B),e=getComputedStyle(D.current),r=getComputedStyle(E.current),n=o.DomHandler.getHeight(D.current)-parseInt(r.height,10),"none"!==e["max-height"]&&0===n&&(D.current.style.height=H.current.offsetHeight+parseInt(r.height,10)>parseInt(e["max-height"],10)?e["max-height"]:H.current.offsetHeight+parseFloat(e.paddingTop)+parseFloat(e.paddingBottom)+parseFloat(e.borderTopWidth)+parseFloat(e.borderBottomWidth)+"px"),q.current=!0})),t.useUnmountEffect((function(){q.current&&window.removeEventListener("resize",B),I.current&&window.cancelAnimationFrame(I.current)})),a.useImperativeHandle(l,(function(){return{props:s,refresh:ee,getElement:function(){return D.current},getContent:function(){return H.current},getXBar:function(){return E.current},getYBar:function(){return S.current}}}));var re=u({id:s.id,ref:D,style:s.style,className:o.classNames(s.className,x("root"))},m.getOtherProps(s),w("root")),ne=u({className:x("wrapper")},w("wrapper")),te=u({className:x("content"),onScroll:function(e){A!==e.target.scrollLeft?(R(e.target.scrollLeft),g("horizontal")):O!==e.target.scrollTop&&(P(e.target.scrollTop),g("vertical")),B()},onMouseEnter:B},w("content")),oe=u({ref:E,role:"scrollbar",className:x("barx"),tabIndex:0,"aria-valuenow":O,"aria-controls":k,"aria-orientation":"horizontal",onFocus:_,onBlur:W,onKeyDown:G,onKeyUp:J,onMouseDown:function(e){j.current=!0,z.current=e.pageX,o.DomHandler.addClass(E.current,"p-scrollpanel-grabbed"),o.DomHandler.addClass(document.body,"p-scrollpanel-grabbed"),document.addEventListener("mousemove",Y),document.addEventListener("mouseup",$),e.preventDefault()}},w("barx")),le=u({ref:S,role:"scrollbar",className:x("bary"),tabIndex:0,"aria-valuenow":A,"aria-controls":k,"aria-orientation":"vertical",onFocus:_,onBlur:W,onKeyDown:G,onKeyUp:J,onMouseDown:function(e){T.current=!0,M.current=e.pageY,o.DomHandler.addClass(S.current,"p-scrollpanel-grabbed"),o.DomHandler.addClass(document.body,"p-scrollpanel-grabbed"),document.addEventListener("mousemove",Y),document.addEventListener("mouseup",$),e.preventDefault()}},w("bary"));return a.createElement("div",re,a.createElement("div",ne,a.createElement("div",c({ref:H},te),s.children)),a.createElement("div",oe),a.createElement("div",le))}));h.displayName="ScrollPanel",exports.ScrollPanel=h;