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

export type FileType = 'document' | 'image' | 'audio' | 'video' | 'custom'

export type FormType =
	| 'text-input'
	| 'text-area'
	| 'select'
	| 'number'
	| 'checkbox'
	| 'file'
	| 'file-list'
	| 'json_object'

export type StartVariableDefaultValue =
	| string
	| number
	| boolean
	| Record<string, unknown>
	| WorkflowUploadFile
	| WorkflowUploadFile[]

export interface StartVariable {
	name: string
	label: string
	max_length?: number
	default_value?: StartVariableDefaultValue
	json?: Record<string, unknown>
	is_require: boolean
	is_hide: boolean
	formType: FormType
	options?: string[]
	file_types?: FileType[]
	file_extensions?: string[]
	allow_link_input?: boolean
}

export type StartData = INodeDataBaseSchema & {
	variables: StartVariable[]
}

export const startNode: INodeType = {
	version: ['1'],
	displayName: getNodeDisplayName('start'),
	name: 'start',
	description: getNodeDescription('start'),
	Setter,
	group: 'start',
	icon: 'lucide:play',
	iconColor: '#296dff',
	inputs: [],
	outputs: [NodeConnectionTypes.main],
	schema: {
		appAgentId: '',
		parentId: '',
		position: {
			x: 20,
			y: 30
		},
		width: 96,
		height: 96,
		selected: false,
		nodeType: 'start',
		zIndex: 1,
		data: {}
	}
}
