Files
discord-decomp/_bundle/getInterpolationIndex.jsx
T
2026-11-01 12:12:55 +02:00

492 lines
18 KiB
React

// Metro module 5608 (f5609).
import _classCallCheck from "./_classCallCheck";
import _createClass from "./_createClass";
import _possibleConstructorReturn from "./_possibleConstructorReturn";
import _getPrototypeOf from "./_getPrototypeOf";
import _inherits from "./_inherits";
import { Component, Fragment } from "react";
import { Platform, StyleSheet, Animated } from "react-native";
import { getIsModalPresentation } from "./Card";
import { SafeAreaProviderCompat, Background } from "./Module5579";
import { ModalTransition, DefaultTransition, ModalFadeTransition } from "./Module5624";
import getDistanceForDirection from "./getDistanceForDirection";
import findLastIndex from "./findLastIndex_5626";
import * as _Module5622 from "./Module5622";
import { forNoAnimation } from "./Module5622";
import { MaybeScreenContainer, MaybeScreen } from "./Module5627";
import Color from "./Color";
import Module5628 from "./Module5628";
function $mk76526($env) {
return (a0, a1, a2) => {
const r10 = $env;
const options = a1.descriptor.options;
let headerStatusBarHeight = options.headerStatusBarHeight;
if (headerStatusBarHeight === void 0) {
headerStatusBarHeight = r10[2] ? 0 : r10[1].top;
}
let headerStyle = options.headerStyle;
const r24 = $env.$parent;
const r25 = r24[8];
if (!headerStyle) {
headerStyle = {};
}
const r27 = r25.flatten(headerStyle);
let r33 = "height" in r27 && typeof r27.height === "number" ? r27.height : r10[5][a1.route.key];
const r34 = r24[13];
const r35 = r10[0];
const cardStyleInterpolator = r35[a2].descriptor.options.cardStyleInterpolator;
let r0 = a2 - 1;
let r1 = 0;
let r3 = 0;
while (0 <= r0) {
const r18 = r35[r0];
const r9 = r18 == null;
const r5 = r0;
const r2 = r1;
const r42 = r9 ? void 0 : r18.descriptor.options.cardStyleInterpolator;
r3 = r2;
if (r42 !== cardStyleInterpolator) {
break;
}
r1 = r2 + 1;
r0 = r5 - 1;
r3 = r1;
}
const r45 = r24[14];
const r46 = r10[3];
let r49 = true;
if (!r46) {
const cardStyleInterpolator2 = a1.descriptor.options.cardStyleInterpolator;
r49 = (0, r24[0])(r24[2][8]).getIsModalPresentation(cardStyleInterpolator2) && r3 !== 0;
}
const key = a1.route.key;
if (typeof r33 !== "number") {
r33 = (0, r24[0])(r24[2][9]).getDefaultHeaderHeight(r10[4], r49, headerStatusBarHeight);
}
a0[key] = r33;
return a0;
};
}
let c3452_12, getInterpolationIndex, getIsModal, getHeaderHeights, getDistanceFromOptions, getProgressFromGesture, styles;
let CardStack;
let env3452 = {};
env3452[11] = function _isNativeReflectConstruct() {
let c14942_0;
try {
c14942_0 = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
} catch ($e) {}
const _isNativeReflectConstruct2 = function _isNativeReflectConstruct() {
return !!c14942_0;
};
env3452[11] = _isNativeReflectConstruct2;
return _isNativeReflectConstruct2();
};
Platform;
const StyleSheet2 = StyleSheet;
c3452_12 = Object.freeze({
options: {}
});
getInterpolationIndex = (a0, a1) => {};
getIsModal = (a0, a1, a2) => {};
getHeaderHeights = (a0, a1, a2, a3, a4, a5) => {};
getDistanceFromOptions = (a0, a1) => {};
getProgressFromGesture = (a0, a1, a2) => {
const r5 = {
width: Math.max(1, a1.width),
height: Math.max(1, a1.height)
};
const r21 = a2?.options || {};
const { presentation, gestureDirection = presentation === "modal" ? ModalTransition.gestureDirection : DefaultTransition.gestureDirection } = r21;
const distanceForDirection = getDistanceForDirection(r5, gestureDirection);
return distanceForDirection > 0 ? a0.interpolate({
inputRange: [0, distanceForDirection],
outputRange: [1, 0]
}) : a0.interpolate({
inputRange: [distanceForDirection, 0],
outputRange: [0, 1]
});
};
CardStack = function CardStack(a0) {
_classCallCheck(this, CardStack);
const r9 = [a0];
const r8 = _getPrototypeOf(CardStack);
const r22 = _possibleConstructorReturn(this, (0, env3452[11])() ? Reflect.construct(r8, r9, _getPrototypeOf(this).constructor) : r8.apply(this, r9));
r22.handleLayout = (a0) => {
const layout3 = a0.nativeEvent.layout;
const { height, width } = layout3;
const layout2 = {
width,
height
};
this.setState((state, props) => {
let r15;
L5: {
if (height === state.layout.height) {
const width2 = state.layout.width;
r15 = null;
if (width === width2) {
break L5;
}
}
const r18 = env3452;
const scenes2 = state.scenes;
const { insets: insets2, isParentHeaderShown: isParentHeaderShown2, isParentModal: isParentModal2 } = props;
const headerHeights2 = state.headerHeights;
let env31376;
const r22 = env31376 = {
$parent: r18
};
env31376[0] = scenes2;
env31376[1] = insets2;
env31376[2] = isParentHeaderShown2;
env31376[3] = isParentModal2;
env31376[4] = layout2;
env31376[5] = headerHeights2;
r15 = {
layout: layout2,
headerHeights: scenes2.reduce($mk76526(r22), {})
};
}
return r15;
});
};
r22.handleHeaderLayout = ({ route, height: height2 }) => {
this.setState(({ headerHeights: headerHeights2 }) => {
const r9 = headerHeights2[route.key];
let r10 = null;
if (r9 !== height2) {
const headerHeights3 = {
...headerHeights2
};
headerHeights3[route.key] = height2;
r10 = {
headerHeights: headerHeights3
};
}
return r10;
});
};
r22.getFocusedRoute = () => {
const state = this.props.state;
return state.routes[state.index];
};
r22.getPreviousScene = ({ route: route2 }) => {
const getPreviousRoute = this.props.getPreviousRoute;
const scenes2 = this.state.scenes;
const previousRoute = getPreviousRoute({
route: route2
});
if (previousRoute) {
return scenes2.find((item) => item.descriptor.route.key === previousRoute.key);
}
};
r22.state = {
routes: [],
scenes: [],
gestures: {},
layout: SafeAreaProviderCompat.initialMetrics.frame,
descriptors: r22.props.descriptors,
headerHeights: {}
};
return r22;
};
_inherits(CardStack, Component);
const r55 = _createClass(CardStack, [{
key: "render",
value: function render() {
let r1;
let c25506_0, c25506_20;
const props = this.props;
const { insets, state, routes, closingRouteKeys, onOpenRoute, onCloseRoute, renderHeader, renderScene, isParentHeaderShown, isParentModal, onTransitionStart, onTransitionEnd, onGestureStart, onGestureEnd, onGestureCancel, detachInactiveScreens = true } = props;
const state2 = this.state;
const { scenes, layout, gestures, headerHeights } = state2;
const r47 = state.routes[state.index];
let c25506_19 = r47;
const height3 = headerHeights[r47.key];
const r55 = this.state.scenes.slice(-2).some((item) => {
let options = item.descriptor.options;
if (options == null) {
options = {};
}
const { headerMode, headerTransparent, headerShown } = options;
return !((headerTransparent ? !headerTransparent : (headerShown === void 0 || headerShown) !== false) && headerMode !== "screen");
});
c25506_20 = r55;
c25506_0 = 1;
let r0 = scenes.length - 1;
let r58 = 1;
while (0 <= r0) {
const options = scenes[r0].descriptor.options;
let detachPreviousScreen = options.detachPreviousScreen;
const r4 = r0;
const r3 = r58;
if (detachPreviousScreen === void 0) {
let r10 = options.presentation !== "transparentModal";
if (r10) {
const isModalPresentation = getIsModalPresentation(options.cardStyleInterpolator);
r10 = isModalPresentation ? r4 !== findLastIndex(scenes, (a0) => {
const cardStyleInterpolator = a0.descriptor.options.cardStyleInterpolator;
return cardStyleInterpolator === _Module5622.forModalPresentationIOS || cardStyleInterpolator?.name === "forModalPresentationIOS";
}) : !isModalPresentation;
}
detachPreviousScreen = r10;
}
if (detachPreviousScreen === false) {
const r73 = r3 + 1;
c25506_0 = r73;
r1 = r73;
} else {
const r7 = scenes.length - 2;
r1 = r3;
if (r4 <= r7) {
break;
}
}
r0 = r4 - 1;
r58 = r1;
}
const r91 = <Fragment key="header">
{renderHeader({
mode: "float",
layout,
scenes,
getPreviousScene: this.getPreviousScene,
getFocusedRoute: this.getFocusedRoute,
onContentHeightChange: this.handleHeaderLayout,
style: [styles.floating, r55 && [{
height: height3
}, styles.absolute]]
})}
</Fragment>;
return <Background>
{r55 ? null : r91}
<MaybeScreenContainer enabled={detachInactiveScreens} style={styles.container} onLayout={this.handleLayout}>
{routes.map((route, a1, a2) => {
const key = c25506_19.key;
const key2 = route.key;
const gesture = gestures[route.key];
const scene = scenes[a1];
const length = a2.length;
const r10 = a1 < length - c25506_0 - 1;
let active = 0;
if (!r10) {
const r42 = scenes[a2.length - 1];
const r44 = a1 !== a2.length - 1 ? a1 >= a2.length - c25506_0 ? 1 : 0 : 2;
active = r42 ? r42.progress.current.interpolate({
inputRange: [0, 0.99999, 1],
outputRange: [1, 1, r44],
extrapolate: "clamp"
}) : 1;
}
const options = scene.descriptor.options;
const { headerShown = true, headerTransparent, headerStyle, headerTintColor, freezeOnBlur } = options;
const { top, right, bottom, left } = insets;
const headerHeight = headerShown !== false ? headerHeights[route.key] : 0;
let headerDarkContent = void 0;
if (headerShown) {
if (typeof headerTintColor === "string") {
headerDarkContent = Color(headerTintColor).isDark();
} else {
const r67 = StyleSheet.flatten(headerStyle);
headerDarkContent = r67 && "backgroundColor" in r67 && typeof r67.backgroundColor === "string" ? !Color(r67.backgroundColor).isDark() : void 0;
}
}
const cardStyleInterpolator = scenes[a1].descriptor.options.cardStyleInterpolator;
let r1 = a1 - 1;
let r93 = 0;
let interpolationIndex = 0;
while (0 <= r1) {
const r95 = scenes[r1];
const r9 = r95 == null;
const r5 = r1;
const r4 = r93;
const r96 = r9 ? void 0 : r95.descriptor.options.cardStyleInterpolator;
interpolationIndex = r4;
if (r96 !== cardStyleInterpolator) {
break;
}
r93 = r4 + 1;
r1 = r5 - 1;
interpolationIndex = r93;
}
const modal = isParentModal ? true : getIsModalPresentation(scene.descriptor.options.cardStyleInterpolator) && interpolationIndex !== 0;
const r114 = scenes[a1 + 1];
const r116 = r114 == null ? void 0 : r114.descriptor.options.presentation;
const r120 = scenes[a1 + 1];
const r122 = r120 == null ? void 0 : r120.descriptor.options.detachPreviousScreen;
const props = {
index: a1,
interpolationIndex,
modal,
active: a1 === a2.length - 1,
focused: key === key2,
closing: closingRouteKeys.includes(route.key),
layout,
gesture,
scene,
safeAreaInsetTop: top,
safeAreaInsetRight: right,
safeAreaInsetBottom: bottom,
safeAreaInsetLeft: left,
onGestureStart,
onGestureCancel,
onGestureEnd,
headerHeight,
isParentHeaderShown,
onHeaderHeightChange: null,
getPreviousScene: null,
getFocusedRoute: null,
headerDarkContent: null,
hasAbsoluteFloatHeader: null,
renderHeader: null,
renderScene: null,
onOpenRoute: null,
onCloseRoute: null,
onTransitionStart: null,
onTransitionEnd: null,
isNextScreenTransparent: null,
detachCurrentScreen: null
};
props.onHeaderHeightChange = this.handleHeaderLayout;
props.getPreviousScene = this.getPreviousScene;
props.getFocusedRoute = this.getFocusedRoute;
props.headerDarkContent = headerDarkContent;
const hasAbsoluteFloatHeader = c25506_20 && !headerTransparent;
const isNextScreenTransparent = r116 === "transparentModal";
const detachCurrentScreen = r122 !== false;
props.hasAbsoluteFloatHeader = hasAbsoluteFloatHeader;
props.renderHeader = renderHeader;
props.renderScene = renderScene;
props.onOpenRoute = onOpenRoute;
props.onCloseRoute = onCloseRoute;
props.onTransitionStart = onTransitionStart;
props.onTransitionEnd = onTransitionEnd;
props.isNextScreenTransparent = isNextScreenTransparent;
props.detachCurrentScreen = detachCurrentScreen;
return <MaybeScreen key={route.key} style={StyleSheet.absoluteFill} enabled={detachInactiveScreens} active={active} freezeOnBlur={freezeOnBlur} pointerEvents="box-none">
<Module5628 {...props} />
</MaybeScreen>;
})}
</MaybeScreenContainer>
{r55 ? r91 : null}
</Background>;
}
}], [{
key: "getDerivedStateFromProps",
value: function getDerivedStateFromProps(a0, a1) {
let c25507_2;
let c25507_0 = a0;
let c25507_1 = a1;
if (a0.routes === a1.routes && a0.descriptors === a1.descriptors) {
return null;
}
const gestures2 = a0.routes.reduce((acc, route) => {
const r11 = c25507_0.descriptors[route.key];
const animationEnabled = (r11?.options || {}).animationEnabled;
const key = route.key;
let r21 = c25507_1.gestures[route.key];
if (!r21) {
const Value = Animated.Value;
const r26 = c25507_0.openingRouteKeys.includes(route.key);
let r27 = 0;
if (r26) {
r27 = 0;
if (animationEnabled !== false) {
const layout3 = c25507_1.layout;
const r33 = r11?.options || {};
const { presentation, gestureDirection = presentation === "modal" ? ModalTransition.gestureDirection : DefaultTransition.gestureDirection } = r33;
r27 = getDistanceForDirection(layout3, gestureDirection);
}
}
r21 = new Value(r27);
}
acc[key] = r21;
return acc;
}, {});
c25507_2 = gestures2;
const scenes2 = a0.routes.map((a0, a1, a2) => {
const r20 = a2[a1 - 1];
const r21 = a2[a1 + 1];
const r32 = c25507_1.scenes[a1];
let c29532_0 = r32;
const r12 = c25507_2[a0.key];
const r33 = r20 ? c25507_2[r20.key] : void 0;
const r34 = r21 ? c25507_2[r21.key] : void 0;
const r38 = c25507_0.descriptors[a0.key] || c25507_1.descriptors[a0.key] || (r32 ? r32.descriptor : c3452_12);
const r44 = c25507_0.descriptors[r21?.key] || c25507_1.descriptors[r21?.key];
const r50 = c25507_0.descriptors[r20?.key] || c25507_1.descriptors[r20?.key];
const r59 = a1 !== a2.length - 1 && (r44 && r44.options.presentation !== "transparentModal") ? r44.options : r38.options;
const r69 = r59.presentation === "modal" ? ModalTransition : r59.presentation === "transparentModal" ? ModalFadeTransition : DefaultTransition;
const { animationEnabled: animationEnabled2 = true, gestureEnabled: gestureEnabled2 = false, gestureDirection = r69.gestureDirection, transitionSpec = r69.transitionSpec, cardStyleInterpolator = animationEnabled2 === false ? forNoAnimation : r69.cardStyleInterpolator, headerStyleInterpolator = r69.headerStyleInterpolator, cardOverlayEnabled = r59.presentation !== "transparentModal" || getIsModalPresentation(cardStyleInterpolator) } = r59;
let headerMode = r38.options.headerMode;
if (headerMode == null) {
const r102 = r59.presentation !== "modal" && r59.presentation !== "transparentModal" && (r44 == null ? void 0 : r44.options.presentation) !== "modal" && (r44 == null ? void 0 : r44.options.presentation) !== "transparentModal";
headerMode = "screen";
if (r102) {
getIsModalPresentation(cardStyleInterpolator);
headerMode = "screen";
}
}
const descriptor = {
...r38,
options: {
...r38.options,
animationEnabled: animationEnabled2,
cardOverlayEnabled,
cardStyleInterpolator,
gestureDirection,
gestureEnabled: gestureEnabled2,
headerStyleInterpolator,
transitionSpec,
headerMode
}
};
const r125 = {
route: a0,
descriptor,
progress: {
current: getProgressFromGesture(r12, c25507_1.layout, r38),
next: r34 ? (r44 == null ? void 0 : r44.options.presentation) !== "transparentModal" ? getProgressFromGesture(r34, c25507_1.layout, r44) : void 0 : void 0,
previous: r33 ? getProgressFromGesture(r33, c25507_1.layout, r50) : void 0
},
__memo: [c25507_1.layout, r38, r44, r50, r12, r34, r33]
};
return r32 ? r125.__memo.every((item, index) => c29532_0.__memo[index] === item) ? r32 : r125 : r125;
});
const { insets: insets2, isParentHeaderShown: isParentHeaderShown2, isParentModal: isParentModal2 } = a0;
const { layout: layout3, headerHeights: headerHeights2 } = a1;
let env25508;
const r30 = env25508 = {
$parent: env3452
};
env25508[0] = scenes2;
env25508[1] = insets2;
env25508[2] = isParentHeaderShown2;
env25508[3] = isParentModal2;
env25508[4] = layout3;
env25508[5] = headerHeights2;
return {
routes: a0.routes,
scenes: scenes2,
gestures: gestures2,
descriptors: a0.descriptors,
headerHeights: scenes2.reduce($mk76526(r30), {})
};
}
}]);
styles = StyleSheet2.create({
container: {
flex: 1
},
absolute: {
position: "absolute",
top: 0,
left: 0,
right: 0
},
floating: {
zIndex: 1
}
});
export default r55;