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

161 lines
4.8 KiB
React

// Metro module 5395 (f5396).
import { useCallback, useMemo, useRef } from "react";
import { useSharedValue } from "./Module1606";
import { INITIAL_CONTAINER_HEIGHT, INITIAL_CONTAINER_OFFSET } from "./Module5249";
import { id } from "./Module5393";
import { MODAL_STACK_BEHAVIOR } from "./Module5246";
import { BottomSheetModalProvider, BottomSheetModalInternalProvider } from "./Module5256";
import { BottomSheetHostingContainer } from "./Module5369";
import { PortalProvider } from "./Module4060";
export default ({ children }) => {
let ref, callback, callback2, callback3, callback4, callback5;
ref = void 0;
callback = void 0;
callback2 = void 0;
callback3 = void 0;
callback4 = void 0;
callback5 = void 0;
const sharedValue = useSharedValue(INITIAL_CONTAINER_HEIGHT);
const sharedValue2 = useSharedValue(INITIAL_CONTAINER_OFFSET);
const memo = useMemo(() => `bottom-sheet-portal-${id()}`, []);
ref = useRef([]);
callback = useCallback((a0, a1, a2) => {
const current4 = ref.current.slice();
const r17 = current4.findIndex((item) => item.key === a0);
const r1 = current4.length - 1;
if (!(r17 !== -1 && r17 === r1)) {
const r21 = current4[current4.length - 1];
if (r21 && !r21.willUnmount) {
if (a2 === MODAL_STACK_BEHAVIOR.replace) {
const ref3 = r21.ref;
if (ref3 != null) {
const current2 = ref3.current;
if (current2 != null) {
current2.dismiss();
}
}
} else if (a2 === MODAL_STACK_BEHAVIOR.switch) {
const ref2 = r21.ref;
if (ref2 != null) {
const current = ref2.current;
if (current != null) {
current.minimize();
}
}
}
}
if (r17 !== -1) {
current4.splice(r17, 1);
if (a1 != null) {
const current3 = a1.current;
if (current3 != null) {
current3.restore();
}
}
}
current4.push({
key: a0,
ref: a1,
willUnmount: false
});
ref.current = current4;
}
}, []);
callback2 = useCallback((c25449_0) => {
const current2 = ref.current.slice();
const r7 = current2.findIndex((item) => item.key === c25449_0);
let r14 = r7 === current2.length - 1;
current2.splice(r7, 1);
ref.current = current2;
const r2 = ref.current.length > 0;
const r24 = ref.current[ref.current.length - 1];
if (r14) {
r14 = r2;
}
if (r14) {
r14 = r24;
}
if (r14) {
r14 = !r24.willUnmount;
}
if (r14) {
const ref2 = ref.current[ref.current.length - 1].ref;
if (ref2 != null) {
const current = ref2.current;
if (current != null) {
current.restore();
}
}
}
}, []);
callback3 = useCallback((c25450_0) => {
const current2 = ref.current.slice();
const r14 = current2.findIndex((item) => item.key === c25450_0);
const r1 = current2.length - 1;
if (r14 !== -1) {
current2[r14].willUnmount = true;
}
let r17 = r14 === r1;
const r4 = current2.length > 1;
if (r17) {
r17 = r4;
}
if (r17) {
const ref2 = current2[current2.length - 2].ref;
if (ref2 != null) {
const current = ref2.current;
if (current != null) {
current.restore();
}
}
}
ref.current = current2;
}, []);
callback4 = useCallback((a0) => {
const current = ref.current;
const r13 = a0 ? current.find((item) => item.key === a0) : current[ref.current.length - 1];
let r16 = !!r13;
if (r16) {
const ref2 = r13.ref;
const r4 = ref2 == null;
r16 = true;
if (!r4) {
const current2 = ref2.current;
const r19 = current2 == null;
r16 = true;
if (!r19) {
current2.dismiss();
r16 = true;
}
}
}
return r16;
}, []);
callback5 = useCallback(() => {
ref.current.map(({ ref: ref2 }) => {
if (ref2 != null) {
const current = ref2.current;
if (current != null) {
current.dismiss();
}
}
});
}, []);
return <BottomSheetModalProvider value={useMemo(() => ({
dismiss: callback4,
dismissAll: callback5
}), [callback4, callback5])}>
<BottomSheetModalInternalProvider value={useMemo(() => ({
hostName: memo,
containerHeight: sharedValue,
containerOffset: sharedValue2,
mountSheet: callback,
unmountSheet: callback2,
willUnmountSheet: callback3
}), [memo, sharedValue, sharedValue2, callback, callback2, callback3])}>
<BottomSheetHostingContainer containerOffset={sharedValue2} containerHeight={sharedValue} />
<PortalProvider rootHostName={memo}>{children}</PortalProvider>
</BottomSheetModalInternalProvider>
</BottomSheetModalProvider>;
};