UNPKG

@kcirtaptrick/framer-motion

Version:

A simple and powerful React animation library

1 lines 89 kB
import t,{useEffect as e,useRef as n,createContext as r,useContext as i}from"react";var o=function(t,e){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(t,e)};var a=function(){return(a=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function s(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]])}return n}function u(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,i,o=n.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(r=o.next()).done;)a.push(r.value)}catch(t){i={error:t}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return a}function l(t,e,n){if(n||2===arguments.length)for(var r,i=0,o=e.length;i<o;i++)!r&&i in e||(r||(r=Array.prototype.slice.call(e,0,i)),r[i]=e[i]);return t.concat(r||Array.prototype.slice.call(e))}function c(t){return"undefined"!=typeof PointerEvent&&t instanceof PointerEvent?!("mouse"!==t.pointerType):t instanceof MouseEvent}function d(t){return!!t.touches}var p={pageX:0,pageY:0};function f(t,e){void 0===e&&(e="page");var n=t.touches[0]||t.changedTouches[0]||p;return{x:n[e+"X"],y:n[e+"Y"]}}function v(t,e){return void 0===e&&(e="page"),{x:t[e+"X"],y:t[e+"Y"]}}function h(t,e){return void 0===e&&(e="page"),{point:d(t)?f(t,e):v(t,e)}}var m=function(t,e){void 0===e&&(e=!1);var n,r=function(e){return t(e,h(e))};return e?(n=r,function(t){var e=t instanceof MouseEvent;(!e||e&&0===t.button)&&n(t)}):r};const y="undefined"!=typeof performance?()=>performance.now():()=>Date.now(),g="undefined"!=typeof window?t=>window.requestAnimationFrame(t):t=>setTimeout(()=>t(y()),1/60*1e3);let x=!0,b=!1,P=!1;const A={delta:0,timestamp:0},T=["read","update","preRender","render","postRender"],w=T.reduce((t,e)=>(t[e]=function(t){let e=[],n=[],r=0,i=!1,o=!1;const a=new WeakSet,s={schedule:(t,o=!1,s=!1)=>{const u=s&&i,l=u?e:n;return o&&a.add(t),-1===l.indexOf(t)&&(l.push(t),u&&i&&(r=e.length)),t},cancel:t=>{const e=n.indexOf(t);-1!==e&&n.splice(e,1),a.delete(t)},process:u=>{if(i)o=!0;else{if(i=!0,[e,n]=[n,e],n.length=0,r=e.length,r)for(let n=0;n<r;n++){const r=e[n];r(u),a.has(r)&&(s.schedule(r),t())}i=!1,o&&(o=!1,s.process(u))}}};return s}(()=>b=!0),t),{}),E=T.reduce((t,e)=>{const n=w[e];return t[e]=(t,e=!1,r=!1)=>(b||C(),n.schedule(t,e,r)),t},{}),S=T.reduce((t,e)=>(t[e]=w[e].cancel,t),{}),V=T.reduce((t,e)=>(t[e]=()=>w[e].process(A),t),{}),M=t=>w[t].process(A),R=t=>{b=!1,A.delta=x?1/60*1e3:Math.max(Math.min(t-A.timestamp,40),1),A.timestamp=t,P=!0,T.forEach(M),P=!1,b&&(x=!1,g(R))},C=()=>{b=!0,x=!0,P||g(R)},L=()=>A;var D=E,O=function(t){return 1e3*t};function k(t,e,n,r){return t.addEventListener(e,n,r),function(){return t.removeEventListener(e,n,r)}}function j(t,n,r,i){e((function(){var e=t.current;if(r&&e)return k(e,n,r,i)}),[t,n,r,i])}var F="undefined"!=typeof window,U={pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointercancel:"mousecancel",pointerover:"mouseover",pointerout:"mouseout",pointerenter:"mouseenter",pointerleave:"mouseleave"},B={pointerdown:"touchstart",pointermove:"touchmove",pointerup:"touchend",pointercancel:"touchcancel"};function I(t){return F&&null===window.onpointerdown?t:F&&null===window.ontouchstart?B[t]:F&&null===window.onmousedown?U[t]:t}function N(t,e,n,r){return k(t,I(e),m(n,"pointerdown"===e),r)}function z(t,e,n,r){return j(t,I(e),n&&m(n,"pointerdown"===e),r)}const X=(t,e,n)=>Math.min(Math.max(n,t),e);function Y({duration:t=800,bounce:e=.25,velocity:n=0,mass:r=1}){let i,o,a=1-e;a=X(.05,1,a),t=X(.01,10,t/1e3),a<1?(i=e=>{const r=e*a,i=r*t;return.001-(r-n)/H(e,a)*Math.exp(-i)},o=e=>{const r=e*a*t,o=r*n+n,s=Math.pow(a,2)*Math.pow(e,2)*t,u=Math.exp(-r),l=H(Math.pow(e,2),a);return(.001-i(e)>0?-1:1)*((o-s)*u)/l}):(i=e=>Math.exp(-e*t)*((e-n)*t+1)-.001,o=e=>Math.exp(-e*t)*(t*t*(n-e)));const s=function(t,e,n){let r=n;for(let n=1;n<12;n++)r-=t(r)/e(r);return r}(i,o,5/t);if(t*=1e3,isNaN(s))return{stiffness:100,damping:10,duration:t};{const e=Math.pow(s,2)*r;return{stiffness:e,damping:2*a*Math.sqrt(r*e),duration:t}}}function H(t,e){return t*Math.sqrt(1-e*e)}const W=["duration","bounce"],G=["stiffness","damping","mass"];function $(t,e){return e.some(e=>void 0!==t[e])}function q(t){var{from:e=0,to:n=1,restSpeed:r=2,restDelta:i}=t,o=s(t,["from","to","restSpeed","restDelta"]);const a={done:!1,value:e};let{stiffness:u,damping:l,mass:c,velocity:d,duration:p,isResolvedFromDuration:f}=function(t){let e=Object.assign({velocity:0,stiffness:100,damping:10,mass:1,isResolvedFromDuration:!1},t);if(!$(t,G)&&$(t,W)){const n=Y(t);e=Object.assign(Object.assign(Object.assign({},e),n),{velocity:0,mass:1}),e.isResolvedFromDuration=!0}return e}(o),v=Z,h=Z;function m(){const t=d?-d/1e3:0,r=n-e,o=l/(2*Math.sqrt(u*c)),a=Math.sqrt(u/c)/1e3;if(void 0===i&&(i=Math.min(Math.abs(n-e)/100,.4)),o<1){const e=H(a,o);v=i=>{const s=Math.exp(-o*a*i);return n-s*((t+o*a*r)/e*Math.sin(e*i)+r*Math.cos(e*i))},h=n=>{const i=Math.exp(-o*a*n);return o*a*i*(Math.sin(e*n)*(t+o*a*r)/e+r*Math.cos(e*n))-i*(Math.cos(e*n)*(t+o*a*r)-e*r*Math.sin(e*n))}}else if(1===o)v=e=>n-Math.exp(-a*e)*(r+(t+a*r)*e);else{const e=a*Math.sqrt(o*o-1);v=i=>{const s=Math.exp(-o*a*i),u=Math.min(e*i,300);return n-s*((t+o*a*r)*Math.sinh(u)+e*r*Math.cosh(u))/e}}}return m(),{next:t=>{const e=v(t);if(f)a.done=t>=p;else{const o=1e3*h(t),s=Math.abs(o)<=r,u=Math.abs(n-e)<=i;a.done=s&&u}return a.value=a.done?n:e,a},flipTarget:()=>{d=-d,[e,n]=[n,e],m()}}}q.needsInterpolation=(t,e)=>"string"==typeof t||"string"==typeof e;const Z=t=>0,_=(t,e,n)=>{const r=e-t;return 0===r?1:(n-t)/r},K=(t,e,n)=>-n*t+n*e+t,J=(t,e)=>n=>Math.max(Math.min(n,e),t),Q=t=>t%1?Number(t.toFixed(5)):t,tt=/(-)?([\d]*\.?[\d])+/g,et=/(#[0-9a-f]{6}|#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2,3}\s*\/*\s*[\d\.]+%?\))/gi,nt=/^(#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2,3}\s*\/*\s*[\d\.]+%?\))$/i;function rt(t){return"string"==typeof t}const it={test:t=>"number"==typeof t,parse:parseFloat,transform:t=>t},ot=Object.assign(Object.assign({},it),{transform:J(0,1)}),at=Object.assign(Object.assign({},it),{default:1}),st=t=>({test:e=>rt(e)&&e.endsWith(t)&&1===e.split(" ").length,parse:parseFloat,transform:e=>`${e}${t}`}),ut=st("deg"),lt=st("%"),ct=st("px"),dt=st("vh"),pt=st("vw"),ft=Object.assign(Object.assign({},lt),{parse:t=>lt.parse(t)/100,transform:t=>lt.transform(100*t)}),vt=(t,e)=>n=>Boolean(rt(n)&&nt.test(n)&&n.startsWith(t)||e&&Object.prototype.hasOwnProperty.call(n,e)),ht=(t,e,n)=>r=>{if(!rt(r))return r;const[i,o,a,s]=r.match(tt);return{[t]:parseFloat(i),[e]:parseFloat(o),[n]:parseFloat(a),alpha:void 0!==s?parseFloat(s):1}},mt={test:vt("hsl","hue"),parse:ht("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:n,alpha:r=1})=>"hsla("+Math.round(t)+", "+lt.transform(Q(e))+", "+lt.transform(Q(n))+", "+Q(ot.transform(r))+")"},yt=J(0,255),gt=Object.assign(Object.assign({},it),{transform:t=>Math.round(yt(t))}),xt={test:vt("rgb","red"),parse:ht("red","green","blue"),transform:({red:t,green:e,blue:n,alpha:r=1})=>"rgba("+gt.transform(t)+", "+gt.transform(e)+", "+gt.transform(n)+", "+Q(ot.transform(r))+")"};const bt={test:vt("#"),parse:function(t){let e="",n="",r="",i="";return t.length>5?(e=t.substr(1,2),n=t.substr(3,2),r=t.substr(5,2),i=t.substr(7,2)):(e=t.substr(1,1),n=t.substr(2,1),r=t.substr(3,1),i=t.substr(4,1),e+=e,n+=n,r+=r,i+=i),{red:parseInt(e,16),green:parseInt(n,16),blue:parseInt(r,16),alpha:i?parseInt(i,16)/255:1}},transform:xt.transform},Pt={test:t=>xt.test(t)||bt.test(t)||mt.test(t),parse:t=>xt.test(t)?xt.parse(t):mt.test(t)?mt.parse(t):bt.parse(t),transform:t=>rt(t)?t:t.hasOwnProperty("red")?xt.transform(t):mt.transform(t)};function At(t){"number"==typeof t&&(t=""+t);const e=[];let n=0;const r=t.match(et);r&&(n=r.length,t=t.replace(et,"${c}"),e.push(...r.map(Pt.parse)));const i=t.match(tt);return i&&(t=t.replace(tt,"${n}"),e.push(...i.map(it.parse))),{values:e,numColors:n,tokenised:t}}function Tt(t){return At(t).values}function wt(t){const{values:e,numColors:n,tokenised:r}=At(t),i=e.length;return t=>{let e=r;for(let r=0;r<i;r++)e=e.replace(r<n?"${c}":"${n}",r<n?Pt.transform(t[r]):Q(t[r]));return e}}const Et=t=>"number"==typeof t?0:t;const St={test:function(t){var e,n,r,i;return isNaN(t)&&rt(t)&&(null!==(n=null===(e=t.match(tt))||void 0===e?void 0:e.length)&&void 0!==n?n:0)+(null!==(i=null===(r=t.match(et))||void 0===r?void 0:r.length)&&void 0!==i?i:0)>0},parse:Tt,createTransformer:wt,getAnimatableNone:function(t){const e=Tt(t);return wt(t)(e.map(Et))}},Vt=new Set(["brightness","contrast","saturate","opacity"]);function Mt(t){let[e,n]=t.slice(0,-1).split("(");if("drop-shadow"===e)return t;const[r]=n.match(tt)||[];if(!r)return t;const i=n.replace(r,"");let o=Vt.has(e)?1:0;return r!==n&&(o*=100),e+"("+o+i+")"}const Rt=/([a-z-]*)\(.*?\)/g,Ct=Object.assign(Object.assign({},St),{getAnimatableNone:t=>{const e=t.match(Rt);return e?e.map(Mt).join(" "):t}});function Lt(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+(e-t)*(2/3-n)*6:t}function Dt({hue:t,saturation:e,lightness:n,alpha:r}){t/=360,n/=100;let i=0,o=0,a=0;if(e/=100){const r=n<.5?n*(1+e):n+e-n*e,s=2*n-r;i=Lt(s,r,t+1/3),o=Lt(s,r,t),a=Lt(s,r,t-1/3)}else i=o=a=n;return{red:Math.round(255*i),green:Math.round(255*o),blue:Math.round(255*a),alpha:r}}const Ot=(t,e,n)=>{const r=t*t,i=e*e;return Math.sqrt(Math.max(0,n*(i-r)+r))},kt=[bt,xt,mt],jt=t=>kt.find(e=>e.test(t)),Ft=(t,e)=>{let n=jt(t),r=jt(e),i=n.parse(t),o=r.parse(e);n===mt&&(i=Dt(i),n=xt),r===mt&&(o=Dt(o),r=xt);const a=Object.assign({},i);return t=>{for(const e in a)"alpha"!==e&&(a[e]=Ot(i[e],o[e],t));return a.alpha=K(i.alpha,o.alpha,t),n.transform(a)}},Ut=t=>"number"==typeof t,Bt=(t,e)=>n=>e(t(n)),It=(...t)=>t.reduce(Bt);function Nt(t,e){return Ut(t)?n=>K(t,e,n):Pt.test(t)?Ft(t,e):Ht(t,e)}const zt=(t,e)=>{const n=[...t],r=n.length,i=t.map((t,n)=>Nt(t,e[n]));return t=>{for(let e=0;e<r;e++)n[e]=i[e](t);return n}},Xt=(t,e)=>{const n=Object.assign(Object.assign({},t),e),r={};for(const i in n)void 0!==t[i]&&void 0!==e[i]&&(r[i]=Nt(t[i],e[i]));return t=>{for(const e in r)n[e]=r[e](t);return n}};function Yt(t){const e=St.parse(t),n=e.length;let r=0,i=0,o=0;for(let t=0;t<n;t++)r||"number"==typeof e[t]?r++:void 0!==e[t].hue?o++:i++;return{parsed:e,numNumbers:r,numRGB:i,numHSL:o}}const Ht=(t,e)=>{const n=St.createTransformer(e),r=Yt(t),i=Yt(e);return r.numHSL===i.numHSL&&r.numRGB===i.numRGB&&r.numNumbers>=i.numNumbers?It(zt(r.parsed,i.parsed),n):n=>""+(n>0?e:t)},Wt=(t,e)=>n=>K(t,e,n);function Gt(t,e,n){const r=[],i=n||("number"==typeof(o=t[0])?Wt:"string"==typeof o?Pt.test(o)?Ft:Ht:Array.isArray(o)?zt:"object"==typeof o?Xt:void 0);var o;const a=t.length-1;for(let n=0;n<a;n++){let o=i(t[n],t[n+1]);if(e){const t=Array.isArray(e)?e[n]:e;o=It(t,o)}r.push(o)}return r}function $t(t,e,{clamp:n=!0,ease:r,mixer:i}={}){const o=t.length;e.length,!r||!Array.isArray(r)||r.length,t[0]>t[o-1]&&(t=[].concat(t),e=[].concat(e),t.reverse(),e.reverse());const a=Gt(e,r,i),s=2===o?function([t,e],[n]){return r=>n(_(t,e,r))}(t,a):function(t,e){const n=t.length,r=n-1;return i=>{let o=0,a=!1;if(i<=t[0]?a=!0:i>=t[r]&&(o=r-1,a=!0),!a){let e=1;for(;e<n&&!(t[e]>i||e===r);e++);o=e-1}const s=_(t[o],t[o+1],i);return e[o](s)}}(t,a);return n?e=>s(X(t[0],t[o-1],e)):s}const qt=t=>e=>1-t(1-e),Zt=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,_t=t=>e=>e*e*((t+1)*e-t),Kt=t=>t,Jt=(Qt=2,t=>Math.pow(t,Qt));var Qt;const te=qt(Jt),ee=Zt(Jt),ne=t=>1-Math.sin(Math.acos(t)),re=qt(ne),ie=Zt(re),oe=_t(1.525),ae=qt(oe),se=Zt(oe),ue=(t=>{const e=_t(t);return t=>(t*=2)<1?.5*e(t):.5*(2-Math.pow(2,-10*(t-1)))})(1.525),le=t=>{if(1===t||0===t)return t;const e=t*t;return t<4/11?7.5625*e:t<8/11?9.075*e-9.9*t+3.4:t<.9?4356/361*e-35442/1805*t+16061/1805:10.8*t*t-20.52*t+10.72},ce=qt(le);function de(t,e){return t.map(()=>e||ee).splice(0,t.length-1)}function pe({from:t=0,to:e=1,ease:n,offset:r,duration:i=300}){const o={done:!1,value:t},a=Array.isArray(e)?e:[t,e],s=function(t,e){return t.map(t=>t*e)}(r&&r.length===a.length?r:function(t){const e=t.length;return t.map((t,n)=>0!==n?n/(e-1):0)}(a),i);function u(){return $t(s,a,{ease:Array.isArray(n)?n:de(a,n)})}let l=u();return{next:t=>(o.value=l(t),o.done=t>=i,o),flipTarget:()=>{a.reverse(),l=u()}}}const fe={keyframes:pe,spring:q,decay:function({velocity:t=0,from:e=0,power:n=.8,timeConstant:r=350,restDelta:i=.5,modifyTarget:o}){const a={done:!1,value:e};let s=n*t;const u=e+s,l=void 0===o?u:o(u);return l!==u&&(s=l-e),{next:t=>{const e=-s*Math.exp(-t/r);return a.done=!(e>i||e<-i),a.value=a.done?l:l+e,a},flipTarget:()=>{}}}};function ve(t,e,n=0){return t-e-n}const he=t=>{const e=({delta:e})=>t(e);return{start:()=>D.update(e,!0),stop:()=>S.update(e)}};function me(t){var e,n,{from:r,autoplay:i=!0,driver:o=he,elapsed:a=0,repeat:u=0,repeatType:l="loop",repeatDelay:c=0,onPlay:d,onStop:p,onComplete:f,onRepeat:v,onUpdate:h}=t,m=s(t,["from","autoplay","driver","elapsed","repeat","repeatType","repeatDelay","onPlay","onStop","onComplete","onRepeat","onUpdate"]);let y,g,x,{to:b}=m,P=0,A=m.duration,T=!1,w=!0;const E=function(t){if(Array.isArray(t.to))return pe;if(fe[t.type])return fe[t.type];const e=new Set(Object.keys(t));return e.has("ease")||e.has("duration")&&!e.has("dampingRatio")?pe:e.has("dampingRatio")||e.has("stiffness")||e.has("mass")||e.has("damping")||e.has("restSpeed")||e.has("restDelta")?q:pe}(m);(null===(n=(e=E).needsInterpolation)||void 0===n?void 0:n.call(e,r,b))&&(x=$t([0,100],[r,b],{clamp:!1}),r=0,b=100);const S=E(Object.assign(Object.assign({},m),{from:r,to:b}));function V(){P++,"reverse"===l?(w=P%2==0,a=function(t,e,n=0,r=!0){return r?ve(e+-t,e,n):e-(t-e)+n}(a,A,c,w)):(a=ve(a,A,c),"mirror"===l&&S.flipTarget()),T=!1,v&&v()}function M(t){if(w||(t=-t),a+=t,!T){const t=S.next(Math.max(0,a));g=t.value,x&&(g=x(g)),T=w?t.done:a<=0}null==h||h(g),T&&(0===P&&(null!=A||(A=a)),P<u?function(t,e,n,r){return r?t>=e+n:t<=-n}(a,A,c,w)&&V():(y.stop(),f&&f()))}return i&&(null==d||d(),y=o(M),y.start()),{stop:()=>{null==p||p(),y.stop()}}}function ye(t,e){return e?t*(1e3/e):0}const ge=t=>t.hasOwnProperty("x")&&t.hasOwnProperty("y"),xe=t=>ge(t)&&t.hasOwnProperty("z"),be=(t,e)=>Math.abs(t-e);function Pe(t,e){if(Ut(t)&&Ut(e))return be(t,e);if(ge(t)&&ge(e)){const n=be(t.x,e.x),r=be(t.y,e.y),i=xe(t)&&xe(e)?be(t.z,e.z):0;return Math.sqrt(Math.pow(n,2)+Math.pow(r,2)+Math.pow(i,2))}}const Ae=(t,e)=>1-3*e+3*t,Te=(t,e)=>3*e-6*t,we=t=>3*t,Ee=(t,e,n)=>((Ae(e,n)*t+Te(e,n))*t+we(e))*t,Se=(t,e,n)=>3*Ae(e,n)*t*t+2*Te(e,n)*t+we(e);function Ve(t,e,n,r){if(t===e&&n===r)return Kt;const i=new Float32Array(11);for(let e=0;e<11;++e)i[e]=Ee(.1*e,t,n);function o(e){let r=0,o=1;for(;10!==o&&i[o]<=e;++o)r+=.1;--o;const a=r+.1*((e-i[o])/(i[o+1]-i[o])),s=Se(a,t,n);return s>=.001?function(t,e,n,r){for(let i=0;i<8;++i){const i=Se(e,n,r);if(0===i)return e;e-=(Ee(e,n,r)-t)/i}return e}(e,a,t,n):0===s?a:function(t,e,n,r,i){let o,a,s=0;do{a=e+(n-e)/2,o=Ee(a,r,i)-t,o>0?n=a:e=a}while(Math.abs(o)>1e-7&&++s<10);return a}(e,r,r+.1,t,n)}return t=>0===t||1===t?t:Ee(o(t),e,r)}var Me=function(){function t(t,e,n){var r=this,i=(void 0===n?{}:n).transformPagePoint;if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.updatePoint=function(){if(r.lastMoveEvent&&r.lastMoveEventInfo){var t=Le(r.lastMoveEventInfo,r.history),e=null!==r.startEvent,n=Pe(t.offset,{x:0,y:0})>=3;if(e||n){var i=t.point,o=L().timestamp;r.history.push(a(a({},i),{timestamp:o}));var s=r.handlers,u=s.onStart,l=s.onMove;e||(u&&u(r.lastMoveEvent,t),r.startEvent=r.lastMoveEvent),l&&l(r.lastMoveEvent,t)}}},this.handlePointerMove=function(t,e){r.lastMoveEvent=t,r.lastMoveEventInfo=Re(e,r.transformPagePoint),c(t)&&0===t.buttons?r.handlePointerUp(t,e):D.update(r.updatePoint,!0)},this.handlePointerUp=function(t,e){r.end();var n=r.handlers,i=n.onEnd,o=n.onSessionEnd,a=Le(Re(e,r.transformPagePoint),r.history);r.startEvent&&i&&i(t,a),o&&o(t,a)},!(d(t)&&t.touches.length>1)){this.handlers=e,this.transformPagePoint=i;var o=Re(h(t),this.transformPagePoint),s=o.point,u=L().timestamp;this.history=[a(a({},s),{timestamp:u})];var l=e.onSessionStart;l&&l(t,Le(o,this.history)),this.removeListeners=It(N(window,"pointermove",this.handlePointerMove),N(window,"pointerup",this.handlePointerUp),N(window,"pointercancel",this.handlePointerUp))}}return t.prototype.updateHandlers=function(t){this.handlers=t},t.prototype.end=function(){this.removeListeners&&this.removeListeners(),S.update(this.updatePoint)},t}();function Re(t,e){return e?{point:e(t.point)}:t}function Ce(t,e){return{x:t.x-e.x,y:t.y-e.y}}function Le(t,e){var n=t.point;return{point:n,delta:Ce(n,Oe(e)),offset:Ce(n,De(e)),velocity:ke(e,.1)}}function De(t){return t[0]}function Oe(t){return t[t.length-1]}function ke(t,e){if(t.length<2)return{x:0,y:0};for(var n=t.length-1,r=null,i=Oe(t);n>=0&&(r=t[n],!(i.timestamp-r.timestamp>O(e)));)n--;if(!r)return{x:0,y:0};var o=(i.timestamp-r.timestamp)/1e3;if(0===o)return{x:0,y:0};var a={x:(i.x-r.x)/o,y:(i.y-r.y)/o};return a.x===1/0&&(a.x=0),a.y===1/0&&(a.y=0),a}function je(t){var e=null;return function(){return null===e&&(e=t,function(){e=null})}}var Fe=je("dragHorizontal"),Ue=je("dragVertical");function Be(t){var e=!1;if("y"===t)e=Ue();else if("x"===t)e=Fe();else{var n=Fe(),r=Ue();n&&r?e=function(){n(),r()}:(n&&n(),r&&r())}return e}function Ie(){var t=Be(!0);return!t||(t(),!1)}function Ne(t){return"object"==typeof t&&Object.prototype.hasOwnProperty.call(t,"current")}function ze(t){return t.max-t.min}function Xe(t,e,n){return void 0===e&&(e=0),void 0===n&&(n=.01),Pe(t,e)<n}function Ye(t,e,n,r){void 0===r&&(r=.5),t.origin=r,t.originPoint=K(e.min,e.max,t.origin),t.scale=ze(n)/ze(e),(Xe(t.scale,1,1e-4)||isNaN(t.scale))&&(t.scale=1),t.translate=K(n.min,n.max,t.origin)-t.originPoint,(Xe(t.translate)||isNaN(t.translate))&&(t.translate=0)}function He(t,e,n,r){Ye(t.x,e.x,n.x,null==r?void 0:r.originX),Ye(t.y,e.y,n.y,null==r?void 0:r.originY)}function We(t,e,n){t.min=n.min+e.min,t.max=t.min+ze(e)}function Ge(t,e,n){t.min=e.min-n.min,t.max=t.min+ze(e)}function $e(t,e,n){Ge(t.x,e.x,n.x),Ge(t.y,e.y,n.y)}function qe(t,e,n){return{min:void 0!==e?t.min+e:void 0,max:void 0!==n?t.max+n-(t.max-t.min):void 0}}function Ze(t,e){var n,r=e.min-t.min,i=e.max-t.max;return e.max-e.min<t.max-t.min&&(r=(n=u([i,r],2))[0],i=n[1]),{min:r,max:i}}var _e;function Ke(t,e,n){return{min:Je(t,e),max:Je(t,n)}}function Je(t,e){var n;return"number"==typeof t?t:null!==(n=t[e])&&void 0!==n?n:0}!function(t){t.Animate="animate",t.Hover="whileHover",t.Tap="whileTap",t.Drag="whileDrag",t.Focus="whileFocus",t.InView="whileInView",t.Exit="exit"}(_e||(_e={}));function Qe(t){return[t("x"),t("y")]}function tn(t){var e=t.top;return{x:{min:t.left,max:t.right},y:{min:e,max:t.bottom}}}function en(t){return void 0===t||1===t}function nn(t){var e=t.scale,n=t.scaleX,r=t.scaleY;return!en(e)||!en(n)||!en(r)}function rn(t){return nn(t)||on(t.x)||on(t.y)||t.z||t.rotate||t.rotateX||t.rotateY}function on(t){return t&&"0%"!==t}function an(t,e,n){return n+e*(t-n)}function sn(t,e,n,r,i){return void 0!==i&&(t=an(t,i,r)),an(t,n,r)+e}function un(t,e,n,r,i){void 0===e&&(e=0),void 0===n&&(n=1),t.min=sn(t.min,e,n,r,i),t.max=sn(t.max,e,n,r,i)}function ln(t,e){var n=e.x,r=e.y;un(t.x,n.translate,n.scale,n.originPoint),un(t.y,r.translate,r.scale,r.originPoint)}function cn(t,e){t.min=t.min+e,t.max=t.max+e}function dn(t,e,n){var r=u(n,3),i=r[0],o=r[1],a=r[2],s=void 0!==e[a]?e[a]:.5,l=K(t.min,t.max,s);un(t,e[i],e[o],l,e.scale)}var pn=["x","scaleX","originX"],fn=["y","scaleY","originY"];function vn(t,e){dn(t.x,e,pn),dn(t.y,e,fn)}function hn(t,e){return tn(function(t,e){if(!e)return t;var n=e({x:t.left,y:t.top}),r=e({x:t.right,y:t.bottom});return{top:n.y,left:n.x,bottom:r.y,right:r.x}}(t.getBoundingClientRect(),e))}var mn={linear:Kt,easeIn:Jt,easeInOut:ee,easeOut:te,circIn:ne,circInOut:ie,circOut:re,backIn:oe,backInOut:se,backOut:ae,anticipate:ue,bounceIn:ce,bounceInOut:t=>t<.5?.5*(1-le(1-2*t)):.5*le(2*t-1)+.5,bounceOut:le},yn=function(t){if(Array.isArray(t)){t.length;var e=u(t,4);return Ve(e[0],e[1],e[2],e[3])}return"string"==typeof t?mn[t]:t},gn=function(t,e){return"zIndex"!==t&&(!("number"!=typeof e&&!Array.isArray(e))||!("string"!=typeof e||!St.test(e)||e.startsWith("url(")))},xn=function(t){return Array.isArray(t)},bn=function(){return{type:"spring",stiffness:500,damping:25,restSpeed:10}},Pn=function(t){return{type:"spring",stiffness:550,damping:0===t?2*Math.sqrt(550):30,restSpeed:10}},An=function(){return{type:"keyframes",ease:"linear",duration:.3}},Tn=function(t){return{type:"keyframes",duration:.8,values:t}},wn={x:bn,y:bn,z:bn,rotate:bn,rotateX:bn,rotateY:bn,rotateZ:bn,scaleX:Pn,scaleY:Pn,scale:Pn,opacity:An,backgroundColor:An,color:An,default:Pn},En=a(a({},it),{transform:Math.round}),Sn={borderWidth:ct,borderTopWidth:ct,borderRightWidth:ct,borderBottomWidth:ct,borderLeftWidth:ct,borderRadius:ct,radius:ct,borderTopLeftRadius:ct,borderTopRightRadius:ct,borderBottomRightRadius:ct,borderBottomLeftRadius:ct,width:ct,maxWidth:ct,height:ct,maxHeight:ct,size:ct,top:ct,right:ct,bottom:ct,left:ct,padding:ct,paddingTop:ct,paddingRight:ct,paddingBottom:ct,paddingLeft:ct,margin:ct,marginTop:ct,marginRight:ct,marginBottom:ct,marginLeft:ct,rotate:ut,rotateX:ut,rotateY:ut,rotateZ:ut,scale:at,scaleX:at,scaleY:at,scaleZ:at,skew:ut,skewX:ut,skewY:ut,distance:ct,translateX:ct,translateY:ct,translateZ:ct,x:ct,y:ct,z:ct,perspective:ct,transformPerspective:ct,opacity:ot,originX:ft,originY:ft,originZ:ct,zIndex:En,fillOpacity:ot,strokeOpacity:ot,numOctaves:En},Vn=a(a({},Sn),{color:Pt,backgroundColor:Pt,outlineColor:Pt,fill:Pt,stroke:Pt,borderColor:Pt,borderTopColor:Pt,borderRightColor:Pt,borderBottomColor:Pt,borderLeftColor:Pt,filter:Ct,WebkitFilter:Ct}),Mn=function(t){return Vn[t]};function Rn(t,e){var n,r=Mn(t);return r!==Ct&&(r=St),null===(n=r.getAnimatableNone)||void 0===n?void 0:n.call(r,e)}var Cn=!1,Ln=function(t){return xn(t)?t[t.length-1]||0:t};function Dn(t){var e=t.ease,n=t.times,r=t.yoyo,i=t.flip,o=t.loop,u=s(t,["ease","times","yoyo","flip","loop"]),l=a({},u);return n&&(l.offset=n),u.duration&&(l.duration=O(u.duration)),u.repeatDelay&&(l.repeatDelay=O(u.repeatDelay)),e&&(l.ease=function(t){return Array.isArray(t)&&"number"!=typeof t[0]}(e)?e.map(yn):yn(e)),"tween"===u.type&&(l.type="keyframes"),(r||o||i)&&(r?l.repeatType="reverse":o?l.repeatType="loop":i&&(l.repeatType="mirror"),l.repeat=o||r||i||u.repeat),"spring"!==u.type&&(l.type="keyframes"),l}function On(t,e,n){var r,i,o,c;return Array.isArray(e.to)&&(null!==(r=t.duration)&&void 0!==r||(t.duration=.8)),function(t){Array.isArray(t.to)&&null===t.to[0]&&(t.to=l([],u(t.to),!1),t.to[0]=t.from)}(e),function(t){t.when,t.delay,t.delayChildren,t.staggerChildren,t.staggerDirection,t.repeat,t.repeatType,t.repeatDelay,t.from;var e=s(t,["when","delay","delayChildren","staggerChildren","staggerDirection","repeat","repeatType","repeatDelay","from"]);return!!Object.keys(e).length}(t)||(t=a(a({},t),(i=n,o=e.to,c=xn(o)?Tn:wn[i]||wn.default,a({to:o},c(o))))),a(a({},e),Dn(t))}function kn(t,e,n,r,i){var o,s=Un(r,t),u=null!==(o=s.from)&&void 0!==o?o:e.get(),l=gn(t,n);return"none"===u&&l&&"string"==typeof n?u=Rn(t,n):jn(u)&&"string"==typeof n?u=Fn(n):!Array.isArray(n)&&jn(n)&&"string"==typeof u&&(n=Fn(u)),gn(t,u)&&l&&!1!==s.type?function(){var r={from:u,to:n,velocity:e.getVelocity(),onComplete:i,onUpdate:function(t){return e.set(t)}};return"inertia"===s.type||"decay"===s.type?function({from:t=0,velocity:e=0,min:n,max:r,power:i=.8,timeConstant:o=750,bounceStiffness:a=500,bounceDamping:s=10,restDelta:u=1,modifyTarget:l,driver:c,onUpdate:d,onComplete:p,onStop:f}){let v;function h(t){return void 0!==n&&t<n||void 0!==r&&t>r}function m(t){return void 0===n?r:void 0===r||Math.abs(n-t)<Math.abs(r-t)?n:r}function y(t){null==v||v.stop(),v=me(Object.assign(Object.assign({},t),{driver:c,onUpdate:e=>{var n;null==d||d(e),null===(n=t.onUpdate)||void 0===n||n.call(t,e)},onComplete:p,onStop:f}))}function g(t){y(Object.assign({type:"spring",stiffness:a,damping:s,restDelta:u},t))}if(h(t))g({from:t,velocity:e,to:m(t)});else{let r=i*e+t;void 0!==l&&(r=l(r));const a=m(r),s=a===n?-1:1;let c,d;const p=t=>{c=d,d=t,e=ye(t-c,L().delta),(1===s&&t>a||-1===s&&t<a)&&g({from:t,to:a,velocity:e})};y({type:"decay",from:t,velocity:e,timeConstant:o,power:i,restDelta:u,modifyTarget:l,onUpdate:h(r)?p:void 0})}return{stop:()=>null==v?void 0:v.stop()}}(a(a({},r),s)):me(a(a({},On(s,r,t)),{onUpdate:function(t){var e;r.onUpdate(t),null===(e=s.onUpdate)||void 0===e||e.call(s,t)},onComplete:function(){var t;r.onComplete(),null===(t=s.onComplete)||void 0===t||t.call(s)}}))}:function(){var t,r,o=Ln(n);return e.set(o),i(),null===(t=null==s?void 0:s.onUpdate)||void 0===t||t.call(s,o),null===(r=null==s?void 0:s.onComplete)||void 0===r||r.call(s),{stop:function(){}}}}function jn(t){return 0===t||"string"==typeof t&&0===parseFloat(t)&&-1===t.indexOf(" ")}function Fn(t){return"number"==typeof t?0:Rn("",t)}function Un(t,e){return t[e]||t.default||t}function Bn(t,e,n,r){return void 0===r&&(r={}),Cn&&(r={type:!1}),e.start((function(i){var o,a,s=kn(t,e,n,r,i),u=function(t,e){var n,r;return null!==(r=null!==(n=(Un(t,e)||{}).delay)&&void 0!==n?n:t.delay)&&void 0!==r?r:0}(r,t),l=function(){return a=s()};return u?o=window.setTimeout(l,O(u)):l(),function(){clearTimeout(o),null==a||a.stop()}}))}var In=new WeakMap,Nn=function(){function t(t){this.openGlobalLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic={x:{min:0,max:0},y:{min:0,max:0}},this.visualElement=t}return t.prototype.start=function(t,e){var n=this,r=(void 0===e?{}:e).snapToCursor,i=void 0!==r&&r;if(!1!==this.visualElement.isPresent){this.panSession=new Me(t,{onSessionStart:function(t){n.stopAnimation(),i&&n.snapToCursor(h(t,"page").point)},onStart:function(t,e){var r,i=n.getProps(),o=i.drag,a=i.dragPropagation,s=i.onDragStart;(!o||a||(n.openGlobalLock&&n.openGlobalLock(),n.openGlobalLock=Be(o),n.openGlobalLock))&&(n.isDragging=!0,n.currentDirection=null,n.resolveConstraints(),n.visualElement.projection&&(n.visualElement.projection.isAnimationBlocked=!0,n.visualElement.projection.target=void 0),Qe((function(t){var e,r,i=n.getAxisMotionValue(t).get()||0;if(lt.test(i)){var o=null===(r=null===(e=n.visualElement.projection)||void 0===e?void 0:e.layout)||void 0===r?void 0:r.actual[t];if(o)i=ze(o)*(parseFloat(i)/100)}n.originPoint[t]=i})),null==s||s(t,e),null===(r=n.visualElement.animationState)||void 0===r||r.setActive(_e.Drag,!0))},onMove:function(t,e){var r=n.getProps(),i=r.dragPropagation,o=r.dragDirectionLock,a=r.onDirectionLock,s=r.onDrag;if(i||n.openGlobalLock){var u=e.offset;if(o&&null===n.currentDirection)return n.currentDirection=function(t,e){void 0===e&&(e=10);var n=null;Math.abs(t.y)>e?n="y":Math.abs(t.x)>e&&(n="x");return n}(u),void(null!==n.currentDirection&&(null==a||a(n.currentDirection)));n.updateAxis("x",e.point,u),n.updateAxis("y",e.point,u),n.visualElement.syncRender(),null==s||s(t,e)}},onSessionEnd:function(t,e){return n.stop(t,e)}},{transformPagePoint:this.visualElement.getTransformPagePoint()})}},t.prototype.stop=function(t,e){var n=this.isDragging;if(this.cancel(),n){var r=e.velocity;this.startAnimation(r);var i=this.getProps().onDragEnd;null==i||i(t,e)}},t.prototype.cancel=function(){var t,e;this.isDragging=!1,this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!1),null===(t=this.panSession)||void 0===t||t.end(),this.panSession=void 0,!this.getProps().dragPropagation&&this.openGlobalLock&&(this.openGlobalLock(),this.openGlobalLock=null),null===(e=this.visualElement.animationState)||void 0===e||e.setActive(_e.Drag,!1)},t.prototype.updateAxis=function(t,e,n){var r=this.getProps().drag;if(n&&zn(t,r,this.currentDirection)){var i,o,a,s,u,l=this.getAxisMotionValue(t),c=this.originPoint[t]+n[t];this.constraints&&this.constraints[t]&&(i=c,o=this.constraints[t],a=this.elastic[t],s=o.min,u=o.max,void 0!==s&&i<s?i=a?K(s,i,a.min):Math.max(i,s):void 0!==u&&i>u&&(i=a?K(u,i,a.max):Math.min(i,u)),c=i),l.set(c)}},t.prototype.resolveConstraints=function(){var t=this,e=this.getProps(),n=e.dragConstraints,r=e.dragElastic,i=(this.visualElement.projection||{}).layout,o=this.constraints;n&&Ne(n)?this.constraints||(this.constraints=this.resolveRefConstraints()):this.constraints=!(!n||!i)&&function(t,e){var n=e.top,r=e.left,i=e.bottom,o=e.right;return{x:qe(t.x,r,o),y:qe(t.y,n,i)}}(i.actual,n),this.elastic=function(t){return void 0===t&&(t=.35),!1===t?t=0:!0===t&&(t=.35),{x:Ke(t,"left","right"),y:Ke(t,"top","bottom")}}(r),o!==this.constraints&&i&&this.constraints&&!this.hasMutatedConstraints&&Qe((function(e){t.getAxisMotionValue(e)&&(t.constraints[e]=function(t,e){var n={};return void 0!==e.min&&(n.min=e.min-t.min),void 0!==e.max&&(n.max=e.max-t.min),n}(i.actual[e],t.constraints[e]))}))},t.prototype.resolveRefConstraints=function(){var t=this.getProps(),e=t.dragConstraints,n=t.onMeasureDragConstraints;if(!e||!Ne(e))return!1;var r=e.current,i=this.visualElement.projection;if(!i||!i.layout)return!1;var o=function(t,e,n){var r=hn(t,n),i=e.scroll;return i&&(cn(r.x,i.x),cn(r.y,i.y)),r}(r,i.root,this.visualElement.getTransformPagePoint()),a=function(t,e){return{x:Ze(t.x,e.x),y:Ze(t.y,e.y)}}(i.layout.actual,o);if(n){var s=n(function(t){var e=t.x,n=t.y;return{top:n.min,right:e.max,bottom:n.max,left:e.min}}(a));this.hasMutatedConstraints=!!s,s&&(a=tn(s))}return a},t.prototype.startAnimation=function(t){var e=this,n=this.getProps(),r=n.drag,i=n.dragMomentum,o=n.dragElastic,s=n.dragTransition,u=n.dragSnapToOrigin,l=n.onDragTransitionEnd,c=this.constraints||{},d=Qe((function(n){var l;if(zn(n,r,e.currentDirection)){var d=null!==(l=null==c?void 0:c[n])&&void 0!==l?l:{};u&&(d={min:0,max:0});var p=o?200:1e6,f=o?40:1e7,v=a(a({type:"inertia",velocity:i?t[n]:0,bounceStiffness:p,bounceDamping:f,timeConstant:750,restDelta:1,restSpeed:10},s),d);return e.startAxisValueAnimation(n,v)}}));return Promise.all(d).then(l)},t.prototype.startAxisValueAnimation=function(t,e){return Bn(t,this.getAxisMotionValue(t),0,e)},t.prototype.stopAnimation=function(){var t=this;Qe((function(e){return t.getAxisMotionValue(e).stop()}))},t.prototype.getAxisMotionValue=function(t){var e,n,r="_drag"+t.toUpperCase(),i=this.visualElement.getProps()[r];return i||this.visualElement.getValue(t,null!==(n=null===(e=this.visualElement.getProps().initial)||void 0===e?void 0:e[t])&&void 0!==n?n:0)},t.prototype.snapToCursor=function(t){var e=this;Qe((function(n){if(zn(n,e.getProps().drag,e.currentDirection)){var r=e.visualElement.projection,i=e.getAxisMotionValue(n);if(r&&r.layout){var o=r.layout.actual[n],a=o.min,s=o.max;i.set(t[n]-K(a,s,.5))}}}))},t.prototype.scalePositionWithinConstraints=function(){var t,e=this,n=this.getProps(),r=n.drag,i=n.dragConstraints,o=this.visualElement.projection;if(Ne(i)&&o&&this.constraints){this.stopAnimation();var a={x:0,y:0};Qe((function(t){var n,r,i,o,s,u=e.getAxisMotionValue(t);if(u){var l=u.get();a[t]=(n={min:l,max:l},r=e.constraints[t],i=.5,o=ze(n),(s=ze(r))>o?i=_(r.min,r.max-o,n.min):o>s&&(i=_(n.min,n.max-s,r.min)),X(0,1,i))}}));var s=this.visualElement.getProps().transformTemplate;this.visualElement.getInstance().style.transform=s?s({},""):"none",null===(t=o.root)||void 0===t||t.updateScroll(),o.updateLayout(),this.resolveConstraints(),Qe((function(t){if(zn(t,r,null)){var n=e.getAxisMotionValue(t),i=e.constraints[t],o=i.min,s=i.max;n.set(K(o,s,a[t]))}}))}},t.prototype.addListeners=function(){var t,e=this;In.set(this.visualElement,this);var n=N(this.visualElement.getInstance(),"pointerdown",(function(t){var n=e.getProps(),r=n.drag,i=n.dragListener;r&&(void 0===i||i)&&e.start(t)})),r=function(){Ne(e.getProps().dragConstraints)&&(e.constraints=e.resolveRefConstraints())},i=this.visualElement.projection,o=i.addEventListener("measure",r);i&&!i.layout&&(null===(t=i.root)||void 0===t||t.updateScroll(),i.updateLayout()),r();var a=k(window,"resize",(function(){e.scalePositionWithinConstraints()}));return i.addEventListener("didUpdate",(function(t){var n=t.delta,r=t.hasLayoutChanged;e.isDragging&&r&&(Qe((function(t){var r=e.getAxisMotionValue(t);r&&(e.originPoint[t]+=n[t].translate,r.set(r.get()+n[t].translate))})),e.visualElement.syncRender())})),function(){a(),n(),o()}},t.prototype.getProps=function(){var t=this.visualElement.getProps(),e=t.drag,n=void 0!==e&&e,r=t.dragDirectionLock,i=void 0!==r&&r,o=t.dragPropagation,s=void 0!==o&&o,u=t.dragConstraints,l=void 0!==u&&u,c=t.dragElastic,d=void 0===c?.35:c,p=t.dragMomentum,f=void 0===p||p;return a(a({},t),{drag:n,dragDirectionLock:i,dragPropagation:s,dragConstraints:l,dragElastic:d,dragMomentum:f})},t}();function zn(t,e,n){return!(!0!==e&&e!==t||null!==n&&n!==t)}function Xn(t){var e=n(null);return null===e.current&&(e.current=t()),e.current}var Yn=r({transformPagePoint:function(t){return t},isStatic:!1,reducedMotion:"never"});function Hn(t){return e((function(){return function(){return t()}}),[])}var Wn=function(t){return function(e){return t(e),null}},Gn={pan:Wn((function(t){var r=t.onPan,o=t.onPanStart,a=t.onPanEnd,s=t.onPanSessionStart,u=t.visualElement,l=r||o||a||s,c=n(null),d=i(Yn).transformPagePoint,p={onSessionStart:s,onStart:o,onMove:r,onEnd:function(t,e){c.current=null,a&&a(t,e)}};e((function(){null!==c.current&&c.current.updateHandlers(p)})),z(u,"pointerdown",l&&function(t){c.current=new Me(t,p,{transformPagePoint:d})}),Hn((function(){return c.current&&c.current.end()}))})),drag:Wn((function(t){var n=t.dragControls,r=t.visualElement,i=Xn((function(){return new Nn(r)}));e((function(){return n&&n.subscribe(i)}),[i,n]),e((function(){return i.addListeners()}),[i])}))},$n=r(null),qn=0,Zn=function(){return qn++};function _n(){var t=i($n);if(null===t)return[!0,null];var n=t.isPresent,r=t.onExitComplete,o=t.register,a=Xn(Zn);e((function(){return o(a)}),[]);return!n&&r?[!1,function(){return null==r?void 0:r(a)}]:[!0]}var Kn=r({}),Jn=r({});function Qn(t,e){-1===t.indexOf(e)&&t.push(e)}function tr(t,e){var n=t.indexOf(e);n>-1&&t.splice(n,1)}var er=function(){function t(){this.subscriptions=[]}return t.prototype.add=function(t){var e=this;return Qn(this.subscriptions,t),function(){return tr(e.subscriptions,t)}},t.prototype.notify=function(t,e,n){var r=this.subscriptions.length;if(r)if(1===r)this.subscriptions[0](t,e,n);else for(var i=0;i<r;i++){var o=this.subscriptions[i];o&&o(t,e,n)}},t.prototype.getSize=function(){return this.subscriptions.length},t.prototype.clear=function(){this.subscriptions.length=0},t}(),nr=function(){function t(t){var e,n=this;this.timeDelta=0,this.lastUpdated=0,this.updateSubscribers=new er,this.velocityUpdateSubscribers=new er,this.renderSubscribers=new er,this.canTrackVelocity=!1,this.updateAndNotify=function(t,e){void 0===e&&(e=!0),n.prev=n.current,n.current=t;var r=L(),i=r.delta,o=r.timestamp;n.lastUpdated!==o&&(n.timeDelta=i,n.lastUpdated=o,D.postRender(n.scheduleVelocityCheck)),n.prev!==n.current&&n.updateSubscribers.notify(n.current),n.velocityUpdateSubscribers.getSize()&&n.velocityUpdateSubscribers.notify(n.getVelocity()),e&&n.renderSubscribers.notify(n.current)},this.scheduleVelocityCheck=function(){return D.postRender(n.velocityCheck)},this.velocityCheck=function(t){t.timestamp!==n.lastUpdated&&(n.prev=n.current,n.velocityUpdateSubscribers.notify(n.getVelocity()))},this.hasAnimated=!1,this.prev=this.current=t,this.canTrackVelocity=(e=this.current,!isNaN(parseFloat(e)))}return t.prototype.onChange=function(t){return this.updateSubscribers.add(t)},t.prototype.clearListeners=function(){this.updateSubscribers.clear()},t.prototype.onRenderRequest=function(t){return t(this.get()),this.renderSubscribers.add(t)},t.prototype.attach=function(t){this.passiveEffect=t},t.prototype.set=function(t,e){void 0===e&&(e=!0),e&&this.passiveEffect?this.passiveEffect(t,this.updateAndNotify):this.updateAndNotify(t,e)},t.prototype.get=function(){return this.current},t.prototype.getPrevious=function(){return this.prev},t.prototype.getVelocity=function(){return this.canTrackVelocity?ye(parseFloat(this.current)-parseFloat(this.prev),this.timeDelta):0},t.prototype.start=function(t){var e=this;return this.stop(),new Promise((function(n){e.hasAnimated=!0,e.stopAnimation=t(n)})).then((function(){return e.clearAnimation()}))},t.prototype.stop=function(){this.stopAnimation&&this.stopAnimation(),this.clearAnimation()},t.prototype.isAnimating=function(){return!!this.stopAnimation},t.prototype.clearAnimation=function(){this.stopAnimation=null},t.prototype.destroy=function(){this.updateSubscribers.clear(),this.renderSubscribers.clear(),this.stop()},t}();function rr(t){return new nr(t)}var ir=function(t){return Boolean(null!==t&&"object"==typeof t&&t.getVelocity)};var or=["TopLeft","TopRight","BottomLeft","BottomRight"],ar=or.length,sr=function(t){return"string"==typeof t?parseFloat(t):t},ur=function(t){return"number"==typeof t||ct.test(t)};function lr(t,e){var n;return null!==(n=t[e])&&void 0!==n?n:t.borderRadius}var cr=pr(0,.5,re),dr=pr(.5,.95,Kt);function pr(t,e,n){return function(r){return r<t?0:r>e?1:n(_(t,e,r))}}function fr(t,e){t.min=e.min,t.max=e.max}function vr(t,e){fr(t.x,e.x),fr(t.y,e.y)}function hr(t,e,n,r,i){return t=an(t-=e,1/n,r),void 0!==i&&(t=an(t,1/i,r)),t}function mr(t,e,n,r,i){var o=u(n,3),a=o[0],s=o[1],l=o[2];!function(t,e,n,r,i,o,a){if(void 0===e&&(e=0),void 0===n&&(n=1),void 0===r&&(r=.5),void 0===o&&(o=t),void 0===a&&(a=t),lt.test(e)&&(e=parseFloat(e),e=K(a.min,a.max,e/100)-a.min),"number"==typeof e){var s=K(o.min,o.max,r);t===o&&(s-=e),t.min=hr(t.min,e,n,s,i),t.max=hr(t.max,e,n,s,i)}}(t,e[a],e[s],e[l],e.scale,r,i)}var yr=["x","scaleX","originX"],gr=["y","scaleY","originY"];function xr(t,e,n,r){mr(t.x,e,yr,null==n?void 0:n.x,null==r?void 0:r.x),mr(t.y,e,gr,null==n?void 0:n.y,null==r?void 0:r.y)}function br(t){return 0===t.translate&&1===t.scale}function Pr(t){return br(t.x)&&br(t.y)}function Ar(t,e){return t.x.min===e.x.min&&t.x.max===e.x.max&&t.y.min===e.y.min&&t.y.max===e.y.max}var Tr=function(){function t(){this.members=[]}return t.prototype.add=function(t){Qn(this.members,t),t.scheduleRender()},t.prototype.remove=function(t){if(tr(this.members,t),t===this.prevLead&&(this.prevLead=void 0),t===this.lead){var e=this.members[this.members.length-1];e&&this.promote(e)}},t.prototype.relegate=function(t){var e,n=this.members.findIndex((function(e){return t===e}));if(0===n)return!1;for(var r=n;r>=0;r--){var i=this.members[r];if(!1!==i.isPresent){e=i;break}}return!!e&&(this.promote(e),!0)},t.prototype.promote=function(t,e){var n,r=this.lead;t!==r&&(this.prevLead=r,this.lead=t,t.show(),r&&(r.instance&&r.scheduleRender(),t.scheduleRender(),t.resumeFrom=r,e&&(t.resumeFrom.preserveOpacity=!0),r.snapshot&&(t.snapshot=r.snapshot,t.snapshot.latestValues=r.animationValues||r.latestValues,t.snapshot.isShared=!0),(null===(n=t.root)||void 0===n?void 0:n.isUpdating)&&(t.isLayoutDirty=!0),!1===t.options.crossfade&&r.hide()))},t.prototype.exitAnimationComplete=function(){this.members.forEach((function(t){var e,n,r,i,o;null===(n=(e=t.options).onExitComplete)||void 0===n||n.call(e),null===(o=null===(r=t.resumingFrom)||void 0===r?void 0:(i=r.options).onExitComplete)||void 0===o||o.call(i)}))},t.prototype.scheduleRender=function(){this.members.forEach((function(t){t.instance&&t.scheduleRender(!1)}))},t.prototype.removeLeadSnapshot=function(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)},t}(),wr={};function Er(t,e,n){var r=t.x.translate/e.x,i=t.y.translate/e.y,o="translate3d(".concat(r,"px, ").concat(i,"px, 0) ");if(n){var a=n.rotate,s=n.rotateX,u=n.rotateY;a&&(o+="rotate(".concat(a,"deg) ")),s&&(o+="rotateX(".concat(s,"deg) ")),u&&(o+="rotateY(".concat(u,"deg) "))}return"translate3d(0px, 0px, 0) scale(1, 1)"===(o+="scale(".concat(t.x.scale,", ").concat(t.y.scale,")"))?"none":o}var Sr=["","X","Y","Z"],Vr=["transformPerspective","x","y","z"];function Mr(t,e){return Vr.indexOf(t)-Vr.indexOf(e)}["translate","scale","rotate","skew"].forEach((function(t){return Sr.forEach((function(e){return Vr.push(t+e)}))}));var Rr=new Set(Vr);function Cr(t){return Rr.has(t)}var Lr=new Set(["originX","originY","originZ"]);function Dr(t){return Lr.has(t)}var Or=function(t,e){return t.depth-e.depth},kr=function(){function t(){this.children=[],this.isDirty=!1}return t.prototype.add=function(t){Qn(this.children,t),this.isDirty=!0},t.prototype.remove=function(t){tr(this.children,t),this.isDirty=!0},t.prototype.forEach=function(t){this.isDirty&&this.children.sort(Or),this.isDirty=!1,this.children.forEach(t)},t}();function jr(t){var e,n=ir(t)?t.get():t;return e=n,Boolean(e&&"object"==typeof e&&e.mix&&e.toValue)?n.toValue():n}var Fr={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function Ur(t){var e=t.attachResizeListener,n=t.defaultParent,r=t.measureScroll,i=t.resetTransform;return function(){function t(t,e,r){var i=this;void 0===e&&(e={}),void 0===r&&(r=null==n?void 0:n()),this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.potentialNodes=new Map,this.checkUpdateFailed=function(){i.isUpdating&&(i.isUpdating=!1,i.clearAllSnapshots())},this.updateProjection=function(){i.nodes.forEach(Hr),i.nodes.forEach(Wr)},this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.id=t,this.latestValues=e,this.root=r?r.root||r:this,this.path=r?l(l([],u(r.path),!1),[r],!1):[],this.parent=r,this.depth=r?r.depth+1:0,t&&this.root.registerPotentialNode(t,this);for(var o=0;o<this.path.length;o++)this.path[o].shouldResetTransform=!0;this.root===this&&(this.nodes=new kr)}return t.prototype.addEventListener=function(t,e){return this.eventHandlers.has(t)||this.eventHandlers.set(t,new er),this.eventHandlers.get(t).add(e)},t.prototype.notifyListeners=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];var r=this.eventHandlers.get(t);null==r||r.notify.apply(r,l([],u(e),!1))},t.prototype.hasListeners=function(t){return this.eventHandlers.has(t)},t.prototype.registerPotentialNode=function(t,e){this.potentialNodes.set(t,e)},t.prototype.mount=function(t,n){var r,i=this;if(void 0===n&&(n=!1),!this.instance){this.isSVG=t instanceof SVGElement&&"svg"!==t.tagName,this.instance=t;var o=this.options,s=o.layoutId,u=o.layout,l=o.visualElement;if(l&&!l.getInstance()&&l.mount(t),this.root.nodes.add(this),null===(r=this.parent)||void 0===r||r.children.add(this),this.id&&this.root.potentialNodes.delete(this.id),n&&(u||s)&&(this.isLayoutDirty=!0),e){var c,d=function(){return i.root.updateBlockedByResize=!1};e(t,(function(){i.root.updateBlockedByResize=!0,clearTimeout(c),c=window.setTimeout(d,250),Fr.hasAnimatedSinceResize&&(Fr.hasAnimatedSinceResize=!1,i.nodes.forEach(Yr))}))}s&&this.root.registerSharedNode(s,this),!1!==this.options.animate&&l&&(s||u)&&this.addEventListener("didUpdate",(function(t){var e,n,r,o,s,u=t.delta,c=t.hasLayoutChanged,d=t.hasRelativeTargetChanged,p=t.layout;if(i.isTreeAnimationBlocked())return i.target=void 0,void(i.relativeTarget=void 0);var f=null!==(n=null!==(e=i.options.transition)&&void 0!==e?e:l.getDefaultTransition())&&void 0!==n?n:Kr,v=l.getProps().onLayoutAnimationComplete,h=!i.targetLayout||!Ar(i.targetLayout,p)||d,m=!c&&d;if((null===(r=i.resumeFrom)||void 0===r?void 0:r.instance)||m||c&&(h||!i.currentAnimation)){i.resumeFrom&&(i.resumingFrom=i.resumeFrom,i.resumingFrom.resumingFrom=void 0),i.setAnimationOrigin(u,m);var y=a(a({},Un(f,"layout")),{onComplete:v});l.shouldReduceMotion&&(y.delay=0,y.type=!1),i.startAnimation(y)}else c||0!==i.animationProgress||i.finishAnimation(),i.isLead()&&(null===(s=(o=i.options).onExitComplete)||void 0===s||s.call(o));i.targetLayout=p}))}},t.prototype.unmount=function(){var t,e;this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this),null===(t=this.getStack())||void 0===t||t.remove(this),null===(e=this.parent)||void 0===e||e.children.delete(this),this.instance=void 0,S.preRender(this.updateProjection)},t.prototype.blockUpdate=function(){this.updateManuallyBlocked=!0},t.prototype.unblockUpdate=function(){this.updateManuallyBlocked=!1},t.prototype.isUpdateBlocked=function(){return this.updateManuallyBlocked||this.updateBlockedByResize},t.prototype.isTreeAnimationBlocked=function(){var t;return this.isAnimationBlocked||(null===(t=this.parent)||void 0===t?void 0:t.isTreeAnimationBlocked())||!1},t.prototype.startUpdate=function(){var t;this.isUpdateBlocked()||(this.isUpdating=!0,null===(t=this.nodes)||void 0===t||t.forEach(Gr))},t.prototype.willUpdate=function(t){var e,n,r;if(void 0===t&&(t=!0),this.root.isUpdateBlocked())null===(n=(e=this.options).onExitComplete)||void 0===n||n.call(e);else if(!this.root.isUpdating&&this.root.startUpdate(),!this.isLayoutDirty){this.isLayoutDirty=!0;for(var i=0;i<this.path.length;i++){var o=this.path[i];o.shouldResetTransform=!0,o.updateScroll()}var a=this.options,s=a.layoutId,u=a.layout;if(void 0!==s||u){var l=null===(r=this.options.visualElement)||void 0===r?void 0:r.getProps().transformTemplate;this.prevTransformTemplateValue=null==l?void 0:l(this.latestValues,""),this.updateSnapshot(),t&&this.notifyListeners("willUpdate")}}},t.prototype.didUpdate=function(){if(this.isUpdateBlocked())return this.unblockUpdate(),this.clearAllSnapshots(),void this.nodes.forEach(zr);this.isUpdating&&(this.isUpdating=!1,this.potentialNodes.size&&(this.potentialNodes.forEach(Jr),this.potentialNodes.clear()),this.nodes.forEach(Xr),this.nodes.forEach(Br),this.nodes.forEach(Ir),this.clearAllSnapshots(),V.update(),V.preRender(),V.render())},t.prototype.clearAllSnapshots=function(){this.nodes.forEach(Nr),this.sharedNodes.forEach($r)},t.prototype.scheduleUpdateProjection=function(){D.preRender(this.updateProjection,!1,!0)},t.prototype.scheduleCheckAfterUnmount=function(){var t=this;D.postRender((function(){t.isLayoutDirty?t.root.didUpdate():t.root.checkUpdateFailed()}))},t.prototype.updateSnapshot=function(){if(!this.snapshot&&this.instance){var t=this.measure(),e=this.removeTransform(this.removeElementScroll(t));ti(e),this.snapshot={measured:t,layout:e,latestValues:{}}}},t.prototype.updateLayout=function(){var t;if(this.instance&&(this.updateScroll(),this.options.alwaysMeasureLayout&&this.isLead()||this.isLayoutDirty)){if(this.resumeFrom&&!this.resumeFrom.instance)for(var e=0;e<this.path.length;e++){this.path[e].updateScroll()}var n=this.measure();ti(n);var r=this.layout;this.layout={measured:n,actual:this.removeElementScroll(n)},this.layoutCorrected={x:{min:0,max:0},y:{min:0,max:0}},this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.actual),null===(t=this.options.visualElement)||void 0===t||t.notifyLayoutMeasure(this.layout.actual,null==r?void 0:r.actual)}},t.prototype.updateScroll=function(){this.options.layoutScroll&&this.instance&&(this.scroll=r(this.instance))},t.prototype.resetTransform=function(){var t;if(i){var e=this.isLayoutDirty||this.shouldResetTransform,n=this.projectionDelta&&!Pr(this.projectionDelta),r=null===(t=this.options.visualElement)||void 0===t?void 0:t.getProps().transformTemplate,o=null==r?void 0:r(this.latestValues,""),a=o!==this.prevTransformTemplateValue;e&&(n||rn(this.latestValues)||a)&&(i(this.instance,o),this.shouldResetTransform=!1,this.scheduleRender())}},t.prototype.measure=function(){var t=this.options.visualElement;if(!t)return{x:{min:0,max:0},y:{min:0,max:0}};var e=t.measureViewportBox(),n=this.root.scroll;return n&&(cn(e.x,n.x),cn(e.y,n.y)),e},t.prototype.removeElementScroll=function(t){var e={x:{min:0,max:0},y:{min:0,max:0}};vr(e,t);for(var n=0;n<this.path.length;n++){var r=this.path[n],i=r.scroll,o=r.options;r!==this.root&&i&&o.layoutScroll&&(cn(e.x,i.x),cn(e.y,i.y))}return e},t.prototype.applyTransform=function(t,e){void 0===e&&(e=!1);var n={x:{min:0,max:0},y:{min:0,max:0}};vr(n,t);for(var r=0;r<this.path.length;r++){var i=this.path[r];!e&&i.options.layoutScroll&&i.scroll&&i!==i.root&&vn(n,{x:-i.scroll.x,y:-i.scroll.y}),rn(i.latestValues)&&vn(n,i.latestValues)}return rn(this.latestValues)&&vn(n,this.latestValues),n},t.prototype.removeTransform=function(t){var e,n={x:{min:0,max:0},y:{min:0,max:0}};vr(n,t);for(var r=0;r<this.path.length;r++){var i=this.path[r];if(i.instance&&rn(i.latestValues)){nn(i.latestValues)&&i.updateSnapshot();var o={x:{min:0,max:0},y:{min:0,max:0}};vr(o,i.measure()),xr(n,i.latestValues,null===(e=i.snapshot)||void 0===e?void 0:e.layout,o)}}return rn(this.latestValues)&&xr(n,this.latestValues),n},t.prototype.setTargetDelta=function(t){this.targetDelta=t,this.root.scheduleUpdateProjection()},t.prototype.setOptions=function(t){var e;this.options=a(a(a({},this.options),t),{crossfade:null===(e=t.crossfade)||void 0===e||e})},t.prototype.clearMeasurements=function(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1},t.prototype.resolveTargetDelta=function(){var t,e,n,r,i=this.options,o=i.layout,a=i.layoutId;this.layout&&(o||a)&&(this.targetDelta||this.relativeTarget||(this.relativeParent=this.getClosestProjectingParent(),this.relativeParent&&this.relativeParent.layout&&(this.relativeTarget={x:{min:0,max:0},y:{min:0,max:0}},this.relativeTargetOrigin={x:{min:0,max:0},y:{min:0,max:0}},$e(this.relativeTargetOrigin,this.layout.actual,this.relativeParent.layout.actual),vr(this.relativeTarget,this.relativeTargetOrigin))),(this.relativeTarget||this.targetDelta)&&(this.t