react-spring-carousel 3.0.0-beta-1.0.422 → 3.0.0-beta-2.0.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,55 +1,29 @@
1
- (function(B,A){typeof exports=="object"&&typeof module<"u"?A(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"],A):(B=typeof globalThis<"u"?globalThis:B||self,A(B["react-spring-carousel"]={},B["react/jsx-runtime"],B["@react-spring/web"],B.React))})(this,function(B,A,ye,E){"use strict";function Ke(r,e,t){return Math.max(e,Math.min(r,t))}const k={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 xe(r,e,t){return e===0||Math.abs(e)===1/0?Math.pow(r,t*5):r*e*t/(e+t*r)}function we(r,e,t,n=.15){return n===0?Ke(r,e,t):r<e?-xe(e-r,t-e,n)+e:r>t?+xe(r-t,t-e,n)+t:r}function Fe(r,[e,t],[n,i]){const[[c,o],[h,_]]=r;return[we(e,c,o,n),we(t,h,_,i)]}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||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(r)}function ze(r){var e=We(r,"string");return typeof e=="symbol"?e:String(e)}function O(r,e,t){return e=ze(e),e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function _e(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(r,i).enumerable})),t.push.apply(t,n)}return t}function w(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?_e(Object(t),!0).forEach(function(n){O(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):_e(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}const Ie={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 Ee(r){return r?r[0].toUpperCase()+r.slice(1):""}const He=["enter","leave"];function Ye(r=!1,e){return r&&!He.includes(e)}function Xe(r,e="",t=!1){const n=Ie[r],i=n&&n[e]||e;return"on"+Ee(r)+Ee(i)+(Ye(t,i)?"Capture":"")}const qe=["gotpointercapture","lostpointercapture"];function Je(r){let e=r.substring(2).toLowerCase();const t=!!~e.indexOf("passive");t&&(e=e.replace("passive",""));const n=qe.includes(e)?"capturecapture":"capture",i=!!~e.indexOf(n);return i&&(e=e.replace("capture","")),{device:e,capture:i,passive:t}}function Qe(r,e=""){const t=Ie[r],n=t&&t[e]||e;return r+n}function re(r){return"touches"in r}function Se(r){return re(r)?"touch":"pointerType"in r?r.pointerType:"mouse"}function Ze(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 et(r){return r.type==="touchend"||r.type==="touchcancel"?r.changedTouches:r.targetTouches}function Ce(r){return re(r)?et(r)[0]:r}function tt(r){return Ze(r).map(e=>e.identifier)}function le(r){const e=Ce(r);return re(r)?e.identifier:e.pointerId}function De(r){const e=Ce(r);return[e.clientX,e.clientY]}function rt(r){const e={};if("buttons"in r&&(e.buttons=r.buttons),"shiftKey"in r){const{shiftKey:t,altKey:n,metaKey:i,ctrlKey:c}=r;Object.assign(e,{shiftKey:t,altKey:n,metaKey:i,ctrlKey:c})}return e}function ne(r,...e){return typeof r=="function"?r(...e):r}function nt(){}function it(...r){return r.length===0?nt:r.length===1?r[0]:function(){let e;for(const t of r)e=t.apply(this,arguments)||e;return e}}function Te(r,e){return Object.assign({},e,r||{})}const st=32;class ot{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:i}=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=i,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?ne(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:i}=this;t.args=this.args;let c=0;if(e&&(t.event=e,n.preventDefault&&e.cancelable&&t.event.preventDefault(),t.type=e.type,i.touches=this.ctrl.pointerIds.size||this.ctrl.touchIds.size,i.locked=!!document.pointerLockElement,Object.assign(i,rt(e)),i.down=i.pressed=i.buttons%2===1||i.touches>0,c=e.timeStamp-t.timeStamp,t.timeStamp=e.timeStamp,t.elapsedTime=t.timeStamp-t.startTime),t._active){const x=t._delta.map(Math.abs);k.addTo(t._distance,x)}this.axisIntent&&this.axisIntent(e);const[o,h]=t._movement,[_,S]=n.threshold,{_step:u,values:T}=t;if(n.hasCustomTransform?(u[0]===!1&&(u[0]=Math.abs(o)>=_&&T[0]),u[1]===!1&&(u[1]=Math.abs(h)>=S&&T[1])):(u[0]===!1&&(u[0]=Math.abs(o)>=_&&Math.sign(o)*_),u[1]===!1&&(u[1]=Math.abs(h)>=S&&Math.sign(h)*S)),t.intentional=u[0]!==!1||u[1]!==!1,!t.intentional)return;const C=[0,0];if(n.hasCustomTransform){const[x,oe]=T;C[0]=u[0]!==!1?x-u[0]:0,C[1]=u[1]!==!1?oe-u[1]:0}else C[0]=u[0]!==!1?o-u[0]:0,C[1]=u[1]!==!1?h-u[1]:0;this.restrictToAxis&&!t._blocked&&this.restrictToAxis(C);const V=t.offset,F=t._active&&!t._blocked||t.active;F&&(t.first=t._active&&!t.active,t.last=!t._active&&t.active,t.active=i[this.ingKey]=t._active,e&&(t.first&&("bounds"in n&&(t._bounds=ne(n.bounds,t)),this.setup&&this.setup()),t.movement=C,this.computeOffset()));const[D,P]=t.offset,[[L,Q],[Z,b]]=t._bounds;t.overflow=[D<L?-1:D>Q?1:0,P<Z?-1:P>b?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 se=t._active?n.rubberband||[0,0]:[0,0];if(t.offset=Fe(t._bounds,t.offset,se),t.delta=k.sub(t.offset,V),this.computeMovement(),F&&(!t.last||c>st)){t.delta=k.sub(t.offset,V);const x=t.delta.map(Math.abs);k.addTo(t.distance,x),t.direction=t.delta.map(Math.sign),t._direction=t._delta.map(Math.sign),!t.first&&c>0&&(t.velocity=[x[0]/c,x[1]/c],t.timeDelta=c)}}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 i=this.handler(w(w(w({},t),e),{},{[this.aliasKey]:e.values}));i!==void 0&&(e.memo=i)}clean(){this.eventStore.clean(),this.timeoutStore.clean()}}function ct([r,e],t){const n=Math.abs(r),i=Math.abs(e);if(n>i&&n>t)return"x";if(i>n&&i>t)return"y"}class at extends ot{constructor(...e){super(...e),O(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=k.add(this.state.lastOffset,this.state.movement)}computeMovement(){this.state.movement=k.sub(this.state.offset,this.state.lastOffset)}axisIntent(e){const t=this.state,n=this.config;if(!t.axis&&e){const i=typeof n.axisThreshold=="object"?n.axisThreshold[Se(e)]:n.axisThreshold;t.axis=ct(t._movement,i)}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 ke=r=>r,Pe=.15,fe={enabled(r=!0){return r},eventOptions(r,e,t){return w(w({},t.shared.eventOptions),r)},preventDefault(r=!1){return r},triggerAllEvents(r=!1){return r},rubberband(r=0){switch(r){case!0:return[Pe,Pe];case!1:return[0,0];default:return k.toVector(r)}},from(r){if(typeof r=="function")return r;if(r!=null)return k.toVector(r)},transform(r,e,t){const n=r||t.shared.transform;if(this.hasCustomTransform=!!n,process.env.NODE_ENV==="development"){const i=n||ke;return c=>{const o=i(c);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||ke},threshold(r){return k.toVector(r,0)}};process.env.NODE_ENV==="development"&&Object.assign(fe,{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 ut=0,q=w(w({},fe),{},{axis(r,e,{axis:t}){if(this.lockDirection=t==="lock",!this.lockDirection)return t},axisThreshold(r=ut){return r},bounds(r={}){if(typeof r=="function")return c=>q.bounds(r(c));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:i=1/0}=r;return[[e,t],[n,i]]}}),Oe={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 lt extends at{constructor(...e){super(...e),O(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(),i={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(i)}}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 i=this.ctrl.setEventIds(e);t.pointerCapture&&e.target.setPointerCapture(e.pointerId),!(i&&i.size>1&&n._pointerActive)&&(this.start(e),this.setupPointer(e),n._pointerId=le(e),n._pointerActive=!0,this.computeValues(De(e)),this.computeInitial(),t.preventScrollAxis&&Se(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 i=le(e);if(t._pointerId!==void 0&&i!==t._pointerId)return;const c=De(e);if(document.pointerLockElement===e.target?t._delta=[e.movementX,e.movementY]:(t._delta=k.sub(c,t._values),this.computeValues(c)),k.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 i=le(e);if(t._pointerId!==void 0&&i!==t._pointerId)return;this.state._pointerActive=!1,this.setActive(),this.compute(e);const[c,o]=t._distance;if(t.tap=c<=n.tapsThreshold&&o<=n.tapsThreshold,t.tap&&n.filterTaps)t._force=!0;else{const[h,_]=t._delta,[S,u]=t._movement,[T,C]=n.swipe.velocity,[V,F]=n.swipe.distance,D=n.swipe.duration;if(t.elapsedTime<D){const P=Math.abs(h/t.timeDelta),L=Math.abs(_/t.timeDelta);P>T&&Math.abs(S)>V&&(t.swipe[0]=Math.sign(h)),L>C&&Math.abs(u)>F&&(t.swipe[1]=Math.sign(_))}}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 i="uv"in e?e.sourceEvent.currentTarget:e.currentTarget;window.getComputedStyle(i).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.",i)}}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,ft(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=Oe[e.key];if(t){const n=this.state,i=e.shiftKey?10:e.altKey?.1:1;this.start(e),n._delta=t(this.config.keyboardDisplacement,i),n._keyboardActive=!0,k.addTo(n._movement,n._delta),this.compute(e),this.emit()}}keyUp(e){e.key in Oe&&(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 ft(r){"persist"in r&&typeof r.persist=="function"&&r.persist()}const J=typeof window<"u"&&window.document&&window.document.createElement;function Ne(){return J&&"ontouchstart"in window}function dt(){return Ne()||J&&window.navigator.maxTouchPoints>1}function ht(){return J&&"onpointerdown"in window}function pt(){return J&&"exitPointerLock"in window.document}function gt(){try{return"constructor"in GestureEvent}catch{return!1}}const M={isBrowser:J,gesture:gt(),touch:Ne(),touchscreen:dt(),pointer:ht(),pointerLock:pt()},mt=250,vt=180,bt=.5,yt=50,xt=250,wt=10,Me={mouse:0,touch:0,pen:8},Le=w(w({},q),{},{device(r,e,{pointer:{touch:t=!1,lock:n=!1,mouse:i=!1}={}}){return this.pointerLock=n&&M.pointerLock,M.touch&&t?"touch":this.pointerLock?"mouse":M.pointer&&!i?"pointer":M.touch?"touch":"mouse"},preventScrollAxis(r,e,{preventScroll:t}){if(this.preventScrollDelay=typeof t=="number"?t:t||t===void 0&&r?mt:void 0,!(!M.touchscreen||t===!1))return r||(t!==void 0?"y":void 0)},pointerCapture(r,e,{pointer:{capture:t=!0,buttons:n=1,keys:i=!0}={}}){return this.pointerButtons=n,this.keys=i,!this.pointerLock&&this.device==="pointer"&&t},threshold(r,e,{filterTaps:t=!1,tapsThreshold:n=3,axis:i=void 0}){const c=k.toVector(r,t?n:i?1:0);return this.filterTaps=t,this.tapsThreshold=n,c},swipe({velocity:r=bt,distance:e=yt,duration:t=xt}={}){return{velocity:this.transform(k.toVector(r)),distance:this.transform(k.toVector(e)),duration:t}},delay(r=0){switch(r){case!0:return vt;case!1:return 0;default:return r}},axisThreshold(r){return r?w(w({},Me),r):Me},keyboardDisplacement(r=wt){return r}});process.env.NODE_ENV==="development"&&Object.assign(Le,{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}}),w(w({},fe),{},{device(r,e,{shared:t,pointer:{touch:n=!1}={}}){if(t.target&&!M.touch&&M.gesture)return"gesture";if(M.touch&&n)return"touch";if(M.touchscreen){if(M.pointer)return"pointer";if(M.touch)return"touch"}},bounds(r,e,{scaleBounds:t={},angleBounds:n={}}){const i=o=>{const h=Te(ne(t,o),{min:-1/0,max:1/0});return[h.min,h.max]},c=o=>{const h=Te(ne(n,o),{min:-1/0,max:1/0});return[h.min,h.max]};return typeof t!="function"&&typeof n!="function"?[i(),c()]:o=>[i(o),c(o)]},threshold(r,e,t){return this.lockDirection=t.axis==="lock",k.toVector(r,this.lockDirection?[.1,3]:0)},modifierKey(r){return r===void 0?"ctrlKey":r},pinchOnWheel(r=!0){return r}}),w(w({},q),{},{mouseOnly:(r=!0)=>r}),w(w({},q),{},{mouseOnly:(r=!0)=>r});const $e=new Map,de=new Map;function _t(r){$e.set(r.key,r.engine),de.set(r.key,r.resolver)}const It={key:"drag",engine:lt,resolver:Le};function Et(r,e){if(r==null)return{};var t={},n=Object.keys(r),i,c;for(c=0;c<n.length;c++)i=n[c],!(e.indexOf(i)>=0)&&(t[i]=r[i]);return t}function St(r,e){if(r==null)return{};var t=Et(r,e),n,i;if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(r);for(i=0;i<c.length;i++)n=c[i],!(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=M.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 ie(r={},e){const t={};for(const[n,i]of Object.entries(e))switch(typeof i){case"function":if(process.env.NODE_ENV==="development"){const c=i.call(t,r[n],n,r);Number.isNaN(c)||(t[n]=c)}else t[n]=i.call(t,r[n],n,r);break;case"object":t[n]=ie(r[n],i);break;case"boolean":i&&(t[n]=r[n]);break}return t}function Tt(r,e,t={}){const n=r,{target:i,eventOptions:c,window:o,enabled:h,transform:_}=n,S=St(n,Dt);if(t.shared=ie({target:i,eventOptions:c,window:o,enabled:h,transform:_},Ct),e){const u=de.get(e);t[e]=ie(w({shared:t.shared},S),u)}else for(const u in S){const T=de.get(u);if(T)t[u]=ie(w({shared:t.shared},S[u]),T);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 t}class Ve{constructor(e,t){O(this,"_listeners",new Set),this._ctrl=e,this._gestureKey=t}add(e,t,n,i,c){const o=this._listeners,h=Qe(t,n),_=this._gestureKey?this._ctrl.config[this._gestureKey].eventOptions:{},S=w(w({},_),c);e.addEventListener(h,i,S);const u=()=>{e.removeEventListener(h,i,S),o.delete(u)};return o.add(u),u}clean(){this._listeners.forEach(e=>e()),this._listeners.clear()}}class kt{constructor(){O(this,"_timeouts",new Map)}add(e,t,n=140,...i){this.remove(e),this._timeouts.set(e,window.setTimeout(t,n,...i))}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 Pt{constructor(e){O(this,"gestures",new Set),O(this,"_targetEventStore",new Ve(this)),O(this,"gestureEventStores",{}),O(this,"gestureTimeoutStores",{}),O(this,"handlers",{}),O(this,"config",{}),O(this,"pointerIds",new Set),O(this,"touchIds",new Set),O(this,"state",{shared:{shiftKey:!1,metaKey:!1,ctrlKey:!1,altKey:!1}}),Ot(this,e)}setEventIds(e){if(re(e))return this.touchIds=new Set(tt(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=Tt(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 i;if(!(t.target&&(i=t.target(),!i))){if(t.enabled){for(const o of this.gestures){const h=this.config[o],_=Ae(n,h.eventOptions,!!i);if(h.enabled){const S=$e.get(o);new S(this,e,o).bind(_)}}const c=Ae(n,t.eventOptions,!!i);for(const o in this.nativeHandlers)c(o,"",h=>this.nativeHandlers[o](w(w({},this.state.shared),{},{event:h,args:e})),void 0,!0)}for(const c in n)n[c]=it(...n[c]);if(!i)return n;for(const c in n){const{device:o,capture:h,passive:_}=Je(c);this._targetEventStore.add(i,o,"",n[c],{capture:h,passive:_})}}}}function X(r,e){r.gestures.add(e),r.gestureEventStores[e]=new Ve(r,e),r.gestureTimeoutStores[e]=new kt}function Ot(r,e){e.drag&&X(r,"drag"),e.wheel&&X(r,"wheel"),e.scroll&&X(r,"scroll"),e.move&&X(r,"move"),e.pinch&&X(r,"pinch"),e.hover&&X(r,"hover")}const Ae=(r,e,t)=>(n,i,c,o={},h=!1)=>{var _,S;const u=(_=o.capture)!==null&&_!==void 0?_:e.capture,T=(S=o.passive)!==null&&S!==void 0?S:e.passive;let C=h?n:Xe(n,i,u);t&&T&&(C+="Passive"),r[C]=r[C]||[],r[C].push(c)};function Nt(r,e={},t,n){const i=E.useMemo(()=>new Pt(r),[]);if(i.applyHandlers(r,n),i.applyConfig(e,t),E.useEffect(i.effect.bind(i)),E.useEffect(()=>i.clean.bind(i),[]),e.target===void 0)return i.bind.bind(i)}function Mt(r,e){return _t(It),Nt({drag:r},e||{},"drag")}const he="RSC::Event";function Lt(){const r=E.useRef(null);function e(n){E.useEffect(()=>{r.current||(r.current=document.createElement("div"));function i(c){n(c.detail)}if(r.current)return r.current.addEventListener(he,i,!1),()=>{var c;(c=r.current)==null||c.removeEventListener(he,i,!1)}},[n])}function t(n){if(r.current){const i=new CustomEvent(he,{detail:n});r.current.dispatchEvent(i)}}return{useListenToCustomEvent:e,emitEvent:t}}function $t(r){const{left:e,right:t,top:n,bottom:i}=r.getBoundingClientRect(),{innerWidth:c,innerHeight:o}=window;return e<0||n<0?{isOut:!0,direction:"start"}:Math.floor(t)>Math.floor(c)||Math.floor(i)>Math.floor(o)?{isOut:!0,direction:"end"}:{isOut:!1,direction:null}}function K(r){return parseFloat(r.toFixed(2))}function Re(r){process.env.NODE_ENV!=="production"&&console.warn(r)}function Vt(r){if(!r||r.trim()==="")return"";let e="",t=!1,n=!0;for(let i=0;i<r.length;i++){const c=r[i];if(c==="$"&&r[i+1]==="{"){t=!0,e+=c;continue}if(t&&c==="}"){t=!1,e+=c,n=!0;continue}if(t){e+=c;continue}if(/\s/.test(c)){if(n)continue;let o=i+1;for(;o<r.length&&/\s/.test(r[o]);)o++;if(o<r.length&&/[{:;,}]/.test(r[o]))continue;e+=" ",n=!0;continue}/[{:;,]/.test(c)?n=!0:n=!1,e+=c}return e}function At({init:r=!0,items:e,slideType:t="fixed",scrollAmount:n,withLoop:i=!1,enableGestures:c=!0,carouselAxis:o="x",slideWhenDragThresholdIsReached:h=!0,scrollAmountType:_,fadeIn:S=!1,initialActiveItem:u}){const[T,C]=E.useState(!1),V=E.useRef([]),F=E.useRef(!1),D=E.useRef(0),P=_??"slide",L=i?[...e.map(s=>({...s,id:`prev-repeated-item-${s.id}`})),...e,...e.map(s=>({...s,id:`next-repeated-item-${s.id}`}))]:e,Q=E.useRef(n),Z=E.useRef(0),b=E.useId().replace(/:/g,""),se=E.useRef(null),x=E.useRef(null),oe=E.useRef(0),v=E.useRef(!0),g=E.useRef(!1),a=E.useRef(0),[R,ce]=ye.useSpring(()=>({value:0,onChange({value:s}){(t==="fixed"||t==="fluid")&&(o==="x"?x.current.style.setProperty("--scroll-x-value",`${s.value}px`):x.current.style.setProperty("--scroll-y-value",`${s.value}px`)),t==="freeScroll"&&(x.current[o==="x"?"scrollLeft":"scrollTop"]=Math.abs(s.value))}}),[o]),{useListenToCustomEvent:je,emitEvent:W}=Lt();function y(){const{totalStartEndGutterCssVar:s}=pe();return K(Q.current??0-s)}function z(){return x.current[o==="x"?"scrollWidth":"scrollHeight"]-se.current.getBoundingClientRect()[o==="x"?"width":"height"]}function ee(s){s&&V.current.push(s),Re("The carousel can't be initialized. List of errors:"),console.table(V.current)}function Rt(){return t==="freeScroll"?{onWheel(){R.value.stop()},onScroll(s){const l=s.currentTarget,d=o==="x"?l.scrollLeft:l.scrollTop,m=o==="x"?l.scrollWidth-l.clientWidth:l.scrollHeight-l.clientHeight;d===0?v.current=!0:d===m?g.current=!0:(v.current=!1,g.current=!1)}}:{}}function pe(){let s=0,l=0,d=0;const m=getComputedStyle(document.documentElement).getPropertyValue(`--${b}-react-spring-carousel-item-gutter`),f=getComputedStyle(document.documentElement).getPropertyValue(`--${b}-react-spring-carousel-items-per-slide`),p=getComputedStyle(document.documentElement).getPropertyValue(`--${b}-react-spring-carousel-item-gutter`);return p.includes("px")&&(s=Number(p.replace("px",""))),d=Number(f)||1,m.includes("px")&&(l=Number(m.replace("px",""))),{totalGutterCssVar:s,totalStartEndGutterCssVar:l,itemsPerSlide:d}}function ae({type:s,actionType:l,newActiveItem:d,shouldAnimate:m=!0}){var U,H,te,ue,Be,Ge,Ue;let f=0,p=R.value.get();if(v.current=!1,g.current=!1,t==="fixed"){const $=a.current;if(s==="prev"&&(a.current=d??a.current-1),s==="next"&&(a.current=d??a.current+1),i&&P==="group"&&D.current>1&&s==="next"){const I=e.length/D.current,G=Math.ceil(I)-1===a.current,Y=Math.ceil(I)===a.current;G&&(g.current=!0),f=-(a.current*y()),Y&&(a.current=0,p=R.value.get()+y()*I,f=0,g.current=!1,v.current=!0)}if(i&&P==="group"&&D.current>1&&s==="prev"){const I=e.length/D.current,G=a.current===0,Y=a.current===-1;f=-(a.current*y()),G&&(v.current=!0),Y&&(v.current=!1,g.current=!0,a.current=I-1,p=R.value.get()-y()*I,f=-y()*I+y())}if(!i&&P==="group"&&D.current>1){const I=e.length/D.current,G=2%I!==0,Y=Math.ceil(I-1)===a.current,be=a.current===0;f=-(a.current*y()),be&&(v.current=!0),Y&&(g.current=!0,G&&(f=-z()))}if(i&&s==="next"&&(P==="slide"||P==="group"&&D.current===1)){const I=((U=e[a.current])==null?void 0:U.id)===e[e.length-1].id,G=L[e.length+a.current].id.includes("repeated-item");I&&(g.current=!0),G&&(a.current=0,p=R.value.get()+y()*e.length,g.current=!1,v.current=!0),f=-(a.current*y())}if(i&&s==="prev"&&(P==="slide"||P==="group"&&D.current===1)){const I=L.findIndex(be=>be.id===e[$].id),G=((H=e[a.current])==null?void 0:H.id)===e[0].id,Y=L[I-1].id.includes("repeated-item");G&&(v.current=!0),Y&&(v.current=!1,g.current=!0,a.current=e.length-1,p=R.value.get()-y()*e.length),f=-(a.current*y())}!i&&P==="slide"&&(((te=e[a.current+1])==null?void 0:te.id)===e[e.length-1].id?g.current=!0:a.current===0?v.current=!0:(v.current=!1,g.current=!1),f=-(a.current*y()),s==="next"&&Math.abs(f)>z()&&(g.current=!0,f=-z())),W({eventName:"onSlideStartChange",sliceActionType:l,slideDirection:s,nextItem:{index:a.current,id:e[a.current].id,startReached:v.current,endReached:g.current}})}if(t==="fluid"){if(s==="prev"&&(a.current=d??a.current-1),s==="next"&&(a.current=d??a.current+1),f=-(a.current*y()),s==="next"&&i){const $=((ue=e[a.current])==null?void 0:ue.id)===e[e.length-1].id,I=L[e.length+a.current].id.includes("repeated-item");$&&(g.current=!0),I&&(a.current=0,p=R.value.get()+y()*e.length,f=0,g.current=!1,v.current=!0)}if(s==="next"&&!i&&(Math.abs(f)>z()?(g.current=!0,f=-z()):(v.current=!1,g.current=!1)),s==="prev"&&!i&&((Be=e[a.current])==null?void 0:Be.id)===e[0].id&&(v.current=!0),s==="prev"&&i){const $=((Ge=e[a.current])==null?void 0:Ge.id)===e[0].id,I=(Ue=L[e.length+a.current])==null?void 0:Ue.id.includes("repeated-item");$&&(v.current=!0),I&&(a.current=e.length-1,p=R.value.get()-y()*e.length,f=-(y()*e.length-y()),v.current=!1,g.current=!0)}W({eventName:"onSlideStartChange",sliceActionType:l,slideDirection:s,nextItem:{startReached:v.current,endReached:g.current,index:0,id:""}})}if(t==="freeScroll"){const $=x.current[o==="x"?"scrollLeft":"scrollTop"],I=o==="x"?x.current.scrollWidth-x.current.clientWidth:x.current.scrollHeight-x.current.clientHeight;p=$,s==="prev"&&(f=p-y(),f<0&&(f=0),p-y()<=0&&(v.current=!0),W({eventName:"onSlideStartChange",sliceActionType:l,slideDirection:s,nextItem:{index:0,id:"",startReached:v.current,endReached:!1}})),s==="next"&&(f=p+y(),f>I&&(f=I),p+y()>=I&&(g.current=!0),W({eventName:"onSlideStartChange",sliceActionType:l,slideDirection:s,nextItem:{index:0,id:"",startReached:!1,endReached:g.current}}))}const N=K(p),j=K(f);oe.current=j,ce.start({from:{value:N},to:{value:j},immediate:!m,onRest({finished:$}){$&&t==="fixed"&&W({eventName:"onSlideChangeComplete",sliceActionType:l,slideDirection:s,currentItem:{index:a.current,id:e[a.current].id,startReached:v.current,endReached:g.current}}),$&&t==="fluid"&&W({eventName:"onSlideChangeComplete",sliceActionType:l,slideDirection:s,currentItem:{index:0,id:"",startReached:v.current,endReached:g.current}})}})}function ge(s,l,d=!0){if(!T){ee("Carousel not initialized yet: slideToNextItem");return}if(s==="drag"||t==="fixed"&&i||t==="fixed"&&!i&&!g.current){const m=l??a.current+1;ae({type:"next",actionType:s,newActiveItem:m,shouldAnimate:d})}(t==="fluid"&&i||t==="fluid"&&!i&&!g.current||t==="freeScroll"&&!g.current)&&ae({type:"next",actionType:s,shouldAnimate:d})}function me(s,l,d=!0){if(!T){ee("Carousel not initialized yet: slideToPrevItem");return}if(s==="drag"||t==="fixed"&&i||t==="fixed"&&!i&&!v.current){const m=l??a.current-1;ae({type:"prev",actionType:s,newActiveItem:m,shouldAnimate:d})}(t==="fluid"&&i||t==="fluid"&&!i&&!v.current||t==="freeScroll"&&!v.current)&&ae({type:"prev",actionType:s,shouldAnimate:d})}function ve(s,l=!0){let d=0;typeof s=="string"?d=e.findIndex(m=>m.id===s):d=s,d>a.current&&ge("click",d,l),d<a.current&&me("click",d,l)}function jt({getContainer:s,activeItem:l,updateTotalValue:d}){const m=s();if(!(m instanceof HTMLElement)){console.warn(`Container is not a valid html element: container is ${m}`);return}const f=m.children[l];if(f){const p=m[o==="x"?"scrollWidth":"scrollHeight"]-m.getBoundingClientRect()[o==="x"?"width":"height"],j=f.offsetLeft+f.offsetWidth/2-m.clientWidth/2,U=$t(f);if(U.isOut){const H=U.direction==="start"?j<0?0:j:j>p?p:j,te=m[o==="x"?"scrollLeft":"scrollTop"];new ye.Controller({from:{value:te},to:{value:d?d({from:te,to:H,itemOutOfViewport:U}):H},onChange({value:ue}){m[o==="x"?"scrollLeft":"scrollTop"]=ue.value}})}}}const Bt=Mt(s=>{if(!T){ee();return}const l=s.dragging,d=s.offset[o==="x"?0:1],m=s.movement[o==="x"?0:1],f=m>Z.current,p=m<-Z.current,N=s.velocity;l&&(W({...s,eventName:"onDrag",slideActionType:"drag"}),ce.start({value:d,immediate:!0,config:{velocity:N}}),h&&(f||p)&&s.cancel()),s.last&&(f?me("drag"):p?ge("drag"):ce.start({value:oe.current,config:{velocity:N}}))},{enabled:c&&t!=="freeScroll",axis:o,rubberband:!i,...i?{}:{bounds:()=>({right:0,left:-z(),top:-z(),bottom:0})},from:()=>[R.value.get(),R.value.get()]});return E.useEffect(()=>{function s(){document.hidden?(F.current=!0,C(!1)):(F.current=!1,C(!0))}function l(){if(x.current.style.top="0px",x.current.style.left="0px",!(t==="fixed"&&!i||t==="freeScroll"||t==="fluid"))if(t==="fixed"&&P==="group"&&D.current>1){const p=e.length*3/D.current;x.current.style[o==="x"?"left":"top"]=`calc(-${K(y()*p/3)}px)`}else x.current.style[o==="x"?"left":"top"]=`calc(-${K(y()*L.length/3)}px)`}function d(){m(),l(),ce.start({immediate:!0,value:-(a.current*y())})}function m(){const p=x.current.children[0];let N=0;const j=t==="fixed"&&P==="group"&&D.current>1;j?N=K(x.current.getBoundingClientRect()[o==="x"?"width":"height"]):N=K(p.getBoundingClientRect()[o==="x"?"width":"height"]);const{totalGutterCssVar:U,totalStartEndGutterCssVar:H}=pe();return N+=U,j&&(N-=H),Q.current=N,N}function f(){V.current=[];const{itemsPerSlide:p}=pe();if(console.log({_itemsPerSlide:p}),D.current=p,L.length===0&&Re("Init is true but no items are available; carousel will not be initialized"),t==="fixed"&&P==="group"&&e.length%D.current!==0&&V.current.push("When using scrollAmountType='group' and itemsPerSlide={number>1} make sure that itemsPerSlides is divisible by the total quantity of items otherwise the carousel won't initialize."),t==="fluid"&&_!==void 0&&V.current.push('scrollAmountType="group" is not available for slideType="fluid"; please change one of them.'),V.current.length>0){ee();return}m(),l(),Z.current=y()/4,C(!0)}if(typeof r=="function")r().then(p=>{if(p)return f(),u!==void 0&&t==="fixed"&&ve(u,!1),window.addEventListener("resize",d),document.addEventListener("visibilitychange",s),()=>{document.removeEventListener("visibilitychange",s),window.removeEventListener("resize",d)}});else{if(r)return f(),window.addEventListener("resize",d),document.addEventListener("visibilitychange",s),()=>{document.removeEventListener("visibilitychange",s),window.removeEventListener("resize",d)};C(!1)}},[Q,r,t,i,o]),E.useEffect(()=>{u!==void 0&&T&&t==="fixed"&&ve(u,!1)},[T,u]),{carouselFragment:A.jsxs(A.Fragment,{children:[A.jsx("style",{id:`carousel-container-${b}`,dangerouslySetInnerHTML:{__html:Vt(`
2
- :root {
3
- --${b}-react-spring-carousel-item-gutter: 0px;
4
- --${b}-react-spring-carousel-start-end-gutter: 0px;
5
- --${b}-react-spring-carousel-items-per-slide: 1;
6
- }
7
- .carousel-${b} {
1
+ (function(O,M){typeof exports=="object"&&typeof module<"u"?M(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"],M):(O=typeof globalThis<"u"?globalThis:O||self,M(O["react-spring-carousel"]={},O["react/jsx-runtime"],O["@react-spring/web"],O.React))})(this,function(O,M,we,y){"use strict";function Ee(r,e,t){return Math.max(e,Math.min(r,t))}const g={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 re(r,e,t){return e===0||Math.abs(e)===1/0?Math.pow(r,t*5):r*e*t/(e+t*r)}function ne(r,e,t,n=.15){return n===0?Ee(r,e,t):r<e?-re(e-r,t-e,n)+e:r>t?+re(r-t,t-e,n)+t:r}function Te(r,[e,t],[n,s]){const[[i,c],[a,u]]=r;return[ne(e,i,c,n),ne(t,a,u,s)]}function xe(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 Se(r){var e=xe(r,"string");return typeof e=="symbol"?e:String(e)}function _(r,e,t){return e=Se(e),e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function se(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 l(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?se(Object(t),!0).forEach(function(n){_(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):se(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}const ie={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 oe(r){return r?r[0].toUpperCase()+r.slice(1):""}const Ie=["enter","leave"];function De(r=!1,e){return r&&!Ie.includes(e)}function ke(r,e="",t=!1){const n=ie[r],s=n&&n[e]||e;return"on"+oe(r)+oe(s)+(De(t,s)?"Capture":"")}const Ce=["gotpointercapture","lostpointercapture"];function Oe(r){let e=r.substring(2).toLowerCase();const t=!!~e.indexOf("passive");t&&(e=e.replace("passive",""));const n=Ce.includes(e)?"capturecapture":"capture",s=!!~e.indexOf(n);return s&&(e=e.replace("capture","")),{device:e,capture:s,passive:t}}function Ae(r,e=""){const t=ie[r],n=t&&t[e]||e;return r+n}function B(r){return"touches"in r}function ae(r){return B(r)?"touch":"pointerType"in r?r.pointerType:"mouse"}function Pe(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 Me(r){return r.type==="touchend"||r.type==="touchcancel"?r.changedTouches:r.targetTouches}function ce(r){return B(r)?Me(r)[0]:r}function $e(r){return Pe(r).map(e=>e.identifier)}function X(r){const e=ce(r);return B(r)?e.identifier:e.pointerId}function ue(r){const e=ce(r);return[e.clientX,e.clientY]}function Ne(r){const e={};if("buttons"in r&&(e.buttons=r.buttons),"shiftKey"in r){const{shiftKey:t,altKey:n,metaKey:s,ctrlKey:i}=r;Object.assign(e,{shiftKey:t,altKey:n,metaKey:s,ctrlKey:i})}return e}function z(r,...e){return typeof r=="function"?r(...e):r}function Le(){}function Re(...r){return r.length===0?Le:r.length===1?r[0]:function(){let e;for(const t of r)e=t.apply(this,arguments)||e;return e}}function fe(r,e){return Object.assign({},e,r||{})}const Ve=32;class je{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?z(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 i=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,Ne(e)),s.down=s.pressed=s.buttons%2===1||s.touches>0,i=e.timeStamp-t.timeStamp,t.timeStamp=e.timeStamp,t.elapsedTime=t.timeStamp-t.startTime),t._active){const D=t._delta.map(Math.abs);g.addTo(t._distance,D)}this.axisIntent&&this.axisIntent(e);const[c,a]=t._movement,[u,p]=n.threshold,{_step:f,values:x}=t;if(n.hasCustomTransform?(f[0]===!1&&(f[0]=Math.abs(c)>=u&&x[0]),f[1]===!1&&(f[1]=Math.abs(a)>=p&&x[1])):(f[0]===!1&&(f[0]=Math.abs(c)>=u&&Math.sign(c)*u),f[1]===!1&&(f[1]=Math.abs(a)>=p&&Math.sign(a)*p)),t.intentional=f[0]!==!1||f[1]!==!1,!t.intentional)return;const v=[0,0];if(n.hasCustomTransform){const[D,Q]=x;v[0]=f[0]!==!1?D-f[0]:0,v[1]=f[1]!==!1?Q-f[1]:0}else v[0]=f[0]!==!1?c-f[0]:0,v[1]=f[1]!==!1?a-f[1]:0;this.restrictToAxis&&!t._blocked&&this.restrictToAxis(v);const $=t.offset,A=t._active&&!t._blocked||t.active;A&&(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=z(n.bounds,t)),this.setup&&this.setup()),t.movement=v,this.computeOffset()));const[S,N]=t.offset,[[I,P],[U,d]]=t._bounds;t.overflow=[S<I?-1:S>P?1:0,N<U?-1:N>d?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 R=t._active?n.rubberband||[0,0]:[0,0];if(t.offset=Te(t._bounds,t.offset,R),t.delta=g.sub(t.offset,$),this.computeMovement(),A&&(!t.last||i>Ve)){t.delta=g.sub(t.offset,$);const D=t.delta.map(Math.abs);g.addTo(t.distance,D),t.direction=t.delta.map(Math.sign),t._direction=t._delta.map(Math.sign),!t.first&&i>0&&(t.velocity=[D[0]/i,D[1]/i],t.timeDelta=i)}}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(l(l(l({},t),e),{},{[this.aliasKey]:e.values}));s!==void 0&&(e.memo=s)}clean(){this.eventStore.clean(),this.timeoutStore.clean()}}function Ue([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 Ke extends je{constructor(...e){super(...e),_(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=g.add(this.state.lastOffset,this.state.movement)}computeMovement(){this.state.movement=g.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[ae(e)]:n.axisThreshold;t.axis=Ue(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 le=r=>r,de=.15,q={enabled(r=!0){return r},eventOptions(r,e,t){return l(l({},t.shared.eventOptions),r)},preventDefault(r=!1){return r},triggerAllEvents(r=!1){return r},rubberband(r=0){switch(r){case!0:return[de,de];case!1:return[0,0];default:return g.toVector(r)}},from(r){if(typeof r=="function")return r;if(r!=null)return g.toVector(r)},transform(r,e,t){const n=r||t.shared.transform;if(this.hasCustomTransform=!!n,process.env.NODE_ENV==="development"){const s=n||le;return i=>{const c=s(i);return(!isFinite(c[0])||!isFinite(c[1]))&&console.warn(`[@use-gesture]: config.transform() must produce a valid result, but it was: [${c[0]},${[1]}]`),c}}return n||le},threshold(r){return g.toVector(r,0)}};process.env.NODE_ENV==="development"&&Object.assign(q,{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 Be=0,V=l(l({},q),{},{axis(r,e,{axis:t}){if(this.lockDirection=t==="lock",!this.lockDirection)return t},axisThreshold(r=Be){return r},bounds(r={}){if(typeof r=="function")return i=>V.bounds(r(i));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]]}}),he={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 ze extends Ke{constructor(...e){super(...e),_(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=V.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=X(e),n._pointerActive=!0,this.computeValues(ue(e)),this.computeInitial(),t.preventScrollAxis&&ae(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=X(e);if(t._pointerId!==void 0&&s!==t._pointerId)return;const i=ue(e);if(document.pointerLockElement===e.target?t._delta=[e.movementX,e.movementY]:(t._delta=g.sub(i,t._values),this.computeValues(i)),g.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=X(e);if(t._pointerId!==void 0&&s!==t._pointerId)return;this.state._pointerActive=!1,this.setActive(),this.compute(e);const[i,c]=t._distance;if(t.tap=i<=n.tapsThreshold&&c<=n.tapsThreshold,t.tap&&n.filterTaps)t._force=!0;else{const[a,u]=t._delta,[p,f]=t._movement,[x,v]=n.swipe.velocity,[$,A]=n.swipe.distance,S=n.swipe.duration;if(t.elapsedTime<S){const N=Math.abs(a/t.timeDelta),I=Math.abs(u/t.timeDelta);N>x&&Math.abs(p)>$&&(t.swipe[0]=Math.sign(a)),I>v&&Math.abs(f)>A&&(t.swipe[1]=Math.sign(u))}}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,Ye(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=he[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,g.addTo(n._movement,n._delta),this.compute(e),this.emit()}}keyUp(e){e.key in he&&(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 Ye(r){"persist"in r&&typeof r.persist=="function"&&r.persist()}const j=typeof window<"u"&&window.document&&window.document.createElement;function pe(){return j&&"ontouchstart"in window}function We(){return pe()||j&&window.navigator.maxTouchPoints>1}function Fe(){return j&&"onpointerdown"in window}function He(){return j&&"exitPointerLock"in window.document}function Xe(){try{return"constructor"in GestureEvent}catch{return!1}}const T={isBrowser:j,gesture:Xe(),touch:pe(),touchscreen:We(),pointer:Fe(),pointerLock:He()},qe=250,Ge=180,Je=.5,Qe=50,Ze=250,et=10,me={mouse:0,touch:0,pen:8},ge=l(l({},V),{},{device(r,e,{pointer:{touch:t=!1,lock:n=!1,mouse:s=!1}={}}){return this.pointerLock=n&&T.pointerLock,T.touch&&t?"touch":this.pointerLock?"mouse":T.pointer&&!s?"pointer":T.touch?"touch":"mouse"},preventScrollAxis(r,e,{preventScroll:t}){if(this.preventScrollDelay=typeof t=="number"?t:t||t===void 0&&r?qe:void 0,!(!T.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 i=g.toVector(r,t?n:s?1:0);return this.filterTaps=t,this.tapsThreshold=n,i},swipe({velocity:r=Je,distance:e=Qe,duration:t=Ze}={}){return{velocity:this.transform(g.toVector(r)),distance:this.transform(g.toVector(e)),duration:t}},delay(r=0){switch(r){case!0:return Ge;case!1:return 0;default:return r}},axisThreshold(r){return r?l(l({},me),r):me},keyboardDisplacement(r=et){return r}});process.env.NODE_ENV==="development"&&Object.assign(ge,{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}}),l(l({},q),{},{device(r,e,{shared:t,pointer:{touch:n=!1}={}}){if(t.target&&!T.touch&&T.gesture)return"gesture";if(T.touch&&n)return"touch";if(T.touchscreen){if(T.pointer)return"pointer";if(T.touch)return"touch"}},bounds(r,e,{scaleBounds:t={},angleBounds:n={}}){const s=c=>{const a=fe(z(t,c),{min:-1/0,max:1/0});return[a.min,a.max]},i=c=>{const a=fe(z(n,c),{min:-1/0,max:1/0});return[a.min,a.max]};return typeof t!="function"&&typeof n!="function"?[s(),i()]:c=>[s(c),i(c)]},threshold(r,e,t){return this.lockDirection=t.axis==="lock",g.toVector(r,this.lockDirection?[.1,3]:0)},modifierKey(r){return r===void 0?"ctrlKey":r},pinchOnWheel(r=!0){return r}}),l(l({},V),{},{mouseOnly:(r=!0)=>r}),l(l({},V),{},{mouseOnly:(r=!0)=>r});const ve=new Map,G=new Map;function tt(r){ve.set(r.key,r.engine),G.set(r.key,r.resolver)}const rt={key:"drag",engine:ze,resolver:ge};function nt(r,e){if(r==null)return{};var t={},n=Object.keys(r),s,i;for(i=0;i<n.length;i++)s=n[i],!(e.indexOf(s)>=0)&&(t[s]=r[s]);return t}function st(r,e){if(r==null)return{};var t=nt(r,e),n,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(r);for(s=0;s<i.length;s++)n=i[s],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(r,n)&&(t[n]=r[n])}return t}const it={target(r){if(r)return()=>"current"in r?r.current:r},enabled(r=!0){return r},window(r=T.isBrowser?window:void 0){return r},eventOptions({passive:r=!0,capture:e=!1}={}){return{passive:r,capture:e}},transform(r){return r}},ot=["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 i=s.call(t,r[n],n,r);Number.isNaN(i)||(t[n]=i)}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 at(r,e,t={}){const n=r,{target:s,eventOptions:i,window:c,enabled:a,transform:u}=n,p=st(n,ot);if(t.shared=Y({target:s,eventOptions:i,window:c,enabled:a,transform:u},it),e){const f=G.get(e);t[e]=Y(l({shared:t.shared},p),f)}else for(const f in p){const x=G.get(f);if(x)t[f]=Y(l({shared:t.shared},p[f]),x);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 ye{constructor(e,t){_(this,"_listeners",new Set),this._ctrl=e,this._gestureKey=t}add(e,t,n,s,i){const c=this._listeners,a=Ae(t,n),u=this._gestureKey?this._ctrl.config[this._gestureKey].eventOptions:{},p=l(l({},u),i);e.addEventListener(a,s,p);const f=()=>{e.removeEventListener(a,s,p),c.delete(f)};return c.add(f),f}clean(){this._listeners.forEach(e=>e()),this._listeners.clear()}}class ct{constructor(){_(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 ut{constructor(e){_(this,"gestures",new Set),_(this,"_targetEventStore",new ye(this)),_(this,"gestureEventStores",{}),_(this,"gestureTimeoutStores",{}),_(this,"handlers",{}),_(this,"config",{}),_(this,"pointerIds",new Set),_(this,"touchIds",new Set),_(this,"state",{shared:{shiftKey:!1,metaKey:!1,ctrlKey:!1,altKey:!1}}),ft(this,e)}setEventIds(e){if(B(e))return this.touchIds=new Set($e(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 c of this.gestures){const a=this.config[c],u=_e(n,a.eventOptions,!!s);if(a.enabled){const p=ve.get(c);new p(this,e,c).bind(u)}}const i=_e(n,t.eventOptions,!!s);for(const c in this.nativeHandlers)i(c,"",a=>this.nativeHandlers[c](l(l({},this.state.shared),{},{event:a,args:e})),void 0,!0)}for(const i in n)n[i]=Re(...n[i]);if(!s)return n;for(const i in n){const{device:c,capture:a,passive:u}=Oe(i);this._targetEventStore.add(s,c,"",n[i],{capture:a,passive:u})}}}}function L(r,e){r.gestures.add(e),r.gestureEventStores[e]=new ye(r,e),r.gestureTimeoutStores[e]=new ct}function ft(r,e){e.drag&&L(r,"drag"),e.wheel&&L(r,"wheel"),e.scroll&&L(r,"scroll"),e.move&&L(r,"move"),e.pinch&&L(r,"pinch"),e.hover&&L(r,"hover")}const _e=(r,e,t)=>(n,s,i,c={},a=!1)=>{var u,p;const f=(u=c.capture)!==null&&u!==void 0?u:e.capture,x=(p=c.passive)!==null&&p!==void 0?p:e.passive;let v=a?n:ke(n,s,f);t&&x&&(v+="Passive"),r[v]=r[v]||[],r[v].push(i)};function lt(r,e={},t,n){const s=y.useMemo(()=>new ut(r),[]);if(s.applyHandlers(r,n),s.applyConfig(e,t),y.useEffect(s.effect.bind(s)),y.useEffect(()=>s.clean.bind(s),[]),e.target===void 0)return s.bind.bind(s)}function dt(r,e){return tt(rt),lt({drag:r},e||{},"drag")}const J="RSC::Event";function ht(){const r=y.useRef(null);function e(n){y.useEffect(()=>{r.current||(r.current=document.createElement("div"));function s(i){n(i.detail)}if(r.current)return r.current.addEventListener(J,s,!1),()=>{var i;(i=r.current)==null||i.removeEventListener(J,s,!1)}},[n])}function t(n){if(r.current){const s=new CustomEvent(J,{detail:n});r.current.dispatchEvent(s)}}return{useListenToCustomEvent:e,emitEvent:t}}function pt({init:r=!0,items:e,withLoop:t=!1,id:n,itemsPerSlide:s=1,gutter:i=0,startEndGutter:c=0,carouselAxis:a="x",slideType:u="fixed",startingPosition:p="start",enableGestures:f=!0,slideWhenDragThresholdIsReached:x=!0,onInit:v}){const $=y.useRef(r),A=y.useRef(null),S=y.useRef(null),N=y.useRef(0),I=y.useRef(!t),P=y.useRef(!1),U=y.useRef(0),d=y.useRef(0),[R,D]=we.useSpring(()=>({value:0,onChange({value:o}){(u==="fixed"||u==="fluid")&&A.current.style.setProperty(`--${n}-offset-position`,`${o.value}px`),u==="freeScroll"&&(S.current[a==="x"?"scrollLeft":"scrollTop"]=Math.abs(o.value))}}),[a]),Q=u!=="freeScroll"&&t?[...e.map(o=>({...o,id:`prev-repeated-item-${o.id}`})),...e,...e.map(o=>({...o,id:`next-repeated-item-${o.id}`}))]:e,{useListenToCustomEvent:be,emitEvent:W}=ht();function Z(o){$.current&&(P.current||K({type:"next",toIndex:o,actionType:"click"}))}function ee(o){$.current&&(I.current||K({type:"prev",toIndex:o,actionType:"click"}))}function K({type:o,shouldAnimate:m=!0,toIndex:k,actionType:w}){const h=F(),H=!m;I.current=!1,P.current=!1;let C=R.value.get(),b=0;if(o==="next"&&(d.current+=1),o==="prev"&&(d.current-=1),k!==void 0&&(d.current=k),u!=="freeScroll"&&o==="next"){const E=te(t?h*(e.length*2):0);b=-(d.current*h),E-Math.abs(b)<h/1.2&&u==="fluid"&&!t&&(b=-E),!t&&Math.abs(b)>=E&&(P.current=!0,b=-E),t&&d.current===e.length&&(d.current=0,C=C+h*e.length,b=0)}if(u!=="freeScroll"&&o==="prev"&&(b=-(d.current*h),!t&&b>=0&&(I.current=!0,b=0),t&&d.current<0&&Math.abs(d.current)===e.length/2&&(C=C-h*e.length,b=-(Math.abs(d.current)*h),d.current=e.length/2)),u==="freeScroll"&&o==="next"){const E=S.current[a==="x"?"scrollLeft":"scrollTop"];C=E,b=E+h}if(u==="freeScroll"&&o==="prev"){const E=S.current[a==="x"?"scrollLeft":"scrollTop"];C=E,b=E-h}N.current=b,W(w==="resize"?{eventName:"onResize",sliceActionType:w,slideDirection:o,currentItem:{index:d.current,id:e[d.current].id,startReached:I.current,endReached:P.current}}:{eventName:"onSlideStartChange",sliceActionType:w,slideDirection:o,nextItem:{index:d.current,id:e[d.current].id,startReached:I.current,endReached:P.current}}),D.start({immediate:H,from:{value:C},to:{value:b},onRest({finished:E}){E&&u==="fixed"&&W({eventName:"onSlideChangeComplete",sliceActionType:w,slideDirection:o,currentItem:{index:d.current,id:e[d.current].id,startReached:I.current,endReached:P.current}}),E&&u==="fluid"&&W({eventName:"onSlideChangeComplete",sliceActionType:w,slideDirection:o,currentItem:{index:0,id:"",startReached:I.current,endReached:P.current}})}})}function F(){const o=S.current.children[0];let m=0;return m=o.getBoundingClientRect()[a==="x"?"width":"height"]+i,m}function te(o){const m=S.current;return m[a==="x"?"scrollWidth":"scrollHeight"]-m.getBoundingClientRect()[a==="x"?"width":"height"]-o}y.useEffect(()=>{function o(w,h){switch(w){case"start":return 0;case"middle-start":return Math.floor((h-1)*.25);case"center":return Math.floor((h-1)*.5);case"middle-end":return Math.floor((h-1)*.75);case"end":return h-1;default:return 0}}function m(w){if(A.current){let h=0;t&&(h=F()*e.length),h-=F()*o(p,s),h-=c,A.current.style.setProperty(`--${n}-offset-modifier`,`${-h}px`),w&&w()}}function k(){m(),K({type:"next",toIndex:d.current,shouldAnimate:!1,actionType:"resize"})}if(r&&(U.current=F()/4),r&&u==="fixed")return m(v),window.addEventListener("resize",k),()=>{window.removeEventListener("resize",k)}},[r,t,n,a,i,p,u]);const mt=dt(o=>{if(!$.current)return;const m=o.dragging,k=o.offset[a==="x"?0:1],w=o.movement[a==="x"?0:1],h=w>U.current,H=w<-U.current,C=o.velocity;m&&(D.start({value:k,immediate:!0,config:{velocity:C}}),x&&(h||H)&&o.cancel()),o.last&&(h?K({actionType:"drag",type:"prev"}):H?K({actionType:"drag",type:"next"}):D.start({value:N.current,config:{velocity:C}}))},{enabled:f&&u!=="freeScroll",axis:a,rubberband:!t,...t?{}:{bounds:()=>({right:0,left:-te(0),top:-te(0),bottom:0})},from:()=>[R.value.get(),R.value.get()]});return{carouselFragment:M.jsxs("div",{ref:A,className:"ReactSpringCarouselContainer","data-part":"Container","data-part-internal":`${n}-Container`,children:[M.jsx("style",{dangerouslySetInnerHTML:{__html:`
2
+ [data-part-internal="${n}-Container"] {
8
3
  display: flex;
9
- overflow: hidden;
10
4
  width: 100%;
11
5
  height: 100%;
12
- padding: ${o==="x"?`0px var(--${b}-react-spring-carousel-start-end-gutter)`:`var(--${b}-react-spring-carousel-start-end-gutter) 0px`};
6
+ overflow: hidden;
7
+ --${n}-gutter: ${i}px;
8
+ --${n}-items-per-slide: ${s};
9
+ --${n}-offset-position: 0px;
10
+ --${n}-offset-modifier: 0px;
11
+ --${n}-scroll-x-value: ${u!=="freeScroll"&&a==="x"?`calc(var(--${n}-offset-position) + var(--${n}-offset-modifier))`:"0px"};
12
+ --${n}-scroll-y-value: ${u!=="freeScroll"&&a==="y"?`calc(var(--${n}-offset-position) + var(--${n}-offset-modifier))`:"0px"};
13
+ --${n}-start-end-gutter: ${c*2}px;
13
14
  }
14
- .carousel-${b} .use-spring-carousel-track {
15
+ [data-part-internal="${n}-Track"] {
15
16
  display: flex;
17
+ flex-direction: ${a==="x"?"row":"column"};
16
18
  width: 100%;
17
- position: relative;
18
- flex-direction: ${o==="x"?"row":"column"};
19
- gap: var(--${b}-react-spring-carousel-item-gutter);
20
-
21
- --initial-active-item: ${u||0};
22
- --offset-position: calc(var(--item-scroll-value) * var(--initial-active-item));
23
- --scroll-x-value: ${t==="fixed"&&o==="x"?"var(--offset-position)":"0px"};
24
- --scroll-y-value: ${t==="fixed"&&o==="y"?"var(--offset-position)":"0px"};
25
-
26
- transform: translate3d(var(--scroll-x-value), var(--scroll-y-value), 0px);
27
- touch-action: ${c?o==="x"?"pan-y":"pan-x":"auto"};
28
- overflow-x: ${t==="freeScroll"&&o==="x"?"auto":"initial"};
29
- overflow-y: ${t==="freeScroll"&&o==="y"?"auto":"initial"};
30
- }
31
- .carousel-${b} .use-spring-carousel-track::after {
32
- content: "";
33
- visibility: hidden;
34
- display: block;
35
- width: var(--${b}-react-spring-carousel-start-end-gutter);
36
- flex-shrink: 0;
19
+ height: 100%;
20
+ gap: var(--${n}-gutter);
21
+ transform: translate3d(var(--${n}-scroll-x-value), var(--${n}-scroll-y-value), 0px);
22
+ overflow-x: ${u==="freeScroll"?"auto":"visible"};
23
+ touch-action: ${f?a==="x"?"pan-y":"pan-x":"auto"};
37
24
  }
38
- .carousel-${b} .use-spring-carousel-item {
39
- position: relative;
25
+ [data-part-internal="${n}-Item"] {
40
26
  display: flex;
41
- width: 100%;
42
- height: 100%;
43
- ${t==="fixed"?`flex: 0 0 calc(100% / var(--${b}-react-spring-carousel-items-per-slide) - calc(var(--${b}-react-spring-carousel-item-gutter) * (var(--${b}-react-spring-carousel-items-per-slide) - 1) / var(--${b}-react-spring-carousel-items-per-slide)));`:""}
27
+ flex: ${u==="fixed"?`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)))`:"1"};
44
28
  }
45
- ${S?`.carousel-${b} .use-spring-carousel-item {
46
- position: absolute;
47
- top: 0;
48
- left: 0;
49
- width: 100%;
50
- height: 100%;
51
- opacity: 0;
52
- }
53
- .carousel-${b} .use-spring-carousel-item:first-child {
54
- opacity: 1;
55
- }`.trim():""}`)}}),A.jsx("div",{className:`use-spring-carousel-container carousel-${b}`,ref:se,"data-carousel-direction":o,children:A.jsx("div",{className:"use-spring-carousel-track",...Bt(),...Rt(),ref:s=>{if(x.current=s,s){const l=s.children[0];l&&s.style.setProperty("--item-scroll-value",`-${l.getBoundingClientRect().width}px`)}},children:L.map((s,l)=>A.jsx("div",{className:"use-spring-carousel-item",id:s.id,children:typeof s.renderItem=="function"?s.renderItem({useListenToCustomEvent:je,index:l}):s.renderItem},`${s.id}-${l}`))})})]}),useListenToCustomEvent:je,slideToNextItem:()=>ge("click"),slideToPrevItem:()=>me("click"),slideToIem:(s,l=!0)=>{if(!T){ee();return}ve(s,l)},handleThumbsContainerScroll:jt,carouselId:b}}B.useSpringCarousel=At,Object.defineProperty(B,Symbol.toStringTag,{value:"Module"})});
29
+ `}}),M.jsx("div",{ref:S,className:"ReactSpringCarouselTrack","data-part":"Track","data-part-internal":`${n}-Track`,...mt(),...u==="freeScroll"?{onWheel(){R.value.stop()}}:{},children:Q.map((o,m)=>M.jsx("div",{className:"ReactSpringCarouselItem","data-part":"Item","data-part-internal":`${n}-Item`,children:typeof o.renderItem=="function"?o.renderItem({useListenToCustomEvent:be,index:m}):o.renderItem},`${o.id}-${m}`))})]}),useListenToCustomEvent:be,slideToNextItem:()=>Z(),slideToPrevItem:()=>ee(),slideToItem:o=>{if(typeof o=="number"){if(!e[o]){console.warn(`The item you're trying to slide doesn't exist. index: ${o}`);return}o>d.current?Z(o):ee(o)}if(typeof o=="string"){const m=e.findIndex(k=>k.id===o);if(m<0){console.warn(`The item you're trying to slide doesn't exist. id: ${o}`);return}m>d.current?Z(m):ee(m)}}}}O.useSpringCarousel=pt,Object.defineProperty(O,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-1.0.422",
3
+ "version": "3.0.0-beta-2.0.1",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.umd.js",
package/README.md DELETED
@@ -1,50 +0,0 @@
1
- # React + TypeScript + Vite
2
-
3
- This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
4
-
5
- Currently, two official plugins are available:
6
-
7
- - [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
8
- - [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
9
-
10
- ## Expanding the ESLint configuration
11
-
12
- If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:
13
-
14
- - Configure the top-level `parserOptions` property like this:
15
-
16
- ```js
17
- export default tseslint.config({
18
- languageOptions: {
19
- // other options...
20
- parserOptions: {
21
- project: ['./tsconfig.node.json', './tsconfig.app.json'],
22
- tsconfigRootDir: import.meta.dirname,
23
- },
24
- },
25
- })
26
- ```
27
-
28
- - Replace `tseslint.configs.recommended` to `tseslint.configs.recommendedTypeChecked` or `tseslint.configs.strictTypeChecked`
29
- - Optionally add `...tseslint.configs.stylisticTypeChecked`
30
- - Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and update the config:
31
-
32
- ```js
33
- // eslint.config.js
34
- import react from 'eslint-plugin-react'
35
-
36
- export default tseslint.config({
37
- // Set the react version
38
- settings: { react: { version: '18.3' } },
39
- plugins: {
40
- // Add the react plugin
41
- react,
42
- },
43
- rules: {
44
- // other rules...
45
- // Enable its recommended rules
46
- ...react.configs.recommended.rules,
47
- ...react.configs['jsx-runtime'].rules,
48
- },
49
- })
50
- ```