@johpaz/hive-agents 0.0.37 → 0.0.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -16
- package/dist/hive.js +107 -105
- package/dist/tool-worker.js +25 -36
- package/dist/ui/assets/{AgentCreateForm-tJZv9FZC.js → AgentCreateForm-0oFbN3gj.js} +1 -1
- package/dist/ui/assets/{AgentDetailPage-Du-mRcAX.js → AgentDetailPage-BJ4L2fNJ.js} +1 -1
- package/dist/ui/assets/AgentNewPage-B3n0LUck.js +1 -0
- package/dist/ui/{dist/assets/AgentsPage-YvSgWRiw.js → assets/AgentsPage-DGNLDXjR.js} +1 -1
- package/dist/ui/assets/{CanvasPage-DtMwGvxf.js → CanvasPage-CnMO1FN8.js} +1 -1
- package/dist/ui/assets/{ChannelsPage-BdBXWHjj.js → ChannelsPage-fbF8K4MR.js} +1 -1
- package/dist/ui/{dist/assets/DashboardPage-ghl1ZguH.js → assets/DashboardPage-VyXXp3U1.js} +1 -1
- package/dist/ui/assets/{LoginPage-CAmSI9Vy.js → LoginPage-DPj2s2Qq.js} +1 -1
- package/dist/ui/{dist/assets/LogsPage-DAPBHkwK.js → assets/LogsPage-B2lY9maY.js} +1 -1
- package/dist/ui/{dist/assets/MeetingPage-WjjGOqqU.js → assets/MeetingPage-2ky_hKiG.js} +1 -1
- package/dist/ui/{dist/assets/ProvidersPage-Ct6HsAi1.js → assets/ProvidersPage-CEyUM2tD.js} +1 -1
- package/dist/ui/{dist/assets/RecoverPage-DpW3l-yv.js → assets/RecoverPage-B-hDZUM2.js} +1 -1
- package/dist/ui/{dist/assets/SettingsPage-DBJ7_E6C.js → assets/SettingsPage-eO0i3g8p.js} +1 -1
- package/dist/ui/assets/{SetupPage-DKmLVUaj.js → SetupPage-ByYqTELb.js} +1 -1
- package/dist/ui/assets/WebChatPage-BuGT2AL0.js +16 -0
- package/dist/ui/assets/{alert-C-NE-P3s.js → alert-Bq6awLlW.js} +1 -1
- package/dist/ui/{dist/assets/alert-dialog-C5mzbHdP.js → assets/alert-dialog-DQvltYmf.js} +1 -1
- package/dist/ui/assets/{badge-ChpACfWO.js → badge-DXUDdTed.js} +1 -1
- package/dist/ui/assets/{dialog-QnZ0ad8O.js → dialog-bI9jImCS.js} +1 -1
- package/dist/ui/assets/{es-NQNoaWDx.js → es-Cg8zdT52.js} +1 -1
- package/dist/ui/{dist/assets/index-DMCjjdqf.js → assets/index-CQ7fn00w.js} +2 -2
- package/dist/ui/assets/{label-D2H1IR_J.js → label-CrH0Jj3v.js} +1 -1
- package/dist/ui/assets/useProviders-CnlC_qCS.js +1 -0
- package/dist/ui/dist/assets/{AgentCreateForm-tJZv9FZC.js → AgentCreateForm-0oFbN3gj.js} +1 -1
- package/dist/ui/dist/assets/{AgentDetailPage-Du-mRcAX.js → AgentDetailPage-BJ4L2fNJ.js} +1 -1
- package/dist/ui/dist/assets/AgentNewPage-B3n0LUck.js +1 -0
- package/dist/ui/{assets/AgentsPage-YvSgWRiw.js → dist/assets/AgentsPage-DGNLDXjR.js} +1 -1
- package/dist/ui/dist/assets/{CanvasPage-DtMwGvxf.js → CanvasPage-CnMO1FN8.js} +1 -1
- package/dist/ui/dist/assets/{ChannelsPage-BdBXWHjj.js → ChannelsPage-fbF8K4MR.js} +1 -1
- package/dist/ui/{assets/DashboardPage-ghl1ZguH.js → dist/assets/DashboardPage-VyXXp3U1.js} +1 -1
- package/dist/ui/dist/assets/{LoginPage-CAmSI9Vy.js → LoginPage-DPj2s2Qq.js} +1 -1
- package/dist/ui/{assets/LogsPage-DAPBHkwK.js → dist/assets/LogsPage-B2lY9maY.js} +1 -1
- package/dist/ui/{assets/MeetingPage-WjjGOqqU.js → dist/assets/MeetingPage-2ky_hKiG.js} +1 -1
- package/dist/ui/{assets/ProvidersPage-Ct6HsAi1.js → dist/assets/ProvidersPage-CEyUM2tD.js} +1 -1
- package/dist/ui/{assets/RecoverPage-DpW3l-yv.js → dist/assets/RecoverPage-B-hDZUM2.js} +1 -1
- package/dist/ui/{assets/SettingsPage-DBJ7_E6C.js → dist/assets/SettingsPage-eO0i3g8p.js} +1 -1
- package/dist/ui/dist/assets/{SetupPage-DKmLVUaj.js → SetupPage-ByYqTELb.js} +1 -1
- package/dist/ui/dist/assets/WebChatPage-BuGT2AL0.js +16 -0
- package/dist/ui/dist/assets/{alert-C-NE-P3s.js → alert-Bq6awLlW.js} +1 -1
- package/dist/ui/{assets/alert-dialog-C5mzbHdP.js → dist/assets/alert-dialog-DQvltYmf.js} +1 -1
- package/dist/ui/dist/assets/{badge-ChpACfWO.js → badge-DXUDdTed.js} +1 -1
- package/dist/ui/dist/assets/{dialog-QnZ0ad8O.js → dialog-bI9jImCS.js} +1 -1
- package/dist/ui/dist/assets/{es-NQNoaWDx.js → es-Cg8zdT52.js} +1 -1
- package/dist/ui/{assets/index-DMCjjdqf.js → dist/assets/index-CQ7fn00w.js} +2 -2
- package/dist/ui/dist/assets/{label-D2H1IR_J.js → label-CrH0Jj3v.js} +1 -1
- package/dist/ui/dist/assets/useProviders-CnlC_qCS.js +1 -0
- package/dist/ui/dist/index.html +1 -1
- package/dist/ui/index.html +1 -1
- package/package.json +1 -1
- package/packages/cli/src/commands/gateway.ts +1 -1
- package/packages/cli/src/commands/onboard.ts +1 -1
- package/packages/core/src/agent/agent-loop.ts +4 -14
- package/packages/core/src/agent/context-compiler.ts +1 -1
- package/packages/core/src/agent/conversation-store.ts +4 -5
- package/packages/core/src/agent/providers/index.ts +3 -4
- package/packages/core/src/agent/tool-selector.ts +3 -4
- package/packages/core/src/gateway/resolver.ts +5 -1
- package/packages/core/src/gateway/routes/chat.ts +16 -16
- package/packages/core/src/gateway/server.ts +44 -45
- package/packages/core/src/storage/seed.ts +39 -33
- package/packages/core/src/tool-runtime/index.ts +20 -0
- package/dist/ui/assets/AgentNewPage-DIFYd_Ys.js +0 -1
- package/dist/ui/assets/WebChatPage-CVRcKept.js +0 -16
- package/dist/ui/assets/useProviders-C6_QHsEi.js +0 -1
- package/dist/ui/dist/assets/AgentNewPage-DIFYd_Ys.js +0 -1
- package/dist/ui/dist/assets/WebChatPage-CVRcKept.js +0 -16
- package/dist/ui/dist/assets/useProviders-C6_QHsEi.js +0 -1
|
@@ -44,19 +44,7 @@ export const SEED_DATA: SeedData = {
|
|
|
44
44
|
{ id: "browser_wait", name: "browser_wait", category: "web", description: "Esperar a que aparezca un elemento o se cumpla una condición. Sinónimos: esperar, condición, elemento, selector, pausa" },
|
|
45
45
|
|
|
46
46
|
// ─────────────────────────────────────────
|
|
47
|
-
// 3.
|
|
48
|
-
// ─────────────────────────────────────────
|
|
49
|
-
{ id: "project_create", name: "project_create", category: "projects", description: "Crear un nuevo proyecto con tareas en la base de datos. Sinónimos: nuevo proyecto, iniciar plan, crear proyecto" },
|
|
50
|
-
{ id: "project_list", name: "project_list", category: "projects", description: "Listar todos los proyectos con su estado. Sinónimos: ver proyectos, historial, listar proyectos, mostrar proyectos" },
|
|
51
|
-
{ id: "project_update", name: "project_update", category: "projects", description: "Actualizar progreso o metadatos del proyecto. Sinónimos: avance, porcentaje, estado, actualizar proyecto" },
|
|
52
|
-
{ id: "project_done", name: "project_done", category: "projects", description: "Marcar proyecto como completado y archivarlo. Sinónimos: proyecto terminado, cerrar proyecto, completado, finalizar" },
|
|
53
|
-
{ id: "project_fail", name: "project_fail", category: "projects", description: "Marcar proyecto como fallido y registrar razón. Sinónimos: proyecto fallido, marcar fracaso, error, falló proyecto" },
|
|
54
|
-
{ id: "task_create", name: "task_create", category: "projects", description: "Agregar una tarea o subtarea a un proyecto existente. Sinónimos: crear tarea, agregar tarea, subtarea, pendiente" },
|
|
55
|
-
{ id: "task_update", name: "task_update", category: "projects", description: "Actualizar estado de tarea (pendiente, en_progreso, hecho). Sinónimos: actualizar tarea, marcar completa, en progreso" },
|
|
56
|
-
{ id: "task_evaluate", name: "task_evaluate", category: "projects", description: "Evaluar resultado de tarea contra criterios de aceptación. Sinónimos: validar resultado, criterios de aceptación, revisar tarea" },
|
|
57
|
-
|
|
58
|
-
// ─────────────────────────────────────────
|
|
59
|
-
// 4. CRON — Tareas programadas (Croner-based)
|
|
47
|
+
// 3. CRON — Tareas programadas (Croner-based)
|
|
60
48
|
// ─────────────────────────────────────────
|
|
61
49
|
{ id: "cron.create", name: "cron.create", category: "cron", description: "Crear tarea programada: recurrente (expresión cron) o única (fire_at). Requiere campo 'task' con instrucción para el agente. Sinónimos: programar tarea, crear recordatorio, agendar, automatizar horario, tarea recurrente, una vez" },
|
|
62
50
|
{ id: "cron.list", name: "cron.list", category: "cron", description: "Listar todas las tareas programadas con próximos horarios de ejecución. Sinónimos: ver tareas programadas, listar cronograma, próximas ejecuciones" },
|
|
@@ -68,12 +56,12 @@ export const SEED_DATA: SeedData = {
|
|
|
68
56
|
{ id: "cron.history", name: "cron.history", category: "cron", description: "Obtener historial de ejecuciones y logs de una tarea programada. Sinónimos: historial ejecuciones, logs tarea, registro ejecuciones" },
|
|
69
57
|
|
|
70
58
|
// ─────────────────────────────────────────
|
|
71
|
-
//
|
|
59
|
+
// 4. CLI — Ejecución de comandos
|
|
72
60
|
// ─────────────────────────────────────────
|
|
73
61
|
{ id: "cli_exec", name: "cli_exec", category: "cli", description: "Ejecutar comandos shell/bash en el entorno del agente. NOTA: NO usar para tareas programadas, usar cron.create. Sinónimos: ejecutar comando, terminal, bash, script, consola" },
|
|
74
62
|
|
|
75
63
|
// ─────────────────────────────────────────
|
|
76
|
-
//
|
|
64
|
+
// 5. AGENTS — Memoria, workers y delegación
|
|
77
65
|
// ─────────────────────────────────────────
|
|
78
66
|
{ id: "memory_write", name: "memory_write", category: "agents", description: "Guardar información en memoria persistente a largo plazo. Sinónimos: guardar memoria, recordar, guardar dato, memoria persistente" },
|
|
79
67
|
{ id: "memory_read", name: "memory_read", category: "agents", description: "Recuperar una entrada de memoria por identificador. Sinónimos: leer memoria, recuperar dato, obtener memoria" },
|
|
@@ -89,10 +77,9 @@ export const SEED_DATA: SeedData = {
|
|
|
89
77
|
{ id: "task_status", name: "task_status", category: "agents", description: "Obtener estado de ejecución de tareas delegadas. Sinónimos: estado tarea delegada, verificar progreso, consultar tarea" },
|
|
90
78
|
{ id: "bus_publish", name: "bus_publish", category: "agents", description: "Publicar mensaje en el Agent Bus para comunicación worker-to-worker. Sinónimos: publicar mensaje, comunicar workers, enviar bus" },
|
|
91
79
|
{ id: "bus_read", name: "bus_read", category: "agents", description: "Leer mensajes no leídos del Agent Bus. Sinónimos: leer mensajes bus, recibir mensajes, verificar bus" },
|
|
92
|
-
{ id: "project_updates", name: "project_updates", category: "agents", description: "Obtener actualizaciones recientes de workers en el mismo proyecto. Sinónimos: actualizaciones proyecto, estado workers, progreso equipo" },
|
|
93
80
|
|
|
94
81
|
// ─────────────────────────────────────────
|
|
95
|
-
//
|
|
82
|
+
// 6. CANVAS — UI interactiva
|
|
96
83
|
// ─────────────────────────────────────────
|
|
97
84
|
{ id: "canvas_render", name: "canvas_render", category: "canvas", description: "Renderizar un componente o visualización en el canvas. Sinónimos: renderizar, visualizar, gráfico, diagrama" },
|
|
98
85
|
{ id: "canvas_ask", name: "canvas_ask", category: "canvas", description: "Mostrar formulario interactivo y esperar input del usuario. Sinónimos: formulario interactivo, preguntar usuario, input" },
|
|
@@ -103,7 +90,7 @@ export const SEED_DATA: SeedData = {
|
|
|
103
90
|
{ id: "canvas_clear", name: "canvas_clear", category: "canvas", description: "Limpiar contenido actual del canvas. Sinónimos: limpiar canvas, borrar visualización, resetear" },
|
|
104
91
|
|
|
105
92
|
// ─────────────────────────────────────────
|
|
106
|
-
//
|
|
93
|
+
// 6b. CANVAS A2UI v0.9 — Superficies interactivas ricas
|
|
107
94
|
// ─────────────────────────────────────────
|
|
108
95
|
{ id: "a2ui_create_surface", name: "a2ui_create_surface", category: "a2ui", description: "Crear superficie A2UI v0.9 para UI interactiva rica: formularios, dashboards, wizards, flujos multi-paso. Siempre llamar ANTES de a2ui_update_components. Requiere surfaceId y catalogId='https://a2ui.org/specification/v0_9/basic_catalog.json'. Sinónimos: crear superficie A2UI, iniciar UI A2UI, crear form A2UI, interfaz interactiva, crear dashboard A2UI" },
|
|
109
96
|
{ id: "a2ui_update_components", name: "a2ui_update_components", category: "a2ui", description: "Enviar componentes A2UI v0.9 como lista plana (adjacency list). Tipos: Text, Button, TextField, Row, Column, Card, List, Tabs, Modal, ChoicePicker, Slider, CheckBox, DateTimeInput, Image, Divider. Reglas: children usa explicitList (NO array), ChoicePicker usa selections (NO value), TextField usa textFieldType (NO variant), Tabs.tabItems.title es string plano. Sinónimos: actualizar componentes A2UI, enviar UI A2UI, renderizar componentes A2UI, layout A2UI" },
|
|
@@ -111,21 +98,21 @@ export const SEED_DATA: SeedData = {
|
|
|
111
98
|
{ id: "a2ui_delete_surface", name: "a2ui_delete_surface", category: "a2ui", description: "Eliminar superficie A2UI v0.9 del canvas. Usar al completar o cancelar el flujo para liberar recursos. Sinónimos: eliminar superficie A2UI, borrar UI A2UI, cerrar formulario A2UI, limpiar canvas A2UI" },
|
|
112
99
|
|
|
113
100
|
// ─────────────────────────────────────────
|
|
114
|
-
//
|
|
101
|
+
// 7. VOICE — Voz
|
|
115
102
|
// ─────────────────────────────────────────
|
|
116
103
|
{ id: "voice_transcribe", name: "voice_transcribe", category: "voice", description: "Transcribir entrada de audio a texto. Sinónimos: transcribir audio, voz a texto, reconocimiento de voz" },
|
|
117
104
|
{ id: "voice_speak", name: "voice_speak", category: "voice", description: "Convertir texto a voz sintetizada. Sinónimos: texto a voz, sintetizar, hablar, leer en voz alta" },
|
|
118
105
|
|
|
119
|
-
//
|
|
106
|
+
// 8. SEARCH-KNOWLEDGE
|
|
120
107
|
{ id: "search_knowledge", name: "search_knowledge", category: "search-knowledge", description: "Buscar en la base de conocimientos. Sinónimos: buscar conocimiento, buscar en la base" },
|
|
121
108
|
|
|
122
|
-
//
|
|
109
|
+
// 9. CORE — Notificaciones y notas
|
|
123
110
|
{ id: "notify", name: "notify", category: "core", description: "Enviar notificación al usuario. Sinónimos: notificar, enviar notificación, alertar, aviso" },
|
|
124
111
|
{ id: "save_note", name: "save_note", category: "core", description: "Guardar nota persistente en el scratchpad. Sinónimos: guardar nota, escribir nota, recordatorio rápido, apuntar" },
|
|
125
112
|
{ id: "report_progress", name: "report_progress", category: "core", description: "Reportar progreso actual al usuario. Sinónimos: reportar progreso, informar estado, actualizar progreso, porcentaje" },
|
|
126
113
|
|
|
127
114
|
// ─────────────────────────────────────────
|
|
128
|
-
//
|
|
115
|
+
// 10. OFFICE — Archivos Office (PDF, DOCX, XLSX, PPTX)
|
|
129
116
|
// ─────────────────────────────────────────
|
|
130
117
|
{ id: "office_leer_pdf", name: "office_leer_pdf", category: "office", description: "Leer contenido de un archivo PDF y retornar texto plano con metadata. Sinónimos: leer pdf, abrir pdf, extraer texto de pdf, contenido pdf, pdf a texto" },
|
|
131
118
|
{ id: "office_escribir_pdf", name: "office_escribir_pdf", category: "office", description: "Generar un archivo PDF desde texto con configuración de márgenes y tamaño de página. Sinónimos: crear pdf, generar pdf, escribir pdf, exportar a pdf" },
|
|
@@ -361,9 +348,9 @@ const INITIAL_PLAYBOOK_RULES = [
|
|
|
361
348
|
applicable_to: JSON.stringify(["code", "development"]),
|
|
362
349
|
},
|
|
363
350
|
{
|
|
364
|
-
rule: "Al
|
|
351
|
+
rule: "Al delegar trabajo complejo a workers, divide el objetivo en pasos atómicos que puedan ejecutarse independientemente",
|
|
365
352
|
category: "agent_creation",
|
|
366
|
-
applicable_to: JSON.stringify(["
|
|
353
|
+
applicable_to: JSON.stringify(["delegation", "workers", "tasks"]),
|
|
367
354
|
},
|
|
368
355
|
{
|
|
369
356
|
rule: "Guarda las preferencias importantes del usuario en el scratchpad usando la herramienta save_note para persistencia entre sesiones",
|
|
@@ -552,24 +539,43 @@ export function seedAllData(): void {
|
|
|
552
539
|
log.info("[seed] ✅ webchat activado por defecto");
|
|
553
540
|
|
|
554
541
|
// 🔟 ACE Playbook - Initial rules for Agentic Context Engineering
|
|
542
|
+
db.query(`DELETE FROM playbook WHERE rule = ?`).run(
|
|
543
|
+
"Al crear proyectos, divide las tareas en pasos atómicos que puedan ejecutarse independientemente"
|
|
544
|
+
);
|
|
545
|
+
|
|
555
546
|
let playbookCount = 0
|
|
556
547
|
for (const rule of INITIAL_PLAYBOOK_RULES) {
|
|
557
|
-
db.query(`
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
548
|
+
const existing = db.query(`SELECT id FROM playbook WHERE rule = ?`).get(rule.rule) as { id: number } | null;
|
|
549
|
+
if (existing) {
|
|
550
|
+
db.query(`
|
|
551
|
+
UPDATE playbook
|
|
552
|
+
SET category = ?, applicable_to = ?, active = 1, updated_at = unixepoch()
|
|
553
|
+
WHERE id = ?
|
|
554
|
+
`).run(rule.category, rule.applicable_to, existing.id);
|
|
555
|
+
} else {
|
|
556
|
+
db.query(`
|
|
557
|
+
INSERT INTO playbook (rule, category, applicable_to, helpful_count, harmful_count, active)
|
|
558
|
+
VALUES (?, ?, ?, 1, 0, 1)
|
|
559
|
+
`).run(rule.rule, rule.category, rule.applicable_to);
|
|
560
|
+
}
|
|
561
561
|
playbookCount++
|
|
562
562
|
}
|
|
563
563
|
log.info(`[seed] ✅ ${playbookCount} ACE playbook rules seeded`);
|
|
564
564
|
|
|
565
|
+
db.run(`DELETE FROM playbook_fts`);
|
|
566
|
+
const activePlaybook = db.query(`
|
|
567
|
+
SELECT id, rule, category, applicable_to
|
|
568
|
+
FROM playbook
|
|
569
|
+
WHERE active = 1
|
|
570
|
+
`).all() as Array<{ id: number; rule: string; category: string; applicable_to: string | null }>;
|
|
565
571
|
const insertPlaybookFts = db.prepare(`
|
|
566
|
-
INSERT OR REPLACE INTO playbook_fts(rule, category, applicable_to)
|
|
567
|
-
VALUES (?, ?, ?)
|
|
572
|
+
INSERT OR REPLACE INTO playbook_fts(rowid, rule, category, applicable_to)
|
|
573
|
+
VALUES (?, ?, ?, ?)
|
|
568
574
|
`);
|
|
569
|
-
for (const rule of
|
|
570
|
-
insertPlaybookFts.run(rule.rule, rule.category, rule.applicable_to);
|
|
575
|
+
for (const rule of activePlaybook) {
|
|
576
|
+
insertPlaybookFts.run(rule.id, rule.rule, rule.category, rule.applicable_to);
|
|
571
577
|
}
|
|
572
|
-
log.info(`[seed] ✅ ${
|
|
578
|
+
log.info(`[seed] ✅ ${activePlaybook.length} reglas playbook sincronizadas a playbook_fts`);
|
|
573
579
|
|
|
574
580
|
log.info("[seed] ✨ Seed completado exitosamente.");
|
|
575
581
|
} catch (err) {
|
|
@@ -139,6 +139,26 @@ function toolErrorResult(
|
|
|
139
139
|
}
|
|
140
140
|
|
|
141
141
|
const DEFAULT_MAIN_THREAD_TOOL_NAMES = new Set([
|
|
142
|
+
// These tools depend on process-local singleton state (SQLite DB, live
|
|
143
|
+
// channel senders, schedulers, browser sessions, or in-memory services).
|
|
144
|
+
"search_knowledge",
|
|
145
|
+
"save_note",
|
|
146
|
+
"memory_write",
|
|
147
|
+
"memory_read",
|
|
148
|
+
"memory_list",
|
|
149
|
+
"memory_search",
|
|
150
|
+
"memory_delete",
|
|
151
|
+
"agent_create",
|
|
152
|
+
"agent_find",
|
|
153
|
+
"agent_archive",
|
|
154
|
+
"task_status",
|
|
155
|
+
"bus_publish",
|
|
156
|
+
"bus_read",
|
|
157
|
+
"get_available_models",
|
|
158
|
+
"meeting_start",
|
|
159
|
+
"meeting_add_segment",
|
|
160
|
+
"meeting_stop",
|
|
161
|
+
"meeting_report",
|
|
142
162
|
"browser_navigate",
|
|
143
163
|
"browser_screenshot",
|
|
144
164
|
"browser_click",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./vendor-query-DsWPbQdG.js";import{t}from"./AgentCreateForm-tJZv9FZC.js";var n=e();function r(){return(0,n.jsx)(t,{})}export{r as AgentNewPage};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{_ as t}from"./vendor-charts-Bu2lyBKP.js";import{o as n}from"./vendor-query-DsWPbQdG.js";import{n as r,r as i}from"./utils-3pnRFmFe.js";import{t as a}from"./circle-alert-CyHDwUj8.js";import{t as o}from"./file-text-BT_9S9SM.js";import{t as s}from"./gauge-D_TMa4i9.js";import{n as c,t as l}from"./square-BD81nFtN.js";import{t as u}from"./pause-BUqah9Bi.js";import{t as d}from"./play-NcZ4swwL.js";import{t as f}from"./refresh-cw-DaYdjQFk.js";import{C as p,_ as m,a as h,b as g,c as _,d as v,f as y,g as b,h as x,i as S,l as C,m as w,n as T,o as E,p as D,r as O,s as k,t as A,u as j,v as M,x as ee,y as te}from"./slider-CsiUDxc3.js";import{t as ne}from"./sparkles-yUEb-7oH.js";import{t as re}from"./triangle-alert-C9Y8Ub4X.js";import{t as N}from"./volume-2-CeSXNDv4.js";import{t as ie}from"./zap-hlXjpSeA.js";import{r as ae}from"./gateway-url-COCbW0IR.js";import{J as P,R as oe,S as se,f as ce,p as le,r as ue,x as de}from"./index-DMCjjdqf.js";var fe=i(`Paperclip`,[[`path`,{d:`m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48`,key:`1u3ebp`}]]),pe=i(`SendHorizontal`,[[`path`,{d:`M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z`,key:`117uat`}],[`path`,{d:`M6 12h16`,key:`s4cdu5`}]]),me=i(`Volume1`,[[`path`,{d:`M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z`,key:`uqj9uw`}],[`path`,{d:`M16 9a5 5 0 0 1 0 6`,key:`1q6k2b`}]]),he=i(`VolumeX`,[[`path`,{d:`M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z`,key:`uqj9uw`}],[`line`,{x1:`22`,x2:`16`,y1:`9`,y2:`15`,key:`1ewh16`}],[`line`,{x1:`16`,x2:`22`,y1:`9`,y2:`15`,key:`5ykzw1`}]]),F=e(t(),1);function ge(e,t){let n;try{n=e()}catch{return}return{getItem:e=>{let r=e=>e===null?null:JSON.parse(e,t?.reviver),i=n.getItem(e)??null;return i instanceof Promise?i.then(r):r(i)},setItem:(e,r)=>n.setItem(e,JSON.stringify(r,t?.replacer)),removeItem:e=>n.removeItem(e)}}var I=e=>t=>{try{let n=e(t);return n instanceof Promise?n:{then(e){return I(e)(n)},catch(e){return this}}}catch(e){return{then(e){return this},catch(t){return I(t)(e)}}}},L=ae()(((e,t)=>(n,r,i)=>{let a={storage:ge(()=>window.localStorage),partialize:e=>e,version:0,merge:(e,t)=>({...t,...e}),...t},o=!1,s=0,c=new Set,l=new Set,u=a.storage;if(!u)return e((...e)=>{console.warn(`[zustand persist middleware] Unable to update item '${a.name}', the given storage is currently unavailable.`),n(...e)},r,i);let d=()=>{let e=a.partialize({...r()});return u.setItem(a.name,{state:e,version:a.version})},f=i.setState;i.setState=(e,t)=>(f(e,t),d());let p=e((...e)=>(n(...e),d()),r,i);i.getInitialState=()=>p;let m,h=()=>{if(!u)return;let e=++s;o=!1,c.forEach(e=>e(r()??p));let t=a.onRehydrateStorage?.call(a,r()??p)||void 0;return I(u.getItem.bind(u))(a.name).then(e=>{if(e)if(typeof e.version==`number`&&e.version!==a.version){if(a.migrate){let t=a.migrate(e.state,e.version);return t instanceof Promise?t.then(e=>[!0,e]):[!0,t]}console.error(`State loaded from storage couldn't be migrated since no migrate function was provided`)}else return[!1,e.state];return[!1,void 0]}).then(t=>{if(e!==s)return;let[i,o]=t;if(m=a.merge(o,r()??p),n(m,!0),i)return d()}).then(()=>{e===s&&(t?.(r(),void 0),m=r(),o=!0,l.forEach(e=>e(m)))}).catch(n=>{e===s&&t?.(void 0,n)})};return i.persist={setOptions:e=>{a={...a,...e},e.storage&&(u=e.storage)},clearStorage:()=>{u?.removeItem(a.name)},getOptions:()=>a,rehydrate:()=>h(),hasHydrated:()=>o,onHydrate:e=>(c.add(e),()=>{c.delete(e)}),onFinishHydration:e=>(l.add(e),()=>{l.delete(e)})},a.skipHydration||h(),m||p})(e=>({messages:[],isLoading:!1,currentSteps:[],streamingMessageId:null,connectionWarning:null,addMessage:t=>e(e=>({messages:[...e.messages,t]})),addMessages:t=>e(e=>({messages:[...e.messages,...t]})),updateMessage:(t,n)=>e(e=>({messages:e.messages.map(e=>e.id===t?{...e,...n}:e)})),setMessages:t=>e({messages:t}),clearMessages:()=>e({messages:[],currentSteps:[],streamingMessageId:null}),setLoading:t=>e({isLoading:t}),addStep:t=>e(e=>({currentSteps:[...e.currentSteps.slice(-4),t]})),clearSteps:()=>e({currentSteps:[]}),setStreamingMessageId:t=>e({streamingMessageId:t}),setConnectionWarning:t=>e({connectionWarning:t})}),{name:`hive-chat-storage`,partialize:e=>({messages:e.messages.slice(-15)})}));function _e(e,t){let n=L(e=>e.addMessage),i=L(e=>e.updateMessage),a=L(e=>e.setLoading);L(e=>e.addStep);let o=L(e=>e.clearSteps),s=L(e=>e.setStreamingMessageId),c=(0,F.useRef)(null);return{handleStreamingChunk:(0,F.useCallback)(l=>{l.content?.startsWith(`🎙️ Transcripción:`)&&a(!0);let u=l.id||c.current||r(),{messages:d}=L.getState(),f=d.find(e=>e.id===u);l.isChunk&&f?i(u,{content:(f.content||``)+l.content,timestamp:l.timestamp||f.timestamp}):l.isChunk&&!f?(c.current=u,s(u),n({id:u,conversationId:t,type:`agent`,content:l.content||``,agentId:e,timestamp:l.timestamp||new Date().toISOString()})):f?i(u,{content:l.content||f.content,timestamp:l.timestamp||f.timestamp,...l.audio&&{audio:{base64:l.audio,mimeType:l.mimeType}}}):n({id:u,conversationId:t,type:`agent`,content:l.content||l.message||``,agentId:e,timestamp:l.timestamp||new Date().toISOString(),...l.audio&&{audio:{base64:l.audio,mimeType:l.mimeType}}}),l.isChunk||(c.current=null,s(null),o(),a(!1))},[e,t,n,i,a,o,s]),handleAudioMessage:(0,F.useCallback)(i=>{n({id:i.id||r(),conversationId:t,type:`agent`,content:i.content||``,agentId:e,timestamp:i.timestamp||new Date().toISOString(),audio:i.audio?{base64:i.audio,mimeType:i.mimeType||`audio/wav`}:void 0}),o(),a(!1)},[e,t,n,o,a]),handleProgress:(0,F.useCallback)(e=>{e.content&&(L.getState().addStep(e.content),L.getState().setLoading(!0))},[]),handleTyping:(0,F.useCallback)(e=>{e.isTyping===!0?L.getState().setLoading(!0):e.isTyping===!1&&(L.getState().clearSteps(),L.getState().setLoading(!1))},[]),resetStreamingRef:(0,F.useCallback)(()=>{c.current=null,s(null)},[s])}}var ve=`hive-narration-prefs`;function ye(){try{let e=localStorage.getItem(ve);if(e)return JSON.parse(e)}catch{}return{enabled:!1,rate:1,pitch:1,voiceName:null}}function be(e){try{localStorage.setItem(ve,JSON.stringify(e))}catch{}}function xe(){let[e,t]=(0,F.useState)(ye),[n,r]=(0,F.useState)(!1),[i,a]=(0,F.useState)(null),o=(0,F.useRef)(null),s=(0,F.useCallback)(e=>e&&window.speechSynthesis.getVoices().find(t=>t.name===e)||null,[]),c=(0,F.useCallback)(t=>{if(!e.enabled||!window.speechSynthesis)return;window.speechSynthesis.cancel();let n=t.replace(/```[\s\S]*?```/g,``).replace(/`[^`]+`/g,``).replace(/[#*_~\[\]()]/g,``).replace(/\n{2,}/g,`. `).replace(/\n/g,` `).trim();if(!n)return;let i=new SpeechSynthesisUtterance(n);i.rate=e.rate,i.pitch=e.pitch;let c=s(e.voiceName);c&&(i.voice=c),i.onstart=()=>{r(!0),a(n.slice(0,50))},i.onend=()=>{r(!1),a(null),o.current=null},i.onerror=()=>{r(!1),a(null),o.current=null},o.current=i,window.speechSynthesis.speak(i)},[e,s]),l=(0,F.useCallback)(()=>{window.speechSynthesis.cancel(),r(!1),a(null),o.current=null},[]),u=(0,F.useCallback)(()=>{t(e=>{let t={...e,enabled:!e.enabled};return be(t),t.enabled||(window.speechSynthesis.cancel(),r(!1),a(null)),t})},[]),d=(0,F.useCallback)(e=>{t(t=>{let n={...t,...e};return be(n),n})},[]);return(0,F.useEffect)(()=>{typeof window<`u`&&window.speechSynthesis&&window.speechSynthesis.getVoices()},[]),(0,F.useEffect)(()=>()=>{window.speechSynthesis?.cancel()},[]),{isEnabled:e.enabled,isSpeaking:n,currentText:i,rate:e.rate,pitch:e.pitch,narrate:c,stop:l,toggle:u,updatePrefs:d}}function Se(e,t){let n=String(e);if(typeof t!=`string`)throw TypeError(`Expected character`);let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}function Ce(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function we(e,t,n){let r=h((n||{}).ignore||[]),i=Te(t),a=-1;for(;++a<i.length;)S(e,`text`,o);function o(e,t){let n=-1,i;for(;++n<t.length;){let e=t[n],a=i?i.children:void 0;if(r(e,a?a.indexOf(e):void 0,i))return;i=e}if(i)return s(e,t)}function s(e,t){let n=t[t.length-1],r=i[a][0],o=i[a][1],s=0,c=n.children.indexOf(e),l=!1,u=[];r.lastIndex=0;let d=r.exec(e.value);for(;d;){let n=d.index,i={index:d.index,input:d.input,stack:[...t,e]},a=o(...d,i);if(typeof a==`string`&&(a=a.length>0?{type:`text`,value:a}:void 0),a===!1?r.lastIndex=n+1:(s!==n&&u.push({type:`text`,value:e.value.slice(s,n)}),Array.isArray(a)?u.push(...a):a&&u.push(a),s=n+d[0].length,l=!0),!r.global)break;d=r.exec(e.value)}return l?(s<e.value.length&&u.push({type:`text`,value:e.value.slice(s)}),n.children.splice(c,1,...u)):u=[e],c+u.length}}function Te(e){let t=[];if(!Array.isArray(e))throw TypeError(`Expected find and replace tuple or list of tuples`);let n=!e[0]||Array.isArray(e[0])?e:[e],r=-1;for(;++r<n.length;){let e=n[r];t.push([Ee(e[0]),De(e[1])])}return t}function Ee(e){return typeof e==`string`?new RegExp(Ce(e),`g`):e}function De(e){return typeof e==`function`?e:function(){return e}}var R=`phrasing`,z=[`autolink`,`link`,`image`,`label`];function Oe(){return{transforms:[Fe],enter:{literalAutolink:Ae,literalAutolinkEmail:B,literalAutolinkHttp:B,literalAutolinkWww:B},exit:{literalAutolink:Pe,literalAutolinkEmail:Ne,literalAutolinkHttp:je,literalAutolinkWww:Me}}}function ke(){return{unsafe:[{character:`@`,before:`[+\\-.\\w]`,after:`[\\-.\\w]`,inConstruct:R,notInConstruct:z},{character:`.`,before:`[Ww]`,after:`[\\-.\\w]`,inConstruct:R,notInConstruct:z},{character:`:`,before:`[ps]`,after:`\\/`,inConstruct:R,notInConstruct:z}]}}function Ae(e){this.enter({type:`link`,title:null,url:``,children:[]},e)}function B(e){this.config.enter.autolinkProtocol.call(this,e)}function je(e){this.config.exit.autolinkProtocol.call(this,e)}function Me(e){this.config.exit.data.call(this,e);let t=this.stack[this.stack.length-1];t.type,t.url=`http://`+this.sliceSerialize(e)}function Ne(e){this.config.exit.autolinkEmail.call(this,e)}function Pe(e){this.exit(e)}function Fe(e){we(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,Ie],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,Le]],{ignore:[`link`,`linkReference`]})}function Ie(e,t,n,r,i){let a=``;if(!Be(i)||(/^w/i.test(t)&&(n=t+n,t=``,a=`http://`),!Re(n)))return!1;let o=ze(n+r);if(!o[0])return!1;let s={type:`link`,title:null,url:a+t+o[0],children:[{type:`text`,value:t+o[0]}]};return o[1]?[s,{type:`text`,value:o[1]}]:s}function Le(e,t,n,r){return!Be(r,!0)||/[-\d_]$/.test(n)?!1:{type:`link`,title:null,url:`mailto:`+t+`@`+n,children:[{type:`text`,value:t+`@`+n}]}}function Re(e){let t=e.split(`.`);return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function ze(e){let t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(`)`),i=Se(e,`(`),a=Se(e,`)`);for(;r!==-1&&i>a;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(`)`),a++;return[e,n]}function Be(e,t){let n=e.input.charCodeAt(e.index-1);return(e.index===0||m(n)||b(n))&&(!t||n!==47)}Xe.peek=Ye;function Ve(){this.buffer()}function He(e){this.enter({type:`footnoteReference`,identifier:``,label:``},e)}function Ue(){this.buffer()}function We(e){this.enter({type:`footnoteDefinition`,identifier:``,label:``,children:[]},e)}function Ge(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=M(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Ke(e){this.exit(e)}function qe(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=M(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Je(e){this.exit(e)}function Ye(){return`[`}function Xe(e,t,n,r){let i=n.createTracker(r),a=i.move(`[^`),o=n.enter(`footnoteReference`),s=n.enter(`reference`);return a+=i.move(n.safe(n.associationId(e),{after:`]`,before:a})),s(),o(),a+=i.move(`]`),a}function Ze(){return{enter:{gfmFootnoteCallString:Ve,gfmFootnoteCall:He,gfmFootnoteDefinitionLabelString:Ue,gfmFootnoteDefinition:We},exit:{gfmFootnoteCallString:Ge,gfmFootnoteCall:Ke,gfmFootnoteDefinitionLabelString:qe,gfmFootnoteDefinition:Je}}}function Qe(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:Xe},unsafe:[{character:`[`,inConstruct:[`label`,`phrasing`,`reference`]}]};function n(e,n,r,i){let a=r.createTracker(i),o=a.move(`[^`),s=r.enter(`footnoteDefinition`),c=r.enter(`label`);return o+=a.move(r.safe(r.associationId(e),{before:o,after:`]`})),c(),o+=a.move(`]:`),e.children&&e.children.length>0&&(a.shift(4),o+=a.move((t?`
|
|
2
|
-
`:` `)+r.indentLines(r.containerFlow(e,a.current()),t?et:$e))),s(),o}}function $e(e,t,n){return t===0?e:et(e,t,n)}function et(e,t,n){return(n?``:` `)+e}var tt=[`autolink`,`destinationLiteral`,`destinationRaw`,`reference`,`titleQuote`,`titleApostrophe`];ot.peek=st;function nt(){return{canContainEols:[`delete`],enter:{strikethrough:it},exit:{strikethrough:at}}}function rt(){return{unsafe:[{character:`~`,inConstruct:`phrasing`,notInConstruct:tt}],handlers:{delete:ot}}}function it(e){this.enter({type:`delete`,children:[]},e)}function at(e){this.exit(e)}function ot(e,t,n,r){let i=n.createTracker(r),a=n.enter(`strikethrough`),o=i.move(`~~`);return o+=n.containerPhrasing(e,{...i.current(),before:o,after:`~`}),o+=i.move(`~~`),a(),o}function st(){return`~`}function ct(e){return e.length}function lt(e,t){let n=t||{},r=(n.align||[]).concat(),i=n.stringLength||ct,a=[],o=[],s=[],c=[],l=0,u=-1;for(;++u<e.length;){let t=[],r=[],a=-1;for(e[u].length>l&&(l=e[u].length);++a<e[u].length;){let o=ut(e[u][a]);if(n.alignDelimiters!==!1){let e=i(o);r[a]=e,(c[a]===void 0||e>c[a])&&(c[a]=e)}t.push(o)}o[u]=t,s[u]=r}let d=-1;if(typeof r==`object`&&`length`in r)for(;++d<l;)a[d]=dt(r[d]);else{let e=dt(r);for(;++d<l;)a[d]=e}d=-1;let f=[],p=[];for(;++d<l;){let e=a[d],t=``,r=``;e===99?(t=`:`,r=`:`):e===108?t=`:`:e===114&&(r=`:`);let i=n.alignDelimiters===!1?1:Math.max(1,c[d]-t.length-r.length),o=t+`-`.repeat(i)+r;n.alignDelimiters!==!1&&(i=t.length+i+r.length,i>c[d]&&(c[d]=i),p[d]=i),f[d]=o}o.splice(1,0,f),s.splice(1,0,p),u=-1;let m=[];for(;++u<o.length;){let e=o[u],t=s[u];d=-1;let r=[];for(;++d<l;){let i=e[d]||``,o=``,s=``;if(n.alignDelimiters!==!1){let e=c[d]-(t[d]||0),n=a[d];n===114?o=` `.repeat(e):n===99?e%2?(o=` `.repeat(e/2+.5),s=` `.repeat(e/2-.5)):(o=` `.repeat(e/2),s=o):s=` `.repeat(e)}n.delimiterStart!==!1&&!d&&r.push(`|`),n.padding!==!1&&!(n.alignDelimiters===!1&&i===``)&&(n.delimiterStart!==!1||d)&&r.push(` `),n.alignDelimiters!==!1&&r.push(o),r.push(i),n.alignDelimiters!==!1&&r.push(s),n.padding!==!1&&r.push(` `),(n.delimiterEnd!==!1||d!==l-1)&&r.push(`|`)}m.push(n.delimiterEnd===!1?r.join(``).replace(/ +$/,``):r.join(``))}return m.join(`
|
|
3
|
-
`)}function ut(e){return e==null?``:String(e)}function dt(e){let t=typeof e==`string`?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function ft(e,t,n,r){let i=n.enter(`blockquote`),a=n.createTracker(r);a.move(`> `),a.shift(2);let o=n.indentLines(n.containerFlow(e,a.current()),pt);return i(),o}function pt(e,t,n){return`>`+(n?``:` `)+e}function mt(e,t){return ht(e,t.inConstruct,!0)&&!ht(e,t.notInConstruct,!1)}function ht(e,t,n){if(typeof t==`string`&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function gt(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
|
|
4
|
-
`&&mt(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?``:` `;return`\\
|
|
5
|
-
`}function _t(e,t){let n=String(e),r=n.indexOf(t),i=r,a=0,o=0;if(typeof t!=`string`)throw TypeError(`Expected substring`);for(;r!==-1;)r===i?++a>o&&(o=a):a=1,i=r+t.length,r=n.indexOf(t,i);return o}function vt(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function yt(e){let t=e.options.fence||"`";if(t!=="`"&&t!==`~`)throw Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function bt(e,t,n,r){let i=yt(n),a=e.value||``,o=i==="`"?`GraveAccent`:`Tilde`;if(vt(e,n)){let e=n.enter(`codeIndented`),t=n.indentLines(a,xt);return e(),t}let s=n.createTracker(r),c=i.repeat(Math.max(_t(a,i)+1,3)),l=n.enter(`codeFenced`),u=s.move(c);if(e.lang){let t=n.enter(`codeFencedLang${o}`);u+=s.move(n.safe(e.lang,{before:u,after:` `,encode:["`"],...s.current()})),t()}if(e.lang&&e.meta){let t=n.enter(`codeFencedMeta${o}`);u+=s.move(` `),u+=s.move(n.safe(e.meta,{before:u,after:`
|
|
6
|
-
`,encode:["`"],...s.current()})),t()}return u+=s.move(`
|
|
7
|
-
`),a&&(u+=s.move(a+`
|
|
8
|
-
`)),u+=s.move(c),l(),u}function xt(e,t,n){return(n?``:` `)+e}function V(e){let t=e.options.quote||`"`;if(t!==`"`&&t!==`'`)throw Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function St(e,t,n,r){let i=V(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`definition`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`[`);return l+=c.move(n.safe(n.associationId(e),{before:l,after:`]`,...c.current()})),l+=c.move(`]: `),s(),!e.url||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`
|
|
9
|
-
`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),o(),l}function Ct(e){let t=e.options.emphasis||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function H(e){return`&#x`+e.toString(16).toUpperCase()+`;`}function U(e,t,n){let r=_(e),i=_(t);return r===void 0?i===void 0?n===`_`?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}wt.peek=Tt;function wt(e,t,n,r){let i=Ct(n),a=n.enter(`emphasis`),o=n.createTracker(r),s=o.move(i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=U(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=H(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=U(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+H(d));let p=o.move(i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function Tt(e,t,n){return n.options.emphasis||`*`}function Et(e,t){let n=!1;return O(e,function(e){if(`value`in e&&/\r?\n|\r/.test(e.value)||e.type===`break`)return n=!0,!1}),!!((!e.depth||e.depth<3)&&ee(e)&&(t.options.setext||n))}function Dt(e,t,n,r){let i=Math.max(Math.min(6,e.depth||1),1),a=n.createTracker(r);if(Et(e,n)){let t=n.enter(`headingSetext`),r=n.enter(`phrasing`),o=n.containerPhrasing(e,{...a.current(),before:`
|
|
10
|
-
`,after:`
|
|
11
|
-
`});return r(),t(),o+`
|
|
12
|
-
`+(i===1?`=`:`-`).repeat(o.length-(Math.max(o.lastIndexOf(`\r`),o.lastIndexOf(`
|
|
13
|
-
`))+1))}let o=`#`.repeat(i),s=n.enter(`headingAtx`),c=n.enter(`phrasing`);a.move(o+` `);let l=n.containerPhrasing(e,{before:`# `,after:`
|
|
14
|
-
`,...a.current()});return/^[\t ]/.test(l)&&(l=H(l.charCodeAt(0))+l.slice(1)),l=l?o+` `+l:o,n.options.closeAtx&&(l+=` `+o),c(),s(),l}Ot.peek=kt;function Ot(e){return e.value||``}function kt(){return`<`}At.peek=jt;function At(e,t,n,r){let i=V(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`image`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`![`);return l+=c.move(n.safe(e.alt,{before:l,after:`]`,...c.current()})),l+=c.move(`](`),s(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),l+=c.move(`)`),o(),l}function jt(){return`!`}Mt.peek=Nt;function Mt(e,t,n,r){let i=e.referenceType,a=n.enter(`imageReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`![`),l=n.safe(e.alt,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function Nt(){return`!`}Pt.peek=Ft;function Pt(e,t,n){let r=e.value||``,i="`",a=-1;for(;RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=` `+r+` `);++a<n.unsafe.length;){let e=n.unsafe[a],t=n.compilePattern(e),i;if(e.atBreak)for(;i=t.exec(r);){let e=i.index;r.charCodeAt(e)===10&&r.charCodeAt(e-1)===13&&e--,r=r.slice(0,e)+` `+r.slice(i.index+1)}}return i+r+i}function Ft(){return"`"}function It(e,t){let n=ee(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type===`text`&&(n===e.url||`mailto:`+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}Lt.peek=Rt;function Lt(e,t,n,r){let i=V(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.createTracker(r),s,c;if(It(e,n)){let t=n.stack;n.stack=[],s=n.enter(`autolink`);let r=o.move(`<`);return r+=o.move(n.containerPhrasing(e,{before:r,after:`>`,...o.current()})),r+=o.move(`>`),s(),n.stack=t,r}s=n.enter(`link`),c=n.enter(`label`);let l=o.move(`[`);return l+=o.move(n.containerPhrasing(e,{before:l,after:`](`,...o.current()})),l+=o.move(`](`),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter(`destinationLiteral`),l+=o.move(`<`),l+=o.move(n.safe(e.url,{before:l,after:`>`,...o.current()})),l+=o.move(`>`)):(c=n.enter(`destinationRaw`),l+=o.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...o.current()}))),c(),e.title&&(c=n.enter(`title${a}`),l+=o.move(` `+i),l+=o.move(n.safe(e.title,{before:l,after:i,...o.current()})),l+=o.move(i),c()),l+=o.move(`)`),s(),l}function Rt(e,t,n){return It(e,n)?`<`:`[`}zt.peek=Bt;function zt(e,t,n,r){let i=e.referenceType,a=n.enter(`linkReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`[`),l=n.containerPhrasing(e,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function Bt(){return`[`}function W(e){let t=e.options.bullet||`*`;if(t!==`*`&&t!==`+`&&t!==`-`)throw Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function Vt(e){let t=W(e),n=e.options.bulletOther;if(!n)return t===`*`?`-`:`*`;if(n!==`*`&&n!==`+`&&n!==`-`)throw Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function Ht(e){let t=e.options.bulletOrdered||`.`;if(t!==`.`&&t!==`)`)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function Ut(e){let t=e.options.rule||`*`;if(t!==`*`&&t!==`-`&&t!==`_`)throw Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function Wt(e,t,n,r){let i=n.enter(`list`),a=n.bulletCurrent,o=e.ordered?Ht(n):W(n),s=e.ordered?o===`.`?`)`:`.`:Vt(n),c=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){let t=e.children?e.children[0]:void 0;if((o===`*`||o===`-`)&&t&&(!t.children||!t.children[0])&&n.stack[n.stack.length-1]===`list`&&n.stack[n.stack.length-2]===`listItem`&&n.stack[n.stack.length-3]===`list`&&n.stack[n.stack.length-4]===`listItem`&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(c=!0),Ut(n)===o&&t){let t=-1;for(;++t<e.children.length;){let n=e.children[t];if(n&&n.type===`listItem`&&n.children&&n.children[0]&&n.children[0].type===`thematicBreak`){c=!0;break}}}}c&&(o=s),n.bulletCurrent=o;let l=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=a,i(),l}function Gt(e){let t=e.options.listItemIndent||`one`;if(t!==`tab`&&t!==`one`&&t!==`mixed`)throw Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function Kt(e,t,n,r){let i=Gt(n),a=n.bulletCurrent||W(n);t&&t.type===`list`&&t.ordered&&(a=(typeof t.start==`number`&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+a);let o=a.length+1;(i===`tab`||i===`mixed`&&(t&&t.type===`list`&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);let s=n.createTracker(r);s.move(a+` `.repeat(o-a.length)),s.shift(o);let c=n.enter(`listItem`),l=n.indentLines(n.containerFlow(e,s.current()),u);return c(),l;function u(e,t,n){return t?(n?``:` `.repeat(o))+e:(n?a:a+` `.repeat(o-a.length))+e}}function qt(e,t,n,r){let i=n.enter(`paragraph`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,r);return a(),i(),o}var Jt=h([`break`,`delete`,`emphasis`,`footnote`,`footnoteReference`,`image`,`imageReference`,`inlineCode`,`inlineMath`,`link`,`linkReference`,`mdxJsxTextElement`,`mdxTextExpression`,`strong`,`text`,`textDirective`]);function Yt(e,t,n,r){return(e.children.some(function(e){return Jt(e)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function Xt(e){let t=e.options.strong||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}Zt.peek=Qt;function Zt(e,t,n,r){let i=Xt(n),a=n.enter(`strong`),o=n.createTracker(r),s=o.move(i+i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=U(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=H(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=U(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+H(d));let p=o.move(i+i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function Qt(e,t,n){return n.options.strong||`*`}function $t(e,t,n,r){return n.safe(e.value,r)}function en(e){let t=e.options.ruleRepetition||3;if(t<3)throw Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function tn(e,t,n){let r=(Ut(n)+(n.options.ruleSpaces?` `:``)).repeat(en(n));return n.options.ruleSpaces?r.slice(0,-1):r}var nn={blockquote:ft,break:gt,code:bt,definition:St,emphasis:wt,hardBreak:gt,heading:Dt,html:Ot,image:At,imageReference:Mt,inlineCode:Pt,link:Lt,linkReference:zt,list:Wt,listItem:Kt,paragraph:qt,root:Yt,strong:Zt,text:$t,thematicBreak:tn};function rn(){return{enter:{table:an,tableData:cn,tableHeader:cn,tableRow:sn},exit:{codeText:ln,table:on,tableData:G,tableHeader:G,tableRow:G}}}function an(e){let t=e._align;this.enter({type:`table`,align:t.map(function(e){return e===`none`?null:e}),children:[]},e),this.data.inTable=!0}function on(e){this.exit(e),this.data.inTable=void 0}function sn(e){this.enter({type:`tableRow`,children:[]},e)}function G(e){this.exit(e)}function cn(e){this.enter({type:`tableCell`,children:[]},e)}function ln(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,un));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function un(e,t){return t===`|`?t:e}function dn(e){let t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=n?` `:`|`;return{unsafe:[{character:`\r`,inConstruct:`tableCell`},{character:`
|
|
15
|
-
`,inConstruct:`tableCell`},{atBreak:!0,character:`|`,after:`[ :-]`},{character:`|`,inConstruct:`tableCell`},{atBreak:!0,character:`:`,after:`-`},{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{inlineCode:f,table:o,tableCell:c,tableRow:s}};function o(e,t,n,r){return l(u(e,n,r),e.align)}function s(e,t,n,r){let i=l([d(e,n,r)]);return i.slice(0,i.indexOf(`
|
|
16
|
-
`))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return lt(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=nn.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function fn(){return{exit:{taskListCheckValueChecked:mn,taskListCheckValueUnchecked:mn,paragraph:hn}}}function pn(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:gn}}}function mn(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function hn(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function gn(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=nn.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function _n(){return[Oe(),Ze(),nt(),rn(),fn()]}function vn(e){return{extensions:[ke(),Qe(e),rt(),dn(e),pn()]}}var yn={tokenize:An,partial:!0},bn={tokenize:jn,partial:!0},xn={tokenize:Mn,partial:!0},Sn={tokenize:Nn,partial:!0},Cn={tokenize:Pn,partial:!0},wn={name:`wwwAutolink`,tokenize:On,previous:Fn},Tn={name:`protocolAutolink`,tokenize:kn,previous:In},K={name:`emailAutolink`,tokenize:Dn,previous:Ln},q={};function En(){return{text:q}}for(var J=48;J<123;)q[J]=K,J++,J===58?J=65:J===91&&(J=97);q[43]=K,q[45]=K,q[46]=K,q[95]=K,q[72]=[K,Tn],q[104]=[K,Tn],q[87]=[K,wn],q[119]=[K,wn];function Dn(e,t,n){let r=this,i,a;return o;function o(t){return!Y(t)||!Ln.call(r,r.previous)||X(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return Y(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(Cn,u,l)(t):t===45||t===95||v(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&j(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function On(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!Fn.call(r,r.previous)||X(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(yn,e.attempt(bn,e.attempt(xn,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function kn(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&In.call(r,r.previous)&&!X(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(j(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||y(t)||w(t)||m(t)||b(t)?n(t):e.attempt(bn,e.attempt(xn,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function An(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function jn(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(Sn,c,s)(t):t===null||w(t)||m(t)||t!==45&&b(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function Mn(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(Sn,t,a)(o):o===null||w(o)||m(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function Nn(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||w(o)||m(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||w(e)||m(e)?t(e):r(e)}function a(e){return j(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):j(t)?(e.consume(t),o):n(t)}}function Pn(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return v(e)?n(e):t(e)}}function Fn(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||w(e)}function In(e){return!j(e)}function Ln(e){return!(e===47||Y(e))}function Y(e){return e===43||e===45||e===46||e===95||v(e)}function X(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var Rn={tokenize:Kn,partial:!0};function zn(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:Un,continuation:{tokenize:Wn},exit:Gn}},text:{91:{name:`gfmFootnoteCall`,tokenize:Hn},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:Bn,resolveTo:Vn}}}}function Bn(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=M(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function Vn(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function Hn(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||w(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(M(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return w(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function Un(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||w(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=M(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return w(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),C(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function Wn(e,t,n){return e.check(E,t,e.attempt(Rn,t,n))}function Gn(e){e.exit(`gfmFootnoteDefinition`)}function Kn(e,t,n){let r=this;return C(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function qn(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&g(o,o.length,0,k(s,e.slice(r+1,n),t)),g(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),g(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=_(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=_(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var Jn=class{constructor(){this.map=[]}add(e,t,n){Yn(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0}};function Yn(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function Xn(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function Zn(){return{flow:{null:{name:`table`,tokenize:Qn,resolveAll:$n}}}}function Qn(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let e=r.events[t][1].type;if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?T:c;return a===T&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):D(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):x(t)?C(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||w(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,x(t)?C(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):S(t)}function h(t){return x(t)?C(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||D(t)?b(t):S(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):S(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return x(t)?C(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||D(n)?!o||i!==a?S(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):S(n)}function S(e){return n(e)}function T(t){return e.enter(`tableRow`),E(t)}function E(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),E):n===null||D(n)?(e.exit(`tableRow`),t(n)):x(n)?C(e,E,`whitespace`)(n):(e.enter(`data`),O(n))}function O(t){return t===null||t===124||w(t)?(e.exit(`data`),E(t)):(e.consume(t),t===92?k:O)}function k(t){return t===92||t===124?(e.consume(t),O):O(t)}}function $n(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new Jn;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(er(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=Z(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=Z(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=Z(f,t,o,i,n,d)):(o[0]=o[1],d=Z(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&er(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=Xn(t.events,n))}return e}function Z(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},Q(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=Q(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=Q(t.events,n[2]),a=Q(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},Q(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function er(e,t,n,r,i){let a=[],o=Q(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function Q(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var tr={name:`tasklistCheck`,tokenize:rr};function nr(){return{text:{91:tr}}}function rr(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return w(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return D(r)?t(r):x(r)?e.check({tokenize:ir},t,n)(r):n(r)}}function ir(e,t,n){return C(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function ar(e){return te([En(),zn(),qn(e),Zn(),nr()])}var or={};function sr(e){let t=this,n=e||or,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(ar(n)),a.push(_n()),o.push(vn(n))}var $=n();function cr(e){return new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}function lr({audio:e,mimeType:t=`audio/webm`}){let[n,r]=(0,F.useState)(!1),[i,a]=(0,F.useState)(null),[o,c]=(0,F.useState)(0),[l,f]=(0,F.useState)(0),[m,h]=(0,F.useState)(1),[g,_]=(0,F.useState)(1),v=(0,F.useRef)(null);(0,F.useEffect)(()=>{e&&!i&&a(`data:${t};base64,${e}`)},[e,i,t]),(0,F.useEffect)(()=>{v.current&&(v.current.playbackRate=g)},[g]),(0,F.useEffect)(()=>{v.current&&(v.current.volume=m)},[m]);let y=()=>{v.current&&(n?v.current.pause():v.current.play(),r(!n))},b=()=>{v.current&&(c(v.current.currentTime),f(v.current.duration))},x=e=>{v.current&&(v.current.currentTime=e[0],c(e[0]))},S=()=>{let e=[1,1.25,1.5,2];_(e[(e.indexOf(g)+1)%e.length])},C=e=>isNaN(e)?`0:00`:`${Math.floor(e/60)}:${Math.floor(e%60).toString().padStart(2,`0`)}`;if(!e)return null;let w=m===0?he:m<.5?me:N;return(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 mt-3 p-3 bg-zinc-900/50 border border-white/5 rounded-2xl w-full max-w-sm shadow-xl backdrop-blur-sm`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`button`,{onClick:y,className:`h-10 w-10 rounded-full bg-blue-600 hover:bg-blue-500 flex items-center justify-center transition-all active:scale-95 shadow-lg shadow-blue-600/20`,children:n?(0,$.jsx)(u,{className:`h-5 w-5 text-white fill-white`}):(0,$.jsx)(d,{className:`h-5 w-5 text-white fill-white ml-0.5`})}),(0,$.jsxs)(`div`,{className:`flex-1 flex flex-col gap-1.5 min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex justify-between items-end mb-0.5`,children:[(0,$.jsx)(`span`,{className:`text-[10px] font-bold text-blue-400/80 uppercase tracking-widest flex items-center gap-1.5`,children:n?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`span`,{className:`flex gap-0.5 items-end h-3`,children:[(0,$.jsx)(`span`,{className:`w-0.5 bg-blue-400/60 animate-[bounce_0.8s_infinite_0ms]`,style:{height:`40%`}}),(0,$.jsx)(`span`,{className:`w-0.5 bg-blue-400/60 animate-[bounce_0.8s_infinite_200ms]`,style:{height:`80%`}}),(0,$.jsx)(`span`,{className:`w-0.5 bg-blue-400/60 animate-[bounce_0.8s_infinite_400ms]`,style:{height:`60%`}})]}),`Reproduciendo`]}):`Audio del Agente`}),(0,$.jsxs)(`span`,{className:`text-[10px] font-mono text-white/40 tabular-nums`,children:[C(o),` / `,C(l)]})]}),(0,$.jsx)(A,{value:[o],max:l||100,step:.1,onValueChange:x,className:`w-full`})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between pt-1 mt-1 border-t border-white/5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 group/vol`,children:[(0,$.jsx)(`button`,{onClick:()=>h(+(m===0)),className:`text-white/40 hover:text-white transition-colors`,children:(0,$.jsx)(w,{className:`h-4 w-4`})}),(0,$.jsx)(`div`,{className:`w-16`,children:(0,$.jsx)(A,{value:[m*100],max:100,onValueChange:e=>h(e[0]/100),className:`h-4`})})]}),(0,$.jsxs)(`button`,{onClick:S,className:`flex items-center gap-1.5 px-2 py-1 rounded-md hover:bg-white/5 text-white/40 hover:text-blue-400 transition-all`,children:[(0,$.jsx)(s,{className:`h-3.5 w-3.5`}),(0,$.jsxs)(`span`,{className:`text-[10px] font-bold min-w-[2.5ch]`,children:[g,`x`]})]})]}),(0,$.jsx)(`button`,{onClick:()=>{v.current&&(v.current.currentTime=0)},className:`text-white/20 hover:text-white/60 transition-colors p-1`,title:`Reiniciar`,children:(0,$.jsx)(p,{className:`h-3.5 w-3.5`})})]}),i&&(0,$.jsx)(`audio`,{ref:v,src:i,onTimeUpdate:b,onLoadedMetadata:b,onEnded:()=>r(!1),onPlay:()=>r(!0),onPause:()=>r(!1),className:`hidden`})]})}function ur({message:e,userName:t=`Tú`,agentName:n=`Agente`,isStreaming:r,onNarrate:i}){let a=e.type===`user`,s=e.type===`error`,c=e.type===`system`,l=!!e.audio?.base64||!!e.audio?.url;return c?(0,$.jsx)(`div`,{className:`flex justify-center my-2`,children:(0,$.jsx)(`span`,{className:`text-[11px] text-white/50 bg-white/5 border border-white/10 px-3 py-1 rounded-full font-mono`,children:e.content})}):s?(0,$.jsx)(`div`,{className:`flex items-center gap-2 justify-center my-2`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-[12px] font-medium text-rose-400 bg-rose-500/10 border border-rose-500/20 px-4 py-2 rounded-xl`,children:[(0,$.jsx)(re,{className:`h-3.5 w-3.5 shrink-0`}),e.content]})}):a?(0,$.jsx)(`div`,{className:`flex items-end justify-end gap-2 group mb-2`,children:(0,$.jsxs)(`div`,{className:`flex flex-col items-end gap-1 max-w-[75%] md:max-w-[65%]`,children:[e.image&&(0,$.jsx)(`div`,{className:`mb-2 rounded-2xl overflow-hidden border border-white/10 shadow-lg bg-black/20`,children:(0,$.jsx)(`img`,{src:e.image.url||`data:${e.image.mimeType||`image/jpeg`};base64,${e.image.base64}`,alt:`adjunto`,className:`max-w-full h-auto max-h-[300px] object-contain`})}),e.document&&(0,$.jsxs)(`div`,{className:`mb-2 flex items-center gap-3 bg-white/5 border border-white/10 px-4 py-3 rounded-2xl w-full`,children:[(0,$.jsx)(`div`,{className:`h-10 w-10 rounded-lg bg-blue-500/10 flex items-center justify-center border border-blue-500/20`,children:(0,$.jsx)(o,{className:`h-6 w-6 text-blue-400`})}),(0,$.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-white truncate`,children:e.document.fileName||`Documento`}),(0,$.jsx)(`span`,{className:`text-[10px] text-white/40 uppercase font-bold tracking-wider`,children:e.document.mimeType?.split(`/`)[1]||`DOC`})]})]}),(0,$.jsx)(`div`,{className:`bg-blue-600/20 text-white px-5 py-3 rounded-3xl rounded-br-sm shadow-sm ring-1 ring-blue-500/30 text-[15px] leading-relaxed whitespace-pre-wrap font-manrope`,children:e.content}),l&&e.audio?.base64&&(0,$.jsx)(lr,{audio:e.audio.base64,mimeType:e.audio.mimeType}),(0,$.jsx)(`span`,{className:`text-[10px] text-white/40 font-medium pr-2 opacity-0 group-hover:opacity-100 transition-opacity`,children:cr(e.timestamp)})]})}):(0,$.jsxs)(`div`,{className:`flex items-start gap-4 group mb-4`,children:[(0,$.jsx)(`div`,{className:`h-10 w-10 rounded-full bg-white/5 border border-white/10 flex items-center justify-center shrink-0 mt-0.5 shadow-sm`,children:(0,$.jsx)(P,{className:`h-5 w-5 text-blue-400`})}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1 max-w-[85%] min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`text-[11px] font-bold text-white/40 uppercase tracking-wider ml-1`,children:n}),e.image&&(0,$.jsx)(`div`,{className:`mb-2 rounded-2xl overflow-hidden border border-white/10 shadow-lg bg-black/20 w-fit`,children:(0,$.jsx)(`img`,{src:e.image.url||`data:${e.image.mimeType||`image/jpeg`};base64,${e.image.base64}`,alt:`adjunto`,className:`max-w-full h-auto max-h-[300px] object-contain`})}),e.document&&(0,$.jsxs)(`div`,{className:`mb-2 flex items-center gap-3 bg-white/5 border border-white/10 px-4 py-3 rounded-2xl w-fit max-w-full`,children:[(0,$.jsx)(`div`,{className:`h-10 w-10 rounded-lg bg-blue-500/10 flex items-center justify-center border border-blue-500/20`,children:(0,$.jsx)(o,{className:`h-6 w-6 text-blue-400`})}),(0,$.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-white truncate`,children:e.document.fileName||`Documento`}),(0,$.jsx)(`span`,{className:`text-[10px] text-white/40 uppercase font-bold tracking-wider`,children:e.document.mimeType?.split(`/`)[1]||`DOC`})]})]}),(0,$.jsxs)(`div`,{className:`text-white/80 text-[15px] leading-relaxed prose prose-invert max-w-none font-newsreader`,children:[(0,$.jsx)(T,{remarkPlugins:[sr],children:e.content}),r&&(0,$.jsx)(`span`,{className:`inline-block w-2 h-4 bg-blue-400 ml-1 align-text-bottom rounded-sm opacity-70`})]}),l&&e.audio?.base64&&(0,$.jsx)(lr,{audio:e.audio.base64,mimeType:e.audio.mimeType}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 pl-1 mt-1 opacity-0 group-hover:opacity-100 transition-opacity`,children:[(0,$.jsx)(`span`,{className:`text-[10px] font-medium text-white/40`,children:cr(e.timestamp)}),i&&(0,$.jsx)(`button`,{onClick:()=>i(e.content),className:`h-6 w-6 rounded flex items-center justify-center text-white/40 hover:text-blue-400 hover:bg-white/5 transition-colors`,title:`Narrar mensaje`,children:(0,$.jsx)(N,{className:`h-3.5 w-3.5`})})]})]})]})}var dr=[{icon:ne,text:`Que puedes hacer?`},{icon:ie,text:`Dame un resumen`},{icon:P,text:`Ayudame con una tarea`}],fr=[];function pr({messages:e,isLoading:t=!1,currentSteps:n=fr,streamingMessageId:r,userName:i,agentName:a,onSuggestionClick:o,onNarrateMessage:s}){let c=(0,F.useRef)(null),l=(0,F.useRef)({count:0,firstId:``,lastId:``});return(0,F.useLayoutEffect)(()=>{let t=c.current;if(!t)return;let n=l.current,r=e[0]?.id??``,i=e[e.length-1]?.id??``,a=n.count===0&&e.length>0,o=n.count>0&&e.length>0&&n.count===e.length&&(n.firstId!==r||n.lastId!==i),s=t.scrollHeight-t.scrollTop-t.clientHeight<200,u=a||o||s||e.length<=1;if(l.current={count:e.length,firstId:r,lastId:i},u){let e=setTimeout(()=>{t.scrollTop=t.scrollHeight},0);return()=>clearTimeout(e)}},[e,t,n]),e.length===0&&!t?(0,$.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center p-8 w-full`,children:[(0,$.jsxs)(`div`,{className:`relative mb-6`,children:[(0,$.jsx)(`div`,{className:`h-16 w-16 rounded-2xl bg-white/5 border border-white/10 flex items-center justify-center shadow-sm`,children:(0,$.jsx)(P,{className:`h-8 w-8 text-blue-400`})}),(0,$.jsx)(`span`,{className:`absolute -bottom-1 -right-1 h-4 w-4 rounded-full bg-emerald-500 border-2 border-white shadow-sm`})]}),(0,$.jsxs)(`div`,{className:`text-center space-y-2 mb-8`,children:[(0,$.jsx)(`p`,{className:`text-lg font-semibold text-white font-manrope`,children:a?`${a} está listo`:`Agente listo`}),(0,$.jsx)(`p`,{className:`text-sm text-white/50 font-manrope`,children:`Inicia la conversación escribiendo un mensaje abajo`})]}),o&&(0,$.jsx)(`div`,{className:`flex flex-col sm:flex-row items-center gap-3`,children:dr.map(e=>{let t=e.icon;return(0,$.jsxs)(`button`,{onClick:()=>o(e.text),className:`flex items-center gap-2 text-sm text-white/70 hover:text-white bg-white/5 border border-white/10 hover:border-white/20 hover:bg-white/10 px-4 py-2.5 rounded-full transition-all cursor-pointer font-medium`,children:[(0,$.jsx)(t,{className:`h-4 w-4 text-blue-400`}),e.text]},e.text)})})]}):(0,$.jsx)(`div`,{className:`flex-1 flex flex-col min-h-0 w-full`,children:(0,$.jsx)(`div`,{ref:c,className:`flex-1 overflow-y-auto w-full`,children:(0,$.jsxs)(`div`,{className:`max-w-3xl mx-auto flex flex-col gap-6 p-4 md:p-8 pb-2`,children:[e.map(e=>(0,$.jsx)(ur,{message:e,userName:i,agentName:a,isStreaming:e.id===r,onNarrate:s},e.id)),t&&!r&&(0,$.jsxs)(`div`,{className:`flex items-start gap-4 animate-in fade-in slide-in-from-bottom-2 duration-300`,children:[(0,$.jsx)(`div`,{className:`h-10 w-10 rounded-full bg-white/5 border border-white/10 flex items-center justify-center shrink-0 shadow-sm mt-1`,children:(0,$.jsx)(P,{className:`h-5 w-5 text-blue-400`})}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 max-w-[80%] min-w-0`,children:[(0,$.jsx)(`span`,{className:`text-[11px] font-bold text-white/40 uppercase tracking-wider ml-1`,children:a}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[n.length>0&&(0,$.jsx)(`div`,{className:`flex flex-col gap-1.5 ml-1`,children:n.map((e,t)=>{let r=t===n.length-1;return(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 rounded-lg border text-xs font-medium transition-all w-fit ${r?`bg-blue-500/10 border-blue-500/20 text-blue-400`:`bg-white/5 border-white/10 text-white/50`}`,children:[(0,$.jsx)(ie,{className:`h-3 w-3 shrink-0 ${r?`text-blue-400`:`text-white/30`}`}),(0,$.jsx)(`span`,{className:`leading-tight`,children:e})]},t)})}),(0,$.jsxs)(`div`,{className:`bg-white/5 border border-white/10 px-4 py-3.5 rounded-2xl rounded-tl-none shadow-sm flex items-center gap-1.5 w-fit`,children:[(0,$.jsx)(`span`,{className:`h-2 w-2 rounded-full bg-white/30 animate-bounce [animation-delay:0ms]`}),(0,$.jsx)(`span`,{className:`h-2 w-2 rounded-full bg-white/30 animate-bounce [animation-delay:150ms]`}),(0,$.jsx)(`span`,{className:`h-2 w-2 rounded-full bg-white/30 animate-bounce [animation-delay:300ms]`})]})]})]})]}),(0,$.jsx)(`div`,{className:`h-0`})]})})})}function mr({onSendMessage:e,onStop:t,disabled:n=!1,isStreaming:r=!1}){let[i,a]=(0,F.useState)(``),[s,u]=(0,F.useState)(!1),[d,f]=(0,F.useState)([]),p=(0,F.useRef)(null),m=(0,F.useRef)([]),h=(0,F.useRef)(null),g=(0,F.useRef)(null);(0,F.useEffect)(()=>{h.current&&(h.current.style.height=`auto`,h.current.style.height=h.current.scrollHeight+`px`)},[i]);let _=()=>{(i.trim()||d.length>0)&&!n&&(e(i.trim()||(d.length>0?`[Adjunto]`:``),{attachments:d.length>0?d:void 0}),a(``),f([]),h.current&&(h.current.style.height=`auto`))},v=async e=>{let t=e.target.files;if(!(!t||t.length===0)){for(let e of Array.from(t)){let t=new FileReader;t.readAsDataURL(e),t.onload=()=>{let n=t.result.split(`,`)[1],r={type:e.type.startsWith(`image/`)?`image`:`document`,base64:n,mimeType:e.type,fileName:e.name};f(e=>[...e,r])}}g.current&&(g.current.value=``)}},y=e=>{f(t=>t.filter((t,n)=>n!==e))};return(0,$.jsx)(`div`,{className:`px-4 pb-4 pt-2 shrink-0 bg-transparent`,children:(0,$.jsxs)(`div`,{className:`max-w-3xl mx-auto`,children:[d.length>0&&(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2 mb-2 px-2`,children:d.map((e,t)=>(0,$.jsxs)(`div`,{className:`group relative flex items-center gap-2 bg-white/10 backdrop-blur-md rounded-lg px-3 py-1.5 border border-white/10`,children:[e.type===`image`?(0,$.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.base64}`,className:`h-8 w-8 rounded object-cover border border-white/20`,alt:`preview`}):(0,$.jsx)(o,{className:`h-5 w-5 text-blue-400`}),(0,$.jsx)(`span`,{className:`text-xs text-white/70 max-w-[120px] truncate`,children:e.fileName}),(0,$.jsx)(`button`,{onClick:()=>y(t),className:`absolute -top-2 -right-2 bg-rose-500 text-white rounded-full p-0.5 opacity-0 group-hover:opacity-100 transition-opacity shadow-lg`,children:(0,$.jsx)(oe,{className:`h-3 w-3`})})]},t))}),(0,$.jsxs)(`div`,{className:`flex items-end gap-2 rounded-[2rem] bg-black/40 backdrop-blur-md px-4 py-3 transition-all shadow-sm border border-white/10 ${n?`opacity-60 bg-black/20`:`hover:border-white/20 focus-within:border-blue-500/50 focus-within:shadow-blue-glow`}`,children:[(0,$.jsx)(`input`,{type:`file`,ref:g,onChange:v,className:`hidden`,multiple:!0}),(0,$.jsx)(`button`,{onClick:()=>g.current?.click(),disabled:n,className:`h-9 w-9 rounded-full flex items-center justify-center shrink-0 mb-0.5 transition-all bg-white/5 text-white/50 hover:bg-white/10 hover:text-white disabled:opacity-30 disabled:cursor-not-allowed`,title:`Adjuntar archivo`,children:(0,$.jsx)(fe,{className:`h-4 w-4`})}),(0,$.jsx)(`button`,{onClick:s?()=>{p.current&&s&&(p.current.stop(),u(!1))}:async()=>{try{let t=await navigator.mediaDevices.getUserMedia({audio:!0}),n=new MediaRecorder(t,{mimeType:`audio/webm`});p.current=n,m.current=[],n.ondataavailable=e=>{e.data.size>0&&m.current.push(e.data)},n.onstop=async()=>{let n=new Blob(m.current,{type:`audio/webm`}),r=new FileReader;r.readAsDataURL(n),r.onloadend=()=>{let t=r.result.split(`,`)[1];e(`[Audio mensaje]`,{audio:t})},t.getTracks().forEach(e=>e.stop())},n.start(),u(!0)}catch(e){console.error(`Error accessing microphone:`,e)}},disabled:n,className:`h-9 w-9 rounded-full flex items-center justify-center shrink-0 mb-0.5 transition-all ${s?`bg-rose-500/20 text-rose-400 hover:bg-rose-500/30 animate-pulse`:`bg-white/5 text-white/50 hover:bg-white/10 hover:text-white`} disabled:opacity-30 disabled:cursor-not-allowed`,children:s?(0,$.jsx)(l,{className:`h-4 w-4`}):(0,$.jsx)(c,{className:`h-4 w-4`})}),(0,$.jsx)(`textarea`,{ref:h,value:i,onChange:e=>{a(e.target.value)},onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),_())},placeholder:n?`Conectando al agente...`:r?`Escribe mientras espera...`:`Escribe un mensaje...`,disabled:n,rows:1,className:`flex-1 min-h-[36px] max-h-[160px] resize-none bg-transparent text-[15px] font-manrope text-white placeholder:text-white/30 focus:outline-none leading-relaxed py-1.5 px-2`,style:{overflow:`auto`}}),r&&t?(0,$.jsx)(`button`,{onClick:t,className:`h-9 w-9 rounded-full flex items-center justify-center shrink-0 mb-0.5 transition-all bg-rose-500 hover:bg-rose-600 text-white shadow-sm shadow-rose-500/20`,title:`Detener generación`,children:(0,$.jsx)(l,{className:`h-4 w-4 fill-current`})}):(0,$.jsx)(`button`,{onClick:_,disabled:!i.trim()&&d.length===0||n,className:`h-9 w-9 rounded-full flex items-center justify-center shrink-0 mb-0.5 transition-all disabled:opacity-30 disabled:cursor-not-allowed bg-blue-600 hover:bg-blue-500 disabled:bg-white/10 text-white shadow-sm`,children:(0,$.jsx)(pe,{className:`h-4 w-4`})})]}),(0,$.jsx)(`p`,{className:`text-[11px] font-medium text-white/30 mt-2.5 text-center font-manrope tracking-wide`,children:s?`Grabando... haz clic para enviar`:`Enter para enviar · Shift+Enter nueva línea`})]})})}function hr(){let e=`main`,{messages:t,addMessage:n,setMessages:i,isLoading:o,currentSteps:s,streamingMessageId:c,connectionWarning:l,setConnectionWarning:u}=L(),{status:d,send:p,subscribe:m}=de(),{currentUser:h,fetchUser:g}=ce(),_=ue(e=>e.agents),v=ue(e=>e.fetchAgents),y=h?.id||`default`,{handleStreamingChunk:b,handleAudioMessage:x,handleProgress:S,handleTyping:C,resetStreamingRef:w}=_e(e,y),T=xe(),E=d===`connected`,D=d===`connecting`,O=_.find(e=>e.role===`coordinator`&&e.enabled)?.name??`Coordinador`;(0,F.useEffect)(()=>{h||g(),_.length===0&&v()},[]),(0,F.useEffect)(()=>{y&&(async()=>{try{let t=await le(`/api/chat/history?sessionId=${y}&limit=15`);t.messages&&i(t.messages.filter(e=>e.role===`user`||e.role===`assistant`).map(t=>({id:t.id,conversationId:t.session_id||t.thread_id,type:t.role===`user`?`user`:`agent`,content:t.content,agentId:e,timestamp:t.created_at})))}catch(e){console.error(`Failed to fetch chat history:`,e)}})()},[y,e,i]),(0,F.useEffect)(()=>{let e=m(`message`,b),t=m(`response`,b),n=m(`audio`,x),r=m(`progress`,S),i=m(`typing`,C);return()=>{e(),t(),n(),r(),i()}},[m,b,x,S,C]),(0,F.useEffect)(()=>{E?u(null):D||u(`Conexion perdida. Reconectando...`)},[E,D,u]);let k=(0,F.useCallback)((t,i)=>{let a=r();T.stop();let o=i?.audio,s=i?.attachments,c={id:a,conversationId:y,type:`user`,content:t,agentId:e,timestamp:new Date().toISOString()};if(o&&(c.audio={base64:o,mimeType:`audio/webm`}),s&&s.length>0){let e=s.find(e=>e.type===`image`),t=s.find(e=>e.type===`document`);e&&(c.image={base64:e.base64,mimeType:e.mimeType,caption:e.fileName}),t&&(c.document={base64:t.base64,mimeType:t.mimeType,fileName:t.fileName})}if(n(c),L.getState().setLoading(!0),w(),E)if(o)p({type:`audio`,audio:o,sessionId:y,timestamp:new Date().toISOString()});else{let e={type:`message`,content:t,sessionId:y,timestamp:new Date().toISOString()};if(s&&s.length>0){let t=s.find(e=>e.type===`image`),n=s.find(e=>e.type===`document`);t&&(e.image={base64:t.base64,mimeType:t.mimeType,caption:t.fileName}),n&&(e.document={base64:n.base64,mimeType:n.mimeType,fileName:n.fileName})}p(e)}else n({id:r(),conversationId:y,type:`error`,content:`No se pudo conectar al agente. Verifica que el gateway este funcionando.`,timestamp:new Date().toISOString()}),L.getState().setLoading(!1)},[E,y,e,n,p,T,w]),A=(0,F.useCallback)(e=>{T.isSpeaking?T.stop():T.narrate(e)},[T]);return(0,$.jsxs)(`div`,{className:`flex-1 flex flex-col w-full min-h-0 bg-transparent overflow-hidden`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 shrink-0 z-10 bg-transparent border-b border-white/5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`span`,{className:`text-sm font-semibold text-white font-manrope tracking-tight`,children:O}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2 py-0.5 rounded-full bg-white/5 border border-white/10`,children:[(0,$.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full ${E?`bg-emerald-500`:D?`bg-amber-500 animate-pulse`:`bg-slate-400`}`}),(0,$.jsx)(`span`,{className:`text-[10px] font-medium text-white/50 uppercase tracking-wider`,children:E?`Conectado`:D?`Conectando`:`Desconectado`})]})]}),(0,$.jsx)(`button`,{onClick:T.toggle,className:`h-8 w-8 rounded-full flex items-center justify-center transition-all ${T.isEnabled?`bg-blue-500/20 text-blue-400 hover:bg-blue-500/30`:`text-white/40 hover:text-white/70 hover:bg-white/5`}`,title:T.isEnabled?`Desactivar narracion`:`Activar narracion`,children:T.isEnabled?(0,$.jsx)(N,{className:`h-4 w-4`}):(0,$.jsx)(he,{className:`h-4 w-4`})})]}),l&&!E&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-2 bg-rose-50 border-b border-rose-100 shrink-0`,children:[(0,$.jsx)(a,{className:`h-3.5 w-3.5 text-rose-500 shrink-0`}),(0,$.jsx)(`span`,{className:`text-xs text-rose-600 flex-1 font-medium`,children:l}),(0,$.jsxs)(`button`,{onClick:()=>{let{connect:e}=se.getState();h?.id&&e(h.id)},className:`flex items-center gap-1 text-[10px] font-bold text-rose-600 hover:text-rose-800 transition-colors uppercase tracking-wider`,children:[(0,$.jsx)(f,{className:`h-3 w-3`}),`Reintentar`]})]}),T.isSpeaking&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-2 bg-blue-500/10 border-b border-blue-500/20 shrink-0`,children:[(0,$.jsxs)(`div`,{className:`flex gap-0.5`,children:[(0,$.jsx)(`span`,{className:`h-1.5 w-0.5 bg-blue-400 rounded-full animate-pulse`,style:{animationDelay:`0ms`}}),(0,$.jsx)(`span`,{className:`h-1.5 w-0.5 bg-blue-400 rounded-full animate-pulse`,style:{animationDelay:`150ms`}}),(0,$.jsx)(`span`,{className:`h-1.5 w-0.5 bg-blue-400 rounded-full animate-pulse`,style:{animationDelay:`300ms`}})]}),(0,$.jsxs)(`span`,{className:`text-[10px] text-blue-400 font-medium font-manrope`,children:[`Narrando`,T.currentText?`: ${T.currentText}...`:`...`]}),(0,$.jsx)(`button`,{onClick:T.stop,className:`text-[10px] text-blue-500 hover:text-blue-300 ml-auto font-bold uppercase tracking-wider`,children:`Detener`})]}),(0,$.jsx)(pr,{messages:t,isLoading:o,currentSteps:s,streamingMessageId:c,userName:h?.name??`Usuario`,agentName:O,onSuggestionClick:k,onNarrateMessage:T.isEnabled?A:void 0}),(0,$.jsx)(mr,{onSendMessage:k,onStop:()=>{E&&p({type:`stop`,sessionId:y})},disabled:!E&&!D,isStreaming:o})]})}export{hr as WebChatPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./index-DMCjjdqf.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./vendor-query-DsWPbQdG.js";import{t}from"./AgentCreateForm-tJZv9FZC.js";var n=e();function r(){return(0,n.jsx)(t,{})}export{r as AgentNewPage};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{_ as t}from"./vendor-charts-Bu2lyBKP.js";import{o as n}from"./vendor-query-DsWPbQdG.js";import{n as r,r as i}from"./utils-3pnRFmFe.js";import{t as a}from"./circle-alert-CyHDwUj8.js";import{t as o}from"./file-text-BT_9S9SM.js";import{t as s}from"./gauge-D_TMa4i9.js";import{n as c,t as l}from"./square-BD81nFtN.js";import{t as u}from"./pause-BUqah9Bi.js";import{t as d}from"./play-NcZ4swwL.js";import{t as f}from"./refresh-cw-DaYdjQFk.js";import{C as p,_ as m,a as h,b as g,c as _,d as v,f as y,g as b,h as x,i as S,l as C,m as w,n as T,o as E,p as D,r as O,s as k,t as A,u as j,v as M,x as ee,y as te}from"./slider-CsiUDxc3.js";import{t as ne}from"./sparkles-yUEb-7oH.js";import{t as re}from"./triangle-alert-C9Y8Ub4X.js";import{t as N}from"./volume-2-CeSXNDv4.js";import{t as ie}from"./zap-hlXjpSeA.js";import{r as ae}from"./gateway-url-COCbW0IR.js";import{J as P,R as oe,S as se,f as ce,p as le,r as ue,x as de}from"./index-DMCjjdqf.js";var fe=i(`Paperclip`,[[`path`,{d:`m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48`,key:`1u3ebp`}]]),pe=i(`SendHorizontal`,[[`path`,{d:`M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z`,key:`117uat`}],[`path`,{d:`M6 12h16`,key:`s4cdu5`}]]),me=i(`Volume1`,[[`path`,{d:`M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z`,key:`uqj9uw`}],[`path`,{d:`M16 9a5 5 0 0 1 0 6`,key:`1q6k2b`}]]),he=i(`VolumeX`,[[`path`,{d:`M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z`,key:`uqj9uw`}],[`line`,{x1:`22`,x2:`16`,y1:`9`,y2:`15`,key:`1ewh16`}],[`line`,{x1:`16`,x2:`22`,y1:`9`,y2:`15`,key:`5ykzw1`}]]),F=e(t(),1);function ge(e,t){let n;try{n=e()}catch{return}return{getItem:e=>{let r=e=>e===null?null:JSON.parse(e,t?.reviver),i=n.getItem(e)??null;return i instanceof Promise?i.then(r):r(i)},setItem:(e,r)=>n.setItem(e,JSON.stringify(r,t?.replacer)),removeItem:e=>n.removeItem(e)}}var I=e=>t=>{try{let n=e(t);return n instanceof Promise?n:{then(e){return I(e)(n)},catch(e){return this}}}catch(e){return{then(e){return this},catch(t){return I(t)(e)}}}},L=ae()(((e,t)=>(n,r,i)=>{let a={storage:ge(()=>window.localStorage),partialize:e=>e,version:0,merge:(e,t)=>({...t,...e}),...t},o=!1,s=0,c=new Set,l=new Set,u=a.storage;if(!u)return e((...e)=>{console.warn(`[zustand persist middleware] Unable to update item '${a.name}', the given storage is currently unavailable.`),n(...e)},r,i);let d=()=>{let e=a.partialize({...r()});return u.setItem(a.name,{state:e,version:a.version})},f=i.setState;i.setState=(e,t)=>(f(e,t),d());let p=e((...e)=>(n(...e),d()),r,i);i.getInitialState=()=>p;let m,h=()=>{if(!u)return;let e=++s;o=!1,c.forEach(e=>e(r()??p));let t=a.onRehydrateStorage?.call(a,r()??p)||void 0;return I(u.getItem.bind(u))(a.name).then(e=>{if(e)if(typeof e.version==`number`&&e.version!==a.version){if(a.migrate){let t=a.migrate(e.state,e.version);return t instanceof Promise?t.then(e=>[!0,e]):[!0,t]}console.error(`State loaded from storage couldn't be migrated since no migrate function was provided`)}else return[!1,e.state];return[!1,void 0]}).then(t=>{if(e!==s)return;let[i,o]=t;if(m=a.merge(o,r()??p),n(m,!0),i)return d()}).then(()=>{e===s&&(t?.(r(),void 0),m=r(),o=!0,l.forEach(e=>e(m)))}).catch(n=>{e===s&&t?.(void 0,n)})};return i.persist={setOptions:e=>{a={...a,...e},e.storage&&(u=e.storage)},clearStorage:()=>{u?.removeItem(a.name)},getOptions:()=>a,rehydrate:()=>h(),hasHydrated:()=>o,onHydrate:e=>(c.add(e),()=>{c.delete(e)}),onFinishHydration:e=>(l.add(e),()=>{l.delete(e)})},a.skipHydration||h(),m||p})(e=>({messages:[],isLoading:!1,currentSteps:[],streamingMessageId:null,connectionWarning:null,addMessage:t=>e(e=>({messages:[...e.messages,t]})),addMessages:t=>e(e=>({messages:[...e.messages,...t]})),updateMessage:(t,n)=>e(e=>({messages:e.messages.map(e=>e.id===t?{...e,...n}:e)})),setMessages:t=>e({messages:t}),clearMessages:()=>e({messages:[],currentSteps:[],streamingMessageId:null}),setLoading:t=>e({isLoading:t}),addStep:t=>e(e=>({currentSteps:[...e.currentSteps.slice(-4),t]})),clearSteps:()=>e({currentSteps:[]}),setStreamingMessageId:t=>e({streamingMessageId:t}),setConnectionWarning:t=>e({connectionWarning:t})}),{name:`hive-chat-storage`,partialize:e=>({messages:e.messages.slice(-15)})}));function _e(e,t){let n=L(e=>e.addMessage),i=L(e=>e.updateMessage),a=L(e=>e.setLoading);L(e=>e.addStep);let o=L(e=>e.clearSteps),s=L(e=>e.setStreamingMessageId),c=(0,F.useRef)(null);return{handleStreamingChunk:(0,F.useCallback)(l=>{l.content?.startsWith(`🎙️ Transcripción:`)&&a(!0);let u=l.id||c.current||r(),{messages:d}=L.getState(),f=d.find(e=>e.id===u);l.isChunk&&f?i(u,{content:(f.content||``)+l.content,timestamp:l.timestamp||f.timestamp}):l.isChunk&&!f?(c.current=u,s(u),n({id:u,conversationId:t,type:`agent`,content:l.content||``,agentId:e,timestamp:l.timestamp||new Date().toISOString()})):f?i(u,{content:l.content||f.content,timestamp:l.timestamp||f.timestamp,...l.audio&&{audio:{base64:l.audio,mimeType:l.mimeType}}}):n({id:u,conversationId:t,type:`agent`,content:l.content||l.message||``,agentId:e,timestamp:l.timestamp||new Date().toISOString(),...l.audio&&{audio:{base64:l.audio,mimeType:l.mimeType}}}),l.isChunk||(c.current=null,s(null),o(),a(!1))},[e,t,n,i,a,o,s]),handleAudioMessage:(0,F.useCallback)(i=>{n({id:i.id||r(),conversationId:t,type:`agent`,content:i.content||``,agentId:e,timestamp:i.timestamp||new Date().toISOString(),audio:i.audio?{base64:i.audio,mimeType:i.mimeType||`audio/wav`}:void 0}),o(),a(!1)},[e,t,n,o,a]),handleProgress:(0,F.useCallback)(e=>{e.content&&(L.getState().addStep(e.content),L.getState().setLoading(!0))},[]),handleTyping:(0,F.useCallback)(e=>{e.isTyping===!0?L.getState().setLoading(!0):e.isTyping===!1&&(L.getState().clearSteps(),L.getState().setLoading(!1))},[]),resetStreamingRef:(0,F.useCallback)(()=>{c.current=null,s(null)},[s])}}var ve=`hive-narration-prefs`;function ye(){try{let e=localStorage.getItem(ve);if(e)return JSON.parse(e)}catch{}return{enabled:!1,rate:1,pitch:1,voiceName:null}}function be(e){try{localStorage.setItem(ve,JSON.stringify(e))}catch{}}function xe(){let[e,t]=(0,F.useState)(ye),[n,r]=(0,F.useState)(!1),[i,a]=(0,F.useState)(null),o=(0,F.useRef)(null),s=(0,F.useCallback)(e=>e&&window.speechSynthesis.getVoices().find(t=>t.name===e)||null,[]),c=(0,F.useCallback)(t=>{if(!e.enabled||!window.speechSynthesis)return;window.speechSynthesis.cancel();let n=t.replace(/```[\s\S]*?```/g,``).replace(/`[^`]+`/g,``).replace(/[#*_~\[\]()]/g,``).replace(/\n{2,}/g,`. `).replace(/\n/g,` `).trim();if(!n)return;let i=new SpeechSynthesisUtterance(n);i.rate=e.rate,i.pitch=e.pitch;let c=s(e.voiceName);c&&(i.voice=c),i.onstart=()=>{r(!0),a(n.slice(0,50))},i.onend=()=>{r(!1),a(null),o.current=null},i.onerror=()=>{r(!1),a(null),o.current=null},o.current=i,window.speechSynthesis.speak(i)},[e,s]),l=(0,F.useCallback)(()=>{window.speechSynthesis.cancel(),r(!1),a(null),o.current=null},[]),u=(0,F.useCallback)(()=>{t(e=>{let t={...e,enabled:!e.enabled};return be(t),t.enabled||(window.speechSynthesis.cancel(),r(!1),a(null)),t})},[]),d=(0,F.useCallback)(e=>{t(t=>{let n={...t,...e};return be(n),n})},[]);return(0,F.useEffect)(()=>{typeof window<`u`&&window.speechSynthesis&&window.speechSynthesis.getVoices()},[]),(0,F.useEffect)(()=>()=>{window.speechSynthesis?.cancel()},[]),{isEnabled:e.enabled,isSpeaking:n,currentText:i,rate:e.rate,pitch:e.pitch,narrate:c,stop:l,toggle:u,updatePrefs:d}}function Se(e,t){let n=String(e);if(typeof t!=`string`)throw TypeError(`Expected character`);let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}function Ce(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function we(e,t,n){let r=h((n||{}).ignore||[]),i=Te(t),a=-1;for(;++a<i.length;)S(e,`text`,o);function o(e,t){let n=-1,i;for(;++n<t.length;){let e=t[n],a=i?i.children:void 0;if(r(e,a?a.indexOf(e):void 0,i))return;i=e}if(i)return s(e,t)}function s(e,t){let n=t[t.length-1],r=i[a][0],o=i[a][1],s=0,c=n.children.indexOf(e),l=!1,u=[];r.lastIndex=0;let d=r.exec(e.value);for(;d;){let n=d.index,i={index:d.index,input:d.input,stack:[...t,e]},a=o(...d,i);if(typeof a==`string`&&(a=a.length>0?{type:`text`,value:a}:void 0),a===!1?r.lastIndex=n+1:(s!==n&&u.push({type:`text`,value:e.value.slice(s,n)}),Array.isArray(a)?u.push(...a):a&&u.push(a),s=n+d[0].length,l=!0),!r.global)break;d=r.exec(e.value)}return l?(s<e.value.length&&u.push({type:`text`,value:e.value.slice(s)}),n.children.splice(c,1,...u)):u=[e],c+u.length}}function Te(e){let t=[];if(!Array.isArray(e))throw TypeError(`Expected find and replace tuple or list of tuples`);let n=!e[0]||Array.isArray(e[0])?e:[e],r=-1;for(;++r<n.length;){let e=n[r];t.push([Ee(e[0]),De(e[1])])}return t}function Ee(e){return typeof e==`string`?new RegExp(Ce(e),`g`):e}function De(e){return typeof e==`function`?e:function(){return e}}var R=`phrasing`,z=[`autolink`,`link`,`image`,`label`];function Oe(){return{transforms:[Fe],enter:{literalAutolink:Ae,literalAutolinkEmail:B,literalAutolinkHttp:B,literalAutolinkWww:B},exit:{literalAutolink:Pe,literalAutolinkEmail:Ne,literalAutolinkHttp:je,literalAutolinkWww:Me}}}function ke(){return{unsafe:[{character:`@`,before:`[+\\-.\\w]`,after:`[\\-.\\w]`,inConstruct:R,notInConstruct:z},{character:`.`,before:`[Ww]`,after:`[\\-.\\w]`,inConstruct:R,notInConstruct:z},{character:`:`,before:`[ps]`,after:`\\/`,inConstruct:R,notInConstruct:z}]}}function Ae(e){this.enter({type:`link`,title:null,url:``,children:[]},e)}function B(e){this.config.enter.autolinkProtocol.call(this,e)}function je(e){this.config.exit.autolinkProtocol.call(this,e)}function Me(e){this.config.exit.data.call(this,e);let t=this.stack[this.stack.length-1];t.type,t.url=`http://`+this.sliceSerialize(e)}function Ne(e){this.config.exit.autolinkEmail.call(this,e)}function Pe(e){this.exit(e)}function Fe(e){we(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,Ie],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,Le]],{ignore:[`link`,`linkReference`]})}function Ie(e,t,n,r,i){let a=``;if(!Be(i)||(/^w/i.test(t)&&(n=t+n,t=``,a=`http://`),!Re(n)))return!1;let o=ze(n+r);if(!o[0])return!1;let s={type:`link`,title:null,url:a+t+o[0],children:[{type:`text`,value:t+o[0]}]};return o[1]?[s,{type:`text`,value:o[1]}]:s}function Le(e,t,n,r){return!Be(r,!0)||/[-\d_]$/.test(n)?!1:{type:`link`,title:null,url:`mailto:`+t+`@`+n,children:[{type:`text`,value:t+`@`+n}]}}function Re(e){let t=e.split(`.`);return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function ze(e){let t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(`)`),i=Se(e,`(`),a=Se(e,`)`);for(;r!==-1&&i>a;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(`)`),a++;return[e,n]}function Be(e,t){let n=e.input.charCodeAt(e.index-1);return(e.index===0||m(n)||b(n))&&(!t||n!==47)}Xe.peek=Ye;function Ve(){this.buffer()}function He(e){this.enter({type:`footnoteReference`,identifier:``,label:``},e)}function Ue(){this.buffer()}function We(e){this.enter({type:`footnoteDefinition`,identifier:``,label:``,children:[]},e)}function Ge(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=M(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Ke(e){this.exit(e)}function qe(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=M(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Je(e){this.exit(e)}function Ye(){return`[`}function Xe(e,t,n,r){let i=n.createTracker(r),a=i.move(`[^`),o=n.enter(`footnoteReference`),s=n.enter(`reference`);return a+=i.move(n.safe(n.associationId(e),{after:`]`,before:a})),s(),o(),a+=i.move(`]`),a}function Ze(){return{enter:{gfmFootnoteCallString:Ve,gfmFootnoteCall:He,gfmFootnoteDefinitionLabelString:Ue,gfmFootnoteDefinition:We},exit:{gfmFootnoteCallString:Ge,gfmFootnoteCall:Ke,gfmFootnoteDefinitionLabelString:qe,gfmFootnoteDefinition:Je}}}function Qe(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:Xe},unsafe:[{character:`[`,inConstruct:[`label`,`phrasing`,`reference`]}]};function n(e,n,r,i){let a=r.createTracker(i),o=a.move(`[^`),s=r.enter(`footnoteDefinition`),c=r.enter(`label`);return o+=a.move(r.safe(r.associationId(e),{before:o,after:`]`})),c(),o+=a.move(`]:`),e.children&&e.children.length>0&&(a.shift(4),o+=a.move((t?`
|
|
2
|
-
`:` `)+r.indentLines(r.containerFlow(e,a.current()),t?et:$e))),s(),o}}function $e(e,t,n){return t===0?e:et(e,t,n)}function et(e,t,n){return(n?``:` `)+e}var tt=[`autolink`,`destinationLiteral`,`destinationRaw`,`reference`,`titleQuote`,`titleApostrophe`];ot.peek=st;function nt(){return{canContainEols:[`delete`],enter:{strikethrough:it},exit:{strikethrough:at}}}function rt(){return{unsafe:[{character:`~`,inConstruct:`phrasing`,notInConstruct:tt}],handlers:{delete:ot}}}function it(e){this.enter({type:`delete`,children:[]},e)}function at(e){this.exit(e)}function ot(e,t,n,r){let i=n.createTracker(r),a=n.enter(`strikethrough`),o=i.move(`~~`);return o+=n.containerPhrasing(e,{...i.current(),before:o,after:`~`}),o+=i.move(`~~`),a(),o}function st(){return`~`}function ct(e){return e.length}function lt(e,t){let n=t||{},r=(n.align||[]).concat(),i=n.stringLength||ct,a=[],o=[],s=[],c=[],l=0,u=-1;for(;++u<e.length;){let t=[],r=[],a=-1;for(e[u].length>l&&(l=e[u].length);++a<e[u].length;){let o=ut(e[u][a]);if(n.alignDelimiters!==!1){let e=i(o);r[a]=e,(c[a]===void 0||e>c[a])&&(c[a]=e)}t.push(o)}o[u]=t,s[u]=r}let d=-1;if(typeof r==`object`&&`length`in r)for(;++d<l;)a[d]=dt(r[d]);else{let e=dt(r);for(;++d<l;)a[d]=e}d=-1;let f=[],p=[];for(;++d<l;){let e=a[d],t=``,r=``;e===99?(t=`:`,r=`:`):e===108?t=`:`:e===114&&(r=`:`);let i=n.alignDelimiters===!1?1:Math.max(1,c[d]-t.length-r.length),o=t+`-`.repeat(i)+r;n.alignDelimiters!==!1&&(i=t.length+i+r.length,i>c[d]&&(c[d]=i),p[d]=i),f[d]=o}o.splice(1,0,f),s.splice(1,0,p),u=-1;let m=[];for(;++u<o.length;){let e=o[u],t=s[u];d=-1;let r=[];for(;++d<l;){let i=e[d]||``,o=``,s=``;if(n.alignDelimiters!==!1){let e=c[d]-(t[d]||0),n=a[d];n===114?o=` `.repeat(e):n===99?e%2?(o=` `.repeat(e/2+.5),s=` `.repeat(e/2-.5)):(o=` `.repeat(e/2),s=o):s=` `.repeat(e)}n.delimiterStart!==!1&&!d&&r.push(`|`),n.padding!==!1&&!(n.alignDelimiters===!1&&i===``)&&(n.delimiterStart!==!1||d)&&r.push(` `),n.alignDelimiters!==!1&&r.push(o),r.push(i),n.alignDelimiters!==!1&&r.push(s),n.padding!==!1&&r.push(` `),(n.delimiterEnd!==!1||d!==l-1)&&r.push(`|`)}m.push(n.delimiterEnd===!1?r.join(``).replace(/ +$/,``):r.join(``))}return m.join(`
|
|
3
|
-
`)}function ut(e){return e==null?``:String(e)}function dt(e){let t=typeof e==`string`?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function ft(e,t,n,r){let i=n.enter(`blockquote`),a=n.createTracker(r);a.move(`> `),a.shift(2);let o=n.indentLines(n.containerFlow(e,a.current()),pt);return i(),o}function pt(e,t,n){return`>`+(n?``:` `)+e}function mt(e,t){return ht(e,t.inConstruct,!0)&&!ht(e,t.notInConstruct,!1)}function ht(e,t,n){if(typeof t==`string`&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function gt(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
|
|
4
|
-
`&&mt(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?``:` `;return`\\
|
|
5
|
-
`}function _t(e,t){let n=String(e),r=n.indexOf(t),i=r,a=0,o=0;if(typeof t!=`string`)throw TypeError(`Expected substring`);for(;r!==-1;)r===i?++a>o&&(o=a):a=1,i=r+t.length,r=n.indexOf(t,i);return o}function vt(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function yt(e){let t=e.options.fence||"`";if(t!=="`"&&t!==`~`)throw Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function bt(e,t,n,r){let i=yt(n),a=e.value||``,o=i==="`"?`GraveAccent`:`Tilde`;if(vt(e,n)){let e=n.enter(`codeIndented`),t=n.indentLines(a,xt);return e(),t}let s=n.createTracker(r),c=i.repeat(Math.max(_t(a,i)+1,3)),l=n.enter(`codeFenced`),u=s.move(c);if(e.lang){let t=n.enter(`codeFencedLang${o}`);u+=s.move(n.safe(e.lang,{before:u,after:` `,encode:["`"],...s.current()})),t()}if(e.lang&&e.meta){let t=n.enter(`codeFencedMeta${o}`);u+=s.move(` `),u+=s.move(n.safe(e.meta,{before:u,after:`
|
|
6
|
-
`,encode:["`"],...s.current()})),t()}return u+=s.move(`
|
|
7
|
-
`),a&&(u+=s.move(a+`
|
|
8
|
-
`)),u+=s.move(c),l(),u}function xt(e,t,n){return(n?``:` `)+e}function V(e){let t=e.options.quote||`"`;if(t!==`"`&&t!==`'`)throw Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function St(e,t,n,r){let i=V(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`definition`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`[`);return l+=c.move(n.safe(n.associationId(e),{before:l,after:`]`,...c.current()})),l+=c.move(`]: `),s(),!e.url||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`
|
|
9
|
-
`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),o(),l}function Ct(e){let t=e.options.emphasis||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function H(e){return`&#x`+e.toString(16).toUpperCase()+`;`}function U(e,t,n){let r=_(e),i=_(t);return r===void 0?i===void 0?n===`_`?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}wt.peek=Tt;function wt(e,t,n,r){let i=Ct(n),a=n.enter(`emphasis`),o=n.createTracker(r),s=o.move(i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=U(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=H(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=U(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+H(d));let p=o.move(i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function Tt(e,t,n){return n.options.emphasis||`*`}function Et(e,t){let n=!1;return O(e,function(e){if(`value`in e&&/\r?\n|\r/.test(e.value)||e.type===`break`)return n=!0,!1}),!!((!e.depth||e.depth<3)&&ee(e)&&(t.options.setext||n))}function Dt(e,t,n,r){let i=Math.max(Math.min(6,e.depth||1),1),a=n.createTracker(r);if(Et(e,n)){let t=n.enter(`headingSetext`),r=n.enter(`phrasing`),o=n.containerPhrasing(e,{...a.current(),before:`
|
|
10
|
-
`,after:`
|
|
11
|
-
`});return r(),t(),o+`
|
|
12
|
-
`+(i===1?`=`:`-`).repeat(o.length-(Math.max(o.lastIndexOf(`\r`),o.lastIndexOf(`
|
|
13
|
-
`))+1))}let o=`#`.repeat(i),s=n.enter(`headingAtx`),c=n.enter(`phrasing`);a.move(o+` `);let l=n.containerPhrasing(e,{before:`# `,after:`
|
|
14
|
-
`,...a.current()});return/^[\t ]/.test(l)&&(l=H(l.charCodeAt(0))+l.slice(1)),l=l?o+` `+l:o,n.options.closeAtx&&(l+=` `+o),c(),s(),l}Ot.peek=kt;function Ot(e){return e.value||``}function kt(){return`<`}At.peek=jt;function At(e,t,n,r){let i=V(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`image`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`![`);return l+=c.move(n.safe(e.alt,{before:l,after:`]`,...c.current()})),l+=c.move(`](`),s(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),l+=c.move(`)`),o(),l}function jt(){return`!`}Mt.peek=Nt;function Mt(e,t,n,r){let i=e.referenceType,a=n.enter(`imageReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`![`),l=n.safe(e.alt,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function Nt(){return`!`}Pt.peek=Ft;function Pt(e,t,n){let r=e.value||``,i="`",a=-1;for(;RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=` `+r+` `);++a<n.unsafe.length;){let e=n.unsafe[a],t=n.compilePattern(e),i;if(e.atBreak)for(;i=t.exec(r);){let e=i.index;r.charCodeAt(e)===10&&r.charCodeAt(e-1)===13&&e--,r=r.slice(0,e)+` `+r.slice(i.index+1)}}return i+r+i}function Ft(){return"`"}function It(e,t){let n=ee(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type===`text`&&(n===e.url||`mailto:`+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}Lt.peek=Rt;function Lt(e,t,n,r){let i=V(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.createTracker(r),s,c;if(It(e,n)){let t=n.stack;n.stack=[],s=n.enter(`autolink`);let r=o.move(`<`);return r+=o.move(n.containerPhrasing(e,{before:r,after:`>`,...o.current()})),r+=o.move(`>`),s(),n.stack=t,r}s=n.enter(`link`),c=n.enter(`label`);let l=o.move(`[`);return l+=o.move(n.containerPhrasing(e,{before:l,after:`](`,...o.current()})),l+=o.move(`](`),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter(`destinationLiteral`),l+=o.move(`<`),l+=o.move(n.safe(e.url,{before:l,after:`>`,...o.current()})),l+=o.move(`>`)):(c=n.enter(`destinationRaw`),l+=o.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...o.current()}))),c(),e.title&&(c=n.enter(`title${a}`),l+=o.move(` `+i),l+=o.move(n.safe(e.title,{before:l,after:i,...o.current()})),l+=o.move(i),c()),l+=o.move(`)`),s(),l}function Rt(e,t,n){return It(e,n)?`<`:`[`}zt.peek=Bt;function zt(e,t,n,r){let i=e.referenceType,a=n.enter(`linkReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`[`),l=n.containerPhrasing(e,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function Bt(){return`[`}function W(e){let t=e.options.bullet||`*`;if(t!==`*`&&t!==`+`&&t!==`-`)throw Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function Vt(e){let t=W(e),n=e.options.bulletOther;if(!n)return t===`*`?`-`:`*`;if(n!==`*`&&n!==`+`&&n!==`-`)throw Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function Ht(e){let t=e.options.bulletOrdered||`.`;if(t!==`.`&&t!==`)`)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function Ut(e){let t=e.options.rule||`*`;if(t!==`*`&&t!==`-`&&t!==`_`)throw Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function Wt(e,t,n,r){let i=n.enter(`list`),a=n.bulletCurrent,o=e.ordered?Ht(n):W(n),s=e.ordered?o===`.`?`)`:`.`:Vt(n),c=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){let t=e.children?e.children[0]:void 0;if((o===`*`||o===`-`)&&t&&(!t.children||!t.children[0])&&n.stack[n.stack.length-1]===`list`&&n.stack[n.stack.length-2]===`listItem`&&n.stack[n.stack.length-3]===`list`&&n.stack[n.stack.length-4]===`listItem`&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(c=!0),Ut(n)===o&&t){let t=-1;for(;++t<e.children.length;){let n=e.children[t];if(n&&n.type===`listItem`&&n.children&&n.children[0]&&n.children[0].type===`thematicBreak`){c=!0;break}}}}c&&(o=s),n.bulletCurrent=o;let l=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=a,i(),l}function Gt(e){let t=e.options.listItemIndent||`one`;if(t!==`tab`&&t!==`one`&&t!==`mixed`)throw Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function Kt(e,t,n,r){let i=Gt(n),a=n.bulletCurrent||W(n);t&&t.type===`list`&&t.ordered&&(a=(typeof t.start==`number`&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+a);let o=a.length+1;(i===`tab`||i===`mixed`&&(t&&t.type===`list`&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);let s=n.createTracker(r);s.move(a+` `.repeat(o-a.length)),s.shift(o);let c=n.enter(`listItem`),l=n.indentLines(n.containerFlow(e,s.current()),u);return c(),l;function u(e,t,n){return t?(n?``:` `.repeat(o))+e:(n?a:a+` `.repeat(o-a.length))+e}}function qt(e,t,n,r){let i=n.enter(`paragraph`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,r);return a(),i(),o}var Jt=h([`break`,`delete`,`emphasis`,`footnote`,`footnoteReference`,`image`,`imageReference`,`inlineCode`,`inlineMath`,`link`,`linkReference`,`mdxJsxTextElement`,`mdxTextExpression`,`strong`,`text`,`textDirective`]);function Yt(e,t,n,r){return(e.children.some(function(e){return Jt(e)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function Xt(e){let t=e.options.strong||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}Zt.peek=Qt;function Zt(e,t,n,r){let i=Xt(n),a=n.enter(`strong`),o=n.createTracker(r),s=o.move(i+i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=U(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=H(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=U(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+H(d));let p=o.move(i+i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function Qt(e,t,n){return n.options.strong||`*`}function $t(e,t,n,r){return n.safe(e.value,r)}function en(e){let t=e.options.ruleRepetition||3;if(t<3)throw Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function tn(e,t,n){let r=(Ut(n)+(n.options.ruleSpaces?` `:``)).repeat(en(n));return n.options.ruleSpaces?r.slice(0,-1):r}var nn={blockquote:ft,break:gt,code:bt,definition:St,emphasis:wt,hardBreak:gt,heading:Dt,html:Ot,image:At,imageReference:Mt,inlineCode:Pt,link:Lt,linkReference:zt,list:Wt,listItem:Kt,paragraph:qt,root:Yt,strong:Zt,text:$t,thematicBreak:tn};function rn(){return{enter:{table:an,tableData:cn,tableHeader:cn,tableRow:sn},exit:{codeText:ln,table:on,tableData:G,tableHeader:G,tableRow:G}}}function an(e){let t=e._align;this.enter({type:`table`,align:t.map(function(e){return e===`none`?null:e}),children:[]},e),this.data.inTable=!0}function on(e){this.exit(e),this.data.inTable=void 0}function sn(e){this.enter({type:`tableRow`,children:[]},e)}function G(e){this.exit(e)}function cn(e){this.enter({type:`tableCell`,children:[]},e)}function ln(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,un));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function un(e,t){return t===`|`?t:e}function dn(e){let t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=n?` `:`|`;return{unsafe:[{character:`\r`,inConstruct:`tableCell`},{character:`
|
|
15
|
-
`,inConstruct:`tableCell`},{atBreak:!0,character:`|`,after:`[ :-]`},{character:`|`,inConstruct:`tableCell`},{atBreak:!0,character:`:`,after:`-`},{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{inlineCode:f,table:o,tableCell:c,tableRow:s}};function o(e,t,n,r){return l(u(e,n,r),e.align)}function s(e,t,n,r){let i=l([d(e,n,r)]);return i.slice(0,i.indexOf(`
|
|
16
|
-
`))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return lt(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=nn.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function fn(){return{exit:{taskListCheckValueChecked:mn,taskListCheckValueUnchecked:mn,paragraph:hn}}}function pn(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:gn}}}function mn(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function hn(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function gn(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=nn.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function _n(){return[Oe(),Ze(),nt(),rn(),fn()]}function vn(e){return{extensions:[ke(),Qe(e),rt(),dn(e),pn()]}}var yn={tokenize:An,partial:!0},bn={tokenize:jn,partial:!0},xn={tokenize:Mn,partial:!0},Sn={tokenize:Nn,partial:!0},Cn={tokenize:Pn,partial:!0},wn={name:`wwwAutolink`,tokenize:On,previous:Fn},Tn={name:`protocolAutolink`,tokenize:kn,previous:In},K={name:`emailAutolink`,tokenize:Dn,previous:Ln},q={};function En(){return{text:q}}for(var J=48;J<123;)q[J]=K,J++,J===58?J=65:J===91&&(J=97);q[43]=K,q[45]=K,q[46]=K,q[95]=K,q[72]=[K,Tn],q[104]=[K,Tn],q[87]=[K,wn],q[119]=[K,wn];function Dn(e,t,n){let r=this,i,a;return o;function o(t){return!Y(t)||!Ln.call(r,r.previous)||X(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return Y(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(Cn,u,l)(t):t===45||t===95||v(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&j(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function On(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!Fn.call(r,r.previous)||X(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(yn,e.attempt(bn,e.attempt(xn,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function kn(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&In.call(r,r.previous)&&!X(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(j(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||y(t)||w(t)||m(t)||b(t)?n(t):e.attempt(bn,e.attempt(xn,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function An(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function jn(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(Sn,c,s)(t):t===null||w(t)||m(t)||t!==45&&b(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function Mn(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(Sn,t,a)(o):o===null||w(o)||m(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function Nn(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||w(o)||m(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||w(e)||m(e)?t(e):r(e)}function a(e){return j(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):j(t)?(e.consume(t),o):n(t)}}function Pn(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return v(e)?n(e):t(e)}}function Fn(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||w(e)}function In(e){return!j(e)}function Ln(e){return!(e===47||Y(e))}function Y(e){return e===43||e===45||e===46||e===95||v(e)}function X(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var Rn={tokenize:Kn,partial:!0};function zn(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:Un,continuation:{tokenize:Wn},exit:Gn}},text:{91:{name:`gfmFootnoteCall`,tokenize:Hn},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:Bn,resolveTo:Vn}}}}function Bn(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=M(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function Vn(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function Hn(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||w(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(M(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return w(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function Un(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||w(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=M(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return w(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),C(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function Wn(e,t,n){return e.check(E,t,e.attempt(Rn,t,n))}function Gn(e){e.exit(`gfmFootnoteDefinition`)}function Kn(e,t,n){let r=this;return C(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function qn(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&g(o,o.length,0,k(s,e.slice(r+1,n),t)),g(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),g(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=_(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=_(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var Jn=class{constructor(){this.map=[]}add(e,t,n){Yn(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0}};function Yn(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function Xn(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function Zn(){return{flow:{null:{name:`table`,tokenize:Qn,resolveAll:$n}}}}function Qn(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let e=r.events[t][1].type;if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?T:c;return a===T&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):D(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):x(t)?C(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||w(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,x(t)?C(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):S(t)}function h(t){return x(t)?C(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||D(t)?b(t):S(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):S(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return x(t)?C(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||D(n)?!o||i!==a?S(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):S(n)}function S(e){return n(e)}function T(t){return e.enter(`tableRow`),E(t)}function E(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),E):n===null||D(n)?(e.exit(`tableRow`),t(n)):x(n)?C(e,E,`whitespace`)(n):(e.enter(`data`),O(n))}function O(t){return t===null||t===124||w(t)?(e.exit(`data`),E(t)):(e.consume(t),t===92?k:O)}function k(t){return t===92||t===124?(e.consume(t),O):O(t)}}function $n(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new Jn;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(er(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=Z(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=Z(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=Z(f,t,o,i,n,d)):(o[0]=o[1],d=Z(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&er(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=Xn(t.events,n))}return e}function Z(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},Q(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=Q(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=Q(t.events,n[2]),a=Q(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},Q(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function er(e,t,n,r,i){let a=[],o=Q(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function Q(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var tr={name:`tasklistCheck`,tokenize:rr};function nr(){return{text:{91:tr}}}function rr(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return w(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return D(r)?t(r):x(r)?e.check({tokenize:ir},t,n)(r):n(r)}}function ir(e,t,n){return C(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function ar(e){return te([En(),zn(),qn(e),Zn(),nr()])}var or={};function sr(e){let t=this,n=e||or,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(ar(n)),a.push(_n()),o.push(vn(n))}var $=n();function cr(e){return new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}function lr({audio:e,mimeType:t=`audio/webm`}){let[n,r]=(0,F.useState)(!1),[i,a]=(0,F.useState)(null),[o,c]=(0,F.useState)(0),[l,f]=(0,F.useState)(0),[m,h]=(0,F.useState)(1),[g,_]=(0,F.useState)(1),v=(0,F.useRef)(null);(0,F.useEffect)(()=>{e&&!i&&a(`data:${t};base64,${e}`)},[e,i,t]),(0,F.useEffect)(()=>{v.current&&(v.current.playbackRate=g)},[g]),(0,F.useEffect)(()=>{v.current&&(v.current.volume=m)},[m]);let y=()=>{v.current&&(n?v.current.pause():v.current.play(),r(!n))},b=()=>{v.current&&(c(v.current.currentTime),f(v.current.duration))},x=e=>{v.current&&(v.current.currentTime=e[0],c(e[0]))},S=()=>{let e=[1,1.25,1.5,2];_(e[(e.indexOf(g)+1)%e.length])},C=e=>isNaN(e)?`0:00`:`${Math.floor(e/60)}:${Math.floor(e%60).toString().padStart(2,`0`)}`;if(!e)return null;let w=m===0?he:m<.5?me:N;return(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 mt-3 p-3 bg-zinc-900/50 border border-white/5 rounded-2xl w-full max-w-sm shadow-xl backdrop-blur-sm`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`button`,{onClick:y,className:`h-10 w-10 rounded-full bg-blue-600 hover:bg-blue-500 flex items-center justify-center transition-all active:scale-95 shadow-lg shadow-blue-600/20`,children:n?(0,$.jsx)(u,{className:`h-5 w-5 text-white fill-white`}):(0,$.jsx)(d,{className:`h-5 w-5 text-white fill-white ml-0.5`})}),(0,$.jsxs)(`div`,{className:`flex-1 flex flex-col gap-1.5 min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex justify-between items-end mb-0.5`,children:[(0,$.jsx)(`span`,{className:`text-[10px] font-bold text-blue-400/80 uppercase tracking-widest flex items-center gap-1.5`,children:n?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`span`,{className:`flex gap-0.5 items-end h-3`,children:[(0,$.jsx)(`span`,{className:`w-0.5 bg-blue-400/60 animate-[bounce_0.8s_infinite_0ms]`,style:{height:`40%`}}),(0,$.jsx)(`span`,{className:`w-0.5 bg-blue-400/60 animate-[bounce_0.8s_infinite_200ms]`,style:{height:`80%`}}),(0,$.jsx)(`span`,{className:`w-0.5 bg-blue-400/60 animate-[bounce_0.8s_infinite_400ms]`,style:{height:`60%`}})]}),`Reproduciendo`]}):`Audio del Agente`}),(0,$.jsxs)(`span`,{className:`text-[10px] font-mono text-white/40 tabular-nums`,children:[C(o),` / `,C(l)]})]}),(0,$.jsx)(A,{value:[o],max:l||100,step:.1,onValueChange:x,className:`w-full`})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between pt-1 mt-1 border-t border-white/5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 group/vol`,children:[(0,$.jsx)(`button`,{onClick:()=>h(+(m===0)),className:`text-white/40 hover:text-white transition-colors`,children:(0,$.jsx)(w,{className:`h-4 w-4`})}),(0,$.jsx)(`div`,{className:`w-16`,children:(0,$.jsx)(A,{value:[m*100],max:100,onValueChange:e=>h(e[0]/100),className:`h-4`})})]}),(0,$.jsxs)(`button`,{onClick:S,className:`flex items-center gap-1.5 px-2 py-1 rounded-md hover:bg-white/5 text-white/40 hover:text-blue-400 transition-all`,children:[(0,$.jsx)(s,{className:`h-3.5 w-3.5`}),(0,$.jsxs)(`span`,{className:`text-[10px] font-bold min-w-[2.5ch]`,children:[g,`x`]})]})]}),(0,$.jsx)(`button`,{onClick:()=>{v.current&&(v.current.currentTime=0)},className:`text-white/20 hover:text-white/60 transition-colors p-1`,title:`Reiniciar`,children:(0,$.jsx)(p,{className:`h-3.5 w-3.5`})})]}),i&&(0,$.jsx)(`audio`,{ref:v,src:i,onTimeUpdate:b,onLoadedMetadata:b,onEnded:()=>r(!1),onPlay:()=>r(!0),onPause:()=>r(!1),className:`hidden`})]})}function ur({message:e,userName:t=`Tú`,agentName:n=`Agente`,isStreaming:r,onNarrate:i}){let a=e.type===`user`,s=e.type===`error`,c=e.type===`system`,l=!!e.audio?.base64||!!e.audio?.url;return c?(0,$.jsx)(`div`,{className:`flex justify-center my-2`,children:(0,$.jsx)(`span`,{className:`text-[11px] text-white/50 bg-white/5 border border-white/10 px-3 py-1 rounded-full font-mono`,children:e.content})}):s?(0,$.jsx)(`div`,{className:`flex items-center gap-2 justify-center my-2`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-[12px] font-medium text-rose-400 bg-rose-500/10 border border-rose-500/20 px-4 py-2 rounded-xl`,children:[(0,$.jsx)(re,{className:`h-3.5 w-3.5 shrink-0`}),e.content]})}):a?(0,$.jsx)(`div`,{className:`flex items-end justify-end gap-2 group mb-2`,children:(0,$.jsxs)(`div`,{className:`flex flex-col items-end gap-1 max-w-[75%] md:max-w-[65%]`,children:[e.image&&(0,$.jsx)(`div`,{className:`mb-2 rounded-2xl overflow-hidden border border-white/10 shadow-lg bg-black/20`,children:(0,$.jsx)(`img`,{src:e.image.url||`data:${e.image.mimeType||`image/jpeg`};base64,${e.image.base64}`,alt:`adjunto`,className:`max-w-full h-auto max-h-[300px] object-contain`})}),e.document&&(0,$.jsxs)(`div`,{className:`mb-2 flex items-center gap-3 bg-white/5 border border-white/10 px-4 py-3 rounded-2xl w-full`,children:[(0,$.jsx)(`div`,{className:`h-10 w-10 rounded-lg bg-blue-500/10 flex items-center justify-center border border-blue-500/20`,children:(0,$.jsx)(o,{className:`h-6 w-6 text-blue-400`})}),(0,$.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-white truncate`,children:e.document.fileName||`Documento`}),(0,$.jsx)(`span`,{className:`text-[10px] text-white/40 uppercase font-bold tracking-wider`,children:e.document.mimeType?.split(`/`)[1]||`DOC`})]})]}),(0,$.jsx)(`div`,{className:`bg-blue-600/20 text-white px-5 py-3 rounded-3xl rounded-br-sm shadow-sm ring-1 ring-blue-500/30 text-[15px] leading-relaxed whitespace-pre-wrap font-manrope`,children:e.content}),l&&e.audio?.base64&&(0,$.jsx)(lr,{audio:e.audio.base64,mimeType:e.audio.mimeType}),(0,$.jsx)(`span`,{className:`text-[10px] text-white/40 font-medium pr-2 opacity-0 group-hover:opacity-100 transition-opacity`,children:cr(e.timestamp)})]})}):(0,$.jsxs)(`div`,{className:`flex items-start gap-4 group mb-4`,children:[(0,$.jsx)(`div`,{className:`h-10 w-10 rounded-full bg-white/5 border border-white/10 flex items-center justify-center shrink-0 mt-0.5 shadow-sm`,children:(0,$.jsx)(P,{className:`h-5 w-5 text-blue-400`})}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1 max-w-[85%] min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`text-[11px] font-bold text-white/40 uppercase tracking-wider ml-1`,children:n}),e.image&&(0,$.jsx)(`div`,{className:`mb-2 rounded-2xl overflow-hidden border border-white/10 shadow-lg bg-black/20 w-fit`,children:(0,$.jsx)(`img`,{src:e.image.url||`data:${e.image.mimeType||`image/jpeg`};base64,${e.image.base64}`,alt:`adjunto`,className:`max-w-full h-auto max-h-[300px] object-contain`})}),e.document&&(0,$.jsxs)(`div`,{className:`mb-2 flex items-center gap-3 bg-white/5 border border-white/10 px-4 py-3 rounded-2xl w-fit max-w-full`,children:[(0,$.jsx)(`div`,{className:`h-10 w-10 rounded-lg bg-blue-500/10 flex items-center justify-center border border-blue-500/20`,children:(0,$.jsx)(o,{className:`h-6 w-6 text-blue-400`})}),(0,$.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-white truncate`,children:e.document.fileName||`Documento`}),(0,$.jsx)(`span`,{className:`text-[10px] text-white/40 uppercase font-bold tracking-wider`,children:e.document.mimeType?.split(`/`)[1]||`DOC`})]})]}),(0,$.jsxs)(`div`,{className:`text-white/80 text-[15px] leading-relaxed prose prose-invert max-w-none font-newsreader`,children:[(0,$.jsx)(T,{remarkPlugins:[sr],children:e.content}),r&&(0,$.jsx)(`span`,{className:`inline-block w-2 h-4 bg-blue-400 ml-1 align-text-bottom rounded-sm opacity-70`})]}),l&&e.audio?.base64&&(0,$.jsx)(lr,{audio:e.audio.base64,mimeType:e.audio.mimeType}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 pl-1 mt-1 opacity-0 group-hover:opacity-100 transition-opacity`,children:[(0,$.jsx)(`span`,{className:`text-[10px] font-medium text-white/40`,children:cr(e.timestamp)}),i&&(0,$.jsx)(`button`,{onClick:()=>i(e.content),className:`h-6 w-6 rounded flex items-center justify-center text-white/40 hover:text-blue-400 hover:bg-white/5 transition-colors`,title:`Narrar mensaje`,children:(0,$.jsx)(N,{className:`h-3.5 w-3.5`})})]})]})]})}var dr=[{icon:ne,text:`Que puedes hacer?`},{icon:ie,text:`Dame un resumen`},{icon:P,text:`Ayudame con una tarea`}],fr=[];function pr({messages:e,isLoading:t=!1,currentSteps:n=fr,streamingMessageId:r,userName:i,agentName:a,onSuggestionClick:o,onNarrateMessage:s}){let c=(0,F.useRef)(null),l=(0,F.useRef)({count:0,firstId:``,lastId:``});return(0,F.useLayoutEffect)(()=>{let t=c.current;if(!t)return;let n=l.current,r=e[0]?.id??``,i=e[e.length-1]?.id??``,a=n.count===0&&e.length>0,o=n.count>0&&e.length>0&&n.count===e.length&&(n.firstId!==r||n.lastId!==i),s=t.scrollHeight-t.scrollTop-t.clientHeight<200,u=a||o||s||e.length<=1;if(l.current={count:e.length,firstId:r,lastId:i},u){let e=setTimeout(()=>{t.scrollTop=t.scrollHeight},0);return()=>clearTimeout(e)}},[e,t,n]),e.length===0&&!t?(0,$.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center p-8 w-full`,children:[(0,$.jsxs)(`div`,{className:`relative mb-6`,children:[(0,$.jsx)(`div`,{className:`h-16 w-16 rounded-2xl bg-white/5 border border-white/10 flex items-center justify-center shadow-sm`,children:(0,$.jsx)(P,{className:`h-8 w-8 text-blue-400`})}),(0,$.jsx)(`span`,{className:`absolute -bottom-1 -right-1 h-4 w-4 rounded-full bg-emerald-500 border-2 border-white shadow-sm`})]}),(0,$.jsxs)(`div`,{className:`text-center space-y-2 mb-8`,children:[(0,$.jsx)(`p`,{className:`text-lg font-semibold text-white font-manrope`,children:a?`${a} está listo`:`Agente listo`}),(0,$.jsx)(`p`,{className:`text-sm text-white/50 font-manrope`,children:`Inicia la conversación escribiendo un mensaje abajo`})]}),o&&(0,$.jsx)(`div`,{className:`flex flex-col sm:flex-row items-center gap-3`,children:dr.map(e=>{let t=e.icon;return(0,$.jsxs)(`button`,{onClick:()=>o(e.text),className:`flex items-center gap-2 text-sm text-white/70 hover:text-white bg-white/5 border border-white/10 hover:border-white/20 hover:bg-white/10 px-4 py-2.5 rounded-full transition-all cursor-pointer font-medium`,children:[(0,$.jsx)(t,{className:`h-4 w-4 text-blue-400`}),e.text]},e.text)})})]}):(0,$.jsx)(`div`,{className:`flex-1 flex flex-col min-h-0 w-full`,children:(0,$.jsx)(`div`,{ref:c,className:`flex-1 overflow-y-auto w-full`,children:(0,$.jsxs)(`div`,{className:`max-w-3xl mx-auto flex flex-col gap-6 p-4 md:p-8 pb-2`,children:[e.map(e=>(0,$.jsx)(ur,{message:e,userName:i,agentName:a,isStreaming:e.id===r,onNarrate:s},e.id)),t&&!r&&(0,$.jsxs)(`div`,{className:`flex items-start gap-4 animate-in fade-in slide-in-from-bottom-2 duration-300`,children:[(0,$.jsx)(`div`,{className:`h-10 w-10 rounded-full bg-white/5 border border-white/10 flex items-center justify-center shrink-0 shadow-sm mt-1`,children:(0,$.jsx)(P,{className:`h-5 w-5 text-blue-400`})}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 max-w-[80%] min-w-0`,children:[(0,$.jsx)(`span`,{className:`text-[11px] font-bold text-white/40 uppercase tracking-wider ml-1`,children:a}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[n.length>0&&(0,$.jsx)(`div`,{className:`flex flex-col gap-1.5 ml-1`,children:n.map((e,t)=>{let r=t===n.length-1;return(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 rounded-lg border text-xs font-medium transition-all w-fit ${r?`bg-blue-500/10 border-blue-500/20 text-blue-400`:`bg-white/5 border-white/10 text-white/50`}`,children:[(0,$.jsx)(ie,{className:`h-3 w-3 shrink-0 ${r?`text-blue-400`:`text-white/30`}`}),(0,$.jsx)(`span`,{className:`leading-tight`,children:e})]},t)})}),(0,$.jsxs)(`div`,{className:`bg-white/5 border border-white/10 px-4 py-3.5 rounded-2xl rounded-tl-none shadow-sm flex items-center gap-1.5 w-fit`,children:[(0,$.jsx)(`span`,{className:`h-2 w-2 rounded-full bg-white/30 animate-bounce [animation-delay:0ms]`}),(0,$.jsx)(`span`,{className:`h-2 w-2 rounded-full bg-white/30 animate-bounce [animation-delay:150ms]`}),(0,$.jsx)(`span`,{className:`h-2 w-2 rounded-full bg-white/30 animate-bounce [animation-delay:300ms]`})]})]})]})]}),(0,$.jsx)(`div`,{className:`h-0`})]})})})}function mr({onSendMessage:e,onStop:t,disabled:n=!1,isStreaming:r=!1}){let[i,a]=(0,F.useState)(``),[s,u]=(0,F.useState)(!1),[d,f]=(0,F.useState)([]),p=(0,F.useRef)(null),m=(0,F.useRef)([]),h=(0,F.useRef)(null),g=(0,F.useRef)(null);(0,F.useEffect)(()=>{h.current&&(h.current.style.height=`auto`,h.current.style.height=h.current.scrollHeight+`px`)},[i]);let _=()=>{(i.trim()||d.length>0)&&!n&&(e(i.trim()||(d.length>0?`[Adjunto]`:``),{attachments:d.length>0?d:void 0}),a(``),f([]),h.current&&(h.current.style.height=`auto`))},v=async e=>{let t=e.target.files;if(!(!t||t.length===0)){for(let e of Array.from(t)){let t=new FileReader;t.readAsDataURL(e),t.onload=()=>{let n=t.result.split(`,`)[1],r={type:e.type.startsWith(`image/`)?`image`:`document`,base64:n,mimeType:e.type,fileName:e.name};f(e=>[...e,r])}}g.current&&(g.current.value=``)}},y=e=>{f(t=>t.filter((t,n)=>n!==e))};return(0,$.jsx)(`div`,{className:`px-4 pb-4 pt-2 shrink-0 bg-transparent`,children:(0,$.jsxs)(`div`,{className:`max-w-3xl mx-auto`,children:[d.length>0&&(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2 mb-2 px-2`,children:d.map((e,t)=>(0,$.jsxs)(`div`,{className:`group relative flex items-center gap-2 bg-white/10 backdrop-blur-md rounded-lg px-3 py-1.5 border border-white/10`,children:[e.type===`image`?(0,$.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.base64}`,className:`h-8 w-8 rounded object-cover border border-white/20`,alt:`preview`}):(0,$.jsx)(o,{className:`h-5 w-5 text-blue-400`}),(0,$.jsx)(`span`,{className:`text-xs text-white/70 max-w-[120px] truncate`,children:e.fileName}),(0,$.jsx)(`button`,{onClick:()=>y(t),className:`absolute -top-2 -right-2 bg-rose-500 text-white rounded-full p-0.5 opacity-0 group-hover:opacity-100 transition-opacity shadow-lg`,children:(0,$.jsx)(oe,{className:`h-3 w-3`})})]},t))}),(0,$.jsxs)(`div`,{className:`flex items-end gap-2 rounded-[2rem] bg-black/40 backdrop-blur-md px-4 py-3 transition-all shadow-sm border border-white/10 ${n?`opacity-60 bg-black/20`:`hover:border-white/20 focus-within:border-blue-500/50 focus-within:shadow-blue-glow`}`,children:[(0,$.jsx)(`input`,{type:`file`,ref:g,onChange:v,className:`hidden`,multiple:!0}),(0,$.jsx)(`button`,{onClick:()=>g.current?.click(),disabled:n,className:`h-9 w-9 rounded-full flex items-center justify-center shrink-0 mb-0.5 transition-all bg-white/5 text-white/50 hover:bg-white/10 hover:text-white disabled:opacity-30 disabled:cursor-not-allowed`,title:`Adjuntar archivo`,children:(0,$.jsx)(fe,{className:`h-4 w-4`})}),(0,$.jsx)(`button`,{onClick:s?()=>{p.current&&s&&(p.current.stop(),u(!1))}:async()=>{try{let t=await navigator.mediaDevices.getUserMedia({audio:!0}),n=new MediaRecorder(t,{mimeType:`audio/webm`});p.current=n,m.current=[],n.ondataavailable=e=>{e.data.size>0&&m.current.push(e.data)},n.onstop=async()=>{let n=new Blob(m.current,{type:`audio/webm`}),r=new FileReader;r.readAsDataURL(n),r.onloadend=()=>{let t=r.result.split(`,`)[1];e(`[Audio mensaje]`,{audio:t})},t.getTracks().forEach(e=>e.stop())},n.start(),u(!0)}catch(e){console.error(`Error accessing microphone:`,e)}},disabled:n,className:`h-9 w-9 rounded-full flex items-center justify-center shrink-0 mb-0.5 transition-all ${s?`bg-rose-500/20 text-rose-400 hover:bg-rose-500/30 animate-pulse`:`bg-white/5 text-white/50 hover:bg-white/10 hover:text-white`} disabled:opacity-30 disabled:cursor-not-allowed`,children:s?(0,$.jsx)(l,{className:`h-4 w-4`}):(0,$.jsx)(c,{className:`h-4 w-4`})}),(0,$.jsx)(`textarea`,{ref:h,value:i,onChange:e=>{a(e.target.value)},onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),_())},placeholder:n?`Conectando al agente...`:r?`Escribe mientras espera...`:`Escribe un mensaje...`,disabled:n,rows:1,className:`flex-1 min-h-[36px] max-h-[160px] resize-none bg-transparent text-[15px] font-manrope text-white placeholder:text-white/30 focus:outline-none leading-relaxed py-1.5 px-2`,style:{overflow:`auto`}}),r&&t?(0,$.jsx)(`button`,{onClick:t,className:`h-9 w-9 rounded-full flex items-center justify-center shrink-0 mb-0.5 transition-all bg-rose-500 hover:bg-rose-600 text-white shadow-sm shadow-rose-500/20`,title:`Detener generación`,children:(0,$.jsx)(l,{className:`h-4 w-4 fill-current`})}):(0,$.jsx)(`button`,{onClick:_,disabled:!i.trim()&&d.length===0||n,className:`h-9 w-9 rounded-full flex items-center justify-center shrink-0 mb-0.5 transition-all disabled:opacity-30 disabled:cursor-not-allowed bg-blue-600 hover:bg-blue-500 disabled:bg-white/10 text-white shadow-sm`,children:(0,$.jsx)(pe,{className:`h-4 w-4`})})]}),(0,$.jsx)(`p`,{className:`text-[11px] font-medium text-white/30 mt-2.5 text-center font-manrope tracking-wide`,children:s?`Grabando... haz clic para enviar`:`Enter para enviar · Shift+Enter nueva línea`})]})})}function hr(){let e=`main`,{messages:t,addMessage:n,setMessages:i,isLoading:o,currentSteps:s,streamingMessageId:c,connectionWarning:l,setConnectionWarning:u}=L(),{status:d,send:p,subscribe:m}=de(),{currentUser:h,fetchUser:g}=ce(),_=ue(e=>e.agents),v=ue(e=>e.fetchAgents),y=h?.id||`default`,{handleStreamingChunk:b,handleAudioMessage:x,handleProgress:S,handleTyping:C,resetStreamingRef:w}=_e(e,y),T=xe(),E=d===`connected`,D=d===`connecting`,O=_.find(e=>e.role===`coordinator`&&e.enabled)?.name??`Coordinador`;(0,F.useEffect)(()=>{h||g(),_.length===0&&v()},[]),(0,F.useEffect)(()=>{y&&(async()=>{try{let t=await le(`/api/chat/history?sessionId=${y}&limit=15`);t.messages&&i(t.messages.filter(e=>e.role===`user`||e.role===`assistant`).map(t=>({id:t.id,conversationId:t.session_id||t.thread_id,type:t.role===`user`?`user`:`agent`,content:t.content,agentId:e,timestamp:t.created_at})))}catch(e){console.error(`Failed to fetch chat history:`,e)}})()},[y,e,i]),(0,F.useEffect)(()=>{let e=m(`message`,b),t=m(`response`,b),n=m(`audio`,x),r=m(`progress`,S),i=m(`typing`,C);return()=>{e(),t(),n(),r(),i()}},[m,b,x,S,C]),(0,F.useEffect)(()=>{E?u(null):D||u(`Conexion perdida. Reconectando...`)},[E,D,u]);let k=(0,F.useCallback)((t,i)=>{let a=r();T.stop();let o=i?.audio,s=i?.attachments,c={id:a,conversationId:y,type:`user`,content:t,agentId:e,timestamp:new Date().toISOString()};if(o&&(c.audio={base64:o,mimeType:`audio/webm`}),s&&s.length>0){let e=s.find(e=>e.type===`image`),t=s.find(e=>e.type===`document`);e&&(c.image={base64:e.base64,mimeType:e.mimeType,caption:e.fileName}),t&&(c.document={base64:t.base64,mimeType:t.mimeType,fileName:t.fileName})}if(n(c),L.getState().setLoading(!0),w(),E)if(o)p({type:`audio`,audio:o,sessionId:y,timestamp:new Date().toISOString()});else{let e={type:`message`,content:t,sessionId:y,timestamp:new Date().toISOString()};if(s&&s.length>0){let t=s.find(e=>e.type===`image`),n=s.find(e=>e.type===`document`);t&&(e.image={base64:t.base64,mimeType:t.mimeType,caption:t.fileName}),n&&(e.document={base64:n.base64,mimeType:n.mimeType,fileName:n.fileName})}p(e)}else n({id:r(),conversationId:y,type:`error`,content:`No se pudo conectar al agente. Verifica que el gateway este funcionando.`,timestamp:new Date().toISOString()}),L.getState().setLoading(!1)},[E,y,e,n,p,T,w]),A=(0,F.useCallback)(e=>{T.isSpeaking?T.stop():T.narrate(e)},[T]);return(0,$.jsxs)(`div`,{className:`flex-1 flex flex-col w-full min-h-0 bg-transparent overflow-hidden`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 shrink-0 z-10 bg-transparent border-b border-white/5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`span`,{className:`text-sm font-semibold text-white font-manrope tracking-tight`,children:O}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2 py-0.5 rounded-full bg-white/5 border border-white/10`,children:[(0,$.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full ${E?`bg-emerald-500`:D?`bg-amber-500 animate-pulse`:`bg-slate-400`}`}),(0,$.jsx)(`span`,{className:`text-[10px] font-medium text-white/50 uppercase tracking-wider`,children:E?`Conectado`:D?`Conectando`:`Desconectado`})]})]}),(0,$.jsx)(`button`,{onClick:T.toggle,className:`h-8 w-8 rounded-full flex items-center justify-center transition-all ${T.isEnabled?`bg-blue-500/20 text-blue-400 hover:bg-blue-500/30`:`text-white/40 hover:text-white/70 hover:bg-white/5`}`,title:T.isEnabled?`Desactivar narracion`:`Activar narracion`,children:T.isEnabled?(0,$.jsx)(N,{className:`h-4 w-4`}):(0,$.jsx)(he,{className:`h-4 w-4`})})]}),l&&!E&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-2 bg-rose-50 border-b border-rose-100 shrink-0`,children:[(0,$.jsx)(a,{className:`h-3.5 w-3.5 text-rose-500 shrink-0`}),(0,$.jsx)(`span`,{className:`text-xs text-rose-600 flex-1 font-medium`,children:l}),(0,$.jsxs)(`button`,{onClick:()=>{let{connect:e}=se.getState();h?.id&&e(h.id)},className:`flex items-center gap-1 text-[10px] font-bold text-rose-600 hover:text-rose-800 transition-colors uppercase tracking-wider`,children:[(0,$.jsx)(f,{className:`h-3 w-3`}),`Reintentar`]})]}),T.isSpeaking&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-2 bg-blue-500/10 border-b border-blue-500/20 shrink-0`,children:[(0,$.jsxs)(`div`,{className:`flex gap-0.5`,children:[(0,$.jsx)(`span`,{className:`h-1.5 w-0.5 bg-blue-400 rounded-full animate-pulse`,style:{animationDelay:`0ms`}}),(0,$.jsx)(`span`,{className:`h-1.5 w-0.5 bg-blue-400 rounded-full animate-pulse`,style:{animationDelay:`150ms`}}),(0,$.jsx)(`span`,{className:`h-1.5 w-0.5 bg-blue-400 rounded-full animate-pulse`,style:{animationDelay:`300ms`}})]}),(0,$.jsxs)(`span`,{className:`text-[10px] text-blue-400 font-medium font-manrope`,children:[`Narrando`,T.currentText?`: ${T.currentText}...`:`...`]}),(0,$.jsx)(`button`,{onClick:T.stop,className:`text-[10px] text-blue-500 hover:text-blue-300 ml-auto font-bold uppercase tracking-wider`,children:`Detener`})]}),(0,$.jsx)(pr,{messages:t,isLoading:o,currentSteps:s,streamingMessageId:c,userName:h?.name??`Usuario`,agentName:O,onSuggestionClick:k,onNarrateMessage:T.isEnabled?A:void 0}),(0,$.jsx)(mr,{onSendMessage:k,onStop:()=>{E&&p({type:`stop`,sessionId:y})},disabled:!E&&!D,isStreaming:o})]})}export{hr as WebChatPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./index-DMCjjdqf.js";
|