/* MIRAI onboarding — schema declarativo */

const MIRAI_ONBOARDING_VERSION = "mirai-onboarding-v3";

const MIRAI_ONBOARDING_TYPE_SECTION = {
  id: "type_gate",
  eyebrow: "Inicio",
  title: "Contanos que tipo de negocio sos",
  intro:
    "Con esto elegimos los planos indicados: unos para inmobiliarias y otros mas generales para empresas.",
};

const MIRAI_ONBOARDING_TYPE_QUESTION = {
  id: "business_type",
  section: "type_gate",
  label: "Sos una inmobiliaria o una empresa?",
  type: "choice",
  required: true,
  options: ["Inmobiliaria", "Empresa"],
  target: ["client", "business_type"],
};

const MIRAI_ONBOARDING_SECTIONS_REALESTATE = [
  {
    id: "welcome",
    eyebrow: "Contacto",
    title: "Diseñemos el agente ideal para tu inmobiliaria",
    intro:
      "Este onboarding nos da el contexto minimo para armar los primeros planos sin pedirte configuraciones tecnicas.",
  },
  {
    id: "business",
    eyebrow: "Operacion actual",
    title: "Como trabajan hoy",
    intro: "Ubicamos zona, volumen, canales y fricciones para entender donde Mirai puede aportar mas rapido.",
  },
  {
    id: "capabilities",
    eyebrow: "Habilidades",
    title: "Que queres que haga el agente",
    intro: "Elegimos las capacidades centrales para definir un alcance inicial claro y facil de implementar.",
  },
  {
    id: "data_capture",
    eyebrow: "Calificacion",
    title: "Que datos conviene pedir",
    intro: "La meta es equilibrar conversion con informacion util, sin volver tediosa la conversacion.",
  },
  {
    id: "catalog",
    eyebrow: "Propiedades",
    title: "Catalogo y recomendaciones",
    intro: "Aparece solo si el agente debe enviar fichas, recomendar propiedades o responder consultas sobre inmuebles.",
    showIf: {
      any: [
        { field: "agent_capabilities", includesAny: ["Recomendar propiedades", "Enviar fichas o links", "Responder consultas sobre propiedades"] },
        { field: "operation_types", includesAny: ["Alquiler", "Compra", "Inversiones", "Emprendimientos"] },
      ],
    },
  },
  {
    id: "handoff",
    eyebrow: "Derivacion",
    title: "Cuando pasa a un asesor",
    intro: "Solo configuramos este bloque si el agente tiene que derivar conversaciones a una persona.",
    showIf: { field: "agent_capabilities", includesAny: ["Derivar a asesor"] },
  },
  {
    id: "integrations",
    eyebrow: "Entrega",
    title: "Como reciben leads e integraciones",
    intro: "Definimos canales, destino del resumen de cada lead y sistemas necesarios para la primera etapa.",
  },
  {
    id: "tone",
    eyebrow: "Experiencia",
    title: "Como deberia sonar",
    intro: "Ajustes suficientes para que el agente se sienta alineado a la marca sin sobreconfigurar.",
  },
  {
    id: "reference_bot",
    eyebrow: "Referencia",
    title: "Referencia opcional",
    intro: "Si probaste un agente Mirai o tenes una preferencia clara, lo usamos como guia de estilo.",
  },
  {
    id: "final",
    eyebrow: "Planos",
    title: "Planos iniciales de tu agente",
    intro: "Revisa el resumen y genera el onboarding para compartirlo con Mirai.",
    final: true,
  },
];

const MIRAI_ONBOARDING_QUESTIONS_REALESTATE = [
  {
    id: "agency_name",
    section: "welcome",
    label: "Nombre de la inmobiliaria",
    type: "text",
    required: true,
    target: ["client", "agency_name"],
  },
  {
    id: "contact_name_role",
    section: "welcome",
    label: "Nombre y rol de quien completa el onboarding",
    type: "text",
    required: true,
    target: ["client", "contact_name_role"],
  },
  {
    id: "email",
    section: "welcome",
    label: "Email",
    type: "email",
    required: true,
    target: ["client", "email"],
  },
  {
    id: "whatsapp",
    section: "welcome",
    label: "WhatsApp de contacto",
    type: "tel",
    required: true,
    target: ["client", "whatsapp"],
  },
  {
    id: "website_or_instagram",
    section: "welcome",
    label: "Sitio web o Instagram",
    type: "url",
    required: false,
    target: ["client", "website_or_instagram"],
  },

  {
    id: "zones",
    section: "business",
    label: "En que ciudad o zonas trabajan principalmente?",
    type: "textarea",
    required: true,
    target: ["business", "zones"],
  },
  {
    id: "operation_types",
    section: "business",
    label: "Que tipo de consultas reciben?",
    type: "multi",
    required: true,
    options: [
      "Alquiler",
      "Compra",
      "Venta / tasacion",
      "Administracion de propiedades",
      "Emprendimientos",
      "Inversiones",
      "Soporte a clientes actuales",
      "Otro",
    ],
    target: ["business", "operation_types"],
  },
  {
    id: "operation_types_other",
    section: "business",
    label: "Que otro tipo de consulta reciben?",
    type: "text",
    required: true,
    showIf: { field: "operation_types", includesAny: ["Otro"] },
    target: ["business", "operation_types_other"],
  },
  {
    id: "lead_volume",
    section: "business",
    label: "Cuantos leads reciben por mes aproximadamente?",
    type: "choice",
    required: true,
    options: ["Menos de 50", "50 a 150", "150 a 500", "Mas de 500", "No lo sabemos"],
    target: ["business", "lead_volume"],
  },
  {
    id: "lead_channels",
    section: "business",
    label: "Por que canales entran hoy?",
    type: "multi",
    required: true,
    options: ["WhatsApp", "Instagram", "Web", "Facebook", "Portales inmobiliarios", "Llamadas", "Referidos", "Otro"],
    target: ["business", "lead_channels"],
  },
  {
    id: "lead_channels_other",
    section: "business",
    label: "Que otro canal usan hoy?",
    type: "text",
    required: true,
    showIf: { field: "lead_channels", includesAny: ["Otro"] },
    target: ["business", "lead_channels_other"],
  },
  {
    id: "pain_points",
    section: "business",
    label: "Que problema queres resolver primero?",
    type: "multi",
    required: true,
    options: [
      "Tardan en responder",
      "Pierden leads",
      "Responden siempre lo mismo",
      "Llegan leads poco calificados",
      "No hay seguimiento",
      "Los asesores reciben consultas incompletas",
      "Las propiedades no estan ordenadas",
      "No saben que leads son buenos",
      "Otro",
    ],
    target: ["business", "pain_points"],
  },
  {
    id: "pain_points_other",
    section: "business",
    label: "Que otro problema queres resolver?",
    type: "textarea",
    required: true,
    showIf: { field: "pain_points", includesAny: ["Otro"] },
    target: ["business", "pain_points_other"],
  },
  {
    id: "success_60",
    section: "business",
    label: "Que seria un exito en los proximos 60 dias?",
    type: "textarea",
    required: false,
    target: ["business", "success_60_days"],
  },

  {
    id: "agent_capabilities",
    section: "capabilities",
    label: "Que habilidades queres que tenga el agente?",
    type: "multi",
    required: true,
    options: [
      "Responder preguntas frecuentes",
      "Detectar intencion",
      "Pedir y ordenar datos del lead",
      "Calificar leads",
      "Recomendar propiedades",
      "Enviar fichas o links",
      "Responder consultas sobre propiedades",
      "Agendar visitas",
      "Hacer seguimiento",
      "Registrar datos en CRM/Sheets",
      "Derivar a asesor",
      "Otro",
    ],
    target: ["objectives", "agent_capabilities"],
  },
  {
    id: "agent_capabilities_other",
    section: "capabilities",
    label: "Que otra habilidad necesita el agente?",
    type: "textarea",
    required: true,
    showIf: { field: "agent_capabilities", includesAny: ["Otro"] },
    target: ["objectives", "agent_capabilities_other"],
  },

  {
    id: "qualification_depth",
    section: "data_capture",
    label: "Nivel de calificacion",
    helper: "1 = menos friccion, 5 = mas datos antes de avanzar.",
    type: "slider",
    required: true,
    min: 1,
    max: 5,
    defaultValue: 3,
    target: ["data_capture", "qualification_depth"],
  },
  {
    id: "basic_data",
    section: "data_capture",
    label: "Que datos deberia pedir siempre?",
    type: "multi",
    required: true,
    options: ["Nombre", "Telefono", "Email", "Zona", "Tipo de operacion", "Tipo de propiedad", "Presupuesto", "Urgencia", "Comentario libre"],
    target: ["data_capture", "basic_data"],
  },
  {
    id: "flow_specific_data",
    section: "data_capture",
    label: "Segun el tipo de consulta, que datos extra importan?",
    type: "multi",
    required: false,
    options: [
      "Ambientes",
      "Garantia / recibos",
      "Fecha de mudanza",
      "Forma de pago",
      "Apto credito",
      "Direccion o zona de la propiedad",
      "Metros cuadrados",
      "Fotos",
      "Propiedad especifica",
      "Otro",
    ],
    showIf: {
      any: [
        { field: "operation_types", includesAny: ["Alquiler", "Compra", "Venta / tasacion", "Inversiones"] },
        { field: "agent_capabilities", includesAny: ["Recomendar propiedades", "Enviar fichas o links", "Responder consultas sobre propiedades"] },
      ],
    },
    target: ["data_capture", "flow_specific_data"],
  },
  {
    id: "flow_specific_data_other",
    section: "data_capture",
    label: "Que otro dato extra importa?",
    type: "text",
    required: true,
    showIf: { field: "flow_specific_data", includesAny: ["Otro"] },
    target: ["data_capture", "flow_specific_data_other"],
  },

  {
    id: "property_source",
    section: "catalog",
    label: "Donde estan cargadas hoy las propiedades?",
    type: "choice",
    required: true,
    options: ["CRM inmobiliario", "Google Sheets", "Excel", "Sitio web", "Tokko", "TecnoGestion", "Portales", "Instagram", "No estan ordenadas", "Otro"],
    target: ["catalog", "property_source"],
  },
  {
    id: "property_source_other",
    section: "catalog",
    label: "Donde mas estan cargadas?",
    type: "text",
    required: true,
    showIf: { field: "property_source", equals: "Otro" },
    target: ["catalog", "property_source_other"],
  },
  {
    id: "catalog_freshness",
    section: "catalog",
    label: "Que tan actualizada esta esa informacion?",
    type: "choice",
    required: true,
    options: ["Actualizada", "Mas o menos", "Desactualizada", "No sabemos"],
    target: ["catalog", "freshness"],
  },
  {
    id: "property_fields",
    section: "catalog",
    label: "Que datos tienen normalmente las propiedades?",
    type: "multi",
    required: false,
    options: ["Fotos", "Descripcion", "Precio actualizado", "Disponibilidad real", "Codigo interno", "Ubicacion o zona", "Ambientes", "Metros cuadrados"],
    target: ["catalog", "property_fields"],
  },
  {
    id: "no_match_behavior",
    section: "catalog",
    label: "Si no hay una propiedad exacta, que deberia hacer?",
    type: "choice",
    required: true,
    options: ["Derivar a humano", "Sugerir alternativas parecidas", "Pedir mas datos", "Decir que no hay disponibilidad"],
    target: ["catalog", "no_match_behavior"],
  },
  {
    id: "recommendation_priority",
    section: "catalog",
    label: "Que criterio deberia priorizar al recomendar?",
    type: "multi",
    required: false,
    options: ["Precio", "Zona", "Disponibilidad", "Prioridad comercial", "Asesor responsable", "No definido"],
    target: ["catalog", "recommendation_priority"],
  },

  {
    id: "handoff_moments",
    section: "handoff",
    label: "Cuando debe derivar a un asesor?",
    type: "multi",
    required: true,
    options: ["Lead calificado", "Pide hablar con humano", "Consulta propiedad especifica", "No hay propiedades disponibles", "Quiere visitar", "Quiere vender/tasar", "Hay que negociar precio", "Otro"],
    target: ["handoff", "moments"],
  },
  {
    id: "handoff_moments_other",
    section: "handoff",
    label: "En que otro momento deberia derivar?",
    type: "textarea",
    required: true,
    showIf: { field: "handoff_moments", includesAny: ["Otro"] },
    target: ["handoff", "moments_other"],
  },
  {
    id: "advisor_assignment",
    section: "handoff",
    label: "Como se asignan los asesores?",
    type: "choice",
    required: true,
    options: ["Todos reciben todo", "Por zona", "Por tipo de operacion", "Por propiedad", "Por turno", "Manualmente", "No esta definido", "Otro"],
    target: ["handoff", "advisor_assignment"],
  },
  {
    id: "advisor_assignment_other",
    section: "handoff",
    label: "Como seria esa asignacion?",
    type: "textarea",
    required: true,
    showIf: { field: "advisor_assignment", equals: "Otro" },
    target: ["handoff", "advisor_assignment_other"],
  },
  {
    id: "advisor_reply_channel",
    section: "handoff",
    label: "Cuando deriva, desde donde deberia contactar el asesor?",
    type: "choice",
    required: true,
    options: ["Desde el mismo WhatsApp del agente", "Desde su numero personal", "A definir con Mirai"],
    target: ["handoff", "advisor_reply_channel"],
  },
  {
    id: "after_hours_behavior",
    section: "handoff",
    label: "Que deberia pasar fuera de horario?",
    type: "textarea",
    required: false,
    target: ["handoff", "after_hours_behavior"],
  },

  {
    id: "lead_summary_delivery",
    section: "integrations",
    label: "Como quieren recibir el resumen de cada lead?",
    type: "multi",
    required: true,
    options: ["WhatsApp", "Email", "Google Sheets", "CRM", "No necesito resumen", "Otro"],
    target: ["integrations", "lead_summary_delivery"],
  },
  {
    id: "lead_summary_delivery_other",
    section: "integrations",
    label: "Como mas quieren recibir los resumenes?",
    type: "text",
    required: true,
    showIf: { field: "lead_summary_delivery", includesAny: ["Otro"] },
    target: ["integrations", "lead_summary_delivery_other"],
  },
  {
    id: "channels_to_connect",
    section: "integrations",
    label: "Que canales queres conectar en la primera etapa?",
    type: "multi",
    required: true,
    options: ["WhatsApp", "Instagram", "Web chat", "Facebook", "Otro"],
    target: ["integrations", "channels"],
  },
  {
    id: "channels_to_connect_other",
    section: "integrations",
    label: "Que otro canal queres conectar?",
    type: "text",
    required: true,
    showIf: { field: "channels_to_connect", includesAny: ["Otro"] },
    target: ["integrations", "channels_other"],
  },
  {
    id: "uses_crm",
    section: "integrations",
    label: "Usan CRM?",
    type: "toggle",
    required: true,
    options: ["Si", "No"],
    target: ["integrations", "uses_crm"],
  },
  {
    id: "crm_name",
    section: "integrations",
    label: "Cual CRM usan?",
    type: "text",
    required: true,
    showIf: { field: "uses_crm", equals: "Si" },
    target: ["integrations", "crm_name"],
  },
  {
    id: "accepts_sheets",
    section: "integrations",
    label: "Aceptarian Google Sheets como base inicial?",
    type: "toggle",
    required: true,
    options: ["Si", "No"],
    showIf: { field: "uses_crm", equals: "No" },
    target: ["integrations", "accepts_google_sheets"],
  },

  {
    id: "tone_style",
    section: "tone",
    label: "Como deberia sonar el agente?",
    type: "choice",
    required: true,
    options: ["Formal", "Cercano", "Premium", "Joven", "Institucional", "Muy directo", "Otro"],
    target: ["tone", "style"],
  },
  {
    id: "tone_style_other",
    section: "tone",
    label: "Que otro estilo deberia tener?",
    type: "text",
    required: true,
    showIf: { field: "tone_style", equals: "Otro" },
    target: ["tone", "style_other"],
  },
  {
    id: "response_length",
    section: "tone",
    label: "Preferis respuestas cortas o explicativas?",
    helper: "1 = muy cortas, 5 = mas explicativas.",
    type: "slider",
    required: true,
    min: 1,
    max: 5,
    defaultValue: 3,
    target: ["tone", "response_length"],
  },
  {
    id: "tone_limits",
    section: "tone",
    label: "Frases, palabras o temas que deberia usar o evitar?",
    type: "textarea",
    required: false,
    target: ["tone", "limits_and_phrases"],
  },
  {
    id: "bot_intro",
    section: "tone",
    label: "Como deberia presentarse?",
    type: "text",
    required: false,
    target: ["tone", "bot_intro"],
  },
  {
    id: "disclose_ai",
    section: "tone",
    label: "Debe aclarar que es un asistente con IA?",
    type: "toggle",
    required: false,
    options: ["Si", "No"],
    target: ["tone", "disclose_ai"],
  },

  {
    id: "tested_reference",
    section: "reference_bot",
    label: "Probaste un agente de referencia?",
    type: "toggle",
    required: false,
    options: ["Si", "No"],
    target: ["reference_bot", "tested_reference"],
  },
  {
    id: "reference_liked",
    section: "reference_bot",
    label: "Que te gusto o que cambiarias?",
    type: "textarea",
    required: false,
    showIf: { field: "tested_reference", equals: "Si" },
    target: ["reference_bot", "notes"],
  },
  {
    id: "interaction_style",
    section: "reference_bot",
    label: "Preferis menu inicial, conversacion libre o hibrido?",
    type: "choice",
    required: false,
    options: ["Menu inicial", "Conversacion libre", "Hibrido", "No estoy seguro"],
    target: ["reference_bot", "interaction_style"],
  },
];

const MIRAI_ONBOARDING_SECTIONS_BUSINESS = [
  {
    id: "welcome",
    eyebrow: "Contacto",
    title: "Diseñemos el agente ideal para tu empresa",
    intro:
      "Este onboarding nos da el contexto minimo para armar los primeros planos sin pedirte configuraciones tecnicas.",
  },
  {
    id: "business",
    eyebrow: "Operacion actual",
    title: "Como trabajan hoy",
    intro: "Ubicamos rubro, volumen, canales y fricciones para entender donde Mirai puede aportar mas rapido.",
  },
  {
    id: "capabilities",
    eyebrow: "Habilidades",
    title: "Que queres que haga el agente",
    intro: "Elegimos las capacidades centrales para definir un alcance inicial claro y facil de implementar.",
  },
  {
    id: "data_capture",
    eyebrow: "Calificacion",
    title: "Que datos conviene pedir",
    intro: "La meta es equilibrar conversion con informacion util, sin volver tediosa la conversacion.",
  },
  {
    id: "catalog",
    eyebrow: "Productos y servicios",
    title: "Catalogo y recomendaciones",
    intro: "Aparece solo si el agente debe enviar informacion, recomendar productos/servicios o responder consultas puntuales.",
    showIf: {
      any: [
        { field: "agent_capabilities", includesAny: ["Recomendar productos o servicios", "Enviar informacion o catalogos", "Responder consultas sobre productos o servicios"] },
        { field: "operation_types", includesAny: ["Ventas", "Consultas de producto/servicio", "Cotizaciones / presupuestos"] },
      ],
    },
  },
  {
    id: "handoff",
    eyebrow: "Derivacion",
    title: "Cuando pasa a una persona",
    intro: "Solo configuramos este bloque si el agente tiene que derivar conversaciones a alguien del equipo.",
    showIf: { field: "agent_capabilities", includesAny: ["Derivar a un humano"] },
  },
  {
    id: "integrations",
    eyebrow: "Entrega",
    title: "Como reciben leads e integraciones",
    intro: "Definimos canales, destino del resumen de cada lead y sistemas necesarios para la primera etapa.",
  },
  {
    id: "tone",
    eyebrow: "Experiencia",
    title: "Como deberia sonar",
    intro: "Ajustes suficientes para que el agente se sienta alineado a la marca sin sobreconfigurar.",
  },
  {
    id: "reference_bot",
    eyebrow: "Referencia",
    title: "Referencia opcional",
    intro: "Si probaste un agente Mirai o tenes una preferencia clara, lo usamos como guia de estilo.",
  },
  {
    id: "final",
    eyebrow: "Planos",
    title: "Planos iniciales de tu agente",
    intro: "Revisa el resumen y genera el onboarding para compartirlo con Mirai.",
    final: true,
  },
];

const MIRAI_ONBOARDING_QUESTIONS_BUSINESS = [
  {
    id: "agency_name",
    section: "welcome",
    label: "Nombre de la empresa",
    type: "text",
    required: true,
    target: ["client", "agency_name"],
  },
  {
    id: "contact_name_role",
    section: "welcome",
    label: "Nombre y rol de quien completa el onboarding",
    type: "text",
    required: true,
    target: ["client", "contact_name_role"],
  },
  {
    id: "email",
    section: "welcome",
    label: "Email",
    type: "email",
    required: true,
    target: ["client", "email"],
  },
  {
    id: "whatsapp",
    section: "welcome",
    label: "WhatsApp de contacto",
    type: "tel",
    required: true,
    target: ["client", "whatsapp"],
  },
  {
    id: "website_or_instagram",
    section: "welcome",
    label: "Sitio web o Instagram",
    type: "url",
    required: false,
    target: ["client", "website_or_instagram"],
  },

  {
    id: "zones",
    section: "business",
    label: "En que rubro estan y donde opera la empresa? (ciudad, pais u online)",
    type: "textarea",
    required: true,
    target: ["business", "zones"],
  },
  {
    id: "operation_types",
    section: "business",
    label: "Que tipo de consultas reciben?",
    type: "multi",
    required: true,
    options: [
      "Ventas",
      "Consultas de producto/servicio",
      "Soporte / postventa",
      "Turnos o reservas",
      "Cotizaciones / presupuestos",
      "Reclamos",
      "Otro",
    ],
    target: ["business", "operation_types"],
  },
  {
    id: "operation_types_other",
    section: "business",
    label: "Que otro tipo de consulta reciben?",
    type: "text",
    required: true,
    showIf: { field: "operation_types", includesAny: ["Otro"] },
    target: ["business", "operation_types_other"],
  },
  {
    id: "lead_volume",
    section: "business",
    label: "Cuantos leads reciben por mes aproximadamente?",
    type: "choice",
    required: true,
    options: ["Menos de 50", "50 a 150", "150 a 500", "Mas de 500", "No lo sabemos"],
    target: ["business", "lead_volume"],
  },
  {
    id: "lead_channels",
    section: "business",
    label: "Por que canales entran hoy?",
    type: "multi",
    required: true,
    options: ["WhatsApp", "Instagram", "Web", "Facebook", "Email", "Llamadas", "Referidos", "Otro"],
    target: ["business", "lead_channels"],
  },
  {
    id: "lead_channels_other",
    section: "business",
    label: "Que otro canal usan hoy?",
    type: "text",
    required: true,
    showIf: { field: "lead_channels", includesAny: ["Otro"] },
    target: ["business", "lead_channels_other"],
  },
  {
    id: "pain_points",
    section: "business",
    label: "Que problema queres resolver primero?",
    type: "multi",
    required: true,
    options: [
      "Tardan en responder",
      "Pierden leads",
      "Responden siempre lo mismo",
      "Llegan leads poco calificados",
      "No hay seguimiento",
      "El equipo recibe consultas incompletas",
      "La informacion de productos/servicios no esta ordenada",
      "No saben que leads son buenos",
      "Otro",
    ],
    target: ["business", "pain_points"],
  },
  {
    id: "pain_points_other",
    section: "business",
    label: "Que otro problema queres resolver?",
    type: "textarea",
    required: true,
    showIf: { field: "pain_points", includesAny: ["Otro"] },
    target: ["business", "pain_points_other"],
  },
  {
    id: "success_60",
    section: "business",
    label: "Que seria un exito en los proximos 60 dias?",
    type: "textarea",
    required: false,
    target: ["business", "success_60_days"],
  },

  {
    id: "agent_capabilities",
    section: "capabilities",
    label: "Que habilidades queres que tenga el agente?",
    type: "multi",
    required: true,
    options: [
      "Responder preguntas frecuentes",
      "Detectar intencion",
      "Pedir y ordenar datos del cliente",
      "Calificar leads",
      "Recomendar productos o servicios",
      "Enviar informacion o catalogos",
      "Responder consultas sobre productos o servicios",
      "Agendar turnos o reuniones",
      "Hacer seguimiento",
      "Registrar datos en CRM/Sheets",
      "Derivar a un humano",
      "Otro",
    ],
    target: ["objectives", "agent_capabilities"],
  },
  {
    id: "agent_capabilities_other",
    section: "capabilities",
    label: "Que otra habilidad necesita el agente?",
    type: "textarea",
    required: true,
    showIf: { field: "agent_capabilities", includesAny: ["Otro"] },
    target: ["objectives", "agent_capabilities_other"],
  },

  {
    id: "qualification_depth",
    section: "data_capture",
    label: "Nivel de calificacion",
    helper: "1 = menos friccion, 5 = mas datos antes de avanzar.",
    type: "slider",
    required: true,
    min: 1,
    max: 5,
    defaultValue: 3,
    target: ["data_capture", "qualification_depth"],
  },
  {
    id: "basic_data",
    section: "data_capture",
    label: "Que datos deberia pedir siempre?",
    type: "multi",
    required: true,
    options: ["Nombre", "Telefono", "Email", "Empresa", "Motivo de contacto", "Presupuesto", "Urgencia", "Comentario libre"],
    target: ["data_capture", "basic_data"],
  },
  {
    id: "flow_specific_data",
    section: "data_capture",
    label: "Segun el tipo de consulta, que datos extra importan?",
    type: "multi",
    required: false,
    options: [
      "Producto o servicio de interes",
      "Cantidad",
      "Fecha requerida",
      "Forma de pago",
      "Documentacion necesaria",
      "Direccion de entrega",
      "Detalles tecnicos",
      "Otro",
    ],
    showIf: {
      any: [
        { field: "operation_types", includesAny: ["Ventas", "Consultas de producto/servicio", "Cotizaciones / presupuestos"] },
        { field: "agent_capabilities", includesAny: ["Recomendar productos o servicios", "Enviar informacion o catalogos", "Responder consultas sobre productos o servicios"] },
      ],
    },
    target: ["data_capture", "flow_specific_data"],
  },
  {
    id: "flow_specific_data_other",
    section: "data_capture",
    label: "Que otro dato extra importa?",
    type: "text",
    required: true,
    showIf: { field: "flow_specific_data", includesAny: ["Otro"] },
    target: ["data_capture", "flow_specific_data_other"],
  },

  {
    id: "property_source",
    section: "catalog",
    label: "Donde esta cargada hoy la informacion de productos o servicios?",
    type: "choice",
    required: true,
    options: ["CRM", "Google Sheets", "Excel", "Sitio web", "Notion", "Catalogo impreso", "No esta ordenada", "Otro"],
    target: ["catalog", "property_source"],
  },
  {
    id: "property_source_other",
    section: "catalog",
    label: "Donde mas esta cargada?",
    type: "text",
    required: true,
    showIf: { field: "property_source", equals: "Otro" },
    target: ["catalog", "property_source_other"],
  },
  {
    id: "catalog_freshness",
    section: "catalog",
    label: "Que tan actualizada esta esa informacion?",
    type: "choice",
    required: true,
    options: ["Actualizada", "Mas o menos", "Desactualizada", "No sabemos"],
    target: ["catalog", "freshness"],
  },
  {
    id: "property_fields",
    section: "catalog",
    label: "Que datos tienen normalmente los productos o servicios?",
    type: "multi",
    required: false,
    options: ["Fotos", "Descripcion", "Precio actualizado", "Disponibilidad real", "Codigo interno / SKU", "Categoria", "Especificaciones tecnicas"],
    target: ["catalog", "property_fields"],
  },
  {
    id: "no_match_behavior",
    section: "catalog",
    label: "Si no hay un producto o servicio exacto, que deberia hacer?",
    type: "choice",
    required: true,
    options: ["Derivar a humano", "Sugerir alternativas parecidas", "Pedir mas datos", "Decir que no hay disponibilidad"],
    target: ["catalog", "no_match_behavior"],
  },
  {
    id: "recommendation_priority",
    section: "catalog",
    label: "Que criterio deberia priorizar al recomendar?",
    type: "multi",
    required: false,
    options: ["Precio", "Disponibilidad", "Prioridad comercial", "Ejecutivo asignado", "No definido"],
    target: ["catalog", "recommendation_priority"],
  },

  {
    id: "handoff_moments",
    section: "handoff",
    label: "Cuando debe derivar a una persona?",
    type: "multi",
    required: true,
    options: ["Lead calificado", "Pide hablar con humano", "Consulta especifica y compleja", "No hay stock o disponibilidad", "Quiere agendar reunion", "Quiere comprar en volumen", "Hay que negociar precio o condiciones", "Otro"],
    target: ["handoff", "moments"],
  },
  {
    id: "handoff_moments_other",
    section: "handoff",
    label: "En que otro momento deberia derivar?",
    type: "textarea",
    required: true,
    showIf: { field: "handoff_moments", includesAny: ["Otro"] },
    target: ["handoff", "moments_other"],
  },
  {
    id: "advisor_assignment",
    section: "handoff",
    label: "Como se asigna al equipo?",
    type: "choice",
    required: true,
    options: ["Todos reciben todo", "Por zona", "Por tipo de consulta", "Por cuenta o cliente", "Por turno", "Manualmente", "No esta definido", "Otro"],
    target: ["handoff", "advisor_assignment"],
  },
  {
    id: "advisor_assignment_other",
    section: "handoff",
    label: "Como seria esa asignacion?",
    type: "textarea",
    required: true,
    showIf: { field: "advisor_assignment", equals: "Otro" },
    target: ["handoff", "advisor_assignment_other"],
  },
  {
    id: "advisor_reply_channel",
    section: "handoff",
    label: "Cuando deriva, desde donde deberia contactar la persona?",
    type: "choice",
    required: true,
    options: ["Desde el mismo WhatsApp del agente", "Desde su numero personal", "A definir con Mirai"],
    target: ["handoff", "advisor_reply_channel"],
  },
  {
    id: "after_hours_behavior",
    section: "handoff",
    label: "Que deberia pasar fuera de horario?",
    type: "textarea",
    required: false,
    target: ["handoff", "after_hours_behavior"],
  },

  {
    id: "lead_summary_delivery",
    section: "integrations",
    label: "Como quieren recibir el resumen de cada lead?",
    type: "multi",
    required: true,
    options: ["WhatsApp", "Email", "Google Sheets", "CRM", "No necesito resumen", "Otro"],
    target: ["integrations", "lead_summary_delivery"],
  },
  {
    id: "lead_summary_delivery_other",
    section: "integrations",
    label: "Como mas quieren recibir los resumenes?",
    type: "text",
    required: true,
    showIf: { field: "lead_summary_delivery", includesAny: ["Otro"] },
    target: ["integrations", "lead_summary_delivery_other"],
  },
  {
    id: "channels_to_connect",
    section: "integrations",
    label: "Que canales queres conectar en la primera etapa?",
    type: "multi",
    required: true,
    options: ["WhatsApp", "Instagram", "Web chat", "Facebook", "Otro"],
    target: ["integrations", "channels"],
  },
  {
    id: "channels_to_connect_other",
    section: "integrations",
    label: "Que otro canal queres conectar?",
    type: "text",
    required: true,
    showIf: { field: "channels_to_connect", includesAny: ["Otro"] },
    target: ["integrations", "channels_other"],
  },
  {
    id: "uses_crm",
    section: "integrations",
    label: "Usan CRM?",
    type: "toggle",
    required: true,
    options: ["Si", "No"],
    target: ["integrations", "uses_crm"],
  },
  {
    id: "crm_name",
    section: "integrations",
    label: "Cual CRM usan?",
    type: "text",
    required: true,
    showIf: { field: "uses_crm", equals: "Si" },
    target: ["integrations", "crm_name"],
  },
  {
    id: "accepts_sheets",
    section: "integrations",
    label: "Aceptarian Google Sheets como base inicial?",
    type: "toggle",
    required: true,
    options: ["Si", "No"],
    showIf: { field: "uses_crm", equals: "No" },
    target: ["integrations", "accepts_google_sheets"],
  },

  {
    id: "tone_style",
    section: "tone",
    label: "Como deberia sonar el agente?",
    type: "choice",
    required: true,
    options: ["Formal", "Cercano", "Premium", "Joven", "Institucional", "Muy directo", "Otro"],
    target: ["tone", "style"],
  },
  {
    id: "tone_style_other",
    section: "tone",
    label: "Que otro estilo deberia tener?",
    type: "text",
    required: true,
    showIf: { field: "tone_style", equals: "Otro" },
    target: ["tone", "style_other"],
  },
  {
    id: "response_length",
    section: "tone",
    label: "Preferis respuestas cortas o explicativas?",
    helper: "1 = muy cortas, 5 = mas explicativas.",
    type: "slider",
    required: true,
    min: 1,
    max: 5,
    defaultValue: 3,
    target: ["tone", "response_length"],
  },
  {
    id: "tone_limits",
    section: "tone",
    label: "Frases, palabras o temas que deberia usar o evitar?",
    type: "textarea",
    required: false,
    target: ["tone", "limits_and_phrases"],
  },
  {
    id: "bot_intro",
    section: "tone",
    label: "Como deberia presentarse?",
    type: "text",
    required: false,
    target: ["tone", "bot_intro"],
  },
  {
    id: "disclose_ai",
    section: "tone",
    label: "Debe aclarar que es un asistente con IA?",
    type: "toggle",
    required: false,
    options: ["Si", "No"],
    target: ["tone", "disclose_ai"],
  },

  {
    id: "tested_reference",
    section: "reference_bot",
    label: "Probaste un agente de referencia?",
    type: "toggle",
    required: false,
    options: ["Si", "No"],
    target: ["reference_bot", "tested_reference"],
  },
  {
    id: "reference_liked",
    section: "reference_bot",
    label: "Que te gusto o que cambiarias?",
    type: "textarea",
    required: false,
    showIf: { field: "tested_reference", equals: "Si" },
    target: ["reference_bot", "notes"],
  },
  {
    id: "interaction_style",
    section: "reference_bot",
    label: "Preferis menu inicial, conversacion libre o hibrido?",
    type: "choice",
    required: false,
    options: ["Menu inicial", "Conversacion libre", "Hibrido", "No estoy seguro"],
    target: ["reference_bot", "interaction_style"],
  },
];

Object.assign(window, {
  MIRAI_ONBOARDING_VERSION,
  MIRAI_ONBOARDING_TYPE_SECTION,
  MIRAI_ONBOARDING_TYPE_QUESTION,
  MIRAI_ONBOARDING_SECTIONS_REALESTATE,
  MIRAI_ONBOARDING_QUESTIONS_REALESTATE,
  MIRAI_ONBOARDING_SECTIONS_BUSINESS,
  MIRAI_ONBOARDING_QUESTIONS_BUSINESS,
});
