import { $t } from '#/locales';

import { rerenderSearchNode } from './datasetNodeRenderer';

export const SearchDatasetNode = async () => {
  return {
    title: $t('aiWorkflow.queryDataset'),
    group: 'base',
    description: $t('aiWorkflow.descriptions.queryDataset'),
    icon: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M4 4H20V6H4V4ZM4 9H20V11H4V9ZM4 14H14V16H4V14ZM4 19H14V21H4V19ZM17 14H22V21H17V14Z"></path></svg>',
    sortNo: 813,
    parametersAddEnable: true,
    outputDefsAddEnable: false,
    renderFirst: true,
    parameters: [],
    forms: [
      {
        name: 'querySql',
        type: 'textarea',
        templateSupport: true,
        label: 'SQL',
        placeholder: $t('aiWorkflow.descriptions.enterSQL'),
        attrs: {
          rows: 6,
        },
      },
    ],
    outputDefs: [
      {
        name: 'data',
        title: 'data',
        dataType: 'Array',
        dataTypeDisabled: true,
        required: true,
        parametersAddEnable: false,
        description: 'data',
        deleteDisabled: true,
        nameDisabled: true,
      },
    ],
    render: rerenderSearchNode,
    onUpdate: rerenderSearchNode,
  };
};
