react-spring-carousel 3.0.0-beta-2.2.0 → 3.0.0-beta-2.2.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/dist/index.umd.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(M,N){typeof exports=="object"&&typeof module<"u"?N(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"],N):(M=typeof globalThis<"u"?globalThis:M||self,N(M["react-spring-carousel"]={},M["react/jsx-runtime"],M["@react-spring/web"],M.React))})(this,function(M,N,ie,d){"use strict";function Fe(r,e,t){return Math.max(e,Math.min(r,t))}const T={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 me(r,e,t){return e===0||Math.abs(e)===1/0?Math.pow(r,t*5):r*e*t/(e+t*r)}function ve(r,e,t,n=.15){return n===0?Fe(r,e,t):r<e?-me(e-r,t-e,n)+e:r>t?+me(r-t,t-e,n)+t:r}function Ge(r,[e,t],[n,s]){const[[a,o],[u,c]]=r;return[ve(e,a,o,n),ve(t,u,c,s)]}function We(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 Ye(r){var e=We(r,"string");return typeof e=="symbol"?e:String(e)}function D(r,e,t){return e=Ye(e),e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function ye(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 y(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?ye(Object(t),!0).forEach(function(n){D(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):ye(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}const be={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 _e(r){return r?r[0].toUpperCase()+r.slice(1):""}const He=["enter","leave"];function qe(r=!1,e){return r&&!He.includes(e)}function Xe(r,e="",t=!1){const n=be[r],s=n&&n[e]||e;return"on"+_e(r)+_e(s)+(qe(t,s)?"Capture":"")}const Je=["gotpointercapture","lostpointercapture"];function Qe(r){let e=r.substring(2).toLowerCase();const t=!!~e.indexOf("passive");t&&(e=e.replace("passive",""));const n=Je.includes(e)?"capturecapture":"capture",s=!!~e.indexOf(n);return s&&(e=e.replace("capture","")),{device:e,capture:s,passive:t}}function Ze(r,e=""){const t=be[r],n=t&&t[e]||e;return r+n}function te(r){return"touches"in r}function we(r){return te(r)?"touch":"pointerType"in r?r.pointerType:"mouse"}function et(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 tt(r){return r.type==="touchend"||r.type==="touchcancel"?r.changedTouches:r.targetTouches}function Te(r){return te(r)?tt(r)[0]:r}function rt(r){return et(r).map(e=>e.identifier)}function oe(r){const e=Te(r);return te(r)?e.identifier:e.pointerId}function xe(r){const e=Te(r);return[e.clientX,e.clientY]}function nt(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 re(r,...e){return typeof r=="function"?r(...e):r}function st(){}function it(...r){return r.length===0?st:r.length===1?r[0]:function(){let e;for(const t of r)e=t.apply(this,arguments)||e;return e}}function Ee(r,e){return Object.assign({},e,r||{})}const ot=32;class at{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?re(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,nt(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 C=t._delta.map(Math.abs);T.addTo(t._distance,C)}this.axisIntent&&this.axisIntent(e);const[o,u]=t._movement,[c,p]=n.threshold,{_step:f,values:_}=t;if(n.hasCustomTransform?(f[0]===!1&&(f[0]=Math.abs(o)>=c&&_[0]),f[1]===!1&&(f[1]=Math.abs(u)>=p&&_[1])):(f[0]===!1&&(f[0]=Math.abs(o)>=c&&Math.sign(o)*c),f[1]===!1&&(f[1]=Math.abs(u)>=p&&Math.sign(u)*p)),t.intentional=f[0]!==!1||f[1]!==!1,!t.intentional)return;const h=[0,0];if(n.hasCustomTransform){const[C,V]=_;h[0]=f[0]!==!1?C-f[0]:0,h[1]=f[1]!==!1?V-f[1]:0}else h[0]=f[0]!==!1?o-f[0]:0,h[1]=f[1]!==!1?u-f[1]:0;this.restrictToAxis&&!t._blocked&&this.restrictToAxis(h);const x=t.offset,E=t._active&&!t._blocked||t.active;E&&(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=re(n.bounds,t)),this.setup&&this.setup()),t.movement=h,this.computeOffset()));const[z,L]=t.offset,[[$,O],[k,U]]=t._bounds;t.overflow=[z<$?-1:z>O?1:0,L<k?-1:L>U?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 K=t._active?n.rubberband||[0,0]:[0,0];if(t.offset=Ge(t._bounds,t.offset,K),t.delta=T.sub(t.offset,x),this.computeMovement(),E&&(!t.last||a>ot)){t.delta=T.sub(t.offset,x);const C=t.delta.map(Math.abs);T.addTo(t.distance,C),t.direction=t.delta.map(Math.sign),t._direction=t._delta.map(Math.sign),!t.first&&a>0&&(t.velocity=[C[0]/a,C[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(y(y(y({},t),e),{},{[this.aliasKey]:e.values}));s!==void 0&&(e.memo=s)}clean(){this.eventStore.clean(),this.timeoutStore.clean()}}function ct([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 ut extends at{constructor(...e){super(...e),D(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=T.add(this.state.lastOffset,this.state.movement)}computeMovement(){this.state.movement=T.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[we(e)]:n.axisThreshold;t.axis=ct(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 Ie=r=>r,Se=.15,ae={enabled(r=!0){return r},eventOptions(r,e,t){return y(y({},t.shared.eventOptions),r)},preventDefault(r=!1){return r},triggerAllEvents(r=!1){return r},rubberband(r=0){switch(r){case!0:return[Se,Se];case!1:return[0,0];default:return T.toVector(r)}},from(r){if(typeof r=="function")return r;if(r!=null)return T.toVector(r)},transform(r,e,t){const n=r||t.shared.transform;if(this.hasCustomTransform=!!n,process.env.NODE_ENV==="development"){const s=n||Ie;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||Ie},threshold(r){return T.toVector(r,0)}};process.env.NODE_ENV==="development"&&Object.assign(ae,{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 lt=0,Q=y(y({},ae),{},{axis(r,e,{axis:t}){if(this.lockDirection=t==="lock",!this.lockDirection)return t},axisThreshold(r=lt){return r},bounds(r={}){if(typeof r=="function")return a=>Q.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]]}}),ke={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 ft extends ut{constructor(...e){super(...e),D(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=Q.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=oe(e),n._pointerActive=!0,this.computeValues(xe(e)),this.computeInitial(),t.preventScrollAxis&&we(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=oe(e);if(t._pointerId!==void 0&&s!==t._pointerId)return;const a=xe(e);if(document.pointerLockElement===e.target?t._delta=[e.movementX,e.movementY]:(t._delta=T.sub(a,t._values),this.computeValues(a)),T.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=oe(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,c]=t._delta,[p,f]=t._movement,[_,h]=n.swipe.velocity,[x,E]=n.swipe.distance,z=n.swipe.duration;if(t.elapsedTime<z){const L=Math.abs(u/t.timeDelta),$=Math.abs(c/t.timeDelta);L>_&&Math.abs(p)>x&&(t.swipe[0]=Math.sign(u)),$>h&&Math.abs(f)>E&&(t.swipe[1]=Math.sign(c))}}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,dt(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=ke[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,T.addTo(n._movement,n._delta),this.compute(e),this.emit()}}keyUp(e){e.key in ke&&(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 dt(r){"persist"in r&&typeof r.persist=="function"&&r.persist()}const Z=typeof window<"u"&&window.document&&window.document.createElement;function Ce(){return Z&&"ontouchstart"in window}function ht(){return Ce()||Z&&window.navigator.maxTouchPoints>1}function pt(){return Z&&"onpointerdown"in window}function gt(){return Z&&"exitPointerLock"in window.document}function mt(){try{return"constructor"in GestureEvent}catch{return!1}}const A={isBrowser:Z,gesture:mt(),touch:Ce(),touchscreen:ht(),pointer:pt(),pointerLock:gt()},vt=250,yt=180,bt=.5,_t=50,wt=250,Tt=10,De={mouse:0,touch:0,pen:8},Ae=y(y({},Q),{},{device(r,e,{pointer:{touch:t=!1,lock:n=!1,mouse:s=!1}={}}){return this.pointerLock=n&&A.pointerLock,A.touch&&t?"touch":this.pointerLock?"mouse":A.pointer&&!s?"pointer":A.touch?"touch":"mouse"},preventScrollAxis(r,e,{preventScroll:t}){if(this.preventScrollDelay=typeof t=="number"?t:t||t===void 0&&r?vt:void 0,!(!A.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=T.toVector(r,t?n:s?1:0);return this.filterTaps=t,this.tapsThreshold=n,a},swipe({velocity:r=bt,distance:e=_t,duration:t=wt}={}){return{velocity:this.transform(T.toVector(r)),distance:this.transform(T.toVector(e)),duration:t}},delay(r=0){switch(r){case!0:return yt;case!1:return 0;default:return r}},axisThreshold(r){return r?y(y({},De),r):De},keyboardDisplacement(r=Tt){return r}});process.env.NODE_ENV==="development"&&Object.assign(Ae,{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}}),y(y({},ae),{},{device(r,e,{shared:t,pointer:{touch:n=!1}={}}){if(t.target&&!A.touch&&A.gesture)return"gesture";if(A.touch&&n)return"touch";if(A.touchscreen){if(A.pointer)return"pointer";if(A.touch)return"touch"}},bounds(r,e,{scaleBounds:t={},angleBounds:n={}}){const s=o=>{const u=Ee(re(t,o),{min:-1/0,max:1/0});return[u.min,u.max]},a=o=>{const u=Ee(re(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",T.toVector(r,this.lockDirection?[.1,3]:0)},modifierKey(r){return r===void 0?"ctrlKey":r},pinchOnWheel(r=!0){return r}}),y(y({},Q),{},{mouseOnly:(r=!0)=>r}),y(y({},Q),{},{mouseOnly:(r=!0)=>r});const $e=new Map,ce=new Map;function xt(r){$e.set(r.key,r.engine),ce.set(r.key,r.resolver)}const Et={key:"drag",engine:ft,resolver:Ae};function It(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 St(r,e){if(r==null)return{};var t=It(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 kt={target(r){if(r)return()=>"current"in r?r.current:r},enabled(r=!0){return r},window(r=A.isBrowser?window:void 0){return r},eventOptions({passive:r=!0,capture:e=!1}={}){return{passive:r,capture:e}},transform(r){return r}},Ct=["target","eventOptions","window","enabled","transform"];function ne(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]=ne(r[n],s);break;case"boolean":s&&(t[n]=r[n]);break}return t}function Dt(r,e,t={}){const n=r,{target:s,eventOptions:a,window:o,enabled:u,transform:c}=n,p=St(n,Ct);if(t.shared=ne({target:s,eventOptions:a,window:o,enabled:u,transform:c},kt),e){const f=ce.get(e);t[e]=ne(y({shared:t.shared},p),f)}else for(const f in p){const _=ce.get(f);if(_)t[f]=ne(y({shared:t.shared},p[f]),_);else if(process.env.NODE_ENV==="development"&&!["drag","pinch","scroll","wheel","move","hover"].includes(f)){if(f==="domTarget")throw Error("[@use-gesture]: `domTarget` option has been renamed to `target`.");console.warn(`[@use-gesture]: Unknown config key \`${f}\` was used. Please read the documentation for further information.`)}}return t}class Oe{constructor(e,t){D(this,"_listeners",new Set),this._ctrl=e,this._gestureKey=t}add(e,t,n,s,a){const o=this._listeners,u=Ze(t,n),c=this._gestureKey?this._ctrl.config[this._gestureKey].eventOptions:{},p=y(y({},c),a);e.addEventListener(u,s,p);const f=()=>{e.removeEventListener(u,s,p),o.delete(f)};return o.add(f),f}clean(){this._listeners.forEach(e=>e()),this._listeners.clear()}}class At{constructor(){D(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 $t{constructor(e){D(this,"gestures",new Set),D(this,"_targetEventStore",new Oe(this)),D(this,"gestureEventStores",{}),D(this,"gestureTimeoutStores",{}),D(this,"handlers",{}),D(this,"config",{}),D(this,"pointerIds",new Set),D(this,"touchIds",new Set),D(this,"state",{shared:{shiftKey:!1,metaKey:!1,ctrlKey:!1,altKey:!1}}),Ot(this,e)}setEventIds(e){if(te(e))return this.touchIds=new Set(rt(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=Dt(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],c=Pe(n,u.eventOptions,!!s);if(u.enabled){const p=$e.get(o);new p(this,e,o).bind(c)}}const a=Pe(n,t.eventOptions,!!s);for(const o in this.nativeHandlers)a(o,"",u=>this.nativeHandlers[o](y(y({},this.state.shared),{},{event:u,args:e})),void 0,!0)}for(const a in n)n[a]=it(...n[a]);if(!s)return n;for(const a in n){const{device:o,capture:u,passive:c}=Qe(a);this._targetEventStore.add(s,o,"",n[a],{capture:u,passive:c})}}}}function W(r,e){r.gestures.add(e),r.gestureEventStores[e]=new Oe(r,e),r.gestureTimeoutStores[e]=new At}function Ot(r,e){e.drag&&W(r,"drag"),e.wheel&&W(r,"wheel"),e.scroll&&W(r,"scroll"),e.move&&W(r,"move"),e.pinch&&W(r,"pinch"),e.hover&&W(r,"hover")}const Pe=(r,e,t)=>(n,s,a,o={},u=!1)=>{var c,p;const f=(c=o.capture)!==null&&c!==void 0?c:e.capture,_=(p=o.passive)!==null&&p!==void 0?p:e.passive;let h=u?n:Xe(n,s,f);t&&_&&(h+="Passive"),r[h]=r[h]||[],r[h].push(a)};function Pt(r,e={},t,n){const s=d.useMemo(()=>new $t(r),[]);if(s.applyHandlers(r,n),s.applyConfig(e,t),d.useEffect(s.effect.bind(s)),d.useEffect(()=>s.clean.bind(s),[]),e.target===void 0)return s.bind.bind(s)}function Mt(r,e){return xt(Et),Pt({drag:r},e||{},"drag")}function Nt(r){const{type:e,actionType:t,toIndex:n,itemsLength:s,withLoop:a,scrollAmount:o,totalAvailable:u}=r;let c=r.currentActive,p=r.fromValueRaw,f=!1,_=!1;e==="next"&&(c+=1),e==="prev"&&(c=c===0?s-1:c-1),n!==void 0&&(c=n);let h=0;e==="next"&&(h=-(c*o),a&&c===s&&(c=0,p=p+o*s,h=0),!a&&(Math.abs(h)>=u||c===s-1)&&(_=!0,h=-u)),e==="prev"&&(h=-(c*o),c===s-1&&(p=p-s*o),!a&&h>=0&&(f=!0,h=0)),t==="resize"&&(h=-(c*o),a||(c===0&&(f=!0),(c===s-1||Math.abs(h)>=u)&&(_=!0,Math.abs(h)>=u&&u>0&&(h=-u))));const x=a?c%s:c,E=a?s+c%s:c;return{newActive:c,fromValue:p,toValue:h,startReached:f,endReached:_,logicalIndex:x,realTrackIndex:E}}function ee(r,e,t){return e==="x"?`translate3d(calc(${r}px + var(--${t}-offset-modifier)), 0px, 0px)`:`translate3d(0px, calc(${r}px + var(--${t}-offset-modifier)), 0px)`}function Lt(){const r=d.useRef(null);r.current===null&&(r.current=new Set);const e=d.useRef(null);return e.current===null&&(e.current={useListenToCustomEvent(t){d.useEffect(()=>{const n=r.current;return n.add(t),()=>{n.delete(t)}},[t])},emitEvent(t){const n=r.current;!n||n.size===0||n.forEach(s=>s(t))}}),e.current}function Vt({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:c=!0,slideWhenDragThresholdIsReached:p=!0,slideType:f="item",initialActiveItem:_=0,renderWindow:h,renderPlaceholder:x}){const[E,z]=d.useState(!1),[,L]=d.useState(0),$=d.useRef(r),O=d.useRef(null),k=d.useRef(null),U=d.useRef(0),K=d.useRef(0),C=d.useRef(!t),V=d.useRef(!1),le=d.useRef(0),w=d.useRef(0),Ne=d.useRef(e);Ne.current=e;const Le=d.useRef(t);Le.current=t;const Ve=d.useRef(!1),F=d.useRef(null),R=d.useRef(null),G=d.useRef(null),Y=d.useRef(null),H=d.useRef({width:0,height:0});function Re(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(m=>m.id===i);return l<0?(console.warn(`initialActiveItem: item with id "${i}" doesn't exist.`),0):l}const se=ie.useSpringRef(),fe=ie.useSpring({value:0,ref:se,onChange({value:i}){k.current.style.transform=ee(i.value,o,n)}}),Bt=t?e.length*3:e.length,{useListenToCustomEvent:je,emitEvent:q}=Lt();function Be(i){if(!i||i.length===0)return null;let l=null,m=-1/0;for(const g of i)(g.media?window.matchMedia(g.media).matches:window.innerWidth>=g.breakpoint)&&g.breakpoint>=m&&(l=g,m=g.breakpoint);return l}function ze(){const{totalGutterCssVar:i}=Ue();return i}function zt(){const i=Be(a);return(i==null?void 0:i.itemsPerSlide)||1}function de(i){$.current&&(V.current||X({type:"next",toIndex:i,actionType:"click"}))}function he(i){$.current&&(C.current||X({type:"prev",toIndex:i,actionType:"click"}))}function X({type:i,shouldAnimate:l=!0,toIndex:m,actionType:g}){var P,J;const I=!l;C.current=!1,V.current=!1;const v=Nt({type:i,actionType:g,toIndex:m,currentActive:w.current,itemsLength:e.length,withLoop:t,scrollAmount:K.current,totalAvailable:i==="next"||g==="resize"?pe(t?K.current*(e.length*2):0):0,fromValueRaw:fe.value.get()}),j=w.current;w.current=v.newActive,C.current=v.startReached,V.current=v.endReached,U.current=v.toValue,h!==void 0&&j!==v.newActive&&L(S=>S+1),q(g==="resize"?{eventName:"onResize",sliceActionType:g,slideDirection:i,currentItem:{id:((P=e.at(v.logicalIndex))==null?void 0:P.id)??"",index:v.logicalIndex,trackIndex:v.realTrackIndex,startReached:C.current,endReached:V.current}}:{eventName:"onSlideStartChange",sliceActionType:g,slideDirection:i,nextItem:{index:v.logicalIndex,id:((J=e.at(v.logicalIndex))==null?void 0:J.id)??"",trackIndex:v.realTrackIndex,startReached:C.current,endReached:V.current}}),I&&k.current&&(k.current.style.transform=ee(v.toValue,o,n)),se.start({immediate:I,from:{value:v.fromValue},to:{value:v.toValue},onChange({value:S}){k.current.style.transform=ee(S.value,o,n)},onRest({finished:S}){var b;if(S){const B=t?w.current%e.length:w.current,Ke=t?e.length+w.current%e.length:w.current;q({eventName:"onSlideChangeComplete",sliceActionType:g,slideDirection:i,currentItem:{index:B,id:((b=e.at(B))==null?void 0:b.id)??"",trackIndex:Ke,startReached:C.current,endReached:V.current}})}}})}function Ut(){const i=k.current;let l=0;return f==="item"?l=i.children[0].getBoundingClientRect()[o==="x"?"width":"height"]+ze():l=i.getBoundingClientRect()[o==="x"?"width":"height"]+ze(),l}function pe(i){const l=k.current;return l[o==="x"?"scrollWidth":"scrollHeight"]-l.getBoundingClientRect()[o==="x"?"width":"height"]-i}function Ue(){const i=Be(s);return{totalGutterCssVar:(i==null?void 0:i.gutter)||0,totalStartEndGutterCssVar:((i==null?void 0:i.startEndGutter)||0)*2}}d.useEffect(()=>{function i(S){const b=zt();switch(S){case"start":return 0;case"middle-start":return Math.floor((b-1)*.25);case"center":return Math.floor((b-1)*.5);case"middle-end":return Math.floor((b-1)*.75);case"end":return b-1;default:return 0}}function l(){K.current=Ut(),le.current=K.current/4;const{totalStartEndGutterCssVar:S}=Ue();let b=0;t&&(b=K.current*e.length),b-=K.current*i(u),b-=S/2,O.current.style.setProperty(`--${n}-offset-modifier`,`${-b}px`)}function m(S){if(O.current&&(l(),z(!0),S)){const b=Re(_),B=t?e.length+b%e.length:b;q({eventName:"onInit",index:b,trackIndex:B})}}function g(){m(),X({type:"resize",toIndex:w.current,shouldAnimate:!1,actionType:"resize"})}function I(){G.current!==null&&(clearTimeout(G.current),G.current=null),Y.current!==null&&(cancelAnimationFrame(Y.current),Y.current=null)}function v(S){Y.current===null&&(Y.current=requestAnimationFrame(()=>{Y.current=null;const b=O.current;if(!b)return;const B=b.getBoundingClientRect();(B.width!==H.current.width||B.height!==H.current.height)&&(H.current={width:B.width,height:B.height},g()),S&&(G.current=window.setTimeout(()=>{G.current=null,v(!1)},400))}))}function j(){I(),v(!0)}function P(){I(),G.current=window.setTimeout(()=>{G.current=null,H.current={width:0,height:0},v(!0)},250)}function J(){document.visibilityState==="visible"&&(I(),H.current={width:0,height:0},v(!0))}if(r){if($.current=!0,Ve.current)g();else if(m(!0),Ve.current=!0,O.current){const b=O.current.getBoundingClientRect();H.current={width:b.width,height:b.height}}const S=window.visualViewport??window;return S.addEventListener("resize",j),window.addEventListener("orientationchange",P),document.addEventListener("visibilitychange",J),()=>{S.removeEventListener("resize",j),window.removeEventListener("orientationchange",P),document.removeEventListener("visibilitychange",J),I()}}},[r,n,o,t]),d.useEffect(()=>{const i=Re(_);r&&i!==w.current&&X({type:"next",toIndex:i,actionType:"resize",shouldAnimate:!1})},[r,_]);const ge=c;function Kt(){if(R.current!==null&&(cancelAnimationFrame(R.current),R.current=null),F.current){const i=F.current;F.current=null,q(i)}}function Ft(i){F.current=i,R.current===null&&(R.current=requestAnimationFrame(()=>{R.current=null;const l=F.current;F.current=null,l&&q(l)}))}d.useEffect(()=>()=>{R.current!==null&&(cancelAnimationFrame(R.current),R.current=null),F.current=null},[]);const Gt=Mt(i=>{if(!$.current)return;const l=i.dragging,m=i.offset[o==="x"?0:1],g=i.movement[o==="x"?0:1],I=g>le.current,v=g<-le.current,j=i.velocity;l&&(Ft({...i,eventName:"onDrag",slideActionType:"drag"}),se.start({value:m,immediate:!0,config:{velocity:j},onChange({value:P}){k.current.style.transform=ee(P.value,o,n)}}),p&&(I||v)&&i.cancel()),i.last&&(Kt(),I?(X({actionType:"drag",type:"prev"}),i.cancel()):v?(X({actionType:"drag",type:"next"}),i.cancel()):(se.start({value:U.current,config:{velocity:j},onChange({value:P}){k.current.style.transform=ee(P.value,o,n)}}),i.cancel()))},{enabled:ge,axis:o,rubberband:!t,...t?{}:{bounds:()=>({right:0,left:-pe(0),top:-pe(0),bottom:0})},from:()=>[fe.value.get(),fe.value.get()]}),Wt=d.useCallback(i=>{var v;const l=Ne.current,g=Le.current?l.length+w.current%l.length:w.current;if(typeof i=="number")return g===i;const I=w.current%l.length;return i===((v=l[I])==null?void 0:v.id)},[]),Yt=d.useMemo(()=>Array.from({length:e.length},(i,l)=>()=>{const m=t?w.current%e.length:w.current;return t?l===(m+1)%e.length:m+1>=e.length?!1:l===m+1}),[e.length,t]),Ht=d.useMemo(()=>Array.from({length:e.length},(i,l)=>()=>{const m=t?w.current%e.length:w.current;return t?l===(m-1+e.length)%e.length:m-1<0?!1:l===m-1}),[e.length,t]),qt=d.useMemo(()=>`
1
+ (function(M,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):(M=typeof globalThis<"u"?globalThis:M||self,L(M["react-spring-carousel"]={},M["react/jsx-runtime"],M["@react-spring/web"],M.React))})(this,function(M,L,ie,d){"use strict";function Ge(r,e,t){return Math.max(e,Math.min(r,t))}const T={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 me(r,e,t){return e===0||Math.abs(e)===1/0?Math.pow(r,t*5):r*e*t/(e+t*r)}function ve(r,e,t,n=.15){return n===0?Ge(r,e,t):r<e?-me(e-r,t-e,n)+e:r>t?+me(r-t,t-e,n)+t:r}function We(r,[e,t],[n,s]){const[[a,o],[l,c]]=r;return[ve(e,a,o,n),ve(t,l,c,s)]}function Ye(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 He(r){var e=Ye(r,"string");return typeof e=="symbol"?e:String(e)}function D(r,e,t){return e=He(e),e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function ye(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 y(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?ye(Object(t),!0).forEach(function(n){D(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):ye(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}const be={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 _e(r){return r?r[0].toUpperCase()+r.slice(1):""}const qe=["enter","leave"];function Xe(r=!1,e){return r&&!qe.includes(e)}function Je(r,e="",t=!1){const n=be[r],s=n&&n[e]||e;return"on"+_e(r)+_e(s)+(Xe(t,s)?"Capture":"")}const Qe=["gotpointercapture","lostpointercapture"];function Ze(r){let e=r.substring(2).toLowerCase();const t=!!~e.indexOf("passive");t&&(e=e.replace("passive",""));const n=Qe.includes(e)?"capturecapture":"capture",s=!!~e.indexOf(n);return s&&(e=e.replace("capture","")),{device:e,capture:s,passive:t}}function et(r,e=""){const t=be[r],n=t&&t[e]||e;return r+n}function te(r){return"touches"in r}function we(r){return te(r)?"touch":"pointerType"in r?r.pointerType:"mouse"}function tt(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 rt(r){return r.type==="touchend"||r.type==="touchcancel"?r.changedTouches:r.targetTouches}function Te(r){return te(r)?rt(r)[0]:r}function nt(r){return tt(r).map(e=>e.identifier)}function oe(r){const e=Te(r);return te(r)?e.identifier:e.pointerId}function xe(r){const e=Te(r);return[e.clientX,e.clientY]}function st(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 re(r,...e){return typeof r=="function"?r(...e):r}function it(){}function ot(...r){return r.length===0?it:r.length===1?r[0]:function(){let e;for(const t of r)e=t.apply(this,arguments)||e;return e}}function Ee(r,e){return Object.assign({},e,r||{})}const at=32;class ct{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?re(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,st(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 C=t._delta.map(Math.abs);T.addTo(t._distance,C)}this.axisIntent&&this.axisIntent(e);const[o,l]=t._movement,[c,p]=n.threshold,{_step:f,values:_}=t;if(n.hasCustomTransform?(f[0]===!1&&(f[0]=Math.abs(o)>=c&&_[0]),f[1]===!1&&(f[1]=Math.abs(l)>=p&&_[1])):(f[0]===!1&&(f[0]=Math.abs(o)>=c&&Math.sign(o)*c),f[1]===!1&&(f[1]=Math.abs(l)>=p&&Math.sign(l)*p)),t.intentional=f[0]!==!1||f[1]!==!1,!t.intentional)return;const h=[0,0];if(n.hasCustomTransform){const[C,R]=_;h[0]=f[0]!==!1?C-f[0]:0,h[1]=f[1]!==!1?R-f[1]:0}else h[0]=f[0]!==!1?o-f[0]:0,h[1]=f[1]!==!1?l-f[1]:0;this.restrictToAxis&&!t._blocked&&this.restrictToAxis(h);const x=t.offset,E=t._active&&!t._blocked||t.active;E&&(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=re(n.bounds,t)),this.setup&&this.setup()),t.movement=h,this.computeOffset()));const[z,V]=t.offset,[[$,O],[k,U]]=t._bounds;t.overflow=[z<$?-1:z>O?1:0,V<k?-1:V>U?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 K=t._active?n.rubberband||[0,0]:[0,0];if(t.offset=We(t._bounds,t.offset,K),t.delta=T.sub(t.offset,x),this.computeMovement(),E&&(!t.last||a>at)){t.delta=T.sub(t.offset,x);const C=t.delta.map(Math.abs);T.addTo(t.distance,C),t.direction=t.delta.map(Math.sign),t._direction=t._delta.map(Math.sign),!t.first&&a>0&&(t.velocity=[C[0]/a,C[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(y(y(y({},t),e),{},{[this.aliasKey]:e.values}));s!==void 0&&(e.memo=s)}clean(){this.eventStore.clean(),this.timeoutStore.clean()}}function ut([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 lt extends ct{constructor(...e){super(...e),D(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=T.add(this.state.lastOffset,this.state.movement)}computeMovement(){this.state.movement=T.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[we(e)]:n.axisThreshold;t.axis=ut(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 Ie=r=>r,Se=.15,ae={enabled(r=!0){return r},eventOptions(r,e,t){return y(y({},t.shared.eventOptions),r)},preventDefault(r=!1){return r},triggerAllEvents(r=!1){return r},rubberband(r=0){switch(r){case!0:return[Se,Se];case!1:return[0,0];default:return T.toVector(r)}},from(r){if(typeof r=="function")return r;if(r!=null)return T.toVector(r)},transform(r,e,t){const n=r||t.shared.transform;if(this.hasCustomTransform=!!n,process.env.NODE_ENV==="development"){const s=n||Ie;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||Ie},threshold(r){return T.toVector(r,0)}};process.env.NODE_ENV==="development"&&Object.assign(ae,{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 ft=0,Q=y(y({},ae),{},{axis(r,e,{axis:t}){if(this.lockDirection=t==="lock",!this.lockDirection)return t},axisThreshold(r=ft){return r},bounds(r={}){if(typeof r=="function")return a=>Q.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]]}}),ke={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 dt extends lt{constructor(...e){super(...e),D(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=Q.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=oe(e),n._pointerActive=!0,this.computeValues(xe(e)),this.computeInitial(),t.preventScrollAxis&&we(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=oe(e);if(t._pointerId!==void 0&&s!==t._pointerId)return;const a=xe(e);if(document.pointerLockElement===e.target?t._delta=[e.movementX,e.movementY]:(t._delta=T.sub(a,t._values),this.computeValues(a)),T.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=oe(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[l,c]=t._delta,[p,f]=t._movement,[_,h]=n.swipe.velocity,[x,E]=n.swipe.distance,z=n.swipe.duration;if(t.elapsedTime<z){const V=Math.abs(l/t.timeDelta),$=Math.abs(c/t.timeDelta);V>_&&Math.abs(p)>x&&(t.swipe[0]=Math.sign(l)),$>h&&Math.abs(f)>E&&(t.swipe[1]=Math.sign(c))}}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,ht(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=ke[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,T.addTo(n._movement,n._delta),this.compute(e),this.emit()}}keyUp(e){e.key in ke&&(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 ht(r){"persist"in r&&typeof r.persist=="function"&&r.persist()}const Z=typeof window<"u"&&window.document&&window.document.createElement;function Ce(){return Z&&"ontouchstart"in window}function pt(){return Ce()||Z&&window.navigator.maxTouchPoints>1}function gt(){return Z&&"onpointerdown"in window}function mt(){return Z&&"exitPointerLock"in window.document}function vt(){try{return"constructor"in GestureEvent}catch{return!1}}const A={isBrowser:Z,gesture:vt(),touch:Ce(),touchscreen:pt(),pointer:gt(),pointerLock:mt()},yt=250,bt=180,_t=.5,wt=50,Tt=250,xt=10,De={mouse:0,touch:0,pen:8},Ae=y(y({},Q),{},{device(r,e,{pointer:{touch:t=!1,lock:n=!1,mouse:s=!1}={}}){return this.pointerLock=n&&A.pointerLock,A.touch&&t?"touch":this.pointerLock?"mouse":A.pointer&&!s?"pointer":A.touch?"touch":"mouse"},preventScrollAxis(r,e,{preventScroll:t}){if(this.preventScrollDelay=typeof t=="number"?t:t||t===void 0&&r?yt:void 0,!(!A.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=T.toVector(r,t?n:s?1:0);return this.filterTaps=t,this.tapsThreshold=n,a},swipe({velocity:r=_t,distance:e=wt,duration:t=Tt}={}){return{velocity:this.transform(T.toVector(r)),distance:this.transform(T.toVector(e)),duration:t}},delay(r=0){switch(r){case!0:return bt;case!1:return 0;default:return r}},axisThreshold(r){return r?y(y({},De),r):De},keyboardDisplacement(r=xt){return r}});process.env.NODE_ENV==="development"&&Object.assign(Ae,{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}}),y(y({},ae),{},{device(r,e,{shared:t,pointer:{touch:n=!1}={}}){if(t.target&&!A.touch&&A.gesture)return"gesture";if(A.touch&&n)return"touch";if(A.touchscreen){if(A.pointer)return"pointer";if(A.touch)return"touch"}},bounds(r,e,{scaleBounds:t={},angleBounds:n={}}){const s=o=>{const l=Ee(re(t,o),{min:-1/0,max:1/0});return[l.min,l.max]},a=o=>{const l=Ee(re(n,o),{min:-1/0,max:1/0});return[l.min,l.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",T.toVector(r,this.lockDirection?[.1,3]:0)},modifierKey(r){return r===void 0?"ctrlKey":r},pinchOnWheel(r=!0){return r}}),y(y({},Q),{},{mouseOnly:(r=!0)=>r}),y(y({},Q),{},{mouseOnly:(r=!0)=>r});const $e=new Map,ce=new Map;function Et(r){$e.set(r.key,r.engine),ce.set(r.key,r.resolver)}const It={key:"drag",engine:dt,resolver:Ae};function St(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 kt(r,e){if(r==null)return{};var t=St(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 Ct={target(r){if(r)return()=>"current"in r?r.current:r},enabled(r=!0){return r},window(r=A.isBrowser?window:void 0){return r},eventOptions({passive:r=!0,capture:e=!1}={}){return{passive:r,capture:e}},transform(r){return r}},Dt=["target","eventOptions","window","enabled","transform"];function ne(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]=ne(r[n],s);break;case"boolean":s&&(t[n]=r[n]);break}return t}function At(r,e,t={}){const n=r,{target:s,eventOptions:a,window:o,enabled:l,transform:c}=n,p=kt(n,Dt);if(t.shared=ne({target:s,eventOptions:a,window:o,enabled:l,transform:c},Ct),e){const f=ce.get(e);t[e]=ne(y({shared:t.shared},p),f)}else for(const f in p){const _=ce.get(f);if(_)t[f]=ne(y({shared:t.shared},p[f]),_);else if(process.env.NODE_ENV==="development"&&!["drag","pinch","scroll","wheel","move","hover"].includes(f)){if(f==="domTarget")throw Error("[@use-gesture]: `domTarget` option has been renamed to `target`.");console.warn(`[@use-gesture]: Unknown config key \`${f}\` was used. Please read the documentation for further information.`)}}return t}class Oe{constructor(e,t){D(this,"_listeners",new Set),this._ctrl=e,this._gestureKey=t}add(e,t,n,s,a){const o=this._listeners,l=et(t,n),c=this._gestureKey?this._ctrl.config[this._gestureKey].eventOptions:{},p=y(y({},c),a);e.addEventListener(l,s,p);const f=()=>{e.removeEventListener(l,s,p),o.delete(f)};return o.add(f),f}clean(){this._listeners.forEach(e=>e()),this._listeners.clear()}}class $t{constructor(){D(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 Ot{constructor(e){D(this,"gestures",new Set),D(this,"_targetEventStore",new Oe(this)),D(this,"gestureEventStores",{}),D(this,"gestureTimeoutStores",{}),D(this,"handlers",{}),D(this,"config",{}),D(this,"pointerIds",new Set),D(this,"touchIds",new Set),D(this,"state",{shared:{shiftKey:!1,metaKey:!1,ctrlKey:!1,altKey:!1}}),Pt(this,e)}setEventIds(e){if(te(e))return this.touchIds=new Set(nt(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=At(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 l=this.config[o],c=Pe(n,l.eventOptions,!!s);if(l.enabled){const p=$e.get(o);new p(this,e,o).bind(c)}}const a=Pe(n,t.eventOptions,!!s);for(const o in this.nativeHandlers)a(o,"",l=>this.nativeHandlers[o](y(y({},this.state.shared),{},{event:l,args:e})),void 0,!0)}for(const a in n)n[a]=ot(...n[a]);if(!s)return n;for(const a in n){const{device:o,capture:l,passive:c}=Ze(a);this._targetEventStore.add(s,o,"",n[a],{capture:l,passive:c})}}}}function W(r,e){r.gestures.add(e),r.gestureEventStores[e]=new Oe(r,e),r.gestureTimeoutStores[e]=new $t}function Pt(r,e){e.drag&&W(r,"drag"),e.wheel&&W(r,"wheel"),e.scroll&&W(r,"scroll"),e.move&&W(r,"move"),e.pinch&&W(r,"pinch"),e.hover&&W(r,"hover")}const Pe=(r,e,t)=>(n,s,a,o={},l=!1)=>{var c,p;const f=(c=o.capture)!==null&&c!==void 0?c:e.capture,_=(p=o.passive)!==null&&p!==void 0?p:e.passive;let h=l?n:Je(n,s,f);t&&_&&(h+="Passive"),r[h]=r[h]||[],r[h].push(a)};function Mt(r,e={},t,n){const s=d.useMemo(()=>new Ot(r),[]);if(s.applyHandlers(r,n),s.applyConfig(e,t),d.useEffect(s.effect.bind(s)),d.useEffect(()=>s.clean.bind(s),[]),e.target===void 0)return s.bind.bind(s)}function Nt(r,e){return Et(It),Mt({drag:r},e||{},"drag")}function Lt(r){const{type:e,actionType:t,toIndex:n,itemsLength:s,withLoop:a,scrollAmount:o,totalAvailable:l}=r;let c=r.currentActive,p=r.fromValueRaw,f=!1,_=!1;e==="next"&&(c+=1),e==="prev"&&(c=c===0?s-1:c-1),n!==void 0&&(c=n);let h=0;e==="next"&&(h=-(c*o),a&&c===s&&(c=0,p=p+o*s,h=0),!a&&(Math.abs(h)>=l||c===s-1)&&(_=!0,h=-l)),e==="prev"&&(h=-(c*o),c===s-1&&(p=p-s*o),!a&&h>=0&&(f=!0,h=0)),t==="resize"&&(h=-(c*o),a||(c===0&&(f=!0),(c===s-1||Math.abs(h)>=l)&&(_=!0,Math.abs(h)>=l&&l>0&&(h=-l))));const x=a?c%s:c,E=a?s+c%s:c;return{newActive:c,fromValue:p,toValue:h,startReached:f,endReached:_,logicalIndex:x,realTrackIndex:E}}function ee(r,e,t){return e==="x"?`translate3d(calc(${r}px + var(--${t}-offset-modifier)), 0px, 0px)`:`translate3d(0px, calc(${r}px + var(--${t}-offset-modifier)), 0px)`}function Vt(){const r=d.useRef(null);r.current===null&&(r.current=new Set);const e=d.useRef(null);return e.current===null&&(e.current={useListenToCustomEvent(t){d.useEffect(()=>{const n=r.current;return n.add(t),()=>{n.delete(t)}},[t])},emitEvent(t){const n=r.current;!n||n.size===0||n.forEach(s=>s(t))}}),e.current}function Rt({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:l="start",enableGestures:c=!0,slideWhenDragThresholdIsReached:p=!0,slideType:f="item",initialActiveItem:_=0,renderWindow:h,renderPlaceholder:x}){const[E,z]=d.useState(!1),[,V]=d.useState(0),$=d.useRef(r),O=d.useRef(null),k=d.useRef(null),U=d.useRef(0),K=d.useRef(0),C=d.useRef(!t),R=d.useRef(!1),le=d.useRef(0),w=d.useRef(0),Ne=d.useRef(0),Le=d.useRef(e);Le.current=e;const Ve=d.useRef(t);Ve.current=t;const Re=d.useRef(!1),F=d.useRef(null),j=d.useRef(null),G=d.useRef(null),Y=d.useRef(null),H=d.useRef({width:0,height:0});function je(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 u=e.findIndex(m=>m.id===i);return u<0?(console.warn(`initialActiveItem: item with id "${i}" doesn't exist.`),0):u}const se=ie.useSpringRef(),fe=ie.useSpring({value:0,ref:se,onChange({value:i}){k.current.style.transform=ee(i.value,o,n)}}),zt=t?e.length*3:e.length,{useListenToCustomEvent:Be,emitEvent:q}=Vt();function ze(i){if(!i||i.length===0)return null;let u=null,m=-1/0;for(const g of i)(g.media?window.matchMedia(g.media).matches:window.innerWidth>=g.breakpoint)&&g.breakpoint>=m&&(u=g,m=g.breakpoint);return u}function Ue(){const{totalGutterCssVar:i}=Ke();return i}function Ut(){const i=ze(a);return(i==null?void 0:i.itemsPerSlide)||1}function de(i){$.current&&(R.current||X({type:"next",toIndex:i,actionType:"click"}))}function he(i){$.current&&(C.current||X({type:"prev",toIndex:i,actionType:"click"}))}function X({type:i,shouldAnimate:u=!0,toIndex:m,actionType:g}){var P,J;const I=!u;C.current=!1,R.current=!1;const v=Lt({type:i,actionType:g,toIndex:m,currentActive:w.current,itemsLength:e.length,withLoop:t,scrollAmount:K.current,totalAvailable:i==="next"||g==="resize"?pe(t?K.current*(e.length*2):0):0,fromValueRaw:fe.value.get()}),B=w.current;w.current=v.newActive,C.current=v.startReached,R.current=v.endReached,U.current=v.toValue,h!==void 0&&B!==v.newActive&&V(S=>S+1),q(g==="resize"?{eventName:"onResize",sliceActionType:g,slideDirection:i,currentItem:{id:((P=e.at(v.logicalIndex))==null?void 0:P.id)??"",index:v.logicalIndex,trackIndex:v.realTrackIndex,startReached:C.current,endReached:R.current}}:{eventName:"onSlideStartChange",sliceActionType:g,slideDirection:i,nextItem:{index:v.logicalIndex,id:((J=e.at(v.logicalIndex))==null?void 0:J.id)??"",trackIndex:v.realTrackIndex,startReached:C.current,endReached:R.current}}),I&&k.current&&(k.current.style.transform=ee(v.toValue,o,n)),se.start({immediate:I,from:{value:v.fromValue},to:{value:v.toValue},onChange({value:S}){k.current.style.transform=ee(S.value,o,n)},onRest({finished:S}){var b;if(S){const N=t?w.current%e.length:w.current,Fe=t?e.length+w.current%e.length:w.current;Ne.current=N,q({eventName:"onSlideChangeComplete",sliceActionType:g,slideDirection:i,currentItem:{index:N,id:((b=e.at(N))==null?void 0:b.id)??"",trackIndex:Fe,startReached:C.current,endReached:R.current}})}}})}function Kt(){const i=k.current;let u=0;return f==="item"?u=i.children[0].getBoundingClientRect()[o==="x"?"width":"height"]+Ue():u=i.getBoundingClientRect()[o==="x"?"width":"height"]+Ue(),u}function pe(i){const u=k.current;return u[o==="x"?"scrollWidth":"scrollHeight"]-u.getBoundingClientRect()[o==="x"?"width":"height"]-i}function Ke(){const i=ze(s);return{totalGutterCssVar:(i==null?void 0:i.gutter)||0,totalStartEndGutterCssVar:((i==null?void 0:i.startEndGutter)||0)*2}}d.useEffect(()=>{function i(S){const b=Ut();switch(S){case"start":return 0;case"middle-start":return Math.floor((b-1)*.25);case"center":return Math.floor((b-1)*.5);case"middle-end":return Math.floor((b-1)*.75);case"end":return b-1;default:return 0}}function u(){K.current=Kt(),le.current=K.current/4;const{totalStartEndGutterCssVar:S}=Ke();let b=0;t&&(b=K.current*e.length),b-=K.current*i(l),b-=S/2,O.current.style.setProperty(`--${n}-offset-modifier`,`${-b}px`)}function m(S){if(O.current&&(u(),z(!0),S)){const b=je(_),N=t?e.length+b%e.length:b;q({eventName:"onInit",index:b,trackIndex:N})}}function g(){m(),X({type:"resize",toIndex:w.current,shouldAnimate:!1,actionType:"resize"})}function I(){G.current!==null&&(clearTimeout(G.current),G.current=null),Y.current!==null&&(cancelAnimationFrame(Y.current),Y.current=null)}function v(S){Y.current===null&&(Y.current=requestAnimationFrame(()=>{Y.current=null;const b=O.current;if(!b)return;const N=b.getBoundingClientRect();(N.width!==H.current.width||N.height!==H.current.height)&&(H.current={width:N.width,height:N.height},g()),S&&(G.current=window.setTimeout(()=>{G.current=null,v(!1)},400))}))}function B(){I(),v(!0)}function P(){I(),G.current=window.setTimeout(()=>{G.current=null,H.current={width:0,height:0},v(!0)},250)}function J(){document.visibilityState==="visible"&&(I(),H.current={width:0,height:0},v(!0))}if(r){if($.current=!0,Re.current)g();else if(m(!0),Re.current=!0,O.current){const b=O.current.getBoundingClientRect();H.current={width:b.width,height:b.height}}const S=window.visualViewport??window;return S.addEventListener("resize",B),window.addEventListener("orientationchange",P),document.addEventListener("visibilitychange",J),()=>{S.removeEventListener("resize",B),window.removeEventListener("orientationchange",P),document.removeEventListener("visibilitychange",J),I()}}},[r,n,o,t]),d.useEffect(()=>{const i=je(_),u=i===Ne.current;r&&i!==w.current&&!u&&X({type:"next",toIndex:i,actionType:"resize",shouldAnimate:!1})},[r,_]);const ge=c;function Ft(){if(j.current!==null&&(cancelAnimationFrame(j.current),j.current=null),F.current){const i=F.current;F.current=null,q(i)}}function Gt(i){F.current=i,j.current===null&&(j.current=requestAnimationFrame(()=>{j.current=null;const u=F.current;F.current=null,u&&q(u)}))}d.useEffect(()=>()=>{j.current!==null&&(cancelAnimationFrame(j.current),j.current=null),F.current=null},[]);const Wt=Nt(i=>{if(!$.current)return;const u=i.dragging,m=i.offset[o==="x"?0:1],g=i.movement[o==="x"?0:1],I=g>le.current,v=g<-le.current,B=i.velocity;u&&(Gt({...i,eventName:"onDrag",slideActionType:"drag"}),se.start({value:m,immediate:!0,config:{velocity:B},onChange({value:P}){k.current.style.transform=ee(P.value,o,n)}}),p&&(I||v)&&i.cancel()),i.last&&(Ft(),I?(X({actionType:"drag",type:"prev"}),i.cancel()):v?(X({actionType:"drag",type:"next"}),i.cancel()):(se.start({value:U.current,config:{velocity:B},onChange({value:P}){k.current.style.transform=ee(P.value,o,n)}}),i.cancel()))},{enabled:ge,axis:o,rubberband:!t,...t?{}:{bounds:()=>({right:0,left:-pe(0),top:-pe(0),bottom:0})},from:()=>[fe.value.get(),fe.value.get()]}),Yt=d.useCallback(i=>{var v;const u=Le.current,g=Ve.current?u.length+w.current%u.length:w.current;if(typeof i=="number")return g===i;const I=w.current%u.length;return i===((v=u[I])==null?void 0:v.id)},[]),Ht=d.useMemo(()=>Array.from({length:e.length},(i,u)=>()=>{const m=t?w.current%e.length:w.current;return t?u===(m+1)%e.length:m+1>=e.length?!1:u===m+1}),[e.length,t]),qt=d.useMemo(()=>Array.from({length:e.length},(i,u)=>()=>{const m=t?w.current%e.length:w.current;return t?u===(m-1+e.length)%e.length:m-1<0?!1:u===m-1}),[e.length,t]),Xt=d.useMemo(()=>`
2
2
  [data-part-internal="${n}-Container"] {
3
3
  display: flex;
4
4
  width: 100%;
@@ -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.slice().sort((i,l)=>i.breakpoint-l.breakpoint).map(i=>`
32
+ ${s&&s.length>0?s.slice().sort((i,u)=>i.breakpoint-u.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
- ${a&&a.length>0?a.slice().sort((i,l)=>i.breakpoint-l.breakpoint).map(i=>`
40
+ ${a&&a.length>0?a.slice().sort((i,u)=>i.breakpoint-u.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
- `,[n,o,ge,e.length,t,E,s,a]);return{carouselFragment:N.jsxs("div",{ref:O,className:"ReactSpringCarouselContainer","data-part":"Container","data-part-internal":`${n}-Container`,...Gt(),children:[N.jsx("style",{dangerouslySetInnerHTML:{__html:qt}}),N.jsx("div",{ref:k,className:"ReactSpringCarouselTrack","data-part":"Track","data-part-internal":`${n}-Track`,onScroll:()=>{C.current=!1,V.current=!1},children:Array.from({length:Bt},(i,l)=>{const m=t?l%e.length:l,g=e[m],I=t&&(l<e.length||l>=e.length*2);if(h!==void 0){const P=t?e.length+w.current%e.length:w.current;if(Math.abs(l-P)>h)return N.jsx("div",{className:"ReactSpringCarouselItem","data-part":"Item","data-part-internal":`${n}-Item`,"data-id":g.id,"aria-hidden":"true",children:x==null?void 0:x({item:g,index:l,isClonedItem:I})},`${g.id}-${l}`)}const v=Yt[m],j=Ht[m];return N.jsx("div",{className:"ReactSpringCarouselItem","data-part":"Item","data-part-internal":`${n}-Item`,"data-id":g.id,children:typeof g.renderItem=="function"?g.renderItem({useListenToCustomEvent:je,index:l,isClonedItem:I,isActiveItem:Wt,isNextItem:v,isPrevItem:j}):g.renderItem},`${g.id}-${l}`)})})]}),useListenToCustomEvent:je,slideToNextItem:()=>de(),slideToPrevItem:()=>he(),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>w.current?de(i):he(i)}if(typeof i=="string"){const l=e.findIndex(m=>m.id===i);if(l<0){console.warn(`The item you're trying to slide doesn't exist. id: ${i}`);return}l>w.current?de(l):he(l)}}}}function Rt(r){let e=0;const t=getComputedStyle(r).getPropertyValue("gap");return t.includes("px")&&(e=Number(t.replace("px",""))),e}function Me(r){return r.scrollWidth-r.clientWidth}function ue(r){const e=r.children[0],t=Rt(r);return e.getBoundingClientRect().width+t}function jt({container:r,onReach:e}){const t=d.useRef("start"),n=d.useRef(0),[,s]=ie.useSpring(()=>({x:0}));function a(u){s.start({from:{x:r.current.scrollLeft},to:{x:u},onChange({value:c}){r.current&&(r.current.scrollLeft=c.x)}})}function o(u){if(!r.current||u==="next"&&t.current==="end"||u==="prev"&&t.current==="start")return;let c=0;if(u==="next"&&(n.current+=1),u==="prev"&&(n.current-=1),c=n.current*ue(r.current),u==="next"){const p=Me(r.current);c>p&&(t.current="end",c=p,e&&e("end"))}u==="prev"&&c<=0&&(t.current="start",n.current=0,c=0,e&&e("start")),a(c)}return d.useEffect(()=>{function u(){var O;const x=ue(r.current),E=((O=[...r.current.children].at(0))==null?void 0:O.getBoundingClientRect().width)||0,z=Array(r.current.childElementCount).fill(0).map((k,U)=>({index:U,start:x*U,end:x*(U+1)})),L=r.current.scrollLeft+E,$=z.find(k=>L>=k.start&&L<k.end);n.current=($==null?void 0:$.index)||0}function c(){s.stop()}function p(x){const E=x.target;E.scrollLeft===0?(n.current=0,t.current="start",e&&e("start")):E.scrollLeft>=Me(E)?(t.current="end",e&&e("end")):t.current!=="idle"&&(t.current="idle",e&&e("idle"))}let f,_=0;function h(){_=r.current.scrollLeft,clearTimeout(f),f=setTimeout(function(){r.current.scrollLeft===_&&u()},200)}if(r.current)return r.current.addEventListener("wheel",c,{passive:!0}),r.current.addEventListener("scroll",p),r.current.addEventListener("scroll",h),()=>{r.current&&(r.current.removeEventListener("scroll",h),r.current.removeEventListener("scroll",p),r.current.removeEventListener("wheel",c))}},[r,e]),d.useEffect(()=>{if(r.current){const u=new ResizeObserver(()=>{a(n.current*ue(r.current))});return u.observe(r.current),()=>{u.disconnect()}}},[]),{scrollToNext(){o("next")},scrollToPrev(){o("prev")}}}M.useSpringCarousel=Vt,M.useSpringScroll=jt,Object.defineProperty(M,Symbol.toStringTag,{value:"Module"})});
47
+ `,[n,o,ge,e.length,t,E,s,a]);return{carouselFragment:L.jsxs("div",{ref:O,className:"ReactSpringCarouselContainer","data-part":"Container","data-part-internal":`${n}-Container`,...Wt(),children:[L.jsx("style",{dangerouslySetInnerHTML:{__html:Xt}}),L.jsx("div",{ref:k,className:"ReactSpringCarouselTrack","data-part":"Track","data-part-internal":`${n}-Track`,onScroll:()=>{C.current=!1,R.current=!1},children:Array.from({length:zt},(i,u)=>{const m=t?u%e.length:u,g=e[m],I=t&&(u<e.length||u>=e.length*2);if(h!==void 0){const P=t?e.length+w.current%e.length:w.current;if(Math.abs(u-P)>h)return L.jsx("div",{className:"ReactSpringCarouselItem","data-part":"Item","data-part-internal":`${n}-Item`,"data-id":g.id,"aria-hidden":"true",children:x==null?void 0:x({item:g,index:u,isClonedItem:I})},`${g.id}-${u}`)}const v=Ht[m],B=qt[m];return L.jsx("div",{className:"ReactSpringCarouselItem","data-part":"Item","data-part-internal":`${n}-Item`,"data-id":g.id,children:typeof g.renderItem=="function"?g.renderItem({useListenToCustomEvent:Be,index:u,isClonedItem:I,isActiveItem:Yt,isNextItem:v,isPrevItem:B}):g.renderItem},`${g.id}-${u}`)})})]}),useListenToCustomEvent:Be,slideToNextItem:()=>de(),slideToPrevItem:()=>he(),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>w.current?de(i):he(i)}if(typeof i=="string"){const u=e.findIndex(m=>m.id===i);if(u<0){console.warn(`The item you're trying to slide doesn't exist. id: ${i}`);return}u>w.current?de(u):he(u)}}}}function jt(r){let e=0;const t=getComputedStyle(r).getPropertyValue("gap");return t.includes("px")&&(e=Number(t.replace("px",""))),e}function Me(r){return r.scrollWidth-r.clientWidth}function ue(r){const e=r.children[0],t=jt(r);return e.getBoundingClientRect().width+t}function Bt({container:r,onReach:e}){const t=d.useRef("start"),n=d.useRef(0),[,s]=ie.useSpring(()=>({x:0}));function a(l){s.start({from:{x:r.current.scrollLeft},to:{x:l},onChange({value:c}){r.current&&(r.current.scrollLeft=c.x)}})}function o(l){if(!r.current||l==="next"&&t.current==="end"||l==="prev"&&t.current==="start")return;let c=0;if(l==="next"&&(n.current+=1),l==="prev"&&(n.current-=1),c=n.current*ue(r.current),l==="next"){const p=Me(r.current);c>p&&(t.current="end",c=p,e&&e("end"))}l==="prev"&&c<=0&&(t.current="start",n.current=0,c=0,e&&e("start")),a(c)}return d.useEffect(()=>{function l(){var O;const x=ue(r.current),E=((O=[...r.current.children].at(0))==null?void 0:O.getBoundingClientRect().width)||0,z=Array(r.current.childElementCount).fill(0).map((k,U)=>({index:U,start:x*U,end:x*(U+1)})),V=r.current.scrollLeft+E,$=z.find(k=>V>=k.start&&V<k.end);n.current=($==null?void 0:$.index)||0}function c(){s.stop()}function p(x){const E=x.target;E.scrollLeft===0?(n.current=0,t.current="start",e&&e("start")):E.scrollLeft>=Me(E)?(t.current="end",e&&e("end")):t.current!=="idle"&&(t.current="idle",e&&e("idle"))}let f,_=0;function h(){_=r.current.scrollLeft,clearTimeout(f),f=setTimeout(function(){r.current.scrollLeft===_&&l()},200)}if(r.current)return r.current.addEventListener("wheel",c,{passive:!0}),r.current.addEventListener("scroll",p),r.current.addEventListener("scroll",h),()=>{r.current&&(r.current.removeEventListener("scroll",h),r.current.removeEventListener("scroll",p),r.current.removeEventListener("wheel",c))}},[r,e]),d.useEffect(()=>{if(r.current){const l=new ResizeObserver(()=>{a(n.current*ue(r.current))});return l.observe(r.current),()=>{l.disconnect()}}},[]),{scrollToNext(){o("next")},scrollToPrev(){o("prev")}}}M.useSpringCarousel=Rt,M.useSpringScroll=Bt,Object.defineProperty(M,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-spring-carousel",
3
- "version": "3.0.0-beta-2.2.0",
3
+ "version": "3.0.0-beta-2.2.1",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.umd.js",