243 lines
12 KiB
JavaScript
243 lines
12 KiB
JavaScript
// Metro module 1689 (f1690).
|
|
import * as _Module1610 from "./Module1610";
|
|
let bisectRoot, __initData;
|
|
export function checkIfConfigIsValid(a0) {
|
|
let c24546_1 = "";
|
|
["stiffness", "damping", "dampingRatio", "restDisplacementThreshold", "restSpeedThreshold", "mass"].forEach((item) => {
|
|
const r7 = a0[item];
|
|
if (r7 <= 0) {
|
|
c24546_1 = c24546_1 + `, ${item} must be grater than zero but got ${r7}`;
|
|
}
|
|
});
|
|
if (a0.duration < 0) {
|
|
c24546_1 = c24546_1 + `, duration can't be negative, got ${a0.duration}`;
|
|
}
|
|
if (a0.clamp?.min && a0.clamp?.max && a0.clamp.min > a0.clamp.max) {
|
|
c24546_1 = c24546_1 + `, clamp.min should be lower than clamp.max, got clamp: {min: ${a0.clamp.min}, max: ${a0.clamp.max}} `;
|
|
}
|
|
if (c24546_1 !== "") {
|
|
_Module1610.logger.warn("Invalid spring config" + c24546_1);
|
|
}
|
|
return c24546_1 === "";
|
|
}
|
|
checkIfConfigIsValid.__closure = {
|
|
logger: _Module1610.logger
|
|
};
|
|
checkIfConfigIsValid.__workletHash = 16835320063819;
|
|
checkIfConfigIsValid.__initData = {
|
|
code: "function checkIfConfigIsValid_Pnpm_springUtilsTs1(config){const{logger}=this.__closure;var _config$clamp,_config$clamp2;let errorMessage='';['stiffness','damping','dampingRatio','restDisplacementThreshold','restSpeedThreshold','mass'].forEach(function(prop){const value=config[prop];if(value<=0){errorMessage+=\", \"+prop+\" must be grater than zero but got \"+value;}});if(config.duration<0){errorMessage+=\", duration can't be negative, got \"+config.duration;}if((_config$clamp=config.clamp)!==null&&_config$clamp!==void 0&&_config$clamp.min&&(_config$clamp2=config.clamp)!==null&&_config$clamp2!==void 0&&_config$clamp2.max&&config.clamp.min>config.clamp.max){errorMessage+=\", clamp.min should be lower than clamp.max, got clamp: {min: \"+config.clamp.min+\", max: \"+config.clamp.max+\"} \";}if(errorMessage!==''){logger.warn('Invalid spring config'+errorMessage);}return errorMessage==='';}"
|
|
};
|
|
const bisectRoot2 = function bisectRoot(a0) {
|
|
let min = a0.min;
|
|
let max = a0.max;
|
|
const func = a0.func;
|
|
let maxIterations = a0.maxIterations;
|
|
if (maxIterations === void 0) {
|
|
maxIterations = 20;
|
|
}
|
|
const r3 = (max + min) / 2;
|
|
const r21 = Math.abs(func(r3));
|
|
let r2 = r3;
|
|
if (r21 > 0.00005) {
|
|
let r0 = r3;
|
|
r2 = r0;
|
|
if (maxIterations > 0) {
|
|
do {
|
|
const r22 = maxIterations - 1;
|
|
const r17 = func(r0);
|
|
const r1 = r0;
|
|
let r24 = min;
|
|
let r25 = r1;
|
|
if (r17 < 0) {
|
|
r25 = max;
|
|
r24 = r1;
|
|
}
|
|
const r27 = (r24 + r25) / 2;
|
|
const r30 = Math.abs(func(r27));
|
|
r2 = r27;
|
|
if (!(r30 > 0.00005)) {
|
|
break;
|
|
}
|
|
r0 = r27;
|
|
max = r25;
|
|
min = r24;
|
|
r2 = r0;
|
|
maxIterations = r22;
|
|
} while (0 < maxIterations);
|
|
}
|
|
}
|
|
return r2;
|
|
};
|
|
bisectRoot2.__closure = {};
|
|
bisectRoot2.__workletHash = 3467677822604;
|
|
bisectRoot2.__initData = {
|
|
code: "function bisectRoot_Pnpm_springUtilsTs2({min:min,max:max,func:func,maxIterations=20}){const ACCURACY=0.00005;let idx=maxIterations;let current=(max+min)/2;while(Math.abs(func(current))>ACCURACY&&idx>0){idx-=1;if(func(current)<0){min=current;}else{max=current;}current=(min+max)/2;}return current;}"
|
|
};
|
|
bisectRoot = bisectRoot2;
|
|
export function initialCalculations(r8 = 0, r5) {
|
|
if (r5.skipAnimation) {
|
|
return {
|
|
zeta: 0,
|
|
omega0: 0,
|
|
omega1: 0
|
|
};
|
|
}
|
|
if (r5.useDuration) {
|
|
const { stiffness: stiffness3, dampingRatio: dampingRatio2 } = r5;
|
|
const omega02 = Math.sqrt(stiffness3 / r8);
|
|
return {
|
|
zeta: dampingRatio2,
|
|
omega0: omega02,
|
|
omega1: dampingRatio2 < 1 ? omega02 * Math.sqrt(1 - dampingRatio2 ** 2) : 0
|
|
};
|
|
}
|
|
const { damping, mass, stiffness: stiffness2 } = r5;
|
|
const zeta = damping / (2 * Math.sqrt(stiffness2 * mass));
|
|
const omega0 = Math.sqrt(stiffness2 / mass);
|
|
return {
|
|
zeta,
|
|
omega0,
|
|
omega1: zeta < 1 ? omega0 * Math.sqrt(1 - zeta ** 2) : 0
|
|
};
|
|
}
|
|
initialCalculations.__closure = {};
|
|
initialCalculations.__workletHash = 5986209785952;
|
|
initialCalculations.__initData = {
|
|
code: "function initialCalculations_Pnpm_springUtilsTs3(mass=0,config){if(config.skipAnimation){return{zeta:0,omega0:0,omega1:0};}if(config.useDuration){const{stiffness:k,dampingRatio:zeta}=config;const omega0=Math.sqrt(k/mass);const omega1=zeta<1?omega0*Math.sqrt(1-zeta**2):0;return{zeta:zeta,omega0:omega0,omega1:omega1};}else{const{damping:c,mass:m,stiffness:k}=config;const zeta=c/(2*Math.sqrt(k*m));const omega0=Math.sqrt(k/m);const omega1=zeta<1?omega0*Math.sqrt(1-zeta**2):0;return{zeta:zeta,omega0:omega0,omega1:omega1};}}"
|
|
};
|
|
export function scaleZetaToMatchClamps({ zeta, toValue, startValue }, a1) {
|
|
const r17 = Number(toValue);
|
|
if (r17 === startValue) {
|
|
return zeta;
|
|
}
|
|
const [r26, r27] = r17 - startValue > 0 ? [a1.min, a1.max] : [a1.max, a1.min];
|
|
const r28 = r27 !== void 0 ? Math.abs((r27 - r17) / (r17 - startValue)) : void 0;
|
|
const r32 = r26 !== void 0 ? Math.abs((r26 - r17) / (r17 - startValue)) : void 0;
|
|
const r14 = [r28 !== void 0 ? Math.abs(Math.log(r28) / Math.PI) : void 0, r32 !== void 0 ? Math.abs(Math.log(r32) / (2 * Math.PI)) : void 0].filter((item) => item !== void 0);
|
|
const r60 = Math;
|
|
return r60.max.apply(r60, [...r14, zeta]);
|
|
}
|
|
scaleZetaToMatchClamps.__closure = {};
|
|
scaleZetaToMatchClamps.__workletHash = 5791837772627;
|
|
scaleZetaToMatchClamps.__initData = {
|
|
code: "function scaleZetaToMatchClamps_Pnpm_springUtilsTs4(animation,clamp){const{zeta:zeta,toValue:toValue,startValue:startValue}=animation;const toValueNum=Number(toValue);if(toValueNum===startValue){return zeta;}const[firstBound,secondBound]=toValueNum-startValue>0?[clamp.min,clamp.max]:[clamp.max,clamp.min];const relativeExtremum1=secondBound!==undefined?Math.abs((secondBound-toValueNum)/(toValueNum-startValue)):undefined;const relativeExtremum2=firstBound!==undefined?Math.abs((firstBound-toValueNum)/(toValueNum-startValue)):undefined;const newZeta1=relativeExtremum1!==undefined?Math.abs(Math.log(relativeExtremum1)/Math.PI):undefined;const newZeta2=relativeExtremum2!==undefined?Math.abs(Math.log(relativeExtremum2)/(2*Math.PI)):undefined;const zetaSatisfyingClamp=[newZeta1,newZeta2].filter(function(x){return x!==undefined;});return Math.max(...zetaSatisfyingClamp,zeta);}"
|
|
};
|
|
__initData = {
|
|
code: "function pnpm_springUtilsTs6(mass){const{v0,k,x0,zeta,threshold,duration}=this.__closure;const amplitude=(mass*v0*v0+k*x0*x0)/(Math.exp(1-0.5*zeta)*k);const c=zeta*2*Math.sqrt(k*mass);return 1000*(-2*mass/c)*Math.log(threshold*0.01/amplitude)-duration;}"
|
|
};
|
|
export function calculateNewMassToMatchDuration(a0, a1, a2) {
|
|
let c24547_0 = a0;
|
|
if (a1.skipAnimation) {
|
|
return 0;
|
|
}
|
|
const { stiffness, dampingRatio, restSpeedThreshold, duration } = a1;
|
|
const func2 = function(a0) {
|
|
const r6 = a0 * a2 * a2;
|
|
const r21 = (r6 + stiffness * c24547_0 * c24547_0) / (Math.exp(1 - 0.5 * dampingRatio) * stiffness);
|
|
return -2 * a0 / (2 * dampingRatio * Math.sqrt(stiffness * a0)) * 1000 * Math.log(0.01 * restSpeedThreshold / r21) - duration;
|
|
};
|
|
func2.__closure = {
|
|
v0: a2,
|
|
k: stiffness,
|
|
x0: a0,
|
|
zeta: dampingRatio,
|
|
threshold: restSpeedThreshold,
|
|
duration
|
|
};
|
|
func2.__workletHash = 9188609427640;
|
|
func2.__initData = __initData;
|
|
const r25 = {
|
|
min: 0,
|
|
max: 100,
|
|
func: func2
|
|
};
|
|
let min = r25.min;
|
|
let max = r25.max;
|
|
const func = r25.func;
|
|
let maxIterations = r25.maxIterations;
|
|
if (maxIterations === void 0) {
|
|
maxIterations = 20;
|
|
}
|
|
const r3 = (max + min) / 2;
|
|
const r36 = Math.abs(func(r3));
|
|
let r37 = r3;
|
|
if (r36 > 0.00005) {
|
|
let r0 = r3;
|
|
r37 = r0;
|
|
if (maxIterations > 0) {
|
|
do {
|
|
const r38 = maxIterations - 1;
|
|
const r39 = func(r0);
|
|
const r1 = r0;
|
|
let r41 = min;
|
|
let r42 = r1;
|
|
if (r39 < 0) {
|
|
r42 = max;
|
|
r41 = r1;
|
|
}
|
|
const r44 = (r41 + r42) / 2;
|
|
const r47 = Math.abs(func(r44));
|
|
r37 = r44;
|
|
if (!(r47 > 0.00005)) {
|
|
break;
|
|
}
|
|
r0 = r44;
|
|
max = r42;
|
|
min = r41;
|
|
r37 = r0;
|
|
maxIterations = r38;
|
|
} while (0 < maxIterations);
|
|
}
|
|
}
|
|
return r37;
|
|
}
|
|
calculateNewMassToMatchDuration.__closure = {
|
|
bisectRoot
|
|
};
|
|
calculateNewMassToMatchDuration.__workletHash = 4742488441783;
|
|
calculateNewMassToMatchDuration.__initData = {
|
|
code: "function calculateNewMassToMatchDuration_Pnpm_springUtilsTs5(x0,config,v0){const{bisectRoot}=this.__closure;if(config.skipAnimation){return 0;}const{stiffness:k,dampingRatio:zeta,restSpeedThreshold:threshold,duration:duration}=config;const durationForMass=function(mass){'worklet';const amplitude=(mass*v0*v0+k*x0*x0)/(Math.exp(1-0.5*zeta)*k);const c=zeta*2*Math.sqrt(k*mass);return 1000*(-2*mass/c)*Math.log(threshold*0.01/amplitude)-duration;};return bisectRoot({min:0,max:100,func:durationForMass});}"
|
|
};
|
|
export function criticallyDampedSpringCalculations({ toValue }, { v0, x0, omega0, t: r3 }) {
|
|
const r13 = Math.exp(-omega0 * r3);
|
|
return {
|
|
position: toValue - r13 * (x0 + (v0 + omega0 * x0) * r3),
|
|
velocity: r13 * (v0 * (r3 * omega0 - 1) + r3 * x0 * omega0 * omega0)
|
|
};
|
|
}
|
|
criticallyDampedSpringCalculations.__closure = {};
|
|
criticallyDampedSpringCalculations.__workletHash = 57813752690;
|
|
criticallyDampedSpringCalculations.__initData = {
|
|
code: "function criticallyDampedSpringCalculations_Pnpm_springUtilsTs7(animation,precalculatedValues){const{toValue:toValue}=animation;const{v0:v0,x0:x0,omega0:omega0,t:t}=precalculatedValues;const criticallyDampedEnvelope=Math.exp(-omega0*t);const criticallyDampedPosition=toValue-criticallyDampedEnvelope*(x0+(v0+omega0*x0)*t);const criticallyDampedVelocity=criticallyDampedEnvelope*(v0*(t*omega0-1)+t*x0*omega0*omega0);return{position:criticallyDampedPosition,velocity:criticallyDampedVelocity};}"
|
|
};
|
|
export function underDampedSpringCalculations({ toValue, current, velocity }, { zeta, t: r11, omega0, omega1 }) {
|
|
const r8 = -velocity;
|
|
const r13 = toValue - current;
|
|
const r16 = Math.sin(omega1 * r11);
|
|
const r19 = Math.cos(omega1 * r11);
|
|
const r25 = Math.exp(-zeta * omega0 * r11);
|
|
const r33 = r25 * (r16 * ((r8 + zeta * omega0 * r13) / omega1) + r13 * r19);
|
|
return {
|
|
position: toValue - r33,
|
|
velocity: zeta * omega0 * r33 - r25 * (r19 * (r8 + zeta * omega0 * r13) - omega1 * r13 * r16)
|
|
};
|
|
}
|
|
underDampedSpringCalculations.__closure = {};
|
|
underDampedSpringCalculations.__workletHash = 16542539931641;
|
|
underDampedSpringCalculations.__initData = {
|
|
code: "function underDampedSpringCalculations_Pnpm_springUtilsTs8(animation,precalculatedValues){const{toValue:toValue,current:current,velocity:velocity}=animation;const{zeta:zeta,t:t,omega0:omega0,omega1:omega1}=precalculatedValues;const v0=-velocity;const x0=toValue-current;const sin1=Math.sin(omega1*t);const cos1=Math.cos(omega1*t);const underDampedEnvelope=Math.exp(-zeta*omega0*t);const underDampedFrag1=underDampedEnvelope*(sin1*((v0+zeta*omega0*x0)/omega1)+x0*cos1);const underDampedPosition=toValue-underDampedFrag1;const underDampedVelocity=zeta*omega0*underDampedFrag1-underDampedEnvelope*(cos1*(v0+zeta*omega0*x0)-omega1*x0*sin1);return{position:underDampedPosition,velocity:underDampedVelocity};}"
|
|
};
|
|
export function isAnimationTerminatingCalculation({ toValue, velocity, startValue, current }, a1) {
|
|
return {
|
|
isOvershooting: !!a1.overshootClamping && (current > toValue && startValue < toValue || current < toValue && startValue > toValue),
|
|
isVelocity: Math.abs(velocity) < a1.restSpeedThreshold,
|
|
isDisplacement: Math.abs(toValue - current) < a1.restDisplacementThreshold
|
|
};
|
|
}
|
|
isAnimationTerminatingCalculation.__closure = {};
|
|
isAnimationTerminatingCalculation.__workletHash = 3775628746247;
|
|
isAnimationTerminatingCalculation.__initData = {
|
|
code: "function isAnimationTerminatingCalculation_Pnpm_springUtilsTs9(animation,config){const{toValue:toValue,velocity:velocity,startValue:startValue,current:current}=animation;const isOvershooting=config.overshootClamping?current>toValue&&startValue<toValue||current<toValue&&startValue>toValue:false;const isVelocity=Math.abs(velocity)<config.restSpeedThreshold;const isDisplacement=Math.abs(toValue-current)<config.restDisplacementThreshold;return{isOvershooting:isOvershooting,isVelocity:isVelocity,isDisplacement:isDisplacement};}"
|
|
};
|
|
export { bisectRoot };
|