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

export type ModuleInvokeData = INodeDataBaseSchema & {
	interface_code: string
}

export const moduleInvokeNode: INodeType = {
	version: ['1'],
	displayName: getNodeDisplayName('module-invoke'),
	name: 'module-invoke',
	Setter,
	description: getNodeDescription('module-invoke'),
	group: 'tool',
	icon: 'lucide:blocks',
	iconColor: '#f79009',
	inputs: [NodeConnectionTypes.main],
	outputs: [NodeConnectionTypes.main],
	validate: (data: ModuleInvokeData) => {
		return data?.interface_code?.trim()
			? false
			: i18n.t('pages.moduleInvokeSetter.interfaceCodeRequired')
	},
	getSubtitle: (data: ModuleInvokeData) => {
		return data?.interface_code ? `code: ${data.interface_code}` : ''
	},
	schema: {
		appAgentId: '',
		parentId: '',
		position: {
			x: 20,
			y: 30
		},
		width: 96,
		height: 96,
		selected: false,
		nodeType: 'module-invoke',
		zIndex: 1,
		data: {
			interface_code: ''
		}
	}
}
