"use client"; import { useEffect, useState } from "react"; import MultipleSelector, { type Option } from "@/components/multiple-selector"; import { Alert, AlertDescription } from "@/components/ui/alert"; import { Checkbox } from "@/components/ui/checkbox"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@/components/ui/select"; import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; import { Textarea } from "@/components/ui/textarea"; import type { CamoufoxConfig, CamoufoxFingerprintConfig } from "@/types"; interface SharedCamoufoxConfigFormProps { config: CamoufoxConfig; onConfigChange: (key: keyof CamoufoxConfig, value: unknown) => void; className?: string; isCreating?: boolean; // Flag to indicate if this is for creating a new profile forceAdvanced?: boolean; // Force advanced mode (for editing) } // Component for editing nested objects like webGl:parameters interface ObjectEditorProps { value: Record | undefined; onChange: (value: Record | undefined) => void; title: string; } function ObjectEditor({ value, onChange, title }: ObjectEditorProps) { const [jsonString, setJsonString] = useState(""); useEffect(() => { setJsonString(JSON.stringify(value || {}, null, 2)); }, [value]); const handleChange = (newValue: string) => { setJsonString(newValue); try { if (newValue.trim() === "" || newValue.trim() === "{}") { onChange(undefined); // Treat empty objects as undefined return; } const parsed = JSON.parse(newValue); if ( typeof parsed === "object" && parsed !== null && Object.keys(parsed).length === 0 ) { onChange(undefined); return; } onChange(parsed as Record); } catch (err) { console.warn("Invalid JSON:", err); } }; return (