/* global React */ const { useState, useEffect, useRef } = React; // ─────────── Case Type Selection ─────────── const CaseTypeSelect = ({ onDone }) => { const { tweaks } = useApp(); const T = tweaks.lang === 'ES'; const [sel, setSel] = useState('ssdi'); const types = [ { k:'ssdi', ico:'balance', tag:'SSDI', title:T?'Seguro por Discapacidad':'Social Security Disability Insurance', desc:T?'Para quienes han trabajado y pagado al Seguro Social.':'If you have worked and paid into Social Security.', time:T?'Típicamente 40–55 min':'Typically 40–55 min' }, { k:'ssi', ico:'shield', tag:'SSI', title:T?'Ingreso de Seguridad Suplementaria':'Supplemental Security Income', desc:T?'Para adultos o niños con ingresos limitados y discapacidad.':'For adults or children with limited income and a disability.', time:T?'Típicamente 45–60 min':'Typically 45–60 min' }, { k:'vadis', ico:'flag', tag:'VA Disability', title:T?'Discapacidad de VA':'VA Disability Compensation', desc:T?'Para veteranos con condición conectada al servicio.':'For veterans with a service-connected condition.', time:T?'Típicamente 50–70 min':'Typically 50–70 min' }, { k:'vahealth', ico:'doc', tag:'VA Healthcare', title:T?'Atención de Salud VA':'VA Healthcare Enrollment', desc:T?'Inscripción en el sistema de salud VA.':'Enrollment in the VA healthcare system.', time:T?'Típicamente 25–35 min':'Typically 25–35 min' }, ]; return (
{T?'Tipo de solicitud':'Choose your case type'}

{T?'¿Qué beneficio está solicitando?':'Which benefit are you applying for?'}

{T?'Puede cambiar esto después. Si no está seguro, use la verificación de elegibilidad.':'You can change this later. Not sure? Take our 2-minute eligibility check.'}

{types.map(t => ( ))}
{T?'¿No está seguro?':'Not sure which one?'} {T?'Tómese 2 minutos para una verificación rápida de elegibilidad. No guarda respuestas.':'Take a 2-minute eligibility check before committing. Your answers aren\'t saved.'}
{T?'Atrás':'Back'} {T?'Continuar':'Continue'}
); }; // ─────────── Pre-flight Eligibility ─────────── const PreFlight = ({ onDone }) => { const [step, setStep] = useState(0); const [eligible, setEligible] = useState(true); const qs = [ { q: 'Are you a U.S. citizen, permanent resident, or refugee/asylee?', opts:['Yes','No','Not sure'] }, { q: 'Do you have a medical condition that has lasted (or is expected to last) at least 12 months?', opts:['Yes','No'] }, { q: 'Are you currently working? If yes, how much are you earning?', opts:['Not working','Less than $1,550/month','$1,550 or more'] }, { q: 'Have you worked and paid Social Security taxes in at least 5 of the past 10 years?', opts:['Yes','No','Not sure'] }, ]; const done = step >= qs.length; return (
Quick eligibility check
{done ? 'RESULT' : `${step+1} / ${qs.length}`}
{!done ? (
Question {step+1}

{qs[step].q}

{qs[step].opts.map((o,i) => ( ))}
Your answers here are not saved and won't affect your application. This is just for guidance.
) : (
{eligible ? <>

Looks like a strong match

Based on your answers, you likely qualify to apply for SSDI. A human reviewer will verify everything.

This is not an approval. The final decision is made by the Social Security Administration. This screening is an estimate only. : <>

You may not meet every requirement

Based on what you shared, you may not qualify for this specific benefit — but you might qualify for another. Would you like to try SSI instead?

}
{setStep(0); setEligible(true);}}> Restart check Continue to application
)}
); }; // ─────────── Intake Sections (data) ─────────── const INTAKE_SECTIONS = [ { k:'personal', title:'About you', steps: ['Name & DOB','Contact','Address','Marital status'] }, { k:'medical', title:'Medical history', steps: ['Primary condition','Diagnosis date','Treating doctors','Medications','Hospitalizations'] }, { k:'work', title:'Work history', steps: ['Current work','Past 15 years','Education','Skills'] }, { k:'daily', title:'Daily living', steps: ['Typical day','Mobility','Self-care','Social'] }, { k:'financial', title:'Finances', steps: ['Income','Resources','Dependents'] }, ]; // ─────────── Smart Intake (hybrid) ─────────── const SmartIntake = ({ onDone, onMessages }) => { const { tweaks } = useApp(); const T = tweaks.lang === 'ES'; const [messages, setMessages] = useState([ { who:'g', text: T?'Hola María 👋 Soy su asistente. Trabajemos juntos en su solicitud de SSDI. Todo lo que escriba se guarda automáticamente. ¿Lista para empezar?':"Hi Maria — I'm your guide. Let's work through your SSDI application together. Everything you type is saved as you go. Ready when you are." }, { who:'u', text: T?'Sí, gracias':"Yes, let's start"}, { who:'g', text: T?'Perfecto. Empecemos por algo fácil: ¿Cuándo comenzó a afectarle su condición de salud en el trabajo o actividades diarias?':"Great. Let's start with something easy — when did your health condition first start affecting your work or daily activities?" }, { who:'u', text: T?'Alrededor de marzo de 2023. La fibromialgia se intensificó mucho.':'Around March 2023. My fibromyalgia flared up badly then.' }, { who:'g', text: T?'Gracias por compartir. Eso nos ayuda mucho. ¿Recuerda haber visto a un médico en ese momento? El nombre y la fecha aproximada es suficiente por ahora.':'Thanks for sharing that. Do you remember seeing a doctor around then? Their name and an approximate date is enough for now.', explainer: T?'¿Por qué preguntamos?': 'Why we\'re asking', explainerBody: T?'La SSA necesita ver un registro médico continuo. Si no recuerda el nombre exacto, está bien — puede añadirlo después.':'The SSA needs to see a continuous medical record. If you don\'t remember the exact name, that\'s OK — you can add it later.' }, ]); const [input, setInput] = useState(''); const [sectionIdx, setSectionIdx] = useState(1); const [stepIdx, setStepIdx] = useState(2); const chatRef = useRef(null); useEffect(() => { chatRef.current?.scrollTo({ top: chatRef.current.scrollHeight, behavior:'smooth' }); }, [messages]); const send = () => { if (!input.trim()) return; setMessages(m => [...m, { who:'u', text: input }]); setInput(''); setTimeout(() => { setMessages(m => [...m, { who:'g', text: T?'Anotado. ¿Su médico le recetó algún medicamento para la fibromialgia? Si es así, ¿recuerda los nombres?':"Got it. Did your doctor prescribe any medications for your fibromyalgia? If so, do you remember which ones?", explainer: T?'Pista útil':'Helpful hint', explainerBody: T?'Una foto de la etiqueta del medicamento funciona. La leeremos y la completaremos por usted.':'A photo of the prescription label works — we\'ll read it and fill this in for you.' }]); setStepIdx(s => Math.min(s+1, 4)); }, 600); }; const progress = Math.round(((sectionIdx + stepIdx/5) / INTAKE_SECTIONS.length) * 100); return (
{/* LEFT NAV */} {/* CHAT */}
{INTAKE_SECTIONS[sectionIdx].title}
{INTAKE_SECTIONS[sectionIdx].steps[stepIdx]}
Save & exit Messages 2
{messages.map((m,i) => ( m.who === 'g' ?
Guide
{m.text}
{m.explainer && (
{m.explainer}: {m.explainerBody}
)}
:
{m.text}
))}
setInput(e.target.value)} onKeyDown={e=>{ if (e.key === 'Enter') send(); }} />
{/* RIGHT — live answer panel */}
); }; // ─────────── Contradiction Resolution ─────────── const ContradictionScreen = ({ onDone, onBack }) => { const [choice, setChoice] = useState(null); return (
One quick thing. We found two answers that don't quite match. Help us pick the right one — this won't delay your case.

Which date is correct?

You mentioned your condition started at two different times. Pick the one that feels closest to the truth — approximate is fine.

{[ { k:'a', label:'March 2023', where:'You said: "Around March 2023. The fibromyalgia flared up badly then."', section:'Medical history · Step 1', when:'14 minutes ago' }, { k:'b', label:'Summer 2022', where:'In your intake, you answered "Summer 2022" to the question "When did symptoms first appear?"', section:'Medical history · Step 2', when:'9 minutes ago' }, ].map(opt => ( ))}
We check for small mismatches because the SSA rejects applications with conflicting dates. It's usually a small memory thing — not a problem.
Back Save answer
); }; Object.assign(window, { CaseTypeSelect, PreFlight, SmartIntake, ContradictionScreen, INTAKE_SECTIONS });