{"version":3,"names":["_defineProperty","obj","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","arg","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","TypeError","Number","BaseAnimationBuilder","withSequence","withTiming","FadeIn","FadeOut","EntryExitTransition","constructor","arguments","delayFunction","getDelayFunction","callback","callbackV","delay","getDelay","enteringAnimation","enteringV","build","exitingAnimation","exitingV","exitingDuration","getDuration","values","enteringValues","exitingValues","animations","transform","prop","keys","Array","isArray","forEach","index","transformProp","push","initialValues","duration","sequence","includes","mergedTransform","concat","map","objectKeys","length","console","error","current","originX","currentOriginX","originY","currentOriginY","width","currentWidth","height","currentHeight","targetOriginX","targetOriginY","targetWidth","targetHeight","createInstance","entering","animation","instance","exiting","combineTransition"],"sources":["EntryExitTransition.ts"],"sourcesContent":["'use strict';\nimport type {\n ILayoutAnimationBuilder,\n LayoutAnimationsValues,\n LayoutAnimationFunction,\n StylePropsWithArrayTransform,\n} from '../animationBuilder/commonTypes';\nimport { BaseAnimationBuilder } from '../animationBuilder';\nimport { withSequence, withTiming } from '../../animation';\nimport { FadeIn, FadeOut } from '../defaultAnimations/Fade';\nimport type { AnimatableValue, AnimationObject } from '../../commonTypes';\nimport type { TransformArrayItem } from '../../helperTypes';\n\nexport class EntryExitTransition\n extends BaseAnimationBuilder\n implements ILayoutAnimationBuilder\n{\n enteringV: BaseAnimationBuilder | typeof BaseAnimationBuilder = FadeIn;\n\n exitingV: BaseAnimationBuilder | typeof BaseAnimationBuilder = FadeOut;\n\n static createInstance(\n this: T\n ): InstanceType {\n return new EntryExitTransition() as InstanceType;\n }\n\n static entering(\n animation: BaseAnimationBuilder | typeof BaseAnimationBuilder\n ): EntryExitTransition {\n const instance = this.createInstance();\n return instance.entering(animation);\n }\n\n entering(\n animation: BaseAnimationBuilder | typeof BaseAnimationBuilder\n ): EntryExitTransition {\n this.enteringV = animation;\n return this;\n }\n\n static exiting(\n animation: BaseAnimationBuilder | typeof BaseAnimationBuilder\n ): EntryExitTransition {\n const instance = this.createInstance();\n return instance.exiting(animation);\n }\n\n exiting(\n animation: BaseAnimationBuilder | typeof BaseAnimationBuilder\n ): EntryExitTransition {\n this.exitingV = animation;\n return this;\n }\n\n build = (): LayoutAnimationFunction => {\n const delayFunction = this.getDelayFunction();\n const callback = this.callbackV;\n const delay = this.getDelay();\n // @ts-ignore Calling `.build()` both static and instance methods works fine here, but `this` types are incompatible. They are not used though, so it's fine.\n const enteringAnimation = this.enteringV.build();\n // @ts-ignore Calling `.build()` both static and instance methods works fine here, but `this` types are incompatible. They are not used though, so it's fine.\n const exitingAnimation = this.exitingV.build();\n const exitingDuration = this.exitingV.getDuration();\n\n return (values) => {\n 'worklet';\n const enteringValues = enteringAnimation(values);\n const exitingValues = exitingAnimation(values);\n const animations: StylePropsWithArrayTransform = {\n transform: [],\n };\n\n for (const prop of Object.keys(exitingValues.animations)) {\n if (prop === 'transform') {\n if (!Array.isArray(exitingValues.animations.transform)) {\n continue;\n }\n exitingValues.animations.transform.forEach((value, index) => {\n for (const transformProp of Object.keys(value)) {\n animations.transform!.push({\n [transformProp]: delayFunction(\n delay,\n withSequence(\n value[transformProp as keyof TransformArrayItem],\n withTiming(\n exitingValues.initialValues.transform\n ? // TODO TYPESCRIPT\n // @ts-ignore This line of code fails tragically\n // in newer versions of React Native, where they have\n // narrowed down the type of `transform` even further.\n // Since this piece of code improperly typed anyway\n // (e.g. it assumes types from RN Animated here) I'd rather\n // fix it in the future when types for animations\n // are properly defined.\n exitingValues.initialValues.transform[index][\n transformProp\n ]\n : 0,\n { duration: 0 }\n )\n )\n ),\n } as TransformArrayItem);\n }\n });\n } else {\n const sequence =\n enteringValues.animations[prop] !== undefined\n ? [\n exitingValues.animations[prop],\n withTiming(enteringValues.initialValues[prop], {\n duration: 0,\n }),\n enteringValues.animations[prop],\n ]\n : [\n exitingValues.animations[prop],\n withTiming(\n Object.keys(values).includes(prop)\n ? values[prop as keyof LayoutAnimationsValues]\n : exitingValues.initialValues[prop],\n { duration: 0 }\n ),\n ];\n\n animations[prop] = delayFunction(delay, withSequence(...sequence));\n }\n }\n for (const prop of Object.keys(enteringValues.animations)) {\n if (prop === 'transform') {\n if (!Array.isArray(enteringValues.animations.transform)) {\n continue;\n }\n enteringValues.animations.transform.forEach((value, index) => {\n for (const transformProp of Object.keys(value)) {\n animations.transform!.push({\n [transformProp]: delayFunction(\n delay + exitingDuration,\n withSequence(\n withTiming(\n enteringValues.initialValues.transform\n ? ((\n enteringValues.initialValues\n .transform as TransformArrayItem[]\n )[index][\n transformProp as keyof TransformArrayItem\n ] as AnimatableValue)\n : 0,\n { duration: exitingDuration }\n ),\n value[\n transformProp as keyof TransformArrayItem\n ] as AnimatableValue\n )\n ),\n } as TransformArrayItem);\n }\n });\n } else if (animations[prop] !== undefined) {\n // it was already added in the previous loop\n continue;\n } else {\n animations[prop] = delayFunction(\n delay,\n withSequence(\n withTiming(enteringValues.initialValues[prop], { duration: 0 }),\n enteringValues.animations[prop]\n )\n );\n }\n }\n\n const mergedTransform = (\n Array.isArray(exitingValues.initialValues.transform)\n ? exitingValues.initialValues.transform\n : []\n ).concat(\n (Array.isArray(enteringValues.animations.transform)\n ? enteringValues.animations.transform\n : []\n ).map((value) => {\n const objectKeys = Object.keys(value);\n if (objectKeys?.length < 1) {\n console.error(\n `[Reanimated]: \\${value} is not a valid Transform object`\n );\n return value;\n }\n\n const transformProp = objectKeys[0];\n const current =\n // TODO TYPESCRIPT\n // @ts-ignore Read similar comment above.\n (value[transformProp] as AnimationObject).current;\n if (typeof current === 'string') {\n if (current.includes('deg')) {\n return {\n [transformProp]: '0deg',\n } as unknown as TransformArrayItem;\n } else {\n return {\n [transformProp]: '0',\n } as unknown as TransformArrayItem;\n }\n } else if (transformProp.includes('translate')) {\n return { [transformProp]: 0 } as unknown as TransformArrayItem;\n } else {\n return { [transformProp]: 1 } as unknown as TransformArrayItem;\n }\n })\n );\n\n return {\n initialValues: {\n ...exitingValues.initialValues,\n originX: values.currentOriginX,\n originY: values.currentOriginY,\n width: values.currentWidth,\n height: values.currentHeight,\n transform: mergedTransform,\n },\n animations: {\n originX: delayFunction(\n delay + exitingDuration,\n withTiming(values.targetOriginX, { duration: exitingDuration })\n ),\n originY: delayFunction(\n delay + exitingDuration,\n withTiming(values.targetOriginY, { duration: exitingDuration })\n ),\n width: delayFunction(\n delay + exitingDuration,\n withTiming(values.targetWidth, { duration: exitingDuration })\n ),\n height: delayFunction(\n delay + exitingDuration,\n withTiming(values.targetHeight, { duration: exitingDuration })\n ),\n ...animations,\n },\n callback,\n };\n };\n };\n}\n\n/**\n * Lets you combine two layout animations into a layout transition. You can modify the behavior by chaining methods like `.delay(500)`.\n *\n * @param exiting - Layout animation used when components are removed from layout (eg. `FadeOut`).\n * @param entering - Layout animation used when components are added to layout (eg. `FadeIn`).\n * @returns A custom layout transition. You pass it to the `layout` prop on [an Animated component](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#animated-component).\n * @see https://docs.swmansion.com/react-native-reanimated/docs/layout-animations/layout-transitions#combine-transition\n */\nexport function combineTransition(\n exiting: BaseAnimationBuilder | typeof BaseAnimationBuilder,\n entering: BaseAnimationBuilder | typeof BaseAnimationBuilder\n): EntryExitTransition {\n return EntryExitTransition.entering(entering).exiting(exiting);\n}\n"],"mappings":"AAAA,YAAY;;AAAC,SAAAA,gBAAAC,GAAA,EAAAC,GAAA,EAAAC,KAAA,IAAAD,GAAA,GAAAE,cAAA,CAAAF,GAAA,OAAAA,GAAA,IAAAD,GAAA,IAAAI,MAAA,CAAAC,cAAA,CAAAL,GAAA,EAAAC,GAAA,IAAAC,KAAA,EAAAA,KAAA,EAAAI,UAAA,QAAAC,YAAA,QAAAC,QAAA,oBAAAR,GAAA,CAAAC,GAAA,IAAAC,KAAA,WAAAF,GAAA;AAAA,SAAAG,eAAAM,GAAA,QAAAR,GAAA,GAAAS,YAAA,CAAAD,GAAA,2BAAAR,GAAA,gBAAAA,GAAA,GAAAU,MAAA,CAAAV,GAA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