react-spring-carousel 3.0.0-beta-1.0.422 → 3.0.0-beta-2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +20 -87
- package/dist/index.es.js +683 -1008
- package/dist/index.umd.js +20 -46
- package/package.json +1 -1
- package/README.md +0 -50
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
|
-
|
|
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,P){typeof exports=="object"&&typeof module<"u"?P(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"],P):(O=typeof globalThis<"u"?globalThis:O||self,P(O["react-spring-carousel"]={},O["react/jsx-runtime"],O["@react-spring/web"],O.React))})(this,function(O,P,vt,w){"use strict";function yt(r,t,e){return Math.max(t,Math.min(r,e))}const m={toVector(r,t){return r===void 0&&(r=t),Array.isArray(r)?r:[r,r]},add(r,t){return[r[0]+t[0],r[1]+t[1]]},sub(r,t){return[r[0]-t[0],r[1]-t[1]]},addTo(r,t){r[0]+=t[0],r[1]+=t[1]},subTo(r,t){r[0]-=t[0],r[1]-=t[1]}};function Z(r,t,e){return t===0||Math.abs(t)===1/0?Math.pow(r,e*5):r*t*e/(t+e*r)}function tt(r,t,e,n=.15){return n===0?yt(r,t,e):r<t?-Z(t-r,e-t,n)+t:r>e?+Z(r-e,e-t,n)+e:r}function _t(r,[t,e],[n,s]){const[[i,c],[o,u]]=r;return[tt(t,i,c,n),tt(e,o,u,s)]}function bt(r,t){if(typeof r!="object"||r===null)return r;var e=r[Symbol.toPrimitive];if(e!==void 0){var n=e.call(r,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(r)}function wt(r){var t=bt(r,"string");return typeof t=="symbol"?t:String(t)}function _(r,t,e){return t=wt(t),t in r?Object.defineProperty(r,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):r[t]=e,r}function et(r,t){var e=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);t&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(r,s).enumerable})),e.push.apply(e,n)}return e}function l(r){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?et(Object(e),!0).forEach(function(n){_(r,n,e[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(e)):et(Object(e)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(e,n))})}return r}const rt={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 nt(r){return r?r[0].toUpperCase()+r.slice(1):""}const Et=["enter","leave"];function Tt(r=!1,t){return r&&!Et.includes(t)}function xt(r,t="",e=!1){const n=rt[r],s=n&&n[t]||t;return"on"+nt(r)+nt(s)+(Tt(e,s)?"Capture":"")}const St=["gotpointercapture","lostpointercapture"];function Dt(r){let t=r.substring(2).toLowerCase();const e=!!~t.indexOf("passive");e&&(t=t.replace("passive",""));const n=St.includes(t)?"capturecapture":"capture",s=!!~t.indexOf(n);return s&&(t=t.replace("capture","")),{device:t,capture:s,passive:e}}function It(r,t=""){const e=rt[r],n=e&&e[t]||t;return r+n}function K(r){return"touches"in r}function st(r){return K(r)?"touch":"pointerType"in r?r.pointerType:"mouse"}function kt(r){return Array.from(r.touches).filter(t=>{var e,n;return t.target===r.currentTarget||((e=r.currentTarget)===null||e===void 0||(n=e.contains)===null||n===void 0?void 0:n.call(e,t.target))})}function Ot(r){return r.type==="touchend"||r.type==="touchcancel"?r.changedTouches:r.targetTouches}function it(r){return K(r)?Ot(r)[0]:r}function Ct(r){return kt(r).map(t=>t.identifier)}function H(r){const t=it(r);return K(r)?t.identifier:t.pointerId}function ot(r){const t=it(r);return[t.clientX,t.clientY]}function Pt(r){const t={};if("buttons"in r&&(t.buttons=r.buttons),"shiftKey"in r){const{shiftKey:e,altKey:n,metaKey:s,ctrlKey:i}=r;Object.assign(t,{shiftKey:e,altKey:n,metaKey:s,ctrlKey:i})}return t}function B(r,...t){return typeof r=="function"?r(...t):r}function At(){}function $t(...r){return r.length===0?At:r.length===1?r[0]:function(){let t;for(const e of r)t=e.apply(this,arguments)||t;return t}}function at(r,t){return Object.assign({},t,r||{})}const Mt=32;class Nt{constructor(t,e,n){this.ctrl=t,this.args=e,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(t){this.ctrl.state[this.key]=t}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:t,shared:e,ingKey:n,args:s}=this;e[n]=t._active=t.active=t._blocked=t._force=!1,t._step=[!1,!1],t.intentional=!1,t._movement=[0,0],t._distance=[0,0],t._direction=[0,0],t._delta=[0,0],t._bounds=[[-1/0,1/0],[-1/0,1/0]],t.args=s,t.axis=void 0,t.memo=void 0,t.elapsedTime=t.timeDelta=0,t.direction=[0,0],t.distance=[0,0],t.overflow=[0,0],t._movementBound=[!1,!1],t.velocity=[0,0],t.movement=[0,0],t.delta=[0,0],t.timeStamp=0}start(t){const e=this.state,n=this.config;e._active||(this.reset(),this.computeInitial(),e._active=!0,e.target=t.target,e.currentTarget=t.currentTarget,e.lastOffset=n.from?B(n.from,e):e.offset,e.offset=e.lastOffset,e.startTime=e.timeStamp=t.timeStamp)}computeValues(t){const e=this.state;e._values=t,e.values=this.config.transform(t)}computeInitial(){const t=this.state;t._initial=t._values,t.initial=t.values}compute(t){const{state:e,config:n,shared:s}=this;e.args=this.args;let i=0;if(t&&(e.event=t,n.preventDefault&&t.cancelable&&e.event.preventDefault(),e.type=t.type,s.touches=this.ctrl.pointerIds.size||this.ctrl.touchIds.size,s.locked=!!document.pointerLockElement,Object.assign(s,Pt(t)),s.down=s.pressed=s.buttons%2===1||s.touches>0,i=t.timeStamp-e.timeStamp,e.timeStamp=t.timeStamp,e.elapsedTime=e.timeStamp-e.startTime),e._active){const S=e._delta.map(Math.abs);m.addTo(e._distance,S)}this.axisIntent&&this.axisIntent(t);const[c,o]=e._movement,[u,h]=n.threshold,{_step:f,values:T}=e;if(n.hasCustomTransform?(f[0]===!1&&(f[0]=Math.abs(c)>=u&&T[0]),f[1]===!1&&(f[1]=Math.abs(o)>=h&&T[1])):(f[0]===!1&&(f[0]=Math.abs(c)>=u&&Math.sign(c)*u),f[1]===!1&&(f[1]=Math.abs(o)>=h&&Math.sign(o)*h)),e.intentional=f[0]!==!1||f[1]!==!1,!e.intentional)return;const y=[0,0];if(n.hasCustomTransform){const[S,G]=T;y[0]=f[0]!==!1?S-f[0]:0,y[1]=f[1]!==!1?G-f[1]:0}else y[0]=f[0]!==!1?c-f[0]:0,y[1]=f[1]!==!1?o-f[1]:0;this.restrictToAxis&&!e._blocked&&this.restrictToAxis(y);const A=e.offset,C=e._active&&!e._blocked||e.active;C&&(e.first=e._active&&!e.active,e.last=!e._active&&e.active,e.active=s[this.ingKey]=e._active,t&&(e.first&&("bounds"in n&&(e._bounds=B(n.bounds,e)),this.setup&&this.setup()),e.movement=y,this.computeOffset()));const[x,$]=e.offset,[[M,R],[U,v]]=e._bounds;e.overflow=[x<M?-1:x>R?1:0,$<U?-1:$>v?1:0],e._movementBound[0]=e.overflow[0]?e._movementBound[0]===!1?e._movement[0]:e._movementBound[0]:!1,e._movementBound[1]=e.overflow[1]?e._movementBound[1]===!1?e._movement[1]:e._movementBound[1]:!1;const L=e._active?n.rubberband||[0,0]:[0,0];if(e.offset=_t(e._bounds,e.offset,L),e.delta=m.sub(e.offset,A),this.computeMovement(),C&&(!e.last||i>Mt)){e.delta=m.sub(e.offset,A);const S=e.delta.map(Math.abs);m.addTo(e.distance,S),e.direction=e.delta.map(Math.sign),e._direction=e._delta.map(Math.sign),!e.first&&i>0&&(e.velocity=[S[0]/i,S[1]/i],e.timeDelta=i)}}emit(){const t=this.state,e=this.shared,n=this.config;if(t._active||this.clean(),(t._blocked||!t.intentional)&&!t._force&&!n.triggerAllEvents)return;const s=this.handler(l(l(l({},e),t),{},{[this.aliasKey]:t.values}));s!==void 0&&(t.memo=s)}clean(){this.eventStore.clean(),this.timeoutStore.clean()}}function Lt([r,t],e){const n=Math.abs(r),s=Math.abs(t);if(n>s&&n>e)return"x";if(s>n&&s>e)return"y"}class Vt extends Nt{constructor(...t){super(...t),_(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=m.add(this.state.lastOffset,this.state.movement)}computeMovement(){this.state.movement=m.sub(this.state.offset,this.state.lastOffset)}axisIntent(t){const e=this.state,n=this.config;if(!e.axis&&t){const s=typeof n.axisThreshold=="object"?n.axisThreshold[st(t)]:n.axisThreshold;e.axis=Lt(e._movement,s)}e._blocked=(n.lockDirection||!!n.axis)&&!e.axis||!!n.axis&&n.axis!==e.axis}restrictToAxis(t){if(this.config.axis||this.config.lockDirection)switch(this.state.axis){case"x":t[1]=0;break;case"y":t[0]=0;break}}}const ct=r=>r,ut=.15,X={enabled(r=!0){return r},eventOptions(r,t,e){return l(l({},e.shared.eventOptions),r)},preventDefault(r=!1){return r},triggerAllEvents(r=!1){return r},rubberband(r=0){switch(r){case!0:return[ut,ut];case!1:return[0,0];default:return m.toVector(r)}},from(r){if(typeof r=="function")return r;if(r!=null)return m.toVector(r)},transform(r,t,e){const n=r||e.shared.transform;if(this.hasCustomTransform=!!n,process.env.NODE_ENV==="development"){const s=n||ct;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||ct},threshold(r){return m.toVector(r,0)}};process.env.NODE_ENV==="development"&&Object.assign(X,{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 jt=0,V=l(l({},X),{},{axis(r,t,{axis:e}){if(this.lockDirection=e==="lock",!this.lockDirection)return e},axisThreshold(r=jt){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:t=-1/0,right:e=1/0,top:n=-1/0,bottom:s=1/0}=r;return[[t,e],[n,s]]}}),ft={ArrowRight:(r,t=1)=>[r*t,0],ArrowLeft:(r,t=1)=>[-1*r*t,0],ArrowUp:(r,t=1)=>[0,-1*r*t],ArrowDown:(r,t=1)=>[0,r*t]};class Rt extends Vt{constructor(...t){super(...t),_(this,"ingKey","dragging")}reset(){super.reset();const t=this.state;t._pointerId=void 0,t._pointerActive=!1,t._keyboardActive=!1,t._preventScroll=!1,t._delayed=!1,t.swipe=[0,0],t.tap=!1,t.canceled=!1,t.cancel=this.cancel.bind(this)}setup(){const t=this.state;if(t._bounds instanceof HTMLElement){const e=t._bounds.getBoundingClientRect(),n=t.currentTarget.getBoundingClientRect(),s={left:e.left-n.left+t.offset[0],right:e.right-n.right+t.offset[0],top:e.top-n.top+t.offset[1],bottom:e.bottom-n.bottom+t.offset[1]};t._bounds=V.bounds(s)}}cancel(){const t=this.state;t.canceled||(t.canceled=!0,t._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(t){const e=this.config,n=this.state;if(t.buttons!=null&&(Array.isArray(e.pointerButtons)?!e.pointerButtons.includes(t.buttons):e.pointerButtons!==-1&&e.pointerButtons!==t.buttons))return;const s=this.ctrl.setEventIds(t);e.pointerCapture&&t.target.setPointerCapture(t.pointerId),!(s&&s.size>1&&n._pointerActive)&&(this.start(t),this.setupPointer(t),n._pointerId=H(t),n._pointerActive=!0,this.computeValues(ot(t)),this.computeInitial(),e.preventScrollAxis&&st(t)!=="mouse"?(n._active=!1,this.setupScrollPrevention(t)):e.delay>0?(this.setupDelayTrigger(t),e.triggerAllEvents&&(this.compute(t),this.emit())):this.startPointerDrag(t))}startPointerDrag(t){const e=this.state;e._active=!0,e._preventScroll=!0,e._delayed=!1,this.compute(t),this.emit()}pointerMove(t){const e=this.state,n=this.config;if(!e._pointerActive)return;const s=H(t);if(e._pointerId!==void 0&&s!==e._pointerId)return;const i=ot(t);if(document.pointerLockElement===t.target?e._delta=[t.movementX,t.movementY]:(e._delta=m.sub(i,e._values),this.computeValues(i)),m.addTo(e._movement,e._delta),this.compute(t),e._delayed&&e.intentional){this.timeoutStore.remove("dragDelay"),e.active=!1,this.startPointerDrag(t);return}if(n.preventScrollAxis&&!e._preventScroll)if(e.axis)if(e.axis===n.preventScrollAxis||n.preventScrollAxis==="xy"){e._active=!1,this.clean();return}else{this.timeoutStore.remove("startPointerDrag"),this.startPointerDrag(t);return}else return;this.emit()}pointerUp(t){this.ctrl.setEventIds(t);try{this.config.pointerCapture&&t.target.hasPointerCapture(t.pointerId)&&t.target.releasePointerCapture(t.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 e=this.state,n=this.config;if(!e._active||!e._pointerActive)return;const s=H(t);if(e._pointerId!==void 0&&s!==e._pointerId)return;this.state._pointerActive=!1,this.setActive(),this.compute(t);const[i,c]=e._distance;if(e.tap=i<=n.tapsThreshold&&c<=n.tapsThreshold,e.tap&&n.filterTaps)e._force=!0;else{const[o,u]=e._delta,[h,f]=e._movement,[T,y]=n.swipe.velocity,[A,C]=n.swipe.distance,x=n.swipe.duration;if(e.elapsedTime<x){const $=Math.abs(o/e.timeDelta),M=Math.abs(u/e.timeDelta);$>T&&Math.abs(h)>A&&(e.swipe[0]=Math.sign(o)),M>y&&Math.abs(f)>C&&(e.swipe[1]=Math.sign(u))}}this.emit()}pointerClick(t){!this.state.tap&&t.detail>0&&(t.preventDefault(),t.stopPropagation())}setupPointer(t){const e=this.config,n=e.device;if(process.env.NODE_ENV==="development")try{if(n==="pointer"&&e.preventScrollDelay===void 0){const s="uv"in t?t.sourceEvent.currentTarget:t.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{}e.pointerLock&&t.currentTarget.requestPointerLock(),e.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(t){this.state._preventScroll&&t.cancelable&&t.preventDefault()}setupScrollPrevention(t){this.state._preventScroll=!1,Ut(t);const e=this.eventStore.add(this.sharedConfig.window,"touch","change",this.preventScroll.bind(this),{passive:!1});this.eventStore.add(this.sharedConfig.window,"touch","end",e),this.eventStore.add(this.sharedConfig.window,"touch","cancel",e),this.timeoutStore.add("startPointerDrag",this.startPointerDrag.bind(this),this.config.preventScrollDelay,t)}setupDelayTrigger(t){this.state._delayed=!0,this.timeoutStore.add("dragDelay",()=>{this.state._step=[0,0],this.startPointerDrag(t)},this.config.delay)}keyDown(t){const e=ft[t.key];if(e){const n=this.state,s=t.shiftKey?10:t.altKey?.1:1;this.start(t),n._delta=e(this.config.keyboardDisplacement,s),n._keyboardActive=!0,m.addTo(n._movement,n._delta),this.compute(t),this.emit()}}keyUp(t){t.key in ft&&(this.state._keyboardActive=!1,this.setActive(),this.compute(t),this.emit())}bind(t){const e=this.config.device;t(e,"start",this.pointerDown.bind(this)),this.config.pointerCapture&&(t(e,"change",this.pointerMove.bind(this)),t(e,"end",this.pointerUp.bind(this)),t(e,"cancel",this.pointerUp.bind(this)),t("lostPointerCapture","",this.pointerUp.bind(this))),this.config.keys&&(t("key","down",this.keyDown.bind(this)),t("key","up",this.keyUp.bind(this))),this.config.filterTaps&&t("click","",this.pointerClick.bind(this),{capture:!0,passive:!1})}}function Ut(r){"persist"in r&&typeof r.persist=="function"&&r.persist()}const j=typeof window<"u"&&window.document&&window.document.createElement;function lt(){return j&&"ontouchstart"in window}function Kt(){return lt()||j&&window.navigator.maxTouchPoints>1}function Bt(){return j&&"onpointerdown"in window}function Yt(){return j&&"exitPointerLock"in window.document}function Wt(){try{return"constructor"in GestureEvent}catch{return!1}}const E={isBrowser:j,gesture:Wt(),touch:lt(),touchscreen:Kt(),pointer:Bt(),pointerLock:Yt()},Ft=250,zt=180,Ht=.5,Xt=50,qt=250,Gt=10,ht={mouse:0,touch:0,pen:8},dt=l(l({},V),{},{device(r,t,{pointer:{touch:e=!1,lock:n=!1,mouse:s=!1}={}}){return this.pointerLock=n&&E.pointerLock,E.touch&&e?"touch":this.pointerLock?"mouse":E.pointer&&!s?"pointer":E.touch?"touch":"mouse"},preventScrollAxis(r,t,{preventScroll:e}){if(this.preventScrollDelay=typeof e=="number"?e:e||e===void 0&&r?Ft:void 0,!(!E.touchscreen||e===!1))return r||(e!==void 0?"y":void 0)},pointerCapture(r,t,{pointer:{capture:e=!0,buttons:n=1,keys:s=!0}={}}){return this.pointerButtons=n,this.keys=s,!this.pointerLock&&this.device==="pointer"&&e},threshold(r,t,{filterTaps:e=!1,tapsThreshold:n=3,axis:s=void 0}){const i=m.toVector(r,e?n:s?1:0);return this.filterTaps=e,this.tapsThreshold=n,i},swipe({velocity:r=Ht,distance:t=Xt,duration:e=qt}={}){return{velocity:this.transform(m.toVector(r)),distance:this.transform(m.toVector(t)),duration:e}},delay(r=0){switch(r){case!0:return zt;case!1:return 0;default:return r}},axisThreshold(r){return r?l(l({},ht),r):ht},keyboardDisplacement(r=Gt){return r}});process.env.NODE_ENV==="development"&&Object.assign(dt,{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({},X),{},{device(r,t,{shared:e,pointer:{touch:n=!1}={}}){if(e.target&&!E.touch&&E.gesture)return"gesture";if(E.touch&&n)return"touch";if(E.touchscreen){if(E.pointer)return"pointer";if(E.touch)return"touch"}},bounds(r,t,{scaleBounds:e={},angleBounds:n={}}){const s=c=>{const o=at(B(e,c),{min:-1/0,max:1/0});return[o.min,o.max]},i=c=>{const o=at(B(n,c),{min:-1/0,max:1/0});return[o.min,o.max]};return typeof e!="function"&&typeof n!="function"?[s(),i()]:c=>[s(c),i(c)]},threshold(r,t,e){return this.lockDirection=e.axis==="lock",m.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 pt=new Map,q=new Map;function Jt(r){pt.set(r.key,r.engine),q.set(r.key,r.resolver)}const Qt={key:"drag",engine:Rt,resolver:dt};function Zt(r,t){if(r==null)return{};var e={},n=Object.keys(r),s,i;for(i=0;i<n.length;i++)s=n[i],!(t.indexOf(s)>=0)&&(e[s]=r[s]);return e}function te(r,t){if(r==null)return{};var e=Zt(r,t),n,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(r);for(s=0;s<i.length;s++)n=i[s],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(r,n)&&(e[n]=r[n])}return e}const ee={target(r){if(r)return()=>"current"in r?r.current:r},enabled(r=!0){return r},window(r=E.isBrowser?window:void 0){return r},eventOptions({passive:r=!0,capture:t=!1}={}){return{passive:r,capture:t}},transform(r){return r}},re=["target","eventOptions","window","enabled","transform"];function Y(r={},t){const e={};for(const[n,s]of Object.entries(t))switch(typeof s){case"function":if(process.env.NODE_ENV==="development"){const i=s.call(e,r[n],n,r);Number.isNaN(i)||(e[n]=i)}else e[n]=s.call(e,r[n],n,r);break;case"object":e[n]=Y(r[n],s);break;case"boolean":s&&(e[n]=r[n]);break}return e}function ne(r,t,e={}){const n=r,{target:s,eventOptions:i,window:c,enabled:o,transform:u}=n,h=te(n,re);if(e.shared=Y({target:s,eventOptions:i,window:c,enabled:o,transform:u},ee),t){const f=q.get(t);e[t]=Y(l({shared:e.shared},h),f)}else for(const f in h){const T=q.get(f);if(T)e[f]=Y(l({shared:e.shared},h[f]),T);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 e}class gt{constructor(t,e){_(this,"_listeners",new Set),this._ctrl=t,this._gestureKey=e}add(t,e,n,s,i){const c=this._listeners,o=It(e,n),u=this._gestureKey?this._ctrl.config[this._gestureKey].eventOptions:{},h=l(l({},u),i);t.addEventListener(o,s,h);const f=()=>{t.removeEventListener(o,s,h),c.delete(f)};return c.add(f),f}clean(){this._listeners.forEach(t=>t()),this._listeners.clear()}}class se{constructor(){_(this,"_timeouts",new Map)}add(t,e,n=140,...s){this.remove(t),this._timeouts.set(t,window.setTimeout(e,n,...s))}remove(t){const e=this._timeouts.get(t);e&&window.clearTimeout(e)}clean(){this._timeouts.forEach(t=>void window.clearTimeout(t)),this._timeouts.clear()}}class ie{constructor(t){_(this,"gestures",new Set),_(this,"_targetEventStore",new gt(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}}),oe(this,t)}setEventIds(t){if(K(t))return this.touchIds=new Set(Ct(t)),this.touchIds;if("pointerId"in t)return t.type==="pointerup"||t.type==="pointercancel"?this.pointerIds.delete(t.pointerId):t.type==="pointerdown"&&this.pointerIds.add(t.pointerId),this.pointerIds}applyHandlers(t,e){this.handlers=t,this.nativeHandlers=e}applyConfig(t,e){this.config=ne(t,e,this.config)}clean(){this._targetEventStore.clean();for(const t of this.gestures)this.gestureEventStores[t].clean(),this.gestureTimeoutStores[t].clean()}effect(){return this.config.shared.target&&this.bind(),()=>this._targetEventStore.clean()}bind(...t){const e=this.config.shared,n={};let s;if(!(e.target&&(s=e.target(),!s))){if(e.enabled){for(const c of this.gestures){const o=this.config[c],u=mt(n,o.eventOptions,!!s);if(o.enabled){const h=pt.get(c);new h(this,t,c).bind(u)}}const i=mt(n,e.eventOptions,!!s);for(const c in this.nativeHandlers)i(c,"",o=>this.nativeHandlers[c](l(l({},this.state.shared),{},{event:o,args:t})),void 0,!0)}for(const i in n)n[i]=$t(...n[i]);if(!s)return n;for(const i in n){const{device:c,capture:o,passive:u}=Dt(i);this._targetEventStore.add(s,c,"",n[i],{capture:o,passive:u})}}}}function N(r,t){r.gestures.add(t),r.gestureEventStores[t]=new gt(r,t),r.gestureTimeoutStores[t]=new se}function oe(r,t){t.drag&&N(r,"drag"),t.wheel&&N(r,"wheel"),t.scroll&&N(r,"scroll"),t.move&&N(r,"move"),t.pinch&&N(r,"pinch"),t.hover&&N(r,"hover")}const mt=(r,t,e)=>(n,s,i,c={},o=!1)=>{var u,h;const f=(u=c.capture)!==null&&u!==void 0?u:t.capture,T=(h=c.passive)!==null&&h!==void 0?h:t.passive;let y=o?n:xt(n,s,f);e&&T&&(y+="Passive"),r[y]=r[y]||[],r[y].push(i)};function ae(r,t={},e,n){const s=w.useMemo(()=>new ie(r),[]);if(s.applyHandlers(r,n),s.applyConfig(t,e),w.useEffect(s.effect.bind(s)),w.useEffect(()=>s.clean.bind(s),[]),t.target===void 0)return s.bind.bind(s)}function ce(r,t){return Jt(Qt),ae({drag:r},t||{},"drag")}function ue({init:r=!0,items:t,withLoop:e=!1,id:n,itemsPerSlide:s=1,gutter:i=0,startEndGutter:c=0,carouselAxis:o="x",slideType:u="fixed",startingPosition:h="start",enableGestures:f=!0,slideWhenDragThresholdIsReached:T=!0,onInit:y}){const A=w.useRef(r),C=w.useRef(null),x=w.useRef(null),$=w.useRef(0),M=w.useRef(!e),R=w.useRef(!1),U=w.useRef(0),v=w.useRef(0),[L,S]=vt.useSpring(()=>({value:0,onChange({value:a}){(u==="fixed"||u==="fluid")&&C.current.style.setProperty(`--${n}-offset-position`,`${a.value}px`),u==="freeScroll"&&(x.current[o==="x"?"scrollLeft":"scrollTop"]=Math.abs(a.value))}}),[o]),G=u!=="freeScroll"&&e?[...t.map(a=>({...a,id:`prev-repeated-item-${a.id}`})),...t,...t.map(a=>({...a,id:`next-repeated-item-${a.id}`}))]:t;function W(a){A.current&&(R.current||J({type:"next",toIndex:a}))}function F(a){A.current&&(M.current||J({type:"prev",toIndex:a}))}function J({type:a,shouldAnimate:d=!0,toIndex:D}){const p=z(),b=!d;M.current=!1,R.current=!1;let I=L.value.get(),g=0;if(a==="next"&&(v.current+=1),a==="prev"&&(v.current-=1),D!==void 0&&(v.current=D),u!=="freeScroll"&&a==="next"){const k=Q(e?p*(t.length*2):0);g=-(v.current*p),k-Math.abs(g)<p/1.2&&u==="fluid"&&!e&&(g=-k),!e&&Math.abs(g)>=k&&(R.current=!0,g=-k),e&&v.current===t.length&&(v.current=0,I=I+p*t.length,g=0)}if(u!=="freeScroll"&&a==="prev"&&(g=-(v.current*p),!e&&g>=0&&(M.current=!0,g=0),e&&v.current<0&&Math.abs(v.current)===t.length/2&&(I=I-p*t.length,g=-(Math.abs(v.current)*p),v.current=t.length/2)),u==="freeScroll"&&a==="next"){const k=x.current[o==="x"?"scrollLeft":"scrollTop"];I=k,g=k+p}if(u==="freeScroll"&&a==="prev"){const k=x.current[o==="x"?"scrollLeft":"scrollTop"];I=k,g=k-p}$.current=g,S.start({immediate:b,from:{value:I},to:{value:g}})}function z(){const a=x.current.children[0];let d=0;return d=a.getBoundingClientRect()[o==="x"?"width":"height"]+i,d}function Q(a){const d=x.current;return d[o==="x"?"scrollWidth":"scrollHeight"]-d.getBoundingClientRect()[o==="x"?"width":"height"]-a}w.useEffect(()=>{function a(p,b){switch(p){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 d(p){if(C.current){let b=0;e&&(b=z()*t.length),b-=z()*a(h,s),b-=c,C.current.style.setProperty(`--${n}-offset-modifier`,`${-b}px`),p&&p()}}function D(){d(),J({type:"next",toIndex:v.current,shouldAnimate:!1})}if(r&&(U.current=z()/4),r&&u==="fixed")return d(y),window.addEventListener("resize",D),()=>{window.removeEventListener("resize",D)}},[r,e,n,o,i,h,u]);const fe=ce(a=>{if(!A.current)return;const d=a.dragging,D=a.offset[o==="x"?0:1],p=a.movement[o==="x"?0:1],b=p>U.current,I=p<-U.current,g=a.velocity;d&&(S.start({value:D,immediate:!0,config:{velocity:g}}),T&&(b||I)&&a.cancel()),a.last&&(b?F():I?W():S.start({value:$.current,config:{velocity:g}}))},{enabled:f&&u!=="freeScroll",axis:o,rubberband:!e,...e?{}:{bounds:()=>({right:0,left:-Q(0),top:-Q(0),bottom:0})},from:()=>[L.value.get(),L.value.get()]});return{carouselFragment:P.jsxs("div",{ref:C,className:"ReactSpringCarouselContainer","data-part":"Container","data-part-internal":`${n}-Container`,children:[P.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
|
-
|
|
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"&&o==="x"?`calc(var(--${n}-offset-position) + var(--${n}-offset-modifier))`:"0px"};
|
|
12
|
+
--${n}-scroll-y-value: ${u!=="freeScroll"&&o==="y"?`calc(var(--${n}-offset-position) + var(--${n}-offset-modifier))`:"0px"};
|
|
13
|
+
--${n}-start-end-gutter: ${c*2}px;
|
|
13
14
|
}
|
|
14
|
-
|
|
15
|
+
[data-part-internal="${n}-Track"] {
|
|
15
16
|
display: flex;
|
|
16
|
-
width: 100%;
|
|
17
|
-
position: relative;
|
|
18
17
|
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;
|
|
37
|
-
}
|
|
38
|
-
.carousel-${b} .use-spring-carousel-item {
|
|
39
|
-
position: relative;
|
|
40
|
-
display: flex;
|
|
41
18
|
width: 100%;
|
|
42
19
|
height: 100%;
|
|
43
|
-
|
|
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?o==="x"?"pan-y":"pan-x":"auto"};
|
|
24
|
+
}
|
|
25
|
+
[data-part-internal="${n}-Item"] {
|
|
26
|
+
display: flex;
|
|
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
|
-
|
|
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
|
+
`}}),P.jsx("div",{ref:x,className:"ReactSpringCarouselTrack","data-part":"Track","data-part-internal":`${n}-Track`,...fe(),...u==="freeScroll"?{onWheel(){L.value.stop()}}:{},children:G.map((a,d)=>P.jsx("div",{className:"ReactSpringCarouselItem","data-part":"Item","data-part-internal":`${n}-Item`,children:a.renderItem},`${a.id}-${d}`))})]}),slideToNextItem:()=>W(),slideToPrevItem:()=>F(),slideToItem:a=>{if(typeof a=="number"){if(!t[a]){console.warn(`The item you're trying to slide doesn't exist. index: ${a}`);return}a>v.current?W(a):F(a)}if(typeof a=="string"){const d=t.findIndex(D=>D.id===a);if(d<0){console.warn(`The item you're trying to slide doesn't exist. id: ${a}`);return}d>v.current?W(d):F(d)}}}}O.useSpringCarousel=ue,Object.defineProperty(O,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
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
|
-
```
|