{
  "name": "VozAlta",
  "displayName": "VozAlta — Texto a Audio",
  "description": "Convierte texto, URLs y PDFs a audio narrado en español usando IA",
  "icon": "https://voz.4l3.org/favicon.ico",
  "version": 1,
  "defaults": {
    "name": "VozAlta"
  },
  "inputs": ["main"],
  "outputs": ["main"],
  "credentials": [],
  "properties": [
    {
      "displayName": "Operación",
      "name": "operation",
      "type": "options",
      "options": [
        { "name": "Texto a Audio", "value": "text", "description": "Convierte texto plano a MP3" },
        { "name": "URL a Audio", "value": "url", "description": "Extrae texto de una URL y genera audio" },
        { "name": "Listar Voces", "value": "voices", "description": "Obtiene las voces disponibles" }
      ],
      "default": "text",
      "noDataExpression": true
    },
    {
      "displayName": "Texto",
      "name": "text",
      "type": "string",
      "typeOptions": { "rows": 5 },
      "default": "",
      "required": true,
      "displayOptions": {
        "show": { "operation": ["text"] }
      },
      "description": "El texto a convertir en audio (máx 100,000 caracteres)"
    },
    {
      "displayName": "URL",
      "name": "url",
      "type": "string",
      "default": "",
      "required": true,
      "displayOptions": {
        "show": { "operation": ["url"] }
      },
      "description": "URL del artículo o página web a convertir en audio"
    },
    {
      "displayName": "Voz",
      "name": "voice",
      "type": "options",
      "options": [
        { "name": "Ald (México)", "value": "es-MX-Ald" },
        { "name": "Davefx (España)", "value": "es-ES-Davefx" },
        { "name": "Sharvard (España)", "value": "es-ES-Sharvard" }
      ],
      "default": "es-MX-Ald",
      "displayOptions": {
        "show": { "operation": ["text", "url"] }
      },
      "description": "Voz para la narración"
    },
    {
      "displayName": "Formato",
      "name": "format",
      "type": "options",
      "options": [
        { "name": "MP3", "value": "mp3" },
        { "name": "WAV", "value": "wav" }
      ],
      "default": "mp3",
      "displayOptions": {
        "show": { "operation": ["text", "url"] }
      }
    }
  ],
  "requestDefaults": {
    "baseURL": "https://voz.4l3.org",
    "headers": {
      "Content-Type": "application/json"
    }
  },
  "routing": {
    "request": {
      "method": "={{$parameter.operation === 'voices' ? 'GET' : 'POST'}}",
      "url": "={{$parameter.operation === 'voices' ? '/voices' : '/convert/' + $parameter.operation}}"
    },
    "send": {
      "type": "body",
      "properties": {
        "text": "={{$parameter.operation === 'text' ? $parameter.text : undefined}}",
        "url": "={{$parameter.operation === 'url' ? $parameter.url : undefined}}",
        "voice": "={{$parameter.voice}}",
        "format": "={{$parameter.format}}"
      }
    }
  }
}
