<script setup lang="ts">
import { HelpCircle } from '@vben/icons';
import { $t } from '@vben/locales';

import BaseNode from './BaseNode.vue';

defineProps(['selected', 'data', 'id']);
</script>

<template>
  <BaseNode
    :selected="selected"
    :execution-status="data.executionStatus"
    :execution-result="data.executionResult"
    :label="data.label || $t('ai-platform.workflow.nodes.question.label')"
    :inputs="[{ id: 'target' }]"
    :outputs="[{ id: 'source' }]"
    :node-id="id"
    node-type="question"
  >
    <template #icon><HelpCircle class="size-5" /></template>
    <template #desc>
      {{ $t('ai-platform.workflow.nodes.question.desc') }}
    </template>

    <div class="space-y-2">
      <div class="rounded bg-purple-50 px-2 py-1.5 text-xs dark:bg-purple-950">
        <div class="mb-1 font-medium text-purple-700 dark:text-purple-300">
          {{ $t('ai-platform.workflow.nodes.common.question') }}
        </div>
        <div class="line-clamp-2 text-purple-600 dark:text-purple-400">
          {{
            data.question ||
            $t('ai-platform.workflow.nodes.common.configureQuestion')
          }}
        </div>
      </div>

      <div
        class="text-muted-foreground flex items-center justify-between text-xs"
      >
        <span>{{ $t('ai-platform.workflow.nodes.question.inputType') }}</span>
        <span class="font-medium">{{ data.input_type || 'text' }}</span>
      </div>

      <div class="rounded bg-green-50 px-2 py-1 text-xs dark:bg-green-950">
        <div
          class="flex items-center justify-between text-green-700 dark:text-green-300"
        >
          <span>{{
            $t('ai-platform.workflow.nodes.common.outputVariable')
          }}</span>
          <span class="font-mono">{{
            data.variable_name || 'user_input'
          }}</span>
        </div>
      </div>
    </div>
  </BaseNode>
</template>
