// Metro module 8365 (f8366). import * as Module19 from "react"; import { useRef, useMemo, useState, useCallback, useEffect } from "react"; import { StyleSheet, View } from "react-native"; import ChannelStore from "../../../stores/ChannelStore"; import GuildMemberStore from "../../../stores/GuildMemberStore"; import UserStore from "../../../stores/UserStore"; import UserProfileSettingsStore from "../UserProfileSettingsStore"; import { UserProfileThemeTypes } from "./Constants"; import { AnalyticEvents, EMPTY_STRING_SNOWFLAKE_ID, UserSettingsSections } from "../../../Constants"; import { ACTION_SHEET_MAX_WIDTH } from "../../action_sheet/native/ActionSheetConstants"; import { createStyles } from "../../../design/components/Styles/native/createStyles"; import * as _Module5245 from "../../../_bundle/Module5245"; import { useBottomSheet, useScrollEventsHandlersDefault, useBottomSheetInternal, BottomSheetScrollView } from "../../../_bundle/Module5245"; import * as _ReanimatedRexport from "../../reanimated/ReanimatedRexport"; import ReanimatedRexport, { useAnimatedReaction, useAnimatedStyle, useSharedValue, useWorkletCallback } from "../../reanimated/ReanimatedRexport"; import useSafeAreaInsets_native from "../../safe_area/useSafeAreaInsets.native"; import { useStateFromStores, useStateFromStoresObject } from "../../../_bundle/Module589"; import useDisplayProfile from "../hooks/useDisplayProfile"; import useAnalyticsLocations, { AnalyticsLocationProvider } from "../../app_analytics/useAnalyticsLocations"; import AnalyticsLocation from "../../app_analytics/AnalyticsLocation"; import { useBottomSheetRef } from "../../../design/components/Sheet/native/useBottomSheetRef"; import { ProfileVisibility } from "../../user_settings/UserSettings"; import { useCreateUserProfileAnalyticsContext, UserProfileAnalyticsProvider } from "../UserProfileAnalyticsContext"; import { useIsScreenLandscape } from "../../screen/useIsScreenLandscape.native"; import useMaybeFetchProfileFrame from "../../collectibles/profile_frames/hooks/useMaybeFetchProfileFrame"; import useMaybeTrackProfileFrameViewed from "../../collectibles/profile_frames/hooks/useMaybeTrackProfileFrameViewed"; import ProfileFrame from "../../collectibles/profile_frames/native/ProfileFrame"; import { ProfileFrameLayerOrder } from "../../../_bundle/Module8088"; import useProfileEffect from "../../collectibles/profile_effects/useProfileEffect"; import useProfileTheme from "../hooks/useProfileTheme"; import useUserProfileBannerHeight from "../hooks/native/useUserProfileBannerHeight"; import useWindowDimensions_native from "../../screen/useWindowDimensions.native"; import { NAV_BAR_HEIGHT_MULTILINE } from "../../../design/components/Navigator/native/NavigatorConstants.native"; import scaleProfileFrame from "../../collectibles/profile_frames/scaleProfileFrame"; import useTheme from "../../../hooks/useTheme"; import { useToken } from "../../../design/tokens/native/useToken"; import Module712 from "../../../_bundle/Module712"; import useUserProfileAnalyticsProperties from "../hooks/native/useUserProfileAnalyticsProperties"; import { shouldDisableUserPresenceInChannel } from "../../applications/ApplicationPresenceUtils"; import { getUser } from "../../../actions/UserActionCreators"; import isChangelogUser from "../../changelog/utils/isChangelogUser"; import maybeFetchUserProfile from "../maybeFetchUserProfile"; import AnalyticsUtils from "../../../utils/AnalyticsUtils"; import { getRootNavigationRef } from "../../main_tabs_v2/RootNavigationRef.native"; import ActionSheetActionCreators from "../../action_sheet/native/ActionSheetActionCreators"; import showUserProfileActionSheet, { getUserProfileActionSheetKey } from "./showUserProfileActionSheet"; import { useNavigation } from "../../../design/components/Navigator/native/useNavigation.native"; import { BottomSheet } from "../../../design/components/Sheet/native/BottomSheet.native"; import { EmptyState } from "../../../design/void/native"; import { NoResults } from "../../../design/components/Illustration/native/redesign/generated/NoResults"; import { intl, t } from "../../../intl/index.native"; import { ThemeContextProvider } from "../../../_bundle/Module3901"; import UserProfileFixedBackground from "./UserProfileFixedBackground"; import { isIOS } from "../../../utils/PlatformUtils"; import { openUserSettings } from "../../user_settings/core/native/openUserSettings"; import NonUserBotProfileContent from "./NonUserBotProfileContent"; import BotUserProfileContent from "./BotUserProfileContent"; import UserProfileContent from "./UserProfileContent"; import ProfileEffect from "../../collectibles/profile_effects/native/ProfileEffect"; import { ActionSheetHeaderBar } from "../../../design/components/Sheet/native/ActionSheetHeaderBar.native"; import { ActionSheetBackdropToast } from "./ActionSheetBackdropToast"; import * as _Module1306 from "../../../_bundle/Module1306"; let useStyles, __initData, __initData2, __initData3, ActionSheetAlignedView, __initData4, __initData5; const UseAnimatedPosition = function UseAnimatedPosition({ animatedPosition }) { const animatedPosition2 = useBottomSheet().animatedPosition; const n = () => animatedPosition2.get(); n.__closure = { value: animatedPosition2 }; n.__workletHash = 5684011437075; n.__initData = __initData; const r19 = (a0) => animatedPosition.set(a0); r19.__closure = { animatedPosition }; r19.__workletHash = 15360670503044; r19.__initData = __initData2; useAnimatedReaction(n, r19); return null; }; ActionSheetAlignedView = function ActionSheetAlignedView(props) { const { animatedPosition: animatedPosition3, animatedIndex, safeAreaTop, children } = props; const c = () => ({ transform: [{ translateY: animatedPosition3.get() + safeAreaTop }], opacity: _ReanimatedRexport.interpolate(animatedIndex.get(), [-1, 0], [0, 1], _ReanimatedRexport.Extrapolation.CLAMP) }); c.__closure = { animatedPosition: animatedPosition3, safeAreaTop, interpolate: _ReanimatedRexport.interpolate, animatedIndex, Extrapolation: _ReanimatedRexport.Extrapolation }; c.__workletHash = 16546700050596; c.__initData = __initData3; return {children}; }; useStyles = createStyles({ container: { flex: 1 }, profileContainer: { position: "relative" }, noPadding: { paddingHorizontal: 0 }, profileEffect: { position: "absolute", top: 0, left: 0, right: 0, zIndex: 1 } }); __initData = { code: "function UserProfileActionSheetTsx1(){const{value}=this.__closure;return value.get();}" }; __initData2 = { code: "function UserProfileActionSheetTsx2(prepared){const{animatedPosition}=this.__closure;return animatedPosition.set(prepared);}" }; __initData3 = { code: "function UserProfileActionSheetTsx3(){const{animatedPosition,safeAreaTop,interpolate,animatedIndex,Extrapolation}=this.__closure;return{transform:[{translateY:animatedPosition.get()+safeAreaTop}],opacity:interpolate(animatedIndex.get(),[-1,0],[0,1],Extrapolation.CLAMP)};}" }; __initData4 = { code: "function UserProfileActionSheetTsx4(payload,context){const{defaultHandleOnScroll,scrollPosition,animatedScrollableState,SCROLLABLE_STATE}=this.__closure;var _defaultHandleOnScrol;(_defaultHandleOnScrol=defaultHandleOnScroll)===null||_defaultHandleOnScrol===void 0||_defaultHandleOnScrol(payload,context);scrollPosition.set(animatedScrollableState.get()===SCROLLABLE_STATE.LOCKED?0:payload.contentOffset.y);}" }; __initData5 = { code: "function UserProfileActionSheetTsx5(){const{scrollPosition}=this.__closure;const transform=scrollPosition.get()<=0?[{translateY:scrollPosition.get()}]:[];return{transform:transform};}" }; const r62 = Module19.memo(function UserProfileActionSheet(props) { let r410; let sharedValue, sharedValue2, top, stateFromStores, guild_id, stateFromStores2, c16538_11, analyticsLocations, sharedValue3, state, setState, state2, setState2, pendingAvatarDecoration, pendingProfileEffect, pendingProfileFrame, createUserProfileAnalyticsContext, frame, width, c16538_24, navigation; const { userId, channelId, messageId, roleId, sessionId, disableCalls, disableMessage, isVoiceContext, onClose, location: location2, openedAt } = props; let isPreviewingChanges = props.isPreviewingChanges; if (isPreviewingChanges === void 0) { isPreviewingChanges = false; } let c16538_3 = isPreviewingChanges; const { showGuildProfile = true, sourceAnalyticsLocations = [] } = props; const location_stack = sourceAnalyticsLocations; const initialSection = props.initialSection; sharedValue = void 0; sharedValue2 = void 0; top = void 0; stateFromStores = void 0; guild_id = void 0; stateFromStores2 = void 0; c16538_11 = void 0; analyticsLocations = void 0; sharedValue3 = void 0; state = void 0; setState = void 0; state2 = void 0; setState2 = void 0; pendingAvatarDecoration = void 0; pendingProfileEffect = void 0; pendingProfileFrame = void 0; createUserProfileAnalyticsContext = void 0; frame = void 0; width = void 0; c16538_24 = void 0; navigation = void 0; const handleUserSettingsClose2 = function handleUserSettingsClose() { navigation.goBack(); showUserProfileActionSheet({ sourceAnalyticsLocations: analyticsLocations, ...createUserProfileAnalyticsContext }); }; const styles = useStyles(); sharedValue = useSharedValue(0); sharedValue2 = useSharedValue(-1); top = useSafeAreaInsets_native().top; stateFromStores = useStateFromStores([UserStore], () => UserStore.getUser(userId)); const stateFromStores3 = useStateFromStores([ChannelStore], () => ChannelStore.getChannel(channelId), [channelId]); guild_id = stateFromStores3?.guild_id; stateFromStores2 = useStateFromStores([GuildMemberStore], () => guild_id != null ? GuildMemberStore.getMember(guild_id, userId) : null); let r94 = stateFromStores?.id; if (r94 == null) { r94 = EMPTY_STRING_SNOWFLAKE_ID; } const displayProfile = useDisplayProfile(r94, showGuildProfile ? guild_id : void 0); c16538_11 = displayProfile; analyticsLocations = useAnalyticsLocations([...location_stack, AnalyticsLocation.USER_PROFILE_ACTION_SHEET]).analyticsLocations; const bottomSheetRef2 = useBottomSheetRef(); const { bottomSheetRef, bottomSheetClose } = bottomSheetRef2; const ref = useRef(null); sharedValue3 = useSharedValue(0); const memo = useMemo(() => { const sharedValue4 = sharedValue3; return (a0, a1, a2) => { const scrollEventsHandlersDefault = useScrollEventsHandlersDefault(a0, a1, a2); const animatedScrollableState = useBottomSheetInternal().animatedScrollableState; const handleOnScroll = scrollEventsHandlersDefault.handleOnScroll; const r27 = function(a0, a1) { if (handleOnScroll != null) { handleOnScroll(a0, a1); } sharedValue4.set(animatedScrollableState.get() !== _Module5245.SCROLLABLE_STATE.LOCKED ? a0.contentOffset.y : 0); }; r27.__closure = { defaultHandleOnScroll: handleOnScroll, scrollPosition: sharedValue4, animatedScrollableState, SCROLLABLE_STATE: _Module5245.SCROLLABLE_STATE }; r27.__workletHash = 13254130622789; r27.__initData = __initData4; return { ...scrollEventsHandlersDefault, handleOnScroll: useWorkletCallback(r27, [handleOnScroll, animatedScrollableState]) }; }; }, [sharedValue3]); const V = function V() { return { transform: sharedValue3.get() <= 0 ? [{ translateY: sharedValue3.get() }] : [] }; }; V.__closure = { scrollPosition: sharedValue3 }; V.__workletHash = 6237718973214; V.__initData = __initData5; const animatedStyle = useAnimatedStyle(V); [state, setState] = useState(false); [state2, setState2] = useState(0); const callback = useCallback((a0) => { setState2(Math.floor(a0.nativeEvent.layout.width)); }, []); const setting = ProfileVisibility.useSetting(); const stateFromStoresObject = useStateFromStoresObject([UserProfileSettingsStore], () => UserProfileSettingsStore.getPendingChanges()); const pendingThemeColors = stateFromStoresObject.pendingThemeColors; pendingAvatarDecoration = stateFromStoresObject.pendingAvatarDecoration; pendingProfileEffect = stateFromStoresObject.pendingProfileEffect; pendingProfileFrame = stateFromStoresObject.pendingProfileFrame; createUserProfileAnalyticsContext = useCreateUserProfileAnalyticsContext({ layout: "ACTION_SHEET", sourceSessionId: sessionId, userId, guildId: guild_id, channelId, messageId, roleId, showGuildProfile }); const r155 = isPreviewingChanges && pendingProfileFrame !== void 0 ? pendingProfileFrame?.skuId : displayProfile == null ? void 0 : displayProfile.profileFrame?.skuId; const isScreenLandscape = useIsScreenLandscape(); frame = useMaybeFetchProfileFrame(isScreenLandscape ? void 0 : r155, "UserProfileActionSheet"); useMaybeTrackProfileFrameViewed({ skuId: isScreenLandscape ? void 0 : r155, openedAt, context: createUserProfileAnalyticsContext, analyticsLocations }); const memo2 = useMemo(() => frame != null ? : null, [frame, sharedValue, top, sharedValue2, state2]); const profileEffect = useProfileEffect(isPreviewingChanges && pendingProfileEffect !== void 0 ? pendingProfileEffect?.skuId : displayProfile == null ? void 0 : displayProfile.profileEffect?.skuId); const profileTheme = useProfileTheme({ user: stateFromStores, displayProfile, pendingThemeColors: isPreviewingChanges ? pendingThemeColors : void 0 }); const { theme, primaryColor, secondaryColor } = profileTheme; const userProfileBannerHeight = useUserProfileBannerHeight(ACTION_SHEET_MAX_WIDTH); const windowDimensions_native = useWindowDimensions_native(); const height = windowDimensions_native.height; width = windowDimensions_native.width; const gradientHeight = height - NAV_BAR_HEIGHT_MULTILINE - top; const memo3 = useMemo(() => { if (c16538_3 && frame != null) { return scaleProfileFrame(frame, Math.min(width, ACTION_SHEET_MAX_WIDTH)).overflowTop; } return 0; }, [isPreviewingChanges, frame, width]); const theme2 = useTheme(); const token = useToken(Module712.colors.INTERACTIVE_TEXT_HOVER, theme); const userProfileAnalyticsProperties = useUserProfileAnalyticsProperties({ userId, user: stateFromStores, channelId, guildId: guild_id, displayProfile, guildMember: stateFromStores2 }); c16538_24 = userProfileAnalyticsProperties; const memo4 = useMemo(() => stateFromStores != null && shouldDisableUserPresenceInChannel(stateFromStores, channelId), [stateFromStores, channelId]); useEffect(() => { if (stateFromStores == null) { getUser(userId); } }, [stateFromStores, userId]); useEffect(() => { if (!(stateFromStores == null || stateFromStores.isNonUserBot() && !isChangelogUser(stateFromStores.id))) { const id = stateFromStores.id; const avatarURL = stateFromStores.getAvatarURL(guild_id, 80); let channelId2 = channelId; if (channelId == null) { channelId2 = void 0; } maybeFetchUserProfile(id, avatarURL, { type: "action_sheet", withMutualGuilds: true, withMutualFriends: true, dispatchWait: true, guildId: guild_id, channelId: channelId2 }); } }, [stateFromStores, guild_id, channelId]); useEffect(() => { let r4 = state; if (!state) { r4 = c16538_11 == null; } if (!r4 && (guild_id == null || stateFromStores2?.fullProfileLoadedTimestamp != null)) { AnalyticsUtils.track(AnalyticEvents.OPEN_POPOUT, c16538_24); setState(true); } }, [userProfileAnalyticsProperties, displayProfile, guild_id, state, stateFromStores2]); const r238 = [pendingAvatarDecoration?.skuId, pendingProfileEffect?.skuId, , ,]; const skuId = pendingProfileFrame?.skuId; const r243 = () => { if (location_stack.at(-1) === AnalyticsLocation.COLLECTIBLES_SHOP_PROFILE_PREVIEW) { const OPEN_MODAL = AnalyticEvents.OPEN_MODAL; let sku_id = pendingAvatarDecoration?.skuId; if (sku_id == null) { sku_id = pendingProfileEffect?.skuId; } if (sku_id == null) { sku_id = pendingProfileFrame?.skuId; } AnalyticsUtils.track(OPEN_MODAL, { type: "Collectibles Shop Details Modal Expanded", location_stack, sku_id }); } }; r238[2] = skuId; r238[3] = location_stack; useEffect(r243, r238); useEffect(() => () => { if (onClose != null) { onClose(); } }, [onClose]); useEffect(() => { let rootNavigationRef, key; const handleNavigationChange2 = function handleNavigationChange() { if ((rootNavigationRef == null ? void 0 : rootNavigationRef.getCurrentRoute()?.key) !== key) { ActionSheetActionCreators.hideActionSheet(getUserProfileActionSheetKey(userId)); } }; rootNavigationRef = getRootNavigationRef(); if (rootNavigationRef != null && rootNavigationRef.isReady()) { key = rootNavigationRef.getCurrentRoute()?.key; rootNavigationRef.addListener("state", handleNavigationChange2); return () => { rootNavigationRef.removeListener("state", handleNavigationChange2); }; } }, [userId]); navigation = useNavigation(); if (stateFromStores == null) { r410 = ; } else { const fetchStartedAt = displayProfile?.fetchStartedAt; const fetchEndedAt = displayProfile?.fetchEndedAt; const isLoaded = displayProfile?.isLoaded; const r286 = [frame != null && , , , ,]; const pointerEvents = isPreviewingChanges ? "none" : void 0; const scrollEventsHandlersHook = isIOS() ? memo : void 0; const props2 = { user: stateFromStores, channel: stateFromStores3, displayProfile, disableCalls, disableMessage, isVoiceContext, location: location2, disableStatus: memo4, scrollViewRef: ref, isPreviewingChanges, navigateToShop: () => openUserSettings({ screen: UserSettingsSections.COLLECTIBLES_SHOP, onClose: handleUserSettingsClose2 }), navigateToPremium: () => openUserSettings({ screen: UserSettingsSections.PREMIUM, onClose: handleUserSettingsClose2 }), showUserProfileActionSheet: function showUserProfileActionSheetWithParams() { showUserProfileActionSheet({ sourceAnalyticsLocations: analyticsLocations, ...createUserProfileAnalyticsContext }); }, initialSection, scrollPosition: isIOS() ? sharedValue3 : void 0 }; r286[2] = {stateFromStores.isNonUserBot() ? : stateFromStores.bot ? : } {profileEffect != null && } ; r286[3] = frame == null && ; const r362 = [{r286}, frame != null && , ,]; if (isPreviewingChanges) { isPreviewingChanges = ; } r362[2] = isPreviewingChanges; r410 = {r362} ; } return r410; }); export default r62;