@ssgoi/react 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.js +435 -431
- package/dist/transitions/index.cjs +1 -1
- package/dist/transitions/index.js +98 -98
- package/dist/{utils-BSgyev81.cjs → utils-DR41YsAh-CN_CfgYX.cjs} +1 -1
- package/dist/{utils-DR41YsAh.js → utils-DR41YsAh-mLT5vDuI.js} +4 -4
- package/dist/view-transitions/index.cjs +1 -1
- package/dist/view-transitions/index.js +177 -173
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ht=require("react/jsx-runtime"),X=require("react"),Bt=require("./utils-BSgyev81.cjs");function dt(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(t);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(t,r[s])&&(n[r[s]]=t[r[s]]);return n}var Y=function(){},V=function(){};process.env.NODE_ENV!=="production"&&(Y=function(t,e){!t&&typeof console<"u"&&console.warn(e)},V=function(t,e){if(!t)throw new Error(e)});const W=(t,e,n)=>Math.min(Math.max(n,t),e),L=.001,_t=.01,it=10,Wt=.05,Gt=1;function Ht({duration:t=800,bounce:e=.25,velocity:n=0,mass:r=1}){let s,i;Y(t<=it*1e3,"Spring duration must be 10 seconds or less");let o=1-e;o=W(Wt,Gt,o),t=W(_t,it,t/1e3),o<1?(s=a=>{const p=a*o,m=p*t,u=p-n,f=G(a,o),h=Math.exp(-m);return L-u/f*h},i=a=>{const m=a*o*t,u=m*n+n,f=Math.pow(o,2)*Math.pow(a,2)*t,h=Math.exp(-m),x=G(Math.pow(a,2),o);return(-s(a)+L>0?-1:1)*((u-f)*h)/x}):(s=a=>{const p=Math.exp(-a*t),m=(a-n)*t+1;return-L+p*m},i=a=>{const p=Math.exp(-a*t),m=(n-a)*(t*t);return p*m});const l=5/t,c=zt(s,i,l);if(t=t*1e3,isNaN(c))return{stiffness:100,damping:10,duration:t};{const a=Math.pow(c,2)*r;return{stiffness:a,damping:o*2*Math.sqrt(r*a),duration:t}}}const Kt=12;function zt(t,e,n){let r=n;for(let s=1;s<Kt;s++)r=r-t(r)/e(r);return r}function G(t,e){return t*Math.sqrt(1-e*e)}const Zt=["duration","bounce"],Jt=["stiffness","damping","mass"];function at(t,e){return e.some(n=>t[n]!==void 0)}function Qt(t){let e=Object.assign({velocity:0,stiffness:100,damping:10,mass:1,isResolvedFromDuration:!1},t);if(!at(t,Jt)&&at(t,Zt)){const n=Ht(t);e=Object.assign(Object.assign(Object.assign({},e),n),{velocity:0,mass:1}),e.isResolvedFromDuration=!0}return e}function tt(t){var{from:e=0,to:n=1,restSpeed:r=2,restDelta:s}=t,i=dt(t,["from","to","restSpeed","restDelta"]);const o={done:!1,value:e};let{stiffness:l,damping:c,mass:a,velocity:p,duration:m,isResolvedFromDuration:u}=Qt(i),f=lt,h=lt;function x(){const y=p?-(p/1e3):0,S=n-e,b=c/(2*Math.sqrt(l*a)),g=Math.sqrt(l/a)/1e3;if(s===void 0&&(s=Math.min(Math.abs(n-e)/100,.4)),b<1){const d=G(g,b);f=M=>{const w=Math.exp(-b*g*M);return n-w*((y+b*g*S)/d*Math.sin(d*M)+S*Math.cos(d*M))},h=M=>{const w=Math.exp(-b*g*M);return b*g*w*(Math.sin(d*M)*(y+b*g*S)/d+S*Math.cos(d*M))-w*(Math.cos(d*M)*(y+b*g*S)-d*S*Math.sin(d*M))}}else if(b===1)f=d=>n-Math.exp(-g*d)*(S+(y+g*S)*d);else{const d=g*Math.sqrt(b*b-1);f=M=>{const w=Math.exp(-b*g*M),T=Math.min(d*M,300);return n-w*((y+b*g*S)*Math.sinh(T)+d*S*Math.cosh(T))/d}}}return x(),{next:y=>{const S=f(y);if(u)o.done=y>=m;else{const b=h(y)*1e3,g=Math.abs(b)<=r,d=Math.abs(n-S)<=s;o.done=g&&d}return o.value=o.done?n:S,o},flipTarget:()=>{p=-p,[e,n]=[n,e],x()}}}tt.needsInterpolation=(t,e)=>typeof t=="string"||typeof e=="string";const lt=t=>0,gt=(t,e,n)=>{const r=e-t;return r===0?1:(n-t)/r},et=(t,e,n)=>-n*t+n*e+t,yt=(t,e)=>n=>Math.max(Math.min(n,e),t),A=t=>t%1?Number(t.toFixed(5)):t,N=/(-)?([\d]*\.?[\d])+/g,H=/(#[0-9a-f]{6}|#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2}(-?[\d\.]+%?)\s*[\,\/]?\s*[\d\.]*%?\))/gi,Xt=/^(#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2}(-?[\d\.]+%?)\s*[\,\/]?\s*[\d\.]*%?\))$/i;function I(t){return typeof t=="string"}const k={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},bt=Object.assign(Object.assign({},k),{transform:yt(0,1)});Object.assign(Object.assign({},k),{default:1});const Yt=t=>({test:e=>I(e)&&e.endsWith(t)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${t}`}),R=Yt("%");Object.assign(Object.assign({},R),{parse:t=>R.parse(t)/100,transform:t=>R.transform(t*100)});const nt=(t,e)=>n=>!!(I(n)&&Xt.test(n)&&n.startsWith(t)||e&&Object.prototype.hasOwnProperty.call(n,e)),xt=(t,e,n)=>r=>{if(!I(r))return r;const[s,i,o,l]=r.match(N);return{[t]:parseFloat(s),[e]:parseFloat(i),[n]:parseFloat(o),alpha:l!==void 0?parseFloat(l):1}},O={test:nt("hsl","hue"),parse:xt("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:n,alpha:r=1})=>"hsla("+Math.round(t)+", "+R.transform(A(e))+", "+R.transform(A(n))+", "+A(bt.transform(r))+")"},te=yt(0,255),B=Object.assign(Object.assign({},k),{transform:t=>Math.round(te(t))}),v={test:nt("rgb","red"),parse:xt("red","green","blue"),transform:({red:t,green:e,blue:n,alpha:r=1})=>"rgba("+B.transform(t)+", "+B.transform(e)+", "+B.transform(n)+", "+A(bt.transform(r))+")"};function ee(t){let e="",n="",r="",s="";return t.length>5?(e=t.substr(1,2),n=t.substr(3,2),r=t.substr(5,2),s=t.substr(7,2)):(e=t.substr(1,1),n=t.substr(2,1),r=t.substr(3,1),s=t.substr(4,1),e+=e,n+=n,r+=r,s+=s),{red:parseInt(e,16),green:parseInt(n,16),blue:parseInt(r,16),alpha:s?parseInt(s,16)/255:1}}const K={test:nt("#"),parse:ee,transform:v.transform},U={test:t=>v.test(t)||K.test(t)||O.test(t),parse:t=>v.test(t)?v.parse(t):O.test(t)?O.parse(t):K.parse(t),transform:t=>I(t)?t:t.hasOwnProperty("red")?v.transform(t):O.transform(t)},St="${c}",Mt="${n}";function ne(t){var e,n,r,s;return isNaN(t)&&I(t)&&((n=(e=t.match(N))===null||e===void 0?void 0:e.length)!==null&&n!==void 0?n:0)+((s=(r=t.match(H))===null||r===void 0?void 0:r.length)!==null&&s!==void 0?s:0)>0}function wt(t){typeof t=="number"&&(t=`${t}`);const e=[];let n=0;const r=t.match(H);r&&(n=r.length,t=t.replace(H,St),e.push(...r.map(U.parse)));const s=t.match(N);return s&&(t=t.replace(N,Mt),e.push(...s.map(k.parse))),{values:e,numColors:n,tokenised:t}}function vt(t){return wt(t).values}function Ot(t){const{values:e,numColors:n,tokenised:r}=wt(t),s=e.length;return i=>{let o=r;for(let l=0;l<s;l++)o=o.replace(l<n?St:Mt,l<n?U.transform(i[l]):A(i[l]));return o}}const re=t=>typeof t=="number"?0:t;function se(t){const e=vt(t);return Ot(t)(e.map(re))}const Tt={test:ne,parse:vt,createTransformer:Ot,getAnimatableNone:se};function _(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+(e-t)*6*n:n<1/2?e:n<2/3?t+(e-t)*(2/3-n)*6:t}function ct({hue:t,saturation:e,lightness:n,alpha:r}){t/=360,e/=100,n/=100;let s=0,i=0,o=0;if(!e)s=i=o=n;else{const l=n<.5?n*(1+e):n+e-n*e,c=2*n-l;s=_(c,l,t+1/3),i=_(c,l,t),o=_(c,l,t-1/3)}return{red:Math.round(s*255),green:Math.round(i*255),blue:Math.round(o*255),alpha:r}}const oe=(t,e,n)=>{const r=t*t,s=e*e;return Math.sqrt(Math.max(0,n*(s-r)+r))},ie=[K,v,O],ut=t=>ie.find(e=>e.test(t)),ft=t=>`'${t}' is not an animatable color. Use the equivalent color code instead.`,Ct=(t,e)=>{let n=ut(t),r=ut(e);V(!!n,ft(t)),V(!!r,ft(e));let s=n.parse(t),i=r.parse(e);n===O&&(s=ct(s),n=v),r===O&&(i=ct(i),r=v);const o=Object.assign({},s);return l=>{for(const c in o)c!=="alpha"&&(o[c]=oe(s[c],i[c],l));return o.alpha=et(s.alpha,i.alpha,l),n.transform(o)}},ae=t=>typeof t=="number",le=(t,e)=>n=>e(t(n)),At=(...t)=>t.reduce(le);function Rt(t,e){return ae(t)?n=>et(t,e,n):U.test(t)?Ct(t,e):Vt(t,e)}const Et=(t,e)=>{const n=[...t],r=n.length,s=t.map((i,o)=>Rt(i,e[o]));return i=>{for(let o=0;o<r;o++)n[o]=s[o](i);return n}},ce=(t,e)=>{const n=Object.assign(Object.assign({},t),e),r={};for(const s in n)t[s]!==void 0&&e[s]!==void 0&&(r[s]=Rt(t[s],e[s]));return s=>{for(const i in r)n[i]=r[i](s);return n}};function pt(t){const e=Tt.parse(t),n=e.length;let r=0,s=0,i=0;for(let o=0;o<n;o++)r||typeof e[o]=="number"?r++:e[o].hue!==void 0?i++:s++;return{parsed:e,numNumbers:r,numRGB:s,numHSL:i}}const Vt=(t,e)=>{const n=Tt.createTransformer(e),r=pt(t),s=pt(e);return r.numHSL===s.numHSL&&r.numRGB===s.numRGB&&r.numNumbers>=s.numNumbers?At(Et(r.parsed,s.parsed),n):(Y(!0,`Complex values '${t}' and '${e}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`),o=>`${o>0?e:t}`)},ue=(t,e)=>n=>et(t,e,n);function fe(t){if(typeof t=="number")return ue;if(typeof t=="string")return U.test(t)?Ct:Vt;if(Array.isArray(t))return Et;if(typeof t=="object")return ce}function pe(t,e,n){const r=[],s=n||fe(t[0]),i=t.length-1;for(let o=0;o<i;o++){let l=s(t[o],t[o+1]);if(e){const c=Array.isArray(e)?e[o]:e;l=At(c,l)}r.push(l)}return r}function me([t,e],[n]){return r=>n(gt(t,e,r))}function he(t,e){const n=t.length,r=n-1;return s=>{let i=0,o=!1;if(s<=t[0]?o=!0:s>=t[r]&&(i=r-1,o=!0),!o){let c=1;for(;c<n&&!(t[c]>s||c===r);c++);i=c-1}const l=gt(t[i],t[i+1],s);return e[i](l)}}function jt(t,e,{clamp:n=!0,ease:r,mixer:s}={}){const i=t.length;V(i===e.length,"Both input and output ranges must be the same length"),V(!r||!Array.isArray(r)||r.length===i-1,"Array of easing functions must be of length `input.length - 1`, as it applies to the transitions **between** the defined values."),t[0]>t[i-1]&&(t=[].concat(t),e=[].concat(e),t.reverse(),e.reverse());const o=pe(e,r,s),l=i===2?me(t,o):he(t,o);return n?c=>l(W(t[0],t[i-1],c)):l}const de=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,ge=t=>e=>Math.pow(e,t),ye=ge(2),be=de(ye);function xe(t,e){return t.map(()=>e||be).splice(0,t.length-1)}function Se(t){const e=t.length;return t.map((n,r)=>r!==0?r/(e-1):0)}function Me(t,e){return t.map(n=>n*e)}function P({from:t=0,to:e=1,ease:n,offset:r,duration:s=300}){const i={done:!1,value:t},o=Array.isArray(e)?e:[t,e],l=Me(r&&r.length===o.length?r:Se(o),s);function c(){return jt(l,o,{ease:Array.isArray(n)?n:xe(o,n)})}let a=c();return{next:p=>(i.value=a(p),i.done=p>=s,i),flipTarget:()=>{o.reverse(),a=c()}}}function we({velocity:t=0,from:e=0,power:n=.8,timeConstant:r=350,restDelta:s=.5,modifyTarget:i}){const o={done:!1,value:e};let l=n*t;const c=e+l,a=i===void 0?c:i(c);return a!==c&&(l=a-e),{next:p=>{const m=-l*Math.exp(-p/r);return o.done=!(m>s||m<-s),o.value=o.done?a:a+m,o},flipTarget:()=>{}}}const mt={keyframes:P,spring:tt,decay:we};function ve(t){if(Array.isArray(t.to))return P;if(mt[t.type])return mt[t.type];const e=new Set(Object.keys(t));return e.has("ease")||e.has("duration")&&!e.has("dampingRatio")?P:e.has("dampingRatio")||e.has("stiffness")||e.has("mass")||e.has("damping")||e.has("restSpeed")||e.has("restDelta")?tt:P}const It=1/60*1e3,Oe=typeof performance<"u"?()=>performance.now():()=>Date.now(),Ft=typeof window<"u"?t=>window.requestAnimationFrame(t):t=>setTimeout(()=>t(Oe()),It);function Te(t){let e=[],n=[],r=0,s=!1,i=!1;const o=new WeakSet,l={schedule:(c,a=!1,p=!1)=>{const m=p&&s,u=m?e:n;return a&&o.add(c),u.indexOf(c)===-1&&(u.push(c),m&&s&&(r=e.length)),c},cancel:c=>{const a=n.indexOf(c);a!==-1&&n.splice(a,1),o.delete(c)},process:c=>{if(s){i=!0;return}if(s=!0,[e,n]=[n,e],n.length=0,r=e.length,r)for(let a=0;a<r;a++){const p=e[a];p(c),o.has(p)&&(l.schedule(p),t())}s=!1,i&&(i=!1,l.process(c))}};return l}const Ce=40;let z=!0,j=!1,Z=!1;const E={delta:0,timestamp:0},F=["read","update","preRender","render","postRender"],$=F.reduce((t,e)=>(t[e]=Te(()=>j=!0),t),{}),Ae=F.reduce((t,e)=>{const n=$[e];return t[e]=(r,s=!1,i=!1)=>(j||Ve(),n.schedule(r,s,i)),t},{}),Re=F.reduce((t,e)=>(t[e]=$[e].cancel,t),{});F.reduce((t,e)=>(t[e]=()=>$[e].process(E),t),{});const Ee=t=>$[t].process(E),Dt=t=>{j=!1,E.delta=z?It:Math.max(Math.min(t-E.timestamp,Ce),1),E.timestamp=t,Z=!0,F.forEach(Ee),Z=!1,j&&(z=!1,Ft(Dt))},Ve=()=>{j=!0,z=!0,Z||Ft(Dt)};function Pt(t,e,n=0){return t-e-n}function je(t,e,n=0,r=!0){return r?Pt(e+-t,e,n):e-(t-e)+n}function Ie(t,e,n,r){return r?t>=e+n:t<=-n}const Fe=t=>{const e=({delta:n})=>t(n);return{start:()=>Ae.update(e,!0),stop:()=>Re.update(e)}};function De(t){var e,n,{from:r,autoplay:s=!0,driver:i=Fe,elapsed:o=0,repeat:l=0,repeatType:c="loop",repeatDelay:a=0,onPlay:p,onStop:m,onComplete:u,onRepeat:f,onUpdate:h}=t,x=dt(t,["from","autoplay","driver","elapsed","repeat","repeatType","repeatDelay","onPlay","onStop","onComplete","onRepeat","onUpdate"]);let{to:y}=x,S,b=0,g=x.duration,d,M=!1,w=!0,T;const rt=ve(x);!((n=(e=rt).needsInterpolation)===null||n===void 0)&&n.call(e,r,y)&&(T=jt([0,100],[r,y],{clamp:!1}),r=0,y=100);const st=rt(Object.assign(Object.assign({},x),{from:r,to:y}));function Ut(){b++,c==="reverse"?(w=b%2===0,o=je(o,g,a,w)):(o=Pt(o,g,a),c==="mirror"&&st.flipTarget()),M=!1,f&&f()}function $t(){S.stop(),u&&u()}function qt(q){if(w||(q=-q),o+=q,!M){const ot=st.next(Math.max(0,o));d=ot.value,T&&(d=T(d)),M=w?ot.done:o<=0}h?.(d),M&&(b===0&&(g??(g=o)),b<l?Ie(o,g,a,w)&&Ut():$t())}function Lt(){p?.(),S=i(qt),S.start()}return s&&Lt(),{stop:()=>{m?.(),S.stop()}}}class C{options;currentValue;velocity=0;isAnimating=!1;controls=null;constructor(e){this.options={from:e.from??0,to:e.to??1,spring:e.spring??{stiffness:100,damping:10},onUpdate:e.onUpdate??(()=>{}),onComplete:e.onComplete??(()=>{}),onStart:e.onStart},this.currentValue=this.options.from}animate=(e=!1)=>{!this.isAnimating&&this.options.onStart&&this.options.onStart(),this.isAnimating=!0;const n=e?this.options.from:this.options.to;let r=this.currentValue,s=performance.now();this.controls=De({from:this.currentValue,to:n,velocity:this.velocity*1e3,stiffness:this.options.spring.stiffness,damping:this.options.spring.damping,mass:1,onUpdate:i=>{const o=performance.now(),l=(o-s)/1e3;if(l>0){const c=(i-r)/l;this.velocity=c/1e3,r=i,s=o}this.currentValue=i,this.options.onUpdate(i)},onComplete:()=>{this.currentValue=n,this.isAnimating=!1,this.controls=null,this.velocity=0,this.options.onComplete()}})};forward(){this.stop(),this.animate(!1)}backward(){this.stop(),this.animate(!0)}reverse(){const e=this.options.from;if(this.options.from=this.options.to,this.options.to=e,this.isAnimating){const n=this.currentValue>(this.options.from+this.options.to)/2;this.stop(),this.animate(!n)}}stop(){this.isAnimating=!1,this.controls&&(this.controls.stop(),this.controls=null)}getVelocity(){return this.velocity}getCurrentValue(){return this.currentValue}getIsAnimating(){return this.isAnimating}getCurrentState(){return{position:this.currentValue,velocity:this.velocity}}setVelocity(e){this.velocity=e}setValue(e){this.currentValue=e}updateOptions(e){if(this.options={...this.options,...e},this.isAnimating&&this.controls){const n=this.currentValue<this.options.to;this.stop(),this.animate(!n)}}static fromState(e,n){const r=new C(n);return r.setValue(e.position),r.setVelocity(e.velocity),r}}function Pe(t,e){let n=null,r=null,s=null,i=null,o=!1;const l=async a=>{if(n&&n.getIsAnimating()&&!o){const p=n.getCurrentState();n.stop(),r&&(r.remove(),r=null),o=!0;const m=t();if(!m.out)return;const u=await Promise.resolve(m.out(a));n=C.fromState(p,{from:1,to:0,spring:u.spring,onStart:u.onStart,onUpdate:f=>{u.tick?.(f)},onComplete:()=>{n=null,o=!1,u.onEnd?.()}}),n.backward();return}if(!n||!n.getIsAnimating()){o=!0;const p=t();if(!p.in)return;const m=await Promise.resolve(p.in(a));m.prepare?.(a),n=new C({from:0,to:1,spring:m.spring,onStart:m.onStart,onUpdate:u=>{m.tick?.(u)},onComplete:()=>{n=null,o=!1,m.onEnd?.()}}),n.forward()}};function c(a){const p=()=>{!s||!r||(i&&s.contains(i)?s.insertBefore(r,i):s.appendChild(r))},m=()=>{r&&(r.remove(),r=null),n=null,o=!1,e?.onCleanupEnd?.()},u=t();if(r=a.cloneNode(!0),n&&n.getIsAnimating()&&o){const f=n.getCurrentState();if(n.stop(),o=!1,!u.in){r=null,m();return}Promise.resolve(u.in(r)).then(async h=>{const x=r&&await u.out?.(r);x?.prepare&&r&&x.prepare(r),p(),n=C.fromState(f,{from:0,to:1,spring:h.spring,onStart:h.onStart,onUpdate:y=>{h.tick?.(y)},onComplete:()=>{h.onEnd?.(),m()}}),n.backward()});return}if(!n||!n.getIsAnimating()||!o){if(o=!1,!u.out){r=null,m();return}Promise.resolve(u.out(r)).then(f=>{r&&f.prepare?.(r),p(),n=new C({from:1,to:0,spring:f.spring,onStart:f.onStart,onUpdate:h=>{f.tick?.(h)},onComplete:()=>{f.onEnd?.(),m()}}),n.forward()})}}return a=>a?(s=a.parentElement,i=a.nextElementSibling,t().in&&l(a),()=>{c(a)}):void 0}const J=new Map,Q=new Map;function Ne(t,e){J.set(t,e);let n=Q.get(t);return n||(n=Pe(()=>{const r=J.get(t);return r||(console.warn(`Transition "${String(t)}" not found`),{})},{onCleanupEnd:()=>ke(t)}),Q.set(t,n),n)}function ke(t){J.delete(t),Q.delete(t)}function Ue(t){return Ne(t.key,{in:t.in,out:t.out})}function $e(t){let e=null;const n=[...t.transitions],r=[];for(const u of t.transitions)u.symmetric&&(n.some(h=>h.from===u.to&&h.to===u.from)||r.push({from:u.to,to:u.from,transition:u.transition}));n.push(...r);let s=null;const i=new Map;let o=null;const l=()=>{s&&o&&i.set(o,{x:s.scrollLeft,y:s.scrollTop})},c=(u,f)=>{s||(s=Bt.getScrollingElement(u),s.addEventListener("scroll",l,{passive:!0})),o=f},a=()=>{const u=e?.from,f=e?.to,h=u&&i.has(u)?i.get(u):{x:0,y:0},x=f&&i.has(f)?i.get(f):{x:0,y:0};return{x:-x.x+h.x,y:-x.y+h.y}};function p(){if(e?.from&&e?.to){const f=qe(e.from,e.to,n)||t.defaultTransition,x={scrollOffset:a()};f&&(f.out&&e.outResolve&&e.outResolve(y=>f.out(y,x)),f.in&&e.inResolve&&e.inResolve(y=>f.in(y,x))),e=null}}const m=async(u,f)=>f==="in"&&(!e||!e.from)?()=>({}):(e||(e={}),f==="out"?(e.from=u,new Promise(h=>{e.outResolve=h,p()})):(e.to=u,new Promise(h=>{e.inResolve=h,p()})));return u=>({key:u,in:async f=>(c(f,u),(await m(u,"in"))(f)),out:async f=>(await m(u,"out"))(f)})}function qe(t,e,n){for(const r of n)if(D(t,r.from)&&D(e,r.to))return r.transition;for(const r of n)if((r.from==="*"||D(t,r.from))&&(r.to==="*"||D(e,r.to)))return r.transition;return null}function D(t,e){if(e==="*")return!0;if(e.endsWith("/*")){const n=e.slice(0,-2);return t===n||t.startsWith(n+"/")}return t===e}const Nt=Ue,kt=X.createContext(null),Le=kt.Provider,Be=()=>{const t=X.useContext(kt);if(!t)throw new Error("useSsgoi must be used within SsgoiProvider");return t},_e=({config:t,children:e})=>{const n=X.useMemo(()=>$e(t),[t]);return ht.jsx(Le,{value:n,children:e})},We=({children:t,id:e})=>{const n=Be();return ht.jsx("div",{ref:Nt(n(e)),"data-ssgoi-transition":e,children:t})};exports.Ssgoi=_e;exports.SsgoiTransition=We;exports.transition=Nt;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Wt=require("./utils-DR41YsAh-CN_CfgYX.cjs"),dt=require("react/jsx-runtime"),_=require("react");var Gt=Object.defineProperty,Ht=(t,e,n)=>e in t?Gt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,A=(t,e,n)=>Ht(t,typeof e!="symbol"?e+"":e,n);function gt(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]]);return n}var tt=function(){},E=function(){};process.env.NODE_ENV!=="production"&&(tt=function(t,e){!t&&typeof console<"u"&&console.warn(e)},E=function(t,e){if(!t)throw new Error(e)});const H=(t,e,n)=>Math.min(Math.max(n,t),e),B=.001,Yt=.01,it=10,zt=.05,Jt=1;function Kt({duration:t=800,bounce:e=.25,velocity:n=0,mass:r=1}){let o,a;tt(t<=it*1e3,"Spring duration must be 10 seconds or less");let s=1-e;s=H(zt,Jt,s),t=H(Yt,it,t/1e3),s<1?(o=u=>{const h=u*s,m=h*t,i=h-n,l=Y(u,s),p=Math.exp(-m);return B-i/l*p},a=u=>{const h=u*s*t,m=h*n+n,i=Math.pow(s,2)*Math.pow(u,2)*t,l=Math.exp(-h),p=Y(Math.pow(u,2),s);return(-o(u)+B>0?-1:1)*((m-i)*l)/p}):(o=u=>{const h=Math.exp(-u*t),m=(u-n)*t+1;return-B+h*m},a=u=>{const h=Math.exp(-u*t),m=(n-u)*(t*t);return h*m});const f=5/t,c=Xt(o,a,f);if(t=t*1e3,isNaN(c))return{stiffness:100,damping:10,duration:t};{const u=Math.pow(c,2)*r;return{stiffness:u,damping:s*2*Math.sqrt(r*u),duration:t}}}const Qt=12;function Xt(t,e,n){let r=n;for(let o=1;o<Qt;o++)r=r-t(r)/e(r);return r}function Y(t,e){return t*Math.sqrt(1-e*e)}const Zt=["duration","bounce"],_t=["stiffness","damping","mass"];function lt(t,e){return e.some(n=>t[n]!==void 0)}function te(t){let e=Object.assign({velocity:0,stiffness:100,damping:10,mass:1,isResolvedFromDuration:!1},t);if(!lt(t,_t)&<(t,Zt)){const n=Kt(t);e=Object.assign(Object.assign(Object.assign({},e),n),{velocity:0,mass:1}),e.isResolvedFromDuration=!0}return e}function et(t){var{from:e=0,to:n=1,restSpeed:r=2,restDelta:o}=t,a=gt(t,["from","to","restSpeed","restDelta"]);const s={done:!1,value:e};let{stiffness:f,damping:c,mass:u,velocity:h,duration:m,isResolvedFromDuration:i}=te(a),l=ut,p=ut;function y(){const b=h?-(h/1e3):0,d=n-e,g=c/(2*Math.sqrt(f*u)),M=Math.sqrt(f/u)/1e3;if(o===void 0&&(o=Math.min(Math.abs(n-e)/100,.4)),g<1){const v=Y(M,g);l=w=>{const x=Math.exp(-g*M*w);return n-x*((b+g*M*d)/v*Math.sin(v*w)+d*Math.cos(v*w))},p=w=>{const x=Math.exp(-g*M*w);return g*M*x*(Math.sin(v*w)*(b+g*M*d)/v+d*Math.cos(v*w))-x*(Math.cos(v*w)*(b+g*M*d)-v*d*Math.sin(v*w))}}else if(g===1)l=v=>n-Math.exp(-M*v)*(d+(b+M*d)*v);else{const v=M*Math.sqrt(g*g-1);l=w=>{const x=Math.exp(-g*M*w),j=Math.min(v*w,300);return n-x*((b+g*M*d)*Math.sinh(j)+v*d*Math.cosh(j))/v}}}return y(),{next:b=>{const d=l(b);if(i)s.done=b>=m;else{const g=p(b)*1e3,M=Math.abs(g)<=r,v=Math.abs(n-d)<=o;s.done=M&&v}return s.value=s.done?n:d,s},flipTarget:()=>{h=-h,[e,n]=[n,e],y()}}}et.needsInterpolation=(t,e)=>typeof t=="string"||typeof e=="string";const ut=t=>0,vt=(t,e,n)=>{const r=e-t;return r===0?1:(n-t)/r},nt=(t,e,n)=>-n*t+n*e+t,yt=(t,e)=>n=>Math.max(Math.min(n,e),t),R=t=>t%1?Number(t.toFixed(5)):t,N=/(-)?([\d]*\.?[\d])+/g,z=/(#[0-9a-f]{6}|#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2}(-?[\d\.]+%?)\s*[\,\/]?\s*[\d\.]*%?\))/gi,ee=/^(#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2}(-?[\d\.]+%?)\s*[\,\/]?\s*[\d\.]*%?\))$/i;function k(t){return typeof t=="string"}const U={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},bt=Object.assign(Object.assign({},U),{transform:yt(0,1)});Object.assign(Object.assign({},U),{default:1});const ne=t=>({test:e=>k(e)&&e.endsWith(t)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${t}`}),V=ne("%");Object.assign(Object.assign({},V),{parse:t=>V.parse(t)/100,transform:t=>V.transform(t*100)});const rt=(t,e)=>n=>!!(k(n)&&ee.test(n)&&n.startsWith(t)||e&&Object.prototype.hasOwnProperty.call(n,e)),Mt=(t,e,n)=>r=>{if(!k(r))return r;const[o,a,s,f]=r.match(N);return{[t]:parseFloat(o),[e]:parseFloat(a),[n]:parseFloat(s),alpha:f!==void 0?parseFloat(f):1}},S={test:rt("hsl","hue"),parse:Mt("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:n,alpha:r=1})=>"hsla("+Math.round(t)+", "+V.transform(R(e))+", "+V.transform(R(n))+", "+R(bt.transform(r))+")"},re=yt(0,255),W=Object.assign(Object.assign({},U),{transform:t=>Math.round(re(t))}),O={test:rt("rgb","red"),parse:Mt("red","green","blue"),transform:({red:t,green:e,blue:n,alpha:r=1})=>"rgba("+W.transform(t)+", "+W.transform(e)+", "+W.transform(n)+", "+R(bt.transform(r))+")"};function oe(t){let e="",n="",r="",o="";return t.length>5?(e=t.substr(1,2),n=t.substr(3,2),r=t.substr(5,2),o=t.substr(7,2)):(e=t.substr(1,1),n=t.substr(2,1),r=t.substr(3,1),o=t.substr(4,1),e+=e,n+=n,r+=r,o+=o),{red:parseInt(e,16),green:parseInt(n,16),blue:parseInt(r,16),alpha:o?parseInt(o,16)/255:1}}const J={test:rt("#"),parse:oe,transform:O.transform},$={test:t=>O.test(t)||J.test(t)||S.test(t),parse:t=>O.test(t)?O.parse(t):S.test(t)?S.parse(t):J.parse(t),transform:t=>k(t)?t:t.hasOwnProperty("red")?O.transform(t):S.transform(t)},wt="${c}",xt="${n}";function se(t){var e,n,r,o;return isNaN(t)&&k(t)&&((n=(e=t.match(N))===null||e===void 0?void 0:e.length)!==null&&n!==void 0?n:0)+((o=(r=t.match(z))===null||r===void 0?void 0:r.length)!==null&&o!==void 0?o:0)>0}function Ot(t){typeof t=="number"&&(t=`${t}`);const e=[];let n=0;const r=t.match(z);r&&(n=r.length,t=t.replace(z,wt),e.push(...r.map($.parse)));const o=t.match(N);return o&&(t=t.replace(N,xt),e.push(...o.map(U.parse))),{values:e,numColors:n,tokenised:t}}function St(t){return Ot(t).values}function jt(t){const{values:e,numColors:n,tokenised:r}=Ot(t),o=e.length;return a=>{let s=r;for(let f=0;f<o;f++)s=s.replace(f<n?wt:xt,f<n?$.transform(a[f]):R(a[f]));return s}}const ae=t=>typeof t=="number"?0:t;function ie(t){const e=St(t);return jt(t)(e.map(ae))}const At={test:se,parse:St,createTransformer:jt,getAnimatableNone:ie};function G(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+(e-t)*6*n:n<1/2?e:n<2/3?t+(e-t)*(2/3-n)*6:t}function ct({hue:t,saturation:e,lightness:n,alpha:r}){t/=360,e/=100,n/=100;let o=0,a=0,s=0;if(!e)o=a=s=n;else{const f=n<.5?n*(1+e):n+e-n*e,c=2*n-f;o=G(c,f,t+1/3),a=G(c,f,t),s=G(c,f,t-1/3)}return{red:Math.round(o*255),green:Math.round(a*255),blue:Math.round(s*255),alpha:r}}const le=(t,e,n)=>{const r=t*t,o=e*e;return Math.sqrt(Math.max(0,n*(o-r)+r))},ue=[J,O,S],ft=t=>ue.find(e=>e.test(t)),pt=t=>`'${t}' is not an animatable color. Use the equivalent color code instead.`,Ct=(t,e)=>{let n=ft(t),r=ft(e);E(!!n,pt(t)),E(!!r,pt(e));let o=n.parse(t),a=r.parse(e);n===S&&(o=ct(o),n=O),r===S&&(a=ct(a),r=O);const s=Object.assign({},o);return f=>{for(const c in s)c!=="alpha"&&(s[c]=le(o[c],a[c],f));return s.alpha=nt(o.alpha,a.alpha,f),n.transform(s)}},ce=t=>typeof t=="number",fe=(t,e)=>n=>e(t(n)),Rt=(...t)=>t.reduce(fe);function Vt(t,e){return ce(t)?n=>nt(t,e,n):$.test(t)?Ct(t,e):Et(t,e)}const Pt=(t,e)=>{const n=[...t],r=n.length,o=t.map((a,s)=>Vt(a,e[s]));return a=>{for(let s=0;s<r;s++)n[s]=o[s](a);return n}},pe=(t,e)=>{const n=Object.assign(Object.assign({},t),e),r={};for(const o in n)t[o]!==void 0&&e[o]!==void 0&&(r[o]=Vt(t[o],e[o]));return o=>{for(const a in r)n[a]=r[a](o);return n}};function ht(t){const e=At.parse(t),n=e.length;let r=0,o=0,a=0;for(let s=0;s<n;s++)r||typeof e[s]=="number"?r++:e[s].hue!==void 0?a++:o++;return{parsed:e,numNumbers:r,numRGB:o,numHSL:a}}const Et=(t,e)=>{const n=At.createTransformer(e),r=ht(t),o=ht(e);return r.numHSL===o.numHSL&&r.numRGB===o.numRGB&&r.numNumbers>=o.numNumbers?Rt(Pt(r.parsed,o.parsed),n):(tt(!0,`Complex values '${t}' and '${e}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`),a=>`${a>0?e:t}`)},he=(t,e)=>n=>nt(t,e,n);function me(t){if(typeof t=="number")return he;if(typeof t=="string")return $.test(t)?Ct:Et;if(Array.isArray(t))return Pt;if(typeof t=="object")return pe}function de(t,e,n){const r=[],o=n||me(t[0]),a=t.length-1;for(let s=0;s<a;s++){let f=o(t[s],t[s+1]);if(e){const c=Array.isArray(e)?e[s]:e;f=Rt(c,f)}r.push(f)}return r}function ge([t,e],[n]){return r=>n(vt(t,e,r))}function ve(t,e){const n=t.length,r=n-1;return o=>{let a=0,s=!1;if(o<=t[0]?s=!0:o>=t[r]&&(a=r-1,s=!0),!s){let c=1;for(;c<n&&!(t[c]>o||c===r);c++);a=c-1}const f=vt(t[a],t[a+1],o);return e[a](f)}}function Tt(t,e,{clamp:n=!0,ease:r,mixer:o}={}){const a=t.length;E(a===e.length,"Both input and output ranges must be the same length"),E(!r||!Array.isArray(r)||r.length===a-1,"Array of easing functions must be of length `input.length - 1`, as it applies to the transitions **between** the defined values."),t[0]>t[a-1]&&(t=[].concat(t),e=[].concat(e),t.reverse(),e.reverse());const s=de(e,r,o),f=a===2?ge(t,s):ve(t,s);return n?c=>f(H(t[0],t[a-1],c)):f}const ye=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,be=t=>e=>Math.pow(e,t),Me=be(2),we=ye(Me);function xe(t,e){return t.map(()=>e||we).splice(0,t.length-1)}function Oe(t){const e=t.length;return t.map((n,r)=>r!==0?r/(e-1):0)}function Se(t,e){return t.map(n=>n*e)}function F({from:t=0,to:e=1,ease:n,offset:r,duration:o=300}){const a={done:!1,value:t},s=Array.isArray(e)?e:[t,e],f=Se(r&&r.length===s.length?r:Oe(s),o);function c(){return Tt(f,s,{ease:Array.isArray(n)?n:xe(s,n)})}let u=c();return{next:h=>(a.value=u(h),a.done=h>=o,a),flipTarget:()=>{s.reverse(),u=c()}}}function je({velocity:t=0,from:e=0,power:n=.8,timeConstant:r=350,restDelta:o=.5,modifyTarget:a}){const s={done:!1,value:e};let f=n*t;const c=e+f,u=a===void 0?c:a(c);return u!==c&&(f=u-e),{next:h=>{const m=-f*Math.exp(-h/r);return s.done=!(m>o||m<-o),s.value=s.done?u:u+m,s},flipTarget:()=>{}}}const mt={keyframes:F,spring:et,decay:je};function Ae(t){if(Array.isArray(t.to))return F;if(mt[t.type])return mt[t.type];const e=new Set(Object.keys(t));return e.has("ease")||e.has("duration")&&!e.has("dampingRatio")?F:e.has("dampingRatio")||e.has("stiffness")||e.has("mass")||e.has("damping")||e.has("restSpeed")||e.has("restDelta")?et:F}const kt=1/60*1e3,Ce=typeof performance<"u"?()=>performance.now():()=>Date.now(),It=typeof window<"u"?t=>window.requestAnimationFrame(t):t=>setTimeout(()=>t(Ce()),kt);function Re(t){let e=[],n=[],r=0,o=!1,a=!1;const s=new WeakSet,f={schedule:(c,u=!1,h=!1)=>{const m=h&&o,i=m?e:n;return u&&s.add(c),i.indexOf(c)===-1&&(i.push(c),m&&o&&(r=e.length)),c},cancel:c=>{const u=n.indexOf(c);u!==-1&&n.splice(u,1),s.delete(c)},process:c=>{if(o){a=!0;return}if(o=!0,[e,n]=[n,e],n.length=0,r=e.length,r)for(let u=0;u<r;u++){const h=e[u];h(c),s.has(h)&&(f.schedule(h),t())}o=!1,a&&(a=!1,f.process(c))}};return f}const Ve=40;let K=!0,T=!1,Q=!1;const P={delta:0,timestamp:0},I=["read","update","preRender","render","postRender"],q=I.reduce((t,e)=>(t[e]=Re(()=>T=!0),t),{}),Pe=I.reduce((t,e)=>{const n=q[e];return t[e]=(r,o=!1,a=!1)=>(T||ke(),n.schedule(r,o,a)),t},{}),Ee=I.reduce((t,e)=>(t[e]=q[e].cancel,t),{});I.reduce((t,e)=>(t[e]=()=>q[e].process(P),t),{});const Te=t=>q[t].process(P),Dt=t=>{T=!1,P.delta=K?kt:Math.max(Math.min(t-P.timestamp,Ve),1),P.timestamp=t,Q=!0,I.forEach(Te),Q=!1,T&&(K=!1,It(Dt))},ke=()=>{T=!0,K=!0,Q||It(Dt)};function Ft(t,e,n=0){return t-e-n}function Ie(t,e,n=0,r=!0){return r?Ft(e+-t,e,n):e-(t-e)+n}function De(t,e,n,r){return r?t>=e+n:t<=-n}const Fe=t=>{const e=({delta:n})=>t(n);return{start:()=>Pe.update(e,!0),stop:()=>Ee.update(e)}};function Ne(t){var e,n,{from:r,autoplay:o=!0,driver:a=Fe,elapsed:s=0,repeat:f=0,repeatType:c="loop",repeatDelay:u=0,onPlay:h,onStop:m,onComplete:i,onRepeat:l,onUpdate:p}=t,y=gt(t,["from","autoplay","driver","elapsed","repeat","repeatType","repeatDelay","onPlay","onStop","onComplete","onRepeat","onUpdate"]);let{to:b}=y,d,g=0,M=y.duration,v,w=!1,x=!0,j;const ot=Ae(y);!((n=(e=ot).needsInterpolation)===null||n===void 0)&&n.call(e,r,b)&&(j=Tt([0,100],[r,b],{clamp:!1}),r=0,b=100);const st=ot(Object.assign(Object.assign({},y),{from:r,to:b}));function $t(){g++,c==="reverse"?(x=g%2===0,s=Ie(s,M,u,x)):(s=Ft(s,M,u),c==="mirror"&&st.flipTarget()),w=!1,l&&l()}function qt(){d.stop(),i&&i()}function Lt(L){if(x||(L=-L),s+=L,!w){const at=st.next(Math.max(0,s));v=at.value,j&&(v=j(v)),w=x?at.done:s<=0}p?.(v),w&&(g===0&&(M??(M=s)),g<f?De(s,M,u,x)&&$t():qt())}function Bt(){h?.(),d=a(Lt),d.start()}return o&&Bt(),{stop:()=>{m?.(),d.stop()}}}class C{constructor(e){A(this,"options"),A(this,"currentValue"),A(this,"velocity",0),A(this,"isAnimating",!1),A(this,"controls",null),A(this,"animate",(n=!1)=>{!this.isAnimating&&this.options.onStart&&this.options.onStart(),this.isAnimating=!0;const r=n?this.options.from:this.options.to;let o=this.currentValue,a=performance.now();this.controls=Ne({from:this.currentValue,to:r,velocity:this.velocity*1e3,stiffness:this.options.spring.stiffness,damping:this.options.spring.damping,mass:1,onUpdate:s=>{const f=performance.now(),c=(f-a)/1e3;if(c>0){const u=(s-o)/c;this.velocity=u/1e3,o=s,a=f}this.currentValue=s,this.options.onUpdate(s)},onComplete:()=>{this.currentValue=r,this.isAnimating=!1,this.controls=null,this.velocity=0,this.options.onComplete()}})}),this.options={from:e.from??0,to:e.to??1,spring:e.spring??{stiffness:100,damping:10},onUpdate:e.onUpdate??(()=>{}),onComplete:e.onComplete??(()=>{}),onStart:e.onStart},this.currentValue=this.options.from}forward(){this.stop(),this.animate(!1)}backward(){this.stop(),this.animate(!0)}reverse(){const e=this.options.from;if(this.options.from=this.options.to,this.options.to=e,this.isAnimating){const n=this.currentValue>(this.options.from+this.options.to)/2;this.stop(),this.animate(!n)}}stop(){this.isAnimating=!1,this.controls&&(this.controls.stop(),this.controls=null)}getVelocity(){return this.velocity}getCurrentValue(){return this.currentValue}getIsAnimating(){return this.isAnimating}getCurrentState(){return{position:this.currentValue,velocity:this.velocity}}setVelocity(e){this.velocity=e}setValue(e){this.currentValue=e}updateOptions(e){if(this.options={...this.options,...e},this.isAnimating&&this.controls){const n=this.currentValue<this.options.to;this.stop(),this.animate(!n)}}static fromState(e,n){const r=new C(n);return r.setValue(e.position),r.setVelocity(e.velocity),r}}function Ue(t,e){let n=null,r=null,o=null,a=null,s=!1;const f=async u=>{var h;if(n&&n.getIsAnimating()&&!s){const m=n.getCurrentState();n.stop(),r&&(r.remove(),r=null),s=!0;const i=t();if(!i.out)return;const l=await Promise.resolve(i.out(u));n=C.fromState(m,{from:1,to:0,spring:l.spring,onStart:l.onStart,onUpdate:p=>{var y;(y=l.tick)==null||y.call(l,p)},onComplete:()=>{var p;n=null,s=!1,(p=l.onEnd)==null||p.call(l)}}),n.backward();return}if(!n||!n.getIsAnimating()){s=!0;const m=t();if(!m.in)return;const i=await Promise.resolve(m.in(u));(h=i.prepare)==null||h.call(i,u),n=new C({from:0,to:1,spring:i.spring,onStart:i.onStart,onUpdate:l=>{var p;(p=i.tick)==null||p.call(i,l)},onComplete:()=>{var l;n=null,s=!1,(l=i.onEnd)==null||l.call(i)}}),n.forward()}};function c(u){const h=()=>{!o||!r||(a&&o.contains(a)?o.insertBefore(r,a):o.appendChild(r))},m=()=>{var l;r&&(r.remove(),r=null),n=null,s=!1,(l=e?.onCleanupEnd)==null||l.call(e)},i=t();if(r=u.cloneNode(!0),n&&n.getIsAnimating()&&s){const l=n.getCurrentState();if(n.stop(),s=!1,!i.in){r=null,m();return}Promise.resolve(i.in(r)).then(async p=>{var y;const b=r&&await((y=i.out)==null?void 0:y.call(i,r));b!=null&&b.prepare&&r&&b.prepare(r),h(),n=C.fromState(l,{from:0,to:1,spring:p.spring,onStart:p.onStart,onUpdate:d=>{var g;(g=p.tick)==null||g.call(p,d)},onComplete:()=>{var d;(d=p.onEnd)==null||d.call(p),m()}}),n.backward()});return}if(!n||!n.getIsAnimating()||!s){if(s=!1,!i.out){r=null,m();return}Promise.resolve(i.out(r)).then(l=>{var p;r&&((p=l.prepare)==null||p.call(l,r)),h(),n=new C({from:1,to:0,spring:l.spring,onStart:l.onStart,onUpdate:y=>{var b;(b=l.tick)==null||b.call(l,y)},onComplete:()=>{var y;(y=l.onEnd)==null||y.call(l),m()}}),n.forward()})}}return u=>u?(o=u.parentElement,a=u.nextElementSibling,t().in&&f(u),()=>{c(u)}):void 0}const X=new Map,Z=new Map;function $e(t,e){X.set(t,e);let n=Z.get(t);return n||(n=Ue(()=>X.get(t)||(console.warn(`Transition "${String(t)}" not found`),{}),{onCleanupEnd:()=>qe(t)}),Z.set(t,n),n)}function qe(t){X.delete(t),Z.delete(t)}function Le(t){return $e(t.key,{in:t.in,out:t.out})}function Be(t){let e=null;const n=[...t.transitions],r=[];for(const i of t.transitions)i.symmetric&&(n.some(l=>l.from===i.to&&l.to===i.from)||r.push({from:i.to,to:i.from,transition:i.transition}));n.push(...r);let o=null;const a=new Map;let s=null;const f=()=>{o&&s&&a.set(s,{x:o.scrollLeft,y:o.scrollTop})},c=(i,l)=>{o||(o=Wt.r(i),o.addEventListener("scroll",f,{passive:!0})),s=l},u=()=>{const i=e?.from,l=e?.to,p=i&&a.has(i)?a.get(i):{x:0,y:0},y=l&&a.has(l)?a.get(l):{x:0,y:0};return{x:-y.x+p.x,y:-y.y+p.y}};function h(){if(e!=null&&e.from&&e!=null&&e.to){const i=We(e.from,e.to,n)||t.defaultTransition,l={scrollOffset:u()};i&&(i.out&&e.outResolve&&e.outResolve(p=>i.out(p,l)),i.in&&e.inResolve&&e.inResolve(p=>i.in(p,l))),e=null}}const m=async(i,l)=>l==="in"&&(!e||!e.from)?()=>({}):(e||(e={}),l==="out"?(e.from=i,new Promise(p=>{e.outResolve=p,h()})):(e.to=i,new Promise(p=>{e.inResolve=p,h()})));return i=>({key:i,in:async l=>(c(l,i),(await m(i,"in"))(l)),out:async l=>(await m(i,"out"))(l)})}function We(t,e,n){for(const r of n)if(D(t,r.from)&&D(e,r.to))return r.transition;for(const r of n)if((r.from==="*"||D(t,r.from))&&(r.to==="*"||D(e,r.to)))return r.transition;return null}function D(t,e){if(e==="*")return!0;if(e.endsWith("/*")){const n=e.slice(0,-2);return t===n||t.startsWith(n+"/")}return t===e}const Nt=Le,Ut=_.createContext(null),Ge=Ut.Provider,He=()=>{const t=_.useContext(Ut);if(!t)throw new Error("useSsgoi must be used within SsgoiProvider");return t},Ye=({config:t,children:e})=>{const n=_.useMemo(()=>Be(t),[t]);return dt.jsx(Ge,{value:n,children:e})},ze=({children:t,id:e})=>{const n=He();return dt.jsx("div",{ref:Nt(n(e)),"data-ssgoi-transition":e,children:t})};exports.Ssgoi=Ye;exports.SsgoiTransition=ze;exports.transition=Nt;
|