granclaw 0.0.1-beta.76 → 0.0.1-beta.78
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/dist/backend/agent/runner-pi.js +33 -22
- package/dist/backend/browser/session-manager.js +5 -8
- package/dist/backend/orchestrator/browser-live.js +13 -1
- package/dist/backend/takeover-url-resolver.js +29 -0
- package/dist/frontend/assets/{index-DX3Q_Srz.js → index-9TKnUbWt.js} +2 -2
- package/dist/frontend/index.html +1 -1
- package/package.json +1 -1
|
@@ -17,6 +17,7 @@ const undici_1 = require("undici");
|
|
|
17
17
|
const os_1 = require("os");
|
|
18
18
|
const crypto_1 = require("crypto");
|
|
19
19
|
const takeover_state_js_1 = require("../takeover-state.js");
|
|
20
|
+
const takeover_url_resolver_js_1 = require("../takeover-url-resolver.js");
|
|
20
21
|
const config_js_1 = require("../config.js");
|
|
21
22
|
const esm_import_js_1 = require("../esm-import.js");
|
|
22
23
|
const agent_db_js_1 = require("../agent-db.js");
|
|
@@ -705,7 +706,7 @@ async function runAgent(agent, message, onChunk, options) {
|
|
|
705
706
|
browserState.handle = (0, session_manager_js_1.createSession)(agent.id, workspaceDir);
|
|
706
707
|
}
|
|
707
708
|
if (browser.recordingSupported && !browserState.handle.recordingStarted) {
|
|
708
|
-
await (0, session_manager_js_1.startRecording)(browserState.handle);
|
|
709
|
+
await (0, session_manager_js_1.startRecording)(browserState.handle, browser);
|
|
709
710
|
}
|
|
710
711
|
const argv = (0, browser_bin_js_1.buildArgv)(browser, command, args);
|
|
711
712
|
try {
|
|
@@ -734,15 +735,18 @@ async function runAgent(agent, message, onChunk, options) {
|
|
|
734
735
|
label: 'Hand off browser to user',
|
|
735
736
|
description: 'Stop the agent loop and let the user interact with the browser directly. ' +
|
|
736
737
|
'Use when you hit a captcha, 2FA prompt, login wall, or need the user to ' +
|
|
737
|
-
'review/edit content before submitting.
|
|
738
|
-
'
|
|
739
|
-
'
|
|
740
|
-
'
|
|
741
|
-
'
|
|
742
|
-
'
|
|
743
|
-
'
|
|
744
|
-
'
|
|
745
|
-
'
|
|
738
|
+
'review/edit content before submitting. PRECONDITION: the browser must be ' +
|
|
739
|
+
'on a real http(s) page — if it is at about:blank the tool will refuse and ' +
|
|
740
|
+
'ask you to navigate first (so the user never lands on a blank takeover). ' +
|
|
741
|
+
'When this tool returns, COPY THE `takeoverMarkdown` FIELD FROM THE TOOL ' +
|
|
742
|
+
'RESULT VERBATIM into your user-facing message. It is pre-formatted as a ' +
|
|
743
|
+
'bounded markdown link `[...](...)` so the URL is unambiguous under Telegram ' +
|
|
744
|
+
'MarkdownV2 and any other renderer. Do NOT paste the raw URL inline, do NOT ' +
|
|
745
|
+
'put any text on the same line as the URL, and do NOT add Spanish/French/other ' +
|
|
746
|
+
'punctuation like `¡`, `¿`, `!` immediately after the URL — the LLM-written ' +
|
|
747
|
+
'text that comes after will get absorbed into the URL by Telegram\'s ' +
|
|
748
|
+
'auto-linker and the link will break. The agent resumes automatically when ' +
|
|
749
|
+
'the user replies in chat.',
|
|
746
750
|
promptSnippet: 'Request human browser control for captcha, review, or auth prompts',
|
|
747
751
|
parameters: {
|
|
748
752
|
type: 'object',
|
|
@@ -764,6 +768,25 @@ async function runAgent(agent, message, onChunk, options) {
|
|
|
764
768
|
content: [{ type: 'text', text: 'No active browser session to hand over. Open a browser first.' }],
|
|
765
769
|
};
|
|
766
770
|
}
|
|
771
|
+
const capturedUrl = await (0, takeover_url_resolver_js_1.resolveTakeoverUrl)({
|
|
772
|
+
explicitUrl: params.url,
|
|
773
|
+
getBrowserUrl: async () => {
|
|
774
|
+
const bin = process.env.AGENT_BROWSER_BIN ?? 'agent-browser';
|
|
775
|
+
const { stdout } = await execFileAsync(bin, ['--session', agent.id, 'get', 'url'], { cwd: workspaceDir, timeout: 5000 });
|
|
776
|
+
return stdout.trim();
|
|
777
|
+
},
|
|
778
|
+
});
|
|
779
|
+
if (!capturedUrl) {
|
|
780
|
+
return {
|
|
781
|
+
content: [{
|
|
782
|
+
type: 'text',
|
|
783
|
+
text: 'Cannot open a takeover session: the browser is at about:blank or has no real page loaded. ' +
|
|
784
|
+
'Navigate the browser to the page the user needs to act on (via browser_navigate or the ' +
|
|
785
|
+
'appropriate tool), then call request_human_browser_takeover again. Alternatively pass the ' +
|
|
786
|
+
'target URL explicitly via the `url` parameter.',
|
|
787
|
+
}],
|
|
788
|
+
};
|
|
789
|
+
}
|
|
767
790
|
const token = (0, crypto_1.randomUUID)();
|
|
768
791
|
const takeoverUrl = process.env.GRANCLAW_PUBLIC_URL
|
|
769
792
|
? `${process.env.GRANCLAW_PUBLIC_URL.replace(/\/$/, '')}/takeover/${token}`
|
|
@@ -771,18 +794,6 @@ async function runAgent(agent, message, onChunk, options) {
|
|
|
771
794
|
const frontendPort = process.env.FRONTEND_PORT ?? process.env.PORT ?? '5173';
|
|
772
795
|
return `http://${getLanIp()}:${frontendPort}/takeover/${token}`;
|
|
773
796
|
})();
|
|
774
|
-
let capturedUrl = params.url;
|
|
775
|
-
if (!capturedUrl) {
|
|
776
|
-
try {
|
|
777
|
-
const bin = process.env.AGENT_BROWSER_BIN ?? 'agent-browser';
|
|
778
|
-
const { stdout } = await execFileAsync(bin, ['--session', agent.id, 'get', 'url'], { cwd: workspaceDir, timeout: 5000 });
|
|
779
|
-
const maybe = stdout.trim();
|
|
780
|
-
if (maybe && maybe !== 'about:blank' && /^https?:\/\//.test(maybe)) {
|
|
781
|
-
capturedUrl = maybe;
|
|
782
|
-
}
|
|
783
|
-
}
|
|
784
|
-
catch { }
|
|
785
|
-
}
|
|
786
797
|
(0, takeover_state_js_1.setTakeover)(agent.id, {
|
|
787
798
|
agentId: agent.id,
|
|
788
799
|
channelId,
|
|
@@ -13,7 +13,7 @@ const path_1 = __importDefault(require("path"));
|
|
|
13
13
|
const fs_1 = __importDefault(require("fs"));
|
|
14
14
|
const child_process_1 = require("child_process");
|
|
15
15
|
const util_1 = require("util");
|
|
16
|
-
const
|
|
16
|
+
const browser_bin_js_1 = require("../agent/browser-bin.js");
|
|
17
17
|
const execFileAsync = (0, util_1.promisify)(child_process_1.execFile);
|
|
18
18
|
function readMeta(metaPath) {
|
|
19
19
|
try {
|
|
@@ -88,14 +88,11 @@ function closeSession(handle, status = 'closed') {
|
|
|
88
88
|
}
|
|
89
89
|
catch { }
|
|
90
90
|
}
|
|
91
|
-
async function startRecording(handle) {
|
|
92
|
-
const bin =
|
|
91
|
+
async function startRecording(handle, res) {
|
|
92
|
+
const bin = res.bin;
|
|
93
93
|
const recordingPath = path_1.default.join(handle.sessionDir, 'recording.webm');
|
|
94
|
-
const
|
|
95
|
-
const
|
|
96
|
-
const launchFlags = [...profileArgs, ...(0, stealth_js_1.stealthArgv)()];
|
|
97
|
-
const recordArgv = ['--session', handle.agentId, ...launchFlags, 'record', 'start', recordingPath];
|
|
98
|
-
const stopArgv = ['--session', handle.agentId, 'record', 'stop'];
|
|
94
|
+
const recordArgv = (0, browser_bin_js_1.buildArgv)(res, 'record', ['start', recordingPath]);
|
|
95
|
+
const stopArgv = (0, browser_bin_js_1.buildArgv)(res, 'record', ['stop']);
|
|
99
96
|
const tryStart = async () => {
|
|
100
97
|
try {
|
|
101
98
|
await execFileAsync(bin, recordArgv, { cwd: handle.workspaceDir, timeout: 5000 });
|
|
@@ -299,6 +299,7 @@ function attachPageCdp(stream, page) {
|
|
|
299
299
|
stream.chromeWs = chromeWs;
|
|
300
300
|
stream.currentTargetId = page.id;
|
|
301
301
|
stream.screencastSessionId = null;
|
|
302
|
+
stream.lastBroadcastUrl = page.url || null;
|
|
302
303
|
chromeWs.on('open', () => {
|
|
303
304
|
if (stream.disposed) {
|
|
304
305
|
try {
|
|
@@ -394,11 +395,21 @@ async function pollActiveTab(stream) {
|
|
|
394
395
|
const target = pickCdpPageForTab(pages, active.url, stream.preferredTargetId);
|
|
395
396
|
if (!target)
|
|
396
397
|
return;
|
|
397
|
-
if (target.id === stream.currentTargetId)
|
|
398
|
+
if (target.id === stream.currentTargetId) {
|
|
399
|
+
if (target.url && target.url !== stream.lastBroadcastUrl) {
|
|
400
|
+
stream.lastBroadcastUrl = target.url;
|
|
401
|
+
sendToSubscribers(stream, {
|
|
402
|
+
type: 'url_changed',
|
|
403
|
+
url: target.url,
|
|
404
|
+
title: target.title,
|
|
405
|
+
});
|
|
406
|
+
}
|
|
398
407
|
return;
|
|
408
|
+
}
|
|
399
409
|
detachPageCdp(stream);
|
|
400
410
|
if (stream.disposed)
|
|
401
411
|
return;
|
|
412
|
+
stream.lastBroadcastUrl = target.url;
|
|
402
413
|
sendToSubscribers(stream, {
|
|
403
414
|
type: 'tab_changed',
|
|
404
415
|
index: active.index,
|
|
@@ -600,6 +611,7 @@ function handleBrowserLiveUpgrade(req, socket, head, getWorkspaceDir) {
|
|
|
600
611
|
flatSessionId: null,
|
|
601
612
|
preferredTargetId: null,
|
|
602
613
|
targetTrackerWs: null,
|
|
614
|
+
lastBroadcastUrl: null,
|
|
603
615
|
};
|
|
604
616
|
streams.set(key, stream);
|
|
605
617
|
void attachChrome(stream).then((reason) => {
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isRealHttpUrl = isRealHttpUrl;
|
|
4
|
+
exports.resolveTakeoverUrl = resolveTakeoverUrl;
|
|
5
|
+
function isRealHttpUrl(url) {
|
|
6
|
+
if (!url)
|
|
7
|
+
return false;
|
|
8
|
+
const trimmed = url.trim();
|
|
9
|
+
if (!trimmed)
|
|
10
|
+
return false;
|
|
11
|
+
if (!/^https?:\/\//i.test(trimmed))
|
|
12
|
+
return false;
|
|
13
|
+
if (trimmed === 'about:blank')
|
|
14
|
+
return false;
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
async function resolveTakeoverUrl(opts) {
|
|
18
|
+
const { explicitUrl, getBrowserUrl } = opts;
|
|
19
|
+
if (isRealHttpUrl(explicitUrl))
|
|
20
|
+
return explicitUrl;
|
|
21
|
+
try {
|
|
22
|
+
const browserUrl = await getBrowserUrl();
|
|
23
|
+
if (isRealHttpUrl(browserUrl))
|
|
24
|
+
return browserUrl;
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
}
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
@@ -87,7 +87,7 @@ Esto eliminará permanentemente:
|
|
|
87
87
|
• Memoria de sesión de Claude
|
|
88
88
|
• Archivos del espacio de trabajo
|
|
89
89
|
|
|
90
|
-
Esta acción no se puede deshacer.`,guardian:"Guardián",comingSoon:"Próximamente",guardianBlurb1:"Configura un agente guardián para controlar lo que puede hacer tu agente principal.",guardianBlurb2:"Define restricciones, bloquea acciones y exige aprobación antes de operaciones sensibles.",guardianChatBlurb:"Chat del guardián.<br />Configura restricciones aquí.",guardianDisconnected:"○ desconectado",errorCreditLimit:"La clave API ha alcanzado su límite de gasto. Recarga créditos o aumenta el límite de la clave en el panel de tu proveedor.",errorRateLimit:"Límite de solicitudes excedido. El proveedor está limitando las peticiones — intenta de nuevo en unos segundos.",errorAuth:"Autenticación fallida. La clave API puede ser inválida o estar expirada — revisa Configuración.",errorNoProvider:"Sin proveedor configurado. Ve a Configuración para agregar uno.",errorNoKey:"Falta la clave API del proveedor. Ve a Configuración para reconfigurar.",errorTimeout:"El agente tardó demasiado en responder. Intenta de nuevo o simplifica tu solicitud.",errorGeneric:"Algo salió mal: {message}"},xM={sessionExpiredLabel:"toma de control",sessionExpired:"Sesión expirada",sessionExpiredBlurb:"Este enlace de toma de control ya fue usado o expiró.",completeLabel:"completo",controlReturned:"Control devuelto al agente",closeTab:"Puedes cerrar esta pestaña.",connecting:"conectando…",agentNeedsHelp:"El agente necesita tu ayuda",liveLabel:"en vivo",waitingStream:"esperando transmisión del navegador…",whatDidYouDo:"¿Qué hiciste?",optional:"(opcional)",describeActionPlaceholder:"Describe tu acción para el agente…",returning:"Devolviendo…",completed:"Completado",urlBarPlaceholder:"Escribe una URL y pulsa Intro para navegar…"},yM={columns:{backlog:"PENDIENTE",inProgress:"EN PROGRESO",scheduled:"PROGRAMADO",toReview:"EN REVISIÓN",done:"COMPLETADO"},statusLabels:{backlog:"Pendiente",inProgress:"En progreso",scheduled:"Programado",toReview:"En revisión",done:"Completado"},editedBy:"editado por {name}",relativeNow:"ahora",relativeMinutes:"hace {n}m",relativeHours:"hace {n}h",relativeDays:"hace {n}d",titlePlaceholder:"Título de tarea…",descPlaceholder:"Descripción (markdown)…",add:"Agregar",cancel:"Cancelar"},bM={saving:"guardando…",close:"Cerrar",status:"Estado",sourceLabel:"fuente",editedByLabel:"editado por",created:"creado",updated:"actualizado",description:"Descripción",descPlaceholder:"Agregar una descripción…",save:"Guardar",cancel:"Cancelar",descEmpty:"Sin descripción — clic para agregar",commentsLabel:"Comentarios ({count})",noComments:"Sin comentarios aún",addComment:"Agregar comentario",commentPlaceholder:"Escribe un comentario… (markdown soportado)",publishComment:"Publicar comentario",publishing:"Publicando…",dangerZone:"Zona peligrosa",deleteTask:"[PELIGROSO] Eliminar tarea",deleting:"eliminando…",deleteConfirm:'¿Eliminar tarea "{title}"? Esta acción no se puede deshacer.'},_M={backToRuns:"← Volver a ejecuciones",loading:"Cargando…",waitingResponse:"Esperando respuesta…",triggering:"Iniciando…",runNow:"Ejecutar ahora",runHistory:"Historial de ejecuciones",noRuns:"Sin ejecuciones aún.",loadingList:"Cargando programados…",emptyIcon:"⏰",emptyText:"Sin programados aún. Pídele al agente que configure tareas recurrentes.",title:"Programados",activeCountOne:"{count} activo",activeCountOther:"{count} activos",next:"Próximo: {time}",last:"Último: {time}",pause:"Pausar",resume:"Reanudar",delete:"Eliminar",deleteConfirm:'¿Eliminar programado "{name}"?'},wM={title:"Flujos de trabajo",emptyText:"Sin flujos de trabajo aún. Pídele al agente que cree uno via chat.",running:"Ejecutando…",run:"Ejecutar",createdOn:"{id} · Creado {date}",back:"← Volver a flujos",run_button:"Ejecutar",stepsTitle:"Pasos ({count})",conditionsOne:"{count} condición",conditionsOther:"{count} condiciones",stepType:"Tipo: {type}",stepTimeout:"Límite de tiempo: {seconds}s",stepId:"ID: {id}",runHistoryTitle:"Historial de ejecuciones ({count})",noRuns:"Sin ejecuciones aún."},kM={loading:"Cargando ejecución…",back:"← Volver al flujo",runLabel:"Ejecución —",errorPrefix:"Error:",input:"Entrada",output:"Salida"},SM={loading:"Cargando monitor…",title:"Monitor",idle:"inactivo",claudeSessionsOne:"{count} sesión claude",claudeSessionsOther:"{count} sesiones claude",processes:"Procesos",agentProcess:"Proceso del Agente",guardianProcess:"Guardián (Big Brother)",browserDaemon:"Demonio de Navegador",activeClaudeSessions:"Sesiones Claude Activas — {count}",jobQueue:"Cola de trabajos — {processing} en proceso, {pending} en espera",noActiveJobs:"Sin trabajos activos",processing:"procesando",queued:"en cola",terminate:"Terminar",cancel:"Cancelar",runningWorkflows:"Flujos de trabajo en ejecución",cpu:"CPU",mem:"MEM",rss:"RSS",uptime:"Tiempo activo"},CM={title:"Integraciones",blurb:"Conecta servicios externos. Cada integración almacena un token como secreto y se activa automáticamente.",moreSoon:"Más integraciones próximamente. Para otras claves API y credenciales, usa la sección de Secretos en la barra lateral.",connected:"Conectado",disconnect:"Desconectar",connect:"Conectar",saveAndConnect:"Guardar y conectar",saving:"Guardando…",cancel:"Cancelar",newPrefix:"Nuevo {label}",pasteNewToken:"Pega el nuevo token",updateToken:"Actualizar token",rotateToken:"Rotar token",errorSave:"Error al guardar — revisa la consola",disconnectConfirm:"¿Desconectar {name}? El agente dejará de usarlo inmediatamente.",telegramDescription:"Recibe y responde mensajes a través de un bot de Telegram.",telegramHelp:"Crea un bot mediante @BotFather en Telegram, luego pega el token aquí.",telegramTokenLabel:"Token del bot"},EM={loading:"Escaneando sesiones…",title:"Uso",totalTokens:"Tokens totales",cachedSuffix:"{amount} en caché",sessions:"Sesiones",modelsCount:"{count} modelos",estCost:"Costo est.",periodDays:"Período de {days} días",avgDay:"Prom/Día",sessionsPerDay:"{count} sesiones/día",dailyTokenUsage:"Uso diario de tokens",noUsageData:"Sin datos de uso",dailyCost:"Costo estimado diario",noCostData:"Sin datos de costo",byModel:"Por modelo",modelSessionsBlurb:"{sessions} sesiones · {input} entrada · {output} salida",tokenBreakdown:"Desglose de tokens",inputTokens:"Tokens de entrada",outputTokens:"Tokens de salida",cacheRead:"Lectura de caché",cacheWrite:"Escritura de caché",toolInvocations:"Invocaciones de herramientas",dailyBreakdown:"Desglose diario",date:"Fecha",tableSessions:"Sesiones",tableInput:"Entrada",tableOutput:"Salida",tableCache:"Caché",tableCost:"Costo"},PM={searchPlaceholder:"Buscar registros…",apply:"Aplicar",live:"En vivo",loading:"cargando…",noResults:'sin resultados para "{query}"',noEntries:"sin entradas de registro",loadOlder:"Cargar {count} entradas anteriores…"},NM={views:{chat:"Chat",tasks:"Tareas",browser:"Navegador",files:"Archivos",workflows:"Flujos de trabajo",schedules:"Programados",monitor:"Monitor",usage:"Uso",logs:"Registros",integrations:"Integraciones",guardian:"Guardián"},comingSoon:"Pronto",secrets:"Secretos",noSecrets:"Sin secretos configurados",updating:"Actualizando {name}",newValue:"nuevo valor",save:"Guardar",secretNamePlaceholder:"NOMBRE",secretValuePlaceholder:"valor",guardrails:"Restricciones",guardrailsBlurb:"Configurado via chat guardián",exportAgent:"📦 Exportar agente",exportTitle:"Descargar una copia de seguridad completa del espacio de trabajo del agente como zip",wipeAgent:"🗑 Borrar agente",wiping:"borrando…"},jM={workspace:"espacio-de-trabajo",savingLabel:"guardando…",saveButton:"Guardar",emptyDir:"Directorio vacío"},TM={common:fM,shell:pM,dashboard:gM,settings:mM,chat:vM,takeover:xM,tasks:yM,taskDetail:bM,schedules:_M,workflows:wM,runDetail:kM,monitor:SM,integrations:CM,usage:EM,logs:PM,agentSettings:NM,files:jM},Ty={en:hM,es:TM},Uk="granclaw:lang";function MM(){if(typeof window>"u")return"en";try{const t=window.localStorage.getItem(Uk);if(t==="en"||t==="es")return t}catch{}return(typeof navigator<"u"?navigator.language:"").toLowerCase().startsWith("es")?"es":"en"}function My(e,t){const n=t.split(".");let r=e;for(const i of n)if(r&&typeof r=="object"&&i in r)r=r[i];else return;return typeof r=="string"?r:void 0}function RM(e,t){return t?e.replace(/\{(\w+)\}/g,(n,r)=>{const i=t[r];return i==null?`{${r}}`:String(i)}):e}const qk=N.createContext(null);function AM({children:e}){const[t,n]=N.useState(()=>MM()),r=N.useCallback(o=>{n(o);try{window.localStorage.setItem(Uk,o)}catch{}},[]);N.useEffect(()=>{try{document.documentElement.lang=t}catch{}},[t]);const i=N.useCallback((o,a)=>{const l=Ty[t],u=My(l,o)??My(Ty.en,o)??o;return RM(u,a)},[t]),s=N.useMemo(()=>({lang:t,setLang:r,t:i}),[t,r,i]);return f.jsx(qk.Provider,{value:s,children:e})}function Ee(){const e=N.useContext(qk);if(!e)throw new Error("useT must be used inside <LanguageProvider>");return e}function DM({className:e}){const{lang:t,setLang:n}=Ee();return f.jsx("div",{className:`flex items-center gap-0.5 rounded-full bg-surface-container/40 p-[2px] ${e??""}`,children:["en","es"].map(r=>f.jsx("button",{onClick:()=>n(r),className:`px-2 py-[2px] rounded-full text-[10px] font-mono uppercase tracking-wider transition-colors ${t===r?"bg-primary/30 text-primary":"text-on-surface-variant/70 hover:text-on-surface"}`,"aria-pressed":t===r,children:r},r))})}function IM(){const e=es(),t=ts(),n=e.pathname.includes("/chat"),{t:r}=Ee();return f.jsxs("div",{className:"flex h-screen flex-col overflow-hidden bg-surface",children:[f.jsxs("header",{className:"flex h-11 flex-shrink-0 items-center justify-between border-b border-outline-variant/20 bg-surface-low px-3 sm:px-5",children:[f.jsxs("button",{onClick:()=>t("/dashboard"),className:"flex items-center gap-2 hover:opacity-80 transition-opacity min-w-0",children:[f.jsx("img",{src:"/granclaw-logo.png",alt:"GranClaw",className:"h-6 w-6 rounded flex-shrink-0"}),f.jsx("span",{className:"font-display font-semibold text-on-surface tracking-tight truncate",children:"GranClaw"}),f.jsxs("span",{className:"text-xs font-mono text-on-surface/60 flex-shrink-0",children:["v","0.0.1-beta.76"]})]}),f.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[f.jsx(DM,{}),f.jsxs("span",{className:"flex items-center gap-1.5 rounded-full bg-secondary-container/20 px-2 sm:px-3 py-1 text-xs font-mono text-secondary flex-shrink-0",children:[f.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-secondary animate-pulse flex-shrink-0"}),f.jsx("span",{className:"hidden sm:inline",children:r("shell.systemPrefix")}),r("shell.onlineSuffix")]})]})]}),f.jsx("main",{className:`flex-1 overflow-auto min-w-0 ${n?"":"p-3 sm:p-5"}`,children:f.jsx(AN,{})})]})}const le="";async function Ry(){const e=await fetch(`${le}/agents`);if(!e.ok)throw new Error(`fetchAgents: ${e.status}`);return e.json()}async function OM(e,t,n,r,i){const s=await fetch(`${le}/agents`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,name:t,model:n,provider:r,...i?{workspaceDir:i}:{}})});if(!s.ok){const o=await s.json().catch(()=>({error:s.statusText}));throw new Error(o.error)}}async function LM(e){const t=await fetch(`${le}/agents/${e}`,{method:"DELETE"});if(!t.ok)throw new Error(`deleteAgent: ${t.status}`)}async function Ay(e){const t=await fetch(`${le}/agents/${e}`);if(!t.ok)throw new Error(`fetchAgent: ${t.status}`);return t.json()}async function Dy(e,t="ui"){const n=await fetch(`${le}/agents/${e}/messages?channelId=${t}&sortBy=asc&limit=200`);if(!n.ok)throw new Error(`fetchMessages: ${n.status}`);return n.json()}async function FM(e){const t=await fetch(`${le}/agents/${e}/reset`,{method:"DELETE"});if(!t.ok)throw new Error(`resetAgent: ${t.status}`)}async function $M(e,t=""){const n=await fetch(`${le}/agents/${e}/files?path=${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`fetchFiles: ${n.status}`);return(await n.json()).entries}async function zM(e,t){const n=await fetch(`${le}/agents/${e}/files/read?path=${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`readFile: ${n.status}`);return(await n.json()).content}async function BM(e,t,n){const r=await fetch(`${le}/agents/${e}/files/write?path=${encodeURIComponent(t)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:n})});if(!r.ok)throw new Error(`writeFile: ${r.status}`)}async function HM(e){const t=await fetch(`${le}/agents/${e}/secrets`);if(!t.ok)throw new Error(`fetchSecrets: ${t.status}`);return t.json()}async function Ep(e,t,n){const r=await fetch(`${le}/agents/${e}/secrets`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:t,value:n})});if(!r.ok)throw new Error(`addSecret: ${r.status}`)}async function Gk(e,t){const n=await fetch(`${le}/agents/${e}/secrets/${encodeURIComponent(t)}`,{method:"DELETE"});if(!n.ok)throw new Error(`deleteSecret: ${n.status}`)}async function WM(e,t){const r=await fetch(`${le}/agents/${e}/tasks`);if(!r.ok)throw new Error(`fetchTasks: ${r.status}`);return r.json()}async function VM(e,t){const n=await fetch(`${le}/agents/${e}/tasks/${t}`);if(!n.ok)throw new Error(`fetchTask: ${n.status}`);return n.json()}async function UM(e,t){const n=await fetch(`${le}/agents/${e}/tasks`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok)throw new Error(`createTask: ${n.status}`);return n.json()}async function Iy(e,t,n){const r=await fetch(`${le}/agents/${e}/tasks/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!r.ok)throw new Error(`updateTask: ${r.status}`);return r.json()}async function qM(e,t){const n=await fetch(`${le}/agents/${e}/tasks/${t}`,{method:"DELETE"});if(!n.ok)throw new Error(`deleteTask: ${n.status}`)}async function GM(e,t,n){const r=await fetch(`${le}/agents/${e}/tasks/${t}/comments`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({body:n})});if(!r.ok)throw new Error(`addTaskComment: ${r.status}`);return r.json()}async function KM(e){const t=await fetch(`${le}/agents/${e}/browser-sessions`);if(!t.ok)throw new Error(`fetchBrowserSessions: ${t.status}`);return t.json()}async function Kk(e,t){const n=await fetch(`${le}/agents/${e}/browser-sessions/${t}`);if(!n.ok)throw new Error(`fetchBrowserSession: ${n.status}`);return n.json()}function YM(e,t){return`${le}/agents/${e}/browser-sessions/${t}/video`}function Yk(e,t){const n=window.location;return`${n.protocol==="https:"?"wss:":"ws:"}//${n.host}/browser-live/${e}/${t}`}function XM(e){return`${le}/agents/${e}/export`}async function Oy(e,t){const n=new URL(`${le}/agents/import`,window.location.origin);t!=null&&t.id&&n.searchParams.set("id",t.id);const r=await fetch(n.toString().replace(window.location.origin,""),{method:"POST",headers:{"Content-Type":"application/zip"},body:e});if(!r.ok){const i=await r.json().catch(()=>({error:r.statusText}));throw new Error(i.error)}return r.json()}async function Ly(e,t){const n=await fetch(`${le}/agents/${e}/monitor/jobs/${t}`,{method:"DELETE"});if(!n.ok)throw new Error(`killJob: ${n.status}`)}async function JM(e){const t=await fetch(`${le}/agents/${e}/monitor`);if(!t.ok)throw new Error(`fetchMonitor: ${t.status}`);return t.json()}async function QM(e,t=30){const n=await fetch(`${le}/agents/${e}/usage?days=${t}`);if(!n.ok)throw new Error(`fetchUsage: ${n.status}`);return n.json()}async function ZM(e){const t=await fetch(`${le}/agents/${e}/schedules`);if(!t.ok)throw new Error(`fetchSchedules: ${t.status}`);return t.json()}async function eR(e,t,n){const r=await fetch(`${le}/agents/${e}/schedules/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!r.ok)throw new Error(`updateSchedule: ${r.status}`);return r.json()}async function tR(e,t){const n=await fetch(`${le}/agents/${e}/schedules/${t}`,{method:"DELETE"});if(!n.ok)throw new Error(`deleteSchedule: ${n.status}`)}async function nR(e,t){const n=await fetch(`${le}/agents/${e}/schedules/${t}/trigger`,{method:"POST"});if(!n.ok)throw new Error(`triggerSchedule: ${n.status}`);return n.json()}async function rR(e,t){const n=await fetch(`${le}/agents/${e}/schedules/${t}/runs`);if(!n.ok)throw new Error(`fetchScheduleRuns: ${n.status}`);return n.json()}async function iR(e,t){const n=await fetch(`${le}/agents/${e}/messages?channelId=${encodeURIComponent(t)}&sortBy=asc&limit=200`);if(!n.ok)throw new Error(`fetchScheduleRunMessages: ${n.status}`);return n.json()}async function sR(e){const t=await fetch(`${le}/agents/${e}/workflows`);if(!t.ok)throw new Error(`fetchWorkflows: ${t.status}`);return t.json()}async function oR(e,t){const n=await fetch(`${le}/agents/${e}/workflows/${t}`);if(!n.ok)throw new Error(`fetchWorkflow: ${n.status}`);return n.json()}async function xh(e,t){const n=await fetch(`${le}/agents/${e}/workflows/${t}/runs`);if(!n.ok)throw new Error(`fetchWorkflowRuns: ${n.status}`);return n.json()}async function aR(e,t,n){const r=await fetch(`${le}/agents/${e}/workflows/${t}/runs/${n}`);if(!r.ok)throw new Error(`fetchWorkflowRun: ${r.status}`);return r.json()}async function lR(e,t){const n=await fetch(`${le}/agents/${e}/workflows/${t}/run`,{method:"POST"});if(!n.ok)throw new Error(`triggerWorkflowRun: ${n.status}`);return n.json()}async function uR(e){const t=new URLSearchParams;e!=null&&e.agentId&&t.set("agentId",e.agentId),e!=null&&e.type&&t.set("type",e.type),e!=null&&e.search&&t.set("search",e.search),(e==null?void 0:e.limit)!=null&&t.set("limit",String(e.limit)),(e==null?void 0:e.offset)!=null&&t.set("offset",String(e.offset));const n=await fetch(`${le}/logs?${t}`);if(!n.ok)throw new Error(`fetchLogs: ${n.status}`);return n.json()}async function Xk(){const e=await fetch(`${le}/settings/provider`);if(!e.ok)throw new Error("Failed to fetch provider settings");return e.json()}const yh={showWorkspaceDirConfig:!0,showBraveSearchConfig:!0,enableIntegrations:!1};async function Jk(){try{const e=await fetch(`${le}/settings/app`);if(!e.ok)return{...yh};const t=await e.json();return{...yh,...t}}catch{return{...yh}}}async function Fy(e,t,n){if(!(await fetch(`${le}/settings/provider`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e,model:t,apiKey:n})})).ok)throw new Error("Failed to save provider settings")}async function cR(e){if(!(await fetch(`${le}/settings/providers/${encodeURIComponent(e)}`,{method:"DELETE"})).ok)throw new Error("Failed to remove provider")}async function dR(){const e=await fetch(`${le}/settings/search`);return e.ok?e.json():{provider:"brave",configured:!1}}async function hR(e,t){const n=await fetch(`${le}/settings/search`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:t})});if(!n.ok)throw new Error(`Failed to save search settings: ${n.status}`)}async function fR(){const e=await fetch(`${le}/settings/search`,{method:"DELETE"});if(!e.ok&&e.status!==204&&e.status!==404)throw new Error(`Failed to clear search settings: ${e.status}`)}const pR={google:[{value:"gemini-2.5-flash",label:"Gemini 2.5 Flash — fast + smart (recommended)"},{value:"gemini-2.5-pro",label:"Gemini 2.5 Pro — most capable"},{value:"gemini-2.5-flash-lite",label:"Gemini 2.5 Flash Lite — cheapest"},{value:"gemini-3-flash-preview",label:"Gemini 3 Flash — preview"},{value:"gemini-3.1-pro-preview",label:"Gemini 3.1 Pro — preview"}],openai:[{value:"gpt-4.1",label:"GPT-4.1 — recommended, 1M ctx"},{value:"gpt-4.1-mini",label:"GPT-4.1 Mini — fast, efficient"},{value:"gpt-4.1-nano",label:"GPT-4.1 Nano — cheapest"}],anthropic:[{value:"claude-sonnet-4-6",label:"Claude Sonnet 4.6 — recommended"},{value:"claude-opus-4-6",label:"Claude Opus 4.6 — most capable"},{value:"claude-haiku-4-5-20251001",label:"Claude Haiku 4.5 — fastest"}],groq:[{value:"openai/gpt-oss-120b",label:"GPT-OSS 120B — flagship, ~500 tok/s"},{value:"openai/gpt-oss-20b",label:"GPT-OSS 20B — fast, efficient"},{value:"llama-3.3-70b-versatile",label:"Llama 3.3 70B — versatile"},{value:"llama-3.1-8b-instant",label:"Llama 3.1 8B — fastest/cheapest"}],openrouter:[{value:"google/gemini-2.5-flash",label:"Gemini 2.5 Flash — best price/perf ($0.30/$2.50 /M)"},{value:"google/gemini-3-flash-preview",label:"Gemini 3 Flash — fast, 1M ctx ($0.50/$3 /M)"},{value:"google/gemini-3.1-pro-preview",label:"Gemini 3.1 Pro — frontier ($2/$12 /M)"},{value:"deepseek/deepseek-v3.2",label:"DeepSeek V3.2 — cheap output ($0.26/$0.38 /M)"},{value:"xiaomi/mimo-v2-pro",label:"MiMo V2 Pro — agentic, 1T params ($1/$3 /M)"},{value:"qwen/qwen3.6-plus",label:"Qwen 3.6 Plus — throughput leader ($0.33/$1.95 /M)"},{value:"minimax/minimax-m2.7",label:"MiniMax M2.7 — agentic ($0.30/$1.20 /M)"},{value:"x-ai/grok-4",label:"Grok 4 — reasoning, 256k ctx ($3/$15 /M)"}],freetier:[{value:"z-ai/glm-5-turbo",label:"GLM 5 Turbo — enterprise default"}]},Qk=[{value:"google",label:"Google Gemini"},{value:"openai",label:"OpenAI"},{value:"anthropic",label:"Anthropic"},{value:"groq",label:"Groq"},{value:"openrouter",label:"OpenRouter"}];function ud(e){return pR[e]??[]}function Pp(e){var t;return((t=ud(e)[0])==null?void 0:t.value)??""}const ya="inline-flex items-center justify-center gap-2 bg-primary text-on-primary px-5 py-2.5 text-sm font-label font-semibold uppercase tracking-widest rounded shadow-sm transition-all hover:bg-surface-tint hover:shadow-md active:scale-[0.98] disabled:opacity-40 disabled:pointer-events-none",gR="inline-flex items-center justify-center gap-2 border border-outline-variant text-on-surface px-5 py-2.5 text-sm font-label font-semibold uppercase tracking-widest rounded transition-all hover:bg-surface-container hover:border-outline active:scale-[0.98] disabled:opacity-40 disabled:pointer-events-none",Zk="inline-flex items-center justify-center gap-1.5 text-on-surface-variant px-2.5 py-1.5 text-xs font-label font-medium uppercase tracking-wider rounded transition-colors hover:bg-surface-container hover:text-on-surface disabled:opacity-40 disabled:pointer-events-none",mR="inline-flex items-center justify-center gap-1.5 text-error px-2.5 py-1.5 text-xs font-label font-medium uppercase tracking-wider rounded transition-colors hover:bg-error/10 disabled:opacity-40 disabled:pointer-events-none",Eu="w-full bg-surface-container-lowest text-on-surface placeholder:text-on-surface-variant border border-outline-variant rounded-lg px-3 py-2 text-sm focus:outline-none focus:border-primary focus:ring-2 focus:ring-primary/20 transition-colors",$y=Eu.replace("text-sm","text-sm font-mono"),Za="bg-surface-container-lowest border border-outline-variant/40 rounded-xl shadow-callout",Ws="inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[10px] font-label font-medium uppercase tracking-wider",Np=`${Ws} bg-surface-container border border-outline-variant/40 text-on-surface-variant`,eS=`${Ws} bg-success/10 border border-success/20 text-success`,vR=`${Ws} bg-warning/10 border border-warning/20 text-warning`;function xR({agent:e,onDelete:t}){const n=ts(),{t:r}=Ee(),i=e.status==="active",s=e.busy===!0;return f.jsxs("div",{onClick:()=>n(`/agents/${e.id}/chat`),className:"group flex items-center gap-4 rounded-xl bg-surface-container-lowest border border-outline-variant/40 p-4 cursor-pointer transition-all hover:border-primary/40 hover:shadow-callout",children:[f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[f.jsx("span",{className:"font-headline text-lg font-bold text-on-surface",children:e.name}),s?f.jsxs("span",{"data-testid":"busy-badge",className:"inline-flex items-center gap-1 rounded-full bg-secondary/15 border border-secondary/30 px-2 py-0.5 text-[10px] font-label font-semibold uppercase tracking-wider text-secondary",children:[f.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-secondary animate-pulse"}),"busy"]}):f.jsx("span",{className:i?eS:Np,children:e.status})]}),f.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[f.jsx("span",{className:"font-mono text-[10px] text-primary/70",children:e.model}),f.jsxs("span",{className:"font-mono text-[10px] text-on-surface-variant/60 hidden sm:inline",children:["id: ",e.id]})]})]}),f.jsx("div",{className:"flex items-center gap-2 flex-shrink-0",children:f.jsx("button",{onClick:o=>{o.stopPropagation(),t()},className:`${mR} sm:opacity-0 sm:group-hover:opacity-100`,children:r("dashboard.delete")})})]})}function yR(){const{t:e}=Ee(),[t,n]=N.useState([]),[r,i]=N.useState(!0),[s,o]=N.useState(null),[a,l]=N.useState({showWorkspaceDirConfig:!0,showBraveSearchConfig:!0,enableIntegrations:!1}),[u,c]=N.useState(!1),[d,h]=N.useState(""),[p,g]=N.useState(""),[m,y]=N.useState(""),[v,x]=N.useState(""),[b,k]=N.useState(""),[w,_]=N.useState(!1),[P,E]=N.useState(!1),[T,S]=N.useState(null),M=N.useRef(null);async function R(C){var ne,j;const ee=(ne=C.target.files)==null?void 0:ne[0];if(ee){E(!0),S(null);try{let ie;try{ie=await Oy(ee)}catch(A){const J=A instanceof Error?A.message:String(A);if(J.includes("already exists")){const O=(j=prompt(`${J}
|
|
90
|
+
Esta acción no se puede deshacer.`,guardian:"Guardián",comingSoon:"Próximamente",guardianBlurb1:"Configura un agente guardián para controlar lo que puede hacer tu agente principal.",guardianBlurb2:"Define restricciones, bloquea acciones y exige aprobación antes de operaciones sensibles.",guardianChatBlurb:"Chat del guardián.<br />Configura restricciones aquí.",guardianDisconnected:"○ desconectado",errorCreditLimit:"La clave API ha alcanzado su límite de gasto. Recarga créditos o aumenta el límite de la clave en el panel de tu proveedor.",errorRateLimit:"Límite de solicitudes excedido. El proveedor está limitando las peticiones — intenta de nuevo en unos segundos.",errorAuth:"Autenticación fallida. La clave API puede ser inválida o estar expirada — revisa Configuración.",errorNoProvider:"Sin proveedor configurado. Ve a Configuración para agregar uno.",errorNoKey:"Falta la clave API del proveedor. Ve a Configuración para reconfigurar.",errorTimeout:"El agente tardó demasiado en responder. Intenta de nuevo o simplifica tu solicitud.",errorGeneric:"Algo salió mal: {message}"},xM={sessionExpiredLabel:"toma de control",sessionExpired:"Sesión expirada",sessionExpiredBlurb:"Este enlace de toma de control ya fue usado o expiró.",completeLabel:"completo",controlReturned:"Control devuelto al agente",closeTab:"Puedes cerrar esta pestaña.",connecting:"conectando…",agentNeedsHelp:"El agente necesita tu ayuda",liveLabel:"en vivo",waitingStream:"esperando transmisión del navegador…",whatDidYouDo:"¿Qué hiciste?",optional:"(opcional)",describeActionPlaceholder:"Describe tu acción para el agente…",returning:"Devolviendo…",completed:"Completado",urlBarPlaceholder:"Escribe una URL y pulsa Intro para navegar…"},yM={columns:{backlog:"PENDIENTE",inProgress:"EN PROGRESO",scheduled:"PROGRAMADO",toReview:"EN REVISIÓN",done:"COMPLETADO"},statusLabels:{backlog:"Pendiente",inProgress:"En progreso",scheduled:"Programado",toReview:"En revisión",done:"Completado"},editedBy:"editado por {name}",relativeNow:"ahora",relativeMinutes:"hace {n}m",relativeHours:"hace {n}h",relativeDays:"hace {n}d",titlePlaceholder:"Título de tarea…",descPlaceholder:"Descripción (markdown)…",add:"Agregar",cancel:"Cancelar"},bM={saving:"guardando…",close:"Cerrar",status:"Estado",sourceLabel:"fuente",editedByLabel:"editado por",created:"creado",updated:"actualizado",description:"Descripción",descPlaceholder:"Agregar una descripción…",save:"Guardar",cancel:"Cancelar",descEmpty:"Sin descripción — clic para agregar",commentsLabel:"Comentarios ({count})",noComments:"Sin comentarios aún",addComment:"Agregar comentario",commentPlaceholder:"Escribe un comentario… (markdown soportado)",publishComment:"Publicar comentario",publishing:"Publicando…",dangerZone:"Zona peligrosa",deleteTask:"[PELIGROSO] Eliminar tarea",deleting:"eliminando…",deleteConfirm:'¿Eliminar tarea "{title}"? Esta acción no se puede deshacer.'},_M={backToRuns:"← Volver a ejecuciones",loading:"Cargando…",waitingResponse:"Esperando respuesta…",triggering:"Iniciando…",runNow:"Ejecutar ahora",runHistory:"Historial de ejecuciones",noRuns:"Sin ejecuciones aún.",loadingList:"Cargando programados…",emptyIcon:"⏰",emptyText:"Sin programados aún. Pídele al agente que configure tareas recurrentes.",title:"Programados",activeCountOne:"{count} activo",activeCountOther:"{count} activos",next:"Próximo: {time}",last:"Último: {time}",pause:"Pausar",resume:"Reanudar",delete:"Eliminar",deleteConfirm:'¿Eliminar programado "{name}"?'},wM={title:"Flujos de trabajo",emptyText:"Sin flujos de trabajo aún. Pídele al agente que cree uno via chat.",running:"Ejecutando…",run:"Ejecutar",createdOn:"{id} · Creado {date}",back:"← Volver a flujos",run_button:"Ejecutar",stepsTitle:"Pasos ({count})",conditionsOne:"{count} condición",conditionsOther:"{count} condiciones",stepType:"Tipo: {type}",stepTimeout:"Límite de tiempo: {seconds}s",stepId:"ID: {id}",runHistoryTitle:"Historial de ejecuciones ({count})",noRuns:"Sin ejecuciones aún."},kM={loading:"Cargando ejecución…",back:"← Volver al flujo",runLabel:"Ejecución —",errorPrefix:"Error:",input:"Entrada",output:"Salida"},SM={loading:"Cargando monitor…",title:"Monitor",idle:"inactivo",claudeSessionsOne:"{count} sesión claude",claudeSessionsOther:"{count} sesiones claude",processes:"Procesos",agentProcess:"Proceso del Agente",guardianProcess:"Guardián (Big Brother)",browserDaemon:"Demonio de Navegador",activeClaudeSessions:"Sesiones Claude Activas — {count}",jobQueue:"Cola de trabajos — {processing} en proceso, {pending} en espera",noActiveJobs:"Sin trabajos activos",processing:"procesando",queued:"en cola",terminate:"Terminar",cancel:"Cancelar",runningWorkflows:"Flujos de trabajo en ejecución",cpu:"CPU",mem:"MEM",rss:"RSS",uptime:"Tiempo activo"},CM={title:"Integraciones",blurb:"Conecta servicios externos. Cada integración almacena un token como secreto y se activa automáticamente.",moreSoon:"Más integraciones próximamente. Para otras claves API y credenciales, usa la sección de Secretos en la barra lateral.",connected:"Conectado",disconnect:"Desconectar",connect:"Conectar",saveAndConnect:"Guardar y conectar",saving:"Guardando…",cancel:"Cancelar",newPrefix:"Nuevo {label}",pasteNewToken:"Pega el nuevo token",updateToken:"Actualizar token",rotateToken:"Rotar token",errorSave:"Error al guardar — revisa la consola",disconnectConfirm:"¿Desconectar {name}? El agente dejará de usarlo inmediatamente.",telegramDescription:"Recibe y responde mensajes a través de un bot de Telegram.",telegramHelp:"Crea un bot mediante @BotFather en Telegram, luego pega el token aquí.",telegramTokenLabel:"Token del bot"},EM={loading:"Escaneando sesiones…",title:"Uso",totalTokens:"Tokens totales",cachedSuffix:"{amount} en caché",sessions:"Sesiones",modelsCount:"{count} modelos",estCost:"Costo est.",periodDays:"Período de {days} días",avgDay:"Prom/Día",sessionsPerDay:"{count} sesiones/día",dailyTokenUsage:"Uso diario de tokens",noUsageData:"Sin datos de uso",dailyCost:"Costo estimado diario",noCostData:"Sin datos de costo",byModel:"Por modelo",modelSessionsBlurb:"{sessions} sesiones · {input} entrada · {output} salida",tokenBreakdown:"Desglose de tokens",inputTokens:"Tokens de entrada",outputTokens:"Tokens de salida",cacheRead:"Lectura de caché",cacheWrite:"Escritura de caché",toolInvocations:"Invocaciones de herramientas",dailyBreakdown:"Desglose diario",date:"Fecha",tableSessions:"Sesiones",tableInput:"Entrada",tableOutput:"Salida",tableCache:"Caché",tableCost:"Costo"},PM={searchPlaceholder:"Buscar registros…",apply:"Aplicar",live:"En vivo",loading:"cargando…",noResults:'sin resultados para "{query}"',noEntries:"sin entradas de registro",loadOlder:"Cargar {count} entradas anteriores…"},NM={views:{chat:"Chat",tasks:"Tareas",browser:"Navegador",files:"Archivos",workflows:"Flujos de trabajo",schedules:"Programados",monitor:"Monitor",usage:"Uso",logs:"Registros",integrations:"Integraciones",guardian:"Guardián"},comingSoon:"Pronto",secrets:"Secretos",noSecrets:"Sin secretos configurados",updating:"Actualizando {name}",newValue:"nuevo valor",save:"Guardar",secretNamePlaceholder:"NOMBRE",secretValuePlaceholder:"valor",guardrails:"Restricciones",guardrailsBlurb:"Configurado via chat guardián",exportAgent:"📦 Exportar agente",exportTitle:"Descargar una copia de seguridad completa del espacio de trabajo del agente como zip",wipeAgent:"🗑 Borrar agente",wiping:"borrando…"},jM={workspace:"espacio-de-trabajo",savingLabel:"guardando…",saveButton:"Guardar",emptyDir:"Directorio vacío"},TM={common:fM,shell:pM,dashboard:gM,settings:mM,chat:vM,takeover:xM,tasks:yM,taskDetail:bM,schedules:_M,workflows:wM,runDetail:kM,monitor:SM,integrations:CM,usage:EM,logs:PM,agentSettings:NM,files:jM},Ty={en:hM,es:TM},Uk="granclaw:lang";function MM(){if(typeof window>"u")return"en";try{const t=window.localStorage.getItem(Uk);if(t==="en"||t==="es")return t}catch{}return(typeof navigator<"u"?navigator.language:"").toLowerCase().startsWith("es")?"es":"en"}function My(e,t){const n=t.split(".");let r=e;for(const i of n)if(r&&typeof r=="object"&&i in r)r=r[i];else return;return typeof r=="string"?r:void 0}function RM(e,t){return t?e.replace(/\{(\w+)\}/g,(n,r)=>{const i=t[r];return i==null?`{${r}}`:String(i)}):e}const qk=N.createContext(null);function AM({children:e}){const[t,n]=N.useState(()=>MM()),r=N.useCallback(o=>{n(o);try{window.localStorage.setItem(Uk,o)}catch{}},[]);N.useEffect(()=>{try{document.documentElement.lang=t}catch{}},[t]);const i=N.useCallback((o,a)=>{const l=Ty[t],u=My(l,o)??My(Ty.en,o)??o;return RM(u,a)},[t]),s=N.useMemo(()=>({lang:t,setLang:r,t:i}),[t,r,i]);return f.jsx(qk.Provider,{value:s,children:e})}function Ee(){const e=N.useContext(qk);if(!e)throw new Error("useT must be used inside <LanguageProvider>");return e}function DM({className:e}){const{lang:t,setLang:n}=Ee();return f.jsx("div",{className:`flex items-center gap-0.5 rounded-full bg-surface-container/40 p-[2px] ${e??""}`,children:["en","es"].map(r=>f.jsx("button",{onClick:()=>n(r),className:`px-2 py-[2px] rounded-full text-[10px] font-mono uppercase tracking-wider transition-colors ${t===r?"bg-primary/30 text-primary":"text-on-surface-variant/70 hover:text-on-surface"}`,"aria-pressed":t===r,children:r},r))})}function IM(){const e=es(),t=ts(),n=e.pathname.includes("/chat"),{t:r}=Ee();return f.jsxs("div",{className:"flex h-screen flex-col overflow-hidden bg-surface",children:[f.jsxs("header",{className:"flex h-11 flex-shrink-0 items-center justify-between border-b border-outline-variant/20 bg-surface-low px-3 sm:px-5",children:[f.jsxs("button",{onClick:()=>t("/dashboard"),className:"flex items-center gap-2 hover:opacity-80 transition-opacity min-w-0",children:[f.jsx("img",{src:"/granclaw-logo.png",alt:"GranClaw",className:"h-6 w-6 rounded flex-shrink-0"}),f.jsx("span",{className:"font-display font-semibold text-on-surface tracking-tight truncate",children:"GranClaw"}),f.jsxs("span",{className:"text-xs font-mono text-on-surface/60 flex-shrink-0",children:["v","0.0.1-beta.78"]})]}),f.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[f.jsx(DM,{}),f.jsxs("span",{className:"flex items-center gap-1.5 rounded-full bg-secondary-container/20 px-2 sm:px-3 py-1 text-xs font-mono text-secondary flex-shrink-0",children:[f.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-secondary animate-pulse flex-shrink-0"}),f.jsx("span",{className:"hidden sm:inline",children:r("shell.systemPrefix")}),r("shell.onlineSuffix")]})]})]}),f.jsx("main",{className:`flex-1 overflow-auto min-w-0 ${n?"":"p-3 sm:p-5"}`,children:f.jsx(AN,{})})]})}const le="";async function Ry(){const e=await fetch(`${le}/agents`);if(!e.ok)throw new Error(`fetchAgents: ${e.status}`);return e.json()}async function OM(e,t,n,r,i){const s=await fetch(`${le}/agents`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,name:t,model:n,provider:r,...i?{workspaceDir:i}:{}})});if(!s.ok){const o=await s.json().catch(()=>({error:s.statusText}));throw new Error(o.error)}}async function LM(e){const t=await fetch(`${le}/agents/${e}`,{method:"DELETE"});if(!t.ok)throw new Error(`deleteAgent: ${t.status}`)}async function Ay(e){const t=await fetch(`${le}/agents/${e}`);if(!t.ok)throw new Error(`fetchAgent: ${t.status}`);return t.json()}async function Dy(e,t="ui"){const n=await fetch(`${le}/agents/${e}/messages?channelId=${t}&sortBy=asc&limit=200`);if(!n.ok)throw new Error(`fetchMessages: ${n.status}`);return n.json()}async function FM(e){const t=await fetch(`${le}/agents/${e}/reset`,{method:"DELETE"});if(!t.ok)throw new Error(`resetAgent: ${t.status}`)}async function $M(e,t=""){const n=await fetch(`${le}/agents/${e}/files?path=${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`fetchFiles: ${n.status}`);return(await n.json()).entries}async function zM(e,t){const n=await fetch(`${le}/agents/${e}/files/read?path=${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`readFile: ${n.status}`);return(await n.json()).content}async function BM(e,t,n){const r=await fetch(`${le}/agents/${e}/files/write?path=${encodeURIComponent(t)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:n})});if(!r.ok)throw new Error(`writeFile: ${r.status}`)}async function HM(e){const t=await fetch(`${le}/agents/${e}/secrets`);if(!t.ok)throw new Error(`fetchSecrets: ${t.status}`);return t.json()}async function Ep(e,t,n){const r=await fetch(`${le}/agents/${e}/secrets`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:t,value:n})});if(!r.ok)throw new Error(`addSecret: ${r.status}`)}async function Gk(e,t){const n=await fetch(`${le}/agents/${e}/secrets/${encodeURIComponent(t)}`,{method:"DELETE"});if(!n.ok)throw new Error(`deleteSecret: ${n.status}`)}async function WM(e,t){const r=await fetch(`${le}/agents/${e}/tasks`);if(!r.ok)throw new Error(`fetchTasks: ${r.status}`);return r.json()}async function VM(e,t){const n=await fetch(`${le}/agents/${e}/tasks/${t}`);if(!n.ok)throw new Error(`fetchTask: ${n.status}`);return n.json()}async function UM(e,t){const n=await fetch(`${le}/agents/${e}/tasks`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok)throw new Error(`createTask: ${n.status}`);return n.json()}async function Iy(e,t,n){const r=await fetch(`${le}/agents/${e}/tasks/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!r.ok)throw new Error(`updateTask: ${r.status}`);return r.json()}async function qM(e,t){const n=await fetch(`${le}/agents/${e}/tasks/${t}`,{method:"DELETE"});if(!n.ok)throw new Error(`deleteTask: ${n.status}`)}async function GM(e,t,n){const r=await fetch(`${le}/agents/${e}/tasks/${t}/comments`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({body:n})});if(!r.ok)throw new Error(`addTaskComment: ${r.status}`);return r.json()}async function KM(e){const t=await fetch(`${le}/agents/${e}/browser-sessions`);if(!t.ok)throw new Error(`fetchBrowserSessions: ${t.status}`);return t.json()}async function Kk(e,t){const n=await fetch(`${le}/agents/${e}/browser-sessions/${t}`);if(!n.ok)throw new Error(`fetchBrowserSession: ${n.status}`);return n.json()}function YM(e,t){return`${le}/agents/${e}/browser-sessions/${t}/video`}function Yk(e,t){const n=window.location;return`${n.protocol==="https:"?"wss:":"ws:"}//${n.host}/browser-live/${e}/${t}`}function XM(e){return`${le}/agents/${e}/export`}async function Oy(e,t){const n=new URL(`${le}/agents/import`,window.location.origin);t!=null&&t.id&&n.searchParams.set("id",t.id);const r=await fetch(n.toString().replace(window.location.origin,""),{method:"POST",headers:{"Content-Type":"application/zip"},body:e});if(!r.ok){const i=await r.json().catch(()=>({error:r.statusText}));throw new Error(i.error)}return r.json()}async function Ly(e,t){const n=await fetch(`${le}/agents/${e}/monitor/jobs/${t}`,{method:"DELETE"});if(!n.ok)throw new Error(`killJob: ${n.status}`)}async function JM(e){const t=await fetch(`${le}/agents/${e}/monitor`);if(!t.ok)throw new Error(`fetchMonitor: ${t.status}`);return t.json()}async function QM(e,t=30){const n=await fetch(`${le}/agents/${e}/usage?days=${t}`);if(!n.ok)throw new Error(`fetchUsage: ${n.status}`);return n.json()}async function ZM(e){const t=await fetch(`${le}/agents/${e}/schedules`);if(!t.ok)throw new Error(`fetchSchedules: ${t.status}`);return t.json()}async function eR(e,t,n){const r=await fetch(`${le}/agents/${e}/schedules/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!r.ok)throw new Error(`updateSchedule: ${r.status}`);return r.json()}async function tR(e,t){const n=await fetch(`${le}/agents/${e}/schedules/${t}`,{method:"DELETE"});if(!n.ok)throw new Error(`deleteSchedule: ${n.status}`)}async function nR(e,t){const n=await fetch(`${le}/agents/${e}/schedules/${t}/trigger`,{method:"POST"});if(!n.ok)throw new Error(`triggerSchedule: ${n.status}`);return n.json()}async function rR(e,t){const n=await fetch(`${le}/agents/${e}/schedules/${t}/runs`);if(!n.ok)throw new Error(`fetchScheduleRuns: ${n.status}`);return n.json()}async function iR(e,t){const n=await fetch(`${le}/agents/${e}/messages?channelId=${encodeURIComponent(t)}&sortBy=asc&limit=200`);if(!n.ok)throw new Error(`fetchScheduleRunMessages: ${n.status}`);return n.json()}async function sR(e){const t=await fetch(`${le}/agents/${e}/workflows`);if(!t.ok)throw new Error(`fetchWorkflows: ${t.status}`);return t.json()}async function oR(e,t){const n=await fetch(`${le}/agents/${e}/workflows/${t}`);if(!n.ok)throw new Error(`fetchWorkflow: ${n.status}`);return n.json()}async function xh(e,t){const n=await fetch(`${le}/agents/${e}/workflows/${t}/runs`);if(!n.ok)throw new Error(`fetchWorkflowRuns: ${n.status}`);return n.json()}async function aR(e,t,n){const r=await fetch(`${le}/agents/${e}/workflows/${t}/runs/${n}`);if(!r.ok)throw new Error(`fetchWorkflowRun: ${r.status}`);return r.json()}async function lR(e,t){const n=await fetch(`${le}/agents/${e}/workflows/${t}/run`,{method:"POST"});if(!n.ok)throw new Error(`triggerWorkflowRun: ${n.status}`);return n.json()}async function uR(e){const t=new URLSearchParams;e!=null&&e.agentId&&t.set("agentId",e.agentId),e!=null&&e.type&&t.set("type",e.type),e!=null&&e.search&&t.set("search",e.search),(e==null?void 0:e.limit)!=null&&t.set("limit",String(e.limit)),(e==null?void 0:e.offset)!=null&&t.set("offset",String(e.offset));const n=await fetch(`${le}/logs?${t}`);if(!n.ok)throw new Error(`fetchLogs: ${n.status}`);return n.json()}async function Xk(){const e=await fetch(`${le}/settings/provider`);if(!e.ok)throw new Error("Failed to fetch provider settings");return e.json()}const yh={showWorkspaceDirConfig:!0,showBraveSearchConfig:!0,enableIntegrations:!1};async function Jk(){try{const e=await fetch(`${le}/settings/app`);if(!e.ok)return{...yh};const t=await e.json();return{...yh,...t}}catch{return{...yh}}}async function Fy(e,t,n){if(!(await fetch(`${le}/settings/provider`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e,model:t,apiKey:n})})).ok)throw new Error("Failed to save provider settings")}async function cR(e){if(!(await fetch(`${le}/settings/providers/${encodeURIComponent(e)}`,{method:"DELETE"})).ok)throw new Error("Failed to remove provider")}async function dR(){const e=await fetch(`${le}/settings/search`);return e.ok?e.json():{provider:"brave",configured:!1}}async function hR(e,t){const n=await fetch(`${le}/settings/search`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:t})});if(!n.ok)throw new Error(`Failed to save search settings: ${n.status}`)}async function fR(){const e=await fetch(`${le}/settings/search`,{method:"DELETE"});if(!e.ok&&e.status!==204&&e.status!==404)throw new Error(`Failed to clear search settings: ${e.status}`)}const pR={google:[{value:"gemini-2.5-flash",label:"Gemini 2.5 Flash — fast + smart (recommended)"},{value:"gemini-2.5-pro",label:"Gemini 2.5 Pro — most capable"},{value:"gemini-2.5-flash-lite",label:"Gemini 2.5 Flash Lite — cheapest"},{value:"gemini-3-flash-preview",label:"Gemini 3 Flash — preview"},{value:"gemini-3.1-pro-preview",label:"Gemini 3.1 Pro — preview"}],openai:[{value:"gpt-4.1",label:"GPT-4.1 — recommended, 1M ctx"},{value:"gpt-4.1-mini",label:"GPT-4.1 Mini — fast, efficient"},{value:"gpt-4.1-nano",label:"GPT-4.1 Nano — cheapest"}],anthropic:[{value:"claude-sonnet-4-6",label:"Claude Sonnet 4.6 — recommended"},{value:"claude-opus-4-6",label:"Claude Opus 4.6 — most capable"},{value:"claude-haiku-4-5-20251001",label:"Claude Haiku 4.5 — fastest"}],groq:[{value:"openai/gpt-oss-120b",label:"GPT-OSS 120B — flagship, ~500 tok/s"},{value:"openai/gpt-oss-20b",label:"GPT-OSS 20B — fast, efficient"},{value:"llama-3.3-70b-versatile",label:"Llama 3.3 70B — versatile"},{value:"llama-3.1-8b-instant",label:"Llama 3.1 8B — fastest/cheapest"}],openrouter:[{value:"google/gemini-2.5-flash",label:"Gemini 2.5 Flash — best price/perf ($0.30/$2.50 /M)"},{value:"google/gemini-3-flash-preview",label:"Gemini 3 Flash — fast, 1M ctx ($0.50/$3 /M)"},{value:"google/gemini-3.1-pro-preview",label:"Gemini 3.1 Pro — frontier ($2/$12 /M)"},{value:"deepseek/deepseek-v3.2",label:"DeepSeek V3.2 — cheap output ($0.26/$0.38 /M)"},{value:"xiaomi/mimo-v2-pro",label:"MiMo V2 Pro — agentic, 1T params ($1/$3 /M)"},{value:"qwen/qwen3.6-plus",label:"Qwen 3.6 Plus — throughput leader ($0.33/$1.95 /M)"},{value:"minimax/minimax-m2.7",label:"MiniMax M2.7 — agentic ($0.30/$1.20 /M)"},{value:"x-ai/grok-4",label:"Grok 4 — reasoning, 256k ctx ($3/$15 /M)"}],freetier:[{value:"z-ai/glm-5-turbo",label:"GLM 5 Turbo — enterprise default"}]},Qk=[{value:"google",label:"Google Gemini"},{value:"openai",label:"OpenAI"},{value:"anthropic",label:"Anthropic"},{value:"groq",label:"Groq"},{value:"openrouter",label:"OpenRouter"}];function ud(e){return pR[e]??[]}function Pp(e){var t;return((t=ud(e)[0])==null?void 0:t.value)??""}const ya="inline-flex items-center justify-center gap-2 bg-primary text-on-primary px-5 py-2.5 text-sm font-label font-semibold uppercase tracking-widest rounded shadow-sm transition-all hover:bg-surface-tint hover:shadow-md active:scale-[0.98] disabled:opacity-40 disabled:pointer-events-none",gR="inline-flex items-center justify-center gap-2 border border-outline-variant text-on-surface px-5 py-2.5 text-sm font-label font-semibold uppercase tracking-widest rounded transition-all hover:bg-surface-container hover:border-outline active:scale-[0.98] disabled:opacity-40 disabled:pointer-events-none",Zk="inline-flex items-center justify-center gap-1.5 text-on-surface-variant px-2.5 py-1.5 text-xs font-label font-medium uppercase tracking-wider rounded transition-colors hover:bg-surface-container hover:text-on-surface disabled:opacity-40 disabled:pointer-events-none",mR="inline-flex items-center justify-center gap-1.5 text-error px-2.5 py-1.5 text-xs font-label font-medium uppercase tracking-wider rounded transition-colors hover:bg-error/10 disabled:opacity-40 disabled:pointer-events-none",Eu="w-full bg-surface-container-lowest text-on-surface placeholder:text-on-surface-variant border border-outline-variant rounded-lg px-3 py-2 text-sm focus:outline-none focus:border-primary focus:ring-2 focus:ring-primary/20 transition-colors",$y=Eu.replace("text-sm","text-sm font-mono"),Za="bg-surface-container-lowest border border-outline-variant/40 rounded-xl shadow-callout",Ws="inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[10px] font-label font-medium uppercase tracking-wider",Np=`${Ws} bg-surface-container border border-outline-variant/40 text-on-surface-variant`,eS=`${Ws} bg-success/10 border border-success/20 text-success`,vR=`${Ws} bg-warning/10 border border-warning/20 text-warning`;function xR({agent:e,onDelete:t}){const n=ts(),{t:r}=Ee(),i=e.status==="active",s=e.busy===!0;return f.jsxs("div",{onClick:()=>n(`/agents/${e.id}/chat`),className:"group flex items-center gap-4 rounded-xl bg-surface-container-lowest border border-outline-variant/40 p-4 cursor-pointer transition-all hover:border-primary/40 hover:shadow-callout",children:[f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[f.jsx("span",{className:"font-headline text-lg font-bold text-on-surface",children:e.name}),s?f.jsxs("span",{"data-testid":"busy-badge",className:"inline-flex items-center gap-1 rounded-full bg-secondary/15 border border-secondary/30 px-2 py-0.5 text-[10px] font-label font-semibold uppercase tracking-wider text-secondary",children:[f.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-secondary animate-pulse"}),"busy"]}):f.jsx("span",{className:i?eS:Np,children:e.status})]}),f.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[f.jsx("span",{className:"font-mono text-[10px] text-primary/70",children:e.model}),f.jsxs("span",{className:"font-mono text-[10px] text-on-surface-variant/60 hidden sm:inline",children:["id: ",e.id]})]})]}),f.jsx("div",{className:"flex items-center gap-2 flex-shrink-0",children:f.jsx("button",{onClick:o=>{o.stopPropagation(),t()},className:`${mR} sm:opacity-0 sm:group-hover:opacity-100`,children:r("dashboard.delete")})})]})}function yR(){const{t:e}=Ee(),[t,n]=N.useState([]),[r,i]=N.useState(!0),[s,o]=N.useState(null),[a,l]=N.useState({showWorkspaceDirConfig:!0,showBraveSearchConfig:!0,enableIntegrations:!1}),[u,c]=N.useState(!1),[d,h]=N.useState(""),[p,g]=N.useState(""),[m,y]=N.useState(""),[v,x]=N.useState(""),[b,k]=N.useState(""),[w,_]=N.useState(!1),[P,E]=N.useState(!1),[T,S]=N.useState(null),M=N.useRef(null);async function R(C){var ne,j;const ee=(ne=C.target.files)==null?void 0:ne[0];if(ee){E(!0),S(null);try{let ie;try{ie=await Oy(ee)}catch(A){const J=A instanceof Error?A.message:String(A);if(J.includes("already exists")){const O=(j=prompt(`${J}
|
|
91
91
|
|
|
92
92
|
Enter a new id for the imported agent:`,""))==null?void 0:j.trim();if(!O){E(!1);return}ie=await Oy(ee,{id:O})}else throw A}await $(),H(`/agents/${ie.id}/chat`)}catch(ie){S(ie instanceof Error?ie.message:e("dashboard.importFailed"))}finally{E(!1),M.current&&(M.current.value="")}}}const $=()=>{Promise.all([Ry(),Xk(),Jk()]).then(([C,ee,ne])=>{var j;if(n(C),o(ee),l(ne),!m){const ie=(j=ee.providers)==null?void 0:j[0];ie&&(y(ie.provider),x(ie.model))}}).catch(console.error).finally(()=>i(!1))};N.useEffect(()=>{$();const C=setInterval(()=>{Ry().then(n).catch(()=>{})},2e3);return()=>clearInterval(C)},[]);const H=ts(),F=(s==null?void 0:s.providers)??[],X=m?ud(m):[];function Z(C){y(C),x(Pp(C))}async function I(){if(!(!d.trim()||!p.trim())){_(!0),S(null);try{const C=d.trim();await OM(C,p.trim(),v,m||void 0,b.trim()||void 0),H(`/agents/${C}/chat`)}catch(C){S(C instanceof Error?C.message:e("common.errorCreate")),_(!1)}}}async function z(C,ee){confirm(e("dashboard.deleteConfirm",{name:ee,id:C}))&&(await LM(C),$())}return r?f.jsx("div",{className:"font-mono text-xs text-on-surface-variant p-8",children:e("dashboard.loadingAgents")}):s&&!s.configured&&t.length===0?f.jsx("div",{className:"max-w-3xl mx-auto py-16 px-4",children:f.jsxs("div",{className:"text-center",children:[f.jsxs("h1",{className:"font-headline text-4xl font-bold text-on-surface mb-4",children:[e("dashboard.getStartedWith")," ",f.jsx("span",{className:"highlight-marker",children:"GranClaw"})]}),f.jsx("p",{className:"font-mono text-xs text-on-surface-variant mb-8",children:e("dashboard.configureProviderBlurb")}),f.jsx(mx,{to:"/settings",className:ya,children:e("dashboard.configureProvider")})]})}):f.jsxs("div",{className:"max-w-4xl mx-auto py-6 sm:py-8 px-4",children:[s&&!s.configured&&f.jsxs("div",{className:"rounded-xl bg-warning/10 border border-warning/30 px-4 py-3 mb-6 flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2",children:[f.jsx("p",{className:"font-mono text-[11px] text-warning",children:e("dashboard.noProviderWarning")}),f.jsx(mx,{to:"/settings",className:"font-label text-[11px] font-semibold uppercase tracking-widest text-primary hover:text-surface-tint flex-shrink-0",children:e("dashboard.configureArrow")})]}),f.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start sm:justify-between gap-4 mb-6 sm:mb-8",children:[f.jsxs("div",{children:[f.jsx("h1",{className:"font-headline text-3xl sm:text-4xl font-bold text-on-surface",children:e("dashboard.title")}),f.jsx("p",{className:"font-mono text-[11px] text-on-surface-variant mt-1",children:e(t.length===1?"dashboard.agentsCountOne":"dashboard.agentsCountOther",{count:t.length})})]}),f.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[f.jsx("input",{ref:M,type:"file",accept:".zip,application/zip",onChange:R,className:"hidden"}),f.jsx("button",{onClick:()=>{var C;return(C=M.current)==null?void 0:C.click()},disabled:P||!(s!=null&&s.configured),className:gR,title:e("dashboard.importTitle"),children:e(P?"dashboard.importing":"dashboard.import")}),f.jsx("button",{onClick:()=>c(C=>!C),disabled:!(s!=null&&s.configured),className:ya,children:e(u?"dashboard.cancel":"dashboard.newAgent")})]})]}),u&&f.jsxs("div",{className:`${Za} p-5 mb-6 space-y-3`,children:[f.jsx("p",{className:"font-label text-[10px] font-semibold uppercase tracking-widest text-on-surface-variant",children:e("dashboard.createNewAgent")}),f.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:[f.jsx("input",{className:$y,placeholder:e("dashboard.agentIdPlaceholder"),value:d,onChange:C=>h(C.target.value.toLowerCase().replace(/[^a-z0-9-]/g,""))}),f.jsx("input",{className:Eu,placeholder:e("dashboard.displayNamePlaceholder"),value:p,onChange:C=>g(C.target.value)})]}),f.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:[f.jsx("select",{className:`${Eu} appearance-none`,value:m,onChange:C=>Z(C.target.value),children:F.map(C=>f.jsx("option",{value:C.provider,children:C.label??C.provider},C.provider))}),f.jsx("select",{className:`${Eu} appearance-none`,value:v,onChange:C=>x(C.target.value),children:X.map(C=>f.jsx("option",{value:C.value,children:C.label},C.value))})]}),a.showWorkspaceDirConfig&&f.jsx("input",{className:$y,placeholder:e("dashboard.workspacePlaceholder",{id:d||e("dashboard.workspacePlaceholderDefault")}),value:b,onChange:C=>k(C.target.value)}),f.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[f.jsx("button",{onClick:I,disabled:w||!d.trim()||!p.trim()||!v,className:ya,children:e(w?"dashboard.creating":"dashboard.create")}),T&&f.jsx("span",{className:"font-mono text-[10px] text-error",children:T})]})]}),f.jsx("div",{className:"space-y-3",children:t.length===0?f.jsxs("div",{className:"text-center py-16",children:[f.jsx("span",{className:"text-3xl opacity-30",children:"🤖"}),f.jsx("p",{className:"font-mono text-[11px] text-on-surface-variant mt-3",children:e("dashboard.noAgents")})]}):t.map(C=>f.jsx(xR,{agent:C,onDelete:()=>z(C.id,C.name)},C.id))})]})}function bR(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const _R=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,wR=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,kR={};function zy(e,t){return(kR.jsx?wR:_R).test(e)}const SR=/[ \t\n\f\r]/g;function CR(e){return typeof e=="object"?e.type==="text"?By(e.value):!1:By(e)}function By(e){return e.replace(SR,"")===""}class gl{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}gl.prototype.normal={};gl.prototype.property={};gl.prototype.space=void 0;function tS(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new gl(n,r,t)}function jp(e){return e.toLowerCase()}class Jt{constructor(t,n){this.attribute=n,this.property=t}}Jt.prototype.attribute="";Jt.prototype.booleanish=!1;Jt.prototype.boolean=!1;Jt.prototype.commaOrSpaceSeparated=!1;Jt.prototype.commaSeparated=!1;Jt.prototype.defined=!1;Jt.prototype.mustUseProperty=!1;Jt.prototype.number=!1;Jt.prototype.overloadedBoolean=!1;Jt.prototype.property="";Jt.prototype.spaceSeparated=!1;Jt.prototype.space=void 0;let ER=0;const de=ns(),nt=ns(),Tp=ns(),W=ns(),Re=ns(),Vs=ns(),Zt=ns();function ns(){return 2**++ER}const Mp=Object.freeze(Object.defineProperty({__proto__:null,boolean:de,booleanish:nt,commaOrSpaceSeparated:Zt,commaSeparated:Vs,number:W,overloadedBoolean:Tp,spaceSeparated:Re},Symbol.toStringTag,{value:"Module"})),bh=Object.keys(Mp);class vm extends Jt{constructor(t,n,r,i){let s=-1;if(super(t,n),Hy(this,"space",i),typeof r=="number")for(;++s<bh.length;){const o=bh[s];Hy(this,bh[s],(r&Mp[o])===Mp[o])}}}vm.prototype.defined=!0;function Hy(e,t,n){n&&(e[t]=n)}function po(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const s=new vm(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[jp(r)]=r,n[jp(s.attribute)]=r}return new gl(t,n,e.space)}const nS=po({properties:{ariaActiveDescendant:null,ariaAtomic:nt,ariaAutoComplete:null,ariaBusy:nt,ariaChecked:nt,ariaColCount:W,ariaColIndex:W,ariaColSpan:W,ariaControls:Re,ariaCurrent:null,ariaDescribedBy:Re,ariaDetails:null,ariaDisabled:nt,ariaDropEffect:Re,ariaErrorMessage:null,ariaExpanded:nt,ariaFlowTo:Re,ariaGrabbed:nt,ariaHasPopup:null,ariaHidden:nt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Re,ariaLevel:W,ariaLive:null,ariaModal:nt,ariaMultiLine:nt,ariaMultiSelectable:nt,ariaOrientation:null,ariaOwns:Re,ariaPlaceholder:null,ariaPosInSet:W,ariaPressed:nt,ariaReadOnly:nt,ariaRelevant:null,ariaRequired:nt,ariaRoleDescription:Re,ariaRowCount:W,ariaRowIndex:W,ariaRowSpan:W,ariaSelected:nt,ariaSetSize:W,ariaSort:null,ariaValueMax:W,ariaValueMin:W,ariaValueNow:W,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function rS(e,t){return t in e?e[t]:t}function iS(e,t){return rS(e,t.toLowerCase())}const PR=po({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Vs,acceptCharset:Re,accessKey:Re,action:null,allow:null,allowFullScreen:de,allowPaymentRequest:de,allowUserMedia:de,alt:null,as:null,async:de,autoCapitalize:null,autoComplete:Re,autoFocus:de,autoPlay:de,blocking:Re,capture:null,charSet:null,checked:de,cite:null,className:Re,cols:W,colSpan:null,content:null,contentEditable:nt,controls:de,controlsList:Re,coords:W|Vs,crossOrigin:null,data:null,dateTime:null,decoding:null,default:de,defer:de,dir:null,dirName:null,disabled:de,download:Tp,draggable:nt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:de,formTarget:null,headers:Re,height:W,hidden:Tp,high:W,href:null,hrefLang:null,htmlFor:Re,httpEquiv:Re,id:null,imageSizes:null,imageSrcSet:null,inert:de,inputMode:null,integrity:null,is:null,isMap:de,itemId:null,itemProp:Re,itemRef:Re,itemScope:de,itemType:Re,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:de,low:W,manifest:null,max:null,maxLength:W,media:null,method:null,min:null,minLength:W,multiple:de,muted:de,name:null,nonce:null,noModule:de,noValidate:de,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:de,optimum:W,pattern:null,ping:Re,placeholder:null,playsInline:de,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:de,referrerPolicy:null,rel:Re,required:de,reversed:de,rows:W,rowSpan:W,sandbox:Re,scope:null,scoped:de,seamless:de,selected:de,shadowRootClonable:de,shadowRootDelegatesFocus:de,shadowRootMode:null,shape:null,size:W,sizes:null,slot:null,span:W,spellCheck:nt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:W,step:null,style:null,tabIndex:W,target:null,title:null,translate:null,type:null,typeMustMatch:de,useMap:null,value:nt,width:W,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Re,axis:null,background:null,bgColor:null,border:W,borderColor:null,bottomMargin:W,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:de,declare:de,event:null,face:null,frame:null,frameBorder:null,hSpace:W,leftMargin:W,link:null,longDesc:null,lowSrc:null,marginHeight:W,marginWidth:W,noResize:de,noHref:de,noShade:de,noWrap:de,object:null,profile:null,prompt:null,rev:null,rightMargin:W,rules:null,scheme:null,scrolling:nt,standby:null,summary:null,text:null,topMargin:W,valueType:null,version:null,vAlign:null,vLink:null,vSpace:W,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:de,disableRemotePlayback:de,prefix:null,property:null,results:W,security:null,unselectable:null},space:"html",transform:iS}),NR=po({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Zt,accentHeight:W,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:W,amplitude:W,arabicForm:null,ascent:W,attributeName:null,attributeType:null,azimuth:W,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:W,by:null,calcMode:null,capHeight:W,className:Re,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:W,diffuseConstant:W,direction:null,display:null,dur:null,divisor:W,dominantBaseline:null,download:de,dx:null,dy:null,edgeMode:null,editable:null,elevation:W,enableBackground:null,end:null,event:null,exponent:W,externalResourcesRequired:null,fill:null,fillOpacity:W,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Vs,g2:Vs,glyphName:Vs,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:W,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:W,horizOriginX:W,horizOriginY:W,id:null,ideographic:W,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:W,k:W,k1:W,k2:W,k3:W,k4:W,kernelMatrix:Zt,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:W,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:W,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:W,overlineThickness:W,paintOrder:null,panose1:null,path:null,pathLength:W,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Re,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:W,pointsAtY:W,pointsAtZ:W,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Zt,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Zt,rev:Zt,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Zt,requiredFeatures:Zt,requiredFonts:Zt,requiredFormats:Zt,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:W,specularExponent:W,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:W,strikethroughThickness:W,string:null,stroke:null,strokeDashArray:Zt,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:W,strokeOpacity:W,strokeWidth:null,style:null,surfaceScale:W,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Zt,tabIndex:W,tableValues:null,target:null,targetX:W,targetY:W,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Zt,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:W,underlineThickness:W,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:W,values:null,vAlphabetic:W,vMathematical:W,vectorEffect:null,vHanging:W,vIdeographic:W,version:null,vertAdvY:W,vertOriginX:W,vertOriginY:W,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:W,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:rS}),sS=po({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),oS=po({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:iS}),aS=po({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),jR={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},TR=/[A-Z]/g,Wy=/-[a-z]/g,MR=/^data[-\w.:]+$/i;function RR(e,t){const n=jp(t);let r=t,i=Jt;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&MR.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(Wy,DR);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!Wy.test(s)){let o=s.replace(TR,AR);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}i=vm}return new i(r,t)}function AR(e){return"-"+e.toLowerCase()}function DR(e){return e.charAt(1).toUpperCase()}const IR=tS([nS,PR,sS,oS,aS],"html"),xm=tS([nS,NR,sS,oS,aS],"svg");function OR(e){return e.join(" ").trim()}var ym={},Vy=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,LR=/\n/g,FR=/^\s*/,$R=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,zR=/^:\s*/,BR=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,HR=/^[;\s]*/,WR=/^\s+|\s+$/g,VR=`
|
|
93
93
|
`,Uy="/",qy="*",Ri="",UR="comment",qR="declaration";function GR(e,t){if(typeof e!="string")throw new TypeError("First argument must be a string");if(!e)return[];t=t||{};var n=1,r=1;function i(g){var m=g.match(LR);m&&(n+=m.length);var y=g.lastIndexOf(VR);r=~y?g.length-y:r+g.length}function s(){var g={line:n,column:r};return function(m){return m.position=new o(g),u(),m}}function o(g){this.start=g,this.end={line:n,column:r},this.source=t.source}o.prototype.content=e;function a(g){var m=new Error(t.source+":"+n+":"+r+": "+g);if(m.reason=g,m.filename=t.source,m.line=n,m.column=r,m.source=e,!t.silent)throw m}function l(g){var m=g.exec(e);if(m){var y=m[0];return i(y),e=e.slice(y.length),m}}function u(){l(FR)}function c(g){var m;for(g=g||[];m=d();)m!==!1&&g.push(m);return g}function d(){var g=s();if(!(Uy!=e.charAt(0)||qy!=e.charAt(1))){for(var m=2;Ri!=e.charAt(m)&&(qy!=e.charAt(m)||Uy!=e.charAt(m+1));)++m;if(m+=2,Ri===e.charAt(m-1))return a("End of comment missing");var y=e.slice(2,m-2);return r+=2,i(y),e=e.slice(m),r+=2,g({type:UR,comment:y})}}function h(){var g=s(),m=l($R);if(m){if(d(),!l(zR))return a("property missing ':'");var y=l(BR),v=g({type:qR,property:Gy(m[0].replace(Vy,Ri)),value:y?Gy(y[0].replace(Vy,Ri)):Ri});return l(HR),v}}function p(){var g=[];c(g);for(var m;m=h();)m!==!1&&(g.push(m),c(g));return g}return u(),p()}function Gy(e){return e?e.replace(WR,Ri):Ri}var KR=GR,YR=zu&&zu.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(ym,"__esModule",{value:!0});ym.default=JR;const XR=YR(KR);function JR(e,t){let n=null;if(!e||typeof e!="string")return n;const r=(0,XR.default)(e),i=typeof t=="function";return r.forEach(s=>{if(s.type!=="declaration")return;const{property:o,value:a}=s;i?t(o,a,s):a&&(n=n||{},n[o]=a)}),n}var cd={};Object.defineProperty(cd,"__esModule",{value:!0});cd.camelCase=void 0;var QR=/^--[a-zA-Z0-9_-]+$/,ZR=/-([a-z])/g,eA=/^[^-]+$/,tA=/^-(webkit|moz|ms|o|khtml)-/,nA=/^-(ms)-/,rA=function(e){return!e||eA.test(e)||QR.test(e)},iA=function(e,t){return t.toUpperCase()},Ky=function(e,t){return"".concat(t,"-")},sA=function(e,t){return t===void 0&&(t={}),rA(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(nA,Ky):e=e.replace(tA,Ky),e.replace(ZR,iA))};cd.camelCase=sA;var oA=zu&&zu.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},aA=oA(ym),lA=cd;function Rp(e,t){var n={};return!e||typeof e!="string"||(0,aA.default)(e,function(r,i){r&&i&&(n[(0,lA.camelCase)(r,t)]=i)}),n}Rp.default=Rp;var uA=Rp;const cA=ig(uA),lS=uS("end"),bm=uS("start");function uS(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function dA(e){const t=bm(e),n=lS(e);if(t&&n)return{start:t,end:n}}function ba(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?Yy(e.position):"start"in e||"end"in e?Yy(e):"line"in e||"column"in e?Ap(e):""}function Ap(e){return Xy(e&&e.line)+":"+Xy(e&&e.column)}function Yy(e){return Ap(e&&e.start)+"-"+Ap(e&&e.end)}function Xy(e){return e&&typeof e=="number"?e:1}class jt extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",s={},o=!1;if(n&&("line"in n&&"column"in n?s={place:n}:"start"in n&&"end"in n?s={place:n}:"type"in n?s={ancestors:[n],place:n.position}:s={...n}),typeof t=="string"?i=t:!s.cause&&t&&(o=!0,i=t.message,s.cause=t),!s.ruleId&&!s.source&&typeof r=="string"){const l=r.indexOf(":");l===-1?s.ruleId=r:(s.source=r.slice(0,l),s.ruleId=r.slice(l+1))}if(!s.place&&s.ancestors&&s.ancestors){const l=s.ancestors[s.ancestors.length-1];l&&(s.place=l.position)}const a=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=a?a.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=a?a.line:void 0,this.name=ba(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=o&&s.cause&&typeof s.cause.stack=="string"?s.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}jt.prototype.file="";jt.prototype.name="";jt.prototype.reason="";jt.prototype.message="";jt.prototype.stack="";jt.prototype.column=void 0;jt.prototype.line=void 0;jt.prototype.ancestors=void 0;jt.prototype.cause=void 0;jt.prototype.fatal=void 0;jt.prototype.place=void 0;jt.prototype.ruleId=void 0;jt.prototype.source=void 0;const _m={}.hasOwnProperty,hA=new Map,fA=/[A-Z]/g,pA=new Set(["table","tbody","thead","tfoot","tr"]),gA=new Set(["td","th"]),cS="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function mA(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=SA(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=kA(n,t.jsx,t.jsxs)}const i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?xm:IR,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},s=dS(i,e,void 0);return s&&typeof s!="string"?s:i.create(e,i.Fragment,{children:s||void 0},void 0)}function dS(e,t,n){if(t.type==="element")return vA(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return xA(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return bA(e,t,n);if(t.type==="mdxjsEsm")return yA(e,t);if(t.type==="root")return _A(e,t,n);if(t.type==="text")return wA(e,t)}function vA(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=xm,e.schema=i),e.ancestors.push(t);const s=fS(e,t.tagName,!1),o=CA(e,t);let a=km(e,t);return pA.has(t.tagName)&&(a=a.filter(function(l){return typeof l=="string"?!CR(l):!0})),hS(e,o,s,t),wm(o,a),e.ancestors.pop(),e.schema=r,e.create(t,s,o,n)}function xA(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}el(e,t.position)}function yA(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);el(e,t.position)}function bA(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=xm,e.schema=i),e.ancestors.push(t);const s=t.name===null?e.Fragment:fS(e,t.name,!0),o=EA(e,t),a=km(e,t);return hS(e,o,s,t),wm(o,a),e.ancestors.pop(),e.schema=r,e.create(t,s,o,n)}function _A(e,t,n){const r={};return wm(r,km(e,t)),e.create(t,e.Fragment,r,n)}function wA(e,t){return t.value}function hS(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function wm(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function kA(e,t,n){return r;function r(i,s,o,a){const u=Array.isArray(o.children)?n:t;return a?u(s,o,a):u(s,o)}}function SA(e,t){return n;function n(r,i,s,o){const a=Array.isArray(s.children),l=bm(r);return t(i,s,o,a,{columnNumber:l?l.column-1:void 0,fileName:e,lineNumber:l?l.line:void 0},void 0)}}function CA(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&_m.call(t.properties,i)){const s=PA(e,i,t.properties[i]);if(s){const[o,a]=s;e.tableCellAlignToStyle&&o==="align"&&typeof a=="string"&&gA.has(t.tagName)?r=a:n[o]=a}}if(r){const s=n.style||(n.style={});s[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function EA(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const s=r.data.estree.body[0];s.type;const o=s.expression;o.type;const a=o.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else el(e,t.position);else{const i=r.name;let s;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const a=r.value.data.estree.body[0];a.type,s=e.evaluater.evaluateExpression(a.expression)}else el(e,t.position);else s=r.value===null?!0:r.value;n[i]=s}return n}function km(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:hA;for(;++r<t.children.length;){const s=t.children[r];let o;if(e.passKeys){const l=s.type==="element"?s.tagName:s.type==="mdxJsxFlowElement"||s.type==="mdxJsxTextElement"?s.name:void 0;if(l){const u=i.get(l)||0;o=l+"-"+u,i.set(l,u+1)}}const a=dS(e,s,o);a!==void 0&&n.push(a)}return n}function PA(e,t,n){const r=RR(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?bR(n):OR(n)),r.property==="style"){let i=typeof n=="object"?n:NA(e,String(n));return e.stylePropertyNameCase==="css"&&(i=jA(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?jR[r.property]||r.property:r.attribute,n]}}function NA(e,t){try{return cA(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,i=new jt("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=e.filePath||void 0,i.url=cS+"#cannot-parse-style-attribute",i}}function fS(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const i=t.split(".");let s=-1,o;for(;++s<i.length;){const a=zy(i[s])?{type:"Identifier",name:i[s]}:{type:"Literal",value:i[s]};o=o?{type:"MemberExpression",object:o,property:a,computed:!!(s&&a.type==="Literal"),optional:!1}:a}r=o}else r=zy(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const i=r.value;return _m.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);el(e)}function el(e,t){const n=new jt("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=cS+"#cannot-handle-mdx-estrees-without-createevaluater",n}function jA(e){const t={};let n;for(n in e)_m.call(e,n)&&(t[TA(n)]=e[n]);return t}function TA(e){let t=e.replace(fA,MA);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function MA(e){return"-"+e.toLowerCase()}const _h={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},RA={};function Sm(e,t){const n=RA,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return pS(e,r,i)}function pS(e,t,n){if(AA(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return Jy(e.children,t,n)}return Array.isArray(e)?Jy(e,t,n):""}function Jy(e,t,n){const r=[];let i=-1;for(;++i<e.length;)r[i]=pS(e[i],t,n);return r.join("")}function AA(e){return!!(e&&typeof e=="object")}const Qy=document.createElement("i");function Cm(e){const t="&"+e+";";Qy.innerHTML=t;const n=Qy.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function ln(e,t,n,r){const i=e.length;let s=0,o;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);s<r.length;)o=r.slice(s,s+1e4),o.unshift(t,0),e.splice(...o),s+=1e4,t+=1e4}function yn(e,t){return e.length>0?(ln(e,e.length,0,t),e):t}const Zy={}.hasOwnProperty;function gS(e){const t={};let n=-1;for(;++n<e.length;)DA(t,e[n]);return t}function DA(e,t){let n;for(n in t){const i=(Zy.call(e,n)?e[n]:void 0)||(e[n]={}),s=t[n];let o;if(s)for(o in s){Zy.call(i,o)||(i[o]=[]);const a=s[o];IA(i[o],Array.isArray(a)?a:a?[a]:[])}}}function IA(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);ln(e,0,0,r)}function mS(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function Ln(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Lt=mi(/[A-Za-z]/),Ct=mi(/[\dA-Za-z]/),OA=mi(/[#-'*+\--9=?A-Z^-~]/);function jc(e){return e!==null&&(e<32||e===127)}const Dp=mi(/\d/),LA=mi(/[\dA-Fa-f]/),FA=mi(/[!-/:-@[-`{-~]/);function se(e){return e!==null&&e<-2}function Me(e){return e!==null&&(e<0||e===32)}function pe(e){return e===-2||e===-1||e===32}const dd=mi(new RegExp("\\p{P}|\\p{S}","u")),Yi=mi(/\s/);function mi(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function go(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const s=e.charCodeAt(n);let o="";if(s===37&&Ct(e.charCodeAt(n+1))&&Ct(e.charCodeAt(n+2)))i=2;else if(s<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(s))||(o=String.fromCharCode(s));else if(s>55295&&s<57344){const a=e.charCodeAt(n+1);s<56320&&a>56319&&a<57344?(o=String.fromCharCode(s,a),i=1):o="�"}else o=String.fromCharCode(s);o&&(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,o=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function be(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let s=0;return o;function o(l){return pe(l)?(e.enter(n),a(l)):t(l)}function a(l){return pe(l)&&s++<i?(e.consume(l),a):(e.exit(n),t(l))}}const $A={tokenize:zA};function zA(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(a){if(a===null){e.consume(a);return}return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),be(e,t,"linePrefix")}function i(a){return e.enter("paragraph"),s(a)}function s(a){const l=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=l),n=l,o(a)}function o(a){if(a===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(a);return}return se(a)?(e.consume(a),e.exit("chunkText"),s):(e.consume(a),o)}}const BA={tokenize:HA},e0={tokenize:WA};function HA(e){const t=this,n=[];let r=0,i,s,o;return a;function a(b){if(r<n.length){const k=n[r];return t.containerState=k[1],e.attempt(k[0].continuation,l,u)(b)}return u(b)}function l(b){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&x();const k=t.events.length;let w=k,_;for(;w--;)if(t.events[w][0]==="exit"&&t.events[w][1].type==="chunkFlow"){_=t.events[w][1].end;break}v(r);let P=k;for(;P<t.events.length;)t.events[P][1].end={..._},P++;return ln(t.events,w+1,0,t.events.slice(k)),t.events.length=P,u(b)}return a(b)}function u(b){if(r===n.length){if(!i)return h(b);if(i.currentConstruct&&i.currentConstruct.concrete)return g(b);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(e0,c,d)(b)}function c(b){return i&&x(),v(r),h(b)}function d(b){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,g(b)}function h(b){return t.containerState={},e.attempt(e0,p,g)(b)}function p(b){return r++,n.push([t.currentConstruct,t.containerState]),h(b)}function g(b){if(b===null){i&&x(),v(0),e.consume(b);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:s}),m(b)}function m(b){if(b===null){y(e.exit("chunkFlow"),!0),v(0),e.consume(b);return}return se(b)?(e.consume(b),y(e.exit("chunkFlow")),r=0,t.interrupt=void 0,a):(e.consume(b),m)}function y(b,k){const w=t.sliceStream(b);if(k&&w.push(null),b.previous=s,s&&(s.next=b),s=b,i.defineSkip(b.start),i.write(w),t.parser.lazy[b.start.line]){let _=i.events.length;for(;_--;)if(i.events[_][1].start.offset<o&&(!i.events[_][1].end||i.events[_][1].end.offset>o))return;const P=t.events.length;let E=P,T,S;for(;E--;)if(t.events[E][0]==="exit"&&t.events[E][1].type==="chunkFlow"){if(T){S=t.events[E][1].end;break}T=!0}for(v(r),_=P;_<t.events.length;)t.events[_][1].end={...S},_++;ln(t.events,E+1,0,t.events.slice(P)),t.events.length=_}}function v(b){let k=n.length;for(;k-- >b;){const w=n[k];t.containerState=w[1],w[0].exit.call(t,e)}n.length=b}function x(){i.write([null]),s=void 0,i=void 0,t.containerState._closeFlow=void 0}}function WA(e,t,n){return be(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function io(e){if(e===null||Me(e)||Yi(e))return 1;if(dd(e))return 2}function hd(e,t,n){const r=[];let i=-1;for(;++i<e.length;){const s=e[i].resolveAll;s&&!r.includes(s)&&(t=s(t,n),r.push(s))}return t}const Ip={name:"attention",resolveAll:VA,tokenize:UA};function VA(e,t){let n=-1,r,i,s,o,a,l,u,c;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;l=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const d={...e[r][1].end},h={...e[n][1].start};t0(d,-l),t0(h,l),o={type:l>1?"strongSequence":"emphasisSequence",start:d,end:{...e[r][1].end}},a={type:l>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:h},s={type:l>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:l>1?"strong":"emphasis",start:{...o.start},end:{...a.end}},e[r][1].end={...o.start},e[n][1].start={...a.end},u=[],e[r][1].end.offset-e[r][1].start.offset&&(u=yn(u,[["enter",e[r][1],t],["exit",e[r][1],t]])),u=yn(u,[["enter",i,t],["enter",o,t],["exit",o,t],["enter",s,t]]),u=yn(u,hd(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),u=yn(u,[["exit",s,t],["enter",a,t],["exit",a,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(c=2,u=yn(u,[["enter",e[n][1],t],["exit",e[n][1],t]])):c=0,ln(e,r-1,n-r+3,u),n=r+u.length-c-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function UA(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=io(r);let s;return o;function o(l){return s=l,e.enter("attentionSequence"),a(l)}function a(l){if(l===s)return e.consume(l),a;const u=e.exit("attentionSequence"),c=io(l),d=!c||c===2&&i||n.includes(l),h=!i||i===2&&c||n.includes(r);return u._open=!!(s===42?d:d&&(i||!h)),u._close=!!(s===42?h:h&&(c||!d)),t(l)}}function t0(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const qA={name:"autolink",tokenize:GA};function GA(e,t,n){let r=0;return i;function i(p){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),s}function s(p){return Lt(p)?(e.consume(p),o):p===64?n(p):u(p)}function o(p){return p===43||p===45||p===46||Ct(p)?(r=1,a(p)):u(p)}function a(p){return p===58?(e.consume(p),r=0,l):(p===43||p===45||p===46||Ct(p))&&r++<32?(e.consume(p),a):(r=0,u(p))}function l(p){return p===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):p===null||p===32||p===60||jc(p)?n(p):(e.consume(p),l)}function u(p){return p===64?(e.consume(p),c):OA(p)?(e.consume(p),u):n(p)}function c(p){return Ct(p)?d(p):n(p)}function d(p){return p===46?(e.consume(p),r=0,c):p===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):h(p)}function h(p){if((p===45||Ct(p))&&r++<63){const g=p===45?h:d;return e.consume(p),g}return n(p)}}const ml={partial:!0,tokenize:KA};function KA(e,t,n){return r;function r(s){return pe(s)?be(e,i,"linePrefix")(s):i(s)}function i(s){return s===null||se(s)?t(s):n(s)}}const vS={continuation:{tokenize:XA},exit:JA,name:"blockQuote",tokenize:YA};function YA(e,t,n){const r=this;return i;function i(o){if(o===62){const a=r.containerState;return a.open||(e.enter("blockQuote",{_container:!0}),a.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(o),e.exit("blockQuoteMarker"),s}return n(o)}function s(o){return pe(o)?(e.enter("blockQuotePrefixWhitespace"),e.consume(o),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(o))}}function XA(e,t,n){const r=this;return i;function i(o){return pe(o)?be(e,s,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o):s(o)}function s(o){return e.attempt(vS,t,n)(o)}}function JA(e){e.exit("blockQuote")}const xS={name:"characterEscape",tokenize:QA};function QA(e,t,n){return r;function r(s){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(s),e.exit("escapeMarker"),i}function i(s){return FA(s)?(e.enter("characterEscapeValue"),e.consume(s),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(s)}}const yS={name:"characterReference",tokenize:ZA};function ZA(e,t,n){const r=this;let i=0,s,o;return a;function a(d){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(d),e.exit("characterReferenceMarker"),l}function l(d){return d===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(d),e.exit("characterReferenceMarkerNumeric"),u):(e.enter("characterReferenceValue"),s=31,o=Ct,c(d))}function u(d){return d===88||d===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(d),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),s=6,o=LA,c):(e.enter("characterReferenceValue"),s=7,o=Dp,c(d))}function c(d){if(d===59&&i){const h=e.exit("characterReferenceValue");return o===Ct&&!Cm(r.sliceSerialize(h))?n(d):(e.enter("characterReferenceMarker"),e.consume(d),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return o(d)&&i++<s?(e.consume(d),c):n(d)}}const n0={partial:!0,tokenize:tD},r0={concrete:!0,name:"codeFenced",tokenize:eD};function eD(e,t,n){const r=this,i={partial:!0,tokenize:w};let s=0,o=0,a;return l;function l(_){return u(_)}function u(_){const P=r.events[r.events.length-1];return s=P&&P[1].type==="linePrefix"?P[2].sliceSerialize(P[1],!0).length:0,a=_,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),c(_)}function c(_){return _===a?(o++,e.consume(_),c):o<3?n(_):(e.exit("codeFencedFenceSequence"),pe(_)?be(e,d,"whitespace")(_):d(_))}function d(_){return _===null||se(_)?(e.exit("codeFencedFence"),r.interrupt?t(_):e.check(n0,m,k)(_)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),h(_))}function h(_){return _===null||se(_)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),d(_)):pe(_)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),be(e,p,"whitespace")(_)):_===96&&_===a?n(_):(e.consume(_),h)}function p(_){return _===null||se(_)?d(_):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),g(_))}function g(_){return _===null||se(_)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),d(_)):_===96&&_===a?n(_):(e.consume(_),g)}function m(_){return e.attempt(i,k,y)(_)}function y(_){return e.enter("lineEnding"),e.consume(_),e.exit("lineEnding"),v}function v(_){return s>0&&pe(_)?be(e,x,"linePrefix",s+1)(_):x(_)}function x(_){return _===null||se(_)?e.check(n0,m,k)(_):(e.enter("codeFlowValue"),b(_))}function b(_){return _===null||se(_)?(e.exit("codeFlowValue"),x(_)):(e.consume(_),b)}function k(_){return e.exit("codeFenced"),t(_)}function w(_,P,E){let T=0;return S;function S(F){return _.enter("lineEnding"),_.consume(F),_.exit("lineEnding"),M}function M(F){return _.enter("codeFencedFence"),pe(F)?be(_,R,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(F):R(F)}function R(F){return F===a?(_.enter("codeFencedFenceSequence"),$(F)):E(F)}function $(F){return F===a?(T++,_.consume(F),$):T>=o?(_.exit("codeFencedFenceSequence"),pe(F)?be(_,H,"whitespace")(F):H(F)):E(F)}function H(F){return F===null||se(F)?(_.exit("codeFencedFence"),P(F)):E(F)}}}function tD(e,t,n){const r=this;return i;function i(o){return o===null?n(o):(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),s)}function s(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}const wh={name:"codeIndented",tokenize:rD},nD={partial:!0,tokenize:iD};function rD(e,t,n){const r=this;return i;function i(u){return e.enter("codeIndented"),be(e,s,"linePrefix",5)(u)}function s(u){const c=r.events[r.events.length-1];return c&&c[1].type==="linePrefix"&&c[2].sliceSerialize(c[1],!0).length>=4?o(u):n(u)}function o(u){return u===null?l(u):se(u)?e.attempt(nD,o,l)(u):(e.enter("codeFlowValue"),a(u))}function a(u){return u===null||se(u)?(e.exit("codeFlowValue"),o(u)):(e.consume(u),a)}function l(u){return e.exit("codeIndented"),t(u)}}function iD(e,t,n){const r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):se(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),i):be(e,s,"linePrefix",5)(o)}function s(o){const a=r.events[r.events.length-1];return a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?t(o):se(o)?i(o):n(o)}}const sD={name:"codeText",previous:aD,resolve:oD,tokenize:lD};function oD(e){let t=e.length-4,n=3,r,i;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(i=r):(r===t||e[r][1].type==="lineEnding")&&(e[i][1].type="codeTextData",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function aD(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function lD(e,t,n){let r=0,i,s;return o;function o(d){return e.enter("codeText"),e.enter("codeTextSequence"),a(d)}function a(d){return d===96?(e.consume(d),r++,a):(e.exit("codeTextSequence"),l(d))}function l(d){return d===null?n(d):d===32?(e.enter("space"),e.consume(d),e.exit("space"),l):d===96?(s=e.enter("codeTextSequence"),i=0,c(d)):se(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),l):(e.enter("codeTextData"),u(d))}function u(d){return d===null||d===32||d===96||se(d)?(e.exit("codeTextData"),l(d)):(e.consume(d),u)}function c(d){return d===96?(e.consume(d),i++,c):i===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(d)):(s.type="codeTextData",u(d))}}class uD{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const i=n||0;this.setCursor(Math.trunc(t));const s=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&Oo(this.left,r),s.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),Oo(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Oo(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);Oo(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Oo(this.left,n.reverse())}}}function Oo(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function bS(e){const t={};let n=-1,r,i,s,o,a,l,u;const c=new uD(e);for(;++n<c.length;){for(;n in t;)n=t[n];if(r=c.get(n),n&&r[1].type==="chunkFlow"&&c.get(n-1)[1].type==="listItemPrefix"&&(l=r[1]._tokenizer.events,s=0,s<l.length&&l[s][1].type==="lineEndingBlank"&&(s+=2),s<l.length&&l[s][1].type==="content"))for(;++s<l.length&&l[s][1].type!=="content";)l[s][1].type==="chunkText"&&(l[s][1]._isInFirstContentOfListItem=!0,s++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,cD(c,n)),n=t[n],u=!0);else if(r[1]._container){for(s=n,i=void 0;s--;)if(o=c.get(s),o[1].type==="lineEnding"||o[1].type==="lineEndingBlank")o[0]==="enter"&&(i&&(c.get(i)[1].type="lineEndingBlank"),o[1].type="lineEnding",i=s);else if(!(o[1].type==="linePrefix"||o[1].type==="listItemIndent"))break;i&&(r[1].end={...c.get(i)[1].start},a=c.slice(i,n),a.unshift(r),c.splice(i,n-i+1,a))}}return ln(e,0,Number.POSITIVE_INFINITY,c.slice(0)),!u}function cD(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const s=[];let o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));const a=o.events,l=[],u={};let c,d,h=-1,p=n,g=0,m=0;const y=[m];for(;p;){for(;e.get(++i)[1]!==p;);s.push(i),p._tokenizer||(c=r.sliceStream(p),p.next||c.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(c),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++h<a.length;)a[h][0]==="exit"&&a[h-1][0]==="enter"&&a[h][1].type===a[h-1][1].type&&a[h][1].start.line!==a[h][1].end.line&&(m=h+1,y.push(m),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):y.pop(),h=y.length;h--;){const v=a.slice(y[h],y[h+1]),x=s.pop();l.push([x,x+v.length-1]),e.splice(x,2,v)}for(l.reverse(),h=-1;++h<l.length;)u[g+l[h][0]]=g+l[h][1],g+=l[h][1]-l[h][0]-1;return u}const dD={resolve:fD,tokenize:pD},hD={partial:!0,tokenize:gD};function fD(e){return bS(e),e}function pD(e,t){let n;return r;function r(a){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),i(a)}function i(a){return a===null?s(a):se(a)?e.check(hD,o,s)(a):(e.consume(a),i)}function s(a){return e.exit("chunkContent"),e.exit("content"),t(a)}function o(a){return e.consume(a),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,i}}function gD(e,t,n){const r=this;return i;function i(o){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),be(e,s,"linePrefix")}function s(o){if(o===null||se(o))return n(o);const a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?t(o):e.interrupt(r.parser.constructs.flow,n,t)(o)}}function _S(e,t,n,r,i,s,o,a,l){const u=l||Number.POSITIVE_INFINITY;let c=0;return d;function d(v){return v===60?(e.enter(r),e.enter(i),e.enter(s),e.consume(v),e.exit(s),h):v===null||v===32||v===41||jc(v)?n(v):(e.enter(r),e.enter(o),e.enter(a),e.enter("chunkString",{contentType:"string"}),m(v))}function h(v){return v===62?(e.enter(s),e.consume(v),e.exit(s),e.exit(i),e.exit(r),t):(e.enter(a),e.enter("chunkString",{contentType:"string"}),p(v))}function p(v){return v===62?(e.exit("chunkString"),e.exit(a),h(v)):v===null||v===60||se(v)?n(v):(e.consume(v),v===92?g:p)}function g(v){return v===60||v===62||v===92?(e.consume(v),p):p(v)}function m(v){return!c&&(v===null||v===41||Me(v))?(e.exit("chunkString"),e.exit(a),e.exit(o),e.exit(r),t(v)):c<u&&v===40?(e.consume(v),c++,m):v===41?(e.consume(v),c--,m):v===null||v===32||v===40||jc(v)?n(v):(e.consume(v),v===92?y:m)}function y(v){return v===40||v===41||v===92?(e.consume(v),m):m(v)}}function wS(e,t,n,r,i,s){const o=this;let a=0,l;return u;function u(p){return e.enter(r),e.enter(i),e.consume(p),e.exit(i),e.enter(s),c}function c(p){return a>999||p===null||p===91||p===93&&!l||p===94&&!a&&"_hiddenFootnoteSupport"in o.parser.constructs?n(p):p===93?(e.exit(s),e.enter(i),e.consume(p),e.exit(i),e.exit(r),t):se(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),c):(e.enter("chunkString",{contentType:"string"}),d(p))}function d(p){return p===null||p===91||p===93||se(p)||a++>999?(e.exit("chunkString"),c(p)):(e.consume(p),l||(l=!pe(p)),p===92?h:d)}function h(p){return p===91||p===92||p===93?(e.consume(p),a++,d):d(p)}}function kS(e,t,n,r,i,s){let o;return a;function a(h){return h===34||h===39||h===40?(e.enter(r),e.enter(i),e.consume(h),e.exit(i),o=h===40?41:h,l):n(h)}function l(h){return h===o?(e.enter(i),e.consume(h),e.exit(i),e.exit(r),t):(e.enter(s),u(h))}function u(h){return h===o?(e.exit(s),l(o)):h===null?n(h):se(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),be(e,u,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),c(h))}function c(h){return h===o||h===null||se(h)?(e.exit("chunkString"),u(h)):(e.consume(h),h===92?d:c)}function d(h){return h===o||h===92?(e.consume(h),c):c(h)}}function _a(e,t){let n;return r;function r(i){return se(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):pe(i)?be(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const mD={name:"definition",tokenize:xD},vD={partial:!0,tokenize:yD};function xD(e,t,n){const r=this;let i;return s;function s(p){return e.enter("definition"),o(p)}function o(p){return wS.call(r,e,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(p)}function a(p){return i=Ln(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),p===58?(e.enter("definitionMarker"),e.consume(p),e.exit("definitionMarker"),l):n(p)}function l(p){return Me(p)?_a(e,u)(p):u(p)}function u(p){return _S(e,c,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(p)}function c(p){return e.attempt(vD,d,d)(p)}function d(p){return pe(p)?be(e,h,"whitespace")(p):h(p)}function h(p){return p===null||se(p)?(e.exit("definition"),r.parser.defined.push(i),t(p)):n(p)}}function yD(e,t,n){return r;function r(a){return Me(a)?_a(e,i)(a):n(a)}function i(a){return kS(e,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function s(a){return pe(a)?be(e,o,"whitespace")(a):o(a)}function o(a){return a===null||se(a)?t(a):n(a)}}const bD={name:"hardBreakEscape",tokenize:_D};function _D(e,t,n){return r;function r(s){return e.enter("hardBreakEscape"),e.consume(s),i}function i(s){return se(s)?(e.exit("hardBreakEscape"),t(s)):n(s)}}const wD={name:"headingAtx",resolve:kD,tokenize:SD};function kD(e,t){let n=e.length-2,r=3,i,s;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(i={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},s={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},ln(e,r,n-r+1,[["enter",i,t],["enter",s,t],["exit",s,t],["exit",i,t]])),e}function SD(e,t,n){let r=0;return i;function i(c){return e.enter("atxHeading"),s(c)}function s(c){return e.enter("atxHeadingSequence"),o(c)}function o(c){return c===35&&r++<6?(e.consume(c),o):c===null||Me(c)?(e.exit("atxHeadingSequence"),a(c)):n(c)}function a(c){return c===35?(e.enter("atxHeadingSequence"),l(c)):c===null||se(c)?(e.exit("atxHeading"),t(c)):pe(c)?be(e,a,"whitespace")(c):(e.enter("atxHeadingText"),u(c))}function l(c){return c===35?(e.consume(c),l):(e.exit("atxHeadingSequence"),a(c))}function u(c){return c===null||c===35||Me(c)?(e.exit("atxHeadingText"),a(c)):(e.consume(c),u)}}const CD=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],i0=["pre","script","style","textarea"],ED={concrete:!0,name:"htmlFlow",resolveTo:jD,tokenize:TD},PD={partial:!0,tokenize:RD},ND={partial:!0,tokenize:MD};function jD(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function TD(e,t,n){const r=this;let i,s,o,a,l;return u;function u(j){return c(j)}function c(j){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(j),d}function d(j){return j===33?(e.consume(j),h):j===47?(e.consume(j),s=!0,m):j===63?(e.consume(j),i=3,r.interrupt?t:C):Lt(j)?(e.consume(j),o=String.fromCharCode(j),y):n(j)}function h(j){return j===45?(e.consume(j),i=2,p):j===91?(e.consume(j),i=5,a=0,g):Lt(j)?(e.consume(j),i=4,r.interrupt?t:C):n(j)}function p(j){return j===45?(e.consume(j),r.interrupt?t:C):n(j)}function g(j){const ie="CDATA[";return j===ie.charCodeAt(a++)?(e.consume(j),a===ie.length?r.interrupt?t:R:g):n(j)}function m(j){return Lt(j)?(e.consume(j),o=String.fromCharCode(j),y):n(j)}function y(j){if(j===null||j===47||j===62||Me(j)){const ie=j===47,A=o.toLowerCase();return!ie&&!s&&i0.includes(A)?(i=1,r.interrupt?t(j):R(j)):CD.includes(o.toLowerCase())?(i=6,ie?(e.consume(j),v):r.interrupt?t(j):R(j)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(j):s?x(j):b(j))}return j===45||Ct(j)?(e.consume(j),o+=String.fromCharCode(j),y):n(j)}function v(j){return j===62?(e.consume(j),r.interrupt?t:R):n(j)}function x(j){return pe(j)?(e.consume(j),x):S(j)}function b(j){return j===47?(e.consume(j),S):j===58||j===95||Lt(j)?(e.consume(j),k):pe(j)?(e.consume(j),b):S(j)}function k(j){return j===45||j===46||j===58||j===95||Ct(j)?(e.consume(j),k):w(j)}function w(j){return j===61?(e.consume(j),_):pe(j)?(e.consume(j),w):b(j)}function _(j){return j===null||j===60||j===61||j===62||j===96?n(j):j===34||j===39?(e.consume(j),l=j,P):pe(j)?(e.consume(j),_):E(j)}function P(j){return j===l?(e.consume(j),l=null,T):j===null||se(j)?n(j):(e.consume(j),P)}function E(j){return j===null||j===34||j===39||j===47||j===60||j===61||j===62||j===96||Me(j)?w(j):(e.consume(j),E)}function T(j){return j===47||j===62||pe(j)?b(j):n(j)}function S(j){return j===62?(e.consume(j),M):n(j)}function M(j){return j===null||se(j)?R(j):pe(j)?(e.consume(j),M):n(j)}function R(j){return j===45&&i===2?(e.consume(j),X):j===60&&i===1?(e.consume(j),Z):j===62&&i===4?(e.consume(j),ee):j===63&&i===3?(e.consume(j),C):j===93&&i===5?(e.consume(j),z):se(j)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(PD,ne,$)(j)):j===null||se(j)?(e.exit("htmlFlowData"),$(j)):(e.consume(j),R)}function $(j){return e.check(ND,H,ne)(j)}function H(j){return e.enter("lineEnding"),e.consume(j),e.exit("lineEnding"),F}function F(j){return j===null||se(j)?$(j):(e.enter("htmlFlowData"),R(j))}function X(j){return j===45?(e.consume(j),C):R(j)}function Z(j){return j===47?(e.consume(j),o="",I):R(j)}function I(j){if(j===62){const ie=o.toLowerCase();return i0.includes(ie)?(e.consume(j),ee):R(j)}return Lt(j)&&o.length<8?(e.consume(j),o+=String.fromCharCode(j),I):R(j)}function z(j){return j===93?(e.consume(j),C):R(j)}function C(j){return j===62?(e.consume(j),ee):j===45&&i===2?(e.consume(j),C):R(j)}function ee(j){return j===null||se(j)?(e.exit("htmlFlowData"),ne(j)):(e.consume(j),ee)}function ne(j){return e.exit("htmlFlow"),t(j)}}function MD(e,t,n){const r=this;return i;function i(o){return se(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),s):n(o)}function s(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}function RD(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(ml,t,n)}}const AD={name:"htmlText",tokenize:DD};function DD(e,t,n){const r=this;let i,s,o;return a;function a(C){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(C),l}function l(C){return C===33?(e.consume(C),u):C===47?(e.consume(C),w):C===63?(e.consume(C),b):Lt(C)?(e.consume(C),E):n(C)}function u(C){return C===45?(e.consume(C),c):C===91?(e.consume(C),s=0,g):Lt(C)?(e.consume(C),x):n(C)}function c(C){return C===45?(e.consume(C),p):n(C)}function d(C){return C===null?n(C):C===45?(e.consume(C),h):se(C)?(o=d,Z(C)):(e.consume(C),d)}function h(C){return C===45?(e.consume(C),p):d(C)}function p(C){return C===62?X(C):C===45?h(C):d(C)}function g(C){const ee="CDATA[";return C===ee.charCodeAt(s++)?(e.consume(C),s===ee.length?m:g):n(C)}function m(C){return C===null?n(C):C===93?(e.consume(C),y):se(C)?(o=m,Z(C)):(e.consume(C),m)}function y(C){return C===93?(e.consume(C),v):m(C)}function v(C){return C===62?X(C):C===93?(e.consume(C),v):m(C)}function x(C){return C===null||C===62?X(C):se(C)?(o=x,Z(C)):(e.consume(C),x)}function b(C){return C===null?n(C):C===63?(e.consume(C),k):se(C)?(o=b,Z(C)):(e.consume(C),b)}function k(C){return C===62?X(C):b(C)}function w(C){return Lt(C)?(e.consume(C),_):n(C)}function _(C){return C===45||Ct(C)?(e.consume(C),_):P(C)}function P(C){return se(C)?(o=P,Z(C)):pe(C)?(e.consume(C),P):X(C)}function E(C){return C===45||Ct(C)?(e.consume(C),E):C===47||C===62||Me(C)?T(C):n(C)}function T(C){return C===47?(e.consume(C),X):C===58||C===95||Lt(C)?(e.consume(C),S):se(C)?(o=T,Z(C)):pe(C)?(e.consume(C),T):X(C)}function S(C){return C===45||C===46||C===58||C===95||Ct(C)?(e.consume(C),S):M(C)}function M(C){return C===61?(e.consume(C),R):se(C)?(o=M,Z(C)):pe(C)?(e.consume(C),M):T(C)}function R(C){return C===null||C===60||C===61||C===62||C===96?n(C):C===34||C===39?(e.consume(C),i=C,$):se(C)?(o=R,Z(C)):pe(C)?(e.consume(C),R):(e.consume(C),H)}function $(C){return C===i?(e.consume(C),i=void 0,F):C===null?n(C):se(C)?(o=$,Z(C)):(e.consume(C),$)}function H(C){return C===null||C===34||C===39||C===60||C===61||C===96?n(C):C===47||C===62||Me(C)?T(C):(e.consume(C),H)}function F(C){return C===47||C===62||Me(C)?T(C):n(C)}function X(C){return C===62?(e.consume(C),e.exit("htmlTextData"),e.exit("htmlText"),t):n(C)}function Z(C){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(C),e.exit("lineEnding"),I}function I(C){return pe(C)?be(e,z,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(C):z(C)}function z(C){return e.enter("htmlTextData"),o(C)}}const Em={name:"labelEnd",resolveAll:FD,resolveTo:$D,tokenize:zD},ID={tokenize:BD},OD={tokenize:HD},LD={tokenize:WD};function FD(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const i=r.type==="labelImage"?4:2;r.type="data",t+=i}}return e.length!==n.length&&ln(e,0,e.length,n),e}function $D(e,t){let n=e.length,r=0,i,s,o,a;for(;n--;)if(i=e[n][1],s){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;e[n][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(o){if(e[n][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(s=n,i.type!=="labelLink")){r=2;break}}else i.type==="labelEnd"&&(o=n);const l={type:e[s][1].type==="labelLink"?"link":"image",start:{...e[s][1].start},end:{...e[e.length-1][1].end}},u={type:"label",start:{...e[s][1].start},end:{...e[o][1].end}},c={type:"labelText",start:{...e[s+r+2][1].end},end:{...e[o-2][1].start}};return a=[["enter",l,t],["enter",u,t]],a=yn(a,e.slice(s+1,s+r+3)),a=yn(a,[["enter",c,t]]),a=yn(a,hd(t.parser.constructs.insideSpan.null,e.slice(s+r+4,o-3),t)),a=yn(a,[["exit",c,t],e[o-2],e[o-1],["exit",u,t]]),a=yn(a,e.slice(o+1)),a=yn(a,[["exit",l,t]]),ln(e,s,e.length,a),e}function zD(e,t,n){const r=this;let i=r.events.length,s,o;for(;i--;)if((r.events[i][1].type==="labelImage"||r.events[i][1].type==="labelLink")&&!r.events[i][1]._balanced){s=r.events[i][1];break}return a;function a(h){return s?s._inactive?d(h):(o=r.parser.defined.includes(Ln(r.sliceSerialize({start:s.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(h),e.exit("labelMarker"),e.exit("labelEnd"),l):n(h)}function l(h){return h===40?e.attempt(ID,c,o?c:d)(h):h===91?e.attempt(OD,c,o?u:d)(h):o?c(h):d(h)}function u(h){return e.attempt(LD,c,d)(h)}function c(h){return t(h)}function d(h){return s._balanced=!0,n(h)}}function BD(e,t,n){return r;function r(d){return e.enter("resource"),e.enter("resourceMarker"),e.consume(d),e.exit("resourceMarker"),i}function i(d){return Me(d)?_a(e,s)(d):s(d)}function s(d){return d===41?c(d):_S(e,o,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(d)}function o(d){return Me(d)?_a(e,l)(d):c(d)}function a(d){return n(d)}function l(d){return d===34||d===39||d===40?kS(e,u,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(d):c(d)}function u(d){return Me(d)?_a(e,c)(d):c(d)}function c(d){return d===41?(e.enter("resourceMarker"),e.consume(d),e.exit("resourceMarker"),e.exit("resource"),t):n(d)}}function HD(e,t,n){const r=this;return i;function i(a){return wS.call(r,e,s,o,"reference","referenceMarker","referenceString")(a)}function s(a){return r.parser.defined.includes(Ln(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(a):n(a)}function o(a){return n(a)}}function WD(e,t,n){return r;function r(s){return e.enter("reference"),e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),i}function i(s){return s===93?(e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),e.exit("reference"),t):n(s)}}const VD={name:"labelStartImage",resolveAll:Em.resolveAll,tokenize:UD};function UD(e,t,n){const r=this;return i;function i(a){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(a),e.exit("labelImageMarker"),s}function s(a){return a===91?(e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelImage"),o):n(a)}function o(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}const qD={name:"labelStartLink",resolveAll:Em.resolveAll,tokenize:GD};function GD(e,t,n){const r=this;return i;function i(o){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(o),e.exit("labelMarker"),e.exit("labelLink"),s}function s(o){return o===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(o):t(o)}}const kh={name:"lineEnding",tokenize:KD};function KD(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),be(e,t,"linePrefix")}}const Pu={name:"thematicBreak",tokenize:YD};function YD(e,t,n){let r=0,i;return s;function s(u){return e.enter("thematicBreak"),o(u)}function o(u){return i=u,a(u)}function a(u){return u===i?(e.enter("thematicBreakSequence"),l(u)):r>=3&&(u===null||se(u))?(e.exit("thematicBreak"),t(u)):n(u)}function l(u){return u===i?(e.consume(u),r++,l):(e.exit("thematicBreakSequence"),pe(u)?be(e,a,"whitespace")(u):a(u))}}const Ht={continuation:{tokenize:ZD},exit:tI,name:"list",tokenize:QD},XD={partial:!0,tokenize:nI},JD={partial:!0,tokenize:eI};function QD(e,t,n){const r=this,i=r.events[r.events.length-1];let s=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,o=0;return a;function a(p){const g=r.containerState.type||(p===42||p===43||p===45?"listUnordered":"listOrdered");if(g==="listUnordered"?!r.containerState.marker||p===r.containerState.marker:Dp(p)){if(r.containerState.type||(r.containerState.type=g,e.enter(g,{_container:!0})),g==="listUnordered")return e.enter("listItemPrefix"),p===42||p===45?e.check(Pu,n,u)(p):u(p);if(!r.interrupt||p===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),l(p)}return n(p)}function l(p){return Dp(p)&&++o<10?(e.consume(p),l):(!r.interrupt||o<2)&&(r.containerState.marker?p===r.containerState.marker:p===41||p===46)?(e.exit("listItemValue"),u(p)):n(p)}function u(p){return e.enter("listItemMarker"),e.consume(p),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||p,e.check(ml,r.interrupt?n:c,e.attempt(XD,h,d))}function c(p){return r.containerState.initialBlankLine=!0,s++,h(p)}function d(p){return pe(p)?(e.enter("listItemPrefixWhitespace"),e.consume(p),e.exit("listItemPrefixWhitespace"),h):n(p)}function h(p){return r.containerState.size=s+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(p)}}function ZD(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(ml,i,s);function i(a){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,be(e,t,"listItemIndent",r.containerState.size+1)(a)}function s(a){return r.containerState.furtherBlankLines||!pe(a)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(a)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(JD,t,o)(a))}function o(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,be(e,e.attempt(Ht,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function eI(e,t,n){const r=this;return be(e,i,"listItemIndent",r.containerState.size+1);function i(s){const o=r.events[r.events.length-1];return o&&o[1].type==="listItemIndent"&&o[2].sliceSerialize(o[1],!0).length===r.containerState.size?t(s):n(s)}}function tI(e){e.exit(this.containerState.type)}function nI(e,t,n){const r=this;return be(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(s){const o=r.events[r.events.length-1];return!pe(s)&&o&&o[1].type==="listItemPrefixWhitespace"?t(s):n(s)}}const s0={name:"setextUnderline",resolveTo:rI,tokenize:iI};function rI(e,t){let n=e.length,r,i,s;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(i=n)}else e[n][1].type==="content"&&e.splice(n,1),!s&&e[n][1].type==="definition"&&(s=n);const o={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type="setextHeadingText",s?(e.splice(i,0,["enter",o,t]),e.splice(s+1,0,["exit",e[r][1],t]),e[r][1].end={...e[s][1].end}):e[r][1]=o,e.push(["exit",o,t]),e}function iI(e,t,n){const r=this;let i;return s;function s(u){let c=r.events.length,d;for(;c--;)if(r.events[c][1].type!=="lineEnding"&&r.events[c][1].type!=="linePrefix"&&r.events[c][1].type!=="content"){d=r.events[c][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||d)?(e.enter("setextHeadingLine"),i=u,o(u)):n(u)}function o(u){return e.enter("setextHeadingLineSequence"),a(u)}function a(u){return u===i?(e.consume(u),a):(e.exit("setextHeadingLineSequence"),pe(u)?be(e,l,"lineSuffix")(u):l(u))}function l(u){return u===null||se(u)?(e.exit("setextHeadingLine"),t(u)):n(u)}}const sI={tokenize:oI};function oI(e){const t=this,n=e.attempt(ml,r,e.attempt(this.parser.constructs.flowInitial,i,be(e,e.attempt(this.parser.constructs.flow,i,e.attempt(dD,i)),"linePrefix")));return n;function r(s){if(s===null){e.consume(s);return}return e.enter("lineEndingBlank"),e.consume(s),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function i(s){if(s===null){e.consume(s);return}return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const aI={resolveAll:CS()},lI=SS("string"),uI=SS("text");function SS(e){return{resolveAll:CS(e==="text"?cI:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],s=n.attempt(i,o,a);return o;function o(c){return u(c)?s(c):a(c)}function a(c){if(c===null){n.consume(c);return}return n.enter("data"),n.consume(c),l}function l(c){return u(c)?(n.exit("data"),s(c)):(n.consume(c),l)}function u(c){if(c===null)return!0;const d=i[c];let h=-1;if(d)for(;++h<d.length;){const p=d[h];if(!p.previous||p.previous.call(r,r.previous))return!0}return!1}}}function CS(e){return t;function t(n,r){let i=-1,s;for(;++i<=n.length;)s===void 0?n[i]&&n[i][1].type==="data"&&(s=i,i++):(!n[i]||n[i][1].type!=="data")&&(i!==s+2&&(n[s][1].end=n[i-1][1].end,n.splice(s+2,i-s-2),i=s+2),s=void 0);return e?e(n,r):n}}function cI(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],i=t.sliceStream(r);let s=i.length,o=-1,a=0,l;for(;s--;){const u=i[s];if(typeof u=="string"){for(o=u.length;u.charCodeAt(o-1)===32;)a++,o--;if(o)break;o=-1}else if(u===-2)l=!0,a++;else if(u!==-1){s++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(a=0),a){const u={type:n===e.length||l||a<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:s?o:r.start._bufferIndex+o,_index:r.start._index+s,line:r.end.line,column:r.end.column-a,offset:r.end.offset-a},end:{...r.end}};r.end={...u.start},r.start.offset===r.end.offset?Object.assign(r,u):(e.splice(n,0,["enter",u,t],["exit",u,t]),n+=2)}n++}return e}const dI={42:Ht,43:Ht,45:Ht,48:Ht,49:Ht,50:Ht,51:Ht,52:Ht,53:Ht,54:Ht,55:Ht,56:Ht,57:Ht,62:vS},hI={91:mD},fI={[-2]:wh,[-1]:wh,32:wh},pI={35:wD,42:Pu,45:[s0,Pu],60:ED,61:s0,95:Pu,96:r0,126:r0},gI={38:yS,92:xS},mI={[-5]:kh,[-4]:kh,[-3]:kh,33:VD,38:yS,42:Ip,60:[qA,AD],91:qD,92:[bD,xS],93:Em,95:Ip,96:sD},vI={null:[Ip,aI]},xI={null:[42,95]},yI={null:[]},bI=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:xI,contentInitial:hI,disable:yI,document:dI,flow:pI,flowInitial:fI,insideSpan:vI,string:gI,text:mI},Symbol.toStringTag,{value:"Module"}));function _I(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},s=[];let o=[],a=[];const l={attempt:P(w),check:P(_),consume:x,enter:b,exit:k,interrupt:P(_,{interrupt:!0})},u={code:null,containerState:{},defineSkip:m,events:[],now:g,parser:e,previous:null,sliceSerialize:h,sliceStream:p,write:d};let c=t.tokenize.call(u,l);return t.resolveAll&&s.push(t),u;function d(M){return o=yn(o,M),y(),o[o.length-1]!==null?[]:(E(t,0),u.events=hd(s,u.events,u),u.events)}function h(M,R){return kI(p(M),R)}function p(M){return wI(o,M)}function g(){const{_bufferIndex:M,_index:R,line:$,column:H,offset:F}=r;return{_bufferIndex:M,_index:R,line:$,column:H,offset:F}}function m(M){i[M.line]=M.column,S()}function y(){let M;for(;r._index<o.length;){const R=o[r._index];if(typeof R=="string")for(M=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===M&&r._bufferIndex<R.length;)v(R.charCodeAt(r._bufferIndex));else v(R)}}function v(M){c=c(M)}function x(M){se(M)?(r.line++,r.column=1,r.offset+=M===-3?2:1,S()):M!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),u.previous=M}function b(M,R){const $=R||{};return $.type=M,$.start=g(),u.events.push(["enter",$,u]),a.push($),$}function k(M){const R=a.pop();return R.end=g(),u.events.push(["exit",R,u]),R}function w(M,R){E(M,R.from)}function _(M,R){R.restore()}function P(M,R){return $;function $(H,F,X){let Z,I,z,C;return Array.isArray(H)?ne(H):"tokenize"in H?ne([H]):ee(H);function ee(J){return O;function O(ae){const ke=ae!==null&&J[ae],U=ae!==null&&J.null,oe=[...Array.isArray(ke)?ke:ke?[ke]:[],...Array.isArray(U)?U:U?[U]:[]];return ne(oe)(ae)}}function ne(J){return Z=J,I=0,J.length===0?X:j(J[I])}function j(J){return O;function O(ae){return C=T(),z=J,J.partial||(u.currentConstruct=J),J.name&&u.parser.constructs.disable.null.includes(J.name)?A():J.tokenize.call(R?Object.assign(Object.create(u),R):u,l,ie,A)(ae)}}function ie(J){return M(z,C),F}function A(J){return C.restore(),++I<Z.length?j(Z[I]):X}}}function E(M,R){M.resolveAll&&!s.includes(M)&&s.push(M),M.resolve&&ln(u.events,R,u.events.length-R,M.resolve(u.events.slice(R),u)),M.resolveTo&&(u.events=M.resolveTo(u.events,u))}function T(){const M=g(),R=u.previous,$=u.currentConstruct,H=u.events.length,F=Array.from(a);return{from:H,restore:X};function X(){r=M,u.previous=R,u.currentConstruct=$,u.events.length=H,a=F,S()}}function S(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function wI(e,t){const n=t.start._index,r=t.start._bufferIndex,i=t.end._index,s=t.end._bufferIndex;let o;if(n===i)o=[e[n].slice(r,s)];else{if(o=e.slice(n,i),r>-1){const a=o[0];typeof a=="string"?o[0]=a.slice(r):o.shift()}s>0&&o.push(e[i].slice(0,s))}return o}function kI(e,t){let n=-1;const r=[];let i;for(;++n<e.length;){const s=e[n];let o;if(typeof s=="string")o=s;else switch(s){case-5:{o="\r";break}case-4:{o=`
|
|
@@ -154,4 +154,4 @@ ${Mt}`:Mt;_(null),g(is=>is.map(Tr=>Tr.id===he?{...Tr,isStreaming:!1,text:fn}:Tr)
|
|
|
154
154
|
prose-table:border-collapse prose-table:text-xs prose-table:w-full
|
|
155
155
|
prose-th:border prose-th:border-outline-variant/40 prose-th:px-2 prose-th:py-1 prose-th:bg-surface-dim prose-th:text-left prose-th:font-medium
|
|
156
156
|
prose-td:border prose-td:border-outline-variant/40 prose-td:px-2 prose-td:py-1`,children:f.jsx(Am,{remarkPlugins:[l$,d$],children:U.text})}):f.jsx(m6,{})})]},U.id)}),f.jsx("div",{ref:T})]}),w&&f.jsxs("div",{"data-testid":"pending-approval",className:"flex items-center gap-3 border-t border-amber-800/50 bg-amber-950/40 px-4 py-3",children:[f.jsx(Jh,{className:"h-5 w-5 text-warning flex-shrink-0 animate-pulse"}),f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsx("p",{className:"font-mono text-xs text-warning font-semibold",children:e("chat.waitingApproval")}),f.jsx("p",{className:"font-mono text-[11px] text-warning/80 mt-0.5",children:w.reason}),f.jsx("p",{className:"font-mono text-[10px] text-amber-500/60 mt-1",children:e("chat.respondInGuardian")})]})]}),f.jsxs("div",{className:"flex gap-2 border-t border-outline-variant/20 p-2 sm:p-3",children:[f.jsx("textarea",{className:"flex-1 min-w-0 rounded bg-surface-container-high px-3 py-2 text-sm text-on-surface placeholder-on-surface-variant outline-none focus:ring-1 focus:ring-primary/40 font-mono resize-none",placeholder:e("chat.messagePlaceholder",{name:d??(u==null?void 0:u.name)??e("chat.roleAgentFallback")}),value:m,onChange:U=>y(U.target.value),onKeyDown:U=>{U.key==="Enter"&&!U.shiftKey&&(U.preventDefault(),ie())},disabled:v,rows:Math.min(m.split(`
|
|
157
|
-
`).length,8),style:{minHeight:"2.5rem",maxHeight:"12rem",overflow:"auto"}}),v?f.jsx("button",{onClick:C,className:"rounded bg-red-500/20 px-4 py-2 text-sm font-medium text-red-400 transition-opacity hover:bg-red-500/30",children:e("chat.stop")}):f.jsx("button",{onClick:ie,disabled:!m.trim()||!z,className:"rounded bg-primary px-4 py-2 text-sm font-medium text-on-primary transition-opacity disabled:opacity-40 hover:opacity-90",children:e("chat.send")})]})]})]}),J&&a==="chat"&&f.jsxs("div",{"data-testid":"bb-panel",className:`hidden md:flex relative flex-shrink-0 flex-col rounded-lg bg-surface-container-lowest overflow-hidden transition-all duration-200 ${S?"w-96":"w-10"}`,children:[f.jsxs("div",{"data-testid":"guardian-coming-soon-overlay",className:"absolute inset-0 z-20 flex flex-col items-center justify-center bg-surface-container-lowest/90 backdrop-blur-sm rounded-lg",children:[f.jsx(Jh,{className:"h-12 w-12 text-warning/30 mb-4"}),S&&f.jsxs(f.Fragment,{children:[f.jsx("p",{className:"font-headline text-lg font-semibold text-on-surface tracking-tight mb-2",children:e("chat.guardian")}),f.jsx("span",{className:"rounded-full bg-warning/10 border border-warning/30 px-3 py-1 font-label text-[10px] font-semibold text-warning uppercase tracking-widest mb-4",children:e("chat.comingSoon")}),f.jsxs("p",{className:"max-w-[260px] text-center font-mono text-[10px] text-on-surface-variant/50 leading-relaxed px-4",children:[e("chat.guardianBlurb1")," ",e("chat.guardianBlurb2")]})]})]}),f.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 border-b border-outline-variant/20",children:[f.jsx(Jh,{className:"h-4 w-4 flex-shrink-0 text-on-surface-variant"}),S&&f.jsx(f.Fragment,{children:f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsx("p",{className:"font-headline text-xs font-semibold text-on-surface truncate",children:"Guardian"}),f.jsx("p",{className:"font-mono text-[9px] text-on-surface-variant",children:e("chat.guardianDisconnected")})]})})]}),S&&f.jsx("div",{className:"flex-1 overflow-hidden p-3 flex flex-col gap-2",children:f.jsx("p",{className:"font-mono text-[10px] text-on-surface-variant/20 m-auto text-center leading-relaxed",dangerouslySetInnerHTML:{__html:e("chat.guardianChatBlurb")}})})]})]})}const Ai="rounded bg-surface-container px-3 py-2 text-[12px] text-on-surface placeholder:text-on-surface-variant/60 outline-none focus:ring-1 focus:ring-primary/25 font-mono transition-shadow w-full",lE=Object.fromEntries(Qk.map(e=>[e.value,e.label]));function y6({entry:e}){const{t}=Ee();return f.jsxs("div",{className:"rounded-lg bg-surface-container-lowest border border-outline-variant/40 p-4",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{className:"font-mono text-[13px] text-on-surface font-semibold",children:e.label??e.provider}),f.jsx("span",{className:"font-mono text-[10px] text-on-surface-variant/70",children:e.model}),f.jsx("span",{className:"text-success text-[10px] font-mono",children:"✓"})]}),f.jsx("span",{className:"rounded px-2 py-0.5 text-[10px] font-mono bg-primary/10 text-primary",children:"managed"})]}),f.jsx("p",{className:"font-mono text-[10px] text-on-surface-variant/60 mt-2",children:t("settings.managedBlurb")})]})}function b6({entry:e,onRemove:t,onReplaceKey:n}){const{t:r}=Ee(),[i,s]=N.useState(!1),[o,a]=N.useState(e.model),[l,u]=N.useState(""),[c,d]=N.useState(!1),[h,p]=N.useState(null),[g,m]=N.useState(!1);async function y(){if(!l.trim()){p(r("common.apiKeyRequired"));return}d(!0),p(null),m(!1);try{await n(e.provider,o,l.trim()),m(!0),u(""),s(!1)}catch(v){p(v instanceof Error?v.message:r("common.errorSave"))}finally{d(!1)}}return f.jsxs("div",{className:"rounded-lg bg-surface-container-lowest border border-outline-variant/40 p-4 space-y-3",children:[f.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[f.jsxs("div",{className:"min-w-0",children:[f.jsx("span",{className:"font-mono text-[13px] text-on-surface font-semibold",children:lE[e.provider]??e.provider}),f.jsx("span",{className:"font-mono text-[10px] text-on-surface-variant/70 ml-2",children:e.model}),f.jsx("span",{className:"ml-2 text-success text-[10px] font-mono",children:"✓"})]}),f.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[!i&&f.jsx("button",{onClick:()=>{s(!0),m(!1)},className:"rounded px-2 py-1 text-[11px] font-mono text-on-surface-variant hover:text-on-surface bg-surface-container transition-colors",children:r("settings.replaceKey")}),f.jsx("button",{onClick:t,className:"rounded px-2 py-1 text-[11px] font-mono text-error/60 hover:text-error hover:bg-error/10 transition-colors",children:r("settings.delete")})]})]}),i&&f.jsxs("div",{className:"space-y-2 pt-1 border-t border-outline-variant/40",children:[f.jsxs("div",{children:[f.jsx("label",{className:"block text-[10px] uppercase tracking-[0.14em] text-on-surface-variant font-medium mb-1",children:r("settings.model")}),f.jsx("select",{className:`${Ai} appearance-none`,value:o,onChange:v=>a(v.target.value),children:ud(e.provider).map(v=>f.jsx("option",{value:v.value,children:v.label},v.value))})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-[10px] uppercase tracking-[0.14em] text-on-surface-variant font-medium mb-1",children:r("settings.newApiKey")}),f.jsx("input",{type:"password",className:Ai,placeholder:r("settings.pasteNewKey"),value:l,onChange:v=>{u(v.target.value),p(null)},autoComplete:"off",autoFocus:!0})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("button",{onClick:y,disabled:c,className:"rounded bg-primary px-3 py-1.5 text-[12px] font-medium text-on-primary transition-opacity disabled:opacity-40 hover:opacity-90",children:r(c?"common.saving":"common.save")}),f.jsx("button",{onClick:()=>{s(!1),u(""),p(null)},className:"rounded px-3 py-1.5 text-[12px] font-mono text-on-surface-variant hover:text-on-surface transition-colors",children:r("common.cancel")}),g&&f.jsx("span",{className:"font-mono text-[11px] text-success",children:r("common.saved")}),h&&f.jsx("span",{className:"font-mono text-[10px] text-error",children:h})]})]})]})}function _6(){const{t:e}=Ee(),t=ts(),[n,r]=N.useState(!0),[i,s]=N.useState([]),[o,a]=N.useState({showWorkspaceDirConfig:!0,showBraveSearchConfig:!0,enableIntegrations:!1}),[l,u]=N.useState(""),[c,d]=N.useState(""),[h,p]=N.useState(""),[g,m]=N.useState(!1),[y,v]=N.useState(null),[x,b]=N.useState(!1),[k,w]=N.useState(""),[_,P]=N.useState(!1),[E,T]=N.useState(null),[S,M]=N.useState(!1),[R,$]=N.useState(!1),[H,F]=N.useState(!1);N.useEffect(()=>{Promise.all([Xk(),dR(),Jk()]).then(([O,ae,ke])=>{s(O.providers??[]),$(ae.configured),a(ke)}).catch(console.error).finally(()=>r(!1))},[]);const X=i.filter(O=>O.managed),Z=i.filter(O=>!O.managed),I=new Set(Z.map(O=>O.provider)),z=new Set(X.map(O=>O.provider)),C=Qk.filter(O=>!I.has(O.value)&&!z.has(O.value));N.useEffect(()=>{if(C.length>0&&!C.find(O=>O.value===l)){const O=C[0].value;u(O),d(Pp(O))}},[i.length]);function ee(O){u(O),d(Pp(O))}async function ne(){if(!l||!c||!h.trim()){v(e("common.allFieldsRequired"));return}m(!0),v(null),b(!1);try{await Fy(l,c,h.trim()),s(O=>[...O.filter(ke=>ke.provider!==l),{provider:l,model:c}]),b(!0),p("")}catch(O){v(O instanceof Error?O.message:e("common.errorSave"))}finally{m(!1)}}async function j(O,ae,ke){await Fy(O,ae,ke),s(U=>U.map(oe=>oe.provider===O&&!oe.managed?{provider:O,model:ae}:oe))}async function ie(O){confirm(e("settings.removeConfirm",{name:lE[O]??O}))&&(await cR(O),s(ae=>ae.filter(ke=>ke.provider!==O)))}async function A(){if(!k.trim()){T(e("common.apiKeyRequired"));return}P(!0),T(null),M(!1);try{await hR("brave",k.trim()),M(!0),$(!0),w(""),F(!1)}catch(O){T(O instanceof Error?O.message:e("common.errorSave"))}finally{P(!1)}}async function J(){P(!0),T(null);try{await fR(),$(!1),w(""),M(!1),F(!1)}catch(O){T(O instanceof Error?O.message:e("common.errorReset"))}finally{P(!1)}}return n?f.jsx("div",{className:"text-on-surface-variant/70 font-mono text-xs p-8",children:e("common.loading")}):f.jsxs("div",{className:"max-w-2xl mx-auto py-6 sm:py-8 px-4",children:[f.jsxs("button",{type:"button",onClick:()=>t(-1),className:"flex items-center gap-1.5 mb-6 font-mono text-[12px] text-on-surface-variant hover:text-on-surface transition-colors",children:[f.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"arrow_back"}),e("settings.backToAgent")]}),f.jsxs("div",{className:"mb-8",children:[f.jsxs("h1",{className:"font-headline text-4xl font-bold text-on-surface",children:[f.jsx("span",{className:"highlight-marker",children:e("settings.titleHighlight")})," ",e("settings.titleSuffix")]}),f.jsx("p",{className:"font-mono text-[11px] text-on-surface-variant mt-2",children:e("settings.blurb")})]}),X.length>0&&f.jsx("div",{className:"space-y-2 mb-4",children:X.map(O=>f.jsx(y6,{entry:O},`managed-${O.provider}`))}),Z.length===0&&X.length===0?f.jsx("p",{className:"font-mono text-[11px] text-warning/80 mb-4",children:e("settings.noProvidersWarning")}):Z.length>0?f.jsx("div",{className:"space-y-2 mb-6",children:Z.map(O=>f.jsx(b6,{entry:O,onRemove:()=>ie(O.provider),onReplaceKey:j},O.provider))}):null,C.length>0&&f.jsxs("div",{className:"rounded-lg bg-surface-container-lowest border border-outline-variant/40 p-5 space-y-4",children:[f.jsx("p",{className:"text-[10px] uppercase tracking-[0.14em] text-on-surface-variant font-medium",children:e("settings.addProvider")}),f.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[f.jsxs("div",{children:[f.jsx("label",{className:"block text-[10px] uppercase tracking-[0.14em] text-on-surface-variant font-medium mb-1.5",children:e("settings.provider")}),f.jsx("select",{className:`${Ai} appearance-none`,value:l,onChange:O=>ee(O.target.value),children:C.map(O=>f.jsx("option",{value:O.value,children:O.label},O.value))})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-[10px] uppercase tracking-[0.14em] text-on-surface-variant font-medium mb-1.5",children:e("settings.model")}),f.jsx("select",{className:`${Ai} appearance-none`,value:c,onChange:O=>d(O.target.value),children:ud(l).map(O=>f.jsx("option",{value:O.value,children:O.label},O.value))})]})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-[10px] uppercase tracking-[0.14em] text-on-surface-variant font-medium mb-1.5",children:e("settings.apiKey")}),f.jsx("input",{type:"password",className:Ai,placeholder:e("settings.pasteApiKey"),value:h,onChange:O=>{p(O.target.value),v(null),b(!1)},autoComplete:"off"})]}),f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("button",{onClick:ne,disabled:g||!h.trim(),className:"rounded bg-primary px-4 py-2 text-sm font-medium text-on-primary transition-opacity disabled:opacity-40 hover:opacity-90",children:e(g?"common.adding":"common.add")}),x&&f.jsx("span",{className:"font-mono text-[11px] text-success",children:e("settings.added")}),y&&f.jsx("span",{className:"font-mono text-[10px] text-error",children:y})]})]}),f.jsxs("div",{className:"mt-8 pt-8 border-t border-outline-variant/40",children:[f.jsx("h2",{className:"font-headline text-2xl font-bold text-on-surface mb-1",children:e("settings.webSearch")}),o.showBraveSearchConfig?f.jsxs(f.Fragment,{children:[f.jsxs("p",{className:"font-mono text-[11px] text-on-surface-variant/70 mb-6",children:[e("settings.braveBlurbPrefix")," ",R?f.jsx("span",{className:"text-success",children:e("settings.configured")}):f.jsx("span",{className:"text-warning",children:e("settings.notConfigured")})]}),f.jsxs("div",{className:"space-y-4",children:[f.jsxs("div",{children:[f.jsx("label",{className:"block font-mono text-[11px] text-on-surface-variant mb-1",children:e("settings.braveKeyLabel")}),R&&!H?f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("input",{type:"password",className:Ai,value:"••••••••••••••••••••",readOnly:!0}),f.jsx("button",{type:"button",onClick:()=>{F(!0),M(!1)},className:"shrink-0 rounded px-3 py-2 text-[11px] font-mono text-on-surface-variant hover:text-on-surface bg-surface-container transition-colors",children:e("common.replace")})]}):f.jsx("input",{type:"password",className:Ai,placeholder:e("settings.enterBraveKey"),value:k,onChange:O=>{w(O.target.value),M(!1)},autoComplete:"off",autoFocus:H})]}),f.jsxs("div",{className:"flex items-center gap-3",children:[(!R||H)&&f.jsx("button",{onClick:A,disabled:_||!k.trim(),className:"rounded-lg bg-primary px-4 py-2 text-sm font-medium text-on-primary transition-opacity hover:opacity-90 disabled:opacity-40 disabled:cursor-not-allowed",children:e(_?"common.saving":"common.save")}),H&&f.jsx("button",{onClick:()=>{F(!1),w(""),T(null)},className:"rounded px-3 py-1.5 text-[12px] font-mono text-on-surface-variant hover:text-on-surface transition-colors",children:e("common.cancel")}),R&&f.jsx("button",{onClick:J,disabled:_,className:"rounded px-3 py-2 text-[12px] font-mono text-on-surface-variant hover:text-error hover:bg-error/10 transition-colors disabled:opacity-40",children:e("common.delete")}),S&&f.jsx("span",{className:"font-mono text-[11px] text-success",children:e("common.saved")}),E&&f.jsx("span",{className:"font-mono text-[10px] text-error",children:E})]})]})]}):f.jsxs("p",{className:"font-mono text-[11px] text-on-surface-variant/70 mt-2",children:[e("settings.braveManagedBlurb")," ",f.jsx("span",{className:"text-success",children:e("settings.active")})]})]})]})}const w6=1280,k6=800,h_=500,f_=5,p_={Backspace:8,Tab:9,Enter:13,Shift:16,Control:17,Alt:18,Pause:19,CapsLock:20,Escape:27,PageUp:33,PageDown:34,End:35,Home:36,ArrowLeft:37,ArrowUp:38,ArrowRight:39,ArrowDown:40,Insert:45,Delete:46,Meta:91,ContextMenu:93,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123};function S6(){const{t:e}=Ee(),{token:t}=Gf(),[n,r]=N.useState(null),[i,s]=N.useState(!1),[o,a]=N.useState(null),[l,u]=N.useState(!1),[c,d]=N.useState(!1),[h,p]=N.useState(""),[g,m]=N.useState(""),[y,v]=N.useState(""),[x,b]=N.useState(""),[k,w]=N.useState(!1),_=N.useRef(null),P=N.useRef(null),E=N.useRef(null),T=N.useRef(null),S=N.useRef({time:0,x:0,y:0});N.useEffect(()=>{t&&fetch(`/api/takeover/${t}`).then(A=>A.status===404?(s(!0),null):A.json()).then(A=>{A&&(r(A),A.url&&m(A.url))}).catch(()=>s(!0))},[t]),N.useEffect(()=>{if(!n)return;const A=new WebSocket(Yk(n.agentId,n.sessionId));return P.current=A,A.onmessage=J=>{try{const O=JSON.parse(J.data);O.type==="frame"&&O.data?a(`data:image/jpeg;base64,${O.data}`):(O.type==="attached"||O.type==="tab_changed")&&(O.url&&m(O.url),O.title&&v(O.title))}catch{}},()=>{A.onmessage=null,A.close()}},[n]),N.useEffect(()=>{var A;(A=E.current)==null||A.focus()},[n]);const M=N.useCallback(A=>{var J;((J=P.current)==null?void 0:J.readyState)===WebSocket.OPEN&&P.current.send(JSON.stringify(A))},[]);N.useEffect(()=>{k||b(g||(n==null?void 0:n.url)||"")},[g,n==null?void 0:n.url,k]);const R=N.useCallback(()=>{const A=x.trim();if(!A)return;const J=/^https?:\/\//i.test(A)?A:`https://${A}`;M({type:"navigate",url:J})},[x,M]),$=N.useCallback((A,J)=>{const O=_.current;if(!O)return{x:0,y:0};const ae=O.getBoundingClientRect();if(ae.width===0||ae.height===0)return{x:0,y:0};const ke=O.naturalWidth||w6,U=O.naturalHeight||k6,oe=Math.max(0,Math.min(ae.width,A-ae.left)),he=Math.max(0,Math.min(ae.height,J-ae.top));return{x:Math.round(oe/ae.width*ke),y:Math.round(he/ae.height*U)}},[]),H=N.useCallback(A=>(A.shiftKey?8:0)|(A.ctrlKey?2:0)|(A.altKey?1:0)|(A.metaKey?4:0),[]),F=A=>A===2?"right":A===1?"middle":"left",X=A=>{const{x:J,y:O}=$(A.clientX,A.clientY);M({type:"mouse",eventType:"mouseMoved",x:J,y:O,button:T.current??"none",clickCount:0,modifiers:H(A.nativeEvent)})},Z=A=>{var hn;(hn=E.current)==null||hn.focus();const{x:J,y:O}=$(A.clientX,A.clientY),ae=F(A.button),ke=Date.now(),U=ke-S.current.time,oe=Math.abs(J-S.current.x),he=Math.abs(O-S.current.y),Ie=U<h_&&oe<f_&&he<f_?2:1;S.current={time:ke,x:J,y:O},T.current=ae,M({type:"mouse",eventType:"mousePressed",x:J,y:O,button:ae,clickCount:Ie,modifiers:H(A.nativeEvent)})},I=A=>{const{x:J,y:O}=$(A.clientX,A.clientY),ae=F(A.button),ke=S.current.time===0?1:Date.now()-S.current.time<h_?2:1;T.current=null,M({type:"mouse",eventType:"mouseReleased",x:J,y:O,button:ae,clickCount:ke,modifiers:H(A.nativeEvent)})},z=()=>{T.current&&(T.current=null)},C=A=>{M({type:"scroll",...$(A.clientX,A.clientY),deltaY:A.deltaY})},ee=A=>{var O;if(((O=A.target)==null?void 0:O.tagName)==="INPUT")return;A.preventDefault();const J=p_[A.key];A.key.length===1?(M({type:"key",eventType:"rawKeyDown",key:A.key,code:A.code,modifiers:H(A.nativeEvent),windowsVirtualKeyCode:A.key.toUpperCase().charCodeAt(0)}),M({type:"insertText",text:A.key})):M({type:"key",eventType:"rawKeyDown",key:A.key,code:A.code,modifiers:H(A.nativeEvent),windowsVirtualKeyCode:J??0})},ne=A=>{var O;if(((O=A.target)==null?void 0:O.tagName)==="INPUT")return;const J=A.key.length===1?A.key.toUpperCase().charCodeAt(0):p_[A.key]??0;M({type:"key",eventType:"keyUp",key:A.key,code:A.code,modifiers:H(A.nativeEvent),windowsVirtualKeyCode:J})},j=A=>{var O;if(((O=A.target)==null?void 0:O.tagName)==="INPUT")return;A.preventDefault();const J=A.clipboardData.getData("text/plain");J&&M({type:"insertText",text:J})},ie=async()=>{var A;if(!(!t||c)){d(!0);try{await fetch(`/api/takeover/${t}/resolve`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({note:h.trim()||void 0})}),(A=P.current)==null||A.close(),u(!0)}catch{d(!1)}}};return i?f.jsx("div",{className:"flex h-screen items-center justify-center bg-background font-body text-on-surface px-6",children:f.jsxs("div",{className:"text-center max-w-md",children:[f.jsx("p",{className:"text-[11px] font-label uppercase tracking-[0.15em] text-secondary/70 mb-2",children:e("takeover.sessionExpiredLabel")}),f.jsx("h1",{className:"font-headline text-[32px] leading-tight text-on-surface mb-3",children:e("takeover.sessionExpired")}),f.jsx("p",{className:"text-[15px] leading-relaxed text-on-surface-variant italic",children:e("takeover.sessionExpiredBlurb")})]})}):l?f.jsx("div",{className:"flex h-screen items-center justify-center bg-background font-body text-on-surface px-6",children:f.jsxs("div",{className:"text-center max-w-md",children:[f.jsx("p",{className:"text-[11px] font-label uppercase tracking-[0.15em] text-primary/70 mb-2",children:e("takeover.completeLabel")}),f.jsx("h1",{className:"font-headline text-[32px] leading-tight text-on-surface mb-3",children:e("takeover.controlReturned")}),f.jsx("p",{className:"text-[15px] leading-relaxed text-on-surface-variant italic",children:e("takeover.closeTab")})]})}):n?f.jsxs("div",{className:"flex flex-col h-screen bg-background font-body text-on-surface overflow-hidden",children:[f.jsxs("div",{className:"flex items-start gap-4 px-8 py-5 bg-surface-container-low flex-shrink-0",children:[f.jsx("div",{className:"flex-shrink-0 mt-1 w-7 h-7 rounded-full bg-primary-fixed flex items-center justify-center",children:f.jsx("span",{className:"font-headline italic text-[15px] text-primary",children:"!"})}),f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsx("p",{className:"text-[10px] font-label uppercase tracking-[0.15em] text-primary/70 mb-1",children:e("takeover.agentNeedsHelp")}),f.jsx("p",{className:"font-headline text-[17px] leading-snug text-on-surface",children:n.reason})]})]}),f.jsxs("div",{className:"flex items-center gap-3 px-6 py-3 bg-surface-container flex-shrink-0",children:[f.jsxs("div",{className:"flex gap-1.5 flex-shrink-0",children:[f.jsx("span",{className:"w-3 h-3 rounded-full bg-secondary/60"}),f.jsx("span",{className:"w-3 h-3 rounded-full bg-tertiary-fixed"}),f.jsx("span",{className:"w-3 h-3 rounded-full bg-primary/40"})]}),f.jsxs("div",{className:"flex-1 flex items-center gap-2 bg-surface-container-lowest rounded-md px-3 py-1.5 min-w-0",children:[f.jsx("span",{className:"text-[11px] text-primary flex-shrink-0","aria-hidden":!0,children:"∎"}),f.jsx("input",{type:"text",value:x,onChange:A=>b(A.target.value),onFocus:A=>{w(!0),A.target.select()},onBlur:()=>w(!1),onKeyDown:A=>{A.stopPropagation(),A.key==="Enter"?(A.preventDefault(),R(),A.currentTarget.blur()):A.key==="Escape"&&(A.preventDefault(),b(g||n.url||""),A.currentTarget.blur())},onKeyUp:A=>A.stopPropagation(),onPaste:A=>A.stopPropagation(),placeholder:e("takeover.urlBarPlaceholder"),spellCheck:!1,autoComplete:"off",className:"flex-1 min-w-0 bg-transparent outline-none text-[12px] font-mono text-on-surface placeholder:text-on-surface-variant/50"}),y&&!k&&f.jsxs("span",{className:"text-[11px] font-body italic text-on-surface-variant/70 flex-shrink-0 hidden md:inline",children:["— ",y]})]}),f.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[f.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-secondary animate-pulse"}),f.jsx("span",{className:"text-[10px] font-label uppercase tracking-[0.15em] text-secondary",children:e("takeover.liveLabel")})]})]}),f.jsx("div",{ref:E,tabIndex:0,className:"flex-1 flex items-center justify-center overflow-hidden outline-none cursor-default bg-surface-container-highest",onMouseMove:X,onMouseDown:Z,onMouseUp:I,onMouseLeave:z,onWheel:C,onKeyDown:ee,onKeyUp:ne,onPaste:j,onContextMenu:A=>A.preventDefault(),children:o?f.jsx("img",{ref:_,src:o,alt:"live browser",className:"max-w-full max-h-full object-contain select-none",draggable:!1,style:{pointerEvents:"none"}}):f.jsx("p",{className:"font-mono text-[10px] text-on-surface-variant/50 animate-pulse",children:e("takeover.waitingStream")})}),f.jsxs("div",{className:"flex items-end gap-4 px-8 py-5 bg-surface-container-low flex-shrink-0",children:[f.jsxs("div",{className:"flex-1 flex flex-col",children:[f.jsxs("label",{className:"text-[10px] font-label uppercase tracking-[0.15em] text-on-surface-variant/70 mb-1",children:[e("takeover.whatDidYouDo")," ",f.jsx("span",{className:"italic text-on-surface-variant/50",children:e("takeover.optional")})]}),f.jsx("input",{type:"text",value:h,onChange:A=>p(A.target.value),onKeyDown:A=>{A.key==="Enter"&&!A.shiftKey&&(A.preventDefault(),ie())},placeholder:e("takeover.describeActionPlaceholder"),disabled:c,className:"bg-transparent border-0 border-b border-outline-variant/30 focus:border-primary focus:outline-none font-body text-[15px] text-on-surface placeholder:text-on-surface-variant/40 placeholder:italic px-0 py-2 disabled:opacity-50"})]}),f.jsx("button",{onClick:ie,disabled:c,className:"flex-shrink-0 rounded-sm bg-primary text-on-primary font-label text-[11px] uppercase tracking-[0.15em] px-5 py-3 hover:bg-primary/90 transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:e(c?"takeover.returning":"takeover.completed")})]})]}):f.jsx("div",{className:"flex h-screen items-center justify-center bg-background font-body",children:f.jsx("p",{className:"font-mono text-[11px] text-on-surface-variant/60 animate-pulse",children:e("takeover.connecting")})})}function C6(){const e=es();return N.useEffect(()=>{Cp("page_viewed",{path:e.pathname})},[e.pathname]),f.jsxs(IN,{children:[f.jsx(Lr,{path:"takeover/:token",element:f.jsx(S6,{})}),f.jsxs(Lr,{element:f.jsx(IM,{}),children:[f.jsx(Lr,{index:!0,element:f.jsx(px,{to:"/dashboard",replace:!0})}),f.jsx(Lr,{path:"dashboard",element:f.jsx(yR,{})}),f.jsx(Lr,{path:"agents/:id/*",element:f.jsx(x6,{})}),f.jsx(Lr,{path:"settings",element:f.jsx(_6,{})}),f.jsx(Lr,{path:"*",element:f.jsx(px,{to:"/dashboard",replace:!0})})]})]})}KT();window.__granclaw={React:ug,useState:N.useState,useEffect:N.useEffect,useCallback:N.useCallback,useRef:N.useRef,registerView:h$};Qh.createRoot(document.getElementById("root")).render(f.jsx(ug.StrictMode,{children:f.jsx(AM,{children:f.jsx(HN,{children:f.jsx(C6,{})})})}));fetch("/ext/index.js").then(e=>{if(!(!e.ok||!(e.headers.get("content-type")||"").includes("javascript")))return e.text()}).then(e=>{if(!e)return;const t=document.createElement("script");t.textContent=e,document.head.appendChild(t)}).catch(()=>{});
|
|
157
|
+
`).length,8),style:{minHeight:"2.5rem",maxHeight:"12rem",overflow:"auto"}}),v?f.jsx("button",{onClick:C,className:"rounded bg-red-500/20 px-4 py-2 text-sm font-medium text-red-400 transition-opacity hover:bg-red-500/30",children:e("chat.stop")}):f.jsx("button",{onClick:ie,disabled:!m.trim()||!z,className:"rounded bg-primary px-4 py-2 text-sm font-medium text-on-primary transition-opacity disabled:opacity-40 hover:opacity-90",children:e("chat.send")})]})]})]}),J&&a==="chat"&&f.jsxs("div",{"data-testid":"bb-panel",className:`hidden md:flex relative flex-shrink-0 flex-col rounded-lg bg-surface-container-lowest overflow-hidden transition-all duration-200 ${S?"w-96":"w-10"}`,children:[f.jsxs("div",{"data-testid":"guardian-coming-soon-overlay",className:"absolute inset-0 z-20 flex flex-col items-center justify-center bg-surface-container-lowest/90 backdrop-blur-sm rounded-lg",children:[f.jsx(Jh,{className:"h-12 w-12 text-warning/30 mb-4"}),S&&f.jsxs(f.Fragment,{children:[f.jsx("p",{className:"font-headline text-lg font-semibold text-on-surface tracking-tight mb-2",children:e("chat.guardian")}),f.jsx("span",{className:"rounded-full bg-warning/10 border border-warning/30 px-3 py-1 font-label text-[10px] font-semibold text-warning uppercase tracking-widest mb-4",children:e("chat.comingSoon")}),f.jsxs("p",{className:"max-w-[260px] text-center font-mono text-[10px] text-on-surface-variant/50 leading-relaxed px-4",children:[e("chat.guardianBlurb1")," ",e("chat.guardianBlurb2")]})]})]}),f.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 border-b border-outline-variant/20",children:[f.jsx(Jh,{className:"h-4 w-4 flex-shrink-0 text-on-surface-variant"}),S&&f.jsx(f.Fragment,{children:f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsx("p",{className:"font-headline text-xs font-semibold text-on-surface truncate",children:"Guardian"}),f.jsx("p",{className:"font-mono text-[9px] text-on-surface-variant",children:e("chat.guardianDisconnected")})]})})]}),S&&f.jsx("div",{className:"flex-1 overflow-hidden p-3 flex flex-col gap-2",children:f.jsx("p",{className:"font-mono text-[10px] text-on-surface-variant/20 m-auto text-center leading-relaxed",dangerouslySetInnerHTML:{__html:e("chat.guardianChatBlurb")}})})]})]})}const Ai="rounded bg-surface-container px-3 py-2 text-[12px] text-on-surface placeholder:text-on-surface-variant/60 outline-none focus:ring-1 focus:ring-primary/25 font-mono transition-shadow w-full",lE=Object.fromEntries(Qk.map(e=>[e.value,e.label]));function y6({entry:e}){const{t}=Ee();return f.jsxs("div",{className:"rounded-lg bg-surface-container-lowest border border-outline-variant/40 p-4",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{className:"font-mono text-[13px] text-on-surface font-semibold",children:e.label??e.provider}),f.jsx("span",{className:"font-mono text-[10px] text-on-surface-variant/70",children:e.model}),f.jsx("span",{className:"text-success text-[10px] font-mono",children:"✓"})]}),f.jsx("span",{className:"rounded px-2 py-0.5 text-[10px] font-mono bg-primary/10 text-primary",children:"managed"})]}),f.jsx("p",{className:"font-mono text-[10px] text-on-surface-variant/60 mt-2",children:t("settings.managedBlurb")})]})}function b6({entry:e,onRemove:t,onReplaceKey:n}){const{t:r}=Ee(),[i,s]=N.useState(!1),[o,a]=N.useState(e.model),[l,u]=N.useState(""),[c,d]=N.useState(!1),[h,p]=N.useState(null),[g,m]=N.useState(!1);async function y(){if(!l.trim()){p(r("common.apiKeyRequired"));return}d(!0),p(null),m(!1);try{await n(e.provider,o,l.trim()),m(!0),u(""),s(!1)}catch(v){p(v instanceof Error?v.message:r("common.errorSave"))}finally{d(!1)}}return f.jsxs("div",{className:"rounded-lg bg-surface-container-lowest border border-outline-variant/40 p-4 space-y-3",children:[f.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[f.jsxs("div",{className:"min-w-0",children:[f.jsx("span",{className:"font-mono text-[13px] text-on-surface font-semibold",children:lE[e.provider]??e.provider}),f.jsx("span",{className:"font-mono text-[10px] text-on-surface-variant/70 ml-2",children:e.model}),f.jsx("span",{className:"ml-2 text-success text-[10px] font-mono",children:"✓"})]}),f.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[!i&&f.jsx("button",{onClick:()=>{s(!0),m(!1)},className:"rounded px-2 py-1 text-[11px] font-mono text-on-surface-variant hover:text-on-surface bg-surface-container transition-colors",children:r("settings.replaceKey")}),f.jsx("button",{onClick:t,className:"rounded px-2 py-1 text-[11px] font-mono text-error/60 hover:text-error hover:bg-error/10 transition-colors",children:r("settings.delete")})]})]}),i&&f.jsxs("div",{className:"space-y-2 pt-1 border-t border-outline-variant/40",children:[f.jsxs("div",{children:[f.jsx("label",{className:"block text-[10px] uppercase tracking-[0.14em] text-on-surface-variant font-medium mb-1",children:r("settings.model")}),f.jsx("select",{className:`${Ai} appearance-none`,value:o,onChange:v=>a(v.target.value),children:ud(e.provider).map(v=>f.jsx("option",{value:v.value,children:v.label},v.value))})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-[10px] uppercase tracking-[0.14em] text-on-surface-variant font-medium mb-1",children:r("settings.newApiKey")}),f.jsx("input",{type:"password",className:Ai,placeholder:r("settings.pasteNewKey"),value:l,onChange:v=>{u(v.target.value),p(null)},autoComplete:"off",autoFocus:!0})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("button",{onClick:y,disabled:c,className:"rounded bg-primary px-3 py-1.5 text-[12px] font-medium text-on-primary transition-opacity disabled:opacity-40 hover:opacity-90",children:r(c?"common.saving":"common.save")}),f.jsx("button",{onClick:()=>{s(!1),u(""),p(null)},className:"rounded px-3 py-1.5 text-[12px] font-mono text-on-surface-variant hover:text-on-surface transition-colors",children:r("common.cancel")}),g&&f.jsx("span",{className:"font-mono text-[11px] text-success",children:r("common.saved")}),h&&f.jsx("span",{className:"font-mono text-[10px] text-error",children:h})]})]})]})}function _6(){const{t:e}=Ee(),t=ts(),[n,r]=N.useState(!0),[i,s]=N.useState([]),[o,a]=N.useState({showWorkspaceDirConfig:!0,showBraveSearchConfig:!0,enableIntegrations:!1}),[l,u]=N.useState(""),[c,d]=N.useState(""),[h,p]=N.useState(""),[g,m]=N.useState(!1),[y,v]=N.useState(null),[x,b]=N.useState(!1),[k,w]=N.useState(""),[_,P]=N.useState(!1),[E,T]=N.useState(null),[S,M]=N.useState(!1),[R,$]=N.useState(!1),[H,F]=N.useState(!1);N.useEffect(()=>{Promise.all([Xk(),dR(),Jk()]).then(([O,ae,ke])=>{s(O.providers??[]),$(ae.configured),a(ke)}).catch(console.error).finally(()=>r(!1))},[]);const X=i.filter(O=>O.managed),Z=i.filter(O=>!O.managed),I=new Set(Z.map(O=>O.provider)),z=new Set(X.map(O=>O.provider)),C=Qk.filter(O=>!I.has(O.value)&&!z.has(O.value));N.useEffect(()=>{if(C.length>0&&!C.find(O=>O.value===l)){const O=C[0].value;u(O),d(Pp(O))}},[i.length]);function ee(O){u(O),d(Pp(O))}async function ne(){if(!l||!c||!h.trim()){v(e("common.allFieldsRequired"));return}m(!0),v(null),b(!1);try{await Fy(l,c,h.trim()),s(O=>[...O.filter(ke=>ke.provider!==l),{provider:l,model:c}]),b(!0),p("")}catch(O){v(O instanceof Error?O.message:e("common.errorSave"))}finally{m(!1)}}async function j(O,ae,ke){await Fy(O,ae,ke),s(U=>U.map(oe=>oe.provider===O&&!oe.managed?{provider:O,model:ae}:oe))}async function ie(O){confirm(e("settings.removeConfirm",{name:lE[O]??O}))&&(await cR(O),s(ae=>ae.filter(ke=>ke.provider!==O)))}async function A(){if(!k.trim()){T(e("common.apiKeyRequired"));return}P(!0),T(null),M(!1);try{await hR("brave",k.trim()),M(!0),$(!0),w(""),F(!1)}catch(O){T(O instanceof Error?O.message:e("common.errorSave"))}finally{P(!1)}}async function J(){P(!0),T(null);try{await fR(),$(!1),w(""),M(!1),F(!1)}catch(O){T(O instanceof Error?O.message:e("common.errorReset"))}finally{P(!1)}}return n?f.jsx("div",{className:"text-on-surface-variant/70 font-mono text-xs p-8",children:e("common.loading")}):f.jsxs("div",{className:"max-w-2xl mx-auto py-6 sm:py-8 px-4",children:[f.jsxs("button",{type:"button",onClick:()=>t(-1),className:"flex items-center gap-1.5 mb-6 font-mono text-[12px] text-on-surface-variant hover:text-on-surface transition-colors",children:[f.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"arrow_back"}),e("settings.backToAgent")]}),f.jsxs("div",{className:"mb-8",children:[f.jsxs("h1",{className:"font-headline text-4xl font-bold text-on-surface",children:[f.jsx("span",{className:"highlight-marker",children:e("settings.titleHighlight")})," ",e("settings.titleSuffix")]}),f.jsx("p",{className:"font-mono text-[11px] text-on-surface-variant mt-2",children:e("settings.blurb")})]}),X.length>0&&f.jsx("div",{className:"space-y-2 mb-4",children:X.map(O=>f.jsx(y6,{entry:O},`managed-${O.provider}`))}),Z.length===0&&X.length===0?f.jsx("p",{className:"font-mono text-[11px] text-warning/80 mb-4",children:e("settings.noProvidersWarning")}):Z.length>0?f.jsx("div",{className:"space-y-2 mb-6",children:Z.map(O=>f.jsx(b6,{entry:O,onRemove:()=>ie(O.provider),onReplaceKey:j},O.provider))}):null,C.length>0&&f.jsxs("div",{className:"rounded-lg bg-surface-container-lowest border border-outline-variant/40 p-5 space-y-4",children:[f.jsx("p",{className:"text-[10px] uppercase tracking-[0.14em] text-on-surface-variant font-medium",children:e("settings.addProvider")}),f.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[f.jsxs("div",{children:[f.jsx("label",{className:"block text-[10px] uppercase tracking-[0.14em] text-on-surface-variant font-medium mb-1.5",children:e("settings.provider")}),f.jsx("select",{className:`${Ai} appearance-none`,value:l,onChange:O=>ee(O.target.value),children:C.map(O=>f.jsx("option",{value:O.value,children:O.label},O.value))})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-[10px] uppercase tracking-[0.14em] text-on-surface-variant font-medium mb-1.5",children:e("settings.model")}),f.jsx("select",{className:`${Ai} appearance-none`,value:c,onChange:O=>d(O.target.value),children:ud(l).map(O=>f.jsx("option",{value:O.value,children:O.label},O.value))})]})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-[10px] uppercase tracking-[0.14em] text-on-surface-variant font-medium mb-1.5",children:e("settings.apiKey")}),f.jsx("input",{type:"password",className:Ai,placeholder:e("settings.pasteApiKey"),value:h,onChange:O=>{p(O.target.value),v(null),b(!1)},autoComplete:"off"})]}),f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("button",{onClick:ne,disabled:g||!h.trim(),className:"rounded bg-primary px-4 py-2 text-sm font-medium text-on-primary transition-opacity disabled:opacity-40 hover:opacity-90",children:e(g?"common.adding":"common.add")}),x&&f.jsx("span",{className:"font-mono text-[11px] text-success",children:e("settings.added")}),y&&f.jsx("span",{className:"font-mono text-[10px] text-error",children:y})]})]}),f.jsxs("div",{className:"mt-8 pt-8 border-t border-outline-variant/40",children:[f.jsx("h2",{className:"font-headline text-2xl font-bold text-on-surface mb-1",children:e("settings.webSearch")}),o.showBraveSearchConfig?f.jsxs(f.Fragment,{children:[f.jsxs("p",{className:"font-mono text-[11px] text-on-surface-variant/70 mb-6",children:[e("settings.braveBlurbPrefix")," ",R?f.jsx("span",{className:"text-success",children:e("settings.configured")}):f.jsx("span",{className:"text-warning",children:e("settings.notConfigured")})]}),f.jsxs("div",{className:"space-y-4",children:[f.jsxs("div",{children:[f.jsx("label",{className:"block font-mono text-[11px] text-on-surface-variant mb-1",children:e("settings.braveKeyLabel")}),R&&!H?f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("input",{type:"password",className:Ai,value:"••••••••••••••••••••",readOnly:!0}),f.jsx("button",{type:"button",onClick:()=>{F(!0),M(!1)},className:"shrink-0 rounded px-3 py-2 text-[11px] font-mono text-on-surface-variant hover:text-on-surface bg-surface-container transition-colors",children:e("common.replace")})]}):f.jsx("input",{type:"password",className:Ai,placeholder:e("settings.enterBraveKey"),value:k,onChange:O=>{w(O.target.value),M(!1)},autoComplete:"off",autoFocus:H})]}),f.jsxs("div",{className:"flex items-center gap-3",children:[(!R||H)&&f.jsx("button",{onClick:A,disabled:_||!k.trim(),className:"rounded-lg bg-primary px-4 py-2 text-sm font-medium text-on-primary transition-opacity hover:opacity-90 disabled:opacity-40 disabled:cursor-not-allowed",children:e(_?"common.saving":"common.save")}),H&&f.jsx("button",{onClick:()=>{F(!1),w(""),T(null)},className:"rounded px-3 py-1.5 text-[12px] font-mono text-on-surface-variant hover:text-on-surface transition-colors",children:e("common.cancel")}),R&&f.jsx("button",{onClick:J,disabled:_,className:"rounded px-3 py-2 text-[12px] font-mono text-on-surface-variant hover:text-error hover:bg-error/10 transition-colors disabled:opacity-40",children:e("common.delete")}),S&&f.jsx("span",{className:"font-mono text-[11px] text-success",children:e("common.saved")}),E&&f.jsx("span",{className:"font-mono text-[10px] text-error",children:E})]})]})]}):f.jsxs("p",{className:"font-mono text-[11px] text-on-surface-variant/70 mt-2",children:[e("settings.braveManagedBlurb")," ",f.jsx("span",{className:"text-success",children:e("settings.active")})]})]})]})}const w6=1280,k6=800,h_=500,f_=5,p_={Backspace:8,Tab:9,Enter:13,Shift:16,Control:17,Alt:18,Pause:19,CapsLock:20,Escape:27,PageUp:33,PageDown:34,End:35,Home:36,ArrowLeft:37,ArrowUp:38,ArrowRight:39,ArrowDown:40,Insert:45,Delete:46,Meta:91,ContextMenu:93,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123};function S6(){const{t:e}=Ee(),{token:t}=Gf(),[n,r]=N.useState(null),[i,s]=N.useState(!1),[o,a]=N.useState(null),[l,u]=N.useState(!1),[c,d]=N.useState(!1),[h,p]=N.useState(""),[g,m]=N.useState(""),[y,v]=N.useState(""),[x,b]=N.useState(""),[k,w]=N.useState(!1),_=N.useRef(null),P=N.useRef(null),E=N.useRef(null),T=N.useRef(null),S=N.useRef({time:0,x:0,y:0});N.useEffect(()=>{t&&fetch(`/api/takeover/${t}`).then(A=>A.status===404?(s(!0),null):A.json()).then(A=>{A&&(r(A),A.url&&m(A.url))}).catch(()=>s(!0))},[t]),N.useEffect(()=>{if(!n)return;const A=new WebSocket(Yk(n.agentId,n.sessionId));return P.current=A,A.onmessage=J=>{try{const O=JSON.parse(J.data);O.type==="frame"&&O.data?a(`data:image/jpeg;base64,${O.data}`):(O.type==="attached"||O.type==="tab_changed"||O.type==="url_changed")&&(O.url&&m(O.url),O.title&&v(O.title))}catch{}},()=>{A.onmessage=null,A.close()}},[n]),N.useEffect(()=>{var A;(A=E.current)==null||A.focus()},[n]);const M=N.useCallback(A=>{var J;((J=P.current)==null?void 0:J.readyState)===WebSocket.OPEN&&P.current.send(JSON.stringify(A))},[]);N.useEffect(()=>{k||b(g||(n==null?void 0:n.url)||"")},[g,n==null?void 0:n.url,k]);const R=N.useCallback(()=>{const A=x.trim();if(!A)return;const J=/^https?:\/\//i.test(A)?A:`https://${A}`;M({type:"navigate",url:J}),m(J)},[x,M]),$=N.useCallback((A,J)=>{const O=_.current;if(!O)return{x:0,y:0};const ae=O.getBoundingClientRect();if(ae.width===0||ae.height===0)return{x:0,y:0};const ke=O.naturalWidth||w6,U=O.naturalHeight||k6,oe=Math.max(0,Math.min(ae.width,A-ae.left)),he=Math.max(0,Math.min(ae.height,J-ae.top));return{x:Math.round(oe/ae.width*ke),y:Math.round(he/ae.height*U)}},[]),H=N.useCallback(A=>(A.shiftKey?8:0)|(A.ctrlKey?2:0)|(A.altKey?1:0)|(A.metaKey?4:0),[]),F=A=>A===2?"right":A===1?"middle":"left",X=A=>{const{x:J,y:O}=$(A.clientX,A.clientY);M({type:"mouse",eventType:"mouseMoved",x:J,y:O,button:T.current??"none",clickCount:0,modifiers:H(A.nativeEvent)})},Z=A=>{var hn;(hn=E.current)==null||hn.focus();const{x:J,y:O}=$(A.clientX,A.clientY),ae=F(A.button),ke=Date.now(),U=ke-S.current.time,oe=Math.abs(J-S.current.x),he=Math.abs(O-S.current.y),Ie=U<h_&&oe<f_&&he<f_?2:1;S.current={time:ke,x:J,y:O},T.current=ae,M({type:"mouse",eventType:"mousePressed",x:J,y:O,button:ae,clickCount:Ie,modifiers:H(A.nativeEvent)})},I=A=>{const{x:J,y:O}=$(A.clientX,A.clientY),ae=F(A.button),ke=S.current.time===0?1:Date.now()-S.current.time<h_?2:1;T.current=null,M({type:"mouse",eventType:"mouseReleased",x:J,y:O,button:ae,clickCount:ke,modifiers:H(A.nativeEvent)})},z=()=>{T.current&&(T.current=null)},C=A=>{M({type:"scroll",...$(A.clientX,A.clientY),deltaY:A.deltaY})},ee=A=>{var O;if(((O=A.target)==null?void 0:O.tagName)==="INPUT")return;A.preventDefault();const J=p_[A.key];A.key.length===1?(M({type:"key",eventType:"rawKeyDown",key:A.key,code:A.code,modifiers:H(A.nativeEvent),windowsVirtualKeyCode:A.key.toUpperCase().charCodeAt(0)}),!A.ctrlKey&&!A.metaKey&&M({type:"insertText",text:A.key})):M({type:"key",eventType:"rawKeyDown",key:A.key,code:A.code,modifiers:H(A.nativeEvent),windowsVirtualKeyCode:J??0})},ne=A=>{var O;if(((O=A.target)==null?void 0:O.tagName)==="INPUT")return;const J=A.key.length===1?A.key.toUpperCase().charCodeAt(0):p_[A.key]??0;M({type:"key",eventType:"keyUp",key:A.key,code:A.code,modifiers:H(A.nativeEvent),windowsVirtualKeyCode:J})},j=A=>{var O;if(((O=A.target)==null?void 0:O.tagName)==="INPUT")return;A.preventDefault();const J=A.clipboardData.getData("text/plain");J&&M({type:"insertText",text:J})},ie=async()=>{var A;if(!(!t||c)){d(!0);try{await fetch(`/api/takeover/${t}/resolve`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({note:h.trim()||void 0})}),(A=P.current)==null||A.close(),u(!0)}catch{d(!1)}}};return i?f.jsx("div",{className:"flex h-screen items-center justify-center bg-background font-body text-on-surface px-6",children:f.jsxs("div",{className:"text-center max-w-md",children:[f.jsx("p",{className:"text-[11px] font-label uppercase tracking-[0.15em] text-secondary/70 mb-2",children:e("takeover.sessionExpiredLabel")}),f.jsx("h1",{className:"font-headline text-[32px] leading-tight text-on-surface mb-3",children:e("takeover.sessionExpired")}),f.jsx("p",{className:"text-[15px] leading-relaxed text-on-surface-variant italic",children:e("takeover.sessionExpiredBlurb")})]})}):l?f.jsx("div",{className:"flex h-screen items-center justify-center bg-background font-body text-on-surface px-6",children:f.jsxs("div",{className:"text-center max-w-md",children:[f.jsx("p",{className:"text-[11px] font-label uppercase tracking-[0.15em] text-primary/70 mb-2",children:e("takeover.completeLabel")}),f.jsx("h1",{className:"font-headline text-[32px] leading-tight text-on-surface mb-3",children:e("takeover.controlReturned")}),f.jsx("p",{className:"text-[15px] leading-relaxed text-on-surface-variant italic",children:e("takeover.closeTab")})]})}):n?f.jsxs("div",{className:"flex flex-col h-screen bg-background font-body text-on-surface overflow-hidden",children:[f.jsxs("div",{className:"flex items-start gap-4 px-8 py-5 bg-surface-container-low flex-shrink-0",children:[f.jsx("div",{className:"flex-shrink-0 mt-1 w-7 h-7 rounded-full bg-primary-fixed flex items-center justify-center",children:f.jsx("span",{className:"font-headline italic text-[15px] text-primary",children:"!"})}),f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsx("p",{className:"text-[10px] font-label uppercase tracking-[0.15em] text-primary/70 mb-1",children:e("takeover.agentNeedsHelp")}),f.jsx("p",{className:"font-headline text-[17px] leading-snug text-on-surface",children:n.reason})]})]}),f.jsxs("div",{className:"flex items-center gap-3 px-6 py-3 bg-surface-container flex-shrink-0",children:[f.jsxs("div",{className:"flex gap-1.5 flex-shrink-0",children:[f.jsx("span",{className:"w-3 h-3 rounded-full bg-secondary/60"}),f.jsx("span",{className:"w-3 h-3 rounded-full bg-tertiary-fixed"}),f.jsx("span",{className:"w-3 h-3 rounded-full bg-primary/40"})]}),f.jsxs("div",{className:"flex-1 flex items-center gap-2 bg-surface-container-lowest rounded-md px-3 py-1.5 min-w-0",children:[f.jsx("span",{className:"text-[11px] text-primary flex-shrink-0","aria-hidden":!0,children:"∎"}),f.jsx("input",{type:"text",value:x,onChange:A=>b(A.target.value),onFocus:A=>{w(!0),A.target.select()},onBlur:()=>w(!1),onKeyDown:A=>{A.stopPropagation(),A.key==="Enter"?(A.preventDefault(),R(),A.currentTarget.blur()):A.key==="Escape"&&(A.preventDefault(),b(g||n.url||""),A.currentTarget.blur())},onKeyUp:A=>A.stopPropagation(),onPaste:A=>A.stopPropagation(),placeholder:e("takeover.urlBarPlaceholder"),spellCheck:!1,autoComplete:"off",className:"flex-1 min-w-0 bg-transparent outline-none text-[12px] font-mono text-on-surface placeholder:text-on-surface-variant/50"}),y&&!k&&f.jsxs("span",{className:"text-[11px] font-body italic text-on-surface-variant/70 flex-shrink-0 hidden md:inline",children:["— ",y]})]}),f.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[f.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-secondary animate-pulse"}),f.jsx("span",{className:"text-[10px] font-label uppercase tracking-[0.15em] text-secondary",children:e("takeover.liveLabel")})]})]}),f.jsx("div",{ref:E,tabIndex:0,className:"flex-1 flex items-center justify-center overflow-hidden outline-none cursor-default bg-surface-container-highest",onMouseMove:X,onMouseDown:Z,onMouseUp:I,onMouseLeave:z,onWheel:C,onKeyDown:ee,onKeyUp:ne,onPaste:j,onContextMenu:A=>A.preventDefault(),children:o?f.jsx("img",{ref:_,src:o,alt:"live browser",className:"max-w-full max-h-full object-contain select-none",draggable:!1,style:{pointerEvents:"none"}}):f.jsx("p",{className:"font-mono text-[10px] text-on-surface-variant/50 animate-pulse",children:e("takeover.waitingStream")})}),f.jsxs("div",{className:"flex items-end gap-4 px-8 py-5 bg-surface-container-low flex-shrink-0",children:[f.jsxs("div",{className:"flex-1 flex flex-col",children:[f.jsxs("label",{className:"text-[10px] font-label uppercase tracking-[0.15em] text-on-surface-variant/70 mb-1",children:[e("takeover.whatDidYouDo")," ",f.jsx("span",{className:"italic text-on-surface-variant/50",children:e("takeover.optional")})]}),f.jsx("input",{type:"text",value:h,onChange:A=>p(A.target.value),onKeyDown:A=>{A.key==="Enter"&&!A.shiftKey&&(A.preventDefault(),ie())},placeholder:e("takeover.describeActionPlaceholder"),disabled:c,className:"bg-transparent border-0 border-b border-outline-variant/30 focus:border-primary focus:outline-none font-body text-[15px] text-on-surface placeholder:text-on-surface-variant/40 placeholder:italic px-0 py-2 disabled:opacity-50"})]}),f.jsx("button",{onClick:ie,disabled:c,className:"flex-shrink-0 rounded-sm bg-primary text-on-primary font-label text-[11px] uppercase tracking-[0.15em] px-5 py-3 hover:bg-primary/90 transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:e(c?"takeover.returning":"takeover.completed")})]})]}):f.jsx("div",{className:"flex h-screen items-center justify-center bg-background font-body",children:f.jsx("p",{className:"font-mono text-[11px] text-on-surface-variant/60 animate-pulse",children:e("takeover.connecting")})})}function C6(){const e=es();return N.useEffect(()=>{Cp("page_viewed",{path:e.pathname})},[e.pathname]),f.jsxs(IN,{children:[f.jsx(Lr,{path:"takeover/:token",element:f.jsx(S6,{})}),f.jsxs(Lr,{element:f.jsx(IM,{}),children:[f.jsx(Lr,{index:!0,element:f.jsx(px,{to:"/dashboard",replace:!0})}),f.jsx(Lr,{path:"dashboard",element:f.jsx(yR,{})}),f.jsx(Lr,{path:"agents/:id/*",element:f.jsx(x6,{})}),f.jsx(Lr,{path:"settings",element:f.jsx(_6,{})}),f.jsx(Lr,{path:"*",element:f.jsx(px,{to:"/dashboard",replace:!0})})]})]})}KT();window.__granclaw={React:ug,useState:N.useState,useEffect:N.useEffect,useCallback:N.useCallback,useRef:N.useRef,registerView:h$};Qh.createRoot(document.getElementById("root")).render(f.jsx(ug.StrictMode,{children:f.jsx(AM,{children:f.jsx(HN,{children:f.jsx(C6,{})})})}));fetch("/ext/index.js").then(e=>{if(!(!e.ok||!(e.headers.get("content-type")||"").includes("javascript")))return e.text()}).then(e=>{if(!e)return;const t=document.createElement("script");t.textContent=e,document.head.appendChild(t)}).catch(()=>{});
|
package/dist/frontend/index.html
CHANGED
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
} catch (_) { /* SSR / blocked storage — ignore */ }
|
|
28
28
|
})();
|
|
29
29
|
</script>
|
|
30
|
-
<script type="module" crossorigin src="/assets/index-
|
|
30
|
+
<script type="module" crossorigin src="/assets/index-9TKnUbWt.js"></script>
|
|
31
31
|
<link rel="stylesheet" crossorigin href="/assets/index-C_L5wqFQ.css">
|
|
32
32
|
</head>
|
|
33
33
|
<body class="bg-background text-on-surface">
|