import { __rest } from '../../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.mjs';
import { jsx, jsxs } from 'react/jsx-runtime';
import { globalLucideIcons } from '@windrun-huaiin/base-ui/components/server';
import { useState } from 'react';
import { cn } from '@windrun-huaiin/lib/utils';
import { Collapsible, CollapsibleTrigger, CollapsibleContent } from 'fumadocs-ui/components/ui/collapsible';
import Link from 'next/link';

const itemVariants = 'flex flex-row items-center gap-2 rounded-md px-2 py-1.5 text-sm hover:bg-fd-accent hover:text-fd-accent-foreground [&_svg]:size-4';
const anotionClass = 'ms-2 px-2 py-0.5 rounded text-xs font-semibold bg-fd-accent/80 text-fd-accent-foreground dark:bg-white/20 dark:text-white';
function ZiaFile(_a) {
    var { name, icon = jsx(globalLucideIcons.File, {}), className, anotion, href } = _a, rest = __rest(_a, ["name", "icon", "className", "anotion", "href"]);
    const validHref = typeof href === 'string' && href.trim() !== '';
    const validAnotion = typeof anotion === 'string' && anotion.trim() !== '';
    if (validHref) {
        return (jsxs(Link, { href: href, className: cn(itemVariants, className), children: [icon, jsx("span", { children: name }), validAnotion && jsx("span", { className: anotionClass, children: anotion })] }));
    }
    return (jsxs("div", Object.assign({ className: cn(itemVariants, className) }, rest, { children: [icon, jsx("span", { children: name }), validAnotion && jsx("span", { className: anotionClass, children: anotion })] })));
}
function ZiaFolder(_a) {
    var { name, anotion, defaultOpen = false, className, children } = _a, props = __rest(_a, ["name", "anotion", "defaultOpen", "className", "children"]);
    const [open, setOpen] = useState(defaultOpen);
    const validAnotion = typeof anotion === 'string' && anotion.trim() !== '';
    return (jsxs(Collapsible, Object.assign({ open: open, onOpenChange: setOpen }, props, { children: [jsxs(CollapsibleTrigger, { className: cn(itemVariants, className, 'w-full'), children: [open ? jsx(globalLucideIcons.FolderOpen, {}) : jsx(globalLucideIcons.Folder, {}), jsx("span", { children: name }), validAnotion && (jsx("span", { className: anotionClass, children: anotion }))] }), jsx(CollapsibleContent, { children: jsx("div", { className: "ms-2 flex flex-col border-l ps-2", children: children }) })] })));
}

export { ZiaFile, ZiaFolder };
