import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
// packages/ui/src/routing/GoTo.tsx
/**
 * @fileoverview GoTo component
 * @description Navigation command palette button
 *
 * @version 0.0.1
 * @since 0.0.1
 * @author AMBROISE PARK Consulting
 */
import { Search } from 'lucide-react';
import { Button, BUTTON_VARIANT, DISPLAY } from '@donotdev/components';
import { useOverlayStore, useTranslation } from '@donotdev/core';
/**
 * GoTo - Command palette trigger button
 *
 * Simple button: Search icon + "Go to" label + keyboard shortcut.
 * Opens command dialog on click.
 */
export const GoTo = ({ display = DISPLAY.AUTO, className, onOpen, }) => {
    const { t } = useTranslation('dndev');
    const openCommandDialog = useOverlayStore((state) => state.openCommandDialog);
    // Platform-aware shortcut (Mac: ⌘K, others: Ctrl+K)
    // navigator.userAgentData?.platform is modern; navigator.platform is the deprecated fallback
    const isMac = typeof navigator !== 'undefined' &&
        /Mac|iPhone|iPad/.test(navigator
            .userAgentData?.platform ?? navigator.platform);
    const shortcut = isMac ? '⌘K' : 'Ctrl+K';
    const handleClick = () => {
        openCommandDialog();
        onOpen?.(); // Call optional callback (e.g., to close parent dropdown)
    };
    return (_jsxs(Button, { variant: BUTTON_VARIANT.OUTLINE, display: display, icon: Search, onClick: handleClick, className: className, "aria-label": t('goTo.ariaLabel', 'Go to page'), children: [t('goTo.label', 'Go to'), _jsx("kbd", { style: {
                    marginInlineStart: 'var(--gap-sm)',
                    padding: '0.125rem 0.375rem',
                    fontSize: 'var(--font-size-xs)',
                    fontFamily: 'var(--font-mono)',
                    opacity: 0.5,
                }, children: shortcut })] }));
};
export default GoTo;
