'use client';
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { MagnifyingGlass, CheckCircle, XCircle, FilePlus, FolderPlus, Note, File, PaperPlaneTilt, CheckSquare, Warning, Trash, TestTube, ArrowSquareOut, Clock } from '@phosphor-icons/react';
import { MethodBadge } from '../../shared/method-badge';
import { getFileType } from '@/lib/api-docs/code-editor';
export function ToolCallDisplay({ tool, onNavigate, onNavigateToDocPage, onOpenFile }) {
    const { toolName, args, result, state } = tool;
    // Helper to render clickable file name
    const ClickableFileName = ({ path, className = '' })=>{
        if (!path) return /*#__PURE__*/ _jsx("span", {
            className: "font-mono text-muted-foreground",
            children: "unknown"
        });
        const fileName = path.split('/').pop() || path;
        return /*#__PURE__*/ _jsx("button", {
            onClick: ()=>onOpenFile?.(path),
            className: `font-mono font-medium text-foreground hover:text-primary hover:underline cursor-pointer transition-colors ${className}`,
            children: fileName
        });
    };
    // Helper to handle search result click
    const handleResultClick = (item)=>{
        if (item.type === 'endpoint') {
            onNavigate?.(item.id);
        } else if (item.type === 'doc') {
            onNavigateToDocPage?.(item.id);
        } else if (item.type === 'changelog') {
            onNavigateToDocPage?.(`changelog/${item.id}`);
        }
    };
    // Loading state - with subtle background
    if (state === 'pending') {
        return /*#__PURE__*/ _jsxs("div", {
            className: "flex items-center gap-2 text-xs py-1.5 px-2.5 rounded-md bg-muted/50 border border-border/50",
            children: [
                /*#__PURE__*/ _jsx("div", {
                    className: "size-3.5 rounded-full border-2 border-primary/30 border-t-primary animate-spin"
                }),
                /*#__PURE__*/ _jsxs("span", {
                    className: "text-muted-foreground",
                    children: [
                        toolName === 'search' && 'Searching...',
                        toolName === 'navigate' && 'Navigating...',
                        toolName === 'search_endpoints' && 'Searching...',
                        toolName === 'navigate_to_endpoint' && 'Navigating...',
                        toolName === 'prefill_parameters' && 'Setting params...',
                        toolName === 'get_endpoint_details' && 'Loading details...',
                        toolName === 'check_request_validity' && 'Validating request...',
                        toolName === 'send_request' && /*#__PURE__*/ _jsxs("span", {
                            className: "flex items-center gap-1.5",
                            children: [
                                /*#__PURE__*/ _jsx(PaperPlaneTilt, {
                                    className: "size-3.5 text-blue-500 animate-pulse",
                                    weight: "fill"
                                }),
                                "Sending request..."
                            ]
                        }),
                        toolName === 'switch_to_notes' && 'Opening Notes...',
                        toolName === 'switch_to_docs' && 'Opening Docs...',
                        toolName === 'switch_to_api_client' && 'Opening API Client...',
                        toolName === 'navigate_to_doc_section' && 'Navigating to section...',
                        toolName === 'navigate_to_doc_page' && 'Navigating to page...',
                        toolName === 'search_docs' && 'Searching documentation...',
                        toolName === 'scroll_to_section' && 'Scrolling to section...',
                        toolName === 'list_notes' && 'Checking existing files...',
                        toolName === 'open_file' && `Opening ${args.path?.split('/').pop() || 'file'}...`,
                        toolName === 'create_folder' && `Creating folder ${args.path || ''}...`,
                        toolName === 'create_file' && `Creating ${args.path?.split('/').pop() || 'file'}...`,
                        toolName === 'write_file' && `Writing ${args.path?.split('/').pop() || 'file'}...`,
                        toolName === 'delete_file' && `Deleting ${args.path?.split('/').pop() || 'file'}...`,
                        toolName === 'delete_all_notes' && 'Deleting all notes...'
                    ]
                })
            ]
        });
    }
    // Error state
    if (state === 'error') {
        return /*#__PURE__*/ _jsxs("div", {
            className: "flex items-center gap-2 text-xs py-1.5 px-2.5 rounded-md bg-destructive/10 border border-destructive/20",
            children: [
                /*#__PURE__*/ _jsx(XCircle, {
                    className: "size-3.5 text-destructive",
                    weight: "fill"
                }),
                /*#__PURE__*/ _jsx("span", {
                    className: "text-destructive",
                    children: "Failed"
                })
            ]
        });
    }
    // === UNIFIED TOOLS ===
    // Unified search
    if (toolName === 'search') {
        const resultData = result;
        const results = resultData?.results || [];
        if (results.length === 0) {
            return /*#__PURE__*/ _jsxs("div", {
                className: "flex items-center gap-2 text-xs py-1.5 px-2.5 rounded-md bg-muted/50 border border-border/50",
                children: [
                    /*#__PURE__*/ _jsx(MagnifyingGlass, {
                        className: "size-3.5 text-muted-foreground",
                        weight: "bold"
                    }),
                    /*#__PURE__*/ _jsx("span", {
                        className: "text-muted-foreground",
                        children: "No results found"
                    })
                ]
            });
        }
        if (results.length === 1) {
            const item = results[0];
            return /*#__PURE__*/ _jsxs("button", {
                onClick: ()=>handleResultClick(item),
                className: "flex items-center gap-2 text-xs py-1.5 px-2.5 rounded-md bg-muted/50 border border-border/50 hover:bg-muted/80 hover:border-border transition-colors cursor-pointer w-full text-left",
                children: [
                    /*#__PURE__*/ _jsx(CheckCircle, {
                        className: "size-3.5 text-green-600 dark:text-green-500",
                        weight: "fill"
                    }),
                    /*#__PURE__*/ _jsx("span", {
                        className: "text-muted-foreground",
                        children: "Found"
                    }),
                    item.method && /*#__PURE__*/ _jsx(MethodBadge, {
                        method: item.method,
                        size: "sm"
                    }),
                    /*#__PURE__*/ _jsx("span", {
                        className: "font-medium truncate",
                        children: item.title
                    })
                ]
            });
        }
        return /*#__PURE__*/ _jsxs("div", {
            className: "py-1.5 px-2.5 rounded-md bg-muted/50 border border-border/50",
            children: [
                /*#__PURE__*/ _jsxs("div", {
                    className: "flex items-center gap-2 text-xs text-muted-foreground mb-1.5",
                    children: [
                        /*#__PURE__*/ _jsx(MagnifyingGlass, {
                            className: "size-3.5",
                            weight: "bold"
                        }),
                        /*#__PURE__*/ _jsxs("span", {
                            children: [
                                "Found ",
                                results.length,
                                " results"
                            ]
                        })
                    ]
                }),
                /*#__PURE__*/ _jsxs("div", {
                    className: "space-y-0.5 ml-5",
                    children: [
                        results.slice(0, 4).map((item, i)=>/*#__PURE__*/ _jsxs("button", {
                                onClick: ()=>handleResultClick(item),
                                className: "flex items-center gap-1.5 text-xs py-1 px-1.5 -ml-1.5 rounded text-muted-foreground hover:bg-muted/80 transition-colors cursor-pointer w-full text-left",
                                children: [
                                    item.type === 'endpoint' && item.method && /*#__PURE__*/ _jsx(MethodBadge, {
                                        method: item.method,
                                        size: "sm"
                                    }),
                                    item.type === 'doc' && /*#__PURE__*/ _jsx(File, {
                                        className: "size-3 text-purple-500",
                                        weight: "fill"
                                    }),
                                    item.type === 'changelog' && /*#__PURE__*/ _jsx(Clock, {
                                        className: "size-3 text-orange-500",
                                        weight: "fill"
                                    }),
                                    /*#__PURE__*/ _jsx("span", {
                                        className: "truncate font-medium text-foreground",
                                        children: item.title
                                    }),
                                    item.group && /*#__PURE__*/ _jsxs("span", {
                                        className: "text-muted-foreground/60 text-[10px]",
                                        children: [
                                            "(",
                                            item.group,
                                            ")"
                                        ]
                                    })
                                ]
                            }, i)),
                        results.length > 4 && /*#__PURE__*/ _jsxs("span", {
                            className: "text-[11px] text-muted-foreground",
                            children: [
                                "+",
                                results.length - 4,
                                " more"
                            ]
                        })
                    ]
                })
            ]
        });
    }
    // Unified navigate
    if (toolName === 'navigate') {
        const resultData = result;
        if (!resultData?.success) {
            return /*#__PURE__*/ _jsxs("div", {
                className: "flex items-center gap-2 text-xs py-1.5 px-2.5 rounded-md bg-muted/50 border border-border/50",
                children: [
                    /*#__PURE__*/ _jsx(XCircle, {
                        className: "size-3.5 text-muted-foreground"
                    }),
                    /*#__PURE__*/ _jsx("span", {
                        className: "text-muted-foreground",
                        children: resultData?.message || 'Navigation failed'
                    })
                ]
            });
        }
        return /*#__PURE__*/ _jsxs("div", {
            className: "flex items-center gap-2 text-xs py-1.5 px-2.5 rounded-md bg-muted/50 border border-border/50",
            children: [
                /*#__PURE__*/ _jsx(CheckCircle, {
                    className: "size-3.5 text-green-600 dark:text-green-500",
                    weight: "fill"
                }),
                /*#__PURE__*/ _jsx("span", {
                    className: "text-muted-foreground",
                    children: "Opened"
                }),
                resultData.method && /*#__PURE__*/ _jsx(MethodBadge, {
                    method: resultData.method,
                    size: "sm"
                }),
                resultData.type === 'changelog' && /*#__PURE__*/ _jsx(Clock, {
                    className: "size-3 text-orange-500",
                    weight: "fill"
                }),
                resultData.type === 'doc' && /*#__PURE__*/ _jsx(File, {
                    className: "size-3 text-purple-500",
                    weight: "fill"
                }),
                /*#__PURE__*/ _jsx("span", {
                    className: "font-medium truncate",
                    children: resultData.title
                })
            ]
        });
    }
    // Navigate to endpoint
    if (toolName === 'navigate_to_endpoint') {
        const resultData = result;
        const endpoint = resultData?.endpoint;
        if (!endpoint) return null;
        return /*#__PURE__*/ _jsxs("div", {
            className: "flex items-center gap-2 text-xs py-1.5 px-2.5 rounded-md bg-muted/50 border border-border/50",
            children: [
                /*#__PURE__*/ _jsx(CheckCircle, {
                    className: "size-3.5 text-green-600 dark:text-green-500",
                    weight: "fill"
                }),
                /*#__PURE__*/ _jsx("span", {
                    className: "text-muted-foreground",
                    children: "Opened"
                }),
                /*#__PURE__*/ _jsx(MethodBadge, {
                    method: endpoint.method,
                    size: "sm"
                }),
                /*#__PURE__*/ _jsx("span", {
                    className: "font-medium truncate",
                    children: endpoint.name
                })
            ]
        });
    }
    // Prefill parameters
    if (toolName === 'prefill_parameters') {
        const prefillData = result || args;
        const items = [];
        if (prefillData.pathVariables?.length) items.push(`${prefillData.pathVariables.length} path vars`);
        if (prefillData.params?.length) items.push(`${prefillData.params.length} params`);
        if (prefillData.headers?.length) items.push(`${prefillData.headers.length} headers`);
        if (prefillData.body) items.push('body');
        return /*#__PURE__*/ _jsxs("div", {
            className: "flex items-center gap-2 text-xs py-1.5 px-2.5 rounded-md bg-muted/50 border border-border/50",
            children: [
                /*#__PURE__*/ _jsx(CheckCircle, {
                    className: "size-3.5 text-green-600 dark:text-green-500",
                    weight: "fill"
                }),
                /*#__PURE__*/ _jsxs("span", {
                    className: "text-muted-foreground",
                    children: [
                        "Set ",
                        items.join(', ')
                    ]
                })
            ]
        });
    }
    // Search endpoints
    if (toolName === 'search_endpoints') {
        const results = result;
        if (!results || results.length === 0) return null;
        if (results.length === 1) {
            return /*#__PURE__*/ _jsxs("div", {
                className: "flex items-center gap-2 text-xs py-1.5 px-2.5 rounded-md bg-muted/50 border border-border/50",
                children: [
                    /*#__PURE__*/ _jsx(CheckCircle, {
                        className: "size-3.5 text-green-600 dark:text-green-500",
                        weight: "fill"
                    }),
                    /*#__PURE__*/ _jsx("span", {
                        className: "text-muted-foreground",
                        children: "Found"
                    }),
                    /*#__PURE__*/ _jsx(MethodBadge, {
                        method: results[0].method,
                        size: "sm"
                    }),
                    /*#__PURE__*/ _jsx("button", {
                        onClick: ()=>onNavigate?.(results[0].id),
                        className: "font-medium truncate hover:underline",
                        children: results[0].name
                    })
                ]
            });
        }
        return /*#__PURE__*/ _jsxs("div", {
            className: "py-1.5 px-2.5 rounded-md bg-muted/50 border border-border/50",
            children: [
                /*#__PURE__*/ _jsxs("div", {
                    className: "flex items-center gap-2 text-xs text-muted-foreground mb-1.5",
                    children: [
                        /*#__PURE__*/ _jsx(MagnifyingGlass, {
                            className: "size-3.5",
                            weight: "bold"
                        }),
                        /*#__PURE__*/ _jsxs("span", {
                            children: [
                                "Found ",
                                results.length,
                                " endpoints"
                            ]
                        })
                    ]
                }),
                /*#__PURE__*/ _jsxs("div", {
                    className: "space-y-0.5 ml-5",
                    children: [
                        results.slice(0, 4).map((ep)=>/*#__PURE__*/ _jsxs("button", {
                                onClick: ()=>onNavigate?.(ep.id),
                                className: "flex items-center gap-1.5 text-xs py-0.5 hover:text-foreground transition-colors text-muted-foreground",
                                children: [
                                    /*#__PURE__*/ _jsx(MethodBadge, {
                                        method: ep.method,
                                        size: "sm"
                                    }),
                                    /*#__PURE__*/ _jsx("span", {
                                        className: "truncate",
                                        children: ep.name
                                    })
                                ]
                            }, ep.id)),
                        results.length > 4 && /*#__PURE__*/ _jsxs("span", {
                            className: "text-[11px] text-muted-foreground",
                            children: [
                                "+",
                                results.length - 4,
                                " more"
                            ]
                        })
                    ]
                })
            ]
        });
    }
    // Get endpoint details
    if (toolName === 'get_endpoint_details') {
        const endpoint = result;
        if (!endpoint) return null;
        return /*#__PURE__*/ _jsxs("div", {
            className: "py-1.5 px-2.5 rounded-md bg-muted/50 border border-border/50",
            children: [
                /*#__PURE__*/ _jsxs("div", {
                    className: "flex items-center gap-2 text-xs",
                    children: [
                        /*#__PURE__*/ _jsx(MethodBadge, {
                            method: endpoint.method || 'GET',
                            size: "sm"
                        }),
                        /*#__PURE__*/ _jsx("span", {
                            className: "font-medium",
                            children: endpoint.name
                        })
                    ]
                }),
                /*#__PURE__*/ _jsx("code", {
                    className: "text-[11px] text-muted-foreground block truncate mt-0.5",
                    children: endpoint.path
                })
            ]
        });
    }
    // Switch to notes
    if (toolName === 'switch_to_notes') {
        return /*#__PURE__*/ _jsxs("div", {
            className: "flex items-center gap-2 text-xs py-1.5 px-2.5 rounded-md bg-muted/50 border border-border/50",
            children: [
                /*#__PURE__*/ _jsx(Note, {
                    className: "size-3.5 text-green-600 dark:text-green-500",
                    weight: "fill"
                }),
                /*#__PURE__*/ _jsx("span", {
                    className: "text-muted-foreground",
                    children: "Opened Notes workspace"
                })
            ]
        });
    }
    // Switch to docs
    if (toolName === 'switch_to_docs') {
        return /*#__PURE__*/ _jsxs("div", {
            className: "flex items-center gap-2 text-xs py-1.5 px-2.5 rounded-md bg-muted/50 border border-border/50",
            children: [
                /*#__PURE__*/ _jsx(File, {
                    className: "size-3.5 text-purple-600 dark:text-purple-500",
                    weight: "fill"
                }),
                /*#__PURE__*/ _jsx("span", {
                    className: "text-muted-foreground",
                    children: "Opened Docs"
                })
            ]
        });
    }
    // Switch to API client
    if (toolName === 'switch_to_api_client') {
        return /*#__PURE__*/ _jsxs("div", {
            className: "flex items-center gap-2 text-xs py-1.5 px-2.5 rounded-md bg-muted/50 border border-border/50",
            children: [
                /*#__PURE__*/ _jsx(TestTube, {
                    className: "size-3.5 text-blue-600 dark:text-blue-500",
                    weight: "fill"
                }),
                /*#__PURE__*/ _jsx("span", {
                    className: "text-muted-foreground",
                    children: "Opened API Client"
                })
            ]
        });
    }
    // Navigate to documentation section
    if (toolName === 'navigate_to_doc_section') {
        const sectionName = args.sectionName || 'section';
        return /*#__PURE__*/ _jsxs("div", {
            className: "flex items-center gap-2 text-xs py-1.5 px-2.5 rounded-md bg-muted/50 border border-border/50",
            children: [
                /*#__PURE__*/ _jsx(ArrowSquareOut, {
                    className: "size-3.5 text-purple-600 dark:text-purple-500",
                    weight: "fill"
                }),
                /*#__PURE__*/ _jsxs("span", {
                    className: "text-muted-foreground",
                    children: [
                        "Navigated to ",
                        /*#__PURE__*/ _jsx("span", {
                            className: "font-medium text-foreground",
                            children: sectionName
                        })
                    ]
                })
            ]
        });
    }
    // Navigate to documentation page
    if (toolName === 'navigate_to_doc_page') {
        const resultData = result;
        const title = args.title || resultData?.title || 'page';
        return /*#__PURE__*/ _jsxs("div", {
            className: "flex items-center gap-2 text-xs py-1.5 px-2.5 rounded-md bg-muted/50 border border-border/50",
            children: [
                /*#__PURE__*/ _jsx(File, {
                    className: "size-3.5 text-purple-600 dark:text-purple-500",
                    weight: "fill"
                }),
                /*#__PURE__*/ _jsxs("span", {
                    className: "text-muted-foreground",
                    children: [
                        "Opened ",
                        /*#__PURE__*/ _jsx("span", {
                            className: "font-medium text-foreground",
                            children: title
                        })
                    ]
                })
            ]
        });
    }
    // Search documentation pages
    if (toolName === 'search_docs') {
        const resultData = result;
        const results = resultData?.results || [];
        if (results.length === 0) {
            return /*#__PURE__*/ _jsxs("div", {
                className: "flex items-center gap-2 text-xs py-1.5 px-2.5 rounded-md bg-muted/50 border border-border/50",
                children: [
                    /*#__PURE__*/ _jsx(MagnifyingGlass, {
                        className: "size-3.5 text-muted-foreground",
                        weight: "bold"
                    }),
                    /*#__PURE__*/ _jsx("span", {
                        className: "text-muted-foreground",
                        children: "No documentation pages found"
                    })
                ]
            });
        }
        if (results.length === 1) {
            return /*#__PURE__*/ _jsxs("div", {
                className: "flex items-center gap-2 text-xs py-1.5 px-2.5 rounded-md bg-muted/50 border border-border/50",
                children: [
                    /*#__PURE__*/ _jsx(CheckCircle, {
                        className: "size-3.5 text-green-600 dark:text-green-500",
                        weight: "fill"
                    }),
                    /*#__PURE__*/ _jsx("span", {
                        className: "text-muted-foreground",
                        children: "Found"
                    }),
                    /*#__PURE__*/ _jsx("span", {
                        className: "font-medium truncate",
                        children: results[0].title
                    }),
                    /*#__PURE__*/ _jsxs("span", {
                        className: "text-muted-foreground/60",
                        children: [
                            "in ",
                            results[0].group
                        ]
                    })
                ]
            });
        }
        return /*#__PURE__*/ _jsxs("div", {
            className: "py-1.5 px-2.5 rounded-md bg-muted/50 border border-border/50",
            children: [
                /*#__PURE__*/ _jsxs("div", {
                    className: "flex items-center gap-2 text-xs text-muted-foreground mb-1.5",
                    children: [
                        /*#__PURE__*/ _jsx(MagnifyingGlass, {
                            className: "size-3.5",
                            weight: "bold"
                        }),
                        /*#__PURE__*/ _jsxs("span", {
                            children: [
                                "Found ",
                                results.length,
                                " documentation pages"
                            ]
                        })
                    ]
                }),
                /*#__PURE__*/ _jsxs("div", {
                    className: "space-y-0.5 ml-5",
                    children: [
                        results.slice(0, 4).map((doc, i)=>/*#__PURE__*/ _jsxs("div", {
                                className: "flex items-center gap-1.5 text-xs py-0.5 text-muted-foreground",
                                children: [
                                    /*#__PURE__*/ _jsx(File, {
                                        className: "size-3 text-purple-500",
                                        weight: "fill"
                                    }),
                                    /*#__PURE__*/ _jsx("span", {
                                        className: "truncate font-medium text-foreground",
                                        children: doc.title
                                    }),
                                    /*#__PURE__*/ _jsxs("span", {
                                        className: "text-muted-foreground/60 text-[10px]",
                                        children: [
                                            "(",
                                            doc.group,
                                            ")"
                                        ]
                                    })
                                ]
                            }, i)),
                        results.length > 4 && /*#__PURE__*/ _jsxs("span", {
                            className: "text-[11px] text-muted-foreground",
                            children: [
                                "+",
                                results.length - 4,
                                " more"
                            ]
                        })
                    ]
                })
            ]
        });
    }
    // Scroll to section within page
    if (toolName === 'scroll_to_section') {
        const resultData = result;
        if (!resultData?.success) {
            return /*#__PURE__*/ _jsxs("div", {
                className: "flex items-center gap-2 text-xs py-1.5 px-2.5 rounded-md bg-muted/50 border border-border/50",
                children: [
                    /*#__PURE__*/ _jsx(MagnifyingGlass, {
                        className: "size-3.5 text-muted-foreground",
                        weight: "bold"
                    }),
                    /*#__PURE__*/ _jsx("span", {
                        className: "text-muted-foreground",
                        children: resultData?.message || 'Section not found'
                    })
                ]
            });
        }
        return /*#__PURE__*/ _jsxs("div", {
            className: "flex items-center gap-2 text-xs py-1.5 px-2.5 rounded-md bg-muted/50 border border-border/50",
            children: [
                /*#__PURE__*/ _jsx(ArrowSquareOut, {
                    className: "size-3.5 text-yellow-600 dark:text-yellow-500",
                    weight: "fill"
                }),
                /*#__PURE__*/ _jsxs("span", {
                    className: "text-muted-foreground",
                    children: [
                        "Scrolled to ",
                        /*#__PURE__*/ _jsx("span", {
                            className: "font-medium text-foreground",
                            children: resultData.heading
                        })
                    ]
                })
            ]
        });
    }
    // List notes (check for existing files)
    if (toolName === 'list_notes') {
        const resultData = result;
        const count = resultData?.count ?? 0;
        const files = resultData?.files ?? [];
        // File type color mapping - matches notes-mode.tsx colors exactly
        const getFileColor = (path)=>{
            const type = getFileType(path);
            const colorMap = {
                'javascript': 'text-yellow-400',
                'typescript': 'text-blue-400',
                'python': 'text-green-500',
                'go': 'text-cyan-400',
                'ruby': 'text-red-400',
                'php': 'text-purple-400',
                'shell': 'text-green-400',
                'markdown': 'text-blue-300',
                'mermaid': 'text-pink-400',
                'json': 'text-yellow-500',
                'yaml': 'text-red-300',
                'text': 'text-zinc-400'
            };
            return colorMap[type] || 'text-zinc-400';
        };
        return /*#__PURE__*/ _jsxs("div", {
            className: "text-xs py-2 px-2.5 rounded-md bg-muted/50 border border-border/50",
            children: [
                /*#__PURE__*/ _jsxs("div", {
                    className: "flex items-center gap-2 mb-1.5",
                    children: [
                        /*#__PURE__*/ _jsx(MagnifyingGlass, {
                            className: "size-3.5 text-violet-600 dark:text-violet-500 flex-shrink-0",
                            weight: "fill"
                        }),
                        /*#__PURE__*/ _jsx("span", {
                            className: "text-muted-foreground",
                            children: count > 0 ? `Found ${count} existing file${count !== 1 ? 's' : ''}` : 'No existing files found'
                        })
                    ]
                }),
                count > 0 && files.length > 0 && /*#__PURE__*/ _jsxs("div", {
                    className: "ml-5 space-y-1",
                    children: [
                        files.slice(0, 5).map((f, i)=>{
                            const fileName = f.path.split('/').pop() || f.path;
                            const folder = f.path.includes('/') ? f.path.split('/').slice(0, -1).join('/') + '/' : '';
                            return /*#__PURE__*/ _jsxs("button", {
                                onClick: ()=>onOpenFile?.(f.path),
                                className: "flex items-center gap-1.5 hover:bg-muted/50 rounded px-1 -mx-1 py-0.5 transition-colors text-left w-full",
                                children: [
                                    /*#__PURE__*/ _jsx(File, {
                                        className: `size-3.5 ${getFileColor(f.path)} flex-shrink-0`,
                                        weight: "fill"
                                    }),
                                    folder && /*#__PURE__*/ _jsx("span", {
                                        className: "text-muted-foreground/60",
                                        children: folder
                                    }),
                                    /*#__PURE__*/ _jsx("span", {
                                        className: "font-mono text-foreground/80 hover:text-primary transition-colors",
                                        children: fileName
                                    })
                                ]
                            }, i);
                        }),
                        files.length > 5 && /*#__PURE__*/ _jsxs("div", {
                            className: "text-muted-foreground/60 italic pl-5",
                            children: [
                                "...and ",
                                files.length - 5,
                                " more"
                            ]
                        })
                    ]
                })
            ]
        });
    }
    // Open existing file
    if (toolName === 'open_file') {
        const path = args.path;
        return /*#__PURE__*/ _jsxs("div", {
            className: "flex items-center gap-2 text-xs py-1.5 px-2.5 rounded-md bg-muted/50 border border-border/50",
            children: [
                /*#__PURE__*/ _jsx(File, {
                    className: "size-3.5 text-blue-600 dark:text-blue-500",
                    weight: "fill"
                }),
                /*#__PURE__*/ _jsx("span", {
                    className: "text-muted-foreground",
                    children: "Opened "
                }),
                /*#__PURE__*/ _jsx(ClickableFileName, {
                    path: path
                })
            ]
        });
    }
    // Create folder
    if (toolName === 'create_folder') {
        const resultData = result;
        const path = args.path || resultData?.path;
        const description = args.description || resultData?.description;
        return /*#__PURE__*/ _jsxs("div", {
            className: "flex items-start gap-2 text-xs py-1.5 px-2.5 rounded-md bg-muted/50 border border-border/50",
            children: [
                /*#__PURE__*/ _jsx(FolderPlus, {
                    className: "size-3.5 text-amber-600 dark:text-amber-500 mt-0.5 flex-shrink-0",
                    weight: "fill"
                }),
                /*#__PURE__*/ _jsxs("div", {
                    children: [
                        /*#__PURE__*/ _jsx("span", {
                            className: "text-muted-foreground",
                            children: "Created folder "
                        }),
                        /*#__PURE__*/ _jsx("span", {
                            className: "font-mono font-medium text-foreground",
                            children: path
                        }),
                        description && /*#__PURE__*/ _jsx("p", {
                            className: "text-muted-foreground mt-0.5",
                            children: description
                        })
                    ]
                })
            ]
        });
    }
    // Create file (empty)
    if (toolName === 'create_file') {
        const resultData = result;
        const path = args.path || resultData?.path;
        const description = args.description || resultData?.description;
        return /*#__PURE__*/ _jsxs("div", {
            className: "flex items-start gap-2 text-xs py-1.5 px-2.5 rounded-md bg-muted/50 border border-border/50",
            children: [
                /*#__PURE__*/ _jsx(FilePlus, {
                    className: "size-3.5 text-blue-600 dark:text-blue-500 mt-0.5 flex-shrink-0",
                    weight: "fill"
                }),
                /*#__PURE__*/ _jsxs("div", {
                    children: [
                        /*#__PURE__*/ _jsx("span", {
                            className: "text-muted-foreground",
                            children: "Created "
                        }),
                        /*#__PURE__*/ _jsx(ClickableFileName, {
                            path: path
                        }),
                        description && /*#__PURE__*/ _jsx("p", {
                            className: "text-muted-foreground mt-0.5",
                            children: description
                        })
                    ]
                })
            ]
        });
    }
    // Write file (content)
    if (toolName === 'write_file') {
        const resultData = result;
        const path = args.path || resultData?.path;
        return /*#__PURE__*/ _jsxs("div", {
            className: "flex items-center gap-2 text-xs py-1.5 px-2.5 rounded-md bg-muted/50 border border-border/50",
            children: [
                /*#__PURE__*/ _jsx(CheckCircle, {
                    className: "size-3.5 text-green-600 dark:text-green-500",
                    weight: "fill"
                }),
                /*#__PURE__*/ _jsx("span", {
                    className: "text-muted-foreground",
                    children: "Wrote "
                }),
                /*#__PURE__*/ _jsx(ClickableFileName, {
                    path: path
                })
            ]
        });
    }
    // Delete file
    if (toolName === 'delete_file') {
        const resultData = result;
        const path = args.path || resultData?.path;
        const reason = args.reason || resultData?.reason;
        const fileName = path?.split('/').pop() || path;
        if (resultData?.error) {
            return /*#__PURE__*/ _jsxs("div", {
                className: "flex items-center gap-2 text-xs py-1.5 px-2.5 rounded-md bg-destructive/10 border border-destructive/20",
                children: [
                    /*#__PURE__*/ _jsx(XCircle, {
                        className: "size-3.5 text-destructive",
                        weight: "fill"
                    }),
                    /*#__PURE__*/ _jsxs("span", {
                        className: "text-destructive",
                        children: [
                            "Failed to delete: ",
                            resultData.error
                        ]
                    })
                ]
            });
        }
        return /*#__PURE__*/ _jsxs("div", {
            className: "flex items-start gap-2 text-xs py-1.5 px-2.5 rounded-md bg-muted/50 border border-border/50",
            children: [
                /*#__PURE__*/ _jsx(Trash, {
                    className: "size-3.5 text-red-600 dark:text-red-500 mt-0.5 flex-shrink-0",
                    weight: "fill"
                }),
                /*#__PURE__*/ _jsxs("div", {
                    children: [
                        /*#__PURE__*/ _jsx("span", {
                            className: "text-muted-foreground",
                            children: "Deleted "
                        }),
                        /*#__PURE__*/ _jsx("span", {
                            className: "font-mono font-medium text-foreground",
                            children: fileName
                        }),
                        reason && /*#__PURE__*/ _jsx("p", {
                            className: "text-muted-foreground mt-0.5",
                            children: reason
                        })
                    ]
                })
            ]
        });
    }
    // Delete all notes
    if (toolName === 'delete_all_notes') {
        const resultData = result;
        if (resultData?.error) {
            return /*#__PURE__*/ _jsxs("div", {
                className: "flex items-center gap-2 text-xs py-1.5 px-2.5 rounded-md bg-destructive/10 border border-destructive/20",
                children: [
                    /*#__PURE__*/ _jsx(XCircle, {
                        className: "size-3.5 text-destructive",
                        weight: "fill"
                    }),
                    /*#__PURE__*/ _jsx("span", {
                        className: "text-destructive",
                        children: resultData.error
                    })
                ]
            });
        }
        const count = resultData?.deletedCount ?? 0;
        const files = resultData?.files ?? [];
        // File type color mapping - matches notes-mode.tsx colors exactly
        const getFileColor = (path)=>{
            const type = getFileType(path);
            const colorMap = {
                'javascript': 'text-yellow-400',
                'typescript': 'text-blue-400',
                'python': 'text-green-500',
                'go': 'text-cyan-400',
                'ruby': 'text-red-400',
                'php': 'text-purple-400',
                'shell': 'text-green-400',
                'markdown': 'text-blue-300',
                'mermaid': 'text-pink-400',
                'json': 'text-yellow-500',
                'yaml': 'text-red-300',
                'text': 'text-zinc-400'
            };
            return colorMap[type] || 'text-zinc-400';
        };
        if (count === 0) {
            return /*#__PURE__*/ _jsxs("div", {
                className: "flex items-center gap-2 text-xs py-1.5 px-2.5 rounded-md bg-muted/50 border border-border/50",
                children: [
                    /*#__PURE__*/ _jsx(Trash, {
                        className: "size-3.5 text-muted-foreground"
                    }),
                    /*#__PURE__*/ _jsx("span", {
                        className: "text-muted-foreground",
                        children: "No notes to delete"
                    })
                ]
            });
        }
        const displayFiles = files.slice(0, 5);
        const remainingCount = files.length - displayFiles.length;
        return /*#__PURE__*/ _jsxs("div", {
            className: "text-xs py-2 px-2.5 rounded-md bg-red-500/5 border border-red-500/20",
            children: [
                /*#__PURE__*/ _jsxs("div", {
                    className: "flex items-center gap-2 mb-2",
                    children: [
                        /*#__PURE__*/ _jsx(Trash, {
                            className: "size-3.5 text-red-600 dark:text-red-500",
                            weight: "fill"
                        }),
                        /*#__PURE__*/ _jsxs("span", {
                            className: "font-medium text-red-700 dark:text-red-400",
                            children: [
                                "Deleted ",
                                count,
                                " file",
                                count !== 1 ? 's' : ''
                            ]
                        })
                    ]
                }),
                /*#__PURE__*/ _jsxs("div", {
                    className: "space-y-1 ml-5",
                    children: [
                        displayFiles.map((filePath, i)=>{
                            const fileName = filePath.split('/').pop() || filePath;
                            const folder = filePath.includes('/') ? filePath.split('/').slice(0, -1).join('/') + '/' : '';
                            return /*#__PURE__*/ _jsxs("div", {
                                className: "flex items-center gap-1.5",
                                children: [
                                    /*#__PURE__*/ _jsx(File, {
                                        className: `size-3.5 ${getFileColor(filePath)}`,
                                        weight: "fill"
                                    }),
                                    /*#__PURE__*/ _jsx("span", {
                                        className: "text-muted-foreground/70",
                                        children: folder
                                    }),
                                    /*#__PURE__*/ _jsx("span", {
                                        className: "font-mono text-foreground/80",
                                        children: fileName
                                    })
                                ]
                            }, i);
                        }),
                        remainingCount > 0 && /*#__PURE__*/ _jsxs("div", {
                            className: "text-muted-foreground/60 italic",
                            children: [
                                "...and ",
                                remainingCount,
                                " more"
                            ]
                        })
                    ]
                })
            ]
        });
    }
    // Check request validity
    if (toolName === 'check_request_validity') {
        const validation = result;
        if (!validation) return null;
        const { isValid, validation: v } = validation;
        const issues = [];
        if (v?.pathParams?.missing?.length) issues.push(`path: ${v.pathParams.missing.join(', ')}`);
        if (v?.queryParams?.missing?.length) issues.push(`params: ${v.queryParams.missing.join(', ')}`);
        if (v?.body?.required && !v?.body?.hasContent) issues.push('body empty');
        if (v?.auth?.required && !v?.auth?.configured) issues.push('auth missing');
        if (isValid) {
            return /*#__PURE__*/ _jsxs("div", {
                className: "flex items-center gap-2 text-xs py-1.5 px-2.5 rounded-md bg-green-500/10 border border-green-500/20",
                children: [
                    /*#__PURE__*/ _jsx(CheckSquare, {
                        className: "size-3.5 text-green-600 dark:text-green-500",
                        weight: "fill"
                    }),
                    /*#__PURE__*/ _jsx("span", {
                        className: "text-green-700 dark:text-green-400",
                        children: "Ready to send"
                    })
                ]
            });
        }
        return /*#__PURE__*/ _jsx("div", {
            className: "py-1.5 px-2.5 rounded-md bg-amber-500/10 border border-amber-500/20",
            children: /*#__PURE__*/ _jsxs("div", {
                className: "flex items-center gap-2 text-xs",
                children: [
                    /*#__PURE__*/ _jsx(Warning, {
                        className: "size-3.5 text-amber-600 dark:text-amber-500",
                        weight: "fill"
                    }),
                    /*#__PURE__*/ _jsxs("span", {
                        className: "text-amber-700 dark:text-amber-400",
                        children: [
                            "Missing: ",
                            issues.join(', ')
                        ]
                    })
                ]
            })
        });
    }
    // Send request
    if (toolName === 'send_request') {
        const response = result;
        if (!response) return null;
        const { success, error } = response;
        if (error || !success) {
            return /*#__PURE__*/ _jsxs("div", {
                className: "flex items-center gap-2 text-xs py-1.5 px-2.5 rounded-md bg-destructive/10 border border-destructive/20",
                children: [
                    /*#__PURE__*/ _jsx(XCircle, {
                        className: "size-3.5 text-destructive",
                        weight: "fill"
                    }),
                    /*#__PURE__*/ _jsx("span", {
                        className: "text-destructive",
                        children: error || 'Request failed'
                    })
                ]
            });
        }
        return /*#__PURE__*/ _jsxs("div", {
            className: "flex items-center gap-2 text-xs py-1.5 px-2.5 rounded-md bg-blue-500/10 border border-blue-500/20",
            children: [
                /*#__PURE__*/ _jsx(PaperPlaneTilt, {
                    className: "size-3.5 text-blue-600 dark:text-blue-500",
                    weight: "fill"
                }),
                /*#__PURE__*/ _jsx("span", {
                    className: "text-blue-700 dark:text-blue-400",
                    children: "Request sent → check response viewer"
                })
            ]
        });
    }
    // Hide unknown tools
    return null;
}
