react-spring-carousel 3.0.0-beta-2.0.106 → 3.0.0-beta-2.1.0
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/dist/index.es.js +751 -739
- package/dist/index.umd.js +10 -10
- package/dist/types.d.ts +2 -0
- package/dist/useEventsModule.d.ts +3 -1
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(A,L){typeof exports=="object"&&typeof module<"u"?L(exports,require("react/jsx-runtime"),require("@react-spring/web"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@react-spring/web","react"],L):(A=typeof globalThis<"u"?globalThis:A||self,L(A["react-spring-carousel"]={},A["react/jsx-runtime"],A["@react-spring/web"],A.React))})(this,function(A,L,J,m){"use strict";function Ne(t,e,r){return Math.max(e,Math.min(t,r))}const _={toVector(t,e){return t===void 0&&(t=e),Array.isArray(t)?t:[t,t]},add(t,e){return[t[0]+e[0],t[1]+e[1]]},sub(t,e){return[t[0]-e[0],t[1]-e[1]]},addTo(t,e){t[0]+=e[0],t[1]+=e[1]},subTo(t,e){t[0]-=e[0],t[1]-=e[1]}};function ae(t,e,r){return e===0||Math.abs(e)===1/0?Math.pow(t,r*5):t*e*r/(e+r*t)}function ce(t,e,r,n=.15){return n===0?Ne(t,e,r):t<e?-ae(e-t,r-e,n)+e:t>r?+ae(t-r,r-e,n)+r:t}function Me(t,[e,r],[n,s]){const[[o,a],[c,f]]=t;return[ce(e,o,a,n),ce(r,c,f,s)]}function Le(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Ve(t){var e=Le(t,"string");return typeof e=="symbol"?e:String(e)}function S(t,e,r){return e=Ve(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ue(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),r.push.apply(r,n)}return r}function p(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?ue(Object(r),!0).forEach(function(n){S(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):ue(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}const le={pointer:{start:"down",change:"move",end:"up"},mouse:{start:"down",change:"move",end:"up"},touch:{start:"start",change:"move",end:"end"},gesture:{start:"start",change:"change",end:"end"}};function fe(t){return t?t[0].toUpperCase()+t.slice(1):""}const je=["enter","leave"];function Re(t=!1,e){return t&&!je.includes(e)}function Be(t,e="",r=!1){const n=le[t],s=n&&n[e]||e;return"on"+fe(t)+fe(s)+(Re(r,s)?"Capture":"")}const Ue=["gotpointercapture","lostpointercapture"];function Ke(t){let e=t.substring(2).toLowerCase();const r=!!~e.indexOf("passive");r&&(e=e.replace("passive",""));const n=Ue.includes(e)?"capturecapture":"capture",s=!!~e.indexOf(n);return s&&(e=e.replace("capture","")),{device:e,capture:s,passive:r}}function Ge(t,e=""){const r=le[t],n=r&&r[e]||e;return t+n}function W(t){return"touches"in t}function de(t){return W(t)?"touch":"pointerType"in t?t.pointerType:"mouse"}function ze(t){return Array.from(t.touches).filter(e=>{var r,n;return e.target===t.currentTarget||((r=t.currentTarget)===null||r===void 0||(n=r.contains)===null||n===void 0?void 0:n.call(r,e.target))})}function We(t){return t.type==="touchend"||t.type==="touchcancel"?t.changedTouches:t.targetTouches}function he(t){return W(t)?We(t)[0]:t}function Ye(t){return ze(t).map(e=>e.identifier)}function Q(t){const e=he(t);return W(t)?e.identifier:e.pointerId}function pe(t){const e=he(t);return[e.clientX,e.clientY]}function Fe(t){const e={};if("buttons"in t&&(e.buttons=t.buttons),"shiftKey"in t){const{shiftKey:r,altKey:n,metaKey:s,ctrlKey:o}=t;Object.assign(e,{shiftKey:r,altKey:n,metaKey:s,ctrlKey:o})}return e}function Y(t,...e){return typeof t=="function"?t(...e):t}function He(){}function Xe(...t){return t.length===0?He:t.length===1?t[0]:function(){let e;for(const r of t)e=r.apply(this,arguments)||e;return e}}function ge(t,e){return Object.assign({},e,t||{})}const qe=32;class Je{constructor(e,r,n){this.ctrl=e,this.args=r,this.key=n,this.state||(this.state={},this.computeValues([0,0]),this.computeInitial(),this.init&&this.init(),this.reset())}get state(){return this.ctrl.state[this.key]}set state(e){this.ctrl.state[this.key]=e}get shared(){return this.ctrl.state.shared}get eventStore(){return this.ctrl.gestureEventStores[this.key]}get timeoutStore(){return this.ctrl.gestureTimeoutStores[this.key]}get config(){return this.ctrl.config[this.key]}get sharedConfig(){return this.ctrl.config.shared}get handler(){return this.ctrl.handlers[this.key]}reset(){const{state:e,shared:r,ingKey:n,args:s}=this;r[n]=e._active=e.active=e._blocked=e._force=!1,e._step=[!1,!1],e.intentional=!1,e._movement=[0,0],e._distance=[0,0],e._direction=[0,0],e._delta=[0,0],e._bounds=[[-1/0,1/0],[-1/0,1/0]],e.args=s,e.axis=void 0,e.memo=void 0,e.elapsedTime=e.timeDelta=0,e.direction=[0,0],e.distance=[0,0],e.overflow=[0,0],e._movementBound=[!1,!1],e.velocity=[0,0],e.movement=[0,0],e.delta=[0,0],e.timeStamp=0}start(e){const r=this.state,n=this.config;r._active||(this.reset(),this.computeInitial(),r._active=!0,r.target=e.target,r.currentTarget=e.currentTarget,r.lastOffset=n.from?Y(n.from,r):r.offset,r.offset=r.lastOffset,r.startTime=r.timeStamp=e.timeStamp)}computeValues(e){const r=this.state;r._values=e,r.values=this.config.transform(e)}computeInitial(){const e=this.state;e._initial=e._values,e.initial=e.values}compute(e){const{state:r,config:n,shared:s}=this;r.args=this.args;let o=0;if(e&&(r.event=e,n.preventDefault&&e.cancelable&&r.event.preventDefault(),r.type=e.type,s.touches=this.ctrl.pointerIds.size||this.ctrl.touchIds.size,s.locked=!!document.pointerLockElement,Object.assign(s,Fe(e)),s.down=s.pressed=s.buttons%2===1||s.touches>0,o=e.timeStamp-r.timeStamp,r.timeStamp=e.timeStamp,r.elapsedTime=r.timeStamp-r.startTime),r._active){const d=r._delta.map(Math.abs);_.addTo(r._distance,d)}this.axisIntent&&this.axisIntent(e);const[a,c]=r._movement,[f,h]=n.threshold,{_step:u,values:b}=r;if(n.hasCustomTransform?(u[0]===!1&&(u[0]=Math.abs(a)>=f&&b[0]),u[1]===!1&&(u[1]=Math.abs(c)>=h&&b[1])):(u[0]===!1&&(u[0]=Math.abs(a)>=f&&Math.sign(a)*f),u[1]===!1&&(u[1]=Math.abs(c)>=h&&Math.sign(c)*h)),r.intentional=u[0]!==!1||u[1]!==!1,!r.intentional)return;const v=[0,0];if(n.hasCustomTransform){const[d,H]=b;v[0]=u[0]!==!1?d-u[0]:0,v[1]=u[1]!==!1?H-u[1]:0}else v[0]=u[0]!==!1?a-u[0]:0,v[1]=u[1]!==!1?c-u[1]:0;this.restrictToAxis&&!r._blocked&&this.restrictToAxis(v);const O=r.offset,x=r._active&&!r._blocked||r.active;x&&(r.first=r._active&&!r.active,r.last=!r._active&&r.active,r.active=s[this.ingKey]=r._active,e&&(r.first&&("bounds"in n&&(r._bounds=Y(n.bounds,r)),this.setup&&this.setup()),r.movement=v,this.computeOffset()));const[I,w]=r.offset,[[N,E],[k,C]]=r._bounds;r.overflow=[I<N?-1:I>E?1:0,w<k?-1:w>C?1:0],r._movementBound[0]=r.overflow[0]?r._movementBound[0]===!1?r._movement[0]:r._movementBound[0]:!1,r._movementBound[1]=r.overflow[1]?r._movementBound[1]===!1?r._movement[1]:r._movementBound[1]:!1;const G=r._active?n.rubberband||[0,0]:[0,0];if(r.offset=Me(r._bounds,r.offset,G),r.delta=_.sub(r.offset,O),this.computeMovement(),x&&(!r.last||o>qe)){r.delta=_.sub(r.offset,O);const d=r.delta.map(Math.abs);_.addTo(r.distance,d),r.direction=r.delta.map(Math.sign),r._direction=r._delta.map(Math.sign),!r.first&&o>0&&(r.velocity=[d[0]/o,d[1]/o],r.timeDelta=o)}}emit(){const e=this.state,r=this.shared,n=this.config;if(e._active||this.clean(),(e._blocked||!e.intentional)&&!e._force&&!n.triggerAllEvents)return;const s=this.handler(p(p(p({},r),e),{},{[this.aliasKey]:e.values}));s!==void 0&&(e.memo=s)}clean(){this.eventStore.clean(),this.timeoutStore.clean()}}function Qe([t,e],r){const n=Math.abs(t),s=Math.abs(e);if(n>s&&n>r)return"x";if(s>n&&s>r)return"y"}class Ze extends Je{constructor(...e){super(...e),S(this,"aliasKey","xy")}reset(){super.reset(),this.state.axis=void 0}init(){this.state.offset=[0,0],this.state.lastOffset=[0,0]}computeOffset(){this.state.offset=_.add(this.state.lastOffset,this.state.movement)}computeMovement(){this.state.movement=_.sub(this.state.offset,this.state.lastOffset)}axisIntent(e){const r=this.state,n=this.config;if(!r.axis&&e){const s=typeof n.axisThreshold=="object"?n.axisThreshold[de(e)]:n.axisThreshold;r.axis=Qe(r._movement,s)}r._blocked=(n.lockDirection||!!n.axis)&&!r.axis||!!n.axis&&n.axis!==r.axis}restrictToAxis(e){if(this.config.axis||this.config.lockDirection)switch(this.state.axis){case"x":e[1]=0;break;case"y":e[0]=0;break}}}const me=t=>t,ve=.15,Z={enabled(t=!0){return t},eventOptions(t,e,r){return p(p({},r.shared.eventOptions),t)},preventDefault(t=!1){return t},triggerAllEvents(t=!1){return t},rubberband(t=0){switch(t){case!0:return[ve,ve];case!1:return[0,0];default:return _.toVector(t)}},from(t){if(typeof t=="function")return t;if(t!=null)return _.toVector(t)},transform(t,e,r){const n=t||r.shared.transform;if(this.hasCustomTransform=!!n,process.env.NODE_ENV==="development"){const s=n||me;return o=>{const a=s(o);return(!isFinite(a[0])||!isFinite(a[1]))&&console.warn(`[@use-gesture]: config.transform() must produce a valid result, but it was: [${a[0]},${[1]}]`),a}}return n||me},threshold(t){return _.toVector(t,0)}};process.env.NODE_ENV==="development"&&Object.assign(Z,{domTarget(t){if(t!==void 0)throw Error("[@use-gesture]: `domTarget` option has been renamed to `target`.");return NaN},lockDirection(t){if(t!==void 0)throw Error("[@use-gesture]: `lockDirection` option has been merged with `axis`. Use it as in `{ axis: 'lock' }`");return NaN},initial(t){if(t!==void 0)throw Error("[@use-gesture]: `initial` option has been renamed to `from`.");return NaN}});const et=0,U=p(p({},Z),{},{axis(t,e,{axis:r}){if(this.lockDirection=r==="lock",!this.lockDirection)return r},axisThreshold(t=et){return t},bounds(t={}){if(typeof t=="function")return o=>U.bounds(t(o));if("current"in t)return()=>t.current;if(typeof HTMLElement=="function"&&t instanceof HTMLElement)return t;const{left:e=-1/0,right:r=1/0,top:n=-1/0,bottom:s=1/0}=t;return[[e,r],[n,s]]}}),ye={ArrowRight:(t,e=1)=>[t*e,0],ArrowLeft:(t,e=1)=>[-1*t*e,0],ArrowUp:(t,e=1)=>[0,-1*t*e],ArrowDown:(t,e=1)=>[0,t*e]};class tt extends Ze{constructor(...e){super(...e),S(this,"ingKey","dragging")}reset(){super.reset();const e=this.state;e._pointerId=void 0,e._pointerActive=!1,e._keyboardActive=!1,e._preventScroll=!1,e._delayed=!1,e.swipe=[0,0],e.tap=!1,e.canceled=!1,e.cancel=this.cancel.bind(this)}setup(){const e=this.state;if(e._bounds instanceof HTMLElement){const r=e._bounds.getBoundingClientRect(),n=e.currentTarget.getBoundingClientRect(),s={left:r.left-n.left+e.offset[0],right:r.right-n.right+e.offset[0],top:r.top-n.top+e.offset[1],bottom:r.bottom-n.bottom+e.offset[1]};e._bounds=U.bounds(s)}}cancel(){const e=this.state;e.canceled||(e.canceled=!0,e._active=!1,setTimeout(()=>{this.compute(),this.emit()},0))}setActive(){this.state._active=this.state._pointerActive||this.state._keyboardActive}clean(){this.pointerClean(),this.state._pointerActive=!1,this.state._keyboardActive=!1,super.clean()}pointerDown(e){const r=this.config,n=this.state;if(e.buttons!=null&&(Array.isArray(r.pointerButtons)?!r.pointerButtons.includes(e.buttons):r.pointerButtons!==-1&&r.pointerButtons!==e.buttons))return;const s=this.ctrl.setEventIds(e);r.pointerCapture&&e.target.setPointerCapture(e.pointerId),!(s&&s.size>1&&n._pointerActive)&&(this.start(e),this.setupPointer(e),n._pointerId=Q(e),n._pointerActive=!0,this.computeValues(pe(e)),this.computeInitial(),r.preventScrollAxis&&de(e)!=="mouse"?(n._active=!1,this.setupScrollPrevention(e)):r.delay>0?(this.setupDelayTrigger(e),r.triggerAllEvents&&(this.compute(e),this.emit())):this.startPointerDrag(e))}startPointerDrag(e){const r=this.state;r._active=!0,r._preventScroll=!0,r._delayed=!1,this.compute(e),this.emit()}pointerMove(e){const r=this.state,n=this.config;if(!r._pointerActive)return;const s=Q(e);if(r._pointerId!==void 0&&s!==r._pointerId)return;const o=pe(e);if(document.pointerLockElement===e.target?r._delta=[e.movementX,e.movementY]:(r._delta=_.sub(o,r._values),this.computeValues(o)),_.addTo(r._movement,r._delta),this.compute(e),r._delayed&&r.intentional){this.timeoutStore.remove("dragDelay"),r.active=!1,this.startPointerDrag(e);return}if(n.preventScrollAxis&&!r._preventScroll)if(r.axis)if(r.axis===n.preventScrollAxis||n.preventScrollAxis==="xy"){r._active=!1,this.clean();return}else{this.timeoutStore.remove("startPointerDrag"),this.startPointerDrag(e);return}else return;this.emit()}pointerUp(e){this.ctrl.setEventIds(e);try{this.config.pointerCapture&&e.target.hasPointerCapture(e.pointerId)&&e.target.releasePointerCapture(e.pointerId)}catch{process.env.NODE_ENV==="development"&&console.warn("[@use-gesture]: If you see this message, it's likely that you're using an outdated version of `@react-three/fiber`. \n\nPlease upgrade to the latest version.")}const r=this.state,n=this.config;if(!r._active||!r._pointerActive)return;const s=Q(e);if(r._pointerId!==void 0&&s!==r._pointerId)return;this.state._pointerActive=!1,this.setActive(),this.compute(e);const[o,a]=r._distance;if(r.tap=o<=n.tapsThreshold&&a<=n.tapsThreshold,r.tap&&n.filterTaps)r._force=!0;else{const[c,f]=r._delta,[h,u]=r._movement,[b,v]=n.swipe.velocity,[O,x]=n.swipe.distance,I=n.swipe.duration;if(r.elapsedTime<I){const w=Math.abs(c/r.timeDelta),N=Math.abs(f/r.timeDelta);w>b&&Math.abs(h)>O&&(r.swipe[0]=Math.sign(c)),N>v&&Math.abs(u)>x&&(r.swipe[1]=Math.sign(f))}}this.emit()}pointerClick(e){!this.state.tap&&e.detail>0&&(e.preventDefault(),e.stopPropagation())}setupPointer(e){const r=this.config,n=r.device;if(process.env.NODE_ENV==="development")try{if(n==="pointer"&&r.preventScrollDelay===void 0){const s="uv"in e?e.sourceEvent.currentTarget:e.currentTarget;window.getComputedStyle(s).touchAction==="auto"&&console.warn("[@use-gesture]: The drag target has its `touch-action` style property set to `auto`. It is recommended to add `touch-action: 'none'` so that the drag gesture behaves correctly on touch-enabled devices. For more information read this: https://use-gesture.netlify.app/docs/extras/#touch-action.\n\nThis message will only show in development mode. It won't appear in production. If this is intended, you can ignore it.",s)}}catch{}r.pointerLock&&e.currentTarget.requestPointerLock(),r.pointerCapture||(this.eventStore.add(this.sharedConfig.window,n,"change",this.pointerMove.bind(this)),this.eventStore.add(this.sharedConfig.window,n,"end",this.pointerUp.bind(this)),this.eventStore.add(this.sharedConfig.window,n,"cancel",this.pointerUp.bind(this)))}pointerClean(){this.config.pointerLock&&document.pointerLockElement===this.state.currentTarget&&document.exitPointerLock()}preventScroll(e){this.state._preventScroll&&e.cancelable&&e.preventDefault()}setupScrollPrevention(e){this.state._preventScroll=!1,rt(e);const r=this.eventStore.add(this.sharedConfig.window,"touch","change",this.preventScroll.bind(this),{passive:!1});this.eventStore.add(this.sharedConfig.window,"touch","end",r),this.eventStore.add(this.sharedConfig.window,"touch","cancel",r),this.timeoutStore.add("startPointerDrag",this.startPointerDrag.bind(this),this.config.preventScrollDelay,e)}setupDelayTrigger(e){this.state._delayed=!0,this.timeoutStore.add("dragDelay",()=>{this.state._step=[0,0],this.startPointerDrag(e)},this.config.delay)}keyDown(e){const r=ye[e.key];if(r){const n=this.state,s=e.shiftKey?10:e.altKey?.1:1;this.start(e),n._delta=r(this.config.keyboardDisplacement,s),n._keyboardActive=!0,_.addTo(n._movement,n._delta),this.compute(e),this.emit()}}keyUp(e){e.key in ye&&(this.state._keyboardActive=!1,this.setActive(),this.compute(e),this.emit())}bind(e){const r=this.config.device;e(r,"start",this.pointerDown.bind(this)),this.config.pointerCapture&&(e(r,"change",this.pointerMove.bind(this)),e(r,"end",this.pointerUp.bind(this)),e(r,"cancel",this.pointerUp.bind(this)),e("lostPointerCapture","",this.pointerUp.bind(this))),this.config.keys&&(e("key","down",this.keyDown.bind(this)),e("key","up",this.keyUp.bind(this))),this.config.filterTaps&&e("click","",this.pointerClick.bind(this),{capture:!0,passive:!1})}}function rt(t){"persist"in t&&typeof t.persist=="function"&&t.persist()}const K=typeof window<"u"&&window.document&&window.document.createElement;function be(){return K&&"ontouchstart"in window}function nt(){return be()||K&&window.navigator.maxTouchPoints>1}function st(){return K&&"onpointerdown"in window}function it(){return K&&"exitPointerLock"in window.document}function ot(){try{return"constructor"in GestureEvent}catch{return!1}}const P={isBrowser:K,gesture:ot(),touch:be(),touchscreen:nt(),pointer:st(),pointerLock:it()},at=250,ct=180,ut=.5,lt=50,ft=250,dt=10,_e={mouse:0,touch:0,pen:8},xe=p(p({},U),{},{device(t,e,{pointer:{touch:r=!1,lock:n=!1,mouse:s=!1}={}}){return this.pointerLock=n&&P.pointerLock,P.touch&&r?"touch":this.pointerLock?"mouse":P.pointer&&!s?"pointer":P.touch?"touch":"mouse"},preventScrollAxis(t,e,{preventScroll:r}){if(this.preventScrollDelay=typeof r=="number"?r:r||r===void 0&&t?at:void 0,!(!P.touchscreen||r===!1))return t||(r!==void 0?"y":void 0)},pointerCapture(t,e,{pointer:{capture:r=!0,buttons:n=1,keys:s=!0}={}}){return this.pointerButtons=n,this.keys=s,!this.pointerLock&&this.device==="pointer"&&r},threshold(t,e,{filterTaps:r=!1,tapsThreshold:n=3,axis:s=void 0}){const o=_.toVector(t,r?n:s?1:0);return this.filterTaps=r,this.tapsThreshold=n,o},swipe({velocity:t=ut,distance:e=lt,duration:r=ft}={}){return{velocity:this.transform(_.toVector(t)),distance:this.transform(_.toVector(e)),duration:r}},delay(t=0){switch(t){case!0:return ct;case!1:return 0;default:return t}},axisThreshold(t){return t?p(p({},_e),t):_e},keyboardDisplacement(t=dt){return t}});process.env.NODE_ENV==="development"&&Object.assign(xe,{useTouch(t){if(t!==void 0)throw Error("[@use-gesture]: `useTouch` option has been renamed to `pointer.touch`. Use it as in `{ pointer: { touch: true } }`.");return NaN},experimental_preventWindowScrollY(t){if(t!==void 0)throw Error("[@use-gesture]: `experimental_preventWindowScrollY` option has been renamed to `preventScroll`.");return NaN},swipeVelocity(t){if(t!==void 0)throw Error("[@use-gesture]: `swipeVelocity` option has been renamed to `swipe.velocity`. Use it as in `{ swipe: { velocity: 0.5 } }`.");return NaN},swipeDistance(t){if(t!==void 0)throw Error("[@use-gesture]: `swipeDistance` option has been renamed to `swipe.distance`. Use it as in `{ swipe: { distance: 50 } }`.");return NaN},swipeDuration(t){if(t!==void 0)throw Error("[@use-gesture]: `swipeDuration` option has been renamed to `swipe.duration`. Use it as in `{ swipe: { duration: 250 } }`.");return NaN}}),p(p({},Z),{},{device(t,e,{shared:r,pointer:{touch:n=!1}={}}){if(r.target&&!P.touch&&P.gesture)return"gesture";if(P.touch&&n)return"touch";if(P.touchscreen){if(P.pointer)return"pointer";if(P.touch)return"touch"}},bounds(t,e,{scaleBounds:r={},angleBounds:n={}}){const s=a=>{const c=ge(Y(r,a),{min:-1/0,max:1/0});return[c.min,c.max]},o=a=>{const c=ge(Y(n,a),{min:-1/0,max:1/0});return[c.min,c.max]};return typeof r!="function"&&typeof n!="function"?[s(),o()]:a=>[s(a),o(a)]},threshold(t,e,r){return this.lockDirection=r.axis==="lock",_.toVector(t,this.lockDirection?[.1,3]:0)},modifierKey(t){return t===void 0?"ctrlKey":t},pinchOnWheel(t=!0){return t}}),p(p({},U),{},{mouseOnly:(t=!0)=>t}),p(p({},U),{},{mouseOnly:(t=!0)=>t});const we=new Map,ee=new Map;function ht(t){we.set(t.key,t.engine),ee.set(t.key,t.resolver)}const pt={key:"drag",engine:tt,resolver:xe};function gt(t,e){if(t==null)return{};var r={},n=Object.keys(t),s,o;for(o=0;o<n.length;o++)s=n[o],!(e.indexOf(s)>=0)&&(r[s]=t[s]);return r}function mt(t,e){if(t==null)return{};var r=gt(t,e),n,s;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(s=0;s<o.length;s++)n=o[s],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}const vt={target(t){if(t)return()=>"current"in t?t.current:t},enabled(t=!0){return t},window(t=P.isBrowser?window:void 0){return t},eventOptions({passive:t=!0,capture:e=!1}={}){return{passive:t,capture:e}},transform(t){return t}},yt=["target","eventOptions","window","enabled","transform"];function F(t={},e){const r={};for(const[n,s]of Object.entries(e))switch(typeof s){case"function":if(process.env.NODE_ENV==="development"){const o=s.call(r,t[n],n,t);Number.isNaN(o)||(r[n]=o)}else r[n]=s.call(r,t[n],n,t);break;case"object":r[n]=F(t[n],s);break;case"boolean":s&&(r[n]=t[n]);break}return r}function bt(t,e,r={}){const n=t,{target:s,eventOptions:o,window:a,enabled:c,transform:f}=n,h=mt(n,yt);if(r.shared=F({target:s,eventOptions:o,window:a,enabled:c,transform:f},vt),e){const u=ee.get(e);r[e]=F(p({shared:r.shared},h),u)}else for(const u in h){const b=ee.get(u);if(b)r[u]=F(p({shared:r.shared},h[u]),b);else if(process.env.NODE_ENV==="development"&&!["drag","pinch","scroll","wheel","move","hover"].includes(u)){if(u==="domTarget")throw Error("[@use-gesture]: `domTarget` option has been renamed to `target`.");console.warn(`[@use-gesture]: Unknown config key \`${u}\` was used. Please read the documentation for further information.`)}}return r}class Ee{constructor(e,r){S(this,"_listeners",new Set),this._ctrl=e,this._gestureKey=r}add(e,r,n,s,o){const a=this._listeners,c=Ge(r,n),f=this._gestureKey?this._ctrl.config[this._gestureKey].eventOptions:{},h=p(p({},f),o);e.addEventListener(c,s,h);const u=()=>{e.removeEventListener(c,s,h),a.delete(u)};return a.add(u),u}clean(){this._listeners.forEach(e=>e()),this._listeners.clear()}}class _t{constructor(){S(this,"_timeouts",new Map)}add(e,r,n=140,...s){this.remove(e),this._timeouts.set(e,window.setTimeout(r,n,...s))}remove(e){const r=this._timeouts.get(e);r&&window.clearTimeout(r)}clean(){this._timeouts.forEach(e=>void window.clearTimeout(e)),this._timeouts.clear()}}class xt{constructor(e){S(this,"gestures",new Set),S(this,"_targetEventStore",new Ee(this)),S(this,"gestureEventStores",{}),S(this,"gestureTimeoutStores",{}),S(this,"handlers",{}),S(this,"config",{}),S(this,"pointerIds",new Set),S(this,"touchIds",new Set),S(this,"state",{shared:{shiftKey:!1,metaKey:!1,ctrlKey:!1,altKey:!1}}),wt(this,e)}setEventIds(e){if(W(e))return this.touchIds=new Set(Ye(e)),this.touchIds;if("pointerId"in e)return e.type==="pointerup"||e.type==="pointercancel"?this.pointerIds.delete(e.pointerId):e.type==="pointerdown"&&this.pointerIds.add(e.pointerId),this.pointerIds}applyHandlers(e,r){this.handlers=e,this.nativeHandlers=r}applyConfig(e,r){this.config=bt(e,r,this.config)}clean(){this._targetEventStore.clean();for(const e of this.gestures)this.gestureEventStores[e].clean(),this.gestureTimeoutStores[e].clean()}effect(){return this.config.shared.target&&this.bind(),()=>this._targetEventStore.clean()}bind(...e){const r=this.config.shared,n={};let s;if(!(r.target&&(s=r.target(),!s))){if(r.enabled){for(const a of this.gestures){const c=this.config[a],f=Te(n,c.eventOptions,!!s);if(c.enabled){const h=we.get(a);new h(this,e,a).bind(f)}}const o=Te(n,r.eventOptions,!!s);for(const a in this.nativeHandlers)o(a,"",c=>this.nativeHandlers[a](p(p({},this.state.shared),{},{event:c,args:e})),void 0,!0)}for(const o in n)n[o]=Xe(...n[o]);if(!s)return n;for(const o in n){const{device:a,capture:c,passive:f}=Ke(o);this._targetEventStore.add(s,a,"",n[o],{capture:c,passive:f})}}}}function j(t,e){t.gestures.add(e),t.gestureEventStores[e]=new Ee(t,e),t.gestureTimeoutStores[e]=new _t}function wt(t,e){e.drag&&j(t,"drag"),e.wheel&&j(t,"wheel"),e.scroll&&j(t,"scroll"),e.move&&j(t,"move"),e.pinch&&j(t,"pinch"),e.hover&&j(t,"hover")}const Te=(t,e,r)=>(n,s,o,a={},c=!1)=>{var f,h;const u=(f=a.capture)!==null&&f!==void 0?f:e.capture,b=(h=a.passive)!==null&&h!==void 0?h:e.passive;let v=c?n:Be(n,s,u);r&&b&&(v+="Passive"),t[v]=t[v]||[],t[v].push(o)};function Et(t,e={},r,n){const s=m.useMemo(()=>new xt(t),[]);if(s.applyHandlers(t,n),s.applyConfig(e,r),m.useEffect(s.effect.bind(s)),m.useEffect(()=>s.clean.bind(s),[]),e.target===void 0)return s.bind.bind(s)}function Tt(t,e){return ht(pt),Et({drag:t},e||{},"drag")}const te="RSC::Event";function St(){const t=m.useRef(null);function e(n){m.useEffect(()=>{t.current||(t.current=document.createElement("div"));function s(o){n(o.detail)}if(t.current)return t.current.addEventListener(te,s,!1),()=>{var o;(o=t.current)==null||o.removeEventListener(te,s,!1)}},[n])}function r(n){if(t.current){const s=new CustomEvent(te,{detail:n});t.current.dispatchEvent(s)}}return{useListenToCustomEvent:e,emitEvent:r}}function It(t){let e=t.replace(/\/\*[\s\S]*?\*\/|([^:]|^)\/\/.*$/gm,"");return e=e.replace(/[\n\t]+/g," "),e=e.replace(/\s*([{}:;,])\s*/g,"$1"),e=e.replace(/\s+}/g,"}"),e=e.replace(/{\s+/g,"{"),e=e.replace(/\s+/g," "),e.trim()}function kt({init:t=!0,items:e,withLoop:r=!1,id:n,gutter:s=[{breakpoint:0,gutter:0,startEndGutter:0}],itemsPerSlide:o=[{breakpoint:0,itemsPerSlide:1}],carouselAxis:a="x",startingPosition:c="start",enableGestures:f=!0,slideWhenDragThresholdIsReached:h=!0,slideType:u="item",initialActiveItem:b=0}){const[v,O]=m.useState(!1),x=m.useRef(t),I=m.useRef(null),w=m.useRef(null),N=m.useRef(0),E=m.useRef(0),k=m.useRef(!r),C=m.useRef(!1),G=m.useRef(0),d=m.useRef(0);function H(i){if(i===void 0)return 0;if(typeof i=="number")return e[i]?i:(console.warn(`initialActiveItem: item at index ${i} doesn't exist.`),0);const l=e.findIndex(y=>y.id===i);return l<0?(console.warn(`initialActiveItem: item with id "${i}" doesn't exist.`),0):l}const X=J.useSpringRef(),ne=J.useSpring({value:0,ref:X,onChange({value:i}){const l=a==="x"?`translate3d(calc(${i.value}px + var(--${n}-offset-modifier)), 0px, 0px)`:`translate3d(0px, calc(${i.value}px + var(--${n}-offset-modifier)), 0px)`;w.current.style.transform=l}}),Ie=r?[...e.map(i=>({...i,id:`prev-repeated-item-${i.id}`,isClonedItem:!0})),...e,...e.map(i=>({...i,id:`next-repeated-item-${i.id}`,isClonedItem:!0}))]:e,{useListenToCustomEvent:ke,emitEvent:z}=St();function Ce(){const{totalGutterCssVar:i}=De();return i}function $t(){if(I.current){const l=window.getComputedStyle(I.current).getPropertyValue(`--${n}-items-per-slide`).trim();return Number(l)||1}return 1}function se(i){x.current&&(C.current||R({type:"next",toIndex:i,actionType:"click"}))}function ie(i){x.current&&(k.current||R({type:"prev",toIndex:i,actionType:"click"}))}function R({type:i,shouldAnimate:l=!0,toIndex:y,actionType:D}){var Pe,Oe;const $=!l;k.current=!1,C.current=!1;let g=ne.value.get(),T=0;if(i==="next"&&(d.current+=1),i==="prev"&&(d.current===0?d.current=e.length-1:d.current-=1),y!==void 0&&(d.current=y),i==="next"){const V=oe(r?E.current*(e.length*2):0);T=-(d.current*E.current),r&&d.current===e.length&&(d.current=0,g=g+E.current*e.length,T=0),!r&&(Math.abs(T)>=V||d.current===e.length-1)&&(C.current=!0,T=-V)}i==="prev"&&(T=-(d.current*E.current),d.current===e.length-1&&(g=g-e.length*E.current),!r&&T>=0&&(k.current=!0,T=0)),N.current=T;const M=r?d.current%e.length:d.current,B=r?e.length+d.current%e.length:d.current;D==="resize"?(T=-(d.current*E.current),z({eventName:"onResize",sliceActionType:D,slideDirection:i,currentItem:{id:((Pe=e.at(M))==null?void 0:Pe.id)??"",index:M,trackIndex:B,startReached:k.current,endReached:C.current}})):z({eventName:"onSlideStartChange",sliceActionType:D,slideDirection:i,nextItem:{index:M,id:((Oe=e.at(M))==null?void 0:Oe.id)??"",trackIndex:B,startReached:k.current,endReached:C.current}}),X.start({immediate:$,from:{value:g},to:{value:T},onChange({value:V}){const q=a==="x"?`translate3d(calc(${V.value}px + var(--${n}-offset-modifier)), 0px, 0px)`:`translate3d(0px, calc(${V.value}px + var(--${n}-offset-modifier)), 0px)`;w.current.style.transform=q},onRest({finished:V}){var q;if(V){const Ae=r?d.current%e.length:d.current,Nt=r?e.length+d.current%e.length:d.current;z({eventName:"onSlideChangeComplete",sliceActionType:D,slideDirection:i,currentItem:{index:Ae,id:((q=e.at(Ae))==null?void 0:q.id)??"",trackIndex:Nt,startReached:k.current,endReached:C.current}})}}})}function Pt(){const i=w.current;let l=0;return u==="item"?l=i.children[0].getBoundingClientRect()[a==="x"?"width":"height"]+Ce():l=i.getBoundingClientRect()[a==="x"?"width":"height"]+Ce(),l}function oe(i){const l=w.current;return l[a==="x"?"scrollWidth":"scrollHeight"]-l.getBoundingClientRect()[a==="x"?"width":"height"]-i}function De(){let i=0,l=0;if(I.current){const y=window.getComputedStyle(I.current),D=y.getPropertyValue(`--${n}-start-end-gutter`).trim();D.includes("px")&&(i=Number(D.replace("px","")));const $=y.getPropertyValue(`--${n}-gutter`).trim();$.includes("px")&&(l=Number($.replace("px","")))}return{totalStartEndGutterCssVar:i,totalGutterCssVar:l}}m.useEffect(()=>{function i($){const g=$t();switch($){case"start":return 0;case"middle-start":return Math.floor((g-1)*.25);case"center":return Math.floor((g-1)*.5);case"middle-end":return Math.floor((g-1)*.75);case"end":return g-1;default:return 0}}function l(){E.current=Pt(),G.current=E.current/4;const{totalStartEndGutterCssVar:$}=De();let g=0;r&&(g=E.current*e.length),g-=E.current*i(c),g-=$/2,I.current.style.setProperty(`--${n}-offset-modifier`,`${-g}px`)}function y($){if(I.current&&(l(),O(!0),$)){const g=H(b),T=r?e.length+g%e.length:g;z({eventName:"onInit",index:g,trackIndex:T})}}function D(){y(),R({type:"resize",toIndex:d.current,shouldAnimate:!1,actionType:"resize"})}if(t)return x.current=!0,y(!0),window.addEventListener("resize",D),()=>{window.removeEventListener("resize",D)}},[t,r,n,a,s,c]),m.useEffect(()=>{const i=H(b);t&&i!==d.current&&R({type:"next",toIndex:i,actionType:"resize",shouldAnimate:!1})},[t,b]);const $e=f,Ot=Tt(i=>{if(!x.current)return;const l=i.dragging,y=i.offset[a==="x"?0:1],D=i.movement[a==="x"?0:1],$=D>G.current,g=D<-G.current,T=i.velocity;l&&(z({...i,eventName:"onDrag",slideActionType:"drag"}),X.start({value:y,immediate:!0,config:{velocity:T},onChange({value:M}){const B=a==="x"?`translate3d(calc(${M.value}px + var(--${n}-offset-modifier)), 0px, 0px)`:`translate3d(0px, calc(${M.value}px + var(--${n}-offset-modifier)), 0px)`;w.current.style.transform=B}}),h&&($||g)&&i.cancel()),i.last&&($?(R({actionType:"drag",type:"prev"}),i.cancel()):g?(R({actionType:"drag",type:"next"}),i.cancel()):(X.start({value:N.current,config:{velocity:T},onChange({value:M}){const B=a==="x"?`translate3d(calc(${M.value}px + var(--${n}-offset-modifier)), 0px, 0px)`:`translate3d(0px, calc(${M.value}px + var(--${n}-offset-modifier)), 0px)`;w.current.style.transform=B}}),i.cancel()))},{enabled:$e,axis:a,rubberband:!r,...r?{}:{bounds:()=>({right:0,left:-oe(0),top:-oe(0),bottom:0})},from:()=>[ne.value.get(),ne.value.get()]});function At(i){var y;const l=r?e.length+d.current%e.length:d.current;return typeof i=="number"?l===i:i===((y=Ie[l])==null?void 0:y.id)}return{carouselFragment:L.jsxs("div",{ref:I,className:"ReactSpringCarouselContainer","data-part":"Container","data-part-internal":`${n}-Container`,...Ot(),children:[L.jsx("style",{dangerouslySetInnerHTML:{__html:It(`
|
|
1
|
+
(function(A,V){typeof exports=="object"&&typeof module<"u"?V(exports,require("react/jsx-runtime"),require("@react-spring/web"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@react-spring/web","react"],V):(A=typeof globalThis<"u"?globalThis:A||self,V(A["react-spring-carousel"]={},A["react/jsx-runtime"],A["@react-spring/web"],A.React))})(this,function(A,V,J,h){"use strict";function Ve(r,e,t){return Math.max(e,Math.min(r,t))}const E={toVector(r,e){return r===void 0&&(r=e),Array.isArray(r)?r:[r,r]},add(r,e){return[r[0]+e[0],r[1]+e[1]]},sub(r,e){return[r[0]-e[0],r[1]-e[1]]},addTo(r,e){r[0]+=e[0],r[1]+=e[1]},subTo(r,e){r[0]-=e[0],r[1]-=e[1]}};function ce(r,e,t){return e===0||Math.abs(e)===1/0?Math.pow(r,t*5):r*e*t/(e+t*r)}function ue(r,e,t,n=.15){return n===0?Ve(r,e,t):r<e?-ce(e-r,t-e,n)+e:r>t?+ce(r-t,t-e,n)+t:r}function Le(r,[e,t],[n,s]){const[[a,o],[u,d]]=r;return[ue(e,a,o,n),ue(t,u,d,s)]}function je(r,e){if(typeof r!="object"||r===null)return r;var t=r[Symbol.toPrimitive];if(t!==void 0){var n=t.call(r,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(r)}function Re(r){var e=je(r,"string");return typeof e=="symbol"?e:String(e)}function k(r,e,t){return e=Re(e),e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function le(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(r,s).enumerable})),t.push.apply(t,n)}return t}function v(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?le(Object(t),!0).forEach(function(n){k(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):le(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}const fe={pointer:{start:"down",change:"move",end:"up"},mouse:{start:"down",change:"move",end:"up"},touch:{start:"start",change:"move",end:"end"},gesture:{start:"start",change:"change",end:"end"}};function de(r){return r?r[0].toUpperCase()+r.slice(1):""}const Be=["enter","leave"];function Ue(r=!1,e){return r&&!Be.includes(e)}function Ke(r,e="",t=!1){const n=fe[r],s=n&&n[e]||e;return"on"+de(r)+de(s)+(Ue(t,s)?"Capture":"")}const Ge=["gotpointercapture","lostpointercapture"];function ze(r){let e=r.substring(2).toLowerCase();const t=!!~e.indexOf("passive");t&&(e=e.replace("passive",""));const n=Ge.includes(e)?"capturecapture":"capture",s=!!~e.indexOf(n);return s&&(e=e.replace("capture","")),{device:e,capture:s,passive:t}}function We(r,e=""){const t=fe[r],n=t&&t[e]||e;return r+n}function W(r){return"touches"in r}function he(r){return W(r)?"touch":"pointerType"in r?r.pointerType:"mouse"}function Fe(r){return Array.from(r.touches).filter(e=>{var t,n;return e.target===r.currentTarget||((t=r.currentTarget)===null||t===void 0||(n=t.contains)===null||n===void 0?void 0:n.call(t,e.target))})}function Ye(r){return r.type==="touchend"||r.type==="touchcancel"?r.changedTouches:r.targetTouches}function pe(r){return W(r)?Ye(r)[0]:r}function He(r){return Fe(r).map(e=>e.identifier)}function Q(r){const e=pe(r);return W(r)?e.identifier:e.pointerId}function ge(r){const e=pe(r);return[e.clientX,e.clientY]}function Xe(r){const e={};if("buttons"in r&&(e.buttons=r.buttons),"shiftKey"in r){const{shiftKey:t,altKey:n,metaKey:s,ctrlKey:a}=r;Object.assign(e,{shiftKey:t,altKey:n,metaKey:s,ctrlKey:a})}return e}function F(r,...e){return typeof r=="function"?r(...e):r}function qe(){}function Je(...r){return r.length===0?qe:r.length===1?r[0]:function(){let e;for(const t of r)e=t.apply(this,arguments)||e;return e}}function me(r,e){return Object.assign({},e,r||{})}const Qe=32;class Ze{constructor(e,t,n){this.ctrl=e,this.args=t,this.key=n,this.state||(this.state={},this.computeValues([0,0]),this.computeInitial(),this.init&&this.init(),this.reset())}get state(){return this.ctrl.state[this.key]}set state(e){this.ctrl.state[this.key]=e}get shared(){return this.ctrl.state.shared}get eventStore(){return this.ctrl.gestureEventStores[this.key]}get timeoutStore(){return this.ctrl.gestureTimeoutStores[this.key]}get config(){return this.ctrl.config[this.key]}get sharedConfig(){return this.ctrl.config.shared}get handler(){return this.ctrl.handlers[this.key]}reset(){const{state:e,shared:t,ingKey:n,args:s}=this;t[n]=e._active=e.active=e._blocked=e._force=!1,e._step=[!1,!1],e.intentional=!1,e._movement=[0,0],e._distance=[0,0],e._direction=[0,0],e._delta=[0,0],e._bounds=[[-1/0,1/0],[-1/0,1/0]],e.args=s,e.axis=void 0,e.memo=void 0,e.elapsedTime=e.timeDelta=0,e.direction=[0,0],e.distance=[0,0],e.overflow=[0,0],e._movementBound=[!1,!1],e.velocity=[0,0],e.movement=[0,0],e.delta=[0,0],e.timeStamp=0}start(e){const t=this.state,n=this.config;t._active||(this.reset(),this.computeInitial(),t._active=!0,t.target=e.target,t.currentTarget=e.currentTarget,t.lastOffset=n.from?F(n.from,t):t.offset,t.offset=t.lastOffset,t.startTime=t.timeStamp=e.timeStamp)}computeValues(e){const t=this.state;t._values=e,t.values=this.config.transform(e)}computeInitial(){const e=this.state;e._initial=e._values,e.initial=e.values}compute(e){const{state:t,config:n,shared:s}=this;t.args=this.args;let a=0;if(e&&(t.event=e,n.preventDefault&&e.cancelable&&t.event.preventDefault(),t.type=e.type,s.touches=this.ctrl.pointerIds.size||this.ctrl.touchIds.size,s.locked=!!document.pointerLockElement,Object.assign(s,Xe(e)),s.down=s.pressed=s.buttons%2===1||s.touches>0,a=e.timeStamp-t.timeStamp,t.timeStamp=e.timeStamp,t.elapsedTime=t.timeStamp-t.startTime),t._active){const f=t._delta.map(Math.abs);E.addTo(t._distance,f)}this.axisIntent&&this.axisIntent(e);const[o,u]=t._movement,[d,m]=n.threshold,{_step:l,values:_}=t;if(n.hasCustomTransform?(l[0]===!1&&(l[0]=Math.abs(o)>=d&&_[0]),l[1]===!1&&(l[1]=Math.abs(u)>=m&&_[1])):(l[0]===!1&&(l[0]=Math.abs(o)>=d&&Math.sign(o)*d),l[1]===!1&&(l[1]=Math.abs(u)>=m&&Math.sign(u)*m)),t.intentional=l[0]!==!1||l[1]!==!1,!t.intentional)return;const b=[0,0];if(n.hasCustomTransform){const[f,H]=_;b[0]=l[0]!==!1?f-l[0]:0,b[1]=l[1]!==!1?H-l[1]:0}else b[0]=l[0]!==!1?o-l[0]:0,b[1]=l[1]!==!1?u-l[1]:0;this.restrictToAxis&&!t._blocked&&this.restrictToAxis(b);const O=t.offset,T=t._active&&!t._blocked||t.active;T&&(t.first=t._active&&!t.active,t.last=!t._active&&t.active,t.active=s[this.ingKey]=t._active,e&&(t.first&&("bounds"in n&&(t._bounds=F(n.bounds,t)),this.setup&&this.setup()),t.movement=b,this.computeOffset()));const[C,S]=t.offset,[[N,I],[D,$]]=t._bounds;t.overflow=[C<N?-1:C>I?1:0,S<D?-1:S>$?1:0],t._movementBound[0]=t.overflow[0]?t._movementBound[0]===!1?t._movement[0]:t._movementBound[0]:!1,t._movementBound[1]=t.overflow[1]?t._movementBound[1]===!1?t._movement[1]:t._movementBound[1]:!1;const G=t._active?n.rubberband||[0,0]:[0,0];if(t.offset=Le(t._bounds,t.offset,G),t.delta=E.sub(t.offset,O),this.computeMovement(),T&&(!t.last||a>Qe)){t.delta=E.sub(t.offset,O);const f=t.delta.map(Math.abs);E.addTo(t.distance,f),t.direction=t.delta.map(Math.sign),t._direction=t._delta.map(Math.sign),!t.first&&a>0&&(t.velocity=[f[0]/a,f[1]/a],t.timeDelta=a)}}emit(){const e=this.state,t=this.shared,n=this.config;if(e._active||this.clean(),(e._blocked||!e.intentional)&&!e._force&&!n.triggerAllEvents)return;const s=this.handler(v(v(v({},t),e),{},{[this.aliasKey]:e.values}));s!==void 0&&(e.memo=s)}clean(){this.eventStore.clean(),this.timeoutStore.clean()}}function et([r,e],t){const n=Math.abs(r),s=Math.abs(e);if(n>s&&n>t)return"x";if(s>n&&s>t)return"y"}class tt extends Ze{constructor(...e){super(...e),k(this,"aliasKey","xy")}reset(){super.reset(),this.state.axis=void 0}init(){this.state.offset=[0,0],this.state.lastOffset=[0,0]}computeOffset(){this.state.offset=E.add(this.state.lastOffset,this.state.movement)}computeMovement(){this.state.movement=E.sub(this.state.offset,this.state.lastOffset)}axisIntent(e){const t=this.state,n=this.config;if(!t.axis&&e){const s=typeof n.axisThreshold=="object"?n.axisThreshold[he(e)]:n.axisThreshold;t.axis=et(t._movement,s)}t._blocked=(n.lockDirection||!!n.axis)&&!t.axis||!!n.axis&&n.axis!==t.axis}restrictToAxis(e){if(this.config.axis||this.config.lockDirection)switch(this.state.axis){case"x":e[1]=0;break;case"y":e[0]=0;break}}}const ve=r=>r,ye=.15,Z={enabled(r=!0){return r},eventOptions(r,e,t){return v(v({},t.shared.eventOptions),r)},preventDefault(r=!1){return r},triggerAllEvents(r=!1){return r},rubberband(r=0){switch(r){case!0:return[ye,ye];case!1:return[0,0];default:return E.toVector(r)}},from(r){if(typeof r=="function")return r;if(r!=null)return E.toVector(r)},transform(r,e,t){const n=r||t.shared.transform;if(this.hasCustomTransform=!!n,process.env.NODE_ENV==="development"){const s=n||ve;return a=>{const o=s(a);return(!isFinite(o[0])||!isFinite(o[1]))&&console.warn(`[@use-gesture]: config.transform() must produce a valid result, but it was: [${o[0]},${[1]}]`),o}}return n||ve},threshold(r){return E.toVector(r,0)}};process.env.NODE_ENV==="development"&&Object.assign(Z,{domTarget(r){if(r!==void 0)throw Error("[@use-gesture]: `domTarget` option has been renamed to `target`.");return NaN},lockDirection(r){if(r!==void 0)throw Error("[@use-gesture]: `lockDirection` option has been merged with `axis`. Use it as in `{ axis: 'lock' }`");return NaN},initial(r){if(r!==void 0)throw Error("[@use-gesture]: `initial` option has been renamed to `from`.");return NaN}});const rt=0,U=v(v({},Z),{},{axis(r,e,{axis:t}){if(this.lockDirection=t==="lock",!this.lockDirection)return t},axisThreshold(r=rt){return r},bounds(r={}){if(typeof r=="function")return a=>U.bounds(r(a));if("current"in r)return()=>r.current;if(typeof HTMLElement=="function"&&r instanceof HTMLElement)return r;const{left:e=-1/0,right:t=1/0,top:n=-1/0,bottom:s=1/0}=r;return[[e,t],[n,s]]}}),be={ArrowRight:(r,e=1)=>[r*e,0],ArrowLeft:(r,e=1)=>[-1*r*e,0],ArrowUp:(r,e=1)=>[0,-1*r*e],ArrowDown:(r,e=1)=>[0,r*e]};class nt extends tt{constructor(...e){super(...e),k(this,"ingKey","dragging")}reset(){super.reset();const e=this.state;e._pointerId=void 0,e._pointerActive=!1,e._keyboardActive=!1,e._preventScroll=!1,e._delayed=!1,e.swipe=[0,0],e.tap=!1,e.canceled=!1,e.cancel=this.cancel.bind(this)}setup(){const e=this.state;if(e._bounds instanceof HTMLElement){const t=e._bounds.getBoundingClientRect(),n=e.currentTarget.getBoundingClientRect(),s={left:t.left-n.left+e.offset[0],right:t.right-n.right+e.offset[0],top:t.top-n.top+e.offset[1],bottom:t.bottom-n.bottom+e.offset[1]};e._bounds=U.bounds(s)}}cancel(){const e=this.state;e.canceled||(e.canceled=!0,e._active=!1,setTimeout(()=>{this.compute(),this.emit()},0))}setActive(){this.state._active=this.state._pointerActive||this.state._keyboardActive}clean(){this.pointerClean(),this.state._pointerActive=!1,this.state._keyboardActive=!1,super.clean()}pointerDown(e){const t=this.config,n=this.state;if(e.buttons!=null&&(Array.isArray(t.pointerButtons)?!t.pointerButtons.includes(e.buttons):t.pointerButtons!==-1&&t.pointerButtons!==e.buttons))return;const s=this.ctrl.setEventIds(e);t.pointerCapture&&e.target.setPointerCapture(e.pointerId),!(s&&s.size>1&&n._pointerActive)&&(this.start(e),this.setupPointer(e),n._pointerId=Q(e),n._pointerActive=!0,this.computeValues(ge(e)),this.computeInitial(),t.preventScrollAxis&&he(e)!=="mouse"?(n._active=!1,this.setupScrollPrevention(e)):t.delay>0?(this.setupDelayTrigger(e),t.triggerAllEvents&&(this.compute(e),this.emit())):this.startPointerDrag(e))}startPointerDrag(e){const t=this.state;t._active=!0,t._preventScroll=!0,t._delayed=!1,this.compute(e),this.emit()}pointerMove(e){const t=this.state,n=this.config;if(!t._pointerActive)return;const s=Q(e);if(t._pointerId!==void 0&&s!==t._pointerId)return;const a=ge(e);if(document.pointerLockElement===e.target?t._delta=[e.movementX,e.movementY]:(t._delta=E.sub(a,t._values),this.computeValues(a)),E.addTo(t._movement,t._delta),this.compute(e),t._delayed&&t.intentional){this.timeoutStore.remove("dragDelay"),t.active=!1,this.startPointerDrag(e);return}if(n.preventScrollAxis&&!t._preventScroll)if(t.axis)if(t.axis===n.preventScrollAxis||n.preventScrollAxis==="xy"){t._active=!1,this.clean();return}else{this.timeoutStore.remove("startPointerDrag"),this.startPointerDrag(e);return}else return;this.emit()}pointerUp(e){this.ctrl.setEventIds(e);try{this.config.pointerCapture&&e.target.hasPointerCapture(e.pointerId)&&e.target.releasePointerCapture(e.pointerId)}catch{process.env.NODE_ENV==="development"&&console.warn("[@use-gesture]: If you see this message, it's likely that you're using an outdated version of `@react-three/fiber`. \n\nPlease upgrade to the latest version.")}const t=this.state,n=this.config;if(!t._active||!t._pointerActive)return;const s=Q(e);if(t._pointerId!==void 0&&s!==t._pointerId)return;this.state._pointerActive=!1,this.setActive(),this.compute(e);const[a,o]=t._distance;if(t.tap=a<=n.tapsThreshold&&o<=n.tapsThreshold,t.tap&&n.filterTaps)t._force=!0;else{const[u,d]=t._delta,[m,l]=t._movement,[_,b]=n.swipe.velocity,[O,T]=n.swipe.distance,C=n.swipe.duration;if(t.elapsedTime<C){const S=Math.abs(u/t.timeDelta),N=Math.abs(d/t.timeDelta);S>_&&Math.abs(m)>O&&(t.swipe[0]=Math.sign(u)),N>b&&Math.abs(l)>T&&(t.swipe[1]=Math.sign(d))}}this.emit()}pointerClick(e){!this.state.tap&&e.detail>0&&(e.preventDefault(),e.stopPropagation())}setupPointer(e){const t=this.config,n=t.device;if(process.env.NODE_ENV==="development")try{if(n==="pointer"&&t.preventScrollDelay===void 0){const s="uv"in e?e.sourceEvent.currentTarget:e.currentTarget;window.getComputedStyle(s).touchAction==="auto"&&console.warn("[@use-gesture]: The drag target has its `touch-action` style property set to `auto`. It is recommended to add `touch-action: 'none'` so that the drag gesture behaves correctly on touch-enabled devices. For more information read this: https://use-gesture.netlify.app/docs/extras/#touch-action.\n\nThis message will only show in development mode. It won't appear in production. If this is intended, you can ignore it.",s)}}catch{}t.pointerLock&&e.currentTarget.requestPointerLock(),t.pointerCapture||(this.eventStore.add(this.sharedConfig.window,n,"change",this.pointerMove.bind(this)),this.eventStore.add(this.sharedConfig.window,n,"end",this.pointerUp.bind(this)),this.eventStore.add(this.sharedConfig.window,n,"cancel",this.pointerUp.bind(this)))}pointerClean(){this.config.pointerLock&&document.pointerLockElement===this.state.currentTarget&&document.exitPointerLock()}preventScroll(e){this.state._preventScroll&&e.cancelable&&e.preventDefault()}setupScrollPrevention(e){this.state._preventScroll=!1,st(e);const t=this.eventStore.add(this.sharedConfig.window,"touch","change",this.preventScroll.bind(this),{passive:!1});this.eventStore.add(this.sharedConfig.window,"touch","end",t),this.eventStore.add(this.sharedConfig.window,"touch","cancel",t),this.timeoutStore.add("startPointerDrag",this.startPointerDrag.bind(this),this.config.preventScrollDelay,e)}setupDelayTrigger(e){this.state._delayed=!0,this.timeoutStore.add("dragDelay",()=>{this.state._step=[0,0],this.startPointerDrag(e)},this.config.delay)}keyDown(e){const t=be[e.key];if(t){const n=this.state,s=e.shiftKey?10:e.altKey?.1:1;this.start(e),n._delta=t(this.config.keyboardDisplacement,s),n._keyboardActive=!0,E.addTo(n._movement,n._delta),this.compute(e),this.emit()}}keyUp(e){e.key in be&&(this.state._keyboardActive=!1,this.setActive(),this.compute(e),this.emit())}bind(e){const t=this.config.device;e(t,"start",this.pointerDown.bind(this)),this.config.pointerCapture&&(e(t,"change",this.pointerMove.bind(this)),e(t,"end",this.pointerUp.bind(this)),e(t,"cancel",this.pointerUp.bind(this)),e("lostPointerCapture","",this.pointerUp.bind(this))),this.config.keys&&(e("key","down",this.keyDown.bind(this)),e("key","up",this.keyUp.bind(this))),this.config.filterTaps&&e("click","",this.pointerClick.bind(this),{capture:!0,passive:!1})}}function st(r){"persist"in r&&typeof r.persist=="function"&&r.persist()}const K=typeof window<"u"&&window.document&&window.document.createElement;function _e(){return K&&"ontouchstart"in window}function it(){return _e()||K&&window.navigator.maxTouchPoints>1}function ot(){return K&&"onpointerdown"in window}function at(){return K&&"exitPointerLock"in window.document}function ct(){try{return"constructor"in GestureEvent}catch{return!1}}const P={isBrowser:K,gesture:ct(),touch:_e(),touchscreen:it(),pointer:ot(),pointerLock:at()},ut=250,lt=180,ft=.5,dt=50,ht=250,pt=10,xe={mouse:0,touch:0,pen:8},we=v(v({},U),{},{device(r,e,{pointer:{touch:t=!1,lock:n=!1,mouse:s=!1}={}}){return this.pointerLock=n&&P.pointerLock,P.touch&&t?"touch":this.pointerLock?"mouse":P.pointer&&!s?"pointer":P.touch?"touch":"mouse"},preventScrollAxis(r,e,{preventScroll:t}){if(this.preventScrollDelay=typeof t=="number"?t:t||t===void 0&&r?ut:void 0,!(!P.touchscreen||t===!1))return r||(t!==void 0?"y":void 0)},pointerCapture(r,e,{pointer:{capture:t=!0,buttons:n=1,keys:s=!0}={}}){return this.pointerButtons=n,this.keys=s,!this.pointerLock&&this.device==="pointer"&&t},threshold(r,e,{filterTaps:t=!1,tapsThreshold:n=3,axis:s=void 0}){const a=E.toVector(r,t?n:s?1:0);return this.filterTaps=t,this.tapsThreshold=n,a},swipe({velocity:r=ft,distance:e=dt,duration:t=ht}={}){return{velocity:this.transform(E.toVector(r)),distance:this.transform(E.toVector(e)),duration:t}},delay(r=0){switch(r){case!0:return lt;case!1:return 0;default:return r}},axisThreshold(r){return r?v(v({},xe),r):xe},keyboardDisplacement(r=pt){return r}});process.env.NODE_ENV==="development"&&Object.assign(we,{useTouch(r){if(r!==void 0)throw Error("[@use-gesture]: `useTouch` option has been renamed to `pointer.touch`. Use it as in `{ pointer: { touch: true } }`.");return NaN},experimental_preventWindowScrollY(r){if(r!==void 0)throw Error("[@use-gesture]: `experimental_preventWindowScrollY` option has been renamed to `preventScroll`.");return NaN},swipeVelocity(r){if(r!==void 0)throw Error("[@use-gesture]: `swipeVelocity` option has been renamed to `swipe.velocity`. Use it as in `{ swipe: { velocity: 0.5 } }`.");return NaN},swipeDistance(r){if(r!==void 0)throw Error("[@use-gesture]: `swipeDistance` option has been renamed to `swipe.distance`. Use it as in `{ swipe: { distance: 50 } }`.");return NaN},swipeDuration(r){if(r!==void 0)throw Error("[@use-gesture]: `swipeDuration` option has been renamed to `swipe.duration`. Use it as in `{ swipe: { duration: 250 } }`.");return NaN}}),v(v({},Z),{},{device(r,e,{shared:t,pointer:{touch:n=!1}={}}){if(t.target&&!P.touch&&P.gesture)return"gesture";if(P.touch&&n)return"touch";if(P.touchscreen){if(P.pointer)return"pointer";if(P.touch)return"touch"}},bounds(r,e,{scaleBounds:t={},angleBounds:n={}}){const s=o=>{const u=me(F(t,o),{min:-1/0,max:1/0});return[u.min,u.max]},a=o=>{const u=me(F(n,o),{min:-1/0,max:1/0});return[u.min,u.max]};return typeof t!="function"&&typeof n!="function"?[s(),a()]:o=>[s(o),a(o)]},threshold(r,e,t){return this.lockDirection=t.axis==="lock",E.toVector(r,this.lockDirection?[.1,3]:0)},modifierKey(r){return r===void 0?"ctrlKey":r},pinchOnWheel(r=!0){return r}}),v(v({},U),{},{mouseOnly:(r=!0)=>r}),v(v({},U),{},{mouseOnly:(r=!0)=>r});const Ee=new Map,ee=new Map;function gt(r){Ee.set(r.key,r.engine),ee.set(r.key,r.resolver)}const mt={key:"drag",engine:nt,resolver:we};function vt(r,e){if(r==null)return{};var t={},n=Object.keys(r),s,a;for(a=0;a<n.length;a++)s=n[a],!(e.indexOf(s)>=0)&&(t[s]=r[s]);return t}function yt(r,e){if(r==null)return{};var t=vt(r,e),n,s;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(r);for(s=0;s<a.length;s++)n=a[s],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(r,n)&&(t[n]=r[n])}return t}const bt={target(r){if(r)return()=>"current"in r?r.current:r},enabled(r=!0){return r},window(r=P.isBrowser?window:void 0){return r},eventOptions({passive:r=!0,capture:e=!1}={}){return{passive:r,capture:e}},transform(r){return r}},_t=["target","eventOptions","window","enabled","transform"];function Y(r={},e){const t={};for(const[n,s]of Object.entries(e))switch(typeof s){case"function":if(process.env.NODE_ENV==="development"){const a=s.call(t,r[n],n,r);Number.isNaN(a)||(t[n]=a)}else t[n]=s.call(t,r[n],n,r);break;case"object":t[n]=Y(r[n],s);break;case"boolean":s&&(t[n]=r[n]);break}return t}function xt(r,e,t={}){const n=r,{target:s,eventOptions:a,window:o,enabled:u,transform:d}=n,m=yt(n,_t);if(t.shared=Y({target:s,eventOptions:a,window:o,enabled:u,transform:d},bt),e){const l=ee.get(e);t[e]=Y(v({shared:t.shared},m),l)}else for(const l in m){const _=ee.get(l);if(_)t[l]=Y(v({shared:t.shared},m[l]),_);else if(process.env.NODE_ENV==="development"&&!["drag","pinch","scroll","wheel","move","hover"].includes(l)){if(l==="domTarget")throw Error("[@use-gesture]: `domTarget` option has been renamed to `target`.");console.warn(`[@use-gesture]: Unknown config key \`${l}\` was used. Please read the documentation for further information.`)}}return t}class Te{constructor(e,t){k(this,"_listeners",new Set),this._ctrl=e,this._gestureKey=t}add(e,t,n,s,a){const o=this._listeners,u=We(t,n),d=this._gestureKey?this._ctrl.config[this._gestureKey].eventOptions:{},m=v(v({},d),a);e.addEventListener(u,s,m);const l=()=>{e.removeEventListener(u,s,m),o.delete(l)};return o.add(l),l}clean(){this._listeners.forEach(e=>e()),this._listeners.clear()}}class wt{constructor(){k(this,"_timeouts",new Map)}add(e,t,n=140,...s){this.remove(e),this._timeouts.set(e,window.setTimeout(t,n,...s))}remove(e){const t=this._timeouts.get(e);t&&window.clearTimeout(t)}clean(){this._timeouts.forEach(e=>void window.clearTimeout(e)),this._timeouts.clear()}}class Et{constructor(e){k(this,"gestures",new Set),k(this,"_targetEventStore",new Te(this)),k(this,"gestureEventStores",{}),k(this,"gestureTimeoutStores",{}),k(this,"handlers",{}),k(this,"config",{}),k(this,"pointerIds",new Set),k(this,"touchIds",new Set),k(this,"state",{shared:{shiftKey:!1,metaKey:!1,ctrlKey:!1,altKey:!1}}),Tt(this,e)}setEventIds(e){if(W(e))return this.touchIds=new Set(He(e)),this.touchIds;if("pointerId"in e)return e.type==="pointerup"||e.type==="pointercancel"?this.pointerIds.delete(e.pointerId):e.type==="pointerdown"&&this.pointerIds.add(e.pointerId),this.pointerIds}applyHandlers(e,t){this.handlers=e,this.nativeHandlers=t}applyConfig(e,t){this.config=xt(e,t,this.config)}clean(){this._targetEventStore.clean();for(const e of this.gestures)this.gestureEventStores[e].clean(),this.gestureTimeoutStores[e].clean()}effect(){return this.config.shared.target&&this.bind(),()=>this._targetEventStore.clean()}bind(...e){const t=this.config.shared,n={};let s;if(!(t.target&&(s=t.target(),!s))){if(t.enabled){for(const o of this.gestures){const u=this.config[o],d=Se(n,u.eventOptions,!!s);if(u.enabled){const m=Ee.get(o);new m(this,e,o).bind(d)}}const a=Se(n,t.eventOptions,!!s);for(const o in this.nativeHandlers)a(o,"",u=>this.nativeHandlers[o](v(v({},this.state.shared),{},{event:u,args:e})),void 0,!0)}for(const a in n)n[a]=Je(...n[a]);if(!s)return n;for(const a in n){const{device:o,capture:u,passive:d}=ze(a);this._targetEventStore.add(s,o,"",n[a],{capture:u,passive:d})}}}}function j(r,e){r.gestures.add(e),r.gestureEventStores[e]=new Te(r,e),r.gestureTimeoutStores[e]=new wt}function Tt(r,e){e.drag&&j(r,"drag"),e.wheel&&j(r,"wheel"),e.scroll&&j(r,"scroll"),e.move&&j(r,"move"),e.pinch&&j(r,"pinch"),e.hover&&j(r,"hover")}const Se=(r,e,t)=>(n,s,a,o={},u=!1)=>{var d,m;const l=(d=o.capture)!==null&&d!==void 0?d:e.capture,_=(m=o.passive)!==null&&m!==void 0?m:e.passive;let b=u?n:Ke(n,s,l);t&&_&&(b+="Passive"),r[b]=r[b]||[],r[b].push(a)};function St(r,e={},t,n){const s=h.useMemo(()=>new Et(r),[]);if(s.applyHandlers(r,n),s.applyConfig(e,t),h.useEffect(s.effect.bind(s)),h.useEffect(()=>s.clean.bind(s),[]),e.target===void 0)return s.bind.bind(s)}function It(r,e){return gt(mt),St({drag:r},e||{},"drag")}const te="RSC::Event";function kt(){const r=h.useRef(null),e=h.useRef(null);return e.current===null&&(e.current={useListenToCustomEvent(t){h.useEffect(()=>{r.current||(r.current=document.createElement("div"));function n(s){t(s.detail)}return r.current.addEventListener(te,n,!1),()=>{var s;(s=r.current)==null||s.removeEventListener(te,n,!1)}},[t])},emitEvent(t){if(r.current){const n=new CustomEvent(te,{detail:t});r.current.dispatchEvent(n)}}}),e.current}function Ct(r){let e=r.replace(/\/\*[\s\S]*?\*\/|([^:]|^)\/\/.*$/gm,"");return e=e.replace(/[\n\t]+/g," "),e=e.replace(/\s*([{}:;,])\s*/g,"$1"),e=e.replace(/\s+}/g,"}"),e=e.replace(/{\s+/g,"{"),e=e.replace(/\s+/g," "),e.trim()}function Dt({init:r=!0,items:e,withLoop:t=!1,id:n,gutter:s=[{breakpoint:0,gutter:0,startEndGutter:0}],itemsPerSlide:a=[{breakpoint:0,itemsPerSlide:1}],carouselAxis:o="x",startingPosition:u="start",enableGestures:d=!0,slideWhenDragThresholdIsReached:m=!0,slideType:l="item",initialActiveItem:_=0}){const[b,O]=h.useState(!1),T=h.useRef(r),C=h.useRef(null),S=h.useRef(null),N=h.useRef(0),I=h.useRef(0),D=h.useRef(!t),$=h.useRef(!1),G=h.useRef(0),f=h.useRef(0),H=h.useRef(e);H.current=e;const ke=h.useRef(t);ke.current=t;const Ce=h.useRef(!1);function De(i){if(i===void 0)return 0;if(typeof i=="number")return e[i]?i:(console.warn(`initialActiveItem: item at index ${i} doesn't exist.`),0);const c=e.findIndex(p=>p.id===i);return c<0?(console.warn(`initialActiveItem: item with id "${i}" doesn't exist.`),0):c}const X=J.useSpringRef(),ne=J.useSpring({value:0,ref:X,onChange({value:i}){const c=o==="x"?`translate3d(calc(${i.value}px + var(--${n}-offset-modifier)), 0px, 0px)`:`translate3d(0px, calc(${i.value}px + var(--${n}-offset-modifier)), 0px)`;S.current.style.transform=c}}),Ot=t?e.length*3:e.length,{useListenToCustomEvent:$e,emitEvent:z}=kt();function Pe(){const{totalGutterCssVar:i}=Oe();return i}function At(){if(C.current){const c=window.getComputedStyle(C.current).getPropertyValue(`--${n}-items-per-slide`).trim();return Number(c)||1}return 1}function se(i){T.current&&($.current||R({type:"next",toIndex:i,actionType:"click"}))}function ie(i){T.current&&(D.current||R({type:"prev",toIndex:i,actionType:"click"}))}function R({type:i,shouldAnimate:c=!0,toIndex:p,actionType:y}){var Ae,Ne;const x=!c;D.current=!1,$.current=!1;let g=ne.value.get(),w=0;if(i==="next"&&(f.current+=1),i==="prev"&&(f.current===0?f.current=e.length-1:f.current-=1),p!==void 0&&(f.current=p),i==="next"){const L=oe(t?I.current*(e.length*2):0);w=-(f.current*I.current),t&&f.current===e.length&&(f.current=0,g=g+I.current*e.length,w=0),!t&&(Math.abs(w)>=L||f.current===e.length-1)&&($.current=!0,w=-L)}i==="prev"&&(w=-(f.current*I.current),f.current===e.length-1&&(g=g-e.length*I.current),!t&&w>=0&&(D.current=!0,w=0)),N.current=w;const M=t?f.current%e.length:f.current,B=t?e.length+f.current%e.length:f.current;y==="resize"?(w=-(f.current*I.current),z({eventName:"onResize",sliceActionType:y,slideDirection:i,currentItem:{id:((Ae=e.at(M))==null?void 0:Ae.id)??"",index:M,trackIndex:B,startReached:D.current,endReached:$.current}})):z({eventName:"onSlideStartChange",sliceActionType:y,slideDirection:i,nextItem:{index:M,id:((Ne=e.at(M))==null?void 0:Ne.id)??"",trackIndex:B,startReached:D.current,endReached:$.current}}),X.start({immediate:x,from:{value:g},to:{value:w},onChange({value:L}){const q=o==="x"?`translate3d(calc(${L.value}px + var(--${n}-offset-modifier)), 0px, 0px)`:`translate3d(0px, calc(${L.value}px + var(--${n}-offset-modifier)), 0px)`;S.current.style.transform=q},onRest({finished:L}){var q;if(L){const Me=t?f.current%e.length:f.current,Bt=t?e.length+f.current%e.length:f.current;z({eventName:"onSlideChangeComplete",sliceActionType:y,slideDirection:i,currentItem:{index:Me,id:((q=e.at(Me))==null?void 0:q.id)??"",trackIndex:Bt,startReached:D.current,endReached:$.current}})}}})}function Nt(){const i=S.current;let c=0;return l==="item"?c=i.children[0].getBoundingClientRect()[o==="x"?"width":"height"]+Pe():c=i.getBoundingClientRect()[o==="x"?"width":"height"]+Pe(),c}function oe(i){const c=S.current;return c[o==="x"?"scrollWidth":"scrollHeight"]-c.getBoundingClientRect()[o==="x"?"width":"height"]-i}function Oe(){let i=0,c=0;if(C.current){const p=window.getComputedStyle(C.current),y=p.getPropertyValue(`--${n}-start-end-gutter`).trim();y.includes("px")&&(i=Number(y.replace("px","")));const x=p.getPropertyValue(`--${n}-gutter`).trim();x.includes("px")&&(c=Number(x.replace("px","")))}return{totalStartEndGutterCssVar:i,totalGutterCssVar:c}}h.useEffect(()=>{function i(x){const g=At();switch(x){case"start":return 0;case"middle-start":return Math.floor((g-1)*.25);case"center":return Math.floor((g-1)*.5);case"middle-end":return Math.floor((g-1)*.75);case"end":return g-1;default:return 0}}function c(){I.current=Nt(),G.current=I.current/4;const{totalStartEndGutterCssVar:x}=Oe();let g=0;t&&(g=I.current*e.length),g-=I.current*i(u),g-=x/2,C.current.style.setProperty(`--${n}-offset-modifier`,`${-g}px`)}function p(x){if(C.current&&(c(),O(!0),x)){const g=De(_),w=t?e.length+g%e.length:g;z({eventName:"onInit",index:g,trackIndex:w})}}function y(){p(),R({type:"resize",toIndex:f.current,shouldAnimate:!1,actionType:"resize"})}if(r)return T.current=!0,Ce.current?y():(p(!0),Ce.current=!0),window.addEventListener("resize",y),()=>{window.removeEventListener("resize",y)}},[r,n,o]),h.useEffect(()=>{const i=De(_);r&&i!==f.current&&R({type:"next",toIndex:i,actionType:"resize",shouldAnimate:!1})},[r,_]);const ae=d,Mt=It(i=>{if(!T.current)return;const c=i.dragging,p=i.offset[o==="x"?0:1],y=i.movement[o==="x"?0:1],x=y>G.current,g=y<-G.current,w=i.velocity;c&&(z({...i,eventName:"onDrag",slideActionType:"drag"}),X.start({value:p,immediate:!0,config:{velocity:w},onChange({value:M}){const B=o==="x"?`translate3d(calc(${M.value}px + var(--${n}-offset-modifier)), 0px, 0px)`:`translate3d(0px, calc(${M.value}px + var(--${n}-offset-modifier)), 0px)`;S.current.style.transform=B}}),m&&(x||g)&&i.cancel()),i.last&&(x?(R({actionType:"drag",type:"prev"}),i.cancel()):g?(R({actionType:"drag",type:"next"}),i.cancel()):(X.start({value:N.current,config:{velocity:w},onChange({value:M}){const B=o==="x"?`translate3d(calc(${M.value}px + var(--${n}-offset-modifier)), 0px, 0px)`:`translate3d(0px, calc(${M.value}px + var(--${n}-offset-modifier)), 0px)`;S.current.style.transform=B}}),i.cancel()))},{enabled:ae,axis:o,rubberband:!t,...t?{}:{bounds:()=>({right:0,left:-oe(0),top:-oe(0),bottom:0})},from:()=>[ne.value.get(),ne.value.get()]}),Vt=h.useCallback(i=>{var g;const c=H.current,y=ke.current?c.length+f.current%c.length:f.current;if(typeof i=="number")return y===i;const x=f.current%c.length;return i===((g=c[x])==null?void 0:g.id)},[]),Lt=h.useMemo(()=>Array.from({length:e.length},(i,c)=>()=>{const p=t?f.current%e.length:f.current;return t?c===(p+1)%e.length:p+1>=e.length?!1:c===p+1}),[e.length,t]),jt=h.useMemo(()=>Array.from({length:e.length},(i,c)=>()=>{const p=t?f.current%e.length:f.current;return t?c===(p-1+e.length)%e.length:p-1<0?!1:c===p-1}),[e.length,t]),Rt=h.useMemo(()=>Ct(`
|
|
2
2
|
[data-part-internal="${n}-Container"] {
|
|
3
3
|
display: flex;
|
|
4
4
|
width: 100%;
|
|
@@ -7,19 +7,19 @@
|
|
|
7
7
|
--${n}-items-per-slide: 1;
|
|
8
8
|
--${n}-offset-position: 0px;
|
|
9
9
|
--${n}-offset-modifier: 0px;
|
|
10
|
-
--${n}-scroll-x-value: ${
|
|
11
|
-
--${n}-scroll-y-value: ${
|
|
10
|
+
--${n}-scroll-x-value: ${o==="x"?`calc(var(--${n}-offset-position) + var(--${n}-offset-modifier))`:"0px"};
|
|
11
|
+
--${n}-scroll-y-value: ${o==="y"?`calc(var(--${n}-offset-position) + var(--${n}-offset-modifier))`:"0px"};
|
|
12
12
|
--${n}-gutter: 0px;
|
|
13
13
|
--${n}-start-end-gutter: 0px;
|
|
14
|
-
touch-action: ${
|
|
14
|
+
touch-action: ${ae?o==="x"?"pan-y":"pan-x":"auto"};
|
|
15
15
|
}
|
|
16
16
|
[data-part-internal="${n}-Track"] {
|
|
17
17
|
display: flex;
|
|
18
18
|
position: relative;
|
|
19
19
|
--initial-offset-modifier: calc(calc(-100% - var(--${n}-gutter) + calc(var(--${n}-start-end-gutter) / 2 / ${e.length} * var(--${n}-items-per-slide)) + var(--${n}-start-end-gutter)) * ${e.length} / var(--${n}-items-per-slide));
|
|
20
|
-
left: ${
|
|
21
|
-
top: ${
|
|
22
|
-
flex-direction: ${
|
|
20
|
+
left: ${t&&o==="x"&&!b?"var(--initial-offset-modifier)":"0px"};
|
|
21
|
+
top: ${t&&o==="y"&&!b?"var(--initial-offset-modifier)":"0px"};
|
|
22
|
+
flex-direction: ${o==="x"?"row":"column"};
|
|
23
23
|
width: 100%;
|
|
24
24
|
height: 100%;
|
|
25
25
|
gap: var(--${n}-gutter);
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
display: flex;
|
|
30
30
|
flex: 1 0 calc(100% / var(--${n}-items-per-slide) - calc(var(--${n}-gutter) * (var(--${n}-items-per-slide) - 1)) / var(--${n}-items-per-slide) - calc(var(--${n}-start-end-gutter) / var(--${n}-items-per-slide)));
|
|
31
31
|
}
|
|
32
|
-
${s&&s.length>0?s.sort((i,
|
|
32
|
+
${s&&s.length>0?s.slice().sort((i,c)=>i.breakpoint-c.breakpoint).map(i=>`
|
|
33
33
|
@media ${i.media||`(min-width: ${i.breakpoint}px)`} {
|
|
34
34
|
[data-part-internal="${n}-Container"] {
|
|
35
35
|
--${n}-gutter: ${i.gutter||0}px;
|
|
@@ -37,11 +37,11 @@
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
`).join(""):""}
|
|
40
|
-
${
|
|
40
|
+
${a&&a.length>0?a.slice().sort((i,c)=>i.breakpoint-c.breakpoint).map(i=>`
|
|
41
41
|
@media ${i.media||`(min-width: ${i.breakpoint}px)`} {
|
|
42
42
|
[data-part-internal="${n}-Container"] {
|
|
43
43
|
--${n}-items-per-slide: ${i.itemsPerSlide||1};
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
`).join(""):""}
|
|
47
|
-
`)}}),
|
|
47
|
+
`),[n,o,ae,e.length,t,b,s,a]);return{carouselFragment:V.jsxs("div",{ref:C,className:"ReactSpringCarouselContainer","data-part":"Container","data-part-internal":`${n}-Container`,...Mt(),children:[V.jsx("style",{dangerouslySetInnerHTML:{__html:Rt}}),V.jsx("div",{ref:S,className:"ReactSpringCarouselTrack","data-part":"Track","data-part-internal":`${n}-Track`,onScroll:()=>{D.current=!1,$.current=!1},children:Array.from({length:Ot},(i,c)=>{const p=t?c%e.length:c,y=e[p],x=t&&(c<e.length||c>=e.length*2),g=Lt[p],w=jt[p];return V.jsx("div",{className:"ReactSpringCarouselItem","data-part":"Item","data-part-internal":`${n}-Item`,"data-id":y.id,children:typeof y.renderItem=="function"?y.renderItem({useListenToCustomEvent:$e,index:c,isClonedItem:x,isActiveItem:Vt,isNextItem:g,isPrevItem:w}):y.renderItem},`${y.id}-${c}`)})})]}),useListenToCustomEvent:$e,slideToNextItem:()=>se(),slideToPrevItem:()=>ie(),slideToItem:i=>{if(typeof i=="number"){if(!e[i]){console.warn(`The item you're trying to slide doesn't exist. index: ${i}`);return}i>f.current?se(i):ie(i)}if(typeof i=="string"){const c=e.findIndex(p=>p.id===i);if(c<0){console.warn(`The item you're trying to slide doesn't exist. id: ${i}`);return}c>f.current?se(c):ie(c)}}}}function $t(r){let e=0;const t=getComputedStyle(r).getPropertyValue("gap");return t.includes("px")&&(e=Number(t.replace("px",""))),e}function Ie(r){return r.scrollWidth-r.clientWidth}function re(r){const e=r.children[0],t=$t(r);return e.getBoundingClientRect().width+t}function Pt({container:r,onReach:e}){const t=h.useRef("start"),n=h.useRef(0),[,s]=J.useSpring(()=>({x:0}));function a(u){s.start({from:{x:r.current.scrollLeft},to:{x:u},onChange({value:d}){r.current&&(r.current.scrollLeft=d.x)}})}function o(u){if(!r.current||u==="next"&&t.current==="end"||u==="prev"&&t.current==="start")return;let d=0;if(u==="next"&&(n.current+=1),u==="prev"&&(n.current-=1),d=n.current*re(r.current),u==="next"){const m=Ie(r.current);d>m&&(t.current="end",d=m,e&&e("end"))}u==="prev"&&d<=0&&(t.current="start",n.current=0,d=0,e&&e("start")),a(d)}return h.useEffect(()=>{function u(){var I;const O=re(r.current),T=((I=[...r.current.children].at(0))==null?void 0:I.getBoundingClientRect().width)||0,C=Array(r.current.childElementCount).fill(0).map((D,$)=>({index:$,start:O*$,end:O*($+1)})),S=r.current.scrollLeft+T,N=C.find(D=>S>=D.start&&S<D.end);n.current=(N==null?void 0:N.index)||0}function d(){s.stop()}function m(O){const T=O.target;T.scrollLeft===0?(n.current=0,t.current="start",e&&e("start")):T.scrollLeft>=Ie(T)?(t.current="end",e&&e("end")):t.current!=="idle"&&(t.current="idle",e&&e("idle"))}let l,_=0;function b(){_=r.current.scrollLeft,clearTimeout(l),l=setTimeout(function(){r.current.scrollLeft===_&&u()},200)}if(r.current)return r.current.addEventListener("wheel",d,{passive:!0}),r.current.addEventListener("scroll",m),r.current.addEventListener("scroll",b),()=>{r.current&&(r.current.removeEventListener("scroll",b),r.current.removeEventListener("scroll",m),r.current.removeEventListener("wheel",d))}},[r,e]),h.useEffect(()=>{if(r.current){const u=new ResizeObserver(()=>{a(n.current*re(r.current))});return u.observe(r.current),()=>{u.disconnect()}}},[]),{scrollToNext(){o("next")},scrollToPrev(){o("prev")}}}A.useSpringCarousel=Dt,A.useSpringScroll=Pt,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})});
|
package/dist/types.d.ts
CHANGED
|
@@ -23,6 +23,8 @@ export type Item = {
|
|
|
23
23
|
index: number;
|
|
24
24
|
isClonedItem: boolean;
|
|
25
25
|
isActiveItem(id: string | number): boolean;
|
|
26
|
+
isNextItem(): boolean;
|
|
27
|
+
isPrevItem(): boolean;
|
|
26
28
|
useListenToCustomEvent(eventHandler: SpringCarouselEventsEventHandler): void;
|
|
27
29
|
}) => ReactNode);
|
|
28
30
|
};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { SpringCarouselEvents, SpringCarouselEventsEventHandler } from './types';
|
|
2
|
-
|
|
2
|
+
type EventsModule = {
|
|
3
3
|
useListenToCustomEvent: (eventHandler: SpringCarouselEventsEventHandler) => void;
|
|
4
4
|
emitEvent: (event: SpringCarouselEvents) => void;
|
|
5
5
|
};
|
|
6
|
+
export declare function useEventsModule(): EventsModule;
|
|
7
|
+
export {};
|