(function(g,A){typeof exports=="object"&&typeof module<"u"?module.exports=A(require("react")):typeof define=="function"&&define.amd?define(["react"],A):(g=typeof globalThis<"u"?globalThis:g||self,g["react-scroller"]=A(g.React))})(this,function(g){"use strict";var A={exports:{}},V={};/** * @license React * react-jsx-runtime.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var me;function We(){if(me)return V;me=1;var o=g,x=Symbol.for("react.element"),t=Symbol.for("react.fragment"),l=Object.prototype.hasOwnProperty,L=o.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,_={key:!0,ref:!0,__self:!0,__source:!0};function Y(y,b,S){var E,p={},C=null,I=null;S!==void 0&&(C=""+S),b.key!==void 0&&(C=""+b.key),b.ref!==void 0&&(I=b.ref);for(E in b)l.call(b,E)&&!_.hasOwnProperty(E)&&(p[E]=b[E]);if(y&&y.defaultProps)for(E in b=y.defaultProps,b)p[E]===void 0&&(p[E]=b[E]);return{$$typeof:x,type:y,key:C,ref:I,props:p,_owner:L.current}}return V.Fragment=t,V.jsx=Y,V.jsxs=Y,V}var B={};/** * @license React * react-jsx-runtime.development.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var Ee;function Ne(){return Ee||(Ee=1,process.env.NODE_ENV!=="production"&&function(){var o=g,x=Symbol.for("react.element"),t=Symbol.for("react.portal"),l=Symbol.for("react.fragment"),L=Symbol.for("react.strict_mode"),_=Symbol.for("react.profiler"),Y=Symbol.for("react.provider"),y=Symbol.for("react.context"),b=Symbol.for("react.forward_ref"),S=Symbol.for("react.suspense"),E=Symbol.for("react.suspense_list"),p=Symbol.for("react.memo"),C=Symbol.for("react.lazy"),I=Symbol.for("react.offscreen"),J=Symbol.iterator,Q="@@iterator";function q(e){if(e===null||typeof e!="object")return null;var r=J&&e[J]||e[Q];return typeof r=="function"?r:null}var j=o.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function m(e){{for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i=1&&h>=0&&s[v]!==R[h];)h--;for(;v>=1&&h>=0;v--,h--)if(s[v]!==R[h]){if(v!==1||h!==1)do if(v--,h--,h<0||s[v]!==R[h]){var w=` `+s[v].replace(" at new "," at ");return e.displayName&&w.includes("")&&(w=w.replace("",e.displayName)),typeof e=="function"&&ne.set(e,w),w}while(v>=1&&h>=0);break}}}finally{fe=!1,ue.current=f,Me(),Error.prepareStackTrace=c}var U=e?e.displayName||e.name:"",Ie=U?te(U):"";return typeof e=="function"&&ne.set(e,Ie),Ie}function Ue(e,r,n){return Te(e,!1)}function Ve(e){var r=e.prototype;return!!(r&&r.isReactComponent)}function ae(e,r,n){if(e==null)return"";if(typeof e=="function")return Te(e,Ve(e));if(typeof e=="string")return te(e);switch(e){case S:return te("Suspense");case E:return te("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case b:return Ue(e.render);case p:return ae(e.type,r,n);case C:{var i=e,c=i._payload,f=i._init;try{return ae(f(c),r,n)}catch{}}}return""}var oe=Object.prototype.hasOwnProperty,Se={},Ce=j.ReactDebugCurrentFrame;function ie(e){if(e){var r=e._owner,n=ae(e.type,e._source,r?r.type:null);Ce.setExtraStackFrame(n)}else Ce.setExtraStackFrame(null)}function Be(e,r,n,i,c){{var f=Function.call.bind(oe);for(var u in e)if(f(e,u)){var s=void 0;try{if(typeof e[u]!="function"){var R=Error((i||"React class")+": "+n+" type `"+u+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[u]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw R.name="Invariant Violation",R}s=e[u](r,u,i,n,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(v){s=v}s&&!(s instanceof Error)&&(ie(c),m("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",i||"React class",n,u,typeof s),ie(null)),s instanceof Error&&!(s.message in Se)&&(Se[s.message]=!0,ie(c),m("Failed %s type: %s",n,s.message),ie(null))}}}var Je=Array.isArray;function de(e){return Je(e)}function Ge(e){{var r=typeof Symbol=="function"&&Symbol.toStringTag,n=r&&e[Symbol.toStringTag]||e.constructor.name||"Object";return n}}function $e(e){try{return Oe(e),!1}catch{return!0}}function Oe(e){return""+e}function Pe(e){if($e(e))return m("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Ge(e)),Oe(e)}var K=j.ReactCurrentOwner,Ke={key:!0,ref:!0,__self:!0,__source:!0},xe,je,ve;ve={};function Xe(e){if(oe.call(e,"ref")){var r=Object.getOwnPropertyDescriptor(e,"ref").get;if(r&&r.isReactWarning)return!1}return e.ref!==void 0}function Ze(e){if(oe.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function Qe(e,r){if(typeof e.ref=="string"&&K.current&&r&&K.current.stateNode!==r){var n=T(K.current.type);ve[n]||(m('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',T(K.current.type),e.ref),ve[n]=!0)}}function qe(e,r){{var n=function(){xe||(xe=!0,m("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",r))};n.isReactWarning=!0,Object.defineProperty(e,"key",{get:n,configurable:!0})}}function er(e,r){{var n=function(){je||(je=!0,m("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",r))};n.isReactWarning=!0,Object.defineProperty(e,"ref",{get:n,configurable:!0})}}var rr=function(e,r,n,i,c,f,u){var s={$$typeof:x,type:e,key:r,ref:n,props:u,_owner:f};return s._store={},Object.defineProperty(s._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(s,"_self",{configurable:!1,enumerable:!1,writable:!1,value:i}),Object.defineProperty(s,"_source",{configurable:!1,enumerable:!1,writable:!1,value:c}),Object.freeze&&(Object.freeze(s.props),Object.freeze(s)),s};function tr(e,r,n,i,c){{var f,u={},s=null,R=null;n!==void 0&&(Pe(n),s=""+n),Ze(r)&&(Pe(r.key),s=""+r.key),Xe(r)&&(R=r.ref,Qe(r,c));for(f in r)oe.call(r,f)&&!Ke.hasOwnProperty(f)&&(u[f]=r[f]);if(e&&e.defaultProps){var v=e.defaultProps;for(f in v)u[f]===void 0&&(u[f]=v[f])}if(s||R){var h=typeof e=="function"?e.displayName||e.name||"Unknown":e;s&&qe(u,h),R&&er(u,h)}return rr(e,s,R,c,i,K.current,u)}}var he=j.ReactCurrentOwner,ke=j.ReactDebugCurrentFrame;function H(e){if(e){var r=e._owner,n=ae(e.type,e._source,r?r.type:null);ke.setExtraStackFrame(n)}else ke.setExtraStackFrame(null)}var ge;ge=!1;function be(e){return typeof e=="object"&&e!==null&&e.$$typeof===x}function De(){{if(he.current){var e=T(he.current.type);if(e)return` Check the render method of \``+e+"`."}return""}}function nr(e){{if(e!==void 0){var r=e.fileName.replace(/^.*[\\\/]/,""),n=e.lineNumber;return` Check your code at `+r+":"+n+"."}return""}}var Le={};function ar(e){{var r=De();if(!r){var n=typeof e=="string"?e:e.displayName||e.name;n&&(r=` Check the top-level render call using <`+n+">.")}return r}}function Fe(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var n=ar(r);if(Le[n])return;Le[n]=!0;var i="";e&&e._owner&&e._owner!==he.current&&(i=" It was passed a child from "+T(e._owner.type)+"."),H(e),m('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',n,i),H(null)}}function Ae(e,r){{if(typeof e!="object")return;if(de(e))for(var n=0;n",s=" Did you accidentally export a JSX literal instead of a component?"):v=typeof e,m("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",v,s)}var h=tr(e,r,n,c,f);if(h==null)return h;if(u){var w=r.children;if(w!==void 0)if(i)if(de(w)){for(var U=0;U{const t=g.useRef({height:0,top:0,boxHeight:0,progress:0,grab:!1,grabOffset:0,grabStart:0,grabDelta:0,scrollStart:0,hovered:!1,inited:!1,bar:{height:0,offset:0,offsetStart:0,offsetDelta:0,clicked:!1}}).current,l=g.useRef(null),L=g.useRef(null),_=g.useRef(null),[Y,y]=g.useState(!1);g.useEffect(()=>{window.addEventListener("pointerup",E),window.addEventListener("pointermove",C),window.addEventListener("touchmove",p,{passive:!1});const a=new ResizeObserver(d=>{t.inited&&(W(),N())});if(l.current)return a.observe(l.current),()=>{window.removeEventListener("pointerup",E),window.removeEventListener("pointermove",C),window.removeEventListener("touchmove",p),a.disconnect()}},[]),g.useEffect(()=>{let a=l.current;if(a)return o.horizontal&&a.addEventListener("wheel",q),a.addEventListener("scroll",j),o.grab&&a.addEventListener("pointerdown",I),()=>{a&&(a.removeEventListener("scroll",j),o.horizontal&&a.removeEventListener("wheel",q),o.grab&&a.removeEventListener("pointerdown",I))}},[l.current]),g.useEffect(()=>{let a=_.current;if(a)return a.addEventListener("pointerdown",J),()=>{a&&a.removeEventListener("pointerdown",J)}},[_.current]),g.useEffect(()=>{let a=L.current;if(a)return a.addEventListener("wheel",Q),()=>{a&&a.removeEventListener("wheel",Q)}},[L.current]),g.useEffect(()=>{W(),N()},[o.children]);const b=()=>{W(),N()},S=(a,d=300)=>{if(!l.current)return;const O=o.horizontal,F=O?l.current.scrollLeft:l.current.scrollTop,ee=a-F,T=performance.now(),P=z=>{if(!l.current)return;const G=z-T,re=Math.min(G/d,1),$=F+ee*re;O?l.current.scrollLeft=$:l.current.scrollTop=$,G({scrollTo:(a,d)=>{S(a,d)},scrollToStart:a=>{S(0,a)},scrollToEnd:a=>{S(t.height,a)},update:()=>{b()},getProperties:()=>t,scrollRef:l}));const E=a=>{var d;t.bar.clicked=!1,t.grab=!1,y(t.hovered),(d=l.current)==null||d.classList.remove("__grabbing")},p=a=>{a.cancelable&&t.bar.clicked&&a.preventDefault()},C=a=>{l.current&&(t.bar.clicked&&(t.bar.offset=M(a),t.bar.offsetDelta=t.bar.offsetStart-t.bar.offset,o.horizontal?l.current.scrollLeft=t.scrollStart+-t.bar.offsetDelta/t.boxHeight*t.height:l.current.scrollTop=t.scrollStart+-t.bar.offsetDelta/t.boxHeight*t.height),t.grab&&(t.grabOffset=M(a),t.grabDelta=t.grabStart-t.grabOffset,o.horizontal?l.current.scrollLeft=t.scrollStart+t.grabDelta:l.current.scrollTop=t.scrollStart+t.grabDelta))},I=a=>{l.current&&(t.bar.clicked||(t.grab=!0,t.grabStart=M(a),o.horizontal?t.scrollStart=l.current.scrollLeft:t.scrollStart=l.current.scrollTop,l.current.classList.add("__grabbing")))},J=a=>{l.current&&(t.bar.clicked=!0,t.bar.offsetStart=M(a),o.horizontal?t.scrollStart=l.current.scrollLeft:t.scrollStart=l.current.scrollTop)},Q=a=>{a.preventDefault(),l.current&&(o.horizontal?l.current.scrollLeft+=a.deltaX:l.current.scrollTop+=a.deltaY)},q=a=>{let d=a;if(d.shiftKey||!l.current||o.horizontal&&!o.horizontalScroll)return;let O=d.wheelDeltaY,F=!1;O?O===d.deltaY*-3&&(F=!0):d.deltaMode===0&&(F=!0),F||(d.preventDefault(),l.current.scrollLeft+=d.deltaY/4),W(),N()},j=a=>{a.stopPropagation(),W(),N()},m=()=>{(o.showWhenMinimal||t.height>t.boxHeight)&&(t.hovered=!0,y(!0))},le=()=>{t.hovered=!1,!t.grab&&(t.bar.clicked||y(!1))},W=()=>{l.current&&(o.horizontal?(t.height=l.current.scrollWidth,t.top=l.current.scrollLeft,t.boxHeight=l.current.clientWidth):(t.height=l.current.scrollHeight,t.top=l.current.scrollTop,t.boxHeight=l.current.clientHeight),t.progress=t.top/(t.height-t.boxHeight),t.inited=!0)},M=a=>{if("x"in a)return o.horizontal?a.x:a.y;{const d=a.touches[0];return o.horizontal?d.clientX:d.clientY}},N=()=>{var a,d,O;_.current&&(t.bar.height=100/(t.height/t.boxHeight),o.horizontal?(_.current.style.width=`${t.bar.height}%`,_.current.style.left=`${t.progress*100-t.progress*t.bar.height}%`):(_.current.style.height=`${t.bar.height}%`,_.current.style.top=`${t.progress*100-t.progress*t.bar.height}%`),t.progress===0&&((a=o.onReachStart)==null||a.call(o)),t.progress===1&&((d=o.onReachEnd)==null||d.call(o)),(O=o.onScroll)==null||O.call(o,t.progress))},se=["scroller",Z(o.className),D(o.horizontal,"horizontal"),D(o.needBar,"bar"),D(o.grabCursor,"grab"),D(o.autoHide,"autoHide"),D(o.barAltPosition,"barAlt"),D(o.borderPadding,"borderPadding"),D(o.borderFade,"borderFade"),D(Y,"hovered")].join(" ");return X.jsxs("div",{className:se,onPointerEnter:m,onPointerLeave:le,children:[o.needBar&&X.jsx("div",{className:`scroller__bar ${Z(o.barClassName)}`,ref:L,children:X.jsx("div",{className:`scroller__bar_roller ${Z(o.barRollerClassName)}`,ref:_})}),X.jsx("div",{className:`scroller__content ${Z(o.contentClassName)}`,ref:l,children:o.children})]})})});