291 lines
9.7 KiB
TypeScript
291 lines
9.7 KiB
TypeScript
// Metro module 1478 (f1479).
|
|
import { AppLauncherRouteName } from "../../app_launcher/native/AppLauncherNativeConstants";
|
|
import { ExpressionPickerViewType } from "../../expression_picker/ExpressionPickerConstants";
|
|
import { MediaKeyboardTarget } from "../../media_keyboard/native/MediaKeyboardConstants";
|
|
import { Storage } from "../../../_bundle/Module595";
|
|
import { KeyboardTypes } from "./KeyboardTypes";
|
|
import { getIsAnyChatInputFocused } from "./ChatInputFocused";
|
|
import { getSafeAreaInsets } from "../../safe_area/useSafeAreaInsets.native";
|
|
import { isAndroid } from "../../../utils/PlatformUtils";
|
|
import Module1593 from "../../../_bundle/Module1593";
|
|
import shallowEqual from "../../../_bundle/shallowEqual";
|
|
import { batchUpdates } from "../../../_bundle/Module705";
|
|
import { create } from "../../../_bundle/Module644";
|
|
import { KeyboardEvents } from "../../../_bundle/Module1595";
|
|
import KeyboardStateDebugging from "../KeyboardStateDebugging";
|
|
import { onKeyboardChanged } from "../../../utils/native/KeyboardManagerUtils";
|
|
import SafeAreaStore_native from "../../safe_area/SafeAreaStore.native";
|
|
import * as _AppEntryKeyContext from "../../window/native/AppEntryKeyContext";
|
|
function $mk69263($env) {
|
|
return () => $env.$parent[11].setState($mk102222($env));
|
|
}
|
|
function $mk102222($env) {
|
|
return (a0) => {
|
|
let r26, r31;
|
|
const r9 = $env;
|
|
const r3 = r9[1];
|
|
if (r3 != null) {
|
|
r31 = [r3];
|
|
} else {
|
|
const r27 = $env.$parent;
|
|
r31 = (0, r27[0])(r27[2][11]).APP_ENTRY_KEYS;
|
|
}
|
|
let r33 = a0;
|
|
let byAppEntry = a0.byAppEntry;
|
|
let r35 = r31[Symbol.iterator]();
|
|
const next = r35.next;
|
|
const r4 = $env.$parent;
|
|
while (true) {
|
|
const r13 = r35 === void 0 ? void 0 : (r26 = next.call(r35)).done ? r35 = void 0 : r26.value;
|
|
if (r35 === void 0) {
|
|
if (byAppEntry !== a0.byAppEntry) {
|
|
r33 = {
|
|
byAppEntry
|
|
};
|
|
}
|
|
return r33;
|
|
}
|
|
try {
|
|
const r11 = byAppEntry[r13];
|
|
const r42 = (0, r4[9])(r11, r9[0], r13);
|
|
if (r11 !== r42) {
|
|
const r44 = {
|
|
...byAppEntry
|
|
};
|
|
r44[r13] = r42;
|
|
byAppEntry = r44;
|
|
}
|
|
} catch (r48) {
|
|
if (r35 !== void 0 && typeof r35.return === "function") {
|
|
try {
|
|
r35.return();
|
|
} catch {}
|
|
}
|
|
throw r48;
|
|
}
|
|
}
|
|
};
|
|
}
|
|
let createInitialEntryState, c1194_6, c1194_7, c1194_8, c1194_11;
|
|
let env1194 = {};
|
|
const computeEntryState = function computeEntryState(a0, a1, a2) {
|
|
let customKeyboardHeight, customKeyboardHeightExcludingSafeAreaInsets, keyboardContexts2, systemKeyboardOpen;
|
|
let r7 = a0;
|
|
let keyboardDuration = a1.keyboardDuration;
|
|
if (keyboardDuration == null) {
|
|
keyboardDuration = a0.keyboardDuration;
|
|
}
|
|
let keyboardHeight = a1.keyboardHeight;
|
|
if (keyboardHeight == null) {
|
|
keyboardHeight = a0.keyboardHeight;
|
|
}
|
|
const keyboardHeight3 = isAndroid() ? Module1593.getImeInsets(false, a2) : keyboardHeight !== 0 ? keyboardHeight - 0 : 0;
|
|
let keyboardHeight2 = a1.keyboardHeight;
|
|
if (keyboardHeight2 == null) {
|
|
keyboardHeight2 = a0.keyboardHeight;
|
|
}
|
|
const keyboardHeightExcludingSafeAreaInsets = isAndroid() ? Module1593.getImeInsets(true, a2) : keyboardHeight2 !== 0 ? keyboardHeight2 - getSafeAreaInsets(a2).bottom : 0;
|
|
let keyboardType = a1.keyboardType?.type;
|
|
if (keyboardType == null) {
|
|
keyboardType = a0.keyboardType;
|
|
}
|
|
const keyboardTypePrevious = keyboardType !== a0.keyboardType ? a0.keyboardType : a0.keyboardTypePrevious;
|
|
let r55 = Storage.get(c1194_6, 253);
|
|
if (r55 == null) {
|
|
r55 = 253;
|
|
}
|
|
if (keyboardType === KeyboardTypes.SYSTEM && (keyboardHeight3 !== 0 && getIsAnyChatInputFocused())) {
|
|
const r67 = Math.max(keyboardHeight3, 200);
|
|
if (r67 !== r55) {
|
|
Storage.set(c1194_6, r67);
|
|
}
|
|
customKeyboardHeight = r67 - 0;
|
|
} else {
|
|
customKeyboardHeight = r55 - 0;
|
|
}
|
|
let r78 = Storage.get(c1194_6, 253);
|
|
if (r78 == null) {
|
|
r78 = 253;
|
|
}
|
|
if (keyboardType === KeyboardTypes.SYSTEM && (keyboardHeight3 !== 0 && getIsAnyChatInputFocused())) {
|
|
const r92 = Math.max(keyboardHeight3, 200);
|
|
if (r92 !== r78) {
|
|
Storage.set(c1194_6, r92);
|
|
}
|
|
customKeyboardHeightExcludingSafeAreaInsets = r92 - getSafeAreaInsets(a2).bottom;
|
|
} else {
|
|
customKeyboardHeightExcludingSafeAreaInsets = r78 - getSafeAreaInsets(a2).bottom;
|
|
}
|
|
const r110 = a0.keyboardContexts[keyboardType];
|
|
let r113 = a1.keyboardType?.context;
|
|
if (r113 == null) {
|
|
r113 = r110;
|
|
}
|
|
const r114 = typeof r110 === "object" && typeof r113 === "object" ? !shallowEqual(r110, r113) : r110 !== r113;
|
|
if (isAndroid()) {
|
|
systemKeyboardOpen = keyboardHeight3 > 0;
|
|
} else {
|
|
systemKeyboardOpen = a1.systemKeyboardOpen;
|
|
if (systemKeyboardOpen == null) {
|
|
systemKeyboardOpen = a0.systemKeyboardOpen;
|
|
}
|
|
}
|
|
if (a0.keyboardContexts[KeyboardTypes.SYSTEM].keyboardWillOpen && a1.systemKeyboardOpen != null) {
|
|
const r137 = {
|
|
...a0.keyboardContexts
|
|
};
|
|
r137[KeyboardTypes.SYSTEM] = {
|
|
...a0.keyboardContexts[KeyboardTypes.SYSTEM],
|
|
keyboardWillOpen: false
|
|
};
|
|
keyboardContexts2 = r137;
|
|
} else {
|
|
const keyboardContexts = a0.keyboardContexts;
|
|
if (r114) {
|
|
const r135 = {
|
|
...keyboardContexts
|
|
};
|
|
r135[keyboardType] = r113;
|
|
keyboardContexts2 = r135;
|
|
} else {
|
|
keyboardContexts2 = keyboardContexts;
|
|
}
|
|
}
|
|
const r158 = shallowEqual(a0.keyboardContexts, keyboardContexts2);
|
|
if (!(a0.keyboardDuration === keyboardDuration && (r158 && (a0.keyboardHeight === keyboardHeight3 && (a0.keyboardHeightExcludingSafeAreaInsets === keyboardHeightExcludingSafeAreaInsets && (a0.keyboardType === keyboardType && (a0.customKeyboardHeight === customKeyboardHeight && (a0.customKeyboardHeightExcludingSafeAreaInsets === customKeyboardHeightExcludingSafeAreaInsets && a0.systemKeyboardOpen === systemKeyboardOpen)))))))) {
|
|
r7 = {
|
|
keyboardContexts: keyboardContexts2,
|
|
keyboardDuration,
|
|
keyboardHeight: keyboardHeight3,
|
|
keyboardHeightExcludingSafeAreaInsets,
|
|
systemKeyboardOpen,
|
|
keyboardType,
|
|
keyboardTypePrevious,
|
|
customKeyboardHeight,
|
|
customKeyboardHeightExcludingSafeAreaInsets
|
|
};
|
|
}
|
|
return r7;
|
|
};
|
|
createInitialEntryState = function createInitialEntryState(a0) {
|
|
KeyboardTypes.SYSTEM;
|
|
let r9 = Storage.get(c1194_6, 253);
|
|
if (r9 == null) {
|
|
r9 = 253;
|
|
}
|
|
KeyboardTypes.SYSTEM;
|
|
KeyboardTypes.SYSTEM;
|
|
let r33 = Storage.get(c1194_6, 253);
|
|
if (r33 == null) {
|
|
r33 = 253;
|
|
}
|
|
KeyboardTypes.SYSTEM;
|
|
const r25 = {
|
|
customKeyboardHeight: r9 - 0,
|
|
customKeyboardHeightExcludingSafeAreaInsets: r33 - getSafeAreaInsets(a0).bottom,
|
|
keyboardContexts: null,
|
|
keyboardDuration: 0,
|
|
keyboardHeight: null,
|
|
keyboardHeightExcludingSafeAreaInsets: null,
|
|
systemKeyboardOpen: false,
|
|
keyboardType: null,
|
|
keyboardTypePrevious: null
|
|
};
|
|
const keyboardContexts = {};
|
|
keyboardContexts[KeyboardTypes.SYSTEM] = {
|
|
keyboardWillOpen: false
|
|
};
|
|
keyboardContexts[KeyboardTypes.EXPRESSION] = ExpressionPickerViewType.EMOJI;
|
|
keyboardContexts[KeyboardTypes.MEDIA] = {
|
|
target: MediaKeyboardTarget.CHAT
|
|
};
|
|
keyboardContexts[KeyboardTypes.APP_LAUNCHER] = {
|
|
initialRouteName: AppLauncherRouteName.HOME
|
|
};
|
|
r25.keyboardContexts = keyboardContexts;
|
|
r25.keyboardHeight = isAndroid() ? Module1593.getImeInsets(false, a0) : 0;
|
|
r25.keyboardHeightExcludingSafeAreaInsets = isAndroid() ? Module1593.getImeInsets(true, a0) : 0;
|
|
r25.keyboardType = KeyboardTypes.SYSTEM;
|
|
r25.keyboardTypePrevious = KeyboardTypes.SYSTEM;
|
|
return r25;
|
|
};
|
|
c1194_6 = "customKeyboardHeight";
|
|
c1194_7 = new Set();
|
|
c1194_8 = new Set();
|
|
const r11 = isAndroid() ? "keyboardDidShow" : "keyboardWillShow";
|
|
const r46 = isAndroid() ? "keyboardDidHide" : "keyboardWillHide";
|
|
c1194_11 = create(() => ({
|
|
byAppEntry: {
|
|
main: createInitialEntryState("main"),
|
|
share: createInitialEntryState("share")
|
|
}
|
|
}));
|
|
KeyboardEvents.addListener(r11, ({ duration, height }) => {
|
|
let env13053;
|
|
KeyboardStateDebugging.reactNativeKeyboardDidShow(height, "KeyboardUIStore");
|
|
const r13 = {
|
|
keyboardHeight: height,
|
|
keyboardDuration: duration,
|
|
systemKeyboardOpen: true
|
|
};
|
|
const r14 = env13053 = {
|
|
$parent: env1194
|
|
};
|
|
env13053[0] = r13;
|
|
env13053[1] = void 0;
|
|
batchUpdates($mk69263(r14));
|
|
onKeyboardChanged(true);
|
|
c1194_8.forEach((item) => item(false));
|
|
});
|
|
KeyboardEvents.addListener(r46, () => {
|
|
let env13054;
|
|
KeyboardStateDebugging.reactNativeKeyboardDidHide("KeyboardUIStore");
|
|
const r11 = env13054 = {
|
|
$parent: env1194
|
|
};
|
|
env13054[0] = {
|
|
keyboardHeight: 0,
|
|
systemKeyboardOpen: false
|
|
};
|
|
env13054[1] = void 0;
|
|
batchUpdates($mk69263(r11));
|
|
onKeyboardChanged(false);
|
|
c1194_8.forEach((item) => item(false));
|
|
});
|
|
SafeAreaStore_native.subscribe(() => {
|
|
let env13055;
|
|
const r1 = env13055 = {
|
|
$parent: env1194
|
|
};
|
|
env13055[0] = {};
|
|
batchUpdates($mk69263(r1));
|
|
});
|
|
export default c1194_11;
|
|
export function setKeyboardType(a0) {
|
|
let r3 = arguments[1];
|
|
if (r3 === void 0) {
|
|
r3 = _AppEntryKeyContext.DEFAULT_APP_ENTRY_KEY;
|
|
}
|
|
let env13057;
|
|
const DEFAULT_APP_ENTRY_KEY = r3;
|
|
c1194_7.forEach((item) => item(a0, DEFAULT_APP_ENTRY_KEY));
|
|
c1194_8.forEach((item) => item(a0.type === KeyboardTypes.SYSTEM && a0.context?.keyboardWillOpen === true, DEFAULT_APP_ENTRY_KEY));
|
|
const r17 = {
|
|
keyboardType: a0
|
|
};
|
|
const r18 = env13057 = {
|
|
$parent: env1194
|
|
};
|
|
env13057[0] = r17;
|
|
env13057[1] = DEFAULT_APP_ENTRY_KEY;
|
|
batchUpdates($mk69263(r18));
|
|
}
|
|
export function addKeyboardWillOpenChangedListener(a0) {
|
|
c1194_8.add(a0);
|
|
return () => c1194_8.delete(a0);
|
|
}
|
|
export function addKeyboardTypeChangedListener(a0) {
|
|
c1194_7.add(a0);
|
|
return () => c1194_7.delete(a0);
|
|
}
|