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

export type ListData = INodeDataBaseSchema & {
	extract_by: {
		enabled: boolean
		serial: string
	}
	filter_by: {
		enabled: boolean
		conditions: Array<{
			comparison_operator:
				| 'contains'
				| 'not_contains'
				| 'start_with'
				| 'end_with'
				| 'is'
				| 'is_not'
				| 'empty'
				| 'not_empty'
				| '='
				| '!='
				| '>'
				| '<'
				| '≥'
				| '≤'
				| 'all_of'
			left_value?: string
			right_value: string
			right_value_list?: string[]
			varType:
				| 'string'
				| 'number'
				| 'boolean'
				| 'object'
				| 'array[string]'
				| 'array[number]'
				| 'array[boolean]'
				| 'array[object]'
				| 'array[file]'
		}>
	}
	limit: {
		enabled: boolean
		size: number
	}
	order_by: {
		enabled: boolean
		key: string
		value: 'asc' | 'desc' | ''
	}
}

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