"use client";
'use strict';

var tslib_es6 = require('../../node_modules/.pnpm/@rollup_plugin-typescript@12.1.4_rollup@4.46.2_tslib@2.8.1_typescript@5.9.3/node_modules/tslib/tslib.es6.js');
var jsxRuntime = require('react/jsx-runtime');
var React = require('react');
var index = require('../../node_modules/.pnpm/class-variance-authority@0.7.1/node_modules/class-variance-authority/dist/index.js');
var Link = require('fumadocs-core/link');
var server = require('@windrun-huaiin/base-ui/components/server');
var shared = require('fumadocs-ui/layouts/shared');
var cn = require('fumadocs-ui/utils/cn');
var searchToggle = require('fumadocs-ui/components/layout/search-toggle');
var themeToggle = require('fumadocs-ui/components/layout/theme-toggle');
var languageToggle = require('fumadocs-ui/components/layout/language-toggle');
var navigationMenu = require('fumadocs-ui/components/ui/navigation-menu');
var popover = require('fumadocs-ui/components/ui/popover');
var button = require('fumadocs-ui/components/ui/button');
var layout = require('fumadocs-ui/contexts/layout');
var i18n = require('fumadocs-ui/contexts/i18n');

const DEFAULT_DESKTOP_ACTIONS = [
    'search',
    'theme',
    'i18n',
    'secondary',
];
const DEFAULT_MOBILE_BAR_ACTIONS = [
    'pinned',
    'search',
    'menu',
];
const DEFAULT_MOBILE_MENU_ACTIONS = [
    'secondary',
    'separator',
    'i18n',
    'theme',
];
function CustomHomeHeader({ nav = {}, i18n = false, links, githubUrl, themeSwitch = {}, searchToggle: searchToggle$1 = {}, bannerHeight = 0, headerHeight = 2.5, maxContentWidth = 1400, navbarClassName, floating = false, desktopActionsOrder = DEFAULT_DESKTOP_ACTIONS, mobileBarActionsOrder = DEFAULT_MOBILE_BAR_ACTIONS, mobileMenuActionsOrder = DEFAULT_MOBILE_MENU_ACTIONS, }) {
    var _a, _b, _c, _d, _e, _f, _g;
    const finalLinks = React.useMemo(() => shared.getLinks(links, githubUrl), [links, githubUrl]);
    const navItems = finalLinks.filter((item) => { var _a; return ['nav', 'all'].includes((_a = item.on) !== null && _a !== void 0 ? _a : 'all'); });
    const menuItems = finalLinks.filter((item) => { var _a; return ['menu', 'all'].includes((_a = item.on) !== null && _a !== void 0 ? _a : 'all'); });
    const mobilePinnedItems = navItems.filter((item) => isSecondary(item) && isMobilePinned(item));
    const filteredMenuItems = menuItems.filter((item) => !isMobilePinned(item));
    const primaryMenuItems = filteredMenuItems.filter((item) => !isSecondary(item));
    const secondaryMenuItems = filteredMenuItems.filter(isSecondary);
    const desktopSecondaryItems = navItems.filter(isSecondary);
    const desktopActionsIncludeGithub = desktopActionsOrder.includes('github');
    const githubDesktopItem = desktopActionsIncludeGithub
        ? desktopSecondaryItems.find((item) => isGithubItem(item, githubUrl))
        : undefined;
    const desktopSecondaryDisplayItems = desktopActionsIncludeGithub && githubDesktopItem
        ? desktopSecondaryItems.filter((item) => !isGithubItem(item, githubUrl))
        : desktopSecondaryItems;
    const desktopActionNodes = {
        search: searchToggle$1.enabled !== false
            ? (_b = (_a = searchToggle$1.components) === null || _a === void 0 ? void 0 : _a.lg) !== null && _b !== void 0 ? _b : (jsxRuntime.jsx(searchToggle.LargeSearchToggle, { className: "w-full rounded-full ps-2.5 max-w-[240px]", hideIfDisabled: true }))
            : null,
        theme: themeSwitch.enabled !== false
            ? (_c = themeSwitch.component) !== null && _c !== void 0 ? _c : jsxRuntime.jsx(themeToggle.ThemeToggle, { mode: themeSwitch === null || themeSwitch === void 0 ? void 0 : themeSwitch.mode })
            : null,
        i18n: i18n ? (jsxRuntime.jsx(CompactLanguageToggle, { children: jsxRuntime.jsx(server.globalLucideIcons.Languages, { className: "size-5" }) })) : null,
        secondary: desktopSecondaryDisplayItems.length ? (jsxRuntime.jsx("ul", { className: "flex flex-row gap-2 items-center empty:hidden", children: desktopSecondaryDisplayItems.map((item, i) => (jsxRuntime.jsx(NavbarLinkItem, { item: item, className: cn.cn(item.type === 'icon' && [
                    '-mx-1',
                    i === 0 && 'ms-0',
                    i === desktopSecondaryDisplayItems.length - 1 && 'me-0',
                ]) }, i))) })) : null,
        github: githubDesktopItem ? (jsxRuntime.jsx(NavbarLinkItem, { item: githubDesktopItem, className: cn.cn(githubDesktopItem.type === 'icon' && '-mx-1') })) : null,
    };
    const mobileMenuActionsIncludeGithub = mobileMenuActionsOrder.includes('github');
    const githubMobileMenuItem = mobileMenuActionsIncludeGithub
        ? secondaryMenuItems.find((item) => isGithubItem(item, githubUrl))
        : undefined;
    const secondaryMenuDisplayItems = mobileMenuActionsIncludeGithub && githubMobileMenuItem
        ? secondaryMenuItems.filter((item) => !isGithubItem(item, githubUrl))
        : secondaryMenuItems;
    const mobileMenuActionNodes = {
        secondary: secondaryMenuDisplayItems.length ? (jsxRuntime.jsx(jsxRuntime.Fragment, { children: secondaryMenuDisplayItems.map((item, i) => (jsxRuntime.jsx(MenuLinkItem, { item: item, className: "-me-1.5" }, i))) })) : null,
        github: githubMobileMenuItem ? (jsxRuntime.jsx(MenuLinkItem, { item: githubMobileMenuItem, className: "-me-1.5" })) : null,
        separator: jsxRuntime.jsx("div", { role: "separator", className: "flex-1" }),
        i18n: i18n ? (jsxRuntime.jsxs(CompactLanguageToggle, { children: [jsxRuntime.jsx(server.globalLucideIcons.Languages, { className: "size-5" }), jsxRuntime.jsx(languageToggle.LanguageToggleText, {}), jsxRuntime.jsx(server.globalLucideIcons.ChevronDown, { className: "size-3 text-fd-muted-foreground" })] })) : null,
        theme: themeSwitch.enabled !== false
            ? (_d = themeSwitch.component) !== null && _d !== void 0 ? _d : jsxRuntime.jsx(themeToggle.ThemeToggle, { mode: themeSwitch === null || themeSwitch === void 0 ? void 0 : themeSwitch.mode })
            : null,
    };
    const shouldRenderMobileUtilities = mobileMenuActionsOrder.some((action) => action !== 'separator' && Boolean(mobileMenuActionNodes[action]));
    const renderMobileMenuAction = (action) => {
        if (action === 'separator' && !shouldRenderMobileUtilities)
            return null;
        return mobileMenuActionNodes[action];
    };
    const menuNode = (jsxRuntime.jsxs(Menu, { children: [jsxRuntime.jsx(MenuTrigger, { "aria-label": "Toggle Menu", className: cn.cn(button.buttonVariants({
                    size: 'icon',
                    color: 'ghost',
                    className: 'group [&_svg]:size-5.5',
                })), enableHover: nav.enableHoverToOpen, children: jsxRuntime.jsx(server.globalLucideIcons.ChevronDown, { className: "transition-transform duration-300 group-data-[state=open]:rotate-180" }) }), jsxRuntime.jsxs(MenuContent, { className: "sm:flex-row sm:items-center sm:justify-end", children: [primaryMenuItems.map((item, i) => (jsxRuntime.jsx(MenuLinkItem, { item: item, className: "sm:hidden" }, i))), shouldRenderMobileUtilities ? (jsxRuntime.jsx("div", { className: "-ms-1.5 flex flex-row items-center gap-1.5 max-sm:mt-2", children: mobileMenuActionsOrder.map((action) => {
                            const node = renderMobileMenuAction(action);
                            if (!node)
                                return null;
                            return (jsxRuntime.jsx(React.Fragment, { children: node }, `mobile-menu-${action}`));
                        }) })) : null] })] }));
    const mobilePinnedNode = mobilePinnedItems.length > 0 ? (jsxRuntime.jsx(jsxRuntime.Fragment, { children: mobilePinnedItems.map((item, i) => (jsxRuntime.jsx(NavbarLinkItem, { item: item, className: "max-sm:-mr-1" }, `mobile-pinned-${i}`))) })) : null;
    const mobileSearchNode = searchToggle$1.enabled !== false
        ? (_f = (_e = searchToggle$1.components) === null || _e === void 0 ? void 0 : _e.sm) !== null && _f !== void 0 ? _f : (jsxRuntime.jsx(searchToggle.SearchToggle, { className: "p-2", hideIfDisabled: true }))
        : null;
    const mobileBarNodes = {
        pinned: mobilePinnedNode,
        search: mobileSearchNode,
        menu: menuNode,
    };
    const getMobileBarNode = (action) => { var _a; return (_a = mobileBarNodes[action]) !== null && _a !== void 0 ? _a : null; };
    return (jsxRuntime.jsxs(CustomNavbar, { bannerHeight: bannerHeight, headerHeight: headerHeight, maxContentWidth: maxContentWidth, className: navbarClassName, floating: floating, children: [jsxRuntime.jsx(Link, { href: (_g = nav.url) !== null && _g !== void 0 ? _g : '/', className: "inline-flex items-center gap-2.5 font-semibold", children: nav.title }), nav.children, jsxRuntime.jsx("ul", { className: "flex flex-row items-center gap-2 px-6 max-sm:hidden", children: navItems
                    .filter((item) => !isSecondary(item))
                    .map((item, i) => (jsxRuntime.jsx(NavbarLinkItem, { item: item, className: "text-sm" }, i))) }), jsxRuntime.jsx("div", { className: "flex flex-row items-center justify-end gap-1.5 flex-1 max-lg:hidden", children: desktopActionsOrder.map((action) => {
                    const node = desktopActionNodes[action];
                    if (!node)
                        return null;
                    return (jsxRuntime.jsx(React.Fragment, { children: node }, `desktop-${action}`));
                }) }), jsxRuntime.jsx("ul", { className: "flex flex-row items-center ms-auto -me-1.5 lg:hidden", children: mobileBarActionsOrder.map((action) => {
                    const node = getMobileBarNode(action);
                    return node ? (jsxRuntime.jsx(React.Fragment, { children: node }, `mobile-bar-${action}`)) : null;
                }) })] }));
}
function CustomNavbar(_a) {
    var { bannerHeight = 0, headerHeight = 2.5, maxContentWidth = 1400, className, style, floating = false } = _a, props = tslib_es6.__rest(_a, ["bannerHeight", "headerHeight", "maxContentWidth", "className", "style", "floating"]);
    const [value, setValue] = React.useState('');
    const { isTransparent } = layout.useNav();
    const cssVars = Object.assign({ '--fd-banner-height': `${bannerHeight}rem`, '--fd-nav-height': `${headerHeight}rem` }, (maxContentWidth
        ? {
            '--fd-nav-max-width': typeof maxContentWidth === 'number'
                ? `${maxContentWidth}px`
                : maxContentWidth,
        }
        : {}));
    const resolvedMaxWidth = maxContentWidth && maxContentWidth !== 0
        ? typeof maxContentWidth === 'number'
            ? `${maxContentWidth}px`
            : maxContentWidth
        : '88rem';
    const minNavWidth = '15rem';
    const floatingWidth = `clamp(${minNavWidth}, 100vw, ${resolvedMaxWidth})`;
    const widthStyle = floating
        ? { width: floatingWidth }
        : { width: '100%', maxWidth: resolvedMaxWidth, minWidth: minNavWidth };
    const headerStyle = Object.assign(Object.assign(Object.assign({}, cssVars), widthStyle), style);
    return (jsxRuntime.jsx(navigationMenu.NavigationMenu, { value: value, onValueChange: setValue, asChild: true, children: jsxRuntime.jsxs("header", Object.assign({}, props, { style: headerStyle, className: cn.cn('rounded-2xl border px-4 py-1 transition-[background-color,box-shadow,transform] duration-300 backdrop-blur-xl shadow-lg shadow-black/5', floating
                ? 'fixed left-1/2 top-[--fd-banner-height] z-1001 -translate-x-1/2'
                : 'relative mx-auto w-full', isTransparent
                ? 'border-transparent bg-transparent shadow-transparent'
                : 'border border-fd-border/60 bg-white/85 dark:border-white/20 dark:bg-neutral-900/75', value.length > 0 &&
                'max-lg:rounded-b-3xl border-fd-border/60 bg-white dark:border-white/20 dark:bg-neutral-900', className), children: [jsxRuntime.jsx(navigationMenu.NavigationMenuList, { className: "flex w-full items-center gap-4 px-1", style: { height: 'var(--fd-nav-height)' }, asChild: true, children: jsxRuntime.jsx("nav", { children: props.children }) }), jsxRuntime.jsx(navigationMenu.NavigationMenuViewport, {})] })) }));
}
const navItemVariants = index.cva('[&_svg]:size-4', {
    variants: {
        variant: {
            main: 'inline-flex items-center gap-1 p-2 text-fd-muted-foreground transition-colors hover:text-fd-accent-foreground data-[active=true]:text-fd-primary',
            button: button.buttonVariants({
                color: 'secondary',
                className: 'gap-1.5',
            }),
            icon: button.buttonVariants({
                color: 'ghost',
                size: 'icon',
            }),
        },
    },
    defaultVariants: {
        variant: 'main',
    },
});
function NavbarLinkItem(_a) {
    var { item } = _a, props = tslib_es6.__rest(_a, ["item"]);
    if (item.type === 'custom')
        return jsxRuntime.jsx("div", Object.assign({}, props, { children: item.children }));
    if (item.type === 'menu') {
        const children = item.items.map((child, j) => {
            var _a, _b;
            if (child.type === 'custom') {
                return jsxRuntime.jsx(React.Fragment, { children: child.children }, j);
            }
            const _c = (_a = child.menu) !== null && _a !== void 0 ? _a : {}, { banner = child.icon ? (jsxRuntime.jsx("div", { className: "w-fit rounded-md border bg-fd-muted p-1 [&_svg]:size-4", children: child.icon })) : null } = _c, rest = tslib_es6.__rest(_c, ["banner"]);
            return (jsxRuntime.jsx(navigationMenu.NavigationMenuLink, { asChild: true, children: jsxRuntime.jsx(Link, Object.assign({ href: child.url, external: child.external }, rest, { className: cn.cn('flex flex-col gap-2 rounded-lg border bg-fd-card p-3 transition-colors hover:bg-fd-accent/80 hover:text-fd-accent-foreground', rest.className), children: (_b = rest.children) !== null && _b !== void 0 ? _b : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [banner, jsxRuntime.jsx("p", { className: "text-[15px] font-medium", children: child.text }), jsxRuntime.jsx("p", { className: "text-sm text-fd-muted-foreground empty:hidden", children: child.description })] })) })) }, `${j}-${child.url}`));
        });
        return (jsxRuntime.jsxs(navigationMenu.NavigationMenuItem, { children: [jsxRuntime.jsx(navigationMenu.NavigationMenuTrigger, Object.assign({}, props, { className: cn.cn(navItemVariants(), 'rounded-md', props.className), children: item.url ? (jsxRuntime.jsx(Link, { href: item.url, external: item.external, children: item.text })) : (item.text) })), jsxRuntime.jsx(navigationMenu.NavigationMenuContent, { className: "grid grid-cols-1 gap-2 p-4 md:grid-cols-2 lg:grid-cols-3", children: children })] }));
    }
    return (jsxRuntime.jsx(navigationMenu.NavigationMenuItem, { children: jsxRuntime.jsx(navigationMenu.NavigationMenuLink, { asChild: true, children: jsxRuntime.jsx(shared.BaseLinkItem, Object.assign({ item: item, "aria-label": item.type === 'icon' ? item.label : undefined }, props, { className: cn.cn(navItemVariants({ variant: item.type }), props.className), children: item.type === 'icon' ? item.icon : item.text })) }) }));
}
const Menu = navigationMenu.NavigationMenuItem;
function MenuLinkItem(_a) {
    var _b;
    var { item } = _a, props = tslib_es6.__rest(_a, ["item"]);
    if (item.type === 'custom')
        return jsxRuntime.jsx("div", { className: cn.cn('grid', props.className), children: item.children });
    if (item.type === 'menu') {
        const header = (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [item.icon, item.text] }));
        return (jsxRuntime.jsxs("div", { className: cn.cn('mb-4 flex flex-col', props.className), children: [jsxRuntime.jsx("p", { className: "mb-1 text-sm text-fd-muted-foreground", children: item.url ? (jsxRuntime.jsx(navigationMenu.NavigationMenuLink, { asChild: true, children: jsxRuntime.jsx(Link, { href: item.url, external: item.external, children: header }) })) : (header) }), item.items.map((child, i) => (jsxRuntime.jsx(MenuLinkItem, { item: child }, i)))] }));
    }
    return (jsxRuntime.jsx(navigationMenu.NavigationMenuLink, { asChild: true, children: jsxRuntime.jsxs(shared.BaseLinkItem, { item: item, className: cn.cn({
                main: 'inline-flex items-center gap-2 py-1.5 transition-colors hover:text-fd-popover-foreground/50 data-[active=true]:font-medium data-[active=true]:text-fd-primary [&_svg]:size-4',
                icon: button.buttonVariants({
                    size: 'icon',
                    color: 'ghost',
                }),
                button: button.buttonVariants({
                    color: 'secondary',
                    className: 'gap-1.5 [&_svg]:size-4',
                }),
            }[(_b = item.type) !== null && _b !== void 0 ? _b : 'main'], props.className), "aria-label": item.type === 'icon' ? item.label : undefined, children: [item.icon, item.type === 'icon' ? undefined : item.text] }) }));
}
function MenuTrigger(_a) {
    var { enableHover = false } = _a, props = tslib_es6.__rest(_a, ["enableHover"]);
    return (jsxRuntime.jsx(navigationMenu.NavigationMenuTrigger, Object.assign({}, props, { onPointerMove: enableHover ? undefined : (e) => e.preventDefault(), children: props.children })));
}
function MenuContent(props) {
    return (jsxRuntime.jsx(navigationMenu.NavigationMenuContent, Object.assign({}, props, { className: cn.cn('flex flex-col p-4 w-full max-w-full min-w-0', props.className), style: Object.assign({ minWidth: 0, width: '100%', maxWidth: '100%' }, props.style), children: props.children })));
}
function CompactLanguageToggle(_a) {
    var { contentClassName } = _a, props = tslib_es6.__rest(_a, ["contentClassName"]);
    const context = i18n.useI18n();
    if (!context.locales)
        throw new Error('Missing `<I18nProvider />`');
    return (jsxRuntime.jsxs(popover.Popover, { children: [jsxRuntime.jsx(popover.PopoverTrigger, Object.assign({ "aria-label": context.text.chooseLanguage }, props, { className: cn.cn(button.buttonVariants({
                    color: 'ghost',
                    className: 'gap-1.5 py-1.5 px-1',
                }), props.className), children: props.children })), jsxRuntime.jsxs(popover.PopoverContent, { className: cn.cn('flex min-w-[150px] z-1001 flex-col overflow-x-hidden rounded-xl border bg-fd-popover/60 p-0 text-fd-popover-foreground backdrop-blur-lg', contentClassName), children: [jsxRuntime.jsx("p", { className: "mb-1 p-2 text-xs font-medium text-fd-muted-foreground", children: context.text.chooseLanguage }), context.locales.map((item) => (jsxRuntime.jsx("button", { type: "button", className: cn.cn('p-2 text-start text-sm', item.locale === context.locale
                            ? 'bg-fd-primary/10 font-medium text-fd-primary'
                            : 'hover:bg-fd-accent hover:text-fd-accent-foreground'), onClick: () => {
                            var _a;
                            (_a = context.onChange) === null || _a === void 0 ? void 0 : _a.call(context, item.locale);
                        }, children: item.name }, item.locale)))] })] }));
}
function isGithubItem(item, githubUrl) {
    return Boolean(githubUrl && item.type === 'icon' && item.url === githubUrl);
}
function isSecondary(item) {
    if ('secondary' in item && item.secondary != null)
        return item.secondary;
    return item.type === 'icon';
}
function isMobilePinned(item) {
    return Boolean(item.mobilePinned);
}

exports.CustomHomeHeader = CustomHomeHeader;
