import { NodeConnectionTypes, type INodeType, type INodeDataBaseSchema } from '../../Interface'
import Setter from './setter.vue'
import { getClassPortLabel, getNodeDescription, getNodeDisplayName } from '@/nodes/i18n'

export type ClassItem = {
	id: string
	name: string
	instruction: string
}

export type QuestionClassifierData = INodeDataBaseSchema & {
	query: string
	classes: ClassItem[]
	instruction: string
	model_id: string
}

export const questionClassifierNode: INodeType = {
	version: ['1'],
	displayName: getNodeDisplayName('question-classifier'),
	name: 'question-classifier',
	description: getNodeDescription('question-classifier'),
	Setter,
	group: 'logic',
	icon: 'lucide:gallery-horizontal-end',
	iconColor: '#17b26a',
	inputs: [NodeConnectionTypes.main],
	outputs: (data: QuestionClassifierData) => {
		const cases = data?.classes || []
		const ports = cases.map((c, index) => {
			return {
				id: c.id,
				label: getClassPortLabel(index),
				type: 'port'
			}
		})

		return ports
	},
	schema: {
		appAgentId: '',
		parentId: '',
		position: {
			x: 20,
			y: 30
		},
		width: 96,
		height: 96,
		selected: false,
		nodeType: 'question-classifier',
		zIndex: 1,
		data: {}
	}
}
