granclaw 0.0.1-beta.89 → 0.0.1-beta.90
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.
|
@@ -644,6 +644,34 @@ function createServer() {
|
|
|
644
644
|
}
|
|
645
645
|
return out;
|
|
646
646
|
}
|
|
647
|
+
function walkSkills(root, dir, out) {
|
|
648
|
+
let entries;
|
|
649
|
+
try {
|
|
650
|
+
entries = fs_1.default.readdirSync(dir, { withFileTypes: true });
|
|
651
|
+
}
|
|
652
|
+
catch {
|
|
653
|
+
return;
|
|
654
|
+
}
|
|
655
|
+
const skillMd = path_1.default.join(dir, 'SKILL.md');
|
|
656
|
+
if (fs_1.default.existsSync(skillMd)) {
|
|
657
|
+
const fm = parseFrontmatter(fs_1.default.readFileSync(skillMd, 'utf8'));
|
|
658
|
+
if (fm.description) {
|
|
659
|
+
const rel = path_1.default.relative(root, dir) || '.';
|
|
660
|
+
out.push({
|
|
661
|
+
name: fm.name ?? path_1.default.basename(dir),
|
|
662
|
+
path: rel.split(path_1.default.sep).join('/'),
|
|
663
|
+
description: fm.description,
|
|
664
|
+
userInvocable: fm['user-invocable'] === 'true',
|
|
665
|
+
});
|
|
666
|
+
}
|
|
667
|
+
return;
|
|
668
|
+
}
|
|
669
|
+
for (const entry of entries) {
|
|
670
|
+
if (!entry.isDirectory() || entry.name.startsWith('.') || entry.name === 'node_modules')
|
|
671
|
+
continue;
|
|
672
|
+
walkSkills(root, path_1.default.join(dir, entry.name), out);
|
|
673
|
+
}
|
|
674
|
+
}
|
|
647
675
|
app.get('/agents/:id/skills', (req, res) => {
|
|
648
676
|
const managed = (0, agent_manager_js_1.getManagedAgent)(req.params.id);
|
|
649
677
|
if (!managed) {
|
|
@@ -657,25 +685,11 @@ function createServer() {
|
|
|
657
685
|
return;
|
|
658
686
|
}
|
|
659
687
|
const skills = [];
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
continue;
|
|
663
|
-
const skillMd = path_1.default.join(skillsDir, entry.name, 'SKILL.md');
|
|
664
|
-
if (!fs_1.default.existsSync(skillMd))
|
|
665
|
-
continue;
|
|
666
|
-
const fm = parseFrontmatter(fs_1.default.readFileSync(skillMd, 'utf8'));
|
|
667
|
-
if (!fm.name && !fm.description)
|
|
668
|
-
continue;
|
|
669
|
-
skills.push({
|
|
670
|
-
name: fm.name ?? entry.name,
|
|
671
|
-
description: fm.description ?? '',
|
|
672
|
-
userInvocable: fm['user-invocable'] === 'true',
|
|
673
|
-
});
|
|
674
|
-
}
|
|
675
|
-
skills.sort((a, b) => a.name.localeCompare(b.name));
|
|
688
|
+
walkSkills(skillsDir, skillsDir, skills);
|
|
689
|
+
skills.sort((a, b) => a.path.localeCompare(b.path));
|
|
676
690
|
res.json({ skills });
|
|
677
691
|
});
|
|
678
|
-
app.get('/agents/:id/skills
|
|
692
|
+
app.get('/agents/:id/skills/*', (req, res) => {
|
|
679
693
|
const managed = (0, agent_manager_js_1.getManagedAgent)(req.params.id);
|
|
680
694
|
if (!managed) {
|
|
681
695
|
res.status(404).json({ error: 'Agent not found' });
|
|
@@ -687,9 +701,10 @@ function createServer() {
|
|
|
687
701
|
res.status(404).json({ error: 'No skills directory' });
|
|
688
702
|
return;
|
|
689
703
|
}
|
|
690
|
-
const
|
|
704
|
+
const rel = req.params[0] ?? '';
|
|
705
|
+
const requested = path_1.default.resolve(skillsDir, rel, 'SKILL.md');
|
|
691
706
|
if (!requested.startsWith(skillsDir + path_1.default.sep)) {
|
|
692
|
-
res.status(400).json({ error: 'Invalid skill
|
|
707
|
+
res.status(400).json({ error: 'Invalid skill path' });
|
|
693
708
|
return;
|
|
694
709
|
}
|
|
695
710
|
if (!fs_1.default.existsSync(requested)) {
|
|
@@ -699,7 +714,8 @@ function createServer() {
|
|
|
699
714
|
const content = fs_1.default.readFileSync(requested, 'utf8');
|
|
700
715
|
const fm = parseFrontmatter(content);
|
|
701
716
|
res.json({
|
|
702
|
-
name: fm.name ??
|
|
717
|
+
name: fm.name ?? path_1.default.basename(rel),
|
|
718
|
+
path: rel,
|
|
703
719
|
description: fm.description ?? '',
|
|
704
720
|
userInvocable: fm['user-invocable'] === 'true',
|
|
705
721
|
allowedTools: fm['allowed-tools'] ?? '',
|
|
@@ -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}"},_M={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…",browserStarting:"iniciando el navegador — la transmisión comenzará cuando cargue una página",browserNotReady:"el navegador está entre páginas — esperando la próxima navegación",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…"},wM={title:"Habilidades",subtitle:"Habilidades que tu agente puede invocar. Las habilidades invocables por el usuario se pueden activar desde el chat con /barra-comando.",empty:"No hay habilidades instaladas todavía. Viven en .pi/skills/ dentro del workspace del agente.",loading:"Cargando habilidades…",selectSkill:"Selecciona una habilidad a la izquierda para ver su definición completa.",userInvocable:"invocable por usuario",allowedTools:"Herramientas permitidas",loadError:"No se pudo cargar la habilidad: {error}"},kM={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"},SM={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.'},CM={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}"?'},EM={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.",runStatus:{running:"en ejecución",completed:"completado",failed:"fallido",cancelled:"cancelado"}},PM={loading:"Cargando ejecución…",back:"← Volver al flujo",runLabel:"Ejecución —",errorPrefix:"Error:",input:"Entrada",output:"Salida"},NM={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"},jM={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"},TM={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"},MM={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…"},RM={views:{chat:"Chat",tasks:"Tareas",skills:"Habilidades",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…"},AM={workspace:"espacio-de-trabajo",savingLabel:"guardando…",saveButton:"Guardar",emptyDir:"Directorio vacío"},DM={common:mM,shell:xM,dashboard:vM,settings:yM,chat:bM,takeover:_M,skillsView:wM,tasks:kM,taskDetail:SM,schedules:CM,workflows:EM,runDetail:PM,monitor:NM,integrations:jM,usage:TM,logs:MM,agentSettings:RM,files:AM},Ay={en:gM,es:DM},Yk="granclaw:lang";function IM(){if(typeof window>"u")return"en";try{const t=window.localStorage.getItem(Yk);if(t==="en"||t==="es")return t}catch{}return(typeof navigator<"u"?navigator.language:"").toLowerCase().startsWith("es")?"es":"en"}function Dy(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 OM(e,t){return t?e.replace(/\{(\w+)\}/g,(n,r)=>{const i=t[r];return i==null?`{${r}}`:String(i)}):e}const Xk=P.createContext(null);function LM({children:e}){const[t,n]=P.useState(()=>IM()),r=P.useCallback(o=>{n(o);try{window.localStorage.setItem(Yk,o)}catch{}},[]);P.useEffect(()=>{try{document.documentElement.lang=t}catch{}},[t]);const i=P.useCallback((o,a)=>{const l=Ay[t],c=Dy(l,o)??Dy(Ay.en,o)??o;return OM(c,a)},[t]),s=P.useMemo(()=>({lang:t,setLang:r,t:i}),[t,r,i]);return f.jsx(Xk.Provider,{value:s,children:e})}function Pe(){const e=P.useContext(Xk);if(!e)throw new Error("useT must be used inside <LanguageProvider>");return e}function FM({className:e}){const{lang:t,setLang:n}=Pe();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 $M(){const e=ns(),t=rs(),n=e.pathname.includes("/chat"),{t:r}=Pe();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.89"]})]}),f.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[f.jsx(FM,{}),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(IN,{})})]})}const ae="";async function Iy(){const e=await fetch(`${ae}/agents`);if(!e.ok)throw new Error(`fetchAgents: ${e.status}`);return e.json()}async function zM(e,t,n,r,i){const s=await fetch(`${ae}/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 BM(e){const t=await fetch(`${ae}/agents/${e}`,{method:"DELETE"});if(!t.ok)throw new Error(`deleteAgent: ${t.status}`)}async function Oy(e){const t=await fetch(`${ae}/agents/${e}`);if(!t.ok)throw new Error(`fetchAgent: ${t.status}`);return t.json()}async function Ly(e,t="ui"){const n=await fetch(`${ae}/agents/${e}/messages?channelId=${t}&sortBy=desc&limit=200`,{cache:"no-store"});if(!n.ok)throw new Error(`fetchMessages: ${n.status}`);return(await n.json()).reverse()}async function HM(e){const t=await fetch(`${ae}/agents/${e}/reset`,{method:"DELETE"});if(!t.ok)throw new Error(`resetAgent: ${t.status}`)}async function VM(e,t=""){const n=await fetch(`${ae}/agents/${e}/files?path=${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`fetchFiles: ${n.status}`);return(await n.json()).entries}async function WM(e,t){const n=await fetch(`${ae}/agents/${e}/files/read?path=${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`readFile: ${n.status}`);return(await n.json()).content}async function UM(e,t,n){const r=await fetch(`${ae}/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 qM(e){const t=await fetch(`${ae}/agents/${e}/secrets`);if(!t.ok)throw new Error(`fetchSecrets: ${t.status}`);return t.json()}async function Tp(e,t,n){const r=await fetch(`${ae}/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 Jk(e,t){const n=await fetch(`${ae}/agents/${e}/secrets/${encodeURIComponent(t)}`,{method:"DELETE"});if(!n.ok)throw new Error(`deleteSecret: ${n.status}`)}async function GM(e){const t=await fetch(`${ae}/agents/${e}/skills`);if(!t.ok)throw new Error(`fetchSkills: ${t.status}`);return(await t.json()).skills}async function KM(e,t){const n=await fetch(`${ae}/agents/${e}/skills/${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`fetchSkillDetail: ${n.status}`);return n.json()}async function YM(e,t){const r=await fetch(`${ae}/agents/${e}/tasks`);if(!r.ok)throw new Error(`fetchTasks: ${r.status}`);return r.json()}async function XM(e,t){const n=await fetch(`${ae}/agents/${e}/tasks/${t}`);if(!n.ok)throw new Error(`fetchTask: ${n.status}`);return n.json()}async function JM(e,t){const n=await fetch(`${ae}/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 Fy(e,t,n){const r=await fetch(`${ae}/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(`${ae}/agents/${e}/tasks/${t}`,{method:"DELETE"});if(!n.ok)throw new Error(`deleteTask: ${n.status}`)}async function ZM(e,t,n){const r=await fetch(`${ae}/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 eR(e){const t=await fetch(`${ae}/agents/${e}/browser-sessions`);if(!t.ok)throw new Error(`fetchBrowserSessions: ${t.status}`);return t.json()}async function Qk(e,t){const n=await fetch(`${ae}/agents/${e}/browser-sessions/${t}`);if(!n.ok)throw new Error(`fetchBrowserSession: ${n.status}`);return n.json()}function tR(e,t){return`${ae}/agents/${e}/browser-sessions/${t}/video`}function Zk(e,t){const n=window.location;return`${n.protocol==="https:"?"wss:":"ws:"}//${n.host}/browser-live/${e}/${t}`}function nR(e){return`${ae}/agents/${e}/export`}async function $y(e,t){const n=new URL(`${ae}/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 zy(e,t){const n=await fetch(`${ae}/agents/${e}/monitor/jobs/${t}`,{method:"DELETE"});if(!n.ok)throw new Error(`killJob: ${n.status}`)}async function rR(e){const t=await fetch(`${ae}/agents/${e}/monitor`);if(!t.ok)throw new Error(`fetchMonitor: ${t.status}`);return t.json()}async function iR(e,t=30){const n=await fetch(`${ae}/agents/${e}/usage?days=${t}`);if(!n.ok)throw new Error(`fetchUsage: ${n.status}`);return n.json()}async function sR(e){const t=await fetch(`${ae}/agents/${e}/schedules`);if(!t.ok)throw new Error(`fetchSchedules: ${t.status}`);return t.json()}async function oR(e,t,n){const r=await fetch(`${ae}/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 aR(e,t){const n=await fetch(`${ae}/agents/${e}/schedules/${t}`,{method:"DELETE"});if(!n.ok)throw new Error(`deleteSchedule: ${n.status}`)}async function lR(e,t){const n=await fetch(`${ae}/agents/${e}/schedules/${t}/trigger`,{method:"POST"});if(!n.ok)throw new Error(`triggerSchedule: ${n.status}`);return n.json()}async function cR(e,t){const n=await fetch(`${ae}/agents/${e}/schedules/${t}/runs`);if(!n.ok)throw new Error(`fetchScheduleRuns: ${n.status}`);return n.json()}async function uR(e,t){const n=await fetch(`${ae}/agents/${e}/messages?channelId=${encodeURIComponent(t)}&sortBy=asc&limit=200`);if(!n.ok)throw new Error(`fetchScheduleRunMessages: ${n.status}`);return n.json()}async function dR(e){const t=await fetch(`${ae}/agents/${e}/workflows`);if(!t.ok)throw new Error(`fetchWorkflows: ${t.status}`);return t.json()}async function hR(e,t){const n=await fetch(`${ae}/agents/${e}/workflows/${t}`);if(!n.ok)throw new Error(`fetchWorkflow: ${n.status}`);return n.json()}async function wh(e,t){const n=await fetch(`${ae}/agents/${e}/workflows/${t}/runs`);if(!n.ok)throw new Error(`fetchWorkflowRuns: ${n.status}`);return n.json()}async function fR(e,t,n){const r=await fetch(`${ae}/agents/${e}/workflows/${t}/runs/${n}`);if(!r.ok)throw new Error(`fetchWorkflowRun: ${r.status}`);return r.json()}async function pR(e,t){const n=await fetch(`${ae}/agents/${e}/workflows/${t}/run`,{method:"POST"});if(!n.ok)throw new Error(`triggerWorkflowRun: ${n.status}`);return n.json()}async function gR(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(`${ae}/logs?${t}`);if(!n.ok)throw new Error(`fetchLogs: ${n.status}`);return n.json()}async function eS(){const e=await fetch(`${ae}/settings/provider`);if(!e.ok)throw new Error("Failed to fetch provider settings");return e.json()}const kh={showWorkspaceDirConfig:!0,showBraveSearchConfig:!0,enableIntegrations:!1};async function tS(){try{const e=await fetch(`${ae}/settings/app`);if(!e.ok)return{...kh};const t=await e.json();return{...kh,...t}}catch{return{...kh}}}async function By(e,t,n){if(!(await fetch(`${ae}/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 mR(e){if(!(await fetch(`${ae}/settings/providers/${encodeURIComponent(e)}`,{method:"DELETE"})).ok)throw new Error("Failed to remove provider")}async function xR(){const e=await fetch(`${ae}/settings/search`);return e.ok?e.json():{provider:"brave",configured:!1}}async function vR(e,t){const n=await fetch(`${ae}/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 yR(){const e=await fetch(`${ae}/settings/search`,{method:"DELETE"});if(!e.ok&&e.status!==204&&e.status!==404)throw new Error(`Failed to clear search settings: ${e.status}`)}const bR={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"}]},nS=[{value:"google",label:"Google Gemini"},{value:"openai",label:"OpenAI"},{value:"anthropic",label:"Anthropic"},{value:"groq",label:"Groq"},{value:"openrouter",label:"OpenRouter"}];function dd(e){return bR[e]??[]}function Mp(e){var t;return((t=dd(e)[0])==null?void 0:t.value)??""}const ba="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",_R="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",rS="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",wR="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",Pc="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",Hy=Pc.replace("text-sm","text-sm font-mono"),el="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",Nc=`${Ws} bg-surface-container border border-outline-variant/40 text-on-surface-variant`,Rp=`${Ws} bg-success/10 border border-success/20 text-success`,Vy=`${Ws} bg-warning/10 border border-warning/20 text-warning`;function kR({agent:e,onDelete:t}){const n=rs(),{t:r}=Pe(),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?Rp:Nc,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:`${wR} sm:opacity-0 sm:group-hover:opacity-100`,children:r("dashboard.delete")})})]})}function SR(){const{t:e}=Pe(),[t,n]=P.useState([]),[r,i]=P.useState(!0),[s,o]=P.useState(null),[a,l]=P.useState({showWorkspaceDirConfig:!0,showBraveSearchConfig:!0,enableIntegrations:!1}),[c,u]=P.useState(!1),[d,h]=P.useState(""),[p,g]=P.useState(""),[m,v]=P.useState(""),[x,y]=P.useState(""),[b,k]=P.useState(""),[w,_]=P.useState(!1),[N,E]=P.useState(!1),[T,S]=P.useState(null),M=P.useRef(null);async function A(C){var te,j;const Q=(te=C.target.files)==null?void 0:te[0];if(Q){E(!0),S(null);try{let re;try{re=await $y(Q)}catch(le){const oe=le instanceof Error?le.message:String(le);if(oe.includes("already exists")){const R=(j=prompt(`${oe}
|
|
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}"},_M={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…",browserStarting:"iniciando el navegador — la transmisión comenzará cuando cargue una página",browserNotReady:"el navegador está entre páginas — esperando la próxima navegación",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…"},wM={title:"Habilidades",subtitle:"Habilidades que tu agente puede invocar. Las habilidades invocables por el usuario se pueden activar desde el chat con /barra-comando.",empty:"No hay habilidades instaladas todavía. Viven en .pi/skills/ dentro del workspace del agente.",loading:"Cargando habilidades…",selectSkill:"Selecciona una habilidad a la izquierda para ver su definición completa.",userInvocable:"invocable por usuario",allowedTools:"Herramientas permitidas",loadError:"No se pudo cargar la habilidad: {error}"},kM={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"},SM={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.'},CM={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}"?'},EM={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.",runStatus:{running:"en ejecución",completed:"completado",failed:"fallido",cancelled:"cancelado"}},PM={loading:"Cargando ejecución…",back:"← Volver al flujo",runLabel:"Ejecución —",errorPrefix:"Error:",input:"Entrada",output:"Salida"},NM={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"},jM={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"},TM={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"},MM={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…"},RM={views:{chat:"Chat",tasks:"Tareas",skills:"Habilidades",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…"},AM={workspace:"espacio-de-trabajo",savingLabel:"guardando…",saveButton:"Guardar",emptyDir:"Directorio vacío"},DM={common:mM,shell:xM,dashboard:vM,settings:yM,chat:bM,takeover:_M,skillsView:wM,tasks:kM,taskDetail:SM,schedules:CM,workflows:EM,runDetail:PM,monitor:NM,integrations:jM,usage:TM,logs:MM,agentSettings:RM,files:AM},Ay={en:gM,es:DM},Yk="granclaw:lang";function IM(){if(typeof window>"u")return"en";try{const t=window.localStorage.getItem(Yk);if(t==="en"||t==="es")return t}catch{}return(typeof navigator<"u"?navigator.language:"").toLowerCase().startsWith("es")?"es":"en"}function Dy(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 OM(e,t){return t?e.replace(/\{(\w+)\}/g,(n,r)=>{const i=t[r];return i==null?`{${r}}`:String(i)}):e}const Xk=P.createContext(null);function LM({children:e}){const[t,n]=P.useState(()=>IM()),r=P.useCallback(o=>{n(o);try{window.localStorage.setItem(Yk,o)}catch{}},[]);P.useEffect(()=>{try{document.documentElement.lang=t}catch{}},[t]);const i=P.useCallback((o,a)=>{const l=Ay[t],c=Dy(l,o)??Dy(Ay.en,o)??o;return OM(c,a)},[t]),s=P.useMemo(()=>({lang:t,setLang:r,t:i}),[t,r,i]);return f.jsx(Xk.Provider,{value:s,children:e})}function Pe(){const e=P.useContext(Xk);if(!e)throw new Error("useT must be used inside <LanguageProvider>");return e}function FM({className:e}){const{lang:t,setLang:n}=Pe();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 $M(){const e=ns(),t=rs(),n=e.pathname.includes("/chat"),{t:r}=Pe();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.90"]})]}),f.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[f.jsx(FM,{}),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(IN,{})})]})}const ae="";async function Iy(){const e=await fetch(`${ae}/agents`);if(!e.ok)throw new Error(`fetchAgents: ${e.status}`);return e.json()}async function zM(e,t,n,r,i){const s=await fetch(`${ae}/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 BM(e){const t=await fetch(`${ae}/agents/${e}`,{method:"DELETE"});if(!t.ok)throw new Error(`deleteAgent: ${t.status}`)}async function Oy(e){const t=await fetch(`${ae}/agents/${e}`);if(!t.ok)throw new Error(`fetchAgent: ${t.status}`);return t.json()}async function Ly(e,t="ui"){const n=await fetch(`${ae}/agents/${e}/messages?channelId=${t}&sortBy=desc&limit=200`,{cache:"no-store"});if(!n.ok)throw new Error(`fetchMessages: ${n.status}`);return(await n.json()).reverse()}async function HM(e){const t=await fetch(`${ae}/agents/${e}/reset`,{method:"DELETE"});if(!t.ok)throw new Error(`resetAgent: ${t.status}`)}async function VM(e,t=""){const n=await fetch(`${ae}/agents/${e}/files?path=${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`fetchFiles: ${n.status}`);return(await n.json()).entries}async function WM(e,t){const n=await fetch(`${ae}/agents/${e}/files/read?path=${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`readFile: ${n.status}`);return(await n.json()).content}async function UM(e,t,n){const r=await fetch(`${ae}/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 qM(e){const t=await fetch(`${ae}/agents/${e}/secrets`);if(!t.ok)throw new Error(`fetchSecrets: ${t.status}`);return t.json()}async function Tp(e,t,n){const r=await fetch(`${ae}/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 Jk(e,t){const n=await fetch(`${ae}/agents/${e}/secrets/${encodeURIComponent(t)}`,{method:"DELETE"});if(!n.ok)throw new Error(`deleteSecret: ${n.status}`)}async function GM(e){const t=await fetch(`${ae}/agents/${e}/skills`);if(!t.ok)throw new Error(`fetchSkills: ${t.status}`);return(await t.json()).skills}async function KM(e,t){const n=t.split("/").map(encodeURIComponent).join("/"),r=await fetch(`${ae}/agents/${e}/skills/${n}`);if(!r.ok)throw new Error(`fetchSkillDetail: ${r.status}`);return r.json()}async function YM(e,t){const r=await fetch(`${ae}/agents/${e}/tasks`);if(!r.ok)throw new Error(`fetchTasks: ${r.status}`);return r.json()}async function XM(e,t){const n=await fetch(`${ae}/agents/${e}/tasks/${t}`);if(!n.ok)throw new Error(`fetchTask: ${n.status}`);return n.json()}async function JM(e,t){const n=await fetch(`${ae}/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 Fy(e,t,n){const r=await fetch(`${ae}/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(`${ae}/agents/${e}/tasks/${t}`,{method:"DELETE"});if(!n.ok)throw new Error(`deleteTask: ${n.status}`)}async function ZM(e,t,n){const r=await fetch(`${ae}/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 eR(e){const t=await fetch(`${ae}/agents/${e}/browser-sessions`);if(!t.ok)throw new Error(`fetchBrowserSessions: ${t.status}`);return t.json()}async function Qk(e,t){const n=await fetch(`${ae}/agents/${e}/browser-sessions/${t}`);if(!n.ok)throw new Error(`fetchBrowserSession: ${n.status}`);return n.json()}function tR(e,t){return`${ae}/agents/${e}/browser-sessions/${t}/video`}function Zk(e,t){const n=window.location;return`${n.protocol==="https:"?"wss:":"ws:"}//${n.host}/browser-live/${e}/${t}`}function nR(e){return`${ae}/agents/${e}/export`}async function $y(e,t){const n=new URL(`${ae}/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 zy(e,t){const n=await fetch(`${ae}/agents/${e}/monitor/jobs/${t}`,{method:"DELETE"});if(!n.ok)throw new Error(`killJob: ${n.status}`)}async function rR(e){const t=await fetch(`${ae}/agents/${e}/monitor`);if(!t.ok)throw new Error(`fetchMonitor: ${t.status}`);return t.json()}async function iR(e,t=30){const n=await fetch(`${ae}/agents/${e}/usage?days=${t}`);if(!n.ok)throw new Error(`fetchUsage: ${n.status}`);return n.json()}async function sR(e){const t=await fetch(`${ae}/agents/${e}/schedules`);if(!t.ok)throw new Error(`fetchSchedules: ${t.status}`);return t.json()}async function oR(e,t,n){const r=await fetch(`${ae}/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 aR(e,t){const n=await fetch(`${ae}/agents/${e}/schedules/${t}`,{method:"DELETE"});if(!n.ok)throw new Error(`deleteSchedule: ${n.status}`)}async function lR(e,t){const n=await fetch(`${ae}/agents/${e}/schedules/${t}/trigger`,{method:"POST"});if(!n.ok)throw new Error(`triggerSchedule: ${n.status}`);return n.json()}async function cR(e,t){const n=await fetch(`${ae}/agents/${e}/schedules/${t}/runs`);if(!n.ok)throw new Error(`fetchScheduleRuns: ${n.status}`);return n.json()}async function uR(e,t){const n=await fetch(`${ae}/agents/${e}/messages?channelId=${encodeURIComponent(t)}&sortBy=asc&limit=200`);if(!n.ok)throw new Error(`fetchScheduleRunMessages: ${n.status}`);return n.json()}async function dR(e){const t=await fetch(`${ae}/agents/${e}/workflows`);if(!t.ok)throw new Error(`fetchWorkflows: ${t.status}`);return t.json()}async function hR(e,t){const n=await fetch(`${ae}/agents/${e}/workflows/${t}`);if(!n.ok)throw new Error(`fetchWorkflow: ${n.status}`);return n.json()}async function wh(e,t){const n=await fetch(`${ae}/agents/${e}/workflows/${t}/runs`);if(!n.ok)throw new Error(`fetchWorkflowRuns: ${n.status}`);return n.json()}async function fR(e,t,n){const r=await fetch(`${ae}/agents/${e}/workflows/${t}/runs/${n}`);if(!r.ok)throw new Error(`fetchWorkflowRun: ${r.status}`);return r.json()}async function pR(e,t){const n=await fetch(`${ae}/agents/${e}/workflows/${t}/run`,{method:"POST"});if(!n.ok)throw new Error(`triggerWorkflowRun: ${n.status}`);return n.json()}async function gR(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(`${ae}/logs?${t}`);if(!n.ok)throw new Error(`fetchLogs: ${n.status}`);return n.json()}async function eS(){const e=await fetch(`${ae}/settings/provider`);if(!e.ok)throw new Error("Failed to fetch provider settings");return e.json()}const kh={showWorkspaceDirConfig:!0,showBraveSearchConfig:!0,enableIntegrations:!1};async function tS(){try{const e=await fetch(`${ae}/settings/app`);if(!e.ok)return{...kh};const t=await e.json();return{...kh,...t}}catch{return{...kh}}}async function By(e,t,n){if(!(await fetch(`${ae}/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 mR(e){if(!(await fetch(`${ae}/settings/providers/${encodeURIComponent(e)}`,{method:"DELETE"})).ok)throw new Error("Failed to remove provider")}async function xR(){const e=await fetch(`${ae}/settings/search`);return e.ok?e.json():{provider:"brave",configured:!1}}async function vR(e,t){const n=await fetch(`${ae}/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 yR(){const e=await fetch(`${ae}/settings/search`,{method:"DELETE"});if(!e.ok&&e.status!==204&&e.status!==404)throw new Error(`Failed to clear search settings: ${e.status}`)}const bR={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"}]},nS=[{value:"google",label:"Google Gemini"},{value:"openai",label:"OpenAI"},{value:"anthropic",label:"Anthropic"},{value:"groq",label:"Groq"},{value:"openrouter",label:"OpenRouter"}];function dd(e){return bR[e]??[]}function Mp(e){var t;return((t=dd(e)[0])==null?void 0:t.value)??""}const ba="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",_R="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",rS="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",wR="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",Pc="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",Hy=Pc.replace("text-sm","text-sm font-mono"),el="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",Nc=`${Ws} bg-surface-container border border-outline-variant/40 text-on-surface-variant`,Rp=`${Ws} bg-success/10 border border-success/20 text-success`,Vy=`${Ws} bg-warning/10 border border-warning/20 text-warning`;function kR({agent:e,onDelete:t}){const n=rs(),{t:r}=Pe(),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?Rp:Nc,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:`${wR} sm:opacity-0 sm:group-hover:opacity-100`,children:r("dashboard.delete")})})]})}function SR(){const{t:e}=Pe(),[t,n]=P.useState([]),[r,i]=P.useState(!0),[s,o]=P.useState(null),[a,l]=P.useState({showWorkspaceDirConfig:!0,showBraveSearchConfig:!0,enableIntegrations:!1}),[c,u]=P.useState(!1),[d,h]=P.useState(""),[p,g]=P.useState(""),[m,v]=P.useState(""),[x,y]=P.useState(""),[b,k]=P.useState(""),[w,_]=P.useState(!1),[N,E]=P.useState(!1),[T,S]=P.useState(null),M=P.useRef(null);async function A(C){var te,j;const Q=(te=C.target.files)==null?void 0:te[0];if(Q){E(!0),S(null);try{let re;try{re=await $y(Q)}catch(le){const oe=le instanceof Error?le.message:String(le);if(oe.includes("already exists")){const R=(j=prompt(`${oe}
|
|
91
91
|
|
|
92
92
|
Enter a new id for the imported agent:`,""))==null?void 0:j.trim();if(!R){E(!1);return}re=await $y(Q,{id:R})}else throw le}await F(),H(`/agents/${re.id}/chat`)}catch(re){S(re instanceof Error?re.message:e("dashboard.importFailed"))}finally{E(!1),M.current&&(M.current.value="")}}}const F=()=>{Promise.all([Iy(),eS(),tS()]).then(([C,Q,te])=>{var j;if(n(C),o(Q),l(te),!m){const re=(j=Q.providers)==null?void 0:j[0];re&&(v(re.provider),y(re.model))}}).catch(console.error).finally(()=>i(!1))};P.useEffect(()=>{F();const C=setInterval(()=>{Iy().then(n).catch(()=>{})},2e3);return()=>clearInterval(C)},[]);const H=rs(),O=(s==null?void 0:s.providers)??[],q=m?dd(m):[];function X(C){v(C),y(Mp(C))}async function I(){if(!(!d.trim()||!p.trim())){_(!0),S(null);try{const C=d.trim();await zM(C,p.trim(),x,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,Q){confirm(e("dashboard.deleteConfirm",{name:Q,id:C}))&&(await BM(C),F())}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(yv,{to:"/settings",className:ba,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(yv,{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:A,className:"hidden"}),f.jsx("button",{onClick:()=>{var C;return(C=M.current)==null?void 0:C.click()},disabled:N||!(s!=null&&s.configured),className:_R,title:e("dashboard.importTitle"),children:e(N?"dashboard.importing":"dashboard.import")}),f.jsx("button",{onClick:()=>u(C=>!C),disabled:!(s!=null&&s.configured),className:ba,children:e(c?"dashboard.cancel":"dashboard.newAgent")})]})]}),c&&f.jsxs("div",{className:`${el} 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:Hy,placeholder:e("dashboard.agentIdPlaceholder"),value:d,onChange:C=>h(C.target.value.toLowerCase().replace(/[^a-z0-9-]/g,""))}),f.jsx("input",{className:Pc,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:`${Pc} appearance-none`,value:m,onChange:C=>X(C.target.value),children:O.map(C=>f.jsx("option",{value:C.provider,children:C.label??C.provider},C.provider))}),f.jsx("select",{className:`${Pc} appearance-none`,value:x,onChange:C=>y(C.target.value),children:q.map(C=>f.jsx("option",{value:C.value,children:C.label},C.value))})]}),a.showWorkspaceDirConfig&&f.jsx("input",{className:Hy,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()||!x,className:ba,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(kR,{agent:C,onDelete:()=>z(C.id,C.name)},C.id))})]})}function CR(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const ER=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,PR=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,NR={};function Wy(e,t){return(NR.jsx?PR:ER).test(e)}const jR=/[ \t\n\f\r]/g;function TR(e){return typeof e=="object"?e.type==="text"?Uy(e.value):!1:Uy(e)}function Uy(e){return e.replace(jR,"")===""}class ml{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}ml.prototype.normal={};ml.prototype.property={};ml.prototype.space=void 0;function iS(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new ml(n,r,t)}function Ap(e){return e.toLowerCase()}class Zt{constructor(t,n){this.attribute=n,this.property=t}}Zt.prototype.attribute="";Zt.prototype.booleanish=!1;Zt.prototype.boolean=!1;Zt.prototype.commaOrSpaceSeparated=!1;Zt.prototype.commaSeparated=!1;Zt.prototype.defined=!1;Zt.prototype.mustUseProperty=!1;Zt.prototype.number=!1;Zt.prototype.overloadedBoolean=!1;Zt.prototype.property="";Zt.prototype.spaceSeparated=!1;Zt.prototype.space=void 0;let MR=0;const he=is(),st=is(),Dp=is(),B=is(),Ie=is(),Us=is(),nn=is();function is(){return 2**++MR}const Ip=Object.freeze(Object.defineProperty({__proto__:null,boolean:he,booleanish:st,commaOrSpaceSeparated:nn,commaSeparated:Us,number:B,overloadedBoolean:Dp,spaceSeparated:Ie},Symbol.toStringTag,{value:"Module"})),Sh=Object.keys(Ip);class _m extends Zt{constructor(t,n,r,i){let s=-1;if(super(t,n),qy(this,"space",i),typeof r=="number")for(;++s<Sh.length;){const o=Sh[s];qy(this,Sh[s],(r&Ip[o])===Ip[o])}}}_m.prototype.defined=!0;function qy(e,t,n){n&&(e[t]=n)}function go(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const s=new _m(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[Ap(r)]=r,n[Ap(s.attribute)]=r}return new ml(t,n,e.space)}const sS=go({properties:{ariaActiveDescendant:null,ariaAtomic:st,ariaAutoComplete:null,ariaBusy:st,ariaChecked:st,ariaColCount:B,ariaColIndex:B,ariaColSpan:B,ariaControls:Ie,ariaCurrent:null,ariaDescribedBy:Ie,ariaDetails:null,ariaDisabled:st,ariaDropEffect:Ie,ariaErrorMessage:null,ariaExpanded:st,ariaFlowTo:Ie,ariaGrabbed:st,ariaHasPopup:null,ariaHidden:st,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Ie,ariaLevel:B,ariaLive:null,ariaModal:st,ariaMultiLine:st,ariaMultiSelectable:st,ariaOrientation:null,ariaOwns:Ie,ariaPlaceholder:null,ariaPosInSet:B,ariaPressed:st,ariaReadOnly:st,ariaRelevant:null,ariaRequired:st,ariaRoleDescription:Ie,ariaRowCount:B,ariaRowIndex:B,ariaRowSpan:B,ariaSelected:st,ariaSetSize:B,ariaSort:null,ariaValueMax:B,ariaValueMin:B,ariaValueNow:B,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function oS(e,t){return t in e?e[t]:t}function aS(e,t){return oS(e,t.toLowerCase())}const RR=go({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Us,acceptCharset:Ie,accessKey:Ie,action:null,allow:null,allowFullScreen:he,allowPaymentRequest:he,allowUserMedia:he,alt:null,as:null,async:he,autoCapitalize:null,autoComplete:Ie,autoFocus:he,autoPlay:he,blocking:Ie,capture:null,charSet:null,checked:he,cite:null,className:Ie,cols:B,colSpan:null,content:null,contentEditable:st,controls:he,controlsList:Ie,coords:B|Us,crossOrigin:null,data:null,dateTime:null,decoding:null,default:he,defer:he,dir:null,dirName:null,disabled:he,download:Dp,draggable:st,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:he,formTarget:null,headers:Ie,height:B,hidden:Dp,high:B,href:null,hrefLang:null,htmlFor:Ie,httpEquiv:Ie,id:null,imageSizes:null,imageSrcSet:null,inert:he,inputMode:null,integrity:null,is:null,isMap:he,itemId:null,itemProp:Ie,itemRef:Ie,itemScope:he,itemType:Ie,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:he,low:B,manifest:null,max:null,maxLength:B,media:null,method:null,min:null,minLength:B,multiple:he,muted:he,name:null,nonce:null,noModule:he,noValidate:he,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:he,optimum:B,pattern:null,ping:Ie,placeholder:null,playsInline:he,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:he,referrerPolicy:null,rel:Ie,required:he,reversed:he,rows:B,rowSpan:B,sandbox:Ie,scope:null,scoped:he,seamless:he,selected:he,shadowRootClonable:he,shadowRootDelegatesFocus:he,shadowRootMode:null,shape:null,size:B,sizes:null,slot:null,span:B,spellCheck:st,src:null,srcDoc:null,srcLang:null,srcSet:null,start:B,step:null,style:null,tabIndex:B,target:null,title:null,translate:null,type:null,typeMustMatch:he,useMap:null,value:st,width:B,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Ie,axis:null,background:null,bgColor:null,border:B,borderColor:null,bottomMargin:B,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:he,declare:he,event:null,face:null,frame:null,frameBorder:null,hSpace:B,leftMargin:B,link:null,longDesc:null,lowSrc:null,marginHeight:B,marginWidth:B,noResize:he,noHref:he,noShade:he,noWrap:he,object:null,profile:null,prompt:null,rev:null,rightMargin:B,rules:null,scheme:null,scrolling:st,standby:null,summary:null,text:null,topMargin:B,valueType:null,version:null,vAlign:null,vLink:null,vSpace:B,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:he,disableRemotePlayback:he,prefix:null,property:null,results:B,security:null,unselectable:null},space:"html",transform:aS}),AR=go({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:nn,accentHeight:B,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:B,amplitude:B,arabicForm:null,ascent:B,attributeName:null,attributeType:null,azimuth:B,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:B,by:null,calcMode:null,capHeight:B,className:Ie,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:B,diffuseConstant:B,direction:null,display:null,dur:null,divisor:B,dominantBaseline:null,download:he,dx:null,dy:null,edgeMode:null,editable:null,elevation:B,enableBackground:null,end:null,event:null,exponent:B,externalResourcesRequired:null,fill:null,fillOpacity:B,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:Us,g2:Us,glyphName:Us,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:B,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:B,horizOriginX:B,horizOriginY:B,id:null,ideographic:B,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:B,k:B,k1:B,k2:B,k3:B,k4:B,kernelMatrix:nn,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:B,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:B,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:B,overlineThickness:B,paintOrder:null,panose1:null,path:null,pathLength:B,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Ie,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:B,pointsAtY:B,pointsAtZ:B,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:nn,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:nn,rev:nn,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:nn,requiredFeatures:nn,requiredFonts:nn,requiredFormats:nn,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:B,specularExponent:B,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:B,strikethroughThickness:B,string:null,stroke:null,strokeDashArray:nn,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:B,strokeOpacity:B,strokeWidth:null,style:null,surfaceScale:B,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:nn,tabIndex:B,tableValues:null,target:null,targetX:B,targetY:B,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:nn,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:B,underlineThickness:B,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:B,values:null,vAlphabetic:B,vMathematical:B,vectorEffect:null,vHanging:B,vIdeographic:B,version:null,vertAdvY:B,vertOriginX:B,vertOriginY:B,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:B,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:oS}),lS=go({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()}}),cS=go({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:aS}),uS=go({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),DR={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"},IR=/[A-Z]/g,Gy=/-[a-z]/g,OR=/^data[-\w.:]+$/i;function LR(e,t){const n=Ap(t);let r=t,i=Zt;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&OR.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(Gy,$R);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!Gy.test(s)){let o=s.replace(IR,FR);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}i=_m}return new i(r,t)}function FR(e){return"-"+e.toLowerCase()}function $R(e){return e.charAt(1).toUpperCase()}const zR=iS([sS,RR,lS,cS,uS],"html"),wm=iS([sS,AR,lS,cS,uS],"svg");function BR(e){return e.join(" ").trim()}var km={},Ky=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,HR=/\n/g,VR=/^\s*/,WR=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,UR=/^:\s*/,qR=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,GR=/^[;\s]*/,KR=/^\s+|\s+$/g,YR=`
|
|
93
93
|
`,Yy="/",Xy="*",Di="",XR="comment",JR="declaration";function QR(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(HR);m&&(n+=m.length);var v=g.lastIndexOf(YR);r=~v?g.length-v:r+g.length}function s(){var g={line:n,column:r};return function(m){return m.position=new o(g),c(),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 v=m[0];return i(v),e=e.slice(v.length),m}}function c(){l(VR)}function u(g){var m;for(g=g||[];m=d();)m!==!1&&g.push(m);return g}function d(){var g=s();if(!(Yy!=e.charAt(0)||Xy!=e.charAt(1))){for(var m=2;Di!=e.charAt(m)&&(Xy!=e.charAt(m)||Yy!=e.charAt(m+1));)++m;if(m+=2,Di===e.charAt(m-1))return a("End of comment missing");var v=e.slice(2,m-2);return r+=2,i(v),e=e.slice(m),r+=2,g({type:XR,comment:v})}}function h(){var g=s(),m=l(WR);if(m){if(d(),!l(UR))return a("property missing ':'");var v=l(qR),x=g({type:JR,property:Jy(m[0].replace(Ky,Di)),value:v?Jy(v[0].replace(Ky,Di)):Di});return l(GR),x}}function p(){var g=[];u(g);for(var m;m=h();)m!==!1&&(g.push(m),u(g));return g}return c(),p()}function Jy(e){return e?e.replace(KR,Di):Di}var ZR=QR,eA=Hc&&Hc.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(km,"__esModule",{value:!0});km.default=nA;const tA=eA(ZR);function nA(e,t){let n=null;if(!e||typeof e!="string")return n;const r=(0,tA.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 hd={};Object.defineProperty(hd,"__esModule",{value:!0});hd.camelCase=void 0;var rA=/^--[a-zA-Z0-9_-]+$/,iA=/-([a-z])/g,sA=/^[^-]+$/,oA=/^-(webkit|moz|ms|o|khtml)-/,aA=/^-(ms)-/,lA=function(e){return!e||sA.test(e)||rA.test(e)},cA=function(e,t){return t.toUpperCase()},Qy=function(e,t){return"".concat(t,"-")},uA=function(e,t){return t===void 0&&(t={}),lA(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(aA,Qy):e=e.replace(oA,Qy),e.replace(iA,cA))};hd.camelCase=uA;var dA=Hc&&Hc.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},hA=dA(km),fA=hd;function Op(e,t){var n={};return!e||typeof e!="string"||(0,hA.default)(e,function(r,i){r&&i&&(n[(0,fA.camelCase)(r,t)]=i)}),n}Op.default=Op;var pA=Op;const gA=lg(pA),dS=hS("end"),Sm=hS("start");function hS(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 mA(e){const t=Sm(e),n=dS(e);if(t&&n)return{start:t,end:n}}function _a(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?Zy(e.position):"start"in e||"end"in e?Zy(e):"line"in e||"column"in e?Lp(e):""}function Lp(e){return e0(e&&e.line)+":"+e0(e&&e.column)}function Zy(e){return Lp(e&&e.start)+"-"+Lp(e&&e.end)}function e0(e){return e&&typeof e=="number"?e:1}class At 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=_a(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}}At.prototype.file="";At.prototype.name="";At.prototype.reason="";At.prototype.message="";At.prototype.stack="";At.prototype.column=void 0;At.prototype.line=void 0;At.prototype.ancestors=void 0;At.prototype.cause=void 0;At.prototype.fatal=void 0;At.prototype.place=void 0;At.prototype.ruleId=void 0;At.prototype.source=void 0;const Cm={}.hasOwnProperty,xA=new Map,vA=/[A-Z]/g,yA=new Set(["table","tbody","thead","tfoot","tr"]),bA=new Set(["td","th"]),fS="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function _A(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=jA(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=NA(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"?wm:zR,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},s=pS(i,e,void 0);return s&&typeof s!="string"?s:i.create(e,i.Fragment,{children:s||void 0},void 0)}function pS(e,t,n){if(t.type==="element")return wA(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return kA(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return CA(e,t,n);if(t.type==="mdxjsEsm")return SA(e,t);if(t.type==="root")return EA(e,t,n);if(t.type==="text")return PA(e,t)}function wA(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=wm,e.schema=i),e.ancestors.push(t);const s=mS(e,t.tagName,!1),o=TA(e,t);let a=Pm(e,t);return yA.has(t.tagName)&&(a=a.filter(function(l){return typeof l=="string"?!TR(l):!0})),gS(e,o,s,t),Em(o,a),e.ancestors.pop(),e.schema=r,e.create(t,s,o,n)}function kA(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)}tl(e,t.position)}function SA(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);tl(e,t.position)}function CA(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=wm,e.schema=i),e.ancestors.push(t);const s=t.name===null?e.Fragment:mS(e,t.name,!0),o=MA(e,t),a=Pm(e,t);return gS(e,o,s,t),Em(o,a),e.ancestors.pop(),e.schema=r,e.create(t,s,o,n)}function EA(e,t,n){const r={};return Em(r,Pm(e,t)),e.create(t,e.Fragment,r,n)}function PA(e,t){return t.value}function gS(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Em(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function NA(e,t,n){return r;function r(i,s,o,a){const c=Array.isArray(o.children)?n:t;return a?c(s,o,a):c(s,o)}}function jA(e,t){return n;function n(r,i,s,o){const a=Array.isArray(s.children),l=Sm(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 TA(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&Cm.call(t.properties,i)){const s=RA(e,i,t.properties[i]);if(s){const[o,a]=s;e.tableCellAlignToStyle&&o==="align"&&typeof a=="string"&&bA.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 MA(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 tl(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 tl(e,t.position);else s=r.value===null?!0:r.value;n[i]=s}return n}function Pm(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:xA;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 c=i.get(l)||0;o=l+"-"+c,i.set(l,c+1)}}const a=pS(e,s,o);a!==void 0&&n.push(a)}return n}function RA(e,t,n){const r=LR(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?CR(n):BR(n)),r.property==="style"){let i=typeof n=="object"?n:AA(e,String(n));return e.stylePropertyNameCase==="css"&&(i=DA(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?DR[r.property]||r.property:r.attribute,n]}}function AA(e,t){try{return gA(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,i=new At("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=fS+"#cannot-parse-style-attribute",i}}function mS(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=Wy(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=Wy(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const i=r.value;return Cm.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);tl(e)}function tl(e,t){const n=new At("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=fS+"#cannot-handle-mdx-estrees-without-createevaluater",n}function DA(e){const t={};let n;for(n in e)Cm.call(e,n)&&(t[IA(n)]=e[n]);return t}function IA(e){let t=e.replace(vA,OA);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function OA(e){return"-"+e.toLowerCase()}const Ch={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"]},LA={};function Nm(e,t){const n=LA,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return xS(e,r,i)}function xS(e,t,n){if(FA(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 t0(e.children,t,n)}return Array.isArray(e)?t0(e,t,n):""}function t0(e,t,n){const r=[];let i=-1;for(;++i<e.length;)r[i]=xS(e[i],t,n);return r.join("")}function FA(e){return!!(e&&typeof e=="object")}const n0=document.createElement("i");function jm(e){const t="&"+e+";";n0.innerHTML=t;const n=n0.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function dn(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 wn(e,t){return e.length>0?(dn(e,e.length,0,t),e):t}const r0={}.hasOwnProperty;function vS(e){const t={};let n=-1;for(;++n<e.length;)$A(t,e[n]);return t}function $A(e,t){let n;for(n in t){const i=(r0.call(e,n)?e[n]:void 0)||(e[n]={}),s=t[n];let o;if(s)for(o in s){r0.call(i,o)||(i[o]=[]);const a=s[o];zA(i[o],Array.isArray(a)?a:a?[a]:[])}}}function zA(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);dn(e,0,0,r)}function yS(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 $n(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const $t=vi(/[A-Za-z]/),jt=vi(/[\dA-Za-z]/),BA=vi(/[#-'*+\--9=?A-Z^-~]/);function Mu(e){return e!==null&&(e<32||e===127)}const Fp=vi(/\d/),HA=vi(/[\dA-Fa-f]/),VA=vi(/[!-/:-@[-`{-~]/);function se(e){return e!==null&&e<-2}function De(e){return e!==null&&(e<0||e===32)}function pe(e){return e===-2||e===-1||e===32}const fd=vi(new RegExp("\\p{P}|\\p{S}","u")),Ji=vi(/\s/);function vi(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function mo(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const s=e.charCodeAt(n);let o="";if(s===37&&jt(e.charCodeAt(n+1))&&jt(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 _e(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 WA={tokenize:UA};function UA(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"),_e(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 qA={tokenize:GA},i0={tokenize:KA};function GA(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,c)(b)}return c(b)}function l(b){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&y();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}x(r);let N=k;for(;N<t.events.length;)t.events[N][1].end={..._},N++;return dn(t.events,w+1,0,t.events.slice(k)),t.events.length=N,c(b)}return a(b)}function c(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(i0,u,d)(b)}function u(b){return i&&y(),x(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(i0,p,g)(b)}function p(b){return r++,n.push([t.currentConstruct,t.containerState]),h(b)}function g(b){if(b===null){i&&y(),x(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){v(e.exit("chunkFlow"),!0),x(0),e.consume(b);return}return se(b)?(e.consume(b),v(e.exit("chunkFlow")),r=0,t.interrupt=void 0,a):(e.consume(b),m)}function v(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 N=t.events.length;let E=N,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(x(r),_=N;_<t.events.length;)t.events[_][1].end={...S},_++;dn(t.events,E+1,0,t.events.slice(N)),t.events.length=_}}function x(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 y(){i.write([null]),s=void 0,i=void 0,t.containerState._closeFlow=void 0}}function KA(e,t,n){return _e(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function so(e){if(e===null||De(e)||Ji(e))return 1;if(fd(e))return 2}function pd(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 $p={name:"attention",resolveAll:YA,tokenize:XA};function YA(e,t){let n=-1,r,i,s,o,a,l,c,u;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};s0(d,-l),s0(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},c=[],e[r][1].end.offset-e[r][1].start.offset&&(c=wn(c,[["enter",e[r][1],t],["exit",e[r][1],t]])),c=wn(c,[["enter",i,t],["enter",o,t],["exit",o,t],["enter",s,t]]),c=wn(c,pd(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),c=wn(c,[["exit",s,t],["enter",a,t],["exit",a,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,c=wn(c,[["enter",e[n][1],t],["exit",e[n][1],t]])):u=0,dn(e,r-1,n-r+3,c),n=r+c.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function XA(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=so(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 c=e.exit("attentionSequence"),u=so(l),d=!u||u===2&&i||n.includes(l),h=!i||i===2&&u||n.includes(r);return c._open=!!(s===42?d:d&&(i||!h)),c._close=!!(s===42?h:h&&(u||!d)),t(l)}}function s0(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const JA={name:"autolink",tokenize:QA};function QA(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 $t(p)?(e.consume(p),o):p===64?n(p):c(p)}function o(p){return p===43||p===45||p===46||jt(p)?(r=1,a(p)):c(p)}function a(p){return p===58?(e.consume(p),r=0,l):(p===43||p===45||p===46||jt(p))&&r++<32?(e.consume(p),a):(r=0,c(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||Mu(p)?n(p):(e.consume(p),l)}function c(p){return p===64?(e.consume(p),u):BA(p)?(e.consume(p),c):n(p)}function u(p){return jt(p)?d(p):n(p)}function d(p){return p===46?(e.consume(p),r=0,u):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||jt(p))&&r++<63){const g=p===45?h:d;return e.consume(p),g}return n(p)}}const xl={partial:!0,tokenize:ZA};function ZA(e,t,n){return r;function r(s){return pe(s)?_e(e,i,"linePrefix")(s):i(s)}function i(s){return s===null||se(s)?t(s):n(s)}}const bS={continuation:{tokenize:tD},exit:nD,name:"blockQuote",tokenize:eD};function eD(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 tD(e,t,n){const r=this;return i;function i(o){return pe(o)?_e(e,s,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o):s(o)}function s(o){return e.attempt(bS,t,n)(o)}}function nD(e){e.exit("blockQuote")}const _S={name:"characterEscape",tokenize:rD};function rD(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 VA(s)?(e.enter("characterEscapeValue"),e.consume(s),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(s)}}const wS={name:"characterReference",tokenize:iD};function iD(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"),c):(e.enter("characterReferenceValue"),s=31,o=jt,u(d))}function c(d){return d===88||d===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(d),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),s=6,o=HA,u):(e.enter("characterReferenceValue"),s=7,o=Fp,u(d))}function u(d){if(d===59&&i){const h=e.exit("characterReferenceValue");return o===jt&&!jm(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),u):n(d)}}const o0={partial:!0,tokenize:oD},a0={concrete:!0,name:"codeFenced",tokenize:sD};function sD(e,t,n){const r=this,i={partial:!0,tokenize:w};let s=0,o=0,a;return l;function l(_){return c(_)}function c(_){const N=r.events[r.events.length-1];return s=N&&N[1].type==="linePrefix"?N[2].sliceSerialize(N[1],!0).length:0,a=_,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),u(_)}function u(_){return _===a?(o++,e.consume(_),u):o<3?n(_):(e.exit("codeFencedFenceSequence"),pe(_)?_e(e,d,"whitespace")(_):d(_))}function d(_){return _===null||se(_)?(e.exit("codeFencedFence"),r.interrupt?t(_):e.check(o0,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"),_e(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,v)(_)}function v(_){return e.enter("lineEnding"),e.consume(_),e.exit("lineEnding"),x}function x(_){return s>0&&pe(_)?_e(e,y,"linePrefix",s+1)(_):y(_)}function y(_){return _===null||se(_)?e.check(o0,m,k)(_):(e.enter("codeFlowValue"),b(_))}function b(_){return _===null||se(_)?(e.exit("codeFlowValue"),y(_)):(e.consume(_),b)}function k(_){return e.exit("codeFenced"),t(_)}function w(_,N,E){let T=0;return S;function S(O){return _.enter("lineEnding"),_.consume(O),_.exit("lineEnding"),M}function M(O){return _.enter("codeFencedFence"),pe(O)?_e(_,A,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(O):A(O)}function A(O){return O===a?(_.enter("codeFencedFenceSequence"),F(O)):E(O)}function F(O){return O===a?(T++,_.consume(O),F):T>=o?(_.exit("codeFencedFenceSequence"),pe(O)?_e(_,H,"whitespace")(O):H(O)):E(O)}function H(O){return O===null||se(O)?(_.exit("codeFencedFence"),N(O)):E(O)}}}function oD(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 Eh={name:"codeIndented",tokenize:lD},aD={partial:!0,tokenize:cD};function lD(e,t,n){const r=this;return i;function i(c){return e.enter("codeIndented"),_e(e,s,"linePrefix",5)(c)}function s(c){const u=r.events[r.events.length-1];return u&&u[1].type==="linePrefix"&&u[2].sliceSerialize(u[1],!0).length>=4?o(c):n(c)}function o(c){return c===null?l(c):se(c)?e.attempt(aD,o,l)(c):(e.enter("codeFlowValue"),a(c))}function a(c){return c===null||se(c)?(e.exit("codeFlowValue"),o(c)):(e.consume(c),a)}function l(c){return e.exit("codeIndented"),t(c)}}function cD(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):_e(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 uD={name:"codeText",previous:hD,resolve:dD,tokenize:fD};function dD(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 hD(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function fD(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,u(d)):se(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),l):(e.enter("codeTextData"),c(d))}function c(d){return d===null||d===32||d===96||se(d)?(e.exit("codeTextData"),l(d)):(e.consume(d),c)}function u(d){return d===96?(e.consume(d),i++,u):i===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(d)):(s.type="codeTextData",c(d))}}class pD{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&&Lo(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),Lo(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Lo(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);Lo(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Lo(this.left,n.reverse())}}}function Lo(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 kS(e){const t={};let n=-1,r,i,s,o,a,l,c;const u=new pD(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type==="chunkFlow"&&u.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,gD(u,n)),n=t[n],c=!0);else if(r[1]._container){for(s=n,i=void 0;s--;)if(o=u.get(s),o[1].type==="lineEnding"||o[1].type==="lineEndingBlank")o[0]==="enter"&&(i&&(u.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={...u.get(i)[1].start},a=u.slice(i,n),a.unshift(r),u.splice(i,n-i+1,a))}}return dn(e,0,Number.POSITIVE_INFINITY,u.slice(0)),!c}function gD(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=[],c={};let u,d,h=-1,p=n,g=0,m=0;const v=[m];for(;p;){for(;e.get(++i)[1]!==p;);s.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),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,v.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):v.pop(),h=v.length;h--;){const x=a.slice(v[h],v[h+1]),y=s.pop();l.push([y,y+x.length-1]),e.splice(y,2,x)}for(l.reverse(),h=-1;++h<l.length;)c[g+l[h][0]]=g+l[h][1],g+=l[h][1]-l[h][0]-1;return c}const mD={resolve:vD,tokenize:yD},xD={partial:!0,tokenize:bD};function vD(e){return kS(e),e}function yD(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(xD,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 bD(e,t,n){const r=this;return i;function i(o){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),_e(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 SS(e,t,n,r,i,s,o,a,l){const c=l||Number.POSITIVE_INFINITY;let u=0;return d;function d(x){return x===60?(e.enter(r),e.enter(i),e.enter(s),e.consume(x),e.exit(s),h):x===null||x===32||x===41||Mu(x)?n(x):(e.enter(r),e.enter(o),e.enter(a),e.enter("chunkString",{contentType:"string"}),m(x))}function h(x){return x===62?(e.enter(s),e.consume(x),e.exit(s),e.exit(i),e.exit(r),t):(e.enter(a),e.enter("chunkString",{contentType:"string"}),p(x))}function p(x){return x===62?(e.exit("chunkString"),e.exit(a),h(x)):x===null||x===60||se(x)?n(x):(e.consume(x),x===92?g:p)}function g(x){return x===60||x===62||x===92?(e.consume(x),p):p(x)}function m(x){return!u&&(x===null||x===41||De(x))?(e.exit("chunkString"),e.exit(a),e.exit(o),e.exit(r),t(x)):u<c&&x===40?(e.consume(x),u++,m):x===41?(e.consume(x),u--,m):x===null||x===32||x===40||Mu(x)?n(x):(e.consume(x),x===92?v:m)}function v(x){return x===40||x===41||x===92?(e.consume(x),m):m(x)}}function CS(e,t,n,r,i,s){const o=this;let a=0,l;return c;function c(p){return e.enter(r),e.enter(i),e.consume(p),e.exit(i),e.enter(s),u}function u(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"),u):(e.enter("chunkString",{contentType:"string"}),d(p))}function d(p){return p===null||p===91||p===93||se(p)||a++>999?(e.exit("chunkString"),u(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 ES(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),c(h))}function c(h){return h===o?(e.exit(s),l(o)):h===null?n(h):se(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),_e(e,c,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),u(h))}function u(h){return h===o||h===null||se(h)?(e.exit("chunkString"),c(h)):(e.consume(h),h===92?d:u)}function d(h){return h===o||h===92?(e.consume(h),u):u(h)}}function wa(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)?_e(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const _D={name:"definition",tokenize:kD},wD={partial:!0,tokenize:SD};function kD(e,t,n){const r=this;let i;return s;function s(p){return e.enter("definition"),o(p)}function o(p){return CS.call(r,e,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(p)}function a(p){return i=$n(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 De(p)?wa(e,c)(p):c(p)}function c(p){return SS(e,u,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(p)}function u(p){return e.attempt(wD,d,d)(p)}function d(p){return pe(p)?_e(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 SD(e,t,n){return r;function r(a){return De(a)?wa(e,i)(a):n(a)}function i(a){return ES(e,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function s(a){return pe(a)?_e(e,o,"whitespace")(a):o(a)}function o(a){return a===null||se(a)?t(a):n(a)}}const CD={name:"hardBreakEscape",tokenize:ED};function ED(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 PD={name:"headingAtx",resolve:ND,tokenize:jD};function ND(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"},dn(e,r,n-r+1,[["enter",i,t],["enter",s,t],["exit",s,t],["exit",i,t]])),e}function jD(e,t,n){let r=0;return i;function i(u){return e.enter("atxHeading"),s(u)}function s(u){return e.enter("atxHeadingSequence"),o(u)}function o(u){return u===35&&r++<6?(e.consume(u),o):u===null||De(u)?(e.exit("atxHeadingSequence"),a(u)):n(u)}function a(u){return u===35?(e.enter("atxHeadingSequence"),l(u)):u===null||se(u)?(e.exit("atxHeading"),t(u)):pe(u)?_e(e,a,"whitespace")(u):(e.enter("atxHeadingText"),c(u))}function l(u){return u===35?(e.consume(u),l):(e.exit("atxHeadingSequence"),a(u))}function c(u){return u===null||u===35||De(u)?(e.exit("atxHeadingText"),a(u)):(e.consume(u),c)}}const TD=["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"],l0=["pre","script","style","textarea"],MD={concrete:!0,name:"htmlFlow",resolveTo:DD,tokenize:ID},RD={partial:!0,tokenize:LD},AD={partial:!0,tokenize:OD};function DD(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 ID(e,t,n){const r=this;let i,s,o,a,l;return c;function c(j){return u(j)}function u(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):$t(j)?(e.consume(j),o=String.fromCharCode(j),v):n(j)}function h(j){return j===45?(e.consume(j),i=2,p):j===91?(e.consume(j),i=5,a=0,g):$t(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 re="CDATA[";return j===re.charCodeAt(a++)?(e.consume(j),a===re.length?r.interrupt?t:A:g):n(j)}function m(j){return $t(j)?(e.consume(j),o=String.fromCharCode(j),v):n(j)}function v(j){if(j===null||j===47||j===62||De(j)){const re=j===47,le=o.toLowerCase();return!re&&!s&&l0.includes(le)?(i=1,r.interrupt?t(j):A(j)):TD.includes(o.toLowerCase())?(i=6,re?(e.consume(j),x):r.interrupt?t(j):A(j)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(j):s?y(j):b(j))}return j===45||jt(j)?(e.consume(j),o+=String.fromCharCode(j),v):n(j)}function x(j){return j===62?(e.consume(j),r.interrupt?t:A):n(j)}function y(j){return pe(j)?(e.consume(j),y):S(j)}function b(j){return j===47?(e.consume(j),S):j===58||j===95||$t(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||jt(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,N):pe(j)?(e.consume(j),_):E(j)}function N(j){return j===l?(e.consume(j),l=null,T):j===null||se(j)?n(j):(e.consume(j),N)}function E(j){return j===null||j===34||j===39||j===47||j===60||j===61||j===62||j===96||De(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)?A(j):pe(j)?(e.consume(j),M):n(j)}function A(j){return j===45&&i===2?(e.consume(j),q):j===60&&i===1?(e.consume(j),X):j===62&&i===4?(e.consume(j),Q):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(RD,te,F)(j)):j===null||se(j)?(e.exit("htmlFlowData"),F(j)):(e.consume(j),A)}function F(j){return e.check(AD,H,te)(j)}function H(j){return e.enter("lineEnding"),e.consume(j),e.exit("lineEnding"),O}function O(j){return j===null||se(j)?F(j):(e.enter("htmlFlowData"),A(j))}function q(j){return j===45?(e.consume(j),C):A(j)}function X(j){return j===47?(e.consume(j),o="",I):A(j)}function I(j){if(j===62){const re=o.toLowerCase();return l0.includes(re)?(e.consume(j),Q):A(j)}return $t(j)&&o.length<8?(e.consume(j),o+=String.fromCharCode(j),I):A(j)}function z(j){return j===93?(e.consume(j),C):A(j)}function C(j){return j===62?(e.consume(j),Q):j===45&&i===2?(e.consume(j),C):A(j)}function Q(j){return j===null||se(j)?(e.exit("htmlFlowData"),te(j)):(e.consume(j),Q)}function te(j){return e.exit("htmlFlow"),t(j)}}function OD(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 LD(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(xl,t,n)}}const FD={name:"htmlText",tokenize:$D};function $D(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),c):C===47?(e.consume(C),w):C===63?(e.consume(C),b):$t(C)?(e.consume(C),E):n(C)}function c(C){return C===45?(e.consume(C),u):C===91?(e.consume(C),s=0,g):$t(C)?(e.consume(C),y):n(C)}function u(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,X(C)):(e.consume(C),d)}function h(C){return C===45?(e.consume(C),p):d(C)}function p(C){return C===62?q(C):C===45?h(C):d(C)}function g(C){const Q="CDATA[";return C===Q.charCodeAt(s++)?(e.consume(C),s===Q.length?m:g):n(C)}function m(C){return C===null?n(C):C===93?(e.consume(C),v):se(C)?(o=m,X(C)):(e.consume(C),m)}function v(C){return C===93?(e.consume(C),x):m(C)}function x(C){return C===62?q(C):C===93?(e.consume(C),x):m(C)}function y(C){return C===null||C===62?q(C):se(C)?(o=y,X(C)):(e.consume(C),y)}function b(C){return C===null?n(C):C===63?(e.consume(C),k):se(C)?(o=b,X(C)):(e.consume(C),b)}function k(C){return C===62?q(C):b(C)}function w(C){return $t(C)?(e.consume(C),_):n(C)}function _(C){return C===45||jt(C)?(e.consume(C),_):N(C)}function N(C){return se(C)?(o=N,X(C)):pe(C)?(e.consume(C),N):q(C)}function E(C){return C===45||jt(C)?(e.consume(C),E):C===47||C===62||De(C)?T(C):n(C)}function T(C){return C===47?(e.consume(C),q):C===58||C===95||$t(C)?(e.consume(C),S):se(C)?(o=T,X(C)):pe(C)?(e.consume(C),T):q(C)}function S(C){return C===45||C===46||C===58||C===95||jt(C)?(e.consume(C),S):M(C)}function M(C){return C===61?(e.consume(C),A):se(C)?(o=M,X(C)):pe(C)?(e.consume(C),M):T(C)}function A(C){return C===null||C===60||C===61||C===62||C===96?n(C):C===34||C===39?(e.consume(C),i=C,F):se(C)?(o=A,X(C)):pe(C)?(e.consume(C),A):(e.consume(C),H)}function F(C){return C===i?(e.consume(C),i=void 0,O):C===null?n(C):se(C)?(o=F,X(C)):(e.consume(C),F)}function H(C){return C===null||C===34||C===39||C===60||C===61||C===96?n(C):C===47||C===62||De(C)?T(C):(e.consume(C),H)}function O(C){return C===47||C===62||De(C)?T(C):n(C)}function q(C){return C===62?(e.consume(C),e.exit("htmlTextData"),e.exit("htmlText"),t):n(C)}function X(C){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(C),e.exit("lineEnding"),I}function I(C){return pe(C)?_e(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 Tm={name:"labelEnd",resolveAll:VD,resolveTo:WD,tokenize:UD},zD={tokenize:qD},BD={tokenize:GD},HD={tokenize:KD};function VD(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&&dn(e,0,e.length,n),e}function WD(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}},c={type:"label",start:{...e[s][1].start},end:{...e[o][1].end}},u={type:"labelText",start:{...e[s+r+2][1].end},end:{...e[o-2][1].start}};return a=[["enter",l,t],["enter",c,t]],a=wn(a,e.slice(s+1,s+r+3)),a=wn(a,[["enter",u,t]]),a=wn(a,pd(t.parser.constructs.insideSpan.null,e.slice(s+r+4,o-3),t)),a=wn(a,[["exit",u,t],e[o-2],e[o-1],["exit",c,t]]),a=wn(a,e.slice(o+1)),a=wn(a,[["exit",l,t]]),dn(e,s,e.length,a),e}function UD(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($n(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(zD,u,o?u:d)(h):h===91?e.attempt(BD,u,o?c:d)(h):o?u(h):d(h)}function c(h){return e.attempt(HD,u,d)(h)}function u(h){return t(h)}function d(h){return s._balanced=!0,n(h)}}function qD(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 De(d)?wa(e,s)(d):s(d)}function s(d){return d===41?u(d):SS(e,o,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(d)}function o(d){return De(d)?wa(e,l)(d):u(d)}function a(d){return n(d)}function l(d){return d===34||d===39||d===40?ES(e,c,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(d):u(d)}function c(d){return De(d)?wa(e,u)(d):u(d)}function u(d){return d===41?(e.enter("resourceMarker"),e.consume(d),e.exit("resourceMarker"),e.exit("resource"),t):n(d)}}function GD(e,t,n){const r=this;return i;function i(a){return CS.call(r,e,s,o,"reference","referenceMarker","referenceString")(a)}function s(a){return r.parser.defined.includes($n(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(a):n(a)}function o(a){return n(a)}}function KD(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 YD={name:"labelStartImage",resolveAll:Tm.resolveAll,tokenize:XD};function XD(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 JD={name:"labelStartLink",resolveAll:Tm.resolveAll,tokenize:QD};function QD(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 Ph={name:"lineEnding",tokenize:ZD};function ZD(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),_e(e,t,"linePrefix")}}const jc={name:"thematicBreak",tokenize:eI};function eI(e,t,n){let r=0,i;return s;function s(c){return e.enter("thematicBreak"),o(c)}function o(c){return i=c,a(c)}function a(c){return c===i?(e.enter("thematicBreakSequence"),l(c)):r>=3&&(c===null||se(c))?(e.exit("thematicBreak"),t(c)):n(c)}function l(c){return c===i?(e.consume(c),r++,l):(e.exit("thematicBreakSequence"),pe(c)?_e(e,a,"whitespace")(c):a(c))}}const Wt={continuation:{tokenize:iI},exit:oI,name:"list",tokenize:rI},tI={partial:!0,tokenize:aI},nI={partial:!0,tokenize:sI};function rI(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:Fp(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(jc,n,c)(p):c(p);if(!r.interrupt||p===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),l(p)}return n(p)}function l(p){return Fp(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"),c(p)):n(p)}function c(p){return e.enter("listItemMarker"),e.consume(p),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||p,e.check(xl,r.interrupt?n:u,e.attempt(tI,h,d))}function u(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 iI(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(xl,i,s);function i(a){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,_e(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(nI,t,o)(a))}function o(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,_e(e,e.attempt(Wt,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function sI(e,t,n){const r=this;return _e(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 oI(e){e.exit(this.containerState.type)}function aI(e,t,n){const r=this;return _e(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 c0={name:"setextUnderline",resolveTo:lI,tokenize:cI};function lI(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 cI(e,t,n){const r=this;let i;return s;function s(c){let u=r.events.length,d;for(;u--;)if(r.events[u][1].type!=="lineEnding"&&r.events[u][1].type!=="linePrefix"&&r.events[u][1].type!=="content"){d=r.events[u][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||d)?(e.enter("setextHeadingLine"),i=c,o(c)):n(c)}function o(c){return e.enter("setextHeadingLineSequence"),a(c)}function a(c){return c===i?(e.consume(c),a):(e.exit("setextHeadingLineSequence"),pe(c)?_e(e,l,"lineSuffix")(c):l(c))}function l(c){return c===null||se(c)?(e.exit("setextHeadingLine"),t(c)):n(c)}}const uI={tokenize:dI};function dI(e){const t=this,n=e.attempt(xl,r,e.attempt(this.parser.constructs.flowInitial,i,_e(e,e.attempt(this.parser.constructs.flow,i,e.attempt(mD,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 hI={resolveAll:NS()},fI=PS("string"),pI=PS("text");function PS(e){return{resolveAll:NS(e==="text"?gI: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(u){return c(u)?s(u):a(u)}function a(u){if(u===null){n.consume(u);return}return n.enter("data"),n.consume(u),l}function l(u){return c(u)?(n.exit("data"),s(u)):(n.consume(u),l)}function c(u){if(u===null)return!0;const d=i[u];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 NS(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 gI(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 c=i[s];if(typeof c=="string"){for(o=c.length;c.charCodeAt(o-1)===32;)a++,o--;if(o)break;o=-1}else if(c===-2)l=!0,a++;else if(c!==-1){s++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(a=0),a){const c={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={...c.start},r.start.offset===r.end.offset?Object.assign(r,c):(e.splice(n,0,["enter",c,t],["exit",c,t]),n+=2)}n++}return e}const mI={42:Wt,43:Wt,45:Wt,48:Wt,49:Wt,50:Wt,51:Wt,52:Wt,53:Wt,54:Wt,55:Wt,56:Wt,57:Wt,62:bS},xI={91:_D},vI={[-2]:Eh,[-1]:Eh,32:Eh},yI={35:PD,42:jc,45:[c0,jc],60:MD,61:c0,95:jc,96:a0,126:a0},bI={38:wS,92:_S},_I={[-5]:Ph,[-4]:Ph,[-3]:Ph,33:YD,38:wS,42:$p,60:[JA,FD],91:JD,92:[CD,_S],93:Tm,95:$p,96:uD},wI={null:[$p,hI]},kI={null:[42,95]},SI={null:[]},CI=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:kI,contentInitial:xI,disable:SI,document:mI,flow:yI,flowInitial:vI,insideSpan:wI,string:bI,text:_I},Symbol.toStringTag,{value:"Module"}));function EI(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:N(w),check:N(_),consume:y,enter:b,exit:k,interrupt:N(_,{interrupt:!0})},c={code:null,containerState:{},defineSkip:m,events:[],now:g,parser:e,previous:null,sliceSerialize:h,sliceStream:p,write:d};let u=t.tokenize.call(c,l);return t.resolveAll&&s.push(t),c;function d(M){return o=wn(o,M),v(),o[o.length-1]!==null?[]:(E(t,0),c.events=pd(s,c.events,c),c.events)}function h(M,A){return NI(p(M),A)}function p(M){return PI(o,M)}function g(){const{_bufferIndex:M,_index:A,line:F,column:H,offset:O}=r;return{_bufferIndex:M,_index:A,line:F,column:H,offset:O}}function m(M){i[M.line]=M.column,S()}function v(){let M;for(;r._index<o.length;){const A=o[r._index];if(typeof A=="string")for(M=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===M&&r._bufferIndex<A.length;)x(A.charCodeAt(r._bufferIndex));else x(A)}}function x(M){u=u(M)}function y(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++)),c.previous=M}function b(M,A){const F=A||{};return F.type=M,F.start=g(),c.events.push(["enter",F,c]),a.push(F),F}function k(M){const A=a.pop();return A.end=g(),c.events.push(["exit",A,c]),A}function w(M,A){E(M,A.from)}function _(M,A){A.restore()}function N(M,A){return F;function F(H,O,q){let X,I,z,C;return Array.isArray(H)?te(H):"tokenize"in H?te([H]):Q(H);function Q(oe){return R;function R(ie){const ee=ie!==null&&oe[ie],Ne=ie!==null&&oe.null,Ze=[...Array.isArray(ee)?ee:ee?[ee]:[],...Array.isArray(Ne)?Ne:Ne?[Ne]:[]];return te(Ze)(ie)}}function te(oe){return X=oe,I=0,oe.length===0?q:j(oe[I])}function j(oe){return R;function R(ie){return C=T(),z=oe,oe.partial||(c.currentConstruct=oe),oe.name&&c.parser.constructs.disable.null.includes(oe.name)?le():oe.tokenize.call(A?Object.assign(Object.create(c),A):c,l,re,le)(ie)}}function re(oe){return M(z,C),O}function le(oe){return C.restore(),++I<X.length?j(X[I]):q}}}function E(M,A){M.resolveAll&&!s.includes(M)&&s.push(M),M.resolve&&dn(c.events,A,c.events.length-A,M.resolve(c.events.slice(A),c)),M.resolveTo&&(c.events=M.resolveTo(c.events,c))}function T(){const M=g(),A=c.previous,F=c.currentConstruct,H=c.events.length,O=Array.from(a);return{from:H,restore:q};function q(){r=M,c.previous=A,c.currentConstruct=F,c.events.length=H,a=O,S()}}function S(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function PI(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 NI(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=`
|
|
@@ -136,7 +136,7 @@ Enter a new id for the imported agent:`,""))==null?void 0:j.trim();if(!R){E(!1);
|
|
|
136
136
|
* Released under the MIT License
|
|
137
137
|
*/class O3{constructor(){this._request=null,this._charts=new Map,this._running=!1,this._lastDate=void 0}_notify(t,n,r,i){const s=n.listeners[i],o=n.duration;s.forEach(a=>a({chart:t,initial:n.initial,numSteps:o,currentStep:Math.min(r-n.start,o)}))}_refresh(){this._request||(this._running=!0,this._request=SC.call(window,()=>{this._update(),this._request=null,this._running&&this._refresh()}))}_update(t=Date.now()){let n=0;this._charts.forEach((r,i)=>{if(!r.running||!r.items.length)return;const s=r.items;let o=s.length-1,a=!1,l;for(;o>=0;--o)l=s[o],l._active?(l._total>r.duration&&(r.duration=l._total),l.tick(t),a=!0):(s[o]=s[s.length-1],s.pop());a&&(i.draw(),this._notify(i,r,t,"progress")),s.length||(r.running=!1,this._notify(i,r,t,"complete"),r.initial=!1),n+=s.length}),this._lastDate=t,n===0&&(this._running=!1)}_getAnims(t){const n=this._charts;let r=n.get(t);return r||(r={running:!1,initial:!0,items:[],listeners:{complete:[],progress:[]}},n.set(t,r)),r}listen(t,n,r){this._getAnims(t).listeners[n].push(r)}add(t,n){!n||!n.length||this._getAnims(t).items.push(...n)}has(t){return this._getAnims(t).items.length>0}start(t){const n=this._charts.get(t);n&&(n.running=!0,n.start=Date.now(),n.duration=n.items.reduce((r,i)=>Math.max(r,i._duration),0),this._refresh())}running(t){if(!this._running)return!1;const n=this._charts.get(t);return!(!n||!n.running||!n.items.length)}stop(t){const n=this._charts.get(t);if(!n||!n.items.length)return;const r=n.items;let i=r.length-1;for(;i>=0;--i)r[i].cancel();n.items=[],this._notify(t,n,Date.now(),"complete")}remove(t){return this._charts.delete(t)}}var dr=new O3;const gb="transparent",L3={boolean(e,t,n){return n>.5?t:e},color(e,t,n){const r=sb(e||gb),i=r.valid&&sb(t||gb);return i&&i.valid?i.mix(r,n).hexString():t},number(e,t,n){return e+(t-e)*n}};class F3{constructor(t,n,r,i){const s=n[r];i=ta([t.to,i,s,t.from]);const o=ta([t.from,s,i]);this._active=!0,this._fn=t.fn||L3[t.type||typeof o],this._easing=Ea[t.easing]||Ea.linear,this._start=Math.floor(Date.now()+(t.delay||0)),this._duration=this._total=Math.floor(t.duration),this._loop=!!t.loop,this._target=n,this._prop=r,this._from=o,this._to=i,this._promises=void 0}active(){return this._active}update(t,n,r){if(this._active){this._notify(!1);const i=this._target[this._prop],s=r-this._start,o=this._duration-s;this._start=r,this._duration=Math.floor(Math.max(o,t.duration)),this._total+=s,this._loop=!!t.loop,this._to=ta([t.to,n,i,t.from]),this._from=ta([t.from,i,n])}}cancel(){this._active&&(this.tick(Date.now()),this._active=!1,this._notify(!1))}tick(t){const n=t-this._start,r=this._duration,i=this._prop,s=this._from,o=this._loop,a=this._to;let l;if(this._active=s!==a&&(o||n<r),!this._active){this._target[i]=a,this._notify(!0);return}if(n<0){this._target[i]=s;return}l=n/r%2,l=o&&l>1?2-l:l,l=this._easing(Math.min(1,Math.max(0,l))),this._target[i]=this._fn(s,a,l)}wait(){const t=this._promises||(this._promises=[]);return new Promise((n,r)=>{t.push({res:n,rej:r})})}_notify(t){const n=t?"res":"rej",r=this._promises||[];for(let i=0;i<r.length;i++)r[i][n]()}}class VC{constructor(t,n){this._chart=t,this._properties=new Map,this.configure(n)}configure(t){if(!ve(t))return;const n=Object.keys(Ue.animation),r=this._properties;Object.getOwnPropertyNames(t).forEach(i=>{const s=t[i];if(!ve(s))return;const o={};for(const a of n)o[a]=s[a];(We(s.properties)&&s.properties||[i]).forEach(a=>{(a===i||!r.has(a))&&r.set(a,o)})})}_animateOptions(t,n){const r=n.options,i=z3(t,r);if(!i)return[];const s=this._createAnimations(i,r);return r.$shared&&$3(t.options.$animations,r).then(()=>{t.options=r},()=>{}),s}_createAnimations(t,n){const r=this._properties,i=[],s=t.$animations||(t.$animations={}),o=Object.keys(n),a=Date.now();let l;for(l=o.length-1;l>=0;--l){const c=o[l];if(c.charAt(0)==="$")continue;if(c==="options"){i.push(...this._animateOptions(t,n));continue}const u=n[c];let d=s[c];const h=r.get(c);if(d)if(h&&d.active()){d.update(h,u,a);continue}else d.cancel();if(!h||!h.duration){t[c]=u;continue}s[c]=d=new F3(h,t,c,u),i.push(d)}return i}update(t,n){if(this._properties.size===0){Object.assign(t,n);return}const r=this._createAnimations(t,n);if(r.length)return dr.add(this._chart,r),!0}}function $3(e,t){const n=[],r=Object.keys(t);for(let i=0;i<r.length;i++){const s=e[r[i]];s&&s.active()&&n.push(s.wait())}return Promise.all(n)}function z3(e,t){if(!t)return;let n=e.options;if(!n){e.options=t;return}return n.$shared&&(e.options=n=Object.assign({},n,{$shared:!1,$animations:{}})),n}function mb(e,t){const n=e&&e.options||{},r=n.reverse,i=n.min===void 0?t:0,s=n.max===void 0?t:0;return{start:r?s:i,end:r?i:s}}function B3(e,t,n){if(n===!1)return!1;const r=mb(e,n),i=mb(t,n);return{top:i.end,right:r.end,bottom:i.start,left:r.start}}function H3(e){let t,n,r,i;return ve(e)?(t=e.top,n=e.right,r=e.bottom,i=e.left):t=n=r=i=e,{top:t,right:n,bottom:r,left:i,disabled:e===!1}}function WC(e,t){const n=[],r=e._getSortedDatasetMetas(t);let i,s;for(i=0,s=r.length;i<s;++i)n.push(r[i].index);return n}function xb(e,t,n,r={}){const i=e.keys,s=r.mode==="single";let o,a,l,c;if(t===null)return;let u=!1;for(o=0,a=i.length;o<a;++o){if(l=+i[o],l===n){if(u=!0,r.all)continue;break}c=e.values[l],Qe(c)&&(s||t===0||rr(t)===rr(c))&&(t+=c)}return!u&&!r.all?0:t}function V3(e,t){const{iScale:n,vScale:r}=t,i=n.axis==="x"?"x":"y",s=r.axis==="x"?"x":"y",o=Object.keys(e),a=new Array(o.length);let l,c,u;for(l=0,c=o.length;l<c;++l)u=o[l],a[l]={[i]:u,[s]:e[u]};return a}function Wh(e,t){const n=e&&e.options.stacked;return n||n===void 0&&t.stack!==void 0}function W3(e,t,n){return`${e.id}.${t.id}.${n.stack||n.type}`}function U3(e){const{min:t,max:n,minDefined:r,maxDefined:i}=e.getUserBounds();return{min:r?t:Number.NEGATIVE_INFINITY,max:i?n:Number.POSITIVE_INFINITY}}function q3(e,t,n){const r=e[t]||(e[t]={});return r[n]||(r[n]={})}function vb(e,t,n,r){for(const i of t.getMatchingVisibleMetas(r).reverse()){const s=e[i.index];if(n&&s>0||!n&&s<0)return i.index}return null}function yb(e,t){const{chart:n,_cachedMeta:r}=e,i=n._stacks||(n._stacks={}),{iScale:s,vScale:o,index:a}=r,l=s.axis,c=o.axis,u=W3(s,o,r),d=t.length;let h;for(let p=0;p<d;++p){const g=t[p],{[l]:m,[c]:v}=g,x=g._stacks||(g._stacks={});h=x[c]=q3(i,u,m),h[a]=v,h._top=vb(h,o,!0,r.type),h._bottom=vb(h,o,!1,r.type);const y=h._visualValues||(h._visualValues={});y[a]=v}}function Uh(e,t){const n=e.scales;return Object.keys(n).filter(r=>n[r].axis===t).shift()}function G3(e,t){return yi(e,{active:!1,dataset:void 0,datasetIndex:t,index:t,mode:"default",type:"dataset"})}function K3(e,t,n){return yi(e,{active:!1,dataIndex:t,parsed:void 0,raw:void 0,element:n,index:t,mode:"default",type:"data"})}function $o(e,t){const n=e.controller.index,r=e.vScale&&e.vScale.axis;if(r){t=t||e._parsed;for(const i of t){const s=i._stacks;if(!s||s[r]===void 0||s[r][n]===void 0)return;delete s[r][n],s[r]._visualValues!==void 0&&s[r]._visualValues[n]!==void 0&&delete s[r]._visualValues[n]}}}const qh=e=>e==="reset"||e==="none",bb=(e,t)=>t?e:Object.assign({},e),Y3=(e,t,n)=>e&&!t.hidden&&t._stacked&&{keys:WC(n,!0),values:null};class zn{constructor(t,n){this.chart=t,this._ctx=t.ctx,this.index=n,this._cachedDataOpts={},this._cachedMeta=this.getMeta(),this._type=this._cachedMeta.type,this.options=void 0,this._parsing=!1,this._data=void 0,this._objectData=void 0,this._sharedOptions=void 0,this._drawStart=void 0,this._drawCount=void 0,this.enableOptionSharing=!1,this.supportsDecimation=!1,this.$context=void 0,this._syncList=[],this.datasetElementType=new.target.datasetElementType,this.dataElementType=new.target.dataElementType,this.initialize()}initialize(){const t=this._cachedMeta;this.configure(),this.linkScales(),t._stacked=Wh(t.vScale,t),this.addElements(),this.options.fill&&!this.chart.isPluginEnabled("filler")&&console.warn("Tried to use the 'fill' option without the 'Filler' plugin enabled. Please import and register the 'Filler' plugin and make sure it is not disabled in the options")}updateIndex(t){this.index!==t&&$o(this._cachedMeta),this.index=t}linkScales(){const t=this.chart,n=this._cachedMeta,r=this.getDataset(),i=(d,h,p,g)=>d==="x"?h:d==="r"?g:p,s=n.xAxisID=ce(r.xAxisID,Uh(t,"x")),o=n.yAxisID=ce(r.yAxisID,Uh(t,"y")),a=n.rAxisID=ce(r.rAxisID,Uh(t,"r")),l=n.indexAxis,c=n.iAxisID=i(l,s,o,a),u=n.vAxisID=i(l,o,s,a);n.xScale=this.getScaleForId(s),n.yScale=this.getScaleForId(o),n.rScale=this.getScaleForId(a),n.iScale=this.getScaleForId(c),n.vScale=this.getScaleForId(u)}getDataset(){return this.chart.data.datasets[this.index]}getMeta(){return this.chart.getDatasetMeta(this.index)}getScaleForId(t){return this.chart.scales[t]}_getOtherScale(t){const n=this._cachedMeta;return t===n.iScale?n.vScale:n.iScale}reset(){this._update("reset")}_destroy(){const t=this._cachedMeta;this._data&&nb(this._data,this),t._stacked&&$o(t)}_dataCheck(){const t=this.getDataset(),n=t.data||(t.data=[]),r=this._data;if(ve(n)){const i=this._cachedMeta;this._data=V3(n,i)}else if(r!==n){if(r){nb(r,this);const i=this._cachedMeta;$o(i),i._parsed=[]}n&&Object.isExtensible(n)&&A5(n,this),this._syncList=[],this._data=n}}addElements(){const t=this._cachedMeta;this._dataCheck(),this.datasetElementType&&(t.dataset=new this.datasetElementType)}buildOrUpdateElements(t){const n=this._cachedMeta,r=this.getDataset();let i=!1;this._dataCheck();const s=n._stacked;n._stacked=Wh(n.vScale,n),n.stack!==r.stack&&(i=!0,$o(n),n.stack=r.stack),this._resyncElements(t),(i||s!==n._stacked)&&(yb(this,n._parsed),n._stacked=Wh(n.vScale,n))}configure(){const t=this.chart.config,n=t.datasetScopeKeys(this._type),r=t.getOptionScopes(this.getDataset(),n,!0);this.options=t.createResolver(r,this.getContext()),this._parsing=this.options.parsing,this._cachedDataOpts={}}parse(t,n){const{_cachedMeta:r,_data:i}=this,{iScale:s,_stacked:o}=r,a=s.axis;let l=t===0&&n===i.length?!0:r._sorted,c=t>0&&r._parsed[t-1],u,d,h;if(this._parsing===!1)r._parsed=i,r._sorted=!0,h=i;else{We(i[t])?h=this.parseArrayData(r,i,t,n):ve(i[t])?h=this.parseObjectData(r,i,t,n):h=this.parsePrimitiveData(r,i,t,n);const p=()=>d[a]===null||c&&d[a]<c[a];for(u=0;u<n;++u)r._parsed[u+t]=d=h[u],l&&(p()&&(l=!1),c=d);r._sorted=l}o&&yb(this,h)}parsePrimitiveData(t,n,r,i){const{iScale:s,vScale:o}=t,a=s.axis,l=o.axis,c=s.getLabels(),u=s===o,d=new Array(i);let h,p,g;for(h=0,p=i;h<p;++h)g=h+r,d[h]={[a]:u||s.parse(c[g],g),[l]:o.parse(n[g],g)};return d}parseArrayData(t,n,r,i){const{xScale:s,yScale:o}=t,a=new Array(i);let l,c,u,d;for(l=0,c=i;l<c;++l)u=l+r,d=n[u],a[l]={x:s.parse(d[0],u),y:o.parse(d[1],u)};return a}parseObjectData(t,n,r,i){const{xScale:s,yScale:o}=t,{xAxisKey:a="x",yAxisKey:l="y"}=this._parsing,c=new Array(i);let u,d,h,p;for(u=0,d=i;u<d;++u)h=u+r,p=n[h],c[u]={x:s.parse(hi(p,a),h),y:o.parse(hi(p,l),h)};return c}getParsed(t){return this._cachedMeta._parsed[t]}getDataElement(t){return this._cachedMeta.data[t]}applyStack(t,n,r){const i=this.chart,s=this._cachedMeta,o=n[t.axis],a={keys:WC(i,!0),values:n._stacks[t.axis]._visualValues};return xb(a,o,s.index,{mode:r})}updateRangeFromParsed(t,n,r,i){const s=r[n.axis];let o=s===null?NaN:s;const a=i&&r._stacks[n.axis];i&&a&&(i.values=a,o=xb(i,s,this._cachedMeta.index)),t.min=Math.min(t.min,o),t.max=Math.max(t.max,o)}getMinMax(t,n){const r=this._cachedMeta,i=r._parsed,s=r._sorted&&t===r.iScale,o=i.length,a=this._getOtherScale(t),l=Y3(n,r,this.chart),c={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY},{min:u,max:d}=U3(a);let h,p;function g(){p=i[h];const m=p[a.axis];return!Qe(p[t.axis])||u>m||d<m}for(h=0;h<o&&!(!g()&&(this.updateRangeFromParsed(c,t,p,l),s));++h);if(s){for(h=o-1;h>=0;--h)if(!g()){this.updateRangeFromParsed(c,t,p,l);break}}return c}getAllParsedValues(t){const n=this._cachedMeta._parsed,r=[];let i,s,o;for(i=0,s=n.length;i<s;++i)o=n[i][t.axis],Qe(o)&&r.push(o);return r}getMaxOverflow(){return!1}getLabelAndValue(t){const n=this._cachedMeta,r=n.iScale,i=n.vScale,s=this.getParsed(t);return{label:r?""+r.getLabelForValue(s[r.axis]):"",value:i?""+i.getLabelForValue(s[i.axis]):""}}_update(t){const n=this._cachedMeta;this.update(t||"default"),n._clip=H3(ce(this.options.clip,B3(n.xScale,n.yScale,this.getMaxOverflow())))}update(t){}draw(){const t=this._ctx,n=this.chart,r=this._cachedMeta,i=r.data||[],s=n.chartArea,o=[],a=this._drawStart||0,l=this._drawCount||i.length-a,c=this.options.drawActiveElementsOnTop;let u;for(r.dataset&&r.dataset.draw(t,s,a,l),u=a;u<a+l;++u){const d=i[u];d.hidden||(d.active&&c?o.push(d):d.draw(t,s))}for(u=0;u<o.length;++u)o[u].draw(t,s)}getStyle(t,n){const r=n?"active":"default";return t===void 0&&this._cachedMeta.dataset?this.resolveDatasetElementOptions(r):this.resolveDataElementOptions(t||0,r)}getContext(t,n,r){const i=this.getDataset();let s;if(t>=0&&t<this._cachedMeta.data.length){const o=this._cachedMeta.data[t];s=o.$context||(o.$context=K3(this.getContext(),t,o)),s.parsed=this.getParsed(t),s.raw=i.data[t],s.index=s.dataIndex=t}else s=this.$context||(this.$context=G3(this.chart.getContext(),this.index)),s.dataset=i,s.index=s.datasetIndex=this.index;return s.active=!!n,s.mode=r,s}resolveDatasetElementOptions(t){return this._resolveElementOptions(this.datasetElementType.id,t)}resolveDataElementOptions(t,n){return this._resolveElementOptions(this.dataElementType.id,n,t)}_resolveElementOptions(t,n="default",r){const i=n==="active",s=this._cachedDataOpts,o=t+"-"+n,a=s[o],l=this.enableOptionSharing&&sl(r);if(a)return bb(a,l);const c=this.chart.config,u=c.datasetElementScopeKeys(this._type,t),d=i?[`${t}Hover`,"hover",t,""]:[t,""],h=c.getOptionScopes(this.getDataset(),u),p=Object.keys(Ue.elements[t]),g=()=>this.getContext(r,i,n),m=c.resolveNamedOptions(h,p,g,d);return m.$shared&&(m.$shared=l,s[o]=Object.freeze(bb(m,l))),m}_resolveAnimations(t,n,r){const i=this.chart,s=this._cachedDataOpts,o=`animation-${n}`,a=s[o];if(a)return a;let l;if(i.options.animation!==!1){const u=this.chart.config,d=u.datasetAnimationScopeKeys(this._type,n),h=u.getOptionScopes(this.getDataset(),d);l=u.createResolver(h,this.getContext(t,r,n))}const c=new VC(i,l&&l.animations);return l&&l._cacheable&&(s[o]=Object.freeze(c)),c}getSharedOptions(t){if(t.$shared)return this._sharedOptions||(this._sharedOptions=Object.assign({},t))}includeOptions(t,n){return!n||qh(t)||this.chart._animationsDisabled}_getSharedOptions(t,n){const r=this.resolveDataElementOptions(t,n),i=this._sharedOptions,s=this.getSharedOptions(r),o=this.includeOptions(n,s)||s!==i;return this.updateSharedOptions(s,n,r),{sharedOptions:s,includeOptions:o}}updateElement(t,n,r,i){qh(i)?Object.assign(t,r):this._resolveAnimations(n,i).update(t,r)}updateSharedOptions(t,n,r){t&&!qh(n)&&this._resolveAnimations(void 0,n).update(t,r)}_setStyle(t,n,r,i){t.active=i;const s=this.getStyle(n,i);this._resolveAnimations(n,r,i).update(t,{options:!i&&this.getSharedOptions(s)||s})}removeHoverStyle(t,n,r){this._setStyle(t,r,"active",!1)}setHoverStyle(t,n,r){this._setStyle(t,r,"active",!0)}_removeDatasetHoverStyle(){const t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!1)}_setDatasetHoverStyle(){const t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!0)}_resyncElements(t){const n=this._data,r=this._cachedMeta.data;for(const[a,l,c]of this._syncList)this[a](l,c);this._syncList=[];const i=r.length,s=n.length,o=Math.min(s,i);o&&this.parse(0,o),s>i?this._insertElements(i,s-i,t):s<i&&this._removeElements(s,i-s)}_insertElements(t,n,r=!0){const i=this._cachedMeta,s=i.data,o=t+n;let a;const l=c=>{for(c.length+=n,a=c.length-1;a>=o;a--)c[a]=c[a-n]};for(l(s),a=t;a<o;++a)s[a]=new this.dataElementType;this._parsing&&l(i._parsed),this.parse(t,n),r&&this.updateElements(s,t,n,"reset")}updateElements(t,n,r,i){}_removeElements(t,n){const r=this._cachedMeta;if(this._parsing){const i=r._parsed.splice(t,n);r._stacked&&$o(r,i)}r.data.splice(t,n)}_sync(t){if(this._parsing)this._syncList.push(t);else{const[n,r,i]=t;this[n](r,i)}this.chart._dataChanges.push([this.index,...t])}_onDataPush(){const t=arguments.length;this._sync(["_insertElements",this.getDataset().data.length-t,t])}_onDataPop(){this._sync(["_removeElements",this._cachedMeta.data.length-1,1])}_onDataShift(){this._sync(["_removeElements",0,1])}_onDataSplice(t,n){n&&this._sync(["_removeElements",t,n]);const r=arguments.length-2;r&&this._sync(["_insertElements",t,r])}_onDataUnshift(){this._sync(["_insertElements",0,arguments.length])}}W(zn,"defaults",{}),W(zn,"datasetElementType",null),W(zn,"dataElementType",null);function X3(e,t){if(!e._cache.$bar){const n=e.getMatchingVisibleMetas(t);let r=[];for(let i=0,s=n.length;i<s;i++)r=r.concat(n[i].controller.getAllParsedValues(e));e._cache.$bar=kC(r.sort((i,s)=>i-s))}return e._cache.$bar}function J3(e){const t=e.iScale,n=X3(t,e.type);let r=t._length,i,s,o,a;const l=()=>{o===32767||o===-32768||(sl(a)&&(r=Math.min(r,Math.abs(o-a)||r)),a=o)};for(i=0,s=n.length;i<s;++i)o=t.getPixelForValue(n[i]),l();for(a=void 0,i=0,s=t.ticks.length;i<s;++i)o=t.getPixelForTick(i),l();return r}function Q3(e,t,n,r){const i=n.barThickness;let s,o;return ge(i)?(s=t.min*n.categoryPercentage,o=n.barPercentage):(s=i*r,o=1),{chunk:s/r,ratio:o,start:t.pixels[e]-s/2}}function Z3(e,t,n,r){const i=t.pixels,s=i[e];let o=e>0?i[e-1]:null,a=e<i.length-1?i[e+1]:null;const l=n.categoryPercentage;o===null&&(o=s-(a===null?t.end-t.start:a-s)),a===null&&(a=s+s-o);const c=s-(s-Math.min(o,a))/2*l;return{chunk:Math.abs(a-o)/2*l/r,ratio:n.barPercentage,start:c}}function ez(e,t,n,r){const i=n.parse(e[0],r),s=n.parse(e[1],r),o=Math.min(i,s),a=Math.max(i,s);let l=o,c=a;Math.abs(o)>Math.abs(a)&&(l=a,c=o),t[n.axis]=c,t._custom={barStart:l,barEnd:c,start:i,end:s,min:o,max:a}}function UC(e,t,n,r){return We(e)?ez(e,t,n,r):t[n.axis]=n.parse(e,r),t}function _b(e,t,n,r){const i=e.iScale,s=e.vScale,o=i.getLabels(),a=i===s,l=[];let c,u,d,h;for(c=n,u=n+r;c<u;++c)h=t[c],d={},d[i.axis]=a||i.parse(o[c],c),l.push(UC(h,d,s,c));return l}function Gh(e){return e&&e.barStart!==void 0&&e.barEnd!==void 0}function tz(e,t,n){return e!==0?rr(e):(t.isHorizontal()?1:-1)*(t.min>=n?1:-1)}function nz(e){let t,n,r,i,s;return e.horizontal?(t=e.base>e.x,n="left",r="right"):(t=e.base<e.y,n="bottom",r="top"),t?(i="end",s="start"):(i="start",s="end"),{start:n,end:r,reverse:t,top:i,bottom:s}}function rz(e,t,n,r){let i=t.borderSkipped;const s={};if(!i){e.borderSkipped=s;return}if(i===!0){e.borderSkipped={top:!0,right:!0,bottom:!0,left:!0};return}const{start:o,end:a,reverse:l,top:c,bottom:u}=nz(e);i==="middle"&&n&&(e.enableBorderRadius=!0,(n._top||0)===r?i=c:(n._bottom||0)===r?i=u:(s[wb(u,o,a,l)]=!0,i=c)),s[wb(i,o,a,l)]=!0,e.borderSkipped=s}function wb(e,t,n,r){return r?(e=iz(e,t,n),e=kb(e,n,t)):e=kb(e,t,n),e}function iz(e,t,n){return e===t?n:e===n?t:e}function kb(e,t,n){return e==="start"?t:e==="end"?n:e}function sz(e,{inflateAmount:t},n){e.inflateAmount=t==="auto"?n===1?.33:0:t}class Ac extends zn{parsePrimitiveData(t,n,r,i){return _b(t,n,r,i)}parseArrayData(t,n,r,i){return _b(t,n,r,i)}parseObjectData(t,n,r,i){const{iScale:s,vScale:o}=t,{xAxisKey:a="x",yAxisKey:l="y"}=this._parsing,c=s.axis==="x"?a:l,u=o.axis==="x"?a:l,d=[];let h,p,g,m;for(h=r,p=r+i;h<p;++h)m=n[h],g={},g[s.axis]=s.parse(hi(m,c),h),d.push(UC(hi(m,u),g,o,h));return d}updateRangeFromParsed(t,n,r,i){super.updateRangeFromParsed(t,n,r,i);const s=r._custom;s&&n===this._cachedMeta.vScale&&(t.min=Math.min(t.min,s.min),t.max=Math.max(t.max,s.max))}getMaxOverflow(){return 0}getLabelAndValue(t){const n=this._cachedMeta,{iScale:r,vScale:i}=n,s=this.getParsed(t),o=s._custom,a=Gh(o)?"["+o.start+", "+o.end+"]":""+i.getLabelForValue(s[i.axis]);return{label:""+r.getLabelForValue(s[r.axis]),value:a}}initialize(){this.enableOptionSharing=!0,super.initialize();const t=this._cachedMeta;t.stack=this.getDataset().stack}update(t){const n=this._cachedMeta;this.updateElements(n.data,0,n.data.length,t)}updateElements(t,n,r,i){const s=i==="reset",{index:o,_cachedMeta:{vScale:a}}=this,l=a.getBasePixel(),c=a.isHorizontal(),u=this._getRuler(),{sharedOptions:d,includeOptions:h}=this._getSharedOptions(n,i);for(let p=n;p<n+r;p++){const g=this.getParsed(p),m=s||ge(g[a.axis])?{base:l,head:l}:this._calculateBarValuePixels(p),v=this._calculateBarIndexPixels(p,u),x=(g._stacks||{})[a.axis],y={horizontal:c,base:m.base,enableBorderRadius:!x||Gh(g._custom)||o===x._top||o===x._bottom,x:c?m.head:v.center,y:c?v.center:m.head,height:c?v.size:Math.abs(m.size),width:c?Math.abs(m.size):v.size};h&&(y.options=d||this.resolveDataElementOptions(p,t[p].active?"active":i));const b=y.options||t[p].options;rz(y,b,x,o),sz(y,b,u.ratio),this.updateElement(t[p],p,y,i)}}_getStacks(t,n){const{iScale:r}=this._cachedMeta,i=r.getMatchingVisibleMetas(this._type).filter(u=>u.controller.options.grouped),s=r.options.stacked,o=[],a=this._cachedMeta.controller.getParsed(n),l=a&&a[r.axis],c=u=>{const d=u._parsed.find(p=>p[r.axis]===l),h=d&&d[u.vScale.axis];if(ge(h)||isNaN(h))return!0};for(const u of i)if(!(n!==void 0&&c(u))&&((s===!1||o.indexOf(u.stack)===-1||s===void 0&&u.stack===void 0)&&o.push(u.stack),u.index===t))break;return o.length||o.push(void 0),o}_getStackCount(t){return this._getStacks(void 0,t).length}_getAxisCount(){return this._getAxis().length}getFirstScaleIdForIndexAxis(){const t=this.chart.scales,n=this.chart.options.indexAxis;return Object.keys(t).filter(r=>t[r].axis===n).shift()}_getAxis(){const t={},n=this.getFirstScaleIdForIndexAxis();for(const r of this.chart.data.datasets)t[ce(this.chart.options.indexAxis==="x"?r.xAxisID:r.yAxisID,n)]=!0;return Object.keys(t)}_getStackIndex(t,n,r){const i=this._getStacks(t,r),s=n!==void 0?i.indexOf(n):-1;return s===-1?i.length-1:s}_getRuler(){const t=this.options,n=this._cachedMeta,r=n.iScale,i=[];let s,o;for(s=0,o=n.data.length;s<o;++s)i.push(r.getPixelForValue(this.getParsed(s)[r.axis],s));const a=t.barThickness;return{min:a||J3(n),pixels:i,start:r._startPixel,end:r._endPixel,stackCount:this._getStackCount(),scale:r,grouped:t.grouped,ratio:a?1:t.categoryPercentage*t.barPercentage}}_calculateBarValuePixels(t){const{_cachedMeta:{vScale:n,_stacked:r,index:i},options:{base:s,minBarLength:o}}=this,a=s||0,l=this.getParsed(t),c=l._custom,u=Gh(c);let d=l[n.axis],h=0,p=r?this.applyStack(n,l,r):d,g,m;p!==d&&(h=p-d,p=d),u&&(d=c.barStart,p=c.barEnd-c.barStart,d!==0&&rr(d)!==rr(c.barEnd)&&(h=0),h+=d);const v=!ge(s)&&!u?s:h;let x=n.getPixelForValue(v);if(this.chart.getDataVisibility(t)?g=n.getPixelForValue(h+p):g=x,m=g-x,Math.abs(m)<o){m=tz(m,n,a)*o,d===a&&(x-=m/2);const y=n.getPixelForDecimal(0),b=n.getPixelForDecimal(1),k=Math.min(y,b),w=Math.max(y,b);x=Math.max(Math.min(x,w),k),g=x+m,r&&!u&&(l._stacks[n.axis]._visualValues[i]=n.getValueForPixel(g)-n.getValueForPixel(x))}if(x===n.getPixelForValue(a)){const y=rr(m)*n.getLineWidthForValue(a)/2;x+=y,m-=y}return{size:m,base:x,head:g,center:g+m/2}}_calculateBarIndexPixels(t,n){const r=n.scale,i=this.options,s=i.skipNull,o=ce(i.maxBarThickness,1/0);let a,l;const c=this._getAxisCount();if(n.grouped){const u=s?this._getStackCount(t):n.stackCount,d=i.barThickness==="flex"?Z3(t,n,i,u*c):Q3(t,n,i,u*c),h=this.chart.options.indexAxis==="x"?this.getDataset().xAxisID:this.getDataset().yAxisID,p=this._getAxis().indexOf(ce(h,this.getFirstScaleIdForIndexAxis())),g=this._getStackIndex(this.index,this._cachedMeta.stack,s?t:void 0)+p;a=d.start+d.chunk*g+d.chunk/2,l=Math.min(o,d.chunk*d.ratio)}else a=r.getPixelForValue(this.getParsed(t)[r.axis],t),l=Math.min(o,n.min*n.ratio);return{base:a-l/2,head:a+l/2,center:a,size:l}}draw(){const t=this._cachedMeta,n=t.vScale,r=t.data,i=r.length;let s=0;for(;s<i;++s)this.getParsed(s)[n.axis]!==null&&!r[s].hidden&&r[s].draw(this._ctx)}}W(Ac,"id","bar"),W(Ac,"defaults",{datasetElementType:!1,dataElementType:"bar",categoryPercentage:.8,barPercentage:.9,grouped:!0,animations:{numbers:{type:"number",properties:["x","y","base","width","height"]}}}),W(Ac,"overrides",{scales:{_index_:{type:"category",offset:!0,grid:{offset:!0}},_value_:{type:"linear",beginAtZero:!0}}});class Dc extends zn{initialize(){this.enableOptionSharing=!0,super.initialize()}parsePrimitiveData(t,n,r,i){const s=super.parsePrimitiveData(t,n,r,i);for(let o=0;o<s.length;o++)s[o]._custom=this.resolveDataElementOptions(o+r).radius;return s}parseArrayData(t,n,r,i){const s=super.parseArrayData(t,n,r,i);for(let o=0;o<s.length;o++){const a=n[r+o];s[o]._custom=ce(a[2],this.resolveDataElementOptions(o+r).radius)}return s}parseObjectData(t,n,r,i){const s=super.parseObjectData(t,n,r,i);for(let o=0;o<s.length;o++){const a=n[r+o];s[o]._custom=ce(a&&a.r&&+a.r,this.resolveDataElementOptions(o+r).radius)}return s}getMaxOverflow(){const t=this._cachedMeta.data;let n=0;for(let r=t.length-1;r>=0;--r)n=Math.max(n,t[r].size(this.resolveDataElementOptions(r))/2);return n>0&&n}getLabelAndValue(t){const n=this._cachedMeta,r=this.chart.data.labels||[],{xScale:i,yScale:s}=n,o=this.getParsed(t),a=i.getLabelForValue(o.x),l=s.getLabelForValue(o.y),c=o._custom;return{label:r[t]||"",value:"("+a+", "+l+(c?", "+c:"")+")"}}update(t){const n=this._cachedMeta.data;this.updateElements(n,0,n.length,t)}updateElements(t,n,r,i){const s=i==="reset",{iScale:o,vScale:a}=this._cachedMeta,{sharedOptions:l,includeOptions:c}=this._getSharedOptions(n,i),u=o.axis,d=a.axis;for(let h=n;h<n+r;h++){const p=t[h],g=!s&&this.getParsed(h),m={},v=m[u]=s?o.getPixelForDecimal(.5):o.getPixelForValue(g[u]),x=m[d]=s?a.getBasePixel():a.getPixelForValue(g[d]);m.skip=isNaN(v)||isNaN(x),c&&(m.options=l||this.resolveDataElementOptions(h,p.active?"active":i),s&&(m.options.radius=0)),this.updateElement(p,h,m,i)}}resolveDataElementOptions(t,n){const r=this.getParsed(t);let i=super.resolveDataElementOptions(t,n);i.$shared&&(i=Object.assign({},i,{$shared:!1}));const s=i.radius;return n!=="active"&&(i.radius=0),i.radius+=ce(r&&r._custom,s),i}}W(Dc,"id","bubble"),W(Dc,"defaults",{datasetElementType:!1,dataElementType:"point",animations:{numbers:{type:"number",properties:["x","y","borderWidth","radius"]}}}),W(Dc,"overrides",{scales:{x:{type:"linear"},y:{type:"linear"}}});function oz(e,t,n){let r=1,i=1,s=0,o=0;if(t<He){const a=e,l=a+t,c=Math.cos(a),u=Math.sin(a),d=Math.cos(l),h=Math.sin(l),p=(b,k,w)=>ol(b,a,l,!0)?1:Math.max(k,k*n,w,w*n),g=(b,k,w)=>ol(b,a,l,!0)?-1:Math.min(k,k*n,w,w*n),m=p(0,c,d),v=p(nt,u,h),x=g(Ee,c,d),y=g(Ee+nt,u,h);r=(m-x)/2,i=(v-y)/2,s=-(m+x)/2,o=-(v+y)/2}return{ratioX:r,ratioY:i,offsetX:s,offsetY:o}}class $i extends zn{constructor(t,n){super(t,n),this.enableOptionSharing=!0,this.innerRadius=void 0,this.outerRadius=void 0,this.offsetX=void 0,this.offsetY=void 0}linkScales(){}parse(t,n){const r=this.getDataset().data,i=this._cachedMeta;if(this._parsing===!1)i._parsed=r;else{let s=l=>+r[l];if(ve(r[t])){const{key:l="value"}=this._parsing;s=c=>+hi(r[c],l)}let o,a;for(o=t,a=t+n;o<a;++o)i._parsed[o]=s(o)}}_getRotation(){return On(this.options.rotation-90)}_getCircumference(){return On(this.options.circumference)}_getRotationExtents(){let t=He,n=-He;for(let r=0;r<this.chart.data.datasets.length;++r)if(this.chart.isDatasetVisible(r)&&this.chart.getDatasetMeta(r).type===this._type){const i=this.chart.getDatasetMeta(r).controller,s=i._getRotation(),o=i._getCircumference();t=Math.min(t,s),n=Math.max(n,s+o)}return{rotation:t,circumference:n-t}}update(t){const n=this.chart,{chartArea:r}=n,i=this._cachedMeta,s=i.data,o=this.getMaxBorderWidth()+this.getMaxOffset(s)+this.options.spacing,a=Math.max((Math.min(r.width,r.height)-o)/2,0),l=Math.min(v5(this.options.cutout,a),1),c=this._getRingWeight(this.index),{circumference:u,rotation:d}=this._getRotationExtents(),{ratioX:h,ratioY:p,offsetX:g,offsetY:m}=oz(d,u,l),v=(r.width-o)/h,x=(r.height-o)/p,y=Math.max(Math.min(v,x)/2,0),b=vC(this.options.radius,y),k=Math.max(b*l,0),w=(b-k)/this._getVisibleDatasetWeightTotal();this.offsetX=g*b,this.offsetY=m*b,i.total=this.calculateTotal(),this.outerRadius=b-w*this._getRingWeightOffset(this.index),this.innerRadius=Math.max(this.outerRadius-w*c,0),this.updateElements(s,0,s.length,t)}_circumference(t,n){const r=this.options,i=this._cachedMeta,s=this._getCircumference();return n&&r.animation.animateRotate||!this.chart.getDataVisibility(t)||i._parsed[t]===null||i.data[t].hidden?0:this.calculateCircumference(i._parsed[t]*s/He)}updateElements(t,n,r,i){const s=i==="reset",o=this.chart,a=o.chartArea,c=o.options.animation,u=(a.left+a.right)/2,d=(a.top+a.bottom)/2,h=s&&c.animateScale,p=h?0:this.innerRadius,g=h?0:this.outerRadius,{sharedOptions:m,includeOptions:v}=this._getSharedOptions(n,i);let x=this._getRotation(),y;for(y=0;y<n;++y)x+=this._circumference(y,s);for(y=n;y<n+r;++y){const b=this._circumference(y,s),k=t[y],w={x:u+this.offsetX,y:d+this.offsetY,startAngle:x,endAngle:x+b,circumference:b,outerRadius:g,innerRadius:p};v&&(w.options=m||this.resolveDataElementOptions(y,k.active?"active":i)),x+=b,this.updateElement(k,y,w,i)}}calculateTotal(){const t=this._cachedMeta,n=t.data;let r=0,i;for(i=0;i<n.length;i++){const s=t._parsed[i];s!==null&&!isNaN(s)&&this.chart.getDataVisibility(i)&&!n[i].hidden&&(r+=Math.abs(s))}return r}calculateCircumference(t){const n=this._cachedMeta.total;return n>0&&!isNaN(t)?He*(Math.abs(t)/n):0}getLabelAndValue(t){const n=this._cachedMeta,r=this.chart,i=r.data.labels||[],s=bl(n._parsed[t],r.options.locale);return{label:i[t]||"",value:s}}getMaxBorderWidth(t){let n=0;const r=this.chart;let i,s,o,a,l;if(!t){for(i=0,s=r.data.datasets.length;i<s;++i)if(r.isDatasetVisible(i)){o=r.getDatasetMeta(i),t=o.data,a=o.controller;break}}if(!t)return 0;for(i=0,s=t.length;i<s;++i)l=a.resolveDataElementOptions(i),l.borderAlign!=="inner"&&(n=Math.max(n,l.borderWidth||0,l.hoverBorderWidth||0));return n}getMaxOffset(t){let n=0;for(let r=0,i=t.length;r<i;++r){const s=this.resolveDataElementOptions(r);n=Math.max(n,s.offset||0,s.hoverOffset||0)}return n}_getRingWeightOffset(t){let n=0;for(let r=0;r<t;++r)this.chart.isDatasetVisible(r)&&(n+=this._getRingWeight(r));return n}_getRingWeight(t){return Math.max(ce(this.chart.data.datasets[t].weight,1),0)}_getVisibleDatasetWeightTotal(){return this._getRingWeightOffset(this.chart.data.datasets.length)||1}}W($i,"id","doughnut"),W($i,"defaults",{datasetElementType:!1,dataElementType:"arc",animation:{animateRotate:!0,animateScale:!1},animations:{numbers:{type:"number",properties:["circumference","endAngle","innerRadius","outerRadius","startAngle","x","y","offset","borderWidth","spacing"]}},cutout:"50%",rotation:0,circumference:360,radius:"100%",spacing:0,indexAxis:"r"}),W($i,"descriptors",{_scriptable:t=>t!=="spacing",_indexable:t=>t!=="spacing"&&!t.startsWith("borderDash")&&!t.startsWith("hoverBorderDash")}),W($i,"overrides",{aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){const n=t.data,{labels:{pointStyle:r,textAlign:i,color:s,useBorderRadius:o,borderRadius:a}}=t.legend.options;return n.labels.length&&n.datasets.length?n.labels.map((l,c)=>{const d=t.getDatasetMeta(0).controller.getStyle(c);return{text:l,fillStyle:d.backgroundColor,fontColor:s,hidden:!t.getDataVisibility(c),lineDash:d.borderDash,lineDashOffset:d.borderDashOffset,lineJoin:d.borderJoinStyle,lineWidth:d.borderWidth,strokeStyle:d.borderColor,textAlign:i,pointStyle:r,borderRadius:o&&(a||d.borderRadius),index:c}}):[]}},onClick(t,n,r){r.chart.toggleDataVisibility(n.index),r.chart.update()}}}});class Ic extends zn{initialize(){this.enableOptionSharing=!0,this.supportsDecimation=!0,super.initialize()}update(t){const n=this._cachedMeta,{dataset:r,data:i=[],_dataset:s}=n,o=this.chart._animationsDisabled;let{start:a,count:l}=EC(n,i,o);this._drawStart=a,this._drawCount=l,PC(n)&&(a=0,l=i.length),r._chart=this.chart,r._datasetIndex=this.index,r._decimated=!!s._decimated,r.points=i;const c=this.resolveDatasetElementOptions(t);this.options.showLine||(c.borderWidth=0),c.segment=this.options.segment,this.updateElement(r,void 0,{animated:!o,options:c},t),this.updateElements(i,a,l,t)}updateElements(t,n,r,i){const s=i==="reset",{iScale:o,vScale:a,_stacked:l,_dataset:c}=this._cachedMeta,{sharedOptions:u,includeOptions:d}=this._getSharedOptions(n,i),h=o.axis,p=a.axis,{spanGaps:g,segment:m}=this.options,v=oo(g)?g:Number.POSITIVE_INFINITY,x=this.chart._animationsDisabled||s||i==="none",y=n+r,b=t.length;let k=n>0&&this.getParsed(n-1);for(let w=0;w<b;++w){const _=t[w],N=x?_:{};if(w<n||w>=y){N.skip=!0;continue}const E=this.getParsed(w),T=ge(E[p]),S=N[h]=o.getPixelForValue(E[h],w),M=N[p]=s||T?a.getBasePixel():a.getPixelForValue(l?this.applyStack(a,E,l):E[p],w);N.skip=isNaN(S)||isNaN(M)||T,N.stop=w>0&&Math.abs(E[h]-k[h])>v,m&&(N.parsed=E,N.raw=c.data[w]),d&&(N.options=u||this.resolveDataElementOptions(w,_.active?"active":i)),x||this.updateElement(_,w,N,i),k=E}}getMaxOverflow(){const t=this._cachedMeta,n=t.dataset,r=n.options&&n.options.borderWidth||0,i=t.data||[];if(!i.length)return r;const s=i[0].size(this.resolveDataElementOptions(0)),o=i[i.length-1].size(this.resolveDataElementOptions(i.length-1));return Math.max(r,s,o)/2}draw(){const t=this._cachedMeta;t.dataset.updateControlPoints(this.chart.chartArea,t.iScale.axis),super.draw()}}W(Ic,"id","line"),W(Ic,"defaults",{datasetElementType:"line",dataElementType:"point",showLine:!0,spanGaps:!1}),W(Ic,"overrides",{scales:{_index_:{type:"category"},_value_:{type:"linear"}}});class Na extends zn{constructor(t,n){super(t,n),this.innerRadius=void 0,this.outerRadius=void 0}getLabelAndValue(t){const n=this._cachedMeta,r=this.chart,i=r.data.labels||[],s=bl(n._parsed[t].r,r.options.locale);return{label:i[t]||"",value:s}}parseObjectData(t,n,r,i){return IC.bind(this)(t,n,r,i)}update(t){const n=this._cachedMeta.data;this._updateRadius(),this.updateElements(n,0,n.length,t)}getMinMax(){const t=this._cachedMeta,n={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY};return t.data.forEach((r,i)=>{const s=this.getParsed(i).r;!isNaN(s)&&this.chart.getDataVisibility(i)&&(s<n.min&&(n.min=s),s>n.max&&(n.max=s))}),n}_updateRadius(){const t=this.chart,n=t.chartArea,r=t.options,i=Math.min(n.right-n.left,n.bottom-n.top),s=Math.max(i/2,0),o=Math.max(r.cutoutPercentage?s/100*r.cutoutPercentage:1,0),a=(s-o)/t.getVisibleDatasetCount();this.outerRadius=s-a*this.index,this.innerRadius=this.outerRadius-a}updateElements(t,n,r,i){const s=i==="reset",o=this.chart,l=o.options.animation,c=this._cachedMeta.rScale,u=c.xCenter,d=c.yCenter,h=c.getIndexAngle(0)-.5*Ee;let p=h,g;const m=360/this.countVisibleElements();for(g=0;g<n;++g)p+=this._computeAngle(g,i,m);for(g=n;g<n+r;g++){const v=t[g];let x=p,y=p+this._computeAngle(g,i,m),b=o.getDataVisibility(g)?c.getDistanceFromCenterForValue(this.getParsed(g).r):0;p=y,s&&(l.animateScale&&(b=0),l.animateRotate&&(x=y=h));const k={x:u,y:d,innerRadius:0,outerRadius:b,startAngle:x,endAngle:y,options:this.resolveDataElementOptions(g,v.active?"active":i)};this.updateElement(v,g,k,i)}}countVisibleElements(){const t=this._cachedMeta;let n=0;return t.data.forEach((r,i)=>{!isNaN(this.getParsed(i).r)&&this.chart.getDataVisibility(i)&&n++}),n}_computeAngle(t,n,r){return this.chart.getDataVisibility(t)?On(this.resolveDataElementOptions(t,n).angle||r):0}}W(Na,"id","polarArea"),W(Na,"defaults",{dataElementType:"arc",animation:{animateRotate:!0,animateScale:!0},animations:{numbers:{type:"number",properties:["x","y","startAngle","endAngle","innerRadius","outerRadius"]}},indexAxis:"r",startAngle:0}),W(Na,"overrides",{aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){const n=t.data;if(n.labels.length&&n.datasets.length){const{labels:{pointStyle:r,color:i}}=t.legend.options;return n.labels.map((s,o)=>{const l=t.getDatasetMeta(0).controller.getStyle(o);return{text:s,fillStyle:l.backgroundColor,strokeStyle:l.borderColor,fontColor:i,lineWidth:l.borderWidth,pointStyle:r,hidden:!t.getDataVisibility(o),index:o}})}return[]}},onClick(t,n,r){r.chart.toggleDataVisibility(n.index),r.chart.update()}}},scales:{r:{type:"radialLinear",angleLines:{display:!1},beginAtZero:!0,grid:{circular:!0},pointLabels:{display:!1},startAngle:0}}});class Xp extends $i{}W(Xp,"id","pie"),W(Xp,"defaults",{cutout:0,rotation:0,circumference:360,radius:"100%"});class Oc extends zn{getLabelAndValue(t){const n=this._cachedMeta.vScale,r=this.getParsed(t);return{label:n.getLabels()[t],value:""+n.getLabelForValue(r[n.axis])}}parseObjectData(t,n,r,i){return IC.bind(this)(t,n,r,i)}update(t){const n=this._cachedMeta,r=n.dataset,i=n.data||[],s=n.iScale.getLabels();if(r.points=i,t!=="resize"){const o=this.resolveDatasetElementOptions(t);this.options.showLine||(o.borderWidth=0);const a={_loop:!0,_fullLoop:s.length===i.length,options:o};this.updateElement(r,void 0,a,t)}this.updateElements(i,0,i.length,t)}updateElements(t,n,r,i){const s=this._cachedMeta.rScale,o=i==="reset";for(let a=n;a<n+r;a++){const l=t[a],c=this.resolveDataElementOptions(a,l.active?"active":i),u=s.getPointPositionForValue(a,this.getParsed(a).r),d=o?s.xCenter:u.x,h=o?s.yCenter:u.y,p={x:d,y:h,angle:u.angle,skip:isNaN(d)||isNaN(h),options:c};this.updateElement(l,a,p,i)}}}W(Oc,"id","radar"),W(Oc,"defaults",{datasetElementType:"line",dataElementType:"point",indexAxis:"r",showLine:!0,elements:{line:{fill:"start"}}}),W(Oc,"overrides",{aspectRatio:1,scales:{r:{type:"radialLinear"}}});class Lc extends zn{getLabelAndValue(t){const n=this._cachedMeta,r=this.chart.data.labels||[],{xScale:i,yScale:s}=n,o=this.getParsed(t),a=i.getLabelForValue(o.x),l=s.getLabelForValue(o.y);return{label:r[t]||"",value:"("+a+", "+l+")"}}update(t){const n=this._cachedMeta,{data:r=[]}=n,i=this.chart._animationsDisabled;let{start:s,count:o}=EC(n,r,i);if(this._drawStart=s,this._drawCount=o,PC(n)&&(s=0,o=r.length),this.options.showLine){this.datasetElementType||this.addElements();const{dataset:a,_dataset:l}=n;a._chart=this.chart,a._datasetIndex=this.index,a._decimated=!!l._decimated,a.points=r;const c=this.resolveDatasetElementOptions(t);c.segment=this.options.segment,this.updateElement(a,void 0,{animated:!i,options:c},t)}else this.datasetElementType&&(delete n.dataset,this.datasetElementType=!1);this.updateElements(r,s,o,t)}addElements(){const{showLine:t}=this.options;!this.datasetElementType&&t&&(this.datasetElementType=this.chart.registry.getElement("line")),super.addElements()}updateElements(t,n,r,i){const s=i==="reset",{iScale:o,vScale:a,_stacked:l,_dataset:c}=this._cachedMeta,u=this.resolveDataElementOptions(n,i),d=this.getSharedOptions(u),h=this.includeOptions(i,d),p=o.axis,g=a.axis,{spanGaps:m,segment:v}=this.options,x=oo(m)?m:Number.POSITIVE_INFINITY,y=this.chart._animationsDisabled||s||i==="none";let b=n>0&&this.getParsed(n-1);for(let k=n;k<n+r;++k){const w=t[k],_=this.getParsed(k),N=y?w:{},E=ge(_[g]),T=N[p]=o.getPixelForValue(_[p],k),S=N[g]=s||E?a.getBasePixel():a.getPixelForValue(l?this.applyStack(a,_,l):_[g],k);N.skip=isNaN(T)||isNaN(S)||E,N.stop=k>0&&Math.abs(_[p]-b[p])>x,v&&(N.parsed=_,N.raw=c.data[k]),h&&(N.options=d||this.resolveDataElementOptions(k,w.active?"active":i)),y||this.updateElement(w,k,N,i),b=_}this.updateSharedOptions(d,i,u)}getMaxOverflow(){const t=this._cachedMeta,n=t.data||[];if(!this.options.showLine){let a=0;for(let l=n.length-1;l>=0;--l)a=Math.max(a,n[l].size(this.resolveDataElementOptions(l))/2);return a>0&&a}const r=t.dataset,i=r.options&&r.options.borderWidth||0;if(!n.length)return i;const s=n[0].size(this.resolveDataElementOptions(0)),o=n[n.length-1].size(this.resolveDataElementOptions(n.length-1));return Math.max(i,s,o)/2}}W(Lc,"id","scatter"),W(Lc,"defaults",{datasetElementType:!1,dataElementType:"point",showLine:!1,fill:!1}),W(Lc,"overrides",{interaction:{mode:"point"},scales:{x:{type:"linear"},y:{type:"linear"}}});var az=Object.freeze({__proto__:null,BarController:Ac,BubbleController:Dc,DoughnutController:$i,LineController:Ic,PieController:Xp,PolarAreaController:Na,RadarController:Oc,ScatterController:Lc});function Pi(){throw new Error("This method is not implemented: Check that a complete date adapter is provided.")}class ex{constructor(t){W(this,"options");this.options=t||{}}static override(t){Object.assign(ex.prototype,t)}init(){}formats(){return Pi()}parse(){return Pi()}format(){return Pi()}add(){return Pi()}diff(){return Pi()}startOf(){return Pi()}endOf(){return Pi()}}var lz={_date:ex};function cz(e,t,n,r){const{controller:i,data:s,_sorted:o}=e,a=i._cachedMeta.iScale,l=e.dataset&&e.dataset.options?e.dataset.options.spanGaps:null;if(a&&t===a.axis&&t!=="r"&&o&&s.length){const c=a._reversePixels?M5:_r;if(r){if(i._sharedOptions){const u=s[0],d=typeof u.getRange=="function"&&u.getRange(t);if(d){const h=c(s,t,n-d),p=c(s,t,n+d);return{lo:h.lo,hi:p.hi}}}}else{const u=c(s,t,n);if(l){const{vScale:d}=i._cachedMeta,{_parsed:h}=e,p=h.slice(0,u.lo+1).reverse().findIndex(m=>!ge(m[d.axis]));u.lo-=Math.max(0,p);const g=h.slice(u.hi).findIndex(m=>!ge(m[d.axis]));u.hi+=Math.max(0,g)}return u}}return{lo:0,hi:s.length-1}}function kd(e,t,n,r,i){const s=e.getSortedVisibleDatasetMetas(),o=n[t];for(let a=0,l=s.length;a<l;++a){const{index:c,data:u}=s[a],{lo:d,hi:h}=cz(s[a],t,o,i);for(let p=d;p<=h;++p){const g=u[p];g.skip||r(g,c,p)}}}function uz(e){const t=e.indexOf("x")!==-1,n=e.indexOf("y")!==-1;return function(r,i){const s=t?Math.abs(r.x-i.x):0,o=n?Math.abs(r.y-i.y):0;return Math.sqrt(Math.pow(s,2)+Math.pow(o,2))}}function Kh(e,t,n,r,i){const s=[];return!i&&!e.isPointInArea(t)||kd(e,n,t,function(a,l,c){!i&&!wr(a,e.chartArea,0)||a.inRange(t.x,t.y,r)&&s.push({element:a,datasetIndex:l,index:c})},!0),s}function dz(e,t,n,r){let i=[];function s(o,a,l){const{startAngle:c,endAngle:u}=o.getProps(["startAngle","endAngle"],r),{angle:d}=_C(o,{x:t.x,y:t.y});ol(d,c,u)&&i.push({element:o,datasetIndex:a,index:l})}return kd(e,n,t,s),i}function hz(e,t,n,r,i,s){let o=[];const a=uz(n);let l=Number.POSITIVE_INFINITY;function c(u,d,h){const p=u.inRange(t.x,t.y,i);if(r&&!p)return;const g=u.getCenterPoint(i);if(!(!!s||e.isPointInArea(g))&&!p)return;const v=a(t,g);v<l?(o=[{element:u,datasetIndex:d,index:h}],l=v):v===l&&o.push({element:u,datasetIndex:d,index:h})}return kd(e,n,t,c),o}function Yh(e,t,n,r,i,s){return!s&&!e.isPointInArea(t)?[]:n==="r"&&!r?dz(e,t,n,i):hz(e,t,n,r,i,s)}function Sb(e,t,n,r,i){const s=[],o=n==="x"?"inXRange":"inYRange";let a=!1;return kd(e,n,t,(l,c,u)=>{l[o]&&l[o](t[n],i)&&(s.push({element:l,datasetIndex:c,index:u}),a=a||l.inRange(t.x,t.y,i))}),r&&!a?[]:s}var fz={modes:{index(e,t,n,r){const i=Ri(t,e),s=n.axis||"x",o=n.includeInvisible||!1,a=n.intersect?Kh(e,i,s,r,o):Yh(e,i,s,!1,r,o),l=[];return a.length?(e.getSortedVisibleDatasetMetas().forEach(c=>{const u=a[0].index,d=c.data[u];d&&!d.skip&&l.push({element:d,datasetIndex:c.index,index:u})}),l):[]},dataset(e,t,n,r){const i=Ri(t,e),s=n.axis||"xy",o=n.includeInvisible||!1;let a=n.intersect?Kh(e,i,s,r,o):Yh(e,i,s,!1,r,o);if(a.length>0){const l=a[0].datasetIndex,c=e.getDatasetMeta(l).data;a=[];for(let u=0;u<c.length;++u)a.push({element:c[u],datasetIndex:l,index:u})}return a},point(e,t,n,r){const i=Ri(t,e),s=n.axis||"xy",o=n.includeInvisible||!1;return Kh(e,i,s,r,o)},nearest(e,t,n,r){const i=Ri(t,e),s=n.axis||"xy",o=n.includeInvisible||!1;return Yh(e,i,s,n.intersect,r,o)},x(e,t,n,r){const i=Ri(t,e);return Sb(e,i,"x",n.intersect,r)},y(e,t,n,r){const i=Ri(t,e);return Sb(e,i,"y",n.intersect,r)}}};const qC=["left","top","right","bottom"];function zo(e,t){return e.filter(n=>n.pos===t)}function Cb(e,t){return e.filter(n=>qC.indexOf(n.pos)===-1&&n.box.axis===t)}function Bo(e,t){return e.sort((n,r)=>{const i=t?r:n,s=t?n:r;return i.weight===s.weight?i.index-s.index:i.weight-s.weight})}function pz(e){const t=[];let n,r,i,s,o,a;for(n=0,r=(e||[]).length;n<r;++n)i=e[n],{position:s,options:{stack:o,stackWeight:a=1}}=i,t.push({index:n,box:i,pos:s,horizontal:i.isHorizontal(),weight:i.weight,stack:o&&s+o,stackWeight:a});return t}function gz(e){const t={};for(const n of e){const{stack:r,pos:i,stackWeight:s}=n;if(!r||!qC.includes(i))continue;const o=t[r]||(t[r]={count:0,placed:0,weight:0,size:0});o.count++,o.weight+=s}return t}function mz(e,t){const n=gz(e),{vBoxMaxWidth:r,hBoxMaxHeight:i}=t;let s,o,a;for(s=0,o=e.length;s<o;++s){a=e[s];const{fullSize:l}=a.box,c=n[a.stack],u=c&&a.stackWeight/c.weight;a.horizontal?(a.width=u?u*r:l&&t.availableWidth,a.height=i):(a.width=r,a.height=u?u*i:l&&t.availableHeight)}return n}function xz(e){const t=pz(e),n=Bo(t.filter(c=>c.box.fullSize),!0),r=Bo(zo(t,"left"),!0),i=Bo(zo(t,"right")),s=Bo(zo(t,"top"),!0),o=Bo(zo(t,"bottom")),a=Cb(t,"x"),l=Cb(t,"y");return{fullSize:n,leftAndTop:r.concat(s),rightAndBottom:i.concat(l).concat(o).concat(a),chartArea:zo(t,"chartArea"),vertical:r.concat(i).concat(l),horizontal:s.concat(o).concat(a)}}function Eb(e,t,n,r){return Math.max(e[n],t[n])+Math.max(e[r],t[r])}function GC(e,t){e.top=Math.max(e.top,t.top),e.left=Math.max(e.left,t.left),e.bottom=Math.max(e.bottom,t.bottom),e.right=Math.max(e.right,t.right)}function vz(e,t,n,r){const{pos:i,box:s}=n,o=e.maxPadding;if(!ve(i)){n.size&&(e[i]-=n.size);const d=r[n.stack]||{size:0,count:1};d.size=Math.max(d.size,n.horizontal?s.height:s.width),n.size=d.size/d.count,e[i]+=n.size}s.getPadding&&GC(o,s.getPadding());const a=Math.max(0,t.outerWidth-Eb(o,e,"left","right")),l=Math.max(0,t.outerHeight-Eb(o,e,"top","bottom")),c=a!==e.w,u=l!==e.h;return e.w=a,e.h=l,n.horizontal?{same:c,other:u}:{same:u,other:c}}function yz(e){const t=e.maxPadding;function n(r){const i=Math.max(t[r]-e[r],0);return e[r]+=i,i}e.y+=n("top"),e.x+=n("left"),n("right"),n("bottom")}function bz(e,t){const n=t.maxPadding;function r(i){const s={left:0,top:0,right:0,bottom:0};return i.forEach(o=>{s[o]=Math.max(t[o],n[o])}),s}return r(e?["left","right"]:["top","bottom"])}function na(e,t,n,r){const i=[];let s,o,a,l,c,u;for(s=0,o=e.length,c=0;s<o;++s){a=e[s],l=a.box,l.update(a.width||t.w,a.height||t.h,bz(a.horizontal,t));const{same:d,other:h}=vz(t,n,a,r);c|=d&&i.length,u=u||h,l.fullSize||i.push(a)}return c&&na(i,t,n,r)||u}function ic(e,t,n,r,i){e.top=n,e.left=t,e.right=t+r,e.bottom=n+i,e.width=r,e.height=i}function Pb(e,t,n,r){const i=n.padding;let{x:s,y:o}=t;for(const a of e){const l=a.box,c=r[a.stack]||{placed:0,weight:1},u=a.stackWeight/c.weight||1;if(a.horizontal){const d=t.w*u,h=c.size||l.height;sl(c.start)&&(o=c.start),l.fullSize?ic(l,i.left,o,n.outerWidth-i.right-i.left,h):ic(l,t.left+c.placed,o,d,h),c.start=o,c.placed+=d,o=l.bottom}else{const d=t.h*u,h=c.size||l.width;sl(c.start)&&(s=c.start),l.fullSize?ic(l,s,i.top,h,n.outerHeight-i.bottom-i.top):ic(l,s,t.top+c.placed,h,d),c.start=s,c.placed+=d,s=l.right}}t.x=s,t.y=o}var Tt={addBox(e,t){e.boxes||(e.boxes=[]),t.fullSize=t.fullSize||!1,t.position=t.position||"top",t.weight=t.weight||0,t._layers=t._layers||function(){return[{z:0,draw(n){t.draw(n)}}]},e.boxes.push(t)},removeBox(e,t){const n=e.boxes?e.boxes.indexOf(t):-1;n!==-1&&e.boxes.splice(n,1)},configure(e,t,n){t.fullSize=n.fullSize,t.position=n.position,t.weight=n.weight},update(e,t,n,r){if(!e)return;const i=Rt(e.options.layout.padding),s=Math.max(t-i.width,0),o=Math.max(n-i.height,0),a=xz(e.boxes),l=a.vertical,c=a.horizontal;je(e.boxes,m=>{typeof m.beforeLayout=="function"&&m.beforeLayout()});const u=l.reduce((m,v)=>v.box.options&&v.box.options.display===!1?m:m+1,0)||1,d=Object.freeze({outerWidth:t,outerHeight:n,padding:i,availableWidth:s,availableHeight:o,vBoxMaxWidth:s/2/u,hBoxMaxHeight:o/2}),h=Object.assign({},i);GC(h,Rt(r));const p=Object.assign({maxPadding:h,w:s,h:o,x:i.left,y:i.top},i),g=mz(l.concat(c),d);na(a.fullSize,p,d,g),na(l,p,d,g),na(c,p,d,g)&&na(l,p,d,g),yz(p),Pb(a.leftAndTop,p,d,g),p.x+=p.w,p.y+=p.h,Pb(a.rightAndBottom,p,d,g),e.chartArea={left:p.left,top:p.top,right:p.left+p.w,bottom:p.top+p.h,height:p.h,width:p.w},je(a.chartArea,m=>{const v=m.box;Object.assign(v,e.chartArea),v.update(p.w,p.h,{left:0,top:0,right:0,bottom:0})})}};class KC{acquireContext(t,n){}releaseContext(t){return!1}addEventListener(t,n,r){}removeEventListener(t,n,r){}getDevicePixelRatio(){return 1}getMaximumSize(t,n,r,i){return n=Math.max(0,n||t.width),r=r||t.height,{width:n,height:Math.max(0,i?Math.floor(n/i):r)}}isAttached(t){return!0}updateConfig(t){}}class _z extends KC{acquireContext(t){return t&&t.getContext&&t.getContext("2d")||null}updateConfig(t){t.options.animation=!1}}const Fc="$chartjs",wz={touchstart:"mousedown",touchmove:"mousemove",touchend:"mouseup",pointerenter:"mouseenter",pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointerleave:"mouseout",pointerout:"mouseout"},Nb=e=>e===null||e==="";function kz(e,t){const n=e.style,r=e.getAttribute("height"),i=e.getAttribute("width");if(e[Fc]={initial:{height:r,width:i,style:{display:n.display,height:n.height,width:n.width}}},n.display=n.display||"block",n.boxSizing=n.boxSizing||"border-box",Nb(i)){const s=db(e,"width");s!==void 0&&(e.width=s)}if(Nb(r))if(e.style.height==="")e.height=e.width/(t||2);else{const s=db(e,"height");s!==void 0&&(e.height=s)}return e}const YC=S3?{passive:!0}:!1;function Sz(e,t,n){e&&e.addEventListener(t,n,YC)}function Cz(e,t,n){e&&e.canvas&&e.canvas.removeEventListener(t,n,YC)}function Ez(e,t){const n=wz[e.type]||e.type,{x:r,y:i}=Ri(e,t);return{type:n,chart:t,native:e,x:r!==void 0?r:null,y:i!==void 0?i:null}}function zu(e,t){for(const n of e)if(n===t||n.contains(t))return!0}function Pz(e,t,n){const r=e.canvas,i=new MutationObserver(s=>{let o=!1;for(const a of s)o=o||zu(a.addedNodes,r),o=o&&!zu(a.removedNodes,r);o&&n()});return i.observe(document,{childList:!0,subtree:!0}),i}function Nz(e,t,n){const r=e.canvas,i=new MutationObserver(s=>{let o=!1;for(const a of s)o=o||zu(a.removedNodes,r),o=o&&!zu(a.addedNodes,r);o&&n()});return i.observe(document,{childList:!0,subtree:!0}),i}const ll=new Map;let jb=0;function XC(){const e=window.devicePixelRatio;e!==jb&&(jb=e,ll.forEach((t,n)=>{n.currentDevicePixelRatio!==e&&t()}))}function jz(e,t){ll.size||window.addEventListener("resize",XC),ll.set(e,t)}function Tz(e){ll.delete(e),ll.size||window.removeEventListener("resize",XC)}function Mz(e,t,n){const r=e.canvas,i=r&&Zm(r);if(!i)return;const s=CC((a,l)=>{const c=i.clientWidth;n(a,l),c<i.clientWidth&&n()},window),o=new ResizeObserver(a=>{const l=a[0],c=l.contentRect.width,u=l.contentRect.height;c===0&&u===0||s(c,u)});return o.observe(i),jz(e,s),o}function Xh(e,t,n){n&&n.disconnect(),t==="resize"&&Tz(e)}function Rz(e,t,n){const r=e.canvas,i=CC(s=>{e.ctx!==null&&n(Ez(s,e))},e);return Sz(r,t,i),i}class Az extends KC{acquireContext(t,n){const r=t&&t.getContext&&t.getContext("2d");return r&&r.canvas===t?(kz(t,n),r):null}releaseContext(t){const n=t.canvas;if(!n[Fc])return!1;const r=n[Fc].initial;["height","width"].forEach(s=>{const o=r[s];ge(o)?n.removeAttribute(s):n.setAttribute(s,o)});const i=r.style||{};return Object.keys(i).forEach(s=>{n.style[s]=i[s]}),n.width=n.width,delete n[Fc],!0}addEventListener(t,n,r){this.removeEventListener(t,n);const i=t.$proxies||(t.$proxies={}),o={attach:Pz,detach:Nz,resize:Mz}[n]||Rz;i[n]=o(t,n,r)}removeEventListener(t,n){const r=t.$proxies||(t.$proxies={}),i=r[n];if(!i)return;({attach:Xh,detach:Xh,resize:Xh}[n]||Cz)(t,n,i),r[n]=void 0}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(t,n,r,i){return k3(t,n,r,i)}isAttached(t){const n=t&&Zm(t);return!!(n&&n.isConnected)}}function Dz(e){return!Qm()||typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas?_z:Az}var dc;let Mr=(dc=class{constructor(){W(this,"x");W(this,"y");W(this,"active",!1);W(this,"options");W(this,"$animations")}tooltipPosition(t){const{x:n,y:r}=this.getProps(["x","y"],t);return{x:n,y:r}}hasValue(){return oo(this.x)&&oo(this.y)}getProps(t,n){const r=this.$animations;if(!n||!r)return this;const i={};return t.forEach(s=>{i[s]=r[s]&&r[s].active()?r[s]._to:this[s]}),i}},W(dc,"defaults",{}),W(dc,"defaultRoutes"),dc);function Iz(e,t){const n=e.options.ticks,r=Oz(e),i=Math.min(n.maxTicksLimit||r,r),s=n.major.enabled?Fz(t):[],o=s.length,a=s[0],l=s[o-1],c=[];if(o>i)return $z(t,c,s,o/i),c;const u=Lz(s,t,i);if(o>0){let d,h;const p=o>1?Math.round((l-a)/(o-1)):null;for(sc(t,c,u,ge(p)?0:a-p,a),d=0,h=o-1;d<h;d++)sc(t,c,u,s[d],s[d+1]);return sc(t,c,u,l,ge(p)?t.length:l+p),c}return sc(t,c,u),c}function Oz(e){const t=e.options.offset,n=e._tickSize(),r=e._length/n+(t?0:1),i=e._maxLength/n;return Math.floor(Math.min(r,i))}function Lz(e,t,n){const r=zz(e),i=t.length/n;if(!r)return Math.max(i,1);const s=E5(r);for(let o=0,a=s.length-1;o<a;o++){const l=s[o];if(l>i)return l}return Math.max(i,1)}function Fz(e){const t=[];let n,r;for(n=0,r=e.length;n<r;n++)e[n].major&&t.push(n);return t}function $z(e,t,n,r){let i=0,s=n[0],o;for(r=Math.ceil(r),o=0;o<e.length;o++)o===s&&(t.push(e[o]),i++,s=n[i*r])}function sc(e,t,n,r,i){const s=ce(r,0),o=Math.min(ce(i,e.length),e.length);let a=0,l,c,u;for(n=Math.ceil(n),i&&(l=i-r,n=l/Math.floor(l/n)),u=s;u<0;)a++,u=Math.round(s+a*n);for(c=Math.max(s,0);c<o;c++)c===u&&(t.push(e[c]),a++,u=Math.round(s+a*n))}function zz(e){const t=e.length;let n,r;if(t<2)return!1;for(r=e[0],n=1;n<t;++n)if(e[n]-e[n-1]!==r)return!1;return r}const Bz=e=>e==="left"?"right":e==="right"?"left":e,Tb=(e,t,n)=>t==="top"||t==="left"?e[t]+n:e[t]-n,Mb=(e,t)=>Math.min(t||e,e);function Rb(e,t){const n=[],r=e.length/t,i=e.length;let s=0;for(;s<i;s+=r)n.push(e[Math.floor(s)]);return n}function Hz(e,t,n){const r=e.ticks.length,i=Math.min(t,r-1),s=e._startPixel,o=e._endPixel,a=1e-6;let l=e.getPixelForTick(i),c;if(!(n&&(r===1?c=Math.max(l-s,o-l):t===0?c=(e.getPixelForTick(1)-l)/2:c=(l-e.getPixelForTick(i-1))/2,l+=i<t?c:-c,l<s-a||l>o+a)))return l}function Vz(e,t){je(e,n=>{const r=n.gc,i=r.length/2;let s;if(i>t){for(s=0;s<i;++s)delete n.data[r[s]];r.splice(0,i)}})}function Ho(e){return e.drawTicks?e.tickLength:0}function Ab(e,t){if(!e.display)return 0;const n=ft(e.font,t),r=Rt(e.padding);return(We(e.text)?e.text.length:1)*n.lineHeight+r.height}function Wz(e,t){return yi(e,{scale:t,type:"scale"})}function Uz(e,t,n){return yi(e,{tick:n,index:t,type:"tick"})}function qz(e,t,n){let r=qm(e);return(n&&t!=="right"||!n&&t==="right")&&(r=Bz(r)),r}function Gz(e,t,n,r){const{top:i,left:s,bottom:o,right:a,chart:l}=e,{chartArea:c,scales:u}=l;let d=0,h,p,g;const m=o-i,v=a-s;if(e.isHorizontal()){if(p=Et(r,s,a),ve(n)){const x=Object.keys(n)[0],y=n[x];g=u[x].getPixelForValue(y)+m-t}else n==="center"?g=(c.bottom+c.top)/2+m-t:g=Tb(e,n,t);h=a-s}else{if(ve(n)){const x=Object.keys(n)[0],y=n[x];p=u[x].getPixelForValue(y)-v+t}else n==="center"?p=(c.left+c.right)/2-v+t:p=Tb(e,n,t);g=Et(r,o,i),d=n==="left"?-nt:nt}return{titleX:p,titleY:g,maxWidth:h,rotation:d}}class ss extends Mr{constructor(t){super(),this.id=t.id,this.type=t.type,this.options=void 0,this.ctx=t.ctx,this.chart=t.chart,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this._margins={left:0,right:0,top:0,bottom:0},this.maxWidth=void 0,this.maxHeight=void 0,this.paddingTop=void 0,this.paddingBottom=void 0,this.paddingLeft=void 0,this.paddingRight=void 0,this.axis=void 0,this.labelRotation=void 0,this.min=void 0,this.max=void 0,this._range=void 0,this.ticks=[],this._gridLineItems=null,this._labelItems=null,this._labelSizes=null,this._length=0,this._maxLength=0,this._longestTextCache={},this._startPixel=void 0,this._endPixel=void 0,this._reversePixels=!1,this._userMax=void 0,this._userMin=void 0,this._suggestedMax=void 0,this._suggestedMin=void 0,this._ticksLength=0,this._borderValue=0,this._cache={},this._dataLimitsCached=!1,this.$context=void 0}init(t){this.options=t.setContext(this.getContext()),this.axis=t.axis,this._userMin=this.parse(t.min),this._userMax=this.parse(t.max),this._suggestedMin=this.parse(t.suggestedMin),this._suggestedMax=this.parse(t.suggestedMax)}parse(t,n){return t}getUserBounds(){let{_userMin:t,_userMax:n,_suggestedMin:r,_suggestedMax:i}=this;return t=sn(t,Number.POSITIVE_INFINITY),n=sn(n,Number.NEGATIVE_INFINITY),r=sn(r,Number.POSITIVE_INFINITY),i=sn(i,Number.NEGATIVE_INFINITY),{min:sn(t,r),max:sn(n,i),minDefined:Qe(t),maxDefined:Qe(n)}}getMinMax(t){let{min:n,max:r,minDefined:i,maxDefined:s}=this.getUserBounds(),o;if(i&&s)return{min:n,max:r};const a=this.getMatchingVisibleMetas();for(let l=0,c=a.length;l<c;++l)o=a[l].controller.getMinMax(this,t),i||(n=Math.min(n,o.min)),s||(r=Math.max(r,o.max));return n=s&&n>r?r:n,r=i&&n>r?n:r,{min:sn(n,sn(r,n)),max:sn(r,sn(n,r))}}getPadding(){return{left:this.paddingLeft||0,top:this.paddingTop||0,right:this.paddingRight||0,bottom:this.paddingBottom||0}}getTicks(){return this.ticks}getLabels(){const t=this.chart.data;return this.options.labels||(this.isHorizontal()?t.xLabels:t.yLabels)||t.labels||[]}getLabelItems(t=this.chart.chartArea){return this._labelItems||(this._labelItems=this._computeLabelItems(t))}beforeLayout(){this._cache={},this._dataLimitsCached=!1}beforeUpdate(){Oe(this.options.beforeUpdate,[this])}update(t,n,r){const{beginAtZero:i,grace:s,ticks:o}=this.options,a=o.sampleSize;this.beforeUpdate(),this.maxWidth=t,this.maxHeight=n,this._margins=r=Object.assign({left:0,right:0,top:0,bottom:0},r),this.ticks=null,this._labelSizes=null,this._gridLineItems=null,this._labelItems=null,this.beforeSetDimensions(),this.setDimensions(),this.afterSetDimensions(),this._maxLength=this.isHorizontal()?this.width+r.left+r.right:this.height+r.top+r.bottom,this._dataLimitsCached||(this.beforeDataLimits(),this.determineDataLimits(),this.afterDataLimits(),this._range=t3(this,s,i),this._dataLimitsCached=!0),this.beforeBuildTicks(),this.ticks=this.buildTicks()||[],this.afterBuildTicks();const l=a<this.ticks.length;this._convertTicksToLabels(l?Rb(this.ticks,a):this.ticks),this.configure(),this.beforeCalculateLabelRotation(),this.calculateLabelRotation(),this.afterCalculateLabelRotation(),o.display&&(o.autoSkip||o.source==="auto")&&(this.ticks=Iz(this,this.ticks),this._labelSizes=null,this.afterAutoSkip()),l&&this._convertTicksToLabels(this.ticks),this.beforeFit(),this.fit(),this.afterFit(),this.afterUpdate()}configure(){let t=this.options.reverse,n,r;this.isHorizontal()?(n=this.left,r=this.right):(n=this.top,r=this.bottom,t=!t),this._startPixel=n,this._endPixel=r,this._reversePixels=t,this._length=r-n,this._alignToPixels=this.options.alignToPixels}afterUpdate(){Oe(this.options.afterUpdate,[this])}beforeSetDimensions(){Oe(this.options.beforeSetDimensions,[this])}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=0,this.right=this.width):(this.height=this.maxHeight,this.top=0,this.bottom=this.height),this.paddingLeft=0,this.paddingTop=0,this.paddingRight=0,this.paddingBottom=0}afterSetDimensions(){Oe(this.options.afterSetDimensions,[this])}_callHooks(t){this.chart.notifyPlugins(t,this.getContext()),Oe(this.options[t],[this])}beforeDataLimits(){this._callHooks("beforeDataLimits")}determineDataLimits(){}afterDataLimits(){this._callHooks("afterDataLimits")}beforeBuildTicks(){this._callHooks("beforeBuildTicks")}buildTicks(){return[]}afterBuildTicks(){this._callHooks("afterBuildTicks")}beforeTickToLabelConversion(){Oe(this.options.beforeTickToLabelConversion,[this])}generateTickLabels(t){const n=this.options.ticks;let r,i,s;for(r=0,i=t.length;r<i;r++)s=t[r],s.label=Oe(n.callback,[s.value,r,t],this)}afterTickToLabelConversion(){Oe(this.options.afterTickToLabelConversion,[this])}beforeCalculateLabelRotation(){Oe(this.options.beforeCalculateLabelRotation,[this])}calculateLabelRotation(){const t=this.options,n=t.ticks,r=Mb(this.ticks.length,t.ticks.maxTicksLimit),i=n.minRotation||0,s=n.maxRotation;let o=i,a,l,c;if(!this._isVisible()||!n.display||i>=s||r<=1||!this.isHorizontal()){this.labelRotation=i;return}const u=this._getLabelSizes(),d=u.widest.width,h=u.highest.height,p=gt(this.chart.width-d,0,this.maxWidth);a=t.offset?this.maxWidth/r:p/(r-1),d+6>a&&(a=p/(r-(t.offset?.5:1)),l=this.maxHeight-Ho(t.grid)-n.padding-Ab(t.title,this.chart.options.font),c=Math.sqrt(d*d+h*h),o=Wm(Math.min(Math.asin(gt((u.highest.height+6)/a,-1,1)),Math.asin(gt(l/c,-1,1))-Math.asin(gt(h/c,-1,1)))),o=Math.max(i,Math.min(s,o))),this.labelRotation=o}afterCalculateLabelRotation(){Oe(this.options.afterCalculateLabelRotation,[this])}afterAutoSkip(){}beforeFit(){Oe(this.options.beforeFit,[this])}fit(){const t={width:0,height:0},{chart:n,options:{ticks:r,title:i,grid:s}}=this,o=this._isVisible(),a=this.isHorizontal();if(o){const l=Ab(i,n.options.font);if(a?(t.width=this.maxWidth,t.height=Ho(s)+l):(t.height=this.maxHeight,t.width=Ho(s)+l),r.display&&this.ticks.length){const{first:c,last:u,widest:d,highest:h}=this._getLabelSizes(),p=r.padding*2,g=On(this.labelRotation),m=Math.cos(g),v=Math.sin(g);if(a){const x=r.mirror?0:v*d.width+m*h.height;t.height=Math.min(this.maxHeight,t.height+x+p)}else{const x=r.mirror?0:m*d.width+v*h.height;t.width=Math.min(this.maxWidth,t.width+x+p)}this._calculatePadding(c,u,v,m)}}this._handleMargins(),a?(this.width=this._length=n.width-this._margins.left-this._margins.right,this.height=t.height):(this.width=t.width,this.height=this._length=n.height-this._margins.top-this._margins.bottom)}_calculatePadding(t,n,r,i){const{ticks:{align:s,padding:o},position:a}=this.options,l=this.labelRotation!==0,c=a!=="top"&&this.axis==="x";if(this.isHorizontal()){const u=this.getPixelForTick(0)-this.left,d=this.right-this.getPixelForTick(this.ticks.length-1);let h=0,p=0;l?c?(h=i*t.width,p=r*n.height):(h=r*t.height,p=i*n.width):s==="start"?p=n.width:s==="end"?h=t.width:s!=="inner"&&(h=t.width/2,p=n.width/2),this.paddingLeft=Math.max((h-u+o)*this.width/(this.width-u),0),this.paddingRight=Math.max((p-d+o)*this.width/(this.width-d),0)}else{let u=n.height/2,d=t.height/2;s==="start"?(u=0,d=t.height):s==="end"&&(u=n.height,d=0),this.paddingTop=u+o,this.paddingBottom=d+o}}_handleMargins(){this._margins&&(this._margins.left=Math.max(this.paddingLeft,this._margins.left),this._margins.top=Math.max(this.paddingTop,this._margins.top),this._margins.right=Math.max(this.paddingRight,this._margins.right),this._margins.bottom=Math.max(this.paddingBottom,this._margins.bottom))}afterFit(){Oe(this.options.afterFit,[this])}isHorizontal(){const{axis:t,position:n}=this.options;return n==="top"||n==="bottom"||t==="x"}isFullSize(){return this.options.fullSize}_convertTicksToLabels(t){this.beforeTickToLabelConversion(),this.generateTickLabels(t);let n,r;for(n=0,r=t.length;n<r;n++)ge(t[n].label)&&(t.splice(n,1),r--,n--);this.afterTickToLabelConversion()}_getLabelSizes(){let t=this._labelSizes;if(!t){const n=this.options.ticks.sampleSize;let r=this.ticks;n<r.length&&(r=Rb(r,n)),this._labelSizes=t=this._computeLabelSizes(r,r.length,this.options.ticks.maxTicksLimit)}return t}_computeLabelSizes(t,n,r){const{ctx:i,_longestTextCache:s}=this,o=[],a=[],l=Math.floor(n/Mb(n,r));let c=0,u=0,d,h,p,g,m,v,x,y,b,k,w;for(d=0;d<n;d+=l){if(g=t[d].label,m=this._resolveTickFontOptions(d),i.font=v=m.string,x=s[v]=s[v]||{data:{},gc:[]},y=m.lineHeight,b=k=0,!ge(g)&&!We(g))b=Fu(i,x.data,x.gc,b,g),k=y;else if(We(g))for(h=0,p=g.length;h<p;++h)w=g[h],!ge(w)&&!We(w)&&(b=Fu(i,x.data,x.gc,b,w),k+=y);o.push(b),a.push(k),c=Math.max(b,c),u=Math.max(k,u)}Vz(s,n);const _=o.indexOf(c),N=a.indexOf(u),E=T=>({width:o[T]||0,height:a[T]||0});return{first:E(0),last:E(n-1),widest:E(_),highest:E(N),widths:o,heights:a}}getLabelForValue(t){return t}getPixelForValue(t,n){return NaN}getValueForPixel(t){}getPixelForTick(t){const n=this.ticks;return t<0||t>n.length-1?null:this.getPixelForValue(n[t].value)}getPixelForDecimal(t){this._reversePixels&&(t=1-t);const n=this._startPixel+t*this._length;return T5(this._alignToPixels?Ei(this.chart,n,0):n)}getDecimalForPixel(t){const n=(t-this._startPixel)/this._length;return this._reversePixels?1-n:n}getBasePixel(){return this.getPixelForValue(this.getBaseValue())}getBaseValue(){const{min:t,max:n}=this;return t<0&&n<0?n:t>0&&n>0?t:0}getContext(t){const n=this.ticks||[];if(t>=0&&t<n.length){const r=n[t];return r.$context||(r.$context=Uz(this.getContext(),t,r))}return this.$context||(this.$context=Wz(this.chart.getContext(),this))}_tickSize(){const t=this.options.ticks,n=On(this.labelRotation),r=Math.abs(Math.cos(n)),i=Math.abs(Math.sin(n)),s=this._getLabelSizes(),o=t.autoSkipPadding||0,a=s?s.widest.width+o:0,l=s?s.highest.height+o:0;return this.isHorizontal()?l*r>a*i?a/r:l/i:l*i<a*r?l/r:a/i}_isVisible(){const t=this.options.display;return t!=="auto"?!!t:this.getMatchingVisibleMetas().length>0}_computeGridLineItems(t){const n=this.axis,r=this.chart,i=this.options,{grid:s,position:o,border:a}=i,l=s.offset,c=this.isHorizontal(),d=this.ticks.length+(l?1:0),h=Ho(s),p=[],g=a.setContext(this.getContext()),m=g.display?g.width:0,v=m/2,x=function(q){return Ei(r,q,m)};let y,b,k,w,_,N,E,T,S,M,A,F;if(o==="top")y=x(this.bottom),N=this.bottom-h,T=y-v,M=x(t.top)+v,F=t.bottom;else if(o==="bottom")y=x(this.top),M=t.top,F=x(t.bottom)-v,N=y+v,T=this.top+h;else if(o==="left")y=x(this.right),_=this.right-h,E=y-v,S=x(t.left)+v,A=t.right;else if(o==="right")y=x(this.left),S=t.left,A=x(t.right)-v,_=y+v,E=this.left+h;else if(n==="x"){if(o==="center")y=x((t.top+t.bottom)/2+.5);else if(ve(o)){const q=Object.keys(o)[0],X=o[q];y=x(this.chart.scales[q].getPixelForValue(X))}M=t.top,F=t.bottom,N=y+v,T=N+h}else if(n==="y"){if(o==="center")y=x((t.left+t.right)/2);else if(ve(o)){const q=Object.keys(o)[0],X=o[q];y=x(this.chart.scales[q].getPixelForValue(X))}_=y-v,E=_-h,S=t.left,A=t.right}const H=ce(i.ticks.maxTicksLimit,d),O=Math.max(1,Math.ceil(d/H));for(b=0;b<d;b+=O){const q=this.getContext(b),X=s.setContext(q),I=a.setContext(q),z=X.lineWidth,C=X.color,Q=I.dash||[],te=I.dashOffset,j=X.tickWidth,re=X.tickColor,le=X.tickBorderDash||[],oe=X.tickBorderDashOffset;k=Hz(this,b,l),k!==void 0&&(w=Ei(r,k,z),c?_=E=S=A=w:N=T=M=F=w,p.push({tx1:_,ty1:N,tx2:E,ty2:T,x1:S,y1:M,x2:A,y2:F,width:z,color:C,borderDash:Q,borderDashOffset:te,tickWidth:j,tickColor:re,tickBorderDash:le,tickBorderDashOffset:oe}))}return this._ticksLength=d,this._borderValue=y,p}_computeLabelItems(t){const n=this.axis,r=this.options,{position:i,ticks:s}=r,o=this.isHorizontal(),a=this.ticks,{align:l,crossAlign:c,padding:u,mirror:d}=s,h=Ho(r.grid),p=h+u,g=d?-u:p,m=-On(this.labelRotation),v=[];let x,y,b,k,w,_,N,E,T,S,M,A,F="middle";if(i==="top")_=this.bottom-g,N=this._getXAxisLabelAlignment();else if(i==="bottom")_=this.top+g,N=this._getXAxisLabelAlignment();else if(i==="left"){const O=this._getYAxisLabelAlignment(h);N=O.textAlign,w=O.x}else if(i==="right"){const O=this._getYAxisLabelAlignment(h);N=O.textAlign,w=O.x}else if(n==="x"){if(i==="center")_=(t.top+t.bottom)/2+p;else if(ve(i)){const O=Object.keys(i)[0],q=i[O];_=this.chart.scales[O].getPixelForValue(q)+p}N=this._getXAxisLabelAlignment()}else if(n==="y"){if(i==="center")w=(t.left+t.right)/2-p;else if(ve(i)){const O=Object.keys(i)[0],q=i[O];w=this.chart.scales[O].getPixelForValue(q)}N=this._getYAxisLabelAlignment(h).textAlign}n==="y"&&(l==="start"?F="top":l==="end"&&(F="bottom"));const H=this._getLabelSizes();for(x=0,y=a.length;x<y;++x){b=a[x],k=b.label;const O=s.setContext(this.getContext(x));E=this.getPixelForTick(x)+s.labelOffset,T=this._resolveTickFontOptions(x),S=T.lineHeight,M=We(k)?k.length:1;const q=M/2,X=O.color,I=O.textStrokeColor,z=O.textStrokeWidth;let C=N;o?(w=E,N==="inner"&&(x===y-1?C=this.options.reverse?"left":"right":x===0?C=this.options.reverse?"right":"left":C="center"),i==="top"?c==="near"||m!==0?A=-M*S+S/2:c==="center"?A=-H.highest.height/2-q*S+S:A=-H.highest.height+S/2:c==="near"||m!==0?A=S/2:c==="center"?A=H.highest.height/2-q*S:A=H.highest.height-M*S,d&&(A*=-1),m!==0&&!O.showLabelBackdrop&&(w+=S/2*Math.sin(m))):(_=E,A=(1-M)*S/2);let Q;if(O.showLabelBackdrop){const te=Rt(O.backdropPadding),j=H.heights[x],re=H.widths[x];let le=A-te.top,oe=0-te.left;switch(F){case"middle":le-=j/2;break;case"bottom":le-=j;break}switch(N){case"center":oe-=re/2;break;case"right":oe-=re;break;case"inner":x===y-1?oe-=re:x>0&&(oe-=re/2);break}Q={left:oe,top:le,width:re+te.width,height:j+te.height,color:O.backdropColor}}v.push({label:k,font:T,textOffset:A,options:{rotation:m,color:X,strokeColor:I,strokeWidth:z,textAlign:C,textBaseline:F,translation:[w,_],backdrop:Q}})}return v}_getXAxisLabelAlignment(){const{position:t,ticks:n}=this.options;if(-On(this.labelRotation))return t==="top"?"left":"right";let i="center";return n.align==="start"?i="left":n.align==="end"?i="right":n.align==="inner"&&(i="inner"),i}_getYAxisLabelAlignment(t){const{position:n,ticks:{crossAlign:r,mirror:i,padding:s}}=this.options,o=this._getLabelSizes(),a=t+s,l=o.widest.width;let c,u;return n==="left"?i?(u=this.right+s,r==="near"?c="left":r==="center"?(c="center",u+=l/2):(c="right",u+=l)):(u=this.right-a,r==="near"?c="right":r==="center"?(c="center",u-=l/2):(c="left",u=this.left)):n==="right"?i?(u=this.left+s,r==="near"?c="right":r==="center"?(c="center",u-=l/2):(c="left",u-=l)):(u=this.left+a,r==="near"?c="left":r==="center"?(c="center",u+=l/2):(c="right",u=this.right)):c="right",{textAlign:c,x:u}}_computeLabelArea(){if(this.options.ticks.mirror)return;const t=this.chart,n=this.options.position;if(n==="left"||n==="right")return{top:0,left:this.left,bottom:t.height,right:this.right};if(n==="top"||n==="bottom")return{top:this.top,left:0,bottom:this.bottom,right:t.width}}drawBackground(){const{ctx:t,options:{backgroundColor:n},left:r,top:i,width:s,height:o}=this;n&&(t.save(),t.fillStyle=n,t.fillRect(r,i,s,o),t.restore())}getLineWidthForValue(t){const n=this.options.grid;if(!this._isVisible()||!n.display)return 0;const i=this.ticks.findIndex(s=>s.value===t);return i>=0?n.setContext(this.getContext(i)).lineWidth:0}drawGrid(t){const n=this.options.grid,r=this.ctx,i=this._gridLineItems||(this._gridLineItems=this._computeGridLineItems(t));let s,o;const a=(l,c,u)=>{!u.width||!u.color||(r.save(),r.lineWidth=u.width,r.strokeStyle=u.color,r.setLineDash(u.borderDash||[]),r.lineDashOffset=u.borderDashOffset,r.beginPath(),r.moveTo(l.x,l.y),r.lineTo(c.x,c.y),r.stroke(),r.restore())};if(n.display)for(s=0,o=i.length;s<o;++s){const l=i[s];n.drawOnChartArea&&a({x:l.x1,y:l.y1},{x:l.x2,y:l.y2},l),n.drawTicks&&a({x:l.tx1,y:l.ty1},{x:l.tx2,y:l.ty2},{color:l.tickColor,width:l.tickWidth,borderDash:l.tickBorderDash,borderDashOffset:l.tickBorderDashOffset})}}drawBorder(){const{chart:t,ctx:n,options:{border:r,grid:i}}=this,s=r.setContext(this.getContext()),o=r.display?s.width:0;if(!o)return;const a=i.setContext(this.getContext(0)).lineWidth,l=this._borderValue;let c,u,d,h;this.isHorizontal()?(c=Ei(t,this.left,o)-o/2,u=Ei(t,this.right,a)+a/2,d=h=l):(d=Ei(t,this.top,o)-o/2,h=Ei(t,this.bottom,a)+a/2,c=u=l),n.save(),n.lineWidth=s.width,n.strokeStyle=s.color,n.beginPath(),n.moveTo(c,d),n.lineTo(u,h),n.stroke(),n.restore()}drawLabels(t){if(!this.options.ticks.display)return;const r=this.ctx,i=this._computeLabelArea();i&&bd(r,i);const s=this.getLabelItems(t);for(const o of s){const a=o.options,l=o.font,c=o.label,u=o.textOffset;Zi(r,c,0,u,l,a)}i&&_d(r)}drawTitle(){const{ctx:t,options:{position:n,title:r,reverse:i}}=this;if(!r.display)return;const s=ft(r.font),o=Rt(r.padding),a=r.align;let l=s.lineHeight/2;n==="bottom"||n==="center"||ve(n)?(l+=o.bottom,We(r.text)&&(l+=s.lineHeight*(r.text.length-1))):l+=o.top;const{titleX:c,titleY:u,maxWidth:d,rotation:h}=Gz(this,l,n,a);Zi(t,r.text,0,0,s,{color:r.color,maxWidth:d,rotation:h,textAlign:qz(a,n,i),textBaseline:"middle",translation:[c,u]})}draw(t){this._isVisible()&&(this.drawBackground(),this.drawGrid(t),this.drawBorder(),this.drawTitle(),this.drawLabels(t))}_layers(){const t=this.options,n=t.ticks&&t.ticks.z||0,r=ce(t.grid&&t.grid.z,-1),i=ce(t.border&&t.border.z,0);return!this._isVisible()||this.draw!==ss.prototype.draw?[{z:n,draw:s=>{this.draw(s)}}]:[{z:r,draw:s=>{this.drawBackground(),this.drawGrid(s),this.drawTitle()}},{z:i,draw:()=>{this.drawBorder()}},{z:n,draw:s=>{this.drawLabels(s)}}]}getMatchingVisibleMetas(t){const n=this.chart.getSortedVisibleDatasetMetas(),r=this.axis+"AxisID",i=[];let s,o;for(s=0,o=n.length;s<o;++s){const a=n[s];a[r]===this.id&&(!t||a.type===t)&&i.push(a)}return i}_resolveTickFontOptions(t){const n=this.options.ticks.setContext(this.getContext(t));return ft(n.font)}_maxDigits(){const t=this._resolveTickFontOptions(0).lineHeight;return(this.isHorizontal()?this.width:this.height)/t}}class oc{constructor(t,n,r){this.type=t,this.scope=n,this.override=r,this.items=Object.create(null)}isForType(t){return Object.prototype.isPrototypeOf.call(this.type.prototype,t.prototype)}register(t){const n=Object.getPrototypeOf(t);let r;Xz(n)&&(r=this.register(n));const i=this.items,s=t.id,o=this.scope+"."+s;if(!s)throw new Error("class does not have id: "+t);return s in i||(i[s]=t,Kz(t,o,r),this.override&&Ue.override(t.id,t.overrides)),o}get(t){return this.items[t]}unregister(t){const n=this.items,r=t.id,i=this.scope;r in n&&delete n[r],i&&r in Ue[i]&&(delete Ue[i][r],this.override&&delete Qi[r])}}function Kz(e,t,n){const r=il(Object.create(null),[n?Ue.get(n):{},Ue.get(t),e.defaults]);Ue.set(t,r),e.defaultRoutes&&Yz(t,e.defaultRoutes),e.descriptors&&Ue.describe(t,e.descriptors)}function Yz(e,t){Object.keys(t).forEach(n=>{const r=n.split("."),i=r.pop(),s=[e].concat(r).join("."),o=t[n].split("."),a=o.pop(),l=o.join(".");Ue.route(s,i,l,a)})}function Xz(e){return"id"in e&&"defaults"in e}class Jz{constructor(){this.controllers=new oc(zn,"datasets",!0),this.elements=new oc(Mr,"elements"),this.plugins=new oc(Object,"plugins"),this.scales=new oc(ss,"scales"),this._typedRegistries=[this.controllers,this.scales,this.elements]}add(...t){this._each("register",t)}remove(...t){this._each("unregister",t)}addControllers(...t){this._each("register",t,this.controllers)}addElements(...t){this._each("register",t,this.elements)}addPlugins(...t){this._each("register",t,this.plugins)}addScales(...t){this._each("register",t,this.scales)}getController(t){return this._get(t,this.controllers,"controller")}getElement(t){return this._get(t,this.elements,"element")}getPlugin(t){return this._get(t,this.plugins,"plugin")}getScale(t){return this._get(t,this.scales,"scale")}removeControllers(...t){this._each("unregister",t,this.controllers)}removeElements(...t){this._each("unregister",t,this.elements)}removePlugins(...t){this._each("unregister",t,this.plugins)}removeScales(...t){this._each("unregister",t,this.scales)}_each(t,n,r){[...n].forEach(i=>{const s=r||this._getRegistryForType(i);r||s.isForType(i)||s===this.plugins&&i.id?this._exec(t,s,i):je(i,o=>{const a=r||this._getRegistryForType(o);this._exec(t,a,o)})})}_exec(t,n,r){const i=Vm(t);Oe(r["before"+i],[],r),n[t](r),Oe(r["after"+i],[],r)}_getRegistryForType(t){for(let n=0;n<this._typedRegistries.length;n++){const r=this._typedRegistries[n];if(r.isForType(t))return r}return this.plugins}_get(t,n,r){const i=n.get(t);if(i===void 0)throw new Error('"'+t+'" is not a registered '+r+".");return i}}var Kn=new Jz;class Qz{constructor(){this._init=void 0}notify(t,n,r,i){if(n==="beforeInit"&&(this._init=this._createDescriptors(t,!0),this._notify(this._init,t,"install")),this._init===void 0)return;const s=i?this._descriptors(t).filter(i):this._descriptors(t),o=this._notify(s,t,n,r);return n==="afterDestroy"&&(this._notify(s,t,"stop"),this._notify(this._init,t,"uninstall"),this._init=void 0),o}_notify(t,n,r,i){i=i||{};for(const s of t){const o=s.plugin,a=o[r],l=[n,i,s.options];if(Oe(a,l,o)===!1&&i.cancelable)return!1}return!0}invalidate(){ge(this._cache)||(this._oldCache=this._cache,this._cache=void 0)}_descriptors(t){if(this._cache)return this._cache;const n=this._cache=this._createDescriptors(t);return this._notifyStateChanges(t),n}_createDescriptors(t,n){const r=t&&t.config,i=ce(r.options&&r.options.plugins,{}),s=Zz(r);return i===!1&&!n?[]:t4(t,s,i,n)}_notifyStateChanges(t){const n=this._oldCache||[],r=this._cache,i=(s,o)=>s.filter(a=>!o.some(l=>a.plugin.id===l.plugin.id));this._notify(i(n,r),t,"stop"),this._notify(i(r,n),t,"start")}}function Zz(e){const t={},n=[],r=Object.keys(Kn.plugins.items);for(let s=0;s<r.length;s++)n.push(Kn.getPlugin(r[s]));const i=e.plugins||[];for(let s=0;s<i.length;s++){const o=i[s];n.indexOf(o)===-1&&(n.push(o),t[o.id]=!0)}return{plugins:n,localIds:t}}function e4(e,t){return!t&&e===!1?null:e===!0?{}:e}function t4(e,{plugins:t,localIds:n},r,i){const s=[],o=e.getContext();for(const a of t){const l=a.id,c=e4(r[l],i);c!==null&&s.push({plugin:a,options:n4(e.config,{plugin:a,local:n[l]},c,o)})}return s}function n4(e,{plugin:t,local:n},r,i){const s=e.pluginScopeKeys(t),o=e.getOptionScopes(r,s);return n&&t.defaults&&o.push(t.defaults),e.createResolver(o,i,[""],{scriptable:!1,indexable:!1,allKeys:!0})}function Jp(e,t){const n=Ue.datasets[e]||{};return((t.datasets||{})[e]||{}).indexAxis||t.indexAxis||n.indexAxis||"x"}function r4(e,t){let n=e;return e==="_index_"?n=t:e==="_value_"&&(n=t==="x"?"y":"x"),n}function i4(e,t){return e===t?"_index_":"_value_"}function Db(e){if(e==="x"||e==="y"||e==="r")return e}function s4(e){if(e==="top"||e==="bottom")return"x";if(e==="left"||e==="right")return"y"}function Qp(e,...t){if(Db(e))return e;for(const n of t){const r=n.axis||s4(n.position)||e.length>1&&Db(e[0].toLowerCase());if(r)return r}throw new Error(`Cannot determine type of '${e}' axis. Please provide 'axis' or 'position' option.`)}function Ib(e,t,n){if(n[t+"AxisID"]===e)return{axis:t}}function o4(e,t){if(t.data&&t.data.datasets){const n=t.data.datasets.filter(r=>r.xAxisID===e||r.yAxisID===e);if(n.length)return Ib(e,"x",n[0])||Ib(e,"y",n[0])}return{}}function a4(e,t){const n=Qi[e.type]||{scales:{}},r=t.scales||{},i=Jp(e.type,t),s=Object.create(null);return Object.keys(r).forEach(o=>{const a=r[o];if(!ve(a))return console.error(`Invalid scale configuration for scale: ${o}`);if(a._proxy)return console.warn(`Ignoring resolver passed as options for scale: ${o}`);const l=Qp(o,a,o4(o,e),Ue.scales[a.type]),c=i4(l,i),u=n.scales||{};s[o]=Sa(Object.create(null),[{axis:l},a,u[l],u[c]])}),e.data.datasets.forEach(o=>{const a=o.type||e.type,l=o.indexAxis||Jp(a,t),u=(Qi[a]||{}).scales||{};Object.keys(u).forEach(d=>{const h=r4(d,l),p=o[h+"AxisID"]||h;s[p]=s[p]||Object.create(null),Sa(s[p],[{axis:h},r[p],u[d]])})}),Object.keys(s).forEach(o=>{const a=s[o];Sa(a,[Ue.scales[a.type],Ue.scale])}),s}function JC(e){const t=e.options||(e.options={});t.plugins=ce(t.plugins,{}),t.scales=a4(e,t)}function QC(e){return e=e||{},e.datasets=e.datasets||[],e.labels=e.labels||[],e}function l4(e){return e=e||{},e.data=QC(e.data),JC(e),e}const Ob=new Map,ZC=new Set;function ac(e,t){let n=Ob.get(e);return n||(n=t(),Ob.set(e,n),ZC.add(n)),n}const Vo=(e,t,n)=>{const r=hi(t,n);r!==void 0&&e.add(r)};class c4{constructor(t){this._config=l4(t),this._scopeCache=new Map,this._resolverCache=new Map}get platform(){return this._config.platform}get type(){return this._config.type}set type(t){this._config.type=t}get data(){return this._config.data}set data(t){this._config.data=QC(t)}get options(){return this._config.options}set options(t){this._config.options=t}get plugins(){return this._config.plugins}update(){const t=this._config;this.clearCache(),JC(t)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(t){return ac(t,()=>[[`datasets.${t}`,""]])}datasetAnimationScopeKeys(t,n){return ac(`${t}.transition.${n}`,()=>[[`datasets.${t}.transitions.${n}`,`transitions.${n}`],[`datasets.${t}`,""]])}datasetElementScopeKeys(t,n){return ac(`${t}-${n}`,()=>[[`datasets.${t}.elements.${n}`,`datasets.${t}`,`elements.${n}`,""]])}pluginScopeKeys(t){const n=t.id,r=this.type;return ac(`${r}-plugin-${n}`,()=>[[`plugins.${n}`,...t.additionalOptionScopes||[]]])}_cachedScopes(t,n){const r=this._scopeCache;let i=r.get(t);return(!i||n)&&(i=new Map,r.set(t,i)),i}getOptionScopes(t,n,r){const{options:i,type:s}=this,o=this._cachedScopes(t,r),a=o.get(n);if(a)return a;const l=new Set;n.forEach(u=>{t&&(l.add(t),u.forEach(d=>Vo(l,t,d))),u.forEach(d=>Vo(l,i,d)),u.forEach(d=>Vo(l,Qi[s]||{},d)),u.forEach(d=>Vo(l,Ue,d)),u.forEach(d=>Vo(l,Kp,d))});const c=Array.from(l);return c.length===0&&c.push(Object.create(null)),ZC.has(n)&&o.set(n,c),c}chartOptionScopes(){const{options:t,type:n}=this;return[t,Qi[n]||{},Ue.datasets[n]||{},{type:n},Ue,Kp]}resolveNamedOptions(t,n,r,i=[""]){const s={$shared:!0},{resolver:o,subPrefixes:a}=Lb(this._resolverCache,t,i);let l=o;if(d4(o,n)){s.$shared=!1,r=fi(r)?r():r;const c=this.createResolver(t,r,a);l=ao(o,r,c)}for(const c of n)s[c]=l[c];return s}createResolver(t,n,r=[""],i){const{resolver:s}=Lb(this._resolverCache,t,r);return ve(n)?ao(s,n,void 0,i):s}}function Lb(e,t,n){let r=e.get(t);r||(r=new Map,e.set(t,r));const i=n.join();let s=r.get(i);return s||(s={resolver:Ym(t,n),subPrefixes:n.filter(a=>!a.toLowerCase().includes("hover"))},r.set(i,s)),s}const u4=e=>ve(e)&&Object.getOwnPropertyNames(e).some(t=>fi(e[t]));function d4(e,t){const{isScriptable:n,isIndexable:r}=MC(e);for(const i of t){const s=n(i),o=r(i),a=(o||s)&&e[i];if(s&&(fi(a)||u4(a))||o&&We(a))return!0}return!1}var h4="4.5.1";const f4=["top","bottom","left","right","chartArea"];function Fb(e,t){return e==="top"||e==="bottom"||f4.indexOf(e)===-1&&t==="x"}function $b(e,t){return function(n,r){return n[e]===r[e]?n[t]-r[t]:n[e]-r[e]}}function zb(e){const t=e.chart,n=t.options.animation;t.notifyPlugins("afterRender"),Oe(n&&n.onComplete,[e],t)}function p4(e){const t=e.chart,n=t.options.animation;Oe(n&&n.onProgress,[e],t)}function eE(e){return Qm()&&typeof e=="string"?e=document.getElementById(e):e&&e.length&&(e=e[0]),e&&e.canvas&&(e=e.canvas),e}const $c={},Bb=e=>{const t=eE(e);return Object.values($c).filter(n=>n.canvas===t).pop()};function g4(e,t,n){const r=Object.keys(e);for(const i of r){const s=+i;if(s>=t){const o=e[i];delete e[i],(n>0||s>t)&&(e[s+n]=o)}}}function m4(e,t,n,r){return!n||e.type==="mouseout"?null:r?t:e}class Xn{static register(...t){Kn.add(...t),Hb()}static unregister(...t){Kn.remove(...t),Hb()}constructor(t,n){const r=this.config=new c4(n),i=eE(t),s=Bb(i);if(s)throw new Error("Canvas is already in use. Chart with ID '"+s.id+"' must be destroyed before the canvas with ID '"+s.canvas.id+"' can be reused.");const o=r.createResolver(r.chartOptionScopes(),this.getContext());this.platform=new(r.platform||Dz(i)),this.platform.updateConfig(r);const a=this.platform.acquireContext(i,o.aspectRatio),l=a&&a.canvas,c=l&&l.height,u=l&&l.width;if(this.id=x5(),this.ctx=a,this.canvas=l,this.width=u,this.height=c,this._options=o,this._aspectRatio=this.aspectRatio,this._layers=[],this._metasets=[],this._stacks=void 0,this.boxes=[],this.currentDevicePixelRatio=void 0,this.chartArea=void 0,this._active=[],this._lastEvent=void 0,this._listeners={},this._responsiveListeners=void 0,this._sortedMetasets=[],this.scales={},this._plugins=new Qz,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=D5(d=>this.update(d),o.resizeDelay||0),this._dataChanges=[],$c[this.id]=this,!a||!l){console.error("Failed to create chart: can't acquire context from the given item");return}dr.listen(this,"complete",zb),dr.listen(this,"progress",p4),this._initialize(),this.attached&&this.update()}get aspectRatio(){const{options:{aspectRatio:t,maintainAspectRatio:n},width:r,height:i,_aspectRatio:s}=this;return ge(t)?n&&s?s:i?r/i:null:t}get data(){return this.config.data}set data(t){this.config.data=t}get options(){return this._options}set options(t){this.config.options=t}get registry(){return Kn}_initialize(){return this.notifyPlugins("beforeInit"),this.options.responsive?this.resize():ub(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins("afterInit"),this}clear(){return ab(this.canvas,this.ctx),this}stop(){return dr.stop(this),this}resize(t,n){dr.running(this)?this._resizeBeforeDraw={width:t,height:n}:this._resize(t,n)}_resize(t,n){const r=this.options,i=this.canvas,s=r.maintainAspectRatio&&this.aspectRatio,o=this.platform.getMaximumSize(i,t,n,s),a=r.devicePixelRatio||this.platform.getDevicePixelRatio(),l=this.width?"resize":"attach";this.width=o.width,this.height=o.height,this._aspectRatio=this.aspectRatio,ub(this,a,!0)&&(this.notifyPlugins("resize",{size:o}),Oe(r.onResize,[this,o],this),this.attached&&this._doResize(l)&&this.render())}ensureScalesHaveIDs(){const n=this.options.scales||{};je(n,(r,i)=>{r.id=i})}buildOrUpdateScales(){const t=this.options,n=t.scales,r=this.scales,i=Object.keys(r).reduce((o,a)=>(o[a]=!1,o),{});let s=[];n&&(s=s.concat(Object.keys(n).map(o=>{const a=n[o],l=Qp(o,a),c=l==="r",u=l==="x";return{options:a,dposition:c?"chartArea":u?"bottom":"left",dtype:c?"radialLinear":u?"category":"linear"}}))),je(s,o=>{const a=o.options,l=a.id,c=Qp(l,a),u=ce(a.type,o.dtype);(a.position===void 0||Fb(a.position,c)!==Fb(o.dposition))&&(a.position=o.dposition),i[l]=!0;let d=null;if(l in r&&r[l].type===u)d=r[l];else{const h=Kn.getScale(u);d=new h({id:l,type:u,ctx:this.ctx,chart:this}),r[d.id]=d}d.init(a,t)}),je(i,(o,a)=>{o||delete r[a]}),je(r,o=>{Tt.configure(this,o,o.options),Tt.addBox(this,o)})}_updateMetasets(){const t=this._metasets,n=this.data.datasets.length,r=t.length;if(t.sort((i,s)=>i.index-s.index),r>n){for(let i=n;i<r;++i)this._destroyDatasetMeta(i);t.splice(n,r-n)}this._sortedMetasets=t.slice(0).sort($b("order","index"))}_removeUnreferencedMetasets(){const{_metasets:t,data:{datasets:n}}=this;t.length>n.length&&delete this._stacks,t.forEach((r,i)=>{n.filter(s=>s===r._dataset).length===0&&this._destroyDatasetMeta(i)})}buildOrUpdateControllers(){const t=[],n=this.data.datasets;let r,i;for(this._removeUnreferencedMetasets(),r=0,i=n.length;r<i;r++){const s=n[r];let o=this.getDatasetMeta(r);const a=s.type||this.config.type;if(o.type&&o.type!==a&&(this._destroyDatasetMeta(r),o=this.getDatasetMeta(r)),o.type=a,o.indexAxis=s.indexAxis||Jp(a,this.options),o.order=s.order||0,o.index=r,o.label=""+s.label,o.visible=this.isDatasetVisible(r),o.controller)o.controller.updateIndex(r),o.controller.linkScales();else{const l=Kn.getController(a),{datasetElementType:c,dataElementType:u}=Ue.datasets[a];Object.assign(l,{dataElementType:Kn.getElement(u),datasetElementType:c&&Kn.getElement(c)}),o.controller=new l(this,r),t.push(o.controller)}}return this._updateMetasets(),t}_resetElements(){je(this.data.datasets,(t,n)=>{this.getDatasetMeta(n).controller.reset()},this)}reset(){this._resetElements(),this.notifyPlugins("reset")}update(t){const n=this.config;n.update();const r=this._options=n.createResolver(n.chartOptionScopes(),this.getContext()),i=this._animationsDisabled=!r.animation;if(this._updateScales(),this._checkEventBindings(),this._updateHiddenIndices(),this._plugins.invalidate(),this.notifyPlugins("beforeUpdate",{mode:t,cancelable:!0})===!1)return;const s=this.buildOrUpdateControllers();this.notifyPlugins("beforeElementsUpdate");let o=0;for(let c=0,u=this.data.datasets.length;c<u;c++){const{controller:d}=this.getDatasetMeta(c),h=!i&&s.indexOf(d)===-1;d.buildOrUpdateElements(h),o=Math.max(+d.getMaxOverflow(),o)}o=this._minPadding=r.layout.autoPadding?o:0,this._updateLayout(o),i||je(s,c=>{c.reset()}),this._updateDatasets(t),this.notifyPlugins("afterUpdate",{mode:t}),this._layers.sort($b("z","_idx"));const{_active:a,_lastEvent:l}=this;l?this._eventHandler(l,!0):a.length&&this._updateHoverStyles(a,a,!0),this.render()}_updateScales(){je(this.scales,t=>{Tt.removeBox(this,t)}),this.ensureScalesHaveIDs(),this.buildOrUpdateScales()}_checkEventBindings(){const t=this.options,n=new Set(Object.keys(this._listeners)),r=new Set(t.events);(!Q0(n,r)||!!this._responsiveListeners!==t.responsive)&&(this.unbindEvents(),this.bindEvents())}_updateHiddenIndices(){const{_hiddenIndices:t}=this,n=this._getUniformDataChanges()||[];for(const{method:r,start:i,count:s}of n){const o=r==="_removeElements"?-s:s;g4(t,i,o)}}_getUniformDataChanges(){const t=this._dataChanges;if(!t||!t.length)return;this._dataChanges=[];const n=this.data.datasets.length,r=s=>new Set(t.filter(o=>o[0]===s).map((o,a)=>a+","+o.splice(1).join(","))),i=r(0);for(let s=1;s<n;s++)if(!Q0(i,r(s)))return;return Array.from(i).map(s=>s.split(",")).map(s=>({method:s[1],start:+s[2],count:+s[3]}))}_updateLayout(t){if(this.notifyPlugins("beforeLayout",{cancelable:!0})===!1)return;Tt.update(this,this.width,this.height,t);const n=this.chartArea,r=n.width<=0||n.height<=0;this._layers=[],je(this.boxes,i=>{r&&i.position==="chartArea"||(i.configure&&i.configure(),this._layers.push(...i._layers()))},this),this._layers.forEach((i,s)=>{i._idx=s}),this.notifyPlugins("afterLayout")}_updateDatasets(t){if(this.notifyPlugins("beforeDatasetsUpdate",{mode:t,cancelable:!0})!==!1){for(let n=0,r=this.data.datasets.length;n<r;++n)this.getDatasetMeta(n).controller.configure();for(let n=0,r=this.data.datasets.length;n<r;++n)this._updateDataset(n,fi(t)?t({datasetIndex:n}):t);this.notifyPlugins("afterDatasetsUpdate",{mode:t})}}_updateDataset(t,n){const r=this.getDatasetMeta(t),i={meta:r,index:t,mode:n,cancelable:!0};this.notifyPlugins("beforeDatasetUpdate",i)!==!1&&(r.controller._update(n),i.cancelable=!1,this.notifyPlugins("afterDatasetUpdate",i))}render(){this.notifyPlugins("beforeRender",{cancelable:!0})!==!1&&(dr.has(this)?this.attached&&!dr.running(this)&&dr.start(this):(this.draw(),zb({chart:this})))}draw(){let t;if(this._resizeBeforeDraw){const{width:r,height:i}=this._resizeBeforeDraw;this._resizeBeforeDraw=null,this._resize(r,i)}if(this.clear(),this.width<=0||this.height<=0||this.notifyPlugins("beforeDraw",{cancelable:!0})===!1)return;const n=this._layers;for(t=0;t<n.length&&n[t].z<=0;++t)n[t].draw(this.chartArea);for(this._drawDatasets();t<n.length;++t)n[t].draw(this.chartArea);this.notifyPlugins("afterDraw")}_getSortedDatasetMetas(t){const n=this._sortedMetasets,r=[];let i,s;for(i=0,s=n.length;i<s;++i){const o=n[i];(!t||o.visible)&&r.push(o)}return r}getSortedVisibleDatasetMetas(){return this._getSortedDatasetMetas(!0)}_drawDatasets(){if(this.notifyPlugins("beforeDatasetsDraw",{cancelable:!0})===!1)return;const t=this.getSortedVisibleDatasetMetas();for(let n=t.length-1;n>=0;--n)this._drawDataset(t[n]);this.notifyPlugins("afterDatasetsDraw")}_drawDataset(t){const n=this.ctx,r={meta:t,index:t.index,cancelable:!0},i=HC(this,t);this.notifyPlugins("beforeDatasetDraw",r)!==!1&&(i&&bd(n,i),t.controller.draw(),i&&_d(n),r.cancelable=!1,this.notifyPlugins("afterDatasetDraw",r))}isPointInArea(t){return wr(t,this.chartArea,this._minPadding)}getElementsAtEventForMode(t,n,r,i){const s=fz.modes[n];return typeof s=="function"?s(this,t,r,i):[]}getDatasetMeta(t){const n=this.data.datasets[t],r=this._metasets;let i=r.filter(s=>s&&s._dataset===n).pop();return i||(i={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null,order:n&&n.order||0,index:t,_dataset:n,_parsed:[],_sorted:!1},r.push(i)),i}getContext(){return this.$context||(this.$context=yi(null,{chart:this,type:"chart"}))}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(t){const n=this.data.datasets[t];if(!n)return!1;const r=this.getDatasetMeta(t);return typeof r.hidden=="boolean"?!r.hidden:!n.hidden}setDatasetVisibility(t,n){const r=this.getDatasetMeta(t);r.hidden=!n}toggleDataVisibility(t){this._hiddenIndices[t]=!this._hiddenIndices[t]}getDataVisibility(t){return!this._hiddenIndices[t]}_updateVisibility(t,n,r){const i=r?"show":"hide",s=this.getDatasetMeta(t),o=s.controller._resolveAnimations(void 0,i);sl(n)?(s.data[n].hidden=!r,this.update()):(this.setDatasetVisibility(t,r),o.update(s,{visible:r}),this.update(a=>a.datasetIndex===t?i:void 0))}hide(t,n){this._updateVisibility(t,n,!1)}show(t,n){this._updateVisibility(t,n,!0)}_destroyDatasetMeta(t){const n=this._metasets[t];n&&n.controller&&n.controller._destroy(),delete this._metasets[t]}_stop(){let t,n;for(this.stop(),dr.remove(this),t=0,n=this.data.datasets.length;t<n;++t)this._destroyDatasetMeta(t)}destroy(){this.notifyPlugins("beforeDestroy");const{canvas:t,ctx:n}=this;this._stop(),this.config.clearCache(),t&&(this.unbindEvents(),ab(t,n),this.platform.releaseContext(n),this.canvas=null,this.ctx=null),delete $c[this.id],this.notifyPlugins("afterDestroy")}toBase64Image(...t){return this.canvas.toDataURL(...t)}bindEvents(){this.bindUserEvents(),this.options.responsive?this.bindResponsiveEvents():this.attached=!0}bindUserEvents(){const t=this._listeners,n=this.platform,r=(s,o)=>{n.addEventListener(this,s,o),t[s]=o},i=(s,o,a)=>{s.offsetX=o,s.offsetY=a,this._eventHandler(s)};je(this.options.events,s=>r(s,i))}bindResponsiveEvents(){this._responsiveListeners||(this._responsiveListeners={});const t=this._responsiveListeners,n=this.platform,r=(l,c)=>{n.addEventListener(this,l,c),t[l]=c},i=(l,c)=>{t[l]&&(n.removeEventListener(this,l,c),delete t[l])},s=(l,c)=>{this.canvas&&this.resize(l,c)};let o;const a=()=>{i("attach",a),this.attached=!0,this.resize(),r("resize",s),r("detach",o)};o=()=>{this.attached=!1,i("resize",s),this._stop(),this._resize(0,0),r("attach",a)},n.isAttached(this.canvas)?a():o()}unbindEvents(){je(this._listeners,(t,n)=>{this.platform.removeEventListener(this,n,t)}),this._listeners={},je(this._responsiveListeners,(t,n)=>{this.platform.removeEventListener(this,n,t)}),this._responsiveListeners=void 0}updateHoverStyle(t,n,r){const i=r?"set":"remove";let s,o,a,l;for(n==="dataset"&&(s=this.getDatasetMeta(t[0].datasetIndex),s.controller["_"+i+"DatasetHoverStyle"]()),a=0,l=t.length;a<l;++a){o=t[a];const c=o&&this.getDatasetMeta(o.datasetIndex).controller;c&&c[i+"HoverStyle"](o.element,o.datasetIndex,o.index)}}getActiveElements(){return this._active||[]}setActiveElements(t){const n=this._active||[],r=t.map(({datasetIndex:s,index:o})=>{const a=this.getDatasetMeta(s);if(!a)throw new Error("No dataset found at index "+s);return{datasetIndex:s,element:a.data[o],index:o}});!Iu(r,n)&&(this._active=r,this._lastEvent=null,this._updateHoverStyles(r,n))}notifyPlugins(t,n,r){return this._plugins.notify(this,t,n,r)}isPluginEnabled(t){return this._plugins._cache.filter(n=>n.plugin.id===t).length===1}_updateHoverStyles(t,n,r){const i=this.options.hover,s=(l,c)=>l.filter(u=>!c.some(d=>u.datasetIndex===d.datasetIndex&&u.index===d.index)),o=s(n,t),a=r?t:s(t,n);o.length&&this.updateHoverStyle(o,i.mode,!1),a.length&&i.mode&&this.updateHoverStyle(a,i.mode,!0)}_eventHandler(t,n){const r={event:t,replay:n,cancelable:!0,inChartArea:this.isPointInArea(t)},i=o=>(o.options.events||this.options.events).includes(t.native.type);if(this.notifyPlugins("beforeEvent",r,i)===!1)return;const s=this._handleEvent(t,n,r.inChartArea);return r.cancelable=!1,this.notifyPlugins("afterEvent",r,i),(s||r.changed)&&this.render(),this}_handleEvent(t,n,r){const{_active:i=[],options:s}=this,o=n,a=this._getActiveElements(t,i,r,o),l=k5(t),c=m4(t,this._lastEvent,r,l);r&&(this._lastEvent=null,Oe(s.onHover,[t,a,this],this),l&&Oe(s.onClick,[t,a,this],this));const u=!Iu(a,i);return(u||n)&&(this._active=a,this._updateHoverStyles(a,i,n)),this._lastEvent=c,u}_getActiveElements(t,n,r,i){if(t.type==="mouseout")return[];if(!r)return n;const s=this.options.hover;return this.getElementsAtEventForMode(t,s.mode,s,i)}}W(Xn,"defaults",Ue),W(Xn,"instances",$c),W(Xn,"overrides",Qi),W(Xn,"registry",Kn),W(Xn,"version",h4),W(Xn,"getChart",Bb);function Hb(){return je(Xn.instances,e=>e._plugins.invalidate())}function x4(e,t,n){const{startAngle:r,x:i,y:s,outerRadius:o,innerRadius:a,options:l}=t,{borderWidth:c,borderJoinStyle:u}=l,d=Math.min(c/o,Pt(r-n));if(e.beginPath(),e.arc(i,s,o-c/2,r+d/2,n-d/2),a>0){const h=Math.min(c/a,Pt(r-n));e.arc(i,s,a+c/2,n-h/2,r+h/2,!0)}else{const h=Math.min(c/2,o*Pt(r-n));if(u==="round")e.arc(i,s,h,n-Ee/2,r+Ee/2,!0);else if(u==="bevel"){const p=2*h*h,g=-p*Math.cos(n+Ee/2)+i,m=-p*Math.sin(n+Ee/2)+s,v=p*Math.cos(r+Ee/2)+i,x=p*Math.sin(r+Ee/2)+s;e.lineTo(g,m),e.lineTo(v,x)}}e.closePath(),e.moveTo(0,0),e.rect(0,0,e.canvas.width,e.canvas.height),e.clip("evenodd")}function v4(e,t,n){const{startAngle:r,pixelMargin:i,x:s,y:o,outerRadius:a,innerRadius:l}=t;let c=i/a;e.beginPath(),e.arc(s,o,a,r-c,n+c),l>i?(c=i/l,e.arc(s,o,l,n+c,r-c,!0)):e.arc(s,o,i,n+nt,r-nt),e.closePath(),e.clip()}function y4(e){return Km(e,["outerStart","outerEnd","innerStart","innerEnd"])}function b4(e,t,n,r){const i=y4(e.options.borderRadius),s=(n-t)/2,o=Math.min(s,r*t/2),a=l=>{const c=(n-Math.min(s,l))*r/2;return gt(l,0,Math.min(s,c))};return{outerStart:a(i.outerStart),outerEnd:a(i.outerEnd),innerStart:gt(i.innerStart,0,o),innerEnd:gt(i.innerEnd,0,o)}}function gs(e,t,n,r){return{x:n+e*Math.cos(t),y:r+e*Math.sin(t)}}function Bu(e,t,n,r,i,s){const{x:o,y:a,startAngle:l,pixelMargin:c,innerRadius:u}=t,d=Math.max(t.outerRadius+r+n-c,0),h=u>0?u+r+n+c:0;let p=0;const g=i-l;if(r){const O=u>0?u-r:0,q=d>0?d-r:0,X=(O+q)/2,I=X!==0?g*X/(X+r):g;p=(g-I)/2}const m=Math.max(.001,g*d-n/Ee)/d,v=(g-m)/2,x=l+v+p,y=i-v-p,{outerStart:b,outerEnd:k,innerStart:w,innerEnd:_}=b4(t,h,d,y-x),N=d-b,E=d-k,T=x+b/N,S=y-k/E,M=h+w,A=h+_,F=x+w/M,H=y-_/A;if(e.beginPath(),s){const O=(T+S)/2;if(e.arc(o,a,d,T,O),e.arc(o,a,d,O,S),k>0){const z=gs(E,S,o,a);e.arc(z.x,z.y,k,S,y+nt)}const q=gs(A,y,o,a);if(e.lineTo(q.x,q.y),_>0){const z=gs(A,H,o,a);e.arc(z.x,z.y,_,y+nt,H+Math.PI)}const X=(y-_/h+(x+w/h))/2;if(e.arc(o,a,h,y-_/h,X,!0),e.arc(o,a,h,X,x+w/h,!0),w>0){const z=gs(M,F,o,a);e.arc(z.x,z.y,w,F+Math.PI,x-nt)}const I=gs(N,x,o,a);if(e.lineTo(I.x,I.y),b>0){const z=gs(N,T,o,a);e.arc(z.x,z.y,b,x-nt,T)}}else{e.moveTo(o,a);const O=Math.cos(T)*d+o,q=Math.sin(T)*d+a;e.lineTo(O,q);const X=Math.cos(S)*d+o,I=Math.sin(S)*d+a;e.lineTo(X,I)}e.closePath()}function _4(e,t,n,r,i){const{fullCircles:s,startAngle:o,circumference:a}=t;let l=t.endAngle;if(s){Bu(e,t,n,r,l,i);for(let c=0;c<s;++c)e.fill();isNaN(a)||(l=o+(a%He||He))}return Bu(e,t,n,r,l,i),e.fill(),l}function w4(e,t,n,r,i){const{fullCircles:s,startAngle:o,circumference:a,options:l}=t,{borderWidth:c,borderJoinStyle:u,borderDash:d,borderDashOffset:h,borderRadius:p}=l,g=l.borderAlign==="inner";if(!c)return;e.setLineDash(d||[]),e.lineDashOffset=h,g?(e.lineWidth=c*2,e.lineJoin=u||"round"):(e.lineWidth=c,e.lineJoin=u||"bevel");let m=t.endAngle;if(s){Bu(e,t,n,r,m,i);for(let v=0;v<s;++v)e.stroke();isNaN(a)||(m=o+(a%He||He))}g&&v4(e,t,m),l.selfJoin&&m-o>=Ee&&p===0&&u!=="miter"&&x4(e,t,m),s||(Bu(e,t,n,r,m,i),e.stroke())}class ra extends Mr{constructor(n){super();W(this,"circumference");W(this,"endAngle");W(this,"fullCircles");W(this,"innerRadius");W(this,"outerRadius");W(this,"pixelMargin");W(this,"startAngle");this.options=void 0,this.circumference=void 0,this.startAngle=void 0,this.endAngle=void 0,this.innerRadius=void 0,this.outerRadius=void 0,this.pixelMargin=0,this.fullCircles=0,n&&Object.assign(this,n)}inRange(n,r,i){const s=this.getProps(["x","y"],i),{angle:o,distance:a}=_C(s,{x:n,y:r}),{startAngle:l,endAngle:c,innerRadius:u,outerRadius:d,circumference:h}=this.getProps(["startAngle","endAngle","innerRadius","outerRadius","circumference"],i),p=(this.options.spacing+this.options.borderWidth)/2,g=ce(h,c-l),m=ol(o,l,c)&&l!==c,v=g>=He||m,x=br(a,u+p,d+p);return v&&x}getCenterPoint(n){const{x:r,y:i,startAngle:s,endAngle:o,innerRadius:a,outerRadius:l}=this.getProps(["x","y","startAngle","endAngle","innerRadius","outerRadius"],n),{offset:c,spacing:u}=this.options,d=(s+o)/2,h=(a+l+u+c)/2;return{x:r+Math.cos(d)*h,y:i+Math.sin(d)*h}}tooltipPosition(n){return this.getCenterPoint(n)}draw(n){const{options:r,circumference:i}=this,s=(r.offset||0)/4,o=(r.spacing||0)/2,a=r.circular;if(this.pixelMargin=r.borderAlign==="inner"?.33:0,this.fullCircles=i>He?Math.floor(i/He):0,i===0||this.innerRadius<0||this.outerRadius<0)return;n.save();const l=(this.startAngle+this.endAngle)/2;n.translate(Math.cos(l)*s,Math.sin(l)*s);const c=1-Math.sin(Math.min(Ee,i||0)),u=s*c;n.fillStyle=r.backgroundColor,n.strokeStyle=r.borderColor,_4(n,this,u,o,a),w4(n,this,u,o,a),n.restore()}}W(ra,"id","arc"),W(ra,"defaults",{borderAlign:"center",borderColor:"#fff",borderDash:[],borderDashOffset:0,borderJoinStyle:void 0,borderRadius:0,borderWidth:2,offset:0,spacing:0,angle:void 0,circular:!0,selfJoin:!1}),W(ra,"defaultRoutes",{backgroundColor:"backgroundColor"}),W(ra,"descriptors",{_scriptable:!0,_indexable:n=>n!=="borderDash"});function tE(e,t,n=t){e.lineCap=ce(n.borderCapStyle,t.borderCapStyle),e.setLineDash(ce(n.borderDash,t.borderDash)),e.lineDashOffset=ce(n.borderDashOffset,t.borderDashOffset),e.lineJoin=ce(n.borderJoinStyle,t.borderJoinStyle),e.lineWidth=ce(n.borderWidth,t.borderWidth),e.strokeStyle=ce(n.borderColor,t.borderColor)}function k4(e,t,n){e.lineTo(n.x,n.y)}function S4(e){return e.stepped?q5:e.tension||e.cubicInterpolationMode==="monotone"?G5:k4}function nE(e,t,n={}){const r=e.length,{start:i=0,end:s=r-1}=n,{start:o,end:a}=t,l=Math.max(i,o),c=Math.min(s,a),u=i<o&&s<o||i>a&&s>a;return{count:r,start:l,loop:t.loop,ilen:c<l&&!u?r+c-l:c-l}}function C4(e,t,n,r){const{points:i,options:s}=t,{count:o,start:a,loop:l,ilen:c}=nE(i,n,r),u=S4(s);let{move:d=!0,reverse:h}=r||{},p,g,m;for(p=0;p<=c;++p)g=i[(a+(h?c-p:p))%o],!g.skip&&(d?(e.moveTo(g.x,g.y),d=!1):u(e,m,g,h,s.stepped),m=g);return l&&(g=i[(a+(h?c:0))%o],u(e,m,g,h,s.stepped)),!!l}function E4(e,t,n,r){const i=t.points,{count:s,start:o,ilen:a}=nE(i,n,r),{move:l=!0,reverse:c}=r||{};let u=0,d=0,h,p,g,m,v,x;const y=k=>(o+(c?a-k:k))%s,b=()=>{m!==v&&(e.lineTo(u,v),e.lineTo(u,m),e.lineTo(u,x))};for(l&&(p=i[y(0)],e.moveTo(p.x,p.y)),h=0;h<=a;++h){if(p=i[y(h)],p.skip)continue;const k=p.x,w=p.y,_=k|0;_===g?(w<m?m=w:w>v&&(v=w),u=(d*u+k)/++d):(b(),e.lineTo(k,w),g=_,d=0,m=v=w),x=w}b()}function Zp(e){const t=e.options,n=t.borderDash&&t.borderDash.length;return!e._decimated&&!e._loop&&!t.tension&&t.cubicInterpolationMode!=="monotone"&&!t.stepped&&!n?E4:C4}function P4(e){return e.stepped?C3:e.tension||e.cubicInterpolationMode==="monotone"?E3:Ai}function N4(e,t,n,r){let i=t._path;i||(i=t._path=new Path2D,t.path(i,n,r)&&i.closePath()),tE(e,t.options),e.stroke(i)}function j4(e,t,n,r){const{segments:i,options:s}=t,o=Zp(t);for(const a of i)tE(e,s,a.style),e.beginPath(),o(e,t,a,{start:n,end:n+r-1})&&e.closePath(),e.stroke()}const T4=typeof Path2D=="function";function M4(e,t,n,r){T4&&!t.options.segment?N4(e,t,n,r):j4(e,t,n,r)}class Jr extends Mr{constructor(t){super(),this.animated=!0,this.options=void 0,this._chart=void 0,this._loop=void 0,this._fullLoop=void 0,this._path=void 0,this._points=void 0,this._segments=void 0,this._decimated=!1,this._pointsUpdated=!1,this._datasetIndex=void 0,t&&Object.assign(this,t)}updateControlPoints(t,n){const r=this.options;if((r.tension||r.cubicInterpolationMode==="monotone")&&!r.stepped&&!this._pointsUpdated){const i=r.spanGaps?this._loop:this._fullLoop;x3(this._points,r,t,i,n),this._pointsUpdated=!0}}set points(t){this._points=t,delete this._segments,delete this._path,this._pointsUpdated=!1}get points(){return this._points}get segments(){return this._segments||(this._segments=R3(this,this.options.segment))}first(){const t=this.segments,n=this.points;return t.length&&n[t[0].start]}last(){const t=this.segments,n=this.points,r=t.length;return r&&n[t[r-1].end]}interpolate(t,n){const r=this.options,i=t[n],s=this.points,o=BC(this,{property:n,start:i,end:i});if(!o.length)return;const a=[],l=P4(r);let c,u;for(c=0,u=o.length;c<u;++c){const{start:d,end:h}=o[c],p=s[d],g=s[h];if(p===g){a.push(p);continue}const m=Math.abs((i-p[n])/(g[n]-p[n])),v=l(p,g,m,r.stepped);v[n]=t[n],a.push(v)}return a.length===1?a[0]:a}pathSegment(t,n,r){return Zp(this)(t,this,n,r)}path(t,n,r){const i=this.segments,s=Zp(this);let o=this._loop;n=n||0,r=r||this.points.length-n;for(const a of i)o&=s(t,this,a,{start:n,end:n+r-1});return!!o}draw(t,n,r,i){const s=this.options||{};(this.points||[]).length&&s.borderWidth&&(t.save(),M4(t,this,r,i),t.restore()),this.animated&&(this._pointsUpdated=!1,this._path=void 0)}}W(Jr,"id","line"),W(Jr,"defaults",{borderCapStyle:"butt",borderDash:[],borderDashOffset:0,borderJoinStyle:"miter",borderWidth:3,capBezierPoints:!0,cubicInterpolationMode:"default",fill:!1,spanGaps:!1,stepped:!1,tension:0}),W(Jr,"defaultRoutes",{backgroundColor:"backgroundColor",borderColor:"borderColor"}),W(Jr,"descriptors",{_scriptable:!0,_indexable:t=>t!=="borderDash"&&t!=="fill"});function Vb(e,t,n,r){const i=e.options,{[n]:s}=e.getProps([n],r);return Math.abs(t-s)<i.radius+i.hitRadius}class zc extends Mr{constructor(n){super();W(this,"parsed");W(this,"skip");W(this,"stop");this.options=void 0,this.parsed=void 0,this.skip=void 0,this.stop=void 0,n&&Object.assign(this,n)}inRange(n,r,i){const s=this.options,{x:o,y:a}=this.getProps(["x","y"],i);return Math.pow(n-o,2)+Math.pow(r-a,2)<Math.pow(s.hitRadius+s.radius,2)}inXRange(n,r){return Vb(this,n,"x",r)}inYRange(n,r){return Vb(this,n,"y",r)}getCenterPoint(n){const{x:r,y:i}=this.getProps(["x","y"],n);return{x:r,y:i}}size(n){n=n||this.options||{};let r=n.radius||0;r=Math.max(r,r&&n.hoverRadius||0);const i=r&&n.borderWidth||0;return(r+i)*2}draw(n,r){const i=this.options;this.skip||i.radius<.1||!wr(this,r,this.size(i)/2)||(n.strokeStyle=i.borderColor,n.lineWidth=i.borderWidth,n.fillStyle=i.backgroundColor,Yp(n,i,this.x,this.y))}getRange(){const n=this.options||{};return n.radius+n.hitRadius}}W(zc,"id","point"),W(zc,"defaults",{borderWidth:1,hitRadius:1,hoverBorderWidth:1,hoverRadius:4,pointStyle:"circle",radius:3,rotation:0}),W(zc,"defaultRoutes",{backgroundColor:"backgroundColor",borderColor:"borderColor"});function rE(e,t){const{x:n,y:r,base:i,width:s,height:o}=e.getProps(["x","y","base","width","height"],t);let a,l,c,u,d;return e.horizontal?(d=o/2,a=Math.min(n,i),l=Math.max(n,i),c=r-d,u=r+d):(d=s/2,a=n-d,l=n+d,c=Math.min(r,i),u=Math.max(r,i)),{left:a,top:c,right:l,bottom:u}}function Qr(e,t,n,r){return e?0:gt(t,n,r)}function R4(e,t,n){const r=e.options.borderWidth,i=e.borderSkipped,s=TC(r);return{t:Qr(i.top,s.top,0,n),r:Qr(i.right,s.right,0,t),b:Qr(i.bottom,s.bottom,0,n),l:Qr(i.left,s.left,0,t)}}function A4(e,t,n){const{enableBorderRadius:r}=e.getProps(["enableBorderRadius"]),i=e.options.borderRadius,s=Vi(i),o=Math.min(t,n),a=e.borderSkipped,l=r||ve(i);return{topLeft:Qr(!l||a.top||a.left,s.topLeft,0,o),topRight:Qr(!l||a.top||a.right,s.topRight,0,o),bottomLeft:Qr(!l||a.bottom||a.left,s.bottomLeft,0,o),bottomRight:Qr(!l||a.bottom||a.right,s.bottomRight,0,o)}}function D4(e){const t=rE(e),n=t.right-t.left,r=t.bottom-t.top,i=R4(e,n/2,r/2),s=A4(e,n/2,r/2);return{outer:{x:t.left,y:t.top,w:n,h:r,radius:s},inner:{x:t.left+i.l,y:t.top+i.t,w:n-i.l-i.r,h:r-i.t-i.b,radius:{topLeft:Math.max(0,s.topLeft-Math.max(i.t,i.l)),topRight:Math.max(0,s.topRight-Math.max(i.t,i.r)),bottomLeft:Math.max(0,s.bottomLeft-Math.max(i.b,i.l)),bottomRight:Math.max(0,s.bottomRight-Math.max(i.b,i.r))}}}}function Jh(e,t,n,r){const i=t===null,s=n===null,a=e&&!(i&&s)&&rE(e,r);return a&&(i||br(t,a.left,a.right))&&(s||br(n,a.top,a.bottom))}function I4(e){return e.topLeft||e.topRight||e.bottomLeft||e.bottomRight}function O4(e,t){e.rect(t.x,t.y,t.w,t.h)}function Qh(e,t,n={}){const r=e.x!==n.x?-t:0,i=e.y!==n.y?-t:0,s=(e.x+e.w!==n.x+n.w?t:0)-r,o=(e.y+e.h!==n.y+n.h?t:0)-i;return{x:e.x+r,y:e.y+i,w:e.w+s,h:e.h+o,radius:e.radius}}class Bc extends Mr{constructor(t){super(),this.options=void 0,this.horizontal=void 0,this.base=void 0,this.width=void 0,this.height=void 0,this.inflateAmount=void 0,t&&Object.assign(this,t)}draw(t){const{inflateAmount:n,options:{borderColor:r,backgroundColor:i}}=this,{inner:s,outer:o}=D4(this),a=I4(o.radius)?al:O4;t.save(),(o.w!==s.w||o.h!==s.h)&&(t.beginPath(),a(t,Qh(o,n,s)),t.clip(),a(t,Qh(s,-n,o)),t.fillStyle=r,t.fill("evenodd")),t.beginPath(),a(t,Qh(s,n)),t.fillStyle=i,t.fill(),t.restore()}inRange(t,n,r){return Jh(this,t,n,r)}inXRange(t,n){return Jh(this,t,null,n)}inYRange(t,n){return Jh(this,null,t,n)}getCenterPoint(t){const{x:n,y:r,base:i,horizontal:s}=this.getProps(["x","y","base","horizontal"],t);return{x:s?(n+i)/2:n,y:s?r:(r+i)/2}}getRange(t){return t==="x"?this.width/2:this.height/2}}W(Bc,"id","bar"),W(Bc,"defaults",{borderSkipped:"start",borderWidth:0,borderRadius:0,inflateAmount:"auto",pointStyle:void 0}),W(Bc,"defaultRoutes",{backgroundColor:"backgroundColor",borderColor:"borderColor"});var L4=Object.freeze({__proto__:null,ArcElement:ra,BarElement:Bc,LineElement:Jr,PointElement:zc});const eg=["rgb(54, 162, 235)","rgb(255, 99, 132)","rgb(255, 159, 64)","rgb(255, 205, 86)","rgb(75, 192, 192)","rgb(153, 102, 255)","rgb(201, 203, 207)"],Wb=eg.map(e=>e.replace("rgb(","rgba(").replace(")",", 0.5)"));function iE(e){return eg[e%eg.length]}function sE(e){return Wb[e%Wb.length]}function F4(e,t){return e.borderColor=iE(t),e.backgroundColor=sE(t),++t}function $4(e,t){return e.backgroundColor=e.data.map(()=>iE(t++)),t}function z4(e,t){return e.backgroundColor=e.data.map(()=>sE(t++)),t}function B4(e){let t=0;return(n,r)=>{const i=e.getDatasetMeta(r).controller;i instanceof $i?t=$4(n,t):i instanceof Na?t=z4(n,t):i&&(t=F4(n,t))}}function Ub(e){let t;for(t in e)if(e[t].borderColor||e[t].backgroundColor)return!0;return!1}function H4(e){return e&&(e.borderColor||e.backgroundColor)}function V4(){return Ue.borderColor!=="rgba(0,0,0,0.1)"||Ue.backgroundColor!=="rgba(0,0,0,0.1)"}var W4={id:"colors",defaults:{enabled:!0,forceOverride:!1},beforeLayout(e,t,n){if(!n.enabled)return;const{data:{datasets:r},options:i}=e.config,{elements:s}=i,o=Ub(r)||H4(i)||s&&Ub(s)||V4();if(!n.forceOverride&&o)return;const a=B4(e);r.forEach(a)}};function U4(e,t,n,r,i){const s=i.samples||r;if(s>=n)return e.slice(t,t+n);const o=[],a=(n-2)/(s-2);let l=0;const c=t+n-1;let u=t,d,h,p,g,m;for(o[l++]=e[u],d=0;d<s-2;d++){let v=0,x=0,y;const b=Math.floor((d+1)*a)+1+t,k=Math.min(Math.floor((d+2)*a)+1,n)+t,w=k-b;for(y=b;y<k;y++)v+=e[y].x,x+=e[y].y;v/=w,x/=w;const _=Math.floor(d*a)+1+t,N=Math.min(Math.floor((d+1)*a)+1,n)+t,{x:E,y:T}=e[u];for(p=g=-1,y=_;y<N;y++)g=.5*Math.abs((E-v)*(e[y].y-T)-(E-e[y].x)*(x-T)),g>p&&(p=g,h=e[y],m=y);o[l++]=h,u=m}return o[l++]=e[c],o}function q4(e,t,n,r){let i=0,s=0,o,a,l,c,u,d,h,p,g,m;const v=[],x=t+n-1,y=e[t].x,k=e[x].x-y;for(o=t;o<t+n;++o){a=e[o],l=(a.x-y)/k*r,c=a.y;const w=l|0;if(w===u)c<g?(g=c,d=o):c>m&&(m=c,h=o),i=(s*i+a.x)/++s;else{const _=o-1;if(!ge(d)&&!ge(h)){const N=Math.min(d,h),E=Math.max(d,h);N!==p&&N!==_&&v.push({...e[N],x:i}),E!==p&&E!==_&&v.push({...e[E],x:i})}o>0&&_!==p&&v.push(e[_]),v.push(a),u=w,s=0,g=m=c,d=h=p=o}}return v}function oE(e){if(e._decimated){const t=e._data;delete e._decimated,delete e._data,Object.defineProperty(e,"data",{configurable:!0,enumerable:!0,writable:!0,value:t})}}function qb(e){e.data.datasets.forEach(t=>{oE(t)})}function G4(e,t){const n=t.length;let r=0,i;const{iScale:s}=e,{min:o,max:a,minDefined:l,maxDefined:c}=s.getUserBounds();return l&&(r=gt(_r(t,s.axis,o).lo,0,n-1)),c?i=gt(_r(t,s.axis,a).hi+1,r,n)-r:i=n-r,{start:r,count:i}}var K4={id:"decimation",defaults:{algorithm:"min-max",enabled:!1},beforeElementsUpdate:(e,t,n)=>{if(!n.enabled){qb(e);return}const r=e.width;e.data.datasets.forEach((i,s)=>{const{_data:o,indexAxis:a}=i,l=e.getDatasetMeta(s),c=o||i.data;if(ta([a,e.options.indexAxis])==="y"||!l.controller.supportsDecimation)return;const u=e.scales[l.xAxisID];if(u.type!=="linear"&&u.type!=="time"||e.options.parsing)return;let{start:d,count:h}=G4(l,c);const p=n.threshold||4*r;if(h<=p){oE(i);return}ge(o)&&(i._data=c,delete i.data,Object.defineProperty(i,"data",{configurable:!0,enumerable:!0,get:function(){return this._decimated},set:function(m){this._data=m}}));let g;switch(n.algorithm){case"lttb":g=U4(c,d,h,r,n);break;case"min-max":g=q4(c,d,h,r);break;default:throw new Error(`Unsupported decimation algorithm '${n.algorithm}'`)}i._decimated=g})},destroy(e){qb(e)}};function Y4(e,t,n){const r=e.segments,i=e.points,s=t.points,o=[];for(const a of r){let{start:l,end:c}=a;c=Sd(l,c,i);const u=tg(n,i[l],i[c],a.loop);if(!t.segments){o.push({source:a,target:u,start:i[l],end:i[c]});continue}const d=BC(t,u);for(const h of d){const p=tg(n,s[h.start],s[h.end],h.loop),g=zC(a,i,p);for(const m of g)o.push({source:m,target:h,start:{[n]:Gb(u,p,"start",Math.max)},end:{[n]:Gb(u,p,"end",Math.min)}})}}return o}function tg(e,t,n,r){if(r)return;let i=t[e],s=n[e];return e==="angle"&&(i=Pt(i),s=Pt(s)),{property:e,start:i,end:s}}function X4(e,t){const{x:n=null,y:r=null}=e||{},i=t.points,s=[];return t.segments.forEach(({start:o,end:a})=>{a=Sd(o,a,i);const l=i[o],c=i[a];r!==null?(s.push({x:l.x,y:r}),s.push({x:c.x,y:r})):n!==null&&(s.push({x:n,y:l.y}),s.push({x:n,y:c.y}))}),s}function Sd(e,t,n){for(;t>e;t--){const r=n[t];if(!isNaN(r.x)&&!isNaN(r.y))break}return t}function Gb(e,t,n,r){return e&&t?r(e[n],t[n]):e?e[n]:t?t[n]:0}function aE(e,t){let n=[],r=!1;return We(e)?(r=!0,n=e):n=X4(e,t),n.length?new Jr({points:n,options:{tension:0},_loop:r,_fullLoop:r}):null}function Kb(e){return e&&e.fill!==!1}function J4(e,t,n){let i=e[t].fill;const s=[t];let o;if(!n)return i;for(;i!==!1&&s.indexOf(i)===-1;){if(!Qe(i))return i;if(o=e[i],!o)return!1;if(o.visible)return i;s.push(i),i=o.fill}return!1}function Q4(e,t,n){const r=nB(e);if(ve(r))return isNaN(r.value)?!1:r;let i=parseFloat(r);return Qe(i)&&Math.floor(i)===i?Z4(r[0],t,i,n):["origin","start","end","stack","shape"].indexOf(r)>=0&&r}function Z4(e,t,n,r){return(e==="-"||e==="+")&&(n=t+n),n===t||n<0||n>=r?!1:n}function eB(e,t){let n=null;return e==="start"?n=t.bottom:e==="end"?n=t.top:ve(e)?n=t.getPixelForValue(e.value):t.getBasePixel&&(n=t.getBasePixel()),n}function tB(e,t,n){let r;return e==="start"?r=n:e==="end"?r=t.options.reverse?t.min:t.max:ve(e)?r=e.value:r=t.getBaseValue(),r}function nB(e){const t=e.options,n=t.fill;let r=ce(n&&n.target,n);return r===void 0&&(r=!!t.backgroundColor),r===!1||r===null?!1:r===!0?"origin":r}function rB(e){const{scale:t,index:n,line:r}=e,i=[],s=r.segments,o=r.points,a=iB(t,n);a.push(aE({x:null,y:t.bottom},r));for(let l=0;l<s.length;l++){const c=s[l];for(let u=c.start;u<=c.end;u++)sB(i,o[u],a)}return new Jr({points:i,options:{}})}function iB(e,t){const n=[],r=e.getMatchingVisibleMetas("line");for(let i=0;i<r.length;i++){const s=r[i];if(s.index===t)break;s.hidden||n.unshift(s.dataset)}return n}function sB(e,t,n){const r=[];for(let i=0;i<n.length;i++){const s=n[i],{first:o,last:a,point:l}=oB(s,t,"x");if(!(!l||o&&a)){if(o)r.unshift(l);else if(e.push(l),!a)break}}e.push(...r)}function oB(e,t,n){const r=e.interpolate(t,n);if(!r)return{};const i=r[n],s=e.segments,o=e.points;let a=!1,l=!1;for(let c=0;c<s.length;c++){const u=s[c],d=o[u.start][n],h=o[u.end][n];if(br(i,d,h)){a=i===d,l=i===h;break}}return{first:a,last:l,point:r}}class lE{constructor(t){this.x=t.x,this.y=t.y,this.radius=t.radius}pathSegment(t,n,r){const{x:i,y:s,radius:o}=this;return n=n||{start:0,end:He},t.arc(i,s,o,n.end,n.start,!0),!r.bounds}interpolate(t){const{x:n,y:r,radius:i}=this,s=t.angle;return{x:n+Math.cos(s)*i,y:r+Math.sin(s)*i,angle:s}}}function aB(e){const{chart:t,fill:n,line:r}=e;if(Qe(n))return lB(t,n);if(n==="stack")return rB(e);if(n==="shape")return!0;const i=cB(e);return i instanceof lE?i:aE(i,r)}function lB(e,t){const n=e.getDatasetMeta(t);return n&&e.isDatasetVisible(t)?n.dataset:null}function cB(e){return(e.scale||{}).getPointPositionForValue?dB(e):uB(e)}function uB(e){const{scale:t={},fill:n}=e,r=eB(n,t);if(Qe(r)){const i=t.isHorizontal();return{x:i?r:null,y:i?null:r}}return null}function dB(e){const{scale:t,fill:n}=e,r=t.options,i=t.getLabels().length,s=r.reverse?t.max:t.min,o=tB(n,t,s),a=[];if(r.grid.circular){const l=t.getPointPositionForValue(0,s);return new lE({x:l.x,y:l.y,radius:t.getDistanceFromCenterForValue(o)})}for(let l=0;l<i;++l)a.push(t.getPointPositionForValue(l,o));return a}function Zh(e,t,n){const r=aB(t),{chart:i,index:s,line:o,scale:a,axis:l}=t,c=o.options,u=c.fill,d=c.backgroundColor,{above:h=d,below:p=d}=u||{},g=i.getDatasetMeta(s),m=HC(i,g);r&&o.points.length&&(bd(e,n),hB(e,{line:o,target:r,above:h,below:p,area:n,scale:a,axis:l,clip:m}),_d(e))}function hB(e,t){const{line:n,target:r,above:i,below:s,area:o,scale:a,clip:l}=t,c=n._loop?"angle":t.axis;e.save();let u=s;s!==i&&(c==="x"?(Yb(e,r,o.top),ef(e,{line:n,target:r,color:i,scale:a,property:c,clip:l}),e.restore(),e.save(),Yb(e,r,o.bottom)):c==="y"&&(Xb(e,r,o.left),ef(e,{line:n,target:r,color:s,scale:a,property:c,clip:l}),e.restore(),e.save(),Xb(e,r,o.right),u=i)),ef(e,{line:n,target:r,color:u,scale:a,property:c,clip:l}),e.restore()}function Yb(e,t,n){const{segments:r,points:i}=t;let s=!0,o=!1;e.beginPath();for(const a of r){const{start:l,end:c}=a,u=i[l],d=i[Sd(l,c,i)];s?(e.moveTo(u.x,u.y),s=!1):(e.lineTo(u.x,n),e.lineTo(u.x,u.y)),o=!!t.pathSegment(e,a,{move:o}),o?e.closePath():e.lineTo(d.x,n)}e.lineTo(t.first().x,n),e.closePath(),e.clip()}function Xb(e,t,n){const{segments:r,points:i}=t;let s=!0,o=!1;e.beginPath();for(const a of r){const{start:l,end:c}=a,u=i[l],d=i[Sd(l,c,i)];s?(e.moveTo(u.x,u.y),s=!1):(e.lineTo(n,u.y),e.lineTo(u.x,u.y)),o=!!t.pathSegment(e,a,{move:o}),o?e.closePath():e.lineTo(n,d.y)}e.lineTo(n,t.first().y),e.closePath(),e.clip()}function ef(e,t){const{line:n,target:r,property:i,color:s,scale:o,clip:a}=t,l=Y4(n,r,i);for(const{source:c,target:u,start:d,end:h}of l){const{style:{backgroundColor:p=s}={}}=c,g=r!==!0;e.save(),e.fillStyle=p,fB(e,o,a,g&&tg(i,d,h)),e.beginPath();const m=!!n.pathSegment(e,c);let v;if(g){m?e.closePath():Jb(e,r,h,i);const x=!!r.pathSegment(e,u,{move:m,reverse:!0});v=m&&x,v||Jb(e,r,d,i)}e.closePath(),e.fill(v?"evenodd":"nonzero"),e.restore()}}function fB(e,t,n,r){const i=t.chart.chartArea,{property:s,start:o,end:a}=r||{};if(s==="x"||s==="y"){let l,c,u,d;s==="x"?(l=o,c=i.top,u=a,d=i.bottom):(l=i.left,c=o,u=i.right,d=a),e.beginPath(),n&&(l=Math.max(l,n.left),u=Math.min(u,n.right),c=Math.max(c,n.top),d=Math.min(d,n.bottom)),e.rect(l,c,u-l,d-c),e.clip()}}function Jb(e,t,n,r){const i=t.interpolate(n,r);i&&e.lineTo(i.x,i.y)}var pB={id:"filler",afterDatasetsUpdate(e,t,n){const r=(e.data.datasets||[]).length,i=[];let s,o,a,l;for(o=0;o<r;++o)s=e.getDatasetMeta(o),a=s.dataset,l=null,a&&a.options&&a instanceof Jr&&(l={visible:e.isDatasetVisible(o),index:o,fill:Q4(a,o,r),chart:e,axis:s.controller.options.indexAxis,scale:s.vScale,line:a}),s.$filler=l,i.push(l);for(o=0;o<r;++o)l=i[o],!(!l||l.fill===!1)&&(l.fill=J4(i,o,n.propagate))},beforeDraw(e,t,n){const r=n.drawTime==="beforeDraw",i=e.getSortedVisibleDatasetMetas(),s=e.chartArea;for(let o=i.length-1;o>=0;--o){const a=i[o].$filler;a&&(a.line.updateControlPoints(s,a.axis),r&&a.fill&&Zh(e.ctx,a,s))}},beforeDatasetsDraw(e,t,n){if(n.drawTime!=="beforeDatasetsDraw")return;const r=e.getSortedVisibleDatasetMetas();for(let i=r.length-1;i>=0;--i){const s=r[i].$filler;Kb(s)&&Zh(e.ctx,s,e.chartArea)}},beforeDatasetDraw(e,t,n){const r=t.meta.$filler;!Kb(r)||n.drawTime!=="beforeDatasetDraw"||Zh(e.ctx,r,e.chartArea)},defaults:{propagate:!0,drawTime:"beforeDatasetDraw"}};const Qb=(e,t)=>{let{boxHeight:n=t,boxWidth:r=t}=e;return e.usePointStyle&&(n=Math.min(n,t),r=e.pointStyleWidth||Math.min(r,t)),{boxWidth:r,boxHeight:n,itemHeight:Math.max(t,n)}},gB=(e,t)=>e!==null&&t!==null&&e.datasetIndex===t.datasetIndex&&e.index===t.index;class Zb extends Mr{constructor(t){super(),this._added=!1,this.legendHitBoxes=[],this._hoveredItem=null,this.doughnutMode=!1,this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this.legendItems=void 0,this.columnSizes=void 0,this.lineWidths=void 0,this.maxHeight=void 0,this.maxWidth=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.height=void 0,this.width=void 0,this._margins=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(t,n,r){this.maxWidth=t,this.maxHeight=n,this._margins=r,this.setDimensions(),this.buildLabels(),this.fit()}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=this._margins.left,this.right=this.width):(this.height=this.maxHeight,this.top=this._margins.top,this.bottom=this.height)}buildLabels(){const t=this.options.labels||{};let n=Oe(t.generateLabels,[this.chart],this)||[];t.filter&&(n=n.filter(r=>t.filter(r,this.chart.data))),t.sort&&(n=n.sort((r,i)=>t.sort(r,i,this.chart.data))),this.options.reverse&&n.reverse(),this.legendItems=n}fit(){const{options:t,ctx:n}=this;if(!t.display){this.width=this.height=0;return}const r=t.labels,i=ft(r.font),s=i.size,o=this._computeTitleHeight(),{boxWidth:a,itemHeight:l}=Qb(r,s);let c,u;n.font=i.string,this.isHorizontal()?(c=this.maxWidth,u=this._fitRows(o,s,a,l)+10):(u=this.maxHeight,c=this._fitCols(o,i,a,l)+10),this.width=Math.min(c,t.maxWidth||this.maxWidth),this.height=Math.min(u,t.maxHeight||this.maxHeight)}_fitRows(t,n,r,i){const{ctx:s,maxWidth:o,options:{labels:{padding:a}}}=this,l=this.legendHitBoxes=[],c=this.lineWidths=[0],u=i+a;let d=t;s.textAlign="left",s.textBaseline="middle";let h=-1,p=-u;return this.legendItems.forEach((g,m)=>{const v=r+n/2+s.measureText(g.text).width;(m===0||c[c.length-1]+v+2*a>o)&&(d+=u,c[c.length-(m>0?0:1)]=0,p+=u,h++),l[m]={left:0,top:p,row:h,width:v,height:i},c[c.length-1]+=v+a}),d}_fitCols(t,n,r,i){const{ctx:s,maxHeight:o,options:{labels:{padding:a}}}=this,l=this.legendHitBoxes=[],c=this.columnSizes=[],u=o-t;let d=a,h=0,p=0,g=0,m=0;return this.legendItems.forEach((v,x)=>{const{itemWidth:y,itemHeight:b}=mB(r,n,s,v,i);x>0&&p+b+2*a>u&&(d+=h+a,c.push({width:h,height:p}),g+=h+a,m++,h=p=0),l[x]={left:g,top:p,col:m,width:y,height:b},h=Math.max(h,y),p+=b+a}),d+=h,c.push({width:h,height:p}),d}adjustHitBoxes(){if(!this.options.display)return;const t=this._computeTitleHeight(),{legendHitBoxes:n,options:{align:r,labels:{padding:i},rtl:s}}=this,o=qs(s,this.left,this.width);if(this.isHorizontal()){let a=0,l=Et(r,this.left+i,this.right-this.lineWidths[a]);for(const c of n)a!==c.row&&(a=c.row,l=Et(r,this.left+i,this.right-this.lineWidths[a])),c.top+=this.top+t+i,c.left=o.leftForLtr(o.x(l),c.width),l+=c.width+i}else{let a=0,l=Et(r,this.top+t+i,this.bottom-this.columnSizes[a].height);for(const c of n)c.col!==a&&(a=c.col,l=Et(r,this.top+t+i,this.bottom-this.columnSizes[a].height)),c.top=l,c.left+=this.left+i,c.left=o.leftForLtr(o.x(c.left),c.width),l+=c.height+i}}isHorizontal(){return this.options.position==="top"||this.options.position==="bottom"}draw(){if(this.options.display){const t=this.ctx;bd(t,this),this._draw(),_d(t)}}_draw(){const{options:t,columnSizes:n,lineWidths:r,ctx:i}=this,{align:s,labels:o}=t,a=Ue.color,l=qs(t.rtl,this.left,this.width),c=ft(o.font),{padding:u}=o,d=c.size,h=d/2;let p;this.drawTitle(),i.textAlign=l.textAlign("left"),i.textBaseline="middle",i.lineWidth=.5,i.font=c.string;const{boxWidth:g,boxHeight:m,itemHeight:v}=Qb(o,d),x=function(_,N,E){if(isNaN(g)||g<=0||isNaN(m)||m<0)return;i.save();const T=ce(E.lineWidth,1);if(i.fillStyle=ce(E.fillStyle,a),i.lineCap=ce(E.lineCap,"butt"),i.lineDashOffset=ce(E.lineDashOffset,0),i.lineJoin=ce(E.lineJoin,"miter"),i.lineWidth=T,i.strokeStyle=ce(E.strokeStyle,a),i.setLineDash(ce(E.lineDash,[])),o.usePointStyle){const S={radius:m*Math.SQRT2/2,pointStyle:E.pointStyle,rotation:E.rotation,borderWidth:T},M=l.xPlus(_,g/2),A=N+h;jC(i,S,M,A,o.pointStyleWidth&&g)}else{const S=N+Math.max((d-m)/2,0),M=l.leftForLtr(_,g),A=Vi(E.borderRadius);i.beginPath(),Object.values(A).some(F=>F!==0)?al(i,{x:M,y:S,w:g,h:m,radius:A}):i.rect(M,S,g,m),i.fill(),T!==0&&i.stroke()}i.restore()},y=function(_,N,E){Zi(i,E.text,_,N+v/2,c,{strikethrough:E.hidden,textAlign:l.textAlign(E.textAlign)})},b=this.isHorizontal(),k=this._computeTitleHeight();b?p={x:Et(s,this.left+u,this.right-r[0]),y:this.top+u+k,line:0}:p={x:this.left+u,y:Et(s,this.top+k+u,this.bottom-n[0].height),line:0},LC(this.ctx,t.textDirection);const w=v+u;this.legendItems.forEach((_,N)=>{i.strokeStyle=_.fontColor,i.fillStyle=_.fontColor;const E=i.measureText(_.text).width,T=l.textAlign(_.textAlign||(_.textAlign=o.textAlign)),S=g+h+E;let M=p.x,A=p.y;l.setWidth(this.width),b?N>0&&M+S+u>this.right&&(A=p.y+=w,p.line++,M=p.x=Et(s,this.left+u,this.right-r[p.line])):N>0&&A+w>this.bottom&&(M=p.x=M+n[p.line].width+u,p.line++,A=p.y=Et(s,this.top+k+u,this.bottom-n[p.line].height));const F=l.x(M);if(x(F,A,_),M=I5(T,M+g+h,b?M+S:this.right,t.rtl),y(l.x(M),A,_),b)p.x+=S+u;else if(typeof _.text!="string"){const H=c.lineHeight;p.y+=cE(_,H)+u}else p.y+=w}),FC(this.ctx,t.textDirection)}drawTitle(){const t=this.options,n=t.title,r=ft(n.font),i=Rt(n.padding);if(!n.display)return;const s=qs(t.rtl,this.left,this.width),o=this.ctx,a=n.position,l=r.size/2,c=i.top+l;let u,d=this.left,h=this.width;if(this.isHorizontal())h=Math.max(...this.lineWidths),u=this.top+c,d=Et(t.align,d,this.right-h);else{const g=this.columnSizes.reduce((m,v)=>Math.max(m,v.height),0);u=c+Et(t.align,this.top,this.bottom-g-t.labels.padding-this._computeTitleHeight())}const p=Et(a,d,d+h);o.textAlign=s.textAlign(qm(a)),o.textBaseline="middle",o.strokeStyle=n.color,o.fillStyle=n.color,o.font=r.string,Zi(o,n.text,p,u,r)}_computeTitleHeight(){const t=this.options.title,n=ft(t.font),r=Rt(t.padding);return t.display?n.lineHeight+r.height:0}_getLegendItemAt(t,n){let r,i,s;if(br(t,this.left,this.right)&&br(n,this.top,this.bottom)){for(s=this.legendHitBoxes,r=0;r<s.length;++r)if(i=s[r],br(t,i.left,i.left+i.width)&&br(n,i.top,i.top+i.height))return this.legendItems[r]}return null}handleEvent(t){const n=this.options;if(!yB(t.type,n))return;const r=this._getLegendItemAt(t.x,t.y);if(t.type==="mousemove"||t.type==="mouseout"){const i=this._hoveredItem,s=gB(i,r);i&&!s&&Oe(n.onLeave,[t,i,this],this),this._hoveredItem=r,r&&!s&&Oe(n.onHover,[t,r,this],this)}else r&&Oe(n.onClick,[t,r,this],this)}}function mB(e,t,n,r,i){const s=xB(r,e,t,n),o=vB(i,r,t.lineHeight);return{itemWidth:s,itemHeight:o}}function xB(e,t,n,r){let i=e.text;return i&&typeof i!="string"&&(i=i.reduce((s,o)=>s.length>o.length?s:o)),t+n.size/2+r.measureText(i).width}function vB(e,t,n){let r=e;return typeof t.text!="string"&&(r=cE(t,n)),r}function cE(e,t){const n=e.text?e.text.length:0;return t*n}function yB(e,t){return!!((e==="mousemove"||e==="mouseout")&&(t.onHover||t.onLeave)||t.onClick&&(e==="click"||e==="mouseup"))}var bB={id:"legend",_element:Zb,start(e,t,n){const r=e.legend=new Zb({ctx:e.ctx,options:n,chart:e});Tt.configure(e,r,n),Tt.addBox(e,r)},stop(e){Tt.removeBox(e,e.legend),delete e.legend},beforeUpdate(e,t,n){const r=e.legend;Tt.configure(e,r,n),r.options=n},afterUpdate(e){const t=e.legend;t.buildLabels(),t.adjustHitBoxes()},afterEvent(e,t){t.replay||e.legend.handleEvent(t.event)},defaults:{display:!0,position:"top",align:"center",fullSize:!0,reverse:!1,weight:1e3,onClick(e,t,n){const r=t.datasetIndex,i=n.chart;i.isDatasetVisible(r)?(i.hide(r),t.hidden=!0):(i.show(r),t.hidden=!1)},onHover:null,onLeave:null,labels:{color:e=>e.chart.options.color,boxWidth:40,padding:10,generateLabels(e){const t=e.data.datasets,{labels:{usePointStyle:n,pointStyle:r,textAlign:i,color:s,useBorderRadius:o,borderRadius:a}}=e.legend.options;return e._getSortedDatasetMetas().map(l=>{const c=l.controller.getStyle(n?0:void 0),u=Rt(c.borderWidth);return{text:t[l.index].label,fillStyle:c.backgroundColor,fontColor:s,hidden:!l.visible,lineCap:c.borderCapStyle,lineDash:c.borderDash,lineDashOffset:c.borderDashOffset,lineJoin:c.borderJoinStyle,lineWidth:(u.width+u.height)/4,strokeStyle:c.borderColor,pointStyle:r||c.pointStyle,rotation:c.rotation,textAlign:i||c.textAlign,borderRadius:o&&(a||c.borderRadius),datasetIndex:l.index}},this)}},title:{color:e=>e.chart.options.color,display:!1,position:"center",text:""}},descriptors:{_scriptable:e=>!e.startsWith("on"),labels:{_scriptable:e=>!["generateLabels","filter","sort"].includes(e)}}};class tx extends Mr{constructor(t){super(),this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this._padding=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(t,n){const r=this.options;if(this.left=0,this.top=0,!r.display){this.width=this.height=this.right=this.bottom=0;return}this.width=this.right=t,this.height=this.bottom=n;const i=We(r.text)?r.text.length:1;this._padding=Rt(r.padding);const s=i*ft(r.font).lineHeight+this._padding.height;this.isHorizontal()?this.height=s:this.width=s}isHorizontal(){const t=this.options.position;return t==="top"||t==="bottom"}_drawArgs(t){const{top:n,left:r,bottom:i,right:s,options:o}=this,a=o.align;let l=0,c,u,d;return this.isHorizontal()?(u=Et(a,r,s),d=n+t,c=s-r):(o.position==="left"?(u=r+t,d=Et(a,i,n),l=Ee*-.5):(u=s-t,d=Et(a,n,i),l=Ee*.5),c=i-n),{titleX:u,titleY:d,maxWidth:c,rotation:l}}draw(){const t=this.ctx,n=this.options;if(!n.display)return;const r=ft(n.font),s=r.lineHeight/2+this._padding.top,{titleX:o,titleY:a,maxWidth:l,rotation:c}=this._drawArgs(s);Zi(t,n.text,0,0,r,{color:n.color,maxWidth:l,rotation:c,textAlign:qm(n.align),textBaseline:"middle",translation:[o,a]})}}function _B(e,t){const n=new tx({ctx:e.ctx,options:t,chart:e});Tt.configure(e,n,t),Tt.addBox(e,n),e.titleBlock=n}var wB={id:"title",_element:tx,start(e,t,n){_B(e,n)},stop(e){const t=e.titleBlock;Tt.removeBox(e,t),delete e.titleBlock},beforeUpdate(e,t,n){const r=e.titleBlock;Tt.configure(e,r,n),r.options=n},defaults:{align:"center",display:!1,font:{weight:"bold"},fullSize:!0,padding:10,position:"top",text:"",weight:2e3},defaultRoutes:{color:"color"},descriptors:{_scriptable:!0,_indexable:!1}};const lc=new WeakMap;var kB={id:"subtitle",start(e,t,n){const r=new tx({ctx:e.ctx,options:n,chart:e});Tt.configure(e,r,n),Tt.addBox(e,r),lc.set(e,r)},stop(e){Tt.removeBox(e,lc.get(e)),lc.delete(e)},beforeUpdate(e,t,n){const r=lc.get(e);Tt.configure(e,r,n),r.options=n},defaults:{align:"center",display:!1,font:{weight:"normal"},fullSize:!0,padding:0,position:"top",text:"",weight:1500},defaultRoutes:{color:"color"},descriptors:{_scriptable:!0,_indexable:!1}};const ia={average(e){if(!e.length)return!1;let t,n,r=new Set,i=0,s=0;for(t=0,n=e.length;t<n;++t){const a=e[t].element;if(a&&a.hasValue()){const l=a.tooltipPosition();r.add(l.x),i+=l.y,++s}}return s===0||r.size===0?!1:{x:[...r].reduce((a,l)=>a+l)/r.size,y:i/s}},nearest(e,t){if(!e.length)return!1;let n=t.x,r=t.y,i=Number.POSITIVE_INFINITY,s,o,a;for(s=0,o=e.length;s<o;++s){const l=e[s].element;if(l&&l.hasValue()){const c=l.getCenterPoint(),u=Gp(t,c);u<i&&(i=u,a=l)}}if(a){const l=a.tooltipPosition();n=l.x,r=l.y}return{x:n,y:r}}};function Un(e,t){return t&&(We(t)?Array.prototype.push.apply(e,t):e.push(t)),e}function hr(e){return(typeof e=="string"||e instanceof String)&&e.indexOf(`
|
|
138
138
|
`)>-1?e.split(`
|
|
139
|
-
`):e}function SB(e,t){const{element:n,datasetIndex:r,index:i}=t,s=e.getDatasetMeta(r).controller,{label:o,value:a}=s.getLabelAndValue(i);return{chart:e,label:o,parsed:s.getParsed(i),raw:e.data.datasets[r].data[i],formattedValue:a,dataset:s.getDataset(),dataIndex:i,datasetIndex:r,element:n}}function e_(e,t){const n=e.chart.ctx,{body:r,footer:i,title:s}=e,{boxWidth:o,boxHeight:a}=t,l=ft(t.bodyFont),c=ft(t.titleFont),u=ft(t.footerFont),d=s.length,h=i.length,p=r.length,g=Rt(t.padding);let m=g.height,v=0,x=r.reduce((k,w)=>k+w.before.length+w.lines.length+w.after.length,0);if(x+=e.beforeBody.length+e.afterBody.length,d&&(m+=d*c.lineHeight+(d-1)*t.titleSpacing+t.titleMarginBottom),x){const k=t.displayColors?Math.max(a,l.lineHeight):l.lineHeight;m+=p*k+(x-p)*l.lineHeight+(x-1)*t.bodySpacing}h&&(m+=t.footerMarginTop+h*u.lineHeight+(h-1)*t.footerSpacing);let y=0;const b=function(k){v=Math.max(v,n.measureText(k).width+y)};return n.save(),n.font=c.string,je(e.title,b),n.font=l.string,je(e.beforeBody.concat(e.afterBody),b),y=t.displayColors?o+2+t.boxPadding:0,je(r,k=>{je(k.before,b),je(k.lines,b),je(k.after,b)}),y=0,n.font=u.string,je(e.footer,b),n.restore(),v+=g.width,{width:v,height:m}}function CB(e,t){const{y:n,height:r}=t;return n<r/2?"top":n>e.height-r/2?"bottom":"center"}function EB(e,t,n,r){const{x:i,width:s}=r,o=n.caretSize+n.caretPadding;if(e==="left"&&i+s+o>t.width||e==="right"&&i-s-o<0)return!0}function PB(e,t,n,r){const{x:i,width:s}=n,{width:o,chartArea:{left:a,right:l}}=e;let c="center";return r==="center"?c=i<=(a+l)/2?"left":"right":i<=s/2?c="left":i>=o-s/2&&(c="right"),EB(c,e,t,n)&&(c="center"),c}function t_(e,t,n){const r=n.yAlign||t.yAlign||CB(e,n);return{xAlign:n.xAlign||t.xAlign||PB(e,t,n,r),yAlign:r}}function NB(e,t){let{x:n,width:r}=e;return t==="right"?n-=r:t==="center"&&(n-=r/2),n}function jB(e,t,n){let{y:r,height:i}=e;return t==="top"?r+=n:t==="bottom"?r-=i+n:r-=i/2,r}function n_(e,t,n,r){const{caretSize:i,caretPadding:s,cornerRadius:o}=e,{xAlign:a,yAlign:l}=n,c=i+s,{topLeft:u,topRight:d,bottomLeft:h,bottomRight:p}=Vi(o);let g=NB(t,a);const m=jB(t,l,c);return l==="center"?a==="left"?g+=c:a==="right"&&(g-=c):a==="left"?g-=Math.max(u,h)+i:a==="right"&&(g+=Math.max(d,p)+i),{x:gt(g,0,r.width-t.width),y:gt(m,0,r.height-t.height)}}function cc(e,t,n){const r=Rt(n.padding);return t==="center"?e.x+e.width/2:t==="right"?e.x+e.width-r.right:e.x+r.left}function r_(e){return Un([],hr(e))}function TB(e,t,n){return yi(e,{tooltip:t,tooltipItems:n,type:"tooltip"})}function i_(e,t){const n=t&&t.dataset&&t.dataset.tooltip&&t.dataset.tooltip.callbacks;return n?e.override(n):e}const uE={beforeTitle:cr,title(e){if(e.length>0){const t=e[0],n=t.chart.data.labels,r=n?n.length:0;if(this&&this.options&&this.options.mode==="dataset")return t.dataset.label||"";if(t.label)return t.label;if(r>0&&t.dataIndex<r)return n[t.dataIndex]}return""},afterTitle:cr,beforeBody:cr,beforeLabel:cr,label(e){if(this&&this.options&&this.options.mode==="dataset")return e.label+": "+e.formattedValue||e.formattedValue;let t=e.dataset.label||"";t&&(t+=": ");const n=e.formattedValue;return ge(n)||(t+=n),t},labelColor(e){const n=e.chart.getDatasetMeta(e.datasetIndex).controller.getStyle(e.dataIndex);return{borderColor:n.borderColor,backgroundColor:n.backgroundColor,borderWidth:n.borderWidth,borderDash:n.borderDash,borderDashOffset:n.borderDashOffset,borderRadius:0}},labelTextColor(){return this.options.bodyColor},labelPointStyle(e){const n=e.chart.getDatasetMeta(e.datasetIndex).controller.getStyle(e.dataIndex);return{pointStyle:n.pointStyle,rotation:n.rotation}},afterLabel:cr,afterBody:cr,beforeFooter:cr,footer:cr,afterFooter:cr};function Vt(e,t,n,r){const i=e[t].call(n,r);return typeof i>"u"?uE[t].call(n,r):i}class ng extends Mr{constructor(t){super(),this.opacity=0,this._active=[],this._eventPosition=void 0,this._size=void 0,this._cachedAnimations=void 0,this._tooltipItems=[],this.$animations=void 0,this.$context=void 0,this.chart=t.chart,this.options=t.options,this.dataPoints=void 0,this.title=void 0,this.beforeBody=void 0,this.body=void 0,this.afterBody=void 0,this.footer=void 0,this.xAlign=void 0,this.yAlign=void 0,this.x=void 0,this.y=void 0,this.height=void 0,this.width=void 0,this.caretX=void 0,this.caretY=void 0,this.labelColors=void 0,this.labelPointStyles=void 0,this.labelTextColors=void 0}initialize(t){this.options=t,this._cachedAnimations=void 0,this.$context=void 0}_resolveAnimations(){const t=this._cachedAnimations;if(t)return t;const n=this.chart,r=this.options.setContext(this.getContext()),i=r.enabled&&n.options.animation&&r.animations,s=new VC(this.chart,i);return i._cacheable&&(this._cachedAnimations=Object.freeze(s)),s}getContext(){return this.$context||(this.$context=TB(this.chart.getContext(),this,this._tooltipItems))}getTitle(t,n){const{callbacks:r}=n,i=Vt(r,"beforeTitle",this,t),s=Vt(r,"title",this,t),o=Vt(r,"afterTitle",this,t);let a=[];return a=Un(a,hr(i)),a=Un(a,hr(s)),a=Un(a,hr(o)),a}getBeforeBody(t,n){return r_(Vt(n.callbacks,"beforeBody",this,t))}getBody(t,n){const{callbacks:r}=n,i=[];return je(t,s=>{const o={before:[],lines:[],after:[]},a=i_(r,s);Un(o.before,hr(Vt(a,"beforeLabel",this,s))),Un(o.lines,Vt(a,"label",this,s)),Un(o.after,hr(Vt(a,"afterLabel",this,s))),i.push(o)}),i}getAfterBody(t,n){return r_(Vt(n.callbacks,"afterBody",this,t))}getFooter(t,n){const{callbacks:r}=n,i=Vt(r,"beforeFooter",this,t),s=Vt(r,"footer",this,t),o=Vt(r,"afterFooter",this,t);let a=[];return a=Un(a,hr(i)),a=Un(a,hr(s)),a=Un(a,hr(o)),a}_createItems(t){const n=this._active,r=this.chart.data,i=[],s=[],o=[];let a=[],l,c;for(l=0,c=n.length;l<c;++l)a.push(SB(this.chart,n[l]));return t.filter&&(a=a.filter((u,d,h)=>t.filter(u,d,h,r))),t.itemSort&&(a=a.sort((u,d)=>t.itemSort(u,d,r))),je(a,u=>{const d=i_(t.callbacks,u);i.push(Vt(d,"labelColor",this,u)),s.push(Vt(d,"labelPointStyle",this,u)),o.push(Vt(d,"labelTextColor",this,u))}),this.labelColors=i,this.labelPointStyles=s,this.labelTextColors=o,this.dataPoints=a,a}update(t,n){const r=this.options.setContext(this.getContext()),i=this._active;let s,o=[];if(!i.length)this.opacity!==0&&(s={opacity:0});else{const a=ia[r.position].call(this,i,this._eventPosition);o=this._createItems(r),this.title=this.getTitle(o,r),this.beforeBody=this.getBeforeBody(o,r),this.body=this.getBody(o,r),this.afterBody=this.getAfterBody(o,r),this.footer=this.getFooter(o,r);const l=this._size=e_(this,r),c=Object.assign({},a,l),u=t_(this.chart,r,c),d=n_(r,c,u,this.chart);this.xAlign=u.xAlign,this.yAlign=u.yAlign,s={opacity:1,x:d.x,y:d.y,width:l.width,height:l.height,caretX:a.x,caretY:a.y}}this._tooltipItems=o,this.$context=void 0,s&&this._resolveAnimations().update(this,s),t&&r.external&&r.external.call(this,{chart:this.chart,tooltip:this,replay:n})}drawCaret(t,n,r,i){const s=this.getCaretPosition(t,r,i);n.lineTo(s.x1,s.y1),n.lineTo(s.x2,s.y2),n.lineTo(s.x3,s.y3)}getCaretPosition(t,n,r){const{xAlign:i,yAlign:s}=this,{caretSize:o,cornerRadius:a}=r,{topLeft:l,topRight:c,bottomLeft:u,bottomRight:d}=Vi(a),{x:h,y:p}=t,{width:g,height:m}=n;let v,x,y,b,k,w;return s==="center"?(k=p+m/2,i==="left"?(v=h,x=v-o,b=k+o,w=k-o):(v=h+g,x=v+o,b=k-o,w=k+o),y=v):(i==="left"?x=h+Math.max(l,u)+o:i==="right"?x=h+g-Math.max(c,d)-o:x=this.caretX,s==="top"?(b=p,k=b-o,v=x-o,y=x+o):(b=p+m,k=b+o,v=x+o,y=x-o),w=b),{x1:v,x2:x,x3:y,y1:b,y2:k,y3:w}}drawTitle(t,n,r){const i=this.title,s=i.length;let o,a,l;if(s){const c=qs(r.rtl,this.x,this.width);for(t.x=cc(this,r.titleAlign,r),n.textAlign=c.textAlign(r.titleAlign),n.textBaseline="middle",o=ft(r.titleFont),a=r.titleSpacing,n.fillStyle=r.titleColor,n.font=o.string,l=0;l<s;++l)n.fillText(i[l],c.x(t.x),t.y+o.lineHeight/2),t.y+=o.lineHeight+a,l+1===s&&(t.y+=r.titleMarginBottom-a)}}_drawColorBox(t,n,r,i,s){const o=this.labelColors[r],a=this.labelPointStyles[r],{boxHeight:l,boxWidth:c}=s,u=ft(s.bodyFont),d=cc(this,"left",s),h=i.x(d),p=l<u.lineHeight?(u.lineHeight-l)/2:0,g=n.y+p;if(s.usePointStyle){const m={radius:Math.min(c,l)/2,pointStyle:a.pointStyle,rotation:a.rotation,borderWidth:1},v=i.leftForLtr(h,c)+c/2,x=g+l/2;t.strokeStyle=s.multiKeyBackground,t.fillStyle=s.multiKeyBackground,Yp(t,m,v,x),t.strokeStyle=o.borderColor,t.fillStyle=o.backgroundColor,Yp(t,m,v,x)}else{t.lineWidth=ve(o.borderWidth)?Math.max(...Object.values(o.borderWidth)):o.borderWidth||1,t.strokeStyle=o.borderColor,t.setLineDash(o.borderDash||[]),t.lineDashOffset=o.borderDashOffset||0;const m=i.leftForLtr(h,c),v=i.leftForLtr(i.xPlus(h,1),c-2),x=Vi(o.borderRadius);Object.values(x).some(y=>y!==0)?(t.beginPath(),t.fillStyle=s.multiKeyBackground,al(t,{x:m,y:g,w:c,h:l,radius:x}),t.fill(),t.stroke(),t.fillStyle=o.backgroundColor,t.beginPath(),al(t,{x:v,y:g+1,w:c-2,h:l-2,radius:x}),t.fill()):(t.fillStyle=s.multiKeyBackground,t.fillRect(m,g,c,l),t.strokeRect(m,g,c,l),t.fillStyle=o.backgroundColor,t.fillRect(v,g+1,c-2,l-2))}t.fillStyle=this.labelTextColors[r]}drawBody(t,n,r){const{body:i}=this,{bodySpacing:s,bodyAlign:o,displayColors:a,boxHeight:l,boxWidth:c,boxPadding:u}=r,d=ft(r.bodyFont);let h=d.lineHeight,p=0;const g=qs(r.rtl,this.x,this.width),m=function(E){n.fillText(E,g.x(t.x+p),t.y+h/2),t.y+=h+s},v=g.textAlign(o);let x,y,b,k,w,_,N;for(n.textAlign=o,n.textBaseline="middle",n.font=d.string,t.x=cc(this,v,r),n.fillStyle=r.bodyColor,je(this.beforeBody,m),p=a&&v!=="right"?o==="center"?c/2+u:c+2+u:0,k=0,_=i.length;k<_;++k){for(x=i[k],y=this.labelTextColors[k],n.fillStyle=y,je(x.before,m),b=x.lines,a&&b.length&&(this._drawColorBox(n,t,k,g,r),h=Math.max(d.lineHeight,l)),w=0,N=b.length;w<N;++w)m(b[w]),h=d.lineHeight;je(x.after,m)}p=0,h=d.lineHeight,je(this.afterBody,m),t.y-=s}drawFooter(t,n,r){const i=this.footer,s=i.length;let o,a;if(s){const l=qs(r.rtl,this.x,this.width);for(t.x=cc(this,r.footerAlign,r),t.y+=r.footerMarginTop,n.textAlign=l.textAlign(r.footerAlign),n.textBaseline="middle",o=ft(r.footerFont),n.fillStyle=r.footerColor,n.font=o.string,a=0;a<s;++a)n.fillText(i[a],l.x(t.x),t.y+o.lineHeight/2),t.y+=o.lineHeight+r.footerSpacing}}drawBackground(t,n,r,i){const{xAlign:s,yAlign:o}=this,{x:a,y:l}=t,{width:c,height:u}=r,{topLeft:d,topRight:h,bottomLeft:p,bottomRight:g}=Vi(i.cornerRadius);n.fillStyle=i.backgroundColor,n.strokeStyle=i.borderColor,n.lineWidth=i.borderWidth,n.beginPath(),n.moveTo(a+d,l),o==="top"&&this.drawCaret(t,n,r,i),n.lineTo(a+c-h,l),n.quadraticCurveTo(a+c,l,a+c,l+h),o==="center"&&s==="right"&&this.drawCaret(t,n,r,i),n.lineTo(a+c,l+u-g),n.quadraticCurveTo(a+c,l+u,a+c-g,l+u),o==="bottom"&&this.drawCaret(t,n,r,i),n.lineTo(a+p,l+u),n.quadraticCurveTo(a,l+u,a,l+u-p),o==="center"&&s==="left"&&this.drawCaret(t,n,r,i),n.lineTo(a,l+d),n.quadraticCurveTo(a,l,a+d,l),n.closePath(),n.fill(),i.borderWidth>0&&n.stroke()}_updateAnimationTarget(t){const n=this.chart,r=this.$animations,i=r&&r.x,s=r&&r.y;if(i||s){const o=ia[t.position].call(this,this._active,this._eventPosition);if(!o)return;const a=this._size=e_(this,t),l=Object.assign({},o,this._size),c=t_(n,t,l),u=n_(t,l,c,n);(i._to!==u.x||s._to!==u.y)&&(this.xAlign=c.xAlign,this.yAlign=c.yAlign,this.width=a.width,this.height=a.height,this.caretX=o.x,this.caretY=o.y,this._resolveAnimations().update(this,u))}}_willRender(){return!!this.opacity}draw(t){const n=this.options.setContext(this.getContext());let r=this.opacity;if(!r)return;this._updateAnimationTarget(n);const i={width:this.width,height:this.height},s={x:this.x,y:this.y};r=Math.abs(r)<.001?0:r;const o=Rt(n.padding),a=this.title.length||this.beforeBody.length||this.body.length||this.afterBody.length||this.footer.length;n.enabled&&a&&(t.save(),t.globalAlpha=r,this.drawBackground(s,t,i,n),LC(t,n.textDirection),s.y+=o.top,this.drawTitle(s,t,n),this.drawBody(s,t,n),this.drawFooter(s,t,n),FC(t,n.textDirection),t.restore())}getActiveElements(){return this._active||[]}setActiveElements(t,n){const r=this._active,i=t.map(({datasetIndex:a,index:l})=>{const c=this.chart.getDatasetMeta(a);if(!c)throw new Error("Cannot find a dataset at index "+a);return{datasetIndex:a,element:c.data[l],index:l}}),s=!Iu(r,i),o=this._positionChanged(i,n);(s||o)&&(this._active=i,this._eventPosition=n,this._ignoreReplayEvents=!0,this.update(!0))}handleEvent(t,n,r=!0){if(n&&this._ignoreReplayEvents)return!1;this._ignoreReplayEvents=!1;const i=this.options,s=this._active||[],o=this._getActiveElements(t,s,n,r),a=this._positionChanged(o,t),l=n||!Iu(o,s)||a;return l&&(this._active=o,(i.enabled||i.external)&&(this._eventPosition={x:t.x,y:t.y},this.update(!0,n))),l}_getActiveElements(t,n,r,i){const s=this.options;if(t.type==="mouseout")return[];if(!i)return n.filter(a=>this.chart.data.datasets[a.datasetIndex]&&this.chart.getDatasetMeta(a.datasetIndex).controller.getParsed(a.index)!==void 0);const o=this.chart.getElementsAtEventForMode(t,s.mode,s,r);return s.reverse&&o.reverse(),o}_positionChanged(t,n){const{caretX:r,caretY:i,options:s}=this,o=ia[s.position].call(this,t,n);return o!==!1&&(r!==o.x||i!==o.y)}}W(ng,"positioners",ia);var MB={id:"tooltip",_element:ng,positioners:ia,afterInit(e,t,n){n&&(e.tooltip=new ng({chart:e,options:n}))},beforeUpdate(e,t,n){e.tooltip&&e.tooltip.initialize(n)},reset(e,t,n){e.tooltip&&e.tooltip.initialize(n)},afterDraw(e){const t=e.tooltip;if(t&&t._willRender()){const n={tooltip:t};if(e.notifyPlugins("beforeTooltipDraw",{...n,cancelable:!0})===!1)return;t.draw(e.ctx),e.notifyPlugins("afterTooltipDraw",n)}},afterEvent(e,t){if(e.tooltip){const n=t.replay;e.tooltip.handleEvent(t.event,n,t.inChartArea)&&(t.changed=!0)}},defaults:{enabled:!0,external:null,position:"average",backgroundColor:"rgba(0,0,0,0.8)",titleColor:"#fff",titleFont:{weight:"bold"},titleSpacing:2,titleMarginBottom:6,titleAlign:"left",bodyColor:"#fff",bodySpacing:2,bodyFont:{},bodyAlign:"left",footerColor:"#fff",footerSpacing:2,footerMarginTop:6,footerFont:{weight:"bold"},footerAlign:"left",padding:6,caretPadding:2,caretSize:5,cornerRadius:6,boxHeight:(e,t)=>t.bodyFont.size,boxWidth:(e,t)=>t.bodyFont.size,multiKeyBackground:"#fff",displayColors:!0,boxPadding:0,borderColor:"rgba(0,0,0,0)",borderWidth:0,animation:{duration:400,easing:"easeOutQuart"},animations:{numbers:{type:"number",properties:["x","y","width","height","caretX","caretY"]},opacity:{easing:"linear",duration:200}},callbacks:uE},defaultRoutes:{bodyFont:"font",footerFont:"font",titleFont:"font"},descriptors:{_scriptable:e=>e!=="filter"&&e!=="itemSort"&&e!=="external",_indexable:!1,callbacks:{_scriptable:!1,_indexable:!1},animation:{_fallback:!1},animations:{_fallback:"animation"}},additionalOptionScopes:["interaction"]},RB=Object.freeze({__proto__:null,Colors:W4,Decimation:K4,Filler:pB,Legend:bB,SubTitle:kB,Title:wB,Tooltip:MB});const AB=(e,t,n,r)=>(typeof t=="string"?(n=e.push(t)-1,r.unshift({index:n,label:t})):isNaN(t)&&(n=null),n);function DB(e,t,n,r){const i=e.indexOf(t);if(i===-1)return AB(e,t,n,r);const s=e.lastIndexOf(t);return i!==s?n:i}const IB=(e,t)=>e===null?null:gt(Math.round(e),0,t);function s_(e){const t=this.getLabels();return e>=0&&e<t.length?t[e]:e}class rg extends ss{constructor(t){super(t),this._startValue=void 0,this._valueRange=0,this._addedLabels=[]}init(t){const n=this._addedLabels;if(n.length){const r=this.getLabels();for(const{index:i,label:s}of n)r[i]===s&&r.splice(i,1);this._addedLabels=[]}super.init(t)}parse(t,n){if(ge(t))return null;const r=this.getLabels();return n=isFinite(n)&&r[n]===t?n:DB(r,t,ce(n,t),this._addedLabels),IB(n,r.length-1)}determineDataLimits(){const{minDefined:t,maxDefined:n}=this.getUserBounds();let{min:r,max:i}=this.getMinMax(!0);this.options.bounds==="ticks"&&(t||(r=0),n||(i=this.getLabels().length-1)),this.min=r,this.max=i}buildTicks(){const t=this.min,n=this.max,r=this.options.offset,i=[];let s=this.getLabels();s=t===0&&n===s.length-1?s:s.slice(t,n+1),this._valueRange=Math.max(s.length-(r?0:1),1),this._startValue=this.min-(r?.5:0);for(let o=t;o<=n;o++)i.push({value:o});return i}getLabelForValue(t){return s_.call(this,t)}configure(){super.configure(),this.isHorizontal()||(this._reversePixels=!this._reversePixels)}getPixelForValue(t){return typeof t!="number"&&(t=this.parse(t)),t===null?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getPixelForTick(t){const n=this.ticks;return t<0||t>n.length-1?null:this.getPixelForValue(n[t].value)}getValueForPixel(t){return Math.round(this._startValue+this.getDecimalForPixel(t)*this._valueRange)}getBasePixel(){return this.bottom}}W(rg,"id","category"),W(rg,"defaults",{ticks:{callback:s_}});function OB(e,t){const n=[],{bounds:i,step:s,min:o,max:a,precision:l,count:c,maxTicks:u,maxDigits:d,includeBounds:h}=e,p=s||1,g=u-1,{min:m,max:v}=t,x=!ge(o),y=!ge(a),b=!ge(c),k=(v-m)/(d+1);let w=eb((v-m)/g/p)*p,_,N,E,T;if(w<1e-14&&!x&&!y)return[{value:m},{value:v}];T=Math.ceil(v/w)-Math.floor(m/w),T>g&&(w=eb(T*w/g/p)*p),ge(l)||(_=Math.pow(10,l),w=Math.ceil(w*_)/_),i==="ticks"?(N=Math.floor(m/w)*w,E=Math.ceil(v/w)*w):(N=m,E=v),x&&y&&s&&N5((a-o)/s,w/1e3)?(T=Math.round(Math.min((a-o)/w,u)),w=(a-o)/T,N=o,E=a):b?(N=x?o:N,E=y?a:E,T=c-1,w=(E-N)/T):(T=(E-N)/w,Ca(T,Math.round(T),w/1e3)?T=Math.round(T):T=Math.ceil(T));const S=Math.max(tb(w),tb(N));_=Math.pow(10,ge(l)?S:l),N=Math.round(N*_)/_,E=Math.round(E*_)/_;let M=0;for(x&&(h&&N!==o?(n.push({value:o}),N<o&&M++,Ca(Math.round((N+M*w)*_)/_,o,o_(o,k,e))&&M++):N<o&&M++);M<T;++M){const A=Math.round((N+M*w)*_)/_;if(y&&A>a)break;n.push({value:A})}return y&&h&&E!==a?n.length&&Ca(n[n.length-1].value,a,o_(a,k,e))?n[n.length-1].value=a:n.push({value:a}):(!y||E===a)&&n.push({value:E}),n}function o_(e,t,{horizontal:n,minRotation:r}){const i=On(r),s=(n?Math.sin(i):Math.cos(i))||.001,o=.75*t*(""+e).length;return Math.min(t/s,o)}class Hu extends ss{constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._endValue=void 0,this._valueRange=0}parse(t,n){return ge(t)||(typeof t=="number"||t instanceof Number)&&!isFinite(+t)?null:+t}handleTickRangeOptions(){const{beginAtZero:t}=this.options,{minDefined:n,maxDefined:r}=this.getUserBounds();let{min:i,max:s}=this;const o=l=>i=n?i:l,a=l=>s=r?s:l;if(t){const l=rr(i),c=rr(s);l<0&&c<0?a(0):l>0&&c>0&&o(0)}if(i===s){let l=s===0?1:Math.abs(s*.05);a(s+l),t||o(i-l)}this.min=i,this.max=s}getTickLimit(){const t=this.options.ticks;let{maxTicksLimit:n,stepSize:r}=t,i;return r?(i=Math.ceil(this.max/r)-Math.floor(this.min/r)+1,i>1e3&&(console.warn(`scales.${this.id}.ticks.stepSize: ${r} would result generating up to ${i} ticks. Limiting to 1000.`),i=1e3)):(i=this.computeTickLimit(),n=n||11),n&&(i=Math.min(n,i)),i}computeTickLimit(){return Number.POSITIVE_INFINITY}buildTicks(){const t=this.options,n=t.ticks;let r=this.getTickLimit();r=Math.max(2,r);const i={maxTicks:r,bounds:t.bounds,min:t.min,max:t.max,precision:n.precision,step:n.stepSize,count:n.count,maxDigits:this._maxDigits(),horizontal:this.isHorizontal(),minRotation:n.minRotation||0,includeBounds:n.includeBounds!==!1},s=this._range||this,o=OB(i,s);return t.bounds==="ticks"&&bC(o,this,"value"),t.reverse?(o.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),o}configure(){const t=this.ticks;let n=this.min,r=this.max;if(super.configure(),this.options.offset&&t.length){const i=(r-n)/Math.max(t.length-1,1)/2;n-=i,r+=i}this._startValue=n,this._endValue=r,this._valueRange=r-n}getLabelForValue(t){return bl(t,this.chart.options.locale,this.options.ticks.format)}}class ig extends Hu{determineDataLimits(){const{min:t,max:n}=this.getMinMax(!0);this.min=Qe(t)?t:0,this.max=Qe(n)?n:1,this.handleTickRangeOptions()}computeTickLimit(){const t=this.isHorizontal(),n=t?this.width:this.height,r=On(this.options.ticks.minRotation),i=(t?Math.sin(r):Math.cos(r))||.001,s=this._resolveTickFontOptions(0);return Math.ceil(n/Math.min(40,s.lineHeight/i))}getPixelForValue(t){return t===null?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getValueForPixel(t){return this._startValue+this.getDecimalForPixel(t)*this._valueRange}}W(ig,"id","linear"),W(ig,"defaults",{ticks:{callback:yd.formatters.numeric}});const cl=e=>Math.floor(Yr(e)),Ni=(e,t)=>Math.pow(10,cl(e)+t);function a_(e){return e/Math.pow(10,cl(e))===1}function l_(e,t,n){const r=Math.pow(10,n),i=Math.floor(e/r);return Math.ceil(t/r)-i}function LB(e,t){const n=t-e;let r=cl(n);for(;l_(e,t,r)>10;)r++;for(;l_(e,t,r)<10;)r--;return Math.min(r,cl(e))}function FB(e,{min:t,max:n}){t=sn(e.min,t);const r=[],i=cl(t);let s=LB(t,n),o=s<0?Math.pow(10,Math.abs(s)):1;const a=Math.pow(10,s),l=i>s?Math.pow(10,i):0,c=Math.round((t-l)*o)/o,u=Math.floor((t-l)/a/10)*a*10;let d=Math.floor((c-u)/Math.pow(10,s)),h=sn(e.min,Math.round((l+u+d*Math.pow(10,s))*o)/o);for(;h<n;)r.push({value:h,major:a_(h),significand:d}),d>=10?d=d<15?15:20:d++,d>=20&&(s++,d=2,o=s>=0?1:o),h=Math.round((l+u+d*Math.pow(10,s))*o)/o;const p=sn(e.max,h);return r.push({value:p,major:a_(p),significand:d}),r}class sg extends ss{constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._valueRange=0}parse(t,n){const r=Hu.prototype.parse.apply(this,[t,n]);if(r===0){this._zero=!0;return}return Qe(r)&&r>0?r:null}determineDataLimits(){const{min:t,max:n}=this.getMinMax(!0);this.min=Qe(t)?Math.max(0,t):null,this.max=Qe(n)?Math.max(0,n):null,this.options.beginAtZero&&(this._zero=!0),this._zero&&this.min!==this._suggestedMin&&!Qe(this._userMin)&&(this.min=t===Ni(this.min,0)?Ni(this.min,-1):Ni(this.min,0)),this.handleTickRangeOptions()}handleTickRangeOptions(){const{minDefined:t,maxDefined:n}=this.getUserBounds();let r=this.min,i=this.max;const s=a=>r=t?r:a,o=a=>i=n?i:a;r===i&&(r<=0?(s(1),o(10)):(s(Ni(r,-1)),o(Ni(i,1)))),r<=0&&s(Ni(i,-1)),i<=0&&o(Ni(r,1)),this.min=r,this.max=i}buildTicks(){const t=this.options,n={min:this._userMin,max:this._userMax},r=FB(n,this);return t.bounds==="ticks"&&bC(r,this,"value"),t.reverse?(r.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),r}getLabelForValue(t){return t===void 0?"0":bl(t,this.chart.options.locale,this.options.ticks.format)}configure(){const t=this.min;super.configure(),this._startValue=Yr(t),this._valueRange=Yr(this.max)-Yr(t)}getPixelForValue(t){return(t===void 0||t===0)&&(t=this.min),t===null||isNaN(t)?NaN:this.getPixelForDecimal(t===this.min?0:(Yr(t)-this._startValue)/this._valueRange)}getValueForPixel(t){const n=this.getDecimalForPixel(t);return Math.pow(10,this._startValue+n*this._valueRange)}}W(sg,"id","logarithmic"),W(sg,"defaults",{ticks:{callback:yd.formatters.logarithmic,major:{enabled:!0}}});function og(e){const t=e.ticks;if(t.display&&e.display){const n=Rt(t.backdropPadding);return ce(t.font&&t.font.size,Ue.font.size)+n.height}return 0}function $B(e,t,n){return n=We(n)?n:[n],{w:U5(e,t.string,n),h:n.length*t.lineHeight}}function c_(e,t,n,r,i){return e===r||e===i?{start:t-n/2,end:t+n/2}:e<r||e>i?{start:t-n,end:t}:{start:t,end:t+n}}function zB(e){const t={l:e.left+e._padding.left,r:e.right-e._padding.right,t:e.top+e._padding.top,b:e.bottom-e._padding.bottom},n=Object.assign({},t),r=[],i=[],s=e._pointLabels.length,o=e.options.pointLabels,a=o.centerPointLabels?Ee/s:0;for(let l=0;l<s;l++){const c=o.setContext(e.getPointLabelContext(l));i[l]=c.padding;const u=e.getPointPosition(l,e.drawingArea+i[l],a),d=ft(c.font),h=$B(e.ctx,d,e._pointLabels[l]);r[l]=h;const p=Pt(e.getIndexAngle(l)+a),g=Math.round(Wm(p)),m=c_(g,u.x,h.w,0,180),v=c_(g,u.y,h.h,90,270);BB(n,t,p,m,v)}e.setCenterPoint(t.l-n.l,n.r-t.r,t.t-n.t,n.b-t.b),e._pointLabelItems=WB(e,r,i)}function BB(e,t,n,r,i){const s=Math.abs(Math.sin(n)),o=Math.abs(Math.cos(n));let a=0,l=0;r.start<t.l?(a=(t.l-r.start)/s,e.l=Math.min(e.l,t.l-a)):r.end>t.r&&(a=(r.end-t.r)/s,e.r=Math.max(e.r,t.r+a)),i.start<t.t?(l=(t.t-i.start)/o,e.t=Math.min(e.t,t.t-l)):i.end>t.b&&(l=(i.end-t.b)/o,e.b=Math.max(e.b,t.b+l))}function HB(e,t,n){const r=e.drawingArea,{extra:i,additionalAngle:s,padding:o,size:a}=n,l=e.getPointPosition(t,r+i+o,s),c=Math.round(Wm(Pt(l.angle+nt))),u=GB(l.y,a.h,c),d=UB(c),h=qB(l.x,a.w,d);return{visible:!0,x:l.x,y:u,textAlign:d,left:h,top:u,right:h+a.w,bottom:u+a.h}}function VB(e,t){if(!t)return!0;const{left:n,top:r,right:i,bottom:s}=e;return!(wr({x:n,y:r},t)||wr({x:n,y:s},t)||wr({x:i,y:r},t)||wr({x:i,y:s},t))}function WB(e,t,n){const r=[],i=e._pointLabels.length,s=e.options,{centerPointLabels:o,display:a}=s.pointLabels,l={extra:og(s)/2,additionalAngle:o?Ee/i:0};let c;for(let u=0;u<i;u++){l.padding=n[u],l.size=t[u];const d=HB(e,u,l);r.push(d),a==="auto"&&(d.visible=VB(d,c),d.visible&&(c=d))}return r}function UB(e){return e===0||e===180?"center":e<180?"left":"right"}function qB(e,t,n){return n==="right"?e-=t:n==="center"&&(e-=t/2),e}function GB(e,t,n){return n===90||n===270?e-=t/2:(n>270||n<90)&&(e-=t),e}function KB(e,t,n){const{left:r,top:i,right:s,bottom:o}=n,{backdropColor:a}=t;if(!ge(a)){const l=Vi(t.borderRadius),c=Rt(t.backdropPadding);e.fillStyle=a;const u=r-c.left,d=i-c.top,h=s-r+c.width,p=o-i+c.height;Object.values(l).some(g=>g!==0)?(e.beginPath(),al(e,{x:u,y:d,w:h,h:p,radius:l}),e.fill()):e.fillRect(u,d,h,p)}}function YB(e,t){const{ctx:n,options:{pointLabels:r}}=e;for(let i=t-1;i>=0;i--){const s=e._pointLabelItems[i];if(!s.visible)continue;const o=r.setContext(e.getPointLabelContext(i));KB(n,o,s);const a=ft(o.font),{x:l,y:c,textAlign:u}=s;Zi(n,e._pointLabels[i],l,c+a.lineHeight/2,a,{color:o.color,textAlign:u,textBaseline:"middle"})}}function dE(e,t,n,r){const{ctx:i}=e;if(n)i.arc(e.xCenter,e.yCenter,t,0,He);else{let s=e.getPointPosition(0,t);i.moveTo(s.x,s.y);for(let o=1;o<r;o++)s=e.getPointPosition(o,t),i.lineTo(s.x,s.y)}}function XB(e,t,n,r,i){const s=e.ctx,o=t.circular,{color:a,lineWidth:l}=t;!o&&!r||!a||!l||n<0||(s.save(),s.strokeStyle=a,s.lineWidth=l,s.setLineDash(i.dash||[]),s.lineDashOffset=i.dashOffset,s.beginPath(),dE(e,n,o,r),s.closePath(),s.stroke(),s.restore())}function JB(e,t,n){return yi(e,{label:n,index:t,type:"pointLabel"})}class sa extends Hu{constructor(t){super(t),this.xCenter=void 0,this.yCenter=void 0,this.drawingArea=void 0,this._pointLabels=[],this._pointLabelItems=[]}setDimensions(){const t=this._padding=Rt(og(this.options)/2),n=this.width=this.maxWidth-t.width,r=this.height=this.maxHeight-t.height;this.xCenter=Math.floor(this.left+n/2+t.left),this.yCenter=Math.floor(this.top+r/2+t.top),this.drawingArea=Math.floor(Math.min(n,r)/2)}determineDataLimits(){const{min:t,max:n}=this.getMinMax(!1);this.min=Qe(t)&&!isNaN(t)?t:0,this.max=Qe(n)&&!isNaN(n)?n:0,this.handleTickRangeOptions()}computeTickLimit(){return Math.ceil(this.drawingArea/og(this.options))}generateTickLabels(t){Hu.prototype.generateTickLabels.call(this,t),this._pointLabels=this.getLabels().map((n,r)=>{const i=Oe(this.options.pointLabels.callback,[n,r],this);return i||i===0?i:""}).filter((n,r)=>this.chart.getDataVisibility(r))}fit(){const t=this.options;t.display&&t.pointLabels.display?zB(this):this.setCenterPoint(0,0,0,0)}setCenterPoint(t,n,r,i){this.xCenter+=Math.floor((t-n)/2),this.yCenter+=Math.floor((r-i)/2),this.drawingArea-=Math.min(this.drawingArea/2,Math.max(t,n,r,i))}getIndexAngle(t){const n=He/(this._pointLabels.length||1),r=this.options.startAngle||0;return Pt(t*n+On(r))}getDistanceFromCenterForValue(t){if(ge(t))return NaN;const n=this.drawingArea/(this.max-this.min);return this.options.reverse?(this.max-t)*n:(t-this.min)*n}getValueForDistanceFromCenter(t){if(ge(t))return NaN;const n=t/(this.drawingArea/(this.max-this.min));return this.options.reverse?this.max-n:this.min+n}getPointLabelContext(t){const n=this._pointLabels||[];if(t>=0&&t<n.length){const r=n[t];return JB(this.getContext(),t,r)}}getPointPosition(t,n,r=0){const i=this.getIndexAngle(t)-nt+r;return{x:Math.cos(i)*n+this.xCenter,y:Math.sin(i)*n+this.yCenter,angle:i}}getPointPositionForValue(t,n){return this.getPointPosition(t,this.getDistanceFromCenterForValue(n))}getBasePosition(t){return this.getPointPositionForValue(t||0,this.getBaseValue())}getPointLabelPosition(t){const{left:n,top:r,right:i,bottom:s}=this._pointLabelItems[t];return{left:n,top:r,right:i,bottom:s}}drawBackground(){const{backgroundColor:t,grid:{circular:n}}=this.options;if(t){const r=this.ctx;r.save(),r.beginPath(),dE(this,this.getDistanceFromCenterForValue(this._endValue),n,this._pointLabels.length),r.closePath(),r.fillStyle=t,r.fill(),r.restore()}}drawGrid(){const t=this.ctx,n=this.options,{angleLines:r,grid:i,border:s}=n,o=this._pointLabels.length;let a,l,c;if(n.pointLabels.display&&YB(this,o),i.display&&this.ticks.forEach((u,d)=>{if(d!==0||d===0&&this.min<0){l=this.getDistanceFromCenterForValue(u.value);const h=this.getContext(d),p=i.setContext(h),g=s.setContext(h);XB(this,p,l,o,g)}}),r.display){for(t.save(),a=o-1;a>=0;a--){const u=r.setContext(this.getPointLabelContext(a)),{color:d,lineWidth:h}=u;!h||!d||(t.lineWidth=h,t.strokeStyle=d,t.setLineDash(u.borderDash),t.lineDashOffset=u.borderDashOffset,l=this.getDistanceFromCenterForValue(n.reverse?this.min:this.max),c=this.getPointPosition(a,l),t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(c.x,c.y),t.stroke())}t.restore()}}drawBorder(){}drawLabels(){const t=this.ctx,n=this.options,r=n.ticks;if(!r.display)return;const i=this.getIndexAngle(0);let s,o;t.save(),t.translate(this.xCenter,this.yCenter),t.rotate(i),t.textAlign="center",t.textBaseline="middle",this.ticks.forEach((a,l)=>{if(l===0&&this.min>=0&&!n.reverse)return;const c=r.setContext(this.getContext(l)),u=ft(c.font);if(s=this.getDistanceFromCenterForValue(this.ticks[l].value),c.showLabelBackdrop){t.font=u.string,o=t.measureText(a.label).width,t.fillStyle=c.backdropColor;const d=Rt(c.backdropPadding);t.fillRect(-o/2-d.left,-s-u.size/2-d.top,o+d.width,u.size+d.height)}Zi(t,a.label,0,-s,u,{color:c.color,strokeColor:c.textStrokeColor,strokeWidth:c.textStrokeWidth})}),t.restore()}drawTitle(){}}W(sa,"id","radialLinear"),W(sa,"defaults",{display:!0,animate:!0,position:"chartArea",angleLines:{display:!0,lineWidth:1,borderDash:[],borderDashOffset:0},grid:{circular:!1},startAngle:0,ticks:{showLabelBackdrop:!0,callback:yd.formatters.numeric},pointLabels:{backdropColor:void 0,backdropPadding:2,display:!0,font:{size:10},callback(t){return t},padding:5,centerPointLabels:!1}}),W(sa,"defaultRoutes",{"angleLines.color":"borderColor","pointLabels.color":"color","ticks.color":"color"}),W(sa,"descriptors",{angleLines:{_fallback:"grid"}});const Cd={millisecond:{common:!0,size:1,steps:1e3},second:{common:!0,size:1e3,steps:60},minute:{common:!0,size:6e4,steps:60},hour:{common:!0,size:36e5,steps:24},day:{common:!0,size:864e5,steps:30},week:{common:!1,size:6048e5,steps:4},month:{common:!0,size:2628e6,steps:12},quarter:{common:!1,size:7884e6,steps:4},year:{common:!0,size:3154e7}},Gt=Object.keys(Cd);function u_(e,t){return e-t}function d_(e,t){if(ge(t))return null;const n=e._adapter,{parser:r,round:i,isoWeekday:s}=e._parseOpts;let o=t;return typeof r=="function"&&(o=r(o)),Qe(o)||(o=typeof r=="string"?n.parse(o,r):n.parse(o)),o===null?null:(i&&(o=i==="week"&&(oo(s)||s===!0)?n.startOf(o,"isoWeek",s):n.startOf(o,i)),+o)}function h_(e,t,n,r){const i=Gt.length;for(let s=Gt.indexOf(e);s<i-1;++s){const o=Cd[Gt[s]],a=o.steps?o.steps:Number.MAX_SAFE_INTEGER;if(o.common&&Math.ceil((n-t)/(a*o.size))<=r)return Gt[s]}return Gt[i-1]}function QB(e,t,n,r,i){for(let s=Gt.length-1;s>=Gt.indexOf(n);s--){const o=Gt[s];if(Cd[o].common&&e._adapter.diff(i,r,o)>=t-1)return o}return Gt[n?Gt.indexOf(n):0]}function ZB(e){for(let t=Gt.indexOf(e)+1,n=Gt.length;t<n;++t)if(Cd[Gt[t]].common)return Gt[t]}function f_(e,t,n){if(!n)e[t]=!0;else if(n.length){const{lo:r,hi:i}=Um(n,t),s=n[r]>=t?n[r]:n[i];e[s]=!0}}function e6(e,t,n,r){const i=e._adapter,s=+i.startOf(t[0].value,r),o=t[t.length-1].value;let a,l;for(a=s;a<=o;a=+i.add(a,1,r))l=n[a],l>=0&&(t[l].major=!0);return t}function p_(e,t,n){const r=[],i={},s=t.length;let o,a;for(o=0;o<s;++o)a=t[o],i[a]=o,r.push({value:a,major:!1});return s===0||!n?r:e6(e,r,i,n)}class ul extends ss{constructor(t){super(t),this._cache={data:[],labels:[],all:[]},this._unit="day",this._majorUnit=void 0,this._offsets={},this._normalized=!1,this._parseOpts=void 0}init(t,n={}){const r=t.time||(t.time={}),i=this._adapter=new lz._date(t.adapters.date);i.init(n),Sa(r.displayFormats,i.formats()),this._parseOpts={parser:r.parser,round:r.round,isoWeekday:r.isoWeekday},super.init(t),this._normalized=n.normalized}parse(t,n){return t===void 0?null:d_(this,t)}beforeLayout(){super.beforeLayout(),this._cache={data:[],labels:[],all:[]}}determineDataLimits(){const t=this.options,n=this._adapter,r=t.time.unit||"day";let{min:i,max:s,minDefined:o,maxDefined:a}=this.getUserBounds();function l(c){!o&&!isNaN(c.min)&&(i=Math.min(i,c.min)),!a&&!isNaN(c.max)&&(s=Math.max(s,c.max))}(!o||!a)&&(l(this._getLabelBounds()),(t.bounds!=="ticks"||t.ticks.source!=="labels")&&l(this.getMinMax(!1))),i=Qe(i)&&!isNaN(i)?i:+n.startOf(Date.now(),r),s=Qe(s)&&!isNaN(s)?s:+n.endOf(Date.now(),r)+1,this.min=Math.min(i,s-1),this.max=Math.max(i+1,s)}_getLabelBounds(){const t=this.getLabelTimestamps();let n=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY;return t.length&&(n=t[0],r=t[t.length-1]),{min:n,max:r}}buildTicks(){const t=this.options,n=t.time,r=t.ticks,i=r.source==="labels"?this.getLabelTimestamps():this._generate();t.bounds==="ticks"&&i.length&&(this.min=this._userMin||i[0],this.max=this._userMax||i[i.length-1]);const s=this.min,o=this.max,a=R5(i,s,o);return this._unit=n.unit||(r.autoSkip?h_(n.minUnit,this.min,this.max,this._getLabelCapacity(s)):QB(this,a.length,n.minUnit,this.min,this.max)),this._majorUnit=!r.major.enabled||this._unit==="year"?void 0:ZB(this._unit),this.initOffsets(i),t.reverse&&a.reverse(),p_(this,a,this._majorUnit)}afterAutoSkip(){this.options.offsetAfterAutoskip&&this.initOffsets(this.ticks.map(t=>+t.value))}initOffsets(t=[]){let n=0,r=0,i,s;this.options.offset&&t.length&&(i=this.getDecimalForValue(t[0]),t.length===1?n=1-i:n=(this.getDecimalForValue(t[1])-i)/2,s=this.getDecimalForValue(t[t.length-1]),t.length===1?r=s:r=(s-this.getDecimalForValue(t[t.length-2]))/2);const o=t.length<3?.5:.25;n=gt(n,0,o),r=gt(r,0,o),this._offsets={start:n,end:r,factor:1/(n+1+r)}}_generate(){const t=this._adapter,n=this.min,r=this.max,i=this.options,s=i.time,o=s.unit||h_(s.minUnit,n,r,this._getLabelCapacity(n)),a=ce(i.ticks.stepSize,1),l=o==="week"?s.isoWeekday:!1,c=oo(l)||l===!0,u={};let d=n,h,p;if(c&&(d=+t.startOf(d,"isoWeek",l)),d=+t.startOf(d,c?"day":o),t.diff(r,n,o)>1e5*a)throw new Error(n+" and "+r+" are too far apart with stepSize of "+a+" "+o);const g=i.ticks.source==="data"&&this.getDataTimestamps();for(h=d,p=0;h<r;h=+t.add(h,a,o),p++)f_(u,h,g);return(h===r||i.bounds==="ticks"||p===1)&&f_(u,h,g),Object.keys(u).sort(u_).map(m=>+m)}getLabelForValue(t){const n=this._adapter,r=this.options.time;return r.tooltipFormat?n.format(t,r.tooltipFormat):n.format(t,r.displayFormats.datetime)}format(t,n){const i=this.options.time.displayFormats,s=this._unit,o=n||i[s];return this._adapter.format(t,o)}_tickFormatFunction(t,n,r,i){const s=this.options,o=s.ticks.callback;if(o)return Oe(o,[t,n,r],this);const a=s.time.displayFormats,l=this._unit,c=this._majorUnit,u=l&&a[l],d=c&&a[c],h=r[n],p=c&&d&&h&&h.major;return this._adapter.format(t,i||(p?d:u))}generateTickLabels(t){let n,r,i;for(n=0,r=t.length;n<r;++n)i=t[n],i.label=this._tickFormatFunction(i.value,n,t)}getDecimalForValue(t){return t===null?NaN:(t-this.min)/(this.max-this.min)}getPixelForValue(t){const n=this._offsets,r=this.getDecimalForValue(t);return this.getPixelForDecimal((n.start+r)*n.factor)}getValueForPixel(t){const n=this._offsets,r=this.getDecimalForPixel(t)/n.factor-n.end;return this.min+r*(this.max-this.min)}_getLabelSize(t){const n=this.options.ticks,r=this.ctx.measureText(t).width,i=On(this.isHorizontal()?n.maxRotation:n.minRotation),s=Math.cos(i),o=Math.sin(i),a=this._resolveTickFontOptions(0).size;return{w:r*s+a*o,h:r*o+a*s}}_getLabelCapacity(t){const n=this.options.time,r=n.displayFormats,i=r[n.unit]||r.millisecond,s=this._tickFormatFunction(t,0,p_(this,[t],this._majorUnit),i),o=this._getLabelSize(s),a=Math.floor(this.isHorizontal()?this.width/o.w:this.height/o.h)-1;return a>0?a:1}getDataTimestamps(){let t=this._cache.data||[],n,r;if(t.length)return t;const i=this.getMatchingVisibleMetas();if(this._normalized&&i.length)return this._cache.data=i[0].controller.getAllParsedValues(this);for(n=0,r=i.length;n<r;++n)t=t.concat(i[n].controller.getAllParsedValues(this));return this._cache.data=this.normalize(t)}getLabelTimestamps(){const t=this._cache.labels||[];let n,r;if(t.length)return t;const i=this.getLabels();for(n=0,r=i.length;n<r;++n)t.push(d_(this,i[n]));return this._cache.labels=this._normalized?t:this.normalize(t)}normalize(t){return kC(t.sort(u_))}}W(ul,"id","time"),W(ul,"defaults",{bounds:"data",adapters:{},time:{parser:!1,unit:!1,round:!1,isoWeekday:!1,minUnit:"millisecond",displayFormats:{}},ticks:{source:"auto",callback:!1,major:{enabled:!1}}});function uc(e,t,n){let r=0,i=e.length-1,s,o,a,l;n?(t>=e[r].pos&&t<=e[i].pos&&({lo:r,hi:i}=_r(e,"pos",t)),{pos:s,time:a}=e[r],{pos:o,time:l}=e[i]):(t>=e[r].time&&t<=e[i].time&&({lo:r,hi:i}=_r(e,"time",t)),{time:s,pos:a}=e[r],{time:o,pos:l}=e[i]);const c=o-s;return c?a+(l-a)*(t-s)/c:a}class ag extends ul{constructor(t){super(t),this._table=[],this._minPos=void 0,this._tableRange=void 0}initOffsets(){const t=this._getTimestampsForTable(),n=this._table=this.buildLookupTable(t);this._minPos=uc(n,this.min),this._tableRange=uc(n,this.max)-this._minPos,super.initOffsets(t)}buildLookupTable(t){const{min:n,max:r}=this,i=[],s=[];let o,a,l,c,u;for(o=0,a=t.length;o<a;++o)c=t[o],c>=n&&c<=r&&i.push(c);if(i.length<2)return[{time:n,pos:0},{time:r,pos:1}];for(o=0,a=i.length;o<a;++o)u=i[o+1],l=i[o-1],c=i[o],Math.round((u+l)/2)!==c&&s.push({time:c,pos:o/(a-1)});return s}_generate(){const t=this.min,n=this.max;let r=super.getDataTimestamps();return(!r.includes(t)||!r.length)&&r.splice(0,0,t),(!r.includes(n)||r.length===1)&&r.push(n),r.sort((i,s)=>i-s)}_getTimestampsForTable(){let t=this._cache.all||[];if(t.length)return t;const n=this.getDataTimestamps(),r=this.getLabelTimestamps();return n.length&&r.length?t=this.normalize(n.concat(r)):t=n.length?n:r,t=this._cache.all=t,t}getDecimalForValue(t){return(uc(this._table,t)-this._minPos)/this._tableRange}getValueForPixel(t){const n=this._offsets,r=this.getDecimalForPixel(t)/n.factor-n.end;return uc(this._table,r*this._tableRange+this._minPos,!0)}}W(ag,"id","timeseries"),W(ag,"defaults",ul.defaults);var t6=Object.freeze({__proto__:null,CategoryScale:rg,LinearScale:ig,LogarithmicScale:sg,RadialLinearScale:sa,TimeScale:ul,TimeSeriesScale:ag});const n6=[az,L4,RB,t6];Xn.register(...n6);function rn(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function Ft(e,t=1){if(typeof document>"u")return`rgba(0,0,0,${t})`;const n=getComputedStyle(document.documentElement).getPropertyValue(`--${e}`).trim();return n?`rgba(${n.split(/\s+/).join(", ")}, ${t})`:`rgba(0,0,0,${t})`}function r6({data:e}){const t=P.useRef(null),n=P.useRef(null);return P.useEffect(()=>{if(!(!t.current||e.daily.length===0))return n.current&&n.current.destroy(),n.current=new Xn(t.current,{type:"bar",data:{labels:e.daily.map(r=>r.date.slice(5)),datasets:[{label:"Input",data:e.daily.map(r=>r.inputTokens),backgroundColor:Ft("primary",.75),borderRadius:2},{label:"Output",data:e.daily.map(r=>r.outputTokens),backgroundColor:Ft("info",.7),borderRadius:2},{label:"Cache Read",data:e.daily.map(r=>r.cacheReadTokens),backgroundColor:Ft("success",.45),borderRadius:2},{label:"Cache Write",data:e.daily.map(r=>r.cacheCreateTokens),backgroundColor:Ft("tertiary-fixed",.75),borderRadius:2}]},options:{responsive:!0,maintainAspectRatio:!1,plugins:{legend:{position:"bottom",labels:{color:Ft("on-surface-variant"),font:{size:10,family:"monospace"},boxWidth:12}},tooltip:{callbacks:{label:r=>`${r.dataset.label}: ${rn(r.raw)} tokens`}}},scales:{x:{stacked:!0,grid:{color:Ft("outline-variant",.3)},ticks:{color:Ft("on-surface-variant"),font:{size:9,family:"monospace"}}},y:{stacked:!0,grid:{color:Ft("outline-variant",.3)},ticks:{color:Ft("on-surface-variant"),font:{size:9,family:"monospace"},callback:r=>rn(r)}}}}}),()=>{var r;(r=n.current)==null||r.destroy()}},[e]),f.jsx("canvas",{ref:t})}function i6({data:e}){const t=P.useRef(null),n=P.useRef(null);return P.useEffect(()=>{if(!(!t.current||e.daily.length===0))return n.current&&n.current.destroy(),n.current=new Xn(t.current,{type:"bar",data:{labels:e.daily.map(r=>r.date.slice(5)),datasets:[{label:"Est. Cost (USD)",data:e.daily.map(r=>Number(r.estimatedCostUsd.toFixed(2))),backgroundColor:Ft("secondary",.75),borderRadius:2}]},options:{responsive:!0,maintainAspectRatio:!1,plugins:{legend:{labels:{color:Ft("on-surface-variant"),font:{size:10,family:"monospace"},boxWidth:12}},tooltip:{callbacks:{label:r=>`$${r.raw.toFixed(2)}`}}},scales:{x:{grid:{color:Ft("outline-variant",.3)},ticks:{color:Ft("on-surface-variant"),font:{size:9,family:"monospace"}}},y:{grid:{color:Ft("outline-variant",.3)},ticks:{color:Ft("on-surface-variant"),font:{size:9,family:"monospace"},callback:r=>`$${r}`}}}}}),()=>{var r;(r=n.current)==null||r.destroy()}},[e]),f.jsx("canvas",{ref:t})}function s6({agentId:e}){const{t}=Pe(),[n,r]=P.useState(null),[i,s]=P.useState(30),[o,a]=P.useState(!0);if(P.useEffect(()=>{a(!0),iR(e,i).then(r).catch(console.error).finally(()=>a(!1))},[e,i]),o||!n)return f.jsx("div",{className:"text-on-surface-variant/70 text-xs p-6",children:t("usage.loading")});const l=Object.entries(n.byModel).sort((c,u)=>u[1].estimatedCostUsd-c[1].estimatedCostUsd);return f.jsxs("div",{className:"flex flex-col h-full w-full min-w-0 bg-background",children:[f.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-outline-variant/30",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{className:"text-[13px] opacity-60",children:"📊"}),f.jsx("span",{className:"text-[11px] uppercase tracking-[0.14em] font-medium text-on-surface-variant",children:t("usage.title")})]}),f.jsx("div",{className:"flex items-center gap-1",children:[7,14,30].map(c=>f.jsxs("button",{onClick:()=>s(c),className:`px-2 py-0.5 rounded text-[9px] font-mono transition-colors ${i===c?"bg-primary/20 text-primary":"text-on-surface-variant/70 hover:text-on-surface-variant/70"}`,children:[c,"d"]},c))})]}),f.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4 scrollbar-thin",children:[f.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[f.jsxs("div",{className:"rounded-lg bg-surface-container-lowest border border-outline-variant/40 p-4",children:[f.jsx("p",{className:"text-[9px] uppercase text-on-surface-variant/60 mb-1.5",children:t("usage.totalTokens")}),f.jsx("p",{className:"font-mono text-[20px] text-on-surface/80",children:rn(n.totalInputTokens+n.totalOutputTokens)}),f.jsx("p",{className:"font-mono text-[9px] text-on-surface-variant/60 mt-1",children:t("usage.cachedSuffix",{amount:rn(n.totalCacheReadTokens+n.totalCacheCreateTokens)})})]}),f.jsxs("div",{className:"rounded-lg bg-surface-container-lowest border border-outline-variant/40 p-4",children:[f.jsx("p",{className:"text-[9px] uppercase text-on-surface-variant/60 mb-1.5",children:t("usage.sessions")}),f.jsx("p",{className:"font-mono text-[20px] text-on-surface/80",children:n.totalSessions}),f.jsx("p",{className:"font-mono text-[9px] text-on-surface-variant/60 mt-1",children:t("usage.modelsCount",{count:Object.keys(n.byModel).length})})]}),f.jsxs("div",{className:"rounded-lg bg-surface-container-lowest border border-outline-variant/40 p-4",children:[f.jsx("p",{className:"text-[9px] uppercase text-on-surface-variant/60 mb-1.5",children:t("usage.estCost")}),f.jsxs("p",{className:"font-mono text-[20px] text-error/80",children:["$",n.totalEstimatedCostUsd.toFixed(2)]}),f.jsx("p",{className:"font-mono text-[9px] text-on-surface-variant/60 mt-1",children:t("usage.periodDays",{days:i})})]}),f.jsxs("div",{className:"rounded-lg bg-surface-container-lowest border border-outline-variant/40 p-4",children:[f.jsx("p",{className:"text-[9px] uppercase text-on-surface-variant/60 mb-1.5",children:t("usage.avgDay")}),f.jsxs("p",{className:"font-mono text-[20px] text-warning/80",children:["$",n.daily.length>0?(n.totalEstimatedCostUsd/n.daily.length).toFixed(2):"0.00"]}),f.jsx("p",{className:"font-mono text-[9px] text-on-surface-variant/60 mt-1",children:t("usage.sessionsPerDay",{count:n.daily.length>0?Math.round(n.totalSessions/n.daily.length):0})})]})]}),f.jsxs("div",{children:[f.jsx("p",{className:"text-[8px] uppercase tracking-[0.18em] text-on-surface-variant/35 font-semibold mb-2",children:t("usage.dailyTokenUsage")}),f.jsx("div",{className:"rounded-lg bg-surface-container-lowest border border-outline-variant/40 p-4",style:{height:"300px"},children:n.daily.length>0?f.jsx(r6,{data:n}):f.jsx("p",{className:"text-on-surface-variant/25 text-xs text-center pt-20",children:t("usage.noUsageData")})})]}),f.jsxs("div",{children:[f.jsx("p",{className:"text-[8px] uppercase tracking-[0.18em] text-on-surface-variant/35 font-semibold mb-2",children:t("usage.dailyCost")}),f.jsx("div",{className:"rounded-lg bg-surface-container-lowest border border-outline-variant/40 p-4",style:{height:"250px"},children:n.daily.length>0?f.jsx(i6,{data:n}):f.jsx("p",{className:"text-on-surface-variant/25 text-xs text-center pt-16",children:t("usage.noCostData")})})]}),l.length>0&&f.jsxs("div",{children:[f.jsx("p",{className:"text-[8px] uppercase tracking-[0.18em] text-on-surface-variant/35 font-semibold mb-2",children:t("usage.byModel")}),f.jsx("div",{className:"space-y-1",children:l.map(([c,u])=>f.jsxs("div",{className:"rounded bg-surface-container-lowest border border-outline-variant/40 p-2.5 flex items-center gap-3",children:[f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsx("span",{className:"font-mono text-[10px] text-on-surface/70 truncate block",children:c}),f.jsx("span",{className:"font-mono text-[9px] text-on-surface-variant/60",children:t("usage.modelSessionsBlurb",{sessions:u.sessions,input:rn(u.inputTokens),output:rn(u.outputTokens)})})]}),f.jsxs("span",{className:"font-mono text-[10px] text-error/60 flex-shrink-0",children:["$",u.estimatedCostUsd.toFixed(2)]})]},c))})]}),f.jsxs("div",{children:[f.jsx("p",{className:"text-[8px] uppercase tracking-[0.18em] text-on-surface-variant/35 font-semibold mb-2",children:t("usage.tokenBreakdown")}),f.jsxs("div",{className:"rounded bg-surface-container-lowest border border-outline-variant/40 p-3 space-y-1.5",children:[f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"font-mono text-[10px] text-on-surface-variant",children:t("usage.inputTokens")}),f.jsx("span",{className:"font-mono text-[10px] text-primary",children:rn(n.totalInputTokens)})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"font-mono text-[10px] text-on-surface-variant",children:t("usage.outputTokens")}),f.jsx("span",{className:"font-mono text-[10px] text-info",children:rn(n.totalOutputTokens)})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"font-mono text-[10px] text-on-surface-variant",children:t("usage.cacheRead")}),f.jsx("span",{className:"font-mono text-[10px] text-success",children:rn(n.totalCacheReadTokens)})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"font-mono text-[10px] text-on-surface-variant",children:t("usage.cacheWrite")}),f.jsx("span",{className:"font-mono text-[10px] text-warning",children:rn(n.totalCacheCreateTokens)})]})]})]}),Object.keys(n.byTool).length>0&&f.jsxs("div",{children:[f.jsx("p",{className:"text-[8px] uppercase tracking-[0.18em] text-on-surface-variant/35 font-semibold mb-2",children:t("usage.toolInvocations")}),f.jsx("div",{className:"rounded-lg bg-surface-container-lowest border border-outline-variant/40 p-3 space-y-1",children:Object.entries(n.byTool).sort((c,u)=>u[1]-c[1]).map(([c,u])=>{const d=Math.max(...Object.values(n.byTool));return f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{className:"font-mono text-[10px] text-on-surface-variant w-40 truncate flex-shrink-0",title:c,children:c}),f.jsx("div",{className:"flex-1 h-3 rounded-sm bg-background overflow-hidden",children:f.jsx("div",{className:"h-full rounded-sm bg-primary/40",style:{width:`${u/d*100}%`}})}),f.jsx("span",{className:"font-mono text-[9px] text-on-surface-variant/70 w-8 text-right flex-shrink-0",children:u})]},c)})})]}),f.jsxs("div",{children:[f.jsx("p",{className:"text-[8px] uppercase tracking-[0.18em] text-on-surface-variant/35 font-semibold mb-2",children:t("usage.dailyBreakdown")}),f.jsx("div",{className:"rounded-lg bg-surface-container-lowest border border-outline-variant/40 overflow-hidden",children:f.jsxs("table",{className:"w-full",children:[f.jsx("thead",{children:f.jsxs("tr",{className:"border-b border-outline-variant/30",children:[f.jsx("th",{className:"px-3 py-2 text-left text-[9px] font-mono text-on-surface-variant/70 font-medium",children:t("usage.date")}),f.jsx("th",{className:"px-3 py-2 text-right text-[9px] font-mono text-on-surface-variant/70 font-medium",children:t("usage.tableSessions")}),f.jsx("th",{className:"px-3 py-2 text-right text-[9px] font-mono text-on-surface-variant/70 font-medium",children:t("usage.tableInput")}),f.jsx("th",{className:"px-3 py-2 text-right text-[9px] font-mono text-on-surface-variant/70 font-medium",children:t("usage.tableOutput")}),f.jsx("th",{className:"px-3 py-2 text-right text-[9px] font-mono text-on-surface-variant/70 font-medium",children:t("usage.tableCache")}),f.jsx("th",{className:"px-3 py-2 text-right text-[9px] font-mono text-on-surface-variant/70 font-medium",children:t("usage.tableCost")})]})}),f.jsx("tbody",{children:[...n.daily].reverse().map(c=>f.jsxs("tr",{className:"border-b border-white/[0.03] hover:bg-white/[0.02]",children:[f.jsx("td",{className:"px-3 py-1.5 font-mono text-[10px] text-on-surface/70",children:c.date}),f.jsx("td",{className:"px-3 py-1.5 font-mono text-[10px] text-on-surface-variant text-right",children:c.sessions}),f.jsx("td",{className:"px-3 py-1.5 font-mono text-[10px] text-primary text-right",children:rn(c.inputTokens)}),f.jsx("td",{className:"px-3 py-1.5 font-mono text-[10px] text-info text-right",children:rn(c.outputTokens)}),f.jsx("td",{className:"px-3 py-1.5 font-mono text-[10px] text-success text-right",children:rn(c.cacheReadTokens+c.cacheCreateTokens)}),f.jsxs("td",{className:"px-3 py-1.5 font-mono text-[10px] text-error/60 text-right",children:["$",c.estimatedCostUsd.toFixed(2)]})]},c.date))})]})})]})]})]})}function o6(e){const t=e.createdAt??e.created_at;return{_id:e._id??e.id,agentId:e.agentId??e.agent_id??"",type:e.type,input:e.input,output:e.output,durationMs:e.durationMs??e.duration_ms,createdAt:typeof t=="number"?new Date(t).toISOString():t??""}}const a6=[{label:"All",value:"default",color:""},{label:"MSG",value:"message",color:"bg-emerald-500"},{label:"TOOL",value:"tool_call",color:"bg-blue-500"},{label:"ERR",value:"error",color:"bg-red-500"},{label:"SYS",value:"system",color:"bg-gray-500"}];function l6(e){return{message:"text-success",tool_call:"text-info",tool_result:"text-info/60",error:"text-error",system:"text-gray-500"}[e]??"text-gray-500"}function c6(e){return{message:"bg-emerald-500/10",tool_call:"bg-blue-500/10",tool_result:"bg-blue-500/5",error:"bg-red-500/10",system:""}[e]??""}function u6(e){return{message:"bg-emerald-400",tool_call:"bg-blue-400",tool_result:"bg-blue-400/60",error:"bg-red-400",system:"bg-gray-600"}[e]??"bg-gray-600"}function d6(e){const t=new Date(e),n=new Date,r=t.toLocaleTimeString("en-US",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"});return t.toDateString()!==n.toDateString()?`${t.toLocaleDateString("en-US",{month:"short",day:"numeric"})} ${r}`:r}function ja(e){if(typeof e=="string")try{return JSON.parse(e)}catch{return e}return e}function h6(e){const t=ja(e.input),n=ja(e.output);if(e.type==="message"){const r=(t==null?void 0:t.text)??"";return String(r)||"(no text)"}if(e.type==="tool_call"){const r=(t==null?void 0:t.tool)??(t==null?void 0:t.tool_name)??(t==null?void 0:t.name)??"",i=(t==null?void 0:t.description)??"";if(r){({...t});const s=ja(t==null?void 0:t.input),o=s?Object.values(s).map(l=>String(l).slice(0,60)).join(", ").slice(0,80):"",a=o?`${r}(${o})`:String(r);return i?`${a} — ${i}`:a}return JSON.stringify(t??{}).slice(0,200)}if(e.type==="tool_result")return JSON.stringify(n??{}).slice(0,200);if(e.type==="error")return String((n==null?void 0:n.message)??n??"unknown error");if(e.type==="system"){const r=n==null?void 0:n.exitCode;return r!==void 0?`process exited (${r})`:"—"}return JSON.stringify(n??{}).slice(0,200)}function f6(e,t){if(!t)return e;const n=e.toLowerCase().indexOf(t.toLowerCase());return n===-1?e:f.jsxs(f.Fragment,{children:[e.slice(0,n),f.jsx("mark",{className:"bg-yellow-400/30 text-yellow-200 rounded-sm px-0.5",children:e.slice(n,n+t.length)}),e.slice(n+t.length)]})}function p6({agentId:e}){const{t}=Pe(),[n,r]=P.useState("default"),[i,s]=P.useState(""),[o,a]=P.useState(""),[l,c]=P.useState([]),[u,d]=P.useState(0),[h,p]=P.useState(!0),[g,m]=P.useState(new Set),[v,x]=P.useState(100),[y,b]=P.useState(!0),k=P.useRef(null),w=P.useRef(null),_=()=>a(i),N=P.useCallback(()=>{gR({agentId:e,type:n==="default"||n==="all"?void 0:n,search:o||void 0,limit:v}).then(S=>{let M=S.items.map(o6);n==="default"&&(M=M.filter(A=>A.type!=="system")),c(M),d(S.total)}).catch(console.error).finally(()=>p(!1))},[e,n,o,v]);P.useEffect(()=>{p(!0),N()},[N]),P.useEffect(()=>{if(!y)return;const S=setInterval(N,3e3);return()=>clearInterval(S)},[y,N]);const E=S=>{m(M=>{const A=new Set(M);return A.has(S)?A.delete(S):A.add(S),A})},T=l;return f.jsxs("div",{className:"flex flex-col h-full w-full min-w-0 rounded-lg overflow-hidden bg-surface-container-lowest",children:[f.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-3 py-2 border-b border-outline-variant/30 bg-background",children:[f.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-1.5",children:[f.jsxs("div",{className:"flex-1 relative",children:[f.jsx("svg",{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-on-surface-variant/60",viewBox:"0 0 20 20",fill:"currentColor",children:f.jsx("path",{fillRule:"evenodd",d:"M9 3.5a5.5 5.5 0 100 11 5.5 5.5 0 000-11zM2 9a7 7 0 1112.452 4.391l3.328 3.329a.75.75 0 11-1.06 1.06l-3.329-3.328A7 7 0 012 9z",clipRule:"evenodd"})}),f.jsx("input",{className:"w-full bg-surface-container-lowest rounded pl-8 pr-7 py-1.5 text-[11px] text-on-surface font-mono placeholder:text-on-surface-variant/25 outline-none focus:ring-1 focus:ring-primary/30 transition-shadow",placeholder:t("logs.searchPlaceholder"),value:i,onChange:S=>s(S.target.value),onKeyDown:S=>S.key==="Enter"&&_()}),i&&f.jsx("button",{onClick:()=>{s(""),a("")},className:"absolute right-2 top-1/2 -translate-y-1/2 text-on-surface-variant hover:text-on-surface text-xs",children:"x"})]}),f.jsx("button",{onClick:_,disabled:i===o,className:"px-2.5 py-1.5 rounded bg-primary/20 text-[10px] font-mono text-primary transition-colors hover:bg-primary/30 disabled:opacity-30 disabled:cursor-default flex-shrink-0",children:t("logs.apply")})]}),f.jsx("div",{className:"flex items-center gap-0.5",children:a6.map(({label:S,value:M,color:A})=>f.jsxs("button",{onClick:()=>r(M),className:`flex items-center gap-1 px-2 py-1 rounded text-[9px] font-mono transition-colors ${n===M?"bg-surface-container-high text-on-surface":"text-on-surface-variant hover:text-on-surface hover:bg-surface-container/50"}`,children:[A&&f.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${A}`}),S]},M))}),f.jsxs("button",{onClick:()=>b(S=>!S),className:`flex items-center gap-1.5 px-2 py-1 rounded text-[9px] font-mono transition-colors ${y?"bg-success/15 text-success":"text-on-surface-variant hover:text-on-surface"}`,children:[f.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${y?"bg-success animate-pulse":"bg-outline/60"}`}),t("logs.live")]}),f.jsxs("span",{className:"font-mono text-[9px] text-on-surface-variant tabular-nums",children:[l.length,"/",u]})]}),f.jsx("div",{ref:w,className:"flex-1 overflow-y-auto scrollbar-thin font-mono text-[11px]",children:h&&l.length===0?f.jsx("div",{className:"flex items-center justify-center h-full",children:f.jsx("span",{className:"text-on-surface-variant text-[10px]",children:t("logs.loading")})}):T.length===0?f.jsx("div",{className:"flex items-center justify-center h-full",children:f.jsx("span",{className:"text-on-surface-variant text-[10px]",children:i?t("logs.noResults",{query:i}):t("logs.noEntries")})}):f.jsxs("div",{className:"py-1",children:[T.map(S=>{const M=g.has(S._id),A=h6(S);return f.jsxs("div",{onClick:()=>E(S._id),className:`group px-3 py-[5px] cursor-pointer transition-colors hover:bg-surface-container/40 ${c6(S.type)} ${M?"bg-surface-container/30":""}`,children:[f.jsxs("div",{className:"flex items-start gap-2 leading-relaxed",children:[f.jsx("span",{className:`mt-[6px] w-[5px] h-[5px] rounded-full flex-shrink-0 ${u6(S.type)}`}),f.jsx("span",{className:"text-on-surface-variant flex-shrink-0 w-[70px] tabular-nums",children:d6(S.createdAt)}),f.jsx("span",{className:`flex-shrink-0 w-[52px] uppercase text-[9px] ${l6(S.type)}`,children:S.type==="tool_call"?"tool":S.type==="tool_result"?"result":S.type}),f.jsx("span",{className:`flex-1 min-w-0 ${M?"":"truncate"} ${S.type==="error"?"text-error":"text-on-surface"}`,children:f6(A,o)}),S.durationMs!=null&&f.jsx("span",{className:"flex-shrink-0 text-[9px] text-on-surface-variant tabular-nums",children:S.durationMs>1e3?`${(S.durationMs/1e3).toFixed(1)}s`:`${S.durationMs}ms`}),f.jsx("span",{className:"flex-shrink-0 text-[8px] text-on-surface-variant opacity-0 group-hover:opacity-100 transition-opacity",children:M?"−":"+"})]}),M&&f.jsxs("div",{className:"ml-[79px] mt-1.5 mb-1 space-y-1.5",children:[!!S.input&&S.input!=="null"&&f.jsxs("div",{children:[f.jsx("span",{className:"font-label text-[8px] uppercase tracking-wider text-on-surface-variant",children:"input"}),f.jsx("pre",{className:"text-[10px] text-on-surface mt-0.5 bg-surface-container-high rounded px-2.5 py-1.5 overflow-auto max-h-48 whitespace-pre-wrap break-words",children:JSON.stringify(ja(S.input),null,2)})]}),!!S.output&&S.output!=="null"&&f.jsxs("div",{children:[f.jsx("span",{className:"font-label text-[8px] uppercase tracking-wider text-on-surface-variant",children:"output"}),f.jsx("pre",{className:"text-[10px] text-on-surface mt-0.5 bg-surface-container-high rounded px-2.5 py-1.5 overflow-auto max-h-48 whitespace-pre-wrap break-words",children:JSON.stringify(ja(S.output),null,2)})]})]})]},S._id)}),l.length<u&&f.jsx("div",{className:"px-3 py-2 text-center",children:f.jsx("button",{onClick:()=>x(S=>S+100),className:"text-[9px] text-primary/40 hover:text-primary/70 transition-colors",children:t("logs.loadOlder",{count:Math.min(100,u-l.length)})})}),f.jsx("div",{ref:k})]})})]})}const g6=[{id:"telegram",name:"Telegram",descriptionKey:"integrations.telegramDescription",icon:"✈️",secretKey:"TELEGRAM_BOT_TOKEN",tokenLabelKey:"integrations.telegramTokenLabel",tokenPlaceholder:"110201543:AAHdqTcvCH1vGWJxfSeofSAs0K5PALDsaw",helpTextKey:"integrations.telegramHelp"}],g_="w-full rounded bg-surface-container px-3 py-2 text-[11px] text-on-surface placeholder:text-on-surface-variant/40 outline-none focus:ring-1 focus:ring-primary/25 font-mono transition-shadow";function m6({def:e,agentId:t,enabled:n,onEnable:r,onDisable:i}){const{t:s}=Pe(),[o,a]=P.useState(!1),[l,c]=P.useState(""),[u,d]=P.useState(!1),[h,p]=P.useState(null);async function g(){if(!l.trim()){p(s("common.tokenRequired"));return}d(!0),p(null);try{await Tp(t,e.secretKey,l.trim()),r(e.secretKey),a(!1),c("")}catch{p(s("integrations.errorSave"))}finally{d(!1)}}async function m(){confirm(s("integrations.disconnectConfirm",{name:e.name}))&&(await Jk(t,e.secretKey),i(e.secretKey))}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 items-start justify-between gap-3",children:[f.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[f.jsx("span",{className:"text-[20px] flex-shrink-0",children:e.icon}),f.jsxs("div",{className:"min-w-0",children:[f.jsx("p",{className:"text-[13px] font-semibold text-on-surface",children:e.name}),f.jsx("p",{className:"font-mono text-[10px] text-on-surface-variant/70 mt-0.5 leading-relaxed",children:s(e.descriptionKey)})]})]}),f.jsx("div",{className:"flex-shrink-0 flex items-center gap-2",children:n?f.jsxs(f.Fragment,{children:[f.jsxs("span",{className:"font-mono text-[9px] text-secondary/80 flex items-center gap-1",children:[f.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-secondary/70"}),s("integrations.connected")]}),f.jsx("button",{onClick:m,className:"rounded px-2 py-1 text-[10px] font-mono text-error/50 hover:text-error hover:bg-error/10 transition-colors",children:s("integrations.disconnect")})]}):f.jsx("button",{onClick:()=>{a(!0),p(null)},className:"rounded bg-primary/10 border border-primary/20 px-3 py-1 text-[11px] font-medium text-primary hover:bg-primary/20 transition-colors",children:s("integrations.connect")})})]}),!n&&o&&f.jsxs("div",{className:"pt-2 border-t border-outline-variant/30 space-y-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:s(e.tokenLabelKey)}),f.jsx("input",{type:"password",className:g_,placeholder:e.tokenPlaceholder,value:l,onChange:v=>{c(v.target.value),p(null)},autoComplete:"off",autoFocus:!0}),f.jsx("p",{className:"font-mono text-[9px] text-on-surface-variant/50 mt-1.5 leading-relaxed",children:s(e.helpTextKey)})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("button",{onClick:g,disabled:u||!l.trim(),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:s(u?"integrations.saving":"integrations.saveAndConnect")}),f.jsx("button",{onClick:()=>{a(!1),c(""),p(null)},className:"rounded px-3 py-1.5 text-[12px] font-mono text-on-surface-variant hover:text-on-surface transition-colors",children:s("integrations.cancel")}),h&&f.jsx("span",{className:"font-mono text-[10px] text-error",children:h})]})]}),n&&o&&f.jsxs("div",{className:"pt-2 border-t border-outline-variant/30 space-y-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:s("integrations.newPrefix",{label:s(e.tokenLabelKey)})}),f.jsx("input",{type:"password",className:g_,placeholder:s("integrations.pasteNewToken"),value:l,onChange:v=>{c(v.target.value),p(null)},autoComplete:"off",autoFocus:!0})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("button",{onClick:g,disabled:u||!l.trim(),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:s(u?"integrations.saving":"integrations.updateToken")}),f.jsx("button",{onClick:()=>{a(!1),c(""),p(null)},className:"rounded px-3 py-1.5 text-[12px] font-mono text-on-surface-variant hover:text-on-surface transition-colors",children:s("integrations.cancel")}),h&&f.jsx("span",{className:"font-mono text-[10px] text-error",children:h})]})]}),n&&!o&&f.jsx("button",{onClick:()=>{a(!0),p(null)},className:"font-mono text-[10px] text-on-surface-variant/50 hover:text-on-surface-variant transition-colors",children:s("integrations.rotateToken")})]})}function x6({agentId:e,secretNames:t,setSecretNames:n}){const{t:r}=Pe();return f.jsxs("div",{className:"flex flex-col gap-4 max-w-xl",children:[f.jsxs("div",{children:[f.jsx("h2",{className:"font-headline text-[22px] font-bold text-on-surface",children:r("integrations.title")}),f.jsx("p",{className:"font-mono text-[11px] text-on-surface-variant/70 mt-1",children:r("integrations.blurb")})]}),f.jsx("div",{className:"space-y-3",children:g6.map(i=>f.jsx(m6,{def:i,agentId:e,enabled:t.includes(i.secretKey),onEnable:s=>n(o=>o.includes(s)?o:[...o,s]),onDisable:s=>n(o=>o.filter(a=>a!==s))},i.id))}),f.jsx("p",{className:"font-mono text-[10px] text-on-surface-variant/40 mt-2",children:r("integrations.moreSoon")})]})}function v6({agentId:e}){const{t}=Pe(),[n,r]=P.useState(null),[i,s]=P.useState(null),[o,a]=P.useState(null),[l,c]=P.useState(null);return P.useEffect(()=>{let u=!1;return GM(e).then(d=>{u||r(d)}).catch(()=>{u||r([])}),()=>{u=!0}},[e]),P.useEffect(()=>{if(!i){a(null),c(null);return}let u=!1;return a(null),c(null),KM(e,i).then(d=>{u||a(d)}).catch(d=>{u||c(d instanceof Error?d.message:String(d))}),()=>{u=!0}},[e,i]),f.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[f.jsxs("div",{className:"w-72 border-r border-outline/20 overflow-y-auto bg-surface-container-lowest",children:[f.jsxs("div",{className:"p-4 border-b border-outline/20",children:[f.jsx("h2",{className:"text-[13px] font-semibold text-on-surface",children:t("skillsView.title")}),f.jsx("p",{className:"text-[10px] text-on-surface-variant mt-1 leading-relaxed",children:t("skillsView.subtitle")})]}),n===null?f.jsx("div",{className:"p-4 text-[11px] text-on-surface-variant font-mono",children:t("skillsView.loading")}):n.length===0?f.jsx("div",{className:"p-4 text-[11px] text-on-surface-variant leading-relaxed",children:t("skillsView.empty")}):f.jsx("ul",{className:"divide-y divide-outline/10",children:n.map(u=>f.jsx("li",{children:f.jsxs("button",{type:"button",onClick:()=>s(u.name),className:`w-full text-left px-4 py-3 hover:bg-surface-container transition-colors ${i===u.name?"bg-surface-container":""}`,children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{className:"text-[12px] font-mono text-on-surface truncate",children:u.name}),u.userInvocable&&f.jsx("span",{className:"text-[8px] uppercase tracking-wider px-1.5 py-0.5 rounded bg-primary/15 text-primary font-medium",children:t("skillsView.userInvocable")})]}),f.jsx("div",{className:"text-[10px] text-on-surface-variant mt-1 line-clamp-2 leading-snug",children:u.description})]})},u.name))})]}),f.jsx("div",{className:"flex-1 overflow-y-auto p-6",children:i?l?f.jsx("div",{className:"text-[11px] text-error font-mono",children:t("skillsView.loadError",{error:l})}):o?f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"mb-4",children:[f.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[f.jsx("h2",{className:"text-[16px] font-semibold text-on-surface font-mono",children:o.name}),o.userInvocable&&f.jsx("span",{className:"text-[9px] uppercase tracking-wider px-1.5 py-0.5 rounded bg-primary/15 text-primary font-medium",children:t("skillsView.userInvocable")})]}),f.jsx("p",{className:"text-[12px] text-on-surface-variant",children:o.description}),o.allowedTools&&f.jsxs("p",{className:"text-[10px] text-on-surface-variant mt-2 font-mono",children:[f.jsxs("span",{className:"opacity-60",children:[t("skillsView.allowedTools"),":"]})," ",o.allowedTools]})]}),f.jsx("div",{className:"text-[12px] text-on-surface/85 leading-relaxed prose prose-sm dark:prose-invert max-w-none",children:f.jsx(vd,{remarkPlugins:[uC],children:y6(o.content)})})]}):f.jsx("div",{className:"text-[11px] text-on-surface-variant font-mono",children:t("skillsView.loading")}):f.jsx("div",{className:"text-[11px] text-on-surface-variant font-mono",children:t("skillsView.selectSkill")})})]})}function y6(e){if(!e.startsWith("---"))return e;const t=e.indexOf(`
|
|
139
|
+
`):e}function SB(e,t){const{element:n,datasetIndex:r,index:i}=t,s=e.getDatasetMeta(r).controller,{label:o,value:a}=s.getLabelAndValue(i);return{chart:e,label:o,parsed:s.getParsed(i),raw:e.data.datasets[r].data[i],formattedValue:a,dataset:s.getDataset(),dataIndex:i,datasetIndex:r,element:n}}function e_(e,t){const n=e.chart.ctx,{body:r,footer:i,title:s}=e,{boxWidth:o,boxHeight:a}=t,l=ft(t.bodyFont),c=ft(t.titleFont),u=ft(t.footerFont),d=s.length,h=i.length,p=r.length,g=Rt(t.padding);let m=g.height,v=0,x=r.reduce((k,w)=>k+w.before.length+w.lines.length+w.after.length,0);if(x+=e.beforeBody.length+e.afterBody.length,d&&(m+=d*c.lineHeight+(d-1)*t.titleSpacing+t.titleMarginBottom),x){const k=t.displayColors?Math.max(a,l.lineHeight):l.lineHeight;m+=p*k+(x-p)*l.lineHeight+(x-1)*t.bodySpacing}h&&(m+=t.footerMarginTop+h*u.lineHeight+(h-1)*t.footerSpacing);let y=0;const b=function(k){v=Math.max(v,n.measureText(k).width+y)};return n.save(),n.font=c.string,je(e.title,b),n.font=l.string,je(e.beforeBody.concat(e.afterBody),b),y=t.displayColors?o+2+t.boxPadding:0,je(r,k=>{je(k.before,b),je(k.lines,b),je(k.after,b)}),y=0,n.font=u.string,je(e.footer,b),n.restore(),v+=g.width,{width:v,height:m}}function CB(e,t){const{y:n,height:r}=t;return n<r/2?"top":n>e.height-r/2?"bottom":"center"}function EB(e,t,n,r){const{x:i,width:s}=r,o=n.caretSize+n.caretPadding;if(e==="left"&&i+s+o>t.width||e==="right"&&i-s-o<0)return!0}function PB(e,t,n,r){const{x:i,width:s}=n,{width:o,chartArea:{left:a,right:l}}=e;let c="center";return r==="center"?c=i<=(a+l)/2?"left":"right":i<=s/2?c="left":i>=o-s/2&&(c="right"),EB(c,e,t,n)&&(c="center"),c}function t_(e,t,n){const r=n.yAlign||t.yAlign||CB(e,n);return{xAlign:n.xAlign||t.xAlign||PB(e,t,n,r),yAlign:r}}function NB(e,t){let{x:n,width:r}=e;return t==="right"?n-=r:t==="center"&&(n-=r/2),n}function jB(e,t,n){let{y:r,height:i}=e;return t==="top"?r+=n:t==="bottom"?r-=i+n:r-=i/2,r}function n_(e,t,n,r){const{caretSize:i,caretPadding:s,cornerRadius:o}=e,{xAlign:a,yAlign:l}=n,c=i+s,{topLeft:u,topRight:d,bottomLeft:h,bottomRight:p}=Vi(o);let g=NB(t,a);const m=jB(t,l,c);return l==="center"?a==="left"?g+=c:a==="right"&&(g-=c):a==="left"?g-=Math.max(u,h)+i:a==="right"&&(g+=Math.max(d,p)+i),{x:gt(g,0,r.width-t.width),y:gt(m,0,r.height-t.height)}}function cc(e,t,n){const r=Rt(n.padding);return t==="center"?e.x+e.width/2:t==="right"?e.x+e.width-r.right:e.x+r.left}function r_(e){return Un([],hr(e))}function TB(e,t,n){return yi(e,{tooltip:t,tooltipItems:n,type:"tooltip"})}function i_(e,t){const n=t&&t.dataset&&t.dataset.tooltip&&t.dataset.tooltip.callbacks;return n?e.override(n):e}const uE={beforeTitle:cr,title(e){if(e.length>0){const t=e[0],n=t.chart.data.labels,r=n?n.length:0;if(this&&this.options&&this.options.mode==="dataset")return t.dataset.label||"";if(t.label)return t.label;if(r>0&&t.dataIndex<r)return n[t.dataIndex]}return""},afterTitle:cr,beforeBody:cr,beforeLabel:cr,label(e){if(this&&this.options&&this.options.mode==="dataset")return e.label+": "+e.formattedValue||e.formattedValue;let t=e.dataset.label||"";t&&(t+=": ");const n=e.formattedValue;return ge(n)||(t+=n),t},labelColor(e){const n=e.chart.getDatasetMeta(e.datasetIndex).controller.getStyle(e.dataIndex);return{borderColor:n.borderColor,backgroundColor:n.backgroundColor,borderWidth:n.borderWidth,borderDash:n.borderDash,borderDashOffset:n.borderDashOffset,borderRadius:0}},labelTextColor(){return this.options.bodyColor},labelPointStyle(e){const n=e.chart.getDatasetMeta(e.datasetIndex).controller.getStyle(e.dataIndex);return{pointStyle:n.pointStyle,rotation:n.rotation}},afterLabel:cr,afterBody:cr,beforeFooter:cr,footer:cr,afterFooter:cr};function Vt(e,t,n,r){const i=e[t].call(n,r);return typeof i>"u"?uE[t].call(n,r):i}class ng extends Mr{constructor(t){super(),this.opacity=0,this._active=[],this._eventPosition=void 0,this._size=void 0,this._cachedAnimations=void 0,this._tooltipItems=[],this.$animations=void 0,this.$context=void 0,this.chart=t.chart,this.options=t.options,this.dataPoints=void 0,this.title=void 0,this.beforeBody=void 0,this.body=void 0,this.afterBody=void 0,this.footer=void 0,this.xAlign=void 0,this.yAlign=void 0,this.x=void 0,this.y=void 0,this.height=void 0,this.width=void 0,this.caretX=void 0,this.caretY=void 0,this.labelColors=void 0,this.labelPointStyles=void 0,this.labelTextColors=void 0}initialize(t){this.options=t,this._cachedAnimations=void 0,this.$context=void 0}_resolveAnimations(){const t=this._cachedAnimations;if(t)return t;const n=this.chart,r=this.options.setContext(this.getContext()),i=r.enabled&&n.options.animation&&r.animations,s=new VC(this.chart,i);return i._cacheable&&(this._cachedAnimations=Object.freeze(s)),s}getContext(){return this.$context||(this.$context=TB(this.chart.getContext(),this,this._tooltipItems))}getTitle(t,n){const{callbacks:r}=n,i=Vt(r,"beforeTitle",this,t),s=Vt(r,"title",this,t),o=Vt(r,"afterTitle",this,t);let a=[];return a=Un(a,hr(i)),a=Un(a,hr(s)),a=Un(a,hr(o)),a}getBeforeBody(t,n){return r_(Vt(n.callbacks,"beforeBody",this,t))}getBody(t,n){const{callbacks:r}=n,i=[];return je(t,s=>{const o={before:[],lines:[],after:[]},a=i_(r,s);Un(o.before,hr(Vt(a,"beforeLabel",this,s))),Un(o.lines,Vt(a,"label",this,s)),Un(o.after,hr(Vt(a,"afterLabel",this,s))),i.push(o)}),i}getAfterBody(t,n){return r_(Vt(n.callbacks,"afterBody",this,t))}getFooter(t,n){const{callbacks:r}=n,i=Vt(r,"beforeFooter",this,t),s=Vt(r,"footer",this,t),o=Vt(r,"afterFooter",this,t);let a=[];return a=Un(a,hr(i)),a=Un(a,hr(s)),a=Un(a,hr(o)),a}_createItems(t){const n=this._active,r=this.chart.data,i=[],s=[],o=[];let a=[],l,c;for(l=0,c=n.length;l<c;++l)a.push(SB(this.chart,n[l]));return t.filter&&(a=a.filter((u,d,h)=>t.filter(u,d,h,r))),t.itemSort&&(a=a.sort((u,d)=>t.itemSort(u,d,r))),je(a,u=>{const d=i_(t.callbacks,u);i.push(Vt(d,"labelColor",this,u)),s.push(Vt(d,"labelPointStyle",this,u)),o.push(Vt(d,"labelTextColor",this,u))}),this.labelColors=i,this.labelPointStyles=s,this.labelTextColors=o,this.dataPoints=a,a}update(t,n){const r=this.options.setContext(this.getContext()),i=this._active;let s,o=[];if(!i.length)this.opacity!==0&&(s={opacity:0});else{const a=ia[r.position].call(this,i,this._eventPosition);o=this._createItems(r),this.title=this.getTitle(o,r),this.beforeBody=this.getBeforeBody(o,r),this.body=this.getBody(o,r),this.afterBody=this.getAfterBody(o,r),this.footer=this.getFooter(o,r);const l=this._size=e_(this,r),c=Object.assign({},a,l),u=t_(this.chart,r,c),d=n_(r,c,u,this.chart);this.xAlign=u.xAlign,this.yAlign=u.yAlign,s={opacity:1,x:d.x,y:d.y,width:l.width,height:l.height,caretX:a.x,caretY:a.y}}this._tooltipItems=o,this.$context=void 0,s&&this._resolveAnimations().update(this,s),t&&r.external&&r.external.call(this,{chart:this.chart,tooltip:this,replay:n})}drawCaret(t,n,r,i){const s=this.getCaretPosition(t,r,i);n.lineTo(s.x1,s.y1),n.lineTo(s.x2,s.y2),n.lineTo(s.x3,s.y3)}getCaretPosition(t,n,r){const{xAlign:i,yAlign:s}=this,{caretSize:o,cornerRadius:a}=r,{topLeft:l,topRight:c,bottomLeft:u,bottomRight:d}=Vi(a),{x:h,y:p}=t,{width:g,height:m}=n;let v,x,y,b,k,w;return s==="center"?(k=p+m/2,i==="left"?(v=h,x=v-o,b=k+o,w=k-o):(v=h+g,x=v+o,b=k-o,w=k+o),y=v):(i==="left"?x=h+Math.max(l,u)+o:i==="right"?x=h+g-Math.max(c,d)-o:x=this.caretX,s==="top"?(b=p,k=b-o,v=x-o,y=x+o):(b=p+m,k=b+o,v=x+o,y=x-o),w=b),{x1:v,x2:x,x3:y,y1:b,y2:k,y3:w}}drawTitle(t,n,r){const i=this.title,s=i.length;let o,a,l;if(s){const c=qs(r.rtl,this.x,this.width);for(t.x=cc(this,r.titleAlign,r),n.textAlign=c.textAlign(r.titleAlign),n.textBaseline="middle",o=ft(r.titleFont),a=r.titleSpacing,n.fillStyle=r.titleColor,n.font=o.string,l=0;l<s;++l)n.fillText(i[l],c.x(t.x),t.y+o.lineHeight/2),t.y+=o.lineHeight+a,l+1===s&&(t.y+=r.titleMarginBottom-a)}}_drawColorBox(t,n,r,i,s){const o=this.labelColors[r],a=this.labelPointStyles[r],{boxHeight:l,boxWidth:c}=s,u=ft(s.bodyFont),d=cc(this,"left",s),h=i.x(d),p=l<u.lineHeight?(u.lineHeight-l)/2:0,g=n.y+p;if(s.usePointStyle){const m={radius:Math.min(c,l)/2,pointStyle:a.pointStyle,rotation:a.rotation,borderWidth:1},v=i.leftForLtr(h,c)+c/2,x=g+l/2;t.strokeStyle=s.multiKeyBackground,t.fillStyle=s.multiKeyBackground,Yp(t,m,v,x),t.strokeStyle=o.borderColor,t.fillStyle=o.backgroundColor,Yp(t,m,v,x)}else{t.lineWidth=ve(o.borderWidth)?Math.max(...Object.values(o.borderWidth)):o.borderWidth||1,t.strokeStyle=o.borderColor,t.setLineDash(o.borderDash||[]),t.lineDashOffset=o.borderDashOffset||0;const m=i.leftForLtr(h,c),v=i.leftForLtr(i.xPlus(h,1),c-2),x=Vi(o.borderRadius);Object.values(x).some(y=>y!==0)?(t.beginPath(),t.fillStyle=s.multiKeyBackground,al(t,{x:m,y:g,w:c,h:l,radius:x}),t.fill(),t.stroke(),t.fillStyle=o.backgroundColor,t.beginPath(),al(t,{x:v,y:g+1,w:c-2,h:l-2,radius:x}),t.fill()):(t.fillStyle=s.multiKeyBackground,t.fillRect(m,g,c,l),t.strokeRect(m,g,c,l),t.fillStyle=o.backgroundColor,t.fillRect(v,g+1,c-2,l-2))}t.fillStyle=this.labelTextColors[r]}drawBody(t,n,r){const{body:i}=this,{bodySpacing:s,bodyAlign:o,displayColors:a,boxHeight:l,boxWidth:c,boxPadding:u}=r,d=ft(r.bodyFont);let h=d.lineHeight,p=0;const g=qs(r.rtl,this.x,this.width),m=function(E){n.fillText(E,g.x(t.x+p),t.y+h/2),t.y+=h+s},v=g.textAlign(o);let x,y,b,k,w,_,N;for(n.textAlign=o,n.textBaseline="middle",n.font=d.string,t.x=cc(this,v,r),n.fillStyle=r.bodyColor,je(this.beforeBody,m),p=a&&v!=="right"?o==="center"?c/2+u:c+2+u:0,k=0,_=i.length;k<_;++k){for(x=i[k],y=this.labelTextColors[k],n.fillStyle=y,je(x.before,m),b=x.lines,a&&b.length&&(this._drawColorBox(n,t,k,g,r),h=Math.max(d.lineHeight,l)),w=0,N=b.length;w<N;++w)m(b[w]),h=d.lineHeight;je(x.after,m)}p=0,h=d.lineHeight,je(this.afterBody,m),t.y-=s}drawFooter(t,n,r){const i=this.footer,s=i.length;let o,a;if(s){const l=qs(r.rtl,this.x,this.width);for(t.x=cc(this,r.footerAlign,r),t.y+=r.footerMarginTop,n.textAlign=l.textAlign(r.footerAlign),n.textBaseline="middle",o=ft(r.footerFont),n.fillStyle=r.footerColor,n.font=o.string,a=0;a<s;++a)n.fillText(i[a],l.x(t.x),t.y+o.lineHeight/2),t.y+=o.lineHeight+r.footerSpacing}}drawBackground(t,n,r,i){const{xAlign:s,yAlign:o}=this,{x:a,y:l}=t,{width:c,height:u}=r,{topLeft:d,topRight:h,bottomLeft:p,bottomRight:g}=Vi(i.cornerRadius);n.fillStyle=i.backgroundColor,n.strokeStyle=i.borderColor,n.lineWidth=i.borderWidth,n.beginPath(),n.moveTo(a+d,l),o==="top"&&this.drawCaret(t,n,r,i),n.lineTo(a+c-h,l),n.quadraticCurveTo(a+c,l,a+c,l+h),o==="center"&&s==="right"&&this.drawCaret(t,n,r,i),n.lineTo(a+c,l+u-g),n.quadraticCurveTo(a+c,l+u,a+c-g,l+u),o==="bottom"&&this.drawCaret(t,n,r,i),n.lineTo(a+p,l+u),n.quadraticCurveTo(a,l+u,a,l+u-p),o==="center"&&s==="left"&&this.drawCaret(t,n,r,i),n.lineTo(a,l+d),n.quadraticCurveTo(a,l,a+d,l),n.closePath(),n.fill(),i.borderWidth>0&&n.stroke()}_updateAnimationTarget(t){const n=this.chart,r=this.$animations,i=r&&r.x,s=r&&r.y;if(i||s){const o=ia[t.position].call(this,this._active,this._eventPosition);if(!o)return;const a=this._size=e_(this,t),l=Object.assign({},o,this._size),c=t_(n,t,l),u=n_(t,l,c,n);(i._to!==u.x||s._to!==u.y)&&(this.xAlign=c.xAlign,this.yAlign=c.yAlign,this.width=a.width,this.height=a.height,this.caretX=o.x,this.caretY=o.y,this._resolveAnimations().update(this,u))}}_willRender(){return!!this.opacity}draw(t){const n=this.options.setContext(this.getContext());let r=this.opacity;if(!r)return;this._updateAnimationTarget(n);const i={width:this.width,height:this.height},s={x:this.x,y:this.y};r=Math.abs(r)<.001?0:r;const o=Rt(n.padding),a=this.title.length||this.beforeBody.length||this.body.length||this.afterBody.length||this.footer.length;n.enabled&&a&&(t.save(),t.globalAlpha=r,this.drawBackground(s,t,i,n),LC(t,n.textDirection),s.y+=o.top,this.drawTitle(s,t,n),this.drawBody(s,t,n),this.drawFooter(s,t,n),FC(t,n.textDirection),t.restore())}getActiveElements(){return this._active||[]}setActiveElements(t,n){const r=this._active,i=t.map(({datasetIndex:a,index:l})=>{const c=this.chart.getDatasetMeta(a);if(!c)throw new Error("Cannot find a dataset at index "+a);return{datasetIndex:a,element:c.data[l],index:l}}),s=!Iu(r,i),o=this._positionChanged(i,n);(s||o)&&(this._active=i,this._eventPosition=n,this._ignoreReplayEvents=!0,this.update(!0))}handleEvent(t,n,r=!0){if(n&&this._ignoreReplayEvents)return!1;this._ignoreReplayEvents=!1;const i=this.options,s=this._active||[],o=this._getActiveElements(t,s,n,r),a=this._positionChanged(o,t),l=n||!Iu(o,s)||a;return l&&(this._active=o,(i.enabled||i.external)&&(this._eventPosition={x:t.x,y:t.y},this.update(!0,n))),l}_getActiveElements(t,n,r,i){const s=this.options;if(t.type==="mouseout")return[];if(!i)return n.filter(a=>this.chart.data.datasets[a.datasetIndex]&&this.chart.getDatasetMeta(a.datasetIndex).controller.getParsed(a.index)!==void 0);const o=this.chart.getElementsAtEventForMode(t,s.mode,s,r);return s.reverse&&o.reverse(),o}_positionChanged(t,n){const{caretX:r,caretY:i,options:s}=this,o=ia[s.position].call(this,t,n);return o!==!1&&(r!==o.x||i!==o.y)}}W(ng,"positioners",ia);var MB={id:"tooltip",_element:ng,positioners:ia,afterInit(e,t,n){n&&(e.tooltip=new ng({chart:e,options:n}))},beforeUpdate(e,t,n){e.tooltip&&e.tooltip.initialize(n)},reset(e,t,n){e.tooltip&&e.tooltip.initialize(n)},afterDraw(e){const t=e.tooltip;if(t&&t._willRender()){const n={tooltip:t};if(e.notifyPlugins("beforeTooltipDraw",{...n,cancelable:!0})===!1)return;t.draw(e.ctx),e.notifyPlugins("afterTooltipDraw",n)}},afterEvent(e,t){if(e.tooltip){const n=t.replay;e.tooltip.handleEvent(t.event,n,t.inChartArea)&&(t.changed=!0)}},defaults:{enabled:!0,external:null,position:"average",backgroundColor:"rgba(0,0,0,0.8)",titleColor:"#fff",titleFont:{weight:"bold"},titleSpacing:2,titleMarginBottom:6,titleAlign:"left",bodyColor:"#fff",bodySpacing:2,bodyFont:{},bodyAlign:"left",footerColor:"#fff",footerSpacing:2,footerMarginTop:6,footerFont:{weight:"bold"},footerAlign:"left",padding:6,caretPadding:2,caretSize:5,cornerRadius:6,boxHeight:(e,t)=>t.bodyFont.size,boxWidth:(e,t)=>t.bodyFont.size,multiKeyBackground:"#fff",displayColors:!0,boxPadding:0,borderColor:"rgba(0,0,0,0)",borderWidth:0,animation:{duration:400,easing:"easeOutQuart"},animations:{numbers:{type:"number",properties:["x","y","width","height","caretX","caretY"]},opacity:{easing:"linear",duration:200}},callbacks:uE},defaultRoutes:{bodyFont:"font",footerFont:"font",titleFont:"font"},descriptors:{_scriptable:e=>e!=="filter"&&e!=="itemSort"&&e!=="external",_indexable:!1,callbacks:{_scriptable:!1,_indexable:!1},animation:{_fallback:!1},animations:{_fallback:"animation"}},additionalOptionScopes:["interaction"]},RB=Object.freeze({__proto__:null,Colors:W4,Decimation:K4,Filler:pB,Legend:bB,SubTitle:kB,Title:wB,Tooltip:MB});const AB=(e,t,n,r)=>(typeof t=="string"?(n=e.push(t)-1,r.unshift({index:n,label:t})):isNaN(t)&&(n=null),n);function DB(e,t,n,r){const i=e.indexOf(t);if(i===-1)return AB(e,t,n,r);const s=e.lastIndexOf(t);return i!==s?n:i}const IB=(e,t)=>e===null?null:gt(Math.round(e),0,t);function s_(e){const t=this.getLabels();return e>=0&&e<t.length?t[e]:e}class rg extends ss{constructor(t){super(t),this._startValue=void 0,this._valueRange=0,this._addedLabels=[]}init(t){const n=this._addedLabels;if(n.length){const r=this.getLabels();for(const{index:i,label:s}of n)r[i]===s&&r.splice(i,1);this._addedLabels=[]}super.init(t)}parse(t,n){if(ge(t))return null;const r=this.getLabels();return n=isFinite(n)&&r[n]===t?n:DB(r,t,ce(n,t),this._addedLabels),IB(n,r.length-1)}determineDataLimits(){const{minDefined:t,maxDefined:n}=this.getUserBounds();let{min:r,max:i}=this.getMinMax(!0);this.options.bounds==="ticks"&&(t||(r=0),n||(i=this.getLabels().length-1)),this.min=r,this.max=i}buildTicks(){const t=this.min,n=this.max,r=this.options.offset,i=[];let s=this.getLabels();s=t===0&&n===s.length-1?s:s.slice(t,n+1),this._valueRange=Math.max(s.length-(r?0:1),1),this._startValue=this.min-(r?.5:0);for(let o=t;o<=n;o++)i.push({value:o});return i}getLabelForValue(t){return s_.call(this,t)}configure(){super.configure(),this.isHorizontal()||(this._reversePixels=!this._reversePixels)}getPixelForValue(t){return typeof t!="number"&&(t=this.parse(t)),t===null?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getPixelForTick(t){const n=this.ticks;return t<0||t>n.length-1?null:this.getPixelForValue(n[t].value)}getValueForPixel(t){return Math.round(this._startValue+this.getDecimalForPixel(t)*this._valueRange)}getBasePixel(){return this.bottom}}W(rg,"id","category"),W(rg,"defaults",{ticks:{callback:s_}});function OB(e,t){const n=[],{bounds:i,step:s,min:o,max:a,precision:l,count:c,maxTicks:u,maxDigits:d,includeBounds:h}=e,p=s||1,g=u-1,{min:m,max:v}=t,x=!ge(o),y=!ge(a),b=!ge(c),k=(v-m)/(d+1);let w=eb((v-m)/g/p)*p,_,N,E,T;if(w<1e-14&&!x&&!y)return[{value:m},{value:v}];T=Math.ceil(v/w)-Math.floor(m/w),T>g&&(w=eb(T*w/g/p)*p),ge(l)||(_=Math.pow(10,l),w=Math.ceil(w*_)/_),i==="ticks"?(N=Math.floor(m/w)*w,E=Math.ceil(v/w)*w):(N=m,E=v),x&&y&&s&&N5((a-o)/s,w/1e3)?(T=Math.round(Math.min((a-o)/w,u)),w=(a-o)/T,N=o,E=a):b?(N=x?o:N,E=y?a:E,T=c-1,w=(E-N)/T):(T=(E-N)/w,Ca(T,Math.round(T),w/1e3)?T=Math.round(T):T=Math.ceil(T));const S=Math.max(tb(w),tb(N));_=Math.pow(10,ge(l)?S:l),N=Math.round(N*_)/_,E=Math.round(E*_)/_;let M=0;for(x&&(h&&N!==o?(n.push({value:o}),N<o&&M++,Ca(Math.round((N+M*w)*_)/_,o,o_(o,k,e))&&M++):N<o&&M++);M<T;++M){const A=Math.round((N+M*w)*_)/_;if(y&&A>a)break;n.push({value:A})}return y&&h&&E!==a?n.length&&Ca(n[n.length-1].value,a,o_(a,k,e))?n[n.length-1].value=a:n.push({value:a}):(!y||E===a)&&n.push({value:E}),n}function o_(e,t,{horizontal:n,minRotation:r}){const i=On(r),s=(n?Math.sin(i):Math.cos(i))||.001,o=.75*t*(""+e).length;return Math.min(t/s,o)}class Hu extends ss{constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._endValue=void 0,this._valueRange=0}parse(t,n){return ge(t)||(typeof t=="number"||t instanceof Number)&&!isFinite(+t)?null:+t}handleTickRangeOptions(){const{beginAtZero:t}=this.options,{minDefined:n,maxDefined:r}=this.getUserBounds();let{min:i,max:s}=this;const o=l=>i=n?i:l,a=l=>s=r?s:l;if(t){const l=rr(i),c=rr(s);l<0&&c<0?a(0):l>0&&c>0&&o(0)}if(i===s){let l=s===0?1:Math.abs(s*.05);a(s+l),t||o(i-l)}this.min=i,this.max=s}getTickLimit(){const t=this.options.ticks;let{maxTicksLimit:n,stepSize:r}=t,i;return r?(i=Math.ceil(this.max/r)-Math.floor(this.min/r)+1,i>1e3&&(console.warn(`scales.${this.id}.ticks.stepSize: ${r} would result generating up to ${i} ticks. Limiting to 1000.`),i=1e3)):(i=this.computeTickLimit(),n=n||11),n&&(i=Math.min(n,i)),i}computeTickLimit(){return Number.POSITIVE_INFINITY}buildTicks(){const t=this.options,n=t.ticks;let r=this.getTickLimit();r=Math.max(2,r);const i={maxTicks:r,bounds:t.bounds,min:t.min,max:t.max,precision:n.precision,step:n.stepSize,count:n.count,maxDigits:this._maxDigits(),horizontal:this.isHorizontal(),minRotation:n.minRotation||0,includeBounds:n.includeBounds!==!1},s=this._range||this,o=OB(i,s);return t.bounds==="ticks"&&bC(o,this,"value"),t.reverse?(o.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),o}configure(){const t=this.ticks;let n=this.min,r=this.max;if(super.configure(),this.options.offset&&t.length){const i=(r-n)/Math.max(t.length-1,1)/2;n-=i,r+=i}this._startValue=n,this._endValue=r,this._valueRange=r-n}getLabelForValue(t){return bl(t,this.chart.options.locale,this.options.ticks.format)}}class ig extends Hu{determineDataLimits(){const{min:t,max:n}=this.getMinMax(!0);this.min=Qe(t)?t:0,this.max=Qe(n)?n:1,this.handleTickRangeOptions()}computeTickLimit(){const t=this.isHorizontal(),n=t?this.width:this.height,r=On(this.options.ticks.minRotation),i=(t?Math.sin(r):Math.cos(r))||.001,s=this._resolveTickFontOptions(0);return Math.ceil(n/Math.min(40,s.lineHeight/i))}getPixelForValue(t){return t===null?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getValueForPixel(t){return this._startValue+this.getDecimalForPixel(t)*this._valueRange}}W(ig,"id","linear"),W(ig,"defaults",{ticks:{callback:yd.formatters.numeric}});const cl=e=>Math.floor(Yr(e)),Ni=(e,t)=>Math.pow(10,cl(e)+t);function a_(e){return e/Math.pow(10,cl(e))===1}function l_(e,t,n){const r=Math.pow(10,n),i=Math.floor(e/r);return Math.ceil(t/r)-i}function LB(e,t){const n=t-e;let r=cl(n);for(;l_(e,t,r)>10;)r++;for(;l_(e,t,r)<10;)r--;return Math.min(r,cl(e))}function FB(e,{min:t,max:n}){t=sn(e.min,t);const r=[],i=cl(t);let s=LB(t,n),o=s<0?Math.pow(10,Math.abs(s)):1;const a=Math.pow(10,s),l=i>s?Math.pow(10,i):0,c=Math.round((t-l)*o)/o,u=Math.floor((t-l)/a/10)*a*10;let d=Math.floor((c-u)/Math.pow(10,s)),h=sn(e.min,Math.round((l+u+d*Math.pow(10,s))*o)/o);for(;h<n;)r.push({value:h,major:a_(h),significand:d}),d>=10?d=d<15?15:20:d++,d>=20&&(s++,d=2,o=s>=0?1:o),h=Math.round((l+u+d*Math.pow(10,s))*o)/o;const p=sn(e.max,h);return r.push({value:p,major:a_(p),significand:d}),r}class sg extends ss{constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._valueRange=0}parse(t,n){const r=Hu.prototype.parse.apply(this,[t,n]);if(r===0){this._zero=!0;return}return Qe(r)&&r>0?r:null}determineDataLimits(){const{min:t,max:n}=this.getMinMax(!0);this.min=Qe(t)?Math.max(0,t):null,this.max=Qe(n)?Math.max(0,n):null,this.options.beginAtZero&&(this._zero=!0),this._zero&&this.min!==this._suggestedMin&&!Qe(this._userMin)&&(this.min=t===Ni(this.min,0)?Ni(this.min,-1):Ni(this.min,0)),this.handleTickRangeOptions()}handleTickRangeOptions(){const{minDefined:t,maxDefined:n}=this.getUserBounds();let r=this.min,i=this.max;const s=a=>r=t?r:a,o=a=>i=n?i:a;r===i&&(r<=0?(s(1),o(10)):(s(Ni(r,-1)),o(Ni(i,1)))),r<=0&&s(Ni(i,-1)),i<=0&&o(Ni(r,1)),this.min=r,this.max=i}buildTicks(){const t=this.options,n={min:this._userMin,max:this._userMax},r=FB(n,this);return t.bounds==="ticks"&&bC(r,this,"value"),t.reverse?(r.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),r}getLabelForValue(t){return t===void 0?"0":bl(t,this.chart.options.locale,this.options.ticks.format)}configure(){const t=this.min;super.configure(),this._startValue=Yr(t),this._valueRange=Yr(this.max)-Yr(t)}getPixelForValue(t){return(t===void 0||t===0)&&(t=this.min),t===null||isNaN(t)?NaN:this.getPixelForDecimal(t===this.min?0:(Yr(t)-this._startValue)/this._valueRange)}getValueForPixel(t){const n=this.getDecimalForPixel(t);return Math.pow(10,this._startValue+n*this._valueRange)}}W(sg,"id","logarithmic"),W(sg,"defaults",{ticks:{callback:yd.formatters.logarithmic,major:{enabled:!0}}});function og(e){const t=e.ticks;if(t.display&&e.display){const n=Rt(t.backdropPadding);return ce(t.font&&t.font.size,Ue.font.size)+n.height}return 0}function $B(e,t,n){return n=We(n)?n:[n],{w:U5(e,t.string,n),h:n.length*t.lineHeight}}function c_(e,t,n,r,i){return e===r||e===i?{start:t-n/2,end:t+n/2}:e<r||e>i?{start:t-n,end:t}:{start:t,end:t+n}}function zB(e){const t={l:e.left+e._padding.left,r:e.right-e._padding.right,t:e.top+e._padding.top,b:e.bottom-e._padding.bottom},n=Object.assign({},t),r=[],i=[],s=e._pointLabels.length,o=e.options.pointLabels,a=o.centerPointLabels?Ee/s:0;for(let l=0;l<s;l++){const c=o.setContext(e.getPointLabelContext(l));i[l]=c.padding;const u=e.getPointPosition(l,e.drawingArea+i[l],a),d=ft(c.font),h=$B(e.ctx,d,e._pointLabels[l]);r[l]=h;const p=Pt(e.getIndexAngle(l)+a),g=Math.round(Wm(p)),m=c_(g,u.x,h.w,0,180),v=c_(g,u.y,h.h,90,270);BB(n,t,p,m,v)}e.setCenterPoint(t.l-n.l,n.r-t.r,t.t-n.t,n.b-t.b),e._pointLabelItems=WB(e,r,i)}function BB(e,t,n,r,i){const s=Math.abs(Math.sin(n)),o=Math.abs(Math.cos(n));let a=0,l=0;r.start<t.l?(a=(t.l-r.start)/s,e.l=Math.min(e.l,t.l-a)):r.end>t.r&&(a=(r.end-t.r)/s,e.r=Math.max(e.r,t.r+a)),i.start<t.t?(l=(t.t-i.start)/o,e.t=Math.min(e.t,t.t-l)):i.end>t.b&&(l=(i.end-t.b)/o,e.b=Math.max(e.b,t.b+l))}function HB(e,t,n){const r=e.drawingArea,{extra:i,additionalAngle:s,padding:o,size:a}=n,l=e.getPointPosition(t,r+i+o,s),c=Math.round(Wm(Pt(l.angle+nt))),u=GB(l.y,a.h,c),d=UB(c),h=qB(l.x,a.w,d);return{visible:!0,x:l.x,y:u,textAlign:d,left:h,top:u,right:h+a.w,bottom:u+a.h}}function VB(e,t){if(!t)return!0;const{left:n,top:r,right:i,bottom:s}=e;return!(wr({x:n,y:r},t)||wr({x:n,y:s},t)||wr({x:i,y:r},t)||wr({x:i,y:s},t))}function WB(e,t,n){const r=[],i=e._pointLabels.length,s=e.options,{centerPointLabels:o,display:a}=s.pointLabels,l={extra:og(s)/2,additionalAngle:o?Ee/i:0};let c;for(let u=0;u<i;u++){l.padding=n[u],l.size=t[u];const d=HB(e,u,l);r.push(d),a==="auto"&&(d.visible=VB(d,c),d.visible&&(c=d))}return r}function UB(e){return e===0||e===180?"center":e<180?"left":"right"}function qB(e,t,n){return n==="right"?e-=t:n==="center"&&(e-=t/2),e}function GB(e,t,n){return n===90||n===270?e-=t/2:(n>270||n<90)&&(e-=t),e}function KB(e,t,n){const{left:r,top:i,right:s,bottom:o}=n,{backdropColor:a}=t;if(!ge(a)){const l=Vi(t.borderRadius),c=Rt(t.backdropPadding);e.fillStyle=a;const u=r-c.left,d=i-c.top,h=s-r+c.width,p=o-i+c.height;Object.values(l).some(g=>g!==0)?(e.beginPath(),al(e,{x:u,y:d,w:h,h:p,radius:l}),e.fill()):e.fillRect(u,d,h,p)}}function YB(e,t){const{ctx:n,options:{pointLabels:r}}=e;for(let i=t-1;i>=0;i--){const s=e._pointLabelItems[i];if(!s.visible)continue;const o=r.setContext(e.getPointLabelContext(i));KB(n,o,s);const a=ft(o.font),{x:l,y:c,textAlign:u}=s;Zi(n,e._pointLabels[i],l,c+a.lineHeight/2,a,{color:o.color,textAlign:u,textBaseline:"middle"})}}function dE(e,t,n,r){const{ctx:i}=e;if(n)i.arc(e.xCenter,e.yCenter,t,0,He);else{let s=e.getPointPosition(0,t);i.moveTo(s.x,s.y);for(let o=1;o<r;o++)s=e.getPointPosition(o,t),i.lineTo(s.x,s.y)}}function XB(e,t,n,r,i){const s=e.ctx,o=t.circular,{color:a,lineWidth:l}=t;!o&&!r||!a||!l||n<0||(s.save(),s.strokeStyle=a,s.lineWidth=l,s.setLineDash(i.dash||[]),s.lineDashOffset=i.dashOffset,s.beginPath(),dE(e,n,o,r),s.closePath(),s.stroke(),s.restore())}function JB(e,t,n){return yi(e,{label:n,index:t,type:"pointLabel"})}class sa extends Hu{constructor(t){super(t),this.xCenter=void 0,this.yCenter=void 0,this.drawingArea=void 0,this._pointLabels=[],this._pointLabelItems=[]}setDimensions(){const t=this._padding=Rt(og(this.options)/2),n=this.width=this.maxWidth-t.width,r=this.height=this.maxHeight-t.height;this.xCenter=Math.floor(this.left+n/2+t.left),this.yCenter=Math.floor(this.top+r/2+t.top),this.drawingArea=Math.floor(Math.min(n,r)/2)}determineDataLimits(){const{min:t,max:n}=this.getMinMax(!1);this.min=Qe(t)&&!isNaN(t)?t:0,this.max=Qe(n)&&!isNaN(n)?n:0,this.handleTickRangeOptions()}computeTickLimit(){return Math.ceil(this.drawingArea/og(this.options))}generateTickLabels(t){Hu.prototype.generateTickLabels.call(this,t),this._pointLabels=this.getLabels().map((n,r)=>{const i=Oe(this.options.pointLabels.callback,[n,r],this);return i||i===0?i:""}).filter((n,r)=>this.chart.getDataVisibility(r))}fit(){const t=this.options;t.display&&t.pointLabels.display?zB(this):this.setCenterPoint(0,0,0,0)}setCenterPoint(t,n,r,i){this.xCenter+=Math.floor((t-n)/2),this.yCenter+=Math.floor((r-i)/2),this.drawingArea-=Math.min(this.drawingArea/2,Math.max(t,n,r,i))}getIndexAngle(t){const n=He/(this._pointLabels.length||1),r=this.options.startAngle||0;return Pt(t*n+On(r))}getDistanceFromCenterForValue(t){if(ge(t))return NaN;const n=this.drawingArea/(this.max-this.min);return this.options.reverse?(this.max-t)*n:(t-this.min)*n}getValueForDistanceFromCenter(t){if(ge(t))return NaN;const n=t/(this.drawingArea/(this.max-this.min));return this.options.reverse?this.max-n:this.min+n}getPointLabelContext(t){const n=this._pointLabels||[];if(t>=0&&t<n.length){const r=n[t];return JB(this.getContext(),t,r)}}getPointPosition(t,n,r=0){const i=this.getIndexAngle(t)-nt+r;return{x:Math.cos(i)*n+this.xCenter,y:Math.sin(i)*n+this.yCenter,angle:i}}getPointPositionForValue(t,n){return this.getPointPosition(t,this.getDistanceFromCenterForValue(n))}getBasePosition(t){return this.getPointPositionForValue(t||0,this.getBaseValue())}getPointLabelPosition(t){const{left:n,top:r,right:i,bottom:s}=this._pointLabelItems[t];return{left:n,top:r,right:i,bottom:s}}drawBackground(){const{backgroundColor:t,grid:{circular:n}}=this.options;if(t){const r=this.ctx;r.save(),r.beginPath(),dE(this,this.getDistanceFromCenterForValue(this._endValue),n,this._pointLabels.length),r.closePath(),r.fillStyle=t,r.fill(),r.restore()}}drawGrid(){const t=this.ctx,n=this.options,{angleLines:r,grid:i,border:s}=n,o=this._pointLabels.length;let a,l,c;if(n.pointLabels.display&&YB(this,o),i.display&&this.ticks.forEach((u,d)=>{if(d!==0||d===0&&this.min<0){l=this.getDistanceFromCenterForValue(u.value);const h=this.getContext(d),p=i.setContext(h),g=s.setContext(h);XB(this,p,l,o,g)}}),r.display){for(t.save(),a=o-1;a>=0;a--){const u=r.setContext(this.getPointLabelContext(a)),{color:d,lineWidth:h}=u;!h||!d||(t.lineWidth=h,t.strokeStyle=d,t.setLineDash(u.borderDash),t.lineDashOffset=u.borderDashOffset,l=this.getDistanceFromCenterForValue(n.reverse?this.min:this.max),c=this.getPointPosition(a,l),t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(c.x,c.y),t.stroke())}t.restore()}}drawBorder(){}drawLabels(){const t=this.ctx,n=this.options,r=n.ticks;if(!r.display)return;const i=this.getIndexAngle(0);let s,o;t.save(),t.translate(this.xCenter,this.yCenter),t.rotate(i),t.textAlign="center",t.textBaseline="middle",this.ticks.forEach((a,l)=>{if(l===0&&this.min>=0&&!n.reverse)return;const c=r.setContext(this.getContext(l)),u=ft(c.font);if(s=this.getDistanceFromCenterForValue(this.ticks[l].value),c.showLabelBackdrop){t.font=u.string,o=t.measureText(a.label).width,t.fillStyle=c.backdropColor;const d=Rt(c.backdropPadding);t.fillRect(-o/2-d.left,-s-u.size/2-d.top,o+d.width,u.size+d.height)}Zi(t,a.label,0,-s,u,{color:c.color,strokeColor:c.textStrokeColor,strokeWidth:c.textStrokeWidth})}),t.restore()}drawTitle(){}}W(sa,"id","radialLinear"),W(sa,"defaults",{display:!0,animate:!0,position:"chartArea",angleLines:{display:!0,lineWidth:1,borderDash:[],borderDashOffset:0},grid:{circular:!1},startAngle:0,ticks:{showLabelBackdrop:!0,callback:yd.formatters.numeric},pointLabels:{backdropColor:void 0,backdropPadding:2,display:!0,font:{size:10},callback(t){return t},padding:5,centerPointLabels:!1}}),W(sa,"defaultRoutes",{"angleLines.color":"borderColor","pointLabels.color":"color","ticks.color":"color"}),W(sa,"descriptors",{angleLines:{_fallback:"grid"}});const Cd={millisecond:{common:!0,size:1,steps:1e3},second:{common:!0,size:1e3,steps:60},minute:{common:!0,size:6e4,steps:60},hour:{common:!0,size:36e5,steps:24},day:{common:!0,size:864e5,steps:30},week:{common:!1,size:6048e5,steps:4},month:{common:!0,size:2628e6,steps:12},quarter:{common:!1,size:7884e6,steps:4},year:{common:!0,size:3154e7}},Gt=Object.keys(Cd);function u_(e,t){return e-t}function d_(e,t){if(ge(t))return null;const n=e._adapter,{parser:r,round:i,isoWeekday:s}=e._parseOpts;let o=t;return typeof r=="function"&&(o=r(o)),Qe(o)||(o=typeof r=="string"?n.parse(o,r):n.parse(o)),o===null?null:(i&&(o=i==="week"&&(oo(s)||s===!0)?n.startOf(o,"isoWeek",s):n.startOf(o,i)),+o)}function h_(e,t,n,r){const i=Gt.length;for(let s=Gt.indexOf(e);s<i-1;++s){const o=Cd[Gt[s]],a=o.steps?o.steps:Number.MAX_SAFE_INTEGER;if(o.common&&Math.ceil((n-t)/(a*o.size))<=r)return Gt[s]}return Gt[i-1]}function QB(e,t,n,r,i){for(let s=Gt.length-1;s>=Gt.indexOf(n);s--){const o=Gt[s];if(Cd[o].common&&e._adapter.diff(i,r,o)>=t-1)return o}return Gt[n?Gt.indexOf(n):0]}function ZB(e){for(let t=Gt.indexOf(e)+1,n=Gt.length;t<n;++t)if(Cd[Gt[t]].common)return Gt[t]}function f_(e,t,n){if(!n)e[t]=!0;else if(n.length){const{lo:r,hi:i}=Um(n,t),s=n[r]>=t?n[r]:n[i];e[s]=!0}}function e6(e,t,n,r){const i=e._adapter,s=+i.startOf(t[0].value,r),o=t[t.length-1].value;let a,l;for(a=s;a<=o;a=+i.add(a,1,r))l=n[a],l>=0&&(t[l].major=!0);return t}function p_(e,t,n){const r=[],i={},s=t.length;let o,a;for(o=0;o<s;++o)a=t[o],i[a]=o,r.push({value:a,major:!1});return s===0||!n?r:e6(e,r,i,n)}class ul extends ss{constructor(t){super(t),this._cache={data:[],labels:[],all:[]},this._unit="day",this._majorUnit=void 0,this._offsets={},this._normalized=!1,this._parseOpts=void 0}init(t,n={}){const r=t.time||(t.time={}),i=this._adapter=new lz._date(t.adapters.date);i.init(n),Sa(r.displayFormats,i.formats()),this._parseOpts={parser:r.parser,round:r.round,isoWeekday:r.isoWeekday},super.init(t),this._normalized=n.normalized}parse(t,n){return t===void 0?null:d_(this,t)}beforeLayout(){super.beforeLayout(),this._cache={data:[],labels:[],all:[]}}determineDataLimits(){const t=this.options,n=this._adapter,r=t.time.unit||"day";let{min:i,max:s,minDefined:o,maxDefined:a}=this.getUserBounds();function l(c){!o&&!isNaN(c.min)&&(i=Math.min(i,c.min)),!a&&!isNaN(c.max)&&(s=Math.max(s,c.max))}(!o||!a)&&(l(this._getLabelBounds()),(t.bounds!=="ticks"||t.ticks.source!=="labels")&&l(this.getMinMax(!1))),i=Qe(i)&&!isNaN(i)?i:+n.startOf(Date.now(),r),s=Qe(s)&&!isNaN(s)?s:+n.endOf(Date.now(),r)+1,this.min=Math.min(i,s-1),this.max=Math.max(i+1,s)}_getLabelBounds(){const t=this.getLabelTimestamps();let n=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY;return t.length&&(n=t[0],r=t[t.length-1]),{min:n,max:r}}buildTicks(){const t=this.options,n=t.time,r=t.ticks,i=r.source==="labels"?this.getLabelTimestamps():this._generate();t.bounds==="ticks"&&i.length&&(this.min=this._userMin||i[0],this.max=this._userMax||i[i.length-1]);const s=this.min,o=this.max,a=R5(i,s,o);return this._unit=n.unit||(r.autoSkip?h_(n.minUnit,this.min,this.max,this._getLabelCapacity(s)):QB(this,a.length,n.minUnit,this.min,this.max)),this._majorUnit=!r.major.enabled||this._unit==="year"?void 0:ZB(this._unit),this.initOffsets(i),t.reverse&&a.reverse(),p_(this,a,this._majorUnit)}afterAutoSkip(){this.options.offsetAfterAutoskip&&this.initOffsets(this.ticks.map(t=>+t.value))}initOffsets(t=[]){let n=0,r=0,i,s;this.options.offset&&t.length&&(i=this.getDecimalForValue(t[0]),t.length===1?n=1-i:n=(this.getDecimalForValue(t[1])-i)/2,s=this.getDecimalForValue(t[t.length-1]),t.length===1?r=s:r=(s-this.getDecimalForValue(t[t.length-2]))/2);const o=t.length<3?.5:.25;n=gt(n,0,o),r=gt(r,0,o),this._offsets={start:n,end:r,factor:1/(n+1+r)}}_generate(){const t=this._adapter,n=this.min,r=this.max,i=this.options,s=i.time,o=s.unit||h_(s.minUnit,n,r,this._getLabelCapacity(n)),a=ce(i.ticks.stepSize,1),l=o==="week"?s.isoWeekday:!1,c=oo(l)||l===!0,u={};let d=n,h,p;if(c&&(d=+t.startOf(d,"isoWeek",l)),d=+t.startOf(d,c?"day":o),t.diff(r,n,o)>1e5*a)throw new Error(n+" and "+r+" are too far apart with stepSize of "+a+" "+o);const g=i.ticks.source==="data"&&this.getDataTimestamps();for(h=d,p=0;h<r;h=+t.add(h,a,o),p++)f_(u,h,g);return(h===r||i.bounds==="ticks"||p===1)&&f_(u,h,g),Object.keys(u).sort(u_).map(m=>+m)}getLabelForValue(t){const n=this._adapter,r=this.options.time;return r.tooltipFormat?n.format(t,r.tooltipFormat):n.format(t,r.displayFormats.datetime)}format(t,n){const i=this.options.time.displayFormats,s=this._unit,o=n||i[s];return this._adapter.format(t,o)}_tickFormatFunction(t,n,r,i){const s=this.options,o=s.ticks.callback;if(o)return Oe(o,[t,n,r],this);const a=s.time.displayFormats,l=this._unit,c=this._majorUnit,u=l&&a[l],d=c&&a[c],h=r[n],p=c&&d&&h&&h.major;return this._adapter.format(t,i||(p?d:u))}generateTickLabels(t){let n,r,i;for(n=0,r=t.length;n<r;++n)i=t[n],i.label=this._tickFormatFunction(i.value,n,t)}getDecimalForValue(t){return t===null?NaN:(t-this.min)/(this.max-this.min)}getPixelForValue(t){const n=this._offsets,r=this.getDecimalForValue(t);return this.getPixelForDecimal((n.start+r)*n.factor)}getValueForPixel(t){const n=this._offsets,r=this.getDecimalForPixel(t)/n.factor-n.end;return this.min+r*(this.max-this.min)}_getLabelSize(t){const n=this.options.ticks,r=this.ctx.measureText(t).width,i=On(this.isHorizontal()?n.maxRotation:n.minRotation),s=Math.cos(i),o=Math.sin(i),a=this._resolveTickFontOptions(0).size;return{w:r*s+a*o,h:r*o+a*s}}_getLabelCapacity(t){const n=this.options.time,r=n.displayFormats,i=r[n.unit]||r.millisecond,s=this._tickFormatFunction(t,0,p_(this,[t],this._majorUnit),i),o=this._getLabelSize(s),a=Math.floor(this.isHorizontal()?this.width/o.w:this.height/o.h)-1;return a>0?a:1}getDataTimestamps(){let t=this._cache.data||[],n,r;if(t.length)return t;const i=this.getMatchingVisibleMetas();if(this._normalized&&i.length)return this._cache.data=i[0].controller.getAllParsedValues(this);for(n=0,r=i.length;n<r;++n)t=t.concat(i[n].controller.getAllParsedValues(this));return this._cache.data=this.normalize(t)}getLabelTimestamps(){const t=this._cache.labels||[];let n,r;if(t.length)return t;const i=this.getLabels();for(n=0,r=i.length;n<r;++n)t.push(d_(this,i[n]));return this._cache.labels=this._normalized?t:this.normalize(t)}normalize(t){return kC(t.sort(u_))}}W(ul,"id","time"),W(ul,"defaults",{bounds:"data",adapters:{},time:{parser:!1,unit:!1,round:!1,isoWeekday:!1,minUnit:"millisecond",displayFormats:{}},ticks:{source:"auto",callback:!1,major:{enabled:!1}}});function uc(e,t,n){let r=0,i=e.length-1,s,o,a,l;n?(t>=e[r].pos&&t<=e[i].pos&&({lo:r,hi:i}=_r(e,"pos",t)),{pos:s,time:a}=e[r],{pos:o,time:l}=e[i]):(t>=e[r].time&&t<=e[i].time&&({lo:r,hi:i}=_r(e,"time",t)),{time:s,pos:a}=e[r],{time:o,pos:l}=e[i]);const c=o-s;return c?a+(l-a)*(t-s)/c:a}class ag extends ul{constructor(t){super(t),this._table=[],this._minPos=void 0,this._tableRange=void 0}initOffsets(){const t=this._getTimestampsForTable(),n=this._table=this.buildLookupTable(t);this._minPos=uc(n,this.min),this._tableRange=uc(n,this.max)-this._minPos,super.initOffsets(t)}buildLookupTable(t){const{min:n,max:r}=this,i=[],s=[];let o,a,l,c,u;for(o=0,a=t.length;o<a;++o)c=t[o],c>=n&&c<=r&&i.push(c);if(i.length<2)return[{time:n,pos:0},{time:r,pos:1}];for(o=0,a=i.length;o<a;++o)u=i[o+1],l=i[o-1],c=i[o],Math.round((u+l)/2)!==c&&s.push({time:c,pos:o/(a-1)});return s}_generate(){const t=this.min,n=this.max;let r=super.getDataTimestamps();return(!r.includes(t)||!r.length)&&r.splice(0,0,t),(!r.includes(n)||r.length===1)&&r.push(n),r.sort((i,s)=>i-s)}_getTimestampsForTable(){let t=this._cache.all||[];if(t.length)return t;const n=this.getDataTimestamps(),r=this.getLabelTimestamps();return n.length&&r.length?t=this.normalize(n.concat(r)):t=n.length?n:r,t=this._cache.all=t,t}getDecimalForValue(t){return(uc(this._table,t)-this._minPos)/this._tableRange}getValueForPixel(t){const n=this._offsets,r=this.getDecimalForPixel(t)/n.factor-n.end;return uc(this._table,r*this._tableRange+this._minPos,!0)}}W(ag,"id","timeseries"),W(ag,"defaults",ul.defaults);var t6=Object.freeze({__proto__:null,CategoryScale:rg,LinearScale:ig,LogarithmicScale:sg,RadialLinearScale:sa,TimeScale:ul,TimeSeriesScale:ag});const n6=[az,L4,RB,t6];Xn.register(...n6);function rn(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function Ft(e,t=1){if(typeof document>"u")return`rgba(0,0,0,${t})`;const n=getComputedStyle(document.documentElement).getPropertyValue(`--${e}`).trim();return n?`rgba(${n.split(/\s+/).join(", ")}, ${t})`:`rgba(0,0,0,${t})`}function r6({data:e}){const t=P.useRef(null),n=P.useRef(null);return P.useEffect(()=>{if(!(!t.current||e.daily.length===0))return n.current&&n.current.destroy(),n.current=new Xn(t.current,{type:"bar",data:{labels:e.daily.map(r=>r.date.slice(5)),datasets:[{label:"Input",data:e.daily.map(r=>r.inputTokens),backgroundColor:Ft("primary",.75),borderRadius:2},{label:"Output",data:e.daily.map(r=>r.outputTokens),backgroundColor:Ft("info",.7),borderRadius:2},{label:"Cache Read",data:e.daily.map(r=>r.cacheReadTokens),backgroundColor:Ft("success",.45),borderRadius:2},{label:"Cache Write",data:e.daily.map(r=>r.cacheCreateTokens),backgroundColor:Ft("tertiary-fixed",.75),borderRadius:2}]},options:{responsive:!0,maintainAspectRatio:!1,plugins:{legend:{position:"bottom",labels:{color:Ft("on-surface-variant"),font:{size:10,family:"monospace"},boxWidth:12}},tooltip:{callbacks:{label:r=>`${r.dataset.label}: ${rn(r.raw)} tokens`}}},scales:{x:{stacked:!0,grid:{color:Ft("outline-variant",.3)},ticks:{color:Ft("on-surface-variant"),font:{size:9,family:"monospace"}}},y:{stacked:!0,grid:{color:Ft("outline-variant",.3)},ticks:{color:Ft("on-surface-variant"),font:{size:9,family:"monospace"},callback:r=>rn(r)}}}}}),()=>{var r;(r=n.current)==null||r.destroy()}},[e]),f.jsx("canvas",{ref:t})}function i6({data:e}){const t=P.useRef(null),n=P.useRef(null);return P.useEffect(()=>{if(!(!t.current||e.daily.length===0))return n.current&&n.current.destroy(),n.current=new Xn(t.current,{type:"bar",data:{labels:e.daily.map(r=>r.date.slice(5)),datasets:[{label:"Est. Cost (USD)",data:e.daily.map(r=>Number(r.estimatedCostUsd.toFixed(2))),backgroundColor:Ft("secondary",.75),borderRadius:2}]},options:{responsive:!0,maintainAspectRatio:!1,plugins:{legend:{labels:{color:Ft("on-surface-variant"),font:{size:10,family:"monospace"},boxWidth:12}},tooltip:{callbacks:{label:r=>`$${r.raw.toFixed(2)}`}}},scales:{x:{grid:{color:Ft("outline-variant",.3)},ticks:{color:Ft("on-surface-variant"),font:{size:9,family:"monospace"}}},y:{grid:{color:Ft("outline-variant",.3)},ticks:{color:Ft("on-surface-variant"),font:{size:9,family:"monospace"},callback:r=>`$${r}`}}}}}),()=>{var r;(r=n.current)==null||r.destroy()}},[e]),f.jsx("canvas",{ref:t})}function s6({agentId:e}){const{t}=Pe(),[n,r]=P.useState(null),[i,s]=P.useState(30),[o,a]=P.useState(!0);if(P.useEffect(()=>{a(!0),iR(e,i).then(r).catch(console.error).finally(()=>a(!1))},[e,i]),o||!n)return f.jsx("div",{className:"text-on-surface-variant/70 text-xs p-6",children:t("usage.loading")});const l=Object.entries(n.byModel).sort((c,u)=>u[1].estimatedCostUsd-c[1].estimatedCostUsd);return f.jsxs("div",{className:"flex flex-col h-full w-full min-w-0 bg-background",children:[f.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-outline-variant/30",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{className:"text-[13px] opacity-60",children:"📊"}),f.jsx("span",{className:"text-[11px] uppercase tracking-[0.14em] font-medium text-on-surface-variant",children:t("usage.title")})]}),f.jsx("div",{className:"flex items-center gap-1",children:[7,14,30].map(c=>f.jsxs("button",{onClick:()=>s(c),className:`px-2 py-0.5 rounded text-[9px] font-mono transition-colors ${i===c?"bg-primary/20 text-primary":"text-on-surface-variant/70 hover:text-on-surface-variant/70"}`,children:[c,"d"]},c))})]}),f.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4 scrollbar-thin",children:[f.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[f.jsxs("div",{className:"rounded-lg bg-surface-container-lowest border border-outline-variant/40 p-4",children:[f.jsx("p",{className:"text-[9px] uppercase text-on-surface-variant/60 mb-1.5",children:t("usage.totalTokens")}),f.jsx("p",{className:"font-mono text-[20px] text-on-surface/80",children:rn(n.totalInputTokens+n.totalOutputTokens)}),f.jsx("p",{className:"font-mono text-[9px] text-on-surface-variant/60 mt-1",children:t("usage.cachedSuffix",{amount:rn(n.totalCacheReadTokens+n.totalCacheCreateTokens)})})]}),f.jsxs("div",{className:"rounded-lg bg-surface-container-lowest border border-outline-variant/40 p-4",children:[f.jsx("p",{className:"text-[9px] uppercase text-on-surface-variant/60 mb-1.5",children:t("usage.sessions")}),f.jsx("p",{className:"font-mono text-[20px] text-on-surface/80",children:n.totalSessions}),f.jsx("p",{className:"font-mono text-[9px] text-on-surface-variant/60 mt-1",children:t("usage.modelsCount",{count:Object.keys(n.byModel).length})})]}),f.jsxs("div",{className:"rounded-lg bg-surface-container-lowest border border-outline-variant/40 p-4",children:[f.jsx("p",{className:"text-[9px] uppercase text-on-surface-variant/60 mb-1.5",children:t("usage.estCost")}),f.jsxs("p",{className:"font-mono text-[20px] text-error/80",children:["$",n.totalEstimatedCostUsd.toFixed(2)]}),f.jsx("p",{className:"font-mono text-[9px] text-on-surface-variant/60 mt-1",children:t("usage.periodDays",{days:i})})]}),f.jsxs("div",{className:"rounded-lg bg-surface-container-lowest border border-outline-variant/40 p-4",children:[f.jsx("p",{className:"text-[9px] uppercase text-on-surface-variant/60 mb-1.5",children:t("usage.avgDay")}),f.jsxs("p",{className:"font-mono text-[20px] text-warning/80",children:["$",n.daily.length>0?(n.totalEstimatedCostUsd/n.daily.length).toFixed(2):"0.00"]}),f.jsx("p",{className:"font-mono text-[9px] text-on-surface-variant/60 mt-1",children:t("usage.sessionsPerDay",{count:n.daily.length>0?Math.round(n.totalSessions/n.daily.length):0})})]})]}),f.jsxs("div",{children:[f.jsx("p",{className:"text-[8px] uppercase tracking-[0.18em] text-on-surface-variant/35 font-semibold mb-2",children:t("usage.dailyTokenUsage")}),f.jsx("div",{className:"rounded-lg bg-surface-container-lowest border border-outline-variant/40 p-4",style:{height:"300px"},children:n.daily.length>0?f.jsx(r6,{data:n}):f.jsx("p",{className:"text-on-surface-variant/25 text-xs text-center pt-20",children:t("usage.noUsageData")})})]}),f.jsxs("div",{children:[f.jsx("p",{className:"text-[8px] uppercase tracking-[0.18em] text-on-surface-variant/35 font-semibold mb-2",children:t("usage.dailyCost")}),f.jsx("div",{className:"rounded-lg bg-surface-container-lowest border border-outline-variant/40 p-4",style:{height:"250px"},children:n.daily.length>0?f.jsx(i6,{data:n}):f.jsx("p",{className:"text-on-surface-variant/25 text-xs text-center pt-16",children:t("usage.noCostData")})})]}),l.length>0&&f.jsxs("div",{children:[f.jsx("p",{className:"text-[8px] uppercase tracking-[0.18em] text-on-surface-variant/35 font-semibold mb-2",children:t("usage.byModel")}),f.jsx("div",{className:"space-y-1",children:l.map(([c,u])=>f.jsxs("div",{className:"rounded bg-surface-container-lowest border border-outline-variant/40 p-2.5 flex items-center gap-3",children:[f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsx("span",{className:"font-mono text-[10px] text-on-surface/70 truncate block",children:c}),f.jsx("span",{className:"font-mono text-[9px] text-on-surface-variant/60",children:t("usage.modelSessionsBlurb",{sessions:u.sessions,input:rn(u.inputTokens),output:rn(u.outputTokens)})})]}),f.jsxs("span",{className:"font-mono text-[10px] text-error/60 flex-shrink-0",children:["$",u.estimatedCostUsd.toFixed(2)]})]},c))})]}),f.jsxs("div",{children:[f.jsx("p",{className:"text-[8px] uppercase tracking-[0.18em] text-on-surface-variant/35 font-semibold mb-2",children:t("usage.tokenBreakdown")}),f.jsxs("div",{className:"rounded bg-surface-container-lowest border border-outline-variant/40 p-3 space-y-1.5",children:[f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"font-mono text-[10px] text-on-surface-variant",children:t("usage.inputTokens")}),f.jsx("span",{className:"font-mono text-[10px] text-primary",children:rn(n.totalInputTokens)})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"font-mono text-[10px] text-on-surface-variant",children:t("usage.outputTokens")}),f.jsx("span",{className:"font-mono text-[10px] text-info",children:rn(n.totalOutputTokens)})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"font-mono text-[10px] text-on-surface-variant",children:t("usage.cacheRead")}),f.jsx("span",{className:"font-mono text-[10px] text-success",children:rn(n.totalCacheReadTokens)})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"font-mono text-[10px] text-on-surface-variant",children:t("usage.cacheWrite")}),f.jsx("span",{className:"font-mono text-[10px] text-warning",children:rn(n.totalCacheCreateTokens)})]})]})]}),Object.keys(n.byTool).length>0&&f.jsxs("div",{children:[f.jsx("p",{className:"text-[8px] uppercase tracking-[0.18em] text-on-surface-variant/35 font-semibold mb-2",children:t("usage.toolInvocations")}),f.jsx("div",{className:"rounded-lg bg-surface-container-lowest border border-outline-variant/40 p-3 space-y-1",children:Object.entries(n.byTool).sort((c,u)=>u[1]-c[1]).map(([c,u])=>{const d=Math.max(...Object.values(n.byTool));return f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{className:"font-mono text-[10px] text-on-surface-variant w-40 truncate flex-shrink-0",title:c,children:c}),f.jsx("div",{className:"flex-1 h-3 rounded-sm bg-background overflow-hidden",children:f.jsx("div",{className:"h-full rounded-sm bg-primary/40",style:{width:`${u/d*100}%`}})}),f.jsx("span",{className:"font-mono text-[9px] text-on-surface-variant/70 w-8 text-right flex-shrink-0",children:u})]},c)})})]}),f.jsxs("div",{children:[f.jsx("p",{className:"text-[8px] uppercase tracking-[0.18em] text-on-surface-variant/35 font-semibold mb-2",children:t("usage.dailyBreakdown")}),f.jsx("div",{className:"rounded-lg bg-surface-container-lowest border border-outline-variant/40 overflow-hidden",children:f.jsxs("table",{className:"w-full",children:[f.jsx("thead",{children:f.jsxs("tr",{className:"border-b border-outline-variant/30",children:[f.jsx("th",{className:"px-3 py-2 text-left text-[9px] font-mono text-on-surface-variant/70 font-medium",children:t("usage.date")}),f.jsx("th",{className:"px-3 py-2 text-right text-[9px] font-mono text-on-surface-variant/70 font-medium",children:t("usage.tableSessions")}),f.jsx("th",{className:"px-3 py-2 text-right text-[9px] font-mono text-on-surface-variant/70 font-medium",children:t("usage.tableInput")}),f.jsx("th",{className:"px-3 py-2 text-right text-[9px] font-mono text-on-surface-variant/70 font-medium",children:t("usage.tableOutput")}),f.jsx("th",{className:"px-3 py-2 text-right text-[9px] font-mono text-on-surface-variant/70 font-medium",children:t("usage.tableCache")}),f.jsx("th",{className:"px-3 py-2 text-right text-[9px] font-mono text-on-surface-variant/70 font-medium",children:t("usage.tableCost")})]})}),f.jsx("tbody",{children:[...n.daily].reverse().map(c=>f.jsxs("tr",{className:"border-b border-white/[0.03] hover:bg-white/[0.02]",children:[f.jsx("td",{className:"px-3 py-1.5 font-mono text-[10px] text-on-surface/70",children:c.date}),f.jsx("td",{className:"px-3 py-1.5 font-mono text-[10px] text-on-surface-variant text-right",children:c.sessions}),f.jsx("td",{className:"px-3 py-1.5 font-mono text-[10px] text-primary text-right",children:rn(c.inputTokens)}),f.jsx("td",{className:"px-3 py-1.5 font-mono text-[10px] text-info text-right",children:rn(c.outputTokens)}),f.jsx("td",{className:"px-3 py-1.5 font-mono text-[10px] text-success text-right",children:rn(c.cacheReadTokens+c.cacheCreateTokens)}),f.jsxs("td",{className:"px-3 py-1.5 font-mono text-[10px] text-error/60 text-right",children:["$",c.estimatedCostUsd.toFixed(2)]})]},c.date))})]})})]})]})]})}function o6(e){const t=e.createdAt??e.created_at;return{_id:e._id??e.id,agentId:e.agentId??e.agent_id??"",type:e.type,input:e.input,output:e.output,durationMs:e.durationMs??e.duration_ms,createdAt:typeof t=="number"?new Date(t).toISOString():t??""}}const a6=[{label:"All",value:"default",color:""},{label:"MSG",value:"message",color:"bg-emerald-500"},{label:"TOOL",value:"tool_call",color:"bg-blue-500"},{label:"ERR",value:"error",color:"bg-red-500"},{label:"SYS",value:"system",color:"bg-gray-500"}];function l6(e){return{message:"text-success",tool_call:"text-info",tool_result:"text-info/60",error:"text-error",system:"text-gray-500"}[e]??"text-gray-500"}function c6(e){return{message:"bg-emerald-500/10",tool_call:"bg-blue-500/10",tool_result:"bg-blue-500/5",error:"bg-red-500/10",system:""}[e]??""}function u6(e){return{message:"bg-emerald-400",tool_call:"bg-blue-400",tool_result:"bg-blue-400/60",error:"bg-red-400",system:"bg-gray-600"}[e]??"bg-gray-600"}function d6(e){const t=new Date(e),n=new Date,r=t.toLocaleTimeString("en-US",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"});return t.toDateString()!==n.toDateString()?`${t.toLocaleDateString("en-US",{month:"short",day:"numeric"})} ${r}`:r}function ja(e){if(typeof e=="string")try{return JSON.parse(e)}catch{return e}return e}function h6(e){const t=ja(e.input),n=ja(e.output);if(e.type==="message"){const r=(t==null?void 0:t.text)??"";return String(r)||"(no text)"}if(e.type==="tool_call"){const r=(t==null?void 0:t.tool)??(t==null?void 0:t.tool_name)??(t==null?void 0:t.name)??"",i=(t==null?void 0:t.description)??"";if(r){({...t});const s=ja(t==null?void 0:t.input),o=s?Object.values(s).map(l=>String(l).slice(0,60)).join(", ").slice(0,80):"",a=o?`${r}(${o})`:String(r);return i?`${a} — ${i}`:a}return JSON.stringify(t??{}).slice(0,200)}if(e.type==="tool_result")return JSON.stringify(n??{}).slice(0,200);if(e.type==="error")return String((n==null?void 0:n.message)??n??"unknown error");if(e.type==="system"){const r=n==null?void 0:n.exitCode;return r!==void 0?`process exited (${r})`:"—"}return JSON.stringify(n??{}).slice(0,200)}function f6(e,t){if(!t)return e;const n=e.toLowerCase().indexOf(t.toLowerCase());return n===-1?e:f.jsxs(f.Fragment,{children:[e.slice(0,n),f.jsx("mark",{className:"bg-yellow-400/30 text-yellow-200 rounded-sm px-0.5",children:e.slice(n,n+t.length)}),e.slice(n+t.length)]})}function p6({agentId:e}){const{t}=Pe(),[n,r]=P.useState("default"),[i,s]=P.useState(""),[o,a]=P.useState(""),[l,c]=P.useState([]),[u,d]=P.useState(0),[h,p]=P.useState(!0),[g,m]=P.useState(new Set),[v,x]=P.useState(100),[y,b]=P.useState(!0),k=P.useRef(null),w=P.useRef(null),_=()=>a(i),N=P.useCallback(()=>{gR({agentId:e,type:n==="default"||n==="all"?void 0:n,search:o||void 0,limit:v}).then(S=>{let M=S.items.map(o6);n==="default"&&(M=M.filter(A=>A.type!=="system")),c(M),d(S.total)}).catch(console.error).finally(()=>p(!1))},[e,n,o,v]);P.useEffect(()=>{p(!0),N()},[N]),P.useEffect(()=>{if(!y)return;const S=setInterval(N,3e3);return()=>clearInterval(S)},[y,N]);const E=S=>{m(M=>{const A=new Set(M);return A.has(S)?A.delete(S):A.add(S),A})},T=l;return f.jsxs("div",{className:"flex flex-col h-full w-full min-w-0 rounded-lg overflow-hidden bg-surface-container-lowest",children:[f.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-3 py-2 border-b border-outline-variant/30 bg-background",children:[f.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-1.5",children:[f.jsxs("div",{className:"flex-1 relative",children:[f.jsx("svg",{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-on-surface-variant/60",viewBox:"0 0 20 20",fill:"currentColor",children:f.jsx("path",{fillRule:"evenodd",d:"M9 3.5a5.5 5.5 0 100 11 5.5 5.5 0 000-11zM2 9a7 7 0 1112.452 4.391l3.328 3.329a.75.75 0 11-1.06 1.06l-3.329-3.328A7 7 0 012 9z",clipRule:"evenodd"})}),f.jsx("input",{className:"w-full bg-surface-container-lowest rounded pl-8 pr-7 py-1.5 text-[11px] text-on-surface font-mono placeholder:text-on-surface-variant/25 outline-none focus:ring-1 focus:ring-primary/30 transition-shadow",placeholder:t("logs.searchPlaceholder"),value:i,onChange:S=>s(S.target.value),onKeyDown:S=>S.key==="Enter"&&_()}),i&&f.jsx("button",{onClick:()=>{s(""),a("")},className:"absolute right-2 top-1/2 -translate-y-1/2 text-on-surface-variant hover:text-on-surface text-xs",children:"x"})]}),f.jsx("button",{onClick:_,disabled:i===o,className:"px-2.5 py-1.5 rounded bg-primary/20 text-[10px] font-mono text-primary transition-colors hover:bg-primary/30 disabled:opacity-30 disabled:cursor-default flex-shrink-0",children:t("logs.apply")})]}),f.jsx("div",{className:"flex items-center gap-0.5",children:a6.map(({label:S,value:M,color:A})=>f.jsxs("button",{onClick:()=>r(M),className:`flex items-center gap-1 px-2 py-1 rounded text-[9px] font-mono transition-colors ${n===M?"bg-surface-container-high text-on-surface":"text-on-surface-variant hover:text-on-surface hover:bg-surface-container/50"}`,children:[A&&f.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${A}`}),S]},M))}),f.jsxs("button",{onClick:()=>b(S=>!S),className:`flex items-center gap-1.5 px-2 py-1 rounded text-[9px] font-mono transition-colors ${y?"bg-success/15 text-success":"text-on-surface-variant hover:text-on-surface"}`,children:[f.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${y?"bg-success animate-pulse":"bg-outline/60"}`}),t("logs.live")]}),f.jsxs("span",{className:"font-mono text-[9px] text-on-surface-variant tabular-nums",children:[l.length,"/",u]})]}),f.jsx("div",{ref:w,className:"flex-1 overflow-y-auto scrollbar-thin font-mono text-[11px]",children:h&&l.length===0?f.jsx("div",{className:"flex items-center justify-center h-full",children:f.jsx("span",{className:"text-on-surface-variant text-[10px]",children:t("logs.loading")})}):T.length===0?f.jsx("div",{className:"flex items-center justify-center h-full",children:f.jsx("span",{className:"text-on-surface-variant text-[10px]",children:i?t("logs.noResults",{query:i}):t("logs.noEntries")})}):f.jsxs("div",{className:"py-1",children:[T.map(S=>{const M=g.has(S._id),A=h6(S);return f.jsxs("div",{onClick:()=>E(S._id),className:`group px-3 py-[5px] cursor-pointer transition-colors hover:bg-surface-container/40 ${c6(S.type)} ${M?"bg-surface-container/30":""}`,children:[f.jsxs("div",{className:"flex items-start gap-2 leading-relaxed",children:[f.jsx("span",{className:`mt-[6px] w-[5px] h-[5px] rounded-full flex-shrink-0 ${u6(S.type)}`}),f.jsx("span",{className:"text-on-surface-variant flex-shrink-0 w-[70px] tabular-nums",children:d6(S.createdAt)}),f.jsx("span",{className:`flex-shrink-0 w-[52px] uppercase text-[9px] ${l6(S.type)}`,children:S.type==="tool_call"?"tool":S.type==="tool_result"?"result":S.type}),f.jsx("span",{className:`flex-1 min-w-0 ${M?"":"truncate"} ${S.type==="error"?"text-error":"text-on-surface"}`,children:f6(A,o)}),S.durationMs!=null&&f.jsx("span",{className:"flex-shrink-0 text-[9px] text-on-surface-variant tabular-nums",children:S.durationMs>1e3?`${(S.durationMs/1e3).toFixed(1)}s`:`${S.durationMs}ms`}),f.jsx("span",{className:"flex-shrink-0 text-[8px] text-on-surface-variant opacity-0 group-hover:opacity-100 transition-opacity",children:M?"−":"+"})]}),M&&f.jsxs("div",{className:"ml-[79px] mt-1.5 mb-1 space-y-1.5",children:[!!S.input&&S.input!=="null"&&f.jsxs("div",{children:[f.jsx("span",{className:"font-label text-[8px] uppercase tracking-wider text-on-surface-variant",children:"input"}),f.jsx("pre",{className:"text-[10px] text-on-surface mt-0.5 bg-surface-container-high rounded px-2.5 py-1.5 overflow-auto max-h-48 whitespace-pre-wrap break-words",children:JSON.stringify(ja(S.input),null,2)})]}),!!S.output&&S.output!=="null"&&f.jsxs("div",{children:[f.jsx("span",{className:"font-label text-[8px] uppercase tracking-wider text-on-surface-variant",children:"output"}),f.jsx("pre",{className:"text-[10px] text-on-surface mt-0.5 bg-surface-container-high rounded px-2.5 py-1.5 overflow-auto max-h-48 whitespace-pre-wrap break-words",children:JSON.stringify(ja(S.output),null,2)})]})]})]},S._id)}),l.length<u&&f.jsx("div",{className:"px-3 py-2 text-center",children:f.jsx("button",{onClick:()=>x(S=>S+100),className:"text-[9px] text-primary/40 hover:text-primary/70 transition-colors",children:t("logs.loadOlder",{count:Math.min(100,u-l.length)})})}),f.jsx("div",{ref:k})]})})]})}const g6=[{id:"telegram",name:"Telegram",descriptionKey:"integrations.telegramDescription",icon:"✈️",secretKey:"TELEGRAM_BOT_TOKEN",tokenLabelKey:"integrations.telegramTokenLabel",tokenPlaceholder:"110201543:AAHdqTcvCH1vGWJxfSeofSAs0K5PALDsaw",helpTextKey:"integrations.telegramHelp"}],g_="w-full rounded bg-surface-container px-3 py-2 text-[11px] text-on-surface placeholder:text-on-surface-variant/40 outline-none focus:ring-1 focus:ring-primary/25 font-mono transition-shadow";function m6({def:e,agentId:t,enabled:n,onEnable:r,onDisable:i}){const{t:s}=Pe(),[o,a]=P.useState(!1),[l,c]=P.useState(""),[u,d]=P.useState(!1),[h,p]=P.useState(null);async function g(){if(!l.trim()){p(s("common.tokenRequired"));return}d(!0),p(null);try{await Tp(t,e.secretKey,l.trim()),r(e.secretKey),a(!1),c("")}catch{p(s("integrations.errorSave"))}finally{d(!1)}}async function m(){confirm(s("integrations.disconnectConfirm",{name:e.name}))&&(await Jk(t,e.secretKey),i(e.secretKey))}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 items-start justify-between gap-3",children:[f.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[f.jsx("span",{className:"text-[20px] flex-shrink-0",children:e.icon}),f.jsxs("div",{className:"min-w-0",children:[f.jsx("p",{className:"text-[13px] font-semibold text-on-surface",children:e.name}),f.jsx("p",{className:"font-mono text-[10px] text-on-surface-variant/70 mt-0.5 leading-relaxed",children:s(e.descriptionKey)})]})]}),f.jsx("div",{className:"flex-shrink-0 flex items-center gap-2",children:n?f.jsxs(f.Fragment,{children:[f.jsxs("span",{className:"font-mono text-[9px] text-secondary/80 flex items-center gap-1",children:[f.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-secondary/70"}),s("integrations.connected")]}),f.jsx("button",{onClick:m,className:"rounded px-2 py-1 text-[10px] font-mono text-error/50 hover:text-error hover:bg-error/10 transition-colors",children:s("integrations.disconnect")})]}):f.jsx("button",{onClick:()=>{a(!0),p(null)},className:"rounded bg-primary/10 border border-primary/20 px-3 py-1 text-[11px] font-medium text-primary hover:bg-primary/20 transition-colors",children:s("integrations.connect")})})]}),!n&&o&&f.jsxs("div",{className:"pt-2 border-t border-outline-variant/30 space-y-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:s(e.tokenLabelKey)}),f.jsx("input",{type:"password",className:g_,placeholder:e.tokenPlaceholder,value:l,onChange:v=>{c(v.target.value),p(null)},autoComplete:"off",autoFocus:!0}),f.jsx("p",{className:"font-mono text-[9px] text-on-surface-variant/50 mt-1.5 leading-relaxed",children:s(e.helpTextKey)})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("button",{onClick:g,disabled:u||!l.trim(),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:s(u?"integrations.saving":"integrations.saveAndConnect")}),f.jsx("button",{onClick:()=>{a(!1),c(""),p(null)},className:"rounded px-3 py-1.5 text-[12px] font-mono text-on-surface-variant hover:text-on-surface transition-colors",children:s("integrations.cancel")}),h&&f.jsx("span",{className:"font-mono text-[10px] text-error",children:h})]})]}),n&&o&&f.jsxs("div",{className:"pt-2 border-t border-outline-variant/30 space-y-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:s("integrations.newPrefix",{label:s(e.tokenLabelKey)})}),f.jsx("input",{type:"password",className:g_,placeholder:s("integrations.pasteNewToken"),value:l,onChange:v=>{c(v.target.value),p(null)},autoComplete:"off",autoFocus:!0})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("button",{onClick:g,disabled:u||!l.trim(),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:s(u?"integrations.saving":"integrations.updateToken")}),f.jsx("button",{onClick:()=>{a(!1),c(""),p(null)},className:"rounded px-3 py-1.5 text-[12px] font-mono text-on-surface-variant hover:text-on-surface transition-colors",children:s("integrations.cancel")}),h&&f.jsx("span",{className:"font-mono text-[10px] text-error",children:h})]})]}),n&&!o&&f.jsx("button",{onClick:()=>{a(!0),p(null)},className:"font-mono text-[10px] text-on-surface-variant/50 hover:text-on-surface-variant transition-colors",children:s("integrations.rotateToken")})]})}function x6({agentId:e,secretNames:t,setSecretNames:n}){const{t:r}=Pe();return f.jsxs("div",{className:"flex flex-col gap-4 max-w-xl",children:[f.jsxs("div",{children:[f.jsx("h2",{className:"font-headline text-[22px] font-bold text-on-surface",children:r("integrations.title")}),f.jsx("p",{className:"font-mono text-[11px] text-on-surface-variant/70 mt-1",children:r("integrations.blurb")})]}),f.jsx("div",{className:"space-y-3",children:g6.map(i=>f.jsx(m6,{def:i,agentId:e,enabled:t.includes(i.secretKey),onEnable:s=>n(o=>o.includes(s)?o:[...o,s]),onDisable:s=>n(o=>o.filter(a=>a!==s))},i.id))}),f.jsx("p",{className:"font-mono text-[10px] text-on-surface-variant/40 mt-2",children:r("integrations.moreSoon")})]})}function v6({agentId:e}){const{t}=Pe(),[n,r]=P.useState(null),[i,s]=P.useState(null),[o,a]=P.useState(null),[l,c]=P.useState(null);return P.useEffect(()=>{let u=!1;return GM(e).then(d=>{u||r(d)}).catch(()=>{u||r([])}),()=>{u=!0}},[e]),P.useEffect(()=>{if(!i){a(null),c(null);return}let u=!1;return a(null),c(null),KM(e,i).then(d=>{u||a(d)}).catch(d=>{u||c(d instanceof Error?d.message:String(d))}),()=>{u=!0}},[e,i]),f.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[f.jsxs("div",{className:"w-72 border-r border-outline/20 overflow-y-auto bg-surface-container-lowest",children:[f.jsxs("div",{className:"p-4 border-b border-outline/20",children:[f.jsx("h2",{className:"text-[13px] font-semibold text-on-surface",children:t("skillsView.title")}),f.jsx("p",{className:"text-[10px] text-on-surface-variant mt-1 leading-relaxed",children:t("skillsView.subtitle")})]}),n===null?f.jsx("div",{className:"p-4 text-[11px] text-on-surface-variant font-mono",children:t("skillsView.loading")}):n.length===0?f.jsx("div",{className:"p-4 text-[11px] text-on-surface-variant leading-relaxed",children:t("skillsView.empty")}):f.jsx("ul",{className:"divide-y divide-outline/10",children:n.map(u=>{const d=u.path.lastIndexOf("/"),h=d>=0?u.path.slice(0,d+1):"",p=d>=0?u.path.slice(d+1):u.name;return f.jsx("li",{children:f.jsxs("button",{type:"button",onClick:()=>s(u.path),className:`w-full text-left px-4 py-3 hover:bg-surface-container transition-colors ${i===u.path?"bg-surface-container":""}`,children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs("span",{className:"text-[12px] font-mono truncate",children:[h&&f.jsx("span",{className:"text-on-surface-variant/60",children:h}),f.jsx("span",{className:"text-on-surface",children:p})]}),u.userInvocable&&f.jsx("span",{className:"text-[8px] uppercase tracking-wider px-1.5 py-0.5 rounded bg-primary/15 text-primary font-medium",children:t("skillsView.userInvocable")})]}),f.jsx("div",{className:"text-[10px] text-on-surface-variant mt-1 line-clamp-2 leading-snug",children:u.description})]})},u.path)})})]}),f.jsx("div",{className:"flex-1 overflow-y-auto p-6",children:i?l?f.jsx("div",{className:"text-[11px] text-error font-mono",children:t("skillsView.loadError",{error:l})}):o?f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"mb-4",children:[f.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[f.jsxs("h2",{className:"text-[16px] font-semibold font-mono",children:[o.path.includes("/")&&f.jsx("span",{className:"text-on-surface-variant/60",children:o.path.slice(0,o.path.lastIndexOf("/")+1)}),f.jsx("span",{className:"text-on-surface",children:o.name})]}),o.userInvocable&&f.jsx("span",{className:"text-[9px] uppercase tracking-wider px-1.5 py-0.5 rounded bg-primary/15 text-primary font-medium",children:t("skillsView.userInvocable")})]}),f.jsx("p",{className:"text-[12px] text-on-surface-variant",children:o.description}),o.allowedTools&&f.jsxs("p",{className:"text-[10px] text-on-surface-variant mt-2 font-mono",children:[f.jsxs("span",{className:"opacity-60",children:[t("skillsView.allowedTools"),":"]})," ",o.allowedTools]})]}),f.jsx("div",{className:"text-[12px] text-on-surface/85 leading-relaxed prose prose-sm dark:prose-invert max-w-none",children:f.jsx(vd,{remarkPlugins:[uC],children:y6(o.content)})})]}):f.jsx("div",{className:"text-[11px] text-on-surface-variant font-mono",children:t("skillsView.loading")}):f.jsx("div",{className:"text-[11px] text-on-surface-variant font-mono",children:t("skillsView.selectSkill")})})]})}function y6(e){if(!e.startsWith("---"))return e;const t=e.indexOf(`
|
|
140
140
|
---`,3);return t===-1?e:e.slice(t+4).replace(/^\n+/,"")}function b6({active:e,completed:t}){const{t:n}=Pe();if(!e&&!t)return null;const r=e?n("chat.compactingContext"):t&&t>1?`${t}× ${n("chat.compactedContext")}`:n("chat.compactedContext");return f.jsxs("div",{"data-testid":e?"compaction-active":"compaction-done",className:"flex items-center gap-2 px-2 py-1 rounded w-full max-w-xl text-left",children:[e?f.jsx("span",{className:"h-3 w-3 rounded-full border-2 border-primary/40 border-t-primary animate-spin flex-shrink-0"}):f.jsx("span",{className:"text-[10px] text-primary/60 flex-shrink-0",children:"🗜"}),f.jsx("span",{className:"font-mono text-[10px] text-on-surface-variant flex-1 truncate",children:r})]})}function _6(e){const t=e.toLowerCase();return t.includes("key limit")||t.includes("credit")||t.includes("insufficient_quota")||t.includes("quota exceeded")||t.includes("billing")?"creditLimit":t.includes("rate limit")||t.includes("rate_limit")||t.includes("too many requests")||t.includes("429")?"rateLimit":t.includes("401")||t.includes("invalid api key")||t.includes("invalid_api_key")||t.includes("authentication")?"auth":t.includes("no provider configured")?"noProvider":t.includes("api key missing")?"noKey":t.includes("timeout")||t.includes("timed out")?"timeout":"generic"}const w6=["chat","files","tasks","skills","browser","workflows","schedules","monitor","usage","logs","integrations"];function k6(){return f.jsx("span",{className:"inline-flex items-end gap-[3px] h-4",children:[0,1,2].map(e=>f.jsx("span",{className:"block w-1.5 h-1.5 rounded-full bg-current",style:{animation:`heartbeat-dot 1.2s ease-in-out ${e*.2}s infinite`}},e))})}function tf({className:e=""}){return f.jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",children:f.jsx("path",{d:"M12 2L3 7v5c0 5.25 3.75 10.15 9 11.25C17.25 22.15 21 17.25 21 12V7L12 2z"})})}function S6({toolCalls:e,isStreaming:t}){const{t:n}=Pe(),[r,i]=P.useState(!1),s=e.length,o=l=>{const c=l.match(/^([^(]+)/);return c?c[1]:l},a=o(e[s-1]??"");return f.jsxs("div",{className:"w-full max-w-xl",children:[f.jsxs("button",{onClick:()=>i(l=>!l),className:"flex items-center gap-2 px-2 py-1 rounded hover:bg-surface-container-lowest/50 transition-colors w-full text-left",children:[t?f.jsx("span",{className:"h-3 w-3 rounded-full border-2 border-primary/40 border-t-primary animate-spin flex-shrink-0"}):f.jsx("span",{className:"text-[10px] text-primary/60 flex-shrink-0",children:"⚙"}),f.jsx("span",{className:"font-mono text-[10px] text-on-surface-variant flex-1 truncate",children:t?n("chat.executing",{tool:a}):n(s===1?"chat.toolCallsOne":"chat.toolCallsOther",{count:s})}),f.jsx("svg",{className:"w-2.5 h-2.5 text-on-surface-variant/30 transition-transform duration-150 flex-shrink-0",style:{transform:r?"rotate(90deg)":"none"},viewBox:"0 0 16 16",fill:"currentColor",children:f.jsx("path",{d:"M6 3l5 5-5 5V3z"})})]}),r&&f.jsx("div",{className:"mt-1 rounded bg-surface-container-lowest/50 overflow-y-auto scrollbar-thin",style:{maxHeight:"10rem"},children:e.map((l,c)=>f.jsxs("div",{className:"font-mono text-[9px] text-on-surface-variant/40 px-2.5 py-1 border-b border-white/[0.03] last:border-0 truncate hover:text-on-surface-variant/60 transition-colors",title:l,children:[f.jsx("span",{className:"text-primary/50",children:o(l)}),f.jsx("span",{className:"text-on-surface-variant/20 ml-1",children:l.slice(o(l).length)})]},c))})]})}function C6(){var xt;const{t:e}=Pe(),{id:t=""}=Jf(),n=P.useSyncExternalStore(hC,dC),r=Jf()["*"]??"",i=r==="chat"?"chat":r.startsWith("view/")?r.slice(5):void 0,s=rs(),o=[...w6,...n.map(U=>U.id)],a=i&&o.includes(i)?i:"chat",l=U=>{jp("chat_view_changed",{agentId:t,view:U}),U==="chat"?s(`/agents/${t}/chat`,{replace:!0}):s(`/agents/${t}/view/${U}`,{replace:!0})},[c,u]=P.useState(null),[d,h]=P.useState(null),[p,g]=P.useState([]),[m,v]=P.useState(""),[x,y]=P.useState(!1),[b,k]=P.useState(!1),[w,_]=P.useState(null),[N,E]=P.useState([]),T=P.useRef(null),[S]=P.useState(!0),[M,A]=P.useState([]),[,F]=P.useState(null),[,H]=P.useState(!1),O=P.useRef(null),q=P.useCallback(()=>{g(U=>U.map(de=>de.isStreaming?{...de,isStreaming:!1,text:de.text||"(connection lost)"}:de)),y(!1),_(null)},[]),X=P.useCallback(()=>{t&&Ly(t,"ui").then(U=>{const de=[];let we=[];for(const be of U)if(be.role==="tool_call")we.push(be.content);else if(be.role==="assistant"){if(!be.content&&we.length===0)continue;de.push({id:be.id,role:"agent",text:be.content,toolCalls:we.length>0?we:void 0}),we=[]}else we.length>0&&(de.push({id:crypto.randomUUID(),role:"agent",text:"",toolCalls:we}),we=[]),de.push({id:be.id,role:"user",text:be.content});we.length>0&&de.push({id:crypto.randomUUID(),role:"agent",text:"",toolCalls:we}),g(de)}).catch(console.error)},[t]),I=P.useRef(!1);I.current=x;const z=P.useCallback(U=>{I.current||(U.type==="done"||U.type==="error"||U.type==="blocked")&&X()},[X]),{sendMessage:C,stopMessage:Q,connected:te}=B0(c==null?void 0:c.id,z,q);function j(){Q(),g(U=>U.map(de=>de.isStreaming?{...de,isStreaming:!1,text:de.text+`
|
|
141
141
|
|
|
142
142
|
*(stopped)*`}:de)),y(!1)}const re=P.useRef(!1),le=P.useRef(null),oe=P.useCallback(U=>{if(!re.current){if(U.type==="text")if(le.current){const de=le.current;A(we=>we.map(be=>be.id===de?{...be,text:be.text+U.text}:be))}else{const de=crypto.randomUUID();le.current=de,A(we=>[...we,{id:de,role:"agent",text:U.text,isStreaming:!0}])}else if(U.type==="done"&&le.current){const de=le.current;A(we=>we.map(be=>be.id===de?{...be,isStreaming:!1}:be)),le.current=null}}},[]);B0(void 0,oe),P.useEffect(()=>{if(!t)return;const U=setInterval(()=>{Oy(t).then(u).catch(console.error)},3e4);return()=>clearInterval(U)},[t]),P.useEffect(()=>{t&&(Oy(t).then(u).catch(console.error),qM(t).then(U=>E(U.names)).catch(console.error),X(),Ly(t,"bb").then(U=>A(U.map(de=>({id:de.id,role:de.role==="user"?"user":"agent",text:de.content})))).catch(console.error))},[t,X]),P.useEffect(()=>{var U;(U=T.current)==null||U.scrollIntoView({behavior:"smooth"})},[p,a]),P.useEffect(()=>{var U;(U=O.current)==null||U.scrollIntoView({behavior:"smooth"})},[M]);function R(){const U=m.trim();if(!U||x)return;jp("chat_message_sent",{agentId:t});const de={id:crypto.randomUUID(),role:"user",text:U},we=crypto.randomUUID(),be={id:we,role:"agent",text:"",isStreaming:!0,toolCalls:[]};g(Me=>[...Me,de,be]),v(""),y(!0);let Vn="",Rr=null;C(U,Me=>{if(Me.type==="text"){const ke=Rr==="tool_call"&&Vn.length>0?`
|
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-BENzgeTj.js"></script>
|
|
31
31
|
<link rel="stylesheet" crossorigin href="/assets/index-DI4uAKWn.css">
|
|
32
32
|
</head>
|
|
33
33
|
<body class="bg-background text-on-surface">
|