// Metro module 15293 (f15294).
import { useCallback } from "react";
import { View } from "react-native";
import ChannelStore from "../../../stores/ChannelStore";
import UserStore from "../../../stores/UserStore";
import { EMPTY_STRING_SNOWFLAKE_ID, MessageTypes, AnalyticEvents } from "../../../Constants";
import { jsx } from "react/jsx-runtime";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import * as _ReanimatedRexport from "../../reanimated/ReanimatedRexport";
import ReanimatedRexport, { useSharedValue, useAnimatedStyle, useAnimatedProps } from "../../reanimated/ReanimatedRexport";
import * as _timing from "../../../design/animation/reanimated/timing/timing";
import { Stack } from "../../../design/components/Stack/native/Stack.native";
import { Button } from "../../../design/components/Button/native/Button.native";
import { intl, t } from "../../../intl/index.native";
import { Text } from "../../../design/components/Text/native/Text";
import { useStateFromStores } from "../../../_bundle/defaultAreStatesEqual";
import { useCanReplyToMessage } from "../../replies/canReplyToMessage";
import { sendWave } from "../../main_tabs_v2/native/friends/components/AddFriendsScreenUtils";
import parseURL from "../../../utils/native/parseURL";
import handleSupportedURL from "../../links/native/handleSupportedURL";
import PeopleUtils from "../../people/PeopleUtils";
import { NotificationCenterLocalItems, NotificationCenterItems, ItemEnum, NotificationCenterActionTypes } from "../NotificationCenterItemsTypes";
import ChannelActionCreators from "../../../actions/ChannelActionCreators";
import RelationshipActionCreators from "../../../actions/RelationshipActionCreators";
import ToastActionCreators from "../../toast/native/ToastActionCreators";
import { createShallowPendingReply } from "../../replies/PendingReplyActionCreators";
import AnalyticsUtils from "../../../utils/AnalyticsUtils";
function $mk96007($env) {
return () => {
const r1 = $env.$parent;
return (0, r1[0])(r1[2][8]).ComponentDispatch.dispatch(r1[9].TEXTAREA_FOCUS, $env[0]);
};
}
let IncomingFriendRequestActions, useStyles, c10868_15, c10868_17, c10868_18, c10868_19, c10868_20, c10868_21;
let env10868 = {};
const focusChatInput = function focusChatInput(a0) {
const r4 = a0 != null ? {
channelId: a0
} : void 0;
let env21852;
const r7 = env21852 = {
$parent: env10868
};
env21852[0] = r4;
setTimeout($mk96007(r7), 0);
};
IncomingFriendRequestActions = function IncomingFriendRequestActions(props) {
const { onAccept, onIgnore, onWavePress, pressed, compactMode } = props;
const styles = useStyles();
const sharedValue = useSharedValue(0);
const sharedValue2 = useSharedValue(-1);
const sharedValue3 = useSharedValue(-1);
const sharedValue4 = useSharedValue(-1);
const u = function u() {
return {
opacity: _timing.withTiming(pressed.get() ? 0 : 1, {
duration: 150
}),
pointerEvents: pressed.get() ? "none" : "auto"
};
};
u.__closure = {
withTiming: _timing.withTiming,
pressed
};
u.__workletHash = 100815030677;
u.__initData = c10868_17;
const animatedStyle = useAnimatedStyle(u);
const _ = function _() {
const r12 = pressed.get() ? 1 : sharedValue.get() / sharedValue2.get();
const r24 = sharedValue2.get() - sharedValue2.get() * r12;
const r1 = pressed.get() ? 0 : -r24 / 2;
return {
transform: [{
scaleX: _timing.withTiming(r12)
}, {
translateX: _timing.withTiming(r1)
}],
opacity: _timing.withTiming(pressed.get() ? 1 : 0),
pointerEvents: pressed.get() ? "auto" : "none"
};
};
_.__closure = {
pressed,
acceptButtonWidth: sharedValue,
buttonWidth: sharedValue2,
withTiming: _timing.withTiming
};
_.__workletHash = 12358515723480;
_.__initData = c10868_18;
const animatedStyle2 = useAnimatedStyle(_);
const E = () => ({
transform: [{
translateX: sharedValue3.get() / 2
}, {
translateY: sharedValue4.get() / 2
}]
});
E.__closure = {
waveWidth: sharedValue3,
waveHeight: sharedValue4
};
E.__workletHash = 667441788226;
E.__initData = c10868_19;
const animatedStyle3 = useAnimatedStyle(E);
const I = function I() {
return {
transform: [{
rotateZ: _ReanimatedRexport.withDelay(450, _ReanimatedRexport.withRepeat(_timing.withTiming(pressed.get() ? "8deg" : "-2deg", {
duration: 150,
easing: _ReanimatedRexport.Easing.inOut(_ReanimatedRexport.Easing.quad)
}), 4, true))
}, {
translateX: -sharedValue3.get() / 2
}, {
translateY: -sharedValue4.get() / 2
}]
};
};
I.__closure = {
withDelay: _ReanimatedRexport.withDelay,
withRepeat: _ReanimatedRexport.withRepeat,
withTiming: _timing.withTiming,
pressed,
Easing: _ReanimatedRexport.Easing,
waveWidth: sharedValue3,
waveHeight: sharedValue4
};
I.__workletHash = 498167545082;
I.__initData = c10868_20;
const animatedStyle4 = useAnimatedStyle(I);
const r91 = function() {
pressed.get();
return {
pointerEvents: "none"
};
};
r91.__closure = {
pressed
};
r91.__workletHash = 3473531476662;
r91.__initData = c10868_21;
const animatedProps = useAnimatedProps(r91);
const props2 = {
text: intl.string(t.zf5jU5),
variant: "primary",
size: null,
onPress: null
};
let size = "md";
props2.size = compactMode ? "sm" : "md";
props2.onPress = onAccept;
const r145 = [
, ,];
const props3 = {
style: animatedStyle2,
onLayout: function onLayout(a0) {
sharedValue2.set(a0.nativeEvent.layout.width);
},
...animatedProps
};
const props4 = {
variant: "secondary",
text: intl.string(t.n8nU4W),
icon:
👋
,
size: null,
onPress: null
};
if (compactMode) {
size = "sm";
}
props4.size = size;
props4.onPress = onWavePress;
props3.children = ;
r145[1] = ;
return {r145};
};
useStyles = createStyles({
buttonsContainer: {
flexDirection: "row",
marginTop: 8
},
actionButtonsContainer: {
flexDirection: "row",
position: "absolute",
left: 0
}
});
c10868_15 = {
ACCEPT: "accept",
IGNORE: "ignore",
WAVE: "wave",
ACTION: "action"
};
c10868_17 = {
code: "function ForYouItemActionButtonsTsx1(){const{withTiming,pressed}=this.__closure;return{opacity:withTiming(!pressed.get()?1:0,{duration:150}),pointerEvents:!pressed.get()?'auto':'none'};}"
};
c10868_18 = {
code: "function ForYouItemActionButtonsTsx2(){const{pressed,acceptButtonWidth,buttonWidth,withTiming}=this.__closure;const scaleX=!pressed.get()?acceptButtonWidth.get()/buttonWidth.get():1;const scaledWidth=buttonWidth.get()-buttonWidth.get()*scaleX;const translateX=!pressed.get()?-scaledWidth/2:0;return{transform:[{scaleX:withTiming(scaleX)},{translateX:withTiming(translateX)}],opacity:withTiming(!pressed.get()?0:1),pointerEvents:!pressed.get()?'none':'auto'};}"
};
c10868_19 = {
code: "function ForYouItemActionButtonsTsx3(){const{waveWidth,waveHeight}=this.__closure;return{transform:[{translateX:waveWidth.get()/2},{translateY:waveHeight.get()/2}]};}"
};
c10868_20 = {
code: "function ForYouItemActionButtonsTsx4(){const{withDelay,withRepeat,withTiming,pressed,Easing,waveWidth,waveHeight}=this.__closure;return{transform:[{rotateZ:withDelay(450,withRepeat(withTiming(pressed.get()?'8deg':'-2deg',{duration:150,easing:Easing.inOut(Easing.quad)}),4,true))},{translateX:-waveWidth.get()/2},{translateY:-waveHeight.get()/2}]};}"
};
c10868_21 = {
code: "function ForYouItemActionButtonsTsx5(){const{pressed}=this.__closure;return{pointerEvents:!pressed.get()?'none':'none'};}"
};
export { IncomingFriendRequestActions };
export function useItemActionButtonPropsV2(a0, a1, a2, a3, a4, a5, a6, a7) {
let r166, accessibilityActions, id2, text;
let callback, sharedValue5, callback2, callback3;
let c21854_0 = a0;
let r3 = a0.other_user?.id;
if (r3 == null) {
r3 = EMPTY_STRING_SNOWFLAKE_ID;
}
const userId = r3;
const location2 = "notification_center_v2";
const stateFromStores = useStateFromStores([ChannelStore], () => ChannelStore.getChannel(c21854_0.message?.channel_id));
const canReplyToMessage2 = useCanReplyToMessage(stateFromStores, a0.message);
const type = a0.message?.type;
const POLL_RESULT = MessageTypes.POLL_RESULT;
callback = useCallback(() => {
sendWave(userId, false, "You Tab");
const dMFromUserId = ChannelStore.getDMFromUserId(userId);
if (dMFromUserId != null) {
handleSupportedURL({
payload: parseURL(`https://discord.com/channels/@me/${dMFromUserId}`).payload,
safe: true,
navigationReplace: false
});
}
a5(c21854_0);
}, [userId, a5, a0]);
sharedValue5 = useSharedValue(false);
callback2 = useCallback(() => {
PeopleUtils.maybeConfirmFriendRequestAccept({
userId,
applicationId: c21854_0.type === NotificationCenterLocalItems.INCOMING_GAME_FRIEND_REQUESTS ? c21854_0.applicationId : void 0,
location: location2,
onConfirm: () => {
const user = UserStore.getUser(userId);
if (user != null) {
const r20 = t["5Uzkdp"];
let globalName = user.globalName;
if (globalName == null) {
globalName = user.username;
}
a6(intl.formatToPlainString(r20, {
username: `**${globalName}**`
}));
}
sharedValue5.set(true);
c21854_0.enableBadge = false;
a3(c21854_0);
}
});
}, [a3, sharedValue5, a0, userId, a6]);
callback3 = useCallback(() => {
PeopleUtils.cancelFriendRequest({
userId,
applicationId: c21854_0.type === NotificationCenterLocalItems.INCOMING_GAME_FRIEND_REQUESTS ? c21854_0.applicationId : void 0,
location: location2
});
}, [a0.applicationId, a0.type, userId]);
const callback4 = useCallback(() => {
if (a2 != null) {
a2.navigate("friends", {
screen: "requests"
});
}
}, [a2]);
const callback5 = useCallback(() => {
ChannelActionCreators.getDMChannel(userId).then((result) => {
let env30863;
handleSupportedURL({
payload: parseURL(`https://discord.com/channels/@me/${result}`).payload,
safe: true,
navigationReplace: false
});
const r20 = env30863 = {
$parent: env10868
};
env30863[0] = void 0;
env30863[0] = result != null ? {
channelId: result
} : void 0;
setTimeout($mk96007(r20), 0);
});
}, [userId]);
const callback6 = useCallback(() => {
RelationshipActionCreators.addRelationship({
userId,
context: {
location: location2
}
});
ToastActionCreators.open({
key: "NOTIF_CENTER_V2_ADD_FRIEND_TOAST",
content: intl.string(t["7MAxkR"])
});
}, [userId]);
const callback7 = useCallback(async () => {
let c27988_0;
L14: {
c27988_0 = void 0;
if (c21854_0.message_id != null && stateFromStores != null) {
await createShallowPendingReply({
messageId: c21854_0.message_id,
channel: stateFromStores,
shouldMention: true,
showMentionToggle: true
});
(0, a1)();
(0, focusChatInput)(c21854_0.message_channel_id);
break L14;
}
(0, a1)();
(0, focusChatInput)(c21854_0.message_channel_id);
return void 0;
}
}, [a1, stateFromStores, a0.message_id, a0.message_channel_id]);
const callback8 = useCallback(() => {
let env27989;
a1();
const message_channel_id = c21854_0.message_channel_id;
const r10 = env27989 = {
$parent: env10868
};
env27989[0] = void 0;
env27989[0] = message_channel_id != null ? {
channelId: message_channel_id
} : void 0;
setTimeout($mk96007(r10), 0);
}, [a1, a0.message_channel_id]);
if (a0.disable_action) {
return {
actionButtons: []
};
}
L52: {
if (a0.type !== NotificationCenterLocalItems.INCOMING_FRIEND_REQUESTS) {
if (a0.type === NotificationCenterLocalItems.INCOMING_FRIEND_REQUESTS_ACCEPTED && a4(a0)) {
break L52;
}
if (a0.type !== NotificationCenterLocalItems.INCOMING_GAME_FRIEND_REQUESTS) {
if (a0.type === NotificationCenterLocalItems.INCOMING_GAME_FRIEND_REQUESTS_ACCEPTED && a4(a0)) {
break L52;
}
if (a0.type === NotificationCenterLocalItems.FRIEND_REQUESTS_GROUPED) {
return {
actionButtons: [{
id: "view_friend_requests",
text: intl.string(t["lMR96+"]),
variant: "secondary",
size: "md",
onPress: callback4
}],
accessibilityActions: [{
name: c10868_15.ACTION,
label: intl.string(t["lMR96+"])
}],
onAccessibilityAction: callback4
};
}
if (a0.type === NotificationCenterItems.GO_LIVE_PUSH) {
return {
actionButtons: [{
id: "join_stream",
text: intl.string(t["Pqj7h+"]),
variant: "secondary",
size: "md",
onPress: a1
}],
accessibilityActions: [{
name: c10868_15.ACTION,
label: intl.string(t["Pqj7h+"])
}],
onAccessibilityAction: a1
};
}
if (a0.type !== NotificationCenterLocalItems.INCOMING_FRIEND_REQUESTS_ACCEPTED && a0.type !== NotificationCenterItems.DM_FRIEND_NUDGE && a0.type !== NotificationCenterItems.FRIEND_REQUEST_ACCEPTED && a0.type !== NotificationCenterItems.GAME_FRIEND_REQUEST_ACCEPTED) {
if (a0.type === NotificationCenterItems.FRIEND_SUGGESTION_CREATED) {
return {
actionButtons: [{
id: "add_friend",
text: intl.string(t["boL/YX"]),
variant: "secondary",
size: "md",
onPress: callback6
}],
accessibilityActions: [{
name: c10868_15.ACTION,
label: intl.string(t["boL/YX"])
}],
onAccessibilityAction: callback6
};
}
if (a0.type === NotificationCenterItems.GUILD_SCHEDULED_EVENT_STARTED) {
return {
actionButtons: [{
id: "join_event",
text: intl.string(t.hRKdcn),
variant: "secondary",
size: "md",
onPress: a1
}],
accessibilityActions: [{
name: c10868_15.ACTION,
label: intl.string(t.hRKdcn)
}],
onAccessibilityAction: a1
};
}
if (a0.type === NotificationCenterItems.LIFECYCLE_ITEM) {
const item_enum = a0.item_enum;
if (ItemEnum.UPDATE_PROFILE === item_enum) {
text = intl.string(t.zMRcWL);
id2 = "update_profile";
} else if (ItemEnum.FIND_FRIENDS === item_enum) {
text = intl.string(t["vwL/4s"]);
id2 = "find_friends";
} else if (ItemEnum.ADD_FRIEND === item_enum) {
text = intl.string(t["boL/YX"]);
id2 = "add_friend";
} else {
const FIRST_MESSAGE = ItemEnum.FIRST_MESSAGE;
id2 = null;
text = null;
if (FIRST_MESSAGE === item_enum) {
text = intl.string(t["GuUH7/"]);
id2 = "send_message";
}
}
return text != null && id2 != null ? {
actionButtons: [{
id: id2,
text,
variant: "secondary",
size: "md",
onPress: a1
}],
accessibilityActions: [{
name: c10868_15.ACTION,
label: text
}],
onAccessibilityAction: a1
} : {
actionButtons: []
};
}
L33: {
if (a0.type !== NotificationCenterItems.RECENT_MENTION && a0.type !== NotificationCenterItems.REPLY_MENTION) {
if (a0.type === NotificationCenterItems.TRENDING_CONTENT) {
r166 = {
actionButtons: [{
id: "read_summary",
text: intl.string(t.k0Q31F),
variant: "secondary",
size: "md",
onPress: callback8
}],
accessibilityActions: [{
name: c10868_15.ACTION,
label: intl.string(t.k0Q31F)
}],
onAccessibilityAction: callback8
};
break L33;
}
r166 = {
actionButtons: []
};
} else {
r166 = canReplyToMessage2 && type !== POLL_RESULT ? {
actionButtons: [{
id: "send_reply",
text: intl.string(t.vBq3iT),
variant: "secondary",
size: "md",
onPress: callback7
}],
accessibilityActions: [{
name: c10868_15.ACTION,
label: intl.string(t.vBq3iT)
}],
onAccessibilityAction: callback7
} : {
actionButtons: []
};
}
}
return r166;
}
return {
actionButtons: [{
id: "send_message",
text: intl.string(t["GuUH7/"]),
variant: "secondary",
size: "md",
onPress: callback5
}],
accessibilityActions: [{
name: c10868_15.ACTION,
label: intl.string(t["GuUH7/"])
}],
onAccessibilityAction: callback5
};
}
}
}
const r406 = {
actionsNode: (0, jsx)(IncomingFriendRequestActions, {
onWavePress: callback,
onAccept: callback2,
onIgnore: callback3,
pressed: sharedValue5,
compactMode: a7
}),
accessibilityActions: null,
onAccessibilityAction: null
};
if (a0.type === NotificationCenterLocalItems.INCOMING_FRIEND_REQUESTS_ACCEPTED) {
accessibilityActions = [{
name: c10868_15.WAVE,
label: intl.string(t.n8nU4W)
}];
} else {
accessibilityActions = [{
name: c10868_15.ACCEPT,
label: intl.string(t.zf5jU5)
}, {
name: c10868_15.IGNORE,
label: intl.string(t.EBN847)
}];
}
r406.accessibilityActions = accessibilityActions;
r406.onAccessibilityAction = (a0) => {
const actionName = a0.nativeEvent.actionName;
if (c10868_15.WAVE === actionName) {
callback();
} else if (c10868_15.ACCEPT === actionName) {
callback2();
} else if (c10868_15.IGNORE === actionName) {
callback3();
}
};
return r406;
}
export function ForYouItemActionButtons(props) {
let r20;
const { item, rowIndex, onSoftAckItem, actionButtons, actionsNode, compactMode, ...props2 } = props;
const styles = useStyles();
let r19 = compactMode ? !compactMode : actionButtons != null;
L9: {
const r1 = actionsNode != null;
if (!r19) {
r20 = null;
if (!r1) {
break L9;
}
}
if (r19) {
r19 = actionButtons.map((actionButton, index) => {
const { id: _id, ...rest } = actionButton;
let id2 = actionButton.id;
const id = id2;
let c27990_1 = rest;
const props = {
...rest,
onPress: (a0) => {
const onPress2 = c27990_1.onPress;
if (onPress2 != null) {
onPress2.call(c27990_1, a0);
}
onSoftAckItem(item);
AnalyticsUtils.track(AnalyticEvents.NOTIFICATION_CENTER_ACTION, {
action_type: NotificationCenterActionTypes.ACTION_BUTTON,
notification_center_id: item.id,
item_type: item.type,
acked: false,
item_index: rowIndex,
deeplink: item.deeplink,
action_button_id: id
});
}
};
if (id == null) {
id2 = index;
}
return ;
});
}
r20 =
{r19}
{r1 ? actionsNode : null}
;
}
return r20;
}