/*
* Copyright (C) 2026 Fluxer Contributors
*
* This file is part of Fluxer.
*
* Fluxer is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Fluxer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Fluxer. If not, see .
*/
import {observer} from 'mobx-react-lite';
import React from 'react';
import {EmojiPickerCategoryList} from '~/components/channel/emoji-picker/EmojiPickerCategoryList';
import {EMOJI_SPRITE_SIZE} from '~/components/channel/emoji-picker/EmojiPickerConstants';
import {EmojiPickerSearchBar} from '~/components/channel/emoji-picker/EmojiPickerSearchBar';
import {useEmojiCategories} from '~/components/channel/emoji-picker/hooks/useEmojiCategories';
import {useVirtualRows} from '~/components/channel/emoji-picker/hooks/useVirtualRows';
import {VirtualizedRow} from '~/components/channel/emoji-picker/VirtualRow';
import mobileStyles from '~/components/channel/MobileEmojiPicker.module.css';
import {
ExpressionPickerHeaderPortal,
useExpressionPickerHeaderPortal,
} from '~/components/popouts/ExpressionPickerPopout';
import {Scroller, type ScrollerHandle} from '~/components/uikit/Scroller';
import {useForceUpdate} from '~/hooks/useForceUpdate';
import {ComponentDispatch} from '~/lib/ComponentDispatch';
import UnicodeEmojis, {EMOJI_SPRITES} from '~/lib/UnicodeEmojis';
import ChannelStore from '~/stores/ChannelStore';
import EmojiStore, {type Emoji, normalizeEmojiSearchQuery} from '~/stores/EmojiStore';
export const MobileEmojiPicker = observer(
({
channelId,
handleSelect,
externalSearchTerm,
externalSetSearchTerm,
hideSearchBar = false,
}: {
channelId?: string;
handleSelect: (emoji: Emoji, shiftKey?: boolean) => void;
externalSearchTerm?: string;
externalSetSearchTerm?: (term: string) => void;
hideSearchBar?: boolean;
}) => {
const headerPortalContext = useExpressionPickerHeaderPortal();
const hasPortal = Boolean(headerPortalContext?.headerPortalElement);
const [internalSearchTerm, setInternalSearchTerm] = React.useState('');
const [hoveredEmoji, setHoveredEmoji] = React.useState(null);
const [renderedEmojis, setRenderedEmojis] = React.useState>([]);
const [allEmojis, setAllEmojis] = React.useState>([]);
const scrollerRef = React.useRef(null);
const emojiRefs = React.useRef