"use client"; import { ChevronDown, ChevronRight, Copy } from "lucide-react"; import { useState } from "react"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { Collapsible, CollapsibleContent, CollapsibleTrigger, } from "@/components/ui/collapsible"; import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, } from "@/components/ui/dialog"; import type { PermissionRequest, PermissionResponse, } from "@/types/permissions"; interface PermissionDialogProps { permissionRequest: PermissionRequest | null; isOpen: boolean; onResponse: (response: PermissionResponse) => void; } export const PermissionDialog = ({ permissionRequest, isOpen, onResponse, }: PermissionDialogProps) => { const [isResponding, setIsResponding] = useState(false); const [isParametersExpanded, setIsParametersExpanded] = useState(false); if (!permissionRequest) return null; const handleResponse = async (decision: "allow" | "deny") => { setIsResponding(true); const response: PermissionResponse = { permissionRequestId: permissionRequest.id, decision, }; try { await onResponse(response); } finally { setIsResponding(false); } }; const formatValue = (value: unknown): string => { if (value === null) return "null"; if (value === undefined) return "undefined"; if (typeof value === "boolean") return value.toString(); if (typeof value === "number") return value.toString(); if (typeof value === "string") return value; return JSON.stringify(value, null, 2); }; const copyToClipboard = async (text: string) => { try { await navigator.clipboard.writeText(text); } catch (error) { console.error("Failed to copy to clipboard:", error); } }; const renderParameterValue = (key: string, value: unknown) => { const formattedValue = formatValue(value); const isLong = formattedValue.length > 100; return (
{formattedValue}