import { NodeType, InitData } from "config";

export interface CategoryItem<T extends NodeType> {
	title: string;
	// TODO(gio): make InitData generic
	init: InitData;
	type: T;
}

export type Category = {
	title: string;
	items: CategoryItem<NodeType>[];
	active?: boolean;
};

const defaultInit: Pick<InitData, "label" | "envVars" | "ports"> = {
	label: "",
	envVars: [],
	ports: [],
};

export const defaultCategories: Category[] = [
	{
		title: "Repository",
		items: [
			{
				title: "Github",
				init: {
					...defaultInit,
				},
				type: "github",
			},
		],
	},
	{
		title: "Services",
		items: [
			{
				title: "Service",
				init: {
					...defaultInit,
				},
				type: "app",
			},
		],
	},
	{
		title: "Storage",
		items: [
			{
				title: "File system",
				init: {
					...defaultInit,
				},
				type: "volume",
			},
			{
				title: "PostgreSQL",
				init: {
					...defaultInit,
					ports: [
						{
							id: "connection",
							name: "connection",
							value: 5432,
						},
					],
				},
				type: "postgresql",
			},
			{
				title: "MongoDB",
				init: {
					...defaultInit,
					ports: [
						{
							id: "connection",
							name: "connection",
							value: 27017,
						},
					],
				},
				type: "mongodb",
			},
		],
	},
	{
		title: "Gateways",
		items: [
			{
				title: "HTTPS",
				init: {
					...defaultInit,
				},
				type: "gateway-https",
			},
			{
				title: "TCP",
				init: {
					...defaultInit,
				},
				type: "gateway-tcp",
			},
		],
	},
	{
		title: "AI", // New Category for AI tools
		items: [
			{
				title: "Agent Sketch",
				init: {
					...defaultInit,
					label: "Agent Sketch", // Default label for the node
					type: "sketch:latest",
					ports: [
						{
							id: "agent",
							name: "agent",
							value: 2001,
						},
						{
							id: "p8080",
							name: "p8080",
							value: 8080,
						},
						{
							id: "p8081",
							name: "p8081",
							value: 8081,
						},
						{
							id: "p8082",
							name: "p8082",
							value: 8082,
						},
						{
							id: "p8083",
							name: "p8083",
							value: 8083,
						},
						{
							id: "p8084",
							name: "p8084",
							value: 8084,
						},
					],
					envVars: [
						{
							id: "agent",
							name: "DODO_PORT_AGENT",
							source: null,
						},
						{
							id: "p8080",
							name: "DODO_PORT_P8080",
							source: null,
						},
						{
							id: "p8081",
							name: "DODO_PORT_P8081",
							source: null,
						},
						{
							id: "p8082",
							name: "DODO_PORT_P8082",
							source: null,
						},
						{
							id: "p8083",
							name: "DODO_PORT_P8083",
							source: null,
						},
						{
							id: "p8084",
							name: "DODO_PORT_P8084",
							source: null,
						},
					],
				},
				type: "app",
			},
		],
	},
];
