morphing-scroll 2.0.0 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- ![logo](https://raw.githubusercontent.com/voodoofugu/morphing-scroll/refs/heads/main/src/assets/banner-logo.jpg?v=1)
1
+ ![logo](https://raw.githubusercontent.com/voodoofugu/morphing-scroll/refs/heads/main/src/assets/banner-logo.jpg)
2
2
 
3
3
  <h2></h2>
4
4
 
@@ -33,6 +33,20 @@ To install the library, use the following command:
33
33
  npm install morphing-scroll
34
34
  ```
35
35
 
36
+ Next, import the `MorphScroll` component into your React application:
37
+
38
+ ```tsx
39
+ import { MorphScroll } from "morphing-scroll";
40
+ ```
41
+
42
+ Start using the `MorphScroll` component by defining the required `size` prop. For better precision and control, it's recommended to begin by understanding the `objectsSize` and `progressTrigger` props, which are explained below.
43
+
44
+ > **✦ Note:**
45
+ > `MorphScroll` exports both **CommonJS** and **ESM** builds:
46
+ >
47
+ > - **Modern bundlers** (e.g. _Vite_, _Webpack 5_, _esbuild_) use the **ESM** (`import`) build
48
+ > - **Node.js** (and older environments) use the **CommonJS** (`require`) build
49
+
36
50
  <h2></h2>
37
51
 
38
52
  ### 〈 Components 〉
@@ -270,8 +284,8 @@ npm install morphing-scroll
270
284
  <summary><b><code>objectsSize</code></b>: <em>[width, height] dimension of cells for each object.</em></summary><br />
271
285
  <ul>
272
286
  <b>Type:</b><br />
273
- number | "firstChild"<br />
274
- | (number | "none" | "firstChild")[]<br />
287
+ number | "size" | "firstChild" | "none"<br />
288
+ | (number | "size" | "firstChild" | "none")[]<br />
275
289
  <br />
276
290
  <b>Default:</b> If you don't provide any value, the default value will be taken from <code>size</code><br />
277
291
  <br />
@@ -280,14 +294,22 @@ npm install morphing-scroll
280
294
  <br />
281
295
  <mark>number</mark> - Sets a fixed size for your custom objects.<br />
282
296
  <br />
283
- <mark>"none"</mark> - Cells will still be created, but <code>MorphScroll</code> will not calculate their sizes-they will simply wrap your objects.<br />
297
+ <mark>"size"</mark> - The dimensions will be taken from <code>size</code>.<br />
284
298
  <br />
285
299
  <mark>"firstChild"</mark> - Creates a <code>ResizeTracker</code> wrapper for the first child of your list. This wrapper will calculate the size of the first child, and these dimensions will be applied to all cells in the list.<br />
286
300
  <br />
301
+ <mark>"none"</mark> - Cells will still be created, but <code>MorphScroll</code> will not calculate their sizes-they will simply wrap your objects.<br />
302
+ <br />
303
+ <mark>undefined</mark> - If no value is provided, the default behavior is partially inferred from the <code>size</code> prop:
304
+ <ul>
305
+ <li>When <code>direction="x"</code>, the height from <code>size</code> will be used, behaving as if you had passed <code>objectsSize=["size", "none"]</code>.</li>
306
+ <li>When <code>direction="y"</code>, the width from <code>size</code> will be used, behaving as if you had passed <code>objectsSize=["none", "size"]</code>.</li>
307
+ </ul>
308
+ <br />
287
309
  ✦ Note:<br />
288
310
  <ul>
289
- <li>All types except "none" can be used as 1 value, or an array of 2 values.</li>
290
- <li><mark>"none"</mark> is not compatible with <code>render={{ type: "virtual" }}</code>.</li>
311
+ <li>All types can be used as 1 value, or an array of 2 values.</li>
312
+ <li><mark>"none"</mark> is not compatible with <code>render</code>.</li>
291
313
  </ul></em><br />
292
314
  <br />
293
315
  <b>Example:</b>
@@ -1016,6 +1038,8 @@ npm install morphing-scroll
1016
1038
  <ul>
1017
1039
  <b>Type:</b> number | number[]<br />
1018
1040
  <br />
1041
+ <b>Default:</b> 0<br />
1042
+ <br />
1019
1043
  <b>Description:</b> <em><br />
1020
1044
  Specifies at what percentage of the observed element’s visibility the callback should be executed.<br />
1021
1045
  <br />
@@ -1048,7 +1072,7 @@ npm install morphing-scroll
1048
1072
  <br />
1049
1073
  <b>Description:</b> <em><br />
1050
1074
  If set to <mark>true</mark>, the tracked elements will always be visible, regardless of their actual intersection status.<br />
1051
- This can be useful for testing purposes or when using the <code>onVisible</code> callback, ensuring it continues to trigger whenever the element enters the viewport.</em><br />
1075
+ This is useful for testing purposes or when using the <code>onVisible</code> callback, ensuring that it reliably triggers whenever the element enters the viewport, even if all elements are already visible.</em><br />
1052
1076
  <br />
1053
1077
  <b>Example:</b>
1054
1078
 
@@ -1081,9 +1105,7 @@ npm install morphing-scroll
1081
1105
  <li><code>rootBounds</code>: The bounding rectangle of the root element relative to the viewport.</li>
1082
1106
  <li><code>target</code>: The observed element.</li>
1083
1107
  <li><code>time</code>: The timestamp when the intersection state changed.</li>
1084
- </ul>
1085
- <br />
1086
- More information in the <b>Link</b> below.</em><br />
1108
+ </ul></em>
1087
1109
  <br />
1088
1110
  <b>Example:</b>
1089
1111
 
package/cjs/index.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";var e=require("react");const t=(e,t=!1,r)=>{let n=[];if(n=Array.isArray(e)?2===e.length?[e[1],e[0],e[1],e[0]]:[...e]:[e,e,e,e],t&&(n=[n[1],n[0],n[3],n[2]]),r){const e=[];for(let t=0;r>t;t++)e.push(n[t%4]);n=e}return n},r=({className:t,children:r,style:n,measure:o="inner",onResize:l})=>{const s=e.useRef(null);e.useEffect((()=>{const e=s.current;if(!e)return;const t=new ResizeObserver((e=>{for(const t of e)l&&l(t.contentRect)}));return t.observe(e),()=>{t.unobserve(e),t.disconnect()}}),[o,l]);const i={minWidth:"100%",minHeight:"100%"},c={width:"max-content",height:"max-content"},a={inner:Object.assign({},c),outer:Object.assign({},i),all:Object.assign(Object.assign({},i),c)};return e.createElement("div",{"resize-tracker":"",className:t,ref:s,style:Object.assign(Object.assign({},a[o]),n)},r)};function n(t,r){const n=e.useMemo((()=>function(e,r){let n=null;const o=(...e)=>{n&&clearTimeout(n),n=setTimeout((()=>{((...e)=>{t(...e)})(...e)}),r)};return o.cancel=()=>{n&&(clearTimeout(n),n=null)},o}(0,r)),[r]);return e.useEffect((()=>()=>{n.cancel()}),[n]),n}let o=1;var l=e.memo((({type:t,direction:r,progressReverse:n,size:o,progressTrigger:l,scrollBarOnHover:s,scrollBarEvent:i,thumbSize:c,thumbSpace:a,objLengthPerSize:u,sliderCheckLocal:d,duration:m})=>{const p="sliderMenu"!==t?{onMouseDown:i,onTouchStart:i}:{},f=e.useMemo((()=>{if("scroll"===t||!r)return;const n=["hybrid","y"].includes(r)?"y":"x",s="x"===n?o[0]:o[1];return Array.from({length:u},((r,o)=>e.createElement("div",{key:o,className:"sliderElem",style:Object.assign({},"sliderMenu"===t&&{cursor:"pointer"}),onClick:"sliderMenu"===t?()=>{i(s*o,n,m,d)}:void 0},Array.isArray(null==l?void 0:l.progressElement)?l.progressElement[o]:null==l?void 0:l.progressElement)))}),[u,r,o,t,i,null==l?void 0:l.progressElement]);return e.createElement(e.Fragment,null,"scroll"===t?e.createElement("div",{className:"ms-bar",style:Object.assign(Object.assign(Object.assign({position:"absolute",width:"fit-content"},"x"===r?Object.assign({transformOrigin:"left top",height:o[0]+"px"},n?{top:0,transform:"rotate(-90deg) translateX(-100%)"}:{transform:"rotate(-90deg)"}):Object.assign({top:0,height:"100%"},n?{left:0}:{right:0})),0!=!(null==l?void 0:l.progressElement)&&{pointerEvents:"none"}),s&&{opacity:0,transition:"opacity 0.1s ease-in-out"})},e.createElement("div",Object.assign({className:"ms-thumb","data-direction":["hybrid","y"].includes(r)?"y":r},p,{style:Object.assign({height:c+"px",willChange:"transform",transform:`translateY(${a}px)`},(null==l?void 0:l.progressElement)&&{cursor:"grab"})}),null==l?void 0:l.progressElement)):u>1&&(null==l?void 0:l.progressElement)&&e.createElement("div",Object.assign({className:"ms-slider","data-direction":["hybrid","y"].includes(r)?"y":r},p,{style:Object.assign(Object.assign(Object.assign({position:"absolute",display:"flex"},"slider"===t&&{cursor:"grab"}),s&&{opacity:0,transition:"opacity 0.1s ease-in-out"}),"x"===r?Object.assign({transformOrigin:"left top",left:"50%",transform:"translateX(-50%)"},n?{top:0}:{bottom:0}):Object.assign({flexDirection:"column",top:"50%",transform:"translateY(-50%)"},n?{left:0}:{right:0}))}),f))})),s=e.memo((({edgeGradient:t,visibility:r,edgeType:n})=>{if(!t)return null;const o=Object.assign(Object.assign(Object.assign(Object.assign({position:"absolute",pointerEvents:"none",transition:"opacity 0.1s ease-in-out"},t.color&&{background:t.color&&`linear-gradient(${"right"===n||"left"===n?"90deg, ":""}${t.color}, transparent)`}),"right"===n||"left"===n?{height:"100%",width:t.size+"px",top:0}:{width:"100%",height:t.size+"px",left:0}),n?{[n]:0}:{}),"right"===n?{transform:"scaleX(-1)"}:"bottom"===n?{transform:"scaleY(-1)"}:{});return e.createElement("div",{className:"ms-edge"+(n?" "+n:""),style:Object.assign(Object.assign({},o),{opacity:r?1:0})})})),i=e.memo((({activity:t,arrows:r,arrowType:n,handleArrow:o,size:l})=>{const s=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({position:"absolute",display:"flex",justifyContent:"center",alignItems:"center",cursor:"pointer",width:r.size+"px"},n?{[n]:0}:{}),"top"===n&&{transform:"rotate(-90deg) translateX(-100%)",transformOrigin:"left top"}),"bottom"===n&&{transform:"rotate(90deg) translateX(-100%)",transformOrigin:"left bottom"}),"left"===n&&{transform:"scaleX(-1)"}),["top","bottom"].includes(n)?{height:l+"px"}:{height:"100%",top:0});return e.createElement("div",{className:`ms-arrow-box ${n}${t?" active":""}`,style:Object.assign({},s),onClick:()=>o(n)},r.element)}));function c(e,t){return e>t?Math.floor(e/t):1}function a(e,t=0,r=1/0){return Math.max(t,Math.min(Math.round(e),r))}const u=(e,t,r)=>{if(!t)return;const n=t.querySelectorAll("."+("scroll"===e?"ms-thumb":"ms-slider"));n.length>0&&(r.current=n)},d=e=>e?"start"===e?"flex-start":"center"===e?"center":"flex-end":void 0;function m(e,t,r=0,n=0){return o=>{var l,s,i,c;const a={width:(null!==(l=o.width)&&void 0!==l?l:0)-r,height:(null!==(s=o.height)&&void 0!==s?s:0)-n};(null===(i=e.current)||void 0===i?void 0:i.width)===a.width&&(null===(c=e.current)||void 0===c?void 0:c.height)===a.height||(e.current=a,t())}}function p(t){const r=[],n=t=>{if(null===t||"number"==typeof t||"boolean"==typeof t||"bigint"==typeof t)r.push(t+"");else if("string"==typeof t)r.push(t);else if("function"==typeof t)r.push("<function>");else if(e.isValidElement(t))r.push("<react-node>");else if(Array.isArray(t))t.forEach(n);else if("object"==typeof t){const e=Object.entries(t).sort((([e],[t])=>e.localeCompare(t)));for(const[,t]of e)n(t)}else void 0===t&&r.push("<undefined>")};return n(t),r.join("/")}function f(e){var t,r,n;const o={x:"touches"in e.mouseEvent?e.mouseEvent.touches[0].clientX:e.mouseEvent.clientX,y:"touches"in e.mouseEvent?e.mouseEvent.touches[0].clientY:e.mouseEvent.clientY,leftover:null!==(r=null===(t=e.prevCoordsRef.current)||void 0===t?void 0:t.leftover)&&void 0!==r?r:0},l=null!==(n=e.prevCoordsRef.current)&&void 0!==n?n:o,s={x:o.x-l.x,y:o.y-l.y};e.prevCoordsRef.current=o;const i=t=>{if(!e.scrollElementRef||!e.objectsWrapperRef)return;let r=0;const n="x"===t?"movementX"in e.mouseEvent?e.mouseEvent.movementX:s.x:"movementY"in e.mouseEvent?e.mouseEvent.movementY:s.y,o=e.scrollElementRef;if("thumb"===e.clicked){const s=e.objectsWrapperRef,i=getComputedStyle(s),c="x"===t?o.clientWidth:o.clientHeight,a="x"===t?s.clientWidth+parseFloat(i.marginLeft)+parseFloat(i.marginRight):s.clientHeight+parseFloat(i.marginTop)+parseFloat(i.marginBottom),u=c-e.thumbSize,d=a-c;if(0>=u||0>=d)return;const m=n*(d/u)+l.leftover,p=Math.trunc(m),f=m-p;e.prevCoordsRef.current.leftover=f,r=p}else r=-n;"x"===t?(o.scrollLeft+=r,e.scrollStateRef.targetScrollX=o.scrollLeft):(o.scrollTop+=r,e.scrollStateRef.targetScrollY=o.scrollTop)},c=t=>{const r=e.objectsWrapperRef;if(!r)return;const n="slider"===e.type&&"wrapp"===e.clicked?-1:1,o=s[t]*n,l="x"===t?e.sizeLocal[0]:e.sizeLocal[1],i="x"===t?r.offsetWidth:r.offsetHeight,c="x"===t?e.scrollElementRef.scrollLeft:e.scrollElementRef.scrollTop;e.numForSliderRef.current+=Math.abs(o),e.numForSliderRef.current>6&&!e.isScrollingRef.current&&(o>0&&i>c+l?e.smoothScroll(c+l,t,e.duration):0>o&&c>0&&e.smoothScroll(c-l,t,e.duration),e.numForSliderRef.current=0)},a=t=>{"thumb"===e.clicked?i(t):"wrapp"===e.clicked?"slider"===e.type?c(t):i(t):"slider"===e.clicked&&c(t)};"hybrid"===e.direction?"wrapp"===e.clicked?(a("x"),a("y")):e.axisFromAtr&&a(e.axisFromAtr):a(e.direction||"y")}function g(e){if(e.controller.abort(),document.body.style.removeProperty("cursor"),["thumb","slider"].includes(e.clicked)&&e.mouseOnEl(e.scrollBar),"wrapp"===e.clicked&&e.mouseOnEl(e.objectsWrapperRef),e.clickedObject.current="none",e.scrollBarOnHover){let t=e.mouseEvent.target,r=!1;for(;t&&t!==document.body;){if(t===e.scrollContentRef){r=!0;break}t=t.parentNode}r||e.mouseOnRefHandle(e.mouseEvent)}e.prevCoordsRef.current=null,e.triggerUpdate()}const h=e=>{e&&("grab"===e.style.cursor?(e.style.cursor="grabbing",e.classList.add("active")):"grabbing"===e.style.cursor&&(e.style.cursor="grab",e.classList.remove("active")))},v="wrap-id",b=new Map,y=(e,t,r)=>{x(e);const n=setTimeout((()=>{t(),b.delete(e)}),r);b.set(e,n)},x=e=>{const t=b.get(e);t&&(clearTimeout(t),b.delete(e))};exports.IntersectionTracker=({className:r,children:n,style:o,root:l,threshold:s,rootMargin:i,visibleContent:c=!1,onVisible:a})=>{const[u,d]=e.useState(!1),m=e.useRef(null),p=e.useMemo((()=>{if(!i)return"";const e=t(i);return`${e[0]}px ${e[1]}px ${e[2]}px ${e[3]}px`}),[i]),f=e.useCallback((([e])=>{d(e.isIntersecting),e.isIntersecting&&a&&a(e)}),[a]);return e.useEffect((()=>{const e=new IntersectionObserver(f,{root:l,threshold:s,rootMargin:p});return m.current&&e.observe(m.current),()=>{e.disconnect()}}),[f,l,s,p]),e.createElement("div",{"intersection-tracker":"",className:r,ref:m,style:o},c||u?n:null)},exports.MorphScroll=({type:x="scroll",className:E,size:j,objectsSize:O,direction:w="y",gap:S,wrapperMargin:R,wrapperMinSize:M,progressReverse:k=!1,progressTrigger:T={wheel:!0},scrollBarOnHover:z=!1,suspending:A=!1,fallback:C,scrollPosition:L,edgeGradient:F,children:N,onScrollValue:I,elementsAlign:$,elementsDirection:W="row",wrapperAlign:X,isScrolling:H,render:Y,emptyElements:B,crossCount:P})=>{var q,D,V,K,G,U;const _=n((()=>{Mt()}),40),J=n((()=>{ht()}),34),Q=function(){const t=e.useRef(null);return null===t.current&&(t.current=""+o++),t.current}();if(!j)throw Error(`Prop "size" is not provided\nMorphScroll〈♦${Q}〉`);Object.keys(T).length;const[Z,ee]=e.useState(0),te=()=>{ee((e=>"number"==typeof e&&1e3>e?e+1:0))},re=e.useRef(null),ne=e.useRef(null),oe=e.useRef(null),le=e.useRef(null),se=e.useRef([]),ie=e.useRef(null),ce=e.useRef("none"),ae=e.useRef({loaded:[],empty:[]}),ue=e.useRef({targetScrollY:0,targetScrollX:0,animating:!1,animationFrameId:0}),de=e.useRef(!1),me=e.useRef(0),pe=e.useRef(null);function fe(){return e.useRef({width:0,height:0})}const ge=fe(),he=fe(),ve=fe(),[be,ye,xe,Ee,je,Oe,we,Se]=function(...e){return e.map(p)}(null==L?void 0:L.value,Y,j,O,B,M,X,S),Re=e.useMemo((()=>{var e,t;return{value:"number"==typeof(null==L?void 0:L.value)||"string"==typeof(null==L?void 0:L.value)?[L.value,L.value]:null!==(e=null==L?void 0:L.value)&&void 0!==e?e:[null],duration:null!==(t=null==L?void 0:L.duration)&&void 0!==t?t:200}}),[be,null==L?void 0:L.duration]),Me={color:null,size:40},ke=e.useMemo((()=>"object"==typeof F?Object.assign(Object.assign({},Me),F):Me),[F]),Te=e.useMemo((()=>Object.assign(Object.assign({},Me),"object"==typeof T.arrows?T.arrows:{})),[T.arrows]),ze=e.useCallback((t=>{if(null==t)return[];if(e.isValidElement(t)){const r=t;return r.type===e.Fragment?e.Children.toArray(r.props.children).flatMap(ze):[r]}return[t]}),[]),Ae=e.useMemo((()=>e.Children.toArray(N).flatMap(ze).map((t=>e.isValidElement(t)&&t.key?t.key+"":null)).filter((e=>null!==e)).filter((e=>{var t;return"clear"!==(null==B?void 0:B.mode)||!(null===(t=ae.current.empty)||void 0===t?void 0:t.includes(e))}))),[N,je,null===(q=ae.current.empty)||void 0===q?void 0:q.join()]),[Ce,Le,Fe,Ne]=R?t(R):[0,0,0,0],Ie=Ce+Fe,$e=Ne+Le,[We,Xe]=e.useMemo((()=>{var e,t;return"number"==typeof S?[S,S]:Array.isArray(S)?[null!==(e=S[1])&&void 0!==e?e:0,null!==(t=S[0])&&void 0!==t?t:0]:[0,0]}),[S]),He=e.useMemo((()=>t((null==Y?void 0:Y.rootMargin)||0,"x"===w)),[ye,w]),[Ye,Be]=He?[He[2],He[0]]:[0,0],Pe=e.useMemo((()=>{const[e,t]=Array.isArray(j)?j:"number"==typeof j?[j,j]:[ge.current.width,ge.current.height];if(!T.arrows||!Te.size)return[e,t,e,t];const r=2*Te.size;let n=e,o=t;return"x"===w?n=e-r:"y"===w?o=t-r:"hybrid"===w&&(n=e-r,o=t-r),[n,o,e,t]}),[xe,Te.size,ge.current]),qe="x"===w?Pe[0]:Pe[1],De=e.useMemo((()=>O?Array.isArray(O)?O:t(O,!0,2):[null,null]),[Ee]),Ve=JSON.stringify(De),Ke=e.useMemo((()=>{const e=(e,t)=>"number"==typeof e?e:"firstChild"===e?t:0;return[e(De[0]&&"none"!==De[0]&&"size"!==De[0]?De[0]:"y"===w&&"none"!==De[0]||"size"===De[0]?Pe[0]:0,ve.current.width),e(De[1]&&"none"!==De[1]&&"size"!==De[1]?De[1]:"x"===w&&"none"!==De[1]||"size"===De[1]?Pe[1]:0,ve.current.height)]}),[Ve,ve.current]),Ge=e.useMemo((()=>{const e="x"===w,t="row"===W,r="column"===W,n=e?Pe[1]:Pe[0],o=e?Ke[1]+Xe:Ke[0]+We,l="hybrid"===w?o*(Ae.length+1)-o:n,s=Math.floor(l/o)||1,i=P&&s>=P?"hybrid"===w?Math.ceil(s/P):P:s,c=i>1&&i<Ae.length?Math.ceil(Ae.length/i):i>Ae.length?1:Ae.length,a=P&&P<Ae.length,u=e=>Number.isFinite(e)&&e>0?e:1;if("hybrid"===w){const e=a?t?P:i:t?Ae.length:1,n=a?r?P:i:r?Ae.length:1;return[u(e),u(n)]}return[u(i),u(c)]}),[Ae.length,w,Ke.join(),Pe.join(),We,$e,Ie,P]),Ue=e.useMemo((()=>{const e=Ge[0]?Ge[0]*Xe-Xe:0,t="x"===w?Ge[1]:Ge[0];return Ke[0]?(Ke[0]+Xe)*t-Xe:(null==Y?void 0:Y.type)?ve.current.width+e:he.current.width}),[Ke[0],Ge.join(),Xe,he.current.width,ve.current,ye]),_e=e.useMemo((()=>{const e=1>Ge[1]?1:Ge[0]*We-We;return Ke[1]?"x"===w?(Ke[1]+We)*Ge[0]-We:(Ke[1]+We)*Ge[1]-We:(null==Y?void 0:Y.type)?ve.current.height+e:he.current.height}),[Ke[1],Ge.join(),We,he.current.height,ve.current,ye]),Je=e.useMemo((()=>_e+Ie),[_e,Ie]),Qe=e.useMemo((()=>Ue+$e),[Ue,$e]),Ze="x"===w?Qe:Je,et="x"===w?(null===(D=oe.current)||void 0===D?void 0:D.scrollLeft)||0:(null===(V=oe.current)||void 0===V?void 0:V.scrollTop)||0,tt=et>1&&!0,rt=Ze>Math.round(et+qe);let nt=!1,ot=!1;"hybrid"===w&&(nt=((null===(K=oe.current)||void 0===K?void 0:K.scrollLeft)||0)>1&&!0,ot=Math.round(((null===(G=oe.current)||void 0===G?void 0:G.scrollLeft)||0)+Pe[0])<Qe);const lt=e.useMemo((()=>{if(!T.progressElement||!Ze)return 0;const e=Math.round(qe/Ze*qe);return!Number.isFinite(e)||0>e?0:e}),[qe,Ze,T.progressElement]),st=e.useMemo((()=>{if(!T.progressElement)return 0;const e=Math.round(Pe[0]/Qe*Pe[0]);return!Number.isFinite(e)||0>e?0:e}),[Pe[0],Qe,T.progressElement]),it=e.useMemo((()=>qe?Ze-qe:Ze),[Ze,qe]),ct=e.useMemo((()=>Pe[0]?Qe-Pe[0]:Qe),[Qe,Pe[0]]),at=e.useCallback((()=>{if(!(null==Y?void 0:Y.type)||1>=Ge[0])return[];const e=Array.from({length:Ae.length},((e,t)=>t)),t=Array.from({length:Ge[0]},(()=>[])),r="x"===w&&"column"===W||"x"!==w&&"row"===W;return e.forEach((e=>{const n=r?e%Ge[0]:Math.floor(e/Ge[1]);t[n]&&t[n].push(e)})),t}),[Ae.length,Ge.join(),ye,W,w]),ut=e.useMemo((()=>{if(!(null==Y?void 0:Y.type))return[{elementTop:0,elementBottom:0,left:0,right:0}];let e=[],t=0;if($){const r=Array.from({length:Ae.length},((e,t)=>t)),n=Math.abs(Math.floor(Ae.length/Ge[0])*Ge[0]-Ae.length);e=n?r.slice(-n):[],"center"===$?t=(Ke[0]+Xe)*(Ge[0]-n)/2:"end"===$&&(t=(Ke[0]+Xe)*(Ge[0]-n))}return Ae.map(((r,n)=>{const o=function(e,t){for(let r=0;r<t.length;r++){const n=t[r].indexOf(e);if(-1!==n)return["x"===w?n:r,["hybrid","y"].includes(w)?n:r]}return[0,0]}(n,at()),l=e.length>0&&e.includes(n)?t:0,s=function(e){const t="x"===w?l:0;return e>0?t+(Ke[1]+We)*e:t}(Ge[0]>1||["hybrid","x"].includes(w)?o[1]:n),i=Ke[1]?s+Ke[1]:s,c=function(e){const t="x"===w?0:l;return e>0?t+(Ke[0]+Xe)*e:t}(1===Ge[0]&&"x"===w?n:o[0]);return{elementTop:s,elementBottom:i,left:c,right:c+Ke[0]}}))}),[N,Ke.join(),S,ye,Ge[0],W]),dt=e.useMemo((()=>(null==Pe?void 0:Pe.length)&&X?function(e,t,r,n){const[o,l="start"]="string"==typeof e?[e,e]:e,s={display:"flex"};return t[0]>r&&(s.justifyContent=d(o)),t[1]>n&&(s.alignItems=d(l)),s}(X,Pe,Qe,Je):{}),[X,Pe.join(),Je,Qe]),mt=e.useMemo((()=>[c(Qe,Pe[0]),c(Je,Pe[1])]),[Qe,Je,Pe.join()]),pt=e.useMemo((()=>"x"===w?mt[0]:mt[1]),[w,mt[0],mt[1]]),ft=e.useCallback((e=>{if(!z)return;const t=()=>((e,t,r,n)=>{e&&e.querySelectorAll(".ms-bar").forEach(((e,t)=>{const o=e;["mouseleave","mouseup","touchend"].includes(r.type)?(o.style.opacity="0",o.classList.remove("hover"),o.classList.add("leave"),n(`mouseOnRef${t}-anim`,(()=>o.classList.remove("leave")),200)):(o.style.opacity="1",o.classList.add("hover"))}))})(ne.current,0,e,y);"mouseleave"===e.type?!["thumb","slider","wrapp"].includes(ce.current)&&t():t()}),[z,x,ce.current,ne.current]),gt=e.useCallback((e=>{oe.current&&(({arrowType:e,scrollElement:t,wrapSize:r,scrollSize:n,smoothScroll:o,duration:l})=>{const s=r[0],i=r[1],c=t.scrollTop,u=t.scrollLeft,d=["top","bottom"].includes(e)?i:s,m=(e,t)=>o(a(e,0,d),t,l);"top"===e&&c>0?m(c-n[1],"y"):"left"===e&&u>0&&m(u-n[0],"x"),"bottom"===e&&c+n[1]!==i?m(c+n[1],"y"):"right"===e&&u+n[0]!==s&&m(u+n[0],"x")})({arrowType:e,scrollElement:oe.current,wrapSize:[Qe,Je],scrollSize:Pe,smoothScroll:Ot,duration:Re.duration})}),[oe.current,Pe.join(),Qe,Je,Re.duration]),ht=e.useCallback((()=>{u(x,re.current,se);const e=oe.current;ne.current&&e&&0!==se.current.length&&((e,t,r,n)=>{!function(){var o,l,s,i;const c=null!==(l=null===(o=t[0])||void 0===o?void 0:o.querySelectorAll(".sliderElem"))&&void 0!==l?l:[],a=null!==(i=null===(s=t[1])||void 0===s?void 0:s.querySelectorAll(".sliderElem"))&&void 0!==i?i:[];function u(e,t,r,n){const o="x"===n?r.scrollLeft:r.scrollTop;e.forEach(((e,r)=>{const l="x"===n?t[0]:t[1],s=o>=l*r&&l*(r+1)>o;e.classList.toggle("active",s)}))}c.length>0&&u(c,r,e,n),a.length>0&&u(a,r,e,"x")}()})(e,se.current,Pe,w)}),[Pe.join(),w,oe,ne,se,x]),vt=e.useCallback((()=>{const e=oe.current;e&&(null==I||I(e.scrollLeft,e.scrollTop),de.current=!0,null==H||H(!0),y("handleScroll-anim",(()=>{de.current=!1,null==H||H(!1),(null==Y?void 0:Y.type)?te():_()}),200),"slider"===x&&J(),(null==Y?void 0:Y.type)||_(),te())}),[w,I,H,ye,x,J]),bt=a(et/it*(qe-lt),0,qe-lt),yt=a(((null===(U=oe.current)||void 0===U?void 0:U.scrollLeft)||0)/ct*(Pe[0]-Pe[0]/Qe*Pe[0]),0,Pe[0]-st),xt=e.useCallback(m(ge,te),[]),Et=e.useCallback(m(he,te,$e,Ie),[$e,Ie]),jt=e.useCallback(m(ve,te),[]),Ot=e.useCallback(((e,t,r,n)=>{const o=oe.current;return o?function(e,t,r,n,o){let l;if(!t&&!n)return null;const s=performance.now(),i=t.scrollTop,c=t.scrollLeft,a=u=>{const d=Math.min((u-s)/r,1);"y"===e?t.scrollTop=i+(n-i)*d:"x"===e&&(t.scrollLeft=c+(n-c)*d),1>d?l=requestAnimationFrame(a):null==o||o()};return l=requestAnimationFrame(a),()=>cancelAnimationFrame(l)}(t,o,r,e,n):null}),[oe]),wt=e.useCallback(((e,t="mousedown",r)=>{const n=e||("scroll"===x?"thumb":"slider");if("wrapp"===e&&!T.content||["thumb","slider"].includes(n)&&!T.progressElement)return;u(x,re.current,se);let o=null;r&&(o=r.getAttribute("data-direction")),function(e){const t=new AbortController,{signal:r}=t;e.clickedObject.current=e.clicked,e.triggerUpdate(),"mousedown"===e.eventType?(["thumb","slider"].includes(e.clicked)&&e.mouseOnEl(e.scrollBar),"wrapp"===e.clicked&&e.mouseOnEl(e.objectsWrapperRef),document.addEventListener("mousemove",(t=>f(Object.assign(Object.assign({},e),{mouseEvent:t}))),{signal:r}),document.addEventListener("mouseup",(r=>g(Object.assign(Object.assign({},e),{mouseEvent:r,controller:t}))),{signal:r})):"touchstart"===e.eventType&&(document.addEventListener("touchmove",(t=>{t.preventDefault(),f(Object.assign(Object.assign({},e),{mouseEvent:t}))}),{signal:r,passive:!1}),document.addEventListener("touchend",(r=>g(Object.assign(Object.assign({},e),{mouseEvent:r,controller:t}))),{signal:r})),document.body.style.cursor="grabbing"}({eventType:t,scrollElementRef:oe.current,objectsWrapperRef:le.current,scrollBar:r||null,clickedObject:ce,scrollContentRef:ne.current,scrollStateRef:ue.current,type:x,scrollBarOnHover:z,mouseOnEl:h,mouseOnRefHandle:ft,triggerUpdate:te,direction:w,smoothScroll:Ot,sizeLocal:[Pe[0],Pe[1]],clicked:n,numForSliderRef:me,isScrollingRef:de,prevCoordsRef:pe,thumbSize:"x"===o?st:lt,axisFromAtr:o,duration:Re.duration})}),[x,T.content,T.progressElement,Pe.join(),lt,st,Re.duration]),St=e.useCallback((e=>{wt(null,e.type,e.target)}),[wt]),Rt=e.useCallback((()=>{wt("wrapp")}),[wt]),Mt=e.useCallback((()=>{re.current&&((e,t,r,n)=>{const{allIds:o,emptyKeysRaw:l}=(()=>{const t=[],r=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>e instanceof Element&&e.hasAttribute(v)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});let o=n.nextNode();for(;o;){const e=o,l=e.getAttribute(v);l&&(t.push(l),0===e.children.length&&r.push(l)),o=n.nextNode()}return{allIds:t,emptyKeysRaw:r}})(),s=new Set(t.current.loaded);o.forEach((e=>s.add(e)));let i=null;if(t.current.empty){const e=new Set(t.current.empty);l.forEach((t=>e.add(t))),i=Array.from(e)}t.current={loaded:"lazy"===n?Array.from(s):o.map((e=>e)),empty:i},r()})(re.current,ae,te,null==Y?void 0:Y.type)}),[ye]),kt=e.useCallback((e=>{(null==B?void 0:B.clickTrigger)&&((e,t,r,n)=>{e.target.closest(r.selector)&&t("emptyKeys-anim",(()=>{n()}),r.delay||0)})(e,y,B.clickTrigger,Mt)}),[je]),Tt=e.useCallback(((e,t,r)=>{if(ie.current){if(ie.current!==Ae[0])return void(ie.current=Ae[0])}else ie.current=Ae[0];const n=Ot(t,e,Re.duration);n&&r.push(n)}),[Ae[0],Re.duration]),zt=e.useMemo((()=>{const e=Object.assign(Object.assign(Object.assign(Object.assign({margin:R?`${Ce}px ${Le}px ${Fe}px ${Ne}px`:"",height:De[1]&&"none"!==De[1]?_e+"px":"fit-content",width:De[0]&&"none"!==De[0]?Ue+"px":"fit-content"},T.content&&{cursor:"grab"}),S&&!(null==Y?void 0:Y.type)&&{gap:`${We}px ${Xe}px`}),M&&function(e,t,r,n,o){const l=(e,t)=>"full"===e?("x"===t?r[0]:r[1])-("x"===t?n:o):e;if("hybrid"!==t&&!Array.isArray(e)){const r=l(e,t)+"px";return"x"===t?{minWidth:r}:{minHeight:r}}let s,i;return Array.isArray(e)?[s,i]=e:s=i=e,{minWidth:l(s,"x")+"px",minHeight:l(i,"y")+"px"}}(M,w,Pe,$e,Ie)),X&&{flexShrink:0});if(null==Y?void 0:Y.type)return Object.assign(Object.assign({},e),{position:"relative"});const t=De[1]?"wrap":void 0,r=1===Ge[0]?"y"===w?"column":"row":W;return Object.assign(Object.assign({},e),{display:"flex",flexDirection:r,flexWrap:t,justifyContent:d($)})}),[R,[Ce,Le,Fe,Ne,$e,Ie].join(),De[1],_e,Ue,T.content,Se,[We,Xe].join(),null==Y?void 0:Y.type,Oe,w,Pe.join(),we,Ge[0],W,$]);e.useEffect((()=>{(B||(null==Y?void 0:Y.type))&&(B||null===ae.current.empty||(ae.current.empty=null),_())}),[je,null==Y?void 0:Y.type,ye,de.current,Ae.length]),e.useEffect((()=>(((null==Y?void 0:Y.type)||H)&&(H&&H(!1),te()),ht(),()=>{ue.current.animationFrameId&&cancelAnimationFrame(ue.current.animationFrameId),(()=>{for(const e of b.values())clearTimeout(e);b.clear()})()})),[]),e.useEffect((()=>{const e=oe.current;if(!e)return;const t=T.wheel?t=>function(e,t,r,n){e.preventDefault(),r.animating||(r.targetScrollX=t.scrollLeft,r.targetScrollY=t.scrollTop),"x"===n?r.targetScrollX=a(r.targetScrollX+e.deltaY,0,t.scrollWidth-t.clientWidth+2):r.targetScrollY=a(r.targetScrollY+e.deltaY,0,t.scrollHeight-t.clientHeight+2),r.animating||(r.animating=!0,r.animationFrameId=requestAnimationFrame((function e(){let o=0;"x"===n?(t.scrollLeft+=.4*(r.targetScrollX-t.scrollLeft),o=Math.abs(t.scrollLeft-r.targetScrollX)):(t.scrollTop+=.4*(r.targetScrollY-t.scrollTop),o=Math.abs(t.scrollTop-r.targetScrollY)),o>2.5?r.animationFrameId=requestAnimationFrame(e):(r.animating=!1,null!==r.animationFrameId&&(cancelAnimationFrame(r.animationFrameId),r.animationFrameId=null))})))}(t,e,ue.current,w):e=>e.preventDefault();return e.addEventListener("wheel",t,{passive:!1}),()=>{e.removeEventListener("wheel",t)}}),[w,T.wheel]),e.useEffect((()=>{if(!Re.value)return;const e=[];return("hybrid"===w?["x","y"]:[w]).forEach((t=>{const r="x"===t?0:1;"end"===Re.value[r]&&Tt(t,"x"===t?ct:it,e)})),()=>{e.forEach((e=>e()))}}),[Re.value.join(),be,it,ct,Qe,Je]),e.useEffect((()=>{if(!Re.value)return;const e=[];return("hybrid"===w?["x","y"]:[w]).forEach((t=>{const r="x"===t?0:1;"number"==typeof Re.value[r]&&Tt(t,Re.value[r],e)})),()=>{e.forEach((e=>e()))}}),[be,null==L?void 0:L.updater]);const At=e.useCallback(((t,r,n,o)=>{var l;const s=Object.assign({width:Ke[0]?Ke[0]+"px":void 0,height:Ke[1]?Ke[1]+"px":void 0},(null==Y?void 0:Y.type)&&Object.assign({position:"absolute",top:r+"px",left:n+"px"},!Ke[0]&&1===Ge[0]&&{transform:"translateX(-50%)"})),i=A?e.createElement(e.Suspense,{fallback:C},o):o,c=(null===(l=null==B?void 0:B.clickTrigger)||void 0===l?void 0:l.selector)&&kt;return e.createElement("div",Object.assign({key:t},Y||B?{[v]:""+t}:{},{className:"ms-object-box",style:s,onClick:c}),i)}),[A,!!C,Ke.join(),oe.current,ye,je,Ge[0]]),Ct=e.createElement("div",{className:"ms-objects-wrapper",ref:le,onMouseDown:Rt,style:zt},Ae.map(((t,n)=>{var o,l,s;const i=e.Children.toArray(N).find((r=>e.isValidElement(r)&&r.key===t)),c=(null==Y?void 0:Y.stopLoadOnScroll)&&de.current&&!ae.current.loaded.includes(""+t)?C:(null===(o=ae.current.empty)||void 0===o?void 0:o.includes(t))?"object"==typeof(null==B?void 0:B.mode)?B.mode.fallback:C:i,a="number"==typeof De[0]&&"number"==typeof De[1]||"firstChild"!==De[0]&&"firstChild"!==De[1]||0!==n?c:e.createElement(r,{onResize:jt},c);if(!(null==Y?void 0:Y.type))return At(t,0,0,a);{const{elementTop:e,elementBottom:r,left:o,right:i}=ut[n],c="x"===w?Ye:Be,u=qe+c>("x"===w?o:e)-et&&("x"===w?i:r)-et>0-c,d="hybrid"!==w||Pe[0]+Ye>o-((null===(l=oe.current)||void 0===l?void 0:l.scrollLeft)||0)&&i-((null===(s=oe.current)||void 0===s?void 0:s.scrollLeft)||0)>0-Ye;if(u&&d)return At(t,e,o,a)}}))),Lt=[{positionType:"x"===w?"left":"top",visibility:tt},{positionType:"x"===w?"right":"bottom",visibility:rt},..."hybrid"===w?[{positionType:"left",visibility:nt},{positionType:"right",visibility:ot}]:[]],Ft=e.createElement("div",{"morph-scroll":`〈♦${Q}〉`,className:E,ref:re,style:{width:Pe[2]+"px",height:Pe[3]+"px"}},e.createElement("div",{className:"ms-content",ref:ne,onMouseEnter:ft,onMouseLeave:ft,onTouchStart:ft,onTouchEnd:ft,style:Object.assign({position:"relative",width:Pe[0]+"px",height:Pe[1]+"px"},T.arrows&&Te.size&&("x"===w?{left:Te.size+"px"}:"y"===w?{top:Te.size+"px"}:{top:Te.size+"px",left:Te.size+"px"}))},e.createElement("div",{className:"ms-element",ref:oe,onScroll:vt,style:Object.assign(Object.assign(Object.assign({width:"100%",height:"100%"},dt),{overflow:{x:Qe>Pe[0]?"scroll hidden":"hidden",y:Je>Pe[1]?"hidden scroll":"hidden",hybrid:`${Qe>Pe[0]?"scroll":"hidden"} ${Je>Pe[1]?"scroll":"hidden"}`,hide:"hidden"}[T.wheel||T.content?w:"hide"]}),"scroll"!==x||"boolean"!=typeof T.progressElement||!1===T.progressElement?{scrollbarWidth:"none"}:{})},Ke[0]&&Ke[1]?Ct:e.createElement(r,{onResize:Et,style:Object.assign({},dt)},Ct)),F&&Lt.map((({positionType:t,visibility:r})=>e.createElement(s,{key:"edge-"+t,edgeGradient:ke,visibility:r,edgeType:t}))),T.progressElement&&!0!==T.progressElement&&[{shouldRender:Ze>lt,direction:w,thumbSize:lt,thumbSpace:bt,objLengthPerSize:pt,progressReverseIndex:0},{shouldRender:"hybrid"===w&&Qe>st,direction:"x",thumbSize:st,thumbSpace:yt,objLengthPerSize:mt[0],progressReverseIndex:1}].filter((({shouldRender:e})=>e)).map((t=>e.createElement(l,{key:t.direction,type:x,direction:t.direction,progressReverse:"boolean"==typeof k?k:k[t.progressReverseIndex],size:Pe,progressTrigger:T,scrollBarOnHover:z,scrollBarEvent:"sliderMenu"===x?Ot:St,thumbSize:t.thumbSize,thumbSpace:t.thumbSpace,objLengthPerSize:t.objLengthPerSize,sliderCheckLocal:ht,duration:Re.duration})))),T.arrows&&Lt.map((({positionType:t,visibility:r})=>e.createElement(i,{key:"arrow-"+t,activity:r,arrows:Te,arrowType:t,handleArrow:gt,size:"hybrid"===w?Pe[0]+2*Te.size:Pe[0]}))));return"auto"===j?e.createElement(r,{measure:"outer",onResize:xt},Ft):Ft},exports.ResizeTracker=r;
package/esm/index.js ADDED
@@ -0,0 +1 @@
1
+ import e,{useMemo as t,useEffect as r,useRef as n}from"react";const o=(e,t=!1,r)=>{let n=[];if(n=Array.isArray(e)?2===e.length?[e[1],e[0],e[1],e[0]]:[...e]:[e,e,e,e],t&&(n=[n[1],n[0],n[3],n[2]]),r){const e=[];for(let t=0;r>t;t++)e.push(n[t%4]);n=e}return n},l=({className:t,children:r,style:n,root:l,threshold:s,rootMargin:i,visibleContent:c=!1,onVisible:a})=>{const[u,d]=e.useState(!1),m=e.useRef(null),p=e.useMemo((()=>{if(!i)return"";const e=o(i);return`${e[0]}px ${e[1]}px ${e[2]}px ${e[3]}px`}),[i]),f=e.useCallback((([e])=>{d(e.isIntersecting),e.isIntersecting&&a&&a(e)}),[a]);return e.useEffect((()=>{const e=new IntersectionObserver(f,{root:l,threshold:s,rootMargin:p});return m.current&&e.observe(m.current),()=>{e.disconnect()}}),[f,l,s,p]),e.createElement("div",{"intersection-tracker":"",className:t,ref:m,style:n},c||u?r:null)},s=({className:t,children:r,style:n,measure:o="inner",onResize:l})=>{const s=e.useRef(null);e.useEffect((()=>{const e=s.current;if(!e)return;const t=new ResizeObserver((e=>{for(const t of e)l&&l(t.contentRect)}));return t.observe(e),()=>{t.unobserve(e),t.disconnect()}}),[o,l]);const i={minWidth:"100%",minHeight:"100%"},c={width:"max-content",height:"max-content"},a={inner:Object.assign({},c),outer:Object.assign({},i),all:Object.assign(Object.assign({},i),c)};return e.createElement("div",{"resize-tracker":"",className:t,ref:s,style:Object.assign(Object.assign({},a[o]),n)},r)};function i(e,n){const o=t((()=>function(t,r){let n=null;const o=(...t)=>{n&&clearTimeout(n),n=setTimeout((()=>{((...t)=>{e(...t)})(...t)}),r)};return o.cancel=()=>{n&&(clearTimeout(n),n=null)},o}(0,n)),[n]);return r((()=>()=>{o.cancel()}),[o]),o}let c=1;var a=e.memo((({type:t,direction:r,progressReverse:n,size:o,progressTrigger:l,scrollBarOnHover:s,scrollBarEvent:i,thumbSize:c,thumbSpace:a,objLengthPerSize:u,sliderCheckLocal:d,duration:m})=>{const p="sliderMenu"!==t?{onMouseDown:i,onTouchStart:i}:{},f=e.useMemo((()=>{if("scroll"===t||!r)return;const n=["hybrid","y"].includes(r)?"y":"x",s="x"===n?o[0]:o[1];return Array.from({length:u},((r,o)=>e.createElement("div",{key:o,className:"sliderElem",style:Object.assign({},"sliderMenu"===t&&{cursor:"pointer"}),onClick:"sliderMenu"===t?()=>{i(s*o,n,m,d)}:void 0},Array.isArray(null==l?void 0:l.progressElement)?l.progressElement[o]:null==l?void 0:l.progressElement)))}),[u,r,o,t,i,null==l?void 0:l.progressElement]);return e.createElement(e.Fragment,null,"scroll"===t?e.createElement("div",{className:"ms-bar",style:Object.assign(Object.assign(Object.assign({position:"absolute",width:"fit-content"},"x"===r?Object.assign({transformOrigin:"left top",height:o[0]+"px"},n?{top:0,transform:"rotate(-90deg) translateX(-100%)"}:{transform:"rotate(-90deg)"}):Object.assign({top:0,height:"100%"},n?{left:0}:{right:0})),0!=!(null==l?void 0:l.progressElement)&&{pointerEvents:"none"}),s&&{opacity:0,transition:"opacity 0.1s ease-in-out"})},e.createElement("div",Object.assign({className:"ms-thumb","data-direction":["hybrid","y"].includes(r)?"y":r},p,{style:Object.assign({height:c+"px",willChange:"transform",transform:`translateY(${a}px)`},(null==l?void 0:l.progressElement)&&{cursor:"grab"})}),null==l?void 0:l.progressElement)):u>1&&(null==l?void 0:l.progressElement)&&e.createElement("div",Object.assign({className:"ms-slider","data-direction":["hybrid","y"].includes(r)?"y":r},p,{style:Object.assign(Object.assign(Object.assign({position:"absolute",display:"flex"},"slider"===t&&{cursor:"grab"}),s&&{opacity:0,transition:"opacity 0.1s ease-in-out"}),"x"===r?Object.assign({transformOrigin:"left top",left:"50%",transform:"translateX(-50%)"},n?{top:0}:{bottom:0}):Object.assign({flexDirection:"column",top:"50%",transform:"translateY(-50%)"},n?{left:0}:{right:0}))}),f))})),u=e.memo((({edgeGradient:t,visibility:r,edgeType:n})=>{if(!t)return null;const o=Object.assign(Object.assign(Object.assign(Object.assign({position:"absolute",pointerEvents:"none",transition:"opacity 0.1s ease-in-out"},t.color&&{background:t.color&&`linear-gradient(${"right"===n||"left"===n?"90deg, ":""}${t.color}, transparent)`}),"right"===n||"left"===n?{height:"100%",width:t.size+"px",top:0}:{width:"100%",height:t.size+"px",left:0}),n?{[n]:0}:{}),"right"===n?{transform:"scaleX(-1)"}:"bottom"===n?{transform:"scaleY(-1)"}:{});return e.createElement("div",{className:"ms-edge"+(n?" "+n:""),style:Object.assign(Object.assign({},o),{opacity:r?1:0})})})),d=e.memo((({activity:t,arrows:r,arrowType:n,handleArrow:o,size:l})=>{const s=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({position:"absolute",display:"flex",justifyContent:"center",alignItems:"center",cursor:"pointer",width:r.size+"px"},n?{[n]:0}:{}),"top"===n&&{transform:"rotate(-90deg) translateX(-100%)",transformOrigin:"left top"}),"bottom"===n&&{transform:"rotate(90deg) translateX(-100%)",transformOrigin:"left bottom"}),"left"===n&&{transform:"scaleX(-1)"}),["top","bottom"].includes(n)?{height:l+"px"}:{height:"100%",top:0});return e.createElement("div",{className:`ms-arrow-box ${n}${t?" active":""}`,style:Object.assign({},s),onClick:()=>o(n)},r.element)}));function m(e,t){return e>t?Math.floor(e/t):1}function p(e,t=0,r=1/0){return Math.max(t,Math.min(Math.round(e),r))}const f=(e,t,r)=>{if(!t)return;const n=t.querySelectorAll("."+("scroll"===e?"ms-thumb":"ms-slider"));n.length>0&&(r.current=n)},g=e=>e?"start"===e?"flex-start":"center"===e?"center":"flex-end":void 0;function h(e,t,r=0,n=0){return o=>{var l,s,i,c;const a={width:(null!==(l=o.width)&&void 0!==l?l:0)-r,height:(null!==(s=o.height)&&void 0!==s?s:0)-n};(null===(i=e.current)||void 0===i?void 0:i.width)===a.width&&(null===(c=e.current)||void 0===c?void 0:c.height)===a.height||(e.current=a,t())}}function v(t){const r=[],n=t=>{if(null===t||"number"==typeof t||"boolean"==typeof t||"bigint"==typeof t)r.push(t+"");else if("string"==typeof t)r.push(t);else if("function"==typeof t)r.push("<function>");else if(e.isValidElement(t))r.push("<react-node>");else if(Array.isArray(t))t.forEach(n);else if("object"==typeof t){const e=Object.entries(t).sort((([e],[t])=>e.localeCompare(t)));for(const[,t]of e)n(t)}else void 0===t&&r.push("<undefined>")};return n(t),r.join("/")}function b(e){var t,r,n;const o={x:"touches"in e.mouseEvent?e.mouseEvent.touches[0].clientX:e.mouseEvent.clientX,y:"touches"in e.mouseEvent?e.mouseEvent.touches[0].clientY:e.mouseEvent.clientY,leftover:null!==(r=null===(t=e.prevCoordsRef.current)||void 0===t?void 0:t.leftover)&&void 0!==r?r:0},l=null!==(n=e.prevCoordsRef.current)&&void 0!==n?n:o,s={x:o.x-l.x,y:o.y-l.y};e.prevCoordsRef.current=o;const i=t=>{if(!e.scrollElementRef||!e.objectsWrapperRef)return;let r=0;const n="x"===t?"movementX"in e.mouseEvent?e.mouseEvent.movementX:s.x:"movementY"in e.mouseEvent?e.mouseEvent.movementY:s.y,o=e.scrollElementRef;if("thumb"===e.clicked){const s=e.objectsWrapperRef,i=getComputedStyle(s),c="x"===t?o.clientWidth:o.clientHeight,a="x"===t?s.clientWidth+parseFloat(i.marginLeft)+parseFloat(i.marginRight):s.clientHeight+parseFloat(i.marginTop)+parseFloat(i.marginBottom),u=c-e.thumbSize,d=a-c;if(0>=u||0>=d)return;const m=n*(d/u)+l.leftover,p=Math.trunc(m),f=m-p;e.prevCoordsRef.current.leftover=f,r=p}else r=-n;"x"===t?(o.scrollLeft+=r,e.scrollStateRef.targetScrollX=o.scrollLeft):(o.scrollTop+=r,e.scrollStateRef.targetScrollY=o.scrollTop)},c=t=>{const r=e.objectsWrapperRef;if(!r)return;const n="slider"===e.type&&"wrapp"===e.clicked?-1:1,o=s[t]*n,l="x"===t?e.sizeLocal[0]:e.sizeLocal[1],i="x"===t?r.offsetWidth:r.offsetHeight,c="x"===t?e.scrollElementRef.scrollLeft:e.scrollElementRef.scrollTop;e.numForSliderRef.current+=Math.abs(o),e.numForSliderRef.current>6&&!e.isScrollingRef.current&&(o>0&&i>c+l?e.smoothScroll(c+l,t,e.duration):0>o&&c>0&&e.smoothScroll(c-l,t,e.duration),e.numForSliderRef.current=0)},a=t=>{"thumb"===e.clicked?i(t):"wrapp"===e.clicked?"slider"===e.type?c(t):i(t):"slider"===e.clicked&&c(t)};"hybrid"===e.direction?"wrapp"===e.clicked?(a("x"),a("y")):e.axisFromAtr&&a(e.axisFromAtr):a(e.direction||"y")}function y(e){if(e.controller.abort(),document.body.style.removeProperty("cursor"),["thumb","slider"].includes(e.clicked)&&e.mouseOnEl(e.scrollBar),"wrapp"===e.clicked&&e.mouseOnEl(e.objectsWrapperRef),e.clickedObject.current="none",e.scrollBarOnHover){let t=e.mouseEvent.target,r=!1;for(;t&&t!==document.body;){if(t===e.scrollContentRef){r=!0;break}t=t.parentNode}r||e.mouseOnRefHandle(e.mouseEvent)}e.prevCoordsRef.current=null,e.triggerUpdate()}const x=e=>{e&&("grab"===e.style.cursor?(e.style.cursor="grabbing",e.classList.add("active")):"grabbing"===e.style.cursor&&(e.style.cursor="grab",e.classList.remove("active")))},E="wrap-id",j=new Map,O=(e,t,r)=>{w(e);const n=setTimeout((()=>{t(),j.delete(e)}),r);j.set(e,n)},w=e=>{const t=j.get(e);t&&(clearTimeout(t),j.delete(e))},S=({type:t="scroll",className:r,size:l,objectsSize:w,direction:S="y",gap:R,wrapperMargin:M,wrapperMinSize:k,progressReverse:T=!1,progressTrigger:z={wheel:!0},scrollBarOnHover:A=!1,suspending:C=!1,fallback:L,scrollPosition:F,edgeGradient:N,children:I,onScrollValue:$,elementsAlign:W,elementsDirection:X="row",wrapperAlign:H,isScrolling:Y,render:B,emptyElements:P,crossCount:q})=>{var D,V,K,G,U,_;const J=i((()=>{kt()}),40),Q=i((()=>{vt()}),34),Z=function(){const e=n(null);return null===e.current&&(e.current=""+c++),e.current}();if(!l)throw Error(`Prop "size" is not provided\nMorphScroll〈♦${Z}〉`);Object.keys(z).length;const[ee,te]=e.useState(0),re=()=>{te((e=>"number"==typeof e&&1e3>e?e+1:0))},ne=e.useRef(null),oe=e.useRef(null),le=e.useRef(null),se=e.useRef(null),ie=e.useRef([]),ce=e.useRef(null),ae=e.useRef("none"),ue=e.useRef({loaded:[],empty:[]}),de=e.useRef({targetScrollY:0,targetScrollX:0,animating:!1,animationFrameId:0}),me=e.useRef(!1),pe=e.useRef(0),fe=e.useRef(null);function ge(){return e.useRef({width:0,height:0})}const he=ge(),ve=ge(),be=ge(),[ye,xe,Ee,je,Oe,we,Se,Re]=function(...e){return e.map(v)}(null==F?void 0:F.value,B,l,w,P,k,H,R),Me=e.useMemo((()=>{var e,t;return{value:"number"==typeof(null==F?void 0:F.value)||"string"==typeof(null==F?void 0:F.value)?[F.value,F.value]:null!==(e=null==F?void 0:F.value)&&void 0!==e?e:[null],duration:null!==(t=null==F?void 0:F.duration)&&void 0!==t?t:200}}),[ye,null==F?void 0:F.duration]),ke={color:null,size:40},Te=e.useMemo((()=>"object"==typeof N?Object.assign(Object.assign({},ke),N):ke),[N]),ze=e.useMemo((()=>Object.assign(Object.assign({},ke),"object"==typeof z.arrows?z.arrows:{})),[z.arrows]),Ae=e.useCallback((t=>{if(null==t)return[];if(e.isValidElement(t)){const r=t;return r.type===e.Fragment?e.Children.toArray(r.props.children).flatMap(Ae):[r]}return[t]}),[]),Ce=e.useMemo((()=>e.Children.toArray(I).flatMap(Ae).map((t=>e.isValidElement(t)&&t.key?t.key+"":null)).filter((e=>null!==e)).filter((e=>{var t;return"clear"!==(null==P?void 0:P.mode)||!(null===(t=ue.current.empty)||void 0===t?void 0:t.includes(e))}))),[I,Oe,null===(D=ue.current.empty)||void 0===D?void 0:D.join()]),[Le,Fe,Ne,Ie]=M?o(M):[0,0,0,0],$e=Le+Ne,We=Ie+Fe,[Xe,He]=e.useMemo((()=>{var e,t;return"number"==typeof R?[R,R]:Array.isArray(R)?[null!==(e=R[1])&&void 0!==e?e:0,null!==(t=R[0])&&void 0!==t?t:0]:[0,0]}),[R]),Ye=e.useMemo((()=>o((null==B?void 0:B.rootMargin)||0,"x"===S)),[xe,S]),[Be,Pe]=Ye?[Ye[2],Ye[0]]:[0,0],qe=e.useMemo((()=>{const[e,t]=Array.isArray(l)?l:"number"==typeof l?[l,l]:[he.current.width,he.current.height];if(!z.arrows||!ze.size)return[e,t,e,t];const r=2*ze.size;let n=e,o=t;return"x"===S?n=e-r:"y"===S?o=t-r:"hybrid"===S&&(n=e-r,o=t-r),[n,o,e,t]}),[Ee,ze.size,he.current]),De="x"===S?qe[0]:qe[1],Ve=e.useMemo((()=>w?Array.isArray(w)?w:o(w,!0,2):[null,null]),[je]),Ke=JSON.stringify(Ve),Ge=e.useMemo((()=>{const e=(e,t)=>"number"==typeof e?e:"firstChild"===e?t:0;return[e(Ve[0]&&"none"!==Ve[0]&&"size"!==Ve[0]?Ve[0]:"y"===S&&"none"!==Ve[0]||"size"===Ve[0]?qe[0]:0,be.current.width),e(Ve[1]&&"none"!==Ve[1]&&"size"!==Ve[1]?Ve[1]:"x"===S&&"none"!==Ve[1]||"size"===Ve[1]?qe[1]:0,be.current.height)]}),[Ke,be.current]),Ue=e.useMemo((()=>{const e="x"===S,t="row"===X,r="column"===X,n=e?qe[1]:qe[0],o=e?Ge[1]+He:Ge[0]+Xe,l="hybrid"===S?o*(Ce.length+1)-o:n,s=Math.floor(l/o)||1,i=q&&s>=q?"hybrid"===S?Math.ceil(s/q):q:s,c=i>1&&i<Ce.length?Math.ceil(Ce.length/i):i>Ce.length?1:Ce.length,a=q&&q<Ce.length,u=e=>Number.isFinite(e)&&e>0?e:1;if("hybrid"===S){const e=a?t?q:i:t?Ce.length:1,n=a?r?q:i:r?Ce.length:1;return[u(e),u(n)]}return[u(i),u(c)]}),[Ce.length,S,Ge.join(),qe.join(),Xe,We,$e,q]),_e=e.useMemo((()=>{const e=Ue[0]?Ue[0]*He-He:0,t="x"===S?Ue[1]:Ue[0];return Ge[0]?(Ge[0]+He)*t-He:(null==B?void 0:B.type)?be.current.width+e:ve.current.width}),[Ge[0],Ue.join(),He,ve.current.width,be.current,xe]),Je=e.useMemo((()=>{const e=1>Ue[1]?1:Ue[0]*Xe-Xe;return Ge[1]?"x"===S?(Ge[1]+Xe)*Ue[0]-Xe:(Ge[1]+Xe)*Ue[1]-Xe:(null==B?void 0:B.type)?be.current.height+e:ve.current.height}),[Ge[1],Ue.join(),Xe,ve.current.height,be.current,xe]),Qe=e.useMemo((()=>Je+$e),[Je,$e]),Ze=e.useMemo((()=>_e+We),[_e,We]),et="x"===S?Ze:Qe,tt="x"===S?(null===(V=le.current)||void 0===V?void 0:V.scrollLeft)||0:(null===(K=le.current)||void 0===K?void 0:K.scrollTop)||0,rt=tt>1&&!0,nt=et>Math.round(tt+De);let ot=!1,lt=!1;"hybrid"===S&&(ot=((null===(G=le.current)||void 0===G?void 0:G.scrollLeft)||0)>1&&!0,lt=Math.round(((null===(U=le.current)||void 0===U?void 0:U.scrollLeft)||0)+qe[0])<Ze);const st=e.useMemo((()=>{if(!z.progressElement||!et)return 0;const e=Math.round(De/et*De);return!Number.isFinite(e)||0>e?0:e}),[De,et,z.progressElement]),it=e.useMemo((()=>{if(!z.progressElement)return 0;const e=Math.round(qe[0]/Ze*qe[0]);return!Number.isFinite(e)||0>e?0:e}),[qe[0],Ze,z.progressElement]),ct=e.useMemo((()=>De?et-De:et),[et,De]),at=e.useMemo((()=>qe[0]?Ze-qe[0]:Ze),[Ze,qe[0]]),ut=e.useCallback((()=>{if(!(null==B?void 0:B.type)||1>=Ue[0])return[];const e=Array.from({length:Ce.length},((e,t)=>t)),t=Array.from({length:Ue[0]},(()=>[])),r="x"===S&&"column"===X||"x"!==S&&"row"===X;return e.forEach((e=>{const n=r?e%Ue[0]:Math.floor(e/Ue[1]);t[n]&&t[n].push(e)})),t}),[Ce.length,Ue.join(),xe,X,S]),dt=e.useMemo((()=>{if(!(null==B?void 0:B.type))return[{elementTop:0,elementBottom:0,left:0,right:0}];let e=[],t=0;if(W){const r=Array.from({length:Ce.length},((e,t)=>t)),n=Math.abs(Math.floor(Ce.length/Ue[0])*Ue[0]-Ce.length);e=n?r.slice(-n):[],"center"===W?t=(Ge[0]+He)*(Ue[0]-n)/2:"end"===W&&(t=(Ge[0]+He)*(Ue[0]-n))}return Ce.map(((r,n)=>{const o=function(e,t){for(let r=0;r<t.length;r++){const n=t[r].indexOf(e);if(-1!==n)return["x"===S?n:r,["hybrid","y"].includes(S)?n:r]}return[0,0]}(n,ut()),l=e.length>0&&e.includes(n)?t:0,s=function(e){const t="x"===S?l:0;return e>0?t+(Ge[1]+Xe)*e:t}(Ue[0]>1||["hybrid","x"].includes(S)?o[1]:n),i=Ge[1]?s+Ge[1]:s,c=function(e){const t="x"===S?0:l;return e>0?t+(Ge[0]+He)*e:t}(1===Ue[0]&&"x"===S?n:o[0]);return{elementTop:s,elementBottom:i,left:c,right:c+Ge[0]}}))}),[I,Ge.join(),R,xe,Ue[0],X]),mt=e.useMemo((()=>(null==qe?void 0:qe.length)&&H?function(e,t,r,n){const[o,l="start"]="string"==typeof e?[e,e]:e,s={display:"flex"};return t[0]>r&&(s.justifyContent=g(o)),t[1]>n&&(s.alignItems=g(l)),s}(H,qe,Ze,Qe):{}),[H,qe.join(),Qe,Ze]),pt=e.useMemo((()=>[m(Ze,qe[0]),m(Qe,qe[1])]),[Ze,Qe,qe.join()]),ft=e.useMemo((()=>"x"===S?pt[0]:pt[1]),[S,pt[0],pt[1]]),gt=e.useCallback((e=>{if(!A)return;const t=()=>((e,t,r,n)=>{e&&e.querySelectorAll(".ms-bar").forEach(((e,t)=>{const o=e;["mouseleave","mouseup","touchend"].includes(r.type)?(o.style.opacity="0",o.classList.remove("hover"),o.classList.add("leave"),n(`mouseOnRef${t}-anim`,(()=>o.classList.remove("leave")),200)):(o.style.opacity="1",o.classList.add("hover"))}))})(oe.current,0,e,O);"mouseleave"===e.type?!["thumb","slider","wrapp"].includes(ae.current)&&t():t()}),[A,t,ae.current,oe.current]),ht=e.useCallback((e=>{le.current&&(({arrowType:e,scrollElement:t,wrapSize:r,scrollSize:n,smoothScroll:o,duration:l})=>{const s=r[0],i=r[1],c=t.scrollTop,a=t.scrollLeft,u=["top","bottom"].includes(e)?i:s,d=(e,t)=>o(p(e,0,u),t,l);"top"===e&&c>0?d(c-n[1],"y"):"left"===e&&a>0&&d(a-n[0],"x"),"bottom"===e&&c+n[1]!==i?d(c+n[1],"y"):"right"===e&&a+n[0]!==s&&d(a+n[0],"x")})({arrowType:e,scrollElement:le.current,wrapSize:[Ze,Qe],scrollSize:qe,smoothScroll:wt,duration:Me.duration})}),[le.current,qe.join(),Ze,Qe,Me.duration]),vt=e.useCallback((()=>{f(t,ne.current,ie);const e=le.current;oe.current&&e&&0!==ie.current.length&&((e,t,r,n)=>{!function(){var o,l,s,i;const c=null!==(l=null===(o=t[0])||void 0===o?void 0:o.querySelectorAll(".sliderElem"))&&void 0!==l?l:[],a=null!==(i=null===(s=t[1])||void 0===s?void 0:s.querySelectorAll(".sliderElem"))&&void 0!==i?i:[];function u(e,t,r,n){const o="x"===n?r.scrollLeft:r.scrollTop;e.forEach(((e,r)=>{const l="x"===n?t[0]:t[1],s=o>=l*r&&l*(r+1)>o;e.classList.toggle("active",s)}))}c.length>0&&u(c,r,e,n),a.length>0&&u(a,r,e,"x")}()})(e,ie.current,qe,S)}),[qe.join(),S,le,oe,ie,t]),bt=e.useCallback((()=>{const e=le.current;e&&(null==$||$(e.scrollLeft,e.scrollTop),me.current=!0,null==Y||Y(!0),O("handleScroll-anim",(()=>{me.current=!1,null==Y||Y(!1),(null==B?void 0:B.type)?re():J()}),200),"slider"===t&&Q(),(null==B?void 0:B.type)||J(),re())}),[S,$,Y,xe,t,Q]),yt=p(tt/ct*(De-st),0,De-st),xt=p(((null===(_=le.current)||void 0===_?void 0:_.scrollLeft)||0)/at*(qe[0]-qe[0]/Ze*qe[0]),0,qe[0]-it),Et=e.useCallback(h(he,re),[]),jt=e.useCallback(h(ve,re,We,$e),[We,$e]),Ot=e.useCallback(h(be,re),[]),wt=e.useCallback(((e,t,r,n)=>{const o=le.current;return o?function(e,t,r,n,o){let l;if(!t&&!n)return null;const s=performance.now(),i=t.scrollTop,c=t.scrollLeft,a=u=>{const d=Math.min((u-s)/r,1);"y"===e?t.scrollTop=i+(n-i)*d:"x"===e&&(t.scrollLeft=c+(n-c)*d),1>d?l=requestAnimationFrame(a):null==o||o()};return l=requestAnimationFrame(a),()=>cancelAnimationFrame(l)}(t,o,r,e,n):null}),[le]),St=e.useCallback(((e,r="mousedown",n)=>{const o=e||("scroll"===t?"thumb":"slider");if("wrapp"===e&&!z.content||["thumb","slider"].includes(o)&&!z.progressElement)return;f(t,ne.current,ie);let l=null;n&&(l=n.getAttribute("data-direction")),function(e){const t=new AbortController,{signal:r}=t;e.clickedObject.current=e.clicked,e.triggerUpdate(),"mousedown"===e.eventType?(["thumb","slider"].includes(e.clicked)&&e.mouseOnEl(e.scrollBar),"wrapp"===e.clicked&&e.mouseOnEl(e.objectsWrapperRef),document.addEventListener("mousemove",(t=>b(Object.assign(Object.assign({},e),{mouseEvent:t}))),{signal:r}),document.addEventListener("mouseup",(r=>y(Object.assign(Object.assign({},e),{mouseEvent:r,controller:t}))),{signal:r})):"touchstart"===e.eventType&&(document.addEventListener("touchmove",(t=>{t.preventDefault(),b(Object.assign(Object.assign({},e),{mouseEvent:t}))}),{signal:r,passive:!1}),document.addEventListener("touchend",(r=>y(Object.assign(Object.assign({},e),{mouseEvent:r,controller:t}))),{signal:r})),document.body.style.cursor="grabbing"}({eventType:r,scrollElementRef:le.current,objectsWrapperRef:se.current,scrollBar:n||null,clickedObject:ae,scrollContentRef:oe.current,scrollStateRef:de.current,type:t,scrollBarOnHover:A,mouseOnEl:x,mouseOnRefHandle:gt,triggerUpdate:re,direction:S,smoothScroll:wt,sizeLocal:[qe[0],qe[1]],clicked:o,numForSliderRef:pe,isScrollingRef:me,prevCoordsRef:fe,thumbSize:"x"===l?it:st,axisFromAtr:l,duration:Me.duration})}),[t,z.content,z.progressElement,qe.join(),st,it,Me.duration]),Rt=e.useCallback((e=>{St(null,e.type,e.target)}),[St]),Mt=e.useCallback((()=>{St("wrapp")}),[St]),kt=e.useCallback((()=>{ne.current&&((e,t,r,n)=>{const{allIds:o,emptyKeysRaw:l}=(()=>{const t=[],r=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>e instanceof Element&&e.hasAttribute(E)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});let o=n.nextNode();for(;o;){const e=o,l=e.getAttribute(E);l&&(t.push(l),0===e.children.length&&r.push(l)),o=n.nextNode()}return{allIds:t,emptyKeysRaw:r}})(),s=new Set(t.current.loaded);o.forEach((e=>s.add(e)));let i=null;if(t.current.empty){const e=new Set(t.current.empty);l.forEach((t=>e.add(t))),i=Array.from(e)}t.current={loaded:"lazy"===n?Array.from(s):o.map((e=>e)),empty:i},r()})(ne.current,ue,re,null==B?void 0:B.type)}),[xe]),Tt=e.useCallback((e=>{(null==P?void 0:P.clickTrigger)&&((e,t,r,n)=>{e.target.closest(r.selector)&&t("emptyKeys-anim",(()=>{n()}),r.delay||0)})(e,O,P.clickTrigger,kt)}),[Oe]),zt=e.useCallback(((e,t,r)=>{if(ce.current){if(ce.current!==Ce[0])return void(ce.current=Ce[0])}else ce.current=Ce[0];const n=wt(t,e,Me.duration);n&&r.push(n)}),[Ce[0],Me.duration]),At=e.useMemo((()=>{const e=Object.assign(Object.assign(Object.assign(Object.assign({margin:M?`${Le}px ${Fe}px ${Ne}px ${Ie}px`:"",height:Ve[1]&&"none"!==Ve[1]?Je+"px":"fit-content",width:Ve[0]&&"none"!==Ve[0]?_e+"px":"fit-content"},z.content&&{cursor:"grab"}),R&&!(null==B?void 0:B.type)&&{gap:`${Xe}px ${He}px`}),k&&function(e,t,r,n,o){const l=(e,t)=>"full"===e?("x"===t?r[0]:r[1])-("x"===t?n:o):e;if("hybrid"!==t&&!Array.isArray(e)){const r=l(e,t)+"px";return"x"===t?{minWidth:r}:{minHeight:r}}let s,i;return Array.isArray(e)?[s,i]=e:s=i=e,{minWidth:l(s,"x")+"px",minHeight:l(i,"y")+"px"}}(k,S,qe,We,$e)),H&&{flexShrink:0});if(null==B?void 0:B.type)return Object.assign(Object.assign({},e),{position:"relative"});const t=Ve[1]?"wrap":void 0,r=1===Ue[0]?"y"===S?"column":"row":X;return Object.assign(Object.assign({},e),{display:"flex",flexDirection:r,flexWrap:t,justifyContent:g(W)})}),[M,[Le,Fe,Ne,Ie,We,$e].join(),Ve[1],Je,_e,z.content,Re,[Xe,He].join(),null==B?void 0:B.type,we,S,qe.join(),Se,Ue[0],X,W]);e.useEffect((()=>{(P||(null==B?void 0:B.type))&&(P||null===ue.current.empty||(ue.current.empty=null),J())}),[Oe,null==B?void 0:B.type,xe,me.current,Ce.length]),e.useEffect((()=>(((null==B?void 0:B.type)||Y)&&(Y&&Y(!1),re()),vt(),()=>{de.current.animationFrameId&&cancelAnimationFrame(de.current.animationFrameId),(()=>{for(const e of j.values())clearTimeout(e);j.clear()})()})),[]),e.useEffect((()=>{const e=le.current;if(!e)return;const t=z.wheel?t=>function(e,t,r,n){e.preventDefault(),r.animating||(r.targetScrollX=t.scrollLeft,r.targetScrollY=t.scrollTop),"x"===n?r.targetScrollX=p(r.targetScrollX+e.deltaY,0,t.scrollWidth-t.clientWidth+2):r.targetScrollY=p(r.targetScrollY+e.deltaY,0,t.scrollHeight-t.clientHeight+2),r.animating||(r.animating=!0,r.animationFrameId=requestAnimationFrame((function e(){let o=0;"x"===n?(t.scrollLeft+=.4*(r.targetScrollX-t.scrollLeft),o=Math.abs(t.scrollLeft-r.targetScrollX)):(t.scrollTop+=.4*(r.targetScrollY-t.scrollTop),o=Math.abs(t.scrollTop-r.targetScrollY)),o>2.5?r.animationFrameId=requestAnimationFrame(e):(r.animating=!1,null!==r.animationFrameId&&(cancelAnimationFrame(r.animationFrameId),r.animationFrameId=null))})))}(t,e,de.current,S):e=>e.preventDefault();return e.addEventListener("wheel",t,{passive:!1}),()=>{e.removeEventListener("wheel",t)}}),[S,z.wheel]),e.useEffect((()=>{if(!Me.value)return;const e=[];return("hybrid"===S?["x","y"]:[S]).forEach((t=>{const r="x"===t?0:1;"end"===Me.value[r]&&zt(t,"x"===t?at:ct,e)})),()=>{e.forEach((e=>e()))}}),[Me.value.join(),ye,ct,at,Ze,Qe]),e.useEffect((()=>{if(!Me.value)return;const e=[];return("hybrid"===S?["x","y"]:[S]).forEach((t=>{const r="x"===t?0:1;"number"==typeof Me.value[r]&&zt(t,Me.value[r],e)})),()=>{e.forEach((e=>e()))}}),[ye,null==F?void 0:F.updater]);const Ct=e.useCallback(((t,r,n,o)=>{var l;const s=Object.assign({width:Ge[0]?Ge[0]+"px":void 0,height:Ge[1]?Ge[1]+"px":void 0},(null==B?void 0:B.type)&&Object.assign({position:"absolute",top:r+"px",left:n+"px"},!Ge[0]&&1===Ue[0]&&{transform:"translateX(-50%)"})),i=C?e.createElement(e.Suspense,{fallback:L},o):o,c=(null===(l=null==P?void 0:P.clickTrigger)||void 0===l?void 0:l.selector)&&Tt;return e.createElement("div",Object.assign({key:t},B||P?{[E]:""+t}:{},{className:"ms-object-box",style:s,onClick:c}),i)}),[C,!!L,Ge.join(),le.current,xe,Oe,Ue[0]]),Lt=e.createElement("div",{className:"ms-objects-wrapper",ref:se,onMouseDown:Mt,style:At},Ce.map(((t,r)=>{var n,o,l;const i=e.Children.toArray(I).find((r=>e.isValidElement(r)&&r.key===t)),c=(null==B?void 0:B.stopLoadOnScroll)&&me.current&&!ue.current.loaded.includes(""+t)?L:(null===(n=ue.current.empty)||void 0===n?void 0:n.includes(t))?"object"==typeof(null==P?void 0:P.mode)?P.mode.fallback:L:i,a="number"==typeof Ve[0]&&"number"==typeof Ve[1]||"firstChild"!==Ve[0]&&"firstChild"!==Ve[1]||0!==r?c:e.createElement(s,{onResize:Ot},c);if(!(null==B?void 0:B.type))return Ct(t,0,0,a);{const{elementTop:e,elementBottom:n,left:s,right:i}=dt[r],c="x"===S?Be:Pe,u=De+c>("x"===S?s:e)-tt&&("x"===S?i:n)-tt>0-c,d="hybrid"!==S||qe[0]+Be>s-((null===(o=le.current)||void 0===o?void 0:o.scrollLeft)||0)&&i-((null===(l=le.current)||void 0===l?void 0:l.scrollLeft)||0)>0-Be;if(u&&d)return Ct(t,e,s,a)}}))),Ft=[{positionType:"x"===S?"left":"top",visibility:rt},{positionType:"x"===S?"right":"bottom",visibility:nt},..."hybrid"===S?[{positionType:"left",visibility:ot},{positionType:"right",visibility:lt}]:[]],Nt=e.createElement("div",{"morph-scroll":`〈♦${Z}〉`,className:r,ref:ne,style:{width:qe[2]+"px",height:qe[3]+"px"}},e.createElement("div",{className:"ms-content",ref:oe,onMouseEnter:gt,onMouseLeave:gt,onTouchStart:gt,onTouchEnd:gt,style:Object.assign({position:"relative",width:qe[0]+"px",height:qe[1]+"px"},z.arrows&&ze.size&&("x"===S?{left:ze.size+"px"}:"y"===S?{top:ze.size+"px"}:{top:ze.size+"px",left:ze.size+"px"}))},e.createElement("div",{className:"ms-element",ref:le,onScroll:bt,style:Object.assign(Object.assign(Object.assign({width:"100%",height:"100%"},mt),{overflow:{x:Ze>qe[0]?"scroll hidden":"hidden",y:Qe>qe[1]?"hidden scroll":"hidden",hybrid:`${Ze>qe[0]?"scroll":"hidden"} ${Qe>qe[1]?"scroll":"hidden"}`,hide:"hidden"}[z.wheel||z.content?S:"hide"]}),"scroll"!==t||"boolean"!=typeof z.progressElement||!1===z.progressElement?{scrollbarWidth:"none"}:{})},Ge[0]&&Ge[1]?Lt:e.createElement(s,{onResize:jt,style:Object.assign({},mt)},Lt)),N&&Ft.map((({positionType:t,visibility:r})=>e.createElement(u,{key:"edge-"+t,edgeGradient:Te,visibility:r,edgeType:t}))),z.progressElement&&!0!==z.progressElement&&[{shouldRender:et>st,direction:S,thumbSize:st,thumbSpace:yt,objLengthPerSize:ft,progressReverseIndex:0},{shouldRender:"hybrid"===S&&Ze>it,direction:"x",thumbSize:it,thumbSpace:xt,objLengthPerSize:pt[0],progressReverseIndex:1}].filter((({shouldRender:e})=>e)).map((r=>e.createElement(a,{key:r.direction,type:t,direction:r.direction,progressReverse:"boolean"==typeof T?T:T[r.progressReverseIndex],size:qe,progressTrigger:z,scrollBarOnHover:A,scrollBarEvent:"sliderMenu"===t?wt:Rt,thumbSize:r.thumbSize,thumbSpace:r.thumbSpace,objLengthPerSize:r.objLengthPerSize,sliderCheckLocal:vt,duration:Me.duration})))),z.arrows&&Ft.map((({positionType:t,visibility:r})=>e.createElement(d,{key:"arrow-"+t,activity:r,arrows:ze,arrowType:t,handleArrow:ht,size:"hybrid"===S?qe[0]+2*ze.size:qe[0]}))));return"auto"===l?e.createElement(s,{measure:"outer",onResize:Et},Nt):Nt};export{l as IntersectionTracker,S as MorphScroll,s as ResizeTracker};
package/package.json CHANGED
@@ -1,11 +1,15 @@
1
1
  {
2
2
  "name": "morphing-scroll",
3
- "version": "2.0.0",
4
- "description": "Library for using various methods of scrolling objects〈♦〉",
3
+ "version": "2.1.1",
4
+ "description": "React library for custom object scrolling and scrollbar styling〈♦〉",
5
5
  "author": "Georg Schilin",
6
6
  "license": "MIT",
7
- "main": "index.js",
8
- "type": "commonjs",
7
+ "main": "cjs/index.js",
8
+ "module": "esm/index.js",
9
+ "exports": {
10
+ "import": "./esm/index.js",
11
+ "require": "./cjs/index.js"
12
+ },
9
13
  "types": "./types/index.d.ts",
10
14
  "keywords": [
11
15
  "react",
package/types/index.d.ts CHANGED
@@ -23,7 +23,7 @@ import MorphScrollT from "./morphScroll";
23
23
  *
24
24
  * ---
25
25
  * ### Links:
26
- * [ResizeTracker Documentation](https://github.com/voodoofugu/morphing-scroll?tab=readme-ov-file#-resizetracker)
26
+ * [ResizeTracker Documentation](https://www.npmjs.com/package/morphing-scroll#-resizetracker)
27
27
  *
28
28
  * [MDN Reference for Resize Observer API](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver)
29
29
  */
@@ -51,7 +51,7 @@ declare const ResizeTracker: React.FC<ResizeTrackerT>;
51
51
  *
52
52
  * ---
53
53
  * ### Links:
54
- * [IntersectionTracker Documentation](https://github.com/voodoofugu/morphing-scroll?tab=readme-ov-file#-intersectiontracker)
54
+ * [IntersectionTracker Documentation](https://www.npmjs.com/package/morphing-scroll#-intersectiontracker)
55
55
  *
56
56
  * [MDN Reference for Intersection Observer API](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API)
57
57
  */
@@ -104,7 +104,7 @@ declare const IntersectionTracker: React.FC<IntersectionTrackerT>;
104
104
  *
105
105
  * ---
106
106
  * ### Links:
107
- * [MorphScroll Documentation](https://github.com/voodoofugu/morphing-scroll?tab=readme-ov-file#-morphscroll)
107
+ * [MorphScroll Documentation](https://www.npmjs.com/package/morphing-scroll#-morphscroll)
108
108
  */
109
109
  declare const MorphScroll: React.FC<MorphScrollT>;
110
110
 
@@ -141,13 +141,14 @@ type MorphScrollT = {
141
141
  *
142
142
  * @description
143
143
  * - `number` *sets the width and height, can be an array of 2 numbers*
144
- * - `"none"` *objects will be created without defined size*
144
+ * - `"size"` *all objects will take the dimensions from the `size` prop*
145
145
  * - `"firstChild"` *all objects will have the same size as the first child*
146
+ * - `"none"` *objects will be created without defined size*
146
147
  *
147
148
  * @example
148
149
  * ```tsx
149
150
  * <MorphScroll {...props}
150
- * objectsSize={[80, 80]}
151
+ * objectsSize={80}
151
152
  * >
152
153
  * {children}
153
154
  * </MorphScroll>
@@ -155,9 +156,10 @@ type MorphScrollT = {
155
156
  */
156
157
  objectsSize:
157
158
  | number
158
- | "none"
159
+ | "size"
159
160
  | "firstChild"
160
- | (number | "none" | "firstChild")[];
161
+ | "none"
162
+ | (number | "size" | "firstChild" | "none")[];
161
163
  /**---
162
164
  * Number of cells in each direction.
163
165
  *___
package/index.js DELETED
@@ -1 +0,0 @@
1
- "use strict";var e=require("react");const t=(e,t=!1,r)=>{let n=[];if(n=Array.isArray(e)?2===e.length?[e[1],e[0],e[1],e[0]]:[...e]:[e,e,e,e],t&&(n=[n[1],n[0],n[3],n[2]]),r){const e=[];for(let t=0;t<r;t++)e.push(n[t%4]);n=e}return n},r=({className:t,children:r,style:n,measure:o="inner",onResize:l})=>{const s=e.useRef(null);e.useEffect((()=>{const e=s.current;if(!e)return;const t=new ResizeObserver((e=>{for(const t of e)l&&l(t.contentRect)}));return t.observe(e),()=>{t.unobserve(e),t.disconnect()}}),[o,l]);const i={minWidth:"100%",minHeight:"100%"},c={width:"max-content",height:"max-content"},a={inner:Object.assign({},c),outer:Object.assign({},i),all:Object.assign(Object.assign({},i),c)};return e.createElement("div",{"resize-tracker":"",className:t,ref:s,style:Object.assign(Object.assign({},a[o]),n)},r)};function n(t,r){const n=e.useMemo((()=>function(e,t){let r=null;const n=(...n)=>{r&&clearTimeout(r),r=setTimeout((()=>{e(...n)}),t)};return n.cancel=()=>{r&&(clearTimeout(r),r=null)},n}(((...e)=>t(...e)),r)),[r]);return e.useEffect((()=>()=>{n.cancel()}),[n]),n}let o=1;var l=e.memo((({type:t,direction:r,progressReverse:n,size:o,progressTrigger:l,scrollBarOnHover:s,scrollBarEvent:i,thumbSize:c,thumbSpace:a,objLengthPerSize:u,sliderCheckLocal:d})=>{const m="sliderMenu"!==t?{onMouseDown:i,onTouchStart:i}:{},p=e.useMemo((()=>{if("scroll"===t||!r)return;const n=["hybrid","y"].includes(r)?"y":"x",s="x"===n?o[0]:o[1];return Array.from({length:u},((r,o)=>e.createElement("div",{key:o,className:"sliderElem",style:Object.assign({},"sliderMenu"===t&&{cursor:"pointer"}),onClick:"sliderMenu"===t?()=>{i(s*o,n,d)}:void 0},Array.isArray(null==l?void 0:l.progressElement)?l.progressElement[o]:null==l?void 0:l.progressElement)))}),[u,r,o,t,i,null==l?void 0:l.progressElement]);return e.createElement(e.Fragment,null,"scroll"===t?e.createElement("div",{className:"ms-bar",style:Object.assign(Object.assign(Object.assign({position:"absolute",width:"fit-content"},"x"===r?Object.assign({transformOrigin:"left top",height:`${o[0]}px`},n?{top:0,transform:"rotate(-90deg) translateX(-100%)"}:{transform:"rotate(-90deg)"}):Object.assign({top:0,height:"100%"},n?{left:0}:{right:0})),!1!=!(null==l?void 0:l.progressElement)&&{pointerEvents:"none"}),s&&{opacity:0,transition:"opacity 0.1s ease-in-out"})},e.createElement("div",Object.assign({className:"ms-thumb","data-direction":["hybrid","y"].includes(r)?"y":r},m,{style:Object.assign({height:`${c}px`,willChange:"transform",transform:`translateY(${a}px)`},(null==l?void 0:l.progressElement)&&{cursor:"grab"})}),null==l?void 0:l.progressElement)):u>1&&(null==l?void 0:l.progressElement)&&e.createElement("div",Object.assign({className:"ms-slider","data-direction":["hybrid","y"].includes(r)?"y":r},m,{style:Object.assign(Object.assign(Object.assign({position:"absolute",display:"flex"},"slider"===t&&{cursor:"grab"}),s&&{opacity:0,transition:"opacity 0.1s ease-in-out"}),"x"===r?Object.assign({transformOrigin:"left top",left:"50%",transform:"translateX(-50%)"},n?{top:0}:{bottom:0}):Object.assign({flexDirection:"column",top:"50%",transform:"translateY(-50%)"},n?{left:0}:{right:0}))}),p))}));var s=e.memo((({edgeGradient:t,visibility:r,edgeType:n})=>{if(!t)return null;const o=Object.assign(Object.assign(Object.assign(Object.assign({position:"absolute",pointerEvents:"none",transition:"opacity 0.1s ease-in-out"},t.color&&{background:t.color&&`linear-gradient(${"right"===n||"left"===n?"90deg, ":""}${t.color}, transparent)`}),"right"===n||"left"===n?{height:"100%",width:`${t.size}px`,top:0}:{width:"100%",height:`${t.size}px`,left:0}),n?{[n]:0}:{}),"right"===n?{transform:"scaleX(-1)"}:"bottom"===n?{transform:"scaleY(-1)"}:{});return e.createElement("div",{className:"ms-edge"+(n?` ${n}`:""),style:Object.assign(Object.assign({},o),{opacity:r?1:0})})}));var i=e.memo((({activity:t,arrows:r,arrowType:n,handleArrow:o,size:l})=>{const s=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({position:"absolute",display:"flex",justifyContent:"center",alignItems:"center",cursor:"pointer",width:`${r.size}px`},n?{[n]:0}:{}),"top"===n&&{transform:"rotate(-90deg) translateX(-100%)",transformOrigin:"left top"}),"bottom"===n&&{transform:"rotate(90deg) translateX(-100%)",transformOrigin:"left bottom"}),"left"===n&&{transform:"scaleX(-1)"}),["top","bottom"].includes(n)?{height:`${l}px`}:{height:"100%",top:0});return e.createElement("div",{className:`ms-arrow-box ${n}${t?" active":""}`,style:Object.assign({},s),onClick:()=>o(n)},r.element)}));function c(e,t){if(e<=t)return 1;return Math.floor(e/t)}function a(e,t=0,r=1/0){return Math.max(t,Math.min(Math.round(e),r))}const u=(e,t,r)=>{if(!t)return;const n=t.querySelectorAll("."+("scroll"===e?"ms-thumb":"ms-slider"));n.length>0&&(r.current=n)};function d(e,t,r=0,n=0){return o=>{var l,s,i,c;const a={width:(null!==(l=o.width)&&void 0!==l?l:0)-r,height:(null!==(s=o.height)&&void 0!==s?s:0)-n};(null===(i=e.current)||void 0===i?void 0:i.width)===a.width&&(null===(c=e.current)||void 0===c?void 0:c.height)===a.height||(e.current=a,t())}}function m(t){const r=[],n=t=>{if(null===t||"number"==typeof t||"boolean"==typeof t||"bigint"==typeof t)r.push(String(t));else if("string"==typeof t)r.push(t);else if("function"==typeof t)r.push("<function>");else if(e.isValidElement(t))r.push("<react-node>");else if(Array.isArray(t))t.forEach(n);else if("object"==typeof t){const e=Object.entries(t).sort((([e],[t])=>e.localeCompare(t)));for(const[,t]of e)n(t)}else void 0===t&&r.push("<undefined>")};return n(t),r.join("/")}function p(e){var t,r,n;const o={x:"touches"in e.mouseEvent?e.mouseEvent.touches[0].clientX:e.mouseEvent.clientX,y:"touches"in e.mouseEvent?e.mouseEvent.touches[0].clientY:e.mouseEvent.clientY,leftover:null!==(r=null===(t=e.prevCoordsRef.current)||void 0===t?void 0:t.leftover)&&void 0!==r?r:0},l=null!==(n=e.prevCoordsRef.current)&&void 0!==n?n:o,s={x:o.x-l.x,y:o.y-l.y};e.prevCoordsRef.current=o;const i=t=>{if(!e.scrollElementRef||!e.objectsWrapperRef)return;let r=0;const n="x"===t?"movementX"in e.mouseEvent?e.mouseEvent.movementX:s.x:"movementY"in e.mouseEvent?e.mouseEvent.movementY:s.y,o=e.scrollElementRef;if("thumb"===e.clicked){const s=e.objectsWrapperRef,i=getComputedStyle(s),c="x"===t?o.clientWidth:o.clientHeight,a="x"===t?s.clientWidth+parseFloat(i.marginLeft)+parseFloat(i.marginRight):s.clientHeight+parseFloat(i.marginTop)+parseFloat(i.marginBottom),u=c-e.thumbSize,d=a-c;if(u<=0||d<=0)return;const m=n*(d/u)+l.leftover,p=Math.trunc(m),f=m-p;e.prevCoordsRef.current.leftover=f,r=p}else r=-n;"x"===t?(o.scrollLeft+=r,e.scrollStateRef.targetScrollX=o.scrollLeft):(o.scrollTop+=r,e.scrollStateRef.targetScrollY=o.scrollTop)},c=t=>{const r=e.objectsWrapperRef;if(!r)return;const n="slider"===e.type&&"wrapp"===e.clicked?-1:1,o=s[t]*n,l="x"===t?e.sizeLocal[0]:e.sizeLocal[1],i="x"===t?r.offsetWidth:r.offsetHeight,c="x"===t?e.scrollElementRef.scrollLeft:e.scrollElementRef.scrollTop;e.numForSliderRef.current+=Math.abs(o),e.numForSliderRef.current>6&&!e.isScrollingRef.current&&(o>0&&c+l<i?e.smoothScroll(c+l,t):o<0&&c>0&&e.smoothScroll(c-l,t),e.numForSliderRef.current=0)},a=t=>{"thumb"===e.clicked?i(t):"wrapp"===e.clicked?"slider"===e.type?c(t):i(t):"slider"===e.clicked&&c(t)};"hybrid"===e.direction?"wrapp"===e.clicked?(a("x"),a("y")):e.axisFromAtr&&a(e.axisFromAtr):a(e.direction||"y")}function f(e){if(e.controller.abort(),document.body.style.removeProperty("cursor"),["thumb","slider"].includes(e.clicked)&&e.mouseOnEl(e.scrollBar),"wrapp"===e.clicked&&e.mouseOnEl(e.objectsWrapperRef),e.clickedObject.current="none",e.scrollBarOnHover){let t=e.mouseEvent.target,r=!1;for(;t&&t!==document.body;){if(t===e.scrollContentRef){r=!0;break}t=t.parentNode}r||e.mouseOnRefHandle(e.mouseEvent)}e.prevCoordsRef.current=null,e.triggerUpdate()}const g=e=>{e&&("grab"===e.style.cursor?(e.style.cursor="grabbing",e.classList.add("active")):"grabbing"===e.style.cursor&&(e.style.cursor="grab",e.classList.remove("active")))},h="wrap-id",b=new Map,v=(e,t,r)=>{y(e);const n=setTimeout((()=>{t(),b.delete(e)}),r);b.set(e,n)},y=e=>{const t=b.get(e);t&&(clearTimeout(t),b.delete(e))};exports.IntersectionTracker=({className:r,children:n,style:o,root:l,threshold:s,rootMargin:i,visibleContent:c=!1,onVisible:a})=>{const[u,d]=e.useState(!1),m=e.useRef(null),p=i?t(i):null,f=p?`${p[0]}px ${p[1]}px ${p[2]}px ${p[3]}px`:"",g=e.useCallback((([e])=>{d(e.isIntersecting),e.isIntersecting&&a&&a(e)}),[a]);e.useEffect((()=>{const e=new IntersectionObserver(g,{root:l,threshold:s,rootMargin:f});return m.current&&e.observe(m.current),()=>{e.disconnect()}}),[g,l,s,f]);const h=c||u?n:null;return e.createElement("div",{"intersection-tracker":"",className:r,ref:m,style:o},h)},exports.MorphScroll=({type:y="scroll",className:x="",size:E,objectsSize:j,direction:O="y",gap:w,wrapperMargin:S,wrapperMinSize:R,progressReverse:M=!1,progressTrigger:k={wheel:!0},scrollBarOnHover:T=!1,suspending:$=!1,fallback:z=null,scrollPosition:C,edgeGradient:L,children:A,onScrollValue:F,elementsAlign:N=!1,elementsDirection:I="row",wrapperAlign:W,isScrolling:X,render:H,emptyElements:Y,crossCount:B})=>{var P,q,D,V,K,G;const U=n((()=>{Mt()}),40),_=n((()=>{ht()}),34),J=function(){const t=e.useRef(null);return null===t.current&&(t.current=""+o++),t.current}(),Q=e=>`Prop "${e}" is not provided\nMorphScroll〈♦${J}〉`;if(!E)throw new Error(Q("size"));0===Object.keys(k).length&&console.error(Q("progressTrigger"));const[Z,ee]=e.useState(0),te=()=>{ee((e=>"number"==typeof e&&e<1e3?e+1:0))},re=e.useRef(null),ne=e.useRef(null),oe=e.useRef(null),le=e.useRef(null),se=e.useRef([]),ie=e.useRef(null),ce=e.useRef("none"),ae=e.useRef({loaded:[],empty:[]}),ue=e.useRef({targetScrollY:0,targetScrollX:0,animating:!1,animationFrameId:0}),de=e.useRef(!1),me=e.useRef(0),pe=e.useRef(null);function fe(){return e.useRef({width:0,height:0})}const ge=fe(),he=fe(),be=fe(),[ve,ye,xe,Ee,je,Oe,we,Se]=function(...e){return e.map(m)}(C,H,E,j,Y,R,W,w),Re=e.useMemo((()=>{var e,t;return{value:"number"==typeof(null==C?void 0:C.value)||"string"==typeof(null==C?void 0:C.value)?[C.value,C.value]:null!==(e=null==C?void 0:C.value)&&void 0!==e?e:[null],duration:null!==(t=null==C?void 0:C.duration)&&void 0!==t?t:200}}),[ve]),Me={color:null,size:40},ke=e.useMemo((()=>"object"==typeof L?Object.assign(Object.assign({},Me),L):Me),[L]),Te=e.useMemo((()=>Object.assign(Object.assign({},Me),"object"==typeof k.arrows?k.arrows:{})),[k.arrows]),$e=e.useCallback((t=>{if(null==t)return[];if(e.isValidElement(t)){const r=t;return r.type===e.Fragment?e.Children.toArray(r.props.children).flatMap($e):[r]}return[t]}),[]),ze=e.useMemo((()=>e.Children.toArray(A).flatMap($e).map((t=>e.isValidElement(t)&&t.key?String(t.key):null)).filter((e=>null!==e)).filter((e=>{var t;return"clear"!==(null==Y?void 0:Y.mode)||!(null===(t=ae.current.empty)||void 0===t?void 0:t.includes(e))}))),[A,je,null===(P=ae.current.empty)||void 0===P?void 0:P.join()]),[Ce,Le,Ae,Fe]=S?t(S):[0,0,0,0],Ne=Ce+Ae,Ie=Fe+Le,[We,Xe]=e.useMemo((()=>{var e,t;return"number"==typeof w?[w,w]:Array.isArray(w)?[null!==(e=w[1])&&void 0!==e?e:0,null!==(t=w[0])&&void 0!==t?t:0]:[0,0]}),[w]),He=e.useMemo((()=>t((null==H?void 0:H.rootMargin)||0,"x"===O)),[ye,O]),[Ye,Be]=He?[He[2],He[0]]:[0,0],Pe=e.useMemo((()=>{const[e,t]=Array.isArray(E)?E:"number"==typeof E?[E,E]:[ge.current.width,ge.current.height];if(!k.arrows||!Te.size)return[e,t,e,t];const r=2*Te.size;let n=e,o=t;return"x"===O?n=e-r:"y"===O?o=t-r:"hybrid"===O&&(n=e-r,o=t-r),[n,o,e,t]}),[xe,Te.size,ge.current]),qe="x"===O?Pe[0]:Pe[1],De=e.useMemo((()=>j?t(j,!0,2):[null,null]),[Ee]),Ve=JSON.stringify(De),Ke=e.useMemo((()=>{const e=(e,t)=>"number"==typeof e?e:"firstChild"===e?t:0;return[e(De[0]&&"none"!==De[0]?De[0]:"y"===O?Pe[0]:0,be.current.width),e(De[1]&&"none"!==De[1]?De[1]:"x"===O?Pe[1]:0,be.current.height)]}),[Ve,be.current]),Ge=e.useMemo((()=>{const e="x"===O,t="row"===I,r="column"===I,n=e?Pe[1]:Pe[0],o=e?Ke[1]+Xe:Ke[0]+We,l="hybrid"===O?o*(ze.length+1)-o:n,s=Math.floor(l/o)||1,i=B&&B<=s?"hybrid"===O?Math.ceil(s/B):B:s,c=i>1&&i<ze.length?Math.ceil(ze.length/i):ze.length,a=B&&B<ze.length;if("hybrid"===O){return[a?t?B:i:t?ze.length:1,a?r?B:i:r?ze.length:1]}return[i,c]}),[ze.length,O,Ke.join(),Pe.join(),We,Ie,Ne,B]),Ue=e.useMemo((()=>{const e=Ge[0]?Ge[0]*Xe-Xe:0,t="x"===O?Ge[1]:Ge[0];return Ke[0]?(Ke[0]+Xe)*t-Xe:(null==H?void 0:H.type)?be.current.width+e:he.current.width}),[Ke[0],Ge.join(),Xe,he.current.width,be.current,ye]),_e=e.useMemo((()=>{const e=Ge[1]<1?1:Ge[0]*We-We;return Ke[1]?"x"===O?(Ke[1]+We)*Ge[0]-We:(Ke[1]+We)*Ge[1]-We:(null==H?void 0:H.type)?be.current.height+e:he.current.height}),[Ke[1],Ge.join(),We,he.current.height,be.current,ye]),Je=e.useMemo((()=>_e+Ne),[_e,Ne]),Qe=e.useMemo((()=>Ue+Ie),[Ue,Ie]),Ze="x"===O?Qe:Je,et="x"===O?(null===(q=oe.current)||void 0===q?void 0:q.scrollLeft)||0:(null===(D=oe.current)||void 0===D?void 0:D.scrollTop)||0,tt=et>1&&!0,rt=Math.round(et+qe)<Ze;let nt=!1,ot=!1;"hybrid"===O&&(nt=((null===(V=oe.current)||void 0===V?void 0:V.scrollLeft)||0)>1&&!0,ot=Math.round(((null===(K=oe.current)||void 0===K?void 0:K.scrollLeft)||0)+Pe[0])<Qe);const lt=e.useMemo((()=>{if(!k.progressElement||!Ze)return 0;const e=Math.round(qe/Ze*qe);return!Number.isFinite(e)||e<0?0:e}),[qe,Ze,k.progressElement]),st=e.useMemo((()=>{if(!k.progressElement)return 0;const e=Math.round(Pe[0]/Qe*Pe[0]);return!Number.isFinite(e)||e<0?0:e}),[Pe[0],Qe,k.progressElement]),it=e.useMemo((()=>qe?Ze-qe:Ze),[Ze,qe]),ct=e.useMemo((()=>Pe[0]?Qe-Pe[0]:Qe),[Qe,Pe[0]]),at=e.useCallback((()=>{if(!(null==H?void 0:H.type)||Ge[0]<=1)return[];const e=Array.from({length:ze.length},((e,t)=>t)),t=Array.from({length:Ge[0]},(()=>[])),r="x"===O&&"column"===I||"x"!==O&&"row"===I;return e.forEach((e=>{const n=r?e%Ge[0]:Math.floor(e/Ge[1]);t[n]&&t[n].push(e)})),t}),[ze.length,Ge.join(),ye,I,O]),ut=e.useMemo((()=>{if(!(null==H?void 0:H.type))return[{elementTop:0,elementBottom:0,left:0,right:0}];let e=[],t=0;if(N){const r=Array.from({length:ze.length},((e,t)=>t)),n=Math.abs(Math.floor(ze.length/Ge[0])*Ge[0]-ze.length);e=n?r.slice(-n):[],"center"===N?t=(Ke[0]+Xe)*(Ge[0]-n)/2:"end"===N&&(t=(Ke[0]+Xe)*(Ge[0]-n))}return ze.map(((r,n)=>{const o=function(e,t){for(let r=0;r<t.length;r++){const n=t[r].indexOf(e);if(-1!==n){const e=["hybrid","y"].includes(O)?n:r;return["x"===O?n:r,e]}}return[0,0]}(n,at()),l=e.length>0&&e.includes(n)?t:0,s=function(e){const t="x"===O?l:0;return e>0?t+(Ke[1]+We)*e:t}(Ge[0]>1||["hybrid","x"].includes(O)?o[1]:n),i=Ke[1]?s+Ke[1]:s,c=function(e){const t="x"===O?0:l;return e>0?t+(Ke[0]+Xe)*e:t}(1===Ge[0]&&"x"===O?n:o[0]),a=c+Ke[0];return{elementTop:s,elementBottom:i,left:c,right:a}}))}),[A,Ke.join(),w,ye,Ge[0],I]),dt=e.useMemo((()=>(null==Pe?void 0:Pe.length)&&W?function(e,t,r,n){const[o,l="start"]="string"==typeof e?[e,e]:e,s=e=>"start"===e?"flex-start":"center"===e?"center":"flex-end",i={display:"flex"};return t[0]>r&&(i.justifyContent=s(o)),t[1]>n&&(i.alignItems=s(l)),i}(W,Pe,Qe,Je):{}),[W,Pe.join(),Je,Qe]),mt=e.useMemo((()=>[c(Qe,Pe[0]),c(Je,Pe[1])]),[Qe,Je,Pe.join()]),pt=e.useMemo((()=>"x"===O?mt[0]:mt[1]),[O,mt[0],mt[1]]),ft=e.useCallback((e=>{if(!T)return;const t=()=>((e,t,r,n)=>{if(!e)return;e.querySelectorAll(`.${t}`).forEach(((e,t)=>{const o=e;["mouseleave","mouseup","touchend"].includes(r.type)?(o.style.opacity="0",o.classList.remove("hover"),o.classList.add("leave"),n(`mouseOnRef${t}-anim`,(()=>o.classList.remove("leave")),200)):(o.style.opacity="1",o.classList.add("hover"))}))})(ne.current,"ms-bar",e,v);"mouseleave"===e.type?!["thumb","slider","wrapp"].includes(ce.current)&&t():t()}),[T,y,ce.current,ne.current]),gt=e.useCallback((e=>{oe.current&&(({arrowType:e,scrollElement:t,wrapSize:r,scrollSize:n,smoothScroll:o})=>{const l=r[0],s=r[1],i=t.scrollTop,c=t.scrollLeft,u=["top","bottom"].includes(e)?s:l,d=(e,t)=>o(a(e,0,u),t);"top"===e&&i>0?d(i-n[1],"y"):"left"===e&&c>0&&d(c-n[0],"x"),"bottom"===e&&i+n[1]!==s?d(i+n[1],"y"):"right"===e&&c+n[0]!==l&&d(c+n[0],"x")})({arrowType:e,scrollElement:oe.current,wrapSize:[Qe,Je],scrollSize:Pe,smoothScroll:Ot})}),[oe.current,Pe.join(),Qe,Je]),ht=e.useCallback((()=>{u(y,re.current,se);const e=oe.current;ne.current&&e&&0!==se.current.length&&((e,t,r,n)=>{!function(){var o,l,s,i;const c=null!==(l=null===(o=t[0])||void 0===o?void 0:o.querySelectorAll(".sliderElem"))&&void 0!==l?l:[],a=null!==(i=null===(s=t[1])||void 0===s?void 0:s.querySelectorAll(".sliderElem"))&&void 0!==i?i:[];function u(e,t,r,n){const o="x"===n?r.scrollLeft:r.scrollTop;e.forEach(((e,r)=>{const l="x"===n?t[0]:t[1],s=o>=l*r&&o<l*(r+1);e.classList.toggle("active",s)}))}c.length>0&&u(c,r,e,n),a.length>0&&u(a,r,e,"x")}()})(e,se.current,Pe,O)}),[Pe.join(),O,oe,ne,se,y]),bt=e.useCallback((()=>{const e=oe.current;e&&(null==F||F(e.scrollLeft,e.scrollTop),de.current=!0,null==X||X(!0),v("handleScroll-anim",(()=>{de.current=!1,null==X||X(!1),(null==H?void 0:H.type)?te():U()}),200),"slider"===y&&_(),(null==H?void 0:H.type)||U(),te())}),[O,F,X,ye,y,_]),vt=a(et/it*(qe-lt),0,qe-lt),yt=a(((null===(G=oe.current)||void 0===G?void 0:G.scrollLeft)||0)/ct*(Pe[0]-Pe[0]/Qe*Pe[0]),0,Pe[0]-st),xt=e.useCallback(d(ge,te),[]),Et=e.useCallback(d(he,te,Ie,Ne),[Ie,Ne]),jt=e.useCallback(d(be,te),[]),Ot=e.useCallback(((e,t,r)=>{const n=oe.current;return n?function(e,t,r,n,o){let l;if(!t)return null;const s=performance.now(),i=t.scrollTop,c=t.scrollLeft,a=u=>{const d=u-s,m=Math.min(d/r,1);"y"===e?t.scrollTop=i+(n-i)*m:"x"===e&&(t.scrollLeft=c+(n-c)*m),m<1?l=requestAnimationFrame(a):null==o||o()};return l=requestAnimationFrame(a),()=>cancelAnimationFrame(l)}(t,n,Re.duration,e,r):null}),[oe,Re.duration]),wt=e.useCallback(((e,t="mousedown",r)=>{const n=e||("scroll"===y?"thumb":"slider");if("wrapp"===e&&!k.content||["thumb","slider"].includes(n)&&!k.progressElement)return;u(y,re.current,se);let o=null;if(r){o=r.getAttribute("data-direction")}!function(e){const t=new AbortController,{signal:r}=t;e.clickedObject.current=e.clicked,e.triggerUpdate(),"mousedown"===e.eventType?(["thumb","slider"].includes(e.clicked)&&e.mouseOnEl(e.scrollBar),"wrapp"===e.clicked&&e.mouseOnEl(e.objectsWrapperRef),document.addEventListener("mousemove",(t=>p(Object.assign(Object.assign({},e),{mouseEvent:t}))),{signal:r}),document.addEventListener("mouseup",(r=>f(Object.assign(Object.assign({},e),{mouseEvent:r,controller:t}))),{signal:r})):"touchstart"===e.eventType&&(document.addEventListener("touchmove",(t=>p(Object.assign(Object.assign({},e),{mouseEvent:t}))),{signal:r}),document.addEventListener("touchend",(r=>f(Object.assign(Object.assign({},e),{mouseEvent:r,controller:t}))),{signal:r})),document.body.style.cursor="grabbing"}({eventType:t,scrollElementRef:oe.current,objectsWrapperRef:le.current,scrollBar:r||null,clickedObject:ce,scrollContentRef:ne.current,scrollStateRef:ue.current,type:y,scrollBarOnHover:T,mouseOnEl:g,mouseOnRefHandle:ft,triggerUpdate:te,direction:O,smoothScroll:Ot,sizeLocal:[Pe[0],Pe[1]],clicked:n,numForSliderRef:me,isScrollingRef:de,prevCoordsRef:pe,thumbSize:"x"===o?st:lt,axisFromAtr:o})}),[y,k.content,k.progressElement,Pe.join(),lt,st]),St=e.useCallback((e=>{wt(null,e.type,e.target)}),[wt]),Rt=e.useCallback((()=>{wt("wrapp")}),[wt]),Mt=e.useCallback((()=>{re.current&&((e,t,r,n)=>{const{allIds:o,emptyKeysRaw:l}=(()=>{const t=[],r=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>e instanceof Element&&e.hasAttribute(h)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});let o=n.nextNode();for(;o;){const e=o,l=e.getAttribute(h);l&&(t.push(l),0===e.children.length&&r.push(l)),o=n.nextNode()}return{allIds:t,emptyKeysRaw:r}})(),s=new Set(t.current.loaded);o.forEach((e=>s.add(e)));let i=null;if(t.current.empty){const e=new Set(t.current.empty);l.forEach((t=>e.add(t))),i=Array.from(e)}t.current={loaded:"lazy"===n?Array.from(s):o.map((e=>e)),empty:i},r()})(re.current,ae,te,null==H?void 0:H.type)}),[ye]),kt=e.useCallback((e=>{(null==Y?void 0:Y.clickTrigger)&&((e,t,r,n)=>{e.target.closest(r.selector)&&t("emptyKeys-anim",(()=>{n()}),r.delay||0)})(e,v,Y.clickTrigger,Mt)}),[je]),Tt=e.useCallback(((e,t,r,n,o,l)=>{if(ie.current||(ie.current=ze[0]),ie.current===ze[0]&&null!==t){if("end"===t&&r>n){const t=Ot(o,e);t&&l.push(t)}else if("number"==typeof t){const r=Ot(t,e);r&&l.push(r)}ie.current=ze[0]}}),[ze[0]]),$t=e.useMemo((()=>{const e=Object.assign(Object.assign(Object.assign(Object.assign({margin:S?`${Ce}px ${Le}px ${Ae}px ${Fe}px`:"",height:De[1]&&"none"!==De[1]?`${_e}px`:"fit-content",width:De[0]&&"none"!==De[0]?`${Ue}px`:"fit-content"},k.content&&{cursor:"grab"}),w&&!(null==H?void 0:H.type)&&{gap:`${We}px ${Xe}px`}),R&&function(e,t,r,n,o){const l=(e,t)=>"full"===e?("x"===t?r[0]:r[1])-("x"===t?n:o):e;if("hybrid"!==t&&!Array.isArray(e)){const r=`${l(e,t)}px`;return"x"===t?{minWidth:r}:{minHeight:r}}let s,i;return Array.isArray(e)?[s,i]=e:s=i=e,{minWidth:`${l(s,"x")}px`,minHeight:`${l(i,"y")}px`}}(R,O,Pe,Ie,Ne)),W&&{flexShrink:0});if(null==H?void 0:H.type)return Object.assign(Object.assign({},e),{position:"relative"});const t=Ge[0]>1&&"hybrid"===O,r=t?I:"x"===O?"row":"column",n=De[1]?"wrap":void 0,o=t&&N?"start"===N?"flex-start":"center"===N?"center":"flex-end":void 0,l=t?void 0:"center";return Object.assign(Object.assign(Object.assign(Object.assign({},e),{display:"flex",flexDirection:r,flexWrap:n}),o&&{justifyContent:o}),l&&{alignItems:l})}),[S,[Ce,Le,Ae,Fe,Ie,Ne].join(),De[1],_e,Ue,k.content,Se,[We,Xe].join(),null==H?void 0:H.type,Oe,O,Pe.join(),we,Ge[0],I,N]);e.useEffect((()=>{(Y||(null==H?void 0:H.type))&&(Y||null===ae.current.empty||(ae.current.empty=null),U())}),[je,null==H?void 0:H.type,ye,de.current,ze.length]),e.useEffect((()=>(((null==H?void 0:H.type)||X)&&(X&&X(!1),te()),ht(),()=>{ue.current.animationFrameId&&cancelAnimationFrame(ue.current.animationFrameId),(()=>{for(const e of b.values())clearTimeout(e);b.clear()})()})),[]),e.useEffect((()=>{const e=oe.current;if(!e)return;const t=k.wheel?t=>function(e,t,r,n){e.preventDefault(),r.animating||(r.targetScrollX=t.scrollLeft,r.targetScrollY=t.scrollTop),"x"===n?r.targetScrollX=a(r.targetScrollX+e.deltaY,0,t.scrollWidth-t.clientWidth+2):r.targetScrollY=a(r.targetScrollY+e.deltaY,0,t.scrollHeight-t.clientHeight+2),r.animating||(r.animating=!0,r.animationFrameId=requestAnimationFrame((function e(){const o=.4;let l=0;"x"===n?(t.scrollLeft+=(r.targetScrollX-t.scrollLeft)*o,l=Math.abs(t.scrollLeft-r.targetScrollX)):(t.scrollTop+=(r.targetScrollY-t.scrollTop)*o,l=Math.abs(t.scrollTop-r.targetScrollY)),l>2.5?r.animationFrameId=requestAnimationFrame(e):(r.animating=!1,null!==r.animationFrameId&&(cancelAnimationFrame(r.animationFrameId),r.animationFrameId=null))})))}(t,e,ue.current,O):e=>e.preventDefault();return e.addEventListener("wheel",t,{passive:!1}),()=>{e.removeEventListener("wheel",t)}}),[O,k.wheel]),e.useEffect((()=>{if(!Re.value||0===ze.length)return;const e=[];return("hybrid"===O?["x","y"]:[O]).forEach((t=>{const r="x"===t?0:1;"end"===Re.value[r]&&Tt(t,"end","x"===t?Qe:Je,Pe[r],"x"===t?ct:it,e)})),()=>{e.forEach((e=>e()))}}),[Re.value.join(),ze[0],ze.length,it]),e.useEffect((()=>{if(!Re.value||0===ze.length)return;const e=[];return("hybrid"===O?["x","y"]:[O]).forEach((t=>{const r="x"===t?0:1;"number"==typeof Re.value[r]&&Tt(t,Re.value[r],"x"===t?Qe:Je,Pe[r],"x"===t?ct:it,e)})),()=>{e.forEach((e=>e()))}}),[Re.value.join(),null==C?void 0:C.updater]);const zt=e.useCallback(((t,r,n,o)=>{var l;const s=Object.assign({width:Ke[0]?`${Ke[0]}px`:void 0,height:Ke[1]?`${Ke[1]}px`:void 0},(null==H?void 0:H.type)&&Object.assign({position:"absolute",top:`${r}px`,left:`${n}px`},!Ke[0]&&1===Ge[0]&&{transform:"translateX(-50%)"})),i=$?e.createElement(e.Suspense,{fallback:z},o):o,c=(null===(l=null==Y?void 0:Y.clickTrigger)||void 0===l?void 0:l.selector)&&kt;return e.createElement("div",Object.assign({key:t},H||Y?{[h]:`${t}`}:{},{className:"ms-object-box",style:s,onClick:c}),i)}),[$,!!z,Ke.join(),oe.current,ye,je,Ge[0]]),Ct=e.createElement("div",{className:"ms-objects-wrapper",ref:le,onMouseDown:Rt,style:$t},ze.map(((t,n)=>{var o,l,s;const i=e.Children.toArray(A).find((r=>e.isValidElement(r)&&r.key===t)),c=(null==H?void 0:H.stopLoadOnScroll)&&de.current&&!ae.current.loaded.includes(`${t}`)?z:(null===(o=ae.current.empty)||void 0===o?void 0:o.includes(t))?"object"==typeof(null==Y?void 0:Y.mode)?Y.mode.fallback:z:i,a="number"==typeof De[0]&&"number"==typeof De[1]||"firstChild"!==De[0]&&"firstChild"!==De[1]||0!==n?c:e.createElement(r,{onResize:jt},c);if(!(null==H?void 0:H.type))return zt(t,0,0,a);{const{elementTop:e,elementBottom:r,left:o,right:i}=ut[n],c="x"===O?Ye:Be,u=qe+c>("x"===O?o:e)-et&&("x"===O?i:r)-et>0-c,d="hybrid"!==O||Pe[0]+Ye>o-((null===(l=oe.current)||void 0===l?void 0:l.scrollLeft)||0)&&i-((null===(s=oe.current)||void 0===s?void 0:s.scrollLeft)||0)>0-Ye;if(u&&d)return zt(t,e,o,a)}}))),Lt=[{positionType:"x"===O?"left":"top",visibility:tt},{positionType:"x"===O?"right":"bottom",visibility:rt},..."hybrid"===O?[{positionType:"left",visibility:nt},{positionType:"right",visibility:ot}]:[]],At=e.createElement("div",{"morph-scroll":`〈♦${J}〉`,className:`${x&&x}`,ref:re,style:{width:`${Pe[2]}px`,height:`${Pe[3]}px`}},e.createElement("div",{className:"ms-content",ref:ne,onMouseEnter:ft,onMouseLeave:ft,onTouchStart:ft,onTouchEnd:ft,style:Object.assign({position:"relative",width:`${Pe[0]}px`,height:`${Pe[1]}px`},k.arrows&&Te.size&&("x"===O?{left:`${Te.size}px`}:"y"===O?{top:`${Te.size}px`}:{top:`${Te.size}px`,left:`${Te.size}px`}))},e.createElement("div",{className:"ms-element",ref:oe,onScroll:bt,style:Object.assign(Object.assign(Object.assign({width:"100%",height:"100%"},dt),{overflow:{x:""+(Qe>Pe[0]?"scroll hidden":"hidden"),y:""+(Je>Pe[1]?"hidden scroll":"hidden"),hybrid:`${Qe>Pe[0]?"scroll":"hidden"} ${Je>Pe[1]?"scroll":"hidden"}`,hide:"hidden"}[k.wheel||k.content?O:"hide"]}),"scroll"!==y||"boolean"!=typeof k.progressElement||!1===k.progressElement?{scrollbarWidth:"none"}:{})},De[0]&&De[1]?Ct:e.createElement(r,{onResize:Et,style:Object.assign({},dt)},Ct)),L&&Lt.map((({positionType:t,visibility:r})=>e.createElement(s,{key:`edge-${t}`,edgeGradient:ke,visibility:r,edgeType:t}))),k.progressElement&&!0!==k.progressElement&&[{shouldRender:lt<Ze,direction:O,thumbSize:lt,thumbSpace:vt,objLengthPerSize:pt,progressReverseIndex:0},{shouldRender:"hybrid"===O&&st<Qe,direction:"x",thumbSize:st,thumbSpace:yt,objLengthPerSize:mt[0],progressReverseIndex:1}].filter((({shouldRender:e})=>e)).map((t=>e.createElement(l,{key:t.direction,type:y,direction:t.direction,progressReverse:"boolean"==typeof M?M:M[t.progressReverseIndex],size:Pe,progressTrigger:k,scrollBarOnHover:T,scrollBarEvent:"sliderMenu"===y?Ot:St,thumbSize:t.thumbSize,thumbSpace:t.thumbSpace,objLengthPerSize:t.objLengthPerSize,sliderCheckLocal:ht})))),k.arrows&&Lt.map((({positionType:t,visibility:r})=>e.createElement(i,{key:`arrow-${t}`,activity:r,arrows:Te,arrowType:t,handleArrow:gt,size:"hybrid"===O?Pe[0]+2*Te.size:Pe[0]}))));return"auto"===E?e.createElement(r,{measure:"outer",onResize:xt},At):At},exports.ResizeTracker=r;