Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@react-spring/core

Package Overview
Dependencies
Maintainers
1
Versions
134
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@react-spring/core - npm Package Compare versions

Comparing version 0.0.1-alpha.2 to 0.0.1-alpha.3

2

index.cjs.js

@@ -1,2 +0,2 @@

"use strict";function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),React__default=_interopDefault(React),_extends=_interopDefault(require("@babel/runtime/helpers/extends")),shared=require("@react-spring/shared"),tslib_1=require("tslib"),useMemoOne=require("use-memo-one"),globals=require("@react-spring/shared/globals"),animated=require("@react-spring/animated"),_objectWithoutPropertiesLoose=_interopDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));function useChain(e,t,n){void 0===n&&(n=1e3),React.useEffect(function(){if(t){var r=0;e.forEach(function(e,i){if(e.current){var s=e.current.controllers;if(s.length){var a=n*t[i];isNaN(a)?a=r:r=a,s.forEach(function(e){e.queue.forEach(function(e){return e.delay+=a}),e.start()})}}})}else{var i=Promise.resolve();e.forEach(function(e){var t=e.current||{},n=t.controllers,r=t.start;if(n&&n.length){var s=n.map(function(e){var t=e.queue;return e.queue=[],t});i=i.then(function(){return n.forEach(function(e,t){var n;return(n=e.queue).push.apply(n,s[t])}),r()})}else console.warn("useChain ref has no animations:",e)})}})}function fillArray(e,t){const n=[];for(let r=0;r<e;r++)n.push(t(r));return n}function withDefault(e,t){return null==e?t:e}function toArray(e){return shared.is.und(e)?[]:Array.isArray(e)?e:[e]}function callProp(e,...t){return shared.is.fun(e)?e(...t):e}function getForwardProps(e){return tslib_1.__rest(e,["children","config","from","to","ref","reset","cancel","reverse","immediate","delay","lazy","items","trail","unique","initial","enter","leave","update","onStart","onRest","onFrame","onDestroyed","timestamp","attach"])}function interpolateTo(e){const t=getForwardProps(e);return e=Object.entries(e).reduce((e,[n,r])=>(n in t||(e[n]=r),e),{}),Object.assign({to:t},e)}function reconcileDeleted(e,t){e=[...e],t=[...t];let n=0,r=0,i=e.length;for(let s=0;s<e.length;s++){if(s===i){if(r+n===i){for(let n=s;n<e.length;n++){const r=e[n],i=tslib_1.__rest(r,["left","right"]);t.push(i)}break}r=i,i=e.length,n=0}let a=-1;const o=e[s],{left:u,right:c}=o,l=tslib_1.__rest(o,["left","right"]);for(let e=t.length;--e>=0;){const{originalKey:n}=t[e];if(n===c){a=e;break}if(n===u){a=e+1;break}}a<0?(n++,e.push(e[s])):t.splice(a,0,l)}return t}function freeze(e){return"undefined"!=typeof process&&"development"===process.env.NODE_ENV?Object.freeze(e):e}const linear=e=>e,emptyObj=Object.freeze({});let nextId=1;class Controller{constructor(e){this.id=nextId++,this.idle=!0,this.runCount=0,this.destroyed=!1,this.props={},this.queue=[],this.timestamps={},this.values={},this.merged={},this.animated={},this.animations={},this.configs=[],this.children=[],this.onEndQueue=[],this.cancelledAt=0,e&&this.update(e).start()}update(e){if(!e||this.destroyed)return this;const t=interpolateTo(e);if(this._ensureAnimated(t.from,!0),this._ensureAnimated(t.to),t.timestamp=globals.now(),shared.is.fun(t.delay)&&shared.is.obj(t.to)){const e=t.from||emptyObj;for(const n in t.to)this.queue.push(Object.assign({},t,{to:{[n]:t.to[n]},from:n in e?{[n]:e[n]}:void 0,delay:Math.max(0,Math.round(t.delay(n)))}))}else t.delay=shared.is.num(t.delay)?Math.max(0,Math.round(t.delay)):0,t.to||(t.to=void 0),t.from||(t.from=void 0),this.queue.push(t);return this}start(e){return this.queue.length?this._flush(e):this._start(e),this}stop(...e){let t=!1;if(shared.is.boo(e[0])&&([t,...e]=e),e.length)for(const t of e){const e=this.configs.findIndex(e=>t===e.key);this._stopAnimation(t),this.configs[e]=this.animations[t]}else this.runCount&&(this.cancelledAt=globals.now(),this.configs.forEach(e=>this._stopAnimation(e.key)),this.configs=Object.values(this.animations),this._stop(t));return this}reset(){return this.stop(),this.destroyed=!1,this.props={},this.queue=[],this.timestamps={},this.values={},this.merged={},this.animated={},this.animations={},this.configs=[],this}destroy(){this.destroyed||(this.stop(),this.destroyed=!0)}onFrame([e,t,n]){if(e===this.id){if(n&&n.length){for(const[e,t]of n)this.values[e]=t;this.props.onFrame(Object.assign({},this.values))}t||this._stop(!0)}}setProp(e,t){return this.props[e]=t,this.timestamps[e]=globals.now(),this}_ensureAnimated(e,t=!1){if(shared.is.obj(e))for(const n in e){const r=e[n];let i=this.animated[n];i&&t&&this.animations[n].isNew&&(i.setValue?i.setValue(r):i=null),i||((i=createAnimated(r))?(this.animated[n]&&moveChildren(this.animated[n],i),this.animated[n]=i,this._stopAnimation(n,!0)):console.warn("Given value not animatable:",r))}}_onEnd(e){this.runCount?this.onEndQueue.push(e):e(!0)}_start(e){e&&this._onEnd(e),this.idle&&this.runCount&&(this.idle=!1,globals.frameLoop.start(this))}_attach(e,t={}){this.children.forEach(n=>{if(t[this.id])return;t[this.id]=!0;const r=e.filter(e=>{const t=getPayload(n,e);if(t)return t.forEach(e=>e.done&&e.reset(!0)),!0});r.length&&(n._attach(r,t),n._start())})}_stop(e){this.idle=!0,globals.frameLoop.stop(this);const{onEndQueue:t}=this;t.length&&(this.onEndQueue=[],t.forEach(t=>t(e)))}_flush(e){const t=this.queue.reduce(reduceDelays,[]);this.queue.length=0;let n=Object.keys(t).length;this.runCount+=n;const r=t=>{if(this.runCount--,!--n&&(e&&e(t),!this.runCount&&t)){const{onRest:e}=this.props;e&&e(this.merged)}};t.forEach((e,t)=>{t?setTimeout(()=>{e.timestamp<this.cancelledAt||this._run(e,r)},t):this._run(e,r)})}_run(e,t){shared.is.arr(e.to)||shared.is.fun(e.to)?this._runAsync(e,t):this._diff(e)?this._animate(e)._start(t):this._onEnd(t)}_runAsync(e,t){var{to:n}=e,r=tslib_1.__rest(e,["to"]);if(this._diff(r)&&this._animate(r),!0===r.cancel)return this.props.asyncTo=void 0,t(!1);const{timestamp:i}=r;if(!this._diff({asyncTo:n,timestamp:i}))return t(!1);const s=()=>i<this.cancelledAt||shared.is.fun(n)&&n!==this.props.asyncTo;let a;const o=e=>{if(s())throw this;return(a=new Promise(t=>{this.update(e).start(t)})).then(()=>{if(s())throw this})};let u=Promise.resolve();shared.is.arr(n)?n.forEach(e=>u=u.then(()=>o(e))):shared.is.fun(n)&&(u=u.then(()=>n(o,this.stop.bind(this)).then(()=>a))),u.catch(e=>e!==this&&console.error(e)).then(()=>t(!s()))}_diff(e){var{timestamp:t,delay:n,config:r,immediate:i,reverse:s,attach:a}=e,o=tslib_1.__rest(e,["timestamp","delay","config","immediate","reverse","attach"]);let u=!1;const c=(e,n,r)=>{if(shared.is.und(n))return;const i=e[e.length-1];if(shared.is.obj(n)){shared.is.obj(r[i])||(r[i]={});for(const t in n)c(e.concat(t),n[t],r[i])}else{const s=e.join("."),a=this.timestamps[s];if(shared.is.und(a)||t>=a){this.timestamps[s]=t,isEqual(n,r[i])||(u=!0,r[i]=n)}}};if(s){const{to:e}=o;o.to=o.from,o.from=shared.is.obj(e)?e:void 0}o.parent=(a?a(this):o.parent)||null;const l=this.props.parent||null;o.parent!==l&&(l&&l.children.splice(l.children.indexOf(this),1),o.parent&&o.parent.children.push(this));for(const e in o)c([e],o[e],this.props);return"reset"in o&&(this.props.reset=!1),"cancel"in o&&(this.props.cancel=void 0),u}_isModified(e,t){return this.timestamps[t]===e.timestamp}_animate(e){const{from:t=emptyObj,to:n=emptyObj,parent:r,onStart:i}=this.props;let s=e=>!1;if(e.cancel&&this._isModified(e,"cancel")){if(!0===e.cancel)return this.stop(),this.cancelledAt=e.timestamp,this;const t=toArray(e.cancel);shared.is.arr(t)&&t.length&&(s=e=>t.indexOf(e)>=0,this.stop(...t))}this.merged=freeze(Object.assign({},t,n));let a=!1;const o=[],u=r&&this._isModified(e,"parent");for(const n in this.merged){if(s(n))continue;const i=this.animations[n];if(!i){console.warn(`Failed to animate key: "${n}"\n`+`Did you forget to define "from.${n}" for an async animation?`);continue}let{animated:c,animatedValues:l}=i;const h=this.merged[n],d=computeGoalValue(h),f=c.getValue();if(e.reset||u||!isEqual(d,f)){if(e.reset||u||!isEqual(d,i.isNew?f:i.goalValue)){let{immediate:i}=shared.is.und(e.immediate)?this.props:e;i=!!callProp(i,n);const s=l.some(e=>!e.done),u=shared.is.und(t[n])?d:computeGoalValue(t[n]),f=isAnimatableString(h);if(f){const t=[e.reset?u:c.getValue(),d];let n=l[0];n?(n.setValue(0,!1),n.reset(s)):n=new animated.AnimatedValue(0);try{moveChildren(c,c=n.interpolate({output:t}))}catch(e){console.warn('Failed to interpolate string from "%s" to "%s"',t[0],t[1]),console.error(e);continue}i&&n.setValue(1,!1)}else{if(shared.is.arr(h))if(c instanceof animated.AnimatedValueArray)e.reset&&c.setValue(u,!1),l.forEach(e=>e.reset(s));else{moveChildren(c,c=createAnimated(u))}else if(c instanceof animated.AnimatedValue)e.reset&&c.setValue(u,!1),c.reset(s);else{moveChildren(c,c=new animated.AnimatedValue(u))}i&&c.setValue(d,!1)}const p=callProp(e.config,n)||callProp(this.props.config,n)||emptyObj;i||o.push(n);const m=l.map(e=>e.getValue()),g=r&&getPayload(r,n)||toArray(f?1:d);a=!0,l=toArray(c.getPayload()),this.animations[n]={key:n,idle:!1,goalValue:d,toValues:g,fromValues:m,animated:c,animatedValues:l,immediate:i,duration:p.duration,easing:withDefault(p.easing,linear),decay:p.decay,mass:withDefault(p.mass,1),tension:withDefault(p.tension,170),friction:withDefault(p.friction,26),initialVelocity:withDefault(p.velocity,0),clamp:withDefault(p.clamp,!1),precision:withDefault(p.precision,.005),config:p}}}else i.idle||(a=!0,this._stopAnimation(n))}if(a){o.length&&(this._attach(o),i&&o.forEach(e=>{i(this.animations[e])}));const e=Object.keys(this.animations);this.configs.length=e.length,e.forEach((e,t)=>{const n=this.animations[e];this.configs[t]=n,this.values[e]=n.animated.getValue(),this.animated[e]=n.animated})}return this}_stopAnimation(e,t){const n=this.animated[e];if(!n)return console.warn(`Cannot stop an animation for a key that isn't animated: "${e}"`);this.timestamps["to."+e]=globals.now();const r=this.animations[e]||emptyObj;if(r.idle&&n===r.animated)return;shared.is.und(t)&&(t=!!r.isNew);const i=toArray(n.getPayload());i.forEach(e=>e.done=!0);const s=n.getValue();this.props.to&&(this.props.to[e]=s),this.animations[e]={key:e,idle:!0,isNew:t,goalValue:s,animated:n,animatedValues:i}}}function createAnimated(e){return shared.is.arr(e)?new animated.AnimatedValueArray(e.map(e=>{const t=createAnimated(e),n=t.getPayload();return t instanceof animated.AnimatedInterpolation?n[0]:n})):isAnimatableString(e)?new animated.AnimatedValue(0).interpolate({output:[e,e]}):new animated.AnimatedValue(e)}function moveChildren(e,t){e.getChildren().slice().forEach(n=>{e.removeChild(n),t.addChild(n);const r=n.getPayload();if(shared.is.arr(r)){const i=r.indexOf(e);if(i>=0){const e=[...r];e[i]=t,n.payload=e}}else if(shared.is.obj(r)){const i=Object.entries(r).find(t=>t[1]===e);i&&(n.payload=Object.assign({},r,{[i[0]]:t}))}})}function reduceDelays(e,t){const n=e[t.delay];return n?(t.to=merge(n.to,t.to),t.from=merge(n.from,t.from),Object.assign(n,t)):e[t.delay]=t,e}function merge(e,t){return shared.is.obj(e)&&shared.is.obj(t)?Object.assign({},e,t):t||e}function isAnimatableString(e){return!!shared.is.str(e)&&(e.startsWith("#")||/\d/.test(e)||!!globals.colorNames[e])}function computeGoalValue(e){return shared.is.arr(e)?e.map(computeGoalValue):isAnimatableString(e)?globals.createStringInterpolator({range:[0,1],output:[e,e]})(1):e}function isEqual(e,t){if(shared.is.arr(e)){if(!shared.is.arr(t)||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}return e===t}function getPayload(e,t){const n=e.animations[t];return n&&n.animatedValues}var useSprings=function(e,t,n){var r=e!==shared.usePrev(e),i=shared.is.fun(t),s=React.useRef({springs:[],ref:null}).current,a=i?[]:t,o=useMemoOne.useMemoOne(function(){return fillArray(e,function(e){var n=new Controller,r=a[e]||(a[e]=callProp(t,e,n));return n.update(r)})},[e]),u=React.useMemo(function(){return{start:function(){return Promise.all(s.springs.map(function(e){return new Promise(function(t){return e.start(t)})}))},update:function(e){var t=shared.is.fun(e),n=shared.is.arr(e);s.springs.forEach(function(r,i){r.update(t?callProp(e,i,r):n?e[i]:e),s.ref||r.start()})},stop:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return s.springs.forEach(function(e){return e.stop.apply(e,t)})}}},[]),c=u.start,l=u.update,h=u.stop,d=a[0]?a[0].ref:i?s.ref:null;React.useImperativeHandle(d,function(){return{start:c,stop:h,get controllers(){return s.springs}}}),React.useEffect(function(){i&&!r||a.forEach(function(e,t){o[t].setProp("config",e.config),o[t].setProp("immediate",e.immediate)}),r?(s.springs.forEach(function(e){return e.destroy()}),s.springs=o,s.ref=d,d||o.forEach(function(e){return e.start()})):i||l(a)},n),shared.useOnce(function(){return function(){s.springs.forEach(function(e){return e.destroy()})}});var f=o.map(function(e){return _extends({},e.animated)});return i?[f,l,h]:f},useSpring=function(e,t){var n=shared.is.fun(e),r=useSprings(1,n?e:[e],t),i=r[0],s=r[1],a=r[2];return n?[i[0],s,a]:i},useTrail=function(e,t){var n=e!==shared.usePrev(e),r=shared.is.fun(t),i=r?null:t,s=React.useRef([]),a=s.current;n&&(a.length=e);var o=useSprings(e,function(e,n){return r&&!i&&(i=callProp(t,n)||{}),a[e]=n,_extends({},i,e>0&&{attach:function(){return a[e-1]},onStart:withArgument(i.onStart,e),onFrame:withArgument(i.onFrame,e),onRest:withArgument(i.onRest,e)},{config:callProp(i.config,e)})}),u=o[0],c=o[1],l=o[2],h=useMemoOne.useCallbackOne(function(e){return c(function(t,n){var r=callProp(e,t,n)||{},i=s.current[r.reverse?t+1:t-1];return _extends({},r,{attach:function(){return i},config:callProp(r.config,t)})})},[]);return React.useEffect(function(){r||n||h(t)}),r?[u,h,l]:u};function withArgument(e,t){return shared.is.fun(e)?function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return e.apply(void 0,r.concat([t]))}:e}var guid=0,INITIAL="initial",ENTER="enter",UPDATE="update",LEAVE="leave",makeKeys=function(e,t){return("function"==typeof t?e.map(t):toArray(t)).map(String)},makeConfig=function(e){var t=e.items,n=e.keys,r=_objectWithoutPropertiesLoose(e,["items","keys"]);return t=toArray(shared.is.und(t)?null:t),_extends({items:t,keys:makeKeys(t,n)},r)};function useTransition(e,t,n){var r=n=makeConfig(_extends({},n,{items:e,keys:t||function(e){return e}})),i=r.lazy,s=void 0!==i&&i,a=(r.unique,r.from,r.enter,r.leave,r.update,r.onDestroyed),o=(r.keys,r.items,r.onFrame),u=r.onRest,c=r.onStart,l=r.ref,h=_objectWithoutPropertiesLoose(r,["lazy","unique","from","enter","leave","update","onDestroyed","keys","items","onFrame","onRest","onStart","ref"]),d=shared.useForceUpdate(),f=React.useRef(!1),p=React.useRef({mounted:!1,first:!0,deleted:[],current:{},transitions:[],prevProps:{},paused:!!n.ref,instances:!f.current&&new Map,forceUpdate:d});return React.useImperativeHandle(n.ref,function(){return{start:function(){return Promise.all(Array.from(p.current.instances).map(function(e){var t=e[1];return new Promise(function(e){return t.start(e)})}))},stop:function(e){return Array.from(p.current.instances).forEach(function(t){return t[1].stop(e)})},get controllers(){return Array.from(p.current.instances).map(function(e){return e[1]})}}}),p.current=diffItems(p.current,n),p.current.changed&&p.current.transitions.forEach(function(e){var t=e.phase,n=e.key,r=e.item,i=e.props;p.current.instances.has(n)||p.current.instances.set(n,new Controller);var d=!1,f=p.current.instances.get(n),m=_extends({},h,i,{ref:l,onRest:function(i){p.current.mounted&&(e.destroyed&&(l||s||cleanUp(p,n),a&&a(r)),!Array.from(p.current.instances).some(function(e){return!e[1].idle})&&(l||s)&&p.current.deleted.length>0&&cleanUp(p),u&&u(r,t,i))},onFrame:o&&function(e){return o(r,t,e)},onStart:c&&function(e){return d||(c(r,t,e),d=!0)}});f.update(m),p.current.paused||f.start()}),shared.useOnce(function(){return p.current.mounted=f.current=!0,function(){p.current.mounted=f.current=!1,Array.from(p.current.instances).map(function(e){return e[1].destroy()}),p.current.instances.clear()}}),p.current.transitions.map(function(e){var t=e.item,n=e.phase,r=e.key;return{item:t,key:r,phase:n,props:_extends({},p.current.instances.get(r).animated)}})}function cleanUp(e,t){var n=e.current,r=function(){if(s){if(a>=i.length)return"break";o=i[a++]}else{if((a=i.next()).done)return"break";o=a.value}var e=o.key,r=function(t){return t.key!==e};(shared.is.und(t)||t===e)&&(n.instances.delete(e),n.transitions=n.transitions.filter(r),n.deleted=n.deleted.filter(r))},i=n.deleted,s=Array.isArray(i),a=0;for(i=s?i:i[Symbol.iterator]();;){var o;if("break"===r())break}n.forceUpdate()}function diffItems(e,t){var n=e.first,r=e.current,i=e.deleted,s=e.prevProps,a=_objectWithoutPropertiesLoose(e,["first","current","deleted","prevProps"]),o=t.items,u=t.keys,c=t.initial,l=t.from,h=t.enter,d=t.leave,f=t.update,p=t.trail,m=void 0===p?0:p,g=t.unique,y=t.config,v=t.order,b=void 0===v?[ENTER,LEAVE,UPDATE]:v,_=makeConfig(s),A=_.keys,E=_.items;t.reset&&(r={},a.transitions=[]);for(var P=Object.keys(r),V=new Set(P),w=new Set(u),x=u.filter(function(e){return!V.has(e)}),j=f?u.filter(function(e){return V.has(e)}):[],k=a.transitions.filter(function(e){return!e.destroyed&&!w.has(e.originalKey)}).map(function(e){return e.originalKey}),O=-m,S=function(){var e=b.shift();e===ENTER?(n&&!shared.is.und(c)&&(e=INITIAL,l=c),x.forEach(function(t){g&&i.find(function(e){return e.originalKey===t})&&(i=i.filter(function(e){return e.originalKey!==t}));var n=u.indexOf(t),s=o[n],a=callProp(h,s,n);r[t]={phase:e,originalKey:t,key:g?String(t):guid++,item:s,props:_extends({delay:O+=m,config:callProp(y,s,e),from:callProp(l,s),to:a},shared.is.obj(a)&&interpolateTo(a))}})):e===LEAVE?k.forEach(function(t){var n=A.indexOf(t),s=E[n],a=callProp(d,s,n);i.push(_extends({},r[t],{phase:e,destroyed:!0,left:A[n-1],right:A[n+1],props:_extends({delay:O+=m,config:callProp(y,s,e),to:a},shared.is.obj(a)&&interpolateTo(a))})),delete r[t]}):e===UPDATE&&j.forEach(function(t){var n=u.indexOf(t),i=o[n],s=callProp(f,i,n);r[t]=_extends({},r[t],{phase:e,props:_extends({delay:O+=m,config:callProp(y,i,e),to:s},shared.is.obj(s)&&interpolateTo(s))})})};b.length;)S();var T=u.map(function(e){return r[e]});return T=reconcileDeleted(i,T),_extends({},a,{first:n&&!x.length,changed:!!(x.length||k.length||j.length),transitions:T,current:r,deleted:i,prevProps:t})}function Spring(e){var t=e.children,n=_objectWithoutPropertiesLoose(e,["children"]);return t(useSpring(n))}function Trail(e){var t=e.items,n=e.children,r=_objectWithoutPropertiesLoose(e,["items","children"]),i=useTrail(t.length,r);return t.map(function(e,t){var r=n(e,t);return shared.is.fun(r)?r(i[t]):r})}function Transition(e){var t=e.items,n=e.keys,r=void 0===n?null:n,i=e.children;return useTransition(t,r,_objectWithoutPropertiesLoose(e,["items","keys","children"])).map(function(e,t){var n=e.item,r=e.key,s=e.props,a=e.phase,o=i(n,a,t),u=shared.is.fun(o)?o(s):o;return u&&React__default.createElement(u.type,_extends({key:r},u.props))})}const raf=globals.requestAnimationFrame;class FrameLoop{constructor({update:e,onFrame:t,requestFrame:n}={}){this.controllers=new Map,this.isActive=!1,this.requestFrame=n||(e=>raf(e)),this.onFrame=t&&t.bind(this)||(e=>{e.forEach(e=>{const t=this.controllers.get(e[0]);t&&t.onFrame(e)})}),this.update=e&&e.bind(this)||(()=>{if(!this.isActive)return!1;const e=[];for(const t of Array.from(this.controllers.keys())){let n=!1;const r=this.controllers.get(t),i=r.props.onFrame&&[];for(const e of r.configs)e.idle||this.advance(e)&&(n=!0,i&&i.push([e.key,e.animated.getValue()]));e.push([t,n,i])}return this.onFrame(e),this.controllers.size?(this.requestFrame(this.update),!0):this.isActive=!1})}start(e){this.controllers.set(e.id,e),this.isActive||(this.isActive=!0,this.requestFrame(this.update))}stop(e){this.controllers.delete(e.id)}advance(e){const t=globals.now();let n=!1,r=!1;for(let i=0;i<e.animatedValues.length;i++){const s=e.animatedValues[i];if(s.done)continue;let a=e.toValues[i];const o=a instanceof animated.Animated?a:null;if(o&&(a=o.getValue()),e.immediate){s.setValue(a),s.done=!0;continue}const u=e.fromValues[i],c=s.startTime;if("string"==typeof u||"string"==typeof a){s.setValue(a),s.done=!0;continue}let l=s.lastPosition,h=Array.isArray(e.initialVelocity)?e.initialVelocity[i]:e.initialVelocity;if(void 0!==e.duration)l=u+e.easing((t-c)/e.duration)*(a-u),r=t>=c+e.duration;else if(e.decay){const n=!0===e.decay?.998:e.decay;l=u+h/(1-n)*(1-Math.exp(-(1-n)*(t-c))),(r=Math.abs(s.lastPosition-l)<.1)&&(a=l)}else{let n=void 0!==s.lastTime?s.lastTime:t;void 0!==s.lastVelocity&&(h=s.lastVelocity),t>n+64&&(n=t);const i=Math.floor(t-n);for(let t=0;t<i;++t){l+=1*(h+=1*((-e.tension*(l-a)+-e.friction*h)/e.mass)/1e3)/1e3}s.lastTime=t,s.lastVelocity=h;const o=!(!e.clamp||0===e.tension)&&(u<a?l>a:l<a),c=Math.abs(h)<=e.precision,d=0===e.tension||Math.abs(a-l)<=e.precision;r=o||c&&d}o&&!o.done&&(r=!1),r?(s.value!==a&&(l=a),s.done=!0):n=!0,s.setValue(l),s.lastPosition=l}return n}}const stringShapeRegex=/[+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,createStringInterpolator=e=>{const t=e.output,n=t[0].match(stringShapeRegex).map(()=>[]);t.forEach(e=>{e.match(stringShapeRegex).forEach((e,t)=>n[t].push(+e))});const r=t[0].match(stringShapeRegex).map((t,r)=>shared.createInterpolator(Object.assign({},e,{output:n[r]})));return e=>{let n=0;return t[0].replace(stringShapeRegex,()=>r[n++](e))}};shared.Globals.assign({frameLoop:new FrameLoop,createStringInterpolator:createStringInterpolator,applyAnimatedValues:()=>!1,createAnimatedStyle:e=>new animated.AnimatedStyle(e),createAnimatedInterpolation:(e,...t)=>new animated.AnimatedInterpolation(e,t)});const update=()=>shared.Globals.frameLoop.update(),config={default:{tension:170,friction:26},gentle:{tension:120,friction:14},wobbly:{tension:180,friction:12},stiff:{tension:210,friction:20},slow:{tension:280,friction:60},molasses:{tension:280,friction:120}};Object.defineProperty(exports,"Globals",{enumerable:!0,get:function(){return shared.Globals}}),Object.defineProperty(exports,"createInterpolator",{enumerable:!0,get:function(){return shared.createInterpolator}}),Object.defineProperty(exports,"interpolate",{enumerable:!0,get:function(){return animated.interpolate}}),exports.Controller=Controller,exports.FrameLoop=FrameLoop,exports.Spring=Spring,exports.Trail=Trail,exports.Transition=Transition,exports.config=config,exports.update=update,exports.useChain=useChain,exports.useSpring=useSpring,exports.useSprings=useSprings,exports.useTrail=useTrail,exports.useTransition=useTransition;
"use strict";function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),React__default=_interopDefault(React),_extends=_interopDefault(require("@babel/runtime/helpers/extends")),shared=require("@react-spring/shared"),tslib_1=require("tslib"),useMemoOne=require("use-memo-one"),globals=require("@react-spring/shared/globals"),animated=require("@react-spring/animated"),_objectWithoutPropertiesLoose=_interopDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));function useChain(e,t,n){void 0===n&&(n=1e3),React.useEffect(function(){if(t){var r=0;e.forEach(function(e,i){if(e.current){var s=e.current.controllers;if(s.length){var a=n*t[i];isNaN(a)?a=r:r=a,s.forEach(function(e){e.queue.forEach(function(e){return e.delay+=a}),e.start()})}}})}else{var i=Promise.resolve();e.forEach(function(e){var t=e.current||{},n=t.controllers,r=t.start;if(n&&n.length){var s=n.map(function(e){var t=e.queue;return e.queue=[],t});i=i.then(function(){return n.forEach(function(e,t){var n;return(n=e.queue).push.apply(n,s[t])}),r()})}else console.warn("useChain ref has no animations:",e)})}})}function fillArray(e,t){const n=[];for(let r=0;r<e;r++)n.push(t(r));return n}function withDefault(e,t){return null==e?t:e}function toArray(e){return shared.is.und(e)?[]:Array.isArray(e)?e:[e]}function callProp(e,...t){return shared.is.fun(e)?e(...t):e}function getForwardProps(e){return tslib_1.__rest(e,["children","config","from","to","ref","reset","cancel","reverse","immediate","delay","lazy","items","trail","unique","initial","enter","leave","update","onStart","onRest","onFrame","onDestroyed","timestamp","attach"])}function interpolateTo(e){const t=getForwardProps(e);return e=Object.entries(e).reduce((e,[n,r])=>(n in t||(e[n]=r),e),{}),Object.assign({to:t},e)}function reconcileDeleted(e,t){e=[...e],t=[...t];let n=0,r=0,i=e.length;for(let s=0;s<e.length;s++){if(s===i){if(r+n===i){for(let n=s;n<e.length;n++){const r=e[n],i=tslib_1.__rest(r,["left","right"]);t.push(i)}break}r=i,i=e.length,n=0}let a=-1;const o=e[s],{left:u,right:c}=o,l=tslib_1.__rest(o,["left","right"]);for(let e=t.length;--e>=0;){const{originalKey:n}=t[e];if(n===c){a=e;break}if(n===u){a=e+1;break}}a<0?(n++,e.push(e[s])):t.splice(a,0,l)}return t}function freeze(e){return"undefined"!=typeof process&&"development"===process.env.NODE_ENV?Object.freeze(e):e}const linear=e=>e,emptyObj=Object.freeze({});let nextId=1;class Controller{constructor(e){this.id=nextId++,this.idle=!0,this.runCount=0,this.destroyed=!1,this.props={},this.queue=[],this.timestamps={},this.values={},this.merged={},this.animated={},this.animations={},this.configs=[],this.children=[],this.onEndQueue=[],this.cancelledAt=0,e&&this.update(e).start()}update(e){if(!e||this.destroyed)return this;const t=interpolateTo(e);if(this._ensureAnimated(t.from,!0),this._ensureAnimated(t.to),t.timestamp=globals.now(),shared.is.fun(t.delay)&&shared.is.obj(t.to)){const e=t.from||emptyObj;for(const n in t.to)this.queue.push(Object.assign({},t,{to:{[n]:t.to[n]},from:n in e?{[n]:e[n]}:void 0,delay:Math.max(0,Math.round(t.delay(n)))}))}else t.delay=shared.is.num(t.delay)?Math.max(0,Math.round(t.delay)):0,t.to||(t.to=void 0),t.from||(t.from=void 0),this.queue.push(t);return this}start(e){return this.queue.length?this._flush(e):this._start(e),this}stop(...e){let t=!1;if(shared.is.boo(e[0])&&([t,...e]=e),e.length)for(const t of e){const e=this.configs.findIndex(e=>t===e.key);this._stopAnimation(t),this.configs[e]=this.animations[t]}else this.runCount&&(this.cancelledAt=globals.now(),this.configs.forEach(e=>this._stopAnimation(e.key)),this.configs=Object.values(this.animations),this._stop(t));return this}reset(){return this.stop(),this.destroyed=!1,this.props={},this.queue=[],this.timestamps={},this.values={},this.merged={},this.animated={},this.animations={},this.configs=[],this}destroy(){this.destroyed||(this.stop(),this.destroyed=!0)}onFrame([e,t,n]){if(e===this.id){if(n&&n.length){for(const[e,t]of n)this.values[e]=t;this.props.onFrame(Object.assign({},this.values))}t||this._stop(!0)}}setProp(e,t){return this.props[e]=t,this.timestamps[e]=globals.now(),this}_ensureAnimated(e,t=!1){if(shared.is.obj(e))for(const n in e){const r=e[n];let i=this.animated[n];i&&t&&this.animations[n].isNew&&(i.setValue?i.setValue(r):i=null),i||((i=createAnimated(r))?(this.animated[n]&&moveChildren(this.animated[n],i),this.animated[n]=i,this._stopAnimation(n,!0)):console.warn("Given value not animatable:",r))}}_onEnd(e){this.runCount?this.onEndQueue.push(e):e(!0)}_start(e){e&&this._onEnd(e),this.idle&&this.runCount&&(this.idle=!1,globals.frameLoop.start(this))}_attach(e,t={}){this.children.forEach(n=>{if(t[this.id])return;t[this.id]=!0;const r=e.filter(e=>{const t=getPayload(n,e);if(t)return t.forEach(e=>e.done&&e.reset(!0)),!0});r.length&&(n._attach(r,t),n._start())})}_stop(e){this.idle=!0,globals.frameLoop.stop(this);const{onEndQueue:t}=this;t.length&&(this.onEndQueue=[],t.forEach(t=>t(e)))}_flush(e){const t=this.queue.reduce(reduceDelays,[]);this.queue.length=0;let n=Object.keys(t).length;this.runCount+=n;const r=t=>{if(this.runCount--,!--n&&(e&&e(t),!this.runCount&&t)){const{onRest:e}=this.props;e&&e(this.merged)}};t.forEach((e,t)=>{t?setTimeout(()=>{e.timestamp<this.cancelledAt||this._run(e,r)},t):this._run(e,r)})}_run(e,t){shared.is.arr(e.to)||shared.is.fun(e.to)?this._runAsync(e,t):this._diff(e)?this._animate(e)._start(t):this._onEnd(t)}_runAsync(e,t){var{to:n}=e,r=tslib_1.__rest(e,["to"]);if(this._diff(r)&&this._animate(r),!0===r.cancel)return this.props.asyncTo=void 0,t(!1);const{timestamp:i}=r;if(!this._diff({asyncTo:n,timestamp:i}))return t(!1);const s=()=>i<this.cancelledAt||shared.is.fun(n)&&n!==this.props.asyncTo;let a;const o=e=>{if(s())throw this;return(a=new Promise(t=>{this.update(e).start(t)})).then(()=>{if(s())throw this})};let u=Promise.resolve();shared.is.arr(n)?n.forEach(e=>u=u.then(()=>o(e))):shared.is.fun(n)&&(u=u.then(()=>n(o,this.stop.bind(this)).then(()=>a))),u.catch(e=>e!==this&&console.error(e)).then(()=>t(!s()))}_diff(e){var{timestamp:t,delay:n,config:r,immediate:i,reverse:s,attach:a}=e,o=tslib_1.__rest(e,["timestamp","delay","config","immediate","reverse","attach"]);let u=!1;const c=(e,n,r)=>{if(shared.is.und(n))return;const i=e[e.length-1];if(shared.is.obj(n)){shared.is.obj(r[i])||(r[i]={});for(const t in n)c(e.concat(t),n[t],r[i])}else{const s=e.join("."),a=this.timestamps[s];if(shared.is.und(a)||t>=a){this.timestamps[s]=t,isEqual(n,r[i])||(u=!0,r[i]=n)}}};if(s){const{to:e}=o;o.to=o.from,o.from=shared.is.obj(e)?e:void 0}o.parent=(a?a(this):o.parent)||null;const l=this.props.parent||null;o.parent!==l&&(l&&l.children.splice(l.children.indexOf(this),1),o.parent&&o.parent.children.push(this));for(const e in o)c([e],o[e],this.props);return"reset"in o&&(this.props.reset=!1),"cancel"in o&&(this.props.cancel=void 0),u}_isModified(e,t){return this.timestamps[t]===e.timestamp}_animate(e){const{from:t=emptyObj,to:n=emptyObj,parent:r,onStart:i}=this.props;let s=e=>!1;if(e.cancel&&this._isModified(e,"cancel")){if(!0===e.cancel)return this.stop(),this.cancelledAt=e.timestamp,this;const t=toArray(e.cancel);shared.is.arr(t)&&t.length&&(s=e=>t.indexOf(e)>=0,this.stop(...t))}this.merged=freeze(Object.assign({},t,n));let a=!1;const o=[],u=r&&this._isModified(e,"parent");for(const n in this.merged){if(s(n))continue;const i=this.animations[n];if(!i){console.warn(`Failed to animate key: "${n}"\n`+`Did you forget to define "from.${n}" for an async animation?`);continue}let{animated:c,animatedValues:l}=i;const h=this.merged[n],d=computeGoalValue(h),f=c.getValue();if(e.reset||u||!isEqual(d,f)){if(e.reset||u||!isEqual(d,i.isNew?f:i.goalValue)){let{immediate:i}=shared.is.und(e.immediate)?this.props:e;i=!!callProp(i,n);const s=l.some(e=>!e.done),u=shared.is.und(t[n])?d:computeGoalValue(t[n]),f=isAnimatableString(h);if(f){const t=[e.reset?u:c.getValue(),d];let n=l[0];n?(n.setValue(0,!1),n.reset(s)):n=new animated.AnimatedValue(0);try{moveChildren(c,c=n.interpolate({output:t}))}catch(e){console.warn('Failed to interpolate string from "%s" to "%s"',t[0],t[1]),console.error(e);continue}i&&n.setValue(1,!1)}else{if(shared.is.arr(h))if(c instanceof animated.AnimatedValueArray)e.reset&&c.setValue(u,!1),l.forEach(e=>e.reset(s));else{moveChildren(c,c=createAnimated(u))}else if(c instanceof animated.AnimatedValue)e.reset&&c.setValue(u,!1),c.reset(s);else{moveChildren(c,c=new animated.AnimatedValue(u))}i&&c.setValue(d,!1)}const p=callProp(e.config,n)||callProp(this.props.config,n)||emptyObj;i||o.push(n);const m=l.map(e=>e.getValue()),g=r&&getPayload(r,n)||toArray(f?1:d);a=!0,l=toArray(c.getPayload()),this.animations[n]={key:n,idle:!1,goalValue:d,toValues:g,fromValues:m,animated:c,animatedValues:l,immediate:i,duration:p.duration,easing:withDefault(p.easing,linear),decay:p.decay,mass:withDefault(p.mass,1),tension:withDefault(p.tension,170),friction:withDefault(p.friction,26),initialVelocity:withDefault(p.velocity,0),clamp:withDefault(p.clamp,!1),precision:withDefault(p.precision,.005),config:p}}}else i.idle||(a=!0,this._stopAnimation(n))}if(a){o.length&&(this._attach(o),i&&o.forEach(e=>{i(this.animations[e])}));const e=Object.keys(this.animations);this.configs.length=e.length,e.forEach((e,t)=>{const n=this.animations[e];this.configs[t]=n,this.values[e]=n.animated.getValue(),this.animated[e]=n.animated})}return this}_stopAnimation(e,t){const n=this.animated[e];if(!n)return console.warn(`Cannot stop an animation for a key that isn't animated: "${e}"`);this.timestamps["to."+e]=globals.now();const r=this.animations[e]||emptyObj;if(r.idle&&n===r.animated)return;shared.is.und(t)&&(t=!!r.isNew);const i=toArray(n.getPayload());i.forEach(e=>e.done=!0);const s=n.getValue();this.props.to&&(this.props.to[e]=s),this.animations[e]={key:e,idle:!0,isNew:t,goalValue:s,animated:n,animatedValues:i}}}function createAnimated(e){return shared.is.arr(e)?new animated.AnimatedValueArray(e.map(e=>{const t=createAnimated(e),n=t.getPayload();return t instanceof animated.AnimatedInterpolation?n[0]:n})):isAnimatableString(e)?new animated.AnimatedValue(0).interpolate({output:[e,e]}):new animated.AnimatedValue(e)}function moveChildren(e,t){e.getChildren().slice().forEach(n=>{e.removeChild(n),t.addChild(n);const r=n.getPayload();if(shared.is.arr(r)){const i=r.indexOf(e);if(i>=0){const e=[...r];e[i]=t,n.payload=e}}else if(shared.is.obj(r)){const i=Object.entries(r).find(t=>t[1]===e);i&&(n.payload=Object.assign({},r,{[i[0]]:t}))}})}function reduceDelays(e,t){const n=e[t.delay];return n?(t.to=merge(n.to,t.to),t.from=merge(n.from,t.from),Object.assign(n,t)):e[t.delay]=t,e}function merge(e,t){return shared.is.obj(e)&&shared.is.obj(t)?Object.assign({},e,t):t||e}function isAnimatableString(e){return!!shared.is.str(e)&&(e.startsWith("#")||/\d/.test(e)||!!globals.colorNames[e])}function computeGoalValue(e){return shared.is.arr(e)?e.map(computeGoalValue):isAnimatableString(e)?globals.createStringInterpolator({range:[0,1],output:[e,e]})(1):e}function isEqual(e,t){if(shared.is.arr(e)){if(!shared.is.arr(t)||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}return e===t}function getPayload(e,t){const n=e.animations[t];return n&&n.animatedValues}var useSprings=function(e,t,n){var r=e!==shared.usePrev(e),i=shared.is.fun(t),s=React.useRef({springs:[],ref:null}).current,a=i?[]:t,o=useMemoOne.useMemoOne(function(){return fillArray(e,function(e){var n=new Controller,r=a[e]||(a[e]=callProp(t,e,n));return n.update(r)})},[e]),u=React.useMemo(function(){return{start:function(){return Promise.all(s.springs.map(function(e){return new Promise(function(t){return e.start(t)})}))},update:function(e){var t=shared.is.fun(e),n=shared.is.arr(e);s.springs.forEach(function(r,i){r.update(t?callProp(e,i,r):n?e[i]:e),s.ref||r.start()})},stop:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return s.springs.forEach(function(e){return e.stop.apply(e,t)})}}},[]),c=u.start,l=u.update,h=u.stop,d=a[0]?a[0].ref:i?s.ref:null;React.useImperativeHandle(d,function(){return{start:c,stop:h,get controllers(){return s.springs}}}),React.useEffect(function(){i&&!r||a.forEach(function(e,t){o[t].setProp("config",e.config),o[t].setProp("immediate",e.immediate)}),r?(s.springs.forEach(function(e){return e.destroy()}),s.springs=o,s.ref=d,d||o.forEach(function(e){return e.start()})):i||l(a)},n),shared.useOnce(function(){return function(){s.springs.forEach(function(e){return e.destroy()})}});var f=o.map(function(e){return _extends({},e.animated)});return i?[f,l,h]:f},useSpring=function(e,t){var n=shared.is.fun(e),r=useSprings(1,n?e:[e],t),i=r[0],s=r[1],a=r[2];return n?[i[0],s,a]:i},useTrail=function(e,t){var n=e!==shared.usePrev(e),r=shared.is.fun(t),i=r?null:t,s=React.useRef([]),a=s.current;n&&(a.length=e);var o=useSprings(e,function(e,n){return r&&!i&&(i=callProp(t,n)||{}),a[e]=n,_extends({},i,e>0&&{attach:function(){return a[e-1]},onStart:withArgument(i.onStart,e),onFrame:withArgument(i.onFrame,e),onRest:withArgument(i.onRest,e)},{config:callProp(i.config,e)})}),u=o[0],c=o[1],l=o[2],h=useMemoOne.useCallbackOne(function(e){return c(function(t,n){var r=callProp(e,t,n)||{},i=s.current[r.reverse?t+1:t-1];return _extends({},r,{attach:function(){return i},config:callProp(r.config,t)})})},[]);return React.useEffect(function(){r||n||h(t)}),r?[u,h,l]:u};function withArgument(e,t){return shared.is.fun(e)?function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return e.apply(void 0,r.concat([t]))}:e}var guid=0,INITIAL="initial",ENTER="enter",UPDATE="update",LEAVE="leave",makeKeys=function(e,t){return("function"==typeof t?e.map(t):toArray(t)).map(String)},makeConfig=function(e){var t=e.items,n=e.keys,r=_objectWithoutPropertiesLoose(e,["items","keys"]);return t=toArray(shared.is.und(t)?null:t),_extends({items:t,keys:makeKeys(t,n)},r)};function useTransition(e,t,n){var r=n=makeConfig(_extends({},n,{items:e,keys:t||function(e){return e}})),i=r.lazy,s=void 0!==i&&i,a=(r.unique,r.from,r.enter,r.leave,r.update,r.onDestroyed),o=(r.keys,r.items,r.onFrame),u=r.onRest,c=r.onStart,l=r.ref,h=_objectWithoutPropertiesLoose(r,["lazy","unique","from","enter","leave","update","onDestroyed","keys","items","onFrame","onRest","onStart","ref"]),d=shared.useForceUpdate(),f=React.useRef(!1),p=React.useRef({mounted:!1,first:!0,deleted:[],current:{},transitions:[],prevProps:{},paused:!!n.ref,instances:!f.current&&new Map,forceUpdate:d});return React.useImperativeHandle(n.ref,function(){return{start:function(){return Promise.all(Array.from(p.current.instances).map(function(e){var t=e[1];return new Promise(function(e){return t.start(e)})}))},stop:function(e){return Array.from(p.current.instances).forEach(function(t){return t[1].stop(e)})},get controllers(){return Array.from(p.current.instances).map(function(e){return e[1]})}}}),p.current=diffItems(p.current,n),p.current.changed&&p.current.transitions.forEach(function(e){var t=e.phase,n=e.key,r=e.item,i=e.props;p.current.instances.has(n)||p.current.instances.set(n,new Controller);var d=!1,f=p.current.instances.get(n),m=_extends({},h,i,{ref:l,onRest:function(i){p.current.mounted&&(e.destroyed&&(l||s||cleanUp(p,n),a&&a(r)),!Array.from(p.current.instances).some(function(e){return!e[1].idle})&&(l||s)&&p.current.deleted.length>0&&cleanUp(p),u&&u(r,t,i))},onFrame:o&&function(e){return o(r,t,e)},onStart:c&&function(e){return d||(c(r,t,e),d=!0)}});f.update(m),p.current.paused||f.start()}),shared.useOnce(function(){return p.current.mounted=f.current=!0,function(){p.current.mounted=f.current=!1,Array.from(p.current.instances).map(function(e){return e[1].destroy()}),p.current.instances.clear()}}),p.current.transitions.map(function(e){var t=e.item,n=e.phase,r=e.key;return{item:t,key:r,phase:n,props:_extends({},p.current.instances.get(r).animated)}})}function cleanUp(e,t){var n=e.current,r=function(){if(s){if(a>=i.length)return"break";o=i[a++]}else{if((a=i.next()).done)return"break";o=a.value}var e=o.key,r=function(t){return t.key!==e};(shared.is.und(t)||t===e)&&(n.instances.delete(e),n.transitions=n.transitions.filter(r),n.deleted=n.deleted.filter(r))},i=n.deleted,s=Array.isArray(i),a=0;for(i=s?i:i[Symbol.iterator]();;){var o;if("break"===r())break}n.forceUpdate()}function diffItems(e,t){var n=e.first,r=e.current,i=e.deleted,s=e.prevProps,a=_objectWithoutPropertiesLoose(e,["first","current","deleted","prevProps"]),o=t.items,u=t.keys,c=t.initial,l=t.from,h=t.enter,d=t.leave,f=t.update,p=t.trail,m=void 0===p?0:p,g=t.unique,y=t.config,v=t.order,b=void 0===v?[ENTER,LEAVE,UPDATE]:v,_=makeConfig(s),A=_.keys,E=_.items;t.reset&&(r={},a.transitions=[]);for(var P=Object.keys(r),V=new Set(P),w=new Set(u),x=u.filter(function(e){return!V.has(e)}),j=f?u.filter(function(e){return V.has(e)}):[],k=a.transitions.filter(function(e){return!e.destroyed&&!w.has(e.originalKey)}).map(function(e){return e.originalKey}),O=-m,S=function(){var e=b.shift();e===ENTER?(n&&!shared.is.und(c)&&(e=INITIAL,l=c),x.forEach(function(t){g&&i.find(function(e){return e.originalKey===t})&&(i=i.filter(function(e){return e.originalKey!==t}));var n=u.indexOf(t),s=o[n],a=callProp(h,s,n);r[t]={phase:e,originalKey:t,key:g?String(t):guid++,item:s,props:_extends({delay:O+=m,config:callProp(y,s,e),from:callProp(l,s),to:a},shared.is.obj(a)&&interpolateTo(a))}})):e===LEAVE?k.forEach(function(t){var n=A.indexOf(t),s=E[n],a=callProp(d,s,n);i.push(_extends({},r[t],{phase:e,destroyed:!0,left:A[n-1],right:A[n+1],props:_extends({delay:O+=m,config:callProp(y,s,e),to:a},shared.is.obj(a)&&interpolateTo(a))})),delete r[t]}):e===UPDATE&&j.forEach(function(t){var n=u.indexOf(t),i=o[n],s=callProp(f,i,n);r[t]=_extends({},r[t],{phase:e,props:_extends({delay:O+=m,config:callProp(y,i,e),to:s},shared.is.obj(s)&&interpolateTo(s))})})};b.length;)S();var T=u.map(function(e){return r[e]});return T=reconcileDeleted(i,T),_extends({},a,{first:n&&!x.length,changed:!!(x.length||k.length||j.length),transitions:T,current:r,deleted:i,prevProps:t})}function Spring(e){var t=e.children,n=_objectWithoutPropertiesLoose(e,["children"]);return t(useSpring(n))}function Trail(e){var t=e.items,n=e.children,r=_objectWithoutPropertiesLoose(e,["items","children"]),i=useTrail(t.length,r);return t.map(function(e,t){var r=n(e,t);return shared.is.fun(r)?r(i[t]):r})}function Transition(e){var t=e.items,n=e.keys,r=void 0===n?null:n,i=e.children;return useTransition(t,r,_objectWithoutPropertiesLoose(e,["items","keys","children"])).map(function(e,t){var n=e.item,r=e.key,s=e.props,a=e.phase,o=i(n,a,t),u=shared.is.fun(o)?o(s):o;return u&&React__default.createElement(u.type,_extends({key:r},u.props))})}class FrameLoop{constructor({update:e,onFrame:t,requestFrame:n}={}){this.controllers=new Map,this.isActive=!1,this.requestFrame=n||(e=>globals.requestAnimationFrame(e)),this.onFrame=t&&t.bind(this)||(e=>{e.forEach(e=>{const t=this.controllers.get(e[0]);t&&t.onFrame(e)})}),this.update=e&&e.bind(this)||(()=>{if(!this.isActive)return!1;const e=[];for(const t of Array.from(this.controllers.keys())){let n=!1;const r=this.controllers.get(t),i=r.props.onFrame&&[];for(const e of r.configs)e.idle||this.advance(e)&&(n=!0,i&&i.push([e.key,e.animated.getValue()]));e.push([t,n,i])}return this.onFrame(e),this.controllers.size?(this.requestFrame(this.update),!0):this.isActive=!1})}start(e){this.controllers.set(e.id,e),this.isActive||(this.isActive=!0,this.requestFrame(this.update))}stop(e){this.controllers.delete(e.id)}advance(e){const t=globals.now();let n=!1,r=!1;for(let i=0;i<e.animatedValues.length;i++){const s=e.animatedValues[i];if(s.done)continue;let a=e.toValues[i];const o=a instanceof animated.Animated?a:null;if(o&&(a=o.getValue()),e.immediate){s.setValue(a),s.done=!0;continue}const u=e.fromValues[i],c=s.startTime;if("string"==typeof u||"string"==typeof a){s.setValue(a),s.done=!0;continue}let l=s.lastPosition,h=Array.isArray(e.initialVelocity)?e.initialVelocity[i]:e.initialVelocity;if(void 0!==e.duration)l=u+e.easing((t-c)/e.duration)*(a-u),r=t>=c+e.duration;else if(e.decay){const n=!0===e.decay?.998:e.decay;l=u+h/(1-n)*(1-Math.exp(-(1-n)*(t-c))),(r=Math.abs(s.lastPosition-l)<.1)&&(a=l)}else{let n=void 0!==s.lastTime?s.lastTime:t;void 0!==s.lastVelocity&&(h=s.lastVelocity),t>n+64&&(n=t);const i=Math.floor(t-n);for(let t=0;t<i;++t){l+=1*(h+=1*((-e.tension*(l-a)+-e.friction*h)/e.mass)/1e3)/1e3}s.lastTime=t,s.lastVelocity=h;const o=!(!e.clamp||0===e.tension)&&(u<a?l>a:l<a),c=Math.abs(h)<=e.precision,d=0===e.tension||Math.abs(a-l)<=e.precision;r=o||c&&d}o&&!o.done&&(r=!1),r?(s.value!==a&&(l=a),s.done=!0):n=!0,s.setValue(l),s.lastPosition=l}return n}}const stringShapeRegex=/[+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,createStringInterpolator=e=>{const t=e.output,n=t[0].match(stringShapeRegex).map(()=>[]);t.forEach(e=>{e.match(stringShapeRegex).forEach((e,t)=>n[t].push(+e))});const r=t[0].match(stringShapeRegex).map((t,r)=>shared.createInterpolator(Object.assign({},e,{output:n[r]})));return e=>{let n=0;return t[0].replace(stringShapeRegex,()=>r[n++](e))}};shared.Globals.assign({frameLoop:new FrameLoop,createStringInterpolator:createStringInterpolator,applyAnimatedValues:()=>!1,createAnimatedStyle:e=>new animated.AnimatedStyle(e),createAnimatedInterpolation:(e,...t)=>new animated.AnimatedInterpolation(e,t)});const update=()=>shared.Globals.frameLoop.update(),config={default:{tension:170,friction:26},gentle:{tension:120,friction:14},wobbly:{tension:180,friction:12},stiff:{tension:210,friction:20},slow:{tension:280,friction:60},molasses:{tension:280,friction:120}};Object.defineProperty(exports,"Globals",{enumerable:!0,get:function(){return shared.Globals}}),Object.defineProperty(exports,"createInterpolator",{enumerable:!0,get:function(){return shared.createInterpolator}}),Object.defineProperty(exports,"interpolate",{enumerable:!0,get:function(){return animated.interpolate}}),exports.Controller=Controller,exports.FrameLoop=FrameLoop,exports.Spring=Spring,exports.Trail=Trail,exports.Transition=Transition,exports.config=config,exports.update=update,exports.useChain=useChain,exports.useSpring=useSpring,exports.useSprings=useSprings,exports.useTrail=useTrail,exports.useTransition=useTransition;
//# sourceMappingURL=index.cjs.js.map

@@ -1,2 +0,2 @@

import t,{useEffect as e,useRef as n,useMemo as s,useImperativeHandle as i}from"react";import r from"@babel/runtime/helpers/esm/extends";import{is as o,usePrev as a,useOnce as c,useForceUpdate as l,Globals as u,createInterpolator as h}from"@react-spring/shared";export{Globals,createInterpolator}from"@react-spring/shared";import{__rest as f}from"tslib";import{useMemoOne as d,useCallbackOne as m}from"use-memo-one";import{now as p,frameLoop as g,createStringInterpolator as y,colorNames as v,requestAnimationFrame as b}from"@react-spring/shared/globals";import{AnimatedValueArray as E,AnimatedInterpolation as V,AnimatedValue as _,Animated as A,AnimatedStyle as k}from"@react-spring/animated";export{interpolate}from"@react-spring/animated";import w from"@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";function j(t,n,s){void 0===s&&(s=1e3),e(()=>{if(n){let e=0;t.forEach((t,i)=>{if(!t.current)return;const r=t.current.controllers;if(r.length){let t=s*n[i];isNaN(t)?t=e:e=t,r.forEach(e=>{e.queue.forEach(e=>e.delay+=t),e.start()})}})}else{let e=Promise.resolve();t.forEach(t=>{const n=t.current||{},s=n.controllers,i=n.start;if(s&&s.length){const t=s.map(t=>{const e=t.queue;return t.queue=[],e});e=e.then(()=>(s.forEach((e,n)=>e.queue.push(...t[n])),i()))}else console.warn("useChain ref has no animations:",t)})}})}function O(t,e){return null==t?e:t}function P(t){return o.und(t)?[]:Array.isArray(t)?t:[t]}function q(t,...e){return o.fun(t)?t(...e):t}function F(t){const e=function(t){return f(t,["children","config","from","to","ref","reset","cancel","reverse","immediate","delay","lazy","items","trail","unique","initial","enter","leave","update","onStart","onRest","onFrame","onDestroyed","timestamp","attach"])}(t);return t=Object.entries(t).reduce((t,[n,s])=>(n in e||(t[n]=s),t),{}),Object.assign({to:e},t)}const x=t=>t,M=Object.freeze({});let S=1;class C{constructor(t){this.id=S++,this.idle=!0,this.runCount=0,this.destroyed=!1,this.props={},this.queue=[],this.timestamps={},this.values={},this.merged={},this.animated={},this.animations={},this.configs=[],this.children=[],this.onEndQueue=[],this.cancelledAt=0,t&&this.update(t).start()}update(t){if(!t||this.destroyed)return this;const e=F(t);if(this._ensureAnimated(e.from,!0),this._ensureAnimated(e.to),e.timestamp=p(),o.fun(e.delay)&&o.obj(e.to)){const t=e.from||M;for(const n in e.to)this.queue.push(Object.assign({},e,{to:{[n]:e.to[n]},from:n in t?{[n]:t[n]}:void 0,delay:Math.max(0,Math.round(e.delay(n)))}))}else e.delay=o.num(e.delay)?Math.max(0,Math.round(e.delay)):0,e.to||(e.to=void 0),e.from||(e.from=void 0),this.queue.push(e);return this}start(t){return this.queue.length?this._flush(t):this._start(t),this}stop(...t){let e=!1;if(o.boo(t[0])&&([e,...t]=t),t.length)for(const e of t){const t=this.configs.findIndex(t=>e===t.key);this._stopAnimation(e),this.configs[t]=this.animations[e]}else this.runCount&&(this.cancelledAt=p(),this.configs.forEach(t=>this._stopAnimation(t.key)),this.configs=Object.values(this.animations),this._stop(e));return this}reset(){return this.stop(),this.destroyed=!1,this.props={},this.queue=[],this.timestamps={},this.values={},this.merged={},this.animated={},this.animations={},this.configs=[],this}destroy(){this.destroyed||(this.stop(),this.destroyed=!0)}onFrame([t,e,n]){if(t===this.id){if(n&&n.length){for(const[t,e]of n)this.values[t]=e;this.props.onFrame(Object.assign({},this.values))}e||this._stop(!0)}}setProp(t,e){return this.props[t]=e,this.timestamps[t]=p(),this}_ensureAnimated(t,e=!1){if(o.obj(t))for(const n in t){const s=t[n];let i=this.animated[n];i&&e&&this.animations[n].isNew&&(i.setValue?i.setValue(s):i=null),i||((i=N(s))?(this.animated[n]&&T(this.animated[n],i),this.animated[n]=i,this._stopAnimation(n,!0)):console.warn("Given value not animatable:",s))}}_onEnd(t){this.runCount?this.onEndQueue.push(t):t(!0)}_start(t){t&&this._onEnd(t),this.idle&&this.runCount&&(this.idle=!1,g.start(this))}_attach(t,e={}){this.children.forEach(n=>{if(e[this.id])return;e[this.id]=!0;const s=t.filter(t=>{const e=Q(n,t);if(e)return e.forEach(t=>t.done&&t.reset(!0)),!0});s.length&&(n._attach(s,e),n._start())})}_stop(t){this.idle=!0,g.stop(this);const{onEndQueue:e}=this;e.length&&(this.onEndQueue=[],e.forEach(e=>e(t)))}_flush(t){const e=this.queue.reduce(R,[]);this.queue.length=0;let n=Object.keys(e).length;this.runCount+=n;const s=e=>{if(this.runCount--,!--n&&(t&&t(e),!this.runCount&&e)){const{onRest:t}=this.props;t&&t(this.merged)}};e.forEach((t,e)=>{e?setTimeout(()=>{t.timestamp<this.cancelledAt||this._run(t,s)},e):this._run(t,s)})}_run(t,e){o.arr(t.to)||o.fun(t.to)?this._runAsync(t,e):this._diff(t)?this._animate(t)._start(e):this._onEnd(e)}_runAsync(t,e){var{to:n}=t,s=f(t,["to"]);if(this._diff(s)&&this._animate(s),!0===s.cancel)return this.props.asyncTo=void 0,e(!1);const{timestamp:i}=s;if(!this._diff({asyncTo:n,timestamp:i}))return e(!1);const r=()=>i<this.cancelledAt||o.fun(n)&&n!==this.props.asyncTo;let a;const c=t=>{if(r())throw this;return(a=new Promise(e=>{this.update(t).start(e)})).then(()=>{if(r())throw this})};let l=Promise.resolve();o.arr(n)?n.forEach(t=>l=l.then(()=>c(t))):o.fun(n)&&(l=l.then(()=>n(c,this.stop.bind(this)).then(()=>a))),l.catch(t=>t!==this&&console.error(t)).then(()=>e(!r()))}_diff(t){var{timestamp:e,delay:n,config:s,immediate:i,reverse:r,attach:a}=t,c=f(t,["timestamp","delay","config","immediate","reverse","attach"]);let l=!1;const u=(t,n,s)=>{if(o.und(n))return;const i=t[t.length-1];if(o.obj(n)){o.obj(s[i])||(s[i]={});for(const e in n)u(t.concat(e),n[e],s[i])}else{const r=t.join("."),a=this.timestamps[r];if(o.und(a)||e>=a){this.timestamps[r]=e,I(n,s[i])||(l=!0,s[i]=n)}}};if(r){const{to:t}=c;c.to=c.from,c.from=o.obj(t)?t:void 0}c.parent=(a?a(this):c.parent)||null;const h=this.props.parent||null;c.parent!==h&&(h&&h.children.splice(h.children.indexOf(this),1),c.parent&&c.parent.children.push(this));for(const t in c)u([t],c[t],this.props);return"reset"in c&&(this.props.reset=!1),"cancel"in c&&(this.props.cancel=void 0),l}_isModified(t,e){return this.timestamps[e]===t.timestamp}_animate(t){const{from:e=M,to:n=M,parent:s,onStart:i}=this.props;let r=t=>!1;if(t.cancel&&this._isModified(t,"cancel")){if(!0===t.cancel)return this.stop(),this.cancelledAt=t.timestamp,this;const e=P(t.cancel);o.arr(e)&&e.length&&(r=t=>e.indexOf(t)>=0,this.stop(...e))}var a;this.merged=(a=Object.assign({},e,n),"undefined"!=typeof process&&"development"===process.env.NODE_ENV?Object.freeze(a):a);let c=!1;const l=[],u=s&&this._isModified(t,"parent");for(const n in this.merged){if(r(n))continue;const i=this.animations[n];if(!i){console.warn(`Failed to animate key: "${n}"\n`+`Did you forget to define "from.${n}" for an async animation?`);continue}let{animated:a,animatedValues:h}=i;const f=this.merged[n],d=D(f),m=a.getValue();if(t.reset||u||!I(d,m)){if(t.reset||u||!I(d,i.isNew?m:i.goalValue)){let{immediate:i}=o.und(t.immediate)?this.props:t;i=!!q(i,n);const r=h.some(t=>!t.done),u=o.und(e[n])?d:D(e[n]),m=K(f);if(m){const e=[t.reset?u:a.getValue(),d];let n=h[0];n?(n.setValue(0,!1),n.reset(r)):n=new _(0);try{T(a,a=n.interpolate({output:e}))}catch(t){console.warn('Failed to interpolate string from "%s" to "%s"',e[0],e[1]),console.error(t);continue}i&&n.setValue(1,!1)}else{if(o.arr(f))if(a instanceof E)t.reset&&a.setValue(u,!1),h.forEach(t=>t.reset(r));else{T(a,a=N(u))}else if(a instanceof _)t.reset&&a.setValue(u,!1),a.reset(r);else{T(a,a=new _(u))}i&&a.setValue(d,!1)}const p=q(t.config,n)||q(this.props.config,n)||M;i||l.push(n);const g=h.map(t=>t.getValue()),y=s&&Q(s,n)||P(m?1:d);c=!0,h=P(a.getPayload()),this.animations[n]={key:n,idle:!1,goalValue:d,toValues:y,fromValues:g,animated:a,animatedValues:h,immediate:i,duration:p.duration,easing:O(p.easing,x),decay:p.decay,mass:O(p.mass,1),tension:O(p.tension,170),friction:O(p.friction,26),initialVelocity:O(p.velocity,0),clamp:O(p.clamp,!1),precision:O(p.precision,.005),config:p}}}else i.idle||(c=!0,this._stopAnimation(n))}if(c){l.length&&(this._attach(l),i&&l.forEach(t=>{i(this.animations[t])}));const t=Object.keys(this.animations);this.configs.length=t.length,t.forEach((t,e)=>{const n=this.animations[t];this.configs[e]=n,this.values[t]=n.animated.getValue(),this.animated[t]=n.animated})}return this}_stopAnimation(t,e){const n=this.animated[t];if(!n)return console.warn(`Cannot stop an animation for a key that isn't animated: "${t}"`);this.timestamps["to."+t]=p();const s=this.animations[t]||M;if(s.idle&&n===s.animated)return;o.und(e)&&(e=!!s.isNew);const i=P(n.getPayload());i.forEach(t=>t.done=!0);const r=n.getValue();this.props.to&&(this.props.to[t]=r),this.animations[t]={key:t,idle:!0,isNew:e,goalValue:r,animated:n,animatedValues:i}}}function N(t){return o.arr(t)?new E(t.map(t=>{const e=N(t),n=e.getPayload();return e instanceof V?n[0]:n})):K(t)?new _(0).interpolate({output:[t,t]}):new _(t)}function T(t,e){t.getChildren().slice().forEach(n=>{t.removeChild(n),e.addChild(n);const s=n.getPayload();if(o.arr(s)){const i=s.indexOf(t);if(i>=0){const t=[...s];t[i]=e,n.payload=t}}else if(o.obj(s)){const i=Object.entries(s).find(e=>e[1]===t);i&&(n.payload=Object.assign({},s,{[i[0]]:e}))}})}function R(t,e){const n=t[e.delay];return n?(e.to=z(n.to,e.to),e.from=z(n.from,e.from),Object.assign(n,e)):t[e.delay]=e,t}function z(t,e){return o.obj(t)&&o.obj(e)?Object.assign({},t,e):e||t}function K(t){return!!o.str(t)&&(t.startsWith("#")||/\d/.test(t)||!!v[t])}function D(t){return o.arr(t)?t.map(D):K(t)?y({range:[0,1],output:[t,t]})(1):t}function I(t,e){if(o.arr(t)){if(!o.arr(e)||t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;return!0}return t===e}function Q(t,e){const n=t.animations[e];return n&&n.animatedValues}const L=(t,l,u)=>{const h=t!==a(t),f=o.fun(l),m=n({springs:[],ref:null}).current,p=f?[]:l,g=d(()=>(function(t,e){const n=[];for(let s=0;s<t;s++)n.push(e(s));return n})(t,t=>{const e=new C,n=p[t]||(p[t]=q(l,t,e));return e.update(n)}),[t]),y=s(()=>({start:()=>Promise.all(m.springs.map(t=>new Promise(e=>t.start(e)))),update:t=>{const e=o.fun(t),n=o.arr(t);m.springs.forEach((s,i)=>{s.update(e?q(t,i,s):n?t[i]:t),m.ref||s.start()})},stop:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return m.springs.forEach(t=>t.stop(...e))}}),[]),v=y.start,b=y.update,E=y.stop,V=p[0]?p[0].ref:f?m.ref:null;i(V,()=>({start:v,stop:E,get controllers(){return m.springs}})),e(()=>{f&&!h||p.forEach((t,e)=>{g[e].setProp("config",t.config),g[e].setProp("immediate",t.immediate)}),h?(m.springs.forEach(t=>t.destroy()),m.springs=g,m.ref=V,V||g.forEach(t=>t.start())):f||b(p)},u),c(()=>()=>{m.springs.forEach(t=>t.destroy())});const _=g.map(t=>r({},t.animated));return f?[_,b,E]:_},$=(t,e)=>{const n=o.fun(t),s=L(1,n?t:[t],e),i=s[0],r=s[1],a=s[2];return n?[i[0],r,a]:i},G=(t,s)=>{const i=t!==a(t),c=o.fun(s);let l=c?null:s;const u=n([]),h=u.current;i&&(h.length=t);const f=L(t,(t,e)=>(c&&!l&&(l=q(s,e)||{}),h[t]=e,r({},l,t>0&&{attach:()=>h[t-1],onStart:U(l.onStart,t),onFrame:U(l.onFrame,t),onRest:U(l.onRest,t)},{config:q(l.config,t)}))),d=f[0],p=f[1],g=f[2],y=m(t=>p((e,n)=>{const s=q(t,e,n)||{},i=u.current[s.reverse?e+1:e-1];return r({},s,{attach:()=>i,config:q(s.config,e)})}),[]);return e(()=>{c||i||y(s)}),c?[d,y,g]:d};function U(t,e){return o.fun(t)?function(){for(var n=arguments.length,s=new Array(n),i=0;i<n;i++)s[i]=arguments[i];return t(...s,e)}:t}let W=0;const B="initial",H="enter",J="update",X="leave",Y=(t,e)=>("function"==typeof e?t.map(e):P(e)).map(String),Z=t=>{let e=t.items,n=t.keys,s=w(t,["items","keys"]);return e=P(o.und(e)?null:e),r({items:e,keys:Y(e,n)},s)};function tt(t,e,s){const a=s=Z(r({},s,{items:t,keys:e||(t=>t)})),u=a.lazy,h=void 0!==u&&u,d=(a.unique,a.from,a.enter,a.leave,a.update,a.onDestroyed),m=(a.keys,a.items,a.onFrame),p=a.onRest,g=a.onStart,y=a.ref,v=w(a,["lazy","unique","from","enter","leave","update","onDestroyed","keys","items","onFrame","onRest","onStart","ref"]),b=l(),E=n(!1),V=n({mounted:!1,first:!0,deleted:[],current:{},transitions:[],prevProps:{},paused:!!s.ref,instances:!E.current&&new Map,forceUpdate:b});return i(s.ref,()=>({start:()=>Promise.all(Array.from(V.current.instances).map(t=>{let e=t[1];return new Promise(t=>e.start(t))})),stop:t=>Array.from(V.current.instances).forEach(e=>{return e[1].stop(t)}),get controllers(){return Array.from(V.current.instances).map(t=>{return t[1]})}})),V.current=function(t,e){let n=t.first,s=t.current,i=t.deleted,a=t.prevProps,c=w(t,["first","current","deleted","prevProps"]),l=e.items,u=e.keys,h=e.initial,d=e.from,m=e.enter,p=e.leave,g=e.update,y=e.trail,v=void 0===y?0:y,b=e.unique,E=e.config,V=e.order,_=void 0===V?[H,X,J]:V,A=Z(a),k=A.keys,j=A.items;e.reset&&(s={},c.transitions=[]);const O=Object.keys(s),P=new Set(O),x=new Set(u),M=u.filter(t=>!P.has(t)),S=g?u.filter(t=>P.has(t)):[],C=c.transitions.filter(t=>!t.destroyed&&!x.has(t.originalKey)).map(t=>t.originalKey);let N=-v;for(;_.length;){let t=_.shift();t===H?(n&&!o.und(h)&&(t=B,d=h),M.forEach(e=>{b&&i.find(t=>t.originalKey===e)&&(i=i.filter(t=>t.originalKey!==e));const n=u.indexOf(e),a=l[n],c=q(m,a,n);s[e]={phase:t,originalKey:e,key:b?String(e):W++,item:a,props:r({delay:N+=v,config:q(E,a,t),from:q(d,a),to:c},o.obj(c)&&F(c))}})):t===X?C.forEach(e=>{const n=k.indexOf(e),a=j[n],c=q(p,a,n);i.push(r({},s[e],{phase:t,destroyed:!0,left:k[n-1],right:k[n+1],props:r({delay:N+=v,config:q(E,a,t),to:c},o.obj(c)&&F(c))})),delete s[e]}):t===J&&S.forEach(e=>{const n=u.indexOf(e),i=l[n],a=q(g,i,n);s[e]=r({},s[e],{phase:t,props:r({delay:N+=v,config:q(E,i,t),to:a},o.obj(a)&&F(a))})})}let T=u.map(t=>s[t]);return T=function(t,e){t=[...t],e=[...e];let n=0,s=0,i=t.length;for(let r=0;r<t.length;r++){if(r===i){if(s+n===i){for(let n=r;n<t.length;n++){const s=t[n],i=f(s,["left","right"]);e.push(i)}break}s=i,i=t.length,n=0}let o=-1;const a=t[r],{left:c,right:l}=a,u=f(a,["left","right"]);for(let t=e.length;--t>=0;){const{originalKey:n}=e[t];if(n===l){o=t;break}if(n===c){o=t+1;break}}o<0?(n++,t.push(t[r])):e.splice(o,0,u)}return e}(i,T),r({},c,{first:n&&!M.length,changed:!!(M.length||C.length||S.length),transitions:T,current:s,deleted:i,prevProps:e})}(V.current,s),V.current.changed&&V.current.transitions.forEach(t=>{const e=t.phase,n=t.key,s=t.item,i=t.props;V.current.instances.has(n)||V.current.instances.set(n,new C);let o=!1;const a=V.current.instances.get(n),c=r({},v,i,{ref:y,onRest:i=>{if(V.current.mounted){t.destroyed&&(y||h||et(V,n),d&&d(s)),!Array.from(V.current.instances).some(t=>{return!t[1].idle})&&(y||h)&&V.current.deleted.length>0&&et(V),p&&p(s,e,i)}},onFrame:m&&(t=>m(s,e,t)),onStart:g&&(t=>o||(g(s,e,t),o=!0))});a.update(c),V.current.paused||a.start()}),c(()=>(V.current.mounted=E.current=!0,()=>{V.current.mounted=E.current=!1,Array.from(V.current.instances).map(t=>{return t[1].destroy()}),V.current.instances.clear()})),V.current.transitions.map(t=>{let e=t.item,n=t.phase,s=t.key;return{item:e,key:s,phase:n,props:r({},V.current.instances.get(s).animated)}})}function et(t,e){let n=t.current;const s=n.deleted;for(let t of s){let s=t.key;const i=t=>t.key!==s;(o.und(e)||e===s)&&(n.instances.delete(s),n.transitions=n.transitions.filter(i),n.deleted=n.deleted.filter(i))}n.forceUpdate()}function nt(t){let e=t.children,n=w(t,["children"]);return e($(n))}function st(t){let e=t.items,n=t.children,s=w(t,["items","children"]);const i=G(e.length,s);return e.map((t,e)=>{const s=n(t,e);return o.fun(s)?s(i[e]):s})}function it(e){let n=e.items,s=e.keys,i=void 0===s?null:s,a=e.children;return tt(n,i,w(e,["items","keys","children"])).map((e,n)=>{let s=e.item,i=e.key,c=e.props,l=e.phase;const u=a(s,l,n),h=o.fun(u)?u(c):u;return h&&t.createElement(h.type,r({key:i},h.props))})}const rt=b;class ot{constructor({update:t,onFrame:e,requestFrame:n}={}){this.controllers=new Map,this.isActive=!1,this.requestFrame=n||(t=>rt(t)),this.onFrame=e&&e.bind(this)||(t=>{t.forEach(t=>{const e=this.controllers.get(t[0]);e&&e.onFrame(t)})}),this.update=t&&t.bind(this)||(()=>{if(!this.isActive)return!1;const t=[];for(const e of Array.from(this.controllers.keys())){let n=!1;const s=this.controllers.get(e),i=s.props.onFrame&&[];for(const t of s.configs)t.idle||this.advance(t)&&(n=!0,i&&i.push([t.key,t.animated.getValue()]));t.push([e,n,i])}return this.onFrame(t),this.controllers.size?(this.requestFrame(this.update),!0):this.isActive=!1})}start(t){this.controllers.set(t.id,t),this.isActive||(this.isActive=!0,this.requestFrame(this.update))}stop(t){this.controllers.delete(t.id)}advance(t){const e=p();let n=!1,s=!1;for(let i=0;i<t.animatedValues.length;i++){const r=t.animatedValues[i];if(r.done)continue;let o=t.toValues[i];const a=o instanceof A?o:null;if(a&&(o=a.getValue()),t.immediate){r.setValue(o),r.done=!0;continue}const c=t.fromValues[i],l=r.startTime;if("string"==typeof c||"string"==typeof o){r.setValue(o),r.done=!0;continue}let u=r.lastPosition,h=Array.isArray(t.initialVelocity)?t.initialVelocity[i]:t.initialVelocity;if(void 0!==t.duration)u=c+t.easing((e-l)/t.duration)*(o-c),s=e>=l+t.duration;else if(t.decay){const n=!0===t.decay?.998:t.decay;u=c+h/(1-n)*(1-Math.exp(-(1-n)*(e-l))),(s=Math.abs(r.lastPosition-u)<.1)&&(o=u)}else{let n=void 0!==r.lastTime?r.lastTime:e;void 0!==r.lastVelocity&&(h=r.lastVelocity),e>n+64&&(n=e);const i=Math.floor(e-n);for(let e=0;e<i;++e){u+=1*(h+=1*((-t.tension*(u-o)+-t.friction*h)/t.mass)/1e3)/1e3}r.lastTime=e,r.lastVelocity=h;const a=!(!t.clamp||0===t.tension)&&(c<o?u>o:u<o),l=Math.abs(h)<=t.precision,f=0===t.tension||Math.abs(o-u)<=t.precision;s=a||l&&f}a&&!a.done&&(s=!1),s?(r.value!==o&&(u=o),r.done=!0):n=!0,r.setValue(u),r.lastPosition=u}return n}}const at=/[+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?/g;u.assign({frameLoop:new ot,createStringInterpolator:t=>{const e=t.output,n=e[0].match(at).map(()=>[]);e.forEach(t=>{t.match(at).forEach((t,e)=>n[e].push(+t))});const s=e[0].match(at).map((e,s)=>h(Object.assign({},t,{output:n[s]})));return t=>{let n=0;return e[0].replace(at,()=>s[n++](t))}},applyAnimatedValues:()=>!1,createAnimatedStyle:t=>new k(t),createAnimatedInterpolation:(t,...e)=>new V(t,e)});const ct=()=>u.frameLoop.update(),lt={default:{tension:170,friction:26},gentle:{tension:120,friction:14},wobbly:{tension:180,friction:12},stiff:{tension:210,friction:20},slow:{tension:280,friction:60},molasses:{tension:280,friction:120}};export{C as Controller,ot as FrameLoop,nt as Spring,st as Trail,it as Transition,lt as config,ct as update,j as useChain,$ as useSpring,L as useSprings,G as useTrail,tt as useTransition};
import t,{useEffect as e,useRef as n,useMemo as s,useImperativeHandle as i}from"react";import r from"@babel/runtime/helpers/esm/extends";import{is as o,usePrev as a,useOnce as c,useForceUpdate as l,Globals as u,createInterpolator as h}from"@react-spring/shared";export{Globals,createInterpolator}from"@react-spring/shared";import{__rest as f}from"tslib";import{useMemoOne as d,useCallbackOne as m}from"use-memo-one";import{now as p,frameLoop as g,createStringInterpolator as y,colorNames as v,requestAnimationFrame as b}from"@react-spring/shared/globals";import{AnimatedValueArray as E,AnimatedInterpolation as V,AnimatedValue as _,Animated as A,AnimatedStyle as k}from"@react-spring/animated";export{interpolate}from"@react-spring/animated";import w from"@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";function j(t,n,s){void 0===s&&(s=1e3),e(()=>{if(n){let e=0;t.forEach((t,i)=>{if(!t.current)return;const r=t.current.controllers;if(r.length){let t=s*n[i];isNaN(t)?t=e:e=t,r.forEach(e=>{e.queue.forEach(e=>e.delay+=t),e.start()})}})}else{let e=Promise.resolve();t.forEach(t=>{const n=t.current||{},s=n.controllers,i=n.start;if(s&&s.length){const t=s.map(t=>{const e=t.queue;return t.queue=[],e});e=e.then(()=>(s.forEach((e,n)=>e.queue.push(...t[n])),i()))}else console.warn("useChain ref has no animations:",t)})}})}function O(t,e){return null==t?e:t}function P(t){return o.und(t)?[]:Array.isArray(t)?t:[t]}function q(t,...e){return o.fun(t)?t(...e):t}function F(t){const e=function(t){return f(t,["children","config","from","to","ref","reset","cancel","reverse","immediate","delay","lazy","items","trail","unique","initial","enter","leave","update","onStart","onRest","onFrame","onDestroyed","timestamp","attach"])}(t);return t=Object.entries(t).reduce((t,[n,s])=>(n in e||(t[n]=s),t),{}),Object.assign({to:e},t)}const x=t=>t,M=Object.freeze({});let S=1;class C{constructor(t){this.id=S++,this.idle=!0,this.runCount=0,this.destroyed=!1,this.props={},this.queue=[],this.timestamps={},this.values={},this.merged={},this.animated={},this.animations={},this.configs=[],this.children=[],this.onEndQueue=[],this.cancelledAt=0,t&&this.update(t).start()}update(t){if(!t||this.destroyed)return this;const e=F(t);if(this._ensureAnimated(e.from,!0),this._ensureAnimated(e.to),e.timestamp=p(),o.fun(e.delay)&&o.obj(e.to)){const t=e.from||M;for(const n in e.to)this.queue.push(Object.assign({},e,{to:{[n]:e.to[n]},from:n in t?{[n]:t[n]}:void 0,delay:Math.max(0,Math.round(e.delay(n)))}))}else e.delay=o.num(e.delay)?Math.max(0,Math.round(e.delay)):0,e.to||(e.to=void 0),e.from||(e.from=void 0),this.queue.push(e);return this}start(t){return this.queue.length?this._flush(t):this._start(t),this}stop(...t){let e=!1;if(o.boo(t[0])&&([e,...t]=t),t.length)for(const e of t){const t=this.configs.findIndex(t=>e===t.key);this._stopAnimation(e),this.configs[t]=this.animations[e]}else this.runCount&&(this.cancelledAt=p(),this.configs.forEach(t=>this._stopAnimation(t.key)),this.configs=Object.values(this.animations),this._stop(e));return this}reset(){return this.stop(),this.destroyed=!1,this.props={},this.queue=[],this.timestamps={},this.values={},this.merged={},this.animated={},this.animations={},this.configs=[],this}destroy(){this.destroyed||(this.stop(),this.destroyed=!0)}onFrame([t,e,n]){if(t===this.id){if(n&&n.length){for(const[t,e]of n)this.values[t]=e;this.props.onFrame(Object.assign({},this.values))}e||this._stop(!0)}}setProp(t,e){return this.props[t]=e,this.timestamps[t]=p(),this}_ensureAnimated(t,e=!1){if(o.obj(t))for(const n in t){const s=t[n];let i=this.animated[n];i&&e&&this.animations[n].isNew&&(i.setValue?i.setValue(s):i=null),i||((i=N(s))?(this.animated[n]&&T(this.animated[n],i),this.animated[n]=i,this._stopAnimation(n,!0)):console.warn("Given value not animatable:",s))}}_onEnd(t){this.runCount?this.onEndQueue.push(t):t(!0)}_start(t){t&&this._onEnd(t),this.idle&&this.runCount&&(this.idle=!1,g.start(this))}_attach(t,e={}){this.children.forEach(n=>{if(e[this.id])return;e[this.id]=!0;const s=t.filter(t=>{const e=Q(n,t);if(e)return e.forEach(t=>t.done&&t.reset(!0)),!0});s.length&&(n._attach(s,e),n._start())})}_stop(t){this.idle=!0,g.stop(this);const{onEndQueue:e}=this;e.length&&(this.onEndQueue=[],e.forEach(e=>e(t)))}_flush(t){const e=this.queue.reduce(R,[]);this.queue.length=0;let n=Object.keys(e).length;this.runCount+=n;const s=e=>{if(this.runCount--,!--n&&(t&&t(e),!this.runCount&&e)){const{onRest:t}=this.props;t&&t(this.merged)}};e.forEach((t,e)=>{e?setTimeout(()=>{t.timestamp<this.cancelledAt||this._run(t,s)},e):this._run(t,s)})}_run(t,e){o.arr(t.to)||o.fun(t.to)?this._runAsync(t,e):this._diff(t)?this._animate(t)._start(e):this._onEnd(e)}_runAsync(t,e){var{to:n}=t,s=f(t,["to"]);if(this._diff(s)&&this._animate(s),!0===s.cancel)return this.props.asyncTo=void 0,e(!1);const{timestamp:i}=s;if(!this._diff({asyncTo:n,timestamp:i}))return e(!1);const r=()=>i<this.cancelledAt||o.fun(n)&&n!==this.props.asyncTo;let a;const c=t=>{if(r())throw this;return(a=new Promise(e=>{this.update(t).start(e)})).then(()=>{if(r())throw this})};let l=Promise.resolve();o.arr(n)?n.forEach(t=>l=l.then(()=>c(t))):o.fun(n)&&(l=l.then(()=>n(c,this.stop.bind(this)).then(()=>a))),l.catch(t=>t!==this&&console.error(t)).then(()=>e(!r()))}_diff(t){var{timestamp:e,delay:n,config:s,immediate:i,reverse:r,attach:a}=t,c=f(t,["timestamp","delay","config","immediate","reverse","attach"]);let l=!1;const u=(t,n,s)=>{if(o.und(n))return;const i=t[t.length-1];if(o.obj(n)){o.obj(s[i])||(s[i]={});for(const e in n)u(t.concat(e),n[e],s[i])}else{const r=t.join("."),a=this.timestamps[r];if(o.und(a)||e>=a){this.timestamps[r]=e,I(n,s[i])||(l=!0,s[i]=n)}}};if(r){const{to:t}=c;c.to=c.from,c.from=o.obj(t)?t:void 0}c.parent=(a?a(this):c.parent)||null;const h=this.props.parent||null;c.parent!==h&&(h&&h.children.splice(h.children.indexOf(this),1),c.parent&&c.parent.children.push(this));for(const t in c)u([t],c[t],this.props);return"reset"in c&&(this.props.reset=!1),"cancel"in c&&(this.props.cancel=void 0),l}_isModified(t,e){return this.timestamps[e]===t.timestamp}_animate(t){const{from:e=M,to:n=M,parent:s,onStart:i}=this.props;let r=t=>!1;if(t.cancel&&this._isModified(t,"cancel")){if(!0===t.cancel)return this.stop(),this.cancelledAt=t.timestamp,this;const e=P(t.cancel);o.arr(e)&&e.length&&(r=t=>e.indexOf(t)>=0,this.stop(...e))}var a;this.merged=(a=Object.assign({},e,n),"undefined"!=typeof process&&"development"===process.env.NODE_ENV?Object.freeze(a):a);let c=!1;const l=[],u=s&&this._isModified(t,"parent");for(const n in this.merged){if(r(n))continue;const i=this.animations[n];if(!i){console.warn(`Failed to animate key: "${n}"\n`+`Did you forget to define "from.${n}" for an async animation?`);continue}let{animated:a,animatedValues:h}=i;const f=this.merged[n],d=D(f),m=a.getValue();if(t.reset||u||!I(d,m)){if(t.reset||u||!I(d,i.isNew?m:i.goalValue)){let{immediate:i}=o.und(t.immediate)?this.props:t;i=!!q(i,n);const r=h.some(t=>!t.done),u=o.und(e[n])?d:D(e[n]),m=K(f);if(m){const e=[t.reset?u:a.getValue(),d];let n=h[0];n?(n.setValue(0,!1),n.reset(r)):n=new _(0);try{T(a,a=n.interpolate({output:e}))}catch(t){console.warn('Failed to interpolate string from "%s" to "%s"',e[0],e[1]),console.error(t);continue}i&&n.setValue(1,!1)}else{if(o.arr(f))if(a instanceof E)t.reset&&a.setValue(u,!1),h.forEach(t=>t.reset(r));else{T(a,a=N(u))}else if(a instanceof _)t.reset&&a.setValue(u,!1),a.reset(r);else{T(a,a=new _(u))}i&&a.setValue(d,!1)}const p=q(t.config,n)||q(this.props.config,n)||M;i||l.push(n);const g=h.map(t=>t.getValue()),y=s&&Q(s,n)||P(m?1:d);c=!0,h=P(a.getPayload()),this.animations[n]={key:n,idle:!1,goalValue:d,toValues:y,fromValues:g,animated:a,animatedValues:h,immediate:i,duration:p.duration,easing:O(p.easing,x),decay:p.decay,mass:O(p.mass,1),tension:O(p.tension,170),friction:O(p.friction,26),initialVelocity:O(p.velocity,0),clamp:O(p.clamp,!1),precision:O(p.precision,.005),config:p}}}else i.idle||(c=!0,this._stopAnimation(n))}if(c){l.length&&(this._attach(l),i&&l.forEach(t=>{i(this.animations[t])}));const t=Object.keys(this.animations);this.configs.length=t.length,t.forEach((t,e)=>{const n=this.animations[t];this.configs[e]=n,this.values[t]=n.animated.getValue(),this.animated[t]=n.animated})}return this}_stopAnimation(t,e){const n=this.animated[t];if(!n)return console.warn(`Cannot stop an animation for a key that isn't animated: "${t}"`);this.timestamps["to."+t]=p();const s=this.animations[t]||M;if(s.idle&&n===s.animated)return;o.und(e)&&(e=!!s.isNew);const i=P(n.getPayload());i.forEach(t=>t.done=!0);const r=n.getValue();this.props.to&&(this.props.to[t]=r),this.animations[t]={key:t,idle:!0,isNew:e,goalValue:r,animated:n,animatedValues:i}}}function N(t){return o.arr(t)?new E(t.map(t=>{const e=N(t),n=e.getPayload();return e instanceof V?n[0]:n})):K(t)?new _(0).interpolate({output:[t,t]}):new _(t)}function T(t,e){t.getChildren().slice().forEach(n=>{t.removeChild(n),e.addChild(n);const s=n.getPayload();if(o.arr(s)){const i=s.indexOf(t);if(i>=0){const t=[...s];t[i]=e,n.payload=t}}else if(o.obj(s)){const i=Object.entries(s).find(e=>e[1]===t);i&&(n.payload=Object.assign({},s,{[i[0]]:e}))}})}function R(t,e){const n=t[e.delay];return n?(e.to=z(n.to,e.to),e.from=z(n.from,e.from),Object.assign(n,e)):t[e.delay]=e,t}function z(t,e){return o.obj(t)&&o.obj(e)?Object.assign({},t,e):e||t}function K(t){return!!o.str(t)&&(t.startsWith("#")||/\d/.test(t)||!!v[t])}function D(t){return o.arr(t)?t.map(D):K(t)?y({range:[0,1],output:[t,t]})(1):t}function I(t,e){if(o.arr(t)){if(!o.arr(e)||t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;return!0}return t===e}function Q(t,e){const n=t.animations[e];return n&&n.animatedValues}const L=(t,l,u)=>{const h=t!==a(t),f=o.fun(l),m=n({springs:[],ref:null}).current,p=f?[]:l,g=d(()=>(function(t,e){const n=[];for(let s=0;s<t;s++)n.push(e(s));return n})(t,t=>{const e=new C,n=p[t]||(p[t]=q(l,t,e));return e.update(n)}),[t]),y=s(()=>({start:()=>Promise.all(m.springs.map(t=>new Promise(e=>t.start(e)))),update:t=>{const e=o.fun(t),n=o.arr(t);m.springs.forEach((s,i)=>{s.update(e?q(t,i,s):n?t[i]:t),m.ref||s.start()})},stop:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return m.springs.forEach(t=>t.stop(...e))}}),[]),v=y.start,b=y.update,E=y.stop,V=p[0]?p[0].ref:f?m.ref:null;i(V,()=>({start:v,stop:E,get controllers(){return m.springs}})),e(()=>{f&&!h||p.forEach((t,e)=>{g[e].setProp("config",t.config),g[e].setProp("immediate",t.immediate)}),h?(m.springs.forEach(t=>t.destroy()),m.springs=g,m.ref=V,V||g.forEach(t=>t.start())):f||b(p)},u),c(()=>()=>{m.springs.forEach(t=>t.destroy())});const _=g.map(t=>r({},t.animated));return f?[_,b,E]:_},$=(t,e)=>{const n=o.fun(t),s=L(1,n?t:[t],e),i=s[0],r=s[1],a=s[2];return n?[i[0],r,a]:i},G=(t,s)=>{const i=t!==a(t),c=o.fun(s);let l=c?null:s;const u=n([]),h=u.current;i&&(h.length=t);const f=L(t,(t,e)=>(c&&!l&&(l=q(s,e)||{}),h[t]=e,r({},l,t>0&&{attach:()=>h[t-1],onStart:U(l.onStart,t),onFrame:U(l.onFrame,t),onRest:U(l.onRest,t)},{config:q(l.config,t)}))),d=f[0],p=f[1],g=f[2],y=m(t=>p((e,n)=>{const s=q(t,e,n)||{},i=u.current[s.reverse?e+1:e-1];return r({},s,{attach:()=>i,config:q(s.config,e)})}),[]);return e(()=>{c||i||y(s)}),c?[d,y,g]:d};function U(t,e){return o.fun(t)?function(){for(var n=arguments.length,s=new Array(n),i=0;i<n;i++)s[i]=arguments[i];return t(...s,e)}:t}let W=0;const B="initial",H="enter",J="update",X="leave",Y=(t,e)=>("function"==typeof e?t.map(e):P(e)).map(String),Z=t=>{let e=t.items,n=t.keys,s=w(t,["items","keys"]);return e=P(o.und(e)?null:e),r({items:e,keys:Y(e,n)},s)};function tt(t,e,s){const a=s=Z(r({},s,{items:t,keys:e||(t=>t)})),u=a.lazy,h=void 0!==u&&u,d=(a.unique,a.from,a.enter,a.leave,a.update,a.onDestroyed),m=(a.keys,a.items,a.onFrame),p=a.onRest,g=a.onStart,y=a.ref,v=w(a,["lazy","unique","from","enter","leave","update","onDestroyed","keys","items","onFrame","onRest","onStart","ref"]),b=l(),E=n(!1),V=n({mounted:!1,first:!0,deleted:[],current:{},transitions:[],prevProps:{},paused:!!s.ref,instances:!E.current&&new Map,forceUpdate:b});return i(s.ref,()=>({start:()=>Promise.all(Array.from(V.current.instances).map(t=>{let e=t[1];return new Promise(t=>e.start(t))})),stop:t=>Array.from(V.current.instances).forEach(e=>{return e[1].stop(t)}),get controllers(){return Array.from(V.current.instances).map(t=>{return t[1]})}})),V.current=function(t,e){let n=t.first,s=t.current,i=t.deleted,a=t.prevProps,c=w(t,["first","current","deleted","prevProps"]),l=e.items,u=e.keys,h=e.initial,d=e.from,m=e.enter,p=e.leave,g=e.update,y=e.trail,v=void 0===y?0:y,b=e.unique,E=e.config,V=e.order,_=void 0===V?[H,X,J]:V,A=Z(a),k=A.keys,j=A.items;e.reset&&(s={},c.transitions=[]);const O=Object.keys(s),P=new Set(O),x=new Set(u),M=u.filter(t=>!P.has(t)),S=g?u.filter(t=>P.has(t)):[],C=c.transitions.filter(t=>!t.destroyed&&!x.has(t.originalKey)).map(t=>t.originalKey);let N=-v;for(;_.length;){let t=_.shift();t===H?(n&&!o.und(h)&&(t=B,d=h),M.forEach(e=>{b&&i.find(t=>t.originalKey===e)&&(i=i.filter(t=>t.originalKey!==e));const n=u.indexOf(e),a=l[n],c=q(m,a,n);s[e]={phase:t,originalKey:e,key:b?String(e):W++,item:a,props:r({delay:N+=v,config:q(E,a,t),from:q(d,a),to:c},o.obj(c)&&F(c))}})):t===X?C.forEach(e=>{const n=k.indexOf(e),a=j[n],c=q(p,a,n);i.push(r({},s[e],{phase:t,destroyed:!0,left:k[n-1],right:k[n+1],props:r({delay:N+=v,config:q(E,a,t),to:c},o.obj(c)&&F(c))})),delete s[e]}):t===J&&S.forEach(e=>{const n=u.indexOf(e),i=l[n],a=q(g,i,n);s[e]=r({},s[e],{phase:t,props:r({delay:N+=v,config:q(E,i,t),to:a},o.obj(a)&&F(a))})})}let T=u.map(t=>s[t]);return T=function(t,e){t=[...t],e=[...e];let n=0,s=0,i=t.length;for(let r=0;r<t.length;r++){if(r===i){if(s+n===i){for(let n=r;n<t.length;n++){const s=t[n],i=f(s,["left","right"]);e.push(i)}break}s=i,i=t.length,n=0}let o=-1;const a=t[r],{left:c,right:l}=a,u=f(a,["left","right"]);for(let t=e.length;--t>=0;){const{originalKey:n}=e[t];if(n===l){o=t;break}if(n===c){o=t+1;break}}o<0?(n++,t.push(t[r])):e.splice(o,0,u)}return e}(i,T),r({},c,{first:n&&!M.length,changed:!!(M.length||C.length||S.length),transitions:T,current:s,deleted:i,prevProps:e})}(V.current,s),V.current.changed&&V.current.transitions.forEach(t=>{const e=t.phase,n=t.key,s=t.item,i=t.props;V.current.instances.has(n)||V.current.instances.set(n,new C);let o=!1;const a=V.current.instances.get(n),c=r({},v,i,{ref:y,onRest:i=>{if(V.current.mounted){t.destroyed&&(y||h||et(V,n),d&&d(s)),!Array.from(V.current.instances).some(t=>{return!t[1].idle})&&(y||h)&&V.current.deleted.length>0&&et(V),p&&p(s,e,i)}},onFrame:m&&(t=>m(s,e,t)),onStart:g&&(t=>o||(g(s,e,t),o=!0))});a.update(c),V.current.paused||a.start()}),c(()=>(V.current.mounted=E.current=!0,()=>{V.current.mounted=E.current=!1,Array.from(V.current.instances).map(t=>{return t[1].destroy()}),V.current.instances.clear()})),V.current.transitions.map(t=>{let e=t.item,n=t.phase,s=t.key;return{item:e,key:s,phase:n,props:r({},V.current.instances.get(s).animated)}})}function et(t,e){let n=t.current;const s=n.deleted;for(let t of s){let s=t.key;const i=t=>t.key!==s;(o.und(e)||e===s)&&(n.instances.delete(s),n.transitions=n.transitions.filter(i),n.deleted=n.deleted.filter(i))}n.forceUpdate()}function nt(t){let e=t.children,n=w(t,["children"]);return e($(n))}function st(t){let e=t.items,n=t.children,s=w(t,["items","children"]);const i=G(e.length,s);return e.map((t,e)=>{const s=n(t,e);return o.fun(s)?s(i[e]):s})}function it(e){let n=e.items,s=e.keys,i=void 0===s?null:s,a=e.children;return tt(n,i,w(e,["items","keys","children"])).map((e,n)=>{let s=e.item,i=e.key,c=e.props,l=e.phase;const u=a(s,l,n),h=o.fun(u)?u(c):u;return h&&t.createElement(h.type,r({key:i},h.props))})}class rt{constructor({update:t,onFrame:e,requestFrame:n}={}){this.controllers=new Map,this.isActive=!1,this.requestFrame=n||(t=>b(t)),this.onFrame=e&&e.bind(this)||(t=>{t.forEach(t=>{const e=this.controllers.get(t[0]);e&&e.onFrame(t)})}),this.update=t&&t.bind(this)||(()=>{if(!this.isActive)return!1;const t=[];for(const e of Array.from(this.controllers.keys())){let n=!1;const s=this.controllers.get(e),i=s.props.onFrame&&[];for(const t of s.configs)t.idle||this.advance(t)&&(n=!0,i&&i.push([t.key,t.animated.getValue()]));t.push([e,n,i])}return this.onFrame(t),this.controllers.size?(this.requestFrame(this.update),!0):this.isActive=!1})}start(t){this.controllers.set(t.id,t),this.isActive||(this.isActive=!0,this.requestFrame(this.update))}stop(t){this.controllers.delete(t.id)}advance(t){const e=p();let n=!1,s=!1;for(let i=0;i<t.animatedValues.length;i++){const r=t.animatedValues[i];if(r.done)continue;let o=t.toValues[i];const a=o instanceof A?o:null;if(a&&(o=a.getValue()),t.immediate){r.setValue(o),r.done=!0;continue}const c=t.fromValues[i],l=r.startTime;if("string"==typeof c||"string"==typeof o){r.setValue(o),r.done=!0;continue}let u=r.lastPosition,h=Array.isArray(t.initialVelocity)?t.initialVelocity[i]:t.initialVelocity;if(void 0!==t.duration)u=c+t.easing((e-l)/t.duration)*(o-c),s=e>=l+t.duration;else if(t.decay){const n=!0===t.decay?.998:t.decay;u=c+h/(1-n)*(1-Math.exp(-(1-n)*(e-l))),(s=Math.abs(r.lastPosition-u)<.1)&&(o=u)}else{let n=void 0!==r.lastTime?r.lastTime:e;void 0!==r.lastVelocity&&(h=r.lastVelocity),e>n+64&&(n=e);const i=Math.floor(e-n);for(let e=0;e<i;++e){u+=1*(h+=1*((-t.tension*(u-o)+-t.friction*h)/t.mass)/1e3)/1e3}r.lastTime=e,r.lastVelocity=h;const a=!(!t.clamp||0===t.tension)&&(c<o?u>o:u<o),l=Math.abs(h)<=t.precision,f=0===t.tension||Math.abs(o-u)<=t.precision;s=a||l&&f}a&&!a.done&&(s=!1),s?(r.value!==o&&(u=o),r.done=!0):n=!0,r.setValue(u),r.lastPosition=u}return n}}const ot=/[+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?/g;u.assign({frameLoop:new rt,createStringInterpolator:t=>{const e=t.output,n=e[0].match(ot).map(()=>[]);e.forEach(t=>{t.match(ot).forEach((t,e)=>n[e].push(+t))});const s=e[0].match(ot).map((e,s)=>h(Object.assign({},t,{output:n[s]})));return t=>{let n=0;return e[0].replace(ot,()=>s[n++](t))}},applyAnimatedValues:()=>!1,createAnimatedStyle:t=>new k(t),createAnimatedInterpolation:(t,...e)=>new V(t,e)});const at=()=>u.frameLoop.update(),ct={default:{tension:170,friction:26},gentle:{tension:120,friction:14},wobbly:{tension:180,friction:12},stiff:{tension:210,friction:20},slow:{tension:280,friction:60},molasses:{tension:280,friction:120}};export{C as Controller,rt as FrameLoop,nt as Spring,st as Trail,it as Transition,ct as config,at as update,j as useChain,$ as useSpring,L as useSprings,G as useTrail,tt as useTransition};
//# sourceMappingURL=index.js.map
{
"name": "@react-spring/core",
"version": "0.0.1-alpha.2",
"version": "0.0.1-alpha.3",
"description": "Cross-platform animation engine",

@@ -5,0 +5,0 @@ "keywords": [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc