import type {NodeProps} from '@xyflow/react'
import AmisNode, {inputsFormColumns, outputsFormColumns} from './AmisNode.tsx'

const CodeNode = (props: NodeProps) => AmisNode({
  nodeProps: props,
  type: 'normal',
  defaultNodeName: '代码执行',
  defaultNodeDescription: '执行自定义的处理代码',
  columnSchema: [
    ...inputsFormColumns(),
    {
      type: 'divider',
    },
    {
      type: 'select',
      name: 'type',
      label: '代码类型',
      required: true,
      options: [
        {
          value: 'javascript',
          label: 'JavaScript',
        },
        {
          value: 'python',
          label: 'Python',
        },
        {
          value: 'lua',
          label: 'Lua',
        },
      ],
    },
    {
      type: 'editor',
      required: true,
      label: '代码内容',
      name: 'content',
      language: '${type}',
      options: {
        wordWrap: 'bounded',
      },
    },
    {
      type: 'divider',
    },
    ...outputsFormColumns(true, true, {result: {type: 'string'}}),
  ],
})

export default CodeNode