// Metro module 1756 (f1757). import { useRef, useEffect } from "react"; import { Platform } from "react-native"; import * as _Module1609 from "./Module1609"; import { isJest } from "./Module1609"; import * as _Module1757 from "./Module1757"; import * as _isAnimated from "./isAnimated"; import { buildWorkletsHash } from "./isAnimated"; import * as _Module1706 from "./Module1706"; import { ReanimatedError } from "./Module1617"; import { useSharedValue } from "./Module1758"; import { initialUpdaterRun } from "./Module1678"; import { makeShareable, runOnUI, startMapper, stopMapper } from "./Module1650"; import { makeViewDescriptorsSet } from "./Module1704"; function $mk113968($env) { return (a0) => { const r5 = $env; const r9 = $env.$parent.$parent[7]; const r16 = r5[1]; const r14 = r16[a0]; const r13 = r5[0]; const r4 = r5[3]; if (r9(r14, r13, a0, r4, $env.$parent[2])) { r5[2][a0] = r4[a0]; delete r16[a0]; } else { r5[4] = false; } }; } let animatedStyleHandleToJSON, c1480_5, prepareAnimation2, runAnimations2, styleUpdater, jestStyleUpdater, c1480_11, c1480_12, c1480_13, c1480_14, c1480_15; let prepareAnimation; let runAnimations; let env1480 = {}; const checkSharedValueUsage = function checkSharedValueUsage(a0, a1) { L17: { if (Array.isArray(a0)) { for (const item2 of a0) { checkSharedValueUsage(item2, a1); } } else { if (typeof a0 === "object" && a0 !== null && a0.value === void 0) { for (const item of Object.keys(a0)) { checkSharedValueUsage(a0[item], item); } break L17; } if (a1 !== void 0 && typeof a0 === "object" && a0 !== null && a0.value !== void 0) { throw new ReanimatedError(`Invalid value passed to \`${a1}\`, maybe you forgot to use \`.value\`?`); } } } }; animatedStyleHandleToJSON = function animatedStyleHandleToJSON() { return "{}"; }; Platform; const shouldBeUseWeb = _Module1609.shouldBeUseWeb(); c1480_5 = shouldBeUseWeb; prepareAnimation = function prepareAnimation(a0, a1, a2, a3) { let c24657_4, current; let c24657_0 = a0; if (Array.isArray(a1)) { a1.forEach((item, index) => { const r4 = a2 && a2[index]; prepareAnimation(c24657_0, item, r4, a3 && a3[index]); }); } if (typeof a1 === "object" && a1.onFrame) { c24657_4 = a1; current = a1.current; if (a3 != null) { if (typeof a3 === "object") { if (a3.value !== void 0) { current = a3.value; } else if (a3.onFrame !== void 0) { if (a2?.current !== void 0) { current = a2.current; } else if (a3?.current !== void 0) { current = a3.current; } } } else { current = a3; } } a1.callStart = (a0) => { c24657_4.onStart(c24657_4, current, a0, a2); }; a1.callStart(a0); a1.callStart = null; } else if (typeof a1 === "object") { Object.keys(a1).forEach((item) => { const r4 = a1[item]; const r15 = a2 && a2[item]; prepareAnimation(c24657_0, r4, r15, a3 && a3[item]); }); } }; prepareAnimation.__closure = {}; prepareAnimation.__workletHash = 14540565048240; prepareAnimation.__initData = { code: "function prepareAnimation_Pnpm_useAnimatedStyleTs1(frameTimestamp,animatedProp,lastAnimation,lastValue){const prepareAnimation_Pnpm_useAnimatedStyleTs1=this._recur;if(Array.isArray(animatedProp)){animatedProp.forEach(function(prop,index){prepareAnimation_Pnpm_useAnimatedStyleTs1(frameTimestamp,prop,lastAnimation&&lastAnimation[index],lastValue&&lastValue[index]);});}if(typeof animatedProp==='object'&&animatedProp.onFrame){const animation=animatedProp;let value=animation.current;if(lastValue!==undefined&&lastValue!==null){if(typeof lastValue==='object'){if(lastValue.value!==undefined){value=lastValue.value;}else if(lastValue.onFrame!==undefined){if((lastAnimation===null||lastAnimation===void 0?void 0:lastAnimation.current)!==undefined){value=lastAnimation.current;}else if((lastValue===null||lastValue===void 0?void 0:lastValue.current)!==undefined){value=lastValue.current;}}}else{value=lastValue;}}animation.callStart=function(timestamp){animation.onStart(animation,value,timestamp,lastAnimation);};animation.callStart(frameTimestamp);animation.callStart=null;}else if(typeof animatedProp==='object'){Object.keys(animatedProp).forEach(function(key){return prepareAnimation_Pnpm_useAnimatedStyleTs1(frameTimestamp,animatedProp[key],lastAnimation&&lastAnimation[key],lastValue&&lastValue[key]);});}}" }; prepareAnimation2 = prepareAnimation; runAnimations = function runAnimations(a0, a1, a2, a3, a4, a5) { let c24658_6, c24658_7; let c24658_5 = a5; if (a4.value) { if (Array.isArray(a0)) { a3[a2] = []; c24658_6 = true; c24658_5 = a2 === "boxShadow"; a0.forEach((item, index) => { if (!runAnimations(item, a1, index, a3[a2], a4, c24658_5)) { c24658_6 = false; } }); return c24658_6; } if (typeof a0 === "object" && a0.onFrame) { const finished = a0.finished; let r29 = true; if (!finished) { if (a0.callStart) { a0.callStart(a1); a0.callStart = null; } const r34 = a0.onFrame(a0, a1); a0.timestamp = a1; r29 = r34; if (r34) { a0.finished = true; const callback = a0.callback; r29 = r34; if (callback) { a0.callback(true); r29 = r34; } } } const current2 = a0.current; a3[a2] = a5 ? { ...current2 } : current2; return r29; } if (typeof a0 === "object") { a3[a2] = {}; c24658_7 = true; Object.keys(a0).forEach((item) => { if (!runAnimations(a0[item], a1, item, a3[a2], a4, c24658_5)) { c24658_7 = false; } }); return c24658_7; } a3[a2] = a0; return true; } return true; }; runAnimations.__closure = {}; runAnimations.__workletHash = 2714844766543; runAnimations.__initData = { code: "function runAnimations_Pnpm_useAnimatedStyleTs2(animation,timestamp,key,result,animationsActive,forceCopyAnimation){const runAnimations_Pnpm_useAnimatedStyleTs2=this._recur;if(!animationsActive.value){return true;}if(Array.isArray(animation)){result[key]=[];let allFinished=true;forceCopyAnimation=key==='boxShadow';animation.forEach(function(entry,index){if(!runAnimations_Pnpm_useAnimatedStyleTs2(entry,timestamp,index,result[key],animationsActive,forceCopyAnimation)){allFinished=false;}});return allFinished;}else if(typeof animation==='object'&&animation.onFrame){let finished=true;if(!animation.finished){if(animation.callStart){animation.callStart(timestamp);animation.callStart=null;}finished=animation.onFrame(animation,timestamp);animation.timestamp=timestamp;if(finished){animation.finished=true;animation.callback&&animation.callback(true);}}if(forceCopyAnimation){result[key]={...animation.current};}else{result[key]=animation.current;}return finished;}else if(typeof animation==='object'){result[key]={};let allFinished=true;Object.keys(animation).forEach(function(k){if(!runAnimations_Pnpm_useAnimatedStyleTs2(animation[k],timestamp,k,result[key],animationsActive,forceCopyAnimation)){allFinished=false;}});return allFinished;}else{result[key]=animation;return true;}}" }; runAnimations2 = runAnimations; const styleUpdater2 = function styleUpdater(a0, a1, a2, c24659_2) { let r4, r5, r26; let frame2; let c24659_0 = a0; let r22 = arguments[4]; if (r22 === void 0) { r22 = false; } frame2 = void 0; let animations = a2.animations; if (animations == null) { animations = {}; } let last2 = a1(); if (last2 == null) { last2 = {}; } const last = a2.last; if (c1480_5 ? !c1480_5 : last2.boxShadow) { _Module1757.processBoxShadow(last2); } const r45 = {}; const r23 = last2; let r2 = false; let r3 = false; let r46 = void 0; let r47 = false; let r9 = false; let r18 = void 0; for (const key in r23) { r5 = r2; r4 = r3; r26 = r46; r47 = r5; r9 = r4; r18 = r26; const r27 = last2[key]; if (_isAnimated.isAnimated(r27)) { const r53 = global.__frameTimestamp || global._getAnimationTimestamp(); prepareAnimation2(r53, r27, animations[key], last[key]); animations[key] = r27; r46 = r53; r2 = r5; r3 = true; } else { r45[key] = r27; delete animations[key]; r2 = true; r3 = r4; r46 = r26; } } r5 = r2; r4 = r3; r26 = r46; r47 = r5; r9 = r4; r18 = r26; if (r9) { frame2 = (a0) => { let r4; let env29029 = {}; const { animations, last } = a2; env29029[0] = last; if (a2.isAnimationCancelled) { a2.isAnimationRunning = false; } else { const r15 = {}; let r3 = true; let r5 = true; for (const key in animations) { r4 = r3; r5 = r4; let c29030_0 = key; const r23 = runAnimations2(animations[key], a0, key, r15, c24659_2); let r2 = false; if (r23) { const isArray = Array.isArray(r15[key]); const r36 = r15[key]; if (isArray) { r36.forEach((item) => { for (const key in item) { const r10 = env29029[0]; if (!(r10[c29030_0] && typeof r10[c29030_0] === "object")) { r10[c29030_0] = {}; } r10[c29030_0][key] = item[key]; } }); } else { last[key] = r36; } delete animations[key]; r2 = r4; } r3 = r2; } r4 = r3; r5 = r4; _Module1706.updateProps(c24659_0, r15); if (r5) { a2.isAnimationRunning = false; } else { requestAnimationFrame(frame2); } } }; a2.animations = animations; if (!a2.isAnimationRunning) { a2.isAnimationCancelled = false; a2.isAnimationRunning = true; frame2(r18); } if (r47) { _Module1706.updateProps(a0, r45); } } else { a2.isAnimationCancelled = true; a2.animations = []; if (!(_isAnimated.shallowEqual(last, last2) && !arguments[5])) { _Module1706.updateProps(a0, last2, r22); } } a2.last = last2; }; styleUpdater2.__closure = { SHOULD_BE_USE_WEB: shouldBeUseWeb, processBoxShadow: _Module1757.processBoxShadow, isAnimated: _isAnimated.isAnimated, prepareAnimation, runAnimations, updateProps: _Module1706.updateProps, shallowEqual: _isAnimated.shallowEqual }; styleUpdater2.__workletHash = 3108907120254; styleUpdater2.__initData = { code: "function styleUpdater_Pnpm_useAnimatedStyleTs3(viewDescriptors,updater,state,animationsActive,isAnimatedProps=false,forceUpdate){const{SHOULD_BE_USE_WEB,processBoxShadow,isAnimated,prepareAnimation,runAnimations,updateProps,shallowEqual}=this.__closure;var _state$animations,_updater;const animations=(_state$animations=state.animations)!==null&&_state$animations!==void 0?_state$animations:{};const newValues=(_updater=updater())!==null&&_updater!==void 0?_updater:{};const oldValues=state.last;const nonAnimatedNewValues={};let hasAnimations=false;let frameTimestamp;let hasNonAnimatedValues=false;if(!SHOULD_BE_USE_WEB&&newValues.boxShadow){processBoxShadow(newValues);}for(const key in newValues){const value=newValues[key];if(isAnimated(value)){frameTimestamp=global.__frameTimestamp||global._getAnimationTimestamp();prepareAnimation(frameTimestamp,value,animations[key],oldValues[key]);animations[key]=value;hasAnimations=true;}else{hasNonAnimatedValues=true;nonAnimatedNewValues[key]=value;delete animations[key];}}if(hasAnimations){const frame=function(timestamp){const{animations:animations,last:last,isAnimationCancelled:isAnimationCancelled}=state;if(isAnimationCancelled){state.isAnimationRunning=false;return;}const updates={};let allFinished=true;for(const propName in animations){const finished=runAnimations(animations[propName],timestamp,propName,updates,animationsActive);if(finished){if(Array.isArray(updates[propName])){updates[propName].forEach(function(obj){for(const prop in obj){if(!last[propName]||typeof last[propName]!=='object'){last[propName]={};}last[propName][prop]=obj[prop];}});}else{last[propName]=updates[propName];}delete animations[propName];}else{allFinished=false;}}if(updates){updateProps(viewDescriptors,updates);}if(!allFinished){requestAnimationFrame(frame);}else{state.isAnimationRunning=false;}};state.animations=animations;if(!state.isAnimationRunning){state.isAnimationCancelled=false;state.isAnimationRunning=true;frame(frameTimestamp);}if(hasNonAnimatedValues){updateProps(viewDescriptors,nonAnimatedNewValues);}}else{state.isAnimationCancelled=true;state.animations=[];if(!shallowEqual(oldValues,newValues)||forceUpdate){updateProps(viewDescriptors,newValues,isAnimatedProps);}}state.last=newValues;}" }; styleUpdater = styleUpdater2; const jestStyleUpdater2 = function jestStyleUpdater(a0, a1, a2, a3, a4, a5, a6) { let env24660; const r12 = env24660 = { $parent: env1480 }; env24660[0] = a0; env24660[1] = a2; env24660[2] = a3; env24660[3] = a4; env24660[4] = a5; let animations = a2.animations; if (animations == null) { animations = {}; } env24660[6] = animations; let last2 = a1(); if (last2 == null) { last2 = {}; } env24660[7] = last2; const last = a2.last; env24660[8] = last; env24660[9] = false; Object.keys(animations).forEach((item) => { if (!_isAnimated.isAnimated(env24660[7][item])) { delete env24660[6][item]; } }); Object.keys(last2).forEach((item) => { const r4 = env24660[7][item]; if (_isAnimated.isAnimated(r4)) { const r9 = global.__frameTimestamp || global._getAnimationTimestamp(); env24660[5] = r9; const r22 = env24660[6]; prepareAnimation2(r9, r4, r22[item], env24660[8][item]); r22[item] = r4; env24660[9] = true; } }); if (env24660[9]) { a2.animations = animations; if (!a2.isAnimationRunning) { let env24661; a2.isAnimationCancelled = false; a2.isAnimationRunning = true; const frame3 = function frame(a0) { let env29031; const r4 = env29031 = { $parent: env24660 }; env29031[0] = a0; const r16 = env24660[1]; const animations = r16.animations; env29031[1] = animations; env29031[2] = r16.last; if (r16.isAnimationCancelled) { r16.isAnimationRunning = false; } else { const r10 = {}; env29031[3] = r10; env29031[4] = true; Object.keys(animations).forEach($mk113968(r4)); if (Object.keys(r10).length) { _Module1706.updatePropsJestWrapper(env24660[0], r10, env24660[3], env24660[4]); } if (env29031[4]) { r16.isAnimationRunning = false; } else { requestAnimationFrame(env24660[10]); } } }; env24660[10] = frame3; const r39 = env24660[5]; const r40 = env24661 = { $parent: r12 }; env24661[0] = r39; env24661[1] = void 0; env24661[2] = void 0; env24661[3] = void 0; env24661[4] = void 0; const animations2 = a2.animations; env24661[1] = animations2; env24661[2] = a2.last; if (a2.isAnimationCancelled) { a2.isAnimationRunning = false; } else { const r43 = {}; env24661[3] = r43; env24661[4] = true; Object.keys(animations2).forEach($mk113968(r40)); if (Object.keys(r43).length) { _Module1706.updatePropsJestWrapper(a0, r43, a4, a5); } if (env24661[4]) { a2.isAnimationRunning = false; } else { requestAnimationFrame(frame3); } } } } else { a2.isAnimationCancelled = true; a2.animations = []; } a2.last = last2; if (!(_isAnimated.shallowEqual(last, last2) && !a6)) { _Module1706.updatePropsJestWrapper(a0, last2, a4, a5); } }; jestStyleUpdater2.__closure = { isAnimated: _isAnimated.isAnimated, prepareAnimation, runAnimations, updatePropsJestWrapper: _Module1706.updatePropsJestWrapper, shallowEqual: _isAnimated.shallowEqual }; jestStyleUpdater2.__workletHash = 12729247822121; jestStyleUpdater2.__initData = { code: "function jestStyleUpdater_Pnpm_useAnimatedStyleTs4(viewDescriptors,updater,state,animationsActive,animatedValues,adapters,forceUpdate){const{isAnimated,prepareAnimation,runAnimations,updatePropsJestWrapper,shallowEqual}=this.__closure;var _state$animations,_updater;const animations=(_state$animations=state.animations)!==null&&_state$animations!==void 0?_state$animations:{};const newValues=(_updater=updater())!==null&&_updater!==void 0?_updater:{};const oldValues=state.last;let hasAnimations=false;let frameTimestamp;Object.keys(animations).forEach(function(key){const value=newValues[key];if(!isAnimated(value)){delete animations[key];}});Object.keys(newValues).forEach(function(key){const value=newValues[key];if(isAnimated(value)){frameTimestamp=global.__frameTimestamp||global._getAnimationTimestamp();prepareAnimation(frameTimestamp,value,animations[key],oldValues[key]);animations[key]=value;hasAnimations=true;}});function frame(timestamp){const{animations:animations,last:last,isAnimationCancelled:isAnimationCancelled}=state;if(isAnimationCancelled){state.isAnimationRunning=false;return;}const updates={};let allFinished=true;Object.keys(animations).forEach(function(propName){const finished=runAnimations(animations[propName],timestamp,propName,updates,animationsActive);if(finished){last[propName]=updates[propName];delete animations[propName];}else{allFinished=false;}});if(Object.keys(updates).length){updatePropsJestWrapper(viewDescriptors,updates,animatedValues,adapters);}if(!allFinished){requestAnimationFrame(frame);}else{state.isAnimationRunning=false;}}if(hasAnimations){state.animations=animations;if(!state.isAnimationRunning){state.isAnimationCancelled=false;state.isAnimationRunning=true;frame(frameTimestamp);}}else{state.isAnimationCancelled=true;state.animations=[];}state.last=newValues;if(!shallowEqual(oldValues,newValues)||forceUpdate){updatePropsJestWrapper(viewDescriptors,newValues,animatedValues,adapters);}}" }; jestStyleUpdater = jestStyleUpdater2; c1480_11 = { code: "function pnpm_useAnimatedStyleTs5(){const{updater,adaptersArray}=this.__closure;const newValues=updater();adaptersArray.forEach(function(adapter){adapter(newValues);});return newValues;}" }; c1480_12 = { code: "function pnpm_useAnimatedStyleTs6(forceUpdate){const{jestStyleUpdater,shareableViewDescriptors,updater,remoteState,areAnimationsActive,jestAnimatedValues,adaptersArray}=this.__closure;jestStyleUpdater(shareableViewDescriptors,updater,remoteState,areAnimationsActive,jestAnimatedValues,adaptersArray,forceUpdate);}" }; c1480_13 = { code: "function pnpm_useAnimatedStyleTs7(forceUpdate){const{styleUpdater,shareableViewDescriptors,updaterFn,remoteState,areAnimationsActive,isAnimatedProps}=this.__closure;styleUpdater(shareableViewDescriptors,updaterFn,remoteState,areAnimationsActive,isAnimatedProps,forceUpdate);}" }; c1480_14 = { code: "function pnpm_useAnimatedStyleTs8(){const{styleUpdater,shareableViewDescriptors,updaterFn,remoteState,areAnimationsActive,isAnimatedProps}=this.__closure;styleUpdater(shareableViewDescriptors,updaterFn,remoteState,areAnimationsActive,isAnimatedProps);remoteState.isFirstRun=false;}" }; c1480_15 = { code: "function pnpm_useAnimatedStyleTs9(){const{remoteState}=this.__closure;return remoteState.isFirstRun=true;}" }; export function useAnimatedStyle(a0, a1, a2) { let r48; const updater = a0; let r4 = arguments[3]; if (r4 === void 0) { r4 = false; } const isAnimatedProps = r4; const ref = useRef(null); let c13204_3 = ref; const r11 = Object; let __closure = a0.__closure; if (__closure == null) { __closure = {}; } const r22 = r11.values(__closure); let c13204_4 = r22; const r23 = c1480_5 && !r22.length && a1?.length; let r16 = r22; if (r23) { c13204_4 = a1; r16 = a1; } const adaptersArray = a2 ? Array.isArray(a2) ? a2 : [a2] : []; const r32 = a2 ? buildWorkletsHash(adaptersArray) : null; const sharedValue = useSharedValue(true); const jestAnimatedValues = useRef({}); if (a1) { a1.push(a0.__workletHash); r48 = a1; } else { r48 = [...r16, a0.__workletHash]; } if (r32) { r48.push(r32); } if (!ref.current) { const value = initialUpdaterRun(a0); ref.current = { initial: { value, updater: a0 }, remoteState: makeShareable({ last: value, animations: {}, isAnimationCancelled: false, isAnimationRunning: false, isFirstRun: true }), viewDescriptors: makeViewDescriptorsSet(), styleUpdaterContainer: { current: void 0 } }; } const current2 = ref.current; const { initial, remoteState, viewDescriptors } = current2; const shareableViewDescriptors = viewDescriptors.shareableViewDescriptors; r48.push(shareableViewDescriptors); useEffect(() => { let current2; let c24662_1; let updaterFn = updater; let updaterFn2 = updater; if (a2) { const r13 = function() { const r5 = updater(); let c29032_0 = r5; adaptersArray.forEach((item) => { item(c29032_0); }); return r5; }; r13.__closure = { updater, adaptersArray }; r13.__workletHash = 2827602676287; r13.__initData = c1480_11; updaterFn = r13; updaterFn2 = r13; } if (isJest()) { const l = function l(a0) { jestStyleUpdater(shareableViewDescriptors, updater, remoteState, sharedValue, jestAnimatedValues, adaptersArray, a0); }; l.__closure = { jestStyleUpdater, shareableViewDescriptors, updater, remoteState, areAnimationsActive: sharedValue, jestAnimatedValues, adaptersArray }; l.__workletHash = 11745429083106; l.__initData = c1480_12; current2 = l; } else { const r21 = function(a0) { styleUpdater(shareableViewDescriptors, updaterFn, remoteState, sharedValue, isAnimatedProps, a0); }; r21.__closure = { styleUpdater, shareableViewDescriptors, updaterFn: updaterFn2, remoteState, areAnimationsActive: sharedValue, isAnimatedProps }; r21.__workletHash = 6831194621571; r21.__initData = c1480_13; const _IS_FABRIC = globalThis.globalThis._IS_FABRIC; const r31 = _IS_FABRIC ? !_IS_FABRIC : remoteState.isFirstRun; current2 = r21; if (r31) { requestAnimationFrame(() => { const r12 = function t() { styleUpdater(shareableViewDescriptors, updaterFn, remoteState, sharedValue, isAnimatedProps); remoteState.isFirstRun = false; }; r12.__closure = { styleUpdater, shareableViewDescriptors, updaterFn, remoteState, areAnimationsActive: sharedValue, isAnimatedProps }; r12.__workletHash = 11622360674991; r12.__initData = c1480_14; runOnUI(r12)(); }); current2 = r21; } } if (c13204_3.current) { c13204_3.current.styleUpdaterContainer.current = current2; } c24662_1 = startMapper(current2, c13204_4); return () => { stopMapper(c24662_1); if (!globalThis.globalThis._IS_FABRIC) { const r18 = () => { remoteState.isFirstRun = true; return true; }; r18.__closure = { remoteState }; r18.__workletHash = 6168210089002; r18.__initData = c1480_15; runOnUI(r18)(); } }; }, r48); useEffect(() => { sharedValue.value = true; return () => { sharedValue.value = false; }; }, [sharedValue]); checkSharedValueUsage(initial.value); const ref2 = useRef(null); if (!ref2.current) { const styleUpdaterContainer = ref.current.styleUpdaterContainer; ref2.current = isJest() ? { viewDescriptors, initial, jestAnimatedValues, toJSON: animatedStyleHandleToJSON, styleUpdaterContainer } : { viewDescriptors, initial, styleUpdaterContainer }; } return ref2.current; }