import { useCallback, useEffect, useMemo, useRef, useState } from "react";
export function getFileSuggestions(query, files = []) {
    const needle = query.replace(/^@/, "").toLowerCase();
    return files
        .filter((file) => !needle || file.toLowerCase().includes(needle))
        .slice(0, 20)
        .map((file) => ({ id: file, label: file, insertText: `@${file}` }));
}
export function renderPlaceholder(value, placeholder = "") {
    return value.length === 0 ? placeholder : value;
}
export function getUnifiedSuggestions(input) {
    const query = input.query.trim();
    if (query.startsWith("@"))
        return getFileSuggestions(query, input.files);
    if (query.startsWith("/")) {
        const needle = query.slice(1).toLowerCase();
        return (input.commands ?? [])
            .filter((command) => command.toLowerCase().includes(needle))
            .slice(0, 20)
            .map((command) => ({ id: command, label: `/${command}`, insertText: `/${command} ` }));
    }
    return [];
}
export function useAfterFirstRender(callback) {
    const first = useRef(true);
    useEffect(() => {
        if (first.current) {
            first.current = false;
            return;
        }
        callback();
    });
}
export function useApiKeyVerification() {
    return { status: "unknown", verify: async () => Boolean(process.env.DEEPSEEK_API_KEY) };
}
export function useArrowKeyHistory(items, initialIndex = items.length) {
    const [index, setIndex] = useState(initialIndex);
    return {
        index,
        current: items[index],
        previous: () => setIndex((value) => Math.max(0, value - 1)),
        next: () => setIndex((value) => Math.min(items.length, value + 1)),
    };
}
export function useAssistantHistory(items = []) {
    return items;
}
export function useAwaySummary() {
    return null;
}
export function useBackgroundTaskNavigation(tasks = []) {
    const [selectedIndex] = useState(0);
    return { selectedIndex, selected: tasks[selectedIndex] };
}
export function useBlink(intervalMs = 500) {
    const [visible, setVisible] = useState(true);
    useEffect(() => {
        const timer = setInterval(() => setVisible((value) => !value), intervalMs);
        return () => clearInterval(timer);
    }, [intervalMs]);
    return visible;
}
export function useCancelRequest() {
    const [cancelled, setCancelled] = useState(false);
    return { cancelled, cancel: () => setCancelled(true) };
}
export function useCanUseTool() {
    return true;
}
export function useClipboardImageHint() {
    return null;
}
export function useCommandKeybindings() {
    return {};
}
export function useCommandQueue() {
    const [queue, setQueue] = useState([]);
    return {
        queue,
        push: (item) => setQueue((items) => [...items, item]),
        shift: () => {
            const first = queue[0];
            setQueue((items) => items.slice(1));
            return first;
        },
    };
}
export function useCopyOnSelect() { }
export function useDeferredHookMessages(messages = []) {
    return messages;
}
export function useDiffData(data) {
    return data;
}
export function useDiffInIDE() {
    return { open: () => undefined };
}
export function useDirectConnect() {
    return { connected: false };
}
export function useDoublePress(callback, delayMs = 900) {
    const lastPress = useRef(0);
    return useCallback(() => {
        const now = Date.now();
        if (now - lastPress.current <= delayMs)
            callback();
        lastPress.current = now;
    }, [callback, delayMs]);
}
export function useDynamicConfig(value) {
    return value;
}
export function useElapsedTime(startMs = Date.now()) {
    const [now, setNow] = useState(Date.now());
    useEffect(() => {
        const timer = setInterval(() => setNow(Date.now()), 1000);
        return () => clearInterval(timer);
    }, []);
    return Math.max(0, now - startMs);
}
export function useExitOnCtrlCD() { }
export function useExitOnCtrlCDWithKeybindings() { }
export function useFileHistorySnapshotInit() { }
export function useGlobalKeybindings() { }
export function useHistorySearch(items = [], query = "") {
    const needle = query.toLowerCase();
    return items.filter((item) => !needle || (item.text ?? "").toLowerCase().includes(needle));
}
export function useIdeAtMentioned() {
    return false;
}
export function useIdeConnectionStatus() {
    return { connected: false };
}
export function useIDEIntegration() {
    return { enabled: false };
}
export function useIdeLogging() { }
export function useIdeSelection() {
    return null;
}
export function useInboxPoller() { }
export function useInputBuffer(initial = "") {
    const [value, setValue] = useState(initial);
    return { value, setValue, clear: () => setValue("") };
}
export function useLogMessages(messages = []) {
    return messages;
}
export function useMainLoopModel(model) {
    return model;
}
export function useManagePlugins() {
    return { enabled: true };
}
export function useMergedClients(clients = []) {
    return clients;
}
export function useMergedCommands(commands = []) {
    return commands;
}
export function useMergedTools(tools = []) {
    return tools;
}
export function useMinDisplayTime(visible, minMs = 300) {
    const [shown, setShown] = useState(visible);
    useEffect(() => {
        if (visible) {
            setShown(true);
            return;
        }
        const timer = setTimeout(() => setShown(false), minMs);
        return () => clearTimeout(timer);
    }, [visible, minMs]);
    return shown;
}
export function useNotifyAfterTimeout(enabled, timeoutMs = 30_000) {
    const [ready, setReady] = useState(false);
    useEffect(() => {
        if (!enabled) {
            setReady(false);
            return;
        }
        const timer = setTimeout(() => setReady(true), timeoutMs);
        return () => clearTimeout(timer);
    }, [enabled, timeoutMs]);
    return ready;
}
export function usePasteHandler(handler) {
    return { paste: (value) => handler?.(value) };
}
export function usePromptSuggestion(query, commands = [], files = []) {
    return useMemo(() => getUnifiedSuggestions({ query, commands, files }), [query, commands, files]);
}
export function useQueueProcessor() {
    return { running: false };
}
export function useRemoteSession() {
    return { connected: false };
}
export function useReplBridge() {
    return { ready: true };
}
export function useScheduledTasks(tasks = []) {
    return tasks;
}
export function useSearchInput(initial = "") {
    const [query, setQuery] = useState(initial);
    return { query, setQuery, clear: () => setQuery("") };
}
export function useSessionBackgrounding() {
    return { backgrounded: false };
}
export function useSettings(settings) {
    return settings;
}
export function useSettingsChange() { }
export function useSkillsChange() { }
export function useSSHSession() {
    return { connected: false };
}
export function useSwarmInitialization() {
    return { initialized: false };
}
export function useSwarmPermissionPoller() { }
export function useTaskListWatcher(tasks = []) {
    return tasks;
}
export function useTasksV2(tasks = []) {
    return tasks;
}
export function useTeammateViewAutoExit() { }
export function useTeleportResume() {
    return { available: false };
}
export function useTextInput(initial = "") {
    return useInputBuffer(initial);
}
export function useTimeout(callback, timeoutMs) {
    useEffect(() => {
        if (timeoutMs === null)
            return;
        const timer = setTimeout(callback, timeoutMs);
        return () => clearTimeout(timer);
    }, [callback, timeoutMs]);
}
export function useTurnDiffs(diffs = []) {
    return diffs;
}
export function useTypeahead(items = [], query = "") {
    const needle = query.toLowerCase();
    return items.filter((item) => item.label.toLowerCase().includes(needle));
}
export function useUpdateNotification() {
    return null;
}
export function useVimInput(initial = "") {
    return { ...useInputBuffer(initial), mode: "insert" };
}
export function useVirtualScroll(items, selectedIndex, visibleCount) {
    const half = Math.floor(Math.max(1, visibleCount) / 2);
    const start = Math.max(0, Math.min(Math.max(0, items.length - visibleCount), selectedIndex - half));
    return items.slice(start, start + visibleCount);
}
export function useVoice() {
    return { recording: false };
}
export function useVoiceEnabled() {
    return false;
}
export function useVoiceIntegration() {
    return { enabled: false };
}
export function useFalseNotification() {
    return null;
}
export const useChromeExtensionNotification = useFalseNotification;
export const useClaudeCodeHintRecommendation = useFalseNotification;
export const useIssueFlagBanner = useFalseNotification;
export const useLspPluginRecommendation = useFalseNotification;
export const useMailboxBridge = useFalseNotification;
export const useOfficialMarketplaceNotification = useFalseNotification;
export const usePluginRecommendationBase = useFalseNotification;
export const usePromptsFromClaudeInChrome = useFalseNotification;
export const usePrStatus = useFalseNotification;
export const useSkillImprovementSurvey = useFalseNotification;
export const useAntOrgWarningNotification = useFalseNotification;
export const useAutoModeUnavailableNotification = useFalseNotification;
export const useCanSwitchToExistingSubscription = useFalseNotification;
export const useDeprecationWarningNotification = useFalseNotification;
export const useFastModeNotification = useFalseNotification;
export const useIDEStatusIndicator = useFalseNotification;
export const useInstallMessages = useFalseNotification;
export const useLspInitializationNotification = useFalseNotification;
export const useMcpConnectivityStatus = useFalseNotification;
export const useModelMigrationNotifications = useFalseNotification;
export const useNpmDeprecationNotification = useFalseNotification;
export const usePluginAutoupdateNotification = useFalseNotification;
export const usePluginInstallationStatus = useFalseNotification;
export const useRateLimitWarningNotification = useFalseNotification;
export const useSettingsErrors = useFalseNotification;
export const useStartupNotification = useFalseNotification;
export const useTeammateShutdownNotification = useFalseNotification;
